Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 4FAF0429E25 for ; Sun, 9 Oct 2011 15:35:53 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -2.3 X-Spam-Level: X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YlOzlfVXCOnF for ; Sun, 9 Oct 2011 15:35:52 -0700 (PDT) Received: from outgoing-mail.its.caltech.edu (outgoing-mail.its.caltech.edu [131.215.239.19]) by olra.theworths.org (Postfix) with ESMTP id 3E621431FB6 for ; Sun, 9 Oct 2011 15:35:52 -0700 (PDT) Received: from earth-doxen.imss.caltech.edu (localhost [127.0.0.1]) by earth-doxen-postvirus (Postfix) with ESMTP id C878866E00FA for ; Sun, 9 Oct 2011 15:35:51 -0700 (PDT) X-Spam-Scanned: at Caltech-IMSS on earth-doxen by amavisd-new Received: from finestructure.net (unknown [72.10.29.245]) (Authenticated sender: jrollins) by earth-doxen-submit (Postfix) with ESMTP id 809CE66E0240 for ; Sun, 9 Oct 2011 15:35:49 -0700 (PDT) Received: by finestructure.net (Postfix, from userid 1000) id 88A56666; Sun, 9 Oct 2011 15:35:48 -0700 (PDT) From: Jameson Graef Rollins To: Notmuch Mail Subject: [PATCH] emacs: Modify notmuch-show-get-message-id to return message-id unprefixed with "id:". Date: Sun, 9 Oct 2011 15:35:48 -0700 Message-Id: <1318199748-25058-1-git-send-email-jrollins@finestructure.net> X-Mailer: git-send-email 1.7.6.3 In-Reply-To: <87mxdabyy8.fsf@washington.ligo-wa.caltech.edu> References: <87mxdabyy8.fsf@washington.ligo-wa.caltech.edu> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Oct 2011 22:35:53 -0000 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@mail.gmail.com" 5))' > /dev/null 2>&1 + (notmuch-show-save-part "cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@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