summary refs log tree commit diff stats
path: root/init.el
diff options
context:
space:
mode:
authorCase Duckworth2021-05-12 19:31:14 -0500
committerCase Duckworth2021-05-12 19:31:14 -0500
commit5b978fb0e39e9a286c5075796270c84e0adbcf08 (patch)
tree9cc5d0a0c30d0188cc0638fe9ee17d21ad38cd03 /init.el
parentChange common-lisp-ide -> sly (diff)
parentRemove INBOX from groups.txt (diff)
downloademacs-5b978fb0e39e9a286c5075796270c84e0adbcf08.tar.gz
emacs-5b978fb0e39e9a286c5075796270c84e0adbcf08.zip
Merge branch 'main' of https://tildegit.org/acdw/emacs
Diffstat (limited to 'init.el')
-rw-r--r--init.el83
1 files changed, 59 insertions, 24 deletions
diff --git a/init.el b/init.el index 53e7d0e..06caede 100644 --- a/init.el +++ b/init.el
@@ -66,7 +66,7 @@
66;; Flash the mode line 66;; Flash the mode line
67(defun flash-mode-line () 67(defun flash-mode-line ()
68 "Flash the modeline as a bell." 68 "Flash the modeline as a bell."
69 (when (eq acdw/system :home) 69 (when (acdw/system :home)
70 (beep)) 70 (beep))
71 (invert-face 'mode-line) 71 (invert-face 'mode-line)
72 (run-with-timer 0.1 nil #'invert-face 'mode-line)) 72 (run-with-timer 0.1 nil #'invert-face 'mode-line))
@@ -103,7 +103,7 @@
103 'browse-url-default-browser) 103 'browse-url-default-browser)
104 browse-url-new-window-flag t 104 browse-url-new-window-flag t
105 browse-url-firefox-new-window-is-tab t) 105 browse-url-firefox-new-window-is-tab t)
106 (when (eq acdw/system :work) 106 (when (acdw/system :work)
107 (add-to-list 'exec-path "C:/Program Files/Mozilla Firefox"))) 107 (add-to-list 'exec-path "C:/Program Files/Mozilla Firefox")))
108 108
109(setup buffers 109(setup buffers
@@ -162,14 +162,14 @@
162 162
163 (:global "C-x C-j" dired-jump) 163 (:global "C-x C-j" dired-jump)
164 164
165 (pcase acdw/system 165 (acdw/system
166 (:work (:straight w32-browser) 166 (:work (:straight w32-browser)
167 (autoload 'dired-w32-browser "w32-browser") 167 (autoload 'dired-w32-browser "w32-browser")
168 (:bind "RET" dired-w32-browser)) 168 (:bind "RET" dired-w32-browser))
169 (:home (:straight dired-open) 169 (:home (:straight dired-open)
170 (require 'dired-open) 170 (require 'dired-open)
171 (:bind "RET" dired-find-alternate-file) 171 (:bind "RET" dired-find-alternate-file)
172 (:option (prepend dired-open-functions) #'dired-open-xdg))) 172 (:option (prepend dired-open-functions) #'dired-open-xdg)))
173 173
174 (:when-loaded 174 (:when-loaded
175 (:straight dired-subtree) 175 (:straight dired-subtree)
@@ -251,11 +251,11 @@
251 (set-terminal-coding-system 'utf-8-unix) 251 (set-terminal-coding-system 'utf-8-unix)
252 (set-keyboard-coding-system 'utf-8-unix) 252 (set-keyboard-coding-system 'utf-8-unix)
253 253
254 (pcase acdw/system 254 (acdw/system
255 (:work (set-clipboard-coding-system 'utf-16-le) 255 (:work (set-clipboard-coding-system 'utf-16-le)
256 (set-selection-coding-system 'utf-16-le)) 256 (set-selection-coding-system 'utf-16-le))
257 (_ (set-selection-coding-system 'utf-8) 257 (_ (set-selection-coding-system 'utf-8)
258 (set-clipboard-coding-system 'utf-8)))) 258 (set-clipboard-coding-system 'utf-8))))
259 259
260(setup eshell 260(setup eshell
261 (:option eshell-directory-name (acdw/dir "eshell/" t) 261 (:option eshell-directory-name (acdw/dir "eshell/" t)
@@ -450,26 +450,58 @@
450 (:option recentf-save-file (acdw/dir "recentf.el") 450 (:option recentf-save-file (acdw/dir "recentf.el")
451 recentf-max-menu-items 100 451 recentf-max-menu-items 100
452 recentf-max-saved-items nil 452 recentf-max-saved-items nil
453 recentf-auto-cleanup 60 453 recentf-auto-cleanup 'mode
454 (append recentf-exclude) (acdw/dir)) 454 (append recentf-exclude) (acdw/dir))
455
456 ;; Magic advice to rename entries in recentf when moving files in
457 ;; dired.
458 (defun rjs/recentf-rename-notify (oldname newname &rest args)
459 (if (file-directory-p newname)
460 (rjs/recentf-rename-directory oldname newname)
461 (rjs/recentf-rename-file oldname newname)))
462
463 (defun rjs/recentf-rename-file (oldname newname)
464 (setq recentf-list
465 (mapcar (lambda (name)
466 (if (string-equal name oldname)
467 newname
468 oldname))
469 recentf-list)))
470
471 (defun rjs/recentf-rename-directory (oldname newname)
472 ;; oldname, newname and all entries of recentf-list should already
473 ;; be absolute and normalised so I think this can just test whether
474 ;; oldname is a prefix of the element.
475 (setq recentf-list
476 (mapcar (lambda (name)
477 (if (string-prefix-p oldname name)
478 (concat newname (substring name (length oldname)))
479 name))
480 recentf-list)))
481
482 (advice-add 'dired-rename-file :after #'rjs/recentf-rename-notify)
483
455 (recentf-mode +1)) 484 (recentf-mode +1))
456 485
457(setup (:require savehist) 486(setup (:require savehist)
458 (:option history-length t 487 (:option history-length t
459 history-delete-duplicates t 488 history-delete-duplicates t
460 savehist-autosave-interval 6 489 savehist-autosave-interval 60
461 savehist-file (acdw/dir "savehist.el")) 490 savehist-file (acdw/dir "savehist.el"))
462 491
463 (dolist (var '(kill-ring 492 (dolist (var '(extended-command-history
493 global-mark-ring
494 kill-ring
495 regexp-search-ring
464 search-ring 496 search-ring
465 regexp-search-ring)) 497 mark-ring))
466 (:option (append savehist-additional-variables) var)) 498 (:option (append savehist-additional-variables) var))
467 499
468 (savehist-mode +1)) 500 (savehist-mode +1))
469 501
470(setup saveplace 502(setup saveplace
471 (:option save-place-file (acdw/dir "places.el") 503 (:option save-place-file (acdw/dir "places.el")
472 save-place-forget-unreadable-files (eq acdw/system :home)) 504 save-place-forget-unreadable-files (acdw/system :home))
473 505
474 (save-place-mode +1)) 506 (save-place-mode +1))
475 507
@@ -595,7 +627,9 @@
595 find-function-C-source-directory (acdw/find-emacs-source)) 627 find-function-C-source-directory (acdw/find-emacs-source))
596 628
597 (:global "M-=" count-words 629 (:global "M-=" count-words
598 "C-w" kill-region-or-backward-word) 630 "C-w" kill-region-or-backward-word
631 "<help> h" nil ; HELLO takes a long time to load on Windows
632 )
599 633
600 ;; Remap C-h to DEL -- <f1> can be the "help" key 634 ;; Remap C-h to DEL -- <f1> can be the "help" key
601 (define-key key-translation-map [?\C-h] [?\C-?]) 635 (define-key key-translation-map [?\C-h] [?\C-?])
@@ -617,7 +651,8 @@
617 651
618 ;; Use a dumb formatter on modes that `apheleia' doesn't work for. 652 ;; Use a dumb formatter on modes that `apheleia' doesn't work for.
619 (hook-defun dumb-auto-format before-save-hook 653 (hook-defun dumb-auto-format before-save-hook
620 (setq stupid-modes '(makefile-mode)) 654 (setq stupid-modes '(makefile-mode
655 org-mode))
621 ;; If there's no apheleia formatter for the mode, just indent the buffer. 656 ;; If there's no apheleia formatter for the mode, just indent the buffer.
622 (unless (or (apply #'derived-mode-p stupid-modes) 657 (unless (or (apply #'derived-mode-p stupid-modes)
623 (and (fboundp 'apheleia--get-formatter-command) 658 (and (fboundp 'apheleia--get-formatter-command)
@@ -985,7 +1020,7 @@ if ripgrep is installed, otherwise `consult-grep'."
985 (:option undo-fu-session-incompatible-files '("/COMMIT_EDITMSG\\'" 1020 (:option undo-fu-session-incompatible-files '("/COMMIT_EDITMSG\\'"
986 "/git-rebase-todo\\'") 1021 "/git-rebase-todo\\'")
987 undo-fu-session-directory (acdw/dir "undo/" t) 1022 undo-fu-session-directory (acdw/dir "undo/" t)
988 undo-fu-session-compression (eq acdw/system :home)) 1023 undo-fu-session-compression (acdw/system :home))
989 1024
990 (global-undo-fu-session-mode +1)) 1025 (global-undo-fu-session-mode +1))
991 1026
@@ -1059,7 +1094,7 @@ call `zzz-to-char'."
1059;;; System-dependent 1094;;; System-dependent
1060 1095
1061;;;; Home 1096;;;; Home
1062(when (eq acdw/system :home) 1097(when (acdw/system :home)
1063 1098
1064 (setup (:straight pkgbuild-mode)) 1099 (setup (:straight pkgbuild-mode))
1065 1100