Skip to content

Commit

Permalink
Fix cumbersome pdf-tools selection behavior
Browse files Browse the repository at this point in the history
Currently, due to evil entering visual state, the selection behavior in
pdf-tools is different from and more cumbersome than in vanilla Emacs (see
emacs-evil/evil#1671).

This commit prevents evil from entering evil-state in pdf-mode and moves the
(only) visual-state yank binding to the evilified-map.

It doesn't look pretty, but it is working much better than before.
  • Loading branch information
dalanicolai authored and smile13241324 committed Sep 15, 2022
1 parent 8d4c114 commit 438fcee
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions layers/+readers/pdf/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
:mode (("\\.pdf\\'" . pdf-view-mode))
:init
(spacemacs//pdf-tools-setup-transient-state)

(add-hook 'pdf-view-mode-hook
(lambda () (add-hook 'evil-evilified-state-entry-hook
(lambda (remove-hook 'activate-mark-hook 'evil-visual-activate-hook t))
nil t)))

:config
(progn
(pdf-tools-install)
Expand Down Expand Up @@ -63,8 +69,6 @@
"O" 'pdf-outline
"n" 'pdf-view-midnight-minor-mode)

(evil-define-key 'visual pdf-view-mode-map "y" 'pdf-view-kill-ring-save)

;; TODO: Make `/', `?' and `n' work like in Evil
(evilified-state-evilify-map pdf-view-mode-map
:mode pdf-view-mode
Expand Down Expand Up @@ -98,7 +102,8 @@
"r" 'pdf-view-revert-buffer
"o" 'pdf-links-action-perform
"O" 'pdf-outline
"zr" 'pdf-view-scale-reset)
"zr" 'pdf-view-scale-reset
"y" 'pdf-view-kill-ring-save)
(evilified-state-evilify-map pdf-outline-buffer-mode-map
:mode pdf-outline-buffer-mode
:eval-after-load pdf-outline
Expand Down

0 comments on commit 438fcee

Please sign in to comment.