mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-06 03:13:16 +00:00
babel: Allow `org-babel-map-src-blocks' to operate on current buffer
* ob.el (org-babel-map-src-blocks): If FILE is nil evaluate BODY forms on source blocks in current buffer; restore point in current buffer.
This commit is contained in:
parent
0a46f202ca
commit
13891fce6e
13
lisp/ob.el
13
lisp/ob.el
|
@ -724,12 +724,14 @@ portions of results lines."
|
||||||
'org-babel-show-result-all 'append 'local)))
|
'org-babel-show-result-all 'append 'local)))
|
||||||
|
|
||||||
(defmacro org-babel-map-src-blocks (file &rest body)
|
(defmacro org-babel-map-src-blocks (file &rest body)
|
||||||
"Evaluate BODY forms on each source-block in FILE."
|
"Evaluate BODY forms on each source-block in FILE. If FILE is
|
||||||
|
nil evaluate BODY forms on source blocks in current buffer."
|
||||||
(declare (indent 1))
|
(declare (indent 1))
|
||||||
`(let ((visited-p (get-file-buffer (expand-file-name ,file)))
|
`(let ((visited-p (or (null ,file)
|
||||||
to-be-removed)
|
(get-file-buffer (expand-file-name ,file))))
|
||||||
|
(point (point)) to-be-removed)
|
||||||
(save-window-excursion
|
(save-window-excursion
|
||||||
(find-file ,file)
|
(if ,file (find-file ,file))
|
||||||
(setq to-be-removed (current-buffer))
|
(setq to-be-removed (current-buffer))
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(while (re-search-forward org-babel-src-block-regexp nil t)
|
(while (re-search-forward org-babel-src-block-regexp nil t)
|
||||||
|
@ -737,7 +739,8 @@ portions of results lines."
|
||||||
(save-match-data ,@body)
|
(save-match-data ,@body)
|
||||||
(goto-char (match-end 0))))
|
(goto-char (match-end 0))))
|
||||||
(unless visited-p
|
(unless visited-p
|
||||||
(kill-buffer to-be-removed))))
|
(kill-buffer to-be-removed))
|
||||||
|
(goto-char point)))
|
||||||
|
|
||||||
(defvar org-file-properties)
|
(defvar org-file-properties)
|
||||||
(defun org-babel-params-from-properties (&optional lang)
|
(defun org-babel-params-from-properties (&optional lang)
|
||||||
|
|
Loading…
Reference in a new issue