summary refs log tree commit diff stats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/+init.el50
-rw-r--r--lisp/+org.el74
-rw-r--r--lisp/acdw.el19
3 files changed, 89 insertions, 54 deletions
diff --git a/lisp/+init.el b/lisp/+init.el index 360a1b9..c1f3cb5 100644 --- a/lisp/+init.el +++ b/lisp/+init.el
@@ -37,41 +37,43 @@ are sorted lexigraphically."
37 nil 37 nil
38 ;; Sort function 38 ;; Sort function
39 (lambda (s1 s2) 39 (lambda (s1 s2)
40 (let ((s1 (cdr s1)) (s2 (cdr s2))) 40 (let ((s1 (cdr s1)) (s2 (cdr s2)))
41 (cond 41 (cond
42 ;; Sort everything /not/ `setup' /before/ `setup' 42 ;; Sort everything /not/ `setup' /before/ `setup'
43 ((and (+init--sexp-setup-p s1) 43 ((and (+init--sexp-setup-p s1)
44 (not (+init--sexp-setup-p s2))) 44 (not (+init--sexp-setup-p s2)))
45 nil) 45 nil)
46 ((and (+init--sexp-setup-p s2) 46 ((and (+init--sexp-setup-p s2)
47 (not (+init--sexp-setup-p s1))) 47 (not (+init--sexp-setup-p s1)))
48 t) 48 t)
49 ;; otherwise... 49 ;; otherwise...
50 (t (let ((s1-straight (+init--sexp-setup-p s1 :straight)) 50 (t (let ((s1-straight (+init--sexp-setup-p s1 :straight))
51 (s2-straight (+init--sexp-setup-p s2 :straight)) 51 (s2-straight (+init--sexp-setup-p s2 :straight))
52 (s1-require (+init--sexp-setup-p s1 :require)) 52 (s1-require (+init--sexp-setup-p s1 :require))
53 (s2-require (+init--sexp-setup-p s2 :require))) 53 (s2-require (+init--sexp-setup-p s2 :require)))
54 (cond 54 (cond
55 ;; `:straight' setups have extra processing 55 ;; `:straight' setups have extra processing
56 ((and s1-straight s2-straight) 56 ((and s1-straight s2-straight)
57 (let* ((r (rx (: ":straight" (? "-when") (* space) (? "(")))) 57 (let* ((r (rx (: ":straight" (? "-when") (* space) (? "("))))
58 (s1 (replace-regexp-in-string r "" s1)) 58 (s1 (replace-regexp-in-string r "" s1))
59 (s2 (replace-regexp-in-string r "" s2))) 59 (s2 (replace-regexp-in-string r "" s2)))
60 (string< s1 s2))) 60 (string< s1 s2)))
61 ;; `:require' setups go first 61 ;; `:require' setups go first
62 ((and s1-require (not s2-require)) t) 62 ((and s1-require (not s2-require)) t)
63 ((and s2-require (not s1-require)) nil) 63 ((and s2-require (not s1-require)) nil)
64 ;; `:straight' setups go last 64 ;; `:straight' setups go last
65 ((and s1-straight (not s2-straight)) nil) 65 ((and s1-straight (not s2-straight)) nil)
66 ((and s2-straight (not s1-straight)) t) 66 ((and s2-straight (not s1-straight)) t)
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 () 70(defun +init-sort-then-save ()
71 "Sort init.el, then save it." 71 "Sort init.el, then save it."
72 (interactive) 72 (interactive)
73 (+init-sort) 73 (+init-sort)
74 (save-buffer)) 74 (if (fboundp #'user-save-buffer)
75 (user-save-buffer)
76 (save-buffer)))
75 77
76;;; Add `setup' forms to `imenu-generic-expression' 78;;; Add `setup' forms to `imenu-generic-expression'
77 79
@@ -79,11 +81,11 @@ are sorted lexigraphically."
79 "Recognize `setup' forms in `imenu'." 81 "Recognize `setup' forms in `imenu'."
80 ;; `imenu-generic-expression' automatically becomes buffer-local when set 82 ;; `imenu-generic-expression' automatically becomes buffer-local when set
81 (setf (alist-get "Setup" imenu-generic-expression nil nil 'string-equal) 83 (setf (alist-get "Setup" imenu-generic-expression nil nil 'string-equal)
82 (list 84 (list
83 (rx (: bol (* space) 85 (rx (: bol (* space)
84 "(setup" (+ space) 86 "(setup" (+ space)
85 (group (? "(") (* nonl)))) 87 (group (? "(") (* nonl))))
86 1))) 88 1)))
87 89
88;;; Major mode 90;;; Major mode
89 91
diff --git a/lisp/+org.el b/lisp/+org.el index fc1caea..090af5a 100644 --- a/lisp/+org.el +++ b/lisp/+org.el
@@ -253,9 +253,9 @@ instead of the true count."
253 253
254;;; org-insert-link-dwim - https://xenodium.com/emacs-dwim-do-what-i-mean/ 254;;; org-insert-link-dwim - https://xenodium.com/emacs-dwim-do-what-i-mean/
255 255
256(defun +org-insert-link-dwim () 256(defun +org-insert-link-dwim (&optional interactivep)
257 "Like `org-insert-link' but with personal dwim preferences." 257 "Like `org-insert-link' but with personal dwim preferences."
258 (interactive) 258 (interactive '(t))
259 (let* ((point-in-link (org-in-regexp org-link-any-re 1)) 259 (let* ((point-in-link (org-in-regexp org-link-any-re 1))
260 (clipboard-url (when (string-match-p 260 (clipboard-url (when (string-match-p
261 (rx (sequence bos 261 (rx (sequence bos
@@ -266,25 +266,30 @@ instead of the true count."
266 (current-kill 0))) 266 (current-kill 0)))
267 (region-content (when (region-active-p) 267 (region-content (when (region-active-p)
268 (buffer-substring-no-properties (region-beginning) 268 (buffer-substring-no-properties (region-beginning)
269 (region-end))))) 269 (region-end))))
270 (cond ((and region-content clipboard-url (not point-in-link)) 270 (org-link (when clipboard-url
271 (delete-region (region-beginning) (region-end)) 271 (org-link-make-string
272 (insert (org-link-make-string clipboard-url region-content))) 272 clipboard-url
273 ((and clipboard-url (not point-in-link)) 273 (or region-content
274 (insert (org-link-make-string 274 (read-string "title: "
275 clipboard-url 275 (with-current-buffer
276 (read-string "title: " 276 (url-retrieve-synchronously
277 (with-current-buffer 277 clipboard-url)
278 (url-retrieve-synchronously 278 (dom-text
279 clipboard-url) 279 (car
280 (dom-text 280 (dom-by-tag (libxml-parse-html-region
281 (car 281 (point-min)
282 (dom-by-tag (libxml-parse-html-region 282 (point-max))
283 (point-min) 283 'title))))))))))
284 (point-max)) 284 (if interactivep
285 'title)))))))) 285 (cond ((and region-content clipboard-url (not point-in-link))
286 (t 286 (delete-region (region-beginning) (region-end))
287 (call-interactively 'org-insert-link))))) 287 (insert org-link))
288 ((and clipboard-url (not point-in-link))
289 (insert org-link))
290 (t
291 (call-interactively 'org-insert-link)))
292 org-link)))
288 293
289;;; Navigate headings with widening 294;;; Navigate headings with widening
290 295
@@ -409,5 +414,32 @@ the deletion might narrow the column."
409 (dotimes (_ fill-column) 414 (dotimes (_ fill-column)
410 (insert "-"))) 415 (insert "-")))
411 416
417;; Follow links, DWIM style
418
419(defun +org-open-at-point-dwim (&optional arg)
420 "Open thing at point, or if there isn't something, list things."
421 (interactive "P")
422 (save-excursion
423 (let* ((this-char-type (org-element-type (org-element-context)))
424 (prev-char-type (save-excursion
425 (backward-char)
426 (org-element-type (org-element-context))))
427 (types '(citation citation-reference clock comment comment-block
428 footnote-definition footnote-reference headline
429 inline-src-block inlinetask keyword link
430 node-property planning src-block timestamp))
431 (type this-char-type))
432 (when (and (memq this-char-type types) (memq prev-char-type types))
433 (backward-char)
434 (setq type prev-char-type)) ; what the fuckckckckck
435 (if (memq type types)
436 (progn (org-open-at-point arg))
437 (while (not
438 (progn
439 (org-back-to-heading)
440 (car (org-offer-links-in-entry (current-buffer) (point) 1))))
441 (org-up-heading-all 1))
442 (org-open-at-point arg)))))
443
412(provide '+org) 444(provide '+org)
413;;; +org.el ends here 445;;; +org.el ends here
diff --git a/lisp/acdw.el b/lisp/acdw.el index 9361cdf..262c15e 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el
@@ -143,7 +143,7 @@ within a `with-current-buffer' form."
143 (let ((pred (or predicate t))) 143 (let ((pred (or predicate t)))
144 (dolist (buf (buffer-list)) 144 (dolist (buf (buffer-list))
145 (with-current-buffer buf 145 (with-current-buffer buf
146 (when (funcall pred buf) 146 (when (if (fboundp pred) (funcall pred buf) pred)
147 (funcall func)))))) 147 (funcall func))))))
148 148
149;; https://github.com/cstby/emacs.d/blob/main/init.el#L67 149;; https://github.com/cstby/emacs.d/blob/main/init.el#L67
@@ -176,14 +176,15 @@ surrounded by empty lines, so opening a paragraph means to make
176three blank lines, then place the point on the second one." 176three blank lines, then place the point on the second one."
177 (interactive "*") 177 (interactive "*")
178 (unless (derived-mode-p 'special-mode 'lui-mode 'comint-mode) 178 (unless (derived-mode-p 'special-mode 'lui-mode 'comint-mode)
179 ;; Go to next blank line. This /isn't/ `end-of-paragraph-text' because 179 ;; Go to next blank line. This /isn't/ `end-of-paragraph-text' because
180 ;; that's weird with org, and I'm guessing other modes too. 180 ;; that's weird with org, and I'm guessing other modes too.
181 (while (not (looking-at "^$")) 181 (while (and (not (looking-at "^$"))
182 (forward-line 1)) 182 (< (point) (point-max)))
183 (newline) 183 (forward-line 1))
184 (delete-blank-lines) 184 (newline)
185 (newline 2) 185 (delete-blank-lines)
186 (previous-line))) 186 (newline 2)
187 (previous-line)))
187 188
188(defun +split-window-then (&optional where arg) 189(defun +split-window-then (&optional where arg)
189 "Split the window into a new buffer. 190 "Split the window into a new buffer.