From b727d4f684a2611351189e134b64fcef3661d9f8 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 11 May 2021 09:44:04 -0500 Subject: Add `acdw/system' macro `acdw/system' eases configuration -- it returns the system when called with no arguments, acts as a test with one argument, or as a `pcase' with more than one argument. --- init.el | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'init.el') diff --git a/init.el b/init.el index 74993fe..af817ee 100644 --- a/init.el +++ b/init.el @@ -66,7 +66,7 @@ ;; Flash the mode line (defun flash-mode-line () "Flash the modeline as a bell." - (when (eq acdw/system :home) + (when (acdw/system :home) (beep)) (invert-face 'mode-line) (run-with-timer 0.1 nil #'invert-face 'mode-line)) @@ -103,7 +103,7 @@ 'browse-url-default-browser) browse-url-new-window-flag t browse-url-firefox-new-window-is-tab t) - (when (eq acdw/system :work) + (when (acdw/system :work) (add-to-list 'exec-path "C:/Program Files/Mozilla Firefox"))) (setup buffers @@ -162,14 +162,14 @@ (:global "C-x C-j" dired-jump) - (pcase acdw/system - (:work (:straight w32-browser) - (autoload 'dired-w32-browser "w32-browser") - (:bind "RET" dired-w32-browser)) - (:home (:straight dired-open) - (require 'dired-open) - (:bind "RET" dired-find-alternate-file) - (:option (prepend dired-open-functions) #'dired-open-xdg))) + (acdw/system + (:work (:straight w32-browser) + (autoload 'dired-w32-browser "w32-browser") + (:bind "RET" dired-w32-browser)) + (:home (:straight dired-open) + (require 'dired-open) + (:bind "RET" dired-find-alternate-file) + (:option (prepend dired-open-functions) #'dired-open-xdg))) (:when-loaded (:straight dired-subtree) @@ -251,11 +251,11 @@ (set-terminal-coding-system 'utf-8-unix) (set-keyboard-coding-system 'utf-8-unix) - (pcase acdw/system - (:work (set-clipboard-coding-system 'utf-16-le) - (set-selection-coding-system 'utf-16-le)) - (_ (set-selection-coding-system 'utf-8) - (set-clipboard-coding-system 'utf-8)))) + (acdw/system + (:work (set-clipboard-coding-system 'utf-16-le) + (set-selection-coding-system 'utf-16-le)) + (_ (set-selection-coding-system 'utf-8) + (set-clipboard-coding-system 'utf-8)))) (setup eshell (:option eshell-directory-name (acdw/dir "eshell/" t) @@ -469,7 +469,7 @@ (setup saveplace (:option save-place-file (acdw/dir "places.el") - save-place-forget-unreadable-files (eq acdw/system :home)) + save-place-forget-unreadable-files (acdw/system :home)) (save-place-mode +1)) @@ -1017,7 +1017,7 @@ if ripgrep is installed, otherwise `consult-grep'." (:option undo-fu-session-incompatible-files '("/COMMIT_EDITMSG\\'" "/git-rebase-todo\\'") undo-fu-session-directory (acdw/dir "undo/" t) - undo-fu-session-compression (eq acdw/system :home)) + undo-fu-session-compression (acdw/system :home)) (global-undo-fu-session-mode +1)) @@ -1091,7 +1091,7 @@ call `zzz-to-char'." ;;; System-dependent ;;;; Home -(when (eq acdw/system :home) +(when (acdw/system :home) (setup (:straight pkgbuild-mode)) -- cgit 1.4.1-21-gabe81 From 2bf518fab7ad0b8d0146a551291f1c34e0660821 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 11 May 2021 09:45:42 -0500 Subject: Add `org-mode' to `stupid-modes' for `dumb-auto-format' To keep hanging list items from indenting at save. --- init.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'init.el') diff --git a/init.el b/init.el index af817ee..ddbb53f 100644 --- a/init.el +++ b/init.el @@ -617,7 +617,8 @@ ;; Use a dumb formatter on modes that `apheleia' doesn't work for. (hook-defun dumb-auto-format before-save-hook - (setq stupid-modes '(makefile-mode)) + (setq stupid-modes '(makefile-mode + org-mode)) ;; If there's no apheleia formatter for the mode, just indent the buffer. (unless (or (apply #'derived-mode-p stupid-modes) (and (fboundp 'apheleia--get-formatter-command) -- cgit 1.4.1-21-gabe81 From 05ea83385ba5478f7463d99e13b615e166c599eb Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 12 May 2021 16:41:58 -0500 Subject: Make recentf dired-aware --- init.el | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'init.el') diff --git a/init.el b/init.el index 24d71ed..9d2fa33 100644 --- a/init.el +++ b/init.el @@ -450,8 +450,37 @@ (:option recentf-save-file (acdw/dir "recentf.el") recentf-max-menu-items 100 recentf-max-saved-items nil - recentf-auto-cleanup 60 + recentf-auto-cleanup 'mode (append recentf-exclude) (acdw/dir)) + + ;; Magic advice to rename entries in recentf when moving files in + ;; dired. + (defun rjs/recentf-rename-notify (oldname newname &rest args) + (if (file-directory-p newname) + (rjs/recentf-rename-directory oldname newname) + (rjs/recentf-rename-file oldname newname))) + + (defun rjs/recentf-rename-file (oldname newname) + (setq recentf-list + (mapcar (lambda (name) + (if (string-equal name oldname) + newname + oldname)) + recentf-list))) + + (defun rjs/recentf-rename-directory (oldname newname) + ;; oldname, newname and all entries of recentf-list should already + ;; be absolute and normalised so I think this can just test whether + ;; oldname is a prefix of the element. + (setq recentf-list + (mapcar (lambda (name) + (if (string-prefix-p oldname name) + (concat newname (substring name (length oldname))) + name)) + recentf-list))) + + (advice-add 'dired-rename-file :after #'rjs/recentf-rename-notify) + (recentf-mode +1)) (setup (:require savehist) -- cgit 1.4.1-21-gabe81 From 92ff615f9cb6a501cef2ca95f35abd20a70d2f28 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 12 May 2021 16:42:18 -0500 Subject: Unbind h --- init.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'init.el') diff --git a/init.el b/init.el index 9d2fa33..b8951a0 100644 --- a/init.el +++ b/init.el @@ -624,7 +624,9 @@ find-function-C-source-directory (acdw/find-emacs-source)) (:global "M-=" count-words - "C-w" kill-region-or-backward-word) + "C-w" kill-region-or-backward-word + " h" nil ; HELLO takes a long time to load on Windows + ) ;; Remap C-h to DEL -- can be the "help" key (define-key key-translation-map [?\C-h] [?\C-?]) -- cgit 1.4.1-21-gabe81 From 2341f0bac30a4206209639e7b25431723fe6e715 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 12 May 2021 16:42:36 -0500 Subject: Save more variables --- init.el | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'init.el') diff --git a/init.el b/init.el index b8951a0..bc61a28 100644 --- a/init.el +++ b/init.el @@ -486,12 +486,15 @@ (setup (:require savehist) (:option history-length t history-delete-duplicates t - savehist-autosave-interval 6 + savehist-autosave-interval 60 savehist-file (acdw/dir "savehist.el")) - (dolist (var '(kill-ring + (dolist (var '(extended-command-history + global-mark-ring + kill-ring + regexp-search-ring search-ring - regexp-search-ring)) + mark-ring)) (:option (append savehist-additional-variables) var)) (savehist-mode +1)) -- cgit 1.4.1-21-gabe81