|
@@ -938,6 +938,10 @@ evaluation mechanisms."
|
|
|
|
|
|
(defvar org-bracket-link-regexp)
|
|
|
|
|
|
+(defun org-babel-active-location-p ()
|
|
|
+ (memq (car (save-match-data (org-element-context)))
|
|
|
+ '(babel-call inline-babel-call inline-src-block src-block)))
|
|
|
+
|
|
|
;;;###autoload
|
|
|
(defun org-babel-open-src-block-result (&optional re-run)
|
|
|
"If `point' is on a src block then open the results of the
|
|
@@ -998,24 +1002,25 @@ end-body --------- point at the end of the body"
|
|
|
(setq to-be-removed (current-buffer))
|
|
|
(goto-char (point-min))
|
|
|
(while (re-search-forward org-babel-src-block-regexp nil t)
|
|
|
- (goto-char (match-beginning 0))
|
|
|
- (let ((full-block (match-string 0))
|
|
|
- (beg-block (match-beginning 0))
|
|
|
- (end-block (match-end 0))
|
|
|
- (lang (match-string 2))
|
|
|
- (beg-lang (match-beginning 2))
|
|
|
- (end-lang (match-end 2))
|
|
|
- (switches (match-string 3))
|
|
|
- (beg-switches (match-beginning 3))
|
|
|
- (end-switches (match-end 3))
|
|
|
- (header-args (match-string 4))
|
|
|
- (beg-header-args (match-beginning 4))
|
|
|
- (end-header-args (match-end 4))
|
|
|
- (body (match-string 5))
|
|
|
- (beg-body (match-beginning 5))
|
|
|
- (end-body (match-end 5)))
|
|
|
- ,@body
|
|
|
- (goto-char end-block))))
|
|
|
+ (when (org-babel-active-location-p)
|
|
|
+ (goto-char (match-beginning 0))
|
|
|
+ (let ((full-block (match-string 0))
|
|
|
+ (beg-block (match-beginning 0))
|
|
|
+ (end-block (match-end 0))
|
|
|
+ (lang (match-string 2))
|
|
|
+ (beg-lang (match-beginning 2))
|
|
|
+ (end-lang (match-end 2))
|
|
|
+ (switches (match-string 3))
|
|
|
+ (beg-switches (match-beginning 3))
|
|
|
+ (end-switches (match-end 3))
|
|
|
+ (header-args (match-string 4))
|
|
|
+ (beg-header-args (match-beginning 4))
|
|
|
+ (end-header-args (match-end 4))
|
|
|
+ (body (match-string 5))
|
|
|
+ (beg-body (match-beginning 5))
|
|
|
+ (end-body (match-end 5)))
|
|
|
+ ,@body
|
|
|
+ (goto-char end-block)))))
|
|
|
(unless visited-p (kill-buffer to-be-removed))
|
|
|
(goto-char point))))
|
|
|
(def-edebug-spec org-babel-map-src-blocks (form body))
|
|
@@ -1036,8 +1041,9 @@ buffer."
|
|
|
(setq to-be-removed (current-buffer))
|
|
|
(goto-char (point-min))
|
|
|
(while (re-search-forward org-babel-inline-src-block-regexp nil t)
|
|
|
- (goto-char (match-beginning 1))
|
|
|
- (save-match-data ,@body)
|
|
|
+ (when (org-babel-active-location-p)
|
|
|
+ (goto-char (match-beginning 1))
|
|
|
+ (save-match-data ,@body))
|
|
|
(goto-char (match-end 0))))
|
|
|
(unless visited-p (kill-buffer to-be-removed))
|
|
|
(goto-char point))))
|
|
@@ -1061,8 +1067,9 @@ buffer."
|
|
|
(setq to-be-removed (current-buffer))
|
|
|
(goto-char (point-min))
|
|
|
(while (re-search-forward org-babel-lob-one-liner-regexp nil t)
|
|
|
- (goto-char (match-beginning 1))
|
|
|
- (save-match-data ,@body)
|
|
|
+ (when (org-babel-active-location-p)
|
|
|
+ (goto-char (match-beginning 1))
|
|
|
+ (save-match-data ,@body))
|
|
|
(goto-char (match-end 0))))
|
|
|
(unless visited-p (kill-buffer to-be-removed))
|
|
|
(goto-char point))))
|
|
@@ -1085,9 +1092,11 @@ buffer."
|
|
|
(setq to-be-removed (current-buffer))
|
|
|
(goto-char (point-min))
|
|
|
(while (re-search-forward ,rx nil t)
|
|
|
- (goto-char (match-beginning 1))
|
|
|
- (when (looking-at org-babel-inline-src-block-regexp)(forward-char 1))
|
|
|
- (save-match-data ,@body)
|
|
|
+ (when (org-babel-active-location-p)
|
|
|
+ (goto-char (match-beginning 1))
|
|
|
+ (when (looking-at org-babel-inline-src-block-regexp)
|
|
|
+ (forward-char 1))
|
|
|
+ (save-match-data ,@body))
|
|
|
(goto-char (match-end 0))))
|
|
|
(unless visited-p (kill-buffer to-be-removed))
|
|
|
(goto-char point))))
|