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 95771431FBC for ; Sun, 2 Dec 2012 16:58:50 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0.201 X-Spam-Level: X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=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 ZMeKvM3wYpM2 for ; Sun, 2 Dec 2012 16:58:50 -0800 (PST) Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id E8FB6431FAE for ; Sun, 2 Dec 2012 16:58:49 -0800 (PST) Received: by mail-wi0-f181.google.com with SMTP id hm9so717986wib.2 for ; Sun, 02 Dec 2012 16:58:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=Ie2vyI3sDwmHFt0xL79oaSqrrtgpzgKhSJ/r8vfpKdo=; b=CycFB17cMkHWBDyU47wgDTDXcH2YCveqq3z6j6CA5RgQGrTz+hwK8PPYgu4SFbhEi6 +iLNWRzvKj84qHbMNykO6Rkcf84NYNlKH2+vRKR64mDD+BxMkCBChcVuBtAPiNz8UCPR rpGlG6TvIz5UVInT5J22yxkcPZnk3wnlv8KVJd76/1nBCMXQ3Q6BouP+Xi/ScsD5ioSJ /TY1BkPORn3EsHiZwgWmq8BG7J2Bt5IDZWbr06YqIYnjTl+gtcoLUEyZ5plPOZI45HxJ j8aTzmgCm2VLJ2NNGW/0cR5euNepCmzoy8mpOl7NM7DBzKRi+sZyHWniXeHQcpg4Xwqk D4hQ== Received: by 10.180.93.69 with SMTP id cs5mr6918960wib.3.1354496328805; Sun, 02 Dec 2012 16:58:48 -0800 (PST) Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) by mx.google.com with ESMTPS id cf6sm10289166wib.3.2012.12.02.16.58.47 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 02 Dec 2012 16:58:47 -0800 (PST) From: Mark Walters To: notmuch@notmuchmail.org Subject: [PATCH v2 1/3] emacs: show: make refresh fix point(ish) Date: Mon, 3 Dec 2012 00:58:35 +0000 Message-Id: <1354496317-24564-2-git-send-email-markwalters1009@gmail.com> X-Mailer: git-send-email 1.7.9.1 In-Reply-To: <1354496317-24564-1-git-send-email-markwalters1009@gmail.com> References: <1354496317-24564-1-git-send-email-markwalters1009@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: Mon, 03 Dec 2012 00:58:50 -0000 This makes a moderate attempt to keep the screen and point in the same place when refreshing (unless we are resetting state). It does this by moving to the same point relative to the start of the message, and moving that to the same line position in the screen relative to the top of the window. This fixes some mild annoyances like the whole message resetting when toggling indentation when reading a diff (ie currently you lose your place). It also makes the follow up patches in this series for toggling parts work much more nicely. --- emacs/notmuch-show.el | 25 ++++++++++++++++++------- 1 files changed, 18 insertions(+), 7 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 489e32c..cc0487c 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -1137,8 +1137,13 @@ function is used." This includes: - the list of open messages, - - the current message." - (list (notmuch-show-get-message-id) (notmuch-show-get-message-ids-for-open-messages))) + - the current message + - point relative to the top of this message + - current line number on screen of point." + (list (count-lines (window-start) (point)) + (- (point) (notmuch-show-message-top)) + (notmuch-show-get-message-id) + (notmuch-show-get-message-ids-for-open-messages))) (defun notmuch-show-apply-state (state) "Apply STATE to the current buffer. @@ -1147,8 +1152,10 @@ This includes: - opening the messages previously opened, - closing all other messages, - moving to the correct current message." - (let ((current (car state)) - (open (cadr state))) + (let* ((height (pop state)) + (relative-point (pop state)) + (current (pop state)) + (open (pop state))) ;; Open those that were open. (goto-char (point-min)) @@ -1158,12 +1165,16 @@ This includes: ;; Go to the previously open message. (goto-char (point-min)) - (unless (loop if (string= current (notmuch-show-get-message-id)) + (if (loop if (string= current (notmuch-show-get-message-id)) return t until (not (notmuch-show-goto-message-next))) + (progn + (notmuch-show-message-adjust) + (forward-char relative-point) + (recenter height)) (goto-char (point-min)) - (message "Previously current message not found.")) - (notmuch-show-message-adjust))) + (message "Previously current message not found.") + (notmuch-show-message-adjust)))) (defun notmuch-show-refresh-view (&optional reset-state) "Refresh the current view. -- 1.7.9.1