summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2021-09-23 17:11:30 -0500
committerCase Duckworth2021-09-23 17:11:30 -0500
commitdf207947bae8f29dce49815587436cde9f49ebed (patch)
tree5a04990f32ea5058ad3f084c9928af9eb8bc6d09
parentAdd TODO (diff)
downloademacs-df207947bae8f29dce49815587436cde9f49ebed.tar.gz
emacs-df207947bae8f29dce49815587436cde9f49ebed.zip
blehhaheoi
-rw-r--r--init.el540
-rw-r--r--lisp/acdw.el132
2 files changed, 348 insertions, 324 deletions
diff --git a/init.el b/init.el index 48f3d39..d8e9bf0 100644 --- a/init.el +++ b/init.el
@@ -21,7 +21,10 @@
21;; NOTE that some of the names in `setup' forms are arbitrary. 21;; NOTE that some of the names in `setup' forms are arbitrary.
22 22
23(setup (:require auth-source) 23(setup (:require auth-source)
24 (:option auth-sources '("~/.authinfo" "~/.authinfo.gpg"))) 24 (:option auth-sources (list (acdw/sync-dir "authinfo")
25 (acdw/sync-dir "authinfo.gpg")
26 "~/.authinfo"
27 "~/.authinfo.gpg")))
25 28
26(setup (:require goto-addr) 29(setup (:require goto-addr)
27 (if (fboundp #'global-goto-address-mode) 30 (if (fboundp #'global-goto-address-mode)
@@ -181,7 +184,25 @@ In short, DO NOT USE THIS FUNCTION!!!"
181 (acdw/add-button-url-regexp-protocol "gemini")) 184 (acdw/add-button-url-regexp-protocol "gemini"))
182 185
183(setup buffers 186(setup buffers
184 (:global "C-x k" #'acdw/kill-a-buffer)) 187 (:global "C-x k" #'acdw/kill-a-buffer)
188 (defun buffer-list-update@set-major-mode ()
189 "Set `major-mode' from buffer name, even when not visiting a file."
190 (let ((name (buffer-name)))
191 (unless (or (active-minibuffer-window)
192 (string-prefix-p "*" name)
193 (not (eq major-mode 'fundamental-mode)))
194 (catch 'done
195 (dolist (cell auto-mode-alist)
196 (let ((regexp (car cell))
197 (mode (cdr cell)))
198 (when (string-match regexp name)
199 (let ((major-mode mode))
200 (funcall mode))
201 (throw 'done mode))))))))
202
203 ;; TODO: more testing, just in case.
204 ;;(add-hook 'buffer-list-update-hook #'buffer-list-update@set-major-mode)
205 )
185 206
186(setup calendar 207(setup calendar
187 (:option calendar-week-start-day 1)) 208 (:option calendar-week-start-day 1))
@@ -189,35 +210,24 @@ In short, DO NOT USE THIS FUNCTION!!!"
189(setup (:straight circe) 210(setup (:straight circe)
190 (require 'circe) 211 (require 'circe)
191 (require 'acdw-irc) 212 (require 'acdw-irc)
192 213
193 (:option acdw-irc/left-margin 12 214 (:option acdw-irc/left-margin 20
194 acdw-irc/post-my-nick "-> " 215 acdw-irc/post-my-nick "-> "
195 circe-channel-killed-confirmation nil 216 circe-channel-killed-confirmation nil
196 circe-color-nicks-everywhere t 217 circe-color-nicks-everywhere t
197 circe-default-nick "acdw" 218 circe-default-nick "acdw"
198 circe-default-part-message "See You, Space Cowpokes . . ." 219 circe-default-part-message "See You, Space Cowpokes . . ."
199 circe-default-user "acdw" 220 circe-default-user "acdw"
200 circe-format-action 221 circe-format-action (format
201 (lambda (&rest plist) 222 (format "%%%ds* {nick} {body}"
202 (concat 223 (- acdw-irc/left-margin 2)) " ")
203 (acdw-irc/margin-format "" "*" "*" t) 224 circe-format-say (format
204 " " (plist-get plist :nick) " " (plist-get plist :body))) 225 "{nick:%1$d.%1$ds} | {body}"
205 circe-format-say 226 (- acdw-irc/left-margin 3))
206 (lambda (&rest plist) 227 circe-format-self-action circe-format-action
207 (concat 228 circe-format-self-say (format
208 (acdw-irc/margin-format (plist-get plist :nick) "" " |" t) 229 "{nick:%1$d.%1$ds} > {body}"
209 " " (plist-get plist :body))) 230 (- acdw-irc/left-margin 3))
210 circe-format-self-action
211 (lambda (&rest plist)
212 (concat
213 (acdw-irc/margin-format "" "-*" " *" t)
214 " " (plist-get plist :nick) " " (plist-get plist :body)))
215 circe-format-self-say
216 (lambda (&rest plist)
217 (concat
218 (acdw-irc/margin-format (plist-get plist :nick) "-" " >" t)
219 " " (plist-get plist :body)))
220 ;; circe-highlight-nick-type 'message
221 circe-network-options 231 circe-network-options
222 `(("Libera Chat" 232 `(("Libera Chat"
223 :channels ("#emacs" "#systemcrafters" "##webpals") 233 :channels ("#emacs" "#systemcrafters" "##webpals")
@@ -226,7 +236,7 @@ In short, DO NOT USE THIS FUNCTION!!!"
226 :host "libera.chat")) 236 :host "libera.chat"))
227 ("Tilde Chat" :host "irc.tilde.chat" :port 6697 :use-tls t 237 ("Tilde Chat" :host "irc.tilde.chat" :port 6697 :use-tls t
228 :channels ("#meta" "#bread" "#dadjokes" "#team" 238 :channels ("#meta" "#bread" "#dadjokes" "#team"
229 "#emacs") 239 "#emacs" "#nsfw")
230 :sasl-username ,circe-default-nick 240 :sasl-username ,circe-default-nick
231 :sasl-password ,(acdw/make-password-fetcher 241 :sasl-password ,(acdw/make-password-fetcher
232 :host "tilde.chat")) 242 :host "tilde.chat"))
@@ -247,9 +257,12 @@ In short, DO NOT USE THIS FUNCTION!!!"
247 circe-server-buffer-action (lambda (buf) 257 circe-server-buffer-action (lambda (buf)
248 (message "Connected to %s" buf))) 258 (message "Connected to %s" buf)))
249 259
250 ;; (:face circe-nick-highlight-face 260 (with-eval-after-load 'circe
251 ;; ((t (:inherit (modus-themes-hl-line))))) 261 (:face circe-nick-highlight-face
252 262 ((t (:inherit (modus-themes-hl-line modus-themes-bold))))
263 circe-my-message-face
264 ((t (:inherit (modus-themes-slant))))))
265
253 (:bind "C-c C-p" #'circe-command-PART 266 (:bind "C-c C-p" #'circe-command-PART
254 "C-l" #'lui-track-jump-to-indicator) 267 "C-l" #'lui-track-jump-to-indicator)
255 268
@@ -280,7 +293,8 @@ In short, DO NOT USE THIS FUNCTION!!!"
280 (with-current-buffer buf 293 (with-current-buffer buf
281 (dolist (buf (circe-server-chat-buffers)) 294 (dolist (buf (circe-server-chat-buffers))
282 (let ((circe-channel-killed-confirmation nil)) 295 (let ((circe-channel-killed-confirmation nil))
283 (kill-buffer buf))) 296 (kill-buffer buf))
297 (cancel-timer 'irc-send--queue))
284 (message "%s: %s" buf circe-server-killed-confirmation) 298 (message "%s: %s" buf circe-server-killed-confirmation)
285 (kill-buffer)))))) 299 (kill-buffer))))))
286 300
@@ -312,12 +326,13 @@ In short, DO NOT USE THIS FUNCTION!!!"
312 #'circe-nick-color-reset) 326 #'circe-nick-color-reset)
313 327
314 (:with-mode lui-mode 328 (:with-mode lui-mode
315 (:option lui-fill-column fill-column 329 (:option lui-fill-column (+ fill-column acdw-irc/left-margin)
316 lui-fill-type (repeat-string acdw-irc/left-margin " ") 330 lui-fill-type (repeat-string acdw-irc/left-margin " ")
317 lui-time-stamp-position 'right-margin 331 lui-time-stamp-position 'right-margin
318 lui-time-stamp-format "%H:%M" 332 lui-time-stamp-format "%H:%M"
319 lui-track-behavior 'before-switch-to-buffer 333 lui-track-behavior 'before-switch-to-buffer
320 lui-track-indicator 'fringe) 334 lui-track-indicator 'fringe
335 lui-fill-remove-face-from-newline nil)
321 336
322 (:local-set fringes-outside-margins t 337 (:local-set fringes-outside-margins t
323 right-margin-width 5 338 right-margin-width 5
@@ -374,8 +389,9 @@ In short, DO NOT USE THIS FUNCTION!!!"
374 dired-collapse 389 dired-collapse
375 dired-git-info) 390 dired-git-info)
376 391
377 (:option dired-recursive-copies 'always 392 (:option dired-recursive-copies 'top
378 dired-recursive-deletes 'always 393 dired-recursive-deletes 'top
394 dired-create-destination-dirs 'ask
379 delete-by-moving-to-trash t 395 delete-by-moving-to-trash t
380 dired-listing-switches "-Al" 396 dired-listing-switches "-Al"
381 ls-lisp-dirs-first t 397 ls-lisp-dirs-first t
@@ -433,24 +449,7 @@ In short, DO NOT USE THIS FUNCTION!!!"
433 449
434 ;; And set the disabled function to something better than the default. 450 ;; And set the disabled function to something better than the default.
435 ;; Now, I can run any disabled command, but I have to use M-x to do it. 451 ;; Now, I can run any disabled command, but I have to use M-x to do it.
436 (setq disabled-command-function 452 (:option disabled-command-function #'acdw/disabled-command-function))
437 (defun acdw/disabled-command-function (&optional cmd keys)
438 (let ((cmd (or cmd this-command))
439 (keys (or keys (this-command-keys))))
440 ;; this logic stolen from original `disabled-command-function'
441 (if (or (eq (aref keys 0) (if (stringp keys)
442 (aref "\M-x" 0)
443 ?\M-x))
444 (and (>= (length keys) 2)
445 (eq (aref keys 0) meta-prefix-char)
446 (eq (aref keys 1) ?x)))
447 ;; it's been run as an M-x command, we want to do it
448 (call-interactively cmd)
449 ;; else, tell the user it's disabled.
450 (message (substitute-command-keys
451 (concat "Command `%s' has been disabled. "
452 "Run with \\[execute-extended-command]."))
453 cmd))))))
454 453
455(setup ediff 454(setup ediff
456 (:option ediff-diff-options "-w" ; ignore whitespace 455 (:option ediff-diff-options "-w" ; ignore whitespace
@@ -459,8 +458,6 @@ In short, DO NOT USE THIS FUNCTION!!!"
459 ;; https://oremacs.com/2015/01/17/setting-up-ediff/ 458 ;; https://oremacs.com/2015/01/17/setting-up-ediff/
460 (add-hook 'ediff-after-quit-hook-internal #'winner-undo)) 459 (add-hook 'ediff-after-quit-hook-internal #'winner-undo))
461 460
462(setup (:straight edit-indirect))
463
464;; requires extension: 461;; requires extension:
465;; https://addons.mozilla.org/en-US/firefox/addon/edit-with-emacs1/ 462;; https://addons.mozilla.org/en-US/firefox/addon/edit-with-emacs1/
466(setup (:straight edit-server) 463(setup (:straight edit-server)
@@ -487,6 +484,8 @@ In short, DO NOT USE THIS FUNCTION!!!"
487 (:with-mode emacs-lisp-mode ;; -_- 484 (:with-mode emacs-lisp-mode ;; -_-
488 (:option eval-expression-print-length nil 485 (:option eval-expression-print-length nil
489 eval-expression-print-level nil 486 eval-expression-print-level nil
487 print-length nil
488 print-level nil
490 lisp-indent-function #'lisp-indent-function) 489 lisp-indent-function #'lisp-indent-function)
491 490
492 (:local-set (append imenu-generic-expression) 491 (:local-set (append imenu-generic-expression)
@@ -494,7 +493,7 @@ In short, DO NOT USE THIS FUNCTION!!!"
494 ,(rx (seq 493 ,(rx (seq
495 (group bol (* space) "(setup" (+ space)) 494 (group bol (* space) "(setup" (+ space))
496 (? (group "(:" (+ graph) (* space) (? "("))) 495 (? (group "(:" (+ graph) (* space) (? "(")))
497 (group (+ (any word ?-))))) 496 (group (+ (any word ?+ ?-)))))
498 3)) 497 3))
499 498
500 (:hook #'checkdoc-minor-mode 499 (:hook #'checkdoc-minor-mode
@@ -522,6 +521,7 @@ In short, DO NOT USE THIS FUNCTION!!!"
522 ;; else /should/ go there. 521 ;; else /should/ go there.
523 (:option 522 (:option
524 attempt-orderly-shutdown-on-fatal-signal nil 523 attempt-orderly-shutdown-on-fatal-signal nil
524 auto-hscroll-mode 'current-line
525 attempt-stack-overflow-recovery nil 525 attempt-stack-overflow-recovery nil
526 echo-keystrokes 0.01 526 echo-keystrokes 0.01
527 find-function-C-source-directory (acdw/find-emacs-source) 527 find-function-C-source-directory (acdw/find-emacs-source)
@@ -544,10 +544,6 @@ In short, DO NOT USE THIS FUNCTION!!!"
544 "A keymap for looking up things.") 544 "A keymap for looking up things.")
545 (global-set-key (kbd "C-c l") lookup-map) 545 (global-set-key (kbd "C-c l") lookup-map)
546 546
547 (defvar toggle-map (make-sparse-keymap)
548 "A keymap for toggling!")
549 (global-set-key (kbd "C-c t") toggle-map)
550
551 (:global "M-=" #'count-words 547 (:global "M-=" #'count-words
552 "C-w" #'kill-region-or-backward-word 548 "C-w" #'kill-region-or-backward-word
553 "C-c d" #'acdw/insert-iso-date 549 "C-c d" #'acdw/insert-iso-date
@@ -557,11 +553,26 @@ In short, DO NOT USE THIS FUNCTION!!!"
557 "C-c _" #'add-file-local-variable 553 "C-c _" #'add-file-local-variable
558 "C-x C-c" #'acdw/fat-finger-exit) 554 "C-x C-c" #'acdw/fat-finger-exit)
559 555
556 ;; inspo: https://github.com/zaeph/.emacs.d/blob/master/init.el#L479
557 (defvar toggle-map (make-sparse-keymap)
558 "A keymap for toggling!")
559 (global-set-key (kbd "C-c t") toggle-map)
560
560 (:with-map toggle-map 561 (:with-map toggle-map
561 (:bind "c" #'column-number-mode 562 (:bind "c" #'column-number-mode
562 "l" #'display-line-numbers-mode 563 "l" #'display-line-numbers-mode
563 "d" #'toggle-debug-on-error)) 564 "d" #'toggle-debug-on-error
565 "s" #'so-long-mode
566 "S" #'scroll-bar-mode))
567
568 ;; Toggle
569 (:with-map toggle-map
570 (:bind "b" (defun acdw/toggle-lexical-binding ()
571 "Toggle `lexical-binding' in the current buffer."
572 (interactive)
573 (setq lexical-binding (not lexical-binding)))))
564 574
575
565 (:with-map case-map 576 (:with-map case-map
566 (require 'titlecase) 577 (require 'titlecase)
567 (:bind "c" #'capitalize-dwim 578 (:bind "c" #'capitalize-dwim
@@ -796,7 +807,7 @@ specific to most general, they are these:
796 word-wrap t 807 word-wrap t
797 truncate-lines nil) 808 truncate-lines nil)
798 809
799 (global-display-fill-column-indicator-mode +1) 810 (global-display-fill-column-indicator-mode -1)
800 (global-so-long-mode +1) 811 (global-so-long-mode +1)
801 812
802 (add-hook 'visual-line-mode-hook 813 (add-hook 'visual-line-mode-hook
@@ -837,6 +848,17 @@ specific to most general, they are these:
837 (fset 'yes-or-no-p #'y-or-n-p) 848 (fset 'yes-or-no-p #'y-or-n-p)
838 (setq use-short-answers t))) 849 (setq use-short-answers t)))
839 850
851(setup mouse
852 ;; Unconditionally follow links when clicked.
853 ;; This is because mouse-1 usually sets point.
854 ;; Other options:
855 ;; +[ms] -> perform mouse-2 until held for [ms], then mouse-1
856 ;; -[ms] -> perform mouse-1 until held for [ms], then mouse-2
857 ;; 'double -> mouse-2 on double click
858 ;; nil -> mouse-1 never follows link
859 ;; <anything> -> mouse-1 /always/ follows link
860 (:option mouse-1-click-follows-link t))
861
840(setup mouse-avoidance 862(setup mouse-avoidance
841 (mouse-avoidance-mode 'exile)) 863 (mouse-avoidance-mode 'exile))
842 864
@@ -869,24 +891,6 @@ specific to most general, they are these:
869 ;; (put 'backward-page 'repeat-map 'page-navigation-repeat-map) 891 ;; (put 'backward-page 'repeat-map 'page-navigation-repeat-map)
870 ) 892 )
871 893
872(setup prog
873 (:option show-paren-delay 0
874 show-paren-style 'mixed
875 show-paren-when-point-inside-paren t
876 show-paren-when-point-in-periphery t
877 smie-indent-basic tab-width)
878
879 (:hook show-paren-mode
880 electric-pair-local-mode
881 acdw/setup-fringes
882
883 (defun prog-mode@auto-fill ()
884 (setq-local comment-auto-fill-only-comments t)
885 (turn-on-auto-fill)))
886
887 (add-hook 'after-save-hook
888 #'executable-make-buffer-file-executable-if-script-p))
889
890(setup repeat 894(setup repeat
891 ;; new for Emacs 28! 895 ;; new for Emacs 28!
892 (:only-if (fboundp #'repeat-mode)) 896 (:only-if (fboundp #'repeat-mode))
@@ -1153,146 +1157,6 @@ specific to most general, they are these:
1153 (:with-feature isearch 1157 (:with-feature isearch
1154 (:bind "C-'" #'avy-isearch))) 1158 (:bind "C-'" #'avy-isearch)))
1155 1159
1156(setup (:straight circe)
1157 (require 'circe)
1158 (require 'acdw-irc)
1159
1160 (:option acdw-irc/left-margin 12
1161 acdw-irc/post-my-nick "-> "
1162 circe-channel-killed-confirmation nil
1163 circe-color-nicks-everywhere t
1164 circe-default-nick "acdw"
1165 circe-default-part-message "See You, Space Cowpokes . . ."
1166 circe-default-user "acdw"
1167 circe-format-action
1168 (lambda (&rest plist)
1169 (concat
1170 (acdw-irc/margin-format "" "*" "*" t)
1171 " " (plist-get plist :nick) " " (plist-get plist :body)))
1172 circe-format-say
1173 (lambda (&rest plist)
1174 (concat
1175 (acdw-irc/margin-format (plist-get plist :nick) "" " |" t)
1176 " " (plist-get plist :body)))
1177 circe-format-self-action
1178 (lambda (&rest plist)
1179 (concat
1180 (acdw-irc/margin-format "" "-*" " *" t)
1181 " " (plist-get plist :nick) " " (plist-get plist :body)))
1182 circe-format-self-say
1183 (lambda (&rest plist)
1184 (concat
1185 (acdw-irc/margin-format (plist-get plist :nick) "-" " >" t)
1186 " " (plist-get plist :body)))
1187 ;; circe-highlight-nick-type 'message
1188 circe-network-options
1189 `(("Libera Chat"
1190 :channels ("#emacs" "#systemcrafters" "##webpals")
1191 :sasl-username ,circe-default-nick
1192 :sasl-password ,(acdw/make-password-fetcher
1193 :host "libera.chat"))
1194 ("Tilde Chat" :host "irc.tilde.chat" :port 6697 :use-tls t
1195 :channels ("#meta" "#bread" "#dadjokes" "#team"
1196 "#emacs")
1197 :sasl-username ,circe-default-nick
1198 :sasl-password ,(acdw/make-password-fetcher
1199 :host "tilde.chat"))
1200 ("Casa" :host "m455.casa" :port 6697 :use-tls t
1201 :channels ("#basement")
1202 :sasl-username ,circe-default-nick
1203 :sasl-password ,(acdw/make-password-fetcher
1204 :host "m455.casa"))
1205 ("Pissnet" :host "piss.hmm.st" :port 6697 :use-tls t
1206 :channels ("#i-just-peed")
1207 :sasl-username ,circe-default-nick
1208 :sasl-password ,(acdw/make-password-fetcher
1209 :host "piss.hmm.st"))
1210 ;; TODO: irc.chat.twitch.tv
1211 )
1212 circe-reduce-lurker-spam t
1213 circe-server-auto-join-default-type :after-auth)
1214
1215 ;; (:face circe-nick-highlight-face
1216 ;; ((t (:inherit (modus-themes-hl-line)))))
1217
1218 (:bind "C-c C-p" #'circe-command-PART
1219 "C-l" #'lui-track-jump-to-indicator)
1220
1221 (:advise circe-command-PART :after
1222 (defun circe-part@kill-buffer (&rest _)
1223 (let ((circe-channel-killed-confirmation nil))
1224 (kill-buffer)))
1225
1226 circe-command-QUIT :after
1227 (defun circe-quit@kill-buffer (&rest _)
1228 ;; `circe-server-killed-confirmation' set to nil, and manually
1229 ;; deleting all chat buffers, pending Github issue #402
1230 ;; (https://github.com/emacs-circe/circe/issues/402)
1231 (let ((circe-server-killed-confirmation nil))
1232 (with-circe-server-buffer
1233 (dolist (buf (circe-server-chat-buffers))
1234 (let ((circe-channel-killed-confirmation nil))
1235 (kill-buffer buf)))
1236 (kill-buffer))))
1237
1238 circe-command-GQUIT :after
1239 (defun circe-gquit@kill-buffer (&rest _)
1240 ;; `circe-server-killed-confirmation' set to nil, and manually
1241 ;; deleting all chat buffers, pending Github issue #402
1242 ;; (https://github.com/emacs-circe/circe/issues/402)
1243 (let ((circe-server-killed-confirmation nil))
1244 (dolist (buf (circe-server-buffers))
1245 (with-current-buffer buf
1246 (dolist (buf (circe-server-chat-buffers))
1247 (let ((circe-channel-killed-confirmation nil))
1248 (kill-buffer buf)))
1249 (message "%s: %s" buf circe-server-killed-confirmation)
1250 (kill-buffer))))))
1251
1252 (defun circe-command-SHORTEN (url)
1253 "Shorten URL using `0x0-shorten-uri'."
1254 (interactive "sURL to shorten: ")
1255 ;; TODO: enable /shorten URL comment syntax
1256 (let ((short-url (0x0-shorten-uri (0x0--choose-server) url)))
1257 (circe-command-SAY short-url)))
1258
1259 (:with-mode circe-chat-mode
1260 (:hook #'acdw/stop-paren-annoyances
1261 #'enable-circe-color-nicks
1262 #'enable-circe-display-images
1263 #'enable-circe-new-day-notifier
1264 (defun circe-chat@set-prompt ()
1265 (lui-set-prompt
1266 (concat
1267 (propertize
1268 (acdw-irc/margin-format (buffer-name) "" ">")
1269 'face 'circe-prompt-face
1270 'read-only t
1271 'intangible t
1272 'cursor-intangible t)
1273 " ")))))
1274
1275 (autoload 'circe-nick-color-reset "circe-color-nicks")
1276 (add-hook 'modus-themes-after-load-theme-hook
1277 #'circe-nick-color-reset)
1278
1279 (:with-mode lui-mode
1280 (:option lui-fill-column fill-column
1281 lui-fill-type (repeat-string acdw-irc/left-margin " ")
1282 lui-time-stamp-position 'right-margin
1283 lui-time-stamp-format "%H:%M"
1284 lui-track-behavior 'before-switch-to-buffer
1285 lui-track-indicator 'fringe)
1286
1287 (:local-set fringes-outside-margins t
1288 right-margin-width 5
1289 scroll-margin 0
1290 word-wrap t
1291 wrap-prefix (repeat-string acdw-irc/left-margin " ")
1292 line-number-mode nil)
1293
1294 (:hook #'enable-lui-track)))
1295
1296(setup (:straight (consult 1160(setup (:straight (consult
1297 :host github 1161 :host github
1298 :repo "minad/consult")) 1162 :repo "minad/consult"))
@@ -1437,24 +1301,6 @@ specific to most general, they are these:
1437 1301
1438(setup (:straight edit-indirect)) 1302(setup (:straight edit-indirect))
1439 1303
1440;; requires extension:
1441;; https://addons.mozilla.org/en-US/firefox/addon/edit-with-emacs1/
1442(setup (:straight edit-server)
1443 (:require edit-server)
1444 (edit-server-start)
1445
1446 (:option edit-server-default-major-mode 'text-mode
1447 edit-server-url-major-mode-alist
1448 (list (cons (rx (| "reddit.com"
1449 "tildes.net"))
1450 'markdown-mode)
1451 (cons (rx "github.com")
1452 'gfm-mode)))
1453
1454 (:advise edit-server-make-frame :before
1455 (defun edit-server@set-a-variable (&rest _)
1456 (setq-local edit-server-frame-p t))))
1457
1458(setup (:straight (electric-cursor 1304(setup (:straight (electric-cursor
1459 :host github 1305 :host github
1460 :repo "duckwork/electric-cursor")) 1306 :repo "duckwork/electric-cursor"))
@@ -1688,28 +1534,14 @@ specific to most general, they are these:
1688 (defvar helpful-pre-windows nil 1534 (defvar helpful-pre-windows nil
1689 "Window configuration /before/ helpful was called.") 1535 "Window configuration /before/ helpful was called.")
1690 1536
1691 (:option helpful-switch-buffer-function 1537 (:option helpful-switch-buffer-function #'pop-to-buffer)
1692 (defun helpful-pop-to-buffer (&rest args)
1693 (if (eq major-mode 'helpful-mode)
1694 (apply #'pop-to-buffer-same-window args)
1695 (require 'winner)
1696 (setq helpful-pre-windows (winner-conf))
1697 (apply #'pop-to-buffer args))))
1698 1538
1699 (:global "<help> f" #'helpful-callable 1539 (:global "<help> f" #'helpful-callable
1700 "<help> v" #'helpful-variable 1540 "<help> v" #'helpful-variable
1701 "<help> k" #'helpful-key 1541 "<help> k" #'helpful-key
1702 "<help> o" #'helpful-symbol) 1542 "<help> o" #'helpful-symbol)
1703 1543
1704 (:bind "q" (defun helpful-quit () 1544 (:bind "q" #'quit-window))
1705 (interactive)
1706 (when (eq major-mode 'helpful-mode)
1707 (quit-window)
1708 (unless (or (= 1 (count-windows))
1709 (eq major-mode 'helpful-mode))
1710 (delete-window)
1711 (ignore-errors
1712 (winner-set helpful-pre-windows)))))))
1713 1545
1714(setup (:straight hungry-delete) 1546(setup (:straight hungry-delete)
1715 (:option hungry-delete-chars-to-skip " \t" 1547 (:option hungry-delete-chars-to-skip " \t"
@@ -1849,11 +1681,12 @@ browser defined in `browse-url-secondary-browser-function'."
1849 1681
1850(setup (:straight (mastodon 1682(setup (:straight (mastodon
1851 :host github 1683 :host github
1852 :repo "mooseyboots/mastodon.el") 1684 :repo "mooseyboots/mastodon.el"))
1853 request)
1854 (:option mastodon-instance-url "https://writing.exchange" 1685 (:option mastodon-instance-url "https://writing.exchange"
1855 mastodon-auth-source-file (car auth-sources) 1686 mastodon-auth-source-file (car auth-sources)
1856 mastodon-client--token-file (acdw/dir "mastodon.plstore")) 1687 mastodon-client--token-file (acdw/dir "mastodon.plstore")
1688 mastodon-tl--enable-proportional-fonts t
1689 mastodon-tl--enable-relative-timestamps nil)
1857 1690
1858 (:hook #'hl-line-mode 1691 (:hook #'hl-line-mode
1859 #'reading-mode)) 1692 #'reading-mode))
@@ -1870,7 +1703,14 @@ browser defined in `browse-url-secondary-browser-function'."
1870 modus-themes-mode-line nil) 1703 modus-themes-mode-line nil)
1871 1704
1872 (acdw/sunrise-sunset #'modus-themes-load-operandi 1705 (acdw/sunrise-sunset #'modus-themes-load-operandi
1873 #'modus-themes-load-vivendi)) 1706 #'modus-themes-load-vivendi)
1707
1708 (add-hook 'modus-themes-after-load-theme-hook
1709 (defun modus-themes@customize-faces ()
1710 "Customize faces of modus-themes."
1711 (custom-set-faces
1712 '(org-tag
1713 ((t (:height 90 :slant italic :inherit org-tag))))))))
1874 1714
1875(setup (:straight mwim) 1715(setup (:straight mwim)
1876 (:global "C-a" #'mwim-beginning 1716 (:global "C-a" #'mwim-beginning
@@ -1949,13 +1789,16 @@ browser defined in `browse-url-secondary-browser-function'."
1949 1789
1950(setup (:straight org 1790(setup (:straight org
1951 org-contrib) 1791 org-contrib)
1952 (:also-load acdw-org) ; so I don't clutter up init.el 1792 (:also-load acdw-org ; so I don't clutter up init.el
1793 chd)
1953 (:option 1794 (:option
1954 org-adapt-indentation nil 1795 org-adapt-indentation nil
1955 org-agenda-files nil ; only until I set this up 1796 org-agenda-files nil ; only until I set this up
1956 org-catch-invisible-edits 'show-and-error 1797 org-catch-invisible-edits 'show-and-error
1957 org-clock-clocked-in-display 'mode-line 1798 org-clock-clocked-in-display 'frame-title
1958 org-clock-string-limit 7 ; gives time and not title 1799 org-clock-frame-title-format (cons '(t org-mode-line-string)
1800 (cons " --- " frame-title-format))
1801 ;;org-clock-string-limit 7 ; gives time and not title
1959 org-confirm-babel-evaluate nil 1802 org-confirm-babel-evaluate nil
1960 org-cycle-separator-lines 0 1803 org-cycle-separator-lines 0
1961 org-directory "~/org" 1804 org-directory "~/org"
@@ -1976,6 +1819,7 @@ browser defined in `browse-url-secondary-browser-function'."
1976 org-list-demote-modify-bullet '(("-" . "+") 1819 org-list-demote-modify-bullet '(("-" . "+")
1977 ("+" . "*") 1820 ("+" . "*")
1978 ("*" . "-")) 1821 ("*" . "-"))
1822 org-log-into-drawer t
1979 org-outline-path-complete-in-steps nil 1823 org-outline-path-complete-in-steps nil
1980 org-pretty-entities t 1824 org-pretty-entities t
1981 org-refile-use-outline-path 'file 1825 org-refile-use-outline-path 'file
@@ -1993,7 +1837,7 @@ browser defined in `browse-url-secondary-browser-function'."
1993 "<S-return>" #'acdw-org/org-table-copy-down 1837 "<S-return>" #'acdw-org/org-table-copy-down
1994 "M-SPC M-SPC" #'insert-zero-width-space 1838 "M-SPC M-SPC" #'insert-zero-width-space
1995 "C-c C-l" #'org-insert-link-dwim 1839 "C-c C-l" #'org-insert-link-dwim
1996 "M-w" #'acdw/copy-region-plain 1840 "C-c w" #'chd/do-the-thing
1997 "C-c C-n" #'acdw/org-next-heading-widen 1841 "C-c C-n" #'acdw/org-next-heading-widen
1998 "C-c C-p" #'acdw/org-previous-heading-widen) 1842 "C-c C-p" #'acdw/org-previous-heading-widen)
1999 1843
@@ -2026,9 +1870,50 @@ browser defined in `browse-url-secondary-browser-function'."
2026 end 1870 end
2027 999))))) 1871 999)))))
2028 1872
2029 (:advise org-delete-backward-char :override #'acdw-org/delete-backward-char)) 1873 (:advise org-delete-backward-char :override #'acdw-org/delete-backward-char)
1874
1875 (el-patch-feature org)
1876 (with-eval-after-load 'org
1877 (el-patch-defun org-format-outline-path (path &optional width prefix separator)
1878 "Format the outline path PATH for display.
1879WIDTH is the maximum number of characters that is available.
1880PREFIX is a prefix to be included in the returned string,
1881such as the file name.
1882SEPARATOR is inserted between the different parts of the path,
1883the default is \"/\"."
1884 (setq width (or width 79))
1885 (setq path (delq nil path))
1886 (unless (> width 0)
1887 (user-error "Argument `width' must be positive"))
1888 (setq separator (or separator "/"))
1889 (let* ((org-odd-levels-only nil)
1890 (fpath (concat
1891 prefix (and prefix path separator)
1892 (mapconcat
1893 (lambda (s) (replace-regexp-in-string "[ \t]+\\'" "" s))
1894 (cl-loop for head in path
1895 for n from 0
1896 collect (el-patch-swap
1897 (org-add-props
1898 head nil '`face
1899 (nth (% n org-n-level-faces) org-level-faces))
1900 head))
1901 separator))))
1902 (when (> (length fpath) width)
1903 (if (< width 7)
1904 ;; It's unlikely that `width' will be this small, but don't
1905 ;; waste characters by adding ".." if it is.
1906 (setq fpath (substring fpath 0 width))
1907 (setf (substring fpath (- width 2)) "..")))
1908 fpath))))
2030 1909
2031(setup (:straight org-appear) 1910(setup (:straight org-appear)
1911 (:option org-appear-autoemphasis t
1912 org-appear-autoentities t
1913 org-appear-autokeywords t
1914 org-appear-autolinks nil
1915 org-appear-autosubmarkers t
1916 org-appear-delay 0)
2032 (:hook-into org-mode)) 1917 (:hook-into org-mode))
2033 1918
2034(setup (:straight package-lint)) 1919(setup (:straight package-lint))
@@ -2047,7 +1932,8 @@ browser defined in `browse-url-secondary-browser-function'."
2047 (:with-map lisp-mode-shared-map 1932 (:with-map lisp-mode-shared-map
2048 (:bind "DEL" #'paredit-backward-delete 1933 (:bind "DEL" #'paredit-backward-delete
2049 "C-M-;" #'comment-or-uncomment-sexp 1934 "C-M-;" #'comment-or-uncomment-sexp
2050 "C-<backspace>" #'paredit-backward-kill-word)) 1935 "C-<backspace>" #'paredit-backward-kill-word
1936 "M-w" #'paredit-copy-as-kill))
2051 (paredit-mode +1)) 1937 (paredit-mode +1))
2052 1938
2053 (dolist (mode lispy-modes) 1939 (dolist (mode lispy-modes)
@@ -2078,20 +1964,8 @@ browser defined in `browse-url-secondary-browser-function'."
2078 (with-current-buffer buf 1964 (with-current-buffer buf
2079 (when (funcall persistent-scratch-scratch-buffer-p-function) 1965 (when (funcall persistent-scratch-scratch-buffer-p-function)
2080 (persistent-scratch-mode +1)))) 1966 (persistent-scratch-mode +1))))
2081
2082 (buffer-list))) 1967 (buffer-list)))
2083 1968
2084(setup (:straight-if pkgbuild-mode
2085 (executable-find "makepkg"))
2086 (:file-match "PKGBUILD"))
2087
2088(setup (:straight powerthesaurus)
2089 (:global "C-c l t" #'powerthesaurus-lookup-word-dwim))
2090
2091;; (setup (:straight prism)
2092;; (dolist (mode lispy-modes)
2093;; (add-hook (intern (format "%s-hook" mode)) #'prism-mode)))
2094
2095(setup prog 1969(setup prog
2096 (:option show-paren-delay 0 1970 (:option show-paren-delay 0
2097 show-paren-style 'mixed 1971 show-paren-style 'mixed
@@ -2107,12 +1981,8 @@ browser defined in `browse-url-secondary-browser-function'."
2107 (setq-local comment-auto-fill-only-comments t) 1981 (setq-local comment-auto-fill-only-comments t)
2108 (turn-on-auto-fill))) 1982 (turn-on-auto-fill)))
2109 1983
2110 (mapc (lambda (buf) 1984 (add-hook 'after-save-hook
2111 (with-current-buffer buf 1985 #'executable-make-buffer-file-executable-if-script-p))
2112 (when (funcall persistent-scratch-scratch-buffer-p-function)
2113 (persistent-scratch-mode +1))))
2114
2115 (buffer-list)))
2116 1986
2117(setup (:straight-if pkgbuild-mode 1987(setup (:straight-if pkgbuild-mode
2118 (executable-find "makepkg")) 1988 (executable-find "makepkg"))
@@ -2121,19 +1991,15 @@ browser defined in `browse-url-secondary-browser-function'."
2121(setup (:straight powerthesaurus) 1991(setup (:straight powerthesaurus)
2122 (:global "C-c l t" #'powerthesaurus-lookup-word-dwim)) 1992 (:global "C-c l t" #'powerthesaurus-lookup-word-dwim))
2123 1993
2124(setup (:straight prism) 19941(setup (:straight restart-emacs)
2125 (dolist (mode lispy-modes) 1995 (defun emacs-upgrade (&optional update-packages)
2126 (add-hook (intern (format "%s-hook" mode)) #'prism-mode))) 1996 "Pull config, upgrade packages, restart Emacs."
2127 1997 (interactive "P")
2128(setup (:straight restart-emacs) 1998 (emacs-git-pull-config)
2129 (defun emacs-upgrade (&optional update-packages) 1999 (when update-packages
2130 "Pull config, upgrade packages, restart Emacs." 2000 (require 'straight-x)
2131 (interactive "P") 2001 (straight-x-pull-all))
2132 (emacs-git-pull-config) 2002 (restart-emacs)))
2133 (when update-packages
2134 (require 'straight-x)
2135 (straight-x-pull-all))
2136 (restart-emacs)))
2137 2003
2138(setup (:straight (shell-command+ 2004(setup (:straight (shell-command+
2139 :host nil 2005 :host nil
@@ -2169,21 +2035,22 @@ browser defined in `browse-url-secondary-browser-function'."
2169 tab-bar-show 1) 2035 tab-bar-show 1)
2170 2036
2171 ;; I've put in a pull request to add the (- 0 right-margin) bit here. 2037 ;; I've put in a pull request to add the (- 0 right-margin) bit here.
2172 (:advise simple-modeline--format :override 2038 (el-patch-feature simple-modeline)
2173 (defun simple-modeline@format (lefts rights) 2039 (with-eval-after-load 'simple-modeline
2174 (let* ((left (simple-modeline--format-segments lefts)) 2040 (el-patch-defun simple-modeline--format (left-segments right-segments)
2175 (right (simple-modeline--format-segments rights)) 2041 "Return a string of `window-width' length containing LEFT-SEGMENTS and RIGHT-SEGMENTS, aligned respectively."
2176 (reserve (length right))) 2042 (let* ((left (simple-modeline--format-segments left-segments))
2177 (concat 2043 (right (simple-modeline--format-segments right-segments))
2178 left 2044 (reserve (length right)))
2179 (propertize " " 2045 (concat
2180 'display `((space :align-to 2046 left
2181 (- right 2047 (propertize " "
2182 (- 0 right-margin) 2048 'display (el-patch-swap
2183 ,reserve))) 2049 `(space :align-to (- right ,reserve))
2184 'face '(:inherit simple-modeline-space)) 2050 `(space :align-to (- right (- 0 right-margin) ,reserve)))
2185 right)))) 2051 'face '(:inherit simple-modeline-space))
2186 2052 right))))
2053
2187 (simple-modeline-mode +1)) 2054 (simple-modeline-mode +1))
2188 2055
2189(setup (:straight-if sly 2056(setup (:straight-if sly
@@ -2304,14 +2171,14 @@ If used with a numeric prefix argument N, N backticks will be inserted."
2304 vertico-count-format nil 2171 vertico-count-format nil
2305 vertico-cycle t) 2172 vertico-cycle t)
2306 2173
2307 (:with-map vertico-map 2174 ;; (:with-map vertico-map
2308 (:bind "<C-backspace>" 2175 ;; (:bind "<C-backspace>"
2309 (defun up-directory (arg) 2176 ;; (defun up-directory (arg)
2310 "Move up a directory (delete backwards to /)." 2177 ;; "Move up a directory (delete backwards to /)."
2311 (interactive "p") 2178 ;; (interactive "p")
2312 (if (string-match-p "/." (minibuffer-contents)) 2179 ;; (if (string-match-p "/." (minibuffer-contents))
2313 (zap-up-to-char (- arg) ?/) 2180 ;; (zap-up-to-char (- arg) ?/)
2314 (backward-kill-word arg))))) 2181 ;; (backward-kill-word arg)))))
2315 2182
2316 (when (boundp 'native-comp-deferred-compilation-deny-list) 2183 (when (boundp 'native-comp-deferred-compilation-deny-list)
2317 (add-to-list 'native-comp-deferred-compilation-deny-list "vertico")) 2184 (add-to-list 'native-comp-deferred-compilation-deny-list "vertico"))
@@ -2319,9 +2186,15 @@ If used with a numeric prefix argument N, N backticks will be inserted."
2319 (vertico-mode +1) 2186 (vertico-mode +1)
2320 2187
2321 ;; Extensions! 2188 ;; Extensions!
2322 (:also-load vertico-mouse) 2189 (:also-load vertico-mouse
2190 vertico-directory)
2323 (vertico-mouse-mode +1) 2191 (vertico-mouse-mode +1)
2324 2192 (:with-map vertico-map
2193 (:bind "RET" #'vertico-directory-enter
2194 "DEL" #'vertico-directory-delete-char
2195 "M-DEL" #'vertico-directory-delete-word))
2196 (add-hook 'rfn-eshadow-update-overlay-hook #'vertico-directory-tidy)
2197
2325 ;; Prefix the current candidate with "> ". From Vertico wiki. 2198 ;; Prefix the current candidate with "> ". From Vertico wiki.
2326 (:advise vertico--format-candidate :around 2199 (:advise vertico--format-candidate :around
2327 (defun vertico-format@add-arrow (orig cand pref suf index start) 2200 (defun vertico-format@add-arrow (orig cand pref suf index start)
@@ -2345,7 +2218,12 @@ If used with a numeric prefix argument N, N backticks will be inserted."
2345(setup (:straight wc-mode) 2218(setup (:straight wc-mode)
2346 (:option wc-modeline-format "[%tww]" 2219 (:option wc-modeline-format "[%tww]"
2347 wc-idle-wait 2) 2220 wc-idle-wait 2)
2348 (:hook-into text-mode)) 2221 (:hook-into text-mode)
2222 (:unbind "C-c C-w a"
2223 "C-c C-w c"
2224 "C-c C-w l"
2225 "C-c C-w w"
2226 "C-c C-w"))
2349 2227
2350(setup (:straight web-mode) 2228(setup (:straight web-mode)
2351 (:option css-level-offset 2 2229 (:option css-level-offset 2
@@ -2413,5 +2291,27 @@ If used with a numeric prefix argument N, N backticks will be inserted."
2413 (call-interactively #'zzz-to-char) 2291 (call-interactively #'zzz-to-char)
2414 (call-interactively #'zzz-up-to-char))))) 2292 (call-interactively #'zzz-up-to-char)))))
2415 2293
2294(setup (:straight dictionary)
2295 (:option dictionary-use-single-buffer t)
2296
2297 (autoload 'dictionary-search "dictionary"
2298 "Ask for a word and search it in all dictionaries" t)
2299 (autoload 'dictionary-match-words "dictionary"
2300 "Ask for a word and search all matching words in the dictionaries" t)
2301 (autoload 'dictionary-lookup-definition "dictionary"
2302 "Unconditionally lookup the word at point." t)
2303 (autoload 'dictionary "dictionary"
2304 "Create a new dictionary buffer" t)
2305 (autoload 'dictionary-mouse-popup-matching-words "dictionary"
2306 "Display entries matching the word at the cursor" t)
2307 (autoload 'dictionary-popup-matching-words "dictionary"
2308 "Display entries matching the word at the point" t)
2309 (autoload 'dictionary-tooltip-mode "dictionary"
2310 "Display tooltips for the current word" t)
2311 (autoload 'global-dictionary-tooltip-mode "dictionary"
2312 "Enable/disable dictionary-tooltip-mode for all buffers" t)
2313
2314 (:with-map lookup-map
2315 (:bind "d" #'dictionary-search)))
2416 2316
2417;;; init.el ends here 2317;;; init.el ends here
diff --git a/lisp/acdw.el b/lisp/acdw.el index dcf7b19..b146f58 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el
@@ -323,6 +323,43 @@ with `string<' starting with the key determined by KEY-FN."
323 (insert-before-markers real) 323 (insert-before-markers real)
324 (delete-region (point) (marker-position end))))))))) 324 (delete-region (point) (marker-position end)))))))))
325 325
326(defun acdw/sort-setups ()
327 "Sort `setup' forms in the current buffer.
328Actually sorts all forms, but based on the logic of `setup'.
329In short, DO NOT USE THIS FUNCTION!!!"
330 (save-excursion
331 (sort-sexps
332 (point-min) (point-max)
333 (lambda (sexp)
334 (format "%S" (cadr sexp)))
335 (lambda (s1 s2) ; oh god, this is worse.
336 (let* ((s1 (cdr s1)) (s2 (cdr s2)) ; for the strings themselves
337 (s1-require (string-match ":require" s1))
338 (s2-require (string-match ":require" s2))
339 (s1-straight (string-match ":straight" s1))
340 (s2-straight (string-match ":straight" s2))
341 (s1-bare (not (or s1-require s1-straight)))
342 (s2-bare (not (or s2-require s2-straight))))
343 (cond
344 ;; if both are the same, sort regular style
345 ((or (and s1-require s2-require)
346 (and s1-bare s2-bare))
347 (string< s1 s2))
348 ((and s1-straight s2-straight)
349 (let* ((r (rx ":straight" (? "-if") (* space) (? "(")))
350 (s1 (replace-regexp-in-string r "" s1))
351 (s2 (replace-regexp-in-string r "" s2)))
352 (message "'%S' '%S'" s1 s2)
353 (string< s1 s2)))
354 ;; requires should go first
355 ((and s1-require (not s2-require)) t)
356 ((and (not s1-require) s2-require) nil)
357 ;; straights should go last
358 ((and s1-straight (not s2-straight)) nil)
359 ((and (not s1-straight) s2-straight) t)
360 ;; else, just sort em.
361 (t (string< s1 s2))))))))
362
326 363
327;;; Emacs configuration functions 364;;; Emacs configuration functions
328 365
@@ -402,6 +439,59 @@ first."
402 (setq deactivate-mark t) 439 (setq deactivate-mark t)
403 nil) 440 nil)
404 441
442;; https://emacs.stackexchange.com/questions/36366/
443(defun html-body-id-filter (output backend info)
444 "Remove random ID attributes generated by Org."
445 (when (eq backend 'html)
446 (replace-regexp-in-string
447 " id=\"[[:alpha:]-]*org[[:alnum:]]\\{7\\}\""
448 ""
449 output t)))
450
451(defun html-body-div-filter (output backend info)
452 "Remove wrapping divs generated by Org."
453 (when (eq backend 'html)
454 (replace-regexp-in-string
455 "</?div[^>]*>\n*" ""
456 output t)))
457
458(defun org-demote-headings (backend)
459 (while (/= (point) (point-max))
460 (org-next-visible-heading 1)
461 (org-demote-subtree)))
462
463(defun acdw/org-export-copy-html ()
464 "Copy a tree as HTML."
465 (interactive)
466 (require 'ox-html)
467 (org-export-with-buffer-copy
468 ;; (add-hook 'org-export-before-parsing-hook #'org-demote-headings nil t)
469 (let ((extracted-heading (acdw/org-extract-heading-text))
470 (org-export-show-temporary-export-buffer nil)
471 (org-export-filter-final-output-functions
472 '(html-body-id-filter html-body-div-filter))
473 (org-export-with-smart-quotes nil)
474 (org-export-smart-quotes-alist nil))
475 (insert "* ORG IS STUPID SOMETIMES\n")
476 (goto-char (point-min))
477 (org-html-export-as-html nil t nil t)
478 (with-current-buffer "*Org HTML Export*"
479 (goto-char (point-min))
480 (replace-regexp "<h2>.*</h2>" "")
481 (insert "<h2>" extracted-heading "</h2>")
482 (flush-lines "^$" (point-min) (point-max))
483 (let ((sentence-end-double-space nil))
484 (unfill-region (point-min) (point-max)))
485 (replace-regexp "<h" "\n<h" nil (1+ (point-min)) (point-max))
486 (replace-regexp "<p" "\n<p" nil (point-min) (point-max))
487 (replace-regexp "<p> +" "<p>" nil (point-min) (point-max))
488 (replace-regexp " +</p>" "</p>" nil (point-min) (point-max))
489 (copy-region-as-kill (point-min) (point-max)))))
490 (when (called-interactively-p 'interactive)
491 (indicate-copied-region))
492 (setq deactivate-mark t)
493 nil)
494
405(defun acdw/org-export-copy () 495(defun acdw/org-export-copy ()
406 "copy a tree" 496 "copy a tree"
407 (interactive) 497 (interactive)
@@ -409,14 +499,17 @@ first."
409 (let ((extracted-heading (acdw/org-extract-heading-text))) 499 (let ((extracted-heading (acdw/org-extract-heading-text)))
410 ;; Export to ASCII - not async, subtree only, visible-only, body-only 500 ;; Export to ASCII - not async, subtree only, visible-only, body-only
411 (let ((org-export-show-temporary-export-buffer nil)) 501 (let ((org-export-show-temporary-export-buffer nil))
412 (org-ascii-export-as-ascii nil t t t)) 502 (org-ascii-export-as-ascii nil t nil t))
413 (with-current-buffer "*Org ASCII Export*" 503 (with-current-buffer "*Org ASCII Export*"
414 (goto-char (point-min)) 504 (goto-char (point-min))
415 (insert extracted-heading) 505 (insert extracted-heading)
416 (newline) 506 (newline 2)
417 (newline)
418 507
419 (unfill-region (point-min) (point-max)) 508 (replace-regexp org-list-full-item-re "
509\4")
510
511 (let ((sentence-end-double-space nil))
512 (unfill-region (point-min) (point-max)))
420 (flush-lines "^$" (point-min) (point-max)) 513 (flush-lines "^$" (point-min) (point-max))
421 514
422 (copy-region-as-kill (point-min) (point-max))) 515 (copy-region-as-kill (point-min) (point-max)))
@@ -435,6 +528,19 @@ first."
435 (match-string-no-properties 2 match)) 528 (match-string-no-properties 2 match))
436 heading)))) 529 heading))))
437 530
531(defun acdw/sync-dir (&optional file make-directory)
532 "Return FILE from ~/Sync.
533Optional argument MAKE-DIRECTORY makes the directory.
534Logic is as in `acdw/dir', which see."
535 (let ((dir (expand-file-name (convert-standard-filename "~/Sync/"))))
536 (if file
537 (let ((file-name (expand-file-name (convert-standard-filename file)
538 dir)))
539 (when make-directory
540 (make-directory (file-name-directory file-name) 'parents))
541 file-name)
542 dir)))
543
438(defun acdw/dir (&optional file make-directory) 544(defun acdw/dir (&optional file make-directory)
439 "Place Emacs files in one place. 545 "Place Emacs files in one place.
440 546
@@ -695,6 +801,24 @@ When called with PREFIX, just kill Emacs without confirmation."
695 (ignore-errors 801 (ignore-errors
696 (delete-frame)))) 802 (delete-frame))))
697 803
804(defun acdw/disabled-command-function (&optional cmd keys)
805 (let ((cmd (or cmd this-command))
806 (keys (or keys (this-command-keys))))
807 ;; this logic stolen from original `disabled-command-function'
808 (if (or (eq (aref keys 0) (if (stringp keys)
809 (aref "\M-x" 0)
810 ?\M-x))
811 (and (>= (length keys) 2)
812 (eq (aref keys 0) meta-prefix-char)
813 (eq (aref keys 1) ?x)))
814 ;; it's been run as an M-x command, we want to do it
815 (call-interactively cmd)
816 ;; else, tell the user it's disabled.
817 (message (substitute-command-keys
818 (concat "Command `%s' has been disabled. "
819 "Run with \\[execute-extended-command]."))
820 cmd))))
821
698 822
699;;; cribbed 823;;; cribbed
700 824