emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Errors get suppressed by org-babel-execute-src-block
@ 2016-02-08 19:02 Gary Oberbrunner
  2016-02-10 20:23 ` Aaron Ecay
  0 siblings, 1 reply; 11+ messages in thread
From: Gary Oberbrunner @ 2016-02-08 19:02 UTC (permalink / raw)
  To: Orgmode Mailing List

[-- Attachment #1: Type: text/plain, Size: 632 bytes --]

org-babel-execute-src-block has a big unwind-protect that basically eats
all errors inside it. I don't think it used to do that. It makes it hard to
debug my sql code since I can't figure out where the actual problem is.

In my case, I'm probably returning no result from some query, and ob-sql is
mis-parsing that; but due to the unwind-protect it doesn't give me a stack
dump or anything useful, just a "Beginning of buffer" message in
*Messages*. And it makes setting debug-on-error not work too.

I'm considering replacing/augmenting that stanza with a condition-case.
What do folks here think? Is there a better way?

-- 
Gary

[-- Attachment #2: Type: text/html, Size: 803 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Errors get suppressed by org-babel-execute-src-block
  2016-02-08 19:02 Errors get suppressed by org-babel-execute-src-block Gary Oberbrunner
@ 2016-02-10 20:23 ` Aaron Ecay
  2016-02-10 22:57   ` Nicolas Goaziou
  2016-02-11 17:08   ` Nick Dokos
  0 siblings, 2 replies; 11+ messages in thread
From: Aaron Ecay @ 2016-02-10 20:23 UTC (permalink / raw)
  To: Gary Oberbrunner, Orgmode Mailing List

[-- Attachment #1: Type: text/plain, Size: 1008 bytes --]

Hi Gary,

2016ko otsailak 8an, Gary Oberbrunner-ek idatzi zuen:
> 
> org-babel-execute-src-block has a big unwind-protect that basically eats
> all errors inside it. I don't think it used to do that. 

The unwind-protect exists since 2010, so you’re probably mistaken about
that (depending on your frame of reference for “used to”...)

That said, the code in question seems very questionable to me.  First
of all, the unwind-protect should not be needed at all, due to the use
of (f)let (IOW, if the unwind-protect was ever needed, it was to paper
over a bug in emacs which should no longer exist).  Secondly, in 2012
commit 57104f9f changed an “org-flet” to a “let” in this function,
which is incorrect (since elisp is a lisp-2).  So the whole thing has
been effectively a no-op since then.

I’d like to install the attached patch to master, if there are no
objections.  That should resolve your concern as well as cleaning up the
dead code.

Aaron

-- 
Aaron Ecay

[-- Attachment #2: 0001-ob-core-remove-cruft.patch --]
[-- Type: text/x-diff, Size: 7551 bytes --]

From bdb68585d5b0ddf5a6c9876028b5f2be2f17e66a Mon Sep 17 00:00:00 2001
From: Aaron Ecay <aaronecay@gmail.com>
Date: Wed, 10 Feb 2016 19:39:04 +0000
Subject: [PATCH] ob-core: remove cruft
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* lisp/ob-core.el (org-babel-execute-src-block): Simplify.
(org-babel-tramp-handle-call-process-region): Remove.

Commit 57104f9f changed an org-flet to a let, rendering the whole
apparatus of modifying call-process-region inoperative.  Supposedly this
was put in place to work around a bug in
tramp-handle-call-process-region, which was removed from tramp in
2012 (after being renamed tramp-sh-call-process-region).  *shrug*

This commit just removes the whole thing.  It also no longer consults
‘org-src-lang-modes’, which is not helpful here.
---
 lisp/ob-core.el | 133 ++++++++++++++++++++------------------------------------
 1 file changed, 47 insertions(+), 86 deletions(-)

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 025985d..77f464f 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -26,6 +26,7 @@
 (eval-when-compile
   (require 'cl))
 (require 'cl-lib)
+(require 'subr-x)			; For `if-let'
 (require 'ob-eval)
 (require 'org-macs)
 (require 'org-compat)
@@ -36,10 +37,8 @@
     nil))
 
 ;; dynamically scoped for tramp
-(defvar org-babel-call-process-region-original nil)
 (defvar org-babel-library-of-babel)
 (defvar org-edit-src-content-indentation)
-(defvar org-src-lang-modes)
 
 (declare-function outline-show-all "outline" ())
 (declare-function org-get-indentation "org" (&optional line))
@@ -679,72 +678,53 @@ block."
 		 (default-directory
 		   (or (and dir (file-name-as-directory (expand-file-name dir)))
 		       default-directory))
-		 (org-babel-call-process-region-original ;; for tramp handler
-		  (or (org-bound-and-true-p
-		       org-babel-call-process-region-original)
-		      (symbol-function 'call-process-region)))
 		 (indent (nth 5 info))
-		 result cmd)
-	    (unwind-protect
-		(let ((call-process-region
-		       (lambda (&rest args)
-			 (apply 'org-babel-tramp-handle-call-process-region
-				args))))
-		  (let ((lang-check
-			 (lambda (f)
-			   (let ((f (intern (concat "org-babel-execute:" f))))
-			     (when (fboundp f) f)))))
-		    (setq cmd
-			  (or (funcall lang-check lang)
-			      (funcall lang-check
-				       (symbol-name
-					(cdr (assoc lang org-src-lang-modes))))
-			      (error "No org-babel-execute function for %s!"
-				     lang))))
-		  (message "executing %s code block%s..."
-			   (capitalize lang)
-			   (if (nth 4 info) (format " (%s)" (nth 4 info)) ""))
-		  (if (member "none" result-params)
-		      (progn
-			(funcall cmd body params)
-			(message "result silenced")
-			(setq result nil))
-		    (setq result
-			  (let ((result (funcall cmd body params)))
-                            (if (and (eq (cdr (assoc :result-type params))
-                                         'value)
-                                     (or (member "vector" result-params)
-                                         (member "table" result-params))
-                                     (not (listp result)))
-                                (list (list result)) result)))
-		    ;; If non-empty result and :file then write to :file.
-		    (when (cdr (assoc :file params))
-		      (when result
-			(with-temp-file (cdr (assoc :file params))
-			  (insert
-			   (org-babel-format-result
-			    result (cdr (assoc :sep (nth 2 info)))))))
-		      (setq result (cdr (assoc :file params))))
-		    ;; Possibly perform post process provided its appropriate.
-		    (when (cdr (assoc :post params))
-		      (let ((*this* (if (cdr (assoc :file params))
-					(org-babel-result-to-file
-					 (cdr (assoc :file params))
-					 (when (assoc :file-desc params)
-					   (or (cdr (assoc :file-desc params))
-					       result)))
-				      result)))
-			(setq result (org-babel-ref-resolve
-				      (cdr (assoc :post params))))
-			(when (cdr (assoc :file params))
-			  (setq result-params
-				(remove "file" result-params)))))
-		    (org-babel-insert-result
-		     result result-params info new-hash indent lang))
-                  (run-hooks 'org-babel-after-execute-hook)
-		  result)
-	      (setq call-process-region
-		    'org-babel-call-process-region-original)))))))))
+		 (cmd (intern (concat "org-babel-execute:" lang)))
+		 result)
+	    (unless (fboundp cmd)
+	      (error "No org-babel-execute function for %s!" lang))
+	    (message "executing %s code block%s..."
+		     (capitalize lang)
+		     (if (nth 4 info) (format " (%s)" (nth 4 info)) ""))
+	    (if (member "none" result-params)
+		(progn
+		  (funcall cmd body params)
+		  (message "result silenced")
+		  (setq result nil))
+	      (setq result
+		    (let ((result (funcall cmd body params)))
+		      (if (and (eq (cdr (assoc :result-type params))
+				   'value)
+			       (or (member "vector" result-params)
+				   (member "table" result-params))
+			       (not (listp result)))
+			  (list (list result)) result)))
+	      ;; If non-empty result and :file then write to :file.
+	      (when (cdr (assoc :file params))
+		(when result
+		  (with-temp-file (cdr (assoc :file params))
+		    (insert
+		     (org-babel-format-result
+		      result (cdr (assoc :sep (nth 2 info)))))))
+		(setq result (cdr (assoc :file params))))
+	      ;; Possibly perform post process provided its appropriate.
+	      (when (cdr (assoc :post params))
+		(let ((*this* (if (cdr (assoc :file params))
+				  (org-babel-result-to-file
+				   (cdr (assoc :file params))
+				   (when (assoc :file-desc params)
+				     (or (cdr (assoc :file-desc params))
+					 result)))
+				result)))
+		  (setq result (org-babel-ref-resolve
+				(cdr (assoc :post params))))
+		  (when (cdr (assoc :file params))
+		    (setq result-params
+			  (remove "file" result-params)))))
+	      (org-babel-insert-result
+	       result result-params info new-hash indent lang))
+	    (run-hooks 'org-babel-after-execute-hook)
+	    result)))))))
 
 (defun org-babel-expand-body:generic (body params &optional var-lines)
   "Expand BODY with PARAMS.
@@ -2993,25 +2973,6 @@ character of the string."
    (org-reverse-string
     (org-babel-chomp (org-reverse-string string) regexp)) regexp))
 
-(defun org-babel-tramp-handle-call-process-region
-  (start end program &optional delete buffer display &rest args)
-  "Use Tramp to handle `call-process-region'.
-Fixes a bug in `tramp-handle-call-process-region'."
-  (if (and (featurep 'tramp) (file-remote-p default-directory))
-      (let ((tmpfile (tramp-compat-make-temp-file "")))
-	(write-region start end tmpfile)
-	(when delete (delete-region start end))
-	(unwind-protect
-	    ;;	(apply 'call-process program tmpfile buffer display args)
-            ;; bug in tramp
-	    (apply 'process-file program tmpfile buffer display args)
-	  (delete-file tmpfile)))
-    ;; org-babel-call-process-region-original is the original emacs
-    ;; definition.  It is in scope from the let binding in
-    ;; org-babel-execute-src-block
-    (apply org-babel-call-process-region-original
-           start end program delete buffer display args)))
-
 (defun org-babel-local-file-name (file)
   "Return the local name component of FILE."
   (or (file-remote-p file 'localname) file))
-- 
2.7.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: Errors get suppressed by org-babel-execute-src-block
  2016-02-10 20:23 ` Aaron Ecay
@ 2016-02-10 22:57   ` Nicolas Goaziou
  2016-02-12 17:22     ` Aaron Ecay
  2016-02-11 17:08   ` Nick Dokos
  1 sibling, 1 reply; 11+ messages in thread
From: Nicolas Goaziou @ 2016-02-10 22:57 UTC (permalink / raw)
  To: Gary Oberbrunner; +Cc: Orgmode Mailing List

Hello,

Aaron Ecay <aaronecay@gmail.com> writes:

> I’d like to install the attached patch to master, if there are no
> objections.  That should resolve your concern as well as cleaning up the
> dead code.

No objection, but...

> +(require 'subr-x)			; For `if-let'

... you are not using `if-let' anywhere if this patch. Besides, we still
cannot use subr-x, since it is a 24.4 library, and, AFAIR, we didn't
drop support for 24.3 yet.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Errors get suppressed by org-babel-execute-src-block
  2016-02-10 20:23 ` Aaron Ecay
  2016-02-10 22:57   ` Nicolas Goaziou
@ 2016-02-11 17:08   ` Nick Dokos
  2016-02-12 17:31     ` Aaron Ecay
  1 sibling, 1 reply; 11+ messages in thread
From: Nick Dokos @ 2016-02-11 17:08 UTC (permalink / raw)
  To: emacs-orgmode

Aaron Ecay <aaronecay@gmail.com> writes:

> Hi Gary,
>
> 2016ko otsailak 8an, Gary Oberbrunner-ek idatzi zuen:
>> 
>> org-babel-execute-src-block has a big unwind-protect that basically eats
>> all errors inside it. I don't think it used to do that. 
>
> The unwind-protect exists since 2010, so you’re probably mistaken about
> that (depending on your frame of reference for “used to”...)
>
> That said, the code in question seems very questionable to me.  First
> of all, the unwind-protect should not be needed at all, due to the use
> of (f)let (IOW, if the unwind-protect was ever needed, it was to paper
> over a bug in emacs which should no longer exist).  Secondly, in 2012
> commit 57104f9f changed an “org-flet” to a “let” in this function,
> which is incorrect (since elisp is a lisp-2).  So the whole thing has
> been effectively a no-op since then.
>
> I’d like to install the attached patch to master, if there are no
> objections.  That should resolve your concern as well as cleaning up the
> dead code.
>

Not sure if there are tests for remote babel execution, but if not,
please make sure to test that (with :dir set to some directory on a
different machine). Michael Albinus had done some work to get that
working a few years ago: he did not want to learn the ins and outs of
org-mode, so he did the minimal amount possible to square babel with
tramp: he did not touch the cruft and there is a lot of cruft in that
code, but I worry that some of what he did might go away with your patch
(to be clear: I have not looked at the patch in any detail, and I have
not gone back to see whether it overlaps with what Michael did). In
particular, Loris Bennett had some simple tests that were failing before
Michael fixed things up, so you might want to look at the two threads:

http://thread.gmane.org/gmane.emacs.orgmode/60102

and

http://thread.gmane.org/gmane.emacs.orgmode/63586

{Warning: they are long and as I said, maybe not even relevant]

BTW, I tried to test, but applying the patch to current master
(8eff64cffee8627578edc33de485201ae579fafe) fails:

,----
| $ git apply --verbose ~/src/org/babel/0001-ob-core-remove-cruft.patch 
| Checking patch lisp/ob-core.el...
| error: while searching for:
|     nil))
| 
| ;; dynamically scoped for tramp
| (defvar org-babel-call-process-region-original nil)
| (defvar org-babel-library-of-babel)
| (defvar org-edit-src-content-indentation)
| (defvar org-src-lang-modes)
| 
| (declare-function outline-show-all "outline" ())
| (declare-function org-get-indentation "org" (&optional line))
| 
| error: patch failed: lisp/ob-core.el:36
| error: lisp/ob-core.el: patch does not apply
`----

--
Nick

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Errors get suppressed by org-babel-execute-src-block
  2016-02-10 22:57   ` Nicolas Goaziou
@ 2016-02-12 17:22     ` Aaron Ecay
  0 siblings, 0 replies; 11+ messages in thread
From: Aaron Ecay @ 2016-02-12 17:22 UTC (permalink / raw)
  To: Nicolas Goaziou, Gary Oberbrunner; +Cc: Orgmode Mailing List

Hi Nicolas,

2016ko otsailak 10an, Nicolas Goaziou-ek idatzi zuen:
> 
> Hello,
> 
> Aaron Ecay <aaronecay@gmail.com> writes:
> 
>> I’d like to install the attached patch to master, if there are no
>> objections.  That should resolve your concern as well as cleaning up the
>> dead code.
> 
> No objection, but...
> 
>> +(require 'subr-x)			; For `if-let'
> 
> ... you are not using `if-let' anywhere if this patch. 

Good catch.  I had used it in a previous version, then refactored it
away but forgot to remove the require.  I’ll push the patch once I have
a chance to rebase it on top of your recent babel changes.

> Besides, we still cannot use subr-x, since it is a 24.4 library, and,
> AFAIR, we didn't drop support for 24.3 yet.

I’ll keep that in mind.

Thanks,

-- 
Aaron Ecay

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Errors get suppressed by org-babel-execute-src-block
  2016-02-11 17:08   ` Nick Dokos
@ 2016-02-12 17:31     ` Aaron Ecay
  2016-02-12 17:59       ` Nick Dokos
  0 siblings, 1 reply; 11+ messages in thread
From: Aaron Ecay @ 2016-02-12 17:31 UTC (permalink / raw)
  To: Nick Dokos, emacs-orgmode

Hi Nick,

2016ko otsailak 11an, Nick Dokos-ek idatzi zuen:
> 
> Not sure if there are tests for remote babel execution, 

AFAIK no.  It would be useful to have these.  All the machines I use run
Linux and are configured very similarly.  Many of the problems in remote
execution come from differences in environments.  So it would be good if
someone could figure out how to test common configurations.  Until that
happens, we have to rely on ad hoc testing or user reports.

> but if not, please make sure to test that (with :dir set to some
> directory on a different machine). Michael Albinus had done some work
> to get that working a few years ago:

AFAICS my patch does not affect the work Michael did.  I will test some
simple remote execution scenarios before I push the patch, just in case.

> BTW, I tried to test, but applying the patch to current master
> (8eff64cffee8627578edc33de485201ae579fafe) fails:

Nicolas pushed some big changes to babel just after I sent my patch.
(Big in terms of the diff to the code, not necessarily in terms of
changing user behavior).  I haven’t looked in detail, but it’s almost
guaranteed that the patch now needs to be rebased, which I’ll do as
soon as I can.

-- 
Aaron Ecay

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Errors get suppressed by org-babel-execute-src-block
  2016-02-12 17:31     ` Aaron Ecay
@ 2016-02-12 17:59       ` Nick Dokos
  2016-02-14 16:07         ` Aaron Ecay
  0 siblings, 1 reply; 11+ messages in thread
From: Nick Dokos @ 2016-02-12 17:59 UTC (permalink / raw)
  To: emacs-orgmode

Aaron Ecay <aaronecay@gmail.com> writes:

> Hi Nick,
>
> 2016ko otsailak 11an, Nick Dokos-ek idatzi zuen:
>> 
>> Not sure if there are tests for remote babel execution, 
>
> AFAIK no.  It would be useful to have these.  All the machines I use run
> Linux and are configured very similarly.  Many of the problems in remote
> execution come from differences in environments.  So it would be good if
> someone could figure out how to test common configurations.  Until that
> happens, we have to rely on ad hoc testing or user reports.
>
I think tramp is pretty good at handling environment differences (and if
not, Michael is pretty responsive at modifying it to fix whatever
breakage people uncover), so for org-mode even simple tests in homogeneous
environments should be useful (e.g. using localhost as the "remote", or
the name of the machine that runs the test: not sure how much
optimization is done at various levels, but it might be enough to test
the remote code paths.)

>> but if not, please make sure to test that (with :dir set to some
>> directory on a different machine). Michael Albinus had done some work
>> to get that working a few years ago:
>
> AFAICS my patch does not affect the work Michael did.  I will test some
> simple remote execution scenarios before I push the patch, just in case.
>

OK - good!

>> BTW, I tried to test, but applying the patch to current master
>> (8eff64cffee8627578edc33de485201ae579fafe) fails:
>
> Nicolas pushed some big changes to babel just after I sent my patch.
> (Big in terms of the diff to the code, not necessarily in terms of
> changing user behavior).  I haven’t looked in detail, but it’s almost
> guaranteed that the patch now needs to be rebased, which I’ll do as
> soon as I can.

Thanks! If you post the patch, I'll try out some simple tests over the
weekend too.

--
Nick

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Errors get suppressed by org-babel-execute-src-block
  2016-02-12 17:59       ` Nick Dokos
@ 2016-02-14 16:07         ` Aaron Ecay
  2016-02-20 13:01           ` Nicolas Goaziou
  0 siblings, 1 reply; 11+ messages in thread
From: Aaron Ecay @ 2016-02-14 16:07 UTC (permalink / raw)
  To: Nick Dokos, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 999 bytes --]

Hi Nick,

2016ko otsailak 12an, Nick Dokos-ek idatzi zuen:
>> AFAICS my patch does not affect the work Michael did.  I will test some
>> simple remote execution scenarios before I push the patch, just in case.
>> 
> 
> OK - good!

I’ve tested, and remote execution seems to work (when tramp works for
me, which it does not do consistently – a known problem)

> 
>>> BTW, I tried to test, but applying the patch to current master
>>> (8eff64cffee8627578edc33de485201ae579fafe) fails:
>> 
>> Nicolas pushed some big changes to babel just after I sent my patch.
>> (Big in terms of the diff to the code, not necessarily in terms of
>> changing user behavior).  I haven’t looked in detail, but it’s almost
>> guaranteed that the patch now needs to be rebased, which I’ll do as
>> soon as I can.
> 
> Thanks! If you post the patch, I'll try out some simple tests over the
> weekend too.

It’s now split into two patches, attached to this message.

-- 
Aaron Ecay

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-org-babel-make-language-alias-function.patch --]
[-- Type: text/x-diff, Size: 2260 bytes --]

From 1e0f0e335bf594c6fe50581deb0775971a97f4f4 Mon Sep 17 00:00:00 2001
From: Aaron Ecay <aaronecay@gmail.com>
Date: Sun, 14 Feb 2016 15:14:30 +0000
Subject: [PATCH 1/2] Add org-babel-make-language-alias function.

* lisp/ob-core.el (org-babel-make-language-alias): New function.
* lisp/ob-emacs-lisp.el: Use it.

Previously this was accomplished via org-src-lang-modes, but that is a
poor solution, as it conflates the remapping of language mode names with
the creation of aliases.
---
 lisp/ob-core.el       | 20 ++++++++++++++++++++
 lisp/ob-emacs-lisp.el |  2 ++
 2 files changed, 22 insertions(+)

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 96296e0..7bd1156 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -3152,6 +3152,26 @@ plus the parameter value."
   (and (member "graphics" (cdr (assq :result-params params)))
        (cdr (assq :file params))))
 
+(defun org-babel-make-language-alias (new old)
+  "Make source blocks of type NEW aliases for those of type OLD.
+
+NEW and OLD should be strings.  This function should be called
+after the babel API for OLD-type source blocks is fully defined.
+
+Callers of this function will probably want to add an entry to
+`org-src-lang-modes' as well."
+  (dolist (fn '("execute" "expand-body" "prep-session"
+		"variable-assignments" "load-session"))
+    (let ((sym (intern-soft (concat "org-babel-" fn ":" old))))
+      (when (and sym (fboundp sym))
+	(defalias (intern (concat "org-babel-" fn ":" new)) sym))))
+  ;; Technically we don't need a `dolist' for just one variable, but
+  ;; we keep it for symmetry/ease of future expansion.
+  (dolist (var '("default-header-args"))
+    (let ((sym (intern-soft (concat "org-babel-" var ":" old))))
+      (when (and sym (boundp sym))
+	(defvaralias (intern (concat "org-babel-" var ":" new)) sym)))))
+
 (provide 'ob-core)
 
 ;; Local variables:
diff --git a/lisp/ob-emacs-lisp.el b/lisp/ob-emacs-lisp.el
index 18936a6..2eb2721 100644
--- a/lisp/ob-emacs-lisp.el
+++ b/lisp/ob-emacs-lisp.el
@@ -72,6 +72,8 @@
          (org-babel-pick-name (cdr (assoc :rowname-names params))
                               (cdr (assoc :rownames params))))))))
 
+(org-babel-make-language-alias "elisp" "emacs-lisp")
+
 (provide 'ob-emacs-lisp)
 
 
-- 
2.7.1


[-- Attachment #3: 0002-ob-core-remove-cruft.patch --]
[-- Type: text/x-diff, Size: 7571 bytes --]

From c5cf453d6f0c590dd99e9f607b2897965460f33f Mon Sep 17 00:00:00 2001
From: Aaron Ecay <aaronecay@gmail.com>
Date: Sun, 14 Feb 2016 15:20:39 +0000
Subject: [PATCH 2/2] ob-core: remove cruft
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* lisp/ob-core.el (org-babel-execute-src-block): Simplify.
(org-babel-tramp-handle-call-process-region): Remove.

Commit 57104f9f changed an org-flet to a let, rendering the whole
apparatus of modifying call-process-region inoperative.  Supposedly this
was put in place to work around a bug in
tramp-handle-call-process-region, which was removed from tramp in
2012 (after being renamed to tramp-sh-call-process-region).  *shrug*
This commit just removes the whole thing.

It also no longer consults ‘org-src-lang-modes’, following on from
commit 6287416.
---
 lisp/ob-core.el | 132 ++++++++++++++++++++------------------------------------
 1 file changed, 46 insertions(+), 86 deletions(-)

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 7bd1156..14226bf 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -35,7 +35,6 @@
       ".exe"
     nil))
 
-(defvar org-babel-call-process-region-original nil)
 (defvar org-babel-library-of-babel)
 (defvar org-edit-src-content-indentation)
 (defvar org-src-lang-modes)
@@ -547,7 +546,6 @@ match group 9.  Other match groups are defined in
   (concat org-babel-name-regexp (regexp-quote name) "[ \t]*$"))
 
 ;;; functions
-(defvar call-process-region)
 (defvar org-babel-current-src-block-location nil
   "Marker pointing to the src block currently being executed.
 This may also point to a call line or an inline code block.  If
@@ -678,71 +676,52 @@ block."
 		 (default-directory
 		   (or (and dir (file-name-as-directory (expand-file-name dir)))
 		       default-directory))
-		 (org-babel-call-process-region-original ;; for tramp handler
-		  (or (org-bound-and-true-p
-		       org-babel-call-process-region-original)
-		      (symbol-function 'call-process-region)))
-		 result cmd)
-	    (unwind-protect
-		(let ((call-process-region
-		       (lambda (&rest args)
-			 (apply 'org-babel-tramp-handle-call-process-region
-				args))))
-		  (let ((lang-check
-			 (lambda (f)
-			   (let ((f (intern (concat "org-babel-execute:" f))))
-			     (when (fboundp f) f)))))
-		    (setq cmd
-			  (or (funcall lang-check lang)
-			      (funcall lang-check
-				       (symbol-name
-					(cdr (assoc lang org-src-lang-modes))))
-			      (error "No org-babel-execute function for %s!"
-				     lang))))
-		  (message "executing %s code block%s..."
-			   (capitalize lang)
-			   (if (nth 4 info) (format " (%s)" (nth 4 info)) ""))
-		  (if (member "none" result-params)
-		      (progn
-			(funcall cmd body params)
-			(message "result silenced")
-			(setq result nil))
-		    (setq result
-			  (let ((result (funcall cmd body params)))
-                            (if (and (eq (cdr (assoc :result-type params))
-                                         'value)
-                                     (or (member "vector" result-params)
-                                         (member "table" result-params))
-                                     (not (listp result)))
-                                (list (list result)) result)))
-		    ;; If non-empty result and :file then write to :file.
-		    (when (cdr (assoc :file params))
-		      (when result
-			(with-temp-file (cdr (assoc :file params))
-			  (insert
-			   (org-babel-format-result
-			    result (cdr (assoc :sep (nth 2 info)))))))
-		      (setq result (cdr (assoc :file params))))
-		    ;; Possibly perform post process provided its appropriate.
-		    (when (cdr (assoc :post params))
-		      (let ((*this* (if (cdr (assoc :file params))
-					(org-babel-result-to-file
-					 (cdr (assoc :file params))
-					 (when (assoc :file-desc params)
-					   (or (cdr (assoc :file-desc params))
-					       result)))
-				      result)))
-			(setq result (org-babel-ref-resolve
-				      (cdr (assoc :post params))))
-			(when (cdr (assoc :file params))
-			  (setq result-params
-				(remove "file" result-params)))))
-		    (org-babel-insert-result
-		     result result-params info new-hash lang))
-                  (run-hooks 'org-babel-after-execute-hook)
-		  result)
-	      (setq call-process-region
-		    'org-babel-call-process-region-original)))))))))
+		 (cmd (intern (concat "org-babel-execute:" lang)))
+		 result)
+	    (unless (fboundp cmd)
+	      (error "No org-babel-execute function for %s!" lang))
+	    (message "executing %s code block%s..."
+		     (capitalize lang)
+		     (if (nth 4 info) (format " (%s)" (nth 4 info)) ""))
+	    (if (member "none" result-params)
+		(progn
+		  (funcall cmd body params)
+		  (message "result silenced")
+		  (setq result nil))
+	      (setq result
+		    (let ((result (funcall cmd body params)))
+		      (if (and (eq (cdr (assoc :result-type params))
+				   'value)
+			       (or (member "vector" result-params)
+				   (member "table" result-params))
+			       (not (listp result)))
+			  (list (list result)) result)))
+	      ;; If non-empty result and :file then write to :file.
+	      (when (cdr (assoc :file params))
+		(when result
+		  (with-temp-file (cdr (assoc :file params))
+		    (insert
+		     (org-babel-format-result
+		      result (cdr (assoc :sep (nth 2 info)))))))
+		(setq result (cdr (assoc :file params))))
+	      ;; Possibly perform post process provided its appropriate.
+	      (when (cdr (assoc :post params))
+		(let ((*this* (if (cdr (assoc :file params))
+				  (org-babel-result-to-file
+				   (cdr (assoc :file params))
+				   (when (assoc :file-desc params)
+				     (or (cdr (assoc :file-desc params))
+					 result)))
+				result)))
+		  (setq result (org-babel-ref-resolve
+				(cdr (assoc :post params))))
+		  (when (cdr (assoc :file params))
+		    (setq result-params
+			  (remove "file" result-params)))))
+	      (org-babel-insert-result
+	       result result-params info new-hash lang))
+	    (run-hooks 'org-babel-after-execute-hook)
+	    result)))))))
 
 (defun org-babel-expand-body:generic (body params &optional var-lines)
   "Expand BODY with PARAMS.
@@ -2974,25 +2953,6 @@ character of the string."
    (org-reverse-string
     (org-babel-chomp (org-reverse-string string) regexp)) regexp))
 
-(defun org-babel-tramp-handle-call-process-region
-  (start end program &optional delete buffer display &rest args)
-  "Use Tramp to handle `call-process-region'.
-Fixes a bug in `tramp-handle-call-process-region'."
-  (if (and (featurep 'tramp) (file-remote-p default-directory))
-      (let ((tmpfile (tramp-compat-make-temp-file "")))
-	(write-region start end tmpfile)
-	(when delete (delete-region start end))
-	(unwind-protect
-	    ;;	(apply 'call-process program tmpfile buffer display args)
-            ;; bug in tramp
-	    (apply 'process-file program tmpfile buffer display args)
-	  (delete-file tmpfile)))
-    ;; org-babel-call-process-region-original is the original emacs
-    ;; definition.  It is in scope from the let binding in
-    ;; org-babel-execute-src-block
-    (apply org-babel-call-process-region-original
-           start end program delete buffer display args)))
-
 (defun org-babel-local-file-name (file)
   "Return the local name component of FILE."
   (or (file-remote-p file 'localname) file))
-- 
2.7.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: Errors get suppressed by org-babel-execute-src-block
  2016-02-14 16:07         ` Aaron Ecay
@ 2016-02-20 13:01           ` Nicolas Goaziou
  2016-02-20 13:33             ` Nick Dokos
  0 siblings, 1 reply; 11+ messages in thread
From: Nicolas Goaziou @ 2016-02-20 13:01 UTC (permalink / raw)
  To: Nick Dokos; +Cc: emacs-orgmode

Hello,

Aaron Ecay <aaronecay@gmail.com> writes:

> I’ve tested, and remote execution seems to work (when tramp works for
> me, which it does not do consistently – a known problem)

Thank you.

IMO, it looks good. You might as well push it and wait for more
feedback, if needed.

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Errors get suppressed by org-babel-execute-src-block
  2016-02-20 13:01           ` Nicolas Goaziou
@ 2016-02-20 13:33             ` Nick Dokos
  2016-02-22 16:05               ` Aaron Ecay
  0 siblings, 1 reply; 11+ messages in thread
From: Nick Dokos @ 2016-02-20 13:33 UTC (permalink / raw)
  To: emacs-orgmode

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Hello,
>
> Aaron Ecay <aaronecay@gmail.com> writes:
>
>> I’ve tested, and remote execution seems to work (when tramp works for
>> me, which it does not do consistently – a known problem)
>
> Thank you.
>
> IMO, it looks good. You might as well push it and wait for more
> feedback, if needed.
>
> Regards,

I did some testing as well and it seems to work.

-- 
Nick

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Errors get suppressed by org-babel-execute-src-block
  2016-02-20 13:33             ` Nick Dokos
@ 2016-02-22 16:05               ` Aaron Ecay
  0 siblings, 0 replies; 11+ messages in thread
From: Aaron Ecay @ 2016-02-22 16:05 UTC (permalink / raw)
  To: Nick Dokos, emacs-orgmode

Hi Nick, hi Nicolas,

2016ko otsailak 20an, Nick Dokos-ek idatzi zuen:
>> IMO, it looks good. You might as well push it and wait for more
>> feedback, if needed.
>> 
>> Regards,
> 
> I did some testing as well and it seems to work.

Thanks for the feedback.  Pushed to master.

-- 
Aaron Ecay

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-02-22 16:05 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-08 19:02 Errors get suppressed by org-babel-execute-src-block Gary Oberbrunner
2016-02-10 20:23 ` Aaron Ecay
2016-02-10 22:57   ` Nicolas Goaziou
2016-02-12 17:22     ` Aaron Ecay
2016-02-11 17:08   ` Nick Dokos
2016-02-12 17:31     ` Aaron Ecay
2016-02-12 17:59       ` Nick Dokos
2016-02-14 16:07         ` Aaron Ecay
2016-02-20 13:01           ` Nicolas Goaziou
2016-02-20 13:33             ` Nick Dokos
2016-02-22 16:05               ` Aaron Ecay

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).