[notmuch] A few patches
I've got a few patches available in my notmuch repo: http://git.pioto.org/gitweb/notmuch.git The 'noarg-count' branch makes `notmuch count` without any argument simply return the total number of messages in the database. This seems like it could be useful. The 'new-unread' branch makes `notmuch new` only tag messages as 'unread' if they don't have a maildir 'seen' flag. This shouldn't affect anyones existing database, but should make initial imports for people migrating from other mail setups (like me) go much better. -- Mike Kelly
[notmuch] [PATCH] GCC3.5 fix
I have reason to need GCC 3.5 which doesn't process the unused(x) macro correctly. This is probably a bug in 3.5, nevertheless the patch is simple and corrects the build. GCC 3.5 also does not understand -Wextra but Makefile is bound to change less frequently, so I did not include a patch for that. -- next part -- A non-text attachment was scrubbed... Name: notmuch_gcc_35.patch Type: text/x-patch Size: 951 bytes Desc: not available URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20100121/ede5d775/attachment.bin>
[notmuch] [PATCH] d_type fix
A review of notmuch-new.c shows three uses of ->d_type: Near line 153, in _entries_resemble_maildir() we can simply allow for DT_UNKNOWN. This would fail if people have MH-style folders which have three folders called "new" "cur" and "tmp", but that seems unlikely, in which case the "tmp" folder would simply not be scanned. Near line 273 in add_files_recursive() we have another check. If DT_UNKNOWN, we fall through, then add_files_recursive() does a stat almost immediately, returning with success if the path isn't a directory. Thus, the fallback is already written. Finally, near line 343, in add_files_recursive() (a long function) we have another check. Here we can simply treat DT_UNKNOWN as DT_LNK, since the logic for the stat() results are the same. Attached is a patch which was tested with reiserfs. It should also work with xfs. -- next part -- A non-text attachment was scrubbed... Name: notmuch_new_d_type_fix.patch Type: text/x-patch Size: 1144 bytes Desc: not available URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20100121/29b03255/attachment.bin>
[notmuch] Fcc, Maildir, and Emacs message-mode -- a bit of code
Dear all, First of all, many thanks to Carl and others for writing notmuch. Some folks on IRC were bemoaning message-mode's annoying inability to save sent-mail to a Maildir using Fcc. I mentioned that I had written a bit of Maildir elisp code for that purpose a while back, and it was suggested that I share it with the list. Some caveats: - I've tested this a good number of times, but not very robustly, since I don't actually use it (I found that I prefer blind-copying myself). Please test it out somewhere safe, on a maildir you can afford to lose. - The hardlinking performed by `add-name-to-file' might be platform and filesystem specific. I'm using linux/ext3, and it works here. I don't know what will happen anywhere else. - I imagine there's a much better implementation inside of Wanderlust, if you can dig through all the libraries. - It's not really commented, but I hope the function names are pretty self-explanatory. - It requires that the directory in the `Fcc:' header already exist and be a maildir (i.e. have cur/, new/, and tmp/). It should be pretty simple to add in a prompt for creating a directory if it points to a nonexistent place. Anyway, here it is: http://jkr.acm.jhu.edu/jkr-maildir.el To use it, set one of the following: If you want Fcc'd messages to be marked as read: (setq message-fcc-handler-function '(lambda (destdir) (jkr/maildir-write-buffer-to-maildir destdir t))) If you want Fcc'd messages to be marked as new: (setq message-fcc-handler-function '(lambda (destdir) (jkr/maildir-write-buffer-to-maildir destdir nil))) Best, Jesse
[notmuch] [PATCH] notmuch.el: add functionality to add or remove tags by region.
On Thu, 21 Jan 2010 10:56:59 -0500, Jameson Rollins wrote: > Notmuch is not to my knowledge capable of tagging a sub-region of a > message, so in that sense it might not work. This is only in notmuch-search mode, so it only operates on full threads. > Would it be better to use some sort of tag/apply system ala mutt > instead? That could work too. The main reason I implemented this is that, as an emacs user, I kept intuitively trying to tag messages in this way, and it wouldn't work. I actually was thinking of combining regions and marking (let's call it that to keep from getting confused with notmuch tags) -- i.e., have region selection in search mode also mark messages. And then there could also be a message-by-message way if you wanted to mark disjoint messages. Best, Jesse
[notmuch] [PATCH] notmuch.el: add functionality to add or remove tags by region.
On Thu, Jan 21, 2010 at 10:35:34AM -0500, Jesse Rosenthal wrote: > Region is emacs-speak for selected area (either click-and-drag or C-SPC > and then motion commands). Basically, this was meant to be an emacsy-way > of tagging a bunch of messages in a buffer at once. I understand what a region is in emacs land, but I don't understand how it translates to mail land. Notmuch is not to my knowledge capable of tagging a sub-region of a message, so in that sense it might not work. If you goal is to tag only a subset of messages in a thread, then regions don't seem like the most natural way to do that, since regions are non-disjoint. Would it be better to use some sort of tag/apply system ala mutt instead? jamie.
[notmuch] [PATCH] notmuch.el: add functionality to add or remove tags by region.
On Thu, 21 Jan 2010 10:23:24 -0500, Jameson Rollins wrote: Hi Jamie, > Hi, Jesse. Can you explain what exactly a "region" is? It's not > clear from your log message or the patch itself. Region is emacs-speak for selected area (either click-and-drag or C-SPC and then motion commands). Basically, this was meant to be an emacsy-way of tagging a bunch of messages in a buffer at once. Best, Jesse
[notmuch] [PATCH] notmuch.el: add functionality to add or remove tags by region.
On Wed, Jan 20, 2010 at 03:58:10PM -0500, Jesse Rosenthal wrote: > This patch adds `-region' versions of the `notmuch-search-' commands to find > properties. It also splits up `notmuch-add/remove-tags' into both a > `-thread' and a `-region' version. (This makes us modify > `notmuch-search-archive-thread' to use the `notmuch-search-remove-tag-thread' > function, instead of `notmuch-search-remove-tag', for consistency.) The > add/remove-tag command called by pressing `+' or `-' will then choose > accordingly, based on whether region is active. Hi, Jesse. Can you explain what exactly a "region" is? It's not clear from your log message or the patch itself. jamie. -- next part -- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20100121/57c86d40/attachment.pgp>
[notmuch] Git feature branch
On Wed, 20 Jan 2010 15:00:46 +0100, "Sebastian Spaeth" wrote: > As I do like some of the additional patches, I am shoving some of them > into my "all feature" branch. I make that one available in case you > want to pull from it. It currently carries: > > Jameson Rollins: Simplify "unread" tag handling in emacs UI. > David Bremner: notmuch.el: Refactor citation markup. Variables for minimum > size, button text. > Dirk-Jan C. Binnema: notmuch-new.c: refactor and improve dirs-to-ignore a bit > Sebastian Spaeth: add notmuch-show-delete keybinding 'd' Cool! It would be useful if you provided thread-id's for each of these so we could look them up and read more about them. micah -- next part -- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 835 bytes Desc: not available URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20100121/554b47b9/attachment.pgp>
[notmuch] [PATCH] notmuch.el: add functionality to add or remove tags by region.
[notmuch] Potential problem using Git for mail (was: Idea for storing tags)
On Fri, 15 Jan 2010, martin f krafft wrote: > also sprach Asheesh Laroia [2010.01.14.2112 +1300]: >> Sure. But the MDA doesn't need to do the commit immediately. Since >> (presumably) we're using Maildir, the MDA on the mail receiving >> server is going to generate filenames that won't cause conflicts. >> So it's okay to leave the files uncommitted. > > So when does the commit happen? > >> When I did the "git merge", git would create the Maildir files in >> ~/Maildir/cur/... non-atomically. > > This might be something that the Git people could address if it was > brought up on the mailing list. Then again, it might not be possible > without going via a temporary file, which I doubt will fly. A temporary file + rename() is the only way, as far as I know. > I suppose that I never actually considered merges on the IMAP server > side, but obviously the IMAP server has to work off a clone, and that > means it needs to merge. It's not "merge" that's unsafe; that just builds a tree in the git index (assuming no conflicts). It's the ensuing process of git writing a tree to the filesystem that is problematic. I could probably actually write a wrapper that locks the Maildir while git is operating. It would probably be specific to each IMAP server. Note that this mean git is fundamentally incompatible with Maildir, not just IMAP servers. >> Dovecot would notice the file in ~/Maildir/cur/ and think, "This file >> must be ready!" So it would parse it even though git hadn't finished >> writing it. This caused me to only see partial headers in Alpine since >> Dovecot parsed it before it was a complete message. > > I wonder if a custom merge driver could address this to properly use > ?/tmp/ to assemble the message and only then move it. I don't think a merge driver can do it for the reason stated above. -- Asheesh. -- I always turn to the sports pages first, which record people's accomplishments. The front page has nothing but man's failures. -- Chief Justice Earl Warren
[notmuch] [PATCH] notmuch new: support for filename pattern filtering
Haven't seen my patch pushed or commented on yet. Was it black-holed, or are people just busy? Thanks much, Bart In message you wrote: > Together with the new support for message deletion (thank > you!) this patch lets me use notmuch in parallel with MH > pretty successfully.
[notmuch] [PATCH] notmuch.el: add functionality to add or remove tags by region.
This patch adds `-region' versions of the `notmuch-search-' commands to find properties. It also splits up `notmuch-add/remove-tags' into both a `-thread' and a `-region' version. (This makes us modify `notmuch-search-archive-thread' to use the `notmuch-search-remove-tag-thread' function, instead of `notmuch-search-remove-tag', for consistency.) The add/remove-tag command called by pressing `+' or `-' will then choose accordingly, based on whether region is active. --- notmuch.el | 95 +--- 1 files changed, 84 insertions(+), 11 deletions(-) diff --git a/notmuch.el b/notmuch.el index 97914f2..e333f24 100644 --- a/notmuch.el +++ b/notmuch.el @@ -1117,18 +1117,41 @@ Complete list of currently available key bindings: (set (make-local-variable 'font-lock-defaults) '(notmuch-search-font-lock-keywords t))) +(defun notmuch-search-properties-in-region (property beg end) + (save-excursion +(let ((output nil) + (last-line (line-number-at-pos end))) + (goto-char beg) + (beginning-of-line) + (while (= (line-number-at-pos) last-line) + (setq output (cons (get-text-property (point) property) output)) + (forward-line 1)) + output))) + (defun notmuch-search-find-thread-id () Return the thread for the current thread (get-text-property (point) 'notmuch-search-thread-id)) +(defun notmuch-search-find-thread-id-region (beg end) + Return a list of threads for the current region + (notmuch-search-properties-in-region 'notmuch-search-thread-id beg end)) + (defun notmuch-search-find-authors () Return the authors for the current thread (get-text-property (point) 'notmuch-search-authors)) +(defun notmuch-search-find-authors-region (beg end) + Return a list of authors for the current region + (notmuch-search-properties-in-region notmuch-search-authors beg end)) + (defun notmuch-search-find-subject () Return the subject for the current thread (get-text-property (point) 'notmuch-search-subject)) +(defun notmuch-search-find-subject-region (beg end) + Return a list of authors for the current region + (notmuch-search-properties-in-region notmuch-search-subject beg end)) + (defun notmuch-search-show-thread () Display the currently selected thread. (interactive) @@ -1173,6 +1196,14 @@ and will also appear in a buffer named \*Notmuch errors*\. (delete-region beg end) (insert (mapconcat 'identity tags )) +(defun notmuch-search-set-tags-region (tags beg end) + (save-excursion +(let ((last-line (line-number-at-pos end))) + (goto-char beg) + (while (= (line-number-at-pos) last-line) + (notmuch-search-set-tags tags) + (forward-line) + (defun notmuch-search-get-tags () (save-excursion (end-of-line) @@ -1182,32 +1213,74 @@ and will also appear in a buffer named \*Notmuch errors*\. (let ((end (- (point) 1))) (split-string (buffer-substring beg end)) +(defun notmuch-search-get-tags-region (beg end) + (save-excursion +(let ((output nil) + (last-line (line-number-at-pos end))) + (goto-char beg) + (while (= (line-number-at-pos) last-line) + (setq output (append output (notmuch-search-get-tags))) + (forward-line 1)) + output))) + +(defun notmuch-search-add-tag-thread (tag) + (notmuch-call-notmuch-process tag (concat + tag) (notmuch-search-find-thread-id)) + (notmuch-search-set-tags (delete-dups (sort (cons tag (notmuch-search-get-tags)) 'string + +(defun notmuch-search-add-tag-region (tag beg end) + (let ((search-id-string (mapconcat 'identity (notmuch-search-find-thread-id-region beg end) or ))) +(notmuch-call-notmuch-process tag (concat + tag) search-id-string) +(notmuch-search-set-tags-region (delete-dups (sort (cons tag (notmuch-search-get-tags-region beg end)) 'string)) beg end))) + +(defun notmuch-search-remove-tag-thread (tag) + (notmuch-call-notmuch-process tag (concat - tag) (notmuch-search-find-thread-id)) + (notmuch-search-set-tags (delete tag (notmuch-search-get-tags + +(defun notmuch-search-remove-tag-region (tag beg end) + (let ((search-id-string (mapconcat 'identity (notmuch-search-find-thread-id-region beg end) or ))) +(notmuch-call-notmuch-process tag (concat - tag) search-id-string) +(notmuch-search-set-tags-region (delete tag (notmuch-search-get-tags-region beg end)) beg end))) + (defun notmuch-search-add-tag (tag) - Add a tag to the currently selected thread. + Add a tag to the currently selected thread or region. -The tag is added to messages in the currently selected thread -which match the current search terms. +The tag is added to messages in the currently selected thread or +region which match the current search terms. (interactive (list (notmuch-select-tag-with-completion Tag to add: ))) - (notmuch-call-notmuch-process tag (concat + tag) (notmuch-search-find-thread-id)) -
Re: [notmuch] [PATCH] notmuch.el: add functionality to add or remove tags by region.
On Thu, Jan 21, 2010 at 10:35:34AM -0500, Jesse Rosenthal wrote: Region is emacs-speak for selected area (either click-and-drag or C-SPC and then motion commands). Basically, this was meant to be an emacsy-way of tagging a bunch of messages in a buffer at once. I understand what a region is in emacs land, but I don't understand how it translates to mail land. Notmuch is not to my knowledge capable of tagging a sub-region of a message, so in that sense it might not work. If you goal is to tag only a subset of messages in a thread, then regions don't seem like the most natural way to do that, since regions are non-disjoint. Would it be better to use some sort of tag/apply system ala mutt instead? jamie. ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [notmuch] [PATCH] notmuch.el: add functionality to add or remove tags by region.
On Thu, 21 Jan 2010 10:56:59 -0500, Jameson Rollins jroll...@finestructure.net wrote: Notmuch is not to my knowledge capable of tagging a sub-region of a message, so in that sense it might not work. This is only in notmuch-search mode, so it only operates on full threads. Would it be better to use some sort of tag/apply system ala mutt instead? That could work too. The main reason I implemented this is that, as an emacs user, I kept intuitively trying to tag messages in this way, and it wouldn't work. I actually was thinking of combining regions and marking (let's call it that to keep from getting confused with notmuch tags) -- i.e., have region selection in search mode also mark messages. And then there could also be a message-by-message way if you wanted to mark disjoint messages. Best, Jesse ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: [notmuch] [PATCH] notmuch.el: add functionality to add or remove tags by region.
...have region selection in search mode also mark messages. And then there could also be a message-by-message way if you wanted to mark disjoint messages. Sorry, I'm getting myself confused here. Not messages, *threads*. ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[notmuch] Fcc, Maildir, and Emacs message-mode -- a bit of code
Dear all, First of all, many thanks to Carl and others for writing notmuch. Some folks on IRC were bemoaning message-mode's annoying inability to save sent-mail to a Maildir using Fcc. I mentioned that I had written a bit of Maildir elisp code for that purpose a while back, and it was suggested that I share it with the list. Some caveats: - I've tested this a good number of times, but not very robustly, since I don't actually use it (I found that I prefer blind-copying myself). Please test it out somewhere safe, on a maildir you can afford to lose. - The hardlinking performed by `add-name-to-file' might be platform and filesystem specific. I'm using linux/ext3, and it works here. I don't know what will happen anywhere else. - I imagine there's a much better implementation inside of Wanderlust, if you can dig through all the libraries. - It's not really commented, but I hope the function names are pretty self-explanatory. - It requires that the directory in the `Fcc:' header already exist and be a maildir (i.e. have cur/, new/, and tmp/). It should be pretty simple to add in a prompt for creating a directory if it points to a nonexistent place. Anyway, here it is: http://jkr.acm.jhu.edu/jkr-maildir.el To use it, set one of the following: If you want Fcc'd messages to be marked as read: (setq message-fcc-handler-function '(lambda (destdir) (jkr/maildir-write-buffer-to-maildir destdir t))) If you want Fcc'd messages to be marked as new: (setq message-fcc-handler-function '(lambda (destdir) (jkr/maildir-write-buffer-to-maildir destdir nil))) Best, Jesse ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[notmuch] [PATCH] d_type fix
A review of notmuch-new.c shows three uses of -d_type: Near line 153, in _entries_resemble_maildir() we can simply allow for DT_UNKNOWN. This would fail if people have MH-style folders which have three folders called new cur and tmp, but that seems unlikely, in which case the tmp folder would simply not be scanned. Near line 273 in add_files_recursive() we have another check. If DT_UNKNOWN, we fall through, then add_files_recursive() does a stat almost immediately, returning with success if the path isn't a directory. Thus, the fallback is already written. Finally, near line 343, in add_files_recursive() (a long function) we have another check. Here we can simply treat DT_UNKNOWN as DT_LNK, since the logic for the stat() results are the same. Attached is a patch which was tested with reiserfs. It should also work with xfs. diff --git a/notmuch-new.c b/notmuch-new.c index b740ee2..3e6b96a 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -153,7 +153,7 @@ _entries_resemble_maildir (struct dirent **entries, int count) int i, found = 0; for (i = 0; i count; i++) { - if (entries[i]-d_type != DT_DIR) + if (entries[i]-d_type != DT_DIR entries[i]-d_type != DT_UNKNOWN) continue; if (strcmp(entries[i]-d_name, new) == 0 || @@ -273,7 +273,8 @@ add_files_recursive (notmuch_database_t *notmuch, entry = fs_entries[i]; - if (entry-d_type != DT_DIR entry-d_type != DT_LNK) + if (entry-d_type != DT_DIR entry-d_type != DT_LNK + entry-d_type != DT_UNKNOWN) continue; /* Ignore special directories to avoid infinite recursion. @@ -343,7 +344,7 @@ add_files_recursive (notmuch_database_t *notmuch, /* If we're looking at a symlink, we only want to add it if it * links to a regular file, (and not to a directory, say). */ - if (entry-d_type == DT_LNK) { + if (entry-d_type == DT_LNK || entry-d_type == DT_UNKNOWN) { int err; next = talloc_asprintf (notmuch, %s/%s, path, entry-d_name); ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[notmuch] [PATCH] GCC3.5 fix
I have reason to need GCC 3.5 which doesn't process the unused(x) macro correctly. This is probably a bug in 3.5, nevertheless the patch is simple and corrects the build. GCC 3.5 also does not understand -Wextra but Makefile is bound to change less frequently, so I did not include a patch for that. diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h index c7fb0ef..ad6dcd8 100644 --- a/lib/notmuch-private.h +++ b/lib/notmuch-private.h @@ -74,7 +74,7 @@ _internal_error (const char *format, ...) PRINTF_ATTRIBUTE (1, 2); _internal_error (format (%s).\n, \ ##__VA_ARGS__, __location__) -#define unused(x) x __attribute__ ((unused)) +#define unused(x) x __attribute__((unused)) /* Thanks to Andrew Tridgell's (SAMBA's) talloc for this definition of * unlikely. The talloc source code comes to us via the GNU LGPL v. 3. diff --git a/notmuch-client.h b/notmuch-client.h index 77766de..87e599a 100644 --- a/notmuch-client.h +++ b/notmuch-client.h @@ -49,7 +49,7 @@ #include talloc.h -#define unused(x) x __attribute__ ((unused)) +#define unused(x) x __attribute__((unused)) /* There's no point in continuing when we've detected that we've done * something wrong internally (as opposed to the user passing in a ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[notmuch] A few patches
I've got a few patches available in my notmuch repo: http://git.pioto.org/gitweb/notmuch.git The 'noarg-count' branch makes `notmuch count` without any argument simply return the total number of messages in the database. This seems like it could be useful. The 'new-unread' branch makes `notmuch new` only tag messages as 'unread' if they don't have a maildir 'seen' flag. This shouldn't affect anyones existing database, but should make initial imports for people migrating from other mail setups (like me) go much better. -- Mike Kelly ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch