Signed-off-by: Jani Nikula <jani@nikula.org> --- emacs/notmuch-hello.el | 9 +++++++-- emacs/notmuch-lib.el | 8 ++++++-- emacs/notmuch.el | 9 +++++++-- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index 0582cae..ad3ae74 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -274,7 +274,9 @@ should be. Returns a cons cell `(tags-per-line width)'." ;; (not elem) indicates an empty slot in the matrix. (when elem (let* ((name (car elem)) - (query (cdr elem)) + (query (if (functionp (cdr elem)) + (funcall (cdr elem) elem) + (cdr elem))) (formatted-name (format "%s " name))) (widget-insert (format "%8s " (notmuch-hello-nice-number @@ -452,7 +454,10 @@ Complete list of currently available key bindings: (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) + if (> (string-to-number (notmuch-saved-search-count + (if (functionp (cdr elem)) + (funcall (cdr elem) elem) + (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))) diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el index 0f856bf..2ecb3fc 100644 --- a/emacs/notmuch-lib.el +++ b/emacs/notmuch-lib.el @@ -36,8 +36,12 @@ ;; (defcustom notmuch-saved-searches nil - "A list of saved searches to display." - :type '(alist :key-type string :value-type string) + "A list of saved searches to display. + +The list of saved searches is a list of key/value pairs, where +the key is the name of the saved search, and value is either a +query string, or a function that should return a query string." + :type '(alist :key-type string :value-type (choice string function)) :group 'notmuch) (defvar notmuch-folders nil diff --git a/emacs/notmuch.el b/emacs/notmuch.el index c1827cc..62f33e9 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -854,14 +854,19 @@ characters as well as `_.+-'. (let (longest (longest-length 0)) (loop for tuple in notmuch-saved-searches - if (let ((quoted-query (regexp-quote (cdr tuple)))) + if (let ((quoted-query (regexp-quote + (if (functionp (cdr tuple)) + (funcall (cdr tuple) tuple) + (cdr tuple))))) (and (string-match (concat "^" quoted-query) query) (> (length (match-string 0 query)) longest-length))) do (setq longest tuple)) longest)) (saved-search-name (car saved-search)) - (saved-search-query (cdr saved-search))) + (saved-search-query (if (functionp (cdr saved-search)) + (funcall (cdr saved-search) saved-search) + (cdr saved-search)))) (cond ((and saved-search (equal saved-search-query query)) ;; Query is the same as saved search (ignoring case) (concat "*notmuch-saved-search-" saved-search-name "*")) -- 1.7.5.4