From: David Bremner Date: Thu, 15 Mar 2012 01:58:20 +0000 (-0300) Subject: Merge branch 'release' X-Git-Tag: 0.13_rc1~159 X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=commitdiff_plain;h=8c175aa1208857b40dc7a49d6d924344818b8122;hp=d8b131c37dccf3c09a61dbd10b543b75903d9e76 Merge branch 'release' --- diff --git a/NEWS b/NEWS index 18760ce7..2d1114db 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,24 @@ Reply to sender to all. The feature is available through the new command line option --reply-to=(all|sender). +Tag exclusion + + Tags can be automatically excluded from search results by adding them + to the new 'search.exclude_tags' option in the Notmuch config file. + + This behaviour can be overridden by explicitly including an excluded + tag in your query, for example: + + notmuch search $your_query and tag:$excluded_tag + + Existing users will probably want to run "notmuch setup" again to add + the new well-commented [search] section to the configuration file. + + For new configurations, accepting the default setting will cause the + tags "deleted" and "spam" to be excluded, equivalent to running: + + notmuch config set search.exclude_tags deleted spam + Mail store folder/file ignore A new configuration option, `new.ignore`, lets users specify a diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index d17a30f9..e9caade5 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -154,6 +154,108 @@ International Bureau of Weights and Measures." (defvar notmuch-hello-url "http://notmuchmail.org" "The `notmuch' web site.") +(defvar notmuch-hello-search-pos nil + "Position of search widget, if any. + +This should only be set by `notmuch-hello-insert-search'.") + +(defvar notmuch-hello-custom-section-options + '((:filter (string :tag "Filter for each tag")) + (:filter-count (string :tag "Different filter to generate message counts")) + (:initially-hidden (const :tag "Hide this section on startup" t)) + (:show-empty-searches (const :tag "Show queries with no matching messages" t)) + (:hide-if-empty (const :tag "Hide this section if all queries are empty +\(and not shown by show-empty-searches)" t))) + "Various customization-options for notmuch-hello-tags/query-section.") + +(define-widget 'notmuch-hello-tags-section 'lazy + "Customize-type for notmuch-hello tag-list sections." + :tag "Customized tag-list section (see docstring for details)" + :type + `(list :tag "" + (const :tag "" notmuch-hello-insert-tags-section) + (string :tag "Title for this section") + (plist + :inline t + :options + ,(append notmuch-hello-custom-section-options + '((:hide-tags (repeat :tag "Tags that will be hidden" + string))))))) + +(define-widget 'notmuch-hello-query-section 'lazy + "Customize-type for custom saved-search-like sections" + :tag "Customized queries section (see docstring for details)" + :type + `(list :tag "" + (const :tag "" notmuch-hello-insert-query-list) + (string :tag "Title for this section") + (repeat :tag "Queries" + (cons (string :tag "Name") (string :tag "Query"))) + (plist :inline t :options ,notmuch-hello-custom-section-options))) + +(defcustom notmuch-hello-sections + (list #'notmuch-hello-insert-header + #'notmuch-hello-insert-saved-searches + #'notmuch-hello-insert-search + #'notmuch-hello-insert-recent-searches + #'notmuch-hello-insert-alltags + #'notmuch-hello-insert-footer) + "Sections for notmuch-hello. + +The list contains functions which are used to construct sections in +notmuch-hello buffer. When notmuch-hello buffer is constructed, +these functions are run in the order they appear in this list. Each +function produces a section simply by adding content to the current +buffer. A section should not end with an empty line, because a +newline will be inserted after each section by `notmuch-hello'. + +Each function should take no arguments. If the produced section +includes `notmuch-hello-target' (i.e. cursor should be positioned +inside this section), the function should return this element's +position. +Otherwise, it should return nil. + +For convenience an element can also be a list of the form (FUNC ARG1 +ARG2 .. ARGN) in which case FUNC will be applied to the rest of the +list. + +A \"Customized tag-list section\" item in the customize-interface +displays a list of all tags, optionally hiding some of them. It +is also possible to filter the list of messages matching each tag +by an additional filter query. Similarly, the count of messages +displayed next to the buttons can be generated by applying a +different filter to the tag query. These filters are also +supported for \"Customized queries section\" items." + :group 'notmuch + :type + '(repeat + (choice (function-item notmuch-hello-insert-header) + (function-item notmuch-hello-insert-saved-searches) + (function-item notmuch-hello-insert-search) + (function-item notmuch-hello-insert-recent-searches) + (function-item notmuch-hello-insert-alltags) + (function-item notmuch-hello-insert-footer) + (function-item notmuch-hello-insert-inbox) + notmuch-hello-tags-section + notmuch-hello-query-section + (function :tag "Custom section")))) + +(defvar notmuch-hello-target nil + "Button text at position of point before rebuilding the notmuch-buffer. + +This variable contains the text of the button, if any, the +point was positioned at before the notmuch-hello buffer was +rebuilt. This should never actually be global and is defined as a +defvar only for documentation purposes and to avoid a compiler +warning about it occurring as a free variable.") + +(defvar notmuch-hello-hidden-sections nil + "List of sections titles whose contents are hidden") + +(defvar notmuch-hello-first-run t + "True if `notmuch-hello' is run for the first time, set to nil +afterwards.") + (defun notmuch-hello-nice-number (n) (let (result) (while (> n 0) @@ -201,8 +303,8 @@ International Bureau of Weights and Measures." (message "Saved '%s' as '%s'." search name) (notmuch-hello-update))) -(defun notmuch-hello-longest-label (tag-alist) - (or (loop for elem in tag-alist +(defun notmuch-hello-longest-label (searches-alist) + (or (loop for elem in searches-alist maximize (length (car elem))) 0)) @@ -266,12 +368,70 @@ should be. Returns a cons cell `(tags-per-line width)'." (* tags-per-line (+ 9 1)))) tags-per-line)))) -(defun notmuch-hello-insert-tags (tag-alist widest target) - (let* ((tags-and-width (notmuch-hello-tags-per-line widest)) +(defun notmuch-hello-filtered-query (query filter) + "Constructs a query to search all messages matching QUERY and FILTER. + +If FILTER is a string, it is directly used in the returned query. + +If FILTER is a function, it is called with QUERY as a parameter and +the string it returns is used as the query. If nil is returned, +the entry is hidden. + +Otherwise, FILTER is ignored. +" + (cond + ((functionp filter) (funcall filter query)) + ((stringp filter) + (concat "(" query ") and (" filter ")")) + (t query))) + +(defun notmuch-hello-query-counts (query-alist &rest options) + "Compute list of counts of matched messages from QUERY-ALIST. + +QUERY-ALIST must be a list containing elements of the form (NAME . QUERY) +or (NAME QUERY COUNT-QUERY). If the latter form is used, +COUNT-QUERY specifies an alternate query to be used to generate +the count for the associated query. + +The result is the list of elements of the form (NAME QUERY COUNT). + +The values :show-empty-searches, :filter and :filter-count from +options will be handled as specified for +`notmuch-hello-insert-searches'." + (notmuch-remove-if-not + #'identity + (mapcar + (lambda (elem) + (let* ((name (car elem)) + (query-and-count (if (consp (cdr elem)) + ;; do we have a different query for the message count? + (cons (second elem) (third elem)) + (cons (cdr elem) (cdr elem)))) + (message-count + (string-to-number + (notmuch-saved-search-count + (notmuch-hello-filtered-query (cdr query-and-count) + (or (plist-get options :filter-count) + (plist-get options :filter))))))) + (and (or (plist-get options :show-empty-searches) (> message-count 0)) + (list name (notmuch-hello-filtered-query + (car query-and-count) (plist-get options :filter)) + message-count)))) + query-alist))) + +(defun notmuch-hello-insert-buttons (searches) + "Insert buttons for SEARCHES. + +SEARCHES must be a list containing lists of the form (NAME QUERY COUNT), where +QUERY is the query to start when the button for the corresponding entry is +activated. COUNT should be the number of messages matching the query. +Such a list can be computed with `notmuch-hello-query-counts'." + (let* ((widest (notmuch-hello-longest-label searches)) + (tags-and-width (notmuch-hello-tags-per-line widest)) (tags-per-line (car tags-and-width)) (widest (cdr tags-and-width)) (count 0) - (reordered-list (notmuch-hello-reflect tag-alist tags-per-line)) + (reordered-list (notmuch-hello-reflect searches tags-per-line)) ;; Hack the display of the buttons used. (widget-push-button-prefix "") (widget-push-button-suffix "") @@ -281,13 +441,13 @@ should be. Returns a cons cell `(tags-per-line width)'." (mapc (lambda (elem) ;; (not elem) indicates an empty slot in the matrix. (when elem - (let* ((name (car elem)) - (query (cdr elem)) + (let* ((name (first elem)) + (query (second elem)) + (msg-count (third elem)) (formatted-name (format "%s " name))) (widget-insert (format "%8s " - (notmuch-hello-nice-number - (string-to-number (notmuch-saved-search-count query))))) - (if (string= formatted-name target) + (notmuch-hello-nice-number msg-count))) + (if (string= formatted-name notmuch-hello-target) (setq found-target-pos (point-marker))) (widget-create 'push-button :notify #'notmuch-hello-widget-search @@ -359,29 +519,241 @@ Complete list of currently available key bindings: (kill-all-local-variables) (use-local-map notmuch-hello-mode-map) (setq major-mode 'notmuch-hello-mode - mode-name "notmuch-hello") + mode-name "notmuch-hello") (run-mode-hooks 'notmuch-hello-mode-hook) ;;(setq buffer-read-only t) ) -(defun notmuch-hello-generate-tag-alist () +(defun notmuch-hello-generate-tag-alist (&optional hide-tags) "Return an alist from tags to queries to display in the all-tags section." - (notmuch-remove-if-not - #'cdr - (mapcar (lambda (tag) - (cons tag - (cond - ((functionp notmuch-hello-tag-list-make-query) - (concat "tag:" tag " and (" - (funcall notmuch-hello-tag-list-make-query tag) ")")) - ((stringp notmuch-hello-tag-list-make-query) - (concat "tag:" tag " and (" - notmuch-hello-tag-list-make-query ")")) - (t (concat "tag:" tag))))) - (notmuch-remove-if-not - (lambda (tag) - (not (member tag notmuch-hello-hide-tags))) - (process-lines notmuch-command "search-tags"))))) + (mapcar (lambda (tag) + (cons tag (format "tag:%s" tag))) + (notmuch-remove-if-not + (lambda (tag) + (not (member tag hide-tags))) + (process-lines notmuch-command "search-tags")))) + +(defun notmuch-hello-insert-header () + "Insert the default notmuch-hello header." + (when notmuch-show-logo + (let ((image notmuch-hello-logo)) + ;; The notmuch logo uses transparency. That can display poorly + ;; when inserting the image into an emacs buffer (black logo on + ;; a black background), so force the background colour of the + ;; image. We use a face to represent the colour so that + ;; `defface' can be used to declare the different possible + ;; colours, which depend on whether the frame has a light or + ;; dark background. + (setq image (cons 'image + (append (cdr image) + (list :background (face-background 'notmuch-hello-logo-background))))) + (insert-image image)) + (widget-insert " ")) + + (widget-insert "Welcome to ") + ;; Hack the display of the links used. + (let ((widget-link-prefix "") + (widget-link-suffix "")) + (widget-create 'link + :notify (lambda (&rest ignore) + (browse-url notmuch-hello-url)) + :help-echo "Visit the notmuch website." + "notmuch") + (widget-insert ". ") + (widget-insert "You have ") + (widget-create 'link + :notify (lambda (&rest ignore) + (notmuch-hello-update)) + :help-echo "Refresh" + (notmuch-hello-nice-number + (string-to-number (car (process-lines notmuch-command "count"))))) + (widget-insert " messages.\n"))) + + +(defun notmuch-hello-insert-saved-searches () + "Insert the saved-searches section." + (let ((searches (notmuch-hello-query-counts + (if notmuch-saved-search-sort-function + (funcall notmuch-saved-search-sort-function + notmuch-saved-searches) + notmuch-saved-searches) + :show-empty-searches notmuch-show-empty-saved-searches)) + found-target-pos) + (when searches + (widget-insert "Saved searches: ") + (widget-create 'push-button + :notify (lambda (&rest ignore) + (customize-variable 'notmuch-saved-searches)) + "edit") + (widget-insert "\n\n") + (let ((start (point))) + (setq found-target-pos + (notmuch-hello-insert-buttons searches)) + (indent-rigidly start (point) notmuch-hello-indent) + found-target-pos)))) + +(defun notmuch-hello-insert-search () + "Insert a search widget." + (widget-insert "Search: ") + (setq notmuch-hello-search-pos (point-marker)) + (widget-create 'editable-field + ;; Leave some space at the start and end of the + ;; search boxes. + :size (max 8 (- (window-width) notmuch-hello-indent + (length "Search: "))) + :action (lambda (widget &rest ignore) + (notmuch-hello-search (widget-value widget)))) + ;; Add an invisible dot to make `widget-end-of-line' ignore + ;; trailing spaces in the search widget field. A dot is used + ;; instead of a space to make `show-trailing-whitespace' + ;; happy, i.e. avoid it marking the whole line as trailing + ;; spaces. + (widget-insert ".") + (put-text-property (1- (point)) (point) 'invisible t) + (widget-insert "\n")) + +(defun notmuch-hello-insert-recent-searches () + "Insert recent searches." + (when notmuch-search-history + (widget-insert "Recent searches: ") + (widget-create 'push-button + :notify (lambda (&rest ignore) + (setq notmuch-search-history nil) + (notmuch-hello-update)) + "clear") + (widget-insert "\n\n") + (let ((start (point))) + (loop for i from 1 to notmuch-hello-recent-searches-max + for search in notmuch-search-history do + (let ((widget-symbol (intern (format "notmuch-hello-search-%d" i)))) + (set widget-symbol + (widget-create 'editable-field + ;; Don't let the search boxes be + ;; less than 8 characters wide. + :size (max 8 + (- (window-width) + ;; Leave some space + ;; at the start and + ;; end of the + ;; boxes. + (* 2 notmuch-hello-indent) + ;; 1 for the space + ;; before the + ;; `[save]' button. 6 + ;; for the `[save]' + ;; button. + 1 6)) + :action (lambda (widget &rest ignore) + (notmuch-hello-search (widget-value widget))) + search)) + (widget-insert " ") + (widget-create 'push-button + :notify (lambda (widget &rest ignore) + (notmuch-hello-add-saved-search widget)) + :notmuch-saved-search-widget widget-symbol + "save")) + (widget-insert "\n")) + (indent-rigidly start (point) notmuch-hello-indent)) + nil)) + +(defun notmuch-hello-insert-searches (title query-alist &rest options) + "Insert a section with TITLE showing a list of buttons made from QUERY-ALIST. + +QUERY-ALIST must be a list containing elements of the form (NAME . QUERY) +or (NAME QUERY COUNT-QUERY). If the latter form is used, +COUNT-QUERY specifies an alternate query to be used to generate +the count for the associated item. + +Supports the following entries in OPTIONS as a plist: +:initially-hidden - if non-nil, section will be hidden on startup +:show-empty-searches - show buttons with no matching messages +:hide-if-empty - hide if no buttons would be shown + (only makes sense without :show-empty-searches) +:filter - This can be a function that takes the search query as its argument and + returns a filter to be used in conjuction with the query for that search or nil + to hide the element. This can also be a string that is used as a combined with + each query using \"and\". +:filter-count - Separate filter to generate the count displayed each search. Accepts + the same values as :filter. If :filter and :filter-count are specified, this + will be used instead of :filter, not in conjunction with it." + (widget-insert title ": ") + (if (and notmuch-hello-first-run (plist-get options :initially-hidden)) + (add-to-list 'notmuch-hello-hidden-sections title)) + (let ((is-hidden (member title notmuch-hello-hidden-sections)) + (start (point))) + (if is-hidden + (widget-create 'push-button + :notify `(lambda (widget &rest ignore) + (setq notmuch-hello-hidden-sections + (delete ,title notmuch-hello-hidden-sections)) + (notmuch-hello-update)) + "show") + (widget-create 'push-button + :notify `(lambda (widget &rest ignore) + (add-to-list 'notmuch-hello-hidden-sections + ,title) + (notmuch-hello-update)) + "hide")) + (widget-insert "\n") + (let (target-pos) + (when (not is-hidden) + (let ((searches (apply 'notmuch-hello-query-counts query-alist options))) + (when (or (not (plist-get options :hide-if-empty)) + searches) + (widget-insert "\n") + (setq target-pos + (notmuch-hello-insert-buttons searches)) + (indent-rigidly start (point) notmuch-hello-indent)))) + target-pos))) + +(defun notmuch-hello-insert-tags-section (&optional title &rest options) + "Insert a section displaying all tags with message counts. + +TITLE defaults to \"All tags\". +Allowed options are those accepted by `notmuch-hello-insert-searches' and the +following: + +:hide-tags - List of tags that should be excluded." + (apply 'notmuch-hello-insert-searches + (or title "All tags") + (notmuch-hello-generate-tag-alist (plist-get options :hide-tags)) + options)) + +(defun notmuch-hello-insert-inbox () + "Show an entry for each saved search and inboxed messages for each tag" + (notmuch-hello-insert-searches "What's in your inbox" + (append + (notmuch-saved-searches) + (notmuch-hello-generate-tag-alist)) + :filter "tag:inbox")) + +(defun notmuch-hello-insert-alltags () + "Insert a section displaying all tags and associated message counts" + (notmuch-hello-insert-tags-section + nil + :initially-hidden (not notmuch-show-all-tags-list) + :hide-tags notmuch-hello-hide-tags + :filter notmuch-hello-tag-list-make-query)) + +(defun notmuch-hello-insert-footer () + "Insert the notmuch-hello footer." + (let ((start (point))) + (widget-insert "Type a search query and hit RET to view matching threads.\n") + (when notmuch-search-history + (widget-insert "Hit RET to re-submit a previous search. Edit it first if you like.\n") + (widget-insert "Save recent searches with the `save' button.\n")) + (when notmuch-saved-searches + (widget-insert "Edit saved searches with the `edit' button.\n")) + (widget-insert "Hit RET or click on a saved search or tag name to view matching threads.\n") + (widget-insert "`=' to refresh this screen. `s' to search messages. `q' to quit.\n") + (widget-create 'link + :notify (lambda (&rest ignore) + (customize-variable 'notmuch-hello-sections)) + :button-prefix "" :button-suffix "" + "Customize") + (widget-insert " this page.") + (let ((fill-column (- (window-width) notmuch-hello-indent))) + (center-region start (point))))) ;;;###autoload (defun notmuch-hello (&optional no-display) @@ -397,13 +769,13 @@ Complete list of currently available key bindings: (set-buffer "*notmuch-hello*") (switch-to-buffer "*notmuch-hello*")) - (let ((target (if (widget-at) - (widget-value (widget-at)) - (condition-case nil - (progn - (widget-forward 1) - (widget-value (widget-at))) - (error nil)))) + (let ((notmuch-hello-target (if (widget-at) + (widget-value (widget-at)) + (condition-case nil + (progn + (widget-forward 1) + (widget-value (widget-at))) + (error nil)))) (inhibit-read-only t)) ;; Delete all editable widget fields. Editable widget fields are @@ -422,168 +794,20 @@ Complete list of currently available key bindings: (mapc 'delete-overlay (car all)) (mapc 'delete-overlay (cdr all))) - (when notmuch-show-logo - (let ((image notmuch-hello-logo)) - ;; The notmuch logo uses transparency. That can display poorly - ;; when inserting the image into an emacs buffer (black logo on - ;; a black background), so force the background colour of the - ;; image. We use a face to represent the colour so that - ;; `defface' can be used to declare the different possible - ;; colours, which depend on whether the frame has a light or - ;; dark background. - (setq image (cons 'image - (append (cdr image) - (list :background (face-background 'notmuch-hello-logo-background))))) - (insert-image image)) - (widget-insert " ")) - - (widget-insert "Welcome to ") - ;; Hack the display of the links used. - (let ((widget-link-prefix "") - (widget-link-suffix "")) - (widget-create 'link - :notify (lambda (&rest ignore) - (browse-url notmuch-hello-url)) - :help-echo "Visit the notmuch website." - "notmuch") - (widget-insert ". ") - (widget-insert "You have ") - (widget-create 'link - :notify (lambda (&rest ignore) - (notmuch-hello-update)) - :help-echo "Refresh" - (notmuch-hello-nice-number - (string-to-number (car (process-lines notmuch-command "count"))))) - (widget-insert " messages.\n")) - - (let ((found-target-pos nil) - (final-target-pos nil) - (default-pos)) - (let* ((saved-alist - ;; Filter out empty saved searches if required. - (if notmuch-show-empty-saved-searches - notmuch-saved-searches - (loop for elem in notmuch-saved-searches - if (> (string-to-number (notmuch-saved-search-count (cdr elem))) 0) - collect elem))) - (saved-widest (notmuch-hello-longest-label saved-alist)) - (alltags-alist (if notmuch-show-all-tags-list (notmuch-hello-generate-tag-alist))) - (alltags-widest (notmuch-hello-longest-label alltags-alist)) - (widest (max saved-widest alltags-widest))) - - (when saved-alist - ;; Sort saved searches if required. - (when notmuch-saved-search-sort-function - (setq saved-alist - (funcall notmuch-saved-search-sort-function saved-alist))) - (widget-insert "\nSaved searches: ") - (widget-create 'push-button - :notify (lambda (&rest ignore) - (customize-variable 'notmuch-saved-searches)) - "edit") - (widget-insert "\n\n") - (setq final-target-pos (point-marker)) - (let ((start (point))) - (setq found-target-pos (notmuch-hello-insert-tags saved-alist widest target)) - (if found-target-pos - (setq final-target-pos found-target-pos)) - (indent-rigidly start (point) notmuch-hello-indent))) - - (widget-insert "\nSearch: ") - (setq default-pos (point-marker)) - (widget-create 'editable-field - ;; Leave some space at the start and end of the - ;; search boxes. - :size (max 8 (- (window-width) notmuch-hello-indent - (length "Search: "))) - :action (lambda (widget &rest ignore) - (notmuch-hello-search (widget-value widget)))) - ;; Add an invisible dot to make `widget-end-of-line' ignore - ;; trailing spaces in the search widget field. A dot is used - ;; instead of a space to make `show-trailing-whitespace' - ;; happy, i.e. avoid it marking the whole line as trailing - ;; spaces. - (widget-insert ".") - (put-text-property (1- (point)) (point) 'invisible t) - (widget-insert "\n") - - (when notmuch-search-history - (widget-insert "\nRecent searches: ") - (widget-create 'push-button - :notify (lambda (&rest ignore) - (setq notmuch-search-history nil) - (notmuch-hello-update)) - "clear") - (widget-insert "\n\n") - (let ((start (point))) - (loop for i from 1 to notmuch-hello-recent-searches-max - for search in notmuch-search-history do - (let ((widget-symbol (intern (format "notmuch-hello-search-%d" i)))) - (set widget-symbol - (widget-create 'editable-field - ;; Don't let the search boxes be - ;; less than 8 characters wide. - :size (max 8 - (- (window-width) - ;; Leave some space - ;; at the start and - ;; end of the - ;; boxes. - (* 2 notmuch-hello-indent) - ;; 1 for the space - ;; before the - ;; `[save]' button. 6 - ;; for the `[save]' - ;; button. - 1 6)) - :action (lambda (widget &rest ignore) - (notmuch-hello-search (widget-value widget))) - search)) - (widget-insert " ") - (widget-create 'push-button - :notify (lambda (widget &rest ignore) - (notmuch-hello-add-saved-search widget)) - :notmuch-saved-search-widget widget-symbol - "save")) - (widget-insert "\n")) - (indent-rigidly start (point) notmuch-hello-indent))) - - (when alltags-alist - (widget-insert "\nAll tags: ") - (widget-create 'push-button - :notify (lambda (widget &rest ignore) - (setq notmuch-show-all-tags-list nil) - (notmuch-hello-update)) - "hide") - (widget-insert "\n\n") - (let ((start (point))) - (setq found-target-pos (notmuch-hello-insert-tags alltags-alist widest target)) - (unless final-target-pos - (setq final-target-pos found-target-pos)) - (indent-rigidly start (point) notmuch-hello-indent))) - - (widget-insert "\n") - - (unless notmuch-show-all-tags-list - (widget-create 'push-button - :notify (lambda (widget &rest ignore) - (setq notmuch-show-all-tags-list t) - (notmuch-hello-update)) - "Show all tags"))) - - (let ((start (point))) - (widget-insert "\n\n") - (widget-insert "Type a search query and hit RET to view matching threads.\n") - (when notmuch-search-history - (widget-insert "Hit RET to re-submit a previous search. Edit it first if you like.\n") - (widget-insert "Save recent searches with the `save' button.\n")) - (when notmuch-saved-searches - (widget-insert "Edit saved searches with the `edit' button.\n")) - (widget-insert "Hit RET or click on a saved search or tag name to view matching threads.\n") - (widget-insert "`=' to refresh this screen. `s' to search messages. `q' to quit.\n") - (let ((fill-column (- (window-width) notmuch-hello-indent))) - (center-region start (point)))) - + (let (final-target-pos) + (mapc + (lambda (section) + (let ((point-before (point)) + (result (if (functionp section) + (funcall section) + (apply (car section) (cdr section))))) + (if (and (not final-target-pos) (integer-or-marker-p result)) + (setq final-target-pos result)) + ;; don't insert a newline when the previous section didn't show + ;; anything. + (unless (eq (point) point-before) + (widget-insert "\n")))) + notmuch-hello-sections) (widget-setup) (when final-target-pos @@ -592,9 +816,10 @@ Complete list of currently available key bindings: (widget-forward 1))) (unless (widget-at) - (goto-char default-pos)))) - - (run-hooks 'notmuch-hello-refresh-hook)) + (when notmuch-hello-search-pos + (goto-char notmuch-hello-search-pos))))) + (run-hooks 'notmuch-hello-refresh-hook) + (setq notmuch-hello-first-run nil)) (defun notmuch-folder () "Deprecated function for invoking notmuch---calling `notmuch' is preferred now." diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 7c4c0bea..4a606310 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -981,7 +981,8 @@ current buffer, if possible." ;; Message visibility depends on whether it matched the search ;; criteria. - (notmuch-show-message-visible msg (plist-get msg :match)))) + (notmuch-show-message-visible msg (and (plist-get msg :match) + (not (plist-get msg :excluded)))))) (defun notmuch-show-toggle-process-crypto () "Toggle the processing of cryptographic MIME parts." @@ -1081,11 +1082,7 @@ function is used." notmuch-show-parent-buffer parent-buffer notmuch-show-query-context query-context) (notmuch-show-build-buffer) - - ;; Move to the first open message and mark it read - (if (notmuch-show-message-visible-p) - (notmuch-show-mark-read) - (notmuch-show-next-open-message)))) + (notmuch-show-goto-first-wanted-message))) (defun notmuch-show-build-buffer () (let ((inhibit-read-only t)) @@ -1167,9 +1164,7 @@ reset based on the original query." (notmuch-show-apply-state state) ;; We're resetting state, so navigate to the first open message ;; and mark it read, just like opening a new show buffer. - (if (notmuch-show-message-visible-p) - (notmuch-show-mark-read) - (notmuch-show-next-open-message))))) + (notmuch-show-goto-first-wanted-message)))) (defvar notmuch-show-stash-map (let ((map (make-sparse-keymap))) @@ -1601,6 +1596,29 @@ to show, nil otherwise." (goto-char (point-max)))) r)) +(defun notmuch-show-next-matching-message () + "Show the next matching message." + (interactive) + (let (r) + (while (and (setq r (notmuch-show-goto-message-next)) + (not (notmuch-show-get-prop :match)))) + (if r + (progn + (notmuch-show-mark-read) + (notmuch-show-message-adjust)) + (goto-char (point-max))))) + +(defun notmuch-show-goto-first-wanted-message () + "Move to the first open message and mark it read" + (goto-char (point-min)) + (if (notmuch-show-message-visible-p) + (notmuch-show-mark-read) + (notmuch-show-next-open-message)) + (when (eobp) + (goto-char (point-min)) + (unless (notmuch-show-get-prop :match) + (notmuch-show-next-matching-message)))) + (defun notmuch-show-previous-open-message () "Show the previous open message." (interactive) diff --git a/emacs/notmuch.el b/emacs/notmuch.el index f851c6f7..99e0c93a 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -872,16 +872,18 @@ non-authors is found, assume that all of the authors match." (goto-char (point-max)) (if (/= (match-beginning 1) line) (insert (concat "Error: Unexpected output from notmuch search:\n" (substring string line (match-beginning 1)) "\n"))) - (let ((beg (point))) - (notmuch-search-show-result date count authors - (notmuch-prettify-subject subject) tags) - (notmuch-search-color-line beg (point) tag-list) - (put-text-property beg (point) 'notmuch-search-thread-id thread-id) - (put-text-property beg (point) 'notmuch-search-authors authors) - (put-text-property beg (point) 'notmuch-search-subject subject) - (when (string= thread-id notmuch-search-target-thread) - (set 'found-target beg) - (set 'notmuch-search-target-thread "found"))) + ;; We currently just throw away excluded matches. + (unless (eq (aref count 1) ?0) + (let ((beg (point))) + (notmuch-search-show-result date count authors + (notmuch-prettify-subject subject) tags) + (notmuch-search-color-line beg (point) tag-list) + (put-text-property beg (point) 'notmuch-search-thread-id thread-id) + (put-text-property beg (point) 'notmuch-search-authors authors) + (put-text-property beg (point) 'notmuch-search-subject subject) + (when (string= thread-id notmuch-search-target-thread) + (set 'found-target beg) + (set 'notmuch-search-target-thread "found")))) (set 'line (match-end 0))) (set 'more nil) (while (and (< line (length string)) (= (elt string line) ?\n)) diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h index 7bf153e0..ea836f72 100644 --- a/lib/notmuch-private.h +++ b/lib/notmuch-private.h @@ -148,6 +148,8 @@ typedef enum _notmuch_private_status { typedef struct _notmuch_doc_id_set notmuch_doc_id_set_t; +typedef struct _notmuch_string_list notmuch_string_list_t; + /* database.cc */ /* Lookup a prefix value by name. @@ -216,6 +218,7 @@ _notmuch_thread_create (void *ctx, notmuch_database_t *notmuch, unsigned int seed_doc_id, notmuch_doc_id_set_t *match_set, + notmuch_string_list_t *excluded_terms, notmuch_sort_t sort); /* message.cc */ @@ -401,6 +404,7 @@ typedef struct _notmuch_message_list { */ struct visible _notmuch_messages { notmuch_bool_t is_of_list_type; + notmuch_doc_id_set_t *excluded_doc_ids; notmuch_message_node_t *iterator; }; @@ -458,11 +462,11 @@ typedef struct _notmuch_string_node { struct _notmuch_string_node *next; } notmuch_string_node_t; -typedef struct visible _notmuch_string_list { +struct visible _notmuch_string_list { int length; notmuch_string_node_t *head; notmuch_string_node_t **tail; -} notmuch_string_list_t; +}; notmuch_string_list_t * _notmuch_string_list_create (const void *ctx); diff --git a/lib/notmuch.h b/lib/notmuch.h index 7929fe72..babd2086 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -449,6 +449,13 @@ typedef enum { const char * notmuch_query_get_query_string (notmuch_query_t *query); +/* Specify whether to results should omit the excluded results rather + * than just marking them excluded. This is useful for passing a + * notmuch_messages_t not containing the excluded messages to other + * functions. */ +void +notmuch_query_set_omit_excluded_messages (notmuch_query_t *query, notmuch_bool_t omit); + /* Specify the sorting desired for this query. */ void notmuch_query_set_sort (notmuch_query_t *query, notmuch_sort_t sort); @@ -665,8 +672,10 @@ notmuch_thread_get_toplevel_messages (notmuch_thread_t *thread); /* Get the number of messages in 'thread' that matched the search. * * This count includes only the messages in this thread that were - * matched by the search from which the thread was created. Contrast - * with notmuch_thread_get_total_messages() . + * matched by the search from which the thread was created and were + * not excluded by any exclude tags passed in with the query (see + * notmuch_query_add_tag_exclude). Contrast with + * notmuch_thread_get_total_messages() . */ int notmuch_thread_get_matched_messages (notmuch_thread_t *thread); @@ -895,7 +904,8 @@ notmuch_message_get_filenames (notmuch_message_t *message); /* Message flags */ typedef enum _notmuch_message_flag { - NOTMUCH_MESSAGE_FLAG_MATCH + NOTMUCH_MESSAGE_FLAG_MATCH, + NOTMUCH_MESSAGE_FLAG_EXCLUDED } notmuch_message_flag_t; /* Get a value of a flag for the email corresponding to 'message'. */ diff --git a/lib/query.cc b/lib/query.cc index 0b366025..ab18fbc6 100644 --- a/lib/query.cc +++ b/lib/query.cc @@ -28,6 +28,7 @@ struct _notmuch_query { const char *query_string; notmuch_sort_t sort; notmuch_string_list_t *exclude_terms; + notmuch_bool_t omit_excluded_messages; }; typedef struct _notmuch_mset_messages { @@ -57,6 +58,12 @@ struct visible _notmuch_threads { notmuch_doc_id_set_t match_set; }; +/* We need this in the message functions so forward declare. */ +static notmuch_bool_t +_notmuch_doc_id_set_init (void *ctx, + notmuch_doc_id_set_t *doc_ids, + GArray *arr); + notmuch_query_t * notmuch_query_create (notmuch_database_t *notmuch, const char *query_string) @@ -79,6 +86,8 @@ notmuch_query_create (notmuch_database_t *notmuch, query->exclude_terms = _notmuch_string_list_create (query); + query->omit_excluded_messages = FALSE; + return query; } @@ -88,6 +97,12 @@ notmuch_query_get_query_string (notmuch_query_t *query) return query->query_string; } +void +notmuch_query_set_omit_excluded_messages (notmuch_query_t *query, notmuch_bool_t omit) +{ + query->omit_excluded_messages = omit; +} + void notmuch_query_set_sort (notmuch_query_t *query, notmuch_sort_t sort) { @@ -122,12 +137,16 @@ _notmuch_messages_destructor (notmuch_mset_messages_t *messages) return 0; } -/* Return a query that does not match messages with the excluded tags - * registered with the query. Any tags that explicitly appear in - * xquery will not be excluded. */ +/* Return a query that matches messages with the excluded tags + * registered with query. Any tags that explicitly appear in xquery + * will not be excluded, and will be removed from the list of exclude + * tags. The caller of this function has to combine the returned + * query appropriately.*/ static Xapian::Query _notmuch_exclude_tags (notmuch_query_t *query, Xapian::Query xquery) { + Xapian::Query exclude_query = Xapian::Query::MatchNothing; + for (notmuch_string_node_t *term = query->exclude_terms->head; term; term = term->next) { Xapian::TermIterator it = xquery.get_terms_begin (); @@ -137,10 +156,12 @@ _notmuch_exclude_tags (notmuch_query_t *query, Xapian::Query xquery) break; } if (it == end) - xquery = Xapian::Query (Xapian::Query::OP_AND_NOT, - xquery, Xapian::Query (term->string)); + exclude_query = Xapian::Query (Xapian::Query::OP_OR, + exclude_query, Xapian::Query (term->string)); + else + term->string = talloc_strdup (query, ""); } - return xquery; + return exclude_query; } notmuch_messages_t * @@ -168,8 +189,9 @@ notmuch_query_search_messages (notmuch_query_t *query) Xapian::Query mail_query (talloc_asprintf (query, "%s%s", _find_prefix ("type"), "mail")); - Xapian::Query string_query, final_query; + Xapian::Query string_query, final_query, exclude_query; Xapian::MSet mset; + Xapian::MSetIterator iterator; unsigned int flags = (Xapian::QueryParser::FLAG_BOOLEAN | Xapian::QueryParser::FLAG_PHRASE | Xapian::QueryParser::FLAG_LOVEHATE | @@ -187,8 +209,35 @@ notmuch_query_search_messages (notmuch_query_t *query) final_query = Xapian::Query (Xapian::Query::OP_AND, mail_query, string_query); } + messages->base.excluded_doc_ids = NULL; + + if (query->exclude_terms) { + exclude_query = _notmuch_exclude_tags (query, final_query); + exclude_query = Xapian::Query (Xapian::Query::OP_AND, + exclude_query, final_query); + + if (query->omit_excluded_messages) + final_query = Xapian::Query (Xapian::Query::OP_AND_NOT, + final_query, exclude_query); + else { + enquire.set_weighting_scheme (Xapian::BoolWeight()); + enquire.set_query (exclude_query); + + mset = enquire.get_mset (0, notmuch->xapian_db->get_doccount ()); + + GArray *excluded_doc_ids = g_array_new (FALSE, FALSE, sizeof (unsigned int)); + + for (iterator = mset.begin (); iterator != mset.end (); iterator++) { + unsigned int doc_id = *iterator; + g_array_append_val (excluded_doc_ids, doc_id); + } + messages->base.excluded_doc_ids = talloc (messages, _notmuch_doc_id_set); + _notmuch_doc_id_set_init (query, messages->base.excluded_doc_ids, + excluded_doc_ids); + g_array_unref (excluded_doc_ids); + } + } - final_query = _notmuch_exclude_tags (query, final_query); enquire.set_weighting_scheme (Xapian::BoolWeight()); @@ -277,6 +326,10 @@ _notmuch_mset_messages_get (notmuch_messages_t *messages) INTERNAL_ERROR ("a messages iterator contains a non-existent document ID.\n"); } + if (messages->excluded_doc_ids && + _notmuch_doc_id_set_contains (messages->excluded_doc_ids, doc_id)) + notmuch_message_set_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED, TRUE); + return message; } @@ -422,6 +475,7 @@ notmuch_threads_get (notmuch_threads_t *threads) threads->query->notmuch, doc_id, &threads->match_set, + threads->query->exclude_terms, threads->query->sort); } @@ -449,7 +503,7 @@ notmuch_query_count_messages (notmuch_query_t *query) Xapian::Query mail_query (talloc_asprintf (query, "%s%s", _find_prefix ("type"), "mail")); - Xapian::Query string_query, final_query; + Xapian::Query string_query, final_query, exclude_query; Xapian::MSet mset; unsigned int flags = (Xapian::QueryParser::FLAG_BOOLEAN | Xapian::QueryParser::FLAG_PHRASE | @@ -469,7 +523,10 @@ notmuch_query_count_messages (notmuch_query_t *query) mail_query, string_query); } - final_query = _notmuch_exclude_tags (query, final_query); + exclude_query = _notmuch_exclude_tags (query, final_query); + + final_query = Xapian::Query (Xapian::Query::OP_AND_NOT, + final_query, exclude_query); enquire.set_weighting_scheme(Xapian::BoolWeight()); enquire.set_docid_order(Xapian::Enquire::ASCENDING); diff --git a/lib/thread.cc b/lib/thread.cc index 0435ee6d..e976d643 100644 --- a/lib/thread.cc +++ b/lib/thread.cc @@ -214,7 +214,8 @@ _thread_cleanup_author (notmuch_thread_t *thread, */ static void _thread_add_message (notmuch_thread_t *thread, - notmuch_message_t *message) + notmuch_message_t *message, + notmuch_string_list_t *exclude_terms) { notmuch_tags_t *tags; const char *tag; @@ -262,6 +263,15 @@ _thread_add_message (notmuch_thread_t *thread, notmuch_tags_move_to_next (tags)) { tag = notmuch_tags_get (tags); + /* Mark excluded messages. */ + for (notmuch_string_node_t *term = exclude_terms->head; term; + term = term->next) { + /* We ignore initial 'K'. */ + if (strcmp(tag, (term->string + 1)) == 0) { + notmuch_message_set_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED, TRUE); + break; + } + } g_hash_table_insert (thread->tags, xstrdup (tag), NULL); } } @@ -321,7 +331,8 @@ _thread_add_matched_message (notmuch_thread_t *thread, _thread_set_subject_from_message (thread, message); } - thread->matched_messages++; + if (!notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED)) + thread->matched_messages++; if (g_hash_table_lookup_extended (thread->message_hash, notmuch_message_get_message_id (message), NULL, @@ -392,6 +403,7 @@ _notmuch_thread_create (void *ctx, notmuch_database_t *notmuch, unsigned int seed_doc_id, notmuch_doc_id_set_t *match_set, + notmuch_string_list_t *exclude_terms, notmuch_sort_t sort) { notmuch_thread_t *thread; @@ -467,7 +479,7 @@ _notmuch_thread_create (void *ctx, if (doc_id == seed_doc_id) message = seed_message; - _thread_add_message (thread, message); + _thread_add_message (thread, message, exclude_terms); if ( _notmuch_doc_id_set_contains (match_set, doc_id)) { _notmuch_doc_id_set_remove (match_set, doc_id); diff --git a/man/man1/notmuch-config.1 b/man/man1/notmuch-config.1 index 2205d288..d22988a7 100644 --- a/man/man1/notmuch-config.1 +++ b/man/man1/notmuch-config.1 @@ -83,6 +83,14 @@ will be ignored, regardless of the location in the mail store directory hierarchy. .RE +.RS 4 +.TP 4 +.B search.exclude_tags +A list of tags that will be excluded from search results by +default. Using an excluded tag in a query will override that +exclusion. +.RE + .RS 4 .TP 4 .B maildir.synchronize_flags diff --git a/man/man1/notmuch-count.1 b/man/man1/notmuch-count.1 index 79dd6a5b..f593065a 100644 --- a/man/man1/notmuch-count.1 +++ b/man/man1/notmuch-count.1 @@ -38,6 +38,13 @@ Output the number of matching messages. This is the default. Output the number of matching threads. .RE .RE + +.RS 4 +.TP 4 +.BR \-\-no\-exclude + +Do not exclude the messages matching search.exclude_tags in the config file. +.RE .RE .RE diff --git a/man/man1/notmuch-search.1 b/man/man1/notmuch-search.1 index 72874d01..c62ad185 100644 --- a/man/man1/notmuch-search.1 +++ b/man/man1/notmuch-search.1 @@ -112,6 +112,13 @@ result from the end. Limit the number of displayed results to N. .RE +.RS 4 +.TP 4 +.BR \-\-no\-exclude + +Do not exclude the messages matching search.exclude_tags in the config file. +.RE + .SH SEE ALSO \fBnotmuch\fR(1), \fBnotmuch-config\fR(1), \fBnotmuch-count\fR(1), diff --git a/man/man1/notmuch-show.1 b/man/man1/notmuch-show.1 index 27a06b7a..ebdd189f 100644 --- a/man/man1/notmuch-show.1 +++ b/man/man1/notmuch-show.1 @@ -128,6 +128,13 @@ multipart/encrypted part will be replaced by the decrypted content. .RE +.RS 4 +.TP 4 +.B \-\-no-exclude + +Do not exclude the messages matching search.exclude_tags in the config file. +.RE + A common use of .B notmuch show is to display a single thread of email messages. For this, use a diff --git a/notmuch-config.c b/notmuch-config.c index 61fda3ea..e9b27509 100644 --- a/notmuch-config.c +++ b/notmuch-config.c @@ -377,7 +377,8 @@ notmuch_config_open (void *ctx, if (notmuch_config_get_search_exclude_tags (config, &tmp) == NULL) { if (is_new) { - /* We do not set default search_exclude_tags for 0.12 */ + const char *tags[] = { "deleted", "spam" }; + notmuch_config_set_search_exclude_tags (config, tags, 2); } else { notmuch_config_set_search_exclude_tags (config, NULL, 0); } diff --git a/notmuch-count.c b/notmuch-count.c index 63459fb6..46b76ae1 100644 --- a/notmuch-count.c +++ b/notmuch-count.c @@ -35,8 +35,7 @@ notmuch_count_command (void *ctx, int argc, char *argv[]) char *query_str; int opt_index; int output = OUTPUT_MESSAGES; - const char **search_exclude_tags; - size_t search_exclude_tags_length; + notmuch_bool_t no_exclude = FALSE; unsigned int i; notmuch_opt_desc_t options[] = { @@ -44,6 +43,7 @@ notmuch_count_command (void *ctx, int argc, char *argv[]) (notmuch_keyword_t []){ { "threads", OUTPUT_THREADS }, { "messages", OUTPUT_MESSAGES }, { 0, 0 } } }, + { NOTMUCH_OPT_BOOLEAN, &no_exclude, "no-exclude", 'd', 0 }, { 0, 0, 0, 0, 0 } }; @@ -78,10 +78,17 @@ notmuch_count_command (void *ctx, int argc, char *argv[]) return 1; } - search_exclude_tags = notmuch_config_get_search_exclude_tags - (config, &search_exclude_tags_length); - for (i = 0; i < search_exclude_tags_length; i++) - notmuch_query_add_tag_exclude (query, search_exclude_tags[i]); + if (!no_exclude) { + const char **search_exclude_tags; + size_t search_exclude_tags_length; + + search_exclude_tags = notmuch_config_get_search_exclude_tags + (config, &search_exclude_tags_length); + for (i = 0; i < search_exclude_tags_length; i++) + notmuch_query_add_tag_exclude (query, search_exclude_tags[i]); + } + + notmuch_query_set_omit_excluded_messages (query, TRUE); switch (output) { case OUTPUT_MESSAGES: diff --git a/notmuch-search.c b/notmuch-search.c index 92ce38a1..f6061e4e 100644 --- a/notmuch-search.c +++ b/notmuch-search.c @@ -210,6 +210,9 @@ do_search_threads (const search_format_t *format, int first_thread = 1; int i; + if (output == OUTPUT_THREADS) + notmuch_query_set_omit_excluded_messages (query, TRUE); + if (offset < 0) { offset += notmuch_query_count_threads (query); if (offset < 0) @@ -300,6 +303,8 @@ do_search_messages (const search_format_t *format, int first_message = 1; int i; + notmuch_query_set_omit_excluded_messages (query, TRUE); + if (offset < 0) { offset += notmuch_query_count_messages (query); if (offset < 0) @@ -371,6 +376,10 @@ do_search_tags (notmuch_database_t *notmuch, const char *tag; int first_tag = 1; + notmuch_query_set_omit_excluded_messages (query, TRUE); + /* should the following only special case if no excluded terms + * specified? */ + /* Special-case query of "*" for better performance. */ if (strcmp (notmuch_query_get_query_string (query), "*") == 0) { tags = notmuch_database_get_all_tags (notmuch); @@ -426,8 +435,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) output_t output = OUTPUT_SUMMARY; int offset = 0; int limit = -1; /* unlimited */ - const char **search_exclude_tags; - size_t search_exclude_tags_length; + notmuch_bool_t no_exclude = FALSE; unsigned int i; enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT } @@ -449,6 +457,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) { "files", OUTPUT_FILES }, { "tags", OUTPUT_TAGS }, { 0, 0 } } }, + { NOTMUCH_OPT_BOOLEAN, &no_exclude, "no-exclude", 'd', 0 }, { NOTMUCH_OPT_INT, &offset, "offset", 'O', 0 }, { NOTMUCH_OPT_INT, &limit, "limit", 'L', 0 }, { 0, 0, 0, 0, 0 } @@ -496,10 +505,15 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) notmuch_query_set_sort (query, sort); - search_exclude_tags = notmuch_config_get_search_exclude_tags - (config, &search_exclude_tags_length); - for (i = 0; i < search_exclude_tags_length; i++) - notmuch_query_add_tag_exclude (query, search_exclude_tags[i]); + if (!no_exclude) { + const char **search_exclude_tags; + size_t search_exclude_tags_length; + + search_exclude_tags = notmuch_config_get_search_exclude_tags + (config, &search_exclude_tags_length); + for (i = 0; i < search_exclude_tags_length; i++) + notmuch_query_add_tag_exclude (query, search_exclude_tags[i]); + } switch (output) { default: diff --git a/notmuch-setup.c b/notmuch-setup.c index 307231d5..94d0aa7b 100644 --- a/notmuch-setup.c +++ b/notmuch-setup.c @@ -133,6 +133,8 @@ notmuch_setup_command (unused (void *ctx), int is_new; const char **new_tags; size_t new_tags_len; + const char **search_exclude_tags; + size_t search_exclude_tags_len; #define prompt(format, ...) \ do { \ @@ -209,7 +211,22 @@ notmuch_setup_command (unused (void *ctx), } - /* Temporarily remove exclude tag support for 0.12 */ + search_exclude_tags = notmuch_config_get_search_exclude_tags (config, &search_exclude_tags_len); + + printf ("Tags to exclude when searching messages (separated by spaces) ["); + print_tag_list (search_exclude_tags, search_exclude_tags_len); + prompt ("]: "); + + if (strlen (response)) { + GPtrArray *tags = parse_tag_list (ctx, response); + + notmuch_config_set_search_exclude_tags (config, + (const char **) tags->pdata, + tags->len); + + g_ptr_array_free (tags, TRUE); + } + if (! notmuch_config_save (config)) { if (is_new) diff --git a/notmuch-show.c b/notmuch-show.c index 93fb16f3..05d51b27 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -35,52 +35,14 @@ static const notmuch_show_format_t format_text = { }; static void -format_message_json (const void *ctx, - notmuch_message_t *message, - unused (int indent)); -static void -format_headers_json (const void *ctx, - notmuch_message_t *message); - -static void -format_headers_message_part_json (GMimeMessage *message); - -static void -format_part_start_json (unused (GMimeObject *part), - int *part_count); - -static void -format_part_encstatus_json (int status); - -static void -#ifdef GMIME_ATLEAST_26 -format_part_sigstatus_json (GMimeSignatureList* siglist); -#else -format_part_sigstatus_json (const GMimeSignatureValidity* validity); -#endif - -static void -format_part_content_json (GMimeObject *part); - -static void -format_part_end_json (GMimeObject *part); +format_part_json_entry (const void *ctx, mime_node_t *node, + int indent, const notmuch_show_params_t *params); -/* Any changes to the JSON format should be reflected in the file - * devel/schemata. */ static const notmuch_show_format_t format_json = { - "[", NULL, - "{", format_message_json, - "\"headers\": {", format_headers_json, format_headers_message_part_json, "}", - ", \"body\": [", - format_part_start_json, - format_part_encstatus_json, - format_part_sigstatus_json, - format_part_content_json, - format_part_end_json, - ", ", - "]", - "}", ", ", - "]" + .message_set_start = "[", + .part = format_part_json_entry, + .message_set_sep = ", ", + .message_set_end = "]" }; static void @@ -170,7 +132,7 @@ _get_one_line_summary (const void *ctx, notmuch_message_t *message) } static void -format_message_json (const void *ctx, notmuch_message_t *message, unused (int indent)) +format_message_json (const void *ctx, notmuch_message_t *message) { notmuch_tags_t *tags; int first = 1; @@ -181,9 +143,10 @@ format_message_json (const void *ctx, notmuch_message_t *message, unused (int in date = notmuch_message_get_date (message); relative_date = notmuch_time_relative_date (ctx, date); - printf ("\"id\": %s, \"match\": %s, \"filename\": %s, \"timestamp\": %ld, \"date_relative\": \"%s\", \"tags\": [", + printf ("\"id\": %s, \"match\": %s, \"excluded\": %s, \"filename\": %s, \"timestamp\": %ld, \"date_relative\": \"%s\", \"tags\": [", json_quote_str (ctx_quote, notmuch_message_get_message_id (message)), notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH) ? "true" : "false", + notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED) ? "true" : "false", json_quote_str (ctx_quote, notmuch_message_get_filename (message)), date, relative_date); @@ -329,66 +292,35 @@ format_headers_message_part_text (GMimeMessage *message) } static void -format_headers_json (const void *ctx, notmuch_message_t *message) -{ - const char *headers[] = { - "Subject", "From", "To", "Cc", "Bcc", "Date" - }; - const char *name, *value; - unsigned int i; - int first_header = 1; - void *ctx_quote = talloc_new (ctx); - - for (i = 0; i < ARRAY_SIZE (headers); i++) { - name = headers[i]; - value = notmuch_message_get_header (message, name); - if (value) - { - if (!first_header) - fputs (", ", stdout); - first_header = 0; - - printf ("%s: %s", - json_quote_str (ctx_quote, name), - json_quote_str (ctx_quote, value)); - } - } - - talloc_free (ctx_quote); -} - -static void -format_headers_message_part_json (GMimeMessage *message) +format_headers_json (const void *ctx, GMimeMessage *message) { - void *ctx = talloc_new (NULL); - void *ctx_quote = talloc_new (ctx); + void *local = talloc_new (ctx); InternetAddressList *recipients; const char *recipients_string; - printf ("%s: %s", - json_quote_str (ctx_quote, "From"), - json_quote_str (ctx_quote, g_mime_message_get_sender (message))); + printf ("{%s: %s", + json_quote_str (local, "Subject"), + json_quote_str (local, g_mime_message_get_subject (message))); + printf (", %s: %s", + json_quote_str (local, "From"), + json_quote_str (local, g_mime_message_get_sender (message))); recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_TO); recipients_string = internet_address_list_to_string (recipients, 0); if (recipients_string) printf (", %s: %s", - json_quote_str (ctx_quote, "To"), - json_quote_str (ctx_quote, recipients_string)); + json_quote_str (local, "To"), + json_quote_str (local, recipients_string)); recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_CC); recipients_string = internet_address_list_to_string (recipients, 0); if (recipients_string) printf (", %s: %s", - json_quote_str (ctx_quote, "Cc"), - json_quote_str (ctx_quote, recipients_string)); - printf (", %s: %s", - json_quote_str (ctx_quote, "Subject"), - json_quote_str (ctx_quote, g_mime_message_get_subject (message))); - printf (", %s: %s", - json_quote_str (ctx_quote, "Date"), - json_quote_str (ctx_quote, g_mime_message_get_date_as_string (message))); + json_quote_str (local, "Cc"), + json_quote_str (local, recipients_string)); + printf (", %s: %s}", + json_quote_str (local, "Date"), + json_quote_str (local, g_mime_message_get_date_as_string (message))); - talloc_free (ctx_quote); - talloc_free (ctx); + talloc_free (local); } /* Write a MIME text part out to the given stream. @@ -471,29 +403,13 @@ signer_status_to_string (GMimeSignerStatus x) } #endif -static void -format_part_start_json (unused (GMimeObject *part), int *part_count) -{ - printf ("{\"id\": %d", *part_count); -} - -static void -format_part_encstatus_json (int status) -{ - printf (", \"encstatus\": [{\"status\": "); - if (status) { - printf ("\"good\""); - } else { - printf ("\"bad\""); - } - printf ("}]"); -} - #ifdef GMIME_ATLEAST_26 static void -format_part_sigstatus_json (GMimeSignatureList *siglist) +format_part_sigstatus_json (mime_node_t *node) { - printf (", \"sigstatus\": ["); + GMimeSignatureList *siglist = node->sig_list; + + printf ("["); if (!siglist) { printf ("]"); @@ -557,9 +473,11 @@ format_part_sigstatus_json (GMimeSignatureList *siglist) } #else static void -format_part_sigstatus_json (const GMimeSignatureValidity* validity) +format_part_sigstatus_json (mime_node_t *node) { - printf (", \"sigstatus\": ["); + const GMimeSignatureValidity* validity = node->sig_validity; + + printf ("["); if (!validity) { printf ("]"); @@ -618,81 +536,6 @@ format_part_sigstatus_json (const GMimeSignatureValidity* validity) } #endif -static void -format_part_content_json (GMimeObject *part) -{ - GMimeContentType *content_type = g_mime_object_get_content_type (GMIME_OBJECT (part)); - GMimeStream *stream_memory = g_mime_stream_mem_new (); - const char *cid = g_mime_object_get_content_id (part); - void *ctx = talloc_new (NULL); - GByteArray *part_content; - - printf (", \"content-type\": %s", - json_quote_str (ctx, g_mime_content_type_to_string (content_type))); - - if (cid != NULL) - printf(", \"content-id\": %s", json_quote_str (ctx, cid)); - - if (GMIME_IS_PART (part)) - { - const char *filename = g_mime_part_get_filename (GMIME_PART (part)); - if (filename) - printf (", \"filename\": %s", json_quote_str (ctx, filename)); - } - - if (g_mime_content_type_is_type (content_type, "text", "*")) - { - /* For non-HTML text parts, we include the content in the - * JSON. Since JSON must be Unicode, we handle charset - * decoding here and do not report a charset to the caller. - * For text/html parts, we do not include the content. If a - * caller is interested in text/html parts, it should retrieve - * them separately and they will not be decoded. Since this - * makes charset decoding the responsibility on the caller, we - * report the charset for text/html parts. - */ - if (g_mime_content_type_is_type (content_type, "text", "html")) - { - const char *content_charset = g_mime_object_get_content_type_parameter (GMIME_OBJECT (part), "charset"); - - if (content_charset != NULL) - printf (", \"content-charset\": %s", json_quote_str (ctx, content_charset)); - } - else - { - show_text_part_content (part, stream_memory); - part_content = g_mime_stream_mem_get_byte_array (GMIME_STREAM_MEM (stream_memory)); - - printf (", \"content\": %s", json_quote_chararray (ctx, (char *) part_content->data, part_content->len)); - } - } - else if (g_mime_content_type_is_type (content_type, "multipart", "*")) - { - printf (", \"content\": ["); - } - else if (g_mime_content_type_is_type (content_type, "message", "rfc822")) - { - printf (", \"content\": [{"); - } - - talloc_free (ctx); - if (stream_memory) - g_object_unref (stream_memory); -} - -static void -format_part_end_json (GMimeObject *part) -{ - GMimeContentType *content_type = g_mime_object_get_content_type (GMIME_OBJECT (part)); - - if (g_mime_content_type_is_type (content_type, "multipart", "*")) - printf ("]"); - else if (g_mime_content_type_is_type (content_type, "message", "rfc822")) - printf ("}]"); - - printf ("}"); -} - static void format_part_content_raw (GMimeObject *part) { @@ -737,11 +580,12 @@ format_part_text (const void *ctx, mime_node_t *node, notmuch_message_t *message = node->envelope_file; part_type = "message"; - printf ("\f%s{ id:%s depth:%d match:%d filename:%s\n", + printf ("\f%s{ id:%s depth:%d match:%d excluded:%d filename:%s\n", part_type, notmuch_message_get_message_id (message), indent, - notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH), + notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH) ? 1 : 0, + notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED) ? 1 : 0, notmuch_message_get_filename (message)); } else { GMimeContentDisposition *disposition = g_mime_object_get_content_disposition (meta); @@ -810,6 +654,112 @@ format_part_text (const void *ctx, mime_node_t *node, printf ("\f%s}\n", part_type); } +static void +format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first) +{ + /* Any changes to the JSON format should be reflected in the file + * devel/schemata. */ + + if (node->envelope_file) { + printf ("{"); + format_message_json (ctx, node->envelope_file); + + printf ("\"headers\": "); + format_headers_json (ctx, GMIME_MESSAGE (node->part)); + + printf (", \"body\": ["); + format_part_json (ctx, mime_node_child (node, 0), first); + + printf ("]}"); + return; + } + + void *local = talloc_new (ctx); + /* The disposition and content-type metadata are associated with + * the envelope for message parts */ + GMimeObject *meta = node->envelope_part ? + GMIME_OBJECT (node->envelope_part) : node->part; + GMimeContentType *content_type = g_mime_object_get_content_type (meta); + const char *cid = g_mime_object_get_content_id (meta); + const char *filename = GMIME_IS_PART (node->part) ? + g_mime_part_get_filename (GMIME_PART (node->part)) : NULL; + const char *terminator = ""; + int i; + + if (!first) + printf (", "); + + printf ("{\"id\": %d", node->part_num); + + if (node->decrypt_attempted) + printf (", \"encstatus\": [{\"status\": \"%s\"}]", + node->decrypt_success ? "good" : "bad"); + + if (node->verify_attempted) { + printf (", \"sigstatus\": "); + format_part_sigstatus_json (node); + } + + printf (", \"content-type\": %s", + json_quote_str (local, g_mime_content_type_to_string (content_type))); + + if (cid) + printf (", \"content-id\": %s", json_quote_str (local, cid)); + + if (filename) + printf (", \"filename\": %s", json_quote_str (local, filename)); + + if (GMIME_IS_PART (node->part)) { + /* For non-HTML text parts, we include the content in the + * JSON. Since JSON must be Unicode, we handle charset + * decoding here and do not report a charset to the caller. + * For text/html parts, we do not include the content. If a + * caller is interested in text/html parts, it should retrieve + * them separately and they will not be decoded. Since this + * makes charset decoding the responsibility on the caller, we + * report the charset for text/html parts. + */ + if (g_mime_content_type_is_type (content_type, "text", "html")) { + const char *content_charset = g_mime_object_get_content_type_parameter (meta, "charset"); + + if (content_charset != NULL) + printf (", \"content-charset\": %s", json_quote_str (local, content_charset)); + } else if (g_mime_content_type_is_type (content_type, "text", "*")) { + GMimeStream *stream_memory = g_mime_stream_mem_new (); + GByteArray *part_content; + show_text_part_content (node->part, stream_memory); + part_content = g_mime_stream_mem_get_byte_array (GMIME_STREAM_MEM (stream_memory)); + + printf (", \"content\": %s", json_quote_chararray (local, (char *) part_content->data, part_content->len)); + g_object_unref (stream_memory); + } + } else if (GMIME_IS_MULTIPART (node->part)) { + printf (", \"content\": ["); + terminator = "]"; + } else if (GMIME_IS_MESSAGE (node->part)) { + printf (", \"content\": [{"); + printf ("\"headers\": "); + format_headers_json (local, GMIME_MESSAGE (node->part)); + + printf (", \"body\": ["); + terminator = "]}]"; + } + + talloc_free (local); + + for (i = 0; i < node->nchildren; i++) + format_part_json (ctx, mime_node_child (node, i), i == 0); + + printf ("%s}", terminator); +} + +static void +format_part_json_entry (const void *ctx, mime_node_t *node, unused (int indent), + unused (const notmuch_show_params_t *params)) +{ + format_part_json (ctx, node, TRUE); +} + static void show_message (void *ctx, const notmuch_show_format_t *format, @@ -1036,6 +986,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) notmuch_show_params_t params = { .part = -1 }; int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED; notmuch_bool_t verify = FALSE; + notmuch_bool_t no_exclude = FALSE; notmuch_opt_desc_t options[] = { { NOTMUCH_OPT_KEYWORD, &format_sel, "format", 'f', @@ -1048,6 +999,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) { NOTMUCH_OPT_BOOLEAN, ¶ms.entire_thread, "entire-thread", 't', 0 }, { NOTMUCH_OPT_BOOLEAN, ¶ms.decrypt, "decrypt", 'd', 0 }, { NOTMUCH_OPT_BOOLEAN, &verify, "verify", 'v', 0 }, + { NOTMUCH_OPT_BOOLEAN, &no_exclude, "no-exclude", 'n', 0 }, { 0, 0, 0, 0, 0 } }; @@ -1078,6 +1030,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) fprintf (stderr, "Error: specifying parts is incompatible with mbox output format.\n"); return 1; } + format = &format_mbox; break; case NOTMUCH_FORMAT_RAW: @@ -1135,10 +1088,28 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) return 1; } + /* if format=mbox then we can not output excluded messages as + * there is no way to make the exclude flag available */ + if (format_sel == NOTMUCH_FORMAT_MBOX) + notmuch_query_set_omit_excluded_messages (query, TRUE); + + /* If a single message is requested we do not use search_excludes. */ if (params.part >= 0) ret = do_show_single (ctx, query, format, ¶ms); - else + else { + if (!no_exclude) { + const char **search_exclude_tags; + size_t search_exclude_tags_length; + unsigned int i; + + search_exclude_tags = notmuch_config_get_search_exclude_tags + (config, &search_exclude_tags_length); + for (i = 0; i < search_exclude_tags_length; i++) + notmuch_query_add_tag_exclude (query, search_exclude_tags[i]); + } ret = do_show (ctx, query, format, ¶ms); + } + notmuch_query_destroy (query); notmuch_database_close (notmuch); diff --git a/test/count b/test/count index 300b1714..976fff16 100755 --- a/test/count +++ b/test/count @@ -37,4 +37,25 @@ test_expect_equal \ "0" \ "`notmuch count --output=threads ${SEARCH}`" +test_begin_subtest "count excluding \"deleted\" messages" +notmuch config set search.exclude_tags = deleted +generate_message '[subject]="Not deleted"' +generate_message '[subject]="Another not deleted"' +generate_message '[subject]="Deleted"' +notmuch new > /dev/null +notmuch tag +deleted id:$gen_msg_id +test_expect_equal \ + "2" \ + "`notmuch count subject:deleted`" + +test_begin_subtest "count \"deleted\" messages, exclude overridden" +test_expect_equal \ + "1" \ + "`notmuch count subject:deleted and tag:deleted`" + +test_begin_subtest "count \"deleted\" messages, with --no-exclude" +test_expect_equal \ + "3" \ + "`notmuch count --no-exclude subject:deleted`" + test_done diff --git a/test/crypto b/test/crypto index 6723ef87..be752b19 100755 --- a/test/crypto +++ b/test/crypto @@ -43,6 +43,7 @@ output=$(notmuch show --format=json --verify subject:"test signed message 001" \ | sed -e 's|"created": [1234567890]*|"created": 946728000|') expected='[[[{"id": "XXXXX", "match": true, + "excluded": false, "filename": "YYYYY", "timestamp": 946728000, "date_relative": "2000-01-01", @@ -50,9 +51,8 @@ expected='[[[{"id": "XXXXX", "headers": {"Subject": "test signed message 001", "From": "Notmuch Test Suite ", "To": "test_suite@notmuchmail.org", - "Cc": "", - "Bcc": "", - "Date": "01 Jan 2000 12:00:00 -0000"}, + "Date": "Sat, + 01 Jan 2000 12:00:00 +0000"}, "body": [{"id": 1, "sigstatus": [{"status": "good", "fingerprint": "'$FINGERPRINT'", @@ -77,6 +77,7 @@ output=$(notmuch show --format=json --verify subject:"test signed message 001" \ | sed -e 's|"created": [1234567890]*|"created": 946728000|') expected='[[[{"id": "XXXXX", "match": true, + "excluded": false, "filename": "YYYYY", "timestamp": 946728000, "date_relative": "2000-01-01", @@ -84,9 +85,8 @@ expected='[[[{"id": "XXXXX", "headers": {"Subject": "test signed message 001", "From": "Notmuch Test Suite ", "To": "test_suite@notmuchmail.org", - "Cc": "", - "Bcc": "", - "Date": "01 Jan 2000 12:00:00 -0000"}, + "Date": "Sat, + 01 Jan 2000 12:00:00 +0000"}, "body": [{"id": 1, "sigstatus": [{"status": "good", "fingerprint": "'$FINGERPRINT'", @@ -111,6 +111,7 @@ output=$(notmuch show --format=json --verify subject:"test signed message 001" \ | sed -e 's|"created": [1234567890]*|"created": 946728000|') expected='[[[{"id": "XXXXX", "match": true, + "excluded": false, "filename": "YYYYY", "timestamp": 946728000, "date_relative": "2000-01-01", @@ -118,9 +119,8 @@ expected='[[[{"id": "XXXXX", "headers": {"Subject": "test signed message 001", "From": "Notmuch Test Suite ", "To": "test_suite@notmuchmail.org", - "Cc": "", - "Bcc": "", - "Date": "01 Jan 2000 12:00:00 -0000"}, + "Date": "Sat, + 01 Jan 2000 12:00:00 +0000"}, "body": [{"id": 1, "sigstatus": [{"status": "error", "keyid": "'$(echo $FINGERPRINT | cut -c 25-)'", @@ -151,7 +151,7 @@ test_begin_subtest "decryption, --format=text" output=$(notmuch show --format=text --decrypt subject:"test encrypted message 001" \ | notmuch_show_sanitize_all \ | sed -e 's|"created": [1234567890]*|"created": 946728000|') -expected=' message{ id:XXXXX depth:0 match:1 filename:XXXXX +expected=' message{ id:XXXXX depth:0 match:1 excluded:0 filename:XXXXX header{ Notmuch Test Suite (2000-01-01) (encrypted inbox) Subject: test encrypted message 001 @@ -185,6 +185,7 @@ output=$(notmuch show --format=json --decrypt subject:"test encrypted message 00 | sed -e 's|"created": [1234567890]*|"created": 946728000|') expected='[[[{"id": "XXXXX", "match": true, + "excluded": false, "filename": "YYYYY", "timestamp": 946728000, "date_relative": "2000-01-01", @@ -192,9 +193,8 @@ expected='[[[{"id": "XXXXX", "headers": {"Subject": "test encrypted message 001", "From": "Notmuch Test Suite ", "To": "test_suite@notmuchmail.org", - "Cc": "", - "Bcc": "", - "Date": "01 Jan 2000 12:00:00 -0000"}, + "Date": "Sat, + 01 Jan 2000 12:00:00 +0000"}, "body": [{"id": 1, "encstatus": [{"status": "good"}], "sigstatus": [], @@ -240,6 +240,7 @@ output=$(notmuch show --format=json --decrypt subject:"test encrypted message 00 | sed -e 's|"created": [1234567890]*|"created": 946728000|') expected='[[[{"id": "XXXXX", "match": true, + "excluded": false, "filename": "YYYYY", "timestamp": 946728000, "date_relative": "2000-01-01", @@ -247,9 +248,8 @@ expected='[[[{"id": "XXXXX", "headers": {"Subject": "test encrypted message 001", "From": "Notmuch Test Suite ", "To": "test_suite@notmuchmail.org", - "Cc": "", - "Bcc": "", - "Date": "01 Jan 2000 12:00:00 -0000"}, + "Date": "Sat, + 01 Jan 2000 12:00:00 +0000"}, "body": [{"id": 1, "encstatus": [{"status": "bad"}], "content-type": "multipart/encrypted", @@ -275,6 +275,7 @@ output=$(notmuch show --format=json --decrypt subject:"test encrypted message 00 | sed -e 's|"created": [1234567890]*|"created": 946728000|') expected='[[[{"id": "XXXXX", "match": true, + "excluded": false, "filename": "YYYYY", "timestamp": 946728000, "date_relative": "2000-01-01", @@ -282,9 +283,8 @@ expected='[[[{"id": "XXXXX", "headers": {"Subject": "test encrypted message 002", "From": "Notmuch Test Suite ", "To": "test_suite@notmuchmail.org", - "Cc": "", - "Bcc": "", - "Date": "01 Jan 2000 12:00:00 -0000"}, + "Date": "Sat, + 01 Jan 2000 12:00:00 +0000"}, "body": [{"id": 1, "encstatus": [{"status": "good"}], "sigstatus": [{"status": "good", @@ -330,6 +330,7 @@ output=$(notmuch show --format=json --verify subject:"test signed message 001" \ | sed -e 's|"created": [1234567890]*|"created": 946728000|') expected='[[[{"id": "XXXXX", "match": true, + "excluded": false, "filename": "YYYYY", "timestamp": 946728000, "date_relative": "2000-01-01", @@ -337,9 +338,8 @@ expected='[[[{"id": "XXXXX", "headers": {"Subject": "test signed message 001", "From": "Notmuch Test Suite ", "To": "test_suite@notmuchmail.org", - "Cc": "", - "Bcc": "", - "Date": "01 Jan 2000 12:00:00 -0000"}, + "Date": "Sat, + 01 Jan 2000 12:00:00 +0000"}, "body": [{"id": 1, "sigstatus": [{"status": "error", "keyid": "6D92612D94E46381", diff --git a/test/emacs b/test/emacs index 75498928..29a489c7 100755 --- a/test/emacs +++ b/test/emacs @@ -78,7 +78,7 @@ thread=$(notmuch search --output=threads subject:message-with-invalid-from) test_emacs "(notmuch-show \"$thread\") (test-output)" cat <EXPECTED -Invalid " From (2001-01-05) (inbox) +"Invalid " (2001-01-05) (inbox) Subject: message-with-invalid-from To: Notmuch Test Suite Date: Fri, 05 Jan 2001 15:43:57 +0000 @@ -414,7 +414,7 @@ test_emacs '(notmuch-show "id:\"bought\"") (reverse-region (point-min) (point-max)) (test-output)' cat <EXPECTED -Sat, 01 Jan 2000 12:00:00 -0000 +Sat, 01 Jan 2000 12:00:00 +0000 Some One Some One Else Notmuch diff --git a/test/emacs-hello b/test/emacs-hello new file mode 100755 index 00000000..b235e3ab --- /dev/null +++ b/test/emacs-hello @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +test_description="Testing emacs notmuch-hello view" +. test-lib.sh + +EXPECTED=$TEST_DIRECTORY/emacs.expected-output + +add_email_corpus + +test_begin_subtest "User-defined section with inbox tag" +test_emacs "(let ((notmuch-hello-sections + (list (lambda () (notmuch-hello-insert-searches + \"Test\" '((\"inbox\" . \"tag:inbox\"))))))) + (notmuch-hello) + (test-output))" +test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-new-section + +test_begin_subtest "User-defined section with empty, hidden entry" +test_emacs "(let ((notmuch-hello-sections + (list (lambda () (notmuch-hello-insert-searches + \"Test-with-empty\" + '((\"inbox\" . \"tag:inbox\") + (\"doesnotexist\" . \"tag:doesnotexist\")) + :hide-empty-searches t))))) + (notmuch-hello) + (test-output))" +test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-section-with-empty + +test_begin_subtest "User-defined section, unread tag filtered out" +test_emacs "(let ((notmuch-hello-sections + (list (lambda () (notmuch-hello-insert-tags-section + \"Test-with-filtered\" + :hide-tags '(\"unread\")))))) + (notmuch-hello) + (test-output))" +test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-section-hidden-tag + +test_begin_subtest "User-defined section, different query for counts" +test_emacs "(let ((notmuch-hello-sections + (list (lambda () (notmuch-hello-insert-tags-section + \"Test-with-counts\" + :filter-count \"tag:signed\"))))) + (notmuch-hello) + (test-output))" +test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-section-counts + +test_done diff --git a/test/emacs.expected-output/notmuch-hello b/test/emacs.expected-output/notmuch-hello index 3e59595f..14707906 100644 --- a/test/emacs.expected-output/notmuch-hello +++ b/test/emacs.expected-output/notmuch-hello @@ -6,9 +6,10 @@ Saved searches: [edit] Search: . -[Show all tags] +All tags: [show] Type a search query and hit RET to view matching threads. Edit saved searches with the `edit' button. Hit RET or click on a saved search or tag name to view matching threads. `=' to refresh this screen. `s' to search messages. `q' to quit. + Customize this page. diff --git a/test/emacs.expected-output/notmuch-hello-new-section b/test/emacs.expected-output/notmuch-hello-new-section new file mode 100644 index 00000000..c64d7128 --- /dev/null +++ b/test/emacs.expected-output/notmuch-hello-new-section @@ -0,0 +1,4 @@ +Test: [hide] + + 52 inbox + diff --git a/test/emacs.expected-output/notmuch-hello-no-saved-searches b/test/emacs.expected-output/notmuch-hello-no-saved-searches index ef0e5d05..05475b15 100644 --- a/test/emacs.expected-output/notmuch-hello-no-saved-searches +++ b/test/emacs.expected-output/notmuch-hello-no-saved-searches @@ -2,9 +2,10 @@ Search: . -[Show all tags] +All tags: [show] Type a search query and hit RET to view matching threads. Edit saved searches with the `edit' button. Hit RET or click on a saved search or tag name to view matching threads. `=' to refresh this screen. `s' to search messages. `q' to quit. + Customize this page. diff --git a/test/emacs.expected-output/notmuch-hello-section-counts b/test/emacs.expected-output/notmuch-hello-section-counts new file mode 100644 index 00000000..9d796590 --- /dev/null +++ b/test/emacs.expected-output/notmuch-hello-section-counts @@ -0,0 +1,5 @@ +Test-with-counts: [hide] + + 2 attachment 7 signed + 7 inbox 7 unread + diff --git a/test/emacs.expected-output/notmuch-hello-section-hidden-tag b/test/emacs.expected-output/notmuch-hello-section-hidden-tag new file mode 100644 index 00000000..3688e7cd --- /dev/null +++ b/test/emacs.expected-output/notmuch-hello-section-hidden-tag @@ -0,0 +1,4 @@ +Test-with-filtered: [hide] + + 4 attachment 52 inbox 7 signed + diff --git a/test/emacs.expected-output/notmuch-hello-section-with-empty b/test/emacs.expected-output/notmuch-hello-section-with-empty new file mode 100644 index 00000000..8209feda --- /dev/null +++ b/test/emacs.expected-output/notmuch-hello-section-with-empty @@ -0,0 +1,4 @@ +Test-with-empty: [hide] + + 52 inbox + diff --git a/test/emacs.expected-output/notmuch-hello-with-empty b/test/emacs.expected-output/notmuch-hello-with-empty index 71edba73..5e532221 100644 --- a/test/emacs.expected-output/notmuch-hello-with-empty +++ b/test/emacs.expected-output/notmuch-hello-with-empty @@ -6,9 +6,10 @@ Saved searches: [edit] Search: . -[Show all tags] +All tags: [show] Type a search query and hit RET to view matching threads. Edit saved searches with the `edit' button. Hit RET or click on a saved search or tag name to view matching threads. `=' to refresh this screen. `s' to search messages. `q' to quit. + Customize this page. diff --git a/test/encoding b/test/encoding index f0d073c5..98abf77f 100755 --- a/test/encoding +++ b/test/encoding @@ -6,7 +6,7 @@ test_begin_subtest "Message with text of unknown charset" add_message '[content-type]="text/plain; charset=unknown-8bit"' \ "[body]=irrelevant" output=$(notmuch show id:${gen_msg_id} 2>&1 | notmuch_show_sanitize) -test_expect_equal "$output" " message{ id:msg-001@notmuch-test-suite depth:0 match:1 filename:/XXX/mail/msg-001 +test_expect_equal "$output" " message{ id:msg-001@notmuch-test-suite depth:0 match:1 excluded:0 filename:/XXX/mail/msg-001 header{ Notmuch Test Suite (2001-01-05) (inbox unread) Subject: Test message #1 diff --git a/test/json b/test/json index 7df43803..64397886 100755 --- a/test/json +++ b/test/json @@ -5,7 +5,7 @@ test_description="--format=json output" test_begin_subtest "Show message: json" add_message "[subject]=\"json-show-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"json-show-message\"" output=$(notmuch show --format=json "json-show-message") -test_expect_equal "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, \"filename\": \"${gen_msg_filename}\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-subject\", \"From\": \"Notmuch Test Suite \", \"To\": \"Notmuch Test Suite \", \"Cc\": \"\", \"Bcc\": \"\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 -0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"text/plain\", \"content\": \"json-show-message\n\"}]}, []]]]" +test_expect_equal "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, \"excluded\": false, \"filename\": \"${gen_msg_filename}\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-subject\", \"From\": \"Notmuch Test Suite \", \"To\": \"Notmuch Test Suite \", \"Date\": \"Sat, 01 Jan 2000 12:00:00 +0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"text/plain\", \"content\": \"json-show-message\n\"}]}, []]]]" test_begin_subtest "Search message: json" add_message "[subject]=\"json-search-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"json-search-message\"" @@ -22,7 +22,7 @@ test_expect_equal "$output" "[{\"thread\": \"XXX\", test_begin_subtest "Show message: json, utf-8" add_message "[subject]=\"json-show-utf8-body-sübjéct\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"jsön-show-méssage\"" output=$(notmuch show --format=json "jsön-show-méssage") -test_expect_equal "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, \"filename\": \"${gen_msg_filename}\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-utf8-body-sübjéct\", \"From\": \"Notmuch Test Suite \", \"To\": \"Notmuch Test Suite \", \"Cc\": \"\", \"Bcc\": \"\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 -0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"text/plain\", \"content\": \"jsön-show-méssage\n\"}]}, []]]]" +test_expect_equal "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, \"excluded\": false, \"filename\": \"${gen_msg_filename}\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-utf8-body-sübjéct\", \"From\": \"Notmuch Test Suite \", \"To\": \"Notmuch Test Suite \", \"Date\": \"Sat, 01 Jan 2000 12:00:00 +0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"text/plain\", \"content\": \"jsön-show-méssage\n\"}]}, []]]]" test_begin_subtest "Show message: json, inline attachment filename" subject='json-show-inline-attachment-filename' @@ -35,7 +35,7 @@ emacs_deliver_message \ (insert \"Message-ID: <$id>\n\")" output=$(notmuch show --format=json "id:$id") filename=$(notmuch search --output=files "id:$id") -test_expect_equal "$output" "[[[{\"id\": \"$id\", \"match\": true, \"filename\": \"$filename\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\"], \"headers\": {\"Subject\": \"$subject\", \"From\": \"Notmuch Test Suite \", \"To\": \"test_suite@notmuchmail.org\", \"Cc\": \"\", \"Bcc\": \"\", \"Date\": \"01 Jan 2000 12:00:00 -0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"multipart/mixed\", \"content\": [{\"id\": 2, \"content-type\": \"text/plain\", \"content\": \"This is a test message with inline attachment with a filename\"}, {\"id\": 3, \"content-type\": \"application/octet-stream\", \"filename\": \"README\"}]}]}, []]]]" +test_expect_equal "$output" "[[[{\"id\": \"$id\", \"match\": true, \"excluded\": false, \"filename\": \"$filename\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\"], \"headers\": {\"Subject\": \"$subject\", \"From\": \"Notmuch Test Suite \", \"To\": \"test_suite@notmuchmail.org\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 +0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"multipart/mixed\", \"content\": [{\"id\": 2, \"content-type\": \"text/plain\", \"content\": \"This is a test message with inline attachment with a filename\"}, {\"id\": 3, \"content-type\": \"application/octet-stream\", \"filename\": \"README\"}]}]}, []]]]" test_begin_subtest "Search message: json, utf-8" add_message "[subject]=\"json-search-utf8-body-sübjéct\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"jsön-search-méssage\"" diff --git a/test/maildir-sync b/test/maildir-sync index d5872a53..d72ec07e 100755 --- a/test/maildir-sync +++ b/test/maildir-sync @@ -46,6 +46,7 @@ test_begin_subtest "notmuch show works with renamed file (without notmuch new)" output=$(notmuch show --format=json id:${gen_msg_id} | filter_show_json) test_expect_equal "$output" '[[[{"id": "adding-replied-tag@notmuch-test-suite", "match": true, +"excluded": false, "filename": "MAIL_DIR/cur/adding-replied-tag:2,RS", "timestamp": 978709437, "date_relative": "2001-01-05", @@ -53,8 +54,6 @@ test_expect_equal "$output" '[[[{"id": "adding-replied-tag@notmuch-test-suite", "headers": {"Subject": "Adding replied tag", "From": "Notmuch Test Suite ", "To": "Notmuch Test Suite ", -"Cc": "", -"Bcc": "", "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [{"id": 1, diff --git a/test/multipart b/test/multipart index 2dd73f59..53782c6e 100755 --- a/test/multipart +++ b/test/multipart @@ -108,7 +108,7 @@ notmuch new > /dev/null test_begin_subtest "--format=text --part=0, full message" notmuch show --format=text --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT cat <EXPECTED - message{ id:87liy5ap00.fsf@yoom.home.cworth.org depth:0 match:1 filename:${MAIL_DIR}/multipart + message{ id:87liy5ap00.fsf@yoom.home.cworth.org depth:0 match:1 excluded:0 filename:${MAIL_DIR}/multipart header{ Carl Worth (2001-01-05) (attachment inbox signed unread) Subject: Multipart message @@ -322,10 +322,10 @@ notmuch show --format=json --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org' | s echo >>OUTPUT # expect *no* newline at end of output cat <EXPECTED -{"id": "87liy5ap00.fsf@yoom.home.cworth.org", "match": true, "filename": "${MAIL_DIR}/multipart", "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["attachment","inbox","signed","unread"], "headers": {"Subject": "Multipart message", "From": "Carl Worth ", "To": "cworth@cworth.org", "Cc": "", "Bcc": "", "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [ +{"id": "87liy5ap00.fsf@yoom.home.cworth.org", "match": true, "excluded": false, "filename": "${MAIL_DIR}/multipart", "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["attachment","inbox","signed","unread"], "headers": {"Subject": "Multipart message", "From": "Carl Worth ", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [ {"id": 1, "content-type": "multipart/signed", "content": [ {"id": 2, "content-type": "multipart/mixed", "content": [ -{"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"From": "Carl Worth ", "To": "cworth@cworth.org", "Subject": "html message", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [ +{"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth ", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [ {"id": 4, "content-type": "multipart/alternative", "content": [ {"id": 5, "content-type": "text/html"}, {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}, @@ -342,7 +342,7 @@ cat <EXPECTED {"id": 1, "content-type": "multipart/signed", "content": [ {"id": 2, "content-type": "multipart/mixed", "content": [ -{"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"From": "Carl Worth ", "To": "cworth@cworth.org", "Subject": "html message", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [ +{"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth ", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [ {"id": 4, "content-type": "multipart/alternative", "content": [ {"id": 5, "content-type": "text/html"}, {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}, @@ -358,7 +358,7 @@ echo >>OUTPUT # expect *no* newline at end of output cat <EXPECTED {"id": 2, "content-type": "multipart/mixed", "content": [ -{"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"From": "Carl Worth ", "To": "cworth@cworth.org", "Subject": "html message", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [ +{"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth ", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [ {"id": 4, "content-type": "multipart/alternative", "content": [ {"id": 5, "content-type": "text/html"}, {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}, @@ -372,7 +372,7 @@ notmuch show --format=json --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org' | s echo >>OUTPUT # expect *no* newline at end of output cat <EXPECTED -{"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"From": "Carl Worth ", "To": "cworth@cworth.org", "Subject": "html message", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [ +{"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth ", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [ {"id": 4, "content-type": "multipart/alternative", "content": [ {"id": 5, "content-type": "text/html"}, {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]} @@ -594,4 +594,4 @@ notmuch show --format=raw --part=3 id:base64-part-with-crlf > crlf.out echo -n -e "\xEF\x0D\x0A" > crlf.expected test_expect_equal_file crlf.out crlf.expected -test_done +test_done \ No newline at end of file diff --git a/test/notmuch-test b/test/notmuch-test index e14d34e4..f03b594d 100755 --- a/test/notmuch-test +++ b/test/notmuch-test @@ -54,6 +54,7 @@ TESTS=" argument-parsing emacs-test-functions emacs-address-cleaning + emacs-hello emacs-show " TESTS=${NOTMUCH_TESTS:=$TESTS} diff --git a/test/search b/test/search index 414be356..081f60ca 100755 --- a/test/search +++ b/test/search @@ -136,7 +136,8 @@ generate_message '[subject]="Deleted"' notmuch new > /dev/null notmuch tag +deleted id:$gen_msg_id output=$(notmuch search subject:deleted | notmuch_search_sanitize) -test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Not deleted (inbox unread)" +test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Not deleted (inbox unread) +thread:XXX 2001-01-05 [0/1] Notmuch Test Suite; Deleted (deleted inbox unread)" test_begin_subtest "Exclude \"deleted\" messages from search, overridden" output=$(notmuch search subject:deleted and tag:deleted | notmuch_search_sanitize) @@ -148,6 +149,11 @@ output=$(notmuch search subject:deleted | notmuch_search_sanitize) test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Not deleted (inbox unread) thread:XXX 2001-01-05 [1/2] Notmuch Test Suite; Not deleted reply (deleted inbox unread)" +test_begin_subtest "Don't exclude \"deleted\" messages when --no-exclude specified" +output=$(notmuch search --no-exclude subject:deleted | notmuch_search_sanitize) +test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Not deleted (inbox unread) +thread:XXX 2001-01-05 [2/2] Notmuch Test Suite; Deleted (deleted inbox unread)" + test_begin_subtest "Don't exclude \"deleted\" messages from search if not configured" notmuch config set search.exclude_tags output=$(notmuch search subject:deleted | notmuch_search_sanitize) diff --git a/test/thread-naming b/test/thread-naming index 942e5939..1a1a48f6 100755 --- a/test/thread-naming +++ b/test/thread-naming @@ -65,7 +65,7 @@ test_expect_equal "$output" "thread:XXX 2001-01-12 [6/8] Notmuch Test Suite; t test_begin_subtest 'Test order of messages in "notmuch show"' output=$(notmuch show thread-naming | notmuch_show_sanitize) -test_expect_equal "$output" " message{ id:msg-$(printf "%03d" $first)@notmuch-test-suite depth:0 match:1 filename:/XXX/mail/msg-$(printf "%03d" $first) +test_expect_equal "$output" " message{ id:msg-$(printf "%03d" $first)@notmuch-test-suite depth:0 match:1 excluded:0 filename:/XXX/mail/msg-$(printf "%03d" $first) header{ Notmuch Test Suite (2001-01-05) (unread) Subject: thread-naming: Initial thread subject @@ -79,7 +79,7 @@ This is just a test message (#$first) part} body} message} - message{ id:msg-$(printf "%03d" $((first + 1)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 1))) + message{ id:msg-$(printf "%03d" $((first + 1)))@notmuch-test-suite depth:1 match:1 excluded:0 filename:/XXX/mail/msg-$(printf "%03d" $((first + 1))) header{ Notmuch Test Suite (2001-01-06) (inbox unread) Subject: thread-naming: Older changed subject @@ -93,7 +93,7 @@ This is just a test message (#$((first + 1))) part} body} message} - message{ id:msg-$(printf "%03d" $((first + 2)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 2))) + message{ id:msg-$(printf "%03d" $((first + 2)))@notmuch-test-suite depth:1 match:1 excluded:0 filename:/XXX/mail/msg-$(printf "%03d" $((first + 2))) header{ Notmuch Test Suite (2001-01-07) (inbox unread) Subject: thread-naming: Newer changed subject @@ -107,7 +107,7 @@ This is just a test message (#$((first + 2))) part} body} message} - message{ id:msg-$(printf "%03d" $((first + 3)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 3))) + message{ id:msg-$(printf "%03d" $((first + 3)))@notmuch-test-suite depth:1 match:1 excluded:0 filename:/XXX/mail/msg-$(printf "%03d" $((first + 3))) header{ Notmuch Test Suite (2001-01-08) (unread) Subject: thread-naming: Final thread subject @@ -121,7 +121,7 @@ This is just a test message (#$((first + 3))) part} body} message} - message{ id:msg-$(printf "%03d" $((first + 4)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 4))) + message{ id:msg-$(printf "%03d" $((first + 4)))@notmuch-test-suite depth:1 match:1 excluded:0 filename:/XXX/mail/msg-$(printf "%03d" $((first + 4))) header{ Notmuch Test Suite (2001-01-09) (inbox unread) Subject: Re: thread-naming: Initial thread subject @@ -135,7 +135,7 @@ This is just a test message (#$((first + 4))) part} body} message} - message{ id:msg-$(printf "%03d" $((first + 5)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 5))) + message{ id:msg-$(printf "%03d" $((first + 5)))@notmuch-test-suite depth:1 match:1 excluded:0 filename:/XXX/mail/msg-$(printf "%03d" $((first + 5))) header{ Notmuch Test Suite (2001-01-10) (inbox unread) Subject: Aw: thread-naming: Initial thread subject @@ -149,7 +149,7 @@ This is just a test message (#$((first + 5))) part} body} message} - message{ id:msg-$(printf "%03d" $((first + 6)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 6))) + message{ id:msg-$(printf "%03d" $((first + 6)))@notmuch-test-suite depth:1 match:1 excluded:0 filename:/XXX/mail/msg-$(printf "%03d" $((first + 6))) header{ Notmuch Test Suite (2001-01-11) (inbox unread) Subject: Vs: thread-naming: Initial thread subject @@ -163,7 +163,7 @@ This is just a test message (#$((first + 6))) part} body} message} - message{ id:msg-$(printf "%03d" $((first + 7)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 7))) + message{ id:msg-$(printf "%03d" $((first + 7)))@notmuch-test-suite depth:1 match:1 excluded:0 filename:/XXX/mail/msg-$(printf "%03d" $((first + 7))) header{ Notmuch Test Suite (2001-01-12) (inbox unread) Subject: Sv: thread-naming: Initial thread subject