aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--emacs/notmuch-lib.el16
-rwxr-xr-xtest/emacs2
2 files changed, 16 insertions, 2 deletions
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 69867ada..eeb005ff 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -161,9 +161,23 @@ the user hasn't set this variable with the old or new value."
"[No Subject]"
subject)))
+(defun notmuch-escape-boolean-term (term)
+ "Escape a boolean term for use in a query.
+
+The caller is responsible for prepending the term prefix and a
+colon. This performs minimal escaping in order to produce
+user-friendly queries."
+
+ (save-match-data
+ (if (or (equal term "")
+ (string-match "[ ()]\\|^\"" term))
+ ;; Requires escaping
+ (concat "\"" (replace-regexp-in-string "\"" "\"\"" term t t) "\"")
+ term)))
+
(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) "\""))
+ (concat "id:" (notmuch-escape-boolean-term id)))
;;
diff --git a/test/emacs b/test/emacs
index 21f1d163..44f641eb 100755
--- a/test/emacs
+++ b/test/emacs
@@ -667,7 +667,7 @@ Some One <someone@somewhere.org>
Some One Else <notsomeone@somewhere.org>
Notmuch <notmuch@notmuchmail.org>
Stash my stashables
-id:"bought"
+id:bought
bought
inbox,stashtest
${gen_msg_filename}