diff options
| author | Basil L. Contovounesios | 2019-04-07 03:36:47 +0100 |
|---|---|---|
| committer | Basil L. Contovounesios | 2019-04-07 03:56:27 +0100 |
| commit | 08235af38c92e95d8ec9d268916d8910ea50ab2d (patch) | |
| tree | d065cbd0fcb339ddf2f2fd0b809400a54deb99ef /lisp | |
| parent | 43f4c7ddd2077b2e786d069bbb9e2de32f23ffb2 (diff) | |
| download | emacs-08235af38c92e95d8ec9d268916d8910ea50ab2d.tar.gz emacs-08235af38c92e95d8ec9d268916d8910ea50ab2d.zip | |
Distinguish buttons from widgets (bug#34506)
* lisp/button.el (button-at):
* lisp/wid-edit.el (widget-at): Avoid returning a false positive
when looking for a button and finding a widget, or vice versa.
* test/lisp/button-tests.el:
* test/lisp/wid-edit-tests.el: New files.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/button.el | 10 | ||||
| -rw-r--r-- | lisp/wid-edit.el | 5 |
2 files changed, 9 insertions, 6 deletions
diff --git a/lisp/button.el b/lisp/button.el index c46f3d9a52b..921e84dfa68 100644 --- a/lisp/button.el +++ b/lisp/button.el | |||
| @@ -382,10 +382,12 @@ Also see `make-text-button'." | |||
| 382 | If the button at POS is a text property button, the return value | 382 | If the button at POS is a text property button, the return value |
| 383 | is a marker pointing to POS." | 383 | is a marker pointing to POS." |
| 384 | (let ((button (get-char-property pos 'button))) | 384 | (let ((button (get-char-property pos 'button))) |
| 385 | (if (or (overlayp button) (null button)) | 385 | (and button (get-char-property pos 'category) |
| 386 | button | 386 | (if (overlayp button) |
| 387 | ;; Must be a text-property button; return a marker pointing to it. | 387 | button |
| 388 | (copy-marker pos t)))) | 388 | ;; Must be a text-property button; |
| 389 | ;; return a marker pointing to it. | ||
| 390 | (copy-marker pos t))))) | ||
| 389 | 391 | ||
| 390 | (defun next-button (pos &optional count-current) | 392 | (defun next-button (pos &optional count-current) |
| 391 | "Return the next button after position POS in the current buffer. | 393 | "Return the next button after position POS in the current buffer. |
diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el index 52c0b5b74d2..b9f98cdc4c7 100644 --- a/lisp/wid-edit.el +++ b/lisp/wid-edit.el | |||
| @@ -1163,8 +1163,9 @@ When not inside a field, signal an error." | |||
| 1163 | 1163 | ||
| 1164 | (defun widget-at (&optional pos) | 1164 | (defun widget-at (&optional pos) |
| 1165 | "The button or field at POS (default, point)." | 1165 | "The button or field at POS (default, point)." |
| 1166 | (or (get-char-property (or pos (point)) 'button) | 1166 | (let ((widget (or (get-char-property (or pos (point)) 'button) |
| 1167 | (widget-field-at pos))) | 1167 | (widget-field-at pos)))) |
| 1168 | (and (widgetp widget) widget))) | ||
| 1168 | 1169 | ||
| 1169 | ;;;###autoload | 1170 | ;;;###autoload |
| 1170 | (defun widget-setup () | 1171 | (defun widget-setup () |