From e8d71f7e9fe111965f81b8627f27530d2ce80048 Mon Sep 17 00:00:00 2001 Message-Id: From: Ihor Radchenko Date: Fri, 1 Oct 2021 14:56:43 +0800 Subject: [PATCH] Save position in mark ring before jumping to definition * lisp/help-mode.el (help-function-def--button-function): Current point is saved in the mark ring before jumping to definition. Following up: https://lists.gnu.org/archive/html/emacs-devel/2021-09/msg01561.html --- etc/NEWS | 3 +++ lisp/help-mode.el | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/etc/NEWS b/etc/NEWS index d0e41baaeb..1dfcc1ae09 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -29,6 +29,9 @@ applies, and please also update docstrings as needed. * Changes in Emacs 29.1 +** Help +*** Jumping to function/variable source now saves mark before moving point +Jumping to source from "*Help*" buffer moves the point when the source buffer is already open. Now, the old point is pushed to mark ring. * Editing Changes in Emacs 29.1 diff --git a/lisp/help-mode.el b/lisp/help-mode.el index 0b404fe89f..0dc4229006 100644 --- a/lisp/help-mode.el +++ b/lisp/help-mode.el @@ -273,6 +273,11 @@ help-function-def--button-function (when (or (< position (point-min)) (> position (point-max))) (widen)) + ;; Save mark for the old location, unless we just opened + ;; the buffer or the point is not actually going to move. + (unless (or (= 1 (point)) + (= (point) position)) + (push-mark nil t)) (goto-char position)) (message "Unable to find location in file"))))) -- 2.32.0