"Jacob S. Gordon" <[email protected]> writes: > On 2026-05-22 10:49, Sacha Chua wrote: >> 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? > > 1+, I’ve noticed this too, mostly when narrowed to a subtree.
+1 Considering that refile targets are offered outside narrowing, it makes sense that we can jump there. >> 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. > > My preference would be to try to preserve it, i.e. if I start narrowed > then we should end up narrowed to the target subtree. For example, if > I start narrowed to ‘A’ or some region/block and jump to ‘B’, I’d like > to to end narrowed to ‘B’: > > * A > * B This may be tricky. You are not always narrowed to a subtree. Narrowing can be arbitrary. > Another perspective: I use ‘imenu’ to jump between headings within a > buffer (since it works in a /lot/ of places outside Org). It will > widen if the target is outside the narrowed region: > > (if (or (< position (point-min)) > (> position (point-max))) > ;; Widen if outside narrowing. > (widen)) > (goto-char position)) +1 Maybe we need something like org-goto-char that will do the above. It can be useful in multiple places, I think. -- Ihor Radchenko // yantar92, Org mode maintainer, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92>
