Mercurial > emacs
comparison lisp/wid-edit.el @ 110870:7a9a2861c2c2
More face customization cleanups.
* cus-edit.el (custom-commands, custom-buffer-create-internal)
(custom-magic-value-create): Pad button tags with spaces.
(custom-face-edit): New variable.
(custom-face-value-create): Determine whether to use the usual
face editor here, instead of using custom-face-selected. Pass
face defaults to custom-face-edit widget.
(custom-face-selected, custom-display-unselected): Delete widgets.
(custom-display-unselected-match): Function removed.
(custom-face-set, custom-face-mark-to-save): Accept
custom-face-edit widgets as the direct widget child.
* wid-edit.el (widget--completing-widget): New var.
(widget-default-complete): Bind it when doing completion.
(widget-string-complete, widget-file-complete): Use it.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Fri, 08 Oct 2010 23:23:38 -0400 |
parents | 4d1b1a2c88c6 |
children | ccdc694ce7bd |
comparison
equal
deleted
inserted
replaced
110869:3684139b9255 | 110870:7a9a2861c2c2 |
---|---|
54 ;;; Commentary: | 54 ;;; Commentary: |
55 ;; | 55 ;; |
56 ;; See `widget.el'. | 56 ;; See `widget.el'. |
57 | 57 |
58 ;;; Code: | 58 ;;; Code: |
59 | |
60 (defvar widget) | |
61 | 59 |
62 ;;; Compatibility. | 60 ;;; Compatibility. |
63 | 61 |
64 (defun widget-event-point (event) | 62 (defun widget-event-point (event) |
65 "Character position of the end of event if that exists, or nil." | 63 "Character position of the end of event if that exists, or nil." |
1460 :mouse-down-action #'ignore | 1458 :mouse-down-action #'ignore |
1461 :action 'widget-default-action | 1459 :action 'widget-default-action |
1462 :notify 'widget-default-notify | 1460 :notify 'widget-default-notify |
1463 :prompt-value 'widget-default-prompt-value) | 1461 :prompt-value 'widget-default-prompt-value) |
1464 | 1462 |
1463 (defvar widget--completing-widget) | |
1464 | |
1465 (defun widget-default-complete (widget) | 1465 (defun widget-default-complete (widget) |
1466 "Call the value of the :complete-function property of WIDGET. | 1466 "Call the value of the :complete-function property of WIDGET. |
1467 If that does not exist, call the value of `widget-complete-field'." | 1467 If that does not exist, call the value of `widget-complete-field'. |
1468 (call-interactively (or (widget-get widget :complete-function) | 1468 During this call, `widget--completing-widget' is bound to WIDGET." |
1469 widget-complete-field))) | 1469 (let ((widget--completing-widget widget)) |
1470 (call-interactively (or (widget-get widget :complete-function) | |
1471 widget-complete-field)))) | |
1470 | 1472 |
1471 (defun widget-default-create (widget) | 1473 (defun widget-default-create (widget) |
1472 "Create WIDGET at point in the current buffer." | 1474 "Create WIDGET at point in the current buffer." |
1473 (widget-specify-insert | 1475 (widget-specify-insert |
1474 (let ((from (point)) | 1476 (let ((from (point)) |
3046 :tag "String" | 3048 :tag "String" |
3047 :format "%{%t%}: %v" | 3049 :format "%{%t%}: %v" |
3048 :complete-function 'ispell-complete-word | 3050 :complete-function 'ispell-complete-word |
3049 :prompt-history 'widget-string-prompt-value-history) | 3051 :prompt-history 'widget-string-prompt-value-history) |
3050 | 3052 |
3051 (defvar widget) | |
3052 | |
3053 (defun widget-string-complete () | 3053 (defun widget-string-complete () |
3054 "Complete contents of string field. | 3054 "Complete contents of string field. |
3055 Completions are taken from the :completion-alist property of the | 3055 Completions are taken from the :completion-alist property of the |
3056 widget. If that isn't a list, it's evalled and expected to yield a list." | 3056 widget. If that isn't a list, it's evalled and expected to yield a list." |
3057 (interactive) | 3057 (interactive) |
3058 (let* ((completion-ignore-case (widget-get widget :completion-ignore-case)) | 3058 (let* ((widget widget--completing-widget) |
3059 (completion-ignore-case (widget-get widget :completion-ignore-case)) | |
3059 (alist (widget-get widget :completion-alist)) | 3060 (alist (widget-get widget :completion-alist)) |
3060 (_ (unless (listp alist) | 3061 (_ (unless (listp alist) |
3061 (setq alist (eval alist))))) | 3062 (setq alist (eval alist))))) |
3062 (completion-in-region (widget-field-start widget) | 3063 (completion-in-region (widget-field-start widget) |
3063 (max (point) (widget-field-text-end widget)) | 3064 (max (point) (widget-field-text-end widget)) |
3098 :tag "File") | 3099 :tag "File") |
3099 | 3100 |
3100 (defun widget-file-complete () | 3101 (defun widget-file-complete () |
3101 "Perform completion on file name preceding point." | 3102 "Perform completion on file name preceding point." |
3102 (interactive) | 3103 (interactive) |
3103 (completion-in-region (widget-field-start widget) | 3104 (let ((widget widget--completing-widget)) |
3104 (max (point) (widget-field-text-end widget)) | 3105 (completion-in-region (widget-field-start widget) |
3105 'completion-file-name-table)) | 3106 (max (point) (widget-field-text-end widget)) |
3107 'completion-file-name-table))) | |
3106 | 3108 |
3107 (defun widget-file-prompt-value (widget prompt value unbound) | 3109 (defun widget-file-prompt-value (widget prompt value unbound) |
3108 ;; Read file from minibuffer. | 3110 ;; Read file from minibuffer. |
3109 (abbreviate-file-name | 3111 (abbreviate-file-name |
3110 (if unbound | 3112 (if unbound |
3723 (defun widget-color-value-create (widget) | 3725 (defun widget-color-value-create (widget) |
3724 (widget-field-value-create widget) | 3726 (widget-field-value-create widget) |
3725 (widget-insert " ") | 3727 (widget-insert " ") |
3726 (widget-create-child-and-convert | 3728 (widget-create-child-and-convert |
3727 widget 'push-button | 3729 widget 'push-button |
3728 :tag "Choose" :action 'widget-color--choose-action) | 3730 :tag " Choose " :action 'widget-color--choose-action) |
3729 (widget-insert " ")) | 3731 (widget-insert " ")) |
3730 | 3732 |
3731 (defun widget-color--choose-action (widget &optional event) | 3733 (defun widget-color--choose-action (widget &optional event) |
3732 (list-colors-display | 3734 (list-colors-display |
3733 nil nil | 3735 nil nil |