unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#71117: 30.0.50; output of describe-function
@ 2024-05-22 13:53 Andreas Röhler
  2024-05-22 14:10 ` Eli Zaretskii
  2024-05-22 17:46 ` Kévin Le Gouguec
  0 siblings, 2 replies; 20+ messages in thread
From: Andreas Röhler @ 2024-05-22 13:53 UTC (permalink / raw)
  To: 71117

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






^ permalink raw reply	[flat|nested] 20+ messages in thread

* bug#71117: 30.0.50; output of describe-function
  2024-05-22 13:53 bug#71117: 30.0.50; output of describe-function Andreas Röhler
@ 2024-05-22 14:10 ` Eli Zaretskii
  2024-05-22 17:46 ` Kévin Le Gouguec
  1 sibling, 0 replies; 20+ messages in thread
From: Eli Zaretskii @ 2024-05-22 14:10 UTC (permalink / raw)
  To: Andreas Röhler, Stefan Monnier; +Cc: 71117

> Date: Wed, 22 May 2024 15:53:07 +0200
> From: Andreas Röhler <andreas.roehler@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.





^ permalink raw reply	[flat|nested] 20+ messages in thread

* bug#71117: 30.0.50; output of describe-function
  2024-05-22 13:53 bug#71117: 30.0.50; output of describe-function Andreas Röhler
  2024-05-22 14:10 ` Eli Zaretskii
@ 2024-05-22 17:46 ` Kévin Le Gouguec
  2024-05-22 18:24   ` Eli Zaretskii
  2024-05-23  6:28   ` Juri Linkov
  1 sibling, 2 replies; 20+ messages in thread
From: Kévin Le Gouguec @ 2024-05-22 17:46 UTC (permalink / raw)
  To: Andreas Röhler; +Cc: 71117

Andreas Röhler <andreas.roehler@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.





^ permalink raw reply	[flat|nested] 20+ messages in thread

* bug#71117: 30.0.50; output of describe-function
  2024-05-22 17:46 ` Kévin Le Gouguec
@ 2024-05-22 18:24   ` Eli Zaretskii
  2024-05-22 22:22     ` Kévin Le Gouguec
  2024-05-23  6:28   ` Juri Linkov
  1 sibling, 1 reply; 20+ messages in thread
From: Eli Zaretskii @ 2024-05-22 18:24 UTC (permalink / raw)
  To: Kévin Le Gouguec; +Cc: 71117, andreas.roehler

> Cc: 71117@debbugs.gnu.org
> From: Kévin Le Gouguec <kevin.legouguec@gmail.com>
> Date: Wed, 22 May 2024 19:46:09 +0200
> 
> Andreas Röhler <andreas.roehler@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?





^ permalink raw reply	[flat|nested] 20+ messages in thread

* bug#71117: 30.0.50; output of describe-function
  2024-05-22 18:24   ` Eli Zaretskii
@ 2024-05-22 22:22     ` Kévin Le Gouguec
  2024-05-23  5:25       ` Eli Zaretskii
  0 siblings, 1 reply; 20+ messages in thread
From: Kévin Le Gouguec @ 2024-05-22 22:22 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 71117, andreas.roehler

Eli Zaretskii <eliz@gnu.org> writes:

>> Cc: 71117@debbugs.gnu.org
>> From: Kévin Le Gouguec <kevin.legouguec@gmail.com>
>> Date: Wed, 22 May 2024 19:46:09 +0200
>> 
>> Andreas Röhler <andreas.roehler@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?





^ permalink raw reply	[flat|nested] 20+ messages in thread

* bug#71117: 30.0.50; output of describe-function
  2024-05-22 22:22     ` Kévin Le Gouguec
@ 2024-05-23  5:25       ` Eli Zaretskii
  2024-05-28 17:44         ` Andrea Corallo
  0 siblings, 1 reply; 20+ messages in thread
From: Eli Zaretskii @ 2024-05-23  5:25 UTC (permalink / raw)
  To: Kévin Le Gouguec; +Cc: 71117, andreas.roehler

> From: Kévin Le Gouguec <kevin.legouguec@gmail.com>
> Cc: andreas.roehler@easy-emacs.de,  71117@debbugs.gnu.org
> Date: Thu, 23 May 2024 00:22:10 +0200
> 
> Eli Zaretskii <eliz@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.





^ permalink raw reply	[flat|nested] 20+ messages in thread

* bug#71117: 30.0.50; output of describe-function
  2024-05-22 17:46 ` Kévin Le Gouguec
  2024-05-22 18:24   ` Eli Zaretskii
@ 2024-05-23  6:28   ` Juri Linkov
  2024-05-23 11:51     ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 1 reply; 20+ messages in thread
From: Juri Linkov @ 2024-05-23  6:28 UTC (permalink / raw)
  To: Kévin Le Gouguec; +Cc: 71117, Andreas Röhler

>> 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.





^ permalink raw reply	[flat|nested] 20+ messages in thread

* bug#71117: 30.0.50; output of describe-function
  2024-05-23  6:28   ` Juri Linkov
@ 2024-05-23 11:51     ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-05-23 17:20       ` Juri Linkov
  0 siblings, 1 reply; 20+ messages in thread
From: Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-05-23 11:51 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 71117, Andreas Röhler, Kévin Le Gouguec

Hi Juri,

Juri Linkov <juri@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





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* bug#71117: 30.0.50; output of describe-function
  2024-05-23 11:51     ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-05-23 17:20       ` Juri Linkov
  2024-05-23 20:23         ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 20+ messages in thread
From: Juri Linkov @ 2024-05-23 17:20 UTC (permalink / raw)
  To: Eshel Yaron; +Cc: 71117, Andreas Röhler, Kévin Le Gouguec

>> 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.





^ permalink raw reply	[flat|nested] 20+ messages in thread

* bug#71117: 30.0.50; output of describe-function
  2024-05-23 17:20       ` Juri Linkov
@ 2024-05-23 20:23         ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 0 replies; 20+ messages in thread
From: Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-05-23 20:23 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 71117, Andreas Röhler, Kévin Le Gouguec

Juri Linkov <juri@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





^ permalink raw reply	[flat|nested] 20+ messages in thread

* bug#71117: 30.0.50; output of describe-function
  2024-05-23  5:25       ` Eli Zaretskii
@ 2024-05-28 17:44         ` Andrea Corallo
  2024-05-28 18:20           ` Eli Zaretskii
  0 siblings, 1 reply; 20+ messages in thread
From: Andrea Corallo @ 2024-05-28 17:44 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 71117, andreas.roehler, Kévin Le Gouguec

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

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Kévin Le Gouguec <kevin.legouguec@gmail.com>
>> Cc: andreas.roehler@easy-emacs.de,  71117@debbugs.gnu.org
>> Date: Thu, 23 May 2024 00:22:10 +0200
>> 
>> Eli Zaretskii <eliz@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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-help-function-source-C-h-z-to-visit-the-function.patch --]
[-- Type: text/x-diff, Size: 3070 bytes --]

From e1ab4f7fae70316ee07c19e3f34fdf5f5b6ac918 Mon Sep 17 00:00:00 2001
From: Andrea Corallo <acorallo@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

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* bug#71117: 30.0.50; output of describe-function
  2024-05-28 17:44         ` Andrea Corallo
@ 2024-05-28 18:20           ` Eli Zaretskii
  2024-05-28 19:42             ` Andrea Corallo
  0 siblings, 1 reply; 20+ messages in thread
From: Eli Zaretskii @ 2024-05-28 18:20 UTC (permalink / raw)
  To: Andrea Corallo; +Cc: 71117, andreas.roehler, kevin.legouguec

> From: Andrea Corallo <acorallo@gnu.org>
> Cc: Kévin Le Gouguec <kevin.legouguec@gmail.com>,
>   71117@debbugs.gnu.org,
>   andreas.roehler@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.





^ permalink raw reply	[flat|nested] 20+ messages in thread

* bug#71117: 30.0.50; output of describe-function
  2024-05-28 18:20           ` Eli Zaretskii
@ 2024-05-28 19:42             ` Andrea Corallo
  2024-05-28 22:04               ` Kévin Le Gouguec
  0 siblings, 1 reply; 20+ messages in thread
From: Andrea Corallo @ 2024-05-28 19:42 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 71117, andreas.roehler, kevin.legouguec

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

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Andrea Corallo <acorallo@gnu.org>
>> Cc: Kévin Le Gouguec <kevin.legouguec@gmail.com>,
>>   71117@debbugs.gnu.org,
>>   andreas.roehler@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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-help-find-source-and-bind-it-to-C-h-z.patch --]
[-- Type: text/x-diff, Size: 1916 bytes --]

From 569eb50994cd0841dcfbc970d574d945aa43b064 Mon Sep 17 00:00:00 2001
From: Andrea Corallo <acorallo@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


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* bug#71117: 30.0.50; output of describe-function
  2024-05-28 19:42             ` Andrea Corallo
@ 2024-05-28 22:04               ` Kévin Le Gouguec
  2024-05-28 22:25                 ` Andrea Corallo
  2024-05-29 11:38                 ` Eli Zaretskii
  0 siblings, 2 replies; 20+ messages in thread
From: Kévin Le Gouguec @ 2024-05-28 22:04 UTC (permalink / raw)
  To: Andrea Corallo; +Cc: Eli Zaretskii, andreas.roehler, 71117

Andrea Corallo <acorallo@gnu.org> writes:

> Eli Zaretskii <eliz@gnu.org> writes:
>
>>> From: Andrea Corallo <acorallo@gnu.org>
>>> Cc: Kévin Le Gouguec <kevin.legouguec@gmail.com>,
>>>   71117@debbugs.gnu.org,
>>>   andreas.roehler@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.





^ permalink raw reply	[flat|nested] 20+ messages in thread

* bug#71117: 30.0.50; output of describe-function
  2024-05-28 22:04               ` Kévin Le Gouguec
@ 2024-05-28 22:25                 ` Andrea Corallo
  2024-05-29 11:25                   ` Eli Zaretskii
  2024-05-29 11:38                 ` Eli Zaretskii
  1 sibling, 1 reply; 20+ messages in thread
From: Andrea Corallo @ 2024-05-28 22:25 UTC (permalink / raw)
  To: Kévin Le Gouguec; +Cc: Eli Zaretskii, andreas.roehler, 71117

Kévin Le Gouguec <kevin.legouguec@gmail.com> writes:

> Andrea Corallo <acorallo@gnu.org> writes:
>
>> Eli Zaretskii <eliz@gnu.org> writes:
>>
>>>> From: Andrea Corallo <acorallo@gnu.org>
>>>> Cc: Kévin Le Gouguec <kevin.legouguec@gmail.com>,
>>>>   71117@debbugs.gnu.org,
>>>>   andreas.roehler@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





^ permalink raw reply	[flat|nested] 20+ messages in thread

* bug#71117: 30.0.50; output of describe-function
  2024-05-28 22:25                 ` Andrea Corallo
@ 2024-05-29 11:25                   ` Eli Zaretskii
  2024-05-29 15:17                     ` Andrea Corallo
  0 siblings, 1 reply; 20+ messages in thread
From: Eli Zaretskii @ 2024-05-29 11:25 UTC (permalink / raw)
  To: Andrea Corallo; +Cc: 71117, andreas.roehler, kevin.legouguec

> From: Andrea Corallo <acorallo@gnu.org>
> Cc: Eli Zaretskii <eliz@gnu.org>,  71117@debbugs.gnu.org,
>   andreas.roehler@easy-emacs.de
> Date: Tue, 28 May 2024 18:25:05 -0400
> 
> Kévin Le Gouguec <kevin.legouguec@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.





^ permalink raw reply	[flat|nested] 20+ messages in thread

* bug#71117: 30.0.50; output of describe-function
  2024-05-28 22:04               ` Kévin Le Gouguec
  2024-05-28 22:25                 ` Andrea Corallo
@ 2024-05-29 11:38                 ` Eli Zaretskii
  1 sibling, 0 replies; 20+ messages in thread
From: Eli Zaretskii @ 2024-05-29 11:38 UTC (permalink / raw)
  To: Kévin Le Gouguec; +Cc: 71117, acorallo, andreas.roehler

> From: Kévin Le Gouguec <kevin.legouguec@gmail.com>
> Cc: Eli Zaretskii <eliz@gnu.org>,  71117@debbugs.gnu.org,
>   andreas.roehler@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.





^ permalink raw reply	[flat|nested] 20+ messages in thread

* bug#71117: 30.0.50; output of describe-function
  2024-05-29 11:25                   ` Eli Zaretskii
@ 2024-05-29 15:17                     ` Andrea Corallo
  2024-05-29 15:54                       ` Eli Zaretskii
  0 siblings, 1 reply; 20+ messages in thread
From: Andrea Corallo @ 2024-05-29 15:17 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 71117, andreas.roehler, kevin.legouguec

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Andrea Corallo <acorallo@gnu.org>
>> Cc: Eli Zaretskii <eliz@gnu.org>,  71117@debbugs.gnu.org,
>>   andreas.roehler@easy-emacs.de
>> Date: Tue, 28 May 2024 18:25:05 -0400
>> 
>> Kévin Le Gouguec <kevin.legouguec@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





^ permalink raw reply	[flat|nested] 20+ messages in thread

* bug#71117: 30.0.50; output of describe-function
  2024-05-29 15:17                     ` Andrea Corallo
@ 2024-05-29 15:54                       ` Eli Zaretskii
  2024-05-29 16:04                         ` Andrea Corallo
  0 siblings, 1 reply; 20+ messages in thread
From: Eli Zaretskii @ 2024-05-29 15:54 UTC (permalink / raw)
  To: Andrea Corallo; +Cc: 71117, andreas.roehler, kevin.legouguec

> From: Andrea Corallo <acorallo@gnu.org>
> Cc: kevin.legouguec@gmail.com,  71117@debbugs.gnu.org,
>   andreas.roehler@easy-emacs.de
> Date: Wed, 29 May 2024 11:17:39 -0400
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> >> From: Andrea Corallo <acorallo@gnu.org>
> >> Cc: Eli Zaretskii <eliz@gnu.org>,  71117@debbugs.gnu.org,
> >>   andreas.roehler@easy-emacs.de
> >> Date: Tue, 28 May 2024 18:25:05 -0400
> >> 
> >> Kévin Le Gouguec <kevin.legouguec@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.





^ permalink raw reply	[flat|nested] 20+ messages in thread

* bug#71117: 30.0.50; output of describe-function
  2024-05-29 15:54                       ` Eli Zaretskii
@ 2024-05-29 16:04                         ` Andrea Corallo
  0 siblings, 0 replies; 20+ messages in thread
From: Andrea Corallo @ 2024-05-29 16:04 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 71117-done, andreas.roehler, kevin.legouguec

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Andrea Corallo <acorallo@gnu.org>
>> Cc: kevin.legouguec@gmail.com,  71117@debbugs.gnu.org,
>>   andreas.roehler@easy-emacs.de
>> Date: Wed, 29 May 2024 11:17:39 -0400
>> 
>> Eli Zaretskii <eliz@gnu.org> writes:
>> 
>> >> From: Andrea Corallo <acorallo@gnu.org>
>> >> Cc: Eli Zaretskii <eliz@gnu.org>,  71117@debbugs.gnu.org,
>> >>   andreas.roehler@easy-emacs.de
>> >> Date: Tue, 28 May 2024 18:25:05 -0400
>> >> 
>> >> Kévin Le Gouguec <kevin.legouguec@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





^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2024-05-29 16:04 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-22 13:53 bug#71117: 30.0.50; output of describe-function Andreas Röhler
2024-05-22 14:10 ` Eli Zaretskii
2024-05-22 17:46 ` Kévin Le Gouguec
2024-05-22 18:24   ` Eli Zaretskii
2024-05-22 22:22     ` Kévin Le Gouguec
2024-05-23  5:25       ` Eli Zaretskii
2024-05-28 17:44         ` Andrea Corallo
2024-05-28 18:20           ` Eli Zaretskii
2024-05-28 19:42             ` Andrea Corallo
2024-05-28 22:04               ` Kévin Le Gouguec
2024-05-28 22:25                 ` Andrea Corallo
2024-05-29 11:25                   ` Eli Zaretskii
2024-05-29 15:17                     ` Andrea Corallo
2024-05-29 15:54                       ` Eli Zaretskii
2024-05-29 16:04                         ` Andrea Corallo
2024-05-29 11:38                 ` Eli Zaretskii
2024-05-23  6:28   ` Juri Linkov
2024-05-23 11:51     ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-23 17:20       ` Juri Linkov
2024-05-23 20:23         ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).