summaryrefslogtreecommitdiff
path: root/modes/pdf
diff options
context:
space:
mode:
author45mg <45mm.cartridge421@slmail.me>2024-03-16 10:31:06 +0530
committerYoumu <condy0919@gmail.com>2024-03-20 02:15:19 +0800
commitf1bb4733def5a1b75d3a9d1b4d2226b6fc90407a (patch)
treec9279e9b72a908393adece5fc5bfcfc032fe1855 /modes/pdf
parent556ca31ce63061d4f979bf805805aa13b3c40847 (diff)
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, emacs-evil/evil-collection#683.
Diffstat (limited to 'modes/pdf')
-rw-r--r--modes/pdf/evil-collection-pdf.el16
1 files changed, 15 insertions, 1 deletions
diff --git a/modes/pdf/evil-collection-pdf.el b/modes/pdf/evil-collection-pdf.el
index 965bd11..e998695 100644
--- a/modes/pdf/evil-collection-pdf.el
+++ b/modes/pdf/evil-collection-pdf.el
@@ -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'."
@@ -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)