mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-21 18:38:08 +01:00
emacs: Escape all message ID queries
This adds a lib function to turn a message ID into a properly escaped message ID query and uses this function wherever we previously hand-constructed ID queries. Wherever this new function is used, documentation has been clarified to refer to "id: queries" instead of "message IDs". This fixes the broken test introduced by the previous patch.
This commit is contained in:
parent
5ae960fc19
commit
ee1180018e
4 changed files with 13 additions and 10 deletions
|
@ -144,6 +144,10 @@ the user hasn't set this variable with the old or new value."
|
||||||
"[No Subject]"
|
"[No Subject]"
|
||||||
subject)))
|
subject)))
|
||||||
|
|
||||||
|
(defun notmuch-id-to-query (id)
|
||||||
|
"Return a query that matches the message with id ID."
|
||||||
|
(concat "id:\"" (replace-regexp-in-string "\"" "\"\"" id t t) "\""))
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
(defun notmuch-common-do-stash (text)
|
(defun notmuch-common-do-stash (text)
|
||||||
|
@ -231,7 +235,7 @@ the given type."
|
||||||
|
|
||||||
(defun notmuch-get-bodypart-content (msg part nth process-crypto)
|
(defun notmuch-get-bodypart-content (msg part nth process-crypto)
|
||||||
(or (plist-get part :content)
|
(or (plist-get part :content)
|
||||||
(notmuch-get-bodypart-internal (concat "id:" (plist-get msg :id)) nth process-crypto)))
|
(notmuch-get-bodypart-internal (notmuch-id-to-query (plist-get msg :id)) nth process-crypto)))
|
||||||
|
|
||||||
(defun notmuch-plist-to-alist (plist)
|
(defun notmuch-plist-to-alist (plist)
|
||||||
(loop for (key value . rest) on plist by #'cddr
|
(loop for (key value . rest) on plist by #'cddr
|
||||||
|
|
|
@ -44,7 +44,7 @@ the \"inbox\" and \"todo\", you would set
|
||||||
(concat "+" str)
|
(concat "+" str)
|
||||||
str))
|
str))
|
||||||
notmuch-message-replied-tags)))
|
notmuch-message-replied-tags)))
|
||||||
(apply 'notmuch-tag (concat "id:" (car (car rep))) tags)))))
|
(apply 'notmuch-tag (notmuch-id-to-query (car (car rep))) tags)))))
|
||||||
|
|
||||||
(add-hook 'message-send-hook 'notmuch-message-mark-replied)
|
(add-hook 'message-send-hook 'notmuch-message-mark-replied)
|
||||||
|
|
||||||
|
|
|
@ -613,7 +613,7 @@ current buffer, if possible."
|
||||||
;; times (hundreds!), which results in many calls to
|
;; times (hundreds!), which results in many calls to
|
||||||
;; `notmuch part'.
|
;; `notmuch part'.
|
||||||
(unless content
|
(unless content
|
||||||
(setq content (notmuch-get-bodypart-internal (concat "id:" message-id)
|
(setq content (notmuch-get-bodypart-internal (notmuch-id-to-query message-id)
|
||||||
part-number notmuch-show-process-crypto))
|
part-number notmuch-show-process-crypto))
|
||||||
(with-current-buffer w3m-current-buffer
|
(with-current-buffer w3m-current-buffer
|
||||||
(notmuch-show-w3m-cid-store-internal url
|
(notmuch-show-w3m-cid-store-internal url
|
||||||
|
@ -1325,16 +1325,16 @@ Some useful entries are:
|
||||||
(plist-get props prop)))
|
(plist-get props prop)))
|
||||||
|
|
||||||
(defun notmuch-show-get-message-id (&optional bare)
|
(defun notmuch-show-get-message-id (&optional bare)
|
||||||
"Return the Message-Id of the current message.
|
"Return an id: query for the Message-Id of the current message.
|
||||||
|
|
||||||
If optional argument BARE is non-nil, return
|
If optional argument BARE is non-nil, return
|
||||||
the Message-Id without prefix and quotes."
|
the Message-Id without id: prefix and escaping."
|
||||||
(if bare
|
(if bare
|
||||||
(notmuch-show-get-prop :id)
|
(notmuch-show-get-prop :id)
|
||||||
(concat "id:\"" (notmuch-show-get-prop :id) "\"")))
|
(notmuch-id-to-query (notmuch-show-get-prop :id))))
|
||||||
|
|
||||||
(defun notmuch-show-get-messages-ids ()
|
(defun notmuch-show-get-messages-ids ()
|
||||||
"Return all message ids of messages in the current thread."
|
"Return all id: queries of messages in the current thread."
|
||||||
(let ((message-ids))
|
(let ((message-ids))
|
||||||
(notmuch-show-mapc
|
(notmuch-show-mapc
|
||||||
(lambda () (push (notmuch-show-get-message-id) message-ids)))
|
(lambda () (push (notmuch-show-get-message-id) message-ids)))
|
||||||
|
@ -1401,7 +1401,7 @@ current thread."
|
||||||
;; thread.
|
;; thread.
|
||||||
|
|
||||||
(defun notmuch-show-get-message-ids-for-open-messages ()
|
(defun notmuch-show-get-message-ids-for-open-messages ()
|
||||||
"Return a list of all message IDs for open messages in the current thread."
|
"Return a list of all id: queries for open messages in the current thread."
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(let (message-ids done)
|
(let (message-ids done)
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
|
@ -1805,7 +1805,7 @@ thread from search."
|
||||||
(notmuch-common-do-stash (notmuch-show-get-from)))
|
(notmuch-common-do-stash (notmuch-show-get-from)))
|
||||||
|
|
||||||
(defun notmuch-show-stash-message-id ()
|
(defun notmuch-show-stash-message-id ()
|
||||||
"Copy message ID of current message to kill-ring."
|
"Copy id: query matching the current message to kill-ring."
|
||||||
(interactive)
|
(interactive)
|
||||||
(notmuch-common-do-stash (notmuch-show-get-message-id)))
|
(notmuch-common-do-stash (notmuch-show-get-message-id)))
|
||||||
|
|
||||||
|
|
|
@ -140,7 +140,6 @@ output=$(notmuch search 'id:"123..456@example"' | notmuch_search_sanitize)
|
||||||
test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Message with .. in Message-Id (inbox search-add show-add)"
|
test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Message with .. in Message-Id (inbox search-add show-add)"
|
||||||
|
|
||||||
test_begin_subtest "Message with quote in Message-Id:"
|
test_begin_subtest "Message with quote in Message-Id:"
|
||||||
test_subtest_known_broken
|
|
||||||
add_message '[id]="\"quote\"@example"' '[subject]="Message with quote in Message-Id"'
|
add_message '[id]="\"quote\"@example"' '[subject]="Message with quote in Message-Id"'
|
||||||
test_emacs '(notmuch-search "subject:\"Message with quote\"")
|
test_emacs '(notmuch-search "subject:\"Message with quote\"")
|
||||||
(notmuch-test-wait)
|
(notmuch-test-wait)
|
||||||
|
|
Loading…
Reference in a new issue