Subject: bug#62376: 30.0.50; global-display-fill-column-indicator-modes broken?

From: Stefan Monnier <[email-masked]>
Date: Thu, 23 Mar 2023 09:16:51 -0400

>> Thanks, I verified that this fixes the bug, and installed it on the
>> emacs-29 branch.
> Hmm... but "C-h v" still tells me the variable is defined in
> loaddefs.el, until display-fill-column-indicator.el is loaded.

I think it's an unrelated problem.

> Can we do anything to prevent this?

Probably.  The code that "fixes/adjusts" this is an ugly hack I came up
with many years ago and it's quite brittle.  My guess is that it doesn't
work any more because of some change to the way we build/handle
`loaddefs.el` (the code works by using `load-history` to see the
"origin" of the variable, (in the present case it should say
`loaddefs.el(c)`) then look for the actual place in that file
where the variable is found, and then checks to see if that place looks
like those produced by `autoload.el` (which here should be the case)
and then uses the comments added by `autoload.el` to find the *real*
origin).

We should really replace it with something more explicit/reliable so we
don't have to "parse" the `loaddefs.el` file, but it's definitely out of
the scope of `emacs-29`.

In the mean time, the patch below seems to make the ugly hack work again
it for me.

        Stefan

diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index f9edf14a1da..b040ec49214 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -438,7 +438,7 @@ find-lisp-object-file-name
       (setq file-name
 	    (locate-file file-name load-path '(".el" ".elc") 'readable)))
      ((and (stringp file-name)
-	   (string-match "[.]*loaddefs.el\\'" file-name))
+	   (string-match "[.]*loaddefs.elc?\\'" file-name))
       ;; An autoloaded variable or face.  Visit loaddefs.el in a buffer
       ;; and try to extract the defining file.  The following form is
       ;; from `describe-function-1' and `describe-variable'.