forked from mirrors/org-mode
babel: tangle works when buffer name and file name differ
Thanks to "w t" from the mailing list for reporting this bug and providing reproduction information.
This commit is contained in:
parent
47a6c25df3
commit
c5e3660fa9
|
@ -71,7 +71,14 @@ specify a default export file for all source blocks. Optional
|
|||
argument LANG can be used to limit the exported source code
|
||||
blocks by language."
|
||||
(interactive "fFile to tangle: \nP")
|
||||
(save-window-excursion (find-file file) (org-babel-tangle target-file lang)))
|
||||
(let ((visited-p (get-file-buffer (expand-file-name file)))
|
||||
to-be-removed)
|
||||
(save-window-excursion
|
||||
(find-file file)
|
||||
(setq to-be-removed (current-buffer))
|
||||
(org-babel-tangle target-file lang))
|
||||
(unless visited-p
|
||||
(kill-buffer to-be-removed))))
|
||||
|
||||
(defun org-babel-tangle-publish (_ filename pub-dir)
|
||||
"Tangle FILENAME and place the results in PUB-DIR."
|
||||
|
|
|
@ -562,14 +562,18 @@ with C-c C-c."
|
|||
(defmacro org-babel-map-source-blocks (file &rest body)
|
||||
"Evaluate BODY forms on each source-block in FILE."
|
||||
(declare (indent 1))
|
||||
`(let ((visited-p (get-buffer (file-name-nondirectory ,file))))
|
||||
`(let ((visited-p (get-file-buffer (expand-file-name ,file)))
|
||||
to-be-removed)
|
||||
(save-window-excursion
|
||||
(find-file ,file) (goto-char (point-min))
|
||||
(find-file ,file)
|
||||
(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))
|
||||
(save-match-data ,@body)
|
||||
(goto-char (match-end 0))))
|
||||
(unless visited-p (kill-buffer (file-name-nondirectory ,file)))))
|
||||
(unless visited-p
|
||||
(kill-buffer to-be-removed))))
|
||||
|
||||
(defun org-babel-params-from-properties (&optional lang)
|
||||
"Return an association list of any source block params which
|
||||
|
|
Loading…
Reference in a new issue