summary refs log tree commit diff stats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/+circe.el13
-rw-r--r--lisp/+modeline.el72
-rw-r--r--lisp/+org.el3
-rw-r--r--lisp/+tab-bar.el20
-rw-r--r--lisp/acdw.el5
5 files changed, 84 insertions, 29 deletions
diff --git a/lisp/+circe.el b/lisp/+circe.el index 3d6ea60..a8db1ec 100644 --- a/lisp/+circe.el +++ b/lisp/+circe.el
@@ -245,6 +245,14 @@ can easily remove elements.")
245 match)) 245 match))
246 text))) 246 text)))
247 247
248(defun +circe-shorten-urls-all ()
249 "Turn on `+circe-shorten-url-mode' in all chat buffers."
250 (interactive)
251 (+mapc-some-buffers
252 (lambda () (+circe-shorten-url-mode +1))
253 (lambda (buf)
254 (derived-mode-p 'circe-chat-mode))))
255
248;; Temperature conversion 256;; Temperature conversion
249 257
250(+circe-define-filter +circe-F/C-mode 258(+circe-define-filter +circe-F/C-mode
@@ -261,12 +269,13 @@ can easily remove elements.")
261 (round (+ 32 (* (/ 9.0 5.0) degc)))) 269 (round (+ 32 (* (/ 9.0 5.0) degc))))
262 270
263(defun str-F/C (text) 271(defun str-F/C (text)
264 (replace-regexp-in-string "[0-9.]+[Ff]" 272 (replace-regexp-in-string "[^.]\\([[:digit:]]+\\(?:\\.[[:digit:]]+\\)?[fF]\\)"
265 (lambda (match) 273 (lambda (match)
266 (format "%s/%dC" match 274 (format "%s/%dC" match
267 (fahrenheit-to-celsius 275 (fahrenheit-to-celsius
268 (string-to-number match)))) 276 (string-to-number match))))
269 text)) 277 text
278 nil 1))
270 279
271(provide '+circe) 280(provide '+circe)
272;;; +circe.el ends here 281;;; +circe.el ends here
diff --git a/lisp/+modeline.el b/lisp/+modeline.el index 3f25a40..10bf6d2 100644 --- a/lisp/+modeline.el +++ b/lisp/+modeline.el
@@ -183,32 +183,54 @@ The order of elements matters: whichever one matches first is applied."
183 "Toggle the percentage display in the mode line (File Percentage Mode)." 183 "Toggle the percentage display in the mode line (File Percentage Mode)."
184 :init-value t :global t :group 'mode-line) 184 :init-value t :global t :group 'mode-line)
185 185
186(defun +modeline-position (&optional _) ; adapted from `simple-modeline' 186(defun +modeline-file-percentage (&optional spacer)
187 "Display the current cursor position." 187 "Display the position in the current file."
188 `(,(or spacer +modeline-default-spacer)
189 (:propertize (file-percentage-mode
190 (" " (-3 "%p") "%%"))
191 font-lock-face font-lock-comment-face)))
192
193(define-minor-mode region-indicator-mode
194 "Toggle the region indicator in the mode line."
195 :init-value t :global t :group 'mode-line)
196
197(defun +modeline-region (&optional spacer)
198 "Display an indicator if the region is active."
199 (when (and region-indicator-mode
200 (region-active-p))
201 (list
202 (format "%s%6s"
203 (or spacer +modeline-default-spacer)
204 (propertize (format "%s%d"
205 (if (and (< (point) (mark))) "-" "+")
206 (apply '+ (mapcar (lambda (pos)
207 (- (cdr pos)
208 (car pos)))
209 (region-bounds))))
210 'font-lock-face 'font-lock-variable-name-face)))))
211
212(defun +modeline-line-column (&optional spacer) ; adapted from `simple-modeline'
213 "Display the current cursor line and column depending on modes."
188 (let ((sep "|") (before " [") (after "]")) 214 (let ((sep "|") (before " [") (after "]"))
189 (list `(:propertize (line-number-mode 215 `(,(or spacer +modeline-default-spacer)
190 ((column-number-mode 216 (:propertize (line-number-mode
191 (column-number-indicator-zero-based 217 ((column-number-mode
192 ,(concat before "%l" sep "%c" after) 218 (column-number-indicator-zero-based
193 ,(concat before "%l" sep "%C" after)) 219 ,(concat before "%l" sep "%c" after)
194 ,(concat before "%l" sep "" after))) 220 ,(concat before "%l" sep "%C" after))
195 ((column-number-mode 221 ,(concat before "%l" sep "" after)))
196 (column-number-indicator-zero-based 222 ((column-number-mode
197 ,(concat before sep "%c" after) 223 (column-number-indicator-zero-based
198 ,(concat before sep "%C" after))))) 224 ,(concat before sep "%c" after)
199 font-lock-face font-lock-comment-face) 225 ,(concat before sep "%C" after)))))
200 (if (region-active-p) 226 font-lock-face font-lock-comment-face))))
201 (propertize (format "%s%-5d" 227
202 (if (and (mark) (< (point) (mark))) "-" "+") 228(defun +modeline-position (&optional _)
203 (apply '+ (mapcar 229 "Display the current cursor position.
204 (lambda (pos) 230See `line-number-mode', `column-number-mode', `file-percentage-mode'"
205 (- (cdr pos) 231 (append (+modeline-line-column)
206 (car pos))) 232 (+modeline-region)
207 (region-bounds)))) 233 (+modeline-file-percentage)))
208 'font-lock-face 'font-lock-variable-name-face))
209 '(:propertize (file-percentage-mode
210 (" " (-3 "%p") "%%"))
211 font-lock-face font-lock-comment-face))))
212 234
213(defun +modeline-vc (&optional spacer) 235(defun +modeline-vc (&optional spacer)
214 "Display the version control branch of the current buffer in the modeline." 236 "Display the version control branch of the current buffer in the modeline."
diff --git a/lisp/+org.el b/lisp/+org.el index 348ba6e..95a3da2 100644 --- a/lisp/+org.el +++ b/lisp/+org.el
@@ -420,7 +420,8 @@ the deletion might narrow the column."
420 "Open thing at point, or if there isn't something, list things." 420 "Open thing at point, or if there isn't something, list things."
421 (interactive "P") 421 (interactive "P")
422 (save-excursion 422 (save-excursion
423 (let* ((this-char-type (org-element-type (org-element-context))) 423 (let* ((browse-url-browser-function #'browse-url-default-browser)
424 (this-char-type (org-element-type (org-element-context)))
424 (prev-char-type (ignore-errors 425 (prev-char-type (ignore-errors
425 (save-excursion 426 (save-excursion
426 (backward-char) 427 (backward-char)
diff --git a/lisp/+tab-bar.el b/lisp/+tab-bar.el index 2a03121..1dc1f68 100644 --- a/lisp/+tab-bar.el +++ b/lisp/+tab-bar.el
@@ -21,6 +21,26 @@
21(defvar +tab-bar-show-original nil 21(defvar +tab-bar-show-original nil
22 "Original value of `tab-bar-show'.") 22 "Original value of `tab-bar-show'.")
23 23
24(defun +tab-bar-tab-name-truncated-left ()
25 "Generate the tab name from the buffer of the selected window.
26This is just like `tab-bar-tab-name-truncated', but truncates the
27name to the left."
28 (let* ((tab-name (buffer-name (window-buffer (minibuffer-selected-window))))
29 (ellipsis (cond
30 (tab-bar-tab-name-ellipsis)
31 ((char-displayable-p ?…) "…")
32 ("...")))
33 (l-ell (length ellipsis))
34 (l-name (length tab-name)))
35 (if (< (length tab-name) tab-bar-tab-name-truncated-max)
36 tab-name
37 (propertize (concat
38 (when (> (+ l-name l-ell) tab-bar-tab-name-truncated-max)
39 ellipsis)
40 (truncate-string-to-width tab-name l-name
41 (max 0 (- l-name tab-bar-tab-name-truncated-max l-ell))))
42 'help-echo tab-name))))
43
24 44
25;; Emacs 27 45;; Emacs 27
26 46
diff --git a/lisp/acdw.el b/lisp/acdw.el index 603f46f..7cad67c 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el
@@ -145,7 +145,10 @@ within a `with-current-buffer' form."
145 (let ((pred (or predicate t))) 145 (let ((pred (or predicate t)))
146 (dolist (buf (buffer-list)) 146 (dolist (buf (buffer-list))
147 (with-current-buffer buf 147 (with-current-buffer buf
148 (when (if (fboundp pred) (funcall pred buf) pred) 148 (when (if (or (eq (car-safe pred) 'closure)
149 (fboundp pred))
150 (funcall pred buf)
151 pred)
149 (funcall func)))))) 152 (funcall func))))))
150 153
151;; https://github.com/cstby/emacs.d/blob/main/init.el#L67 154;; https://github.com/cstby/emacs.d/blob/main/init.el#L67