Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 2c / 24fca547312168542751ca13dbc54fc1df33e7
1 Return-Path: <jrollins@finestructure.net>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 4FAF0429E25\r
6         for <notmuch@notmuchmail.org>; Sun,  9 Oct 2011 15:35:53 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -2.3\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id YlOzlfVXCOnF for <notmuch@notmuchmail.org>;\r
16         Sun,  9 Oct 2011 15:35:52 -0700 (PDT)\r
17 Received: from outgoing-mail.its.caltech.edu (outgoing-mail.its.caltech.edu\r
18         [131.215.239.19])\r
19         by olra.theworths.org (Postfix) with ESMTP id 3E621431FB6\r
20         for <notmuch@notmuchmail.org>; Sun,  9 Oct 2011 15:35:52 -0700 (PDT)\r
21 Received: from earth-doxen.imss.caltech.edu (localhost [127.0.0.1])\r
22         by earth-doxen-postvirus (Postfix) with ESMTP id C878866E00FA\r
23         for <notmuch@notmuchmail.org>; Sun,  9 Oct 2011 15:35:51 -0700 (PDT)\r
24 X-Spam-Scanned: at Caltech-IMSS on earth-doxen by amavisd-new\r
25 Received: from finestructure.net (unknown [72.10.29.245])\r
26         (Authenticated sender: jrollins)\r
27         by earth-doxen-submit (Postfix) with ESMTP id 809CE66E0240\r
28         for <notmuch@notmuchmail.org>; Sun,  9 Oct 2011 15:35:49 -0700 (PDT)\r
29 Received: by finestructure.net (Postfix, from userid 1000)\r
30         id 88A56666; Sun,  9 Oct 2011 15:35:48 -0700 (PDT)\r
31 From: Jameson Graef Rollins <jrollins@finestructure.net>\r
32 To: Notmuch Mail <notmuch@notmuchmail.org>\r
33 Subject: [PATCH] emacs: Modify notmuch-show-get-message-id to return\r
34         message-id unprefixed with "id:".\r
35 Date: Sun,  9 Oct 2011 15:35:48 -0700\r
36 Message-Id: <1318199748-25058-1-git-send-email-jrollins@finestructure.net>\r
37 X-Mailer: git-send-email 1.7.6.3\r
38 In-Reply-To: <87mxdabyy8.fsf@washington.ligo-wa.caltech.edu>\r
39 References: <87mxdabyy8.fsf@washington.ligo-wa.caltech.edu>\r
40 X-BeenThere: notmuch@notmuchmail.org\r
41 X-Mailman-Version: 2.1.13\r
42 Precedence: list\r
43 List-Id: "Use and development of the notmuch mail system."\r
44         <notmuch.notmuchmail.org>\r
45 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
46         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
47 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
48 List-Post: <mailto:notmuch@notmuchmail.org>\r
49 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
50 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
51         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
52 X-List-Received-Date: Sun, 09 Oct 2011 22:35:53 -0000\r
53 \r
54 This modifies the notmuch-show "c i" binding to yank just the\r
55 message-id to the kill-ring, without the "id:" prefix.  This makes\r
56 this yank binding consistent with the rest of the yank bindings in\r
57 that they don't include any search term prefixes.  This is a more\r
58 natural interface and will cause less confusion when pasting into\r
59 non-notmuch contexts.\r
60 \r
61 Internal functions are modified to prepend the "id:" prefix as needed,\r
62 including the notmuch-show-get-bodypart-internal and\r
63 notmuch-show-save-part internal functions which are modified to accept\r
64 just the bare message-id as the primary argument.\r
65 ---\r
66  emacs/notmuch-show.el |   27 ++++++++++++++-------------\r
67  test/emacs            |    2 +-\r
68  2 files changed, 15 insertions(+), 14 deletions(-)\r
69 \r
70 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
71 index 8db5435..be85b12 100644\r
72 --- a/emacs/notmuch-show.el\r
73 +++ b/emacs/notmuch-show.el\r
74 @@ -99,7 +99,7 @@ any given message."\r
75  (defmacro with-current-notmuch-show-message (&rest body)\r
76    "Evaluate body with current buffer set to the text of current message"\r
77    `(save-excursion\r
78 -     (let ((id (notmuch-show-get-message-id)))\r
79 +     (let ((id (concat "id:" (notmuch-show-get-message-id))))\r
80         (let ((buf (generate-new-buffer (concat "*notmuch-msg-" id "*"))))\r
81           (with-current-buffer buf\r
82             (call-process notmuch-command nil t nil "show" "--format=raw" id)\r
83 @@ -412,7 +412,7 @@ current buffer, if possible."\r
84           ;; times (hundreds!), which results in many calls to\r
85           ;; `notmuch part'.\r
86           (unless content\r
87 -           (setq content (notmuch-show-get-bodypart-internal (concat "id:" message-id)\r
88 +           (setq content (notmuch-show-get-bodypart-internal message-id\r
89                                                               part-number))\r
90             (with-current-buffer w3m-current-buffer\r
91               (notmuch-show-w3m-cid-store-internal url\r
92 @@ -615,12 +615,13 @@ current buffer, if possible."\r
93  ;; Uses the buffer-local variable notmuch-show-process-crypto to\r
94  ;; determine if parts should be decrypted first.\r
95  (defun notmuch-show-get-bodypart-internal (message-id part-number)\r
96 -  (let ((args '("show" "--format=raw"))\r
97 +  (let ((id (concat "id:" message-id))\r
98 +       (args '("show" "--format=raw"))\r
99         (part-arg (format "--part=%s" part-number)))\r
100      (setq args (append args (list part-arg)))\r
101      (if notmuch-show-process-crypto\r
102         (setq args (append args '("--decrypt"))))\r
103 -    (setq args (append args (list message-id)))\r
104 +    (setq args (append args (list id)))\r
105      (with-temp-buffer\r
106        (let ((coding-system-for-read 'no-conversion))\r
107         (progn\r
108 @@ -629,7 +630,7 @@ current buffer, if possible."\r
109  \r
110  (defun notmuch-show-get-bodypart-content (msg part nth)\r
111    (or (plist-get part :content)\r
112 -      (notmuch-show-get-bodypart-internal (concat "id:" (plist-get msg :id)) nth)))\r
113 +      (notmuch-show-get-bodypart-internal (plist-get msg :id) nth)))\r
114  \r
115  ;; \f\r
116 \r
117  \r
118 @@ -1050,7 +1051,7 @@ All currently available key bindings:\r
119  \r
120  (defun notmuch-show-get-message-id ()\r
121    "Return the message id of the current message."\r
122 -  (concat "id:\"" (notmuch-show-get-prop :id) "\""))\r
123 +  (concat "\"" (notmuch-show-get-prop :id) "\""))\r
124  \r
125  ;; dme: Would it make sense to use a macro for many of these?\r
126  \r
127 @@ -1195,7 +1196,7 @@ any effects from previous calls to\r
128  (defun notmuch-show-reply (&optional prompt-for-sender)\r
129    "Reply to the current message."\r
130    (interactive "P")\r
131 -  (notmuch-mua-new-reply (notmuch-show-get-message-id) prompt-for-sender))\r
132 +  (notmuch-mua-new-reply (concat "id:" (notmuch-show-get-message-id)) prompt-for-sender))\r
133  \r
134  (defun notmuch-show-forward-message (&optional prompt-for-sender)\r
135    "Forward the current message."\r
136 @@ -1242,7 +1243,7 @@ any effects from previous calls to\r
137  (defun notmuch-show-view-raw-message ()\r
138    "View the file holding the current message."\r
139    (interactive)\r
140 -  (let* ((id (notmuch-show-get-message-id))\r
141 +  (let* ((id (concat "id:" (notmuch-show-get-message-id)))\r
142          (buf (get-buffer-create (concat "*notmuch-raw-" id "*"))))\r
143      (call-process notmuch-command nil buf nil "show" "--format=raw" id)\r
144      (switch-to-buffer buf)\r
145 @@ -1266,11 +1267,11 @@ than only the current message."\r
146         (setq shell-command \r
147               (concat notmuch-command " show --format=mbox "\r
148                       (shell-quote-argument\r
149 -                      (mapconcat 'identity (notmuch-show-get-message-ids-for-open-messages) " OR "))\r
150 +                      (mapconcat 'identity "id:" (notmuch-show-get-message-ids-for-open-messages) " OR "))\r
151                       " | " command))\r
152        (setq shell-command\r
153             (concat notmuch-command " show --format=raw "\r
154 -                   (shell-quote-argument (notmuch-show-get-message-id)) " | " command)))\r
155 +                   (shell-quote-argument (concat "id:" (notmuch-show-get-message-id))) " | " command)))\r
156      (let ((buf (get-buffer-create (concat "*notmuch-pipe*"))))\r
157        (with-current-buffer buf\r
158         (setq buffer-read-only nil)\r
159 @@ -1312,7 +1313,7 @@ the result."\r
160          (new-tags (notmuch-show-add-tags-worker current-tags toadd)))\r
161  \r
162      (unless (equal current-tags new-tags)\r
163 -      (apply 'notmuch-tag (notmuch-show-get-message-id)\r
164 +      (apply 'notmuch-tag (concat "id:" (notmuch-show-get-message-id))\r
165              (mapcar (lambda (s) (concat "+" s)) toadd))\r
166        (notmuch-show-set-tags new-tags))))\r
167  \r
168 @@ -1320,13 +1321,13 @@ the result."\r
169    "Remove a tag from the current message."\r
170    (interactive\r
171     (list (notmuch-select-tag-with-completion\r
172 -         "Tag to remove: " (notmuch-show-get-message-id))))\r
173 +         "Tag to remove: " (concat "id:" (notmuch-show-get-message-id)))))\r
174  \r
175    (let* ((current-tags (notmuch-show-get-tags))\r
176          (new-tags (notmuch-show-del-tags-worker current-tags toremove)))\r
177  \r
178      (unless (equal current-tags new-tags)\r
179 -      (apply 'notmuch-tag (notmuch-show-get-message-id)\r
180 +      (apply 'notmuch-tag (concat "id:" (notmuch-show-get-message-id))\r
181              (mapcar (lambda (s) (concat "-" s)) toremove))\r
182        (notmuch-show-set-tags new-tags))))\r
183  \r
184 diff --git a/test/emacs b/test/emacs\r
185 index 6d9cfd9..deb5808 100755\r
186 --- a/test/emacs\r
187 +++ b/test/emacs\r
188 @@ -262,7 +262,7 @@ test_expect_equal_file attachment1.gz "$EXPECTED/attachment"\r
189  test_begin_subtest "Save attachment from within emacs using notmuch-show-save-part"\r
190  # save as archive to test that Emacs does not re-compress .gz\r
191  test_emacs '(let ((standard-input "\"attachment2.gz\""))\r
192 -             (notmuch-show-save-part "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com" 5))' > /dev/null 2>&1\r
193 +             (notmuch-show-save-part "cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com" 5))' > /dev/null 2>&1\r
194  test_expect_equal_file attachment2.gz "$EXPECTED/attachment"\r
195  \r
196  test_begin_subtest "View raw message within emacs"\r
197 -- \r
198 1.7.6.3\r
199 \r