From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: "Basil L. Contovounesios" Newsgroups: gmane.emacs.bugs Subject: bug#34506: 27.0.50: push-button bug with basic text-property button Date: Sun, 07 Apr 2019 04:14:09 +0100 Message-ID: <877ec6zev2.fsf@tcd.ie> References: <83pnrql9p0.fsf@gnu.org> <831s45ksiz.fsf@gnu.org> <875ztgrfb3.fsf@tcd.ie> <838sycjw0j.fsf@gnu.org> <87lg2bsssc.fsf@tcd.ie> <9A74136C-D6E3-44B8-8C9F-060BFC29E068@gmail.com> <874l8ssi91.fsf@tcd.ie> <83a7idh2un.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="47195"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: rswgnu@gmail.com, 34506-done@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Apr 07 05:15:17 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hCyH4-000C4g-HT for geb-bug-gnu-emacs@m.gmane.org; Sun, 07 Apr 2019 05:15:14 +0200 Original-Received: from localhost ([127.0.0.1]:33636 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hCyH3-0003Dx-IT for geb-bug-gnu-emacs@m.gmane.org; Sat, 06 Apr 2019 23:15:13 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:53514) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hCyGu-0003Cq-6q for bug-gnu-emacs@gnu.org; Sat, 06 Apr 2019 23:15:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hCyGs-0000Yk-O3 for bug-gnu-emacs@gnu.org; Sat, 06 Apr 2019 23:15:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:34122) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hCyGs-0000YW-Ge for bug-gnu-emacs@gnu.org; Sat, 06 Apr 2019 23:15:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hCyGs-0007Bs-Bd for bug-gnu-emacs@gnu.org; Sat, 06 Apr 2019 23:15:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Basil L. Contovounesios" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Apr 2019 03:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34506 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed Original-Received: via spool by 34506-done@debbugs.gnu.org id=D34506.155460686627570 (code D ref 34506); Sun, 07 Apr 2019 03:15:02 +0000 Original-Received: (at 34506-done) by debbugs.gnu.org; 7 Apr 2019 03:14:26 +0000 Original-Received: from localhost ([127.0.0.1]:47663 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hCyGI-0007Ac-1V for submit@debbugs.gnu.org; Sat, 06 Apr 2019 23:14:26 -0400 Original-Received: from mail-ed1-f48.google.com ([209.85.208.48]:32884) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hCyGE-0007AB-R3 for 34506-done@debbugs.gnu.org; Sat, 06 Apr 2019 23:14:24 -0400 Original-Received: by mail-ed1-f48.google.com with SMTP id q3so3315027edg.0 for <34506-done@debbugs.gnu.org>; Sat, 06 Apr 2019 20:14:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=X4SjB18cXkRogDeBRrXytt/nOQObaF5GSoCt5IAPenw=; b=OkCLVFxXRXKcVnR0+kp2JNK1Os6LnmC1QfjgrQnq2o3RM1wzzKZHvYTRfv2RrCbZBh EXHIA8GLPtt34ZP69vSuKY/OJcet/3wh8Vq1e7mOMOROQ4bNXnEKP1X2W0HPRUbj4ofu 295CHQhkfM4jL/Ta6N9Q85YgjxXHtrxxWhNEYoP7fEfUKH6NHtrOdjc3BzASlcDoque2 gv2nDJ4s6nvuig/oIknlET7Y6bGftohyPS+4O2H7p6MM/aHu/erFPV2mu9Y6H2+pikh8 eLk1NOjVVeHzqe5G9ZdOR0RvO7naBKaDcfQqQWeJAavgmBJ1zpB7Vuh2d3e4gdv1c3F/ QCzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=X4SjB18cXkRogDeBRrXytt/nOQObaF5GSoCt5IAPenw=; b=Fy1hJ0tBFq5NcFgPmzLH8ezi0X6Z0TaR43wy7HOeKSyuq5WL22+KtJRzJZ3AoXEQSI va7OejbmMjwzzXtecVD3fofnBN9emcxMtDHqkduaFwgSAacwYp0BeBEdY1MuoZCWMB07 p4WghXNHGnnFJbSh9sbiHnNyVujZUZIOP9vzE/x8XukaQjnZGFKYZdc9EwcTN+GAmnWu 24EHpdEFnARAdBGfmztspmMNNjl6g+4GelxM36rLLgxkO+R3YbbNqE2Qr/5lIOqGImUW pLRmrq7bbOdRoziTNqg435zxQY6eLPlmx4yFkKBz7dbczB2CIKom8p77nQtbJrWf3kA6 wPZQ== X-Gm-Message-State: APjAAAW2fDeTqknggungbEb9ccPnv9T95ZqiBOrzwWTAY3TvBjHkdMjt EtxbX6cO4d/Hl9RLueAZe09d1Q== X-Google-Smtp-Source: APXvYqx1gYUX+HnMGaKL8pXWJCxjoVgZZNqrb1Z3Fxps+TpTNTtuZFktpVh2YAI7B+XtAEYp2csalw== X-Received: by 2002:aa7:c6c6:: with SMTP id b6mr13448105eds.69.1554606856923; Sat, 06 Apr 2019 20:14:16 -0700 (PDT) Original-Received: from localhost ([2a02:8084:20e2:c380:f786:805d:f4ab:1006]) by smtp.gmail.com with ESMTPSA id e3sm7730293edb.22.2019.04.06.20.14.15 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 06 Apr 2019 20:14:15 -0700 (PDT) In-Reply-To: <83a7idh2un.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 2 Mar 2019 14:34:24 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:157300 Archived-At: --=-=-= Content-Type: text/plain tags 34506 fixed close 34506 quit --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Distinguish-buttons-from-widgets-bug-34506.patch >From 08235af38c92e95d8ec9d268916d8910ea50ab2d Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Sun, 7 Apr 2019 03:36:47 +0100 Subject: [PATCH] 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. --- lisp/button.el | 10 ++++++---- lisp/wid-edit.el | 5 +++-- test/lisp/button-tests.el | 40 +++++++++++++++++++++++++++++++++++++ test/lisp/wid-edit-tests.el | 39 ++++++++++++++++++++++++++++++++++++ 4 files changed, 88 insertions(+), 6 deletions(-) create mode 100644 test/lisp/button-tests.el create mode 100644 test/lisp/wid-edit-tests.el 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 () diff --git a/test/lisp/button-tests.el b/test/lisp/button-tests.el new file mode 100644 index 0000000000..d54a992ab8 --- /dev/null +++ b/test/lisp/button-tests.el @@ -0,0 +1,40 @@ +;;; button-tests.el --- tests for button.el -*- lexical-binding: t -*- + +;; Copyright (C) 2019 Free Software Foundation, Inc. + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Code: + +(require 'ert) + +(ert-deftest button-at () + "Test `button-at' behavior." + (with-temp-buffer + (should-not (button-at (point))) + (let ((button (insert-text-button "text button")) + (marker (button-at (1- (point))))) + (should (markerp marker)) + (should (= (button-end button) (button-end marker) (point)))) + (let ((button (insert-button "overlay button")) + (overlay (button-at (1- (point))))) + (should (overlayp overlay)) + (should (eq button overlay))) + ;; Buttons and widgets are incompatible (bug#34506). + (widget-create 'link "link widget") + (should-not (button-at (1- (point)))))) + +;;; button-tests.el ends here diff --git a/test/lisp/wid-edit-tests.el b/test/lisp/wid-edit-tests.el new file mode 100644 index 0000000000..a4350e715e --- /dev/null +++ b/test/lisp/wid-edit-tests.el @@ -0,0 +1,39 @@ +;;; wid-edit-tests.el --- tests for wid-edit.el -*- lexical-binding: t -*- + +;; Copyright (C) 2019 Free Software Foundation, Inc. + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Code: + +(require 'ert) +(require 'wid-edit) + +(ert-deftest widget-at () + "Test `widget-at' behavior." + (with-temp-buffer + (should-not (widget-at)) + (let ((marco (widget-create 'link "link widget")) + (polo (widget-at (1- (point))))) + (should (widgetp polo)) + (should (eq marco polo))) + ;; Buttons and widgets are incompatible (bug#34506). + (insert-text-button "text button") + (should-not (widget-at (1- (point)))) + (insert-button "overlay button") + (should-not (widget-at (1- (point)))))) + +;;; wid-edit-tests.el ends here -- 2.20.1 --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> From: "Basil L. Contovounesios" >> Cc: Eli Zaretskii , 34506@debbugs.gnu.org >> Date: Mon, 25 Feb 2019 02:40:26 +0000 >> >> > If buttons and widgets are wholly incompatible and separate then button-at >> > should return nil when on a widget even if both buttons and widgets use the same >> > underlying mechanism. >> >> How's the following? > > LGTM, but can we please have a simple test for this, so that this > never again regresses? Of course. I've pushed the attached patch to master, and am thus closing this bug report. Let me know if I missed anything. Thanks, -- Basil --=-=-=--