# HG changeset patch # User Richard M. Stallman # Date 944855982 0 # Node ID f7c68655bd5d92be54b6796ad5495de1c99d4b79 # Parent 4008c82964662ec89deb6eb8fc3b3e87010695d2 (custom-save-delete): Delete all occurrences, leave point where the first occurrence was. (custom-save-faces): Insert a newline at the end of the comment. Avoid a double newline there. If final closeparen is at bol, put a space before it. (custom-save-variables): Likewise. (custom-file): Doc fix. diff -r 4008c8296466 -r f7c68655bd5d lisp/cus-edit.el --- a/lisp/cus-edit.el Fri Dec 10 18:14:01 1999 +0000 +++ b/lisp/cus-edit.el Fri Dec 10 19:59:42 1999 +0000 @@ -3345,7 +3345,12 @@ "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) @@ -3358,8 +3363,9 @@ "~/" 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)) @@ -3367,18 +3373,23 @@ (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'." @@ -3397,7 +3408,7 @@ (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)) @@ -3408,7 +3419,9 @@ (comment (get symbol 'saved-variable-comment)) sep) (when (or value comment) - (princ "\n '(") + (unless (bolp) + (princ "\n")) + (princ " '(") (prin1 symbol) (princ " ") (prin1 (car value)) @@ -3433,6 +3446,8 @@ (t (princ ")")))))) saved-list) + (if (bolp) + (princ " ")) (princ ")") (unless (looking-at "\n") (princ "\n"))))) @@ -3457,7 +3472,7 @@ (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)) @@ -3467,7 +3482,9 @@ (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) @@ -3485,6 +3502,8 @@ (t (princ ")"))))) saved-list) + (if (bolp) + (princ " ")) (princ ")") (unless (looking-at "\n") (princ "\n")))))