diff options
-rw-r--r-- | init.el | 66 | ||||
-rw-r--r-- | lisp/+modeline.el | 47 | ||||
-rw-r--r-- | lisp/+org.el | 7 | ||||
-rw-r--r-- | lisp/+tab-bar.el | 80 |
4 files changed, 150 insertions, 50 deletions
diff --git a/init.el b/init.el index ae61b87..74d08a6 100644 --- a/init.el +++ b/init.el | |||
@@ -113,7 +113,8 @@ | |||
113 | (+ensure-after-init #'+pulse-location-mode)) | 113 | (+ensure-after-init #'+pulse-location-mode)) |
114 | 114 | ||
115 | (setup (:require reading) | 115 | (setup (:require reading) |
116 | (:global "C-c C-r" #'reading-mode)) | 116 | (:hook-into view-mode) ; XXX doesn't go back |
117 | ) | ||
117 | 118 | ||
118 | (setup (:require user-save) | 119 | (setup (:require user-save) |
119 | (add-hook 'user-save-hook #'+clean-empty-lines) | 120 | (add-hook 'user-save-hook #'+clean-empty-lines) |
@@ -178,9 +179,12 @@ | |||
178 | (cond ((executable-find "mpv") #'+browse-image-with-mpv) | 179 | (cond ((executable-find "mpv") #'+browse-image-with-mpv) |
179 | (t #'eww-browse-url)) | 180 | (t #'eww-browse-url)) |
180 | args))) | 181 | args))) |
181 | (cons (rx ; videos | 182 | (cons (rx |
182 | (or "youtube.com" "youtu.be" "yewtu.be" | 183 | (or "youtube.com" "youtu.be" "yewtu.be" |
183 | (seq "." (or "mp4" "gif" "mov" "MOV" "webm") eos))) | 184 | ;; videos |
185 | (seq "." (or "mp4" "gif" "mov" "MOV" "webm") eos) | ||
186 | ;; music | ||
187 | (seq "." (or "ogg" "mp3") eos))) | ||
184 | (lambda (&rest args) | 188 | (lambda (&rest args) |
185 | (apply (if (executable-find "mpv") | 189 | (apply (if (executable-find "mpv") |
186 | #'+browse-url-with-mpv | 190 | #'+browse-url-with-mpv |
@@ -1038,6 +1042,7 @@ See also `crux-reopen-as-root-mode'." | |||
1038 | (:+key "M-q" #'filldent-dwim)) | 1042 | (:+key "M-q" #'filldent-dwim)) |
1039 | 1043 | ||
1040 | (setup (:straight flyspell-correct) | 1044 | (setup (:straight flyspell-correct) |
1045 | (:load-after flyspell) | ||
1041 | (:also-load +flyspell-correct) | 1046 | (:also-load +flyspell-correct) |
1042 | (:option flyspell-correct--cr-key ";") | 1047 | (:option flyspell-correct--cr-key ";") |
1043 | (:bind-into flyspell | 1048 | (:bind-into flyspell |
@@ -1230,7 +1235,8 @@ See also `crux-reopen-as-root-mode'." | |||
1230 | (:hook-into org-mode)) | 1235 | (:hook-into org-mode)) |
1231 | 1236 | ||
1232 | (setup (:straight org-sticky-header) | 1237 | (setup (:straight org-sticky-header) |
1233 | (:hook-into org-mode)) | 1238 | ;; (:hook-into org-mode) |
1239 | ) | ||
1234 | 1240 | ||
1235 | (setup (:straight org-visibility) | 1241 | (setup (:straight org-visibility) |
1236 | (:option org-visibility-state-file (.etc "org-visibility") | 1242 | (:option org-visibility-state-file (.etc "org-visibility") |
@@ -1289,27 +1295,32 @@ See also `crux-reopen-as-root-mode'." | |||
1289 | (setup (:straight (simple-modeline | 1295 | (setup (:straight (simple-modeline |
1290 | :fork (:host github :repo "duckwork/simple-modeline"))) | 1296 | :fork (:host github :repo "duckwork/simple-modeline"))) |
1291 | (:require +modeline) | 1297 | (:require +modeline) |
1292 | (:option simple-modeline-segments `((;; left | 1298 | (:option simple-modeline-segments |
1293 | +modeline-ace-window-display | 1299 | `(( ; left |
1294 | +modeline-modified | 1300 | +modeline-ace-window-display |
1295 | ,(+modeline-concat | 1301 | +modeline-modified |
1296 | '(+modeline-god-mode | 1302 | +modeline-buffer-name |
1297 | +modeline-reading-mode | 1303 | (lambda () (+modeline-vc ": ")) |
1298 | +modeline-narrowed) | 1304 | ,(+modeline-concat |
1299 | ",") | 1305 | '(+modeline-minions |
1300 | +modeline-buffer-name | 1306 | +modeline-major-mode)) |
1301 | +modeline-position | 1307 | +modeline-anzu |
1302 | +modeline-anzu | 1308 | ) |
1303 | ) | 1309 | ( ; right |
1304 | (;; right | 1310 | (lambda () |
1305 | +modeline-track | 1311 | (unless +tab-bar-misc-info-mode |
1306 | +modeline-vc | 1312 | (+modeline-concat |
1307 | simple-modeline-segment-misc-info | 1313 | '(+modeline-track |
1308 | simple-modeline-segment-process | 1314 | simple-modeline-segment-misc-info)))) |
1309 | +modeline-text-scale | 1315 | |
1310 | +modeline-minions | 1316 | simple-modeline-segment-process |
1311 | +modeline-major-mode | 1317 | +modeline-text-scale |
1312 | ))) | 1318 | ,(+modeline-concat |
1319 | '(+modeline-god-mode | ||
1320 | +modeline-reading-mode | ||
1321 | +modeline-narrowed) | ||
1322 | ",") | ||
1323 | +modeline-position))) | ||
1313 | (simple-modeline-mode +1)) | 1324 | (simple-modeline-mode +1)) |
1314 | 1325 | ||
1315 | (setup (:straight smartscan) | 1326 | (setup (:straight smartscan) |
@@ -1480,3 +1491,8 @@ See also `crux-reopen-as-root-mode'." | |||
1480 | (:require +zzz-to-char) | 1491 | (:require +zzz-to-char) |
1481 | (:option zzz-to-char-reach 1024) | 1492 | (:option zzz-to-char-reach 1024) |
1482 | (:global "M-z" #'+zzz-to-char)) | 1493 | (:global "M-z" #'+zzz-to-char)) |
1494 | |||
1495 | (setup tab-bar | ||
1496 | (:require +tab-bar) | ||
1497 | (tab-bar-mode +1) | ||
1498 | (+tab-bar-misc-info-mode +1)) | ||
diff --git a/lisp/+modeline.el b/lisp/+modeline.el index a0195f1..3f25a40 100644 --- a/lisp/+modeline.el +++ b/lisp/+modeline.el | |||
@@ -88,7 +88,7 @@ This function makes a lambda, so you can throw it straight into | |||
88 | (defun +modeline-major-mode (&optional spacer) | 88 | (defun +modeline-major-mode (&optional spacer) |
89 | "Display the current `major-mode'." | 89 | "Display the current `major-mode'." |
90 | (concat (or spacer +modeline-default-spacer) | 90 | (concat (or spacer +modeline-default-spacer) |
91 | (propertize (+string-truncate (format-mode-line mode-name) 12) | 91 | (propertize (+string-truncate (format-mode-line mode-name) 16) |
92 | 'face 'bold | 92 | 'face 'bold |
93 | 'keymap mode-line-major-mode-keymap | 93 | 'keymap mode-line-major-mode-keymap |
94 | 'help-echo (concat (format-mode-line mode-name) | 94 | 'help-echo (concat (format-mode-line mode-name) |
@@ -185,27 +185,30 @@ The order of elements matters: whichever one matches first is applied." | |||
185 | 185 | ||
186 | (defun +modeline-position (&optional _) ; adapted from `simple-modeline' | 186 | (defun +modeline-position (&optional _) ; adapted from `simple-modeline' |
187 | "Display the current cursor position." | 187 | "Display the current cursor position." |
188 | (list '((line-number-mode | 188 | (let ((sep "|") (before " [") (after "]")) |
189 | ((column-number-mode | 189 | (list `(:propertize (line-number-mode |
190 | (column-number-indicator-zero-based | 190 | ((column-number-mode |
191 | (9 " %l:%c") | 191 | (column-number-indicator-zero-based |
192 | (9 " %l:%C")) | 192 | ,(concat before "%l" sep "%c" after) |
193 | (6 " %l:"))) | 193 | ,(concat before "%l" sep "%C" after)) |
194 | ((column-number-mode | 194 | ,(concat before "%l" sep "" after))) |
195 | (column-number-indicator-zero-based | 195 | ((column-number-mode |
196 | (5 " :%c") | 196 | (column-number-indicator-zero-based |
197 | (5 " :%C")))))) | 197 | ,(concat before sep "%c" after) |
198 | '(file-percentage-mode | 198 | ,(concat before sep "%C" after))))) |
199 | ((-3 "%p") "%% ")) | 199 | font-lock-face font-lock-comment-face) |
200 | (if (region-active-p) | 200 | (if (region-active-p) |
201 | (propertize (format "%s%-5d" | 201 | (propertize (format "%s%-5d" |
202 | (if (and (mark) (< (point) (mark))) "-" "+") | 202 | (if (and (mark) (< (point) (mark))) "-" "+") |
203 | (apply '+ (mapcar | 203 | (apply '+ (mapcar |
204 | (lambda (pos) | 204 | (lambda (pos) |
205 | (- (cdr pos) | 205 | (- (cdr pos) |
206 | (car pos))) | 206 | (car pos))) |
207 | (region-bounds)))) | 207 | (region-bounds)))) |
208 | 'font-lock-face 'font-lock-variable-name-face)))) | 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)))) | ||
209 | 212 | ||
210 | (defun +modeline-vc (&optional spacer) | 213 | (defun +modeline-vc (&optional spacer) |
211 | "Display the version control branch of the current buffer in the modeline." | 214 | "Display the version control branch of the current buffer in the modeline." |
diff --git a/lisp/+org.el b/lisp/+org.el index 090af5a..348ba6e 100644 --- a/lisp/+org.el +++ b/lisp/+org.el | |||
@@ -421,9 +421,10 @@ the deletion might narrow the column." | |||
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* ((this-char-type (org-element-type (org-element-context))) |
424 | (prev-char-type (save-excursion | 424 | (prev-char-type (ignore-errors |
425 | (backward-char) | 425 | (save-excursion |
426 | (org-element-type (org-element-context)))) | 426 | (backward-char) |
427 | (org-element-type (org-element-context))))) | ||
427 | (types '(citation citation-reference clock comment comment-block | 428 | (types '(citation citation-reference clock comment comment-block |
428 | footnote-definition footnote-reference headline | 429 | footnote-definition footnote-reference headline |
429 | inline-src-block inlinetask keyword link | 430 | inline-src-block inlinetask keyword link |
diff --git a/lisp/+tab-bar.el b/lisp/+tab-bar.el new file mode 100644 index 0000000..2a03121 --- /dev/null +++ b/lisp/+tab-bar.el | |||
@@ -0,0 +1,80 @@ | |||
1 | ;;; +tab-bar.el -*- lexical-binding: t; -*- | ||
2 | |||
3 | ;;; Commentary: | ||
4 | |||
5 | ;; Emacs 28 comes with an easy-to-use `tab-bar-format' option, but I still use | ||
6 | ;; Emacs 27 on my Windows machine. Thus, the code in this file. | ||
7 | |||
8 | ;;; Code: | ||
9 | |||
10 | (require 'tab-bar) | ||
11 | |||
12 | |||
13 | ;; Common | ||
14 | |||
15 | (defun +tab-bar-misc-info () | ||
16 | "Display `mode-line-misc-info', formatted for the tab-bar." | ||
17 | `((global menu-item ,(string-trim-right | ||
18 | (format-mode-line mode-line-misc-info)) | ||
19 | ignore))) | ||
20 | |||
21 | (defvar +tab-bar-show-original nil | ||
22 | "Original value of `tab-bar-show'.") | ||
23 | |||
24 | |||
25 | ;; Emacs 27 | ||
26 | |||
27 | (defun +tab-bar-misc-info-27 (output &rest _) | ||
28 | "Display `mode-line-misc-info' in the `tab-bar' on Emacs 27. | ||
29 | This is :filter-return advice for `tab-bar-make-keymap-1'." | ||
30 | (let* ((reserve (length (format-mode-line mode-line-misc-info))) | ||
31 | (str (propertize " " | ||
32 | 'display `(space :align-to (- right (- 0 right-margin) | ||
33 | ,reserve))))) | ||
34 | (prog1 (append output | ||
35 | `((align-right menu-item ,str nil)) | ||
36 | (+tab-bar-misc-info))))) | ||
37 | |||
38 | |||
39 | ;; Emacs 28 | ||
40 | |||
41 | (defvar +tab-bar-format-original nil | ||
42 | "Original value of `tab-bar-format'.") | ||
43 | |||
44 | (defun +tab-bar-misc-info-28 () | ||
45 | "Display `mode-line-misc-info', right-aligned, on Emacs 28." | ||
46 | (append (unless (memq 'tab-bar-format-align-right tab-bar-format) | ||
47 | '(tab-bar-format-align-right)) | ||
48 | '(+tab-bar-misc-info))) | ||
49 | |||
50 | |||
51 | |||
52 | (define-minor-mode +tab-bar-misc-info-mode | ||
53 | "Show the `mode-line-misc-info' in the `tab-bar'." | ||
54 | :lighter "" | ||
55 | :global t | ||
56 | (if +tab-bar-misc-info-mode | ||
57 | (progn ; Enable | ||
58 | (setq +tab-bar-show-original tab-bar-show) | ||
59 | (cond | ||
60 | ((boundp 'tab-bar-format) ; Emacs 28 | ||
61 | (setq +tab-bar-format-original tab-bar-format) | ||
62 | (unless (memq '+tab-bar-misc-info tab-bar-format) | ||
63 | (setq tab-bar-format | ||
64 | (append tab-bar-format (+tab-bar-misc-info-28))))) | ||
65 | ((fboundp 'tab-bar-make-keymap-1) ; Emacs 27 | ||
66 | (advice-add 'tab-bar-make-keymap-1 :filter-return | ||
67 | '+tab-bar-misc-info-27))) | ||
68 | (setq tab-bar-show t)) | ||
69 | (progn ; Disable | ||
70 | (setq tab-bar-show +tab-bar-show-original) | ||
71 | (cond | ||
72 | ((boundp 'tab-bar-format) ; Emacs 28 | ||
73 | (setq tab-bar-format +tab-bar-format-original)) | ||
74 | ((fboundp 'tab-bar-make-keymap-1) ; Emacs 27 | ||
75 | (advice-remove 'tab-bar-make-keymap-1 '+tab-bar-misc-info-27)))))) | ||
76 | |||
77 | |||
78 | |||
79 | (provide '+tab-bar) | ||
80 | ;;; +tab-bar.el ends here | ||