summaryrefslogtreecommitdiffhomepage
path: root/custom
diff options
context:
space:
mode:
Diffstat (limited to 'custom')
-rw-r--r--custom/jao-custom-notmuch.el187
1 files changed, 96 insertions, 91 deletions
diff --git a/custom/jao-custom-notmuch.el b/custom/jao-custom-notmuch.el
index 7ac409f..e093ed4 100644
--- a/custom/jao-custom-notmuch.el
+++ b/custom/jao-custom-notmuch.el
@@ -54,9 +54,14 @@
(jao-minibuffer-add-variable 'jao-notmuch-minibuffer-string -20))
;;; saved searches
-(defvar jao-notmuch--new "tag:\"/^(unread|new)$/\"")
-(defvar jao-notmuch--new-rx (regexp-quote jao-notmuch--new))
-(defvar jao-notmuch--newa (concat jao-notmuch--new " AND "))
+(defvar jao-notmuch--new nil)
+(defvar jao-notmuch--new-rx nil)
+(defvar jao-notmuch--newa nil)
+
+(defun jao-notmuch--set-new-search (s)
+ (setq jao-notmuch--new s
+ jao-notmuch--new-rx (regexp-quote jao-notmuch--new)
+ jao-notmuch--newa (concat jao-notmuch--new " AND ")))
(defun jao-notmuch--q (d0 &optional k d1 qs st)
(let ((q (or (when qs (mapconcat #'identity qs " AND "))
@@ -103,91 +108,97 @@
(symbol-value lst)))
(add-to-list lst s t)))
-(defun jao-notmuch-add-saved-searches (searches)
- (dolist (s searches)
- (jao-notmuch--replace 'jao-notmuch-widened-searches (jao-notmuch--widen s))
- (jao-notmuch--replace 'notmuch-saved-searches s)))
-
-(defmacro jao-notmuch-def-searches (name searches &optional no-save)
+(defun jao-notmuch--def-searches (name searches &optional no-save)
(declare (indent 1))
- (let ((name (and name (format "%s" name)))
- (id (intern (format "jao-notmuch-%s-searches" (or name (gensym))))))
- `(progn (defvar ,id nil)
- (setq ,id ,searches)
- (defun ,id () (jao-notmuch-hello--insert-searches ,id ,name))
- ,@(unless no-save `((jao-notmuch-add-saved-searches ,id)))
- (add-to-list 'notmuch-hello-sections ',id t))))
+ (unless no-save
+ (dolist (s searches)
+ (jao-notmuch--replace 'jao-notmuch-widened-searches
+ (jao-notmuch--widen s))
+ (jao-notmuch--replace 'notmuch-saved-searches s)))
+ (add-to-list 'notmuch-hello-sections
+ `(jao-notmuch-hello--insert-searches ,searches ,name)
+ t))
(defvar jao-notmuch-widened-searches nil)
-(setq notmuch-hello-sections nil
- notmuch-saved-searches nil
- jao-notmuch-widened-searches nil)
-
-(jao-notmuch-def-searches inbox
- `(,(jao-notmuch--q "inbox" "i")
- ,(jao-notmuch--q "write" "w")
- ,(jao-notmuch--q "drivel" "d")
- ,(jao-notmuch--q "trove" "t")
- ,(jao-notmuch--q "local" "x")))
-
-(jao-notmuch-def-searches news
- (mapcar 'jao-notmuch--q-feed
- '(("fn" "news")
- ("fd" "noticias")
- ("ff" "fun")
- ("fw" "words")
- ("fc" "computers")
- ("fp" "pens"))))
-
-(jao-notmuch-def-searches hacking
- `(,(jao-notmuch--q "hacking" "h")
- ,(jao-notmuch--q "prog" "p")
- ,@(mapcar 'jao-notmuch--q-feed
- '(("lc" "clojure")
- ("le" "emacs")
- ("lg" "geiser")
- ("lh" "haskell")
- ("ll" "lisp")
- ("ln" "notmuch")
- ("lr" "rust")
- ("ls" "scheme")
- ("lx" "xmobar")))))
-
-(jao-notmuch-def-searches sci
- (mapcar 'jao-notmuch--q-feed
- '(("sp" "philosophy")
- ("sm" "math")
- ("sp" "physics")
- ("ss" "sci")
- ("sg" "gr-qc")
- ("sq" "quant-ph"))))
-
-(jao-notmuch-def-searches flags
- (jao-notmuch-widen-searches notmuch-saved-searches " AND tag:flagged")
- t)
-
-(jao-notmuch-def-searches nil
- `(,(jao-notmuch--q "flagged" "F" nil '("tag:flagged"))))
-
-(jao-notmuch-def-searches today
- `(,(jao-notmuch--q "new" "N" nil (list jao-notmuch--new "not tag:draft"))
- ,(jao-notmuch--q "drafts" "D" nil '("tag:draft") t)
- ,(jao-notmuch--q "sent" "S" nil '("date:1d.." "tag:sent") t)
- ,(jao-notmuch--q "today" "T" nil
- '("tag:jao" "date:24h.."
- "not tag:\"/(sent|feeds|spam|local)/\"")
- t)))
-
-(jao-notmuch-def-searches trove
- '((:query "tag:trove" :name "trove" :search-type tree)
- (:query "tag:hacking" :name "hacking" :search-type tree)
- (:query "not tag:trove and not tag:hacking" :name "untroved"
- :search-type tree)
- (:query "tag:sent" :name "sent")))
-
-(jao-notmuch-def-searches nil
- '((:query "*" :name "messages" :search-type tree)))
+(defun jao-notmuch-define-searches (s)
+ (jao-notmuch--set-new-search s)
+
+ (setq notmuch-hello-sections nil
+ notmuch-saved-searches nil
+ jao-notmuch-widened-searches nil)
+
+ (jao-notmuch--def-searches "inbox"
+ `(,(jao-notmuch--q "inbox" "i")
+ ,(jao-notmuch--q "write" "w")
+ ,(jao-notmuch--q "drivel" "d")
+ ,(jao-notmuch--q "trove" "t")
+ ,(jao-notmuch--q "local" "x")))
+
+ (jao-notmuch--def-searches "news"
+ (mapcar 'jao-notmuch--q-feed
+ '(("fn" "news")
+ ("fd" "noticias")
+ ("ff" "fun")
+ ("fw" "words")
+ ("fc" "computers")
+ ("fp" "pens"))))
+
+ (jao-notmuch--def-searches "hacking"
+ `(,(jao-notmuch--q "hacking" "h")
+ ,(jao-notmuch--q "prog" "p")
+ ,@(mapcar 'jao-notmuch--q-feed
+ '(("lc" "clojure")
+ ("le" "emacs")
+ ("lg" "geiser")
+ ("lh" "haskell")
+ ("ll" "lisp")
+ ("ln" "notmuch")
+ ("lr" "rust")
+ ("ls" "scheme")
+ ("lx" "xmobar")))))
+
+ (jao-notmuch--def-searches "sci"
+ (mapcar 'jao-notmuch--q-feed
+ '(("sp" "philosophy")
+ ("sm" "math")
+ ("sp" "physics")
+ ("ss" "sci")
+ ("sg" "gr-qc")
+ ("sq" "quant-ph"))))
+
+ (jao-notmuch--def-searches "flags"
+ (jao-notmuch-widen-searches notmuch-saved-searches " AND tag:flagged")
+ t)
+
+ (jao-notmuch--def-searches nil
+ `(,(jao-notmuch--q "flagged" "F" nil '("tag:flagged"))))
+
+ (jao-notmuch--def-searches "today"
+ `(,(jao-notmuch--q "new" "N" nil (list jao-notmuch--new "not tag:draft"))
+ ,(jao-notmuch--q "drafts" "D" nil '("tag:draft") t)
+ ,(jao-notmuch--q "sent" "S" nil '("date:1d.." "tag:sent") t)
+ ,(jao-notmuch--q "today" "T" nil
+ '("tag:jao" "date:24h.."
+ "not tag:\"/(sent|feeds|spam|local)/\"")
+ t)))
+
+ (jao-notmuch--def-searches "trove"
+ '((:query "tag:trove" :name "trove" :search-type tree)
+ (:query "tag:hacking" :name "hacking" :search-type tree)
+ (:query "not tag:trove and not tag:hacking" :name "untroved"
+ :search-type tree)
+ (:query "tag:sent" :name "sent")))
+
+ (jao-notmuch--def-searches nil
+ '((:query "*" :name "messages" :search-type tree)))
+
+ ;; (add-to-list 'notmuch-hello-sections 'notmuch-hello-insert-alltags t)
+
+ (when (display-graphic-p)
+ (add-to-list 'notmuch-hello-sections '(insert " "))))
+
+(jao-notmuch-define-searches "tag:\"/^(unread|new)$/\"")
(defun jao-notmuch-jump-search (&optional widen)
(interactive "P")
@@ -293,12 +304,6 @@
(use-package jao-notmuch :demand t)
;;; hello
-(defun jao-notmuch-hello--header () (insert " "))
-(when (display-graphic-p)
- (add-to-list 'notmuch-hello-sections 'jao-notmuch-hello--header))
-
-;; (add-to-list 'notmuch-hello-sections 'notmuch-hello-insert-alltags t)
-
(defun jao-notmuch-refresh-agenda ()
(interactive)
(save-window-excursion (calendar) (jao-org-agenda)))
@@ -565,7 +570,7 @@
(defun jao-notmuch-use-one-pane ()
(interactive)
- (add-to-list 'jao-afio-frame-parameters '("mail" ((width . 120))))
+ (jao-afio-add-frame-parameters mail (width . 120))
(advice-remove 'notmuch-tree #'jao-notmuch-before-tree)
(advice-remove 'notmuch-tree-quit #'jao-notmuch-after-tree-quit))