Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 3AAE7429E36 for ; Wed, 25 Jan 2012 07:11:46 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.799 X-Spam-Level: X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, 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 0R3OBXI7r48E for ; Wed, 25 Jan 2012 07:11:45 -0800 (PST) Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 3A942431FBC for ; Wed, 25 Jan 2012 07:11:45 -0800 (PST) Received: by bkbzt19 with SMTP id zt19so3531795bkb.26 for ; Wed, 25 Jan 2012 07:11:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:subject:in-reply-to:references:user-agent:date:message-id :mime-version:content-type; bh=y7H/TK6SixpM6OOrl9ya9OJhXt+5Vuevvx4KeivZmPM=; b=fOA0ijKVMdV1PJW6lRp8hD+nBhyJU0KxdCJ1081cAjilqm2HfZ2JqdQp/A5u1rb+4m y8qD9SM+6gXaAu/FNmNsAszbOHv9AbXj+rAYMHifNcWss8fx5gMwNihc9lV6xBJuuMef yVEDaGTJFak6FA4a1j9yG4FsnfI3CsJD2aULg= Received: by 10.204.155.89 with SMTP id r25mr7136193bkw.11.1327504302317; Wed, 25 Jan 2012 07:11:42 -0800 (PST) Received: from localhost ([91.144.186.21]) by mx.google.com with ESMTPS id sp6sm1615622bkb.2.2012.01.25.07.11.40 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 25 Jan 2012 07:11:41 -0800 (PST) From: Dmitry Kurochkin To: David Edmondson , notmuch@notmuchmail.org Subject: Re: [PATCH 1/1] emacs: Take more care when hiding regions with buttons. In-Reply-To: <1327503908-17226-1-git-send-email-dme@dme.org> References: <1327503908-17226-1-git-send-email-dme@dme.org> User-Agent: Notmuch/0.11+100~gd650abf (http://notmuchmail.org) Emacs/23.3.1 (x86_64-pc-linux-gnu) Date: Wed, 25 Jan 2012 19:10:35 +0400 Message-ID: <871uqng6ms.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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:11:46 -0000 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. > > 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. > --- > > This is a hack, but I couldn't see another way around it. Can anyone > find a better solution? > I think it would be much easier to understand the problem and probably suggest a solution if there is a test :) Regards, Dmitry > emacs/notmuch-wash.el | 57 ++++++++++++++++++++++++++++++++---------------- > 1 files changed, 38 insertions(+), 19 deletions(-) > > 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 indentation." > ;; 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-spec)) > - (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 the > + ;; beginning of the buffer we must move forward a little to avoid > + ;; creating an overlay that will hide the button intended to be used > + ;; 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 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-spec)) > + (overlay-put overlay 'isearch-open-invisible #'notmuch-wash-region-isearch-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))))) > > (defun notmuch-wash-excerpt-citations (msg depth) > "Excerpt citations and up to one signature." > -- > 1.7.8.3 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch