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 18B08431FB6 for ; Tue, 24 May 2011 16:27:32 -0700 (PDT) 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 qcEJF6Sh+M+9 for ; Tue, 24 May 2011 16:27:30 -0700 (PDT) Received: from mail-fx0-f53.google.com (mail-fx0-f53.google.com [209.85.161.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id D9DAA431FD0 for ; Tue, 24 May 2011 16:27:29 -0700 (PDT) Received: by fxm8 with SMTP id 8so5375718fxm.26 for ; Tue, 24 May 2011 16:27:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:in-reply-to:references :user-agent:date:message-id:mime-version:content-type; bh=n8rt4SkIfFX77y8mj/vMo6+D3zpuqEpziGNcWarkNwA=; b=DGSkjXpXiuGaZBtPwW8KURLq+ta9ucWsbCmwmpERTXe+Sxjrto7o4UQfxvmtYQZxDH uWl+9W3M9liO2UwVIRpmKgEUP3WLGNTWPOaeN70/NNU9PzjuLE0jdR3o8e7KKPa8+BUD Pbqf4j4GppncGCEhkJnLoEAe8QPChYO4r2SbQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version:content-type; b=nNc/KtbhFlsal0CP56jfuNqcMr+Fj0rbloaYWtouwg8PxGmm6mEH2chkX/OhuF4sJN kiWFCa2qyjirR4+7NSJZEzX1/cS9vImugdF2uqzNrRxCEjxW+6f1btqxU04TvjxyZNrI 2zVMhNgg2/PxPmb/PuJc+A1cGUpQOcTNGK+nE= Received: by 10.223.98.5 with SMTP id o5mr4298702fan.33.1306279648595; Tue, 24 May 2011 16:27:28 -0700 (PDT) Received: from localhost ([91.144.186.21]) by mx.google.com with ESMTPS id o1sm925fah.4.2011.05.24.16.27.27 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 24 May 2011 16:27:28 -0700 (PDT) From: Dmitry Kurochkin To: Carl Worth , Austin Clements Subject: Re: [PATCH] Save and restore point explicitly in `notmuch-wash-toggle-invisible-action'. In-Reply-To: <87d3j7bs8t.fsf@yoom.home.cworth.org> References: <1306090675-26982-1-git-send-email-dmitry.kurochkin@gmail.com> <1306164587-20326-1-git-send-email-dmitry.kurochkin@gmail.com> <87oc2rlujb.fsf@yoom.home.cworth.org> <8762ozrfrr.fsf@gmail.com> <87oc2rvjvj.fsf@yoom.home.cworth.org> <871uznrbh5.fsf@gmail.com> <87d3j7bs8t.fsf@yoom.home.cworth.org> User-Agent: Notmuch/0.5-216-g0104e23 (http://notmuchmail.org) Emacs/23.3.1 (x86_64-pc-linux-gnu) Date: Wed, 25 May 2011 03:27:51 +0400 Message-ID: <87vcwzptl4.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: notmuch@notmuchmail.org 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: Tue, 24 May 2011 23:27:32 -0000 On Tue, 24 May 2011 16:20:34 -0700, Carl Worth wrote: > On Tue, 24 May 2011 18:43:41 -0400, Austin Clements wrote: > > Saving point this way is a bit dangerous, though. For example, if > > you're near the end of the buffer and shorten the label, attempting to > > restore the point could result in an error (or, a more benign example: > > the cursor could wind up outside the label so pressing RET repeatedly > > won't toggle it). > > > > Unfortunately, I don't know of a clean solution to this, but I think I > > would rather the cursor move, but stay within the label (probably > > moving to the beginning), than have problems like the above. > > Here's my fix. Let me know what you think. > (button-end cite-button) would move the point outside the button - to the next character after it. Regards, Dmitry > -Carl > > From a32e02bf0d2b57d51695f7d4ea6cdda9acb21322 Mon Sep 17 00:00:00 2001 > From: Carl Worth > Date: Mon, 23 May 2011 19:29:46 +0400 > Subject: [PATCH] Carefully preverse point when changing button text in > `notmuch-wash-toggle-invisible-action'. > > Previously, save-excursion was used to attempt to save the point, but > this was unreliable since the region containing the marker saved by > save-excursion was deleted. Instead, we save an integer position > indicating the offset of point within the old button. Then, we restore > point to the same offset within the new button, (but cap the offset to > avoid leaving the button entirely). > --- > emacs/notmuch-wash.el | 13 +++++++------ > 1 files changed, 7 insertions(+), 6 deletions(-) > > diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el > index 8455eee..3dceb8b 100644 > --- a/emacs/notmuch-wash.el > +++ b/emacs/notmuch-wash.el > @@ -82,13 +82,14 @@ collapse the remaining lines into a button.") > (let* ((new-start (button-start cite-button)) > (overlay (button-get cite-button 'overlay)) > (button-label (notmuch-wash-button-label overlay)) > + (button-offset (- (point) new-start)) > (inhibit-read-only t)) > - (save-excursion > - (goto-char new-start) > - (insert button-label) > - (let ((old-end (button-end cite-button))) > - (move-overlay cite-button new-start (point)) > - (delete-region (point) old-end)))) > + (goto-char new-start) > + (insert button-label) > + (let ((old-end (button-end cite-button))) > + (move-overlay cite-button new-start (point)) > + (delete-region (point) old-end)) > + (goto-char (min (button-end cite-button) (+ new-start button-offset)))) > (force-window-update) > (redisplay t)) > > -- > 1.7.5.1 > Non-text part: application/pgp-signature