smartparens icon indicating copy to clipboard operation
smartparens copied to clipboard

Cheat sheet is empty (Emacs-28.0.50)

Open naoking158 opened this issue 3 years ago • 4 comments

I started using this wonderful package.

When I tried to open the cheat sheet, nothing showed up.

I have no idea what to do due to no errors or warnings. I would appreciate your help.

Thanks.

Expected behavior

A cheat sheet will appear.

Actual behavior

No appear.  2021-08-11 at 13 44 28

Steps to reproduce the problem

M-x sp-cheat-sheet

Backtraces if necessary (M-x toggle-debug-on-error)

No error message.

Environment & version information

  • smartparens version: 20210529.1129
  • Active major-mode: lisp-interaction-mode
  • Emacs version (M-x emacs-version): GNU Emacs 28.0.50 (build 1, x86_64-apple-darwin20.6.0, NS appkit-2022.60 Version 11.5.1 (Build 20G80)) of 2021-08-08
  • Spacemacs/Evil/Other starterkit (specify which)/Vanilla: Vanilla
  • OS: darwin

naoking158 avatar Aug 11 '21 04:08 naoking158

Please try on Emacs-27.2 instead of HEAD Emacs. Emacs 28.0 is develop channel and unstable Emacs. And please invoke Emacs with emacs -q.

conao3 avatar Aug 11 '21 05:08 conao3

@conao3 , thank you for your advice.

I checked with Emacs-27.2 and 28.0 with the minimum configuration. In v27.2, the cheat sheet was displayed correctly, so it seems that something is in conflict with v28.0.

 2021-08-11 at 15 12 32

naoking158 avatar Aug 11 '21 06:08 naoking158

Well, this function kind of depends on the internals of help mode so if that changed it will break. When v28 comes out we'll have to fix it.

Fuco1 avatar Aug 17 '21 19:08 Fuco1

Emacs 28 is now released. I still see this probelm on Emacs 28.2.50.

sonofjon avatar Sep 15 '22 12:09 sonofjon

This problem is due to a change in locate-file-internal (used by locate-file which is used by locate-library) which swaps the found file with the natively compiled file if found. This means it returns a file with a eln suffix. locate-file in turn has a special case for this where it looks up which source file the eln file was compiled from and returns that. So in this case it would return something like '/smartparens.el'. This is the value that sp-cheat-sheet uses to find the loaded functions in load-history but load-history records the functions as loaded from the elc file (so the compiled bytecode file) which means that coammands in sp-cheat-sheet will be empty.

I found the way this works a little confusing and it seems to have been cleaned up on the emacs-29 branch. But waiting for that is probably not an option so my suggestion for fixing this is replacing the loop extracting the commands from load-history with something that doesn't rely on file extensions. Using feature-symbols from loadhist.el is one solution which would look like this:

 (cl-loop for i in (cdr (feature-symbols 'smartparens))
          if (and (consp i) (eq (car i) 'defun) (commandp (cdr i)))
          collect (cdr i)))

I can open a pull request if this seems like the right way to go?

radenling avatar Jan 23 '23 19:01 radenling

Yes, seems to be a good approach @radenling.

For (and (consp i) (car i)) you can use car-safe which is a built-in C function doing just that.

/* Take the car or cdr of something whose type is not known.  */
INLINE Lisp_Object
CAR_SAFE (Lisp_Object c)
{
  return CONSP (c) ? XCAR (c) : Qnil;
}

Don't forget to add require for loadhist somewhere to load the feature-symbols.

Fuco1 avatar Feb 07 '23 13:02 Fuco1