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 180BD431FD0 for ; Tue, 24 May 2011 16:02:30 -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 FXvkrC2Fbfl4 for ; Tue, 24 May 2011 16:02:28 -0700 (PDT) Received: from mail-ey0-f181.google.com (mail-ey0-f181.google.com [209.85.215.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 26B4D431FB6 for ; Tue, 24 May 2011 16:02:28 -0700 (PDT) Received: by eyh5 with SMTP id 5so2557681eyh.26 for ; Tue, 24 May 2011 16:02:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=AQh+DeAduutsycHmO3ihmilEdIpERSrUqx+xwbKvdTM=; b=R10u9lJDA1utmitxbCTDvH9MzNm6bzpZU/KDSnqS4Y4tU/Znm8UqJPjqZmLMcjUI2z GcqiyE8Ln/v7DhSCUMntZpWza7TM22hbuHB1/uqexTSPS1oDVi1EGK1G+wPNuDqFC/9y KQGLHNe6LIGYJon0ArDS/6Vfo2XxnM8cUM5RU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=ZREhFiSoSxhGsFC6Ds2oSy7+uISmsJH3njYXYMRivCT3s/H4MbfTkXrLte2y02w1Gh q3BMYFyAPbdmz1EN4eHpUS4zB5EWkHVJvUebYirTldElaUIX2Ywi1rOtmlDz/kgvkI25 NCSaiTCHALe1RCo+s3m5zRhUHkqRxv1lqolFg= Received: by 10.213.35.68 with SMTP id o4mr1388408ebd.104.1306278146784; Tue, 24 May 2011 16:02:26 -0700 (PDT) Received: from localhost ([91.144.186.21]) by mx.google.com with ESMTPS id y3sm5670396eeh.9.2011.05.24.16.02.25 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 24 May 2011 16:02:26 -0700 (PDT) From: Dmitry Kurochkin To: notmuch@notmuchmail.org Subject: [PATCH] Save and restore point explicitly in `notmuch-wash-toggle-invisible-action'. Date: Wed, 25 May 2011 03:02:43 +0400 Message-Id: <1306278163-20784-1-git-send-email-dmitry.kurochkin@gmail.com> X-Mailer: git-send-email 1.7.5.1 In-Reply-To: <87y61vpuuc.fsf@gmail.com> References: <87y61vpuuc.fsf@gmail.com> 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:02:30 -0000 Before the change, save-excursion was used to save the point. But the restored position is affected by buffer modifications, which results in jumping cursor. The patch saves and restores point explicitly by using a variable instead of save-excursion. --- 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 863459e..115c3bb 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)) + (old-point (point)) (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 old-point (1- (button-end cite-button))))) (force-window-update) (redisplay t)) -- 1.7.5.1