GNU bug report logs - #74792
29.2.50; goto-address-mode should support RET in special-mode buffers

Previous Next

Package: emacs;

Reported by: Spencer Baugh <sbaugh <at> janestreet.com>

Date: Wed, 11 Dec 2024 16:12:01 UTC

Severity: normal

Found in version 29.2.50

To reply to this bug, email your comments to 74792 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#74792; Package emacs. (Wed, 11 Dec 2024 16:12:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Spencer Baugh <sbaugh <at> janestreet.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 11 Dec 2024 16:12:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Spencer Baugh <sbaugh <at> janestreet.com>
To: bug-gnu-emacs <at> gnu.org
Cc: dmitry <at> gutov.dev
Subject: 29.2.50; goto-address-mode should support RET in special-mode buffers
Date: Wed, 11 Dec 2024 11:10:53 -0500
goto-address-mode binds C-c RET to goto-address-at-point when point is
on a URL or email address.  In special-mode buffers (or maybe any
read-only buffer?) it should also bind RET while point is on the URL or
email address.

This would improve functionality for packages which create special-mode
buffers showing arbitrary text that may contain URLs.

For example, commit messages may contain URLs, and enabling
goto-message-mode in vc-log buffers highlights those URLs, but RET
doesn't work to follow them.  Similarly, magit enables goto-address-mode
in buffers showing a commit message, but it implements separate handling
for RET on URLs since goto-address-mode doesn't provide that as a
binding.

This could be done with an extended-menu-item binding with a filter
which checks (derived-mode-p 'special-mode), but maybe there's a better
way?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#74792; Package emacs. (Wed, 11 Dec 2024 17:10:03 GMT) Full text and rfc822 format available.

Message #8 received at 74792 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Spencer Baugh <sbaugh <at> janestreet.com>
Cc: dmitry <at> gutov.dev, 74792 <at> debbugs.gnu.org
Subject: Re: bug#74792: 29.2.50;
 goto-address-mode should support RET in special-mode buffers
Date: Wed, 11 Dec 2024 19:09:27 +0200
> Cc: dmitry <at> gutov.dev
> Date: Wed, 11 Dec 2024 11:10:53 -0500
> From:  Spencer Baugh via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> 
> 
> goto-address-mode binds C-c RET to goto-address-at-point when point is
> on a URL or email address.  In special-mode buffers (or maybe any
> read-only buffer?) it should also bind RET while point is on the URL or
> email address.

I don't think it's a good idea, since many special-mode descendants
bind RET to useful commands.  For goto-address-at-point to override
that would be a nuisance, I think.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#74792; Package emacs. (Wed, 11 Dec 2024 17:41:02 GMT) Full text and rfc822 format available.

Message #11 received at 74792 <at> debbugs.gnu.org (full text, mbox):

From: Spencer Baugh <sbaugh <at> janestreet.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Dmitry Gutov <dmitry <at> gutov.dev>, 74792 <at> debbugs.gnu.org
Subject: Re: bug#74792: 29.2.50; goto-address-mode should support RET in
 special-mode buffers
Date: Wed, 11 Dec 2024 12:39:59 -0500
[Message part 1 (text/plain, inline)]
On Wed, Dec 11, 2024, 12:09 PM Eli Zaretskii <eliz <at> gnu.org> wrote:

> > Cc: dmitry <at> gutov.dev
> > Date: Wed, 11 Dec 2024 11:10:53 -0500
> > From:  Spencer Baugh via "Bug reports for GNU Emacs,
> >  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> >
> >
> > goto-address-mode binds C-c RET to goto-address-at-point when point is
> > on a URL or email address.  In special-mode buffers (or maybe any
> > read-only buffer?) it should also bind RET while point is on the URL or
> > email address.
>
> I don't think it's a good idea, since many special-mode descendants
> bind RET to useful commands.  For goto-address-at-point to override
> that would be a nuisance, I think.
>

True, but when I've specifically moved point to a URL it is usually because
I want to follow the URL, not do whatever is bound to RET in the mode.

But this sounds like something that may differ between users, so perhaps we
could add this controlled by a defcustom?

>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#74792; Package emacs. (Wed, 11 Dec 2024 18:59:02 GMT) Full text and rfc822 format available.

Message #14 received at 74792 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Spencer Baugh <sbaugh <at> janestreet.com>
Cc: dmitry <at> gutov.dev, 74792 <at> debbugs.gnu.org
Subject: Re: bug#74792: 29.2.50; goto-address-mode should support RET in
 special-mode buffers
Date: Wed, 11 Dec 2024 20:55:41 +0200
> From: Spencer Baugh <sbaugh <at> janestreet.com>
> Date: Wed, 11 Dec 2024 12:39:59 -0500
> Cc: 74792 <at> debbugs.gnu.org, Dmitry Gutov <dmitry <at> gutov.dev>
> 
> On Wed, Dec 11, 2024, 12:09 PM Eli Zaretskii <eliz <at> gnu.org> wrote:
> 
>  > Cc: dmitry <at> gutov.dev
>  > Date: Wed, 11 Dec 2024 11:10:53 -0500
>  > From:  Spencer Baugh via "Bug reports for GNU Emacs,
>  >  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>  > 
>  > 
>  > goto-address-mode binds C-c RET to goto-address-at-point when point is
>  > on a URL or email address.  In special-mode buffers (or maybe any
>  > read-only buffer?) it should also bind RET while point is on the URL or
>  > email address.
> 
>  I don't think it's a good idea, since many special-mode descendants
>  bind RET to useful commands.  For goto-address-at-point to override
>  that would be a nuisance, I think.
> 
> True, but when I've specifically moved point to a URL it is usually because I want to follow the URL, not do
> whatever is bound to RET in the mode.

You cannot know that.  E.g., point could be on a URL by chance, for
example, if a buffer starts with a URL.

> But this sounds like something that may differ between users, so perhaps we could add this controlled by a
> defcustom?

Let's first hear that enough people here think that it might sometimes
be a good thing.  If so, then yes, a user option, by default off,
could be a way to introduce such behavior.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#74792; Package emacs. (Thu, 12 Dec 2024 16:46:05 GMT) Full text and rfc822 format available.

Message #17 received at 74792 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Spencer Baugh <sbaugh <at> janestreet.com>, 74792 <at> debbugs.gnu.org,
 dmitry <at> gutov.dev
Subject: Re: bug#74792: 29.2.50; goto-address-mode should support RET in
 special-mode buffers
Date: Thu, 12 Dec 2024 18:35:18 +0200
>>  > goto-address-mode binds C-c RET to goto-address-at-point when point is
>>  > on a URL or email address.  In special-mode buffers (or maybe any
>>  > read-only buffer?) it should also bind RET while point is on the URL or
>>  > email address.
>> 
>>  I don't think it's a good idea, since many special-mode descendants
>>  bind RET to useful commands.  For goto-address-at-point to override
>>  that would be a nuisance, I think.
>> 
>> True, but when I've specifically moved point to a URL it is usually because I want to follow the URL, not do
>> whatever is bound to RET in the mode.
>
> You cannot know that.  E.g., point could be on a URL by chance, for
> example, if a buffer starts with a URL.
>
>> But this sounds like something that may differ between users, so perhaps we could add this controlled by a
>> defcustom?
>
> Let's first hear that enough people here think that it might sometimes
> be a good thing.  If so, then yes, a user option, by default off,
> could be a way to introduce such behavior.

Typing just RET would be more intuitive, but indeed there is a problem
that e.g. 'C-h C-t RET RET RET ...' will scroll lines one by one
until this line becomes current:

  https://www.gnu.org/licenses/why-assign.html

Then RET will surprisingly visit that URL.

Unfortunately, an option can't help because most users might want to
enable it, but only if it doesn't misfire in unexpected situations.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#74792; Package emacs. (Thu, 12 Dec 2024 20:48:01 GMT) Full text and rfc822 format available.

Message #20 received at 74792 <at> debbugs.gnu.org (full text, mbox):

From: Spencer Baugh <sbaugh <at> janestreet.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: dmitry <at> gutov.dev, Eli Zaretskii <eliz <at> gnu.org>, 74792 <at> debbugs.gnu.org
Subject: Re: bug#74792: 29.2.50; goto-address-mode should support RET in
 special-mode buffers
Date: Thu, 12 Dec 2024 15:47:12 -0500
Juri Linkov <juri <at> linkov.net> writes:

>>>  > goto-address-mode binds C-c RET to goto-address-at-point when point is
>>>  > on a URL or email address.  In special-mode buffers (or maybe any
>>>  > read-only buffer?) it should also bind RET while point is on the URL or
>>>  > email address.
>>> 
>>>  I don't think it's a good idea, since many special-mode descendants
>>>  bind RET to useful commands.  For goto-address-at-point to override
>>>  that would be a nuisance, I think.
>>> 
>>> True, but when I've specifically moved point to a URL it is usually because I want to follow the URL, not do
>>> whatever is bound to RET in the mode.
>>
>> You cannot know that.  E.g., point could be on a URL by chance, for
>> example, if a buffer starts with a URL.
>>
>>> But this sounds like something that may differ between users, so perhaps we could add this controlled by a
>>> defcustom?
>>
>> Let's first hear that enough people here think that it might sometimes
>> be a good thing.  If so, then yes, a user option, by default off,
>> could be a way to introduce such behavior.
>
> Typing just RET would be more intuitive, but indeed there is a problem
> that e.g. 'C-h C-t RET RET RET ...' will scroll lines one by one
> until this line becomes current:
>
>   https://www.gnu.org/licenses/why-assign.html
>
> Then RET will surprisingly visit that URL.
>
> Unfortunately, an option can't help because most users might want to
> enable it, but only if it doesn't misfire in unexpected situations.

True.  Perhaps it should be enabled buffer-locally, then.  Then a user
can set it in a major-mode hook - and if a major-mode does not bind RET
to something else, the major-mode can just enable it.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#74792; Package emacs. (Thu, 12 Dec 2024 23:22:03 GMT) Full text and rfc822 format available.

Message #23 received at 74792 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dmitry <at> gutov.dev>
To: Eli Zaretskii <eliz <at> gnu.org>, Spencer Baugh <sbaugh <at> janestreet.com>
Cc: 74792 <at> debbugs.gnu.org
Subject: Re: bug#74792: 29.2.50; goto-address-mode should support RET in
 special-mode buffers
Date: Fri, 13 Dec 2024 01:20:45 +0200
On 11/12/2024 20:55, Eli Zaretskii wrote:

>>   > goto-address-mode binds C-c RET to goto-address-at-point when point is
>>   > on a URL or email address.  In special-mode buffers (or maybe any
>>   > read-only buffer?) it should also bind RET while point is on the URL or
>>   > email address.
>>
>>   I don't think it's a good idea, since many special-mode descendants
>>   bind RET to useful commands.  For goto-address-at-point to override
>>   that would be a nuisance, I think.
>>
>> True, but when I've specifically moved point to a URL it is usually because I want to follow the URL, not do
>> whatever is bound to RET in the mode.
> 
> You cannot know that.  E.g., point could be on a URL by chance, for
> example, if a buffer starts with a URL.

I also regularly try RET in such cases, notice it does not work, and 
then have to reach for the mouse. Just not often enough to look up and 
remember the alternative.

>> But this sounds like something that may differ between users, so perhaps we could add this controlled by a
>> defcustom?
> 
> Let's first hear that enough people here think that it might sometimes
> be a good thing.  If so, then yes, a user option, by default off,
> could be a way to introduce such behavior.

The same option could affect other "C-c RET" bindings as well, such as 
browse-url-button-open in ansi-osc-hyperlink-map and 
bug-reference-push-button in bug-reference-map.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#74792; Package emacs. (Fri, 13 Dec 2024 07:38:01 GMT) Full text and rfc822 format available.

Message #26 received at 74792 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Spencer Baugh <sbaugh <at> janestreet.com>
Cc: dmitry <at> gutov.dev, Eli Zaretskii <eliz <at> gnu.org>, 74792 <at> debbugs.gnu.org
Subject: Re: bug#74792: 29.2.50; goto-address-mode should support RET in
 special-mode buffers
Date: Fri, 13 Dec 2024 09:31:49 +0200
>> Typing just RET would be more intuitive, but indeed there is a problem
>> that e.g. 'C-h C-t RET RET RET ...' will scroll lines one by one
>> until this line becomes current:
>>
>>   https://www.gnu.org/licenses/why-assign.html
>>
>> Then RET will surprisingly visit that URL.
>>
>> Unfortunately, an option can't help because most users might want to
>> enable it, but only if it doesn't misfire in unexpected situations.
>
> True.  Perhaps it should be enabled buffer-locally, then.  Then a user
> can set it in a major-mode hook - and if a major-mode does not bind RET
> to something else, the major-mode can just enable it.

This means disabling RET on links in etc/TODO and all other
link-rich files that use 'view-help-file':

(defun describe-distribution ()
  "Display info on how to obtain the latest version of GNU Emacs."
  (interactive)
  (view-help-file "DISTRIB"))

(defun describe-copying ()
  "Display info on how you may redistribute copies of GNU Emacs."
  (interactive)
  (view-help-file "COPYING"))

(defun view-emacs-problems ()
  "Display info on known problems with Emacs and possible workarounds."
  (interactive)
  (view-help-file "PROBLEMS"))

(defun view-emacs-debugging ()
  "Display info on how to debug Emacs problems."
  (interactive)
  (view-help-file "DEBUG"))

For a long time I had been using RET to scroll by one line in Info:

  (define-key Info-mode-map [return]
    (lambda ()
      (interactive)
      (if nil ;; TODO: add predicate to check if point is on Info refs
          (Info-follow-nearest-node)
        (View-scroll-line-forward))))

But still can't find a predicate that would prevent RET from visiting
a reference only when the cursor moves to it while scrolling.
And don't believe this is possible.  So need to use other
less intuitive keys to visit links.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#74792; Package emacs. (Mon, 16 Dec 2024 17:57:01 GMT) Full text and rfc822 format available.

Message #29 received at 74792 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Spencer Baugh <sbaugh <at> janestreet.com>
Cc: dmitry <at> gutov.dev, Eli Zaretskii <eliz <at> gnu.org>, 74792 <at> debbugs.gnu.org
Subject: Re: bug#74792: 29.2.50; goto-address-mode should support RET in
 special-mode buffers
Date: Mon, 16 Dec 2024 19:54:43 +0200
> For a long time I had been using RET to scroll by one line in Info:
>
>   (define-key Info-mode-map [return]
>     (lambda ()
>       (interactive)
>       (if nil ;; TODO: add predicate to check if point is on Info refs
>           (Info-follow-nearest-node)
>         (View-scroll-line-forward))))
>
> But still can't find a predicate that would prevent RET from visiting
> a reference only when the cursor moves to it while scrolling.
> And don't believe this is possible.  So need to use other
> less intuitive keys to visit links.

I forgot about other futile attempts to find a suitable heuristic:

  (define-key gnus-article-mode-map [return] 'my-gnus-article-press-or-scroll)
  (defun my-gnus-article-press-or-scroll ()
    (interactive)
    ;; When point is at the bottom of the window while scrolling
    (if (eq (point) (save-excursion (move-to-window-line -1) (point)))
        (View-scroll-line-forward)
      (gnus-article-press-button)))

Here the button is pressed when point is not at the bottom,
because point moves to the bottom while scrolling.
But in `emacs -Q` I see that point remains at the top
while scrolling.  So this behavior depends on customization.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#74792; Package emacs. (Tue, 01 Apr 2025 22:21:02 GMT) Full text and rfc822 format available.

Message #32 received at 74792 <at> debbugs.gnu.org (full text, mbox):

From: Spencer Baugh <sbaugh <at> janestreet.com>
To: 74792 <at> debbugs.gnu.org
Cc: dmitry <at> gutov.dev, Eli Zaretskii <eliz <at> gnu.org>,
 Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#74792: 29.2.50; goto-address-mode should support RET in
 special-mode buffers
Date: Tue, 01 Apr 2025 18:20:15 -0400
As a more broad change which might also be useful, it would be nice if
there was a way to get goto-address-mode to use button.el buttons
instead of its own custom overlays.  Or perhaps to use wid-edit.el
widgets.

I say this because if I have:
- A buffer that has buttons or widgets
- where TAB is bound to button-forward or widget-forward to navigate
  between buttons,
- and which also contains some arbitrary stretches of text (e.g. commit messages)
- and which wants to make URLs in that text clickable

It would be nice to be able to use goto-address-mode to do this.  But it
would also be nice if goto-address-mode made the URLs into button.el
buttons or widgets, so that TAB navigated to the URLs too.

Perhaps this is just something the individual major mode should
implement, though?  But maybe there's some opportunity for sharing some
code to do the task "turn some text matching a regex into a
button/widget"?





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#74792; Package emacs. (Fri, 04 Apr 2025 06:53:01 GMT) Full text and rfc822 format available.

Message #35 received at 74792 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Spencer Baugh <sbaugh <at> janestreet.com>
Cc: dmitry <at> gutov.dev, 74792 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#74792: 29.2.50; goto-address-mode should support RET in
 special-mode buffers
Date: Fri, 04 Apr 2025 09:51:14 +0300
> As a more broad change which might also be useful, it would be nice if
> there was a way to get goto-address-mode to use button.el buttons
> instead of its own custom overlays.  Or perhaps to use wid-edit.el
> widgets.
>
> I say this because if I have:
> - A buffer that has buttons or widgets
> - where TAB is bound to button-forward or widget-forward to navigate
>   between buttons,
> - and which also contains some arbitrary stretches of text (e.g. commit messages)
> - and which wants to make URLs in that text clickable
>
> It would be nice to be able to use goto-address-mode to do this.  But it
> would also be nice if goto-address-mode made the URLs into button.el
> buttons or widgets, so that TAB navigated to the URLs too.
>
> Perhaps this is just something the individual major mode should
> implement, though?  But maybe there's some opportunity for sharing some
> code to do the task "turn some text matching a regex into a
> button/widget"?

Allowing TAB to navigate to the next URL would be nice.
I don't know how easy is to add button.el buttons to goto-addr.el.
Alternatively, goto-address-highlight-keymap could have
a goto-address specific command to go to the next
'goto-address' overlay.




This bug report was last modified 74 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.