Sorry, forgot to edit the subject to make it a patch. Patch attached here again for convenance.
Paul Bryan <[email protected]> writes: > Here's a patch for this. It's slightly different to the suggest fix > below, but does essentially the same thing. > > Cheers, > Paul. > >>> "Ben H. W." via "General discussions about Org-mode." >>> <[email protected]> writes: >>>> Suggested fix >>>> >>>> ┌──── >>>> │ (and (re-search-forward >>>> │ (concat " " (regexp-quote block-name) " ends here") nil t) >>>> │ (setq end (line-beginning-position))) >>>> └──── > > -- *Paul* 0001-lisp-ob-tangle.el-jump-to-org-when-tangled-code-bloc.patch: >From bcdc0a57f5073fa3d99cc4e6c528d1cee287a9ed Mon Sep 17 00:00:00 2001 From: Paul Bryan <[email protected]> Date: Wed, 24 Jun 2026 18:49:22 +1000 Subject: [PATCH] lisp/ob-tangle.el: Fix jump-to-org when tangled code block contains headlines lisp/ob-tangle.el (org-babel-tangle-jump-to-org): Fix jump-to-org when tangled code block contains headlines ============================================================================================================ TINYCHANGE Reported-by: Ben H. W. Link: <https://list.orgmode.org/[email protected]/> --- lisp/ob-tangle.el | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el index a8bc8c251..810a9c590 100644 --- a/lisp/ob-tangle.el +++ b/lisp/ob-tangle.el @@ -723,7 +723,8 @@ of the current buffer." "Jump from a tangled code file to the related Org mode file." (interactive) (let ((mid (point)) - start body-start end target-buffer target-char link block-name body) + (end 0) + start body-start target-buffer target-char link block-name body) (save-window-excursion (save-excursion (while (and (re-search-backward org-link-bracket-re nil t) @@ -733,12 +734,12 @@ of the current buffer." (setq link (match-string 0)) (setq block-name (match-string 2)) (save-excursion - (save-match-data - (re-search-forward - (concat " " (regexp-quote block-name) - " ends here") - nil t) - (setq end (line-beginning-position)))))))) + (if (save-match-data + (re-search-forward + (concat " " (regexp-quote block-name) + " ends here") + nil t)) + (setq end (line-beginning-position)))))))) (unless (and start (< start mid) (< mid end)) (error "Not in tangled code")) (setq body (buffer-substring body-start end))) -- 2.54.0 -- *Paul*
>From bcdc0a57f5073fa3d99cc4e6c528d1cee287a9ed Mon Sep 17 00:00:00 2001 From: Paul Bryan <[email protected]> Date: Wed, 24 Jun 2026 18:49:22 +1000 Subject: [PATCH] lisp/ob-tangle.el: Fix jump-to-org when tangled code block contains headlines * lisp/ob-tangle.el (org-babel-tangle-jump-to-org): Fix jump-to-org when tangled code block contains headlines TINYCHANGE Reported-by: Ben H. W. Link: https://list.orgmode.org/[email protected]/ --- lisp/ob-tangle.el | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el index a8bc8c251..810a9c590 100644 --- a/lisp/ob-tangle.el +++ b/lisp/ob-tangle.el @@ -723,7 +723,8 @@ of the current buffer." "Jump from a tangled code file to the related Org mode file." (interactive) (let ((mid (point)) - start body-start end target-buffer target-char link block-name body) + (end 0) + start body-start target-buffer target-char link block-name body) (save-window-excursion (save-excursion (while (and (re-search-backward org-link-bracket-re nil t) @@ -733,12 +734,12 @@ of the current buffer." (setq link (match-string 0)) (setq block-name (match-string 2)) (save-excursion - (save-match-data - (re-search-forward - (concat " " (regexp-quote block-name) - " ends here") - nil t) - (setq end (line-beginning-position)))))))) + (if (save-match-data + (re-search-forward + (concat " " (regexp-quote block-name) + " ends here") + nil t)) + (setq end (line-beginning-position)))))))) (unless (and start (< start mid) (< mid end)) (error "Not in tangled code")) (setq body (buffer-substring body-start end))) -- 2.54.0
