Skip to content

Commit

Permalink
Add command and submenu to switch between selection styles
Browse files Browse the repository at this point in the history
Make it possible to set `pdf-view-selection-style` from Easy Menu.

Closes: vedang#190
  • Loading branch information
astoff authored and vedang committed Jun 10, 2023
1 parent fb6616c commit 5b58c6b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lisp/pdf-misc.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
14 changes: 14 additions & 0 deletions lisp/pdf-view.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5b58c6b

Please sign in to comment.