[PATCH v2 2/2] emacs: add `notmuch-show-stash-mlarchive-link{, -and-go}'
authorPieter Praet <pieter@praet.org>
Mon, 30 Jan 2012 07:12:54 +0000 (08:12 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:43:36 +0000 (09:43 -0800)
11/fe2a0ca7a4b8c065df7a145905192eaaed568e [new file with mode: 0644]

diff --git a/11/fe2a0ca7a4b8c065df7a145905192eaaed568e b/11/fe2a0ca7a4b8c065df7a145905192eaaed568e
new file mode 100644 (file)
index 0000000..3de7184
--- /dev/null
@@ -0,0 +1,217 @@
+Return-Path: <pieter@praet.org>\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 95F3A42117E\r
+       for <notmuch@notmuchmail.org>; Sun, 29 Jan 2012 23:15:11 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.677\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.677 tagged_above=-999 required=5\r
+       tests=[HS_INDEX_PARAM=0.023, RCVD_IN_DNSWL_LOW=-0.7]\r
+       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 VMzreRimSV0J for <notmuch@notmuchmail.org>;\r
+       Sun, 29 Jan 2012 23:15:08 -0800 (PST)\r
+Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com\r
+       [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id AD707429E4E\r
+       for <notmuch@notmuchmail.org>; Sun, 29 Jan 2012 23:15:04 -0800 (PST)\r
+Received: by mail-wi0-f181.google.com with SMTP id hi8so3322964wib.26\r
+       for <notmuch@notmuchmail.org>; Sun, 29 Jan 2012 23:15:04 -0800 (PST)\r
+Received: by 10.180.93.194 with SMTP id cw2mr8490259wib.0.1327907704403;\r
+       Sun, 29 Jan 2012 23:15:04 -0800 (PST)\r
+Received: from localhost ([109.131.39.11])\r
+       by mx.google.com with ESMTPS id eq5sm49621542wib.2.2012.01.29.23.15.03\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Sun, 29 Jan 2012 23:15:04 -0800 (PST)\r
+From: Pieter Praet <pieter@praet.org>\r
+To: David Edmondson <dme@dme.org>\r
+Subject: [PATCH v2 2/2] emacs: add `notmuch-show-stash-mlarchive-link{,\r
+       -and-go}'\r
+Date: Mon, 30 Jan 2012 08:12:54 +0100\r
+Message-Id: <1327907574-12760-2-git-send-email-pieter@praet.org>\r
+X-Mailer: git-send-email 1.7.8.1\r
+In-Reply-To: <1327397873-20596-1-git-send-email-dme@dme.org>\r
+References: <1327397873-20596-1-git-send-email-dme@dme.org>\r
+Cc: Notmuch Mail <notmuch@notmuchmail.org>\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: Mon, 30 Jan 2012 07:15:11 -0000\r
+\r
+* emacs/notmuch-show.el\r
+\r
+  (notmuch-show-stash-mlarchive-link-alist):\r
+    New defcustom of type `alist' (key = name, value = URI),\r
+    containing Mailing List Archive URI's for searching by Message-Id.\r
+\r
+  (notmuch-show-stash-mlarchive-link-default):\r
+    New defcustom, default MLA to use when `notmuch-show-stash-mlarchive-link'\r
+    received no user input whatsoever.  Available choices are generated using\r
+    the contents of `notmuch-show-stash-mlarchive-link-alist'.\r
+\r
+  (notmuch-show-stash-map):\r
+    Added keybinds "l" and "L" for `notmuch-show-stash-mlarchive-link'\r
+    respectively `notmuch-show-stash-mlarchive-link-and-go'.\r
+\r
+  (notmuch-show-stash-mlarchive-link):\r
+    New function, stashes a URI pointing to the current message at one\r
+    of the MLAs configured in `notmuch-show-stash-mlarchive-link-alist'.\r
+    Prompts user with `completing-read' if not provided with an MLA key.\r
+\r
+  (notmuch-show-stash-mlarchive-link-and-go):\r
+    New function, uses `notmuch-show-stash-mlarchive-link' to\r
+    stash a URI, and then visits it using the browser configured\r
+    in `browse-url-browser-function'.\r
+\r
+* test/emacs\r
+\r
+  Expanded subtest "Stashing in notmuch-show" wrt new functions\r
+  `notmuch-show-stash-mlarchive-link{,-and-go}'.\r
+\r
+\r
+Based on original work [1] by David Edmondson <dme@dme.org>.\r
+\r
+[1] id:"1327397873-20596-1-git-send-email-dme@dme.org"\r
+\r
+---\r
+\r
+Addressed comments by David Edmondson [2] and Dmitry Kurochkin [3].\r
+\r
+[2] id:"cunsjj1jyfj.fsf@hotblack-desiato.hh.sledj.net"\r
+[3] id:"87zkd9je5j.fsf@gmail.com"\r
+\r
+ emacs/notmuch-show.el |   61 +++++++++++++++++++++++++++++++++++++++++++++++++\r
+ test/emacs            |    8 +++++-\r
+ 2 files changed, 68 insertions(+), 1 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index b13d088..3d1312c 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -124,6 +124,35 @@ indentation."\r
+                (const :tag "View interactively"\r
+                       notmuch-show-interactively-view-part)))\r
+ \r
++(defcustom notmuch-show-stash-mlarchive-link-alist\r
++  '(("Gmane" . "http://mid.gmane.org/")\r
++    ("MARC" . "http://marc.info/?i=")\r
++    ("Mail Archive, The" . "http://mail-archive.com/search?l=mid&q=")\r
++    ;; FIXME: can these services be searched by `Message-Id' ?\r
++    ;; ("MarkMail" . "http://markmail.org/")\r
++    ;; ("Nabble" . "http://nabble.com/")\r
++    ;; ("opensubscriber" . "http://opensubscriber.com/")\r
++    )\r
++  "List of Mailing List Archives to use when stashing links.\r
++\r
++These URIs are concatenated with the current message's\r
++Message-Id in `notmuch-show-stash-mlarchive-link'."\r
++  :type '(alist :key-type (string :tag "Name")\r
++              :value-type (string :tag "URL"))\r
++  :group 'notmuch-show)\r
++\r
++(defcustom notmuch-show-stash-mlarchive-link-default "Gmane"\r
++  "Default Mailing List Archive to use when stashing links.\r
++\r
++This is used when `notmuch-show-stash-mlarchive-link' isn't\r
++provided with an MLA argument nor `completing-read' input."\r
++  :type `(choice\r
++        ,@(mapcar\r
++           (lambda (mla)\r
++             (list 'const :tag (car mla) :value (car mla)))\r
++           notmuch-show-stash-mlarchive-link-alist))\r
++  :group 'notmuch-show)\r
++\r
+ (defmacro with-current-notmuch-show-message (&rest body)\r
+   "Evaluate body with current buffer set to the text of current message"\r
+   `(save-excursion\r
+@@ -1048,6 +1077,8 @@ thread id.  If a prefix is given, crypto processing is toggled."\r
+     (define-key map "s" 'notmuch-show-stash-subject)\r
+     (define-key map "T" 'notmuch-show-stash-tags)\r
+     (define-key map "t" 'notmuch-show-stash-to)\r
++    (define-key map "l" 'notmuch-show-stash-mlarchive-link)\r
++    (define-key map "L" 'notmuch-show-stash-mlarchive-link-and-go)\r
+     map)\r
+   "Submap for stash commands")\r
+ (fset 'notmuch-show-stash-map notmuch-show-stash-map)\r
+@@ -1640,6 +1671,36 @@ buffer."\r
+   (interactive)\r
+   (notmuch-common-do-stash (notmuch-show-get-to)))\r
+ \r
++(defun notmuch-show-stash-mlarchive-link (&optional mla)\r
++  "Copy an ML Archive URI for the current message to the kill-ring.\r
++\r
++This presumes that the message is available at the selected Mailing List Archive.\r
++\r
++If optional argument MLA is non-nil, use the provided key instead of prompting\r
++the user (see `notmuch-show-stash-mlarchive-link-alist')."\r
++  (interactive)\r
++  (notmuch-common-do-stash\r
++   (concat (cdr (assoc\r
++               (or mla\r
++                   (let ((completion-ignore-case t))\r
++                     (completing-read\r
++                      "Mailing List Archive: "\r
++                      notmuch-show-stash-mlarchive-link-alist\r
++                      nil t nil nil notmuch-show-stash-mlarchive-link-default)))\r
++               notmuch-show-stash-mlarchive-link-alist))\r
++         (notmuch-show-get-message-id t))))\r
++\r
++(defun notmuch-show-stash-mlarchive-link-and-go (&optional mla)\r
++  "Copy an ML Archive URI for the current message to the kill-ring and visit it.\r
++\r
++This presumes that the message is available at the selected Mailing List Archive.\r
++\r
++If optional argument MLA is non-nil, use the provided key instead of prompting\r
++the user (see `notmuch-show-stash-mlarchive-link-alist')."\r
++  (interactive)\r
++  (notmuch-show-stash-mlarchive-link mla)\r
++  (browse-url (current-kill 0 t)))\r
++\r
+ ;; Commands typically bound to buttons.\r
+ \r
+ (defun notmuch-show-part-button-default (&optional button)\r
+diff --git a/test/emacs b/test/emacs\r
+index 8ca4c8a..38df3a3 100755\r
+--- a/test/emacs\r
++++ b/test/emacs\r
+@@ -382,9 +382,12 @@ test_emacs '(notmuch-show "id:\"bought\"")\r
+       (notmuch-show-stash-message-id-stripped)\r
+       (notmuch-show-stash-tags)\r
+       (notmuch-show-stash-filename)\r
++      (notmuch-show-stash-mlarchive-link "Gmane")\r
++      (notmuch-show-stash-mlarchive-link "MARC")\r
++      (notmuch-show-stash-mlarchive-link "Mail Archive, The")\r
+       (switch-to-buffer\r
+         (generate-new-buffer "*test-stashing*"))\r
+-      (dotimes (i 9)\r
++      (dotimes (i 12)\r
+         (yank)\r
+         (insert "\n")\r
+         (rotate-yank-pointer 1))\r
+@@ -400,6 +403,9 @@ id:"bought"\r
+ bought\r
+ inbox,stashtest\r
+ ${gen_msg_filename}\r
++http://mid.gmane.org/bought\r
++http://marc.info/?i=bought\r
++http://mail-archive.com/search?l=mid&q=bought\r
+ EOF\r
+ test_expect_equal_file OUTPUT EXPECTED\r
+ \r
+-- \r
+1.7.8.1\r
+\r