ergoemacs / ergoemacs-mode

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

issue with dependencies on other packages, maybe #453

Closed nerditation closed 3 years ago

nerditation commented 7 years ago

I am using the latest ergoemacs-mode package from the "melpa.org" repository. emacs version: GNU Emacs 25.1.1 (x86_64-w64-mingw32)

when I try to use the describe-key command (<f1> k), emacs gave a beep and showed a message in the minibuffer: symbol's value as variable is void: icicle-ido-like-mode

FYI, <f1> c doesn't have any problem, only <f1> k has errors.

so I did a little investigation. I was not quite sure I completely understood the code, but I assume ergoemacs-mode tried to detect some extra packages and gave them special support if existed. icicles is one of them. multiple-cursors is another. apparently some boundp guards were missing.

since I am not confident to modify ergoemacs-mode myself, I simply installed icicles and multiple-cursors and now everything works.

I suggest either:

a) list packages like icicles as dependencies, or b) use with-eval-after-load to support optional packages so no need to use boundp everywhere.

BTW, when I generate my ergoemacs key map picture, I found it located in ~/.emacs.d/eurgoemacs-extras, note the typo eurgoemacs. a quick grep gives 2 eurgoemacs result, both inside strings.

mattfidler commented 7 years ago

I think this should fix it. It seems to fix it for me. Let me know.

nerditation commented 7 years ago

unfortunately, it doesn't work for me.

to test it, I deleted the ergoemacs-mode from the ~/.emacs.d/elpa directory, and cloned the latest GitHub repository. then I run emacs -Q, and then put the following code into the scratch buffer:

(package-initialize) ; make sure required dependencies such as undo-tree can be loaded
(add-to-list 'load-path "W:/github.com/ergoemacs/ergoemacs-mode/")
(require 'ergoemacs-mode)
(ergoemacs-mode 1)
(setq debug-on-error t)

then I run M-x eval-buffer command. when I try to use describe-key, I still got the "symbol's value as variable is void: icicle-ido-like-mode" error message, also got this HORRIBLE stacktrace, which contains special characters and I can't even paste it into other programs like notepad, so I save it to a file using emacs. see the attached file.

stacktrace-describe-key.txt

also, while testing, I found another weird error: if I press <f1> k immediately after eval-buffer, I will get args-out-of-range error, with a huge stacktrace too. this stack trace doesn't seem to have special characters though. but this only happened when it is the very first command after ergoemacs is loaded (through eval-buffer). if I enter any other command like move cursor, then I wouldn't get the args-out-of-range error, but only the original "Symbol's value is void" one.

stacktrace-first-command.txt

mattfidler commented 7 years ago

Thanks for the report. I can't read the first stack-trace, unfortunately. I can read the second though.

nerditation commented 7 years ago

I tried to examine the problem, and managed to find some clue. the inner most call stack is actually inside a lambda, which contains compiled byte code, thus results those unprintable characters in the stacktrace message. the lambda is defined inside the function help--binding-locus, at line 704 of file help.el.

simply put, the command <f1> k calls help--binding-locus to look up the command name and doc for the given key, and the help--binding-locus function does this by looping through minor-mode-map-alist and check each entry. most of the giant stacktrace is actually the contents of minor-mode-map-alist. this list also contains byte codes of compiled lisp functions with unprintable characters inside. the offending entry which trigger the error is:

((icicle-ido-like-mode keymap (ergoemacs-labeled lambda nil (interactive) (quote (:map-key (cond-map icicle-ido-like-mode us)))) keymap (keymap (remap keymap (ergoemacs-apropos-user-options . apropos-user-options)))))

what remains unclear to me is which code added the icicle-ido-like-mode map to this minor-mode-map-alist. I am unfamiliar with the codebase of ergoemacs-mode, and grep doesn't give me any useful information. I suppose it was done via some indirection layers.

nerditation commented 7 years ago

also did some google and found this similar issue: syl20bnr/spacemacs#8027, and there is a similar explanation in the comments.

mattfidler commented 7 years ago

That is fascinating.

The minor-mode-map-alist is modified in ergoemacs-map--minor-mode-map-alist. This function does the following:

mattfidler commented 7 years ago

Sorry about the accidental close. I deferred adding multiple-cursors-mode and icicle-ido-like-mode until the offending packages are loaded (I think). I am so grateful for your help. For me it works just fine.

I'm assuming that many packages assume the key in the minor-mode-map-alist is actually bound. Therefore ergoemacs-mode's old treatment of this issue caused problems.

nerditation commented 7 years ago

thanks, now it fixed the "symbol's value as variable is void" problem, but the args-out-of-range problem remains. I guess it's somewhat related with #438, because it only occur on the very first command invoked after ergoemacs-mode loaded. here is the stacktrace I get:


Debugger entered--Lisp error: (args-out-of-range "" -1)
  signal(args-out-of-range ("" -1))
  ergoemacs-command-loop--grow-interactive(describe-key t nil)
  ergoemacs-command-loop--call-interactively(describe-key t)
  ergoemacs-command-loop--execute(describe-key)
  ergoemacs-command-loop--internal()
  ergoemacs-command-loop--timer()
  apply(ergoemacs-command-loop--timer nil)
  timer-event-handler([t 0 0 50000 nil ergoemacs-command-loop--timer nil idle 0])
nerditation commented 7 years ago

I did a little more experiments. here's what I found:

after ergoemacs-mode loaded, there was a message in the minibuffer:

Started ‘ergoemacs-mode’. Total startup time 1.379652 (Load: 1.204507, Initialize:0.175145)

as long this message is in the minibuffer, certain commands would trigger this args-out-of-range error, <f1> k is one of such commands. interestingly, both <f1> k and C-h k would trigger the error, while M-a describe-key wouldn't.

if you first press any keys/commands that would clear the message in the minibuffer, like move cursor or mouse click (click on title bar won't clear the message though), then <f1> k will just work, no error generated.

more interstingly, if debug-on-error flag is set and thus a stacktrace window pops up, then as long as you don't delete that stacktrace window, subsequent <f1> k will always generate the error, including M-a describe-key, but the error message sometimes could be (args-out-of-range "" 0), sometimes be (args-out-of-range "" -1)

in practice, I suppose this wouldn't be a big issue. only the very first command might trigger this error, which could be confusing sometimes, but generally wouldn't affect very much.

but since #438 has very similar situation, it might potentially interfere with other packages. for me, it happened helm is not affected.

TinaRussell commented 6 years ago

I’m getting the “args out of range” error with \<f1> k (followed by any key combination), and then if I run “M-x describe-key” followed by any key combination I get the “Symbol’s value as a variable is void: icicle-ido-like-mode” error. (There’s no difference whether or not this is the first time the command, or any other, was called, nor does there seem to be any difference based on what’s in the minibuffer.)

I installed icicles and multiple-cursors to try to fix this, but no luck. I’m using ErgoEmacs 5.16.10.12 from melpa-stable.

mattfidler commented 6 years ago

I think this was fixed in the unstable version. I use the version every day, but there are some bugs that I haven't had time to fix. You could try running ergoemacs-mode in melpa unstable and see if that fixes the problem...

mattfidler commented 3 years ago

Reopen if you have issues on the new github version