From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: =?UTF-8?Q?Cl=C3=A9ment?= Pit-Claudel Newsgroups: gmane.emacs.bugs Subject: bug#40859: Clicking the wrap-prefix string inside a button causes an error Date: Sun, 26 Apr 2020 12:44:15 -0400 Message-ID: <98b37654-1133-05b7-a7b1-3f32b9a74ad9@gmail.com> References: <837dy2746e.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------5252D7B6CF06BEA71BFB0D35" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="129968"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 Cc: 40859@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Apr 26 18:45:16 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jSkP5-000Xe3-0F for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 26 Apr 2020 18:45:15 +0200 Original-Received: from localhost ([::1]:36384 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jSkP3-0005HQ-Va for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 26 Apr 2020 12:45:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46394) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jSkOt-0005HD-FZ for bug-gnu-emacs@gnu.org; Sun, 26 Apr 2020 12:45:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jSkOt-0005I3-3n for bug-gnu-emacs@gnu.org; Sun, 26 Apr 2020 12:45:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:50704) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jSkOs-0005Hy-Nc for bug-gnu-emacs@gnu.org; Sun, 26 Apr 2020 12:45:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jSkOs-0004NI-LV for bug-gnu-emacs@gnu.org; Sun, 26 Apr 2020 12:45:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Cl=C3=A9ment?= Pit-Claudel Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 26 Apr 2020 16:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 40859 X-GNU-PR-Package: emacs Original-Received: via spool by 40859-submit@debbugs.gnu.org id=B40859.158791946616716 (code B ref 40859); Sun, 26 Apr 2020 16:45:02 +0000 Original-Received: (at 40859) by debbugs.gnu.org; 26 Apr 2020 16:44:26 +0000 Original-Received: from localhost ([127.0.0.1]:34012 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jSkOI-0004LY-1P for submit@debbugs.gnu.org; Sun, 26 Apr 2020 12:44:26 -0400 Original-Received: from mail-qk1-f173.google.com ([209.85.222.173]:39482) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jSkOG-0004LL-7M for 40859@debbugs.gnu.org; Sun, 26 Apr 2020 12:44:25 -0400 Original-Received: by mail-qk1-f173.google.com with SMTP id o135so3247176qke.6 for <40859@debbugs.gnu.org>; Sun, 26 Apr 2020 09:44:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=Yowa1GxGeTS3pVVKve/8/KnHNSNRmabgn2CAr5gYs8M=; b=o817L/mtfIz7Zcuq5ucDON/6UkLQsMT6lDF5e5oXwuXX/cvGhj0HIKXmt68AIJadz7 xsX344mNhN/bpBhjdvJ/vTCaJGUvan0U523kOXGVfnsH0KLdmU2BGePF0SAy5QxbgoUB ZuEIbGIvudEAnNS4EMerD7KUCs4DLbriO2JJvB+EZaPPlhiYV9pBuj5sm400T5jZSNVc nbBpiNxCVoE4Vzw42H0jtZ4xJ5TYhpsMwHT+6tOBVV/izEIJ6ew+1Czvtp6iFxWAgvsG bD020FcOa3wWQ/nt2lFYg2rfk/HgPOFPZp++nMsdbpFZibizFVl5//sZsRy3cQWIRbS+ 9uTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=Yowa1GxGeTS3pVVKve/8/KnHNSNRmabgn2CAr5gYs8M=; b=EUvRC3elW2LYNbJjHvFti8iYYUBXcwpYjf/YAJn2pIg0/NEyJmlyVcHfw3ZeqwS83G fSG6+VbUkUSBKqxcfUI/bMtrJuA/6BHXHx+GyRPjoOZC/N+rJ9OckDGdUzvPl+LxtGRJ YJltgweHnthQVjv77Pa2GQpGdBZH/llsS9XxB4W6q9L9F4/6CMqIxisdVAX/WWOluukF AJTt3+BpoUSCHEcXK3wMSmHgTZ5wtc539bAZJM0Gb/o2e2UBZCxts538yQX8SMPQnVaI dvS/8FyTwIu0mjvmLTRzc8B+8F+plxXRZD4OaUBdleiyftc0seb08f9Z5U1ERQFfuTqn WhFA== X-Gm-Message-State: AGi0PuaYsNhnl6ft8jrJcr05M0GdS1I54fxGKq1vpbl1dJzfhhLA/EBt Wq8ioGmP44jlTn1gyXPfKmGXfaMPaTA= X-Google-Smtp-Source: APiQypIus5f9V4iz7LbDU2BVxhluplCjnSe1VW3xGQR+FbJX7X3vqosY/UUDGGbUzV1ZQvuKSzOupQ== X-Received: by 2002:a37:af05:: with SMTP id y5mr19070898qke.471.1587919458347; Sun, 26 Apr 2020 09:44:18 -0700 (PDT) Original-Received: from ?IPv6:2601:184:4180:66e7:54d6:bfeb:aa49:9d3b? ([2601:184:4180:66e7:54d6:bfeb:aa49:9d3b]) by smtp.googlemail.com with ESMTPSA id z26sm8084784qkg.39.2020.04.26.09.44.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 26 Apr 2020 09:44:17 -0700 (PDT) In-Reply-To: <837dy2746e.fsf@gnu.org> Content-Language: en-GB X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:179087 Archived-At: This is a multi-part message in MIME format. --------------5252D7B6CF06BEA71BFB0D35 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit On 26/04/2020 09.43, Eli Zaretskii wrote: >> From: Clément Pit-Claudel >> Date: Sat, 25 Apr 2020 23:40:38 -0400 >> >> The following snippet inserts a button with a long label and a wrap-prefix. Clicking the prefix causes an error, whose backtrace is shown below. > > Isn't that a cockpit error? Here's a tentative patch, but I can't claim to understand the button.el code well :/ --------------5252D7B6CF06BEA71BFB0D35 Content-Type: text/x-patch; charset=UTF-8; name="0001-Only-treat-display-strings-as-buttons-if-they-have-a.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Only-treat-display-strings-as-buttons-if-they-have-a.pa"; filename*1="tch" >From 11034798933a1e0c9498b0409cd463acb822f2d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Pit-Claudel?= Date: Sun, 26 Apr 2020 12:41:42 -0400 Subject: [PATCH] Only treat display strings as buttons if they have a 'button property * lisp/button.el (push-button): Use posn-point instead of posn-string if the string doesn't have a 'button property (Bug#40859). --- lisp/button.el | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lisp/button.el b/lisp/button.el index b3afc4eca2..c33a3e8ac2 100644 --- a/lisp/button.el +++ b/lisp/button.el @@ -469,10 +469,12 @@ push-button ;; POS is a mouse event; switch to the proper window/buffer (let ((posn (event-start pos))) (with-current-buffer (window-buffer (posn-window posn)) - (if (posn-string posn) - ;; mode-line, header-line, or display string event. - (button-activate (posn-string posn) t) - (push-button (posn-point posn) t)))) + (let* ((str (posn-string posn)) + (str-button (get-text-property (cdr str) 'button (car str)))) + (if (and str str-button) + ;; mode-line, header-line, or display string event. + (button-activate str t) + (push-button (posn-point posn) t))))) ;; POS is just normal position (let ((button (button-at (or pos (point))))) (when button -- 2.17.1 --------------5252D7B6CF06BEA71BFB0D35--