aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-04-30 09:16:45 -0500
committerCraig Jennings <c@cjennings.net>2026-04-30 09:16:45 -0500
commit0ab3032947fb6dbff0fcbf8a666b7fdcd8f08a5a (patch)
treeea297d208c5980de0950381f57e3b50edb5d6dd2 /modules
parenteaf3848e7893326f2ddaaab23633106e0afe8fd8 (diff)
downloaddotemacs-0ab3032947fb6dbff0fcbf8a666b7fdcd8f08a5a.tar.gz
dotemacs-0ab3032947fb6dbff0fcbf8a666b7fdcd8f08a5a.zip
refactor(config-utilities): extract cj/--delete-compiled-files-in-dir
Splits the file-walking work out of cj/delete-emacs-home-compiled-files so it takes a directory parameter and returns a count. The interactive wrapper still hardcodes user-emacs-directory and prints the same status messages, just with the count interpolated. The split is scope-aligned with adding tests for the file-walking behaviour. The original function couldn't be tested without spawning files inside user-emacs-directory itself, which would pollute the running config.
Diffstat (limited to 'modules')
-rw-r--r--modules/config-utilities.el25
1 files changed, 17 insertions, 8 deletions
diff --git a/modules/config-utilities.el b/modules/config-utilities.el
index 2af3effa..e4d0cf69 100644
--- a/modules/config-utilities.el
+++ b/modules/config-utilities.el
@@ -107,18 +107,27 @@ Recompile natively when supported, otherwise fall back to byte compilation."
(keymap-set cj/debug-config-keymap "c h" 'cj/recompile-emacs-home)
+(defun cj/--delete-compiled-files-in-dir (dir)
+ "Delete every .elc and .eln file under DIR recursively.
+Returns the count of files deleted."
+ (require 'find-lisp)
+ (let ((count 0))
+ (mapc (lambda (path)
+ (when (or (string-suffix-p ".elc" path)
+ (string-suffix-p ".eln" path))
+ (delete-file path)
+ (setq count (1+ count))))
+ (find-lisp-find-files dir ""))
+ count))
+
(defun cj/delete-emacs-home-compiled-files ()
- "Delete all compiled files recursively in \='user-emacs-directory\='."
+ "Delete all compiled files recursively in `user-emacs-directory'."
(interactive)
(message "Deleting compiled files under %s. This may take a while."
user-emacs-directory)
- (require 'find-lisp) ;; make sure the package is required
- (mapc (lambda (path)
- (when (or (string-suffix-p ".elc" path)
- (string-suffix-p ".eln" path))
- (delete-file path)))
- (find-lisp-find-files user-emacs-directory ""))
- (message "Done. Compiled files removed under %s" user-emacs-directory))
+ (let ((count (cj/--delete-compiled-files-in-dir user-emacs-directory)))
+ (message "Done. %d compiled file(s) removed under %s"
+ count user-emacs-directory)))
(keymap-set cj/debug-config-keymap "c d" 'cj/delete-emacs-home-compiled-files)
(defun cj/compile-this-elisp-buffer ()