[PATCH v2 1/2] emacs: `notmuch-show-get-message-id': optionally return Message-Id sans prefix

Pieter Praet pieter at praet.org
Sun Jan 29 23:12:53 PST 2012


* emacs/notmuch-show.el

  (notmuch-show-get-message-id):
    Add optional arg BARE.  When non-nil, return a Message-Id without
    quotes and prefix, thus obviating the need to strip them off again
    in various places.

  (notmuch-show-stash-message-id-stripped):
    Update wrt changes in `notmuch-show-get-message-id'.

---
 emacs/notmuch-show.el |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 84ac624..b13d088 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1216,9 +1216,14 @@ Some useful entries are:
 		   (notmuch-show-get-message-properties))))
     (plist-get props prop)))
 
-(defun notmuch-show-get-message-id ()
-  "Return the message id of the current message."
-  (concat "id:\"" (notmuch-show-get-prop :id) "\""))
+(defun notmuch-show-get-message-id (&optional bare)
+  "Return the Message-Id of the current message.
+
+If optional argument BARE is non-nil, return
+the Message-Id without prefix and quotes."
+  (if bare
+      (notmuch-show-get-prop :id)
+    (concat "id:\"" (notmuch-show-get-prop :id) "\"")))
 
 ;; dme: Would it make sense to use a macro for many of these?
 
@@ -1618,7 +1623,7 @@ buffer."
 (defun notmuch-show-stash-message-id-stripped ()
   "Copy message ID of current message (sans `id:' prefix) to kill-ring."
   (interactive)
-  (notmuch-common-do-stash (substring (notmuch-show-get-message-id) 4 -1)))
+  (notmuch-common-do-stash (notmuch-show-get-message-id t)))
 
 (defun notmuch-show-stash-subject ()
   "Copy Subject field of current message to kill-ring."
-- 
1.7.8.1



More information about the notmuch mailing list