Mercurial > hg > xemacs-beta
comparison lisp/cus-edit.el @ 4178:e687f1912d5b
[xemacs-hg @ 2007-09-20 21:18:33 by didierv]
User options interactive prompting improvements
author | didierv |
---|---|
date | Thu, 20 Sep 2007 21:18:35 +0000 |
parents | cef5f57bb9e2 |
children | ef6c55ab3090 |
comparison
equal
deleted
inserted
replaced
4177:d080fe09a356 | 4178:e687f1912d5b |
---|---|
1 ;;; cus-edit.el --- Tools for customizating Emacs and Lisp packages. | 1 ;;; cus-edit.el --- Tools for customizating Emacs and Lisp packages. |
2 ;; | 2 ;; |
3 ;; Copyright (C) 2007 Didier Verna | |
4 ;; Copyright (C) 2003 Ben Wing | |
3 ;; Copyright (C) 1996, 1997, 2000 Free Software Foundation, Inc. | 5 ;; Copyright (C) 1996, 1997, 2000 Free Software Foundation, Inc. |
4 ;; Copyright (C) 2003 Ben Wing. | |
5 ;; | 6 ;; |
6 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk> | 7 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk> |
7 ;; Maintainer: Hrvoje Niksic <hniksic@xemacs.org> | 8 ;; Maintainer: Didier Verna <didier@xemacs.org> |
8 ;; Keywords: help, faces | 9 ;; Keywords: help, faces |
9 ;; Version: 1.9960-x | 10 ;; Version: 1.9960-x |
10 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/ | 11 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/ |
11 | 12 |
12 ;; This file is part of XEmacs. | 13 ;; This file is part of XEmacs. |
304 "Customize variable: ") | 305 "Customize variable: ") |
305 obarray (lambda (symbol) | 306 obarray (lambda (symbol) |
306 (and (boundp symbol) | 307 (and (boundp symbol) |
307 (or (get symbol 'custom-type) | 308 (or (get symbol 'custom-type) |
308 (user-variable-p symbol)))) | 309 (user-variable-p symbol)))) |
309 t nil nil (and v (symbol-name v)))) | 310 t nil nil (and v (symbol-name v)))) |
310 (list (if (equal val "") | 311 (list (if (equal val "") |
311 (if (symbolp v) v nil) | 312 (if (symbolp v) v nil) |
312 (intern val))))) | 313 (intern val))))) |
313 | 314 |
314 ;; Here we take not only the actual groups, but the loads, too. | 315 ;; Here we take not only the actual groups, but the loads, too. |
649 ;;; The Customize Commands | 650 ;;; The Customize Commands |
650 | 651 |
651 (defun custom-prompt-variable (prompt-var prompt-val &optional comment) | 652 (defun custom-prompt-variable (prompt-var prompt-val &optional comment) |
652 "Prompt for a variable and a value and return them as a list. | 653 "Prompt for a variable and a value and return them as a list. |
653 PROMPT-VAR is the prompt for the variable, and PROMPT-VAL is the | 654 PROMPT-VAR is the prompt for the variable, and PROMPT-VAL is the |
654 prompt for the value. The %s escape in PROMPT-VAL is replaced with | 655 prompt for the value. A %s escape in PROMPT-VAL is replaced with |
655 the name of the variable. | 656 the name of the variable. A final colon is appended to both prompts. |
656 | 657 |
657 If the variable has a `variable-interactive' property, that is used as if | 658 If the variable has a `variable-interactive' property, that is used as if |
658 it were the arg to `interactive' (which see) to interactively read the value. | 659 it were the arg to `interactive' (which see) to interactively read the value. |
659 | 660 |
660 If the variable has a `custom-type' property, it must be a widget and the | 661 If the variable has a `custom-type' property, it must be a widget and the |
661 `:prompt-value' property of that widget will be used for reading the value. | 662 `:prompt-value' property of that widget will be used for reading the value. |
662 | 663 |
663 If optional COMMENT argument is non nil, also prompt for a comment and return | 664 If optional COMMENT argument is non nil, also prompt for a comment and return |
664 it as the third element in the list." | 665 it as the third element in the list." |
665 (let* ((var (read-variable prompt-var)) | 666 (let* ((var (read-variable (concat prompt-var ": "))) |
666 (minibuffer-help-form '(describe-variable var)) | 667 (minibuffer-help-form '(describe-variable var)) |
667 (val | 668 (val |
668 (let ((prop (get var 'variable-interactive)) | 669 (let ((prop (get var 'variable-interactive)) |
669 (type (get var 'custom-type)) | 670 (type (get var 'custom-type)) |
670 (prompt (format prompt-val var))) | 671 (prompt (format prompt-val var))) |
681 prompt | 682 prompt |
682 (if (boundp var) | 683 (if (boundp var) |
683 (symbol-value var)) | 684 (symbol-value var)) |
684 (not (boundp var)))) | 685 (not (boundp var)))) |
685 (t | 686 (t |
686 (eval-minibuffer prompt)))))) | 687 (eval-minibuffer (concat prompt ": "))))))) |
687 (if comment | 688 (if comment |
688 (list var val | 689 (list var val |
689 (read-string "Comment: " (get var 'variable-comment))) | 690 (read-string "Comment: " (get var 'variable-comment))) |
690 (list var val)) | 691 (list var val)))) |
691 )) | |
692 | 692 |
693 ;;;###autoload | 693 ;;;###autoload |
694 (defun customize-set-value (var val &optional comment) | 694 (defun customize-set-value (var val &optional comment) |
695 "Set VARIABLE to VALUE. VALUE is a Lisp object. | 695 "Set VARIABLE to VALUE. VALUE is a Lisp object. |
696 | 696 |
699 | 699 |
700 If VARIABLE has a `custom-type' property, it must be a widget and the | 700 If VARIABLE has a `custom-type' property, it must be a widget and the |
701 `:prompt-value' property of that widget will be used for reading the value. | 701 `:prompt-value' property of that widget will be used for reading the value. |
702 | 702 |
703 If given a prefix (or a COMMENT argument), also prompt for a comment." | 703 If given a prefix (or a COMMENT argument), also prompt for a comment." |
704 (interactive (custom-prompt-variable "Set variable: " | 704 (interactive (custom-prompt-variable "Set variable" |
705 "Set %s to value: " | 705 "Set value of %s" |
706 current-prefix-arg)) | 706 current-prefix-arg)) |
707 | 707 |
708 (set var val) | 708 (set var val) |
709 (cond ((string= comment "") | 709 (cond ((string= comment "") |
710 (put var 'variable-comment nil)) | 710 (put var 'variable-comment nil)) |
726 | 726 |
727 If VARIABLE has a `custom-type' property, it must be a widget and the | 727 If VARIABLE has a `custom-type' property, it must be a widget and the |
728 `:prompt-value' property of that widget will be used for reading the value. | 728 `:prompt-value' property of that widget will be used for reading the value. |
729 | 729 |
730 If given a prefix (or a COMMENT argument), also prompt for a comment." | 730 If given a prefix (or a COMMENT argument), also prompt for a comment." |
731 (interactive (custom-prompt-variable "Set variable: " | 731 (interactive (custom-prompt-variable "Set variable" |
732 "Set customized value for %s to: " | 732 "Set customized value of %s" |
733 current-prefix-arg)) | 733 current-prefix-arg)) |
734 (funcall (or (get variable 'custom-set) 'set-default) variable value) | 734 (funcall (or (get variable 'custom-set) 'set-default) variable value) |
735 (put variable 'customized-value (list (custom-quote value))) | 735 (put variable 'customized-value (list (custom-quote value))) |
736 (cond ((string= comment "") | 736 (cond ((string= comment "") |
737 (put variable 'variable-comment nil) | 737 (put variable 'variable-comment nil) |
755 | 755 |
756 If VARIABLE has a `custom-type' property, it must be a widget and the | 756 If VARIABLE has a `custom-type' property, it must be a widget and the |
757 `:prompt-value' property of that widget will be used for reading the value. | 757 `:prompt-value' property of that widget will be used for reading the value. |
758 | 758 |
759 If given a prefix (or a COMMENT argument), also prompt for a comment." | 759 If given a prefix (or a COMMENT argument), also prompt for a comment." |
760 (interactive (custom-prompt-variable "Set and save variable: " | 760 (interactive (custom-prompt-variable "Set and save variable" |
761 "Set and save value for %s as: " | 761 "Set and save value of %s" |
762 current-prefix-arg)) | 762 current-prefix-arg)) |
763 (funcall (or (get variable 'custom-set) 'set-default) variable value) | 763 (funcall (or (get variable 'custom-set) 'set-default) variable value) |
764 (put variable 'saved-value (list (custom-quote value))) | 764 (put variable 'saved-value (list (custom-quote value))) |
765 (custom-push-theme 'theme-value variable 'user 'set (list (custom-quote value))) | 765 (custom-push-theme 'theme-value variable 'user 'set (list (custom-quote value))) |
766 (cond ((string= comment "") | 766 (cond ((string= comment "") |
1768 (backtrace-in-condition-handler-eliminating-handler | 1768 (backtrace-in-condition-handler-eliminating-handler |
1769 '__custom_load_cd1__))) | 1769 '__custom_load_cd1__))) |
1770 (return-from custom-load nil))) | 1770 (return-from custom-load nil))) |
1771 #'(lambda () | 1771 #'(lambda () |
1772 (load (expand-file-name "custom-defines" dir)))))) | 1772 (load (expand-file-name "custom-defines" dir)))))) |
1773 ;; we get here only from the `return-from'; see above | 1773 ;; we get here only from the `return-from'; see above |
1774 (load source)))) | 1774 (load source)))) |
1775 | 1775 |
1776 (defun custom-load-widget (widget) | 1776 (defun custom-load-widget (widget) |
1777 "Load all dependencies for WIDGET." | 1777 "Load all dependencies for WIDGET." |
1778 (custom-load-symbol (widget-value widget))) | 1778 (custom-load-symbol (widget-value widget))) |
2543 (define-widget 'custom-face 'custom | 2543 (define-widget 'custom-face 'custom |
2544 "Customize face." | 2544 "Customize face." |
2545 :sample-face 'custom-face-tag-face | 2545 :sample-face 'custom-face-tag-face |
2546 :help-echo "Set or reset this face" | 2546 :help-echo "Set or reset this face" |
2547 :documentation-property #'(lambda (face) | 2547 :documentation-property #'(lambda (face) |
2548 (face-doc-string face)) | 2548 (face-doc-string face)) |
2549 :value-create 'custom-face-value-create | 2549 :value-create 'custom-face-value-create |
2550 :action 'custom-face-action | 2550 :action 'custom-face-action |
2551 :custom-category 'face | 2551 :custom-category 'face |
2552 :custom-form nil ; defaults to value of `custom-face-default-form' | 2552 :custom-form nil ; defaults to value of `custom-face-default-form' |
2553 :custom-set 'custom-face-set | 2553 :custom-set 'custom-face-set |
3494 (auto-mode-alist nil)) | 3494 (auto-mode-alist nil)) |
3495 (set-buffer (find-file-noselect custom-file))) | 3495 (set-buffer (find-file-noselect custom-file))) |
3496 (goto-char (point-min)) | 3496 (goto-char (point-min)) |
3497 (condition-case nil | 3497 (condition-case nil |
3498 (while (not (eobp)) | 3498 (while (not (eobp)) |
3499 (let ((sexp (read (current-buffer)))) | 3499 (let ((sexp (read (current-buffer)))) |
3500 (when (and (listp sexp) | 3500 (when (and (listp sexp) |
3501 (memq (car sexp) symbols)) | 3501 (memq (car sexp) symbols)) |
3502 (delete-region (save-excursion | 3502 (delete-region (save-excursion |
3503 (backward-sexp) | 3503 (backward-sexp) |
3504 (point)) | 3504 (point)) |
3505 (point)) | 3505 (point)) |
3506 (while (and (eolp) (not (eobp))) | 3506 (while (and (eolp) (not (eobp))) |
3507 (delete-region (point) (prog2 (forward-line 1) (point)))) | 3507 (delete-region (point) (prog2 (forward-line 1) (point)))) |
3508 ))) | 3508 ))) |
3509 (end-of-file nil))) | 3509 (end-of-file nil))) |
3510 | 3510 |
3511 (defsubst custom-save-variable-p (symbol) | 3511 (defsubst custom-save-variable-p (symbol) |
3512 "Return non-nil if symbol SYMBOL is a customized variable." | 3512 "Return non-nil if symbol SYMBOL is a customized variable." |
3513 (and (symbolp symbol) | 3513 (and (symbolp symbol) |
3514 (let ((spec (car-safe (get symbol 'theme-value)))) | 3514 (let ((spec (car-safe (get symbol 'theme-value)))) |
3515 (or (and spec (eq (car spec) 'user) | 3515 (or (and spec (eq (car spec) 'user) |
3516 (eq (second spec) 'set)) | 3516 (eq (second spec) 'set)) |
3517 (get symbol 'saved-variable-comment) | 3517 (get symbol 'saved-variable-comment) |
3518 ;; support non-themed vars | 3518 ;; support non-themed vars |
3519 (and (null spec) (get symbol 'saved-value)))))) | 3519 (and (null spec) (get symbol 'saved-value)))))) |
3520 | 3520 |
3521 (defun custom-save-variable-internal (symbol) | 3521 (defun custom-save-variable-internal (symbol) |
3522 "Print variable SYMBOL to the standard output. | 3522 "Print variable SYMBOL to the standard output. |
3523 SYMBOL must be a customized variable." | 3523 SYMBOL must be a customized variable." |
3524 (let ((requests (get symbol 'custom-requests)) | 3524 (let ((requests (get symbol 'custom-requests)) |
3525 (now (not (or (get symbol 'standard-value) | 3525 (now (not (or (get symbol 'standard-value) |
3526 (and (not (boundp symbol)) | 3526 (and (not (boundp symbol)) |
3527 (not (eq (get symbol 'force-value) | 3527 (not (eq (get symbol 'force-value) |
3528 'rogue)))))) | 3528 'rogue)))))) |
3529 (comment (get symbol 'saved-variable-comment)) | 3529 (comment (get symbol 'saved-variable-comment)) |
3530 ;; Print everything, no placeholders `...' | 3530 ;; Print everything, no placeholders `...' |
3531 (print-level nil) | 3531 (print-level nil) |
3532 (print-length nil)) | 3532 (print-length nil)) |
3533 (unless (custom-save-variable-p symbol) | 3533 (unless (custom-save-variable-p symbol) |
3534 (error 'wrong-type-argument "Not a customized variable" symbol)) | 3534 (error 'wrong-type-argument "Not a customized variable" symbol)) |
3535 (princ "\n '(") | 3535 (princ "\n '(") |
3536 (prin1 symbol) | 3536 (prin1 symbol) |
3537 (princ " ") | 3537 (princ " ") |
3538 ;; This comment stuff is in the way #### | 3538 ;; This comment stuff is in the way #### |
3539 ;; Is (eq (third spec) (car saved-value)) ???? | 3539 ;; Is (eq (third spec) (car saved-value)) ???? |
3540 ;; (prin1 (third spec)) | 3540 ;; (prin1 (third spec)) |
3541 ;; XEmacs -- pretty-print value if available | 3541 ;; XEmacs -- pretty-print value if available |
3542 (if (and custom-save-pretty-print | 3542 (if (and custom-save-pretty-print |
3543 (fboundp 'pp)) | 3543 (fboundp 'pp)) |
3544 ;; To suppress bytecompiler warning | 3544 ;; To suppress bytecompiler warning |
3545 (with-fboundp 'pp | 3545 (with-fboundp 'pp |
3546 (pp (car (get symbol 'saved-value)))) | 3546 (pp (car (get symbol 'saved-value)))) |
3547 (prin1 (car (get symbol 'saved-value)))) | 3547 (prin1 (car (get symbol 'saved-value)))) |
3548 (when (or now requests comment) | 3548 (when (or now requests comment) |
3549 (princ (if now " t" " nil"))) | 3549 (princ (if now " t" " nil"))) |
3550 (when (or comment requests) | 3550 (when (or comment requests) |
3551 (princ " ") | 3551 (princ " ") |
3568 ;; 'custom-reset-variables | 3568 ;; 'custom-reset-variables |
3569 ;; 'custom-set-variables) | 3569 ;; 'custom-set-variables) |
3570 (custom-save-loaded-themes) | 3570 (custom-save-loaded-themes) |
3571 (custom-save-resets 'theme-value 'custom-reset-variables nil) | 3571 (custom-save-resets 'theme-value 'custom-reset-variables nil) |
3572 (let ((standard-output (current-buffer)) | 3572 (let ((standard-output (current-buffer)) |
3573 (sorted-list ())) | 3573 (sorted-list ())) |
3574 ;; First create a sorted list of saved variables. | 3574 ;; First create a sorted list of saved variables. |
3575 (mapatoms | 3575 (mapatoms |
3576 (lambda (symbol) | 3576 (lambda (symbol) |
3577 (when (custom-save-variable-p symbol) | 3577 (when (custom-save-variable-p symbol) |
3578 (push symbol sorted-list)))) | 3578 (push symbol sorted-list)))) |
3579 (setq sorted-list (sort sorted-list 'string<)) | 3579 (setq sorted-list (sort sorted-list 'string<)) |
3580 (unless (bolp) | 3580 (unless (bolp) |
3581 (princ "\n")) | 3581 (princ "\n")) |
3582 (princ "(custom-set-variables") | 3582 (princ "(custom-set-variables") |
3583 (mapc 'custom-save-variable-internal | 3583 (mapc 'custom-save-variable-internal |
3584 sorted-list) | 3584 sorted-list) |
3585 (princ ")") | 3585 (princ ")") |
3586 (unless (looking-at "\n") | 3586 (unless (looking-at "\n") |
3587 (princ "\n"))))) | 3587 (princ "\n"))))) |
3588 | 3588 |
3589 (defvar custom-save-face-ignoring nil) | 3589 (defvar custom-save-face-ignoring nil) |
3590 | 3590 |
3591 (defsubst custom-save-face-p (symbol) | 3591 (defsubst custom-save-face-p (symbol) |
3592 "Return non-nil if SYMBOL is a customized face." | 3592 "Return non-nil if SYMBOL is a customized face." |
3593 (let ((theme-spec (car-safe (get symbol 'theme-face))) | 3593 (let ((theme-spec (car-safe (get symbol 'theme-face))) |
3594 (comment (get symbol 'saved-face-comment))) | 3594 (comment (get symbol 'saved-face-comment))) |
3595 (or (and (not (memq symbol custom-save-face-ignoring)) | 3595 (or (and (not (memq symbol custom-save-face-ignoring)) |
3596 ;; Don't print default face here. | 3596 ;; Don't print default face here. |
3597 (or (and theme-spec | 3597 (or (and theme-spec |
3598 (eq (car theme-spec) 'user) | 3598 (eq (car theme-spec) 'user) |
3599 (eq (second theme-spec) 'set)) | 3599 (eq (second theme-spec) 'set)) |
3600 ;; cope with non-themed faces | 3600 ;; cope with non-themed faces |
3601 (and (null theme-spec) | 3601 (and (null theme-spec) |
3602 (get symbol 'saved-face)))) | 3602 (get symbol 'saved-face)))) |
3603 comment))) | 3603 comment))) |
3604 | 3604 |
3605 (defun custom-save-face-internal (symbol) | 3605 (defun custom-save-face-internal (symbol) |
3606 "Print face SYMBOL to the standard output. | 3606 "Print face SYMBOL to the standard output. |
3607 SYMBOL must be a customized face." | 3607 SYMBOL must be a customized face." |
3608 (let ((comment (get symbol 'saved-face-comment)) | 3608 (let ((comment (get symbol 'saved-face-comment)) |
3609 (now (not (or (get symbol 'face-defface-spec) | 3609 (now (not (or (get symbol 'face-defface-spec) |
3610 (and (not (find-face symbol)) | 3610 (and (not (find-face symbol)) |
3611 (not (eq (get symbol 'force-face) 'rogue)))))) | 3611 (not (eq (get symbol 'force-face) 'rogue)))))) |
3612 ;; Print everything, no placeholders `...' | 3612 ;; Print everything, no placeholders `...' |
3613 (print-level nil) | 3613 (print-level nil) |
3614 (print-length nil)) | 3614 (print-length nil)) |
3615 (if (memq symbol custom-save-face-ignoring) | 3615 (if (memq symbol custom-save-face-ignoring) |
3616 ;; Do nothing | 3616 ;; Do nothing |
3617 nil | 3617 nil |
3618 ;; Print face | 3618 ;; Print face |
3619 (unless (custom-save-face-p symbol) | 3619 (unless (custom-save-face-p symbol) |
3620 (error 'wrong-type-argument "Not a customized face" symbol)) | 3620 (error 'wrong-type-argument "Not a customized face" symbol)) |
3621 (princ "\n '(") | 3621 (princ "\n '(") |
3622 (prin1 symbol) | 3622 (prin1 symbol) |
3623 (princ " ") | 3623 (princ " ") |
3624 (prin1 (get symbol 'saved-face)) | 3624 (prin1 (get symbol 'saved-face)) |
3625 (if (or comment now) | 3625 (if (or comment now) |
3626 (princ (if now " t" " nil"))) | 3626 (princ (if now " t" " nil"))) |
3627 (when comment | 3627 (when comment |
3628 (princ " ") | 3628 (princ " ") |
3629 (prin1 comment)) | 3629 (prin1 comment)) |
3630 (princ ")")))) | 3630 (princ ")")))) |
3631 | 3631 |
3632 (defun custom-save-faces () | 3632 (defun custom-save-faces () |
3633 "Save all customized faces in `custom-file'." | 3633 "Save all customized faces in `custom-file'." |
3634 (save-excursion | 3634 (save-excursion |
3639 ;; a bad behavior <npak@ispras.ru> | 3639 ;; a bad behavior <npak@ispras.ru> |
3640 ;;(custom-save-delete-any 'custom-reset-faces | 3640 ;;(custom-save-delete-any 'custom-reset-faces |
3641 ;; 'custom-set-faces) | 3641 ;; 'custom-set-faces) |
3642 (custom-save-resets 'theme-face 'custom-reset-faces '(default)) | 3642 (custom-save-resets 'theme-face 'custom-reset-faces '(default)) |
3643 (let ((standard-output (current-buffer)) | 3643 (let ((standard-output (current-buffer)) |
3644 (sorted-list ())) | 3644 (sorted-list ())) |
3645 ;; Create a sorted list of faces | 3645 ;; Create a sorted list of faces |
3646 (mapatoms | 3646 (mapatoms |
3647 (lambda (symbol) | 3647 (lambda (symbol) |
3648 (when (custom-save-face-p symbol) | 3648 (when (custom-save-face-p symbol) |
3649 (push symbol sorted-list)))) | 3649 (push symbol sorted-list)))) |
3650 (setq sorted-list (sort sorted-list 'string<)) | 3650 (setq sorted-list (sort sorted-list 'string<)) |
3651 (unless (bolp) | 3651 (unless (bolp) |
3652 (princ "\n")) | 3652 (princ "\n")) |
3653 (princ "(custom-set-faces") | 3653 (princ "(custom-set-faces") |
3654 ;; The default face must be first, since it affects the others. | 3654 ;; The default face must be first, since it affects the others. |
3655 (when (custom-save-face-p 'default) | 3655 (when (custom-save-face-p 'default) |
3656 (custom-save-face-internal 'default)) | 3656 (custom-save-face-internal 'default)) |
3657 (let ((custom-save-face-ignoring '(default))) | 3657 (let ((custom-save-face-ignoring '(default))) |
3658 (mapc 'custom-save-face-internal | 3658 (mapc 'custom-save-face-internal |
3659 sorted-list)) | 3659 sorted-list)) |
3660 (princ ")") | 3660 (princ ")") |
3661 (unless (looking-at "\n") | 3661 (unless (looking-at "\n") |
3662 (princ "\n"))))) | 3662 (princ "\n"))))) |
3663 | 3663 |
3664 (defmacro make-custom-save-resets-mapper (property setter) | 3664 (defmacro make-custom-save-resets-mapper (property setter) |
3665 "Create a mapper for `custom-save-resets'." | 3665 "Create a mapper for `custom-save-resets'." |
3666 `(lambda (object) | 3666 `(lambda (object) |
3667 (let ((spec (car-safe (get object (quote ,property)))) | 3667 (let ((spec (car-safe (get object (quote ,property)))) |
3668 (print-level nil) | 3668 (print-level nil) |
3669 (print-length nil)) | 3669 (print-length nil)) |
3670 (with-boundp '(ignored-special started-writing) | 3670 (with-boundp '(ignored-special started-writing) |
3671 (when (and (not (memq object ignored-special)) | 3671 (when (and (not (memq object ignored-special)) |
3672 (eq (car spec) 'user) | 3672 (eq (car spec) 'user) |
3673 (eq (second spec) 'reset)) | 3673 (eq (second spec) 'reset)) |
3674 ;; Do not write reset statements unless necessary. | 3674 ;; Do not write reset statements unless necessary. |
3675 (unless started-writing | 3675 (unless started-writing |
3676 (setq started-writing t) | 3676 (setq started-writing t) |
3677 (unless (bolp) | 3677 (unless (bolp) |
3678 (princ "\n")) | 3678 (princ "\n")) |
3679 (princ "(") | 3679 (princ "(") |
3680 (princ (quote ,setter)) | 3680 (princ (quote ,setter)) |
3681 (princ "\n '(") | 3681 (princ "\n '(") |
3682 (prin1 object) | 3682 (prin1 object) |
3683 (princ " ") | 3683 (princ " ") |
3684 (prin1 (third spec)) | 3684 (prin1 (third spec)) |
3685 (princ ")"))))))) | 3685 (princ ")"))))))) |
3686 | 3686 |
3687 (defconst custom-save-resets-mapper-alist | 3687 (defconst custom-save-resets-mapper-alist |
3688 (eval-when-compile | 3688 (eval-when-compile |
3689 (list (list 'theme-value 'custom-reset-variables | 3689 (list (list 'theme-value 'custom-reset-variables |
3690 (byte-compile | 3690 (byte-compile |
3691 (make-custom-save-resets-mapper | 3691 (make-custom-save-resets-mapper |
3692 'theme-value 'custom-reset-variables))) | 3692 'theme-value 'custom-reset-variables))) |
3693 (list 'theme-face 'custom-reset-faces | 3693 (list 'theme-face 'custom-reset-faces |
3694 (byte-compile | 3694 (byte-compile |
3695 (make-custom-save-resets-mapper | 3695 (make-custom-save-resets-mapper |
3696 'theme-face 'custom-reset-faces))))) | 3696 'theme-face 'custom-reset-faces))))) |
3697 "Never use it. | 3697 "Never use it. |
3698 Hashes several heavily used functions for `custom-save-resets'") | 3698 Hashes several heavily used functions for `custom-save-resets'") |
3699 | 3699 |
3700 (defun custom-save-resets (property setter special) | 3700 (defun custom-save-resets (property setter special) |
3701 (declare (special ignored-special)) | 3701 (declare (special ignored-special)) |
3702 (let (started-writing ignored-special) | 3702 (let (started-writing ignored-special) |
3703 ;; (custom-save-delete setter) Done by caller | 3703 ;; (custom-save-delete setter) Done by caller |
3704 (let ((standard-output (current-buffer)) | 3704 (let ((standard-output (current-buffer)) |
3705 (mapper (let ((triple (assq property custom-save-resets-mapper-alist))) | 3705 (mapper (let ((triple (assq property custom-save-resets-mapper-alist))) |
3706 (if (and triple (eq (second triple) setter)) | 3706 (if (and triple (eq (second triple) setter)) |
3707 (third triple) | 3707 (third triple) |
3708 (make-custom-save-resets-mapper property setter))))) | 3708 (make-custom-save-resets-mapper property setter))))) |
3709 (mapc mapper special) | 3709 (mapc mapper special) |
3710 (setq ignored-special special) | 3710 (setq ignored-special special) |
3711 (mapatoms mapper) | 3711 (mapatoms mapper) |
3712 (when started-writing | 3712 (when started-writing |
3713 (princ ")\n"))))) | 3713 (princ ")\n"))))) |
3714 | 3714 |
3715 | 3715 |
3716 (defun custom-save-loaded-themes () | 3716 (defun custom-save-loaded-themes () |
3717 (let ((themes (reverse (get 'user 'theme-loads-themes))) | 3717 (let ((themes (reverse (get 'user 'theme-loads-themes))) |
3718 (standard-output (current-buffer)) | 3718 (standard-output (current-buffer)) |
3719 (print-level nil) | 3719 (print-level nil) |
3720 (print-length nil)) | 3720 (print-length nil)) |
3721 (when themes | 3721 (when themes |
3722 (unless (bolp) (princ "\n")) | 3722 (unless (bolp) (princ "\n")) |
3723 (princ "(custom-load-themes") | 3723 (princ "(custom-load-themes") |
3724 (mapc (lambda (theme) | 3724 (mapc (lambda (theme) |
3725 (princ "\n '") | 3725 (princ "\n '") |
3908 Complete content of editable text field. \\[widget-complete] | 3908 Complete content of editable text field. \\[widget-complete] |
3909 \\<custom-mode-map>\ | 3909 \\<custom-mode-map>\ |
3910 Invoke button under point. \\[widget-button-press] | 3910 Invoke button under point. \\[widget-button-press] |
3911 Set all modifications. \\[Custom-set] | 3911 Set all modifications. \\[Custom-set] |
3912 Make all modifications default. \\[Custom-save] | 3912 Make all modifications default. \\[Custom-save] |
3913 Reset all modified options. \\[Custom-reset-current] | 3913 Reset all modified options. \\[Custom-reset-current] |
3914 Reset all modified or set options. \\[Custom-reset-saved] | 3914 Reset all modified or set options. \\[Custom-reset-saved] |
3915 Reset all options. \\[Custom-reset-standard] | 3915 Reset all options. \\[Custom-reset-standard] |
3916 | 3916 |
3917 Entry to this mode calls the value of `custom-mode-hook' | 3917 Entry to this mode calls the value of `custom-mode-hook' |
3918 if that value is non-nil." | 3918 if that value is non-nil." |