summary refs log tree commit diff stats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/acdw-apheleia.el25
-rw-r--r--lisp/acdw-circe.el15
-rw-r--r--lisp/acdw-modeline.el11
-rw-r--r--lisp/acdw-re.el4
-rw-r--r--lisp/acdw-setup.el11
-rw-r--r--lisp/acdw.el25
-rw-r--r--lisp/chd.el49
7 files changed, 124 insertions, 16 deletions
diff --git a/lisp/acdw-apheleia.el b/lisp/acdw-apheleia.el new file mode 100644 index 0000000..1b646ef --- /dev/null +++ b/lisp/acdw-apheleia.el
@@ -0,0 +1,25 @@
1;;; acdw-apheleia.el --- bespoke apheleia junk -*- lexical-binding: t -*-
2
3;;; Commentary:
4
5;;; Code:
6
7(require 'apheleia)
8
9(defcustom apheleia-stupid-modes '(makefile-mode
10 org-mode)
11 "List of stupid modes to not use `apheleia-global-mode' on."
12 :type '(repeat function)
13 :group 'apheleia)
14
15(defun apheleia-dumb-auto-format ()
16 "Format a buffer dumbly."
17 ;; If there's no apheleia formatter for the mode, just indent the
18 ;; buffer.
19 (unless (or (apply #'derived-mode-p apheleia-stupid-modes)
20 (and (fboundp 'apheleia--get-formatter-command)
21 (apheleia--get-formatter-command)))
22 (indent-region (point-min) (point-max))))
23
24(provide 'acdw-apheleia)
25;;; acdw-apheleia ends here
diff --git a/lisp/acdw-circe.el b/lisp/acdw-circe.el index 69b10be..e85587b 100644 --- a/lisp/acdw-circe.el +++ b/lisp/acdw-circe.el
@@ -17,6 +17,21 @@
17 (let ((short-url (0x0-shorten-uri (0x0--choose-server) url))) 17 (let ((short-url (0x0-shorten-uri (0x0--choose-server) url)))
18 (circe-command-SAY short-url))) 18 (circe-command-SAY short-url)))
19 19
20;;; Hooks
21
22(defun circe-chat@set-prompt ()
23 "Set the prompt to the buffer name, shortening it."
24 (interactive) ; set interactive to unfuck the prompt when need be
25 (lui-set-prompt
26 (propertize
27 (concat
28 (acdw-irc/margin-format (buffer-name) "" ">")
29 " ")
30 'face 'circe-prompt-face
31 'read-only t
32 'intangible t
33 'cursor-intangible t)))
34
20;;; Advices 35;;; Advices
21 36
22(defun circe-part@kill-buffer (&rest _) 37(defun circe-part@kill-buffer (&rest _)
diff --git a/lisp/acdw-modeline.el b/lisp/acdw-modeline.el index 25502ec..9963309 100644 --- a/lisp/acdw-modeline.el +++ b/lisp/acdw-modeline.el
@@ -125,6 +125,10 @@ indicator in the mode-line."
125 'mouse-2 #'mode-line-widen)) 125 'mouse-2 #'mode-line-widen))
126 'mouse-face 'mode-line-highlight)))) 126 'mouse-face 'mode-line-highlight))))
127 127
128(define-minor-mode file-percentage-mode
129 "Toggle the percentage display in the mode line (File Percentage Mode)."
130 :init-value t :global t :group 'mode-line)
131
128(defun acdw-modeline/position () 132(defun acdw-modeline/position ()
129 "Displays the current cursor position in the mode-line. 133 "Displays the current cursor position in the mode-line.
130 134
@@ -140,7 +144,10 @@ is, if point < mark."
140 ((column-number-mode 144 ((column-number-mode
141 (column-number-indicator-zero-based 145 (column-number-indicator-zero-based
142 (5 " C%c") 146 (5 " C%c")
143 (5 " C%C"))))) 147 (5 " C%C")))
148 " "))
149 (file-percentage-mode
150 (7 "%p%% "))
144 ,(if (region-active-p) 151 ,(if (region-active-p)
145 (propertize (format "%s%-5d" 152 (propertize (format "%s%-5d"
146 (if (and (mark) 153 (if (and (mark)
@@ -183,7 +190,7 @@ is, if point < mark."
183(defun acdw-modeline/wc () 190(defun acdw-modeline/wc ()
184 "Display current `wc-buffer-stats'." 191 "Display current `wc-buffer-stats'."
185 (when (bound-and-true-p wc-mode) 192 (when (bound-and-true-p wc-mode)
186 (or wc-buffer-stats "[w]"))) 193 (or wc-buffer-stats " [w]")))
187 194
188(defun acdw-modeline/winum () 195(defun acdw-modeline/winum ()
189 "Show the `winum' number of the current window in the modeline. 196 "Show the `winum' number of the current window in the modeline.
diff --git a/lisp/acdw-re.el b/lisp/acdw-re.el index db46af1..1fc0a9c 100644 --- a/lisp/acdw-re.el +++ b/lisp/acdw-re.el
@@ -17,6 +17,10 @@
17;; Pulled mostly from karthinks: 17;; Pulled mostly from karthinks:
18;; https://karthinks.com/software/bridging-islands-in-emacs-1/ 18;; https://karthinks.com/software/bridging-islands-in-emacs-1/
19 19
20;; UPDATED CODE:
21;; https://github.com/karthink/.emacs.d/blob/master/init.el#L981
22;; https://github.com/karthink/.emacs.d/blob/master/lisp/reb-fix.el
23
20;;; Code: 24;;; Code:
21 25
22(defvar acdw/re-builder-positions nil 26(defvar acdw/re-builder-positions nil
diff --git a/lisp/acdw-setup.el b/lisp/acdw-setup.el index e271faa..eb4d12b 100644 --- a/lisp/acdw-setup.el +++ b/lisp/acdw-setup.el
@@ -87,5 +87,16 @@ package. This macro is not repeatable."
87 (let ((recipe (cadr sexp))) 87 (let ((recipe (cadr sexp)))
88 (if (consp recipe) (car recipe) recipe)))) 88 (if (consp recipe) (car recipe) recipe))))
89 89
90;; https://www.emacswiki.org/emacs/SetupEl
91(setup-define :load-after
92 (lambda (&rest features)
93 (let ((body `(require ',(setup-get 'feature))))
94 (dolist (feature (if (listp features)
95 (nreverse features)
96 (list features)))
97 (setq body `(with-eval-after-load ',feature ,body)))
98 body))
99 :documentation "Load the current feature after FEATURES.")
100
90(provide 'acdw-setup) 101(provide 'acdw-setup)
91;;; acdw-setup.el ends here 102;;; acdw-setup.el ends here
diff --git a/lisp/acdw.el b/lisp/acdw.el index 86443a1..792b9ef 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el
@@ -93,7 +93,7 @@ features."
93 (let* ((this (car features)) 93 (let* ((this (car features))
94 (rest (cdr features))) 94 (rest (cdr features)))
95 `(with-eval-after-load ',this 95 `(with-eval-after-load ',this
96 (with-eval-after-all ,rest ,@body))))) 96 (with-eval-after-loads ,rest ,@body)))))
97 97
98(defmacro with-message (message &rest body) 98(defmacro with-message (message &rest body)
99 "Execute BODY, messaging 'MESSAGE...' before and 'MESSAGE... Done.' after." 99 "Execute BODY, messaging 'MESSAGE...' before and 'MESSAGE... Done.' after."
@@ -338,26 +338,23 @@ In short, DO NOT USE THIS FUNCTION!!!"
338 (save-excursion 338 (save-excursion
339 (sort-sexps 339 (sort-sexps
340 (point-min) (point-max) 340 (point-min) (point-max)
341 (lambda (sexp) 341 ;; Key function
342 (format "%S" (cadr sexp))) 342 nil
343 ;; Sort function
343 (lambda (s1 s2) ; oh god, this is worse. 344 (lambda (s1 s2) ; oh god, this is worse.
344 (let* ((s1 (cdr s1)) (s2 (cdr s2)) ; for the strings themselves 345 (let* ((s1 (cdr s1)) (s2 (cdr s2)) ; for the strings themselves
345 (s1-require (string-match ":require" s1)) 346 (require-regexp (rx bos (* nonl) ":require"))
346 (s2-require (string-match ":require" s2)) 347 (straight-regexp (rx bos (* nonl) ":straight"))
347 (s1-straight (string-match ":straight" s1)) 348 (s1-require (string-match require-regexp s1))
348 (s2-straight (string-match ":straight" s2)) 349 (s2-require (string-match require-regexp s2))
349 (s1-bare (not (or s1-require s1-straight))) 350 (s1-straight (string-match straight-regexp s1))
350 (s2-bare (not (or s2-require s2-straight)))) 351 (s2-straight (string-match straight-regexp s2)))
351 (cond 352 (cond
352 ;; if both are the same, sort regular style 353 ;; Straight forms require some weirdness
353 ((or (and s1-require s2-require)
354 (and s1-bare s2-bare))
355 (string< s1 s2))
356 ((and s1-straight s2-straight) 354 ((and s1-straight s2-straight)
357 (let* ((r (rx ":straight" (? "-if") (* space) (? "("))) 355 (let* ((r (rx ":straight" (? "-if") (* space) (? "(")))
358 (s1 (replace-regexp-in-string r "" s1)) 356 (s1 (replace-regexp-in-string r "" s1))
359 (s2 (replace-regexp-in-string r "" s2))) 357 (s2 (replace-regexp-in-string r "" s2)))
360 (message "'%S' '%S'" s1 s2)
361 (string< s1 s2))) 358 (string< s1 s2)))
362 ;; requires should go first 359 ;; requires should go first
363 ((and s1-require (not s2-require)) t) 360 ((and s1-require (not s2-require)) t)
diff --git a/lisp/chd.el b/lisp/chd.el new file mode 100644 index 0000000..697c134 --- /dev/null +++ b/lisp/chd.el
@@ -0,0 +1,49 @@
1;;; chd.el --- CHD customizations -*- lexical-binding: t -*-
2
3(require 'acdw-org)
4(require 'org)
5
6(defun chd/narrow-to-task (&optional point)
7 "Narrow the buffer to the task POINT is in."
8 (interactive "d")
9 (when point (goto-char point))
10 (if (called-interactively-p 'interactive)
11 (save-excursion
12 (while (not (org-entry-is-todo-p))
13 (acdw/org-previous-heading-widen 1))
14 (org-narrow-to-subtree))
15 ;; well this is dumb...
16 (while (not (org-entry-is-todo-p))
17 (acdw/org-previous-heading-widen 1))
18 (org-narrow-to-subtree)))
19
20(defun chd/clock-in ()
21 "Clock in to the current task."
22 (save-excursion
23 (chd/narrow-to-task)
24 (org-clock-in)))
25
26(defun chd/do-the-thing ()
27 "Copy the plain version of the current task and open its link."
28 (interactive)
29 (chd/narrow-to-task)
30 (save-excursion
31 ;; Prepare buffer
32 (acdw/flyspell-correct-f7) ; This is defined... elsewhere.
33
34 ;; Export the buffer and copy it
35 (pcase (org-entry-get (point-min) "EXPORTAS" t)
36 ("html" (acdw/org-export-copy-html))
37 (_ (acdw/org-export-copy)))
38
39 ;; Open the link to the doc
40 (org-back-to-heading)
41 (org-open-at-point)))
42
43;;; NOTES
44;; org-protocol: https://orgmode.org/worg/org-contrib/org-protocol.html
45;; the bit i wanna pull from TaskIQ: 'document.getElementById("preview")
46
47
48(provide 'chd)
49;;; chd.el ends here