* [PATCH 1/4] emacs: Add functions and bindings to archive and mark thread as read
2011-06-28 7:31 [PATCH 0/4] emacs: find non-matching mails, plus small tweaks Jani Nikula
@ 2011-06-28 7:31 ` Jani Nikula
2011-06-28 7:31 ` [PATCH 2/4] emacs: Add option to make adding saved searches append, not prepend Jani Nikula
` (2 subsequent siblings)
3 siblings, 0 replies; 10+ messages in thread
From: Jani Nikula @ 2011-06-28 7:31 UTC (permalink / raw)
To: notmuch
Add "mark as read" versions of the archive thread functions to archive and
and mark each message in thread as read by removing the "inbox" and
"unread" tags from the messages. Also add default keybindings A and X for
them: shifted a and x also mark as read.
---
emacs/notmuch-show.el | 25 ++++++++++++++++++++++---
1 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 6685717..dbed0a4 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -886,7 +886,9 @@ function is used. "
(define-key map "-" 'notmuch-show-remove-tag)
(define-key map "+" 'notmuch-show-add-tag)
(define-key map "x" 'notmuch-show-archive-thread-then-exit)
+ (define-key map "X" 'notmuch-show-archive-and-read-thread-then-exit)
(define-key map "a" 'notmuch-show-archive-thread)
+ (define-key map "A" 'notmuch-show-archive-and-read-thread)
(define-key map "N" 'notmuch-show-next-message)
(define-key map "P" 'notmuch-show-previous-message)
(define-key map "n" 'notmuch-show-next-open-message)
@@ -1349,10 +1351,12 @@ argument, hide all of the messages."
(interactive)
(backward-button 1))
-(defun notmuch-show-archive-thread-internal (show-next)
+(defun notmuch-show-archive-thread-internal (show-next mark-read)
;; Remove the tag from the current set of messages.
(goto-char (point-min))
(loop do (notmuch-show-remove-tag "inbox")
+ (if mark-read
+ (notmuch-show-remove-tag "unread"))
until (not (notmuch-show-goto-message-next)))
;; Move to the next item in the search results, if any.
(let ((parent-buffer notmuch-show-parent-buffer))
@@ -1376,12 +1380,27 @@ being delivered to the same thread. It does not archive the
entire thread, but only the messages shown in the current
buffer."
(interactive)
- (notmuch-show-archive-thread-internal t))
+ (notmuch-show-archive-thread-internal t nil))
+
+(defun notmuch-show-archive-and-read-thread ()
+ "Archive and read each message in thread, then show next thread from search.
+
+Archive and mark as read each message currently shown by removing
+the \"inbox\" and \"unread\" tags from each. Then kill this
+buffer and show the next thread from the search from which this
+thread was originally shown."
+ (interactive)
+ (notmuch-show-archive-thread-internal t t))
(defun notmuch-show-archive-thread-then-exit ()
"Archive each message in thread, then exit back to search results."
(interactive)
- (notmuch-show-archive-thread-internal nil))
+ (notmuch-show-archive-thread-internal nil nil))
+
+(defun notmuch-show-archive-and-read-thread-then-exit ()
+ "Archive and read each message in thread, then exit back to search results."
+ (interactive)
+ (notmuch-show-archive-thread-internal nil t))
(defun notmuch-show-stash-cc ()
"Copy CC field of current message to kill-ring."
--
1.7.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/4] emacs: Add option to make adding saved searches append, not prepend
2011-06-28 7:31 [PATCH 0/4] emacs: find non-matching mails, plus small tweaks Jani Nikula
2011-06-28 7:31 ` [PATCH 1/4] emacs: Add functions and bindings to archive and mark thread as read Jani Nikula
@ 2011-06-28 7:31 ` Jani Nikula
2011-06-28 7:31 ` [PATCH 3/4] emacs: Add pseudo saved search to match mail that no saved search matches Jani Nikula
2011-06-28 7:31 ` [PATCH 4/4] emacs: Add pseudo tag to match all messages that have no tags Jani Nikula
3 siblings, 0 replies; 10+ messages in thread
From: Jani Nikula @ 2011-06-28 7:31 UTC (permalink / raw)
To: notmuch
Add new customization option notmuch-add-saved-search-appends to determine
whether new saved searches should be appended to or inserted in front of
saved searches. The default remains insert in front.
---
emacs/notmuch-hello.el | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 65fde75..84bce3a 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -42,6 +42,11 @@
:type 'boolean
:group 'notmuch)
+(defcustom notmuch-add-saved-search-appends nil
+ "Should new saved searches be appended instead of inserted to saved searches?"
+ :type 'boolean
+ :group 'notmuch)
+
(defvar notmuch-hello-indent 4
"How much to indent non-headers.")
@@ -168,8 +173,9 @@ Typically \",\" in the US and UK and \".\" in Europe."
collect elem))
;; Add the new one.
(customize-save-variable 'notmuch-saved-searches
- (push (cons name search)
- notmuch-saved-searches))
+ (add-to-list 'notmuch-saved-searches
+ (cons name search)
+ notmuch-add-saved-search-appends))
(message "Saved '%s' as '%s'." search name)
(notmuch-hello-update)))
--
1.7.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/4] emacs: Add pseudo saved search to match mail that no saved search matches
2011-06-28 7:31 [PATCH 0/4] emacs: find non-matching mails, plus small tweaks Jani Nikula
2011-06-28 7:31 ` [PATCH 1/4] emacs: Add functions and bindings to archive and mark thread as read Jani Nikula
2011-06-28 7:31 ` [PATCH 2/4] emacs: Add option to make adding saved searches append, not prepend Jani Nikula
@ 2011-06-28 7:31 ` Jani Nikula
2011-06-29 19:14 ` Jameson Graef Rollins
2011-06-28 7:31 ` [PATCH 4/4] emacs: Add pseudo tag to match all messages that have no tags Jani Nikula
3 siblings, 1 reply; 10+ messages in thread
From: Jani Nikula @ 2011-06-28 7:31 UTC (permalink / raw)
To: notmuch
Add a pseudo saved search that matches all the mail that no other saved
search matches. Add new customization option notmuch-saved-searches-nomatch
to enable and name the pseudo saved search.
---
emacs/notmuch-hello.el | 30 +++++++++++++++++++++++-------
1 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 84bce3a..b9c9b01 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -47,6 +47,12 @@
:type 'boolean
:group 'notmuch)
+(defcustom notmuch-saved-searches-nomatch nil
+ "Name of the pseudo saved search that no other saved search matches."
+ :type '(choice (const :tag "Off" nil)
+ string)
+ :group 'notmuch)
+
(defvar notmuch-hello-indent 4
"How much to indent non-headers.")
@@ -363,6 +369,22 @@ Complete list of currently available key bindings:
(not (member tag notmuch-hello-hide-tags)))
(process-lines notmuch-command "search-tags")))))
+(defun notmuch-hello-saved-alist ()
+ (if notmuch-saved-searches
+ (let ((saved-alist notmuch-saved-searches))
+ (when notmuch-saved-searches-nomatch
+ ;; Append the no-match search.
+ (add-to-list 'saved-alist
+ (cons notmuch-saved-searches-nomatch
+ (mapconcat (lambda (arg) (concat "(not (" (cdr arg) "))")) notmuch-saved-searches " and ")) t))
+ ;; Filter out empty saved searches if required.
+ (if notmuch-show-empty-saved-searches
+ saved-alist
+ (loop for elem in saved-alist
+ if (> (string-to-number (notmuch-saved-search-count (cdr elem))) 0)
+ collect elem)))
+ notmuch-saved-searches))
+
;;;###autoload
(defun notmuch-hello (&optional no-display)
"Run notmuch and display saved searches, known tags, etc."
@@ -433,13 +455,7 @@ Complete list of currently available key bindings:
(let ((found-target-pos nil)
(final-target-pos nil))
- (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)))
+ (let* ((saved-alist (notmuch-hello-saved-alist))
(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))
--
1.7.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 3/4] emacs: Add pseudo saved search to match mail that no saved search matches
2011-06-28 7:31 ` [PATCH 3/4] emacs: Add pseudo saved search to match mail that no saved search matches Jani Nikula
@ 2011-06-29 19:14 ` Jameson Graef Rollins
2011-06-29 20:15 ` Jani Nikula
0 siblings, 1 reply; 10+ messages in thread
From: Jameson Graef Rollins @ 2011-06-29 19:14 UTC (permalink / raw)
To: Jani Nikula, notmuch
[-- Attachment #1: Type: text/plain, Size: 882 bytes --]
On Tue, 28 Jun 2011 07:31:31 +0000, Jani Nikula <jani@nikula.org> wrote:
> Add a pseudo saved search that matches all the mail that no other saved
> search matches. Add new customization option notmuch-saved-searches-nomatch
> to enable and name the pseudo saved search.
Hi, Jani. I haven't looked too closely at these patches yet, although
they seem to look ok at first glance. However, I would like to argue
*against* using new customization variables for the names of certain
static saved searches. For instance I don't see the point of the
"notmuch-saved-searches-nomatch" and "notmuch-tags-nomatch"
customization variables. Do people *really* need to be able to
customize those names? Why not just pick a sensible name and go with
it?
Customization is great, but if there's too much the code and
customization UI become overly cluttered and hard to parse.
jmho
jamie.
[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/4] emacs: Add pseudo saved search to match mail that no saved search matches
2011-06-29 19:14 ` Jameson Graef Rollins
@ 2011-06-29 20:15 ` Jani Nikula
2011-06-29 20:49 ` Jameson Graef Rollins
0 siblings, 1 reply; 10+ messages in thread
From: Jani Nikula @ 2011-06-29 20:15 UTC (permalink / raw)
To: Jameson Graef Rollins, notmuch
On Wed, 29 Jun 2011 12:14:05 -0700, Jameson Graef Rollins <jrollins@finestructure.net> wrote:
Non-text part: multipart/signed
> On Tue, 28 Jun 2011 07:31:31 +0000, Jani Nikula <jani@nikula.org> wrote:
> > Add a pseudo saved search that matches all the mail that no other saved
> > search matches. Add new customization option notmuch-saved-searches-nomatch
> > to enable and name the pseudo saved search.
>
> Hi, Jani. I haven't looked too closely at these patches yet, although
> they seem to look ok at first glance. However, I would like to argue
> *against* using new customization variables for the names of certain
> static saved searches. For instance I don't see the point of the
> "notmuch-saved-searches-nomatch" and "notmuch-tags-nomatch"
> customization variables. Do people *really* need to be able to
> customize those names? Why not just pick a sensible name and go with
> it?
Hi, I didn't add the customization specifically to customize the name,
but rather to be able to switch the feature on/off. I felt that people
might want to customize that. And while at it, customizing the name in
the same variable seemed like a good idea. It's probably not desirable
to collide with whatever search/tag names people might use.
So to clarify, do you prefer having on/off switches, or just enabling
this without customization at all? Personally I'd shy away from the
latter, but I guess it depends on how useful vs. distracting people find
this.
> Customization is great, but if there's too much the code and
> customization UI become overly cluttered and hard to parse.
Agreed.
Jani
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/4] emacs: Add pseudo saved search to match mail that no saved search matches
2011-06-29 20:15 ` Jani Nikula
@ 2011-06-29 20:49 ` Jameson Graef Rollins
2011-06-29 21:47 ` Jani Nikula
0 siblings, 1 reply; 10+ messages in thread
From: Jameson Graef Rollins @ 2011-06-29 20:49 UTC (permalink / raw)
To: Jani Nikula, notmuch
[-- Attachment #1: Type: text/plain, Size: 443 bytes --]
On Wed, 29 Jun 2011 20:15:22 +0000, Jani Nikula <jani@nikula.org> wrote:
> So to clarify, do you prefer having on/off switches, or just enabling
> this without customization at all? Personally I'd shy away from the
> latter, but I guess it depends on how useful vs. distracting people find
> this.
My opinion is to just make it a feature without any customization at
all. I can see no harm in having these searches always available.
jamie.
[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/4] emacs: Add pseudo saved search to match mail that no saved search matches
2011-06-29 20:49 ` Jameson Graef Rollins
@ 2011-06-29 21:47 ` Jani Nikula
0 siblings, 0 replies; 10+ messages in thread
From: Jani Nikula @ 2011-06-29 21:47 UTC (permalink / raw)
To: Jameson Graef Rollins, notmuch
On Wed, 29 Jun 2011 13:49:18 -0700, Jameson Graef Rollins <jrollins@finestructure.net> wrote:
Non-text part: multipart/signed
> On Wed, 29 Jun 2011 20:15:22 +0000, Jani Nikula <jani@nikula.org> wrote:
> > So to clarify, do you prefer having on/off switches, or just enabling
> > this without customization at all? Personally I'd shy away from the
> > latter, but I guess it depends on how useful vs. distracting people find
> > this.
>
> My opinion is to just make it a feature without any customization at
> all. I can see no harm in having these searches always available.
That should clean up the code a bit as well. Then we're left with
picking the sensible names. I just use "other" and "no tags" myself. Do
you see value in e.g. surrounding them in brackets like "[other]" and
"[no tags]" to signify they are special? Better ideas? I'm not a native
speaker...
And while at it, how about also making append the non-customizable, IMHO
sensible, default for saved searches in patch 2/4?
Jani
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 4/4] emacs: Add pseudo tag to match all messages that have no tags
2011-06-28 7:31 [PATCH 0/4] emacs: find non-matching mails, plus small tweaks Jani Nikula
` (2 preceding siblings ...)
2011-06-28 7:31 ` [PATCH 3/4] emacs: Add pseudo saved search to match mail that no saved search matches Jani Nikula
@ 2011-06-28 7:31 ` Jani Nikula
2011-06-30 7:56 ` Pieter Praet
3 siblings, 1 reply; 10+ messages in thread
From: Jani Nikula @ 2011-06-28 7:31 UTC (permalink / raw)
To: notmuch
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
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 4/4] emacs: Add pseudo tag to match all messages that have no tags
2011-06-28 7:31 ` [PATCH 4/4] emacs: Add pseudo tag to match all messages that have no tags Jani Nikula
@ 2011-06-30 7:56 ` Pieter Praet
0 siblings, 0 replies; 10+ messages in thread
From: Pieter Praet @ 2011-06-30 7:56 UTC (permalink / raw)
To: Jani Nikula, notmuch
On Tue, 28 Jun 2011 07:31:32 +0000, Jani Nikula <jani@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@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
^ permalink raw reply [flat|nested] 10+ messages in thread