diff options
| author | Richard M. Stallman | 1999-12-10 19:59:42 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1999-12-10 19:59:42 +0000 |
| commit | a34511a1ebfd93b4c2f122da12b8b5e52154e7d0 (patch) | |
| tree | fcfcbcd788564c355caca0fcfb652b0b5e81d634 | |
| parent | ae56feaedadcbc55ecef8c0a4c640c7531b75862 (diff) | |
| download | emacs-a34511a1ebfd93b4c2f122da12b8b5e52154e7d0.tar.gz emacs-a34511a1ebfd93b4c2f122da12b8b5e52154e7d0.zip | |
(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.
| -rw-r--r-- | lisp/cus-edit.el | 57 |
1 files changed, 38 insertions, 19 deletions
diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el index 17505d8f689..98e1f49b2a8 100644 --- a/lisp/cus-edit.el +++ b/lisp/cus-edit.el | |||
| @@ -3345,7 +3345,12 @@ Optional EVENT is the location for the menu." | |||
| 3345 | "File used for storing customization information. | 3345 | "File used for storing customization information. |
| 3346 | The default is nil, which means to use your init file | 3346 | The default is nil, which means to use your init file |
| 3347 | as specified by `user-init-file'. If you specify some other file, | 3347 | as specified by `user-init-file'. If you specify some other file, |
| 3348 | you need to explicitly load that file for the settings to take effect." | 3348 | you need to explicitly load that file for the settings to take effect. |
| 3349 | |||
| 3350 | When you change this variable, look in the previous custom file | ||
| 3351 | \(usually your init file) for the forms `(custom-set-variables ...)' | ||
| 3352 | and `(custom-set-faces ...)', and copy them (whichever ones you find) | ||
| 3353 | to the new custom file. This will preserve your existing customizations." | ||
| 3349 | :type '(choice (const :tag "Your Emacs init file" nil) file) | 3354 | :type '(choice (const :tag "Your Emacs init file" nil) file) |
| 3350 | :group 'customize) | 3355 | :group 'customize) |
| 3351 | 3356 | ||
| @@ -3358,8 +3363,9 @@ you need to explicitly load that file for the settings to take effect." | |||
| 3358 | "~/" nil nil ".emacs")))) | 3363 | "~/" nil nil ".emacs")))) |
| 3359 | 3364 | ||
| 3360 | (defun custom-save-delete (symbol) | 3365 | (defun custom-save-delete (symbol) |
| 3361 | "Delete the call to SYMBOL from `custom-file'. | 3366 | "Visit `custom-file' and delete all calls to SYMBOL from it. |
| 3362 | Leave point at the location of the call, or after the last expression." | 3367 | Leave point at the old location of the first such call, |
| 3368 | or (if there were none) at the end of the buffer." | ||
| 3363 | (let ((default-major-mode)) | 3369 | (let ((default-major-mode)) |
| 3364 | (set-buffer (find-file-noselect (custom-file)))) | 3370 | (set-buffer (find-file-noselect (custom-file)))) |
| 3365 | (goto-char (point-min)) | 3371 | (goto-char (point-min)) |
| @@ -3367,18 +3373,23 @@ Leave point at the location of the call, or after the last expression." | |||
| 3367 | (while (forward-comment 1)) | 3373 | (while (forward-comment 1)) |
| 3368 | (or (eobp) | 3374 | (or (eobp) |
| 3369 | (save-excursion (forward-sexp (buffer-size)))) ; Test for scan errors. | 3375 | (save-excursion (forward-sexp (buffer-size)))) ; Test for scan errors. |
| 3370 | (catch 'found | 3376 | (let (first) |
| 3371 | (while t | 3377 | (catch 'found |
| 3372 | ;; Skip all whitespace and comments. | 3378 | (while t ;; We exit this loop only via throw. |
| 3373 | (while (forward-comment 1)) | 3379 | ;; Skip all whitespace and comments. |
| 3374 | (let ((start (point)) | 3380 | (while (forward-comment 1)) |
| 3375 | (sexp (condition-case nil | 3381 | (let ((start (point)) |
| 3376 | (read (current-buffer)) | 3382 | (sexp (condition-case nil |
| 3377 | (end-of-file (throw 'found nil))))) | 3383 | (read (current-buffer)) |
| 3378 | (when (and (listp sexp) | 3384 | (end-of-file (throw 'found nil))))) |
| 3379 | (eq (car sexp) symbol)) | 3385 | (when (and (listp sexp) |
| 3380 | (delete-region start (point)) | 3386 | (eq (car sexp) symbol)) |
| 3381 | (throw 'found nil)))))) | 3387 | (delete-region start (point)) |
| 3388 | (unless first | ||
| 3389 | (setq first (point))))))) | ||
| 3390 | (if first | ||
| 3391 | (goto-char first) | ||
| 3392 | (goto-char (point-max))))) | ||
| 3382 | 3393 | ||
| 3383 | (defun custom-save-variables () | 3394 | (defun custom-save-variables () |
| 3384 | "Save all customized variables in `custom-file'." | 3395 | "Save all customized variables in `custom-file'." |
| @@ -3397,7 +3408,7 @@ Leave point at the location of the call, or after the last expression." | |||
| 3397 | (princ "\n")) | 3408 | (princ "\n")) |
| 3398 | (princ "(custom-set-variables | 3409 | (princ "(custom-set-variables |
| 3399 | ;; custom-set-variables was added by Custom -- don't edit or cut/paste it! | 3410 | ;; custom-set-variables was added by Custom -- don't edit or cut/paste it! |
| 3400 | ;; Your init file must only contain one such instance.") | 3411 | ;; Your init file must only contain one such instance.\n") |
| 3401 | (mapcar | 3412 | (mapcar |
| 3402 | (lambda (symbol) | 3413 | (lambda (symbol) |
| 3403 | (let ((value (get symbol 'saved-value)) | 3414 | (let ((value (get symbol 'saved-value)) |
| @@ -3408,7 +3419,9 @@ Leave point at the location of the call, or after the last expression." | |||
| 3408 | (comment (get symbol 'saved-variable-comment)) | 3419 | (comment (get symbol 'saved-variable-comment)) |
| 3409 | sep) | 3420 | sep) |
| 3410 | (when (or value comment) | 3421 | (when (or value comment) |
| 3411 | (princ "\n '(") | 3422 | (unless (bolp) |
| 3423 | (princ "\n")) | ||
| 3424 | (princ " '(") | ||
| 3412 | (prin1 symbol) | 3425 | (prin1 symbol) |
| 3413 | (princ " ") | 3426 | (princ " ") |
| 3414 | (prin1 (car value)) | 3427 | (prin1 (car value)) |
| @@ -3433,6 +3446,8 @@ Leave point at the location of the call, or after the last expression." | |||
| 3433 | (t | 3446 | (t |
| 3434 | (princ ")")))))) | 3447 | (princ ")")))))) |
| 3435 | saved-list) | 3448 | saved-list) |
| 3449 | (if (bolp) | ||
| 3450 | (princ " ")) | ||
| 3436 | (princ ")") | 3451 | (princ ")") |
| 3437 | (unless (looking-at "\n") | 3452 | (unless (looking-at "\n") |
| 3438 | (princ "\n"))))) | 3453 | (princ "\n"))))) |
| @@ -3457,7 +3472,7 @@ Leave point at the location of the call, or after the last expression." | |||
| 3457 | (princ "\n")) | 3472 | (princ "\n")) |
| 3458 | (princ "(custom-set-faces | 3473 | (princ "(custom-set-faces |
| 3459 | ;; custom-set-faces was added by Custom -- don't edit or cut/paste it! | 3474 | ;; custom-set-faces was added by Custom -- don't edit or cut/paste it! |
| 3460 | ;; Your init file must only contain one such instance.") | 3475 | ;; Your init file must only contain one such instance.\n") |
| 3461 | (mapcar | 3476 | (mapcar |
| 3462 | (lambda (symbol) | 3477 | (lambda (symbol) |
| 3463 | (let ((value (get symbol 'saved-face)) | 3478 | (let ((value (get symbol 'saved-face)) |
| @@ -3467,7 +3482,9 @@ Leave point at the location of the call, or after the last expression." | |||
| 3467 | (comment (get 'default 'saved-face-comment))) | 3482 | (comment (get 'default 'saved-face-comment))) |
| 3468 | (unless (eq symbol 'default)) | 3483 | (unless (eq symbol 'default)) |
| 3469 | ;; Don't print default face here. | 3484 | ;; Don't print default face here. |
| 3470 | (princ "\n '(") | 3485 | (unless (bolp) |
| 3486 | (princ "\n")) | ||
| 3487 | (princ " '(") | ||
| 3471 | (prin1 symbol) | 3488 | (prin1 symbol) |
| 3472 | (princ " ") | 3489 | (princ " ") |
| 3473 | (prin1 value) | 3490 | (prin1 value) |
| @@ -3485,6 +3502,8 @@ Leave point at the location of the call, or after the last expression." | |||
| 3485 | (t | 3502 | (t |
| 3486 | (princ ")"))))) | 3503 | (princ ")"))))) |
| 3487 | saved-list) | 3504 | saved-list) |
| 3505 | (if (bolp) | ||
| 3506 | (princ " ")) | ||
| 3488 | (princ ")") | 3507 | (princ ")") |
| 3489 | (unless (looking-at "\n") | 3508 | (unless (looking-at "\n") |
| 3490 | (princ "\n"))))) | 3509 | (princ "\n"))))) |