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: Sun, 14 Feb 2016 16:07:18 +0000 Message-ID: <87mvr3b7ih.fsf@gmail.com> References: <87pow4pb5b.fsf@gmail.com> <87bn7nrx7v.fsf@alphaville.usersys.redhat.com> <87ziv5kf80.fsf@gmail.com> <87oablrery.fsf@alphaville.usersys.redhat.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49295) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aUzCp-0008LQ-AW for emacs-orgmode@gnu.org; Sun, 14 Feb 2016 11:07:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aUzCk-00056d-8r for emacs-orgmode@gnu.org; Sun, 14 Feb 2016 11:07:27 -0500 Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]:34564) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aUzCj-00056W-ST for emacs-orgmode@gnu.org; Sun, 14 Feb 2016 11:07:22 -0500 Received: by mail-wm0-x22c.google.com with SMTP id b205so39342014wmb.1 for ; Sun, 14 Feb 2016 08:07:21 -0800 (PST) In-Reply-To: <87oablrery.fsf@alphaville.usersys.redhat.com> 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: Nick Dokos , emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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. >>=20 >=20 > OK - good! I=E2=80=99ve tested, and remote execution seems to work (when tramp works f= or me, which it does not do consistently =E2=80=93 a known problem) >=20 >>> BTW, I tried to test, but applying the patch to current master >>> (8eff64cffee8627578edc33de485201ae579fafe) fails: >>=20 >> 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=E2=80=99t looked in detail, but it=E2= =80=99s almost >> guaranteed that the patch now needs to be rebased, which I=E2=80=99ll do= as >> soon as I can. >=20 > Thanks! If you post the patch, I'll try out some simple tests over the > weekend too. It=E2=80=99s now split into two patches, attached to this message. --=20 Aaron Ecay --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Add-org-babel-make-language-alias-function.patch >From 1e0f0e335bf594c6fe50581deb0775971a97f4f4 Mon Sep 17 00:00:00 2001 From: Aaron Ecay 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 --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename=0002-ob-core-remove-cruft.patch Content-Transfer-Encoding: quoted-printable >From c5cf453d6f0c590dd99e9f607b2897965460f33f Mon Sep 17 00:00:00 2001 From: Aaron Ecay 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=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 to 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, 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)) =20 -(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]*$")) =20 ;;; 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))))))) =20 (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)) =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 --=-=-=--