smartparens
smartparens copied to clipboard
Cheat sheet is empty (Emacs-28.0.50)
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.
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
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 , 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.

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.
Emacs 28 is now released. I still see this probelm on Emacs 28.2.50.
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 '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?
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
.