From 580997252f80b765b208fcd9f4c696c061e2b9ad Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Thu, 15 Nov 2012 14:49:53 -0500 Subject: [PATCH] emacs: Improve the regexp used to match id:'s in messages This regexp agrees with Xapian query syntax much more closely, though we specifically disallow various cases that would be confusing in the context of an email body (e.g., punctuation at the end of an id: link is not considered part of the id: link because it's probably part of the surrounding text). In particular, this handles id: links that are not surrounded by quotes much better, which stash is much more likely to generate now that we don't quote id's that don't need to be quoted. It also handles quoted id: links better. We update the buttonization test to reflect the new pattern. --- emacs/notmuch-show.el | 20 +++++++++++++++++++- test/emacs-show | 20 ++++++++++---------- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index d061367e..49961fbb 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -996,6 +996,24 @@ message at DEPTH in the current thread." "Insert the forest of threads FOREST." (mapc (lambda (thread) (notmuch-show-insert-thread thread 0)) forest)) +(defvar notmuch-id-regexp + (concat + ;; Match the id: prefix only if it begins a word (to disallow, for + ;; example, matching cid:). + "\\ Date: Fri, 05 Jan 2001 15:43:57 +0000 <> -<> <> <> <> -<> <> -(<> [<> -<> +<>. <>, <>; <>: +<>? <>! +(<>) [<>] +<>... <> <> -<> -<>"c def +<>)def +<> def <>def -<>"c"def -id:"ab c"def +<>def +<>def <>.def id:"abc " -<> +id:) id: -c<> +cid:xxx EOF test_expect_equal_file OUTPUT EXPECTED