branch: externals/clipboard-collector
commit 440c2804599d1b54fbc010e5d92a991dc9a0fef9
Author: Clemens Radermacher <[email protected]>
Commit: Clemens Radermacher <[email protected]>
Use transient map
---
README.org | 8 ++++----
clipboard-collector.el | 9 ++++++++-
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/README.org b/README.org
index a1f1f4f..7e2306c 100644
--- a/README.org
+++ b/README.org
@@ -15,11 +15,11 @@ You can use it to simply collect multiple entries by binding
#+END_SRC
Once called the clipboard is observed and any text that is copied/killed gets
-collected (even when done outside of Emacs). To finish use =C-c C-c= in any
-buffer to insert the collected items separated by newlines.
+collected. To finish use =C-c C-c= in any buffer to insert the collected items
+separated by newlines.
-If you want to have specific rules which items are added and maybe transform
-them before collecting them you can create you own commands using
+If you want to have specific rules for which items get collected and maybe
+transform them before collecting them you can create you own commands using
=clipboard-collector-create= macro.
Here is an example for collecting contact information from a website for org
diff --git a/clipboard-collector.el b/clipboard-collector.el
index 7c7cf4e..eb82512 100644
--- a/clipboard-collector.el
+++ b/clipboard-collector.el
@@ -42,11 +42,17 @@
(define-minor-mode clipboard-collector-mode
"Start collecting clipboard items.
-Rules used are defined in `clipboard-collector--rules'."
+Rules used are defined in `clipboard-collector--rules'. Because
+this mode is only for temporary use and you want its bindings to
+have precedence over all other ones when activated,
+`clipboard-collector-mode-map' is made transient while this mode
+is active."
:lighter " cc"
:global t
(if clipboard-collector-mode
(progn
+ (setq clipboard-collector--transient-exit
+ (set-transient-map clipboard-collector-mode-map t))
(setq cliboard-collector--enable-primary
select-enable-primary)
(setq select-enable-primary t)
@@ -62,6 +68,7 @@ Rules used are defined in `clipboard-collector--rules'."
(run-at-time 0 0.2 #'clipboard-collector--try-collect))
(message "Start collecting, finish with %s."
(substitute-command-keys "\\[clipboard-collector-finish]")))
+ (funcall clipboard-collector--transient-exit)
(setq select-enable-primary cliboard-collector--enable-primary)
(when clipboard-collector--timer
(cancel-timer clipboard-collector--timer))