[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/tmr 5c2b601c03 1/7: Provide tmr-prefix-map and tmr-acti
From: |
ELPA Syncer |
Subject: |
[elpa] externals/tmr 5c2b601c03 1/7: Provide tmr-prefix-map and tmr-action-map as part of the package |
Date: |
Mon, 26 Dec 2022 00:58:18 -0500 (EST) |
branch: externals/tmr
commit 5c2b601c03c271d4f8d2b380217d6bca899997d7
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Provide tmr-prefix-map and tmr-action-map as part of the package
We make sure that tmr-prefix-map is autoloaded by using a command, which
rewrites the prefix map symbol function and replays the input events.
---
README.org | 55 +++++++++++++++++--------------------------------------
tmr.el | 38 ++++++++++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+), 38 deletions(-)
diff --git a/README.org b/README.org
index 9102bc517b..e46a4193bc 100644
--- a/README.org
+++ b/README.org
@@ -332,28 +332,16 @@ Everything is in place to set up the package.
#+cindex: Package configuration
#+begin_src emacs-lisp
-;; Load the `tmr' library
-(require 'tmr)
-
-;; set to nil to disable the sound
-(setq tmr-sound-file
"/usr/share/sounds/freedesktop/stereo/alarm-clock-elapsed.oga")
-
-(setq tmr-notification-urgency 'normal)
-
-;; Read the `tmr-descriptions-list' doc string
-(setq tmr-descriptions-list 'tmr-description-history)
-
-;; OPTIONALLY set global key bindings:
-(let ((map global-map))
- (define-key map (kbd "C-c t t") #'tmr)
- (define-key map (kbd "C-c t T") #'tmr-with-description)
- (define-key map (kbd "C-c t l") #'tmr-tabulated-view) ; "list timers"
mnemonic
- (define-key map (kbd "C-c t c") #'tmr-clone)
- (define-key map (kbd "C-c t k") #'tmr-cancel)
- (define-key map (kbd "C-c t s") #'tmr-reschedule)
- (define-key map (kbd "C-c t e") #'tmr-edit-description)
- (define-key map (kbd "C-c t r") #'tmr-remove)
- (define-key map (kbd "C-c t R") #'tmr-remove-finished))
+ ;; set to nil to disable the sound
+ (setq tmr-sound-file
"/usr/share/sounds/freedesktop/stereo/alarm-clock-elapsed.oga")
+
+ (setq tmr-notification-urgency 'normal)
+
+ ;; Read the `tmr-descriptions-list' doc string
+ (setq tmr-descriptions-list 'tmr-description-history)
+
+ ;; OPTIONALLY set global prefix bindings (autoloaded):
+ (define-key global-map "\C-ct" 'tmr-prefix-map)
#+end_src
* Integration with Embark
@@ -368,22 +356,13 @@ objects recognisable by Embark. All the user needs is
something like
the following glue code:
#+begin_src emacs-lisp
-(defvar tmr-action-map
- (let ((map (make-sparse-keymap)))
- (define-key map "k" #'tmr-remove)
- (define-key map "r" #'tmr-remove)
- (define-key map "R" #'tmr-remove-finished)
- (define-key map "c" #'tmr-clone)
- (define-key map "e" #'tmr-edit-description)
- (define-key map "s" #'tmr-reschedule)
- map))
-
-(with-eval-after-load 'embark
- (add-to-list 'embark-keymap-alist '(tmr-timer . tmr-action-map))
- (cl-loop
- for cmd the key-bindings of tmr-action-map
- if (commandp cmd) do
- (add-to-list 'embark-post-action-hooks (list cmd 'embark--restart))))
+ (with-eval-after-load 'tmr
+ (with-eval-after-load 'embark
+ (add-to-list 'embark-keymap-alist '(tmr-timer . tmr-action-map))
+ (cl-loop
+ for cmd the key-bindings of tmr-action-map
+ if (commandp cmd) do
+ (add-to-list 'embark-post-action-hooks (list cmd 'embark--restart)))))
#+end_src
* Acknowledgements
diff --git a/tmr.el b/tmr.el
index 1f172340fe..58792b6402 100644
--- a/tmr.el
+++ b/tmr.el
@@ -471,5 +471,43 @@ ANNOTATION is an annotation function."
(category . ,category))
(complete-with-action action candidates str pred))))
+(defvar tmr-action-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map "k" #'tmr-remove)
+ (define-key map "r" #'tmr-remove)
+ (define-key map "R" #'tmr-remove-finished)
+ (define-key map "c" #'tmr-clone)
+ (define-key map "e" #'tmr-edit-description)
+ (define-key map "s" #'tmr-reschedule)
+ map)
+ "Action map for TMRs, which can be utilized by Embark.")
+
+(defvar tmr-prefix-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map "+" #'tmr)
+ (define-key map "*" #'tmr-with-description)
+ (define-key map "t" #'tmr)
+ (define-key map "T" #'tmr-with-description)
+ (define-key map "l" 'tmr-tabulated-view) ;; autoloaded
+ (define-key map "c" #'tmr-clone)
+ (define-key map "s" #'tmr-reschedule)
+ (define-key map "e" #'tmr-edit-description)
+ (define-key map "r" #'tmr-remove)
+ (define-key map "R" #'tmr-remove-finished)
+ (define-key map "k" #'tmr-cancel)
+ map)
+ "Global prefix map for TMRs.
+This map should be bound to a global prefix.")
+
+;;;###autoload
+(defun tmr-prefix-map ()
+ "Helper command to autoload variable `tmr-prefix-map'."
+ (interactive)
+ ;; Redefine the prefix map and replay events
+ (fset #'tmr-prefix-map tmr-prefix-map)
+ (setq unread-command-events
+ (mapcar (lambda (ev) (cons t ev))
+ (listify-key-sequence (this-command-keys-vector)))))
+
(provide 'tmr)
;;; tmr.el ends here
- [elpa] externals/tmr updated (00c0ea6518 -> 4061f487da), ELPA Syncer, 2022/12/26
- [elpa] externals/tmr 899abb281c 2/7: Clarify that TMR has key binding prefix, ELPA Syncer, 2022/12/26
- [elpa] externals/tmr e356bab82a 3/7: Use 'vindex' for tmr-prefix-map (Info manual), ELPA Syncer, 2022/12/26
- [elpa] externals/tmr 1bb08cb6c5 6/7: Reword one-line description of ancillary files, ELPA Syncer, 2022/12/26
- [elpa] externals/tmr 4061f487da 7/7: Use tilde for proper code symbol in the manual, ELPA Syncer, 2022/12/26
- [elpa] externals/tmr 5c2b601c03 1/7: Provide tmr-prefix-map and tmr-action-map as part of the package,
ELPA Syncer <=
- [elpa] externals/tmr 32cf26e6a4 5/7: Remove package headers from ancillary files, ELPA Syncer, 2022/12/26
- [elpa] externals/tmr 1adde47e25 4/7: Add missing backronyms, ELPA Syncer, 2022/12/26