Hello all! Has anyone else noticed that if you are currently narrowed to a region and then you use C-u org-refile to jump to a heading that is in the same buffer but outside your current narrowing, it doesn't move your point because (goto-char ...) with a position outside your narrowed region just takes you to either the point-min or point-max?
It came up for me because I've been using org-narrow-to-subtree to focus, I also have some hooks so that jumping to a heading narrows to just that thing. I often like to use C-u C-c r (my shortcut for org-refile) to jump to related things in other subtrees. I tried searching the list for "org-refile when narrowed" (https://list.orgmode.org/?q=org-refile+when+narrowed), but I didn't spot anything particularly relevant. I'm not entirely sure what the correct behaviour should be. Maybe it's good that it respects narrowing, maybe people might expect it to jump to the un-narrowed part. I want to get it to widen first and then jump to the part I want, which necessitates tinkering with the innards of org-refile since I don't want to unconditionally widen. This isn't a formal patch yet, just wanted to sketch things out in case other people had thoughts. How should Org Mode behave in this situation? (org-refile jump while narrowed to something else) Sacha --- /tmp/git-blob-G7gNMi/org-refile.el 2026-05-22 10:40:22.596758106 -0400 +++ lisp/org-refile.el 2026-05-22 10:40:22.571758073 -0400 @@ -486,6 +486,7 @@ ((equal arg 3) "Refile (and keep)") (t "Refile"))) (regionp (org-region-active-p)) + (previous-buffer (current-buffer)) (region-start (and regionp (region-beginning))) (region-end (and regionp (region-end))) (org-refile-keep (if (equal arg 3) t org-refile-keep)) @@ -553,9 +554,14 @@ (progn (org-mark-ring-push) (pop-to-buffer-same-window nbuf) - (goto-char (cond (pos) + (let ((new-pos (cond (pos) ((org-notes-order-reversed-p) (point-min)) - (t (point-max)))) + (t (point-max))))) + (when (and (eq nbuf previous-buffer) + (or (< new-pos (point-min)) + (> new-pos (point-max)))) + (widen)) + (goto-char new-pos)) (org-fold-show-context 'org-goto)) (if regionp (progn
