From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aaron Ecay Subject: Re: Errors get suppressed by org-babel-execute-src-block Date: Wed, 10 Feb 2016 20:23:44 +0000 Message-ID: <87pow4pb5b.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48352) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTbIk-0007Ja-3t for emacs-orgmode@gnu.org; Wed, 10 Feb 2016 15:23:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aTbIh-0007M9-9T for emacs-orgmode@gnu.org; Wed, 10 Feb 2016 15:23:50 -0500 Received: from mail-wm0-x230.google.com ([2a00:1450:400c:c09::230]:35830) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTbIg-0007Lh-SW for emacs-orgmode@gnu.org; Wed, 10 Feb 2016 15:23:47 -0500 Received: by mail-wm0-x230.google.com with SMTP id c200so45905649wme.0 for ; Wed, 10 Feb 2016 12:23:46 -0800 (PST) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Gary Oberbrunner , Orgmode Mailing List --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Gary, 2016ko otsailak 8an, Gary Oberbrunner-ek idatzi zuen: >=20 > 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.=20 The unwind-protect exists since 2010, so you=E2=80=99re probably mistaken a= bout that (depending on your frame of reference for =E2=80=9Cused to=E2=80=9D...) 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 =E2=80=9Corg-flet=E2=80=9D to a =E2=80=9Clet=E2= =80=9D 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=E2=80=99d 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 --=20 Aaron Ecay --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0001-ob-core-remove-cruft.patch Content-Transfer-Encoding: quoted-printable >From bdb68585d5b0ddf5a6c9876028b5f2be2f17e66a Mon Sep 17 00:00:00 2001 From: Aaron Ecay Date: Wed, 10 Feb 2016 19:39:04 +0000 Subject: [PATCH] ob-core: remove cruft MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-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 =E2=80=98org-src-lang-modes=E2=80=99, 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)) =20 ;; 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) =20 (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))))))) =20 (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)) =20 -(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)) --=20 2.7.1 --=-=-=--