Mercurial > emacs
comparison lisp/cus-edit.el @ 46408:ccaa90ab16a3
New operation :custom-standard-value.
(Custom-reset-standard): Use it.
(custom-variable, custom-face): Define it.
(custom-variable-standard-value, custom-face-standard-value): New fns.
(custom-face-save): Don't save a face whose value is standard.
(custom-save-faces): Use SYMBOL, not 'default, to set NOW and COMMENT.
(custom-face-edit-fix-value): If VALUE is not a list, pass it thru.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 16 Jul 2002 13:37:21 +0000 |
parents | abb237aa3c61 |
children | 2c25b46baf82 |
comparison
equal
deleted
inserted
replaced
46407:4c4398249108 | 46408:ccaa90ab16a3 |
---|---|
696 This operation eliminates any saved settings for the group members, | 696 This operation eliminates any saved settings for the group members, |
697 making them as if they had never been customized at all." | 697 making them as if they had never been customized at all." |
698 (interactive) | 698 (interactive) |
699 (let ((children custom-options)) | 699 (let ((children custom-options)) |
700 (mapc (lambda (widget) | 700 (mapc (lambda (widget) |
701 (and (get (widget-value widget) 'standard-value) | 701 (and (widget-apply widget :custom-standard-value) |
702 (if (memq (widget-get widget :custom-state) | 702 (if (memq (widget-get widget :custom-state) |
703 '(modified set changed saved rogue)) | 703 '(modified set changed saved rogue)) |
704 (widget-apply widget :custom-reset-standard)))) | 704 (widget-apply widget :custom-reset-standard)))) |
705 children))) | 705 children))) |
706 | 706 |
2049 :action 'custom-variable-action | 2049 :action 'custom-variable-action |
2050 :custom-set 'custom-variable-set | 2050 :custom-set 'custom-variable-set |
2051 :custom-save 'custom-variable-save | 2051 :custom-save 'custom-variable-save |
2052 :custom-reset-current 'custom-redraw | 2052 :custom-reset-current 'custom-redraw |
2053 :custom-reset-saved 'custom-variable-reset-saved | 2053 :custom-reset-saved 'custom-variable-reset-saved |
2054 :custom-reset-standard 'custom-variable-reset-standard) | 2054 :custom-reset-standard 'custom-variable-reset-standard |
2055 :custom-standard-value 'custom-variable-standard-value) | |
2055 | 2056 |
2056 (defun custom-variable-type (symbol) | 2057 (defun custom-variable-type (symbol) |
2057 "Return a widget suitable for editing the value of SYMBOL. | 2058 "Return a widget suitable for editing the value of SYMBOL. |
2058 If SYMBOL has a `custom-type' property, use that. | 2059 If SYMBOL has a `custom-type' property, use that. |
2059 Otherwise, look up symbol in `custom-guess-type-alist'." | 2060 Otherwise, look up symbol in `custom-guess-type-alist'." |
2267 'standard | 2268 'standard |
2268 'changed)) | 2269 'changed)) |
2269 (t 'rogue)))) | 2270 (t 'rogue)))) |
2270 (widget-put widget :custom-state state))) | 2271 (widget-put widget :custom-state state))) |
2271 | 2272 |
2273 (defun custom-variable-standard-value (widget) | |
2274 (get (widget-value widget) 'standard-value)) | |
2275 | |
2272 (defvar custom-variable-menu | 2276 (defvar custom-variable-menu |
2273 '(("Set for Current Session" custom-variable-set | 2277 '(("Set for Current Session" custom-variable-set |
2274 (lambda (widget) | 2278 (lambda (widget) |
2275 (eq (widget-get widget :custom-state) 'modified))) | 2279 (eq (widget-get widget :custom-state) 'modified))) |
2276 ("Save for Future Sessions" custom-variable-save | 2280 ("Save for Future Sessions" custom-variable-save |
2473 (nth 1 att))) | 2477 (nth 1 att))) |
2474 custom-face-attributes)) | 2478 custom-face-attributes)) |
2475 | 2479 |
2476 (defun custom-face-edit-fix-value (widget value) | 2480 (defun custom-face-edit-fix-value (widget value) |
2477 "Ignoring WIDGET, convert :bold and :italic in VALUE to new form." | 2481 "Ignoring WIDGET, convert :bold and :italic in VALUE to new form." |
2478 (let (result) | 2482 (if (listp value) |
2479 (while value | 2483 (let (result) |
2480 (let ((key (car value)) | 2484 (while value |
2481 (val (car (cdr value)))) | 2485 (let ((key (car value)) |
2482 (cond ((eq key :italic) | 2486 (val (car (cdr value)))) |
2483 (push :slant result) | 2487 (cond ((eq key :italic) |
2484 (push (if val 'italic 'normal) result)) | 2488 (push :slant result) |
2485 ((eq key :bold) | 2489 (push (if val 'italic 'normal) result)) |
2486 (push :weight result) | 2490 ((eq key :bold) |
2487 (push (if val 'bold 'normal) result)) | 2491 (push :weight result) |
2488 (t | 2492 (push (if val 'bold 'normal) result)) |
2489 (push key result) | 2493 (t |
2490 (push val result)))) | 2494 (push key result) |
2491 (setq value (cdr (cdr value)))) | 2495 (push val result)))) |
2492 (setq result (nreverse result)) | 2496 (setq value (cdr (cdr value)))) |
2493 result)) | 2497 (setq result (nreverse result)) |
2498 result) | |
2499 value)) | |
2494 | 2500 |
2495 (defun custom-face-edit-convert-widget (widget) | 2501 (defun custom-face-edit-convert-widget (widget) |
2496 "Convert :args as widget types in WIDGET." | 2502 "Convert :args as widget types in WIDGET." |
2497 (widget-put | 2503 (widget-put |
2498 widget | 2504 widget |
2660 :custom-set 'custom-face-set | 2666 :custom-set 'custom-face-set |
2661 :custom-save 'custom-face-save | 2667 :custom-save 'custom-face-save |
2662 :custom-reset-current 'custom-redraw | 2668 :custom-reset-current 'custom-redraw |
2663 :custom-reset-saved 'custom-face-reset-saved | 2669 :custom-reset-saved 'custom-face-reset-saved |
2664 :custom-reset-standard 'custom-face-reset-standard | 2670 :custom-reset-standard 'custom-face-reset-standard |
2671 :custom-standard-value 'custom-face-standard-value | |
2665 :custom-menu 'custom-face-menu-create) | 2672 :custom-menu 'custom-face-menu-create) |
2666 | 2673 |
2667 (define-widget 'custom-face-all 'editable-list | 2674 (define-widget 'custom-face-all 'editable-list |
2668 "An editable list of display specifications and attributes." | 2675 "An editable list of display specifications and attributes." |
2669 :entry-format "%i %d %v" | 2676 :entry-format "%i %d %v" |
2977 (if (face-spec-choose value) | 2984 (if (face-spec-choose value) |
2978 (face-spec-set symbol value) | 2985 (face-spec-set symbol value) |
2979 ;; face-set-spec ignores empty attribute lists, so just give it | 2986 ;; face-set-spec ignores empty attribute lists, so just give it |
2980 ;; something harmless instead. | 2987 ;; something harmless instead. |
2981 (face-spec-set symbol '((t :foreground unspecified)))) | 2988 (face-spec-set symbol '((t :foreground unspecified)))) |
2982 (put symbol 'saved-face value) | 2989 (unless (eq (widget-get widget :custom-state) 'standard) |
2990 (put symbol 'saved-face value)) | |
2983 (put symbol 'customized-face nil) | 2991 (put symbol 'customized-face nil) |
2984 (put symbol 'face-comment comment) | 2992 (put symbol 'face-comment comment) |
2985 (put symbol 'customized-face-comment nil) | 2993 (put symbol 'customized-face-comment nil) |
2986 (put symbol 'saved-face-comment comment) | 2994 (put symbol 'saved-face-comment comment) |
2987 (custom-save-all) | 2995 (custom-save-all) |
3004 (widget-value-set child value) | 3012 (widget-value-set child value) |
3005 ;; This call manages the comment visibility | 3013 ;; This call manages the comment visibility |
3006 (widget-value-set comment-widget (or comment "")) | 3014 (widget-value-set comment-widget (or comment "")) |
3007 (custom-face-state-set widget) | 3015 (custom-face-state-set widget) |
3008 (custom-redraw-magic widget))) | 3016 (custom-redraw-magic widget))) |
3017 | |
3018 (defun custom-face-standard-value (widget) | |
3019 (get (widget-value widget) 'face-defface-spec)) | |
3009 | 3020 |
3010 (defun custom-face-reset-standard (widget) | 3021 (defun custom-face-reset-standard (widget) |
3011 "Restore WIDGET to the face's standard settings. | 3022 "Restore WIDGET to the face's standard settings. |
3012 This operation eliminates any saved setting for the face, | 3023 This operation eliminates any saved setting for the face, |
3013 restoring it to the state of a face that has never been customized." | 3024 restoring it to the state of a face that has never been customized." |
3679 ;; custom-set-faces was added by Custom -- don't edit or cut/paste it! | 3690 ;; custom-set-faces was added by Custom -- don't edit or cut/paste it! |
3680 ;; Your init file should contain only one such instance.\n") | 3691 ;; Your init file should contain only one such instance.\n") |
3681 (mapcar | 3692 (mapcar |
3682 (lambda (symbol) | 3693 (lambda (symbol) |
3683 (let ((value (get symbol 'saved-face)) | 3694 (let ((value (get symbol 'saved-face)) |
3684 (now (not (or (get 'default 'face-defface-spec) | 3695 (now (not (or (get symbol 'face-defface-spec) |
3685 (and (not (custom-facep 'default)) | 3696 (and (not (custom-facep symbol)) |
3686 (not (get 'default 'force-face)))))) | 3697 (not (get symbol 'force-face)))))) |
3687 (comment (get 'default 'saved-face-comment))) | 3698 (comment (get symbol 'saved-face-comment))) |
3688 (unless (eq symbol 'default)) | |
3689 ;; Don't print default face here. | 3699 ;; Don't print default face here. |
3690 (unless (bolp) | 3700 (unless (bolp) |
3691 (princ "\n")) | 3701 (princ "\n")) |
3692 (princ " '(") | 3702 (princ " '(") |
3693 (prin1 symbol) | 3703 (prin1 symbol) |