diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2022-09-02 10:10:48 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2022-09-04 11:43:45 -0700 |
commit | 92f808fbea8e8afe9ec7c37533b306ed7fce5b09 (patch) | |
tree | 223d800baa11c273b82a44abda3ec70bacdb43d9 | |
parent | 5ec8751539cffb416f2dca70093d4209c365a0e9 (diff) | |
download | dotfiles-92f808fbea8e8afe9ec7c37533b306ed7fce5b09.tar.gz |
add my own simplified redtick.el with tick earlier in mode line
-rw-r--r-- | .emacs.d/init.el | 17 | ||||
-rw-r--r-- | .emacs.d/site-lisp/redtick.el | 65 |
2 files changed, 67 insertions, 15 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 5e0696f5..11db2413 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -3457,23 +3457,10 @@ mutt's review view, after exiting EDITOR." ;; but chances are someday I'll want to use that obscure markdown-mode feature (setq ws-butler-global-exempt-modes '(markdown-mode message-mode)) +(autoload 'redtick "redtick") (global-set-key "\C-cP" #'redtick) +(autoload 'redtick-mode "redtick") (global-set-key "\C-cgP" #'redtick-mode) -(setq redtick-history-file nil) - -;; Insert a copy of the timer earlier in the mode line for when the standard -;; one is pushed out of visibility by a long buffer name in a narrow window. -(with-eval-after-load 'redtick - (let ((addition - '(:eval (cond ((and redtick-mode (redtick--selected-window-p)) - (list redtick--current-bar " ")) - (redtick-mode " ")))) - (format (default-value 'mode-line-format))) - (unless (member addition format) - (catch 'done - (while (setq format (cdr format)) - (when (eq (cadr format) 'mode-line-buffer-identification) - (throw 'done (push addition (cdr format))))))))) (with-eval-after-load 'org-d20 (setq org-d20-dice-sound diff --git a/.emacs.d/site-lisp/redtick.el b/.emacs.d/site-lisp/redtick.el new file mode 100644 index 00000000..9ca4ed79 --- /dev/null +++ b/.emacs.d/site-lisp/redtick.el @@ -0,0 +1,65 @@ +;;; redtick.el --- Smallest pomodoro timer (1 char) -*- lexical-binding: t -*- + +;; Copyright (C) 2022 Sean Whitton + +;; Simplified ver. of F. Febles's Unlicensed redtick.el. My work is GPL-3+. + +;;; Code: + +(defconst redtick--ticks + (let ((map (make-mode-line-mouse-map 'mouse-1 #'redtick))) + (mapcar (pcase-lambda (`(,time ,char ,colour)) + (cons time + (concat (propertize + char 'pointer 'hand 'local-map map + 'face `(:inherit mode-line :foreground ,colour)) + " "))) + '((187.5 "█" "#ffff66") (187.5 "▇" "#ffcc66") + (187.5 "▆" "#cc9966") (187.5 "▅" "#ff9966") + (187.5 "▄" "#cc6666") (187.5 "▃" "#ff6666") + (187.5 "▂" "#ff3366") (187.5 "▁" "#ff0066") + + (37.5 "█" "#00cc66") (37.5 "▇" "#33cc66") + (37.5 "▆" "#66cc66") (37.5 "▅" "#00ff66") + (37.5 "▄" "#33ff66") (37.5 "▃" "#66ff66") + (37.5 "▂" "#99ff66") (37.5 "▁" "#ccff66") + + (nil "✓" "#cf6a4c"))))) + +(defvar redtick--tick) +(defvar redtick--timer) + +(defun redtick--update-tick (ticks) + (when (caar ticks) + (setq redtick--timer + (run-at-time (caar ticks) nil #'redtick--update-tick (cdr ticks)))) + (setq redtick--tick (cdar ticks)) + (force-mode-line-update t)) + +;;;###autoload +(define-minor-mode redtick-mode + "Little Pomodoro timer in the mode line." + :global t + (setq redtick--timer nil redtick--tick (cdar (last redtick--ticks))) + (when redtick-mode + (let ((tick '(:eval (and redtick-mode + (if (mode-line-window-selected-p) + redtick--tick + " ")))) + (format (default-value 'mode-line-format))) + (unless (member tick format) + (catch 'done + (while (setq format (cdr format)) + (when (eq (cadr format) 'mode-line-buffer-identification) + (throw 'done (push tick (cdr format)))))) + (force-mode-line-update t))))) + +;;;###autoload +(defun redtick () + (interactive) + (redtick-mode 1) + (redtick--update-tick redtick--ticks)) + +(provide 'redtick) + +;;; redtick.el ends here |