feat(emacs): savehist-mode
This commit is contained in:
9
users/crumb/programs/emacs/history
Normal file
9
users/crumb/programs/emacs/history
Normal file
@@ -0,0 +1,9 @@
|
||||
;; -*- mode: emacs-lisp; coding: utf-8-unix -*-
|
||||
;; Minibuffer history file, automatically generated by ‘savehist’.
|
||||
|
||||
(setq savehist-minibuffer-history-variables '(minibuffer-history file-name-history evil-ex-history evil-ex-search-history))
|
||||
(setq minibuffer-history '("file-name-concat"))
|
||||
(setq file-name-history '(#("/persist/dots/users/crumb/programs/emacs/modules/syd-autosave.el" 0 64 (project "/persist/dots/"))))
|
||||
(setq evil-ex-history '("qa" "w"))
|
||||
(setq evil-ex-search-history '("savehi"))
|
||||
(setq evil-jumps-history '((2219 #1="/persist/dots/users/crumb/programs/emacs/modules/syd-autosave.el") (1758 #1#) (3255 #1#) (3279 #1#) (1697 #1#)))
|
||||
@@ -38,5 +38,38 @@
|
||||
(find-file-hook . recentf-save-list))
|
||||
:custom (recentf-save-file (file-name-concat syd-data-dir "recentf")))
|
||||
|
||||
(use-package savehist
|
||||
:defer-incrementally custom
|
||||
:hook (on-first-input-hook . savehist-mode)
|
||||
:custom (savehist-file (file-name-concat syd-cache-dir "savehist"))
|
||||
:config
|
||||
(setq savehist-save-minibuffer-history t
|
||||
savehist-autosave-interval nil ; save on kill only
|
||||
savehist-additional-variables
|
||||
'(kill-ring ; persist clipboard
|
||||
register-alist ; persist macros
|
||||
mark-ring global-mark-ring ; persist marks
|
||||
search-ring regexp-search-ring)) ; persist searches
|
||||
(syd-add-hook 'savehist-save-hook
|
||||
(defun syd--savehist-unpropertize-variables-h ()
|
||||
"Remove text properties from `kill-ring' to reduce savehist cache size."
|
||||
(setq kill-ring
|
||||
(mapcar #'substring-no-properties
|
||||
(cl-remove-if-not #'stringp kill-ring))
|
||||
register-alist
|
||||
(cl-loop for (reg . item) in register-alist
|
||||
if (stringp item)
|
||||
collect (cons reg (substring-no-properties item))
|
||||
else collect (cons reg item))))
|
||||
(defun syd--savehist-remove-unprintable-registers-h ()
|
||||
"Remove unwriteable registers (e.g. containing window configurations).
|
||||
Otherwise, `savehist' would discard `register-alist' entirely if we don't omit
|
||||
the unwritable tidbits."
|
||||
;; Save new value in the temp buffer savehist is running
|
||||
;; `savehist-save-hook' in. We don't want to actually remove the
|
||||
;; unserializable registers in the current session!
|
||||
(setq-local register-alist
|
||||
(cl-remove-if-not #'savehist-printable register-alist)))))
|
||||
|
||||
|
||||
(provide 'syd-autosave)
|
||||
|
||||
Reference in New Issue
Block a user