pdf-tools icon indicating copy to clipboard operation
pdf-tools copied to clipboard

Keep the selection while copying and highlighting

Open ghost opened this issue 2 years ago • 3 comments

When I make a comment in a pdf file using pdf-tools I first select the text and then operate on it, using one of the highlight options. If I want to copy text I do the same. However, many times I would like both to highlight and copy at the same time, but if I perform either a copy or highlight the text is thereafter immediately deselected. I would like to change this behavior, so that selection persists. Is this possible?

ghost avatar Aug 18 '22 05:08 ghost

Currently this is not supported. It is relatively easy to add this as a feature to the copy command, and slightly more difficult to add it as a feature to the annot commands.

I will happily accept a PR for this which introduces a flag to control the desired behaviour.

vedang avatar Aug 20 '22 19:08 vedang

I have a customized function to do copy and then org-capture and then a default highlight style. You may try to remove the org-capture and bind this new function to a key shortcut.

(defun capture-notes-as-highlighting()
  (interactive)
  (kill-new (replace-regexp-in-string "-\n" "" (car (pdf-view-active-region-text))))
  (org-capture 1 "Q")
  (org-capture-finalize)
  (pdf-annot-add-highlight-markup-annotation (pdf-view-active-region t) "yellow")
  )

tongjie-chen avatar Aug 22 '22 03:08 tongjie-chen

This works when you bind a key to it. Ideally one would also like to integrate it with the right click menu.

ghost avatar Aug 22 '22 05:08 ghost