("-function\\'" function)
("-functions\\'" (repeat function))
("-list\\'" (repeat sexp))
- ("-alist\\'" (repeat (cons sexp sexp))))
+ ("-alist\\'" (alist :key-type sexp :value-type sexp)))
"Alist of (MATCH TYPE).
MATCH should be a regexp matching the name of a symbol, and TYPE should
(put variable 'saved-variable-comment comment)))
(put variable 'customized-value nil)
(put variable 'customized-variable-comment nil)
- (custom-save-all)
+ (if (custom-file t)
+ (custom-save-all)
+ (message "Setting `%s' temporarily since \"emacs -q\" would overwrite customizations"
+ variable)
+ (set variable value))
value)
+;; Some parts of Emacs might prompt the user to save customizations,
+;; during startup before customizations are loaded. This function
+;; handles this corner case by avoiding calling `custom-save-variable'
+;; too early, which could wipe out existing customizations.
+
+;;;###autoload
+(defun customize-push-and-save (list-var elts)
+ "Add ELTS to LIST-VAR and save for future sessions, safely.
+ELTS should be a list. This function adds each entry to the
+value of LIST-VAR using `add-to-list'.
+
+If Emacs is initialized, call `customize-save-variable' to save
+the resulting list value now. Otherwise, add an entry to
+`after-init-hook' to save it after initialization."
+ (dolist (entry elts)
+ (add-to-list list-var entry))
+ (if after-init-time
+ (let ((coding-system-for-read nil))
+ (customize-save-variable list-var (eval list-var)))
+ (add-hook 'after-init-hook
+ `(lambda ()
+ (customize-push-and-save ',list-var ',elts)))))
+
;;;###autoload
(defun customize ()
"Select a customization buffer which you can use to set user options.
;; We want simple widgets to be displayed by default, but complex
;; widgets to be hidden.
+;; This widget type is obsolete as of Emacs 24.1.
(widget-put (get 'item 'widget-type) :custom-show t)
(widget-put (get 'editable-field 'widget-type)
:custom-show (lambda (_widget value)
(setq widget nil)))))
(widget-setup))
+(make-obsolete 'custom-show "this widget type is no longer supported." "24.1")
(defun custom-show (widget value)
"Non-nil if WIDGET should be shown with VALUE by default."
(let ((show (widget-get widget :custom-show)))
if only the first line of the docstring is shown."))
:group 'customize)
-(defun custom-file ()
+(defun custom-file (&optional no-error)
"Return the file name for saving customizations."
- (file-chase-links
- (or custom-file
- (let ((user-init-file user-init-file)
- (default-init-file
- (if (eq system-type 'ms-dos) "~/_emacs" "~/.emacs")))
- (when (null user-init-file)
- (if (or (file-exists-p default-init-file)
- (and (eq system-type 'windows-nt)
- (file-exists-p "~/_emacs")))
- ;; Started with -q, i.e. the file containing
- ;; Custom settings hasn't been read. Saving
- ;; settings there would overwrite other settings.
- (error "Saving settings from \"emacs -q\" would overwrite existing customizations"))
- (setq user-init-file default-init-file))
- user-init-file))))
+ (if (null user-init-file)
+ ;; Started with -q, i.e. the file containing Custom settings
+ ;; hasn't been read. Saving settings there won't make much
+ ;; sense.
+ (if no-error
+ nil
+ (error "Saving settings from \"emacs -q\" would overwrite existing customizations"))
+ (file-chase-links (or custom-file user-init-file))))
;; If recentf-mode is non-nil, this is defined.
(declare-function recentf-expand-file-name "recentf" (name))