about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2021-12-04 23:09:33 -0600
committerCase Duckworth2021-12-04 23:09:33 -0600
commitb1d307126913cbd4d8af818f7aec7ada6a0ea4ad (patch)
treefdbedcf62596ad56d8bc1a36ea4c4d993ddc3168
parentChange defaults (diff)
downloademacs-b1d307126913cbd4d8af818f7aec7ada6a0ea4ad.tar.gz
emacs-b1d307126913cbd4d8af818f7aec7ada6a0ea4ad.zip
uhhhhhhhh
-rw-r--r--init.el62
-rw-r--r--lisp/+elisp.el18
-rw-r--r--lisp/+modeline.el157
-rw-r--r--lisp/+pulse.el50
4 files changed, 286 insertions, 1 deletions
diff --git a/init.el b/init.el index 57657fe..631ae3d 100644 --- a/init.el +++ b/init.el
@@ -16,10 +16,13 @@
16 16
17;;; Code: 17;;; Code:
18 18
19;; Delete when no longer ... remacs'd
19;; Require early-init.el just in case it hasn't been yet. 20;; Require early-init.el just in case it hasn't been yet.
20(require 'early-init (locate-user-emacs-file "early-init.el") :noerror) 21(require 'early-init (locate-user-emacs-file "early-init.el") :noerror)
22
21;; Requre my private stuff 23;; Requre my private stuff
22(require 'private) 24(require 'private)
25(setq debug-on-error t)
23 26
24(setup (:require +defaults)) 27(setup (:require +defaults))
25 28
@@ -72,6 +75,20 @@
72 (with-eval-after-load 'frowny 75 (with-eval-after-load 'frowny
73 (add-to-list 'frowny-inhibit-modes 'dired-mode))) 76 (add-to-list 'frowny-inhibit-modes 'dired-mode)))
74 77
78(setup eldoc
79 (:hook-into elisp-mode
80 lisp-interaction-mode))
81
82(setup elisp-mode
83 (:also-load +elisp)
84 (:option eval-expression-print-length nil
85 eval-expression-print-level nil)
86 (:with-map (emacs-lisp-mode-map lisp-interaction-mode-map)
87 (:bind "C-c C-c" 'eval-defun
88 "C-c C-k" '+elisp-eval-region-or-buffer
89 "C-c C-z" 'ielm))
90 (advice-add 'eval-region :around '+eval-region@pulse))
91
75(setup eshell 92(setup eshell
76 (:also-load +eshell 93 (:also-load +eshell
77 em-smart 94 em-smart
@@ -108,6 +125,22 @@
108 '("tildegit.org" "tildegit.org/api/v1" "tildegit.org" 125 '("tildegit.org" "tildegit.org/api/v1" "tildegit.org"
109 forge-gitea-repository))))) 126 forge-gitea-repository)))))
110 127
128(setup prog
129 (:local-set comment-auto-fill-only-comments t)
130 (:hook 'prettify-symbols-mode
131 'display-fill-column-indicator-mode
132 'turn-on-auto-fill))
133
134(setup pulse
135 (:also-load +pulse)
136 (:option pulse-flag nil
137 pulse-delay 0.5
138 pulse-iterations 1)
139 (+pulse-location-mode +1))
140
141(setup text
142 (:hook 'turn-on-auto-fill))
143
111(setup (:straight 0x0) 144(setup (:straight 0x0)
112 (:option 0x0-default-server 'ttm) 145 (:option 0x0-default-server 'ttm)
113 (with-eval-after-load 'embark 146 (with-eval-after-load 'embark
@@ -118,6 +151,7 @@
118 ) 151 )
119 152
120(setup (:straight anzu) 153(setup (:straight anzu)
154 (:option anzu-cons-mode-line-p nil)
121 (:global [remap query-replace] 'anzu-query-replace-regexp 155 (:global [remap query-replace] 'anzu-query-replace-regexp
122 [remap query-replace-regexp] 'anzu-query-replace-regexp) 156 [remap query-replace-regexp] 'anzu-query-replace-regexp)
123 (global-anzu-mode +1) 157 (global-anzu-mode +1)
@@ -348,7 +382,7 @@
348 (:option prefix-help-command 'embark-prefix-help-command) 382 (:option prefix-help-command 'embark-prefix-help-command)
349 (:global "C-." 'embark-act 383 (:global "C-." 'embark-act
350 "M-." 'embark-dwim 384 "M-." 'embark-dwim
351 "C-h B" 'embark-bindings)) 385 "<help> B" 'embark-bindings))
352 386
353(setup (:straight embark-consult) 387(setup (:straight embark-consult)
354 (:load-after consult embark) 388 (:load-after consult embark)
@@ -565,6 +599,25 @@
565 "M-!" 'shell-command+) 599 "M-!" 'shell-command+)
566 (:global "M-!" 'shell-command+)) 600 (:global "M-!" 'shell-command+))
567 601
602(setup (:straight (simple-modeline
603 :fork (:repo "duckwork/simple-modeline")))
604 (:also-load +modeline)
605 (:option simple-modeline-segments '((;; left
606 +modeline-modified
607 +modeline-buffer-name
608 +modeline-position
609 +modeline-anzu
610 )
611 (;; right
612 +modeline-track
613 +modeline-vc
614 simple-modeline-segment-misc-info
615 simple-modeline-segment-process
616 +modeline-narrowed
617 +modeline-minions
618 +modeline-major-mode)))
619 (simple-modeline-mode +1))
620
568(setup (:straight (sophomore 621(setup (:straight (sophomore
569 :host github 622 :host github
570 :repo "duckwork/sophomore.el")) 623 :repo "duckwork/sophomore.el"))
@@ -637,3 +690,10 @@
637 (:option whitespace-cleanup-mode-preserve-point t) 690 (:option whitespace-cleanup-mode-preserve-point t)
638 (remove-hook 'before-save-hook 'whitespace-cleanup) 691 (remove-hook 'before-save-hook 'whitespace-cleanup)
639 (global-whitespace-cleanup-mode +1)) 692 (global-whitespace-cleanup-mode +1))
693
694(setup (:straight zzz-to-char)
695 (:global "M-z" (lambda (prefix)
696 "Call `zzz-to-char' or `zzz-up-to-char' with PREFIX arg."
697 (interactive "P")
698 (call-interactively
699 (if prefix #'zzz-up-to-char #'zzz-to-char)))))
diff --git a/lisp/+elisp.el b/lisp/+elisp.el new file mode 100644 index 0000000..d2f018a --- /dev/null +++ b/lisp/+elisp.el
@@ -0,0 +1,18 @@
1;;; +elisp.el -*- lexical-binding: t; -*-
2
3;;; Code:
4
5(defun +elisp-eval-region-or-buffer ()
6 (interactive)
7 (if (region-active-p)
8 (eval-region (region-beginning) (region-end))
9 (eval-buffer)))
10
11;; Should I move this to `+pulse' ?
12(defun +eval-region@pulse (advised beg end &rest args)
13 "ADVICE to pulse an eval'd region."
14 (apply advised beg end args)
15 (pulse-momentary-highlight-region beg end))
16
17(provide '+elisp)
18;;; +elisp.el ends here
diff --git a/lisp/+modeline.el b/lisp/+modeline.el new file mode 100644 index 0000000..b417e50 --- /dev/null +++ b/lisp/+modeline.el
@@ -0,0 +1,157 @@
1;;; +modeline.el --- my modeline customizations -*- lexical-binding: t; -*-
2
3;;; Commentary:
4
5;; `+modeline.el' is kind of a dumping ground for various
6;; modeline-related functions. I probably don't use everything in
7;; here. Credit given where possible.
8
9;;; Code:
10
11(require '+util)
12(require 'simple-modeline)
13(require 'minions)
14
15(defgroup +modeline nil
16 "Various customization options for my modeline things."
17 :prefix "+modeline-"
18 :group 'simple-modeline)
19
20(defun +modeline-buffer-name () ; gonsie
21 "Display the buffer name."
22 (propertize
23 (+string-align (buffer-name) 20 :before " " :ellipsis "… ")
24 'face 'bold
25 'help-echo (or (buffer-file-name)
26 (buffer-name))
27 'mouse-face 'mode-line-highlight))
28
29(defcustom +modeline-minions-icon "&"
30 "The \"icon\" for `+modeline-minions' button."
31 :type 'string)
32
33(defun +modeline-minions ()
34 "Display a button for `minions-minor-modes-menu'."
35 (concat " "
36 (propertize
37 +modeline-minions-icon
38 'help-echo "Minor modes menu\nmouse-1: show menu."
39 'local-map (purecopy (simple-modeline-make-mouse-map
40 'mouse-1
41 (lambda (event)
42 (interactive "e")
43 (with-selected-window
44 (posn-window (event-start event))
45 (minions-minor-modes-menu)))))
46 'mouse-face 'mode-line-highlight)))
47
48(defun +modeline-major-mode ()
49 "Display the current `major-mode'."
50 (concat " "
51 (propertize (+string-truncate (format-mode-line mode-name)
52 12 "…")
53 'face 'bold
54 'keymap mode-line-major-mode-keymap
55 'mouse-face 'mode-line-highlight)))
56
57(defcustom +modeline-modified-icon-alist '((ephemeral . "*")
58 (readonly . "=")
59 (modified . "+")
60 (special . "~")
61 (t . "-"))
62 "\"Icons\" to display depending on buffer status in modeline.
63The CAR of each field is one of `readonly', `modified',
64`special', `ephemeral', or t, and the CDR is a string to display
65in that mode.
66
67`readonly' is true if the buffer is read-only and visiting a file.
68`modified' is true if the buffer is modified.
69`special' is true if the buffer is a special-mode or derived buffer.
70`ephemeral' is true if the buffer is not visiting a file.
71t is the fall-back, shown when nothing else in the alist applies.
72
73The order of elements matters: whichever one matches first is applied."
74 :type '(alist :key-type symbol
75 :value-type string)
76 :options '("readonly" "modified" "special" "t"))
77
78(defcustom +modeline-modified-icon-special-modes '(special-mode)
79 "Modes to apply the `special-mode' icon to in the
80`+modeline-modified'."
81 :type '(repeat function))
82
83(defun +modeline-modified () ; modified from `simple-modeline-status-modified'
84 "Display a color-coded \"icon\" indicator for the buffer's status."
85 (let* ((icon (catch :icon
86 (dolist (cell +modeline-modified-icon-alist)
87 (when (pcase (car cell)
88 ('ephemeral (not (buffer-file-name)))
89 ('readonly buffer-read-only)
90 ('modified (buffer-modified-p))
91 ('special
92 (apply 'derived-mode-p
93 +modeline-modified-icon-special-modes))
94 ('t t)
95 (_ nil))
96 (throw :icon (cdr cell)))))))
97 (concat " "
98 (propertize (or icon "")
99 'mouse-face 'mode-line-highlight))))
100
101(defun +modeline-narrowed ()
102 "Display an indication that the buffer is narrowed."
103 (when (buffer-narrowed-p)
104 (concat " "
105 (propertize "N"
106 'help-echo (format "%s\n%s"
107 "Buffer is narrowed."
108 "mouse-2: widen buffer.")
109 'local-map (purecopy (simple-modeline-make-mouse-map
110 'mouse-2 'mode-line-widen))
111 'mouse-face 'mode-line-highlight))))
112
113(define-minor-mode file-percentage-mode
114 "Toggle the percentage display in the mode line (File Percentage Mode)."
115 :init-value t :global t :group 'mode-line)
116
117(defun +modeline-position () ; adapted from `simple-modeline'
118 "Display the current cursor position."
119 (list '((line-number-mode
120 ((column-number-mode
121 (column-number-indicator-zero-based
122 (9 " %l:%c")
123 (9 " %l:%C"))
124 (6 " %l:")))
125 ((column-number-mode
126 (column-number-indicator-zero-based
127 (5 " :%c")
128 (5 " :%C"))))))
129 '(file-percentage-mode
130 ((-3 "%p") "%% "))
131 (if (region-active-p)
132 (propertize (format "%s%-5d"
133 (if (and (mark) (< (point) (mark))) "-" "+")
134 (apply '+ (mapcar
135 (lambda (pos)
136 (- (cdr pos)
137 (car pos)))
138 (region-bounds))))
139 'font-lock-face 'font-lock-variable-name-face))))
140
141(defun +modeline-vc ()
142 "Display the version control branch of the current buffer in the modeline."
143 ;; from https://www.gonsie.com/blorg/modeline.html, from Doom
144 (if-let ((backend (vc-backend buffer-file-name)))
145 (concat " " (substring vc-mode (+ (if (eq backend 'Hg) 2 3) 2)))))
146
147(defun +modeline-track ()
148 "Display `tracking-mode' information."
149 '(tracking-mode
150 tracking-mode-line-buffers))
151
152(defun +modeline-anzu ()
153 "Display `anzu--update-mode-line'."
154 (anzu--update-mode-line))
155
156(provide '+modeline)
157;;; +modeline.el ends here
diff --git a/lisp/+pulse.el b/lisp/+pulse.el new file mode 100644 index 0000000..6ba7ded --- /dev/null +++ b/lisp/+pulse.el
@@ -0,0 +1,50 @@
1;;; +pulse.el -*- lexical-binding: t; -*-
2
3;;; Code:
4
5(defgroup +pulse nil
6 "Extra customizations for `pulse'."
7 :group 'pulse
8 :prefix "+pulse-")
9
10(defcustom +pulse-location-commands '(scroll-up-command
11 scroll-down-command
12 recenter-top-bottom
13 other-window
14 switch-to-buffer
15 redraw-frame)
16 "Commands to pulse the current line after.
17Good for finding location."
18 :type '(repeat function))
19
20(defcustom +pulse-location-function '+pulse-line-current-window
21 "What function to call after `+pulse-location-commands'."
22 :type 'function)
23
24;; XXX: this doesn't work yet. I only want to pulse the line in the
25;; active window, so when I have the same buffer viewed in multiple
26;; windows I can still see where my cursor is. To see the issue, C-x
27;; 2 then C-x o a few times.
28(defun +pulse-line-current-window (&rest _)
29 "Pulse the current line, but only if this window is active."
30 (pulse-momentary-highlight-one-line
31 (window-point (selected-window))))
32
33(defun +pulse--advice-remove (symbol where function &optional props)
34 "Remove advice SYMBOL from FUNCTION.
35This uses the same args as `advice-add' for easy toggling.
36WHERE and PROPS are discarded."
37 (ignore where props)
38 (advice-remove symbol function))
39
40(define-minor-mode +pulse-location-mode
41 "After moving locations, pulse where we are."
42 :global t
43 :keymap nil
44 (dolist (command +pulse-location-commands)
45 (funcall
46 (if +pulse-location-mode 'advice-add '+pulse--advice-remove)
47 command :after +pulse-location-function)))
48
49(provide '+pulse)
50;;; +pulse.el ends here