Compare commits

...

4 Commits

Author SHA1 Message Date
Case Duckworth 02addc0aff Add timers 2022-05-12 22:38:33 -05:00
Case Duckworth b3c2d9ded9 meh 2022-05-12 22:38:31 -05:00
Case Duckworth 97bbe5e322 Inhibit org-mode-hook in org-agenda 2022-05-12 22:38:01 -05:00
Case Duckworth 134409aa67 Modeline stuff! 2022-05-12 22:37:47 -05:00
7 changed files with 355 additions and 115 deletions

87
init.el
View File

@ -50,11 +50,7 @@
"C-w" #'+kill-word-backward-or-region
"C-x C-m" #'execute-extended-command ; original: coding systems
"C-<backspace>" #'+backward-kill-word
"C-x TAB" #'+indent-rigidly
;; Alright, Yegge... NOPE! C-x t is tab prefix ... (maybe F6 or something?)
;; "C-x t" #'beginning-of-buffer
;; "C-x e" #'end-of-buffer
)
"C-x TAB" #'+indent-rigidly)
;; C-h deletes backward - see https://idiomdrottning.org/bad-emacs-defaults
(global-set-key (kbd "C-h") 'delete-backward-char)
(keyboard-translate ?\C-h ?\C-?)
@ -571,6 +567,7 @@
(setq load-path
(cl-remove-if (lambda (path) (string-match-p "lisp/org\\'" path)) load-path))
(:also-load +org)
(with-eval-after-load '+org (+org-agenda-inhibit-hooks-mode +1))
(:option org-adapt-indentation nil
org-auto-align-tags t
org-archive-mark-done t
@ -856,6 +853,14 @@
(+scratch-text-scratch))
(add-hook 'kill-buffer-query-functions #'+scratch-immortal))
(setup shell
(:option shell-command-prompt-show-cwd t)
(:local-set +modeline-position-function
(lambda () (string-replace (getenv "HOME")
"~"
default-directory)))
(:hook #'form-feed-mode))
(setup shr
(:also-load +shr)
(:option shr-width (- fill-column 5) ; pad out for wide letters
@ -893,6 +898,7 @@
;;+tab-bar-emms
+tab-bar-tracking-mode
+tab-bar-notmuch-count
+tab-bar-timer
+tab-bar-date))
(tab-bar-mode +1)
(display-time-mode +1))
@ -1336,6 +1342,8 @@
(+with-eval-after-loads (consult +consult)
(:option consult-narrow-key "<"
consult-project-root-function '+consult-project-root)
(add-to-list 'consult-buffer-filter
(rx "*" (or "scratch" "text") "*"))
(consult-customize consult-theme
:preview-key '(:debounce 0.2 any))
(consult-customize consult-ripgrep consult-git-grep consult-grep
@ -1818,6 +1826,7 @@
:fork ( :host nil
:repo "https://codeberg.org/acdw/emacs-jabber")))
(:also-load +jabber)
(:option +jabber-pre-prompt "~ ~ ~\n")
(:option jabber-account-list '(("acdw@hmm.st"))
jabber-groupchat-buffer-format "%n"
jabber-chat-buffer-format "%n"
@ -1828,15 +1837,15 @@
("." . jabber-muc-presence-dim))
jabber-muc-colorize-foreign nil ; colorizing doesn't match my color theme
jabber-chat-foreign-prompt-format (concat +jabber-pre-prompt
"[%t] %n\n"
"%n\n"
(make-string +jabber-ws-prefix
?\ ))
jabber-chat-local-prompt-format (concat +jabber-pre-prompt
"[%t] %n\n"
"%n\n"
(make-string +jabber-ws-prefix
?\ ))
jabber-groupchat-prompt-format (concat +jabber-pre-prompt
"[%t] %n\n"
"%n\n"
(make-string +jabber-ws-prefix
?\ ))
jabber-auto-reconnect t)
@ -1922,13 +1931,10 @@
"FreeMono"
"FreeSerif"
"Unifont"
"Symbola"))
found)
"Symbola")))
(dolist (font emoji-fonts)
(when (member font ffl)
(push font found)
(set-fontset-font t 'symbol (font-spec :family font) nil :append)))
(nreverse found))
(set-fontset-font t 'symbol (font-spec :family font) nil :append))))
(machine-settings-load)))
(setup (:straight macrostep)
@ -2021,6 +2027,11 @@
(add-hook 'modus-themes-after-load-theme-hook
(defun +modus-themes-mostly-monochrome ()
"Set up mdous-themes to be mostly monochrome."
;; Major mode in the mode-line
(defface +modeline-text-mode-face nil
"Text-mode major mode face.")
(defface +modeline-prog-mode-face nil
"Prog-mode major mode face.")
(modus-themes-with-colors
(custom-set-faces
`(font-lock-builtin-face ((,class :inherit modus-themes-bold
@ -2050,14 +2061,11 @@
:foreground ,red-nuanced-fg)))
`(font-lock-todo-face ((,class :inherit font-lock-comment-face
:foreground ,fg-header
:background ,yellow-intense-bg))))
;; Major mode in the mode-line
(defface +modeline-text-mode-face `((,class ( :foreground ,blue
:inherit modus-themes-bold)))
"Text-mode major mode face.")
(defface +modeline-prog-mode-face `((,class ( :foreground ,magenta
:inherit modus-themes-bold)))
"Prog-mode major mode face.")
:background ,yellow-intense-bg)))
`(+modeline-text-mode-face ((,class :foreground ,blue
:inherit modus-themes-bold)))
`(+modeline-prog-mode-face ((,class :foreground ,magenta
:inherit modus-themes-bold))))
(:option +modeline-major-mode-faces `((text-mode . +modeline-text-mode-face)
(prog-mode . +modeline-prog-mode-face)
(t . bold))))))
@ -2076,6 +2084,14 @@
(:global "C-a" #'mwim-beginning
"C-e" #'mwim-end))
(setup (:straight native-complete)
(with-eval-after-load 'shell
(native-complete-setup-bash))
(:with-hook shell-mode-hook
(:local-set completion-at-point-functions
(cons 'native-complete-at-point
completion-at-point-functions))))
(setup (:straight notmuch-bookmarks)
(:load-after notmuch)
(:when-loaded
@ -2156,10 +2172,23 @@
(define-key org-mode-map (kbd "C-x n t") #'org-taskwise-narrow-to-task)))
(setup (:straight org-visibility)
(:require org-visibility)
(:load-after org user-save)
(:option org-visibility-state-file (.etc "org-visibility")
org-visibility-include-regexps '("\\.org\\'"))
(org-visibility-enable-hooks))
(with-eval-after-load 'org-visibility
;; I have to add these hooks myself since I don't want it triggering on
;; /every/ save, but just when I `user-save'.
(add-hook 'user-save-hook #'org-visibility-save-noerror :append)
(add-hook 'kill-buffer-hook #'org-visibility-save-noerror :append)
(add-hook 'kill-emacs-hook #'org-visibility-save-all-buffers :append)
(add-hook 'find-file-hook #'org-visibility-load :append)
(add-hook 'first-change-hook #'org-visibility-dirty :append)
(add-hook 'org-cycle-hook #'org-visibility-dirty-org-cycle :append)))
(setup (:straight org-wc)
(:load-after org simple-modeline)
(:also-load +org-wc)
(add-hook 'org-mode-hook #'+org-wc-mode))
(setup (:straight orglink)
(:option orglink-activate-in-modes '(text-mode prog-mode))
@ -2182,8 +2211,7 @@
(:bind "DEL" #'paredit-backward-delete
"C-<backspace>" #'+paredit-backward-kill-word
"C-w" (lambda (arg) (interactive "P")
(+kill-word-backward-or-region arg
#'paredit-backward-kill-word))
(+kill-word-backward-or-region arg #'paredit-backward-kill-word))
"M-s" nil)
(dolist (hook '(emacs-lisp-mode-hook
eval-expression-minibuffer-setup-hook
@ -2273,18 +2301,17 @@
(+modeline-concat
'(+modeline-track
simple-modeline-segment-misc-info))))
+modeline-position
simple-modeline-segment-process
+modeline-text-scale
,(+modeline-concat
'(+modeline-god-mode
+modeline-kmacro-indicator
+modeline-reading-mode
+modeline-narrowed)
+modeline-narrowed
+modeline-text-scale
+modeline-input-method)
",")
+modeline-input-method
+modeline-position
+modeline-major-mode
+modeline-file-percentage
+modeline-spacer)))
(simple-modeline-mode +1))

View File

@ -190,7 +190,8 @@ Do this only if the buffer is not visiting a file."
file-name-shadow-mode
minibuffer-electric-default-mode
delete-selection-mode
column-number-mode))
;; column-number-mode
))
(when (fboundp enable-mode)
(funcall enable-mode +1)))

View File

@ -25,35 +25,27 @@ will default to this string.")
;;; Combinators
(defun +modeline-concat (segments &optional separator)
"Concatenate multiple `simple-modeline'-style SEGMENTS.
SEGMENTS is a list of either modeline segment-functions (see
`simple-modeline' functions for an example of types of
functions), though it can also contain cons cells of the
form (SEGMENT . PREDICATE).
"Concatenate multiple functional modeline SEGMENTS.
Each segment in SEGMENTS is a function returning a mode-line
construct.
Segments are separated from each other using SEPARATOR, which
defaults to a \" \". Only segments that evaluate to a
non-trivial string (that is, a string not equal to \"\") will be
separated, for a cleaner look.
Segments are separated using SEPARATOR, which defaults to
`+modeline-default-spacer'. Only segments that evaluate to a
non-zero-length string will be separated, for a cleaner look.
This function makes a lambda, so you can throw it straight into
`simple-modeline-segments'."
(setq separator (or separator +modeline-default-spacer))
(lambda ()
(apply #'concat
(let (this-sep result-list)
(dolist (segment segments)
(push (funcall (or (car-safe segment) segment)
this-sep)
result-list)
(if (or (cdr-safe segment)
(and (car result-list)
(not (equal (car result-list) ""))))
(setq this-sep separator)
(setq this-sep nil)))
;; (unless (seq-some #'null result-list)
;; (push +modeline-default-spacer result-list))
(nreverse result-list)))))
This function returns a lambda that should be `:eval'd or
`funcall'd in a mode-line context."
(let ((separator (or separator +modeline-default-spacer)))
(lambda ()
(let (this-sep result)
(dolist (segment segments)
(let ((segstr (funcall segment this-sep)))
(when (and segstr
(not (equal segstr "")))
(push segstr result)
(setq this-sep separator))))
(apply #'concat
(nreverse result))))))
(defun +modeline-spacer (&optional n spacer &rest strings)
"Make an N-length SPACER, or prepend SPACER to STRINGS.
@ -152,7 +144,7 @@ in the cdr will be applied to the major-mode in the mode line."
"("
(propertize ;; (+string-truncate (format-mode-line mode-name) 16)
(format-mode-line mode-name)
'face (if (actually-selected-window-p)
'face (when (actually-selected-window-p)
;; XXX: This is probably really inefficient. I need to
;; simply detect which mode it's in when I change major
;; modes (`change-major-mode-hook') and change the face
@ -160,8 +152,7 @@ in the cdr will be applied to the major-mode in the mode line."
(catch :done (dolist (cel +modeline-major-mode-faces)
(when (derived-mode-p (car cel))
(throw :done (cdr cel))))
(alist-get t +modeline-major-mode-faces))
'unspecified)
(alist-get t +modeline-major-mode-faces)))
'keymap (let ((map (make-sparse-keymap)))
(bindings--define-key map [mode-line down-mouse-1]
`(menu-item "Menu Bar" ignore
@ -293,13 +284,26 @@ The order of elements matters: whichever one matches first is applied."
;; (t (format "%d%%%%%%%%%%" perc))))
;; ;; TODO: add scroll-up and scroll-down bindings.
;; ))
(let ((perc (format-mode-line '(-3 "%p"))))
(let ((perc (format-mode-line '(-2 "%p"))))
(+modeline-spacer nil spacer
"/"
(pcase perc
("Top" ".^^")
("Bot" ".__")
("All" ".::")
(_ (format ".%02d" (string-to-number (substring perc 0 2)))))))))
("To" "Top")
("Bo" "Bot")
("Al" "All")
(_ (format ".%02d" (string-to-number perc))))))))
(defun +modeline-file-percentage-ascii-icon (&optional spacer)
(when file-percentage-mode
(+modeline-spacer nil spacer
(let ((perc (format-mode-line '(-2 "%p"))))
(pcase perc
("To" "/\\")
("Bo" "\\/")
("Al" "[]")
(_ (let ((vec (vector "/|" "//" "||" "\\\\" "\\|" "\\|"))
(perc (string-to-number perc)))
(aref vec (floor (/ perc 17))))))))))
(defun +modeline-file-percentage-icon (&optional spacer)
"Display the position in the current file as an icon."
@ -307,14 +311,14 @@ The order of elements matters: whichever one matches first is applied."
(let ((perc (+modeline--percentage)))
(propertize (+modeline-spacer nil spacer
(cond
((+modeline--buffer-contained-in-window-p) "")
((= perc 0) "")
((< perc 20) "")
((< perc 40) "")
((< perc 60) "")
((< perc 80) "")
((< perc 100) "")
((>= perc 100) "")))
((+modeline--buffer-contained-in-window-p) "111")
((= perc 0) "000")
((< perc 20) "001")
((< perc 40) "010")
((< perc 60) "011")
((< perc 80) "100")
((< perc 100) "101")
((>= perc 100) "110")))
'help-echo (format "Point is %d%% through the buffer."
perc)))))
@ -327,30 +331,25 @@ The order of elements matters: whichever one matches first is applied."
(when (and region-indicator-mode
(region-active-p))
(+modeline-spacer nil spacer
(propertize (format "%s%d"
(if (and (< (point) (mark))) "-" "+")
(propertize (format "%d%s"
(apply '+ (mapcar (lambda (pos)
(- (cdr pos)
(car pos)))
(region-bounds))))
(region-bounds)))
(if (and (< (point) (mark))) "-" "+"))
'font-lock-face 'font-lock-variable-name-face))))
(defun +modeline-line (&optional spacer)
(when line-number-mode
(+modeline-spacer nil spacer "%2l")))
(+modeline-spacer nil spacer
"%l")))
(defun +modeline-column (&optional spacer)
(when column-number-mode
(+modeline-spacer nil spacer
"|"
(if column-number-indicator-zero-based "%2c" "%2C"))))
(defun +modeline-line-column (&optional spacer) ; adapted from `simple-modeline'
"Display the current cursor line and column depending on modes."
(+modeline-spacer nil spacer
(+modeline-line "")
"|"
(+modeline-column "")))
(defcustom +modeline-position-function nil
"Function to use instead of `+modeline-position' in modeline."
:type '(choice (const :tag "Default" nil)
@ -362,11 +361,14 @@ The order of elements matters: whichever one matches first is applied."
See `line-number-mode', `column-number-mode', and
`file-percentage-mode'. If `+modeline-position-function' is set
to a function in the current buffer, call that function instead."
(+modeline-spacer nil spacer
(cond ((functionp +modeline-position-function)
(funcall +modeline-position-function))
(t (concat (+modeline-region)
(+modeline-line-column))))))
(cond ((functionp +modeline-position-function)
(+modeline-spacer nil spacer
(funcall +modeline-position-function)))
(t (funcall (+modeline-concat '(+modeline-region
+modeline-line
+modeline-column
+modeline-file-percentage)
"")))))
(defun +modeline-vc (&optional spacer)
"Display the version control branch of the current buffer in the modeline."

97
lisp/+org-wc.el Normal file
View File

@ -0,0 +1,97 @@
;;; +org-wc.el --- org-wc in the modeline -*- lexical-binding: t; -*-
;;; Commentary:
;;; Code:
(require 'org-wc)
(require '+modeline)
(require 'cl-lib)
(defgroup +org-wc nil
"Extra fast word-counting in `org-mode'"
:group 'org-wc
:group 'org)
(defvar-local +org-wc-word-count nil
"Running total of words in this buffer.")
(defcustom +org-wc-update-after-funcs '(org-narrow-to-subtree
org-narrow-to-block
org-narrow-to-element
org-capture-narrow
org-taskwise-narrow-to-task)
"Functions after which to update the word count."
:type '(repeat function))
(defcustom +org-wc-deletion-idle-timer 0.25
"Length of time, in seconds, to wait before updating word-count."
:type 'number)
(defcustom +org-wc-huge-change 5000
"Number of characters that constitute a \"huge\" insertion."
:type 'number)
(defvar-local +org-wc-update-timer nil)
(defun +org-wc-delayed-update (&rest _)
(if +org-wc-update-timer
(setq +org-wc-update-timer nil)
(setq +org-wc-update-timer
(run-with-idle-timer +org-wc-deletion-idle-timer nil #'+org-wc-update))))
(defun +org-wc-force-update ()
(interactive)
(message "Counting words...")
(when (timerp +org-wc-update-timer)
(cancel-timer +org-wc-update-timer))
(+org-wc-update)
(message "Counting words...done"))
(defun +org-wc-update ()
(dlet ((+org-wc-counting t))
(+org-wc-buffer)
(force-mode-line-update)
(setq +org-wc-update-timer nil)))
(defun +org-wc-changed (start end length)
(+org-wc-delayed-update))
(defun +org-wc-buffer ()
"Count the words in the buffer."
(when (derived-mode-p 'org-mode)
(setq +org-wc-word-count
(org-word-count-aux (point-min) (point-max)))))
(defvar +org-wc-counting nil
"Are we currently counting?")
(defun +org-wc-recount-widen (&rest _)
(when (and (not +org-wc-counting))
(+org-wc-update)))
(defun +org-wc-modeline ()
(when +org-wc-word-count
(format " %sw" +org-wc-word-count)))
(define-minor-mode +org-wc-mode
"Count words in `org-mode' buffers in the mode-line."
:lighter ""
:keymap (let ((map (make-sparse-keymap)))
(define-key map (kbd "C-c C-.") #'+org-wc-force-update)
map)
(if +org-wc-mode
(progn ; turn on
(+org-wc-buffer)
(add-hook 'after-change-functions #'+org-wc-delayed-update nil t)
(setq-local +modeline-position-function #'+org-wc-modeline)
(dolist (fn +org-wc-update-after-funcs)
(advice-add fn :after #'+org-wc-update)))
(progn ; turn off
(remove-hook 'after-change-functions #'+org-wc-delayed-update t)
(kill-local-variable '+modeline-position-function)
(dolist (fn +org-wc-update-after-funcs)
(advice-remove fn #'+org-wc-update)))))
(provide '+org-wc)
;;; +org-wc.el ends here

View File

@ -650,5 +650,39 @@ and POST-PROCESS are passed to `org-export-to-file'."
(set-category-table +org-category-table)
(setq-local word-wrap-by-category t))
;;; Inhibit hooks on `org-agenda'
;; It's really annoying when I call `org-agenda' and five hundred Ispell
;; processes are created because I have `flyspell-mode' in the hook. This mode
;; inhibits those hooks when entering the agenda, but runs them when opening the
;; actual buffer.
(defun +org-agenda-inhibit-hooks (fn &rest r)
"Advice to inhibit hooks when entering `org-agenda'."
(dlet ((org-mode-hook nil)) ; I'm not sure if `dlet' is strictly needed
(apply fn r)))
(defvar-local +org-hook-has-run-p nil
"Whether `org-mode-hook' has run in the current buffer.")
(defun +org-agenda-switch-run-hooks (&rest _)
"Advice to run `org-mode-hook' when entering org-mode.
This should only fire when switching to a buffer from `org-agenda'."
(unless +org-hook-has-run-p
(run-hooks 'org-mode-hook)
(setq +org-hook-has-run-p t)))
(define-minor-mode +org-agenda-inhibit-hooks-mode
"Inhibit `org-mode-hook' when opening `org-agenda'."
:lighter ""
:global t
(if +org-agenda-inhibit-hooks-mode
(progn ; Enable
(advice-add 'org-agenda :around #'+org-agenda-inhibit-hooks)
(advice-add 'org-agenda-switch-to :after #'+org-agenda-switch-run-hooks))
(progn ; Disable
(advice-remove 'org-agenda #'+org-agenda-inhibit-hooks)
(advice-remove 'org-agenda-switch-to #'+org-agenda-switch-run-hooks))))
(provide '+org)
;;; +org.el ends here

View File

@ -47,12 +47,40 @@
(when-let ((help (plist-get item 'help-echo)))
(list :help help)))))))
(defun +tab-bar-timer ()
"Display `+timer-string' in the tab-bar."
(when +timer-string
`((timer-string menu-item
,(concat " " +timer-string)
(lambda (ev)
(interactive "e")
(cond ((not +timer-timer) nil)
((equal +timer-string +timer-running-string)
(popup-menu
'("Running timer"
["Cancel timer" +timer-cancel t])
ev))
(t (setq +timer-string ""))))))))
(defun +tab-bar-date ()
"Display `display-time-string' in the tab-bar."
(when display-time-mode
`((date-time-string menu-item
,(propertize (concat " " display-time-string))
ignore
(lambda (ev)
(interactive "e")
(popup-menu
(append '("Timer")
(let (r)
(dolist (time '(3 5 10))
(push (vector (format "Timer for %d minutes" time)
`(lambda () (interactive)
(+timer ,time))
:active t)
r))
(nreverse r))
'(["Timer for ..." +timer t]))
ev))
:help (discord-date-string)))))
(defun +tab-bar-notmuch-count ()
@ -220,7 +248,7 @@ name to the left."
(when (> (+ l-name l-ell) tab-bar-tab-name-truncated-max)
ellipsis)
(truncate-string-to-width tab-name l-name
(max 0 (- l-name tab-bar-tab-name-truncated-max l-ell))))
(max 0 (- l-name tab-bar-tab-name-truncated-max l-ell))))
'help-echo tab-name))))
(defun +tab-bar-format-align-right ()
@ -267,27 +295,27 @@ Used by `tab-bar-format-menu-bar'."
(el-patch-feature tab-bar)
(with-eval-after-load 'tab-bar
(el-patch-defun tab-bar--format-tab (tab i)
"Format TAB using its index I and return the result as a keymap."
(append
(el-patch-remove
`((,(intern (format "sep-%i" i)) menu-item ,(tab-bar-separator) ignore)))
(cond
((eq (car tab) 'current-tab)
`((current-tab
menu-item
,(funcall tab-bar-tab-name-format-function tab i)
ignore
:help "Current tab")))
(t
`((,(intern (format "tab-%i" i))
menu-item
,(funcall tab-bar-tab-name-format-function tab i)
,(alist-get 'binding tab)
:help "Click to visit tab"))))
(when (alist-get 'close-binding tab)
`((,(if (eq (car tab) 'current-tab) 'C-current-tab (intern (format "C-tab-%i" i)))
menu-item ""
,(alist-get 'close-binding tab)))))))
"Format TAB using its index I and return the result as a keymap."
(append
(el-patch-remove
`((,(intern (format "sep-%i" i)) menu-item ,(tab-bar-separator) ignore)))
(cond
((eq (car tab) 'current-tab)
`((current-tab
menu-item
,(funcall tab-bar-tab-name-format-function tab i)
ignore
:help "Current tab")))
(t
`((,(intern (format "tab-%i" i))
menu-item
,(funcall tab-bar-tab-name-format-function tab i)
,(alist-get 'binding tab)
:help "Click to visit tab"))))
(when (alist-get 'close-binding tab)
`((,(if (eq (car tab) 'current-tab) 'C-current-tab (intern (format "C-tab-%i" i)))
menu-item ""
,(alist-get 'close-binding tab)))))))
;; Emacs 27
@ -300,8 +328,8 @@ This is :filter-return advice for `tab-bar-make-keymap-1'."
'display `(space :align-to (- right (- 0 right-margin)
,reserve)))))
(prog1 (append output
`((align-right menu-item ,str nil))
(+tab-bar-misc-info)))))
`((align-right menu-item ,str nil))
(+tab-bar-misc-info)))))
;; Emacs 28

View File

@ -457,5 +457,56 @@ sort order."
(car args))
(cdr args)))
;;; Timers!
;; inspired by [[https://git.sr.ht/~protesilaos/tmr/tree/main/item/tmr.el][prot's tmr.el package]]
(defvar +timer-string nil)
(defvar +timer-timer nil)
(defcustom +timer-running-string ""
"What to display when the timer is running."
:type 'string)
(defcustom +timer-done-string ""
"What to display when the timer is done."
:type 'string)
(defun +timer (time)
"Set a timer for TIME."
(interactive (list (read-string "Set a timer for how long? ")))
(let ((secs (cond ((natnump time) (* time 60))
((and (stringp time)
(string-match-p "[0-9]\\'" time))
(* (string-to-number time) 60))
(t (let ((secs 0)
(time time))
(save-match-data
(while (string-match "\\([0-9.]+\\)\\([hms]\\)" time)
(cl-incf secs
(* (string-to-number (match-string 1 time))
(pcase (match-string 2 time)
("h" 3600)
("m" 60)
("s" 1))))
(setq time (substring time (match-end 0)))))
secs)))))
(message "Setting timer for \"%s\" (%S seconds)..." time secs)
(setq +timer-string +timer-running-string)
(setq +timer-timer (run-with-timer secs nil
(lambda ()
(message "%S-second timer DONE!" secs)
(setq +timer-string +timer-done-string)
(ding))))))
(defun +timer-cancel ()
"Cancel the running timer."
(interactive)
(cond ((not +timer-timer)
(message "No timer found!"))
(t
(cancel-timer +timer-timer)
(message "Timer canceled.")))
(setq +timer-string nil))
(provide 'acdw)
;;; acdw.el ends here