[PATCH 1/2] contrib: pick: move save-excursion closer to message insertion
authorMark Walters <markwalters1009@gmail.com>
Thu, 10 Jan 2013 10:41:16 +0000 (10:41 +0000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:53:04 +0000 (09:53 -0800)
46/364c5038e65dd9c247d4333c820460027cf046 [new file with mode: 0644]

diff --git a/46/364c5038e65dd9c247d4333c820460027cf046 b/46/364c5038e65dd9c247d4333c820460027cf046
new file mode 100644 (file)
index 0000000..8babce3
--- /dev/null
@@ -0,0 +1,126 @@
+Return-Path: <markwalters1009@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 84E73431FAF\r
+       for <notmuch@notmuchmail.org>; Thu, 10 Jan 2013 02:41:23 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.201\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
+       RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id ApjG66bP5LOf for <notmuch@notmuchmail.org>;\r
+       Thu, 10 Jan 2013 02:41:23 -0800 (PST)\r
+Received: from mail-we0-f171.google.com (mail-we0-f171.google.com\r
+       [74.125.82.171]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id BFAC2431FB6\r
+       for <notmuch@notmuchmail.org>; Thu, 10 Jan 2013 02:41:22 -0800 (PST)\r
+Received: by mail-we0-f171.google.com with SMTP id u3so169568wey.2\r
+       for <notmuch@notmuchmail.org>; Thu, 10 Jan 2013 02:41:21 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to\r
+       :references:mime-version:content-type:content-transfer-encoding;\r
+       bh=NHFI9jXTJCTEokIKdN8V4Blwa/OObvBTro/5tvWD3VI=;\r
+       b=P1Dqy4LmvJLc4XnBmiEEldvZAHsTabJn+GBVz02ymfm+xS4sXT1MhIxhMYUsDFgft3\r
+       5RqDXXOogHowa5rMv8YxT0OkpBd06yTi30YUMzt4b73rR7leArrR8R4JLNLmbRDqojKk\r
+       R3lXQiYQXHUu3GokqLKlH5VtGeM4NMlqly0lJRRLNP4YQ5reQDfrJUkcrJhJ3kobNmrD\r
+       lcseZIGtdlGtyU2jrPuYWiHnP1ZdYX++At3o+VxCrYXXXT2lNeQvVwLnPpoHXO4DpNaz\r
+       z6u7TPq5H8/71zbYwswSGGu7GuaMD04kqOemrZK6r1X+CJZSPbK2oF+EL0UmdSpvRHTp\r
+       4wMA==\r
+X-Received: by 10.180.72.146 with SMTP id d18mr8200752wiv.33.1357814481617;\r
+       Thu, 10 Jan 2013 02:41:21 -0800 (PST)\r
+Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
+       by mx.google.com with ESMTPS id bw9sm7779330wib.5.2013.01.10.02.41.20\r
+       (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+       Thu, 10 Jan 2013 02:41:21 -0800 (PST)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject:\r
+ [PATCH 1/2] contrib: pick: move save-excursion closer to message insertion\r
+Date: Thu, 10 Jan 2013 10:41:16 +0000\r
+Message-Id: <1357814477-1348-2-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1357814477-1348-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1357814477-1348-1-git-send-email-markwalters1009@gmail.com>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=UTF-8\r
+Content-Transfer-Encoding: 8bit\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Thu, 10 Jan 2013 10:41:23 -0000\r
+\r
+Pick keeps point roughly at the top of the buffer while inserting\r
+messages at the end as they come in (from the async\r
+parser). Previously the save-excursion to do this was done once for\r
+each thread inserted: now it is done for each individual message.\r
+\r
+The advantage is that the message insertion code can decide where to\r
+leave point. In the next patch point will be left on the target message.\r
+\r
+Note notmuch-pick-insert-msg is unchanged as that is used by the tag\r
+display update code.\r
+---\r
+ contrib/notmuch-pick/notmuch-pick.el |   17 ++++++++++-------\r
+ 1 files changed, 10 insertions(+), 7 deletions(-)\r
+\r
+diff --git a/contrib/notmuch-pick/notmuch-pick.el b/contrib/notmuch-pick/notmuch-pick.el\r
+index d75a66a..d597126 100644\r
+--- a/contrib/notmuch-pick/notmuch-pick.el\r
++++ b/contrib/notmuch-pick/notmuch-pick.el\r
+@@ -638,6 +638,11 @@ unchanged ADDRESS if parsing fails."\r
+   (notmuch-pick-set-message-properties msg)\r
+   (insert "\n"))\r
\r
++(defun notmuch-pick-goto-and-insert-msg (msg)\r
++  "Insert msg at the end of the buffer."\r
++  (save-excursion\r
++    (goto-char (point-max))\r
++    (notmuch-pick-insert-msg msg)))\r
+ (defun notmuch-pick-insert-tree (tree depth tree-status first last)\r
+   "Insert the message tree TREE at depth DEPTH in the current thread."\r
+   (let ((msg (car tree))\r
+@@ -659,7 +664,7 @@ unchanged ADDRESS if parsing fails."\r
+       (push "├" tree-status)))\r
\r
+       (push (concat (if replies "┬" "─") "►") tree-status)\r
+-      (notmuch-pick-insert-msg (plist-put msg :tree-status tree-status))\r
++      (notmuch-pick-goto-and-insert-msg (plist-put msg :tree-status tree-status))\r
+       (pop tree-status)\r
+       (pop tree-status)\r
\r
+@@ -678,12 +683,10 @@ unchanged ADDRESS if parsing fails."\r
+         do (notmuch-pick-insert-tree tree depth tree-status (eq count 1) (eq count n)))))\r
\r
+ (defun notmuch-pick-insert-forest-thread (forest-thread)\r
+-  (save-excursion\r
+-    (goto-char (point-max))\r
+-    (let (tree-status)\r
+-      ;; Reset at the start of each main thread.\r
+-      (setq notmuch-pick-previous-subject nil)\r
+-      (notmuch-pick-insert-thread forest-thread 0 tree-status))))\r
++  (let (tree-status)\r
++    ;; Reset at the start of each main thread.\r
++    (setq notmuch-pick-previous-subject nil)\r
++    (notmuch-pick-insert-thread forest-thread 0 tree-status)))\r
\r
+ (defun notmuch-pick-insert-forest (forest)\r
+   (mapc 'notmuch-pick-insert-forest-thread forest))\r
+-- \r
+1.7.9.1\r
+\r