* sup-like label listings (elisp)
@ 2010-04-11 18:56 Taru Karttunen
2010-04-12 8:14 ` David Edmondson
0 siblings, 1 reply; 4+ messages in thread
From: Taru Karttunen @ 2010-04-11 18:56 UTC (permalink / raw)
To: notmuch
Hello
Attached is code to produce sup-like label listings.
It adds two new shortcuts:
'l' - produce a listing of all tags and their messages
'L' - produce a listing of all tags and their unread (or starred) messages
(defun taru-notmuch-t2unread (s)
(mapcar (lambda (s) (cons s (concat "tag:" s " AND (tag:unread OR tag:starred)"))) s))
(defun taru-notmuch-t2all (s)
(mapcar (lambda (s) (cons s (concat "tag:" s))) s))
(setq taru-notmuch-real-folders notmuch-folders)
(setq notmuch-search-oldest-first nil)
(defun taru-notmuch-all-tags () (process-lines "notmuch" "search-tags"))
(setq notmuch-folders (taru-notmuch-t2all (taru-notmuch-all-tags)))
(defun taru-notmuch-folders ()
(interactive)
(setq notmuch-folders taru-notmuch-real-folders)
(notmuch-folder))
(defun taru-notmuch-list ()
(interactive)
(setq notmuch-folders (taru-notmuch-t2all (taru-notmuch-all-tags)))
(notmuch-folder))
(defun taru-notmuch-listu ()
(interactive)
(setq notmuch-folders (taru-notmuch-t2unread (taru-notmuch-all-tags)))
(notmuch-folder))
(defun taru-notmuch-addlist ()
(local-set-key "F" 'taru-notmuch-folders) ; folders
(local-set-key "l" 'taru-notmuch-list) ; all tags
(local-set-key "L" 'taru-notmuch-listu)) ; all tags - unread
(add-hook 'notmuch-search-hook 'taru-notmuch-addlist)
I hope others will find this useful.
- Taru Karttunen
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: sup-like label listings (elisp)
2010-04-11 18:56 sup-like label listings (elisp) Taru Karttunen
@ 2010-04-12 8:14 ` David Edmondson
2010-04-12 8:26 ` David Edmondson
2010-04-12 8:38 ` Sebastian Spaeth
0 siblings, 2 replies; 4+ messages in thread
From: David Edmondson @ 2010-04-12 8:14 UTC (permalink / raw)
To: Taru Karttunen, notmuch
How about this approach:
commit 0f591b5ac149179540327f1d300009b593c043ec
Author: David Edmondson <dme@dme.org>
Date: Mon Apr 12 09:13:15 2010 +0100
emacs: More flexible folder mode construction
Allow callers to `notmuch-folder' to optionally specify the alist of
folders to be shown and a title for the buffer.
Add `notmuch-folder-all-tags' and `notmuch-folder-all-tags-unread'
based on the above.
Modified emacs/notmuch.el
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 6d44249..7b867c6 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -888,17 +888,41 @@ Currently available key bindings:
(if search
(notmuch-search (cdr search) notmuch-search-oldest-first))))
+(defun notmuch-folder-all-tags-unread ()
+ "Show the notmuch folder view for messages tagged `unread' for
+all tags."
+ (interactive)
+ (notmuch-folder-all-tags "tag:unread"))
+
+(defun notmuch-folder-all-tags (&optional search-restriction)
+ "Show the notmuch folder view for all tags. The optional
+parameter `search-restriction' allows the tag based search to be
+refined."
+ (interactive)
+ (notmuch-folder
+ (mapcar '(lambda (tag)
+ (cons tag (concat "tag:" tag
+ (if search-restriction
+ (concat " AND ( " search-restriction " )")
+ ""))))
+ (process-lines notmuch-command "search-tags"))
+ search-restriction))
+
;;;###autoload
-(defun notmuch-folder ()
+(defun notmuch-folder (&optional folders title)
"Show the notmuch folder view and update the displayed counts."
(interactive)
- (let ((buffer (get-buffer-create "*notmuch-folders*")))
+ (let ((buffer (get-buffer-create
+ (concat "*notmuch-folders"
+ (if title (concat "-" title) "")
+ "*")))
+ (folders (or folders notmuch-folders)))
(switch-to-buffer buffer)
(let ((inhibit-read-only t)
(n (line-number-at-pos)))
(erase-buffer)
(notmuch-folder-mode)
- (notmuch-folder-add notmuch-folders)
+ (notmuch-folder-add folders)
(goto-char (point-min))
(goto-line n))))
dme.
--
David Edmondson, http://dme.org
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: sup-like label listings (elisp)
2010-04-12 8:14 ` David Edmondson
@ 2010-04-12 8:26 ` David Edmondson
2010-04-12 8:38 ` Sebastian Spaeth
1 sibling, 0 replies; 4+ messages in thread
From: David Edmondson @ 2010-04-12 8:26 UTC (permalink / raw)
To: Taru Karttunen, notmuch
Oops. That one wasn't complete. Try:
commit 0c55967141e7685b0ba23b45a74c1e48a5964f6c
Author: David Edmondson <dme@dme.org>
Date: Mon Apr 12 09:24:44 2010 +0100
emacs: More flexible folder mode construction
Allow callers to `notmuch-folder' to optionally specify the alist of
folders to be shown and a title for the buffer.
Add `notmuch-folder-all-tags' and `notmuch-folder-all-tags-unread'
based on the above.
Modified emacs/notmuch.el
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 6d44249..b6a5e5f 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -888,16 +888,43 @@ Currently available key bindings:
(if search
(notmuch-search (cdr search) notmuch-search-oldest-first))))
+(defun notmuch-folder-all-tags-unread ()
+ "Show the notmuch folder view for messages tagged `unread' for
+all tags."
+ (interactive)
+ (notmuch-folder-all-tags "tag:unread"))
+
+(defun notmuch-folder-all-tags (&optional search-restriction)
+ "Show the notmuch folder view for all tags. The optional
+parameter `search-restriction' allows the tag based search to be
+refined."
+ (interactive)
+ (notmuch-folder
+ (mapcar '(lambda (tag)
+ (cons tag (concat "tag:" tag
+ (if search-restriction
+ (concat " AND ( " search-restriction " )")
+ ""))))
+ (process-lines notmuch-command "search-tags"))
+ search-restriction))
+
;;;###autoload
-(defun notmuch-folder ()
+(defun notmuch-folder (&optional folders title)
"Show the notmuch folder view and update the displayed counts."
(interactive)
- (let ((buffer (get-buffer-create "*notmuch-folders*")))
+ (let ((buffer (get-buffer-create
+ (concat "*notmuch-folders"
+ (if title (concat "-" title) "")
+ "*")))
+ (folders (or folders notmuch-folders)))
(switch-to-buffer buffer)
(let ((inhibit-read-only t)
(n (line-number-at-pos)))
(erase-buffer)
(notmuch-folder-mode)
+ ;; Must come after `notmuch-folder-mode', as that kills all
+ ;; local variables.
+ (set (make-local-variable 'notmuch-folders) folders)
(notmuch-folder-add notmuch-folders)
(goto-char (point-min))
(goto-line n))))
dme.
--
David Edmondson, http://dme.org
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: sup-like label listings (elisp)
2010-04-12 8:14 ` David Edmondson
2010-04-12 8:26 ` David Edmondson
@ 2010-04-12 8:38 ` Sebastian Spaeth
1 sibling, 0 replies; 4+ messages in thread
From: Sebastian Spaeth @ 2010-04-12 8:38 UTC (permalink / raw)
To: David Edmondson, Taru Karttunen, notmuch
On Mon, 12 Apr 2010 09:14:27 +0100, David Edmondson <dme@dme.org> wrote:
> How about this approach:
ooh! me likey!
Thanks, very nice to get an overview over all my tags.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-04-12 8:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-11 18:56 sup-like label listings (elisp) Taru Karttunen
2010-04-12 8:14 ` David Edmondson
2010-04-12 8:26 ` David Edmondson
2010-04-12 8:38 ` Sebastian Spaeth
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).