aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1998-04-02 06:33:26 +0000
committerRichard M. Stallman1998-04-02 06:33:26 +0000
commit4084d128919837556441de2b37d66b6e52345d1f (patch)
tree975b709345853210e87fd9da1f8ac1f4e3ff1b99
parentc3fd0eea6ccca81df139c141960fca3e14c01a92 (diff)
downloademacs-4084d128919837556441de2b37d66b6e52345d1f.tar.gz
emacs-4084d128919837556441de2b37d66b6e52345d1f.zip
Delete some compatibility code.
(widget-event-point, widget-read-event): Define unconditionally. (widget-echo-help-mouse): Don't use window-end. (widget-choice-value-create): If there is an :explicit-choice, respect it. (widget-choice-action): Record an explicit choice in :explicit-choice.
-rw-r--r--lisp/wid-edit.el96
1 files changed, 42 insertions, 54 deletions
diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
index 34930699b20..b473c3eb1c5 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -34,31 +34,18 @@
34(eval-when-compile (require 'cl)) 34(eval-when-compile (require 'cl))
35 35
36;;; Compatibility. 36;;; Compatibility.
37
38(defun widget-event-point (event)
39 "Character position of the end of event if that exists, or nil."
40 (posn-point (event-end event))))
41
42(defalias 'widget-read-event 'read-event)
37 43
38(eval-and-compile 44(eval-and-compile
39 (autoload 'pp-to-string "pp") 45 (autoload 'pp-to-string "pp")
40 (autoload 'Info-goto-node "info") 46 (autoload 'Info-goto-node "info")
41 (autoload 'finder-commentary "finder" nil t) 47 (autoload 'finder-commentary "finder" nil t)
42 48
43 (when (string-match "XEmacs" emacs-version)
44 (condition-case nil
45 (require 'overlay)
46 (error (load-library "x-overlay"))))
47
48 (if (string-match "XEmacs" emacs-version)
49 (defun widget-event-point (event)
50 "Character position of the end of event if that exists, or nil."
51 (if (mouse-event-p event)
52 (event-point event)
53 nil))
54 (defun widget-event-point (event)
55 "Character position of the end of event if that exists, or nil."
56 (posn-point (event-end event))))
57
58 (defalias 'widget-read-event (if (string-match "XEmacs" emacs-version)
59 'next-event
60 'read-event))
61
62 (unless (and (featurep 'custom) (fboundp 'custom-declare-variable)) 49 (unless (and (featurep 'custom) (fboundp 'custom-declare-variable))
63 ;; We have the old custom-library, hack around it! 50 ;; We have the old custom-library, hack around it!
64 (defmacro defgroup (&rest args) nil) 51 (defmacro defgroup (&rest args) nil)
@@ -78,24 +65,7 @@
78 (and (eventp event) 65 (and (eventp event)
79 (memq (event-basic-type event) '(mouse-1 mouse-2 mouse-3)) 66 (memq (event-basic-type event) '(mouse-1 mouse-2 mouse-3))
80 (or (memq 'click (event-modifiers event)) 67 (or (memq 'click (event-modifiers event))
81 (memq 'drag (event-modifiers event)))))) 68 (memq 'drag (event-modifiers event)))))))
82
83 (unless (fboundp 'functionp)
84 ;; Missing from Emacs 19.34 and earlier.
85 (defun functionp (object)
86 "Non-nil of OBJECT is a type of object that can be called as a function."
87 (or (subrp object) (byte-code-function-p object)
88 (eq (car-safe object) 'lambda)
89 (and (symbolp object) (fboundp object)))))
90
91 (unless (fboundp 'error-message-string)
92 ;; Emacs function missing in XEmacs.
93 (defun error-message-string (obj)
94 "Convert an error value to an error message."
95 (let ((buf (get-buffer-create " *error-message*")))
96 (erase-buffer buf)
97 (display-error obj buf)
98 (buffer-string buf)))))
99 69
100;;; Customization. 70;;; Customization.
101 71
@@ -1965,21 +1935,30 @@ If END is omitted, it defaults to the length of LIST."
1965 ;; Insert the first choice that matches the value. 1935 ;; Insert the first choice that matches the value.
1966 (let ((value (widget-get widget :value)) 1936 (let ((value (widget-get widget :value))
1967 (args (widget-get widget :args)) 1937 (args (widget-get widget :args))
1938 (explicit (widget-get widget :explicit-choice))
1939 (explicit-value (widget-get widget :explicit-choice-value))
1968 current) 1940 current)
1969 (while args 1941 (if (and explicit (eq value explicit-value))
1970 (setq current (car args) 1942 (progn
1971 args (cdr args)) 1943 ;; If the user specified the choice for this value,
1972 (when (widget-apply current :match value) 1944 ;; respect that choice as long as the value is the same.
1973 (widget-put widget :children (list (widget-create-child-value 1945 (widget-put widget :children (list (widget-create-child-value
1974 widget current value))) 1946 widget explicit value)))
1975 (widget-put widget :choice current) 1947 (widget-put widget :choice explicit))
1976 (setq args nil 1948 (while args
1977 current nil))) 1949 (setq current (car args)
1978 (when current 1950 args (cdr args))
1979 (let ((void (widget-get widget :void))) 1951 (when (widget-apply current :match value)
1980 (widget-put widget :children (list (widget-create-child-and-convert 1952 (widget-put widget :children (list (widget-create-child-value
1981 widget void :value value))) 1953 widget current value)))
1982 (widget-put widget :choice void))))) 1954 (widget-put widget :choice current)
1955 (setq args nil
1956 current nil)))
1957 (when current
1958 (let ((void (widget-get widget :void)))
1959 (widget-put widget :children (list (widget-create-child-and-convert
1960 widget void :value value)))
1961 (widget-put widget :choice void))))))
1983 1962
1984(defun widget-choice-value-get (widget) 1963(defun widget-choice-value-get (widget)
1985 ;; Get value of the child widget. 1964 ;; Get value of the child widget.
@@ -2028,6 +2007,7 @@ when he invoked the menu."
2028 (old (widget-get widget :choice)) 2007 (old (widget-get widget :choice))
2029 (tag (widget-apply widget :menu-tag-get)) 2008 (tag (widget-apply widget :menu-tag-get))
2030 (completion-ignore-case (widget-get widget :case-fold)) 2009 (completion-ignore-case (widget-get widget :case-fold))
2010 this-explicit
2031 current choices) 2011 current choices)
2032 ;; Remember old value. 2012 ;; Remember old value.
2033 (if (and old (not (widget-apply widget :validate))) 2013 (if (and old (not (widget-apply widget :validate)))
@@ -2054,8 +2034,16 @@ when he invoked the menu."
2054 (cons (cons (widget-apply current :menu-tag-get) 2034 (cons (cons (widget-apply current :menu-tag-get)
2055 current) 2035 current)
2056 choices))) 2036 choices)))
2037 (setq this-explicit t)
2057 (widget-choose tag (reverse choices) event)))) 2038 (widget-choose tag (reverse choices) event))))
2058 (when current 2039 (when current
2040 ;; If this was an explicit user choice,
2041 ;; record the choice, and the record the value it was made for.
2042 ;; widget-choice-value-create will respect this choice,
2043 ;; as long as the value is the same.
2044 (when this-explicit
2045 (widget-put widget :explicit-choice current)
2046 (widget-put widget :explicit-choice-value (widget-get widget :value)))
2059 (widget-value-set widget 2047 (widget-value-set widget
2060 (widget-apply current :value-to-external 2048 (widget-apply current :value-to-external
2061 (widget-get current :value))) 2049 (widget-get current :value)))
@@ -3025,7 +3013,7 @@ It will read a directory name from the minibuffer when invoked."
3025 "History of input to `widget-symbol-prompt-value'.") 3013 "History of input to `widget-symbol-prompt-value'.")
3026 3014
3027(define-widget 'symbol 'editable-field 3015(define-widget 'symbol 'editable-field
3028 "A lisp symbol." 3016 "A Lisp symbol."
3029 :value nil 3017 :value nil
3030 :tag "Symbol" 3018 :tag "Symbol"
3031 :format "%{%t%}: %v" 3019 :format "%{%t%}: %v"
@@ -3057,7 +3045,7 @@ It will read a directory name from the minibuffer when invoked."
3057 "History of input to `widget-function-prompt-value'.") 3045 "History of input to `widget-function-prompt-value'.")
3058 3046
3059(define-widget 'function 'sexp 3047(define-widget 'function 'sexp
3060 "A lisp function." 3048 "A Lisp function."
3061 :complete-function 'lisp-complete-symbol 3049 :complete-function 'lisp-complete-symbol
3062 :prompt-value 'widget-field-prompt-value 3050 :prompt-value 'widget-field-prompt-value
3063 :prompt-internal 'widget-symbol-prompt-internal 3051 :prompt-internal 'widget-symbol-prompt-internal
@@ -3454,7 +3442,7 @@ Enable with (run-with-idle-timer 1 t 'widget-echo-help-mouse)"
3454 (select-window win) 3442 (select-window win)
3455 (let* ((result (compute-motion (window-start win) 3443 (let* ((result (compute-motion (window-start win)
3456 '(0 . 0) 3444 '(0 . 0)
3457 (window-end win) 3445 (point-max)
3458 where 3446 where
3459 (window-width win) 3447 (window-width win)
3460 (cons (window-hscroll) 0) 3448 (cons (window-hscroll) 0)