Subject: bug#56643: 29.0.50; Help-mode bookmarks not loading with native compilation

From: [email-masked]
Date: Thu, 21 Jul 2022 10:01:57 +0000

> > Alternatively we could introduce a named helper function. Note there
> > are more calls of `help-setup-xref' using lambdas in arguments.
>
>
> And that would solve the problem? Did you try that?

I tried it with describe-function and it does solve the problem, although as noted above there are many other functions that generate help buffers and pass in a lambda.

Named helper:

(defun describe-function-xref-func (function buffer)
  (let ((describe-function-orig-buffer
                    (if (buffer-live-p buffer) buffer)))
               (describe-function function)))

Revised describe-function snippet:

    (help-setup-xref
     (list 'describe-function-xref-func function describe-function-orig-buffer)
     (called-interactively-p 'interactive))

This produces the following bookmark, which I confirmed still works after restarting Emacs:

("named-function-help-bookmark"
 (position . 1)
 (last-modified 25305 7198 806743 243000)
 (help-fn . describe-function-xref-func)
 (help-args completing-read "*scratch*")
 (position . 1)
 (handler . help-bookmark-jump))

> > I see a more general problem: anywhere where printing an anonymous
> > function readably is necessary there is a potential breakage when using
> > natively compiled Emacs - right?  That would be quite a limitation.

I had the same thought. I'd bet there are other packages that rely on being able to read code back reliably. I"m curious if there is any metadata at all attached to a natively-compiled function?