emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/pdf-tools 5b58c6bcc3 3/8: Add command and submenu to switc


From: ELPA Syncer
Subject: [nongnu] elpa/pdf-tools 5b58c6bcc3 3/8: Add command and submenu to switch between selection styles
Date: Sat, 10 Jun 2023 16:02:07 -0400 (EDT)

branch: elpa/pdf-tools
commit 5b58c6bcc3744c9ad984ba60448f8e98b994f913
Author: Augusto Stoffel <arstoffel@gmail.com>
Commit: Vedang Manerikar <ved.manerikar@gmail.com>

    Add command and submenu to switch between selection styles
    
    Make it possible to set `pdf-view-selection-style` from Easy Menu.
    
    Closes: #190
---
 lisp/pdf-misc.el | 13 +++++++++++++
 lisp/pdf-view.el | 14 ++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/lisp/pdf-misc.el b/lisp/pdf-misc.el
index b6bb896d1a..bcba8aeabc 100644
--- a/lisp/pdf-misc.el
+++ b/lisp/pdf-misc.el
@@ -143,6 +143,19 @@
     ["Copy region" pdf-view-kill-ring-save
      :keys "\\[kill-ring-save]"
      :active (pdf-view-active-region-p)]
+    ("Selection style"
+     ["Glyph" (pdf-view-set-selection-style 'glyph)
+      :style radio
+      :selected (eq pdf-view-selection-style 'glyph)
+      :help "When dragging the mouse, select individual characters."]
+     ["Word" (pdf-view-set-selection-style 'word)
+      :style radio
+      :selected (eq pdf-view-selection-style 'word)
+      :help "When dragging the mouse, select entire words."]
+     ["Line" (pdf-view-set-selection-style 'line)
+      :style radio
+      :selected (eq pdf-view-selection-style 'line)
+      :help "When dragging the mouse, select entire lines."])
     "--"
     ["Isearch document" isearch-forward
      :visible (bound-and-true-p pdf-isearch-minor-mode)]
diff --git a/lisp/pdf-view.el b/lisp/pdf-view.el
index c1fc21b754..9253721e7a 100644
--- a/lisp/pdf-view.el
+++ b/lisp/pdf-view.el
@@ -1624,6 +1624,20 @@ the `convert' program is used."
       (dolist (f (cons result images))
         (when (file-exists-p f)
           (delete-file f))))))
+
+(defun pdf-view-set-selection-style (&optional style)
+  "Set `pdf-view-selection-style' to STYLE in the current buffer.
+
+When called interactively or without an argument, cycle between
+the selection styles."
+  (interactive)
+  (unless style
+    (setq style (or (cadr (memq pdf-view-selection-style '(glyph word line)))
+                    'glyph))
+    (message "Setting selection style to `%s'." style))
+  (pdf-view-deactivate-region)
+  (setq-local pdf-view-selection-style style))
+
 
 ;; * ================================================================== *
 ;; * Bookmark + Register Integration



reply via email to

[Prev in Thread] Current Thread [Next in Thread]