Subject: Re: bug#71117: 30.0.50; output of describe-function

From: Eshel Yaron <[email-masked]>
Date: Thu, 23 May 2024 13:51:02 +0200

Hi Juri,

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