summary refs log tree commit diff stats
path: root/lisp
diff options
context:
space:
mode:
authorCase Duckworth2022-05-23 20:12:53 -0500
committerCase Duckworth2022-05-23 20:12:59 -0500
commitdd3afe747ecf51f87d33318c2ad68953d153495f (patch)
treec364d2c59741f68bb3f51e8a28f84a2a9712fd37 /lisp
parentAdd timers (diff)
downloademacs-dd3afe747ecf51f87d33318c2ad68953d153495f.tar.gz
emacs-dd3afe747ecf51f87d33318c2ad68953d153495f.zip
meh
Diffstat (limited to 'lisp')
-rw-r--r--lisp/+avy.el60
-rw-r--r--lisp/+emacs.el6
-rw-r--r--lisp/+modeline.el6
-rw-r--r--lisp/+org-drawer-list.el12
-rw-r--r--lisp/+org-wc.el29
-rw-r--r--lisp/+org.el2
-rw-r--r--lisp/+pdf-tools.el38
-rw-r--r--lisp/+scratch.el25
-rw-r--r--lisp/+titlecase.el26
-rw-r--r--lisp/acdw.el26
10 files changed, 201 insertions, 29 deletions
diff --git a/lisp/+avy.el b/lisp/+avy.el index 5010e95..0606405 100644 --- a/lisp/+avy.el +++ b/lisp/+avy.el
@@ -17,5 +17,65 @@
17 (cdr (ring-ref avy-ring 0)))) 17 (cdr (ring-ref avy-ring 0))))
18 t) 18 t)
19 19
20
21;;; Remove `buffer-face-mode' when avy is active.
22
23(defcustom +avy-buffer-face-functions '(avy-goto-char
24 avy-goto-char-in-line
25 avy-goto-char-2
26 avy-goto-char-2-above
27 avy-goto-char-2-below
28 avy-goto-word-0
29 avy-goto-whitespace-end
30 avy-goto-word-0-above
31 avy-goto-word-0-below
32 avy-goto-whitespace-end-above
33 avy-goto-whitespace-end-below
34 avy-goto-word-1
35 avy-goto-word-1-above
36 avy-goto-word-1-below
37 avy-goto-symbol-1
38 avy-goto-symbol-1-above
39 avy-goto-symbol-1-below
40 avy-goto-subword-0
41 avy-goto-subword-1
42 avy-goto-word-or-subword-1
43 avy-goto-line
44 avy-goto-line-above
45 avy-goto-line-below
46 avy-goto-end-of-line
47 avy-goto-char-timer)
48 "Functions to disable `buffer-face-mode' during.")
49
50(defvar-local +avy-buffer-face-mode-face nil
51 "The state of `buffer-face-mode' before calling `avy-with'.")
52
53(defun +avy@un-buffer-face (&rest _)
54 "BEFORE advice on `avy-with' to disable `buffer-face-mode'."
55 (when buffer-face-mode
56 (setq +avy-buffer-face-mode-face buffer-face-mode-face)
57 (buffer-face-mode -1)))
58
59(defun +avy@re-buffer-face (&rest _)
60 "AFTER advice on `avy-with' to re-enable `buffer-face-mode'."
61 (when +avy-buffer-face-mode-face
62 (setq buffer-face-mode-face +avy-buffer-face-mode-face)
63 (buffer-face-mode +1)))
64
65(define-minor-mode +avy-buffer-face-local-mode
66 "Turn off `buffer-face-mode' before doing Avy selections.
67Restore the mode after the selection."
68 :lighter ""
69 :global t
70 (setq +avy-buffer-face-mode-face nil)
71 (cond
72 (+avy-buffer-face-mode
73 (dolist (fn +avy-buffer-face-functions)
74 (advice-add fn :before #'+avy@un-buffer-face))
75 (advice-add 'avy--done :after #'+avy@re-buffer-face))
76 (t (dolist (fn +avy-buffer-face-functions)
77 (advice-remove fn #'+avy@un-buffer-face))
78 (advice-remove 'avy--done #'+avy@re-buffer-face))))
79
20(provide '+avy) 80(provide '+avy)
21;;; avy.el ends here 81;;; avy.el ends here
diff --git a/lisp/+emacs.el b/lisp/+emacs.el index 3c5d383..dedde98 100644 --- a/lisp/+emacs.el +++ b/lisp/+emacs.el
@@ -73,8 +73,6 @@ Do this only if the buffer is not visiting a file."
73 (executable-find "gm") 73 (executable-find "gm")
74 (executable-find "ffmpeg")) 74 (executable-find "ffmpeg"))
75 indent-tabs-mode nil 75 indent-tabs-mode nil
76 indicate-buffer-boundaries 'left
77 indicate-empty-lines nil
78 inhibit-startup-screen t 76 inhibit-startup-screen t
79 initial-buffer-choice t 77 initial-buffer-choice t
80 kept-new-versions 6 78 kept-new-versions 6
@@ -98,9 +96,11 @@ Do this only if the buffer is not visiting a file."
98 native-comp-deferred-compilation nil 96 native-comp-deferred-compilation nil
99 read-answer-short t 97 read-answer-short t
100 read-buffer-completion-ignore-case t 98 read-buffer-completion-ignore-case t
101 ;; read-extended-command-predicate (when (fboundp 99 ;; read-extended-command-predicate
100 ;; (when (fboundp
102 ;; 'command-completion-default-include-p) 101 ;; 'command-completion-default-include-p)
103 ;; 'command-completion-default-include-p) 102 ;; 'command-completion-default-include-p)
103 read-process-output-max (+bytes 1 :mib) ; We’re in the future man. Set that to at least a megabyte
104 recenter-positions '(top middle bottom) 104 recenter-positions '(top middle bottom)
105 regexp-search-ring-max 100 105 regexp-search-ring-max 100
106 regexp-search-ring-max 200 106 regexp-search-ring-max 200
diff --git a/lisp/+modeline.el b/lisp/+modeline.el index 86dbad4..2c9bbee 100644 --- a/lisp/+modeline.el +++ b/lisp/+modeline.el
@@ -393,9 +393,9 @@ to a function in the current buffer, call that function instead."
393 ;; adapted from https://github.com/seagle0128/doom-modeline 393 ;; adapted from https://github.com/seagle0128/doom-modeline
394 (when (and (boundp 'text-scale-mode-amount) 394 (when (and (boundp 'text-scale-mode-amount)
395 (/= text-scale-mode-amount 0)) 395 (/= text-scale-mode-amount 0))
396 (format (if (> text-scale-mode-amount 0) "%s(%+d)" "%s(%-d)") 396 (+modeline-spacer nil spacer
397 (or spacer +modeline-default-spacer) 397 (concat (if (> text-scale-mode-amount 0) "+" "-")
398 text-scale-mode-amount))) 398 (number-to-string text-scale-mode-amount)))))
399 399
400(defun +modeline-ace-window-display (&optional spacer) 400(defun +modeline-ace-window-display (&optional spacer)
401 "Display `ace-window-display-mode' information in the modeline." 401 "Display `ace-window-display-mode' information in the modeline."
diff --git a/lisp/+org-drawer-list.el b/lisp/+org-drawer-list.el index 2fc7234..5066d4d 100644 --- a/lisp/+org-drawer-list.el +++ b/lisp/+org-drawer-list.el
@@ -26,7 +26,7 @@ format the list item as an Org link."
26 "mailto"))) 26 "mailto")))
27 (current-kill 0)) 27 (current-kill 0))
28 (string-trim (current-kill 0)) 28 (string-trim (current-kill 0))
29 (read-string "URL: "))) 29 (read-string "Resource URL: ")))
30 (url-title (let ((clipboard-headings 30 (url-title (let ((clipboard-headings
31 (+org-insert--get-title-and-headings clipboard-url))) 31 (+org-insert--get-title-and-headings clipboard-url)))
32 (read-string "title (edit): " 32 (read-string "title (edit): "
@@ -34,8 +34,14 @@ format the list item as an Org link."
34 "title: " clipboard-headings 34 "title: " clipboard-headings
35 nil nil nil nil (car clipboard-headings)))))) 35 nil nil nil nil (car clipboard-headings))))))
36 (list clipboard-url url-title))) 36 (list clipboard-url url-title)))
37 (org-drawer-list-add +org-drawer-list-resources-drawer 37 (let (current-visible-mode visible-mode)
38 (org-link-make-string url title))) 38 ;; XXX: This is not the "proper" way to fix the issue I was having --- I've
39 ;; isolated the bug to somewhere in `org-insert-item', but this fix works
40 ;; well enough™ for now.
41 (visible-mode +1)
42 (org-drawer-list-add +org-drawer-list-resources-drawer
43 (org-link-make-string url title))
44 (visible-mode (if current-visible-mode +1 -1))))
39 45
40(provide '+org-drawer-list) 46(provide '+org-drawer-list)
41;;; +org-drawer-list.el ends here 47;;; +org-drawer-list.el ends here
diff --git a/lisp/+org-wc.el b/lisp/+org-wc.el index 7ab0050..edd88f0 100644 --- a/lisp/+org-wc.el +++ b/lisp/+org-wc.el
@@ -19,8 +19,7 @@
19(defcustom +org-wc-update-after-funcs '(org-narrow-to-subtree 19(defcustom +org-wc-update-after-funcs '(org-narrow-to-subtree
20 org-narrow-to-block 20 org-narrow-to-block
21 org-narrow-to-element 21 org-narrow-to-element
22 org-capture-narrow 22 org-capture-narrow)
23 org-taskwise-narrow-to-task)
24 "Functions after which to update the word count." 23 "Functions after which to update the word count."
25 :type '(repeat function)) 24 :type '(repeat function))
26 25
@@ -32,6 +31,16 @@
32 "Number of characters that constitute a \"huge\" insertion." 31 "Number of characters that constitute a \"huge\" insertion."
33 :type 'number) 32 :type 'number)
34 33
34(defcustom +org-wc-huge-buffer 10000
35 "Number of words past which we're not going to try to count."
36 :type 'number)
37
38(defvar +org-wc-correction -5
39 "Number to add to `+org-wc-word-count', for some reason?
40`+org-wc-word-count' seems to consistently be off by 5. Thus
41this correction. (At some point I should correct the underlying
42code... probably).")
43
35(defvar-local +org-wc-update-timer nil) 44(defvar-local +org-wc-update-timer nil)
36 45
37(defun +org-wc-delayed-update (&rest _) 46(defun +org-wc-delayed-update (&rest _)
@@ -48,7 +57,7 @@
48 (+org-wc-update) 57 (+org-wc-update)
49 (message "Counting words...done")) 58 (message "Counting words...done"))
50 59
51(defun +org-wc-update () 60(defun +org-wc-update (&rest _) ; Needs variadic parameters, since it's advice
52 (dlet ((+org-wc-counting t)) 61 (dlet ((+org-wc-counting t))
53 (+org-wc-buffer) 62 (+org-wc-buffer)
54 (force-mode-line-update) 63 (force-mode-line-update)
@@ -59,9 +68,14 @@
59 68
60(defun +org-wc-buffer () 69(defun +org-wc-buffer ()
61 "Count the words in the buffer." 70 "Count the words in the buffer."
62 (when (derived-mode-p 'org-mode) 71 (when (and (derived-mode-p 'org-mode)
72 (not (eq +org-wc-word-count 'huge)))
63 (setq +org-wc-word-count 73 (setq +org-wc-word-count
64 (org-word-count-aux (point-min) (point-max))))) 74 (cond
75 ((> (count-words (point-min) (point-max))
76 +org-wc-huge-buffer)
77 'huge)
78 (t (org-word-count-aux (point-min) (point-max)))))))
65 79
66(defvar +org-wc-counting nil 80(defvar +org-wc-counting nil
67 "Are we currently counting?") 81 "Are we currently counting?")
@@ -71,8 +85,9 @@
71 (+org-wc-update))) 85 (+org-wc-update)))
72 86
73(defun +org-wc-modeline () 87(defun +org-wc-modeline ()
74 (when +org-wc-word-count 88 (cond
75 (format " %sw" +org-wc-word-count))) 89 ((eq +org-wc-word-count 'huge) "huge")
90 (+org-wc-word-count (format " %sw" (max 0 (+ +org-wc-word-count +org-wc-correction))))))
76 91
77(define-minor-mode +org-wc-mode 92(define-minor-mode +org-wc-mode
78 "Count words in `org-mode' buffers in the mode-line." 93 "Count words in `org-mode' buffers in the mode-line."
diff --git a/lisp/+org.el b/lisp/+org.el index 89ed483..6b93a7a 100644 --- a/lisp/+org.el +++ b/lisp/+org.el
@@ -669,7 +669,7 @@ and POST-PROCESS are passed to `org-export-to-file'."
669 "Advice to run `org-mode-hook' when entering org-mode. 669 "Advice to run `org-mode-hook' when entering org-mode.
670This should only fire when switching to a buffer from `org-agenda'." 670This should only fire when switching to a buffer from `org-agenda'."
671 (unless +org-hook-has-run-p 671 (unless +org-hook-has-run-p
672 (run-hooks 'org-mode-hook) 672 (run-mode-hooks 'org-mode-hook)
673 (setq +org-hook-has-run-p t))) 673 (setq +org-hook-has-run-p t)))
674 674
675(define-minor-mode +org-agenda-inhibit-hooks-mode 675(define-minor-mode +org-agenda-inhibit-hooks-mode
diff --git a/lisp/+pdf-tools.el b/lisp/+pdf-tools.el new file mode 100644 index 0000000..9b15b27 --- /dev/null +++ b/lisp/+pdf-tools.el
@@ -0,0 +1,38 @@
1;;; +pdf-tools.el --- Extras for the excellent pdf-tools' -*- lexical-binding: t; -*-
2
3;;; Commentary:
4
5;;; Code:
6
7;; XXX: The way I'm dispatching browsers here is /very/ down-and-dirty. It
8;; needs to be much improved.
9
10(defun +pdf-view-open-all-pagelinks (&optional browse-url-func)
11 "Open all the links on this page of a PDF.
12BROWSE-URL-FUNC overrides the default `browse-url'."
13 (interactive)
14 (let ((links (pdf-info-pagelinks (pdf-view-current-page)))
15 (browse-url-func (or browse-url-func #'browse-url))
16 (seen))
17 (dolist (link links)
18 (when-let* ((uri (alist-get 'uri link))
19 (_ (not (member uri seen))))
20 (push uri seen)
21 (funcall browse-url-func uri)))))
22
23(defun +pdf-view-open-links-in-chrome ()
24 "Open all links on this PDF page in Chrome.
25See also `+pdf-view-open-all-pagelinks'."
26 (interactive)
27 (+pdf-view-open-all-pagelinks #'browse-url-chrome))
28
29(defun +pdf-view-position (&optional spacer)
30 "Return the page we're on for the modeline."
31 (when (derived-mode-p 'pdf-view-mode)
32 (format "%sp.%s/%s"
33 (or spacer (bound-and-true-p +modeline-default-spacer) " ")
34 (pdf-view-current-page)
35 (pdf-info-number-of-pages))))
36
37(provide '+pdf-tools)
38;;; +pdf-tools.el ends here
diff --git a/lisp/+scratch.el b/lisp/+scratch.el index e9b825a..7fc2bde 100644 --- a/lisp/+scratch.el +++ b/lisp/+scratch.el
@@ -35,18 +35,33 @@ For `kill-buffer-query-functions'."
35 "ABANDON ALL HOPE YE WHO ENTER HERE")))) 35 "ABANDON ALL HOPE YE WHO ENTER HERE"))))
36 (concat (replace-regexp-in-string "^" ";; " s) 36 (concat (replace-regexp-in-string "^" ";; " s)
37 "\n\n"))) 37 "\n\n")))
38 38
39;; [[https://old.reddit.com/r/emacs/comments/ui1q41/weekly_tips_tricks_c_thread/i7ef4xg/][u/bhrgunatha]] 39;; [[https://old.reddit.com/r/emacs/comments/ui1q41/weekly_tips_tricks_c_thread/i7ef4xg/][u/bhrgunatha]]
40(defun +scratch-text-scratch () 40(defun +scratch-text-scratch ()
41 "Create a \"*text*\" scratch buffer in Text mode." 41 "Create a \"*text*\" scratch buffer in Text mode."
42 (with-current-buffer (get-buffer-create "*text*") 42 (with-current-buffer (get-buffer-create "*text*")
43 (text-mode))) 43 (text-mode)))
44 44
45(defcustom +scratch-buffers '("*text*" "*scratch*")
46 "Scratch buffers.")
47
48(defvar +scratch-last-non-scratch-buffer nil
49 "Last buffer that wasn't a scratch buffer.")
50
45(defun +scratch-toggle (buffer) 51(defun +scratch-toggle (buffer)
46 "Switch to BUFFER, or to the previous buffer." 52 "Switch to BUFFER, or to the previous (non-scratch) buffer."
47 (switch-to-buffer (unless (eq (current-buffer) 53 (if (or (null +scratch-last-non-scratch-buffer)
48 (get-buffer buffer)) 54 (not (member (buffer-name (current-buffer)) +scratch-buffers)))
49 buffer))) 55 ;; Switch to a scratch buffer
56 (progn
57 (setq +scratch-last-non-scratch-buffer (current-buffer))
58 (switch-to-buffer buffer))
59 ;; Switch away from scratch buffer ...
60 (if (equal (get-buffer-create buffer) (current-buffer))
61 ;; to the original buffer
62 (switch-to-buffer +scratch-last-non-scratch-buffer)
63 ;; to another scratch
64 (switch-to-buffer buffer))))
50 65
51(defun +scratch-switch-to-scratch () 66(defun +scratch-switch-to-scratch ()
52 "Switch to scratch buffer." 67 "Switch to scratch buffer."
diff --git a/lisp/+titlecase.el b/lisp/+titlecase.el new file mode 100644 index 0000000..1366a46 --- /dev/null +++ b/lisp/+titlecase.el
@@ -0,0 +1,26 @@
1;;; +titlecase.el --- Titlecase extras -*- lexical-binding: t; -*-
2
3;;; Commentary:
4
5;;; Code:
6
7(defun +titlecase-sentence-style-dwim ()
8 "Titlecase a sentence."
9 (interactive)
10 (titlecase-dwim 'sentence))
11
12(defun +titlecase-org-headings ()
13 (interactive)
14 (save-excursion
15 (goto-char (point-min))
16 ;; See also `org-map-tree'. I'm not using that function because I want to
17 ;; skip the first headline. A better solution would be to patch
18 ;; `titlecase-line' to ignore org-mode metadata (TODO cookies, tags, etc).
19 (let ((level (funcall outline-level)))
20 (while (and (progn (outline-next-heading)
21 (> (funcall outline-level) level))
22 (not (eobp)))
23 (titlecase-line)))))
24
25(provide '+titlecase)
26;;; +titlecase.el ends here
diff --git a/lisp/acdw.el b/lisp/acdw.el index 9b3ab93..191cdfb 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el
@@ -282,7 +282,8 @@ always nil; this function is mostly intended for use in init."
282 282
283(defcustom chat-functions '(+irc 283(defcustom chat-functions '(+irc
284 jabber-connect-all 284 jabber-connect-all
285 slack-start) 285 ;; slack-start
286 )
286 "Functions to start when calling `chat'." 287 "Functions to start when calling `chat'."
287 :type '(repeat function) 288 :type '(repeat function)
288 :group 'applications) 289 :group 'applications)
@@ -292,16 +293,17 @@ always nil; this function is mostly intended for use in init."
292 (interactive) 293 (interactive)
293 (+with-progress "Quitting circe..." 294 (+with-progress "Quitting circe..."
294 (ignore-errors 295 (ignore-errors
295 (circe-command-GQUIT " 🫀 🍞") 296 (circe-command-GQUIT "peace love bread")
296 (cancel-timer (irc-connection-get conn :flood-timer)))) 297 (cancel-timer (irc-connection-get conn :flood-timer))))
297 (+with-progress "Quitting jabber..." 298 (+with-progress "Quitting jabber..."
298 (ignore-errors 299 (ignore-errors
299 (jabber-disconnect))) 300 (jabber-disconnect)))
300 (+with-progress "Quitting-slack..." 301 (when (boundp '+slack-teams)
301 (dolist (team +slack-teams) 302 (+with-progress "Quitting-slack..."
302 (ignore-errors 303 (dolist (team +slack-teams)
303 (slack-team-disconnect team))) 304 (ignore-errors
304 (ignore-errors (slack-ws-close))) 305 (slack-team-disconnect team)))
306 (ignore-errors (slack-ws-close))))
305 (+with-progress "Killing buffers..." 307 (+with-progress "Killing buffers..."
306 (ignore-errors 308 (ignore-errors
307 (+mapc-some-buffers (lambda () "Remove the buffer from tracking and kill it unconditionally." 309 (+mapc-some-buffers (lambda () "Remove the buffer from tracking and kill it unconditionally."
@@ -496,6 +498,9 @@ sort order."
496 (lambda () 498 (lambda ()
497 (message "%S-second timer DONE!" secs) 499 (message "%S-second timer DONE!" secs)
498 (setq +timer-string +timer-done-string) 500 (setq +timer-string +timer-done-string)
501 (let ((visible-bell t)
502 (ring-bell-function nil))
503 (ding))
499 (ding)))))) 504 (ding))))))
500 505
501(defun +timer-cancel () 506(defun +timer-cancel ()
@@ -508,5 +513,12 @@ sort order."
508 (message "Timer canceled."))) 513 (message "Timer canceled.")))
509 (setq +timer-string nil)) 514 (setq +timer-string nil))
510 515
516
517
518(defun +switch-to-last-buffer ()
519 "Switch to the last-used buffer in this window."
520 (interactive)
521 (switch-to-buffer nil))
522
511(provide 'acdw) 523(provide 'acdw)
512;;; acdw.el ends here 524;;; acdw.el ends here