diff options
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 11 | ||||
| -rw-r--r-- | lisp/cus-edit.el | 82 | ||||
| -rw-r--r-- | lisp/cus-theme.el | 9 | ||||
| -rw-r--r-- | lisp/custom.el | 9 |
4 files changed, 85 insertions, 26 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9c47091a7aa..f317d650db7 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,14 @@ | |||
| 1 | 2010-10-16 Chong Yidong <cyd@stupidchicken.com> | 1 | 2010-10-16 Chong Yidong <cyd@stupidchicken.com> |
| 2 | 2 | ||
| 3 | * cus-edit.el (custom-variable, custom-face): Combine the | ||
| 4 | :inhibit-magic and :display-style properties into a single | ||
| 5 | :custom-style property. | ||
| 6 | (custom-toggle-hide-variable, custom-toggle-hide-face): New | ||
| 7 | functions. If hiding an edited value, save it to :shown-value. | ||
| 8 | (custom-variable-value-create, custom-face-value-create): Use | ||
| 9 | them. | ||
| 10 | (custom-magic-reset): Allow magic property to be unset. | ||
| 11 | |||
| 3 | * custom.el: Custom themes no longer use load-path. | 12 | * custom.el: Custom themes no longer use load-path. |
| 4 | (custom-theme-load-path): New option. Change built-in theme | 13 | (custom-theme-load-path): New option. Change built-in theme |
| 5 | directory to etc/. | 14 | directory to etc/. |
| @@ -9,6 +18,8 @@ | |||
| 9 | 18 | ||
| 10 | * cus-theme.el (describe-theme-1): Use custom-theme--load-path. | 19 | * cus-theme.el (describe-theme-1): Use custom-theme--load-path. |
| 11 | (customize-themes): Link to custom-theme-load-path variable. | 20 | (customize-themes): Link to custom-theme-load-path variable. |
| 21 | (custom-theme-add-var-1, custom-theme-add-face-1): Use the | ||
| 22 | :custom-style property. | ||
| 12 | 23 | ||
| 13 | * themes/*.el: Moved to etc/. | 24 | * themes/*.el: Moved to etc/. |
| 14 | 25 | ||
diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el index 793b5cccedf..e0a76b21ff8 100644 --- a/lisp/cus-edit.el +++ b/lisp/cus-edit.el | |||
| @@ -2077,7 +2077,8 @@ and `face'." | |||
| 2077 | (defun custom-magic-reset (widget) | 2077 | (defun custom-magic-reset (widget) |
| 2078 | "Redraw the :custom-magic property of WIDGET." | 2078 | "Redraw the :custom-magic property of WIDGET." |
| 2079 | (let ((magic (widget-get widget :custom-magic))) | 2079 | (let ((magic (widget-get widget :custom-magic))) |
| 2080 | (widget-value-set magic (widget-value magic)))) | 2080 | (when magic |
| 2081 | (widget-value-set magic (widget-value magic))))) | ||
| 2081 | 2082 | ||
| 2082 | ;;; The `custom' Widget. | 2083 | ;;; The `custom' Widget. |
| 2083 | 2084 | ||
| @@ -2465,8 +2466,9 @@ The following properties have special meanings for this widget: | |||
| 2465 | :shown-value, if non-nil, should be a list whose `car' is the | 2466 | :shown-value, if non-nil, should be a list whose `car' is the |
| 2466 | variable value to display in place of the current value. | 2467 | variable value to display in place of the current value. |
| 2467 | 2468 | ||
| 2468 | :inhibit-magic, if non-nil, inhibits creating the magic | 2469 | :custom-style describes the widget interface style; nil is the |
| 2469 | custom-state widget." | 2470 | default style, while `simple' means a simpler interface that |
| 2471 | inhibits the magic custom-state widget." | ||
| 2470 | :format "%v" | 2472 | :format "%v" |
| 2471 | :help-echo "Set or reset this variable." | 2473 | :help-echo "Set or reset this variable." |
| 2472 | :documentation-property #'custom-variable-documentation | 2474 | :documentation-property #'custom-variable-documentation |
| @@ -2552,7 +2554,7 @@ try matching its doc string against `custom-guess-doc-alist'." | |||
| 2552 | :on "Hide" | 2554 | :on "Hide" |
| 2553 | :off-image "right" | 2555 | :off-image "right" |
| 2554 | :off "Show Value" | 2556 | :off "Show Value" |
| 2555 | :action 'custom-toggle-parent | 2557 | :action 'custom-toggle-hide-variable |
| 2556 | nil) | 2558 | nil) |
| 2557 | buttons) | 2559 | buttons) |
| 2558 | (insert " ") | 2560 | (insert " ") |
| @@ -2572,7 +2574,7 @@ try matching its doc string against `custom-guess-doc-alist'." | |||
| 2572 | :off "Show" | 2574 | :off "Show" |
| 2573 | :on-image "down" | 2575 | :on-image "down" |
| 2574 | :off-image "right" | 2576 | :off-image "right" |
| 2575 | :action 'custom-toggle-parent | 2577 | :action 'custom-toggle-hide-variable |
| 2576 | t) | 2578 | t) |
| 2577 | buttons) | 2579 | buttons) |
| 2578 | (insert " ") | 2580 | (insert " ") |
| @@ -2602,7 +2604,7 @@ try matching its doc string against `custom-guess-doc-alist'." | |||
| 2602 | :off "Show" | 2604 | :off "Show" |
| 2603 | :on-image "down" | 2605 | :on-image "down" |
| 2604 | :off-image "right" | 2606 | :off-image "right" |
| 2605 | :action 'custom-toggle-parent | 2607 | :action 'custom-toggle-hide-variable |
| 2606 | t) | 2608 | t) |
| 2607 | buttons) | 2609 | buttons) |
| 2608 | (insert " ") | 2610 | (insert " ") |
| @@ -2631,7 +2633,7 @@ try matching its doc string against `custom-guess-doc-alist'." | |||
| 2631 | (unless (eq (preceding-char) ?\n) | 2633 | (unless (eq (preceding-char) ?\n) |
| 2632 | (widget-insert "\n")) | 2634 | (widget-insert "\n")) |
| 2633 | ;; Create the magic button. | 2635 | ;; Create the magic button. |
| 2634 | (unless (widget-get widget :inhibit-magic) | 2636 | (unless (eq (widget-get widget :custom-style) 'simple) |
| 2635 | (let ((magic (widget-create-child-and-convert | 2637 | (let ((magic (widget-create-child-and-convert |
| 2636 | widget 'custom-magic nil))) | 2638 | widget 'custom-magic nil))) |
| 2637 | (widget-put widget :custom-magic magic) | 2639 | (widget-put widget :custom-magic magic) |
| @@ -2667,6 +2669,31 @@ try matching its doc string against `custom-guess-doc-alist'." | |||
| 2667 | (custom-add-parent-links widget)) | 2669 | (custom-add-parent-links widget)) |
| 2668 | (custom-add-see-also widget))))) | 2670 | (custom-add-see-also widget))))) |
| 2669 | 2671 | ||
| 2672 | (defun custom-toggle-hide-variable (visibility-widget &rest ignore) | ||
| 2673 | "Toggle the visibility of a `custom-variable' parent widget. | ||
| 2674 | By default, this signals an error if the parent has unsaved | ||
| 2675 | changes. If the parent has a `simple' :custom-style property, | ||
| 2676 | the present value is saved to its :shown-value property instead." | ||
| 2677 | (let ((widget (widget-get visibility-widget :parent))) | ||
| 2678 | (unless (eq (widget-type widget) 'custom-variable) | ||
| 2679 | (error "Invalid widget type")) | ||
| 2680 | (custom-load-widget widget) | ||
| 2681 | (let ((state (widget-get widget :custom-state))) | ||
| 2682 | (if (eq state 'hidden) | ||
| 2683 | (widget-put widget :custom-state 'unknown) | ||
| 2684 | ;; In normal interface, widget can't be hidden if modified. | ||
| 2685 | (when (memq state '(invalid modified set)) | ||
| 2686 | (if (eq (widget-get widget :custom-style) 'simple) | ||
| 2687 | (widget-put widget :shown-value | ||
| 2688 | (list (widget-value | ||
| 2689 | (car-safe | ||
| 2690 | (widget-get widget :children))))) | ||
| 2691 | (error "There are unsaved changes"))) | ||
| 2692 | (widget-put widget :documentation-shown nil) | ||
| 2693 | (widget-put widget :custom-state 'hidden)) | ||
| 2694 | (custom-redraw widget) | ||
| 2695 | (widget-setup)))) | ||
| 2696 | |||
| 2670 | (defun custom-tag-action (widget &rest args) | 2697 | (defun custom-tag-action (widget &rest args) |
| 2671 | "Pass :action to first child of WIDGET's parent." | 2698 | "Pass :action to first child of WIDGET's parent." |
| 2672 | (apply 'widget-apply (car (widget-get (widget-get widget :parent) :children)) | 2699 | (apply 'widget-apply (car (widget-get (widget-get widget :parent) :children)) |
| @@ -3291,17 +3318,15 @@ The following properties have special meanings for this widget: | |||
| 3291 | Lisp sexp), or `mismatch' (should not happen); if nil, use | 3318 | Lisp sexp), or `mismatch' (should not happen); if nil, use |
| 3292 | the return value of `custom-face-default-form'. | 3319 | the return value of `custom-face-default-form'. |
| 3293 | 3320 | ||
| 3294 | :display-style, if non-nil, describes the style of display to | 3321 | :custom-style describes the widget interface style; nil is the |
| 3295 | use. If the value is `concise', a neater interface is shown. | 3322 | default style, while `simple' means a simpler interface that |
| 3323 | inhibits the magic custom-state widget. | ||
| 3296 | 3324 | ||
| 3297 | :sample-indent, if non-nil, is the number of columns to which to | 3325 | :sample-indent, if non-nil, is the number of columns to which to |
| 3298 | indent the face sample (an integer). | 3326 | indent the face sample (an integer). |
| 3299 | 3327 | ||
| 3300 | :shown-value, if non-nil, is the face spec to display as the value | 3328 | :shown-value, if non-nil, is the face spec to display as the value |
| 3301 | of the widget, instead of the current face spec. | 3329 | of the widget, instead of the current face spec." |
| 3302 | |||
| 3303 | :inhibit-magic, if non-nil, inhibits creating the magic | ||
| 3304 | custom-state widget." | ||
| 3305 | :sample-face 'custom-face-tag | 3330 | :sample-face 'custom-face-tag |
| 3306 | :help-echo "Set or reset this face." | 3331 | :help-echo "Set or reset this face." |
| 3307 | :documentation-property #'face-doc-string | 3332 | :documentation-property #'face-doc-string |
| @@ -3395,6 +3420,29 @@ WIDGET should be a `custom-face' widget." | |||
| 3395 | (setq spec `((t ,(face-attr-construct face (selected-frame)))))) | 3420 | (setq spec `((t ,(face-attr-construct face (selected-frame)))))) |
| 3396 | (custom-pre-filter-face-spec spec))) | 3421 | (custom-pre-filter-face-spec spec))) |
| 3397 | 3422 | ||
| 3423 | (defun custom-toggle-hide-face (visibility-widget &rest ignore) | ||
| 3424 | "Toggle the visibility of a `custom-face' parent widget. | ||
| 3425 | By default, this signals an error if the parent has unsaved | ||
| 3426 | changes. If the parent has a `simple' :custom-style property, | ||
| 3427 | the present value is saved to its :shown-value property instead." | ||
| 3428 | (let ((widget (widget-get visibility-widget :parent))) | ||
| 3429 | (unless (eq (widget-type widget) 'custom-face) | ||
| 3430 | (error "Invalid widget type")) | ||
| 3431 | (custom-load-widget widget) | ||
| 3432 | (let ((state (widget-get widget :custom-state))) | ||
| 3433 | (if (eq state 'hidden) | ||
| 3434 | (widget-put widget :custom-state 'unknown) | ||
| 3435 | ;; In normal interface, widget can't be hidden if modified. | ||
| 3436 | (when (memq state '(invalid modified set)) | ||
| 3437 | (if (eq (widget-get widget :custom-style) 'simple) | ||
| 3438 | (widget-put widget :shown-value | ||
| 3439 | (custom-face-widget-to-spec widget)) | ||
| 3440 | (error "There are unsaved changes"))) | ||
| 3441 | (widget-put widget :documentation-shown nil) | ||
| 3442 | (widget-put widget :custom-state 'hidden)) | ||
| 3443 | (custom-redraw widget) | ||
| 3444 | (widget-setup)))) | ||
| 3445 | |||
| 3398 | (defun custom-face-value-create (widget) | 3446 | (defun custom-face-value-create (widget) |
| 3399 | "Create a list of the display specifications for WIDGET." | 3447 | "Create a list of the display specifications for WIDGET." |
| 3400 | (let* ((buttons (widget-get widget :buttons)) | 3448 | (let* ((buttons (widget-get widget :buttons)) |
| @@ -3402,7 +3450,7 @@ WIDGET should be a `custom-face' widget." | |||
| 3402 | (tag (or (widget-get widget :tag) | 3450 | (tag (or (widget-get widget :tag) |
| 3403 | (prin1-to-string symbol))) | 3451 | (prin1-to-string symbol))) |
| 3404 | (hiddenp (eq (widget-get widget :custom-state) 'hidden)) | 3452 | (hiddenp (eq (widget-get widget :custom-state) 'hidden)) |
| 3405 | (style (widget-get widget :display-style)) | 3453 | (style (widget-get widget :custom-style)) |
| 3406 | children) | 3454 | children) |
| 3407 | 3455 | ||
| 3408 | (if (eq custom-buffer-style 'tree) | 3456 | (if (eq custom-buffer-style 'tree) |
| @@ -3425,7 +3473,7 @@ WIDGET should be a `custom-face' widget." | |||
| 3425 | :help-echo "Hide or show this face." | 3473 | :help-echo "Hide or show this face." |
| 3426 | :on "Hide" :off "Show" | 3474 | :on "Hide" :off "Show" |
| 3427 | :on-image "down" :off-image "right" | 3475 | :on-image "down" :off-image "right" |
| 3428 | :action 'custom-toggle-parent | 3476 | :action 'custom-toggle-hide-face |
| 3429 | (not hiddenp)) | 3477 | (not hiddenp)) |
| 3430 | buttons) | 3478 | buttons) |
| 3431 | ;; Face name (tag). | 3479 | ;; Face name (tag). |
| @@ -3452,7 +3500,7 @@ WIDGET should be a `custom-face' widget." | |||
| 3452 | (insert "\n") | 3500 | (insert "\n") |
| 3453 | 3501 | ||
| 3454 | ;; Magic. | 3502 | ;; Magic. |
| 3455 | (unless (widget-get widget :inhibit-magic) | 3503 | (unless (eq (widget-get widget :custom-style) 'simple) |
| 3456 | (let ((magic (widget-create-child-and-convert | 3504 | (let ((magic (widget-create-child-and-convert |
| 3457 | widget 'custom-magic nil))) | 3505 | widget 'custom-magic nil))) |
| 3458 | (widget-put widget :custom-magic magic) | 3506 | (widget-put widget :custom-magic magic) |
| @@ -3462,7 +3510,7 @@ WIDGET should be a `custom-face' widget." | |||
| 3462 | (widget-put widget :buttons buttons) | 3510 | (widget-put widget :buttons buttons) |
| 3463 | 3511 | ||
| 3464 | ;; Insert documentation. | 3512 | ;; Insert documentation. |
| 3465 | (unless (and hiddenp (eq style 'concise)) | 3513 | (unless (and hiddenp (eq style 'simple)) |
| 3466 | (widget-put widget :documentation-indent 3) | 3514 | (widget-put widget :documentation-indent 3) |
| 3467 | (widget-add-documentation-string-button | 3515 | (widget-add-documentation-string-button |
| 3468 | widget :visibility-widget 'custom-visibility) | 3516 | widget :visibility-widget 'custom-visibility) |
diff --git a/lisp/cus-theme.el b/lisp/cus-theme.el index 34a03539719..4295fa75206 100644 --- a/lisp/cus-theme.el +++ b/lisp/cus-theme.el | |||
| @@ -41,7 +41,7 @@ | |||
| 41 | map) | 41 | map) |
| 42 | "Keymap for `custom-new-theme-mode'.") | 42 | "Keymap for `custom-new-theme-mode'.") |
| 43 | 43 | ||
| 44 | (define-derived-mode custom-new-theme-mode nil "Cus-Theme" | 44 | (define-derived-mode custom-new-theme-mode nil "Custom-Theme" |
| 45 | "Major mode for editing Custom themes. | 45 | "Major mode for editing Custom themes. |
| 46 | Do not call this mode function yourself. It is meant for internal use." | 46 | Do not call this mode function yourself. It is meant for internal use." |
| 47 | (use-local-map custom-new-theme-mode-map) | 47 | (use-local-map custom-new-theme-mode-map) |
| @@ -214,7 +214,7 @@ interactively, this defaults to the current value of VAR." | |||
| 214 | :notify 'ignore | 214 | :notify 'ignore |
| 215 | :custom-level 0 | 215 | :custom-level 0 |
| 216 | :custom-state 'hidden | 216 | :custom-state 'hidden |
| 217 | :inhibit-magic t)) | 217 | :custom-style 'simple)) |
| 218 | custom-theme-variables) | 218 | custom-theme-variables) |
| 219 | (widget-insert " ")) | 219 | (widget-insert " ")) |
| 220 | 220 | ||
| @@ -250,9 +250,8 @@ SPEC, if non-nil, should be a face spec to which to set the widget." | |||
| 250 | :documentation-shown t | 250 | :documentation-shown t |
| 251 | :value symbol | 251 | :value symbol |
| 252 | :custom-state 'hidden | 252 | :custom-state 'hidden |
| 253 | :display-style 'concise | 253 | :custom-style 'simple |
| 254 | :shown-value spec | 254 | :shown-value spec |
| 255 | :inhibit-magic t | ||
| 256 | :sample-indent 34)) | 255 | :sample-indent 34)) |
| 257 | custom-theme-faces) | 256 | custom-theme-faces) |
| 258 | (widget-insert " ")) | 257 | (widget-insert " ")) |
| @@ -476,7 +475,7 @@ It includes all faces in list FACES." | |||
| 476 | map) | 475 | map) |
| 477 | "Keymap for `custom-theme-choose-mode'.") | 476 | "Keymap for `custom-theme-choose-mode'.") |
| 478 | 477 | ||
| 479 | (define-derived-mode custom-theme-choose-mode nil "Cus-Theme" | 478 | (define-derived-mode custom-theme-choose-mode nil "Themes" |
| 480 | "Major mode for selecting Custom themes. | 479 | "Major mode for selecting Custom themes. |
| 481 | Do not call this mode function yourself. It is meant for internal use." | 480 | Do not call this mode function yourself. It is meant for internal use." |
| 482 | (use-local-map custom-theme-choose-mode-map) | 481 | (use-local-map custom-theme-choose-mode-map) |
diff --git a/lisp/custom.el b/lisp/custom.el index 8ece438065f..738b9c6bc8d 100644 --- a/lisp/custom.el +++ b/lisp/custom.el | |||
| @@ -1066,10 +1066,11 @@ directory first---see `custom-theme-load-path'." | |||
| 1066 | Emacs commands for loading custom themes (e.g. `customize-themes' | 1066 | Emacs commands for loading custom themes (e.g. `customize-themes' |
| 1067 | and `load-theme') search for custom theme files in the specified | 1067 | and `load-theme') search for custom theme files in the specified |
| 1068 | order. Each element in the list should be one of the following: | 1068 | order. Each element in the list should be one of the following: |
| 1069 | \(i) the symbol `custom-theme-directory', which means the value | 1069 | - the symbol `custom-theme-directory', meaning the value of |
| 1070 | of that variable; (ii) the symbol t (the built-in Emacs theme | 1070 | `custom-theme-directory'. |
| 1071 | directory, named \"themes\" in `data-directory'); or \(iii) a | 1071 | - the symbol t, meaning the built-in theme directory (a directory |
| 1072 | directory name (a string)." | 1072 | named \"themes\" in `data-directory'). |
| 1073 | - a directory name (a string)." | ||
| 1073 | :type '(repeat (choice (const :tag "custom-theme-directory" | 1074 | :type '(repeat (choice (const :tag "custom-theme-directory" |
| 1074 | custom-theme-directory) | 1075 | custom-theme-directory) |
| 1075 | (const :tag "Built-in theme directory" t) | 1076 | (const :tag "Built-in theme directory" t) |