all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Basil L. Contovounesios" <contovob@tcd.ie>
To: Eli Zaretskii <eliz@gnu.org>
Cc: rswgnu@gmail.com, 34506@debbugs.gnu.org
Subject: bug#34506: 27.0.50: push-button bug with basic text-property button
Date: Tue, 19 Feb 2019 15:26:59 +0000	[thread overview]
Message-ID: <87lg2bsssc.fsf@tcd.ie> (raw)
In-Reply-To: <838sycjw0j.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 19 Feb 2019 05:29:48 +0200")

Eli Zaretskii <eliz@gnu.org> writes:

>> From: "Basil L. Contovounesios" <contovob@tcd.ie>
>> Cc: <rswgnu@gmail.com>,  <34506@debbugs.gnu.org>
>> Date: Mon, 18 Feb 2019 20:51:12 +0000
>> 
>> So I'm guessing what you meant is "you cannot safely invoke button-type
>> if the button at point might be a widget rather than a button".
>
> No, I'm trying to explain why button-type returns nil in the case of
> text-buttons.

I'm sorry if I've misunderstood something obvious, but button-type
should never return nil for any kind of button.el button, regardless of
whether it's a text or overlay button.

As stated in '(elisp) Button Types', "every button has a button type".
For example, the following should return 'button:

  (with-temp-buffer
    (let* ((tstart  (prog1 (point) (insert-text-button "text")))
           (ostart  (prog1 (point) (insert-button "overlay")))
           (tbutton (button-at tstart))
           (obutton (button-at ostart))
           (ttype   (button-type tbutton))
           (otype   (button-type obutton)))
      (cl-assert (and tbutton obutton ttype otype))
      (cl-assert (eq ttype otype))
      (cl-assert (eq ttype (button-type tstart)))
      (cl-assert (null (button-type ostart)))
      ttype))

[ By the way, would something like this be welcome as a start for
  test/lisp/button-tests.el? ]

The only cases (within reason) in which button-type may return nil are:

0. button-type is mistakenly given a buffer position POS instead of an
   overlay when the button at POS is an overlay (not text) button, as
   shown in the example above.  Using (button-at POS) avoids this
   problem.

1. button-type is given the value of a widget's (not button's) 'button
   overlay property.  This is not that far-fetched since both libraries
   rely on (get-char-property POS 'button), but I don't see why anyone
   would mix widgets and buttons in the same buffer and run the risk of
   such gotchas.  I believe this contributed in part to Robert's
   confusion.

Am I missing something?

-- 
Basil





  reply	other threads:[~2019-02-19 15:26 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-16 22:08 bug#34506: 27.0.50: push-button bug with basic text-property button Bob Weiner
2019-02-17 15:24 ` Eli Zaretskii
2019-02-17 23:46   ` Robert Weiner
2019-02-18 15:47     ` Eli Zaretskii
2019-02-18 16:56       ` Robert Weiner
2019-02-18 17:36         ` Eli Zaretskii
2019-02-18 20:52         ` Basil L. Contovounesios
2019-02-18 20:51       ` Basil L. Contovounesios
2019-02-18 22:54         ` Robert Weiner
2019-02-19  3:08           ` Basil L. Contovounesios
2019-02-19  3:29         ` Eli Zaretskii
2019-02-19 15:26           ` Basil L. Contovounesios [this message]
2019-02-20  5:22             ` Robert Weiner
2019-02-25  2:40               ` Basil L. Contovounesios
2019-03-02 12:34                 ` Eli Zaretskii
2019-04-07  3:14                   ` Basil L. Contovounesios

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lg2bsssc.fsf@tcd.ie \
    --to=contovob@tcd.ie \
    --cc=34506@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=rswgnu@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.