diff options
author | Case Duckworth | 2022-08-19 13:39:13 -0500 |
---|---|---|
committer | Case Duckworth | 2022-08-19 13:39:13 -0500 |
commit | 7d0ff465220bec224c1f0c1163e6b4a88e1fb4c6 (patch) | |
tree | 6c36a8846bc74db584713948a6c382d66047e2ad /lisp | |
parent | Add credit (diff) | |
download | emacs-7d0ff465220bec224c1f0c1163e6b4a88e1fb4c6.tar.gz emacs-7d0ff465220bec224c1f0c1163e6b4a88e1fb4c6.zip |
bleh
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/+modeline.el | 41 | ||||
-rw-r--r-- | lisp/+notmuch.el | 35 | ||||
-rw-r--r-- | lisp/+tab-bar.el | 15 |
3 files changed, 70 insertions, 21 deletions
diff --git a/lisp/+modeline.el b/lisp/+modeline.el index 11d6a4c..c6e8463 100644 --- a/lisp/+modeline.el +++ b/lisp/+modeline.el | |||
@@ -89,14 +89,15 @@ and appended with `truncate-string-ellipsis'." | |||
89 | 89 | ||
90 | (defun +modeline-buffer-name (&optional spacer) ; gonsie | 90 | (defun +modeline-buffer-name (&optional spacer) ; gonsie |
91 | "Display the buffer name." | 91 | "Display the buffer name." |
92 | (let ((bufname (string-trim (string-replace "%" "" (buffer-name))))) | 92 | (let ((bufname (string-trim (string-replace "%" "%%%%" (buffer-name))))) |
93 | (+modeline-spacer nil spacer | 93 | (+modeline-spacer nil spacer |
94 | (if (and +modeline-buffer-position (fboundp +modeline-buffer-position)) | 94 | (if (and +modeline-buffer-position (fboundp +modeline-buffer-position)) |
95 | (funcall +modeline-buffer-position) | 95 | (funcall +modeline-buffer-position) |
96 | (propertize (cond | 96 | (propertize (cond |
97 | ((ignore-errors | 97 | ((ignore-errors |
98 | (and (> +modeline-buffer-name-max-length 0) | 98 | (and |
99 | (< +modeline-buffer-name-max-length 1))) | 99 | (> +modeline-buffer-name-max-length 0) |
100 | (< +modeline-buffer-name-max-length 1))) | ||
100 | (truncate-string-to-width bufname | 101 | (truncate-string-to-width bufname |
101 | (* (window-total-width) | 102 | (* (window-total-width) |
102 | +modeline-buffer-name-max-length) | 103 | +modeline-buffer-name-max-length) |
@@ -149,14 +150,14 @@ in the cdr will be applied to the major-mode in the mode line." | |||
149 | (propertize ;; (+string-truncate (format-mode-line mode-name) 16) | 150 | (propertize ;; (+string-truncate (format-mode-line mode-name) 16) |
150 | (format-mode-line mode-name) | 151 | (format-mode-line mode-name) |
151 | 'face (when (actually-selected-window-p) | 152 | 'face (when (actually-selected-window-p) |
152 | ;; XXX: This is probably really inefficient. I need to | 153 | ;; XXX: This is probably really inefficient. I need to |
153 | ;; simply detect which mode it's in when I change major | 154 | ;; simply detect which mode it's in when I change major |
154 | ;; modes (`change-major-mode-hook') and change the face | 155 | ;; modes (`change-major-mode-hook') and change the face |
155 | ;; there, probably. | 156 | ;; there, probably. |
156 | ;; (catch :done (dolist (cel +modeline-major-mode-faces) | 157 | ;; (catch :done (dolist (cel +modeline-major-mode-faces) |
157 | ;; (when (derived-mode-p (car cel)) | 158 | ;; (when (derived-mode-p (car cel)) |
158 | ;; (throw :done (cdr cel)))) | 159 | ;; (throw :done (cdr cel)))) |
159 | ;; (alist-get t +modeline-major-mode-faces)) | 160 | ;; (alist-get t +modeline-major-mode-faces)) |
160 | '+modeline-major-mode-face) | 161 | '+modeline-major-mode-face) |
161 | 'keymap (let ((map (make-sparse-keymap))) | 162 | 'keymap (let ((map (make-sparse-keymap))) |
162 | (bindings--define-key map [mode-line down-mouse-1] | 163 | (bindings--define-key map [mode-line down-mouse-1] |
@@ -302,13 +303,13 @@ The order of elements matters: whichever one matches first is applied." | |||
302 | (when file-percentage-mode | 303 | (when file-percentage-mode |
303 | (+modeline-spacer nil spacer | 304 | (+modeline-spacer nil spacer |
304 | (let ((perc (format-mode-line '(-2 "%p")))) | 305 | (let ((perc (format-mode-line '(-2 "%p")))) |
305 | (pcase perc | 306 | (pcase perc |
306 | ("To" "/\\") | 307 | ("To" "/\\") |
307 | ("Bo" "\\/") | 308 | ("Bo" "\\/") |
308 | ("Al" "[]") | 309 | ("Al" "[]") |
309 | (_ (let ((vec (vector "/|" "//" "||" "\\\\" "\\|" "\\|")) | 310 | (_ (let ((vec (vector "/|" "//" "||" "\\\\" "\\|" "\\|")) |
310 | (perc (string-to-number perc))) | 311 | (perc (string-to-number perc))) |
311 | (aref vec (floor (/ perc 17)))))))))) | 312 | (aref vec (floor (/ perc 17)))))))))) |
312 | 313 | ||
313 | (defun +modeline-file-percentage-icon (&optional spacer) | 314 | (defun +modeline-file-percentage-icon (&optional spacer) |
314 | "Display the position in the current file as an icon." | 315 | "Display the position in the current file as an icon." |
@@ -379,8 +380,8 @@ to a function in the current buffer, call that function instead." | |||
379 | "Display the version control branch of the current buffer in the modeline." | 380 | "Display the version control branch of the current buffer in the modeline." |
380 | ;; from https://www.gonsie.com/blorg/modeline.html, from Doom | 381 | ;; from https://www.gonsie.com/blorg/modeline.html, from Doom |
381 | (when-let ((backend (vc-backend buffer-file-name))) | 382 | (when-let ((backend (vc-backend buffer-file-name))) |
382 | (+modeline-spacer nil spacer | 383 | (+modeline-spacer nil spacer |
383 | (substring vc-mode (+ (if (eq backend 'Hg) 2 3) 2))))) | 384 | (substring vc-mode (+ (if (eq backend 'Hg) 2 3) 2))))) |
384 | 385 | ||
385 | (defun +modeline-track (&optional spacer) | 386 | (defun +modeline-track (&optional spacer) |
386 | "Display `tracking-mode' information." | 387 | "Display `tracking-mode' information." |
diff --git a/lisp/+notmuch.el b/lisp/+notmuch.el index 890edbe..9e79c5a 100644 --- a/lisp/+notmuch.el +++ b/lisp/+notmuch.el | |||
@@ -58,5 +58,40 @@ for search." | |||
58 | nil) | 58 | nil) |
59 | 'notmuch-address-history))) | 59 | 'notmuch-address-history))) |
60 | 60 | ||
61 | (defcustom +notmuch-spam-tags '("+spam" "+Spam") | ||
62 | "A list of tag changes to apply when marking a thread as spam." | ||
63 | :type '(repeat string)) | ||
64 | |||
65 | (defun +notmuch-tree-mark-spam-then-next (&optional ham beg end) | ||
66 | "Mark the current message as spam and move to the next." | ||
67 | (interactive "P") | ||
68 | (+notmuch-tree-mark-spam ham) | ||
69 | (notmuch-tree-next-matching-message)) | ||
70 | |||
71 | (defun +notmuch-tree-mark-spam (&optional ham) | ||
72 | "Mark the current message as spam. | ||
73 | That is, apply the tag changes in `+notmuch-spam-tags' to it. If | ||
74 | an optional prefix HAM argument is given, the message will be | ||
75 | marked as not-spam (\"ham\"), i.e., the tag changes in | ||
76 | `+notmuch-spam-tags' will be reversed." | ||
77 | (interactive "P") | ||
78 | (when +notmuch-spam-tags | ||
79 | (notmuch-tree-tag | ||
80 | (notmuch-tag-change-list +notmuch-spam-tags ham)))) | ||
81 | |||
82 | (defun +notmuch-search-mark-spam (&optional ham beg end) | ||
83 | "Mark the current thread or region as spam. | ||
84 | This adds the tags in `+notmuch-spam-tags' to the message. With | ||
85 | an optional HAM prefix argument, mark the messages as | ||
86 | not-spam (\"ham\"). | ||
87 | |||
88 | This function advances the next thread when finished." | ||
89 | (interactive (cons current-prefix-arg (notmuch-interactive-region))) | ||
90 | (when +notmuch-spam-tags | ||
91 | (notmuch-search-tag | ||
92 | (notmuch-tag-change-list +notmuch-spam-tags ham) beg end)) | ||
93 | (when (eq beg end) | ||
94 | (notmuch-search-next-thread))) | ||
95 | |||
61 | (provide '+notmuch) | 96 | (provide '+notmuch) |
62 | ;;; +notmuch.el ends here | 97 | ;;; +notmuch.el ends here |
diff --git a/lisp/+tab-bar.el b/lisp/+tab-bar.el index 7ff991c..6c9debd 100644 --- a/lisp/+tab-bar.el +++ b/lisp/+tab-bar.el | |||
@@ -32,6 +32,19 @@ | |||
32 | "Hide the `tracking-mode' information when clocked in." | 32 | "Hide the `tracking-mode' information when clocked in." |
33 | :type 'boolean) | 33 | :type 'boolean) |
34 | 34 | ||
35 | (defun format-mode-line-unescaping (construct) | ||
36 | "Return a mode-line construct as a string, but unescape `%'s." | ||
37 | (format-mode-line | ||
38 | (cond ((listp construct) | ||
39 | (cl-loop for item in construct | ||
40 | collect (cond ((stringp item) | ||
41 | (string-replace "%" "%%" item)) | ||
42 | ((and (listp item) (eq :propertize (car item))) | ||
43 | (format-mode-line-unescaping item)) | ||
44 | (t item)))) | ||
45 | ((stringp construct) (string-replace "%" "%%" construct)) | ||
46 | (t construct)))) | ||
47 | |||
35 | (defun +tab-bar-tracking-mode () | 48 | (defun +tab-bar-tracking-mode () |
36 | "Display `tracking-mode-line-buffers' in the tab-bar." | 49 | "Display `tracking-mode-line-buffers' in the tab-bar." |
37 | ;; TODO: write something to convert a mode-line construct to a tab-bar | 50 | ;; TODO: write something to convert a mode-line construct to a tab-bar |
@@ -45,7 +58,7 @@ | |||
45 | as item = (nth i tracking-mode-line-buffers) | 58 | as item = (nth i tracking-mode-line-buffers) |
46 | collect (append (list (intern (format "tracking-mode-line-%s" i)) | 59 | collect (append (list (intern (format "tracking-mode-line-%s" i)) |
47 | 'menu-item | 60 | 'menu-item |
48 | (string-trim (format-mode-line item))) | 61 | (string-trim (format-mode-line-unescaping item))) |
49 | (if-let ((keymap (plist-get item 'keymap))) | 62 | (if-let ((keymap (plist-get item 'keymap))) |
50 | (list (alist-get 'down-mouse-1 (cdadr keymap))) | 63 | (list (alist-get 'down-mouse-1 (cdadr keymap))) |
51 | (list #'ignore)) | 64 | (list #'ignore)) |