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

pdf: disable visual-mode #794

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion modes/pdf/evil-collection-pdf.el
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,18 @@ Consider COUNT."
(or reg ?\")
(mapconcat #'identity txt nil))))

(defun evil-collection-pdf-disable-visual-mode ()
"Don't enter visual-mode when the mark is activated.
Rationale: pdf-view allows using the region to select text within the pdf,
but evil-mode does not know how to do this. It selects entire pdf images
instead, which is useless and counterintuitive."
(add-hook 'evil-local-mode-hook
(lambda () (remove-hook
'activate-mark-hook
'evil-visual-activate-hook
t))
nil t))

;;;###autoload
(defun evil-collection-pdf-setup ()
"Set up `evil' bindings for `pdf-view'."
Expand Down Expand Up @@ -195,7 +207,9 @@ Consider COUNT."
(evil-collection-define-key 'normal 'pdf-view-mode-map
(kbd "C-u") 'pdf-view-scroll-down-or-previous-page))

(evil-collection-define-key 'visual 'pdf-view-mode-map
(add-hook 'pdf-view-mode-hook #'evil-collection-pdf-disable-visual-mode)

(evil-collection-define-key 'normal 'pdf-view-mode-map
"y" 'evil-collection-pdf-yank)

(evil-collection-inhibit-insert-state 'pdf-history-minor-mode-map)
Expand Down
Loading