diff options
-rw-r--r-- | init.el | 223 | ||||
-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 |
7 files changed, 353 insertions, 177 deletions
diff --git a/init.el b/init.el index d4a6a0f..1000714 100644 --- a/init.el +++ b/init.el | |||
@@ -24,13 +24,19 @@ | |||
24 | (setq debug-on-error t) | 24 | (setq debug-on-error t) |
25 | 25 | ||
26 | (setup (:require +emacs) | 26 | (setup (:require +emacs) |
27 | (:also-load +lisp) | ||
27 | ;; +emacs.el contains super-basic defaults that are basically | 28 | ;; +emacs.el contains super-basic defaults that are basically |
28 | ;; necessary for good functioning. In this block, I add extra | 29 | ;; necessary for good functioning. In this block, I add extra |
29 | ;; things or more "experimental" ones that might not belong in a | 30 | ;; things or more "experimental" ones that might not belong in a |
30 | ;; separate file. | 31 | ;; separate file. |
31 | (:global "C-x C-k" 'kill-this-buffer | 32 | (:global "C-x C-k" #'kill-this-buffer |
32 | "C-x 4 n" 'clone-buffer | 33 | "C-x 4 n" #'clone-buffer |
33 | "C-c v" 'visible-mode) | 34 | "C-c v" #'visible-mode |
35 | "C-M-;" #'+lisp-comment-or-uncomment-sexp) | ||
36 | ;; Unbind stuff, too. | ||
37 | (dolist (key '("C-M-j" | ||
38 | "M-j")) | ||
39 | (global-set-key (kbd key) nil)) | ||
34 | ;; C-h deletes backward - see https://idiomdrottning.org/bad-emacs-defaults | 40 | ;; C-h deletes backward - see https://idiomdrottning.org/bad-emacs-defaults |
35 | (global-set-key (kbd "C-h") 'delete-backward-char) | 41 | (global-set-key (kbd "C-h") 'delete-backward-char) |
36 | (keyboard-translate ?\C-h ?\C-?) | 42 | (keyboard-translate ?\C-h ?\C-?) |
@@ -44,10 +50,7 @@ | |||
44 | (advice-add 'yank-pop :after '+yank@indent)) | 50 | (advice-add 'yank-pop :after '+yank@indent)) |
45 | 51 | ||
46 | (setup (:require +init) | 52 | (setup (:require +init) |
47 | (:bind "C-c s" (lambda () | 53 | (:bind "C-c s" #'+init-sort-then-save) |
48 | (interactive) | ||
49 | (+init-sort) | ||
50 | (save-buffer))) | ||
51 | (:hook #'+init-add-setup-to-imenu)) | 54 | (:hook #'+init-add-setup-to-imenu)) |
52 | 55 | ||
53 | (setup (:require +key) | 56 | (setup (:require +key) |
@@ -68,8 +71,7 @@ | |||
68 | (:also-load +pulse) | 71 | (:also-load +pulse) |
69 | (:option pulse-flag nil | 72 | (:option pulse-flag nil |
70 | pulse-delay 0.5 | 73 | pulse-delay 0.5 |
71 | pulse-iterations 1 | 74 | pulse-iterations 1) |
72 | (append +pulse-location-commands) 'lui-track-jump-to-indicator) | ||
73 | (+pulse-location-mode +1)) | 75 | (+pulse-location-mode +1)) |
74 | 76 | ||
75 | (setup (:require reading) | 77 | (setup (:require reading) |
@@ -93,8 +95,8 @@ | |||
93 | (setup browse-url | 95 | (setup browse-url |
94 | (:require +browse-url) | 96 | (:require +browse-url) |
95 | (:option browse-url-secondary-browser-function (if (executable-find "firefox") | 97 | (:option browse-url-secondary-browser-function (if (executable-find "firefox") |
96 | 'browse-url-firefox | 98 | #'browse-url-firefox |
97 | 'browse-url-default-browser) | 99 | #'browse-url-default-browser) |
98 | browse-url-new-window-flag nil | 100 | browse-url-new-window-flag nil |
99 | browse-url-firefox-arguments '("--new-tab") | 101 | browse-url-firefox-arguments '("--new-tab") |
100 | browse-url-firefox-new-window-is-tab t) | 102 | browse-url-firefox-new-window-is-tab t) |
@@ -105,15 +107,15 @@ | |||
105 | "." (or "jpeg" "jpg" "png") eos) | 107 | "." (or "jpeg" "jpg" "png") eos) |
106 | (lambda (&rest args) | 108 | (lambda (&rest args) |
107 | (apply | 109 | (apply |
108 | (cond ((executable-find "mpv") '+browse-image-with-mpv) | 110 | (cond ((executable-find "mpv") #'+browse-image-with-mpv) |
109 | (t 'eww-browse-url)) | 111 | (t #'eww-browse-url)) |
110 | args))) | 112 | args))) |
111 | (cons (rx ; videos | 113 | (cons (rx ; videos |
112 | (or "youtube.com" "youtu.be" "yewtu.be" | 114 | (or "youtube.com" "youtu.be" "yewtu.be" |
113 | (seq "." (or "mp4" "gif" "mov" "MOV") eos))) | 115 | (seq "." (or "mp4" "gif" "mov" "MOV") eos))) |
114 | (lambda (&rest args) | 116 | (lambda (&rest args) |
115 | (apply (if (executable-find "mpv") | 117 | (apply (if (executable-find "mpv") |
116 | '+browse-url-with-mpv | 118 | #'+browse-url-with-mpv |
117 | browse-url-secondary-browser-function) | 119 | browse-url-secondary-browser-function) |
118 | args))) | 120 | args))) |
119 | (cons (rx ; non-eww-friendly websites | 121 | (cons (rx ; non-eww-friendly websites |
@@ -130,7 +132,7 @@ | |||
130 | )) | 132 | )) |
131 | browse-url-secondary-browser-function) | 133 | browse-url-secondary-browser-function) |
132 | (cons "." ; everything else | 134 | (cons "." ; everything else |
133 | 'eww-browse-url))) | 135 | #'eww-browse-url))) |
134 | ;; Transform URLs before passing to `browse-url' | 136 | ;; Transform URLs before passing to `browse-url' |
135 | (:option +browse-url-transformations `((,(rx "//" (or "youtube.com" | 137 | (:option +browse-url-transformations `((,(rx "//" (or "youtube.com" |
136 | "youtu.be")) | 138 | "youtu.be")) |
@@ -163,7 +165,8 @@ | |||
163 | custom-raised-buttons nil | 165 | custom-raised-buttons nil |
164 | custom-unlispify-tag-names nil | 166 | custom-unlispify-tag-names nil |
165 | custom-variable-default-form 'lisp | 167 | custom-variable-default-form 'lisp |
166 | +custom-variable-allowlist '(safe-local-variable-values)) | 168 | +custom-variable-allowlist '(safe-local-variable-values |
169 | warning-suppress-types)) | ||
167 | (when (file-exists-p custom-file) | 170 | (when (file-exists-p custom-file) |
168 | (+custom-load-ignoring-most-customizations t)) | 171 | (+custom-load-ignoring-most-customizations t)) |
169 | (advice-add #'custom-buffer-create-internal :after #'+cus-edit-expand-widgets) | 172 | (advice-add #'custom-buffer-create-internal :after #'+cus-edit-expand-widgets) |
@@ -183,10 +186,10 @@ | |||
183 | dired-listing-switches "-Al" | 186 | dired-listing-switches "-Al" |
184 | ls-lisp-dirs-first t | 187 | ls-lisp-dirs-first t |
185 | dired-ls-F-marks-symlinks t | 188 | dired-ls-F-marks-symlinks t |
186 | dired-no-confirm '(byte-compile | 189 | dired-no-confirm '(byte-compile load |
187 | chgrp chmod chown copy | 190 | chgrp chmod chown |
188 | hardlink load move | 191 | copy move hardlink symlink |
189 | shell touch symlink) | 192 | shell touch) |
190 | dired-dwim-target t) | 193 | dired-dwim-target t) |
191 | (:bind "<backspace>" #'dired-up-directory | 194 | (:bind "<backspace>" #'dired-up-directory |
192 | "TAB" #'dired-subtree-cycle | 195 | "TAB" #'dired-subtree-cycle |
@@ -205,7 +208,7 @@ | |||
205 | (:option dired-listing-switches | 208 | (:option dired-listing-switches |
206 | (concat dired-listing-switches " -F"))))) | 209 | (concat dired-listing-switches " -F"))))) |
207 | (with-eval-after-load 'frowny | 210 | (with-eval-after-load 'frowny |
208 | (add-to-list 'frowny-inhibit-modes 'dired-mode))) | 211 | (add-to-list 'frowny-inhibit-modes #'dired-mode))) |
209 | 212 | ||
210 | (setup eldoc | 213 | (setup eldoc |
211 | (:hook-into elisp-mode | 214 | (:hook-into elisp-mode |
@@ -333,7 +336,7 @@ | |||
333 | 336 | ||
334 | (setup scratch | 337 | (setup scratch |
335 | (:require +scratch) | 338 | (:require +scratch) |
336 | (:option initial-major-mode 'lisp-interaction-mode | 339 | (:option initial-major-mode #'lisp-interaction-mode |
337 | initial-scratch-message | 340 | initial-scratch-message |
338 | ";; ABANDON ALL HOPE YE WHO ENTER HERE\n\n") | 341 | ";; ABANDON ALL HOPE YE WHO ENTER HERE\n\n") |
339 | (add-hook 'kill-buffer-query-functions #'+scratch-immortal)) | 342 | (add-hook 'kill-buffer-query-functions #'+scratch-immortal)) |
@@ -344,7 +347,7 @@ | |||
344 | (setup (:straight 0x0) | 347 | (setup (:straight 0x0) |
345 | (:option 0x0-default-server 'ttm) | 348 | (:option 0x0-default-server 'ttm) |
346 | (with-eval-after-load 'embark | 349 | (with-eval-after-load 'embark |
347 | (define-key embark-region-map (kbd "U") '0x0-dwim))) | 350 | (define-key embark-region-map (kbd "U") #'0x0-dwim))) |
348 | 351 | ||
349 | (setup (:straight ace-window) | 352 | (setup (:straight ace-window) |
350 | (:require +ace-window) | 353 | (:require +ace-window) |
@@ -416,7 +419,7 @@ | |||
416 | circe-prompt-string (format (format "%%%ds> " | 419 | circe-prompt-string (format (format "%%%ds> " |
417 | (- +circe-left-margin 2)) | 420 | (- +circe-left-margin 2)) |
418 | " ")) | 421 | " ")) |
419 | 422 | ||
420 | (:option +circe-server-buffer-action (lambda (buf) | 423 | (:option +circe-server-buffer-action (lambda (buf) |
421 | (message "Connected to %s" buf)) | 424 | (message "Connected to %s" buf)) |
422 | +circe-network-inhibit-autoconnect _circe-network-inhibit-autoconnect | 425 | +circe-network-inhibit-autoconnect _circe-network-inhibit-autoconnect |
@@ -434,7 +437,7 @@ | |||
434 | (advice-add #'circe-command-PART :after #'+circe-kill-buffer) | 437 | (advice-add #'circe-command-PART :after #'+circe-kill-buffer) |
435 | (advice-add #'circe-command-QUIT :after #'+circe-quit@kill-buffer) | 438 | (advice-add #'circe-command-QUIT :after #'+circe-quit@kill-buffer) |
436 | (advice-add #'circe-command-GQUIT :after #'+circe-gquit@kill-buffer) | 439 | (advice-add #'circe-command-GQUIT :after #'+circe-gquit@kill-buffer) |
437 | 440 | ||
438 | (:with-mode circe-chat-mode | 441 | (:with-mode circe-chat-mode |
439 | (:hook #'enable-circe-color-nicks | 442 | (:hook #'enable-circe-color-nicks |
440 | #'enable-circe-new-day-notifier | 443 | #'enable-circe-new-day-notifier |
@@ -454,7 +457,8 @@ | |||
454 | (,(+lui-make-formatting-list-rx "_") | 457 | (,(+lui-make-formatting-list-rx "_") |
455 | 1 lui-emphasis-face) | 458 | 1 lui-emphasis-face) |
456 | (,(+lui-make-formatting-list-rx "/") | 459 | (,(+lui-make-formatting-list-rx "/") |
457 | 1 lui-emphasis-face))) | 460 | 1 lui-emphasis-face)) |
461 | (append +pulse-location-commands) 'lui-track-jump-to-indicator) | ||
458 | (:hook #'visual-line-mode | 462 | (:hook #'visual-line-mode |
459 | #'enable-lui-track | 463 | #'enable-lui-track |
460 | #'visual-fill-column-mode) | 464 | #'visual-fill-column-mode) |
@@ -481,67 +485,67 @@ | |||
481 | (:also-load +consult) | 485 | (:also-load +consult) |
482 | ;; from Consult wiki | 486 | ;; from Consult wiki |
483 | (:option register-preview-delay 0 | 487 | (:option register-preview-delay 0 |
484 | register-preview-function 'consult-register-format | 488 | register-preview-function 'consult-register-format |
485 | xref-show-xrefs-function 'consult-xref | 489 | xref-show-xrefs-function 'consult-xref |
486 | xref-show-definitions-function 'consult-xref | 490 | xref-show-definitions-function 'consult-xref |
487 | tab-always-indent 'complete | 491 | tab-always-indent 'complete |
488 | completion-in-region-function 'consult-completion-in-region) | 492 | completion-in-region-function 'consult-completion-in-region) |
489 | (advice-add #'register-preview :override #'consult-register-window) | 493 | (advice-add #'register-preview :override #'consult-register-window) |
490 | (advice-add #'completing-read-multiple :override | 494 | (advice-add #'completing-read-multiple :override |
491 | #'consult-completing-read-multiple) | 495 | #'consult-completing-read-multiple) |
492 | (dolist (binding '(;; C-c bindings (mode-specific-map) | 496 | (dolist (binding '(;; C-c bindings (mode-specific-map) |
493 | ("C-c h" . consult-history) | 497 | ("C-c h" . consult-history) |
494 | ("C-c m" . consult-mode-command) | 498 | ("C-c m" . consult-mode-command) |
495 | ("C-c b" . consult-bookmark) | 499 | ("C-c b" . consult-bookmark) |
496 | ("C-c k" . consult-kmacro) | 500 | ("C-c k" . consult-kmacro) |
497 | ;; C-x bindings (ctl-x-map) | 501 | ;; C-x bindings (ctl-x-map) |
498 | ("C-x M-:" . consult-complex-command) | 502 | ("C-x M-:" . consult-complex-command) |
499 | ("C-x b" . consult-buffer) | 503 | ("C-x b" . consult-buffer) |
500 | ("C-x 4 b" . consult-buffer-other-window) | 504 | ("C-x 4 b" . consult-buffer-other-window) |
501 | ("C-x 5 b" . consult-buffer-other-frame) | 505 | ("C-x 5 b" . consult-buffer-other-frame) |
502 | ;; Custom M-# bindings for fast register access | 506 | ;; Custom M-# bindings for fast register access |
503 | ("M-#" . consult-register-load) | 507 | ("M-#" . consult-register-load) |
504 | ("M-'" . consult-register-store) | 508 | ("M-'" . consult-register-store) |
505 | ("C-M-#" . consult-register) | 509 | ("C-M-#" . consult-register) |
506 | ;; Other custom bindings | 510 | ;; Other custom bindings |
507 | ("M-y" . consult-yank-pop) | 511 | ("M-y" . consult-yank-pop) |
508 | ("<f1> a" . consult-apropos) | 512 | ("<f1> a" . consult-apropos) |
509 | ;; M-g bindings (goto-map) | 513 | ;; M-g bindings (goto-map) |
510 | ("M-g e" . consult-compile-error) | 514 | ("M-g e" . consult-compile-error) |
511 | ("M-g f" . consult-flymake) ; or consult-flycheck | 515 | ("M-g f" . consult-flymake) ; or consult-flycheck |
512 | ("M-g g" . consult-goto-line) | 516 | ("M-g g" . consult-goto-line) |
513 | ("M-g M-g" . consult-goto-line) | 517 | ("M-g M-g" . consult-goto-line) |
514 | ("M-g o" . consult-outline) ; or consult-org-heading | 518 | ("M-g o" . consult-outline) ; or consult-org-heading |
515 | ("M-g m" . consult-mark) | 519 | ("M-g m" . consult-mark) |
516 | ("M-g k" . consult-global-mark) | 520 | ("M-g k" . consult-global-mark) |
517 | ("M-g i" . consult-imenu) | 521 | ("M-g i" . consult-imenu) |
518 | ("M-g I" . consult-imenu-multi) | 522 | ("M-g I" . consult-imenu-multi) |
519 | ;; M-s bindings (search-map) | 523 | ;; M-s bindings (search-map) |
520 | ("M-s f" . consult-find) | 524 | ("M-s f" . consult-find) |
521 | ("M-s F" . consult-locate) | 525 | ("M-s F" . consult-locate) |
522 | ("M-s g" . consult-grep) | 526 | ("M-s g" . consult-grep) |
523 | ("M-s G" . consult-git-grep) | 527 | ("M-s G" . consult-git-grep) |
524 | ("M-s r" . consult-ripgrep) | 528 | ("M-s r" . consult-ripgrep) |
525 | ("M-s l" . consult-line) | 529 | ("M-s l" . consult-line) |
526 | ("M-s L" . consult-line-multi) | 530 | ("M-s L" . consult-line-multi) |
527 | ("M-s m" . consult-multi-occur) | 531 | ("M-s m" . consult-multi-occur) |
528 | ("M-s k" . consult-keep-lines) | 532 | ("M-s k" . consult-keep-lines) |
529 | ("M-s u" . consult-focus-lines) | 533 | ("M-s u" . consult-focus-lines) |
530 | ;; Isearch integration | 534 | ;; Isearch integration |
531 | ("M-s e" . consult-isearch-history))) | 535 | ("M-s e" . consult-isearch-history))) |
532 | (define-key +key-mode-map (kbd (car binding)) (cdr binding))) | 536 | (define-key +key-mode-map (kbd (car binding)) (cdr binding))) |
533 | (with-eval-after-load 'isearch-mode | 537 | (with-eval-after-load 'isearch-mode |
534 | (dolist (binding '(("M-e" . consult-isearch-history) | 538 | (dolist (binding '(("M-e" . consult-isearch-history) |
535 | ("M-s e" . consult-isearch-history) | 539 | ("M-s e" . consult-isearch-history) |
536 | ("M-s l" . consult-line) | 540 | ("M-s l" . consult-line) |
537 | ("M-s L" . consult-line-multi))) | 541 | ("M-s L" . consult-line-multi))) |
538 | (define-key isearch-mode-map (car binding) (cdr binding)))) | 542 | (define-key isearch-mode-map (car binding) (cdr binding)))) |
539 | (with-eval-after-load 'org-mode | 543 | (with-eval-after-load 'org-mode |
540 | (define-key org-mode-map "M-g o" 'consult-org-heading)) | 544 | (define-key org-mode-map "M-g o" 'consult-org-heading)) |
541 | (advice-add 'consult-yank-pop :after '+yank@indent) | 545 | (advice-add 'consult-yank-pop :after '+yank@indent) |
542 | (with-eval-after-load 'consult | 546 | (with-eval-after-load 'consult |
543 | (:option consult-narrow-key "<" | 547 | (:option consult-narrow-key "<" |
544 | consult-project-root-function '+consult-project-root) | 548 | consult-project-root-function '+consult-project-root) |
545 | (consult-customize | 549 | (consult-customize |
546 | consult-theme | 550 | consult-theme |
547 | :preview-key '(:debounce 0.2 any) | 551 | :preview-key '(:debounce 0.2 any) |
@@ -629,8 +633,8 @@ See also `crux-reopen-as-root-mode'." | |||
629 | (setup (:straight embark) | 633 | (setup (:straight embark) |
630 | (:option prefix-help-command 'embark-prefix-help-command) | 634 | (:option prefix-help-command 'embark-prefix-help-command) |
631 | (:+key "C-." #'embark-act | 635 | (:+key "C-." #'embark-act |
632 | "M-." #'embark-dwim | 636 | "M-." #'embark-dwim |
633 | "<f1> B" #'embark-bindings)) | 637 | "<f1> B" #'embark-bindings)) |
634 | 638 | ||
635 | (setup (:straight embark-consult) | 639 | (setup (:straight embark-consult) |
636 | (:load-after consult embark) | 640 | (:load-after consult embark) |
@@ -708,7 +712,7 @@ See also `crux-reopen-as-root-mode'." | |||
708 | 712 | ||
709 | (setup (:straight hungry-delete) | 713 | (setup (:straight hungry-delete) |
710 | (:option hungry-delete-chars-to-skip " \t" | 714 | (:option hungry-delete-chars-to-skip " \t" |
711 | hungry-delete-join-reluctantly nil) | 715 | hungry-delete-join-reluctantly nil) |
712 | (:bind-into paredit | 716 | (:bind-into paredit |
713 | ;; I define these functions here because they really require both packages | 717 | ;; I define these functions here because they really require both packages |
714 | ;; to make any sense. So, would I put them in `+hungry-delete' or | 718 | ;; to make any sense. So, would I put them in `+hungry-delete' or |
@@ -717,14 +721,14 @@ See also `crux-reopen-as-root-mode'." | |||
717 | (defun acdw/paredit-hungry-delete-backward (arg) | 721 | (defun acdw/paredit-hungry-delete-backward (arg) |
718 | (interactive "P") | 722 | (interactive "P") |
719 | (if (looking-back "[ \t]" 1) | 723 | (if (looking-back "[ \t]" 1) |
720 | (hungry-delete-backward (or arg 1)) | 724 | (hungry-delete-backward (or arg 1)) |
721 | (paredit-backward-delete arg))) | 725 | (paredit-backward-delete arg))) |
722 | [remap paredit-forward-delete] | 726 | [remap paredit-forward-delete] |
723 | (defun acdw/paredit-hungry-delete-forward (arg) | 727 | (defun acdw/paredit-hungry-delete-forward (arg) |
724 | (interactive "P") | 728 | (interactive "P") |
725 | (if (looking-at "[ \t]") | 729 | (if (looking-at "[ \t]") |
726 | (hungry-delete-forward (or arg 1)) | 730 | (hungry-delete-forward (or arg 1)) |
727 | (paredit-forward-delete arg)))) | 731 | (paredit-forward-delete arg)))) |
728 | (global-hungry-delete-mode +1)) | 732 | (global-hungry-delete-mode +1)) |
729 | 733 | ||
730 | (setup (:straight isearch-mb) | 734 | (setup (:straight isearch-mb) |
@@ -733,19 +737,19 @@ See also `crux-reopen-as-root-mode'." | |||
733 | ;; project's README. | 737 | ;; project's README. |
734 | (with-eval-after-load 'isearch-mb | 738 | (with-eval-after-load 'isearch-mb |
735 | (dolist (spec '((isearch-mb--with-buffer | 739 | (dolist (spec '((isearch-mb--with-buffer |
736 | ("M-e" . consult-isearch) | 740 | ("M-e" . consult-isearch) |
737 | ("C-o" . loccur-isearch)) | 741 | ("C-o" . loccur-isearch)) |
738 | (isearch-mb--after-exit | 742 | (isearch-mb--after-exit |
739 | ("M-%" . anzu-isearch-query-replace) | 743 | ("M-%" . anzu-isearch-query-replace) |
740 | ("M-s l" . consult-line)))) | 744 | ("M-s l" . consult-line)))) |
741 | (let ((isearch-mb-list (car spec)) | 745 | (let ((isearch-mb-list (car spec)) |
742 | (isearch-mb-binds (cdr spec))) | 746 | (isearch-mb-binds (cdr spec))) |
743 | (dolist (cell isearch-mb-binds) | 747 | (dolist (cell isearch-mb-binds) |
744 | (let ((key (car cell)) | 748 | (let ((key (car cell)) |
745 | (command (cdr cell))) | 749 | (command (cdr cell))) |
746 | (when (fboundp command) | 750 | (when (fboundp command) |
747 | (add-to-list isearch-mb-list command) | 751 | (add-to-list isearch-mb-list command) |
748 | (define-key isearch-mb-minibuffer-map (kbd key) command))))))) | 752 | (define-key isearch-mb-minibuffer-map (kbd key) command))))))) |
749 | (isearch-mb-mode +1)) | 753 | (isearch-mb-mode +1)) |
750 | 754 | ||
751 | (setup (:straight lacarte) | 755 | (setup (:straight lacarte) |
@@ -881,11 +885,18 @@ See also `crux-reopen-as-root-mode'." | |||
881 | (setup (:straight org-sticky-header) | 885 | (setup (:straight org-sticky-header) |
882 | (:hook-into org-mode)) | 886 | (:hook-into org-mode)) |
883 | 887 | ||
888 | (setup (:straight package-lint)) | ||
889 | |||
884 | (setup (:straight paredit) | 890 | (setup (:straight paredit) |
885 | (:bind "DEL" #'paredit-backward-delete | 891 | (:bind "DEL" #'paredit-backward-delete |
886 | "C-<backspace>" #'paredit-backward-kill-word) | 892 | "C-<backspace>" #'paredit-backward-kill-word) |
887 | (:hook-into emacs-lisp-mode lisp-interaction-mode | 893 | (dolist (hook '(emacs-lisp-mode-hook |
888 | lisp-mode scheme-mode) | 894 | eval-expression-minibuffer-setup-hook |
895 | ielm-mode-hook | ||
896 | lisp-interaction-mode-hook | ||
897 | lisp-mode-hook | ||
898 | scheme-mode-hook)) | ||
899 | (add-hook hook #'enable-paredit-mode)) | ||
889 | (:also-load eldoc) | 900 | (:also-load eldoc) |
890 | (eldoc-add-command #'paredit-backward-delete #'paredit-close-round)) | 901 | (eldoc-add-command #'paredit-backward-delete #'paredit-close-round)) |
891 | 902 | ||
@@ -911,13 +922,15 @@ See also `crux-reopen-as-root-mode'." | |||
911 | (setup (:straight sicp)) | 922 | (setup (:straight sicp)) |
912 | 923 | ||
913 | (setup (:straight (simple-modeline | 924 | (setup (:straight (simple-modeline |
914 | :fork (:repo "duckwork/simple-modeline"))) | 925 | :fork (:host github :repo "duckwork/simple-modeline"))) |
915 | (:also-load +modeline) | 926 | (:also-load +modeline) |
916 | (:option simple-modeline-segments '((;; left | 927 | (:option simple-modeline-segments `((;; left |
917 | +modeline-ace-window-display | 928 | +modeline-ace-window-display |
918 | +modeline-modified | 929 | +modeline-modified |
919 | +modeline-reading-mode | 930 | ,(+modeline-concat |
920 | +modeline-narrowed | 931 | '(+modeline-reading-mode |
932 | +modeline-narrowed) | ||
933 | ",") | ||
921 | +modeline-buffer-name | 934 | +modeline-buffer-name |
922 | +modeline-position | 935 | +modeline-position |
923 | +modeline-anzu | 936 | +modeline-anzu |
@@ -968,8 +981,8 @@ See also `crux-reopen-as-root-mode'." | |||
968 | (list | 981 | (list |
969 | (propertize " " | 982 | (propertize " " |
970 | 'display | 983 | 'display |
971 | `((space | 984 | `((space |
972 | :align-to | 985 | :align-to |
973 | ,(unless (bound-and-true-p visual-fill-column-mode) | 986 | ,(unless (bound-and-true-p visual-fill-column-mode) |
974 | 0)))) | 987 | 0)))) |
975 | (funcall topsy-fn)))))) | 988 | (funcall topsy-fn)))))) |
@@ -1023,7 +1036,6 @@ See also `crux-reopen-as-root-mode'." | |||
1023 | 1036 | ||
1024 | (setup (:straight whitespace-cleanup-mode) | 1037 | (setup (:straight whitespace-cleanup-mode) |
1025 | (:option whitespace-cleanup-mode-preserve-point t) | 1038 | (:option whitespace-cleanup-mode-preserve-point t) |
1026 | ;;(remove-hook 'before-save-hook 'whitespace-cleanup) | ||
1027 | (global-whitespace-cleanup-mode +1)) | 1039 | (global-whitespace-cleanup-mode +1)) |
1028 | 1040 | ||
1029 | (setup (:straight zoom-frm)) | 1041 | (setup (:straight zoom-frm)) |
@@ -1034,3 +1046,8 @@ See also `crux-reopen-as-root-mode'." | |||
1034 | (interactive "P") | 1046 | (interactive "P") |
1035 | (call-interactively | 1047 | (call-interactively |
1036 | (if prefix #'zzz-up-to-char #'zzz-to-char))))) | 1048 | (if prefix #'zzz-up-to-char #'zzz-to-char))))) |
1049 | |||
1050 | (setup (:straight (actually-selected-window | ||
1051 | :host github | ||
1052 | :repo "duckwork/actually-selected-window.el")) | ||
1053 | (actually-selected-window-mode +1)) | ||
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 | ||