emacs-evil / evil-collection

A set of keybindings for evil-mode
GNU General Public License v3.0
1.2k stars 275 forks source link

Possible regression `(void-variable foo-map)` when using `evil-collection-setup-hook` #753

Closed gagbo closed 1 year ago

gagbo commented 1 year ago

Linked to #750, and to https://github.com/doomemacs/doomemacs/issues/7408

There's something weird going on with evil-collection-setup-hooks that seemed to appear since the change from evil-delay to evil-with-delay in https://github.com/emacs-evil/evil-collection/commit/de0b62b604e87ce43e2adc9e09bcd5174e8b877a and/or the usage of Emacs 29.1.

Even though keymaps are supposed to be undefined (I don't use dired-hacks, so dired-filter-mark-map is indeed never defined), my evil-collection-setup-hook that does keymap translations on the fly still tries do access the map, leading to this (lengthy) backtrace below:

Long backtrace, ignore the long lists of strings; those are the remappings
Debugger entered--Lisp error: (void-variable dired-filter-mark-map)
  evil-collection--translate-key(normal dired-filter-mark-map ("p" "h" "P" "H" "t" "j" "T" "J" "s" "k" "S" "K" "r" "l" "R" "L" "j" "t" "J" "T" "k" "s" "K" "S" "\20" "\10" "\20" "\10" "\24" "\n" "\24" "\n" "\23" "\13" "\23" "\13" "\22" "\f" "\22" "\f" "\n" "\24" "\n" "\24" "\13" "\23" "\13" "\23" [134217840] [134217832] ...) nil)
  #f(compiled-function (name &rest _) #)(evil-delay-in-\'\`)
  apply(#f(compiled-function (name &rest _) #) evil-delay-in-\'\`)
  #f(compiled-function (&rest args2) #)()
  evil-collection-translate-key((normal motion visual operator) (dired-mode-map dired-filter-mark-map dired-filter-map) "p" "h" "P" "H" "t" "j" "T" "J" "s" "k" "S" "K" "r" "l" "R" "L" "j" "t" "J" "T" "k" "s" "K" "S" "\20" "\10" "\20" "\10" "\24" "\n" "\24" "\n" "\23" "\13" "\23" "\13" "\22" "\f" "\22" "\f" "\n" "\24" "\n" "\24" "\13" "\23" "\13" "\23" ...)
  (let ((pr-style (or pr-style +layout-optimot-pr-rotation-style))) (evil-collection-translate-key '(normal motion visual operator) keymaps "p" "h" "P" "H" "t" "j" "T" "J" "s" "k" "S" "K" "r" "l" "R" "L" "j" "t" "J" "T" "k" "s" "K" "S" (kbd "C-p") (kbd "C-h") (kbd "C-P") (kbd "C-H") (kbd "C-t") (kbd "C-j") (kbd "C-T") (kbd "C-J") (kbd "C-s") (kbd "C-k") (kbd "C-S") (kbd "C-K") (kbd "C-r") (kbd "C-l") (kbd "C-R") (kbd "C-L") (kbd "C-j") (kbd "C-t") (kbd "C-J") (kbd "C-T") (kbd "C-k") (kbd "C-s") (kbd "C-K") ...) (if (eq pr-style 'ergodis) (evil-collection-translate-key '(normal motion visual operator) keymaps "h" "r" "H" "R" "l" "c" "L" "P" (kbd "C-h") (kbd "C-r") (kbd "C-H") (kbd "C-R") (kbd "C-l") (kbd "C-p") (kbd "C-L") (kbd "C-P") (kbd "M-h") (kbd "M-r") (kbd "M-H") (kbd "M-R") (kbd "M-l") (kbd "M-p") (kbd "M-L") (kbd "M-P") :destructive nil) (evil-collection-translate-key '(normal motion visual operator) keymaps "h" "p" "H" "P" "l" "r" "L" "R" (kbd "C-h") (kbd "C-p") (kbd "C-H") (kbd "C-P") (kbd "C-l") (kbd "C-r") (kbd "C-L") (kbd "C-R") (kbd "M-h") (kbd "M-p") (kbd "M-H") (kbd "M-P") (kbd "M-l") (kbd "M-r") (kbd "M-L") (kbd "M-R") :destructive nil)) (evil-collection-translate-key '(insert) keymaps (kbd "M-p") (kbd "M-h") (kbd "M-P") (kbd "M-H") (kbd "M-t") (kbd "M-j") (kbd "M-T") (kbd "M-J") (kbd "M-s") (kbd "M-k") (kbd "M-S") (kbd "M-K") (kbd "M-r") (kbd "M-l") (kbd "M-R") (kbd "M-L") (kbd "M-j") (kbd "M-t") (kbd "M-J") (kbd "M-T") (kbd "M-k") (kbd "M-s") (kbd "M-K") (kbd "M-S") :destructive nil) (if (eq pr-style 'ergodis) (evil-collection-translate-key '(insert) keymaps (kbd "M-h") (kbd "M-r") (kbd "M-H") (kbd "M-R") (kbd "M-l") (kbd "M-p") (kbd "M-L") (kbd "M-P") :destructive nil) (evil-collection-translate-key '(insert) keymaps (kbd "M-h") (kbd "M-p") (kbd "M-H") (kbd "M-P") (kbd "M-l") (kbd "M-r") (kbd "M-L") (kbd "M-R") :destructive nil)) (evil-collection-translate-key '(normal motion visual operator) keymaps "«" "<" "»" ">" :destructive nil) (evil-collection-translate-key '(normal motion visual operator) keymaps "à" "^" "À" "0" :destructive nil))
  +layout-optimot-rotate-keymaps((dired-mode-map dired-filter-mark-map dired-filter-map))
  +layout-optimot-rotate-evil-collection-keymap(dired (dired-mode-map dired-filter-mark-map dired-filter-map))
  run-hook-with-args(+layout-optimot-rotate-evil-collection-keymap dired (dired-mode-map dired-filter-mark-map dired-filter-map))
  #f(compiled-function () #)()
  eval-after-load(dired #f(compiled-function () #))
  evil-collection-init((dired))
  (condition-case err (evil-collection-init (list module)) ((debug error) (message "evil-collection error: %s" err) nil))
  (if (memq (or (car-safe module) module) disabled-list) nil (if doom-inhibit-log nil (doom--log "editor:evil: loading evil-collection-%s %s" (or (car-safe module) module) (if after-init-time "" "(too early!)"))) (condition-case err (evil-collection-init (list module)) ((debug error) (message "evil-collection error: %s" err) nil)))
  +evil-collection-init(dired (anaconda-mode buff-menu calc comint company custom eldoc elisp-mode ert free-keys helm help indent image kotlin-mode outline replace shortdoc simple slime lispy))
  (closure ((mode . dired)) nil (+evil-collection-init mode +evil-collection-disabled-list))()
  eval-after-load-helper("/opt/homebrew/Cellar/emacs-plus@29/29.1/share/emac...")
  do-after-load-evaluation("/opt/homebrew/Cellar/emacs-plus@29/29.1/share/emac...")
  require(dired)
  byte-code("\300\301!\210\302\303\304\305\306\301%\210\307\310\311\312\313DD\314\315\316\306\303&\7\207" [require dired custom-declare-group dired-x nil "Extended directory editing (dired-x)." :group custom-declare-variable dired-bind-vm funcall function #f(compiled-function () #) "Non-nil means \"V\" runs `dired-vm', otherwise \"V\" r..." :type boolean] 8)
  require(dired-x)
  byte-code("\300\301!\210\300\302!\210\300\303!\210\300\304!\210\300\305!\210\300\306!\210\307\310\311\312\313\314%\210\315\316\317\320\321DD\322\313\310\323\324&\7\210\315\325\317..." [require tab-bar project vc seq cl-lib dired-x custom-declare-group tabspaces nil "Manage tab/workspace buffers." :group convenience custom-declare-variable tabspaces-default-tab funcall function #f(compiled-function () #) "Specify a default tab by name TAB." :type string tabspaces-remove-to-default #f(compiled-function () #) "Add buffer to default tabspace when removed from c..." boolean tabspaces-include-buffers #f(compiled-function () #) "Buffers that should always get included in a new t..." (repeat string) tabspaces-use-filtered-buffers-as-default #f(compiled-function () #) "When t, remap `switch-to-buffer' to `tabspaces-swi..." tabspaces-keymap-prefix #f(compiled-function () #) "Key prefix for the tabspaces-prefix-map keymap."] 8)
  (tabspaces-mode 1)
  doom--tabspace-setup()
  run-hooks(after-init-hook delayed-warnings-hook)
  command-line()
  normal-top-level()

I know the stacktrace has some Doom Emacs in the middle, but it's a regression here, and the doom code called here hasn't changed in a while so I think it's still relevant.

I still don't know what evil-delay is supposed to do different than evil-with-delay, nor whether the (evil-collection--translate... calls in the new version are supposed to stay unquoted, but there's something that should not be evaluated that started to become evaluated.

jojojames commented 1 year ago

https://github.com/emacs-evil/evil-collection/issues/750 dup? Closing this one anyways.