diff --git a/lisp/button.el b/lisp/button.el index c46f3d9a52..921e84dfa6 100644 --- a/lisp/button.el +++ b/lisp/button.el @@ -382,10 +382,12 @@ button-at If the button at POS is a text property button, the return value is a marker pointing to POS." (let ((button (get-char-property pos 'button))) - (if (or (overlayp button) (null button)) - button - ;; Must be a text-property button; return a marker pointing to it. - (copy-marker pos t)))) + (and button (get-char-property pos 'category) + (if (overlayp button) + button + ;; Must be a text-property button; + ;; return a marker pointing to it. + (copy-marker pos t))))) (defun next-button (pos &optional count-current) "Return the next button after position POS in the current buffer. diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el index 52c0b5b74d..b9f98cdc4c 100644 --- a/lisp/wid-edit.el +++ b/lisp/wid-edit.el @@ -1163,8 +1163,9 @@ widget-field-list (defun widget-at (&optional pos) "The button or field at POS (default, point)." - (or (get-char-property (or pos (point)) 'button) - (widget-field-at pos))) + (let ((widget (or (get-char-property (or pos (point)) 'button) + (widget-field-at pos)))) + (and (widgetp widget) widget))) ;;;###autoload (defun widget-setup ()