Re: [PATCH 1/1] emacs: Take more care when hiding regions with buttons.
authorDavid Edmondson <dme@dme.org>
Wed, 25 Jan 2012 15:18:31 +0000 (15:18 +0000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:43:16 +0000 (09:43 -0800)
d6/2b0c6438b3eae88017e66a7da9feea1d216382 [new file with mode: 0644]

diff --git a/d6/2b0c6438b3eae88017e66a7da9feea1d216382 b/d6/2b0c6438b3eae88017e66a7da9feea1d216382
new file mode 100644 (file)
index 0000000..9a1c85f
--- /dev/null
@@ -0,0 +1,192 @@
+Return-Path: <dme@dme.org>\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 32B75429E39\r
+       for <notmuch@notmuchmail.org>; Wed, 25 Jan 2012 07:18:41 -0800 (PST)\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 d1QzB2gVT7YT for <notmuch@notmuchmail.org>;\r
+       Wed, 25 Jan 2012 07:18:40 -0800 (PST)\r
+Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com\r
+ [74.125.82.45])       (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
+ certificate requested)        by olra.theworths.org (Postfix) with ESMTPS id\r
+ C7F1B429E36   for <notmuch@notmuchmail.org>; Wed, 25 Jan 2012 07:18:39 -0800\r
+ (PST)\r
+Received: by wgbdt12 with SMTP id dt12so4908511wgb.2\r
+       for <notmuch@notmuchmail.org>; Wed, 25 Jan 2012 07:18:38 -0800 (PST)\r
+Received: by 10.180.73.111 with SMTP id k15mr1076953wiv.5.1327504718495;\r
+       Wed, 25 Jan 2012 07:18:38 -0800 (PST)\r
+Received: from hotblack-desiato.hh.sledj.net\r
+       (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25])\r
+       by mx.google.com with ESMTPS id ho4sm385021wib.3.2012.01.25.07.18.36\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Wed, 25 Jan 2012 07:18:37 -0800 (PST)\r
+Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)\r
+       id 6B3E89FE67; Wed, 25 Jan 2012 15:18:35 +0000 (GMT)\r
+To: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
+Subject: Re: [PATCH 1/1] emacs: Take more care when hiding regions with\r
+       buttons.\r
+In-Reply-To: <871uqng6ms.fsf@gmail.com>\r
+References: <1327503908-17226-1-git-send-email-dme@dme.org>\r
+       <871uqng6ms.fsf@gmail.com>\r
+User-Agent: Notmuch/0.11+114~g550724b (http://notmuchmail.org) Emacs/24.0.92.1\r
+       (x86_64-pc-linux-gnu)\r
+From: David Edmondson <dme@dme.org>\r
+Date: Wed, 25 Jan 2012 15:18:31 +0000\r
+Message-ID: <cun62fzn73s.fsf@hotblack-desiato.hh.sledj.net>\r
+MIME-Version: 1.0\r
+Content-Type: multipart/signed; boundary="=-=-=";\r
+       micalg=pgp-sha1; protocol="application/pgp-signature"\r
+X-Gm-Message-State:\r
+ ALoCoQkA/jE2qEpXxZBDoJ1AZthYK9Nocf+6i7/MDuORUfmpgvLrRADOP5oOAY9gbJjeSkPJw484\r
+Cc: Notmuch Mail <notmuch@notmuchmail.org>\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: Wed, 25 Jan 2012 15:18:41 -0000\r
+\r
+--=-=-=\r
+Content-Type: text/plain\r
+Content-Transfer-Encoding: quoted-printable\r
+\r
+On Wed, 25 Jan 2012 19:10:35 +0400, Dmitry Kurochkin <dmitry.kurochkin@gmai=\r
+l.com> wrote:\r
+> On Wed, 25 Jan 2012 15:05:08 +0000, David Edmondson <dme@dme.org> wrote:\r
+> > If the region to be hidden with a button by\r
+> > `notmuch-wash-region-to-button' starts at the beginning of the buffer,\r
+> > the invisible region will include the inserted button. This is\r
+> > unfortunate, as it means that it is not possible to see the button to\r
+> > be pressed.\r
+> >=20\r
+> > Make a little space at the start of the buffer before inserting the\r
+> > button to avoid this, not forgetting to remove the inserted space upon\r
+> > completion.\r
+> > ---\r
+> >=20\r
+> > This is a hack, but I couldn't see another way around it. Can anyone\r
+> > find a better solution?\r
+> >=20\r
+>=20\r
+> I think it would be much easier to understand the problem and probably\r
+> suggest a solution if there is a test :)\r
+\r
+Wow, and I have that new test infrastructure to use!\r
+\r
+>=20\r
+> Regards,\r
+>   Dmitry\r
+>=20\r
+> >  emacs/notmuch-wash.el |   57 ++++++++++++++++++++++++++++++++---------=\r
+-------\r
+> >  1 files changed, 38 insertions(+), 19 deletions(-)\r
+> >=20\r
+> > diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el\r
+> > index 5c1e830..4afd3b3 100644\r
+> > --- a/emacs/notmuch-wash.el\r
+> > +++ b/emacs/notmuch-wash.el\r
+> > @@ -147,25 +147,44 @@ insert before the button, probably for indentatio=\r
+n."\r
+> >    ;; symbols because of the way the button code works. Note that\r
+> >    ;; replacing intern-soft with make-symbol will cause this to fail,\r
+> >    ;; since the newly created symbol has no plist.\r
+> > -\r
+> > -  (let ((overlay (make-overlay beg end))\r
+> > -  (message-invis-spec (plist-get msg :message-invis-spec))\r
+> > -  (invis-spec (make-symbol (concat "notmuch-" type "-region")))\r
+> > -  (button-type (intern-soft (concat "notmuch-wash-button-"\r
+> > -                                    type "-toggle-type"))))\r
+> > -    (add-to-invisibility-spec invis-spec)\r
+> > -    (overlay-put overlay 'invisible (list invis-spec message-invis-spe=\r
+c))\r
+> > -    (overlay-put overlay 'isearch-open-invisible #'notmuch-wash-region=\r
+-isearch-show)\r
+> > -    (overlay-put overlay 'priority 10)\r
+> > -    (overlay-put overlay 'type type)\r
+> > -    (goto-char (1+ end))\r
+> > -    (save-excursion\r
+> > -      (goto-char (1- beg))\r
+> > -      (insert prefix)\r
+> > -      (insert-button (notmuch-wash-button-label overlay)\r
+> > -               'invisibility-spec invis-spec\r
+> > -               'overlay overlay\r
+> > -               :type button-type))))\r
+> > +  (save-excursion\r
+> > +    ;; If the beginning of the region to be converted to a button is t=\r
+he\r
+> > +    ;; beginning of the buffer we must move forward a little to avoid\r
+> > +    ;; creating an overlay that will hide the button intended to be us=\r
+ed\r
+> > +    ;; to reveal the hidden region.\r
+> > +    (let (scene-of-crime)\r
+> > +      (when (eq beg (point-min))\r
+> > +  (goto-char (point-min))\r
+> > +  (insert "\n")\r
+> > +  (setq scene-of-crime (point-min)\r
+> > +        beg (point)))\r
+> > +\r
+> > +      ;; This uses some slightly tricky conversions between strings and\r
+> > +      ;; symbols because of the way the button code works. Note that\r
+> > +      ;; replacing intern-soft with make-symbol will cause this to fai=\r
+l,\r
+> > +      ;; since the newly created symbol has no plist.\r
+> > +\r
+> > +      (let ((overlay (make-overlay beg end))\r
+> > +      (message-invis-spec (plist-get msg :message-invis-spec))\r
+> > +      (invis-spec (make-symbol (concat "notmuch-" type "-region")))\r
+> > +      (button-type (intern-soft (concat "notmuch-wash-button-"\r
+> > +                                        type "-toggle-type"))))\r
+> > +  (add-to-invisibility-spec invis-spec)\r
+> > +  (overlay-put overlay 'invisible (list invis-spec message-invis-spec))\r
+> > +  (overlay-put overlay 'isearch-open-invisible #'notmuch-wash-region-is=\r
+earch-show)\r
+> > +  (overlay-put overlay 'priority 10)\r
+> > +  (overlay-put overlay 'type type)\r
+> > +\r
+> > +  (goto-char (1- beg))\r
+> > +  (insert prefix)\r
+> > +  (insert-button (notmuch-wash-button-label overlay)\r
+> > +                 'invisibility-spec invis-spec\r
+> > +                 'overlay overlay\r
+> > +                 :type button-type))\r
+> > +\r
+> > +      (when scene-of-crime\r
+> > +          (goto-char scene-of-crime)\r
+> > +          (delete-char 1)))))\r
+> >=20=20\r
+> >  (defun notmuch-wash-excerpt-citations (msg depth)\r
+> >    "Excerpt citations and up to one signature."\r
+> > --=20\r
+> > 1.7.8.3\r
+> >=20\r
+> > _______________________________________________\r
+> > notmuch mailing list\r
+> > notmuch@notmuchmail.org\r
+> > http://notmuchmail.org/mailman/listinfo/notmuch\r
+\r
+--=-=-=\r
+Content-Type: application/pgp-signature\r
+\r
+-----BEGIN PGP SIGNATURE-----\r
+Version: GnuPG v1.4.11 (GNU/Linux)\r
+\r
+iEYEARECAAYFAk8gHUcACgkQaezQq/BJZRb+UQCgg6OTsoocoq6hKc5ViAB873I/\r
+pI4An10/4r8Z/JPUIv+mlmn46y8F0Iuq\r
+=TDrC\r
+-----END PGP SIGNATURE-----\r
+--=-=-=--\r