all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: Eli Zaretskii <eliz@gnu.org>,
	Stefan Kangas <stefankangas@gmail.com>,
	arthur.miller@live.com, emacs-devel@gnu.org
Subject: Re: Patch proposal: display symbol source code in help buffers
Date: Fri, 01 Oct 2021 15:05:57 +0800	[thread overview]
Message-ID: <87wnmxcjhm.fsf@localhost> (raw)
In-Reply-To: <87ee9h27rm.fsf@gnus.org>

[-- Attachment #1: Type: text/plain, Size: 1062 bytes --]

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Save-position-in-mark-ring-before-jumping-to-definit.patch --]
[-- Type: text/x-diff, Size: 1763 bytes --]

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.
 
 \f
 * 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.
 
 \f
 * 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	other threads:[~2021-10-01  7:05 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-19 19:50 Patch proposal: display symbol source code in help buffers Arthur Miller
2021-09-20  5:46 ` Lars Ingebrigtsen
2021-09-20  6:09   ` Stefan Kangas
2021-09-20  6:14     ` Lars Ingebrigtsen
2021-09-20  7:17       ` Ihor Radchenko
2021-09-20  7:43         ` Stefan Kangas
2021-09-20  8:29           ` martin rudalics
2021-09-20  9:04           ` Ihor Radchenko
2021-09-20 23:45             ` Arthur Miller
2021-09-21  4:16             ` Lars Ingebrigtsen
2021-09-21  6:59               ` Ihor Radchenko
2021-09-21  7:41                 ` Stefan Kangas
2021-09-21  8:38                   ` Eli Zaretskii
2021-09-21  9:17                     ` Ihor Radchenko
2021-09-21 16:49                       ` Lars Ingebrigtsen
2021-10-01  7:05                         ` Ihor Radchenko [this message]
2021-10-01  7:09                           ` Lars Ingebrigtsen
2021-10-01  7:21                             ` Ihor Radchenko
2021-10-01  7:21                               ` Lars Ingebrigtsen
2021-10-01  9:04                                 ` Ihor Radchenko
2021-10-01 12:20                                   ` Lars Ingebrigtsen
2021-10-01  7:24                           ` Eli Zaretskii
2021-10-01  9:08                             ` Ihor Radchenko
2021-10-01 10:24                               ` Eli Zaretskii
2021-10-01 14:14                                 ` Ihor Radchenko
2021-09-21  8:34               ` martin rudalics
2021-09-20 15:01           ` Arthur Miller
2021-09-21  7:41             ` Stefan Kangas
2021-09-20 15:27         ` Arthur Miller
2021-09-20  6:47     ` Eli Zaretskii
2021-09-20 15:27       ` Arthur Miller
2021-09-20 14:55     ` Arthur Miller
2021-09-21  4:18       ` Lars Ingebrigtsen
2021-09-21 10:26         ` Arthur Miller
2021-09-20 15:23   ` Arthur Miller
2021-09-20  5:59 ` Eli Zaretskii
2021-09-20  6:37   ` Gregor Zattler
2021-09-20  7:01     ` Eli Zaretskii
2021-09-20 15:21       ` Arthur Miller
2021-09-20  8:21     ` martin rudalics
2021-09-20 18:13       ` Arthur Miller
2021-09-21  8:34         ` martin rudalics
2021-09-21 10:24           ` Arthur Miller
2021-09-21 16:52             ` martin rudalics
2021-09-21 18:56               ` Arthur Miller
2021-09-21 17:30           ` Juri Linkov
2021-09-21 19:13             ` Arthur Miller
2021-09-22  7:49               ` martin rudalics
2021-09-22 16:04                 ` Juri Linkov
2021-09-22 17:52                   ` martin rudalics
2021-09-23  8:15                     ` martin rudalics
2021-09-23 15:52                       ` Juri Linkov
2021-09-26  9:10                         ` martin rudalics
2021-09-22 22:38                 ` Arthur Miller
2021-09-23  8:22                   ` martin rudalics
2021-09-20 12:19     ` Dmitry Gutov
2021-09-20 15:13       ` Arthur Miller
2021-09-20 15:11   ` Arthur Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wnmxcjhm.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=arthur.miller@live.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=larsi@gnus.org \
    --cc=stefankangas@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.