From aeba6f9ad3c88a093baba0444926c405ea74aca5 Mon Sep 17 00:00:00 2001 From: Dave Love Date: Sun, 16 Jul 2000 15:27:43 +0000 Subject: [PATCH] (widget-specify-field, widget-specify-button): Allow non-string help-echo. (widget-types-convert-widget): Defsubst it. (widget-echo-help): Try to cope with a help-echo function of two possible sorts. --- lisp/wid-edit.el | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el index dd5c3e2dd7..a4de1d35e2 100644 --- a/lisp/wid-edit.el +++ b/lisp/wid-edit.el @@ -304,8 +304,7 @@ new value.") (overlay-put overlay 'keymap map) (overlay-put overlay 'face face) ;;(overlay-put overlay 'balloon-help help-echo) - (if (stringp help-echo) - (overlay-put overlay 'help-echo help-echo))) + (overlay-put overlay 'help-echo help-echo)) (widget-specify-secret widget)) (defun widget-specify-secret (field) @@ -338,8 +337,7 @@ new value.") (overlay-put overlay 'face face) (overlay-put overlay 'mouse-face widget-mouse-face)) ;;(overlay-put overlay 'balloon-help help-echo) - (if (stringp help-echo) - (overlay-put overlay 'help-echo help-echo)))) + (overlay-put overlay 'help-echo help-echo))) (defun widget-specify-sample (widget from to) "Specify sample for WIDGET between FROM and TO." @@ -1167,7 +1165,8 @@ Optional EVENT is the event that triggered the action." found (widget-apply child :validate))) found)) -(defun widget-types-convert-widget (widget) +;; Made defsubst to speed up face editor creation. +(defsubst widget-types-convert-widget (widget) "Convert :args as widget types in WIDGET." (widget-put widget :args (mapcar 'widget-convert (widget-get widget :args))) widget) @@ -3367,12 +3366,24 @@ To use this type, you must define :match or :match-alternatives." (let* ((widget (widget-at pos)) (help-echo (and widget (widget-get widget :help-echo)))) (if (or (stringp help-echo) - (and (symbolp help-echo) (fboundp help-echo) - (stringp (setq help-echo (funcall help-echo widget))))) + (and (functionp help-echo) + ;; Kluge: help-echo originally could be a function of + ;; one arg -- the widget. It is more useful in Emacs + ;; 21 to have it as a function usable also as a + ;; help-echo property, when it can sort out its own + ;; widget if necessary. Try both calling sequences + ;; (rather than messing around to get the function's + ;; arity). + (stringp + (setq help-echo + (condition-case nil + (funcall help-echo (current-buffer) (point)) + (error (funcall help-echo widget)))))) + (stringp (eval help-echo))) (message "%s" help-echo)))) ;;; The End: (provide 'wid-edit) -;; wid-edit.el ends here +;;; wid-edit.el ends here -- 2.20.1