ergoemacs / ergoemacs-mode

ergoemacs-mode
ergoemacs.github.io/
GNU General Public License v3.0
293 stars 35 forks source link

Error in post-command-hook: wrong type argument, and analysis #455

Closed nerditation closed 3 years ago

nerditation commented 7 years ago

today I found my Windows configuration doesn't work on my Linux system. after ergoemacs-mode loaded, the first command I press would give an "Error in post-command-hook", I think it might be the same problem with #378. after that, some ergoemacs overriden commands stopped working, such as the Alt + i/j/k/l cursor movement command in a helm pop up window.

after some debugging, I might have found the possible cause. @mattfidler you might want to check and confirm this though.

by default, the emacs package installed by the package manager (I am using zypper, other distribution might be different) only contains .elc files in the directory /usr/share/emacs/25.1/lisp/, while the .el files are located in a seperated package named emacs-el.

in function ergoemacs-map-properties--override-map-p, this line of code:

(if (string-match-p ergoemacs-map-properties--deferred-hooks-directory-regexp (find-lisp-object-file-name (nth 2 key) (symbol-function (nth 2 key)))) ...)

the call to find-lisp-object-file-name could return nil when the according .el file cannot be found, then the string-match-p function would complain about the function argument type being wrong. when the hook throws, emacs simply backlists the hook which essentially disables ergoemacs' overriding key map.

of course, those who builds emacs from source won't encounter this problem. however, there doesn't seem to be an easy solution for ergoemacs-mode alone. simply check the return value of find-lisp-object-file-name would work around functionally , but there still generates a lot of messages in the format "no library XXYYZZ.el in search path". almost every command would generate it. I am not sure where this message is originated, but I assume it has something to do with the hooks.

I am not sure it is intended behavior or bug , but imo, find-lisp-object-file-name should return the name of .elc file which loaded, in case the .el files don't exist, instead of returning nil.

but in my case, I simply installed the emacs-el package. anyway.

mattfidler commented 7 years ago

Thanks I look into it next week

mattfidler commented 3 years ago

Reopen if you have issues on the new github version