Skip to content

Commit f1bb473

Browse files
45mgcondy0919
authored andcommitted
pdf: disable visual-mode
Evil's visual-mode does not know how to select text within a PDF, and instead selects the entire pdf image, which is useless and counterintuitive - see doomemacs/doomemacs#6286, #683.
1 parent 556ca31 commit f1bb473

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

modes/pdf/evil-collection-pdf.el

+15-1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,18 @@ Consider COUNT."
9898
(or reg ?\")
9999
(mapconcat #'identity txt nil))))
100100

101+
(defun evil-collection-pdf-disable-visual-mode ()
102+
"Don't enter visual-mode when the mark is activated.
103+
Rationale: pdf-view allows using the region to select text within the pdf,
104+
but evil-mode does not know how to do this. It selects entire pdf images
105+
instead, which is useless and counterintuitive."
106+
(add-hook 'evil-local-mode-hook
107+
(lambda () (remove-hook
108+
'activate-mark-hook
109+
'evil-visual-activate-hook
110+
t))
111+
nil t))
112+
101113
;;;###autoload
102114
(defun evil-collection-pdf-setup ()
103115
"Set up `evil' bindings for `pdf-view'."
@@ -195,7 +207,9 @@ Consider COUNT."
195207
(evil-collection-define-key 'normal 'pdf-view-mode-map
196208
(kbd "C-u") 'pdf-view-scroll-down-or-previous-page))
197209

198-
(evil-collection-define-key 'visual 'pdf-view-mode-map
210+
(add-hook 'pdf-view-mode-hook #'evil-collection-pdf-disable-visual-mode)
211+
212+
(evil-collection-define-key 'normal 'pdf-view-mode-map
199213
"y" 'evil-collection-pdf-yank)
200214

201215
(evil-collection-inhibit-insert-state 'pdf-history-minor-mode-map)

0 commit comments

Comments
 (0)