From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: [PATCH] Make src block location available to execution backends Date: Thu, 06 Jun 2013 09:18:43 -0600 Message-ID: <87wqq76ze4.fsf@gmail.com> References: <874ndcoegb.fsf@gmail.com> <874ndbmr9b.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41499) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkbyS-00022N-08 for emacs-orgmode@gnu.org; Thu, 06 Jun 2013 11:19:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UkbyQ-0006Et-7Y for emacs-orgmode@gnu.org; Thu, 06 Jun 2013 11:19:35 -0400 Received: from mail-pd0-f175.google.com ([209.85.192.175]:41178) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkbyP-0006Eh-V7 for emacs-orgmode@gnu.org; Thu, 06 Jun 2013 11:19:34 -0400 Received: by mail-pd0-f175.google.com with SMTP id 4so3472488pdd.6 for ; Thu, 06 Jun 2013 08:19:33 -0700 (PDT) In-Reply-To: <874ndbmr9b.fsf@gmail.com> (Vitalie Spinu's message of "Thu, 06 Jun 2013 13:07:44 +0200") 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: Vitalie Spinu Cc: emacs-orgmode@gnu.org Vitalie Spinu writes: > Hi again, > > I wrapped it in a patch. All tests are fine. Will be very happy if > someone could have a glance. I have my FSF papers signed. > I've just applied this patch. I think this is an excellent idea, and I appreciate the clean implementation and packaging into a git-patch. Cheers! > > Thanks, > > Vitalie > > > From 90dc398856c121c0a1cac36d6726e49d9fa31570 Mon Sep 17 00:00:00 2001 > From: Vitalie Spinu > Date: Thu, 6 Jun 2013 12:04:02 +0200 > Subject: [PATCH] make src block location available to execution backends > > * lisp/ob-core.el (org-babel-where-is-src-block-head): return > point-marker instead of point. > > (org-babel-current-exec-src-block-head): new global variable which is > bound during `org-babel-execute-src-block-maybe' > > (org-babel-get-src-block-info): return a list of 7 elements, last > being the header location > > Evaluation backends might need to use the exact location of the block in > original org file. For example when inserting the correct source > references for visual debugging. With this patch the information on > current block is available in `org-babel-current-exec-src-block-head'. > --- > lisp/ob-core.el | 13 ++++++++----- > 1 file changed, 8 insertions(+), 5 deletions(-) > > diff --git a/lisp/ob-core.el b/lisp/ob-core.el > index 8d26c4e..93c5d5e 100644 > --- a/lisp/ob-core.el > +++ b/lisp/ob-core.el > @@ -251,14 +251,14 @@ references; a process which could likely result in the execution > of other code blocks. > > Returns a list > - (language body header-arguments-alist switches name indent)." > + (language body header-arguments-alist switches name indent block-head)." > (let ((case-fold-search t) head info name indent) > ;; full code block > (if (setq head (org-babel-where-is-src-block-head)) > (save-excursion > (goto-char head) > (setq info (org-babel-parse-src-block-match)) > - (setq indent (car (last info))) > + (setq indent (nth 5 info)) > (setq info (butlast info)) > (while (and (forward-line -1) > (looking-at org-babel-multi-line-header-regexp)) > @@ -274,7 +274,7 @@ Returns a list > ;; resolve variable references and add summary parameters > (when (and info (not light)) > (setf (nth 2 info) (org-babel-process-params (nth 2 info)))) > - (when info (append info (list name indent))))) > + (when info (append info (list name indent head))))) > > (defvar org-current-export-file) ; dynamically bound > (defmacro org-babel-check-confirm-evaluate (info &rest body) > @@ -535,6 +535,8 @@ can not be resolved.") > > ;;; functions > (defvar call-process-region) > +(defvar org-babel-current-exec-src-block-head nil > + "Marker to the currently processed src block.") > > ;;;###autoload > (defun org-babel-execute-src-block (&optional arg info params) > @@ -562,6 +564,7 @@ block." > (let* ((params (if params > (org-babel-process-params merged-params) > (nth 2 info))) > + (org-babel-current-exec-src-block-head (nth 6 info)) > (cachep (and (not arg) (cdr (assoc :cache params)) > (string= "yes" (cdr (assoc :cache params))))) > (new-hash (when cachep (org-babel-sha1-hash info))) > @@ -592,7 +595,7 @@ block." > (or (org-bound-and-true-p > org-babel-call-process-region-original) > (symbol-function 'call-process-region))) > - (indent (car (last info))) > + (indent (nth 5 info)) > result cmd) > (unwind-protect > (let ((call-process-region > @@ -1592,7 +1595,7 @@ If the point is not on a source block then return nil." > (< top initial) (< initial bottom) > (progn (goto-char top) (beginning-of-line 1) > (looking-at org-babel-src-block-regexp)) > - (point)))))) > + (point-marker)))))) > > ;;;###autoload > (defun org-babel-goto-src-block-head () -- Eric Schulte http://cs.unm.edu/~eschulte