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 4BD68429E26 for ; Tue, 24 May 2011 16:00:24 -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 bdIQ0CfAwgkJ for ; Tue, 24 May 2011 16:00:23 -0700 (PDT) Received: from mail-yx0-f181.google.com (mail-yx0-f181.google.com [209.85.213.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id CADDE431FB6 for ; Tue, 24 May 2011 16:00:23 -0700 (PDT) Received: by yxm8 with SMTP id 8so3410273yxm.26 for ; Tue, 24 May 2011 16:00:23 -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 :content-transfer-encoding; bh=L/J8mSomEk6uFIrcsgUjRD1XI3rDZDNdc5oZVesNCGE=; b=uhX2h+aASJoc+rTaf/cc00bdA0Z0GKzMnR7Pl7BayNehFvkrR9bbFHKuf8F5wpEPyQ ONsYyNGlYbpSlIFzXaAaZsHg4NPfN9hIztaJtzGAey/LzJoR5U1tfUJc1Xo38F8HpmXq 9GRgpJXmJ99k4CNkFlEwt/Uo7ykr6e6q7NbF0= 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:content-transfer-encoding; b=I2lzRmojbfogxGrVxY4MgESyLN7y+vo/yTNYlNKSxv0lILClvwc7j+W6A3Xt605oZo vrP1OKkmF6Bk1l5tXKLFYYR60/ISdhfFkf0GnZYqnLtVQlOjvsGJL0rGgLrGR8xBltfB 5JSQy+BnnI22o2qKzo3X/gzO0hpsNEFDk2j+g= Received: by 10.100.115.10 with SMTP id n10mr5696154anc.119.1306278023211; Tue, 24 May 2011 16:00:23 -0700 (PDT) Received: from localhost ([91.144.186.21]) by mx.google.com with ESMTPS id z2sm5920102anj.37.2011.05.24.16.00.20 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 24 May 2011 16:00:22 -0700 (PDT) From: Dmitry Kurochkin To: Austin Clements Subject: Re: [PATCH] Save and restore point explicitly in `notmuch-wash-toggle-invisible-action'. In-Reply-To: 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> 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:00:43 +0400 Message-ID: <87y61vpuuc.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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:00:24 -0000 On Tue, 24 May 2011 18:43:41 -0400, Austin Clements wrot= e: > On Tue, May 24, 2011 at 6:16 PM, Dmitry Kurochkin > wrote: > > When a user clicks the button, the cursor is somewhere inside the old > > label. =C2=A0If we save the point as a marker, after step 3 it would en= d up > > at the position where the old label was. =C2=A0If the new label is inse= rted > > before the old one, that means after the new label. =C2=A0So the cursor= jumps > > from inside the button to the position after the button. =C2=A0Since th= e new > > button is placed at the same position where the old one was, restoring > > the point to the same offset it was at the beginning works as we need. >=20 > 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). >=20 > 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. Good point. I will send an amended patch that moved to min(old-pos, new-button-end - 1). This leaves the cursor in place when possible and avoids problems with out-of-bounds position (assuming the label is not empty). Regards, Dmitry