Browse Source

call org-confirm-babel-evaluate from code block

  Always call org-confirm-babel-evaluate from the head of the code
  block being evaluated so that the info may be found with
  e.g., (org-babel-get-src-block-info 'light)

* lisp/ob-core.el (org-babel-check-confirm-evaluate): Call
  org-confirm-babel-evaluate from code block head.
Eric Schulte 4 years ago
parent
commit
2eef1b4549
1 changed files with 6 additions and 3 deletions
  1. 6 3
      lisp/ob-core.el

+ 6 - 3
lisp/ob-core.el

@@ -287,11 +287,12 @@ hold the language of the code block, and BLOCK-NAME will hold the
 name of the code block."
   (declare (indent defun))
   (org-with-gensyms
-      (lang block-body headers name eval eval-no export eval-no-export)
+      (lang block-body headers name head eval eval-no export eval-no-export)
     `(let* ((,lang           (nth 0 ,info))
 	    (,block-body     (nth 1 ,info))
 	    (,headers        (nth 2 ,info))
 	    (,name           (nth 4 ,info))
+	    (,head           (nth 6 ,info))
 	    (,eval           (or (cdr  (assoc :eval   ,headers))
 				 (when (assoc :noeval ,headers) "no")))
 	    (,eval-no        (or (equal ,eval "no")
@@ -303,8 +304,10 @@ name of the code block."
 	    (query           (or (equal ,eval "query")
 				 (and ,export (equal ,eval "query-export"))
 				 (if (functionp org-confirm-babel-evaluate)
-				     (funcall org-confirm-babel-evaluate
-					      ,lang ,block-body)
+				     (save-excursion
+				       (goto-char ,head)
+				       (funcall org-confirm-babel-evaluate
+						,lang ,block-body))
 				   org-confirm-babel-evaluate)))
 	    (code-block      (if ,info (format  " %s "  ,lang) " "))
 	    (block-name      (if ,name (format " (%s) " ,name) " ")))