Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[spacemacs-defaults] Tweak savehist configuration #16762

Merged
merged 1 commit into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions layers/+spacemacs/spacemacs-defaults/config.el
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,13 @@ or `nil' to only save and not visit the file."
;; Session
;; ---------------------------------------------------------------------------

(spacemacs|defc spacemacs-savehist-autosave-idle-interval 60
"Idle interval between autosaves of minibuffer histories and other
variables (see `savehist-mode' and `savehist-additional-variables')."
'integer)

(defvar spacemacs--savehist-idle-timer nil)

;; scratch buffer empty
(setq initial-scratch-message dotspacemacs-initial-scratch-message)
;; don't create backup~ files
Expand Down
27 changes: 24 additions & 3 deletions layers/+spacemacs/spacemacs-defaults/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -413,9 +413,30 @@
savehist-additional-variables '(search-ring
regexp-search-ring
extended-command-history
kill-ring)
savehist-autosave-interval 60)
(savehist-mode t)))
kill-ring
kmacro-ring
log-edit-comment-ring)
;; We use an idle timer instead, as saving can cause
;; noticable delays with large histories.
savehist-autosave-interval nil)
(savehist-mode t)
(define-advice savehist-save
(:around (orig &rest args) spacemacs//kill-ring-no-properties)
"Text properties can blow up the savehist file and lead to
excessive pauses when saving."
(if (memq 'kill-ring savehist-additional-variables)
(let ((kill-ring (mapcar #'substring-no-properties
(cl-remove-if-not #'stringp kill-ring))))
(apply orig args))
(apply orig args)))
(when (and (boundp 'spacemacs--savehist-idle-timer)
(timerp spacemacs--savehist-idle-timer))
(cancel-timer spacemacs--savehist-idle-timer))
(setq spacemacs--savehist-idle-timer
(run-with-idle-timer
spacemacs-savehist-autosave-idle-interval
spacemacs-savehist-autosave-idle-interval
#'savehist-autosave))))

(defun spacemacs-defaults/init-saveplace ()
(use-package saveplace
Expand Down
Loading