Re: [BUG] Custom headers in `notmuch-message-headers` are broken
> 3) We should think carefully about whether we want to blindly send >certain large headers like "Received". Some people use notmuch via >ssh or equivalent, and it might (dunno) be a concern. I'd prefer `notmuch show` to dump everything by default and have an option like `--headers` to limit those. I.e. to get current behavior you'd just dump comma-separated `notmuch-message-headers` into that option in `notmuch.el` and be happy. > 1) You'll want to avoid duplicating headers already emitted Why? Wouldn't that prevent you from parsing "Received" headers in `notmuch.el`? ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[BUG] Custom headers in `notmuch-message-headers` are broken
# What I did I added "X-Github-Sender" to `notmuch-message-headers`. Looked at a message sent via github with `notmuch-show`. # What I expected To see "X-Github-Sender" header displayed in `notmuch-show`. # What I got No such header was displayed. # Why `(notmuch-show "query")` runs ``` notmuch show --format=sexp --format-version=4 query ``` internally. The latter produces a sexp with ``` :headers (:Subject "" :From "" :To "" :Reply-To "" :Date "") ``` even when the message has many more headers. The end result is that `notmuch-message-headers` variable has no effect. ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: notmuch.el: controlling what does and doesn't get expanded in searches
Hi. I struggled with the same problem and wrote the following bit of code to solve it. I've been using it for a couple of years now and I'm so happy with it, that I forgot I wanted to get around to fix those TODOs. Feel free do whatever with it. Hope it helps. Cheers, Jan ;; A bit of notmuch-show-hook magic ;; ;; It makes notmuch-show ;; * show messages matching the specific query and hide the rest, or, if the query matches the whole thread, ;; * show unread or flagged messages of the thread and hide the rest, or, if there're no such messages, ;; * show all the messages ;; and jump to the very first one of those. ;; ;; This saves a lot of key presses. ;; ;; TODO: more generic one: by search query ;; TODO: rewrite using notmuch-show-mapc (defun oxij/notmuch-show-only-tags (tags) "In notmuch-show-mode show messages matching tags, hide the rest" (interactive) (save-excursion (goto-char (point-min)) (loop do (let ((props (notmuch-show-get-message-properties))) (if (remove-if-not (lambda (e) (member e tags)) (plist-get props :tags)) (notmuch-show-message-visible props t) (notmuch-show-message-visible props nil))) until (not (notmuch-show-goto-message-next) ;; TODO: how do I break out of mapc? (defun oxij/notmuch-show-interesting () "Hide boring messages when all messages in the buffer match the specified query" (let ((all-matched t)) (notmuch-show-mapc (lambda () (let ((props (notmuch-show-get-message-properties))) (unless (plist-get props :match) (setq all-matched nil) (when all-matched (oxij/notmuch-show-only-tags '("unread" "flagged") ;; notmuch-show-goto-first-wanted-message will be called just after ;; this hook and will undo the result of this when ;; oxij/notmuch-show-interesting hides everything. see the source of ;; notmuch-show-goto-first-wanted-message for details (add-hook 'notmuch-show-hook 'oxij/notmuch-show-interesting) ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [BUG] gmime-3.0.1 (was: [PATCH] crypto: gracefully handle gmime errors)
David Bremnerwrites: > There is code involved with configuring gmime-2.6, which nonetheless > does not involve calling gpg itself. As for notmuch-crypto.el, yes it's > true that the emacs client sometimes does some stuff directly with gpg, > but that has nothing to do with gmime. That's what I wanted to hear. Thank you! (And another thanks for the patience.) Cheers, Jan ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [BUG] gmime-3.0.1 (was: [PATCH] crypto: gracefully handle gmime errors)
Servilio Afre Puentes <servi...@gmail.com> writes: > On Tue, Sep 05 2017, Jan Malakhovski wrote: > > [...] >> I added `gpgme` to `buildInputs` of `gmime` and now `notmuch` passes all >> the tests. Yay! So that was the root problem. >> >> Is it correct to assume that when building with `gmime-3` `notmuch` >> stops calling `gpg` binary and does all the things PGP using `gmime-3`? > > Yes, they use GPGME instead of a custom wrapper: > > https://mail.gnome.org/archives/gmime-devel-list/2017-April/msg2.html > > BTW, I created a merge-request to have GMime 3 in Nixpkgs: > > https://github.com/NixOS/nixpkgs/pull/28796 I continued this nix-specific discussion there. ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [BUG] gmime-3.0.1 (was: [PATCH] crypto: gracefully handle gmime errors)
David Bremnerwrites: >> I added `gpgme` to `buildInputs` of `gmime` and now `notmuch` passes all >> the tests. Yay! So that was the root problem. >> >> Is it correct to assume that when building with `gmime-3` `notmuch` >> stops calling `gpg` binary and does all the things PGP using `gmime-3`? >> > > notmuch does not call gpg directly in either case. What changes in the > way gmime calls gpg. In 2.6 gmime called gpg, while in 3.0 it uses gpgme. > It sounds like your gmime-3 package is missing a dependency on gpgme. Why then at the very least - crypto.c - notmuch-config.c - emacs/notmuch-crypto.el files refer to "gpg" in the source with lines like params.crypto.gpgpath = notmuch_config_get_crypto_gpg_path (config); notmuch_config_set_crypto_gpg_path (config, "gpg"); gpgctx = g_mime_gpg_context_new (NULL, crypto->gpgpath ? crypto->gpgpath : "gpg") ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [BUG] gmime-3.0.1 (was: [PATCH] crypto: gracefully handle gmime errors)
Hi. David Bremnerwrites: > I'm fairly certain this something nix specific. 3.0.1 is the > default version of gmime I develop against these days. > >> patching sources > > What patches, if any are applied here? None. >> T350-crypto: Testing PGP/MIME signature verification and decryption >> PASS emacs delivery of signed message >> FAIL signature verification >> --- T350-crypto.2.expected 2017-08-31 14:25:03.126885225 + >> +++ T350-crypto.2.output2017-08-31 14:25:03.126885225 + >> @@ -18,13 +18,7 @@ >> ], >> "content-type": "multipart/signed", >> "id": 1, >> -"sigstatus": [ >> -{ >> -"created": 946728000, >> -"fingerprint": >> "5AEAB11F5E33DCE875DDB75B6D92612D94E46381", >> -"status": "good" >> -} >> -] >> +"sigstatus": [] >> } >> ], >> "date_relative": "2000-01-01", >> Failed to verify signed part: Cannot verify multipart/signed part: >> unregistered signature protocol 'application/pgp-signature'. > > It seems like your gmime install doesn't understand PGP/MIME. That's > pretty strange since afaik it enables SMIME and PGP/MIME with the same flag. > > Previously you wrote > , > |I wonder why gnupg stops getting referenced with gmime-3.0.1. My guess > |is that `./configure` does something very different when compiling with > |gmime-3. > ` > > Although I don't think that configure is really the problem, the missing > dependence on gnupg is suspicious. Not having a gpg binary at all > should cause more failures and/or messages about skipping. It's hard for > me to test because on Debian there is a hard dependency of gmime-3.0 on > gnupg. I added `gpgme` to `buildInputs` of `gmime` and now `notmuch` passes all the tests. Yay! So that was the root problem. Is it correct to assume that when building with `gmime-3` `notmuch` stops calling `gpg` binary and does all the things PGP using `gmime-3`? It's the only explanation I have for why `notmuch` package stops directly referencing `gpg` even when the sources get patched with 's/gpg/${pkgs.gpg}/bin/gpg/g' (not exactly, but close enough). Cheers, Jan ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH] cli: propagate NULL from _mime_node_create, handle it in callers.
Hi. David Bremnerwrites: > Can you check if this fixes the segfault for you? It's based on your > patch, and your followup comment. It tries to handle all of the places > mime_node_child is called. It fixes segfaults the same way my patch does, but it also suffers from the same problems. It fixes the SIGSEGV, but, as with my patch, without some more code around those NULLs `notmuch search --format=sexp --decrypt` simply produces empty bodies (`:body ()`) for suspect messages. That breaks rendering of those messages in `notmuch.el` (it fails with some exception and stops rendering the rest of the thread; which is better than rendering no messages in the thread, but still very far from ideal). This solution also doesn't print any content when it could (in case of an invalid signature). Compiling with gmime-3.0.1, on the other hand, works perfectly. It just shows that the signature is invalid and that's it, the rest of the message and the rest of the thread renders perfectly. The problem with gmime-3.0.1, as my other message still stuck in moderation shows, is that a lot of other tests fail with some silly differences in the produced JSONs. Maybe its a bug in the tests. Maybe its a problem of `gmime` from `nixpkgs` (apparently, it can't do pkcs7 and I didn't investigate why yet). I'm not sure. TBH, I would just `exit(1)` with an error like "your gmime is broken" instead of producing NULLs whet gmime produces a NULL (to be future-proof), assert non-NULL in all the other places, drop support for gmime-2.6.*, require gmime-3.*, fix the tests (or `nixpkgs`) and get happy. Cheers, Jan ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH] crypto: gracefully handle gmime errors
David Bremner <da...@tethera.net> writes: > Jan Malakhovski <o...@oxij.org> writes: > >> >> The test suite has such a message already. "signature verification >> (notmuch CLI)" test fails with a SIGSEGV when built with gmime-2.6.23. >> >> T355-smime: Testing S/MIME signature verification and decryption >> gpgsm: keybox >> '/tmp/nix-build-notmuch-0.25.drv-0/notmuch-test-8789.qe2sRf/gnupg/pubring.kbx' >> created >> PASS emacs delivery of S/MIME signed message >> PASS emacs delivery of S/MIME encrypted + signed message >> PASS Signature verification (openssl) >> FAIL signature verification (notmuch CLI) > > Actually now that I try, I can't duplicate this failure on Debian (also > with gmime-2.6.23). Matt, can you confirm or deny that the failures you > were having were with SMIME signed messages? Versions of all dependencies as per diff of `nix-store -q --requisites` between two builds, if it helps: --- /proc/self/fd/112017-08-31 23:53:53.387411873 + +++ /proc/self/fd/122017-08-31 23:53:53.405412185 + @@ -1,10 +1,9 @@ /nix/store/y4ihw837rm0s0ps5f31zi18w7ri1a0y8-glibc-2.25 /nix/store/bcg4yk2kinfd9703m3qlh7gkivkg1kqj-zlib-1.2.11 /nix/store/2hd1rag058ija0ivn3ip4lfjdsnk1l9r-glib-2.52.1 -/nix/store/3ia3cz1hikmfhwgmbyf0j005myh9y7rb-gmime-2.6.23 +/nix/store/8ms9r6qw41rds9f59swiaaypmx07p376-gmime-3.0.1 /nix/store/axldd4qjamb2c1lgi7d6k3s51qyy4610-bash-4.4-p12 /nix/store/ds1qs36gzkzr4z6fvpdchwkhgkwq94p5-gcc-6.4.0-lib /nix/store/9636ksx6g2yifzx4d3wcfir87s3dzlja-xapian-1.4.4 -/nix/store/g3px2vjcfhaq7f6hdm1xnmbk5ry5qjrv-gnupg-2.1.23 /nix/store/wfq4aip4ljnv0irx0r8b54pihfhz6im9-talloc-2.1.8 -/nix/store/h0lzwh8pmpcdzg7q8xl9bj5lzd9rvf71-notmuch-0.25 +/nix/store/kfwjlk0mqzisc77zxiflbamnrc52mfhq-notmuch-0.25 I wonder why gnupg stops getting referenced with gmime-3.0.1. My guess is that `./configure` does something very different when compiling with gmime-3. Also, I think another message of mine got stuck in premoderation because it had a biggish attachment with a build log. Cheers, Jan ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH] crypto: gracefully handle gmime errors
David Bremnerwrites: > Oh, by the way, I think this was reported already in > id:qf5d17wzq90@google.com, but we don't have a test case. Yep. Seems to be the same bug. Added to References. > So if you have (or can make) a message that triggers these segfaults, > and that you can share, that would be helpful. The test suite has such a message already. "signature verification (notmuch CLI)" test fails with a SIGSEGV when built with gmime-2.6.23. T355-smime: Testing S/MIME signature verification and decryption gpgsm: keybox '/tmp/nix-build-notmuch-0.25.drv-0/notmuch-test-8789.qe2sRf/gnupg/pubring.kbx' created PASS emacs delivery of S/MIME signed message PASS emacs delivery of S/MIME encrypted + signed message PASS Signature verification (openssl) FAIL signature verification (notmuch CLI) --- T355-smime.4.expected 2017-08-31 14:57:24.145052329 + +++ T355-smime.4.output 2017-08-31 14:57:24.145052329 + @@ -1,56 +1 @@ -[ -[ -[ -{ -"body": [ -{ -"content": [ -{ -"content": "This is a test signed message.\n", -"content-type": "text/plain", -"id": 2 -}, -{ -"content-disposition": "attachment", -"content-length": "NONZERO", -"content-transfer-encoding": "base64", -"content-type": "application/x-pkcs7-signature", -"filename": "smime.p7s", -"id": 3 -} -], -"content-type": "multipart/signed", -"id": 1, -"sigstatus": [ -{ -"created": 946728000, -"expires": 424242424, -"fingerprint": "616F46CD73834C63847756AF0DFB64A6E0972A47", -"status": "good" -} -] -} -], -"date_relative": "2000-01-01", -"excluded": false, -"filename": [ -"Y" -], -"headers": { -"Date": "Sat, 01 Jan 2000 12:00:00 +", -"From": "Notmuch Test Suite ", -"Subject": "test signed message 001", -"To": "test_su...@notmuchmail.org" -}, -"id": "X", -"match": true, -"tags": [ -"inbox", -"signed" -], -"timestamp": 946728000 -}, -[] -] -] -] + Failed to construct pkcs7 context. No JSON object could be decoded PASS Decryption and signature verification (openssl) Cheers, Jan ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH] crypto: gracefully handle gmime errors
Hi. On second though @@ -354,6 +357,8 @@ _mime_node_seek_dfs_walk (mime_node_t *node, int *n) *n -= 1; for (i = 0; i < node->nchildren; i++) { mime_node_t *child = mime_node_child (node, i); + if (!child) + return NULL; mime_node_t *ret = _mime_node_seek_dfs_walk (child, n); if (ret) return ret; is probably an incorrect way to do this since the next child node can succeed. Maybe it should be `continue` instead of `return NULL`. Not sure. Feel free to ignore this patch if there's a better way to fix those SIGSEGVs. I get them by building against `gmime-2.6.23` and running `tests/T355-smime.sh` and by trying to open some mails in my inbox (which breaks display in emacs as `notmuch` just crashed in the middle of an s-expression). Cheers, Jan ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[PATCH] crypto: gracefully handle gmime errors
Before: dies by SIGSEGV when gmime produces an error. After: doesn't print NULL mime nodes. --- mime-node.c| 5 + notmuch-show.c | 18 +- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/mime-node.c b/mime-node.c index 24d73afa..f27aeb9a 100644 --- a/mime-node.c +++ b/mime-node.c @@ -317,7 +317,10 @@ mime_node_child (mime_node_t *parent, int child) INTERNAL_ERROR ("Unexpected GMimeObject type: %s", g_type_name (G_OBJECT_TYPE (parent->part))); } + node = _mime_node_create (parent, sub); +if (!node) + return NULL; if (child == parent->next_child && parent->next_part_num != -1) { /* We're traversing in depth-first order. Record the child's @@ -354,6 +357,8 @@ _mime_node_seek_dfs_walk (mime_node_t *node, int *n) *n -= 1; for (i = 0; i < node->nchildren; i++) { mime_node_t *child = mime_node_child (node, i); + if (!child) + return NULL; mime_node_t *ret = _mime_node_seek_dfs_walk (child, n); if (ret) return ret; diff --git a/notmuch-show.c b/notmuch-show.c index cdcc2a98..2c591e37 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -567,8 +567,11 @@ format_part_text (const void *ctx, sprinter_t *sp, mime_node_t *node, } } -for (i = 0; i < node->nchildren; i++) - format_part_text (ctx, sp, mime_node_child (node, i), indent, params); +for (i = 0; i < node->nchildren; i++) { + mime_node_t * child = mime_node_child (node, i); + if (child) + format_part_text (ctx, sp, child, indent, params); +} if (GMIME_IS_MESSAGE (node->part)) g_mime_stream_printf (stream, "\fbody}\n"); @@ -619,7 +622,9 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node, if (output_body) { sp->map_key (sp, "body"); sp->begin_list (sp); - format_part_sprinter (ctx, sp, mime_node_child (node, 0), TRUE, include_html); + mime_node_t * child = mime_node_child (node, 0); + if (child) + format_part_sprinter (ctx, sp, child, TRUE, include_html); sp->end (sp); } sp->end (sp); @@ -720,8 +725,11 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node, nclose = 3; } -for (i = 0; i < node->nchildren; i++) - format_part_sprinter (ctx, sp, mime_node_child (node, i), TRUE, include_html); +for (i = 0; i < node->nchildren; i++) { + mime_node_t * child = mime_node_child (node, i); + if (child) + format_part_sprinter (ctx, sp, child, TRUE, include_html); +} /* Close content structures */ for (i = 0; i < nclose; i++) -- 2.14.1 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[PATCH] build: fix unbound variable in configure
--- configure | 1 + 1 file changed, 1 insertion(+) diff --git a/configure b/configure index 364854f3..c0a550c7 100755 --- a/configure +++ b/configure @@ -651,6 +651,7 @@ if command -v cppcheck > /dev/null; then have_cppcheck=1 printf "Yes.\n" else +have_cppcheck=0 printf "No.\n" fi -- 2.14.1 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[PATCH] python: fix get_filenames() and make it actually usable
The problem with the previous implementation is that different versions of python exhaust __iter__() differently and the implementation that can be exhausted is not only absolutely unusable in the user code, but it also can not be consistently used with both python 2.* and 3.*. This doesn't change the interface. --- bindings/python/notmuch/filenames.py | 84 +++- 1 file changed, 26 insertions(+), 58 deletions(-) diff --git a/bindings/python/notmuch/filenames.py b/bindings/python/notmuch/filenames.py index 229f414..e2b8886 100644 --- a/bindings/python/notmuch/filenames.py +++ b/bindings/python/notmuch/filenames.py @@ -65,6 +65,18 @@ class Filenames(Python3StringMixIn): _get.argtypes = [NotmuchFilenamesP] _get.restype = c_char_p +_valid = nmlib.notmuch_filenames_valid +_valid.argtypes = [NotmuchFilenamesP] +_valid.restype = bool + +_move_to_next = nmlib.notmuch_filenames_move_to_next +_move_to_next.argtypes = [NotmuchFilenamesP] +_move_to_next.restype = None + +_destroy = nmlib.notmuch_filenames_destroy +_destroy.argtypes = [NotmuchFilenamesP] +_destroy.restype = None + def __init__(self, files_p, parent): """ :param files_p: A pointer to an underlying *notmuch_tags_t* @@ -83,68 +95,24 @@ class Filenames(Python3StringMixIn): if not files_p: raise NullPointerError() -self._files_p = files_p +self._list = [] +while self._valid(files_p): +file_ = self._get(files_p) +self._move_to_next(files_p) +self._list.append(file_.decode('utf-8', 'ignore')) +self._destroy(files_p) + #save reference to parent object so we keep it alive self._parent = parent def __iter__(self): -""" Make Filenames an iterator """ -return self - -_valid = nmlib.notmuch_filenames_valid -_valid.argtypes = [NotmuchFilenamesP] -_valid.restype = bool - -_move_to_next = nmlib.notmuch_filenames_move_to_next -_move_to_next.argtypes = [NotmuchFilenamesP] -_move_to_next.restype = None - -def __next__(self): -if not self._files_p: -raise NotInitializedError() - -if not self._valid(self._files_p): -self._files_p = None -raise StopIteration - -file_ = Filenames._get(self._files_p) -self._move_to_next(self._files_p) -return file_.decode('utf-8', 'ignore') -next = __next__ # python2.x iterator protocol compatibility - -def __unicode__(self): -"""Represent Filenames() as newline-separated list of full paths - -.. note:: - -This method exhausts the iterator object, so you will not be able to -iterate over them again. -""" -return "\n".join(self) - -_destroy = nmlib.notmuch_filenames_destroy -_destroy.argtypes = [NotmuchMessageP] -_destroy.restype = None - -def __del__(self): -"""Close and free the notmuch filenames""" -if self._files_p: -self._destroy(self._files_p) +"""Make Filenames an iterator""" +return self._list.__iter__() def __len__(self): -"""len(:class:`Filenames`) returns the number of contained files +"""len(:class:`Filenames`) returns the number of contained files""" +return self._list.__len__() -.. note:: - -This method exhausts the iterator object, so you will not be able to -iterate over them again. -""" -if not self._files_p: -raise NotInitializedError() - -i = 0 -while self._valid(self._files_p): -self._move_to_next(self._files_p) -i += 1 -self._files_p = None -return i +def __unicode__(self): +"""Represent Filenames() as newline-separated list of full paths""" +return "\n".join(self) -- 2.4.1
[PATCH] python: fix get_filenames() and make it actually usable
The problem with the previous implementation is that different versions of python exhaust __iter__() differently and the implementation that can be exhausted is not only absolutely unusable in the user code, but it also can not be consistently used with both python 2.* and 3.*. This doesn't change the interface. --- bindings/python/notmuch/filenames.py | 84 +++- 1 file changed, 26 insertions(+), 58 deletions(-) diff --git a/bindings/python/notmuch/filenames.py b/bindings/python/notmuch/filenames.py index 229f414..e2b8886 100644 --- a/bindings/python/notmuch/filenames.py +++ b/bindings/python/notmuch/filenames.py @@ -65,6 +65,18 @@ class Filenames(Python3StringMixIn): _get.argtypes = [NotmuchFilenamesP] _get.restype = c_char_p +_valid = nmlib.notmuch_filenames_valid +_valid.argtypes = [NotmuchFilenamesP] +_valid.restype = bool + +_move_to_next = nmlib.notmuch_filenames_move_to_next +_move_to_next.argtypes = [NotmuchFilenamesP] +_move_to_next.restype = None + +_destroy = nmlib.notmuch_filenames_destroy +_destroy.argtypes = [NotmuchFilenamesP] +_destroy.restype = None + def __init__(self, files_p, parent): :param files_p: A pointer to an underlying *notmuch_tags_t* @@ -83,68 +95,24 @@ class Filenames(Python3StringMixIn): if not files_p: raise NullPointerError() -self._files_p = files_p +self._list = [] +while self._valid(files_p): +file_ = self._get(files_p) +self._move_to_next(files_p) +self._list.append(file_.decode('utf-8', 'ignore')) +self._destroy(files_p) + #save reference to parent object so we keep it alive self._parent = parent def __iter__(self): - Make Filenames an iterator -return self - -_valid = nmlib.notmuch_filenames_valid -_valid.argtypes = [NotmuchFilenamesP] -_valid.restype = bool - -_move_to_next = nmlib.notmuch_filenames_move_to_next -_move_to_next.argtypes = [NotmuchFilenamesP] -_move_to_next.restype = None - -def __next__(self): -if not self._files_p: -raise NotInitializedError() - -if not self._valid(self._files_p): -self._files_p = None -raise StopIteration - -file_ = Filenames._get(self._files_p) -self._move_to_next(self._files_p) -return file_.decode('utf-8', 'ignore') -next = __next__ # python2.x iterator protocol compatibility - -def __unicode__(self): -Represent Filenames() as newline-separated list of full paths - -.. note:: - -This method exhausts the iterator object, so you will not be able to -iterate over them again. - -return \n.join(self) - -_destroy = nmlib.notmuch_filenames_destroy -_destroy.argtypes = [NotmuchMessageP] -_destroy.restype = None - -def __del__(self): -Close and free the notmuch filenames -if self._files_p: -self._destroy(self._files_p) +Make Filenames an iterator +return self._list.__iter__() def __len__(self): -len(:class:`Filenames`) returns the number of contained files +len(:class:`Filenames`) returns the number of contained files +return self._list.__len__() -.. note:: - -This method exhausts the iterator object, so you will not be able to -iterate over them again. - -if not self._files_p: -raise NotInitializedError() - -i = 0 -while self._valid(self._files_p): -self._move_to_next(self._files_p) -i += 1 -self._files_p = None -return i +def __unicode__(self): +Represent Filenames() as newline-separated list of full paths +return \n.join(self) -- 2.4.1 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch