"File used for storing customization information.
The default is nil, which means to use your init file
as specified by `user-init-file'. If you specify some other file,
-you need to explicitly load that file for the settings to take effect."
+you need to explicitly load that file for the settings to take effect.
+
+When you change this variable, look in the previous custom file
+\(usually your init file) for the forms `(custom-set-variables ...)'
+and `(custom-set-faces ...)', and copy them (whichever ones you find)
+to the new custom file. This will preserve your existing customizations."
:type '(choice (const :tag "Your Emacs init file" nil) file)
:group 'customize)
"~/" nil nil ".emacs"))))
(defun custom-save-delete (symbol)
- "Delete the call to SYMBOL from `custom-file'.
-Leave point at the location of the call, or after the last expression."
+ "Visit `custom-file' and delete all calls to SYMBOL from it.
+Leave point at the old location of the first such call,
+or (if there were none) at the end of the buffer."
(let ((default-major-mode))
(set-buffer (find-file-noselect (custom-file))))
(goto-char (point-min))
(while (forward-comment 1))
(or (eobp)
(save-excursion (forward-sexp (buffer-size)))) ; Test for scan errors.
- (catch 'found
- (while t
- ;; Skip all whitespace and comments.
- (while (forward-comment 1))
- (let ((start (point))
- (sexp (condition-case nil
- (read (current-buffer))
- (end-of-file (throw 'found nil)))))
- (when (and (listp sexp)
- (eq (car sexp) symbol))
- (delete-region start (point))
- (throw 'found nil))))))
+ (let (first)
+ (catch 'found
+ (while t ;; We exit this loop only via throw.
+ ;; Skip all whitespace and comments.
+ (while (forward-comment 1))
+ (let ((start (point))
+ (sexp (condition-case nil
+ (read (current-buffer))
+ (end-of-file (throw 'found nil)))))
+ (when (and (listp sexp)
+ (eq (car sexp) symbol))
+ (delete-region start (point))
+ (unless first
+ (setq first (point)))))))
+ (if first
+ (goto-char first)
+ (goto-char (point-max)))))
(defun custom-save-variables ()
"Save all customized variables in `custom-file'."
(princ "\n"))
(princ "(custom-set-variables
;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
- ;; Your init file must only contain one such instance.")
+ ;; Your init file must only contain one such instance.\n")
(mapcar
(lambda (symbol)
(let ((value (get symbol 'saved-value))
(comment (get symbol 'saved-variable-comment))
sep)
(when (or value comment)
- (princ "\n '(")
+ (unless (bolp)
+ (princ "\n"))
+ (princ " '(")
(prin1 symbol)
(princ " ")
(prin1 (car value))
(t
(princ ")"))))))
saved-list)
+ (if (bolp)
+ (princ " "))
(princ ")")
(unless (looking-at "\n")
(princ "\n")))))
(princ "\n"))
(princ "(custom-set-faces
;; custom-set-faces was added by Custom -- don't edit or cut/paste it!
- ;; Your init file must only contain one such instance.")
+ ;; Your init file must only contain one such instance.\n")
(mapcar
(lambda (symbol)
(let ((value (get symbol 'saved-face))
(comment (get 'default 'saved-face-comment)))
(unless (eq symbol 'default))
;; Don't print default face here.
- (princ "\n '(")
+ (unless (bolp)
+ (princ "\n"))
+ (princ " '(")
(prin1 symbol)
(princ " ")
(prin1 value)
(t
(princ ")")))))
saved-list)
+ (if (bolp)
+ (princ " "))
(princ ")")
(unless (looking-at "\n")
(princ "\n")))))