[PATCH v2] emacs: show: use interactive instead of current-prefix-arg
authorMark Walters <markwalters1009@gmail.com>
Sun, 13 Oct 2013 07:39:12 +0000 (08:39 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:57:24 +0000 (09:57 -0800)
d9/74e5c4584caf1516e37ea3c4e42b0a6deabd6b [new file with mode: 0644]

diff --git a/d9/74e5c4584caf1516e37ea3c4e42b0a6deabd6b b/d9/74e5c4584caf1516e37ea3c4e42b0a6deabd6b
new file mode 100644 (file)
index 0000000..c3c2238
--- /dev/null
@@ -0,0 +1,175 @@
+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 1B793431FAF\r
+       for <notmuch@notmuchmail.org>; Sun, 13 Oct 2013 00:39:39 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 2.7\r
+X-Spam-Level: **\r
+X-Spam-Status: No, score=2.7 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
+       FREEMAIL_REPLY=2.499, 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 bSK2La6b8A-U for <notmuch@notmuchmail.org>;\r
+       Sun, 13 Oct 2013 00:39:31 -0700 (PDT)\r
+Received: from mail-wi0-f173.google.com (mail-wi0-f173.google.com\r
+       [209.85.212.173]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 54AC5431FAE\r
+       for <notmuch@notmuchmail.org>; Sun, 13 Oct 2013 00:39:31 -0700 (PDT)\r
+Received: by mail-wi0-f173.google.com with SMTP id h11so866021wiv.12\r
+       for <notmuch@notmuchmail.org>; Sun, 13 Oct 2013 00:39:30 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=from:to:cc:subject:date:message-id;\r
+       bh=YqxiVOPYFrqRla8MpM1bOzYLWxXwRaC5ibFxhjr3Bdo=;\r
+       b=0sbkoYSak20hea9264b1bxxM3fBSKwI57Hcyhv38LWqROa9AUm7CFfKIA/ZtadihmZ\r
+       YiIZCXVqEMqhH1ivb1LwOpb+5stJP/UJjH2G6275D5u+OnoFMj/qdPl6OIXEZtmbpMJe\r
+       oe9gQJOBqkxH4ohLIZeRCI2KRiW3wuk5NP0oLc2roCyOTKp/9y7GcUCL8y/8/LfpjMPl\r
+       tc00/0IUlaAwPGKZ5x389E8iMBDNw9KjeTbl4V1BxVjwAUcwks/52ybSspgb28mPJZph\r
+       URyYLGUr1EXPq7HtsKEObBx62mFtqYnoz+afi//MPCMiKXTFQlTfYcZOQue3pLaqF1qJ\r
+       dM9A==\r
+X-Received: by 10.180.160.212 with SMTP id xm20mr9723888wib.23.1381649969892; \r
+       Sun, 13 Oct 2013 00:39:29 -0700 (PDT)\r
+Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
+       by mx.google.com with ESMTPSA id i8sm21922217wiy.6.1969.12.31.16.00.00\r
+       (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+       Sun, 13 Oct 2013 00:39:29 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2] emacs: show: use interactive instead of current-prefix-arg\r
+Date: Sun, 13 Oct 2013 08:39:12 +0100\r
+Message-Id: <1381649952-23122-1-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\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: Sun, 13 Oct 2013 07:39:39 -0000\r
+\r
+Currently notmuch-show looks at the prefix-arg directly via\r
+current-prefix-arg. This changes it to use the interactive\r
+specification.\r
+\r
+One test (for elide-toggle functionality) set the prefix arg\r
+directly. Update this test to set the new argument directly.\r
+---\r
+\r
+This is version 2 of the patches at\r
+id:1381348886-5673-1-git-send-email-markwalters1009@gmail.com The\r
+changes are in fixes in response to Austin's review\r
+id:20131013033157.GE10539@mit.edu and his comments on irc.\r
+\r
+Specifically, this updates the doc string for elide-toggle in\r
+notmuch-show and folds the test fix in (so the tests should always\r
+pass)\r
+\r
+I can also confirm that C-u RET on an id:-button link does work as\r
+expected (and as currently): opening the appropriate message with\r
+inverted elide behaviour.\r
+\r
+Best wishes \r
+\r
+Mark\r
+\r
+\r
+\r
+ emacs/notmuch-show.el |   12 +++++++-----\r
+ emacs/notmuch.el      |    5 +++--\r
+ test/emacs-show       |    3 +--\r
+ 3 files changed, 11 insertions(+), 9 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 5d7e24b..3189dda 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -1080,15 +1080,17 @@ buttons for a corresponding notmuch search."\r
+       (make-text-button (first link) (second link)\r
+                         :type 'notmuch-button-type\r
+                         'action `(lambda (arg)\r
+-                                   (notmuch-show ,(third link)))\r
++                                   (notmuch-show ,(third link) current-prefix-arg))\r
+                         'follow-link t\r
+                         'help-echo "Mouse-1, RET: search for this message"\r
+                         'face goto-address-mail-face)))))\r
\r
+ ;;;###autoload\r
+-(defun notmuch-show (thread-id &optional parent-buffer query-context buffer-name)\r
++(defun notmuch-show (thread-id &optional elide-toggle parent-buffer query-context buffer-name)\r
+   "Run \"notmuch show\" with the given thread ID and display results.\r
\r
++ELIDE-TOGGLE, if non-nil, inverts the default elide behavior.\r
++\r
+ The optional PARENT-BUFFER is the notmuch-search buffer from\r
+ which this notmuch-show command was executed, (so that the\r
+ next thread from that buffer can be show when done with this\r
+@@ -1102,7 +1104,7 @@ The optional BUFFER-NAME provides the name of the buffer in\r
+ which the message thread is shown. If it is nil (which occurs\r
+ when the command is called interactively) the argument to the\r
+ function is used."\r
+-  (interactive "sNotmuch show: ")\r
++  (interactive "sNotmuch show: \nP")\r
+   (let ((buffer-name (generate-new-buffer-name\r
+                     (or buffer-name\r
+                         (concat "*notmuch-" thread-id "*")))))\r
+@@ -1112,9 +1114,9 @@ function is used."\r
+     (setq notmuch-show-process-crypto notmuch-crypto-process-mime)\r
+     ;; Set the default value for\r
+     ;; `notmuch-show-elide-non-matching-messages' in this buffer. If\r
+-    ;; there is a prefix argument, invert the default.\r
++    ;; elide-toggle is set, invert the default.\r
+     (setq notmuch-show-elide-non-matching-messages notmuch-show-only-matching-messages)\r
+-    (if current-prefix-arg\r
++    (if elide-toggle\r
+       (setq notmuch-show-elide-non-matching-messages (not notmuch-show-elide-non-matching-messages)))\r
\r
+     (setq notmuch-show-thread-id thread-id\r
+diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+index 0ff248b..7124d0a 100644\r
+--- a/emacs/notmuch.el\r
++++ b/emacs/notmuch.el\r
+@@ -486,13 +486,14 @@ If BARE is set then do not prefix with \"thread:\""\r
+   "Return a list of authors for the current region"\r
+   (notmuch-search-properties-in-region :subject beg end))\r
\r
+-(defun notmuch-search-show-thread ()\r
++(defun notmuch-search-show-thread (&optional elide-toggle)\r
+   "Display the currently selected thread."\r
+-  (interactive)\r
++  (interactive "P")\r
+   (let ((thread-id (notmuch-search-find-thread-id))\r
+       (subject (notmuch-search-find-subject)))\r
+     (if (> (length thread-id) 0)\r
+       (notmuch-show thread-id\r
++                    elide-toggle\r
+                     (current-buffer)\r
+                     notmuch-search-query-string\r
+                     ;; Name the buffer based on the subject.\r
+diff --git a/test/emacs-show b/test/emacs-show\r
+index ae70053..fb23db4 100755\r
+--- a/test/emacs-show\r
++++ b/test/emacs-show\r
+@@ -91,8 +91,7 @@ test_begin_subtest "notmuch-show: elide non-matching messages (w/ prefix arg to\r
+ test_emacs '(let ((notmuch-show-only-matching-messages nil))\r
+       (notmuch-search "from:lars@seas.harvard.edu and subject:\"Maildir storage\"")\r
+       (notmuch-test-wait)\r
+-      (let ((current-prefix-arg t))\r
+-        (notmuch-search-show-thread))\r
++      (notmuch-search-show-thread t)\r
+       (notmuch-test-wait)\r
+       (test-visible-output))'\r
+ test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-elide-non-matching-messages-on\r
+-- \r
+1.7.9.1\r
+\r