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