comparison lisp/wid-edit.el @ 89483:2f877ed80fa6

*** empty log message ***
author Kenichi Handa <handa@m17n.org>
date Mon, 08 Sep 2003 12:53:41 +0000
parents 375f2633d815 49f9e4204d1b
children 68c22ea6027c
comparison
equal deleted inserted replaced
88123:375f2633d815 89483:2f877ed80fa6
2888 :tag "String" 2888 :tag "String"
2889 :format "%{%t%}: %v" 2889 :format "%{%t%}: %v"
2890 :complete-function 'ispell-complete-word 2890 :complete-function 'ispell-complete-word
2891 :prompt-history 'widget-string-prompt-value-history) 2891 :prompt-history 'widget-string-prompt-value-history)
2892 2892
2893 (eval-when-compile (defvar widget))
2894
2895 (defun widget-string-complete ()
2896 "Complete contents of string field.
2897 Completions are taken from the :completion-alist property of the
2898 widget. If that isn't a list, it's evalled and expected to yield a list."
2899 (interactive)
2900 (let* ((prefix (buffer-substring-no-properties (widget-field-start widget)
2901 (point)))
2902 (completion-ignore-case (widget-get widget :completion-ignore-case))
2903 (alist (widget-get widget :completion-alist))
2904 (_ (unless (listp alist)
2905 (setq alist (eval alist))))
2906 (completion (try-completion prefix alist)))
2907 (cond ((eq completion t)
2908 (when completion-ignore-case
2909 ;; Replace field with completion in case its case is different.
2910 (delete-region (widget-field-start widget)
2911 (widget-field-end widget))
2912 (insert-and-inherit (car (assoc-ignore-case prefix alist))))
2913 (message "Only match"))
2914 ((null completion)
2915 (error "No match"))
2916 ((not (eq t (compare-strings prefix nil nil completion nil nil
2917 completion-ignore-case)))
2918 (when completion-ignore-case
2919 ;; Replace field with completion in case its case is different.
2920 (delete-region (widget-field-start widget)
2921 (widget-field-end widget))
2922 (insert-and-inherit completion)))
2923 (t
2924 (message "Making completion list...")
2925 (with-output-to-temp-buffer "*Completions*"
2926 (display-completion-list
2927 (all-completions prefix alist nil)))
2928 (message "Making completion list...done")))))
2929
2893 (define-widget 'regexp 'string 2930 (define-widget 'regexp 'string
2894 "A regular expression." 2931 "A regular expression."
2895 :match 'widget-regexp-match 2932 :match 'widget-regexp-match
2896 :validate 'widget-regexp-validate 2933 :validate 'widget-regexp-validate
2897 ;; Doesn't work well with terminating newline. 2934 ;; Doesn't work well with terminating newline.
3044 :complete-function (lambda () 3081 :complete-function (lambda ()
3045 (interactive) 3082 (interactive)
3046 (lisp-complete-symbol 'boundp)) 3083 (lisp-complete-symbol 'boundp))
3047 :tag "Variable") 3084 :tag "Variable")
3048 3085
3049 (defvar widget-coding-system-prompt-value-history nil
3050 "History of input to `widget-coding-system-prompt-value'.")
3051
3052 (define-widget 'coding-system 'symbol 3086 (define-widget 'coding-system 'symbol
3053 "A MULE coding-system." 3087 "A MULE coding-system."
3054 :format "%{%t%}: %v" 3088 :format "%{%t%}: %v"
3055 :tag "Coding system" 3089 :tag "Coding system"
3056 :base-only nil 3090 :base-only nil
3057 :prompt-history 'widget-coding-system-prompt-value-history 3091 :prompt-history 'coding-system-value-history
3058 :prompt-value 'widget-coding-system-prompt-value 3092 :prompt-value 'widget-coding-system-prompt-value
3059 :action 'widget-coding-system-action 3093 :action 'widget-coding-system-action
3060 :complete-function (lambda () 3094 :complete-function (lambda ()
3061 (interactive) 3095 (interactive)
3062 (lisp-complete-symbol 'coding-system-p)) 3096 (lisp-complete-symbol 'coding-system-p))
3212 :value-to-external (lambda (widget value) 3246 :value-to-external (lambda (widget value)
3213 (if (stringp value) 3247 (if (stringp value)
3214 (aref value 0) 3248 (aref value 0)
3215 value)) 3249 value))
3216 :match (lambda (widget value) 3250 :match (lambda (widget value)
3217 (char-valid-p value))) 3251 (characterp value)))
3218 3252
3219 (define-widget 'list 'group 3253 (define-widget 'list 'group
3220 "A Lisp list." 3254 "A Lisp list."
3221 :tag "List" 3255 :tag "List"
3222 :format "%{%t%}:\n%v") 3256 :format "%{%t%}:\n%v")