GNU bug report logs - #71117
30.0.50; output of describe-function

Previous Next

Package: emacs;

Reported by: Andreas Röhler <andreas.roehler <at> easy-emacs.de>

Date: Wed, 22 May 2024 13:54:01 UTC

Severity: normal

Found in version 30.0.50

Done: Andrea Corallo <acorallo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 71117 in the body.
You can then email your comments to 71117 AT debbugs.gnu.org in the normal way.

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#71117; Package emacs. (Wed, 22 May 2024 13:54:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Andreas Röhler <andreas.roehler <at> easy-emacs.de>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 22 May 2024 13:54:02 GMT) Full text and rfc822 format available.

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

From: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.0.50; output of describe-function
Date: Wed, 22 May 2024 15:53:07 +0200
Hi,

often use ‘C-h f’, i.e. ‘describe-function’, in order to jump onto the 
source code.

Which is done afterwards by a command calling ‘(switch-to-buffer 
(other-buffer))’ followed by TAB, RET.

With recent Emacs, calling for example ‘C-h f list RET’, appears

"list is a ‘primitive-function’ in ‘C source code’".

Now the first active button is ‘primitive-function’, which is rather 
basic and seldom of interest. So I have to tab twice - and by habit 
often get the first, wrong one...

May it be possible to switch the button, like:

"list is defined in ‘C source code’, a ‘primitive-function’".

---

Thanks,
Andreas

GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, 
cairo version 1.16.0) of 2024-05-21





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#71117; Package emacs. (Wed, 22 May 2024 14:12:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Andreas Röhler <andreas.roehler <at> easy-emacs.de>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 71117 <at> debbugs.gnu.org
Subject: Re: bug#71117: 30.0.50; output of describe-function
Date: Wed, 22 May 2024 17:10:45 +0300
> Date: Wed, 22 May 2024 15:53:07 +0200
> From: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
> 
> often use ‘C-h f’, i.e. ‘describe-function’, in order to jump onto the 
> source code.
> 
> Which is done afterwards by a command calling ‘(switch-to-buffer 
> (other-buffer))’ followed by TAB, RET.
> 
> With recent Emacs, calling for example ‘C-h f list RET’, appears
> 
> "list is a ‘primitive-function’ in ‘C source code’".
> 
> Now the first active button is ‘primitive-function’, which is rather 
> basic and seldom of interest. So I have to tab twice - and by habit 
> often get the first, wrong one...
> 
> May it be possible to switch the button, like:
> 
> "list is defined in ‘C source code’, a ‘primitive-function’".

I guess nothing is ever good enough, sigh...

Adding Stefan.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#71117; Package emacs. (Wed, 22 May 2024 17:48:02 GMT) Full text and rfc822 format available.

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

From: Kévin Le Gouguec <kevin.legouguec <at> gmail.com>
To: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
Cc: 71117 <at> debbugs.gnu.org
Subject: Re: bug#71117: 30.0.50; output of describe-function
Date: Wed, 22 May 2024 19:46:09 +0200
Andreas Röhler <andreas.roehler <at> easy-emacs.de> writes:

> Hi,
>
> often use ‘C-h f’, i.e. ‘describe-function’, in order to jump onto the source code.
>
> Which is done afterwards by a command calling ‘(switch-to-buffer (other-buffer))’ followed by TAB, RET.
>
> With recent Emacs, calling for example ‘C-h f list RET’, appears
>
> "list is a ‘primitive-function’ in ‘C source code’".
>
> Now the first active button is ‘primitive-function’, which is rather basic and seldom of interest. So I have to tab twice - and by habit often get the first, wrong one...
>
> May it be possible to switch the button, like:
>
> "list is defined in ‘C source code’, a ‘primitive-function’".

Might you be interested in 's', bound to 'help-view-source'?  Won't
solve the "force-of-habit" problem, but I find it rather convenient: no
need to TAB to the button; hopefully future-proof as redesigns wash over
*Help*.  I've found it worth the brain re-wiring.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#71117; Package emacs. (Wed, 22 May 2024 18:26:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Kévin Le Gouguec <kevin.legouguec <at> gmail.com>
Cc: 71117 <at> debbugs.gnu.org, andreas.roehler <at> easy-emacs.de
Subject: Re: bug#71117: 30.0.50; output of describe-function
Date: Wed, 22 May 2024 21:24:58 +0300
> Cc: 71117 <at> debbugs.gnu.org
> From: Kévin Le Gouguec <kevin.legouguec <at> gmail.com>
> Date: Wed, 22 May 2024 19:46:09 +0200
> 
> Andreas Röhler <andreas.roehler <at> easy-emacs.de> writes:
> 
> > Now the first active button is ‘primitive-function’, which is rather basic and seldom of interest. So I have to tab twice - and by habit often get the first, wrong one...
> >
> > May it be possible to switch the button, like:
> >
> > "list is defined in ‘C source code’, a ‘primitive-function’".
> 
> Might you be interested in 's', bound to 'help-view-source'?

Which reminds me that we still don't have a "C-h SOMETHING" binding
that would go to the source without the need to switch to the *Help*
buffer.  At one time we discussed something like that, and I thought
we actually installed it, but I guess I was dreaming, because I cannot
find it...

Any takers?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#71117; Package emacs. (Wed, 22 May 2024 22:24:01 GMT) Full text and rfc822 format available.

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

From: Kévin Le Gouguec <kevin.legouguec <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 71117 <at> debbugs.gnu.org, andreas.roehler <at> easy-emacs.de
Subject: Re: bug#71117: 30.0.50; output of describe-function
Date: Thu, 23 May 2024 00:22:10 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

>> Cc: 71117 <at> debbugs.gnu.org
>> From: Kévin Le Gouguec <kevin.legouguec <at> gmail.com>
>> Date: Wed, 22 May 2024 19:46:09 +0200
>> 
>> Andreas Röhler <andreas.roehler <at> easy-emacs.de> writes:
>> 
>> > Now the first active button is ‘primitive-function’, which is rather basic and seldom of interest. So I have to tab twice - and by habit often get the first, wrong one...
>> >
>> > May it be possible to switch the button, like:
>> >
>> > "list is defined in ‘C source code’, a ‘primitive-function’".
>> 
>> Might you be interested in 's', bound to 'help-view-source'?
>
> Which reminds me that we still don't have a "C-h SOMETHING" binding
> that would go to the source without the need to switch to the *Help*
> buffer.  At one time we discussed something like that, and I thought
> we actually installed it, but I guess I was dreaming, because I cannot
> find it...

Were you thinking of a command that specifically targets the symbol from
a displayed *Help* buffer, so the user would do e.g.

C-h v VAR RET   ; shows *Help* for VAR
C-h SOMETHING   ; finds source for VAR

where C-h SOMETHING's implementation would do (a smarter version of)
(with-current-buffer "*Help*"
  (help-view-source))

?  Can't say I remember such a command; otherwise, I'm reminded of
find-func's find-function-setup-keys, which installs a bunch of
upper-case bindings on the C-x map (resp. C-x [45] maps) to invoke the
find-* commands (resp. find-*-other-{window,frame}).

> Any takers?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#71117; Package emacs. (Thu, 23 May 2024 05:27:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Kévin Le Gouguec <kevin.legouguec <at> gmail.com>
Cc: 71117 <at> debbugs.gnu.org, andreas.roehler <at> easy-emacs.de
Subject: Re: bug#71117: 30.0.50; output of describe-function
Date: Thu, 23 May 2024 08:25:45 +0300
> From: Kévin Le Gouguec <kevin.legouguec <at> gmail.com>
> Cc: andreas.roehler <at> easy-emacs.de,  71117 <at> debbugs.gnu.org
> Date: Thu, 23 May 2024 00:22:10 +0200
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> > Which reminds me that we still don't have a "C-h SOMETHING" binding
> > that would go to the source without the need to switch to the *Help*
> > buffer.  At one time we discussed something like that, and I thought
> > we actually installed it, but I guess I was dreaming, because I cannot
> > find it...
> 
> Were you thinking of a command that specifically targets the symbol from
> a displayed *Help* buffer, so the user would do e.g.
> 
> C-h v VAR RET   ; shows *Help* for VAR
> C-h SOMETHING   ; finds source for VAR
> 
> where C-h SOMETHING's implementation would do (a smarter version of)
> (with-current-buffer "*Help*"
>   (help-view-source))
> 
> ?

Yes, exactly.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#71117; Package emacs. (Thu, 23 May 2024 06:31:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Kévin Le Gouguec <kevin.legouguec <at> gmail.com>
Cc: 71117 <at> debbugs.gnu.org,
 Andreas Röhler <andreas.roehler <at> easy-emacs.de>
Subject: Re: bug#71117: 30.0.50; output of describe-function
Date: Thu, 23 May 2024 09:28:46 +0300
>> May it be possible to switch the button, like:
>>
>> "list is defined in ‘C source code’, a ‘primitive-function’".
>
> Might you be interested in 's', bound to 'help-view-source'?  Won't
> solve the "force-of-habit" problem, but I find it rather convenient: no
> need to TAB to the button; hopefully future-proof as redesigns wash over
> *Help*.  I've found it worth the brain re-wiring.

Except there is a bug that prevents 's' from handling some C variables, e.g.:

0. emacs -Q
1. C-h v minibuffer-allow-text-properties RET
2. s

fails with

  (error "Don’t know where ‘minibuffer-allow-text-properties’ is defined")

So still need to use 'TAB RET' to navigate to C source.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#71117; Package emacs. (Thu, 23 May 2024 11:52:01 GMT) Full text and rfc822 format available.

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

From: Eshel Yaron <me <at> eshelyaron.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: 71117 <at> debbugs.gnu.org,
 Andreas Röhler <andreas.roehler <at> easy-emacs.de>,
 Kévin Le Gouguec <kevin.legouguec <at> gmail.com>
Subject: Re: bug#71117: 30.0.50; output of describe-function
Date: Thu, 23 May 2024 13:51:02 +0200
Hi Juri,

Juri Linkov <juri <at> linkov.net> writes:

>>> May it be possible to switch the button, like:
>>>
>>> "list is defined in ‘C source code’, a ‘primitive-function’".
>>
>> Might you be interested in 's', bound to 'help-view-source'?  Won't
>> solve the "force-of-habit" problem, but I find it rather convenient: no
>> need to TAB to the button; hopefully future-proof as redesigns wash over
>> *Help*.  I've found it worth the brain re-wiring.
>
> Except there is a bug that prevents 's' from handling some C variables, e.g.:
>
> 0. emacs -Q
> 1. C-h v minibuffer-allow-text-properties RET
> 2. s
>
> fails with
>
>   (error "Don’t know where ‘minibuffer-allow-text-properties’ is defined")
>
> So still need to use 'TAB RET' to navigate to C source.

That bothered me too.  Does this patch help?

diff --git a/lisp/help-mode.el b/lisp/help-mode.el
index 48433d899ab..e16408be7b0 100644
--- a/lisp/help-mode.el
+++ b/lisp/help-mode.el
@@ -265,7 +265,9 @@ help-function-def--button-function
     (require 'find-func)
     (when (eq file 'C-source)
       (setq file
-            (help-C-file-name (indirect-function fun) 'fun)))
+            (if (memq type '(variable defvar))
+                (help-C-file-name fun 'var)
+              (help-C-file-name (indirect-function fun) 'fun))))
     ;; Don't use find-function-noselect because it follows
     ;; aliases (which fails for built-in functions).
     (let* ((location




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#71117; Package emacs. (Thu, 23 May 2024 17:36:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Eshel Yaron <me <at> eshelyaron.com>
Cc: 71117 <at> debbugs.gnu.org,
 Andreas Röhler <andreas.roehler <at> easy-emacs.de>,
 Kévin Le Gouguec <kevin.legouguec <at> gmail.com>
Subject: Re: bug#71117: 30.0.50; output of describe-function
Date: Thu, 23 May 2024 20:20:27 +0300
>> Except there is a bug that prevents 's' from handling some C variables, e.g.:
>>
>> 0. emacs -Q
>> 1. C-h v minibuffer-allow-text-properties RET
>> 2. s
>>
>> fails with
>>
>>   (error "Don’t know where ‘minibuffer-allow-text-properties’ is defined")
>>
>> So still need to use 'TAB RET' to navigate to C source.
>
> That bothered me too.  Does this patch help?

Thanks, now there is no such problem anymore.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#71117; Package emacs. (Thu, 23 May 2024 20:24:01 GMT) Full text and rfc822 format available.

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

From: Eshel Yaron <me <at> eshelyaron.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: 71117 <at> debbugs.gnu.org,
 Andreas Röhler <andreas.roehler <at> easy-emacs.de>,
 Kévin Le Gouguec <kevin.legouguec <at> gmail.com>
Subject: Re: bug#71117: 30.0.50; output of describe-function
Date: Thu, 23 May 2024 22:23:35 +0200
Juri Linkov <juri <at> linkov.net> writes:

>>> Except there is a bug that prevents 's' from handling some C variables, e.g.:
>>>
>>> 0. emacs -Q
>>> 1. C-h v minibuffer-allow-text-properties RET
>>> 2. s
>>>
>>> fails with
>>>
>>>   (error "Don’t know where ‘minibuffer-allow-text-properties’ is defined")
>>>
>>> So still need to use 'TAB RET' to navigate to C source.
>>
>> That bothered me too.  Does this patch help?
>
> Thanks, now there is no such problem anymore.

Nice, pushed the fix to master.

Regarding the general issue of jumping to function/variable source,
I find C-x F and friends (enabled by find-function-setup-keys) quite
convenient.


Best,

Eshel




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#71117; Package emacs. (Tue, 28 May 2024 17:48:01 GMT) Full text and rfc822 format available.

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

From: Andrea Corallo <acorallo <at> gnu.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 71117 <at> debbugs.gnu.org, andreas.roehler <at> easy-emacs.de,
 Kévin Le Gouguec <kevin.legouguec <at> gmail.com>
Subject: Re: bug#71117: 30.0.50; output of describe-function
Date: Tue, 28 May 2024 13:44:33 -0400
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Kévin Le Gouguec <kevin.legouguec <at> gmail.com>
>> Cc: andreas.roehler <at> easy-emacs.de,  71117 <at> debbugs.gnu.org
>> Date: Thu, 23 May 2024 00:22:10 +0200
>> 
>> Eli Zaretskii <eliz <at> gnu.org> writes:
>> 
>> > Which reminds me that we still don't have a "C-h SOMETHING" binding
>> > that would go to the source without the need to switch to the *Help*
>> > buffer.  At one time we discussed something like that, and I thought
>> > we actually installed it, but I guess I was dreaming, because I cannot
>> > find it...
>> 
>> Were you thinking of a command that specifically targets the symbol from
>> a displayed *Help* buffer, so the user would do e.g.
>> 
>> C-h v VAR RET   ; shows *Help* for VAR
>> C-h SOMETHING   ; finds source for VAR
>> 
>> where C-h SOMETHING's implementation would do (a smarter version of)
>> (with-current-buffer "*Help*"
>>   (help-view-source))
>> 
>> ?
>
> Yes, exactly.

Something like the attached?

It makes C-h z FUNCTION find the source for FUNCTION.

Not sure C-h z is the best (but there are not may other letter still
available).

Also ATM the patch is missing the NEWS entry (will do after).

Thanks

  Andrea

[0001-Add-help-function-source-C-h-z-to-visit-the-function.patch (text/x-diff, inline)]
From e1ab4f7fae70316ee07c19e3f34fdf5f5b6ac918 Mon Sep 17 00:00:00 2001
From: Andrea Corallo <acorallo <at> gnu.org>
Date: Tue, 28 May 2024 19:33:54 +0200
Subject: [PATCH] Add 'help-function-source' 'C-h z' to visit function's
 source (bug#71117)

* lisp/help.el (help-map): Bind 'help-function-source' to C-h z.
(help-for-help): Add 'help-function-source'.
* lisp/help-fns.el
(help-fns--describe-function-or-command-prompt): Extend arg
to support 'src-fun'.
(help-function-source): New function.
---
 lisp/help-fns.el | 17 ++++++++++++-----
 lisp/help.el     |  2 ++
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index a202c2d247e..66153f84b8f 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -224,14 +224,15 @@ describe-function-orig-buffer

 (defun help-fns--describe-function-or-command-prompt (&optional want-command)
   "Prompt for a function from `describe-function' or `describe-command'.
-If optional argument WANT-COMMAND is non-nil, prompt for an
-interactive command."
+If optional argument WANT-COMMAND is `is-command', prompt for an
+interactive command, if is `src-fun' prompt for go to function source."
   (let* ((fn (if want-command
                  (caar command-history)
                (function-called-at-point)))
-         (prompt (format-prompt (if want-command
-                                    "Describe command"
-                                  "Describe function")
+         (prompt (format-prompt (cl-case want-command
+                                  ('is-command "Describe command")
+                                  ('src-fun "Find source of function")
+                                  (t "Describe function"))
                                 fn))
          (enable-recursive-minibuffers t)
          (val (completing-read
@@ -298,6 +299,12 @@ describe-function
           ;; Return the text we displayed.
           (buffer-string))))))

+;;;###autoload
+(defun help-function-source (function)
+  "Switch to a buffer visiting the source of FUNCTION (a symbol)."
+  (interactive (help-fns--describe-function-or-command-prompt 'src-fun))
+  (xref-find-definitions (symbol-name function)))
+
 ;;;###autoload
 (defun describe-command (command)
   "Display the full documentation of COMMAND (a symbol).
diff --git a/lisp/help.el b/lisp/help.el
index 616a45328fd..a753a31a2e3 100644
--- a/lisp/help.el
+++ b/lisp/help.el
@@ -114,6 +114,7 @@ help-map
   "R"    #'info-display-manual
   "s"    #'describe-syntax
   "t"    #'help-with-tutorial
+  "z"    #'help-function-source
   "v"    #'describe-variable
   "w"    #'where-is
   "x"    #'describe-command
@@ -418,6 +419,7 @@ 'help
         "Search documentation of functions, variables, and other items")
        ("describe-command" "Show help for command")
        ("describe-function" "Show help for function")
+       ("help-function-source" "Show the source for function")
        ("describe-variable" "Show help for variable")
        ("describe-symbol" "Show help for function or variable"))
       ("Manuals"
--
2.34.1

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#71117; Package emacs. (Tue, 28 May 2024 18:22:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Andrea Corallo <acorallo <at> gnu.org>
Cc: 71117 <at> debbugs.gnu.org, andreas.roehler <at> easy-emacs.de,
 kevin.legouguec <at> gmail.com
Subject: Re: bug#71117: 30.0.50; output of describe-function
Date: Tue, 28 May 2024 21:20:24 +0300
> From: Andrea Corallo <acorallo <at> gnu.org>
> Cc: Kévin Le Gouguec <kevin.legouguec <at> gmail.com>,
>   71117 <at> debbugs.gnu.org,
>   andreas.roehler <at> easy-emacs.de
> Date: Tue, 28 May 2024 13:44:33 -0400
> 
> >> Were you thinking of a command that specifically targets the symbol from
> >> a displayed *Help* buffer, so the user would do e.g.
> >> 
> >> C-h v VAR RET   ; shows *Help* for VAR
> >> C-h SOMETHING   ; finds source for VAR
> >> 
> >> where C-h SOMETHING's implementation would do (a smarter version of)
> >> (with-current-buffer "*Help*"
> >>   (help-view-source))
> >> 
> >> ?
> >
> > Yes, exactly.
> 
> Something like the attached?
> 
> It makes C-h z FUNCTION find the source for FUNCTION.

I might be mistaken, but I don't think this is what I had in mind.  My
use case is exactly like described above: I type "C-h v" or "C-h f",
which displays the *Help* buffer in the other window.  Then I want to
go to the source where the variable or function are defined, but
without the need to switch to the window showing *Help*.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#71117; Package emacs. (Tue, 28 May 2024 19:43:02 GMT) Full text and rfc822 format available.

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

From: Andrea Corallo <acorallo <at> gnu.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 71117 <at> debbugs.gnu.org, andreas.roehler <at> easy-emacs.de,
 kevin.legouguec <at> gmail.com
Subject: Re: bug#71117: 30.0.50; output of describe-function
Date: Tue, 28 May 2024 15:42:30 -0400
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Andrea Corallo <acorallo <at> gnu.org>
>> Cc: Kévin Le Gouguec <kevin.legouguec <at> gmail.com>,
>>   71117 <at> debbugs.gnu.org,
>>   andreas.roehler <at> easy-emacs.de
>> Date: Tue, 28 May 2024 13:44:33 -0400
>> 
>> >> Were you thinking of a command that specifically targets the symbol from
>> >> a displayed *Help* buffer, so the user would do e.g.
>> >> 
>> >> C-h v VAR RET   ; shows *Help* for VAR
>> >> C-h SOMETHING   ; finds source for VAR
>> >> 
>> >> where C-h SOMETHING's implementation would do (a smarter version of)
>> >> (with-current-buffer "*Help*"
>> >>   (help-view-source))
>> >> 
>> >> ?
>> >
>> > Yes, exactly.
>> 
>> Something like the attached?
>> 
>> It makes C-h z FUNCTION find the source for FUNCTION.
>
> I might be mistaken, but I don't think this is what I had in mind.

You are not.

> My use case is exactly like described above: I type "C-h v" or "C-h
> f", which displays the *Help* buffer in the other window.  Then I want
> to go to the source where the variable or function are defined, but
> without the need to switch to the window showing *Help*.

The attached is my understanding of what we want (still using C-h z).
Kévin's mail make me suspect I've been too naive but anyway 😅...

Thanks

  Andrea

[0001-Add-help-find-source-and-bind-it-to-C-h-z.patch (text/x-diff, inline)]
From 569eb50994cd0841dcfbc970d574d945aa43b064 Mon Sep 17 00:00:00 2001
From: Andrea Corallo <acorallo <at> gnu.org>
Date: Tue, 28 May 2024 21:06:21 +0200
Subject: [PATCH] Add 'help-find-source' and bind it to C-h z

* lisp/help-fns.el (help-find-source): New function.
* lisp/help.el (help-map): Bind 'help-find-source' to C-h z.
(help-for-help): Add 'help-find-source'.
---
 lisp/help-fns.el | 9 +++++++++
 lisp/help.el     | 2 ++
 2 files changed, 11 insertions(+)

diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index a202c2d247e..74760197c8b 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -298,6 +298,15 @@ describe-function
           ;; Return the text we displayed.
           (buffer-string))))))
 
+;;;###autoload
+(defun help-find-source ()
+  "Switch to a buffer visiting the source of what is being described in *Help*."
+  (interactive)
+  (if-let ((help-buffer (get-buffer "*Help*")))
+      (with-current-buffer help-buffer
+          (help-view-source))
+    (error "No *Help* buffer found")))
+
 ;;;###autoload
 (defun describe-command (command)
   "Display the full documentation of COMMAND (a symbol).
diff --git a/lisp/help.el b/lisp/help.el
index 616a45328fd..aa835008358 100644
--- a/lisp/help.el
+++ b/lisp/help.el
@@ -114,6 +114,7 @@ help-map
   "R"    #'info-display-manual
   "s"    #'describe-syntax
   "t"    #'help-with-tutorial
+  "z"    #'help-find-source
   "v"    #'describe-variable
   "w"    #'where-is
   "x"    #'describe-command
@@ -418,6 +419,7 @@ 'help
         "Search documentation of functions, variables, and other items")
        ("describe-command" "Show help for command")
        ("describe-function" "Show help for function")
+       ("help-find-source" "Show the source for what's being described in *Help*")
        ("describe-variable" "Show help for variable")
        ("describe-symbol" "Show help for function or variable"))
       ("Manuals"
-- 
2.34.1


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#71117; Package emacs. (Tue, 28 May 2024 22:06:02 GMT) Full text and rfc822 format available.

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

From: Kévin Le Gouguec <kevin.legouguec <at> gmail.com>
To: Andrea Corallo <acorallo <at> gnu.org>
Cc: Eli Zaretskii <eliz <at> gnu.org>, andreas.roehler <at> easy-emacs.de,
 71117 <at> debbugs.gnu.org
Subject: Re: bug#71117: 30.0.50; output of describe-function
Date: Wed, 29 May 2024 00:04:26 +0200
Andrea Corallo <acorallo <at> gnu.org> writes:

> Eli Zaretskii <eliz <at> gnu.org> writes:
>
>>> From: Andrea Corallo <acorallo <at> gnu.org>
>>> Cc: Kévin Le Gouguec <kevin.legouguec <at> gmail.com>,
>>>   71117 <at> debbugs.gnu.org,
>>>   andreas.roehler <at> easy-emacs.de
>>> Date: Tue, 28 May 2024 13:44:33 -0400
>>> 
>>> >> Were you thinking of a command that specifically targets the symbol from
>>> >> a displayed *Help* buffer, so the user would do e.g.
>>> >> 
>>> >> C-h v VAR RET   ; shows *Help* for VAR
>>> >> C-h SOMETHING   ; finds source for VAR
>>> >> 
>>> >> where C-h SOMETHING's implementation would do (a smarter version of)
>>> >> (with-current-buffer "*Help*"
>>> >>   (help-view-source))
>>> >> 
>>> >> ?
>>> >
>>> > Yes, exactly.
>>> 
>>> Something like the attached?
>>> 
>>> It makes C-h z FUNCTION find the source for FUNCTION.
>>
>> I might be mistaken, but I don't think this is what I had in mind.
>
> You are not.
>
>> My use case is exactly like described above: I type "C-h v" or "C-h
>> f", which displays the *Help* buffer in the other window.  Then I want
>> to go to the source where the variable or function are defined, but
>> without the need to switch to the window showing *Help*.
>
> The attached is my understanding of what we want (still using C-h z).
> Kévin's mail make me suspect I've been too naive but anyway 😅...

I don't actually have concrete examples where my allegedly-not-so-smart
serving suggestion might fail 😉 The best I can come up with are
what-ifs, e.g. "what if a user advises describe-* functions to rename
*Help* buffers to something non-standard like *Help <SYM>*"; my answer
then would be "describe-* commands could set some variable,
e.g. last-help-buffer, that 'C-h z' could then consult".

That's if we cared to support this kind of edge case, of course.

Re. the binding: if we are entering "Do Something With That Help Buffer
I Just Invoked"-land, I wonder if we should stop at view-source; I could
imagine users wanting to do other useful things like goto-info or
customize.  In which case maybe we can find a mnemonic prefix to tuck
all these actions?

Thinking of e.g. 'C-h 4' (for the "other-window" connotation) or 'C-h H'
(for "current _H_elp buffer"); help-find-source would then be bound to
'C-h 4 s', for example.

(info-other-window currently hogs 'C-h 4 i' unfortunately… though
nowadays 'C-x 4 4 i' also works, and 'C-x 4 i' is currently free 🤔

'C-x 4 h' is also free to use as a prefix, but maybe a bit of a
fingerful)

Don't give too much weight to my ramblings; I find 'C-h z' a bit
cryptic, but I don't know that my alternatives are better.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#71117; Package emacs. (Tue, 28 May 2024 22:26:01 GMT) Full text and rfc822 format available.

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

From: Andrea Corallo <acorallo <at> gnu.org>
To: Kévin Le Gouguec <kevin.legouguec <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, andreas.roehler <at> easy-emacs.de,
 71117 <at> debbugs.gnu.org
Subject: Re: bug#71117: 30.0.50; output of describe-function
Date: Tue, 28 May 2024 18:25:05 -0400
Kévin Le Gouguec <kevin.legouguec <at> gmail.com> writes:

> Andrea Corallo <acorallo <at> gnu.org> writes:
>
>> Eli Zaretskii <eliz <at> gnu.org> writes:
>>
>>>> From: Andrea Corallo <acorallo <at> gnu.org>
>>>> Cc: Kévin Le Gouguec <kevin.legouguec <at> gmail.com>,
>>>>   71117 <at> debbugs.gnu.org,
>>>>   andreas.roehler <at> easy-emacs.de
>>>> Date: Tue, 28 May 2024 13:44:33 -0400
>>>> 
>>>> >> Were you thinking of a command that specifically targets the symbol from
>>>> >> a displayed *Help* buffer, so the user would do e.g.
>>>> >> 
>>>> >> C-h v VAR RET   ; shows *Help* for VAR
>>>> >> C-h SOMETHING   ; finds source for VAR
>>>> >> 
>>>> >> where C-h SOMETHING's implementation would do (a smarter version of)
>>>> >> (with-current-buffer "*Help*"
>>>> >>   (help-view-source))
>>>> >> 
>>>> >> ?
>>>> >
>>>> > Yes, exactly.
>>>> 
>>>> Something like the attached?
>>>> 
>>>> It makes C-h z FUNCTION find the source for FUNCTION.
>>>
>>> I might be mistaken, but I don't think this is what I had in mind.
>>
>> You are not.
>>
>>> My use case is exactly like described above: I type "C-h v" or "C-h
>>> f", which displays the *Help* buffer in the other window.  Then I want
>>> to go to the source where the variable or function are defined, but
>>> without the need to switch to the window showing *Help*.
>>
>> The attached is my understanding of what we want (still using C-h z).
>> Kévin's mail make me suspect I've been too naive but anyway 😅...
>
> I don't actually have concrete examples where my allegedly-not-so-smart
> serving suggestion might fail 😉 The best I can come up with are
> what-ifs, e.g. "what if a user advises describe-* functions to rename
> *Help* buffers to something non-standard like *Help <SYM>*"; my answer
> then would be "describe-* commands could set some variable,
> e.g. last-help-buffer, that 'C-h z' could then consult".
>
> That's if we cared to support this kind of edge case, of course.

I thought about the variable but I didn't like to have to maintain a
status more (ie clean the variable when *Help* is killed).  OTOH in
help-fns-tests.el we already have a good number of hard-coded '*Help*'
around, so I think the current status quo is that we don't care.

> Re. the binding: if we are entering "Do Something With That Help Buffer
> I Just Invoked"-land, I wonder if we should stop at view-source; I could
> imagine users wanting to do other useful things like goto-info or
> customize.  In which case maybe we can find a mnemonic prefix to tuck
> all these actions?
>
> Thinking of e.g. 'C-h 4' (for the "other-window" connotation) or 'C-h H'
> (for "current _H_elp buffer"); help-find-source would then be bound to
> 'C-h 4 s', for example.
>
> (info-other-window currently hogs 'C-h 4 i' unfortunately… though
> nowadays 'C-x 4 4 i' also works, and 'C-x 4 i' is currently free 🤔
>
> 'C-x 4 h' is also free to use as a prefix, but maybe a bit of a
> fingerful)
>
> Don't give too much weight to my ramblings; I find 'C-h z' a bit
> cryptic, but I don't know that my alternatives are better.

I think those are actually good points, 'C-h z' is not very nice and
'C-h 4 s' would be probably easier to remember as 's' has the same
meaning in the *Help* buffer it-self.

  Andrea




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#71117; Package emacs. (Wed, 29 May 2024 11:27:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Andrea Corallo <acorallo <at> gnu.org>
Cc: 71117 <at> debbugs.gnu.org, andreas.roehler <at> easy-emacs.de,
 kevin.legouguec <at> gmail.com
Subject: Re: bug#71117: 30.0.50; output of describe-function
Date: Wed, 29 May 2024 14:25:45 +0300
> From: Andrea Corallo <acorallo <at> gnu.org>
> Cc: Eli Zaretskii <eliz <at> gnu.org>,  71117 <at> debbugs.gnu.org,
>   andreas.roehler <at> easy-emacs.de
> Date: Tue, 28 May 2024 18:25:05 -0400
> 
> Kévin Le Gouguec <kevin.legouguec <at> gmail.com> writes:
> 
> > Thinking of e.g. 'C-h 4' (for the "other-window" connotation) or 'C-h H'
> > (for "current _H_elp buffer"); help-find-source would then be bound to
> > 'C-h 4 s', for example.
> >
> > (info-other-window currently hogs 'C-h 4 i' unfortunately… though
> > nowadays 'C-x 4 4 i' also works, and 'C-x 4 i' is currently free 🤔
> >
> > 'C-x 4 h' is also free to use as a prefix, but maybe a bit of a
> > fingerful)
> >
> > Don't give too much weight to my ramblings; I find 'C-h z' a bit
> > cryptic, but I don't know that my alternatives are better.
> 
> I think those are actually good points, 'C-h z' is not very nice and
> 'C-h 4 s' would be probably easier to remember as 's' has the same
> meaning in the *Help* buffer it-self.

I don't want to rebind "C-h 4 i", but "C-h 4 s" or "C-h 4 RET" should
be good.

This also needs an update in NEWS and the manual.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#71117; Package emacs. (Wed, 29 May 2024 11:40:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Kévin Le Gouguec <kevin.legouguec <at> gmail.com>
Cc: 71117 <at> debbugs.gnu.org, acorallo <at> gnu.org, andreas.roehler <at> easy-emacs.de
Subject: Re: bug#71117: 30.0.50; output of describe-function
Date: Wed, 29 May 2024 14:38:49 +0300
> From: Kévin Le Gouguec <kevin.legouguec <at> gmail.com>
> Cc: Eli Zaretskii <eliz <at> gnu.org>,  71117 <at> debbugs.gnu.org,
>   andreas.roehler <at> easy-emacs.de
> Date: Wed, 29 May 2024 00:04:26 +0200
> 
> I don't actually have concrete examples where my allegedly-not-so-smart
> serving suggestion might fail 😉 The best I can come up with are
> what-ifs, e.g. "what if a user advises describe-* functions to rename
> *Help* buffers to something non-standard like *Help <SYM>*";

First, AFAICT describe-* functions don't know about the name of the
buffer.  So advising them will not affect the buffer name.

Second, if someone advises the functions which do know about that,
they have an uphill battle to fight, and IMNSHO they get what they
deserve.

Last, but not least, if we want to be holier that the Pope, we can use
the function help-buffer to get at the buffer, whatever its name.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#71117; Package emacs. (Wed, 29 May 2024 15:18:02 GMT) Full text and rfc822 format available.

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

From: Andrea Corallo <acorallo <at> gnu.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 71117 <at> debbugs.gnu.org, andreas.roehler <at> easy-emacs.de,
 kevin.legouguec <at> gmail.com
Subject: Re: bug#71117: 30.0.50; output of describe-function
Date: Wed, 29 May 2024 11:17:39 -0400
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Andrea Corallo <acorallo <at> gnu.org>
>> Cc: Eli Zaretskii <eliz <at> gnu.org>,  71117 <at> debbugs.gnu.org,
>>   andreas.roehler <at> easy-emacs.de
>> Date: Tue, 28 May 2024 18:25:05 -0400
>> 
>> Kévin Le Gouguec <kevin.legouguec <at> gmail.com> writes:
>> 
>> > Thinking of e.g. 'C-h 4' (for the "other-window" connotation) or 'C-h H'
>> > (for "current _H_elp buffer"); help-find-source would then be bound to
>> > 'C-h 4 s', for example.
>> >
>> > (info-other-window currently hogs 'C-h 4 i' unfortunately… though
>> > nowadays 'C-x 4 4 i' also works, and 'C-x 4 i' is currently free 🤔
>> >
>> > 'C-x 4 h' is also free to use as a prefix, but maybe a bit of a
>> > fingerful)
>> >
>> > Don't give too much weight to my ramblings; I find 'C-h z' a bit
>> > cryptic, but I don't know that my alternatives are better.
>> 
>> I think those are actually good points, 'C-h z' is not very nice and
>> 'C-h 4 s' would be probably easier to remember as 's' has the same
>> meaning in the *Help* buffer it-self.
>
> I don't want to rebind "C-h 4 i", but "C-h 4 s" or "C-h 4 RET" should
> be good.
>
> This also needs an update in NEWS and the manual.

Okay done, please have a look as usual.

Also, we have a warning now on master because lisp/ldefs-boot.el needs
to be regenerated.  I did run admin/update_autogen but the diff is a
little bigger then I expected (is not only related to the introduced
function).  Should I commit this? Do we have another way to regenerate
ldefs-boot.el we typically use?

Thanks

  Andrea




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#71117; Package emacs. (Wed, 29 May 2024 15:56:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Andrea Corallo <acorallo <at> gnu.org>
Cc: 71117 <at> debbugs.gnu.org, andreas.roehler <at> easy-emacs.de,
 kevin.legouguec <at> gmail.com
Subject: Re: bug#71117: 30.0.50; output of describe-function
Date: Wed, 29 May 2024 18:54:39 +0300
> From: Andrea Corallo <acorallo <at> gnu.org>
> Cc: kevin.legouguec <at> gmail.com,  71117 <at> debbugs.gnu.org,
>   andreas.roehler <at> easy-emacs.de
> Date: Wed, 29 May 2024 11:17:39 -0400
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> >> From: Andrea Corallo <acorallo <at> gnu.org>
> >> Cc: Eli Zaretskii <eliz <at> gnu.org>,  71117 <at> debbugs.gnu.org,
> >>   andreas.roehler <at> easy-emacs.de
> >> Date: Tue, 28 May 2024 18:25:05 -0400
> >> 
> >> Kévin Le Gouguec <kevin.legouguec <at> gmail.com> writes:
> >> 
> >> > Thinking of e.g. 'C-h 4' (for the "other-window" connotation) or 'C-h H'
> >> > (for "current _H_elp buffer"); help-find-source would then be bound to
> >> > 'C-h 4 s', for example.
> >> >
> >> > (info-other-window currently hogs 'C-h 4 i' unfortunately… though
> >> > nowadays 'C-x 4 4 i' also works, and 'C-x 4 i' is currently free 🤔
> >> >
> >> > 'C-x 4 h' is also free to use as a prefix, but maybe a bit of a
> >> > fingerful)
> >> >
> >> > Don't give too much weight to my ramblings; I find 'C-h z' a bit
> >> > cryptic, but I don't know that my alternatives are better.
> >> 
> >> I think those are actually good points, 'C-h z' is not very nice and
> >> 'C-h 4 s' would be probably easier to remember as 's' has the same
> >> meaning in the *Help* buffer it-self.
> >
> > I don't want to rebind "C-h 4 i", but "C-h 4 s" or "C-h 4 RET" should
> > be good.
> >
> > This also needs an update in NEWS and the manual.
> 
> Okay done, please have a look as usual.

LGTM, thanks.

> Also, we have a warning now on master because lisp/ldefs-boot.el needs
> to be regenerated.  I did run admin/update_autogen but the diff is a
> little bigger then I expected (is not only related to the introduced
> function).  Should I commit this? Do we have another way to regenerate
> ldefs-boot.el we typically use?

I never use admin/update_autogen, I just regenerate loaddefs.el (as in
"make -C lisp autoloads-force") and the do what make-tarball.txt says:

  5.  Copy lisp/loaddefs.el to lisp/ldefs-boot.el.  After copying, edit
      ldefs-boot.el to add

      ;; no-byte-compile: t

      to its file-local variables section, otherwise make-dist will
      complain.

And I just did that, so we should be okay for a while.




Reply sent to Andrea Corallo <acorallo <at> gnu.org>:
You have taken responsibility. (Wed, 29 May 2024 16:05:02 GMT) Full text and rfc822 format available.

Notification sent to Andreas Röhler <andreas.roehler <at> easy-emacs.de>:
bug acknowledged by developer. (Wed, 29 May 2024 16:05:02 GMT) Full text and rfc822 format available.

Message #64 received at 71117-done <at> debbugs.gnu.org (full text, mbox):

From: Andrea Corallo <acorallo <at> gnu.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 71117-done <at> debbugs.gnu.org, andreas.roehler <at> easy-emacs.de,
 kevin.legouguec <at> gmail.com
Subject: Re: bug#71117: 30.0.50; output of describe-function
Date: Wed, 29 May 2024 12:04:18 -0400
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Andrea Corallo <acorallo <at> gnu.org>
>> Cc: kevin.legouguec <at> gmail.com,  71117 <at> debbugs.gnu.org,
>>   andreas.roehler <at> easy-emacs.de
>> Date: Wed, 29 May 2024 11:17:39 -0400
>> 
>> Eli Zaretskii <eliz <at> gnu.org> writes:
>> 
>> >> From: Andrea Corallo <acorallo <at> gnu.org>
>> >> Cc: Eli Zaretskii <eliz <at> gnu.org>,  71117 <at> debbugs.gnu.org,
>> >>   andreas.roehler <at> easy-emacs.de
>> >> Date: Tue, 28 May 2024 18:25:05 -0400
>> >> 
>> >> Kévin Le Gouguec <kevin.legouguec <at> gmail.com> writes:
>> >> 
>> >> > Thinking of e.g. 'C-h 4' (for the "other-window" connotation) or 'C-h H'
>> >> > (for "current _H_elp buffer"); help-find-source would then be bound to
>> >> > 'C-h 4 s', for example.
>> >> >
>> >> > (info-other-window currently hogs 'C-h 4 i' unfortunately… though
>> >> > nowadays 'C-x 4 4 i' also works, and 'C-x 4 i' is currently free 🤔
>> >> >
>> >> > 'C-x 4 h' is also free to use as a prefix, but maybe a bit of a
>> >> > fingerful)
>> >> >
>> >> > Don't give too much weight to my ramblings; I find 'C-h z' a bit
>> >> > cryptic, but I don't know that my alternatives are better.
>> >> 
>> >> I think those are actually good points, 'C-h z' is not very nice and
>> >> 'C-h 4 s' would be probably easier to remember as 's' has the same
>> >> meaning in the *Help* buffer it-self.
>> >
>> > I don't want to rebind "C-h 4 i", but "C-h 4 s" or "C-h 4 RET" should
>> > be good.
>> >
>> > This also needs an update in NEWS and the manual.
>> 
>> Okay done, please have a look as usual.
>
> LGTM, thanks.

I feel I'm improving! 😀

>> Also, we have a warning now on master because lisp/ldefs-boot.el needs
>> to be regenerated.  I did run admin/update_autogen but the diff is a
>> little bigger then I expected (is not only related to the introduced
>> function).  Should I commit this? Do we have another way to regenerate
>> ldefs-boot.el we typically use?
>
> I never use admin/update_autogen, I just regenerate loaddefs.el (as in
> "make -C lisp autoloads-force") and the do what make-tarball.txt says:
>
>   5.  Copy lisp/loaddefs.el to lisp/ldefs-boot.el.  After copying, edit
>       ldefs-boot.el to add
>
>       ;; no-byte-compile: t
>
>       to its file-local variables section, otherwise make-dist will
>       complain.

Noted

> And I just did that, so we should be okay for a while.

Thanks.

I'm closing this then, happy to reopen if necessary.

  Andrea




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 27 Jun 2024 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 357 days ago.

Previous Next


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