[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#41473: Not saving all user options
From: |
Philip K. |
Subject: |
bug#41473: Not saving all user options |
Date: |
Sat, 23 May 2020 10:04:19 +0200 |
Hi,
I was rewriting parts of my configuration recently, and one important
change was to use `customize-set-variable' more extensivly (via a
setq-like macro). What annoys me is that even though I specify all the
variables in my init.el, they eventually get regenerated in my
`custom-file'. The standard solutions seems to have been setting
`custom-file' to /dev/null, but since I like to use the ECI for
temporary changes.
What I would be interested in, would be a way to tell customize not to
write out a user-option, to keep configurations cleaner. I tried this in
the patch bellow, by checking of the comment starts with four or more
spaces, but it could just as well be any other predicate such as a
string starting with a zero-width whitespace, the string "NONSAVE" or a
property in the symbol plist. The important thing would be that macros
such as my setq-like macro, or use-package could keep the entire
configuration cleaner, without having to give up on a `custom-file'
entierly -- ideally a pure user wouldn't even notice.
Is there any argument against something like this in principle, or is
there already such a mechanism I overlooked?
--
Philip K.
>From 06d4030245e037b2e7e88180cda542c5ebd22ebb Mon Sep 17 00:00:00 2001
From: Philip K <philip@warpmail.net>
Date: Sat, 23 May 2020 09:47:49 +0200
Subject: [PATCH] Inhibit saving user options when comments start with =<4
spaces
---
lisp/cus-edit.el | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el
index 1ec2708550..510b1b3711 100644
--- a/lisp/cus-edit.el
+++ b/lisp/cus-edit.el
@@ -4594,17 +4594,21 @@ custom-save-variables
(save-excursion
(custom-save-delete 'custom-set-variables)
(let ((standard-output (current-buffer))
- (saved-list (make-list 1 0))
- sort-fold-case)
+ saved-list sort-fold-case)
;; First create a sorted list of saved variables.
(mapatoms
(lambda (symbol)
- (if (and (get symbol 'saved-value)
- ;; ignore theme values
- (or (null (get symbol 'theme-value))
- (eq 'user (caar (get symbol 'theme-value)))))
- (nconc saved-list (list symbol)))))
- (setq saved-list (sort (cdr saved-list) 'string<))
+ (when (and (get symbol 'saved-value)
+ ;; don't save comments with four or more preceding
+ ;; space charachters
+ (not (string-match-p
+ "^[[:space:]]{4,}"
+ (get symbol 'saved-variable-comment)))
+ ;; ignore theme values
+ (or (null (get symbol 'theme-value))
+ (eq 'user (caar (get symbol 'theme-value)))))
+ (push symbol saved-list))))
+ (setq saved-list (sort saved-list 'string<))
(unless (bolp)
(princ "\n"))
(princ "(custom-set-variables
--
2.20.1
- bug#41473: Not saving all user options,
Philip K. <=