Skip to content

Commit

Permalink
emacs 28 auto-save setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Chen Bin committed Nov 21, 2024
1 parent 1d43adf commit 10cb5a9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions init.el
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
(setq *linux* (or (eq system-type 'gnu/linux) (eq system-type 'linux)) )
(setq *unix* (or *linux* (eq system-type 'usg-unix-v) (eq system-type 'berkeley-unix)) )
(setq *emacs28* (>= emacs-major-version 28))
(setq *emacs29* (>= emacs-major-version 29))

;; don't GC during startup to save time
(unless (bound-and-true-p my-computer-has-smaller-memory-p)
Expand Down
13 changes: 12 additions & 1 deletion lisp/init-misc.el
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,18 @@
(file-writable-p (buffer-file-name))
(not (memq major-mode my-auto-save-exclude-major-mode-list))))

(setq auto-save-visited-predicate #'my-auto-save-visited-predicate)
(defun my-auto-save-visited-mode-setup ()
"Auto save setup."
;; turn off `auto-save-visited-mode' in certain scenarios
(when (my-auto-save-visited-predicate)
(setq-local auto-save-visited-mode nil)))

(cond
(*emacs29*
(setq auto-save-visited-predicate #'my-auto-save-visited-predicate))
(t
(defvar auto-save-visited-predicate)
(add-hook 'auto-save-visited-mode-hook #'my-auto-save-visited-mode-setup)))

(my-run-with-idle-timer 2 #'auto-save-visited-mode)
;; }}
Expand Down

0 comments on commit 10cb5a9

Please sign in to comment.