:group 'find-function
:version "21.1")
+(defvar find-widget-regexp
+ (concat "^\\s-*(define-widget" find-function-space-re "%s\\(\\s-\\|$\\)"))
+
(defcustom find-face-regexp
(concat"^\\s-*(defface" find-function-space-re "%s\\(\\s-\\|$\\)")
"The regexp used by `find-face' to search for a face definition.
(defface . find-function--defface)
(feature . find-feature-regexp)
(defalias . find-alias-regexp)
- (ert-deftest . find-ert-deftest-regexp))
+ (ert-deftest . find-ert-deftest-regexp)
+ (define-widget . find-widget-regexp))
"Alist mapping definition types into regexp variables.
Each regexp variable's value should actually be a format string
to be used to substitute the desired symbol name into the regexp.
(defun elisp--xref-infer-namespace (pos)
"Find the likely namespace of the identifier at POS.
-Return one of `function', `variable' `maybe-variable', `feature', `face', or
-`any' (indicating any namespace). `maybe-variable' indicates a variable
-namespace but with lower confidence."
+Return one of `function', `variable' `maybe-variable', `feature',
+`face', `widget-type', or `any' (indicating any namespace).
+`maybe-variable' indicates a variable namespace but with lower
+confidence."
(save-excursion
(goto-char pos)
(cl-flet ((looking-at-sym ()
nil)
((defface face) 'face)
((feature) 'feature)
+ ((widget-type) 'widget-type)
((defvar variable constant) 'variable)
((defun function macro special-form top-level major-mode) 'function))))
cl-defgeneric cl-defmethod))
('variable '(defvar))
('face '(defface))
- ('feature '(feature)))))
+ ('feature '(feature))
+ ('widget-type '(define-widget)))))
(cl-loop for d in definitions
when (memq
(xref-elisp-location-type (xref-item-location d))
(when file
(push (elisp--xref-make-xref 'defface symbol file) xrefs))))
+ (when (get 'symbol 'widget-type)
+ (when-let ((file (find-lisp-object-file-name symbol 'define-widget)))
+ (push (elisp--xref-make-xref 'define-widget symbol file) xrefs)))
+
(when (fboundp symbol)
(let ((file (find-lisp-object-file-name symbol (symbol-function symbol)))
generic doc)
(error "Widget documentation must be nil or a string"))
(put name 'widget-type (cons class args))
(put name 'widget-documentation (purecopy doc))
+ (add-to-list 'current-load-list `(define-widget . ,name))
name)
(define-obsolete-function-alias 'widget-plist-member #'plist-member "26.1")