emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Patch proposal: display symbol source code in help buffers


From: Ihor Radchenko
Subject: Re: Patch proposal: display symbol source code in help buffers
Date: Fri, 01 Oct 2021 15:05:57 +0800

Lars Ingebrigtsen <larsi@gnus.org> writes:

> I was thinking something slightly more subtle.  That is, if we've just
> opened the file (i.e., it has not been displayed before), we should not
> push the mark.  And if point didn't move, we shouldn't push the mark
> either, I think.

I agree that there is not much reason to push mark when point does not
move.

I slightly disagree about the case of opening new file.  I personally
find it useful when the first element added to mark ring is BOB.  When
cycling across mark ring, BOB is a nice visual indication that I already
looked across the whole ring, especially if I am searching for mark that
is actually not in the mark ring (though I thought otherwise).

On the other hand, it is rather a matter of personal preference.  Not
pushing BOB to mark ring might be a better default.  Even if it not, we
would probably need to change other places across the code to add BOB
consistently.  That's a whole other discussion.

See the updated patch.  Hopefully I got the news entry for Emacs 29.1
right.

Best,
Ihor

>From e8d71f7e9fe111965f81b8627f27530d2ce80048 Mon Sep 17 00:00:00 2001
Message-Id: 
<e8d71f7e9fe111965f81b8627f27530d2ce80048.1633071433.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]