From b3a80c70bfca02287ca8ecdcba98cea170d9783b Mon Sep 17 00:00:00 2001 Message-ID: From: Ihor Radchenko Date: Sat, 6 Jul 2024 17:26:08 +0200 Subject: [PATCH] org-refile: Push point to Org mark ring before jumping * lisp/org-refile.el (org-refile): (org-refile-goto-last-stored): Save position to the Org mark ring if we are about to jump to a different position. * etc/ORG-NEWS (~org-refile~ now saves current position to Org mark ring when jumping to heading): Document the new feature. Link: https://orgmode.org/list/CAJcAo8vYLJ3YGH0+nZs1rgtdq2iRKzJ8tuGxJKRD-XyEwEm4FA@mail.gmail.com --- etc/ORG-NEWS | 8 +++++++- lisp/org-refile.el | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index b9f51667d..4e9d1bf8d 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -93,8 +93,14 @@ Runtime error near line 2: attempt to write a readonly database (8) [ Babel evaluation exited with code 1 ] #+end_example - ** Miscellaneous +*** ~org-refile~ now saves current position to Org mark ring when jumping to heading + +When ~org-refile~ is called with =C-u= or =C-u C-u= prefix argument +(to jump to heading or to jump to the last refiled heading), it saves +point to Org mark ring before jumping. Then, the user can return back +via ~org-mark-ring-goto~. + *** Trailing =-= is now allowed in plain links Previously, plain links like diff --git a/lisp/org-refile.el b/lisp/org-refile.el index c8e64903c..44361c143 100644 --- a/lisp/org-refile.el +++ b/lisp/org-refile.el @@ -544,6 +544,7 @@ (defun org-refile (&optional arg default-buffer rfloc msg) (setq nbuf (find-file-noselect file 'nowarn)) (if (and arg (not (equal arg 3))) (progn + (org-mark-ring-push) (pop-to-buffer-same-window nbuf) (goto-char (cond (pos) ((org-notes-order-reversed-p) (point-min)) @@ -634,6 +635,7 @@ (defun org-refile (&optional arg default-buffer rfloc msg) (defun org-refile-goto-last-stored () "Go to the location where the last refile was stored." (interactive) + (org-mark-ring-push) (bookmark-jump (plist-get org-bookmark-names-plist :last-refile)) (message "This is the location of the last refile")) -- 2.45.2