From mboxrd@z Thu Jan 1 00:00:00 1970 From: Achim Gratz Subject: Re: org-agenda-write taking very long (probably because of babel) Date: Wed, 27 Feb 2013 23:56:51 +0100 Message-ID: <87y5e9icwc.fsf@Rainer.invalid> References: <2013-02-27T17-53-25@devnull.Karl-Voit.at> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:40682) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UApw3-0008WR-L3 for emacs-orgmode@gnu.org; Wed, 27 Feb 2013 17:57:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UApw1-0004x7-RY for emacs-orgmode@gnu.org; Wed, 27 Feb 2013 17:57:15 -0500 Received: from plane.gmane.org ([80.91.229.3]:46829) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UApw1-0004wt-Fv for emacs-orgmode@gnu.org; Wed, 27 Feb 2013 17:57:13 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UApwL-00013o-7q for emacs-orgmode@gnu.org; Wed, 27 Feb 2013 23:57:33 +0100 Received: from pd9eb2cca.dip.t-dialin.net ([217.235.44.202]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 27 Feb 2013 23:57:33 +0100 Received: from Stromeko by pd9eb2cca.dip.t-dialin.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 27 Feb 2013 23:57:33 +0100 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: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Karl Voit writes: > I guess this relates to ... > > org-babel-exp processing... [25 times] > > ... which also pops up some babel result graphics which did not > happen before. > > Was there a change in the default settings or is this a bug? Yes there was, sorry for that. I missed something that was going on in an otherwise inconspicously named function and that unintentionally changed the conditions for when source blocks are eligible for evaluation. Since your setup was affected, may I ask you to apply this patch after the next update (which should include 302d3780ec) and report if this fixes the issue you had? --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-ob-core-do-not-ask-for-confirmation-if-cached-result.patch Content-Transfer-Encoding: 8bit >From ac8841d2af9fcc490e5d98cb63eaaf74d3ba73f7 Mon Sep 17 00:00:00 2001 From: Achim Gratz Date: Wed, 27 Feb 2013 22:55:26 +0100 Subject: [PATCH] ob-core: do not ask for confirmation if cached result is current MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * lisp/ob-core.el (org-babel-execute-src-block): Do not ask for confirmation if the cached result is current. Since `org-babel-confirm-evaluate´ does additional things besides asking for confirmation, call it first with `org-confirm-babel-evaluate´ bound to nil. This has the effect that it will never ask the user, but will indicate if the block should be evaluated. If yes, determine whether the cached result block is current (this is deferred until now since `org-babel-process-params´ might trigger expensive operations). If `cache-current-p´ is t or `org-confirm-babel-evaluate´ is nil, evaluate the source block without asking. In case the cache is current the evaluation will not actually do anything but return the cached value, so this is safe. In case `org-confirm-babel-evaluate´ is nil the user would not be asked anyway, so the call of `org-babel-confirm-evaluate´ is not necessary. Otherwise run `org-babel-confirm-evaluate´ again to ask permission from the user and act depending on the answer. --- lisp/ob-core.el | 141 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 73 insertions(+), 68 deletions(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 275a4f7..8b6b2a6 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -523,80 +523,85 @@ (defun org-babel-execute-src-block (&optional arg info params) (interactive) (let* ((info (or info (org-babel-get-src-block-info))) (merged-params (org-babel-merge-params (nth 2 info) params))) - (when (org-babel-confirm-evaluate - (let ((i info)) (setf (nth 2 i) merged-params) i)) - (let* ((lang (nth 0 info)) - (params (if params + (when (let ((org-confirm-babel-evaluate nil)) ;; do not ask yet + (org-babel-confirm-evaluate + (let ((i info)) (setf (nth 2 i) merged-params) i))) + (let* ((params (if params (org-babel-process-params merged-params) (nth 2 info))) (cache-p (and (not arg) (cdr (assoc :cache params)) (string= "yes" (cdr (assoc :cache params))))) - (result-params (cdr (assoc :result-params params))) (new-hash (when cache-p (org-babel-sha1-hash info))) (old-hash (when cache-p (org-babel-current-result-hash))) - (cache-current-p (and (not arg) new-hash (equal new-hash old-hash))) - (body (setf (nth 1 info) - (if (org-babel-noweb-p params :eval) - (org-babel-expand-noweb-references info) - (nth 1 info)))) - (dir (cdr (assoc :dir params))) - (default-directory - (or (and dir (file-name-as-directory (expand-file-name dir))) - default-directory)) - (org-babel-call-process-region-original - (if (boundp 'org-babel-call-process-region-original) - org-babel-call-process-region-original - (symbol-function 'call-process-region))) - (indent (car (last 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)))) - (if cache-current-p - (save-excursion ;; return cached result - (goto-char (org-babel-where-is-src-block-result nil info)) - (end-of-line 1) (forward-char 1) - (setq result (org-babel-read-result)) - (message (replace-regexp-in-string - "%" "%%" (format "%S" result))) result) - (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 - ((lambda (result) - (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)) - (funcall cmd body params))) - ;; 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)))) - (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)))))) + (cache-current-p (and (not arg) new-hash (equal new-hash old-hash)))) + (when (or cache-current-p + (null org-confirm-babel-evaluate) + (org-babel-confirm-evaluate ;; perhaps ask now + (let ((i info)) (setf (nth 2 i) merged-params) i))) + (let* ((lang (nth 0 info)) + (result-params (cdr (assoc :result-params params))) + (body (setf (nth 1 info) + (if (org-babel-noweb-p params :eval) + (org-babel-expand-noweb-references info) + (nth 1 info)))) + (dir (cdr (assoc :dir params))) + (default-directory + (or (and dir (file-name-as-directory (expand-file-name dir))) + default-directory)) + (org-babel-call-process-region-original + (if (boundp 'org-babel-call-process-region-original) + org-babel-call-process-region-original + (symbol-function 'call-process-region))) + (indent (car (last 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)))) + (if cache-current-p + (save-excursion ;; return cached result + (goto-char (org-babel-where-is-src-block-result nil info)) + (end-of-line 1) (forward-char 1) + (setq result (org-babel-read-result)) + (message (replace-regexp-in-string + "%" "%%" (format "%S" result))) result) + (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 + ((lambda (result) + (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)) + (funcall cmd body params))) + ;; 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)))) + (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)))))))) (defun org-babel-expand-body:generic (body params &optional var-lines) "Expand BODY with PARAMS. -- 1.8.1.4 --=-=-= Content-Type: text/plain Regards, Achim. -- +<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+ Samples for the Waldorf Blofeld: http://Synth.Stromeko.net/Downloads.html#BlofeldSamplesExtra --=-=-=--