[PATCH 4/4] emacs: Add pseudo tag to match all messages that have no tags

Pieter Praet pieter at praet.org
Thu Jun 30 00:56:22 PDT 2011


On Tue, 28 Jun 2011 07:31:32 +0000, Jani Nikula <jani at nikula.org> wrote:
> Add a pseudo tag that matches all the messages that have no tags. Add new
> customization option notmuch-tags-nomatch to enable and name the pseudo
> tag.
> ---
>  emacs/notmuch-hello.el |   18 ++++++++++++++++--
>  1 files changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
> index b9c9b01..1770f60 100644
> --- a/emacs/notmuch-hello.el
> +++ b/emacs/notmuch-hello.el
> @@ -53,6 +53,12 @@
>  		 string)
>    :group 'notmuch)
>  
> +(defcustom notmuch-tags-nomatch nil
> +  "Name of the pseudo tag to match messages that have no tags."
> +  :type '(choice (const :tag "Off" nil)
> +		 string)
> +  :group 'notmuch)
> +
>  (defvar notmuch-hello-indent 4
>    "How much to indent non-headers.")
>  
> @@ -352,7 +358,7 @@ Complete list of currently available key bindings:
>  
>  (defun notmuch-hello-generate-tag-alist ()
>    "Return an alist from tags to queries to display in the all-tags section."
> -  (notmuch-remove-if-not
> +  (let ((tag-alist (notmuch-remove-if-not
>     #'cdr
>     (mapcar (lambda (tag)
>  	     (cons tag
> @@ -367,7 +373,15 @@ Complete list of currently available key bindings:
>  	   (notmuch-remove-if-not
>  	    (lambda (tag)
>  	      (not (member tag notmuch-hello-hide-tags)))
> -	    (process-lines notmuch-command "search-tags")))))
> +	    (process-lines notmuch-command "search-tags"))))))
> +    (when notmuch-tags-nomatch
> +      (let ((no-tag-search
> +	     (cons notmuch-tags-nomatch
> +		   (mapconcat (lambda (arg) (concat "(not (" (cdr arg) "))")) tag-alist " and "))))
> +	(if (> (string-to-number (notmuch-saved-search-count (cdr no-tag-search))) 0)
> +	    ;; Append the no-match search.
> +	    (add-to-list 'tag-alist no-tag-search t))))
> +    tag-alist))
>  
>  (defun notmuch-hello-saved-alist ()
>    (if notmuch-saved-searches
> -- 
> 1.7.1
> 
> _______________________________________________
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


IMHO, this should be handled in notmuch core.

eg.
  `notmuch search tag:*' matches all tagged
  `notmuch search tag:'  matches all non-tagged.

-> No need for an extra customization option in Emacs,
   just a simple saved search.

Opinions?


Peace

-- 
Pieter


More information about the notmuch mailing list