[PATCH v2 1/5] emacs: Retain text properties when toggling buttons
authorAustin Clements <amdragon@MIT.EDU>
Thu, 30 May 2013 01:13:44 +0000 (21:13 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:55:08 +0000 (09:55 -0800)
3d/3afcde4d67927b7a59761ce7e67ac4c0974223 [new file with mode: 0644]

diff --git a/3d/3afcde4d67927b7a59761ce7e67ac4c0974223 b/3d/3afcde4d67927b7a59761ce7e67ac4c0974223
new file mode 100644 (file)
index 0000000..f4d2cd2
--- /dev/null
@@ -0,0 +1,117 @@
+Return-Path: <amdragon@mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id EE08B431FAE\r
+       for <notmuch@notmuchmail.org>; Wed, 29 May 2013 18:14:12 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id ncEGCoUbxbOd for <notmuch@notmuchmail.org>;\r
+       Wed, 29 May 2013 18:14:06 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-4.mit.edu (dmz-mailsec-scanner-4.mit.edu\r
+       [18.9.25.15])\r
+       by olra.theworths.org (Postfix) with ESMTP id 2FF7F431FB6\r
+       for <notmuch@notmuchmail.org>; Wed, 29 May 2013 18:13:59 -0700 (PDT)\r
+X-AuditID: 1209190f-b7f256d000005616-fc-51a6a7d6737a\r
+Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
+       by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id B6.C0.22038.6D7A6A15; Wed, 29 May 2013 21:13:58 -0400 (EDT)\r
+Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
+       by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id r4U1DtFW029491; \r
+       Wed, 29 May 2013 21:13:55 -0400\r
+Received: from drake.dyndns.org (c-76-21-105-205.hsd1.ca.comcast.net\r
+       [76.21.105.205]) (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id r4U1DqSP003004\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Wed, 29 May 2013 21:13:54 -0400\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1UhrRA-0003Yq-0Q; Wed, 29 May 2013 21:13:52 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 1/5] emacs: Retain text properties when toggling buttons\r
+Date: Wed, 29 May 2013 21:13:44 -0400\r
+Message-Id: <1369876428-13537-2-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <1369876428-13537-1-git-send-email-amdragon@mit.edu>\r
+References: <1369876428-13537-1-git-send-email-amdragon@mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFtrDIsWRmVeSWpSXmKPExsUixG6nontt+bJAg8UNRhar5/JYXL85k9mB\r
+       yWPnrLvsHs9W3WIOYIrisklJzcksSy3St0vgyth4UKWgm6/iSut7tgbGHdxdjJwcEgImEvcm\r
+       X2CBsMUkLtxbz9bFyMUhJLCPUeLKh0VQzkZGic+rz7BCOKeZJJasu8UO4cxllHhz7yArSD+b\r
+       gIbEtv3LGUFsEQFpiZ13Z4PFmQUcJT7vBxnFySEs4C3R0/6eHcRmEVCVWHS9B2w3r4CDxMX/\r
+       Z6DuUJTofjYBrJ4TqPd923WwmUJANc3f+pgmMPIvYGRYxSibklulm5uYmVOcmqxbnJyYl5da\r
+       pGuil5tZopeaUrqJERRInJL8Oxi/HVQ6xCjAwajEw7tBa1mgEGtiWXFl7iFGSQ4mJVHeNUuB\r
+       QnxJ+SmVGYnFGfFFpTmpxYcYJTiYlUR412gD5XhTEiurUovyYVLSHCxK4rxXU276CwmkJ5ak\r
+       ZqemFqQWwWRlODiUJHhtlwE1ChalpqdWpGXmlCCkmTg4QYbzAA1XAqnhLS5IzC3OTIfIn2JU\r
+       lBKHaBYASWSU5sH1wiL9FaM40CvCvKYgVTzAJAHX/QpoMBPQYHHmxSCDSxIRUlINjItLj0aI\r
+       r3zXYP6EYSpvUbjBmryV79a8eL5lQeUFuwKFQ4abj9RomrybZSs1dc/v2vucj+6ZiBsH5u3v\r
+       WnT52AOZRb/ul64sX/L+nGzuhLKvF2d/XVN38F+5mKeH9L8L80JtJ9tXPLywUde+xXd32AXF\r
+       M5km4of9vqgnzTb5lJuqH2TEKsB0WkSJpTgj0VCLuag4EQDLRPa4zwIAAA==\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Thu, 30 May 2013 01:14:13 -0000\r
+\r
+Previously, we lost any text properties applied to part buttons or\r
+wash buttons when they were toggled because `insert' directly copies\r
+the text properties of the string being inserted.  Fix this by\r
+capturing the properties applied to the button beforehand and\r
+re-applying them after inserting the new text.\r
+---\r
+ emacs/notmuch-show.el |    2 ++\r
+ emacs/notmuch-wash.el |    2 ++\r
+ 2 files changed, 4 insertions(+)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index b0a8d8a..a080134 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -559,10 +559,12 @@ message at DEPTH in the current thread."\r
+            (new-start (button-start button))\r
+            (button-label (button-get button :base-label))\r
+            (old-point (point))\r
++           (properties (text-properties-at (point)))\r
+            (inhibit-read-only t))\r
+       (overlay-put overlay 'invisible (not show))\r
+       (goto-char new-start)\r
+       (insert "[ " button-label (if show " ]" " (hidden) ]"))\r
++      (set-text-properties new-start (point) properties)\r
+       (let ((old-end (button-end button)))\r
+         (move-overlay button new-start (point))\r
+         (delete-region (point) old-end))\r
+diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el\r
+index 8a68819..8fe91e1 100644\r
+--- a/emacs/notmuch-wash.el\r
++++ b/emacs/notmuch-wash.el\r
+@@ -104,9 +104,11 @@ lower).")\r
+        (overlay (button-get cite-button 'overlay))\r
+        (button-label (notmuch-wash-button-label overlay))\r
+        (old-point (point))\r
++       (properties (text-properties-at (point)))\r
+        (inhibit-read-only t))\r
+     (goto-char new-start)\r
+     (insert button-label)\r
++    (set-text-properties new-start (point) properties)\r
+     (let ((old-end (button-end cite-button)))\r
+       (move-overlay cite-button new-start (point))\r
+       (delete-region (point) old-end))\r
+-- \r
+1.7.10.4\r
+\r