mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2025-02-05 21:26:18 +00:00
ob: ob-jump-to-org is more robust to link comment impostors
* lisp/ob-tangle.el (org-babel-tangle-jump-to-org): Ever wider searches until either a matching block is found, or the limits of the file are reached.
This commit is contained in:
parent
0dfde2da72
commit
c8e5ba90cc
@ -393,7 +393,7 @@ form
|
||||
(insert-comment
|
||||
(org-fill-template org-babel-tangle-comment-format-end link-data))))))
|
||||
|
||||
;; detangling functions
|
||||
;; dangling functions
|
||||
(defvar org-bracket-link-analytic-regexp)
|
||||
(defun org-babel-detangle (&optional source-code-file)
|
||||
"Propagate changes in source file back original to Org-mode file.
|
||||
@ -420,20 +420,24 @@ which enable the original code blocks to be found."
|
||||
"Jump from a tangled code file to the related Org-mode file."
|
||||
(interactive)
|
||||
(let ((mid (point))
|
||||
target-buffer target-char
|
||||
start end link path block-name body)
|
||||
start end done
|
||||
target-buffer target-char link path block-name body)
|
||||
(save-window-excursion
|
||||
(save-excursion
|
||||
(unless (and (re-search-backward org-bracket-link-analytic-regexp nil t)
|
||||
(setq start (point-at-eol))
|
||||
(setq link (match-string 0))
|
||||
(setq path (match-string 3))
|
||||
(setq block-name (match-string 5))
|
||||
(re-search-forward
|
||||
(concat " " (regexp-quote block-name) " ends here") nil t)
|
||||
(setq end (point-at-bol))
|
||||
(< start mid) (< mid end))
|
||||
(error "not in tangled code"))
|
||||
(while (and (re-search-backward org-bracket-link-analytic-regexp nil t)
|
||||
(not ; ever wider searches until matching block comments
|
||||
(and (setq start (point-at-eol))
|
||||
(setq link (match-string 0))
|
||||
(setq path (match-string 3))
|
||||
(setq block-name (match-string 5))
|
||||
(save-excursion
|
||||
(save-match-data
|
||||
(re-search-forward
|
||||
(concat " " (regexp-quote block-name)
|
||||
" ends here") nil t)
|
||||
(setq end (point-at-bol))))))))
|
||||
(unless (and start (< start mid) (< mid end))
|
||||
(error "not in tangled code"))
|
||||
(setq body (org-babel-trim (buffer-substring start end))))
|
||||
(when (string-match "::" path)
|
||||
(setq path (substring path 0 (match-beginning 0))))
|
||||
|
Loading…
x
Reference in New Issue
Block a user