Subject: bug#74792: 29.2.50; goto-address-mode should support RET in special-mode buffers

From: Juri Linkov <[email-masked]>
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.