[PATCH] emacs: Modify notmuch-show-get-message-id to return message-id unprefixed with "id:".
Jameson Graef Rollins
jrollins at finestructure.net
Sun Oct 9 15:35:48 PDT 2011
This modifies the notmuch-show "c i" binding to yank just the
message-id to the kill-ring, without the "id:" prefix. This makes
this yank binding consistent with the rest of the yank bindings in
that they don't include any search term prefixes. This is a more
natural interface and will cause less confusion when pasting into
non-notmuch contexts.
Internal functions are modified to prepend the "id:" prefix as needed,
including the notmuch-show-get-bodypart-internal and
notmuch-show-save-part internal functions which are modified to accept
just the bare message-id as the primary argument.
---
emacs/notmuch-show.el | 27 ++++++++++++++-------------
test/emacs | 2 +-
2 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 8db5435..be85b12 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -99,7 +99,7 @@ any given message."
(defmacro with-current-notmuch-show-message (&rest body)
"Evaluate body with current buffer set to the text of current message"
`(save-excursion
- (let ((id (notmuch-show-get-message-id)))
+ (let ((id (concat "id:" (notmuch-show-get-message-id))))
(let ((buf (generate-new-buffer (concat "*notmuch-msg-" id "*"))))
(with-current-buffer buf
(call-process notmuch-command nil t nil "show" "--format=raw" id)
@@ -412,7 +412,7 @@ current buffer, if possible."
;; times (hundreds!), which results in many calls to
;; `notmuch part'.
(unless content
- (setq content (notmuch-show-get-bodypart-internal (concat "id:" message-id)
+ (setq content (notmuch-show-get-bodypart-internal message-id
part-number))
(with-current-buffer w3m-current-buffer
(notmuch-show-w3m-cid-store-internal url
@@ -615,12 +615,13 @@ current buffer, if possible."
;; Uses the buffer-local variable notmuch-show-process-crypto to
;; determine if parts should be decrypted first.
(defun notmuch-show-get-bodypart-internal (message-id part-number)
- (let ((args '("show" "--format=raw"))
+ (let ((id (concat "id:" message-id))
+ (args '("show" "--format=raw"))
(part-arg (format "--part=%s" part-number)))
(setq args (append args (list part-arg)))
(if notmuch-show-process-crypto
(setq args (append args '("--decrypt"))))
- (setq args (append args (list message-id)))
+ (setq args (append args (list id)))
(with-temp-buffer
(let ((coding-system-for-read 'no-conversion))
(progn
@@ -629,7 +630,7 @@ current buffer, if possible."
(defun notmuch-show-get-bodypart-content (msg part nth)
(or (plist-get part :content)
- (notmuch-show-get-bodypart-internal (concat "id:" (plist-get msg :id)) nth)))
+ (notmuch-show-get-bodypart-internal (plist-get msg :id) nth)))
;;
@@ -1050,7 +1051,7 @@ All currently available key bindings:
(defun notmuch-show-get-message-id ()
"Return the message id of the current message."
- (concat "id:\"" (notmuch-show-get-prop :id) "\""))
+ (concat "\"" (notmuch-show-get-prop :id) "\""))
;; dme: Would it make sense to use a macro for many of these?
@@ -1195,7 +1196,7 @@ any effects from previous calls to
(defun notmuch-show-reply (&optional prompt-for-sender)
"Reply to the current message."
(interactive "P")
- (notmuch-mua-new-reply (notmuch-show-get-message-id) prompt-for-sender))
+ (notmuch-mua-new-reply (concat "id:" (notmuch-show-get-message-id)) prompt-for-sender))
(defun notmuch-show-forward-message (&optional prompt-for-sender)
"Forward the current message."
@@ -1242,7 +1243,7 @@ any effects from previous calls to
(defun notmuch-show-view-raw-message ()
"View the file holding the current message."
(interactive)
- (let* ((id (notmuch-show-get-message-id))
+ (let* ((id (concat "id:" (notmuch-show-get-message-id)))
(buf (get-buffer-create (concat "*notmuch-raw-" id "*"))))
(call-process notmuch-command nil buf nil "show" "--format=raw" id)
(switch-to-buffer buf)
@@ -1266,11 +1267,11 @@ than only the current message."
(setq shell-command
(concat notmuch-command " show --format=mbox "
(shell-quote-argument
- (mapconcat 'identity (notmuch-show-get-message-ids-for-open-messages) " OR "))
+ (mapconcat 'identity "id:" (notmuch-show-get-message-ids-for-open-messages) " OR "))
" | " command))
(setq shell-command
(concat notmuch-command " show --format=raw "
- (shell-quote-argument (notmuch-show-get-message-id)) " | " command)))
+ (shell-quote-argument (concat "id:" (notmuch-show-get-message-id))) " | " command)))
(let ((buf (get-buffer-create (concat "*notmuch-pipe*"))))
(with-current-buffer buf
(setq buffer-read-only nil)
@@ -1312,7 +1313,7 @@ the result."
(new-tags (notmuch-show-add-tags-worker current-tags toadd)))
(unless (equal current-tags new-tags)
- (apply 'notmuch-tag (notmuch-show-get-message-id)
+ (apply 'notmuch-tag (concat "id:" (notmuch-show-get-message-id))
(mapcar (lambda (s) (concat "+" s)) toadd))
(notmuch-show-set-tags new-tags))))
@@ -1320,13 +1321,13 @@ the result."
"Remove a tag from the current message."
(interactive
(list (notmuch-select-tag-with-completion
- "Tag to remove: " (notmuch-show-get-message-id))))
+ "Tag to remove: " (concat "id:" (notmuch-show-get-message-id)))))
(let* ((current-tags (notmuch-show-get-tags))
(new-tags (notmuch-show-del-tags-worker current-tags toremove)))
(unless (equal current-tags new-tags)
- (apply 'notmuch-tag (notmuch-show-get-message-id)
+ (apply 'notmuch-tag (concat "id:" (notmuch-show-get-message-id))
(mapcar (lambda (s) (concat "-" s)) toremove))
(notmuch-show-set-tags new-tags))))
diff --git a/test/emacs b/test/emacs
index 6d9cfd9..deb5808 100755
--- a/test/emacs
+++ b/test/emacs
@@ -262,7 +262,7 @@ test_expect_equal_file attachment1.gz "$EXPECTED/attachment"
test_begin_subtest "Save attachment from within emacs using notmuch-show-save-part"
# save as archive to test that Emacs does not re-compress .gz
test_emacs '(let ((standard-input "\"attachment2.gz\""))
- (notmuch-show-save-part "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a at mail.gmail.com" 5))' > /dev/null 2>&1
+ (notmuch-show-save-part "cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a at mail.gmail.com" 5))' > /dev/null 2>&1
test_expect_equal_file attachment2.gz "$EXPECTED/attachment"
test_begin_subtest "View raw message within emacs"
--
1.7.6.3
More information about the notmuch
mailing list