Improve startup performance and reduce resource usage

- Defer elfeed auto-update timers until first use (was running at startup)
- Fix consult-project-function to handle nil project gracefully
- Remove duplicate delete-trailing-whitespace hook
- Remove redundant diff-hl find-file-hook (global-diff-hl-mode handles it)
- Reduce treemacs resource usage (lower git entries, disable filewatch)
- Make dired dotfiles-first sorting opt-in (C-c s to sort, C-c S to toggle)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Jens Luedicke
2026-01-19 16:34:33 +01:00
parent c6d72d79ed
commit 3fd6384b3b
6 changed files with 54 additions and 25 deletions

View File

@@ -28,8 +28,13 @@
(define-key dired-mode-map (kbd "* /") 'dired-mark-directories))
;; Custom sorting: directories first (dotted first), then files (dotted first)
;; This is opt-in to avoid performance overhead on every directory open
(defvar dired-sort-dotfiles-first-enabled nil
"When non-nil, automatically sort dired buffers with dotfiles first.")
(defun dired-sort-dotfiles-first ()
"Sort dired: dirs first (dots first within), then files (dots first within)."
(interactive)
(save-excursion
(let (buffer-read-only)
(goto-char (point-min))
@@ -84,8 +89,26 @@
(insert line "\n")))))
(set-buffer-modified-p nil)))
;; Apply custom sorting after dired reads directory
(add-hook 'dired-after-readin-hook 'dired-sort-dotfiles-first)
(defun dired-maybe-sort-dotfiles-first ()
"Sort dired buffer if `dired-sort-dotfiles-first-enabled' is non-nil."
(when dired-sort-dotfiles-first-enabled
(dired-sort-dotfiles-first)))
(defun dired-toggle-dotfiles-first-sorting ()
"Toggle automatic dotfiles-first sorting in dired."
(interactive)
(setq dired-sort-dotfiles-first-enabled (not dired-sort-dotfiles-first-enabled))
(if dired-sort-dotfiles-first-enabled
(progn
(add-hook 'dired-after-readin-hook 'dired-maybe-sort-dotfiles-first)
(message "Dired dotfiles-first sorting enabled"))
(remove-hook 'dired-after-readin-hook 'dired-maybe-sort-dotfiles-first)
(message "Dired dotfiles-first sorting disabled")))
;; Keybinding to manually sort current buffer or toggle auto-sorting
(with-eval-after-load 'dired
(define-key dired-mode-map (kbd "C-c s") 'dired-sort-dotfiles-first)
(define-key dired-mode-map (kbd "C-c S") 'dired-toggle-dotfiles-first-sorting))
(provide 'init-dired)
;;; init-dired.el ends here