Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix up Info-mode #501

Merged
merged 4 commits into from
Sep 4, 2021
Merged

Fix up Info-mode #501

merged 4 commits into from
Sep 4, 2021

Conversation

MaxCan-Code
Copy link
Contributor

No description provided.

@KSSysLab
Copy link

KSSysLab commented Jul 7, 2021

I'm curious about why digit-argument bindings are not working out of box.

When pressing 0, Emacs will try to find the keymap in this order. It can be confirmed that emulation-mode-map-alists will be used. And the first element is evil-mode-map-alist. Let me dig deeper.

;; eval under evil-normal-state
(mapcar 'car evil-mode-map-alist)
;;=> (t evil-normal-state-local-minor-mode outline-minor-mode evil-collection-unimpaired-mode t evil-normal-state-minor-mode t evil-motion-state-local-minor-mode visual-line-mode evil-collection-unimpaired-mode evil-motion-state-minor-mode)

Found that evil-motion-state-minor-mode is in this alist. And

;; eval under evil-normal-state
(describe-keymap (alist-get 'evil-motion-state-minor-mode evil-mode-map-alist))

;; ...
;; ,               evil-repeat-find-char-reverse
;; -               evil-previous-line-first-non-blank
;; /               evil-search-forward
;; 0               evil-digit-argument-or-evil-beginning-of-line
;; 1 .. 9          digit-argument
;; :               evil-ex
;; ;               evil-repeat-find-char
;; ?               evil-search-backward
;; B               evil-backward-WORD-begin
;; E               evil-forward-WORD-end
;; ...

[1, 9] have already bound to digit-argument.

So when I press 0 in evil normal state, Emacs should find digit-argument. However, Emacs runs Info-nth-menu-item which is bound in Info-mode-map. Note that Info-mode-map is the 7th candidate when lookup keys.

@KSSysLab
Copy link

KSSysLab commented Jul 7, 2021

evil-overriding-maps is a variable defined in ‘evil-vars.el’.

Its value is shown below.

  You can customize this variable.

Keymaps that should override Evil maps.
Entries have the form (MAP-VAR . STATE), where MAP-VAR is
a keymap variable and STATE is the state whose bindings
should be overridden. If STATE is nil, all states are
overridden.

Value:
((Buffer-menu-mode-map)
 (color-theme-mode-map)
 (comint-mode-map)
 (compilation-mode-map)
 (grep-mode-map)
 (dictionary-mode-map)
 (ert-results-mode-map . motion)
 (Info-mode-map . motion)
 (speedbar-key-map)
 (speedbar-file-key-map)
 (speedbar-buffers-key-map))

[back]

Info-mdoe-map is in evil-overriding-maps, so that the commands bound in evil motion state map will have no effects.

@MaxCan-Code
Copy link
Contributor Author

Info-nth-menu-item still overrides digit-argument after I delete Info-mode-map from evil-overriding-maps:

(defun evil-collection-info-setup ()
"Set up `evil' bindings for `info-mode'."
(evil-collection-set-readonly-bindings 'Info-mode-map)
(evil-set-initial-state 'Info-mode 'normal)
(evil-collection-define-key 'normal 'Info-mode-map

(defun evil-collection-info-setup ()
  "Set up `evil' bindings for `info-mode'."
  (evil-collection-set-readonly-bindings 'Info-mode-map)
+ (assoc-delete-all 'Info-mode-map evil-overriding-maps)
  (evil-set-initial-state 'Info-mode 'normal)
  (evil-collection-define-key 'normal 'Info-mode-map

Let me know if there's a better way to do this

@condy0919
Copy link
Collaborator

If you're a use-package user, use :custom to customize the evil-overriding-maps.

@condy0919
Copy link
Collaborator

FYI, I propose to change the default value of evil-overriding-maps emacs-evil/evil#1488

@MaxCan-Code
Copy link
Contributor Author

MaxCan-Code commented Jul 8, 2021

When that change comes through, I can remove the manual evil overrides in

;; goto
"gd" 'Info-goto-node ; TODO: "gd" does not match the rationale of "go to definition". Change?
"gm" 'Info-menu
"m" 'evil-set-marker ; Else this would be `Info-menu'.
"gt" 'Info-top-node
"t" 'evil-find-char-to ; Else this would be `Info-top-node'.
"gT" 'Info-toc
"T" 'evil-find-char-to-backward ; Else this would be `Info-toc'.
"gf" 'Info-follow-reference
"f" 'evil-find-char ; Else this would be `Info-follow-reference'.
;; TODO: "[" and "]" are Emacs default for fine-grained browsing.
and
"g?" 'Info-summary
"?" evil-collection-evil-search-backward) ; Else this would be `Info-summary'.
(evil-collection-define-key 'visual 'Info-mode-map
"l" 'evil-forward-char
"h" 'evil-backward-char
"w" 'evil-forward-word-begin
"b" 'evil-backward-word-begin
"e" 'evil-forward-word-end
"f" 'evil-find-char
"t" 'evil-find-char-to
"T" 'evil-find-char-to-backward
"0" 'evil-digit-argument-or-evil-beginning-of-line
"gg" 'evil-goto-first-line)

@condy0919
Copy link
Collaborator

The PR is merged.

> "gd" does not match the rationale of "go to definition"
* `Info-goto-node` bound to `g` in emacs Info mode, bind to `g G` instead
* `L` taken by evil, `g L` for `Info-history` instead
@MaxCan-Code
Copy link
Contributor Author

The mappings are fixed

@condy0919 condy0919 merged commit 7c2cb5a into emacs-evil:master Sep 4, 2021
@condy0919
Copy link
Collaborator

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants