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

image-mode and pdf-tools conflict #23

Closed
Ambrevar opened this issue Nov 9, 2017 · 6 comments
Closed

image-mode and pdf-tools conflict #23

Ambrevar opened this issue Nov 9, 2017 · 6 comments
Labels

Comments

@Ambrevar
Copy link
Collaborator

Ambrevar commented Nov 9, 2017

Depending on the load order, one mode takes precedence over the other which makes the latter unusable.

This might have to do with an inheritance problem.
Bug was reported upstream: politza/pdf-tools#324

@Ambrevar Ambrevar added the MELPA label Nov 9, 2017
@jojojames
Copy link
Collaborator

I don't use pdf-tools so won't be able to look at it directly.

I'm curious what the minor map alist looks like before/after you normalize keymaps?

(evil-normalize-keymaps)

evil-mode-map-alist <----------

@Ambrevar
Copy link
Collaborator Author

The before/after keymaps are the same.
Let me know if you want a dump.

A first glance at the problem reveals that

  • doc-view and image-mode suffer from the same conflict.
  • image-mode-map contains quite a few "remap". This could be the very root of the issue.

@Ambrevar
Copy link
Collaborator Author

By the way since doc-view is also concerned, you should be able to reproduce :)

@Ambrevar
Copy link
Collaborator Author

Some first experiments:

  • The conflict happens in any state, Emacs state included.

  • Emacs without evil is fine.

  • I don't think it has anything to do with remap as j is not a remapped
    binding. I am not sure though.

  • If doc-view / pdf-view maps are set first, then everything is OK.

  • If image-mode map is set first, then the last binding will override the rest.

I tried using that result over the loading process of evil-collection to get
doc-view and image-mode to work but it did not. There must be something else.

Initial setup:

(require 'evil)
(evil-mode 1)

Some tests:

;;; Issue: doc-view overrides image-mode.

(evil-set-initial-state 'image-mode 'motion)
(evil-define-key 'motion image-mode-map "j" 'message-news)
(find-file "bar.png")

(evil-set-initial-state 'doc-view-mode 'motion)
(evil-define-key 'motion doc-view-mode-map "j" 'emacs-version)
(find-file "foo.odt")
;;; Change order.
;;; Issue: None.

(evil-set-initial-state 'doc-view-mode 'motion)
(evil-define-key 'motion doc-view-mode-map "j" 'emacs-version)
(find-file "foo.odt")

(evil-set-initial-state 'image-mode 'motion)
(evil-define-key 'motion image-mode-map "j" 'message-news)
(find-file "bar.png")
;;; Emacs state suffers from the same conflict.
;;; Issue: doc-view overrides image-mode.

(evil-set-initial-state 'image-mode 'emacs)
(evil-define-key 'emacs image-mode-map "j" 'message-news)
(find-file "bar.png")

(evil-define-key 'emacs doc-view-mode-map "j" 'emacs-version)
(find-file "foo.odt")
;;; Emacs without Evil is fine.
;;; Issue: None.

(find-file "bar.png")
(define-key image-mode-map "j" 'message-news)
(find-file "foo.odt")
(define-key doc-view-mode-map "j" 'emacs-version)
;;; Issue: image-mode binding is undefined

(evil-set-initial-state 'image-mode 'emacs)
(find-file "bar.png")
(evil-define-key 'emacs doc-view-mode-map "j" 'emacs-version)
(find-file "foo.odt")
(evil-define-key 'emacs image-mode-map "j" 'message-news)
;;; Issue: Both bindings are undefined.

(evil-set-initial-state 'image-mode 'emacs)
(find-file "bar.png")
(find-file "foo.odt")
(evil-define-key 'emacs doc-view-mode-map "j" 'emacs-version)
(evil-define-key 'emacs image-mode-map "j" 'message-news)
;;; The starred functions trigger the same issue.
;;; Issue: doc-view overrides image-mode

(evil-set-initial-state 'image-mode 'emacs)
(require 'image-mode)
(require 'doc-view)
(evil-define-key* 'emacs image-mode-map "j" 'message-news)
(evil-define-key* 'emacs doc-view-mode-map "j" 'emacs-version)
(find-file "bar.png")
(find-file "foo.odt")

@jojojames jojojames mentioned this issue Nov 14, 2017
@Ambrevar
Copy link
Collaborator Author

emacs-evil/evil#982 fixes this.

@Ambrevar
Copy link
Collaborator Author

Special thanks to @noctuid, this was a hard one.

Ambrevar pushed a commit that referenced this issue Aug 5, 2020
Currently getting bound to image-scroll-up and image-scroll-down from evil-collection-image.el. Not sure if it is relevant, but evil-collection-image.el has a TODO referencing this closed issue: #23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants