diff options
author | Case Duckworth | 2021-12-29 22:55:55 -0600 |
---|---|---|
committer | Case Duckworth | 2021-12-29 22:55:55 -0600 |
commit | 038e5de1adf2de6cdf28a428a44b0753813b928c (patch) | |
tree | beb71cc3157ac2af3dc586fc02b74b906605e338 /lisp | |
parent | Re-install (new and improved!) filldent.el (diff) | |
download | emacs-038e5de1adf2de6cdf28a428a44b0753813b928c.tar.gz emacs-038e5de1adf2de6cdf28a428a44b0753813b928c.zip |
Lots and lots of changes, oh jeez
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/+emacs.el | 95 | ||||
-rw-r--r-- | lisp/+init.el | 6 | ||||
-rw-r--r-- | lisp/+lisp.el | 89 | ||||
-rw-r--r-- | lisp/+modeline.el | 110 | ||||
-rw-r--r-- | lisp/+setup.el | 2 | ||||
-rw-r--r-- | lisp/+util.el | 5 |
6 files changed, 233 insertions, 74 deletions
diff --git a/lisp/+emacs.el b/lisp/+emacs.el index 7ad6768..2d63e82 100644 --- a/lisp/+emacs.el +++ b/lisp/+emacs.el | |||
@@ -11,7 +11,8 @@ | |||
11 | ;; Emacs. But like, why would I want to? | 11 | ;; Emacs. But like, why would I want to? |
12 | 12 | ||
13 | ;; Other notable packages include | 13 | ;; Other notable packages include |
14 | ;; https://git.sr.ht/~technomancy/better-defaults/ | 14 | ;; - https://git.sr.ht/~technomancy/better-defaults/ |
15 | ;; - https://github.com/susam/emfy | ||
15 | 16 | ||
16 | ;;; Code: | 17 | ;;; Code: |
17 | 18 | ||
@@ -45,6 +46,7 @@ Do this only if the buffer is not visiting a file." | |||
45 | completion-category-overrides '((file (styles . (partial-completion)))) | 46 | completion-category-overrides '((file (styles . (partial-completion)))) |
46 | completion-ignore-case t | 47 | completion-ignore-case t |
47 | completion-styles '(substring partial-completion) | 48 | completion-styles '(substring partial-completion) |
49 | create-lockfiles nil | ||
48 | cursor-in-non-selected-windows 'hollow | 50 | cursor-in-non-selected-windows 'hollow |
49 | cursor-type 'bar | 51 | cursor-type 'bar |
50 | custom-file (.etc "custom.el") | 52 | custom-file (.etc "custom.el") |
@@ -64,6 +66,8 @@ Do this only if the buffer is not visiting a file." | |||
64 | hscroll-step 1 | 66 | hscroll-step 1 |
65 | imenu-auto-rescan t | 67 | imenu-auto-rescan t |
66 | indent-tabs-mode nil | 68 | indent-tabs-mode nil |
69 | indicate-empty-lines t | ||
70 | indicate-buffer-boundaries 'left | ||
67 | inhibit-startup-screen t | 71 | inhibit-startup-screen t |
68 | initial-buffer-choice t | 72 | initial-buffer-choice t |
69 | kill-do-not-save-duplicates t | 73 | kill-do-not-save-duplicates t |
@@ -75,8 +79,8 @@ Do this only if the buffer is not visiting a file." | |||
75 | mark-ring-max 50 | 79 | mark-ring-max 50 |
76 | minibuffer-eldef-shorten-default t | 80 | minibuffer-eldef-shorten-default t |
77 | minibuffer-prompt-properties (list 'read-only t | 81 | minibuffer-prompt-properties (list 'read-only t |
78 | 'cursor-intangible t | 82 | 'cursor-intangible t |
79 | 'face 'minibuffer-prompt) | 83 | 'face 'minibuffer-prompt) |
80 | mode-require-final-newline 'visit-save | 84 | mode-require-final-newline 'visit-save |
81 | mouse-drag-copy-region t | 85 | mouse-drag-copy-region t |
82 | mouse-yank-at-point t | 86 | mouse-yank-at-point t |
@@ -84,8 +88,8 @@ Do this only if the buffer is not visiting a file." | |||
84 | read-answer-short t | 88 | read-answer-short t |
85 | read-buffer-completion-ignore-case t | 89 | read-buffer-completion-ignore-case t |
86 | read-extended-command-predicate (when (fboundp | 90 | read-extended-command-predicate (when (fboundp |
87 | 'command-completion-default-include-p) | 91 | 'command-completion-default-include-p) |
88 | 'command-completion-default-include-p) | 92 | 'command-completion-default-include-p) |
89 | recenter-positions '(top middle bottom) | 93 | recenter-positions '(top middle bottom) |
90 | regexp-search-ring-max 100 | 94 | regexp-search-ring-max 100 |
91 | regexp-search-ring-max 200 | 95 | regexp-search-ring-max 200 |
@@ -101,7 +105,9 @@ Do this only if the buffer is not visiting a file." | |||
101 | show-paren-style 'mixed | 105 | show-paren-style 'mixed |
102 | show-paren-when-point-in-periphery t | 106 | show-paren-when-point-in-periphery t |
103 | show-paren-when-point-inside-paren t | 107 | show-paren-when-point-inside-paren t |
108 | ;;show-trailing-whitespace t | ||
104 | tab-bar-show 1 | 109 | tab-bar-show 1 |
110 | tab-width 4 | ||
105 | tramp-backup-directory-alist backup-directory-alist | 111 | tramp-backup-directory-alist backup-directory-alist |
106 | use-dialog-box nil | 112 | use-dialog-box nil |
107 | use-file-dialog nil | 113 | use-file-dialog nil |
@@ -117,6 +123,13 @@ Do this only if the buffer is not visiting a file." | |||
117 | yank-pop-change-selection t | 123 | yank-pop-change-selection t |
118 | ) | 124 | ) |
119 | 125 | ||
126 | ;; Programming language offsets. | ||
127 | ;; Set these after the initial block so I can use `tab-width' | ||
128 | (setq-default | ||
129 | c-basic-offset tab-width) | ||
130 | |||
131 | ;; Emacs 28 ships with an option, `use-short-answers', that makes this form | ||
132 | ;; obsolete, but I still use 27 at work. | ||
120 | (when (version< emacs-version "28") | 133 | (when (version< emacs-version "28") |
121 | (fset 'yes-or-no-p 'y-or-n-p)) | 134 | (fset 'yes-or-no-p 'y-or-n-p)) |
122 | 135 | ||
@@ -150,23 +163,23 @@ Do this only if the buffer is not visiting a file." | |||
150 | ;;; Modes | 163 | ;;; Modes |
151 | 164 | ||
152 | (dolist (enable-mode '(global-auto-revert-mode | 165 | (dolist (enable-mode '(global-auto-revert-mode |
153 | blink-cursor-mode | 166 | blink-cursor-mode |
154 | electric-pair-mode | 167 | electric-pair-mode |
155 | show-paren-mode | 168 | show-paren-mode |
156 | global-so-long-mode | 169 | global-so-long-mode |
157 | minibuffer-depth-indicate-mode | 170 | minibuffer-depth-indicate-mode |
158 | file-name-shadow-mode | 171 | file-name-shadow-mode |
159 | minibuffer-electric-default-mode | 172 | minibuffer-electric-default-mode |
160 | delete-selection-mode | 173 | delete-selection-mode |
161 | column-number-mode)) | 174 | column-number-mode)) |
162 | (when (fboundp enable-mode) | 175 | (when (fboundp enable-mode) |
163 | (funcall enable-mode +1))) | 176 | (funcall enable-mode +1))) |
164 | 177 | ||
165 | (dolist (disable-mode '(tooltip-mode | 178 | (dolist (disable-mode '(tooltip-mode |
166 | tool-bar-mode | 179 | tool-bar-mode |
167 | menu-bar-mode | 180 | menu-bar-mode |
168 | scroll-bar-mode | 181 | scroll-bar-mode |
169 | horizontal-scroll-bar-mode)) | 182 | horizontal-scroll-bar-mode)) |
170 | (when (fboundp disable-mode) | 183 | (when (fboundp disable-mode) |
171 | (funcall disable-mode -1))) | 184 | (funcall disable-mode -1))) |
172 | 185 | ||
@@ -187,19 +200,19 @@ PRESERVE-NL-BACK and MODE." | |||
187 | (cycle-spacing (- n) preserve-nl-back mode)) | 200 | (cycle-spacing (- n) preserve-nl-back mode)) |
188 | 201 | ||
189 | (defun +save-buffers-quit (&optional arg) | 202 | (defun +save-buffers-quit (&optional arg) |
190 | "Silently save each buffer, then kill the current connection. | 203 | "Silently save each buffer, then kill the current connection. |
191 | If the current frame has no client, kill Emacs itself using | 204 | If the current frame has no client, kill Emacs itself using |
192 | `save-buffers-kill-emacs' after confirming with the user. | 205 | `save-buffers-kill-emacs' after confirming with the user. |
193 | 206 | ||
194 | With prefix ARG, silently save all file-visiting buffers, then | 207 | With prefix ARG, silently save all file-visiting buffers, then |
195 | kill without asking." | 208 | kill without asking." |
196 | (interactive "P") | 209 | (interactive "P") |
197 | (save-some-buffers t) | 210 | (save-some-buffers t) |
198 | (if (and (not (frame-parameter nil 'client)) | 211 | (if (and (not (frame-parameter nil 'client)) |
199 | (and (not arg))) | 212 | (and (not arg))) |
200 | (when (yes-or-no-p "Sure you want to quit? ") | 213 | (when (yes-or-no-p "Sure you want to quit? ") |
201 | (save-buffers-kill-emacs)) | 214 | (save-buffers-kill-emacs)) |
202 | (server-save-buffers-kill-terminal nil))) | 215 | (server-save-buffers-kill-terminal nil))) |
203 | 216 | ||
204 | ;;; Bindings | 217 | ;;; Bindings |
205 | 218 | ||
@@ -225,9 +238,9 @@ kill without asking." | |||
225 | 238 | ||
226 | (when (require 'uniquify nil :noerror) | 239 | (when (require 'uniquify nil :noerror) |
227 | (setq-default uniquify-buffer-name-style 'forward | 240 | (setq-default uniquify-buffer-name-style 'forward |
228 | uniquify-separator path-separator | 241 | uniquify-separator path-separator |
229 | uniquify-after-kill-buffer-p t | 242 | uniquify-after-kill-buffer-p t |
230 | uniquify-ignore-buffers-re "^\\*")) | 243 | uniquify-ignore-buffers-re "^\\*")) |
231 | 244 | ||
232 | (when (require 'goto-addr) | 245 | (when (require 'goto-addr) |
233 | (if (fboundp 'global-goto-address-mode) | 246 | (if (fboundp 'global-goto-address-mode) |
@@ -236,34 +249,34 @@ kill without asking." | |||
236 | 249 | ||
237 | (when (require 'recentf nil :noerror) | 250 | (when (require 'recentf nil :noerror) |
238 | (setq-default recentf-save-file (.etc "recentf.el") | 251 | (setq-default recentf-save-file (.etc "recentf.el") |
239 | recentf-max-menu-items 100 | 252 | recentf-max-menu-items 100 |
240 | recentf-max-saved-items nil | 253 | recentf-max-saved-items nil |
241 | recentf-auto-cleanup 'mode) | 254 | recentf-auto-cleanup 'mode) |
242 | (add-to-list 'recentf-exclude .etc) | 255 | (add-to-list 'recentf-exclude .etc) |
243 | (recentf-mode +1)) | 256 | (recentf-mode +1)) |
244 | 257 | ||
245 | (when (require 'repeat nil :noerror) | 258 | (when (require 'repeat nil :noerror) |
246 | (setq-default repeat-exit-key "g" | 259 | (setq-default repeat-exit-key "g" |
247 | repeat-exit-timeout 5) | 260 | repeat-exit-timeout 5) |
248 | (repeat-mode +1)) | 261 | (repeat-mode +1)) |
249 | 262 | ||
250 | (when (require 'savehist nil :noerror) | 263 | (when (require 'savehist nil :noerror) |
251 | (setq-default history-length t | 264 | (setq-default history-length t |
252 | history-delete-duplicates t | 265 | history-delete-duplicates t |
253 | history-autosave-interval 60 | 266 | history-autosave-interval 60 |
254 | savehist-file (.etc "savehist.el")) | 267 | savehist-file (.etc "savehist.el")) |
255 | (dolist (var '(extended-command-history | 268 | (dolist (var '(extended-command-history |
256 | global-mark-ring | 269 | global-mark-ring |
257 | kill-ring | 270 | kill-ring |
258 | regexp-search-ring | 271 | regexp-search-ring |
259 | search-ring | 272 | search-ring |
260 | mark-ring)) | 273 | mark-ring)) |
261 | (add-to-list 'savehist-additional-variables var)) | 274 | (add-to-list 'savehist-additional-variables var)) |
262 | (savehist-mode +1)) | 275 | (savehist-mode +1)) |
263 | 276 | ||
264 | (when (require 'saveplace nil :noerror) | 277 | (when (require 'saveplace nil :noerror) |
265 | (setq-default save-place-file (.etc "places.el") | 278 | (setq-default save-place-file (.etc "places.el") |
266 | save-place-forget-unreadable-files (eq system-type 'gnu/linux)) | 279 | save-place-forget-unreadable-files (eq system-type 'gnu/linux)) |
267 | (save-place-mode +1)) | 280 | (save-place-mode +1)) |
268 | 281 | ||
269 | ;; (when (require 'tramp) | 282 | ;; (when (require 'tramp) |
diff --git a/lisp/+init.el b/lisp/+init.el index 3ab0486..360a1b9 100644 --- a/lisp/+init.el +++ b/lisp/+init.el | |||
@@ -67,6 +67,12 @@ are sorted lexigraphically." | |||
67 | ;; otherwise, sort lexigraphically | 67 | ;; otherwise, sort lexigraphically |
68 | (t (string< s1 s2)))))))))))) | 68 | (t (string< s1 s2)))))))))))) |
69 | 69 | ||
70 | (defun +init-sort-then-save () | ||
71 | "Sort init.el, then save it." | ||
72 | (interactive) | ||
73 | (+init-sort) | ||
74 | (save-buffer)) | ||
75 | |||
70 | ;;; Add `setup' forms to `imenu-generic-expression' | 76 | ;;; Add `setup' forms to `imenu-generic-expression' |
71 | 77 | ||
72 | (defun +init-add-setup-to-imenu () | 78 | (defun +init-add-setup-to-imenu () |
diff --git a/lisp/+lisp.el b/lisp/+lisp.el index 3267fd9..07dfcbd 100644 --- a/lisp/+lisp.el +++ b/lisp/+lisp.el | |||
@@ -67,5 +67,94 @@ with `string<' starting with the key determined by KEY-FN." | |||
67 | (insert-before-markers real) | 67 | (insert-before-markers real) |
68 | (delete-region (point) (marker-position end)))))))) | 68 | (delete-region (point) (marker-position end)))))))) |
69 | 69 | ||
70 | ;;; Comment-or-uncomment-sexp | ||
71 | ;; from https://endlessparentheses.com/a-comment-or-uncomment-sexp-command.html | ||
72 | |||
73 | (defun +lisp-uncomment-sexp (&optional n) | ||
74 | "Uncomment N sexps around point." | ||
75 | (interactive "P") | ||
76 | (let* ((initial-point (point-marker)) | ||
77 | (inhibit-field-text-motion t) | ||
78 | (p) | ||
79 | (end (save-excursion | ||
80 | (when (elt (syntax-ppss) 4) | ||
81 | (re-search-backward comment-start-skip | ||
82 | (line-beginning-position) | ||
83 | t)) | ||
84 | (setq p (point-marker)) | ||
85 | (comment-forward (point-max)) | ||
86 | (point-marker))) | ||
87 | (beg (save-excursion | ||
88 | (forward-line 0) | ||
89 | (while (and (not (bobp)) | ||
90 | (= end (save-excursion | ||
91 | (comment-forward (point-max)) | ||
92 | (point)))) | ||
93 | (forward-line -1)) | ||
94 | (goto-char (line-end-position)) | ||
95 | (re-search-backward comment-start-skip | ||
96 | (line-beginning-position) | ||
97 | t) | ||
98 | (ignore-errors | ||
99 | (while (looking-at-p comment-start-skip) | ||
100 | (forward-char -1))) | ||
101 | (point-marker)))) | ||
102 | (unless (= beg end) | ||
103 | (uncomment-region beg end) | ||
104 | (goto-char p) | ||
105 | ;; Indentify the "top-level" sexp inside the comment. | ||
106 | (while (and (ignore-errors (backward-up-list) t) | ||
107 | (>= (point) beg)) | ||
108 | (skip-chars-backward (rx (syntax expression-prefix))) | ||
109 | (setq p (point-marker))) | ||
110 | ;; Re-comment everything before it. | ||
111 | (ignore-errors | ||
112 | (comment-region beg p)) | ||
113 | ;; And everything after it. | ||
114 | (goto-char p) | ||
115 | (forward-sexp (or n 1)) | ||
116 | (skip-chars-forward "\r\n[:blank:]") | ||
117 | (if (< (point) end) | ||
118 | (ignore-errors | ||
119 | (comment-region (point) end)) | ||
120 | ;; If this is a closing delimiter, pull it up. | ||
121 | (goto-char end) | ||
122 | (skip-chars-forward "\r\n[:blank:]") | ||
123 | (when (eq 5 (car (syntax-after (point)))) | ||
124 | (delete-indentation)))) | ||
125 | ;; Without a prefix, it's more useful to leave point where | ||
126 | ;; it was. | ||
127 | (unless n | ||
128 | (goto-char initial-point)))) | ||
129 | |||
130 | (defun +lisp-comment-sexp--raw () | ||
131 | "Comment the sexp at point or ahead of point." | ||
132 | (pcase (or (bounds-of-thing-at-point 'sexp) | ||
133 | (save-excursion | ||
134 | (skip-chars-forward "\r\n[:blank:]") | ||
135 | (bounds-of-thing-at-point 'sexp))) | ||
136 | (`(,l . ,r) | ||
137 | (goto-char r) | ||
138 | (skip-chars-forward "\r\n[:blank:]") | ||
139 | (save-excursion | ||
140 | (comment-region l r)) | ||
141 | (skip-chars-forward "\r\n[:blank:]")))) | ||
142 | |||
143 | (defun +lisp-comment-or-uncomment-sexp (&optional n) | ||
144 | "Comment the sexp at point and move past it. | ||
145 | If already inside (or before) a comment, uncomment instead. | ||
146 | With a prefix argument N, (un)comment that many sexps." | ||
147 | (interactive "P") | ||
148 | (if (or (elt (syntax-ppss) 4) | ||
149 | (< (save-excursion | ||
150 | (skip-chars-forward "\r\n[:blank:]") | ||
151 | (point)) | ||
152 | (save-excursion | ||
153 | (comment-forward 1) | ||
154 | (point)))) | ||
155 | (+lisp-uncomment-sexp n) | ||
156 | (dotimes (_ (or n 1)) | ||
157 | (+lisp-comment-sexp--raw)))) | ||
158 | |||
70 | (provide '+lisp) | 159 | (provide '+lisp) |
71 | ;;; +lisp.el ends here | 160 | ;;; +lisp.el ends here |
diff --git a/lisp/+modeline.el b/lisp/+modeline.el index 5354e5b..5f46a75 100644 --- a/lisp/+modeline.el +++ b/lisp/+modeline.el | |||
@@ -17,22 +17,62 @@ | |||
17 | :prefix "+modeline-" | 17 | :prefix "+modeline-" |
18 | :group 'simple-modeline) | 18 | :group 'simple-modeline) |
19 | 19 | ||
20 | (defun +modeline-buffer-name () ; gonsie | 20 | (defcustom +modeline-default-spacer " " |
21 | "Default spacer to use for modeline elements. | ||
22 | All modeline elements take an optional argument, `spacer', which | ||
23 | will default to this string.") | ||
24 | |||
25 | ;;; Combinators | ||
26 | |||
27 | (defun +modeline-concat (segments &optional separator) | ||
28 | "Concatenate multiple `simple-modeline'-style SEGMENTS. | ||
29 | SEGMENTS is a list of either modeline segment-functions (see | ||
30 | `simple-modeline' functions for an example of types of | ||
31 | functions), though it can also contain cons cells of the | ||
32 | form (SEGMENT . PREDICATE). | ||
33 | |||
34 | Segments are separated from each other using SEPARATOR, which | ||
35 | defaults to a \" \". space. Only segments that evaluate to a | ||
36 | non-trivial string (that is, a string not equal to \"\") will be | ||
37 | separated, for a cleaner look. | ||
38 | |||
39 | This function makes a lambda, so you can throw it straight into | ||
40 | `simple-modeline-segments'." | ||
41 | (setq separator (or separator +modeline-default-spacer)) | ||
42 | (lambda () | ||
43 | (apply #'concat | ||
44 | (let (this-sep result-list) | ||
45 | (dolist (segment segments) | ||
46 | (push (funcall (or (car-safe segment) segment) | ||
47 | this-sep) | ||
48 | result-list) | ||
49 | (if (or (cdr-safe segment) | ||
50 | (and (car result-list) | ||
51 | (not (equal (car result-list) "")))) | ||
52 | (setq this-sep separator) | ||
53 | (setq this-sep nil))) | ||
54 | (unless (seq-some #'null result-list) | ||
55 | (push +modeline-default-spacer result-list)) | ||
56 | (nreverse result-list))))) | ||
57 | |||
58 | ;;; Modeline segments | ||
59 | |||
60 | (defun +modeline-buffer-name (&optional spacer) ; gonsie | ||
21 | "Display the buffer name." | 61 | "Display the buffer name." |
22 | (concat " " (propertize | 62 | (concat (or spacer +modeline-default-spacer) |
23 | (+string-align (buffer-name) 20 :before "" :ellipsis "~ ") | 63 | (propertize |
24 | 'face 'bold | 64 | (+string-align (buffer-name) 20 :ellipsis nil) |
25 | 'help-echo (or (buffer-file-name) | 65 | 'help-echo (or (buffer-file-name) |
26 | (buffer-name)) | 66 | (buffer-name)) |
27 | 'mouse-face 'mode-line-highlight))) | 67 | 'mouse-face 'mode-line-highlight))) |
28 | 68 | ||
29 | (defcustom +modeline-minions-icon "&" | 69 | (defcustom +modeline-minions-icon "&" |
30 | "The \"icon\" for `+modeline-minions' button." | 70 | "The \"icon\" for `+modeline-minions' button." |
31 | :type 'string) | 71 | :type 'string) |
32 | 72 | ||
33 | (defun +modeline-minions () | 73 | (defun +modeline-minions (&optional spacer) |
34 | "Display a button for `minions-minor-modes-menu'." | 74 | "Display a button for `minions-minor-modes-menu'." |
35 | (concat " " | 75 | (concat (or spacer +modeline-default-spacer) |
36 | (propertize | 76 | (propertize |
37 | +modeline-minions-icon | 77 | +modeline-minions-icon |
38 | 'help-echo "Minor modes menu\nmouse-1: show menu." | 78 | 'help-echo "Minor modes menu\nmouse-1: show menu." |
@@ -45,9 +85,9 @@ | |||
45 | (minions-minor-modes-menu))))) | 85 | (minions-minor-modes-menu))))) |
46 | 'mouse-face 'mode-line-highlight))) | 86 | 'mouse-face 'mode-line-highlight))) |
47 | 87 | ||
48 | (defun +modeline-major-mode () | 88 | (defun +modeline-major-mode (&optional spacer) |
49 | "Display the current `major-mode'." | 89 | "Display the current `major-mode'." |
50 | (concat " " | 90 | (concat (or spacer +modeline-default-spacer) |
51 | (propertize (+string-truncate (format-mode-line mode-name) | 91 | (propertize (+string-truncate (format-mode-line mode-name) |
52 | 12 "~") | 92 | 12 "~") |
53 | 'face 'bold | 93 | 'face 'bold |
@@ -80,7 +120,7 @@ The order of elements matters: whichever one matches first is applied." | |||
80 | `+modeline-modified'." | 120 | `+modeline-modified'." |
81 | :type '(repeat function)) | 121 | :type '(repeat function)) |
82 | 122 | ||
83 | (defun +modeline-modified () ; modified from `simple-modeline-status-modified' | 123 | (defun +modeline-modified (&optional spacer) ; modified from `simple-modeline-status-modified' |
84 | "Display a color-coded \"icon\" indicator for the buffer's status." | 124 | "Display a color-coded \"icon\" indicator for the buffer's status." |
85 | (let* ((icon (catch :icon | 125 | (let* ((icon (catch :icon |
86 | (dolist (cell +modeline-modified-icon-alist) | 126 | (dolist (cell +modeline-modified-icon-alist) |
@@ -94,14 +134,20 @@ The order of elements matters: whichever one matches first is applied." | |||
94 | ('t t) | 134 | ('t t) |
95 | (_ nil)) | 135 | (_ nil)) |
96 | (throw :icon (cdr cell))))))) | 136 | (throw :icon (cdr cell))))))) |
97 | (concat " " | 137 | (concat (or spacer +modeline-default-spacer) |
98 | (propertize (or icon "") | 138 | (propertize (or icon "") |
99 | 'mouse-face 'mode-line-highlight)))) | 139 | 'mouse-face 'mode-line-highlight)))) |
100 | 140 | ||
101 | (defun +modeline-narrowed () | 141 | (defun +modeline-buffer-modes (&optional spacer) |
142 | "Display various buffer-specific stuff cleanly." | ||
143 | ;; This is clunky and should probably be improved. | ||
144 | (concat (+modeline-reading-mode) | ||
145 | (+modeline-narrowed (when reading-mode ",")))) | ||
146 | |||
147 | (defun +modeline-narrowed (&optional spacer) | ||
102 | "Display an indication that the buffer is narrowed." | 148 | "Display an indication that the buffer is narrowed." |
103 | (when (buffer-narrowed-p) | 149 | (when (buffer-narrowed-p) |
104 | (concat " " | 150 | (concat (or spacer +modeline-default-spacer) |
105 | (propertize "N" | 151 | (propertize "N" |
106 | 'help-echo (format "%s\n%s" | 152 | 'help-echo (format "%s\n%s" |
107 | "Buffer is narrowed." | 153 | "Buffer is narrowed." |
@@ -111,10 +157,10 @@ The order of elements matters: whichever one matches first is applied." | |||
111 | 'face 'font-lock-doc-face | 157 | 'face 'font-lock-doc-face |
112 | 'mouse-face 'mode-line-highlight)))) | 158 | 'mouse-face 'mode-line-highlight)))) |
113 | 159 | ||
114 | (defun +modeline-reading-mode () | 160 | (defun +modeline-reading-mode (&optional spacer) |
115 | "Display an indication that the buffer is in `reading-mode'." | 161 | "Display an indication that the buffer is in `reading-mode'." |
116 | (when reading-mode | 162 | (when reading-mode |
117 | (concat " " | 163 | (concat (or spacer +modeline-default-spacer) |
118 | (propertize | 164 | (propertize |
119 | (concat "R" (when (bound-and-true-p +eww-readable-p) "w")) | 165 | (concat "R" (when (bound-and-true-p +eww-readable-p) "w")) |
120 | 'help-echo (format "%s\n%s" | 166 | 'help-echo (format "%s\n%s" |
@@ -136,7 +182,7 @@ The order of elements matters: whichever one matches first is applied." | |||
136 | "Toggle the percentage display in the mode line (File Percentage Mode)." | 182 | "Toggle the percentage display in the mode line (File Percentage Mode)." |
137 | :init-value t :global t :group 'mode-line) | 183 | :init-value t :global t :group 'mode-line) |
138 | 184 | ||
139 | (defun +modeline-position () ; adapted from `simple-modeline' | 185 | (defun +modeline-position (&optional _) ; adapted from `simple-modeline' |
140 | "Display the current cursor position." | 186 | "Display the current cursor position." |
141 | (list '((line-number-mode | 187 | (list '((line-number-mode |
142 | ((column-number-mode | 188 | ((column-number-mode |
@@ -160,34 +206,38 @@ The order of elements matters: whichever one matches first is applied." | |||
160 | (region-bounds)))) | 206 | (region-bounds)))) |
161 | 'font-lock-face 'font-lock-variable-name-face)))) | 207 | 'font-lock-face 'font-lock-variable-name-face)))) |
162 | 208 | ||
163 | (defun +modeline-vc () | 209 | (defun +modeline-vc (&optional spacer) |
164 | "Display the version control branch of the current buffer in the modeline." | 210 | "Display the version control branch of the current buffer in the modeline." |
165 | ;; from https://www.gonsie.com/blorg/modeline.html, from Doom | 211 | ;; from https://www.gonsie.com/blorg/modeline.html, from Doom |
166 | (if-let ((backend (vc-backend buffer-file-name))) | 212 | (if-let ((backend (vc-backend buffer-file-name))) |
167 | (concat " " (substring vc-mode (+ (if (eq backend 'Hg) 2 3) 2))))) | 213 | (concat (or spacer +modeline-default-spacer) |
214 | (substring vc-mode (+ (if (eq backend 'Hg) 2 3) 2))))) | ||
168 | 215 | ||
169 | (defun +modeline-track () | 216 | (defun +modeline-track (&optional spacer) |
170 | "Display `tracking-mode' information." | 217 | "Display `tracking-mode' information." |
171 | '(tracking-mode | 218 | (when tracking-mode |
172 | tracking-mode-line-buffers)) | 219 | tracking-mode-line-buffers)) |
173 | 220 | ||
174 | (defun +modeline-anzu () | 221 | (defun +modeline-anzu (&optional spacer) |
175 | "Display `anzu--update-mode-line'." | 222 | "Display `anzu--update-mode-line'." |
176 | (concat " " (anzu--update-mode-line))) | 223 | (concat (or spacer +modeline-default-spacer) |
224 | (anzu--update-mode-line))) | ||
177 | 225 | ||
178 | (defun +modeline-text-scale () | 226 | (defun +modeline-text-scale (&optional spacer) |
179 | "Display text scaling level." | 227 | "Display text scaling level." |
180 | ;; adapted from https://github.com/seagle0128/doom-modeline | 228 | ;; adapted from https://github.com/seagle0128/doom-modeline |
181 | (when (and (boundp 'text-scale-mode-amount) | 229 | (when (and (boundp 'text-scale-mode-amount) |
182 | (/= text-scale-mode-amount 0)) | 230 | (/= text-scale-mode-amount 0)) |
183 | (format (if (> text-scale-mode-amount 0) " (%+d)" " (%-d)") | 231 | (format (if (> text-scale-mode-amount 0) "%s(%+d)" "%s(%-d)") |
232 | (or spacer +modeline-default-spacer) | ||
184 | text-scale-mode-amount))) | 233 | text-scale-mode-amount))) |
185 | 234 | ||
186 | (defun +modeline-ace-window-display () | 235 | (defun +modeline-ace-window-display (&optional spacer) |
187 | "Display `ace-window-display-mode' information in the modeline." | 236 | "Display `ace-window-display-mode' information in the modeline." |
188 | '(+ace-window-display-mode | 237 | (when (and +ace-window-display-mode |
189 | (ace-window-mode | 238 | ace-window-mode) |
190 | (" " (:eval (window-parameter (selected-window) 'ace-window-path)))))) | 239 | (concat (or spacer +modeline-default-spacer) |
240 | (window-parameter (selected-window) 'ace-window-path)))) | ||
191 | 241 | ||
192 | (provide '+modeline) | 242 | (provide '+modeline) |
193 | ;;; +modeline.el ends here | 243 | ;;; +modeline.el ends here |
diff --git a/lisp/+setup.el b/lisp/+setup.el index dce5d7b..ac99c1f 100644 --- a/lisp/+setup.el +++ b/lisp/+setup.el | |||
@@ -72,7 +72,7 @@ | |||
72 | 72 | ||
73 | (setup-define :straight | 73 | (setup-define :straight |
74 | (lambda (recipe) | 74 | (lambda (recipe) |
75 | `(unless (straight-use-package ',recipe) | 75 | `(unless (ignore-errors (straight-use-package ',recipe)) |
76 | ,(setup-quit))) | 76 | ,(setup-quit))) |
77 | :documentation | 77 | :documentation |
78 | "Install RECIPE with `straight-use-package'. | 78 | "Install RECIPE with `straight-use-package'. |
diff --git a/lisp/+util.el b/lisp/+util.el index fb77278..45d1e6d 100644 --- a/lisp/+util.el +++ b/lisp/+util.el | |||
@@ -58,7 +58,8 @@ either side of S. | |||
58 | 58 | ||
59 | FILL is the string to fill extra space with (default \" \"). | 59 | FILL is the string to fill extra space with (default \" \"). |
60 | 60 | ||
61 | ELLIPSIS is the string to show when S is too long to fit (default \"...\"). | 61 | ELLIPSIS is the string to show when S is too long to fit (default |
62 | \"...\"). If nil, don't truncate the string. | ||
62 | 63 | ||
63 | ALIGNMENT can be one of these: | 64 | ALIGNMENT can be one of these: |
64 | - nil: align to `+string-default-alignment' | 65 | - nil: align to `+string-default-alignment' |
@@ -73,7 +74,7 @@ ALIGNMENT can be one of these: | |||
73 | (format "%s%s%s%s%s" | 74 | (format "%s%s%s%s%s" |
74 | before | 75 | before |
75 | (if (eq alignment 'left) "" filler) | 76 | (if (eq alignment 'left) "" filler) |
76 | (+string-truncate s max-length ellipsis alignment) | 77 | (if ellipsis (+string-truncate s max-length ellipsis alignment) s) |
77 | (if (eq alignment 'right) "" filler) | 78 | (if (eq alignment 'right) "" filler) |
78 | after))) | 79 | after))) |
79 | 80 | ||