[PATCH 1/4] emacs: Retain text properties when toggling buttons
authorAustin Clements <amdragon@MIT.EDU>
Mon, 27 May 2013 20:46:31 +0000 (16:46 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:55:05 +0000 (09:55 -0800)
c4/e16830e6050131c6c39b849034c7ea853d4761 [new file with mode: 0644]

diff --git a/c4/e16830e6050131c6c39b849034c7ea853d4761 b/c4/e16830e6050131c6c39b849034c7ea853d4761
new file mode 100644 (file)
index 0000000..dd36654
--- /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 E1158431FAE\r
+       for <notmuch@notmuchmail.org>; Mon, 27 May 2013 13:46:54 -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 JT9R7QFML7HS for <notmuch@notmuchmail.org>;\r
+       Mon, 27 May 2013 13:46:47 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-7.mit.edu (DMZ-MAILSEC-SCANNER-7.MIT.EDU\r
+       [18.7.68.36])\r
+       by olra.theworths.org (Postfix) with ESMTP id 48791431FAF\r
+       for <notmuch@notmuchmail.org>; Mon, 27 May 2013 13:46:47 -0700 (PDT)\r
+X-AuditID: 12074424-b7f8c6d0000028c4-1a-51a3c634b37f\r
+Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])\r
+       by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id 19.E5.10436.436C3A15; Mon, 27 May 2013 16:46:45 -0400 (EDT)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH-1.MIT.EDU [18.9.28.11])\r
+       by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id r4RKkhsn032253; \r
+       Mon, 27 May 2013 16:46:43 -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 r4RKkewD026417\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Mon, 27 May 2013 16:46:42 -0400\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1Uh4JT-0008NB-Mz; Mon, 27 May 2013 16:46:39 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 1/4] emacs: Retain text properties when toggling buttons\r
+Date: Mon, 27 May 2013 16:46:31 -0400\r
+Message-Id: <1369687594-31774-2-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <1369687594-31774-1-git-send-email-amdragon@mit.edu>\r
+References: <1369687594-31774-1-git-send-email-amdragon@mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFtrDIsWRmVeSWpSXmKPExsUixCmqrWt6bHGgwaS3zBar5/JYXL85k9mB\r
+       yWPnrLvsHs9W3WIOYIrisklJzcksSy3St0vgyth4UKWgm6/iSut7tgbGHdxdjJwcEgImEsu3\r
+       rGKHsMUkLtxbz9bFyMUhJLCPUeLzl+msEM5GIGfhPXYI5zSTxNH3k6CcuYwSW1fMZgHpZxPQ\r
+       kNi2fzkjiC0iIC2x8+5sVhCbWcBR4vP+RWwgtrCAh8ScjxuZQGwWAVWJzolHwGxeAQeJ/mdr\r
+       GCHuUJTofjYBrJ4TqPfKrt9gc4SAala/7mCawMi/gJFhFaNsSm6Vbm5iZk5xarJucXJiXl5q\r
+       ka65Xm5miV5qSukmRlAgsbuo7GBsPqR0iFGAg1GJh9cic3GgEGtiWXFl7iFGSQ4mJVFe9iNA\r
+       Ib6k/JTKjMTijPii0pzU4kOMEhzMSiK821cA5XhTEiurUovyYVLSHCxK4rzXU276CwmkJ5ak\r
+       ZqemFqQWwWRlODiUJHjlQIYKFqWmp1akZeaUIKSZODhBhvMADc8AqeEtLkjMLc5Mh8ifYlSU\r
+       EuctB0kIgCQySvPgemGR/opRHOgVYV4nkCoeYJKA634FNJgJaLA4M9jgkkSElFQD4/wrudu9\r
+       lm7Sd1H8kB/tyGbz8+ikP9qJKa6HLrqtCymvtNAXnK97SNF/4SHtXw5Xl68s6V/Jy+X0xL9L\r
+       vqfzH7v44brPti84vnJJm70+KBz9K9phtyeHWnbR9JML8mbPrN2UdUZw09PXzk6eKnaLFizd\r
+       tDXS8WxBW1f3WpEVlas42LdX26xqV2Ipzkg01GIuKk4EAOcRN8TPAgAA\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: Mon, 27 May 2013 20:46:55 -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