[PATCH] test/thread-naming: remove excess escaping from sender address.

2017-05-23 Thread David Bremner
This is another case where the behaviour of gmime-2.6 and gmime-3.0
seems to differ. It may be that we prefer the more lax parsing of the
previous version, but that should be tested seperately.
---

As far as I can tell, the "LOOSE" parsing in gmime-3.0 is not as loose
as previous. It could well be that in the previous version we were
passing the raw header to xapian for term generation. That's arguably
the right thing to do, but as hinted in the commit message, I'd rather
deal with that in a seperate commit.

 test/T200-thread-naming.sh | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/test/T200-thread-naming.sh b/test/T200-thread-naming.sh
index 132c1d77..2167ba8e 100755
--- a/test/T200-thread-naming.sh
+++ b/test/T200-thread-naming.sh
@@ -66,11 +66,11 @@ test_expect_equal "$output" "thread:XXX   2001-01-12 [6/8] 
Notmuch Test Suite; t
 test_begin_subtest "Use empty subjects if necessary."
 add_message '[subject]="@FORCE_EMPTY"' \
'[date]="Sat, 13 Jan 2001 15:43:45 -"' \
-'[from]="Empty Sender \"'
+'[from]="Empty Sender "'
 empty_parent=${gen_msg_id}
 add_message '[subject]="@FORCE_EMPTY"' \
'[date]="Sun, 14 Jan 2001 15:43:45 -"' \
-'[from]="Empty Sender \"' \
+'[from]="Empty Sender "' \
 "[in-reply-to]=\<$empty_parent\>"
 output=$(notmuch search --sort=newest-first from:empty_t...@notmuchmail.org | 
notmuch_search_sanitize)
 test_expect_equal "$output" "thread:XXX   2001-01-14 [2/2] Empty Sender;  
(inbox unread)"
@@ -78,15 +78,15 @@ test_expect_equal "$output" "thread:XXX   2001-01-14 [2/2] 
Empty Sender;  (inbox
 test_begin_subtest "Avoid empty subjects if possible (newest-first)."
 add_message '[subject]="Non-empty subject (1)"' \
'[date]="Mon, 15 Jan 2001 15:43:45 -"' \
-'[from]="Empty Sender \"' \
+'[from]="Empty Sender "' \
 "[in-reply-to]=\<$empty_parent\>"
 add_message '[subject]="Non-empty subject (2)"' \
'[date]="Mon, 16 Jan 2001 15:43:45 -"' \
-'[from]="Empty Sender \"' \
+'[from]="Empty Sender "' \
 "[in-reply-to]=\<$empty_parent\>"
 add_message '[subject]="@FORCE_EMPTY"' \
'[date]="Tue, 17 Jan 2001 15:43:45 -"' \
-'[from]="Empty Sender \"' \
+'[from]="Empty Sender "' \
 "[in-reply-to]=\<$empty_parent\>"
 output=$(notmuch search --sort=newest-first from:Empty | 
notmuch_search_sanitize)
 test_expect_equal "$output" "thread:XXX   2001-01-17 [5/5] Empty Sender; 
Non-empty subject (2) (inbox unread)"
-- 
2.11.0

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 2/2] exit lingering gpg agents at the end of relevant tests

2017-05-23 Thread Daniel Kahn Gillmor
On Tue 2017-05-23 21:54:25 +0300, Tomi Ollila wrote:
> Since gnupg 2.1.20, gpg-agent no longer shut itself down when
> $GNUPGHOME directory is removed.
>
> Add exit hooks to the test modules which execute `gpgconf --kill all`
>
> Add exit hooks to execute `gpgconf --kill all` in the modules that
> create $GNUPGHOME for gpg to work with.

this pair of patches LGTM.

 --dkg
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v2 00/11] Add filesize index, search, sort & emacs UI

2017-05-23 Thread Ioan-Adrian Ratiu
On Tue, 23 May 2017, Jani Nikula  wrote:
> On Fri, 19 May 2017, Ioan-Adrian Ratiu  wrote:
>> I'd like to add a feature to quickly work with mail file sizes
>> because using custom scripts / external programs which parse
>> maildir contents is slow, and non-intuitive, especially since
>> notmuch does incremental parsing and has such a nice emacs UI.
>
> Before we dive into the details, I guess at least I'd like to see better
> rationale for the feature. I don't see myself searching or sorting based
> on message size. What's the use case? (I wouldn't mind adding the
> message size to the formatted output, but that doesn't require indexing
> the size or adding the search support for it.)

The use case is very simple: I routinely get big mail and want to know
about it to take various actions (extract attach, forward, archive etc).

Of course I can always write a script to search the maildir but that
takes too long, I'd very much rather have incremental indexing,
instant search and a very nice GUI front-end (emacs saved searches in
my case).

With this series I now have saved searches based on filesize which tell
me exactly instantly how many messages I have in a certain size range.

>
> One fundamental issue David noted on IRC, it'll be hard to decide what
> to index for "message" size when there are duplicates that typically
> have different sizes. For other things, we've indexed whatever comes
> first, but I suppose we'd like to fix that.

Yes, agreed, and I'll go even further: notmuch search shows thread
results - what I did in this patch series is sum up the total messages
file sizes in a thread for the search results.

We could do something similar, i.e. add all duplicate file sizes to the
"message" size and those in turn get added to a thread size. I'm not
saying we should necessarily do this, I'm just pointing it out as an
alternative which would work very well for me.

Ionel

>
> BR,
> Jani.
>
>>
>>
>> Ioan-Adrian Ratiu (11):
>>   lib: message: index message file sizes
>>   lib: database: store message filesize & add range processor
>>   notmuch-search: add filesize based sort order
>>   emacs: make notmuch-search-oldest-first generic
>>   emacs: notmuch-search: add filesize sorting
>>   sprinter: add unsigned_long printer function
>>   lib: thread: add thread total size function
>>   notmuch-search: output total_filesize thread result
>>   notmuch-show: export message filesize
>>   emacs: notmuch-search: add display thread sizes capability
>>   emacs: notmuch-show: add filesize to headerline
>>
>>  devel/schemata |  1 +
>>  doc/notmuch-emacs.rst  |  4 ++--
>>  emacs/notmuch-hello.el | 24 +---
>>  emacs/notmuch-jump.el  | 11 +--
>>  emacs/notmuch-lib.el   |  9 ++---
>>  emacs/notmuch-show.el  |  5 -
>>  emacs/notmuch-tree.el  |  2 +-
>>  emacs/notmuch.el   | 48 +---
>>  lib/database-private.h |  1 +
>>  lib/database.cc|  6 ++
>>  lib/index.cc   | 10 ++
>>  lib/message-file.c | 18 +-
>>  lib/message.cc | 29 +
>>  lib/notmuch-private.h  | 16 
>>  lib/notmuch.h  | 21 +
>>  lib/query.cc   |  6 ++
>>  lib/thread.cc  | 12 
>>  notmuch-search.c   |  8 +++-
>>  notmuch-show.c |  5 +
>>  sprinter-json.c|  9 +
>>  sprinter-sexp.c|  9 +
>>  sprinter-text.c|  9 +
>>  sprinter.h |  1 +
>>  23 files changed, 223 insertions(+), 41 deletions(-)
>>
>> -- 
>> 2.13.0
>>
>> ___
>> notmuch mailing list
>> notmuch@notmuchmail.org
>> https://notmuchmail.org/mailman/listinfo/notmuch
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[no subject]

2017-05-23 Thread Tomi Ollila
This implementation adds add_exit_function (and rm_exit_function)
which can also be used for other things in the future.

Now that I did this simpler way would be to just check for
existence of $GNUPGHOME for indication to exit gpg processes.

If that path is taken this series can be used for future reference
if need for atexit functionality arises.

From Tomi Ollila  # This line is ignored.
From: Tomi Ollila 
Subject: stop gpg-agent (among other) processes at test module exit
In-Reply-To: 

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 2/2] exit lingering gpg agents at the end of relevant tests

2017-05-23 Thread Tomi Ollila
Since gnupg 2.1.20, gpg-agent no longer shut itself down when
$GNUPGHOME directory is removed.

Add exit hooks to the test modules which execute `gpgconf --kill all`

Add exit hooks to execute `gpgconf --kill all` in the modules that
create $GNUPGHOME for gpg to work with.
---
 test/T350-crypto.sh | 2 ++
 test/T355-smime.sh  | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/test/T350-crypto.sh b/test/T350-crypto.sh
index b7d3a2c..d21cad1 100755
--- a/test/T350-crypto.sh
+++ b/test/T350-crypto.sh
@@ -11,6 +11,8 @@ add_gnupg_home ()
 {
 local output
 [ -d ${GNUPGHOME} ] && return
+_gnupg_exit () { gpgconf --kill all 2>/dev/null || true; }
+at_exit_function _gnupg_exit
 mkdir -m 0700 "$GNUPGHOME"
 gpg --no-tty --import <$TEST_DIRECTORY/gnupg-secret-key.asc 
>"$GNUPGHOME"/import.log 2>&1
 test_debug "cat $GNUPGHOME/import.log"
diff --git a/test/T355-smime.sh b/test/T355-smime.sh
index 639ca69..0f39bc6 100755
--- a/test/T355-smime.sh
+++ b/test/T355-smime.sh
@@ -7,6 +7,8 @@ add_gpgsm_home ()
 {
 local fpr
 [ -d ${GNUPGHOME} ] && return
+_gnupg_exit () { gpgconf --kill all 2>/dev/null || true; }
+at_exit_function _gnupg_exit
 mkdir -m 0700 "$GNUPGHOME"
 gpgsm --no-tty --no-common-certs-import --disable-dirmngr --import < 
$TEST_DIRECTORY/smime/test.crt >"$GNUPGHOME"/import.log 2>&1
 fpr=$(gpgsm  --list-key test_su...@notmuchmail.org | sed -n 
's/.*fingerprint: //p')
-- 
2.9.3

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 1/2] test-lib.sh: add "atexit" functionality

2017-05-23 Thread Tomi Ollila
New function at_exit_function registers given function to be called
at script termination.

Functions so registered are called in the reverse order of their
registration; no arguments are passed.

Function is called only once; re-adding with function name already
registered will remove previous registration.

New function rm_exit_function can be used to remove registration.

Modules (and possibly test-lib.sh functions) in future commits will
register such functions.
---
 test/test-lib.sh | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/test/test-lib.sh b/test/test-lib.sh
index 988b00a..37f8ddf 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -219,10 +219,21 @@ test_fixed=0
 test_broken=0
 test_success=0
 
+declare -a _exit_functions=()
+
+at_exit_function () {
+   _exit_functions=($1 ${_exit_functions[@]/$1})
+}
+
+rm_exit_function () {
+   _exit_functions=(${_exit_functions[@]/$1})
+}
+
 _exit_common () {
code=$?
trap - EXIT
set +ex
+   for _fn in ${_exit_functions[@]}; do $_fn; done
rm -rf "$TEST_TMPDIR"
 }
 
-- 
2.9.3

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v2 00/11] Add filesize index, search, sort & emacs UI

2017-05-23 Thread Jani Nikula
On Fri, 19 May 2017, Ioan-Adrian Ratiu  wrote:
> I'd like to add a feature to quickly work with mail file sizes
> because using custom scripts / external programs which parse
> maildir contents is slow, and non-intuitive, especially since
> notmuch does incremental parsing and has such a nice emacs UI.

Before we dive into the details, I guess at least I'd like to see better
rationale for the feature. I don't see myself searching or sorting based
on message size. What's the use case? (I wouldn't mind adding the
message size to the formatted output, but that doesn't require indexing
the size or adding the search support for it.)

One fundamental issue David noted on IRC, it'll be hard to decide what
to index for "message" size when there are duplicates that typically
have different sizes. For other things, we've indexed whatever comes
first, but I suppose we'd like to fix that.

BR,
Jani.

>
>
> Ioan-Adrian Ratiu (11):
>   lib: message: index message file sizes
>   lib: database: store message filesize & add range processor
>   notmuch-search: add filesize based sort order
>   emacs: make notmuch-search-oldest-first generic
>   emacs: notmuch-search: add filesize sorting
>   sprinter: add unsigned_long printer function
>   lib: thread: add thread total size function
>   notmuch-search: output total_filesize thread result
>   notmuch-show: export message filesize
>   emacs: notmuch-search: add display thread sizes capability
>   emacs: notmuch-show: add filesize to headerline
>
>  devel/schemata |  1 +
>  doc/notmuch-emacs.rst  |  4 ++--
>  emacs/notmuch-hello.el | 24 +---
>  emacs/notmuch-jump.el  | 11 +--
>  emacs/notmuch-lib.el   |  9 ++---
>  emacs/notmuch-show.el  |  5 -
>  emacs/notmuch-tree.el  |  2 +-
>  emacs/notmuch.el   | 48 +---
>  lib/database-private.h |  1 +
>  lib/database.cc|  6 ++
>  lib/index.cc   | 10 ++
>  lib/message-file.c | 18 +-
>  lib/message.cc | 29 +
>  lib/notmuch-private.h  | 16 
>  lib/notmuch.h  | 21 +
>  lib/query.cc   |  6 ++
>  lib/thread.cc  | 12 
>  notmuch-search.c   |  8 +++-
>  notmuch-show.c |  5 +
>  sprinter-json.c|  9 +
>  sprinter-sexp.c|  9 +
>  sprinter-text.c|  9 +
>  sprinter.h |  1 +
>  23 files changed, 223 insertions(+), 41 deletions(-)
>
> -- 
> 2.13.0
>
> ___
> notmuch mailing list
> notmuch@notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v2 06/11] sprinter: add unsigned_long printer function

2017-05-23 Thread Jani Nikula
On Fri, 19 May 2017, Ioan-Adrian Ratiu  wrote:
> We need to output unsigned long values for message and thread
> (sum of all message's) file sizes.

The sprinter types should be about the types that can be represented
using the format being output, i.e. JSON and S-Expressions, *not* about
the C types. I'd rather see the integer sprinter functions expanded to a
bigger type.

BR,
Jani.


>
> Signed-off-by: Ioan-Adrian Ratiu 
> ---
>  sprinter-json.c | 9 +
>  sprinter-sexp.c | 9 +
>  sprinter-text.c | 9 +
>  sprinter.h  | 1 +
>  4 files changed, 28 insertions(+)
>
> diff --git a/sprinter-json.c b/sprinter-json.c
> index 0a077907..de1dbec2 100644
> --- a/sprinter-json.c
> +++ b/sprinter-json.c
> @@ -132,6 +132,14 @@ json_integer (struct sprinter *sp, int val)
>  }
>  
>  static void
> +json_unsigned_long (struct sprinter *sp, unsigned long val)
> +{
> +struct sprinter_json *spj = json_begin_value (sp);
> +
> +fprintf (spj->stream, "%lu", val);
> +}
> +
> +static void
>  json_boolean (struct sprinter *sp, notmuch_bool_t val)
>  {
>  struct sprinter_json *spj = json_begin_value (sp);
> @@ -181,6 +189,7 @@ sprinter_json_create (const void *ctx, FILE *stream)
>   .string = json_string,
>   .string_len = json_string_len,
>   .integer = json_integer,
> + .unsigned_long = json_unsigned_long,
>   .boolean = json_boolean,
>   .null = json_null,
>   .map_key = json_map_key,
> diff --git a/sprinter-sexp.c b/sprinter-sexp.c
> index 08783e11..3162ad9c 100644
> --- a/sprinter-sexp.c
> +++ b/sprinter-sexp.c
> @@ -169,6 +169,14 @@ sexp_integer (struct sprinter *sp, int val)
>  }
>  
>  static void
> +sexp_unsigned_long (struct sprinter *sp, unsigned long val)
> +{
> +struct sprinter_sexp *sps = sexp_begin_value (sp);
> +
> +fprintf (sps->stream, "%lu", val);
> +}
> +
> +static void
>  sexp_boolean (struct sprinter *sp, notmuch_bool_t val)
>  {
>  struct sprinter_sexp *sps = sexp_begin_value (sp);
> @@ -216,6 +224,7 @@ sprinter_sexp_create (const void *ctx, FILE *stream)
>   .string = sexp_string,
>   .string_len = sexp_string_len,
>   .integer = sexp_integer,
> + .unsigned_long = sexp_unsigned_long,
>   .boolean = sexp_boolean,
>   .null = sexp_null,
>   .map_key = sexp_map_key,
> diff --git a/sprinter-text.c b/sprinter-text.c
> index 7779488f..5d1607e9 100644
> --- a/sprinter-text.c
> +++ b/sprinter-text.c
> @@ -52,6 +52,14 @@ text_integer (struct sprinter *sp, int val)
>  }
>  
>  static void
> +text_unsigned_long (struct sprinter *sp, unsigned long val)
> +{
> +struct sprinter_text *sptxt = (struct sprinter_text *) sp;
> +
> +fprintf (sptxt->stream, "%lu", val);
> +}
> +
> +static void
>  text_boolean (struct sprinter *sp, notmuch_bool_t val)
>  {
>  struct sprinter_text *sptxt = (struct sprinter_text *) sp;
> @@ -123,6 +131,7 @@ sprinter_text_create (const void *ctx, FILE *stream)
>   .string = text_string,
>   .string_len = text_string_len,
>   .integer = text_integer,
> + .unsigned_long = text_unsigned_long,
>   .boolean = text_boolean,
>   .null = text_null,
>   .map_key = text_map_key,
> diff --git a/sprinter.h b/sprinter.h
> index f859672f..2495a7d1 100644
> --- a/sprinter.h
> +++ b/sprinter.h
> @@ -34,6 +34,7 @@ typedef struct sprinter {
>  void (*string) (struct sprinter *, const char *);
>  void (*string_len) (struct sprinter *, const char *, size_t);
>  void (*integer) (struct sprinter *, int);
> +void (*unsigned_long) (struct sprinter *, unsigned long);
>  void (*boolean) (struct sprinter *, notmuch_bool_t);
>  void (*null) (struct sprinter *);
>  
> -- 
> 2.13.0
>
> ___
> notmuch mailing list
> notmuch@notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: Add support for imenu

2017-05-23 Thread Jani Nikula
On Tue, 23 May 2017, Damien Cassou  wrote:
> Please find attached a patch adding imenu support in both search 
> and show modes.

I would appreciate a commit message explaining what the patch is about,
written to someone who doesn't know what imenu is, or how it could be
applicable in search and show modes.

Please also look into using git send-email if possible, instead of
attaching the patch.

BR,
Jani.


>
> -- 
> Damien Cassou
> http://damiencassou.seasidehosting.st
>
> "Success is the ability to go from one failure to another without
> losing enthusiasm." --Winston Churchill
> From aa29c3e4227ad95e940a047494ef5367eaa57596 Mon Sep 17 00:00:00 2001
> From: Damien Cassou 
> Date: Tue, 23 May 2017 17:19:57 +0200
> Subject: [PATCH] Add imenu support in notmuch-show and notmuch-search
>
> ---
>  emacs/notmuch-show.el | 22 +-
>  emacs/notmuch.el  | 27 ---
>  2 files changed, 45 insertions(+), 4 deletions(-)
>
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index c670160..b7d6429 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -1516,7 +1516,11 @@
>  \\{notmuch-show-mode-map}"
>(setq notmuch-buffer-refresh-function #'notmuch-show-refresh-view)
>(setq buffer-read-only t
> - truncate-lines t))
> + truncate-lines t)
> +  (setq imenu-prev-index-position-function
> +#'notmuch-show-imenu-prev-index-position-function)
> +  (setq imenu-extract-index-name-function
> +#'notmuch-show-imenu-extract-index-name-function))
>  
>  (defun notmuch-tree-from-show-current-query ()
>"Call notmuch tree with the current query"
> @@ -2455,6 +2459,22 @@(list (completing-read "Mime type to use (default 
> text/plain): "
> (mailcap-mime-types) nil nil nil nil "text/plain")))
>(notmuch-show-apply-to-current-part-handle #'notmuch-show--mm-display-part 
> mime-type))
>  
> +(defun notmuch-show-imenu-prev-index-position-function ()
> +  "Move point to previous message in notmuch-show buffer.
> +This function is used as a value for
> +`imenu-prev-index-position-function'."
> +  (if (bobp)
> +  nil
> +(notmuch-show-previous-message)
> +t))
> +
> +(defun notmuch-show-imenu-extract-index-name-function ()
> +  "Return imenu name for line at point.
> +This function is used as a value for
> +`imenu-extract-index-name-function'.  Point should be at the
> +beginning of the line."
> +  (buffer-substring-no-properties (line-beginning-position) 
> (line-end-position)))
> +
>  (provide 'notmuch-show)
>  
>  ;;; notmuch-show.el ends here
> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> index 40b9fab..90af68e 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -374,7 +374,11 @@   (setq notmuch-buffer-refresh-function 
> #'notmuch-search-refresh-view)
>(set (make-local-variable 'scroll-preserve-screen-position) t)
>(add-to-invisibility-spec (cons 'ellipsis t))
>(setq truncate-lines t)
> -  (setq buffer-read-only t))
> +  (setq buffer-read-only t)
> +  (setq imenu-prev-index-position-function
> +#'notmuch-search-imenu-prev-index-position-function)
> +  (setq imenu-extract-index-name-function
> +#'notmuch-search-imenu-extract-index-name-function))
>  
>  (defun notmuch-search-get-result ( pos)
>"Return the result object for the thread at POS (or point).
> @@ -1094,8 +1098,8 @@   (bury-buffer))
>  
>  ;; Find the first notmuch buffer.
>  (setq first (loop for buffer in (buffer-list)
> -  if (notmuch-interesting-buffer buffer)
> -  return buffer))
> +   if (notmuch-interesting-buffer buffer)
> +   return buffer))
>  
>  (if first
>   ;; If the first one we found is any other than the starting
> @@ -1104,6 +1108,23 @@(unless (eq first start)
> (switch-to-buffer first))
>(notmuch
>  
> + Imenu Support
> +
> +(defun notmuch-search-imenu-prev-index-position-function ()
> +  "Move point to previous message in notmuch-search buffer.
> +This function is used as a value for
> +`imenu-prev-index-position-function'."
> +  (notmuch-search-previous-thread))
> +
> +(defun notmuch-search-imenu-extract-index-name-function ()
> +  "Return imenu name for line at point.
> +This function is used as a value for
> +`imenu-extract-index-name-function'.  Point should be at the
> +beginning of the line."
> +  (let ((subject (notmuch-search-find-subject))
> + (author (notmuch-search-find-authors)))
> +(format "%s (%s)" subject author)))
> +
>  (setq mail-user-agent 'notmuch-user-agent)
>  
>  (provide 'notmuch)
> -- 
> 2.9.4
>
> ___
> notmuch mailing list
> notmuch@notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Add support for imenu

2017-05-23 Thread Damien Cassou
Please find attached a patch adding imenu support in both search 
and show modes.


--
Damien Cassou
http://damiencassou.seasidehosting.st

"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill
>From aa29c3e4227ad95e940a047494ef5367eaa57596 Mon Sep 17 00:00:00 2001
From: Damien Cassou 
Date: Tue, 23 May 2017 17:19:57 +0200
Subject: [PATCH] Add imenu support in notmuch-show and notmuch-search

---
 emacs/notmuch-show.el | 22 +-
 emacs/notmuch.el  | 27 ---
 2 files changed, 45 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index c670160..b7d6429 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1516,7 +1516,11 @@
 \\{notmuch-show-mode-map}"
   (setq notmuch-buffer-refresh-function #'notmuch-show-refresh-view)
   (setq buffer-read-only t
-	truncate-lines t))
+	truncate-lines t)
+  (setq imenu-prev-index-position-function
+#'notmuch-show-imenu-prev-index-position-function)
+  (setq imenu-extract-index-name-function
+#'notmuch-show-imenu-extract-index-name-function))
 
 (defun notmuch-tree-from-show-current-query ()
   "Call notmuch tree with the current query"
@@ -2455,6 +2459,22 @@(list (completing-read "Mime type to use (default text/plain): "
 			  (mailcap-mime-types) nil nil nil nil "text/plain")))
   (notmuch-show-apply-to-current-part-handle #'notmuch-show--mm-display-part mime-type))
 
+(defun notmuch-show-imenu-prev-index-position-function ()
+  "Move point to previous message in notmuch-show buffer.
+This function is used as a value for
+`imenu-prev-index-position-function'."
+  (if (bobp)
+  nil
+(notmuch-show-previous-message)
+t))
+
+(defun notmuch-show-imenu-extract-index-name-function ()
+  "Return imenu name for line at point.
+This function is used as a value for
+`imenu-extract-index-name-function'.  Point should be at the
+beginning of the line."
+  (buffer-substring-no-properties (line-beginning-position) (line-end-position)))
+
 (provide 'notmuch-show)
 
 ;;; notmuch-show.el ends here
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 40b9fab..90af68e 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -374,7 +374,11 @@   (setq notmuch-buffer-refresh-function #'notmuch-search-refresh-view)
   (set (make-local-variable 'scroll-preserve-screen-position) t)
   (add-to-invisibility-spec (cons 'ellipsis t))
   (setq truncate-lines t)
-  (setq buffer-read-only t))
+  (setq buffer-read-only t)
+  (setq imenu-prev-index-position-function
+#'notmuch-search-imenu-prev-index-position-function)
+  (setq imenu-extract-index-name-function
+#'notmuch-search-imenu-extract-index-name-function))
 
 (defun notmuch-search-get-result ( pos)
   "Return the result object for the thread at POS (or point).
@@ -1094,8 +1098,8 @@   (bury-buffer))
 
 ;; Find the first notmuch buffer.
 (setq first (loop for buffer in (buffer-list)
-		 if (notmuch-interesting-buffer buffer)
-		 return buffer))
+		  if (notmuch-interesting-buffer buffer)
+		  return buffer))
 
 (if first
 	;; If the first one we found is any other than the starting
@@ -1104,6 +1108,23 @@ 	(unless (eq first start)
 	  (switch-to-buffer first))
   (notmuch
 
+ Imenu Support
+
+(defun notmuch-search-imenu-prev-index-position-function ()
+  "Move point to previous message in notmuch-search buffer.
+This function is used as a value for
+`imenu-prev-index-position-function'."
+  (notmuch-search-previous-thread))
+
+(defun notmuch-search-imenu-extract-index-name-function ()
+  "Return imenu name for line at point.
+This function is used as a value for
+`imenu-extract-index-name-function'.  Point should be at the
+beginning of the line."
+  (let ((subject (notmuch-search-find-subject))
+	(author (notmuch-search-find-authors)))
+(format "%s (%s)" subject author)))
+
 (setq mail-user-agent 'notmuch-user-agent)
 
 (provide 'notmuch)
-- 
2.9.4

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: changing behaviour of notmuch show --part=1

2017-05-23 Thread David Bremner
Daniel Kahn Gillmor  writes:

>>
>> 2) Allow-varying-output: Consider the previous behaviour a bug, fixed by
>>using gmime-3.0.  This makes it hard for people to rely on, although
>>how one relies on it currently since it varies by message is a
>>mystery.
>>
>> 3) Fix the alleged bug: special case the output of the body with
>>gmime-2.6 to avoid outputting headers.
>
> i favor (2) for the short term, while treating (3) as an open bug to be
> fixed.
>
> thanks for identifying this, David.
>
>--dkg

(2) is essentially implimented by

id:20170523005351.15431-3-da...@tethera.net

Jeff Stedfast wrote the following code for (3) on the gmime-devel list;
it needs to be conditionalized on GMIME_MAJOR_VERSION, and tested.

,
| 
|  This is a bit of a hack, but...
| 
|  cache = g_mime_header_list_get_stream (object->headers);
|  g_object_ref (cache);
|  g_mime_header_list_set_stream (object->headers, NULL);
| 
|  g_mime_object_write_to_stream (object, ostream);
| 
|  g_mime_header_list_set_stream (object->headers, cache);
|  g_object_unref (cache);
| 
`
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 2/2] cli/dump: don't include tags when not asked for

2017-05-23 Thread David Bremner
David Bremner  writes:

> Add in the analogous test for tags that is given for properties a few
> lines below.
> ---
>  notmuch-dump.c| 3 ++-
>  test/T610-message-property.sh | 1 -
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/notmuch-dump.c b/notmuch-dump.c
> index e451ac0c..5cc3b2f6 100644
> --- a/notmuch-dump.c
> +++ b/notmuch-dump.c
> @@ -250,7 +250,8 @@ database_dump_file (notmuch_database_t *notmuch, gzFile 
> output,
>  
>   message = notmuch_messages_get (messages);
>  
> - if (dump_tags_message (notmuch, message, output_format, output,
> + if ((include & DUMP_INCLUDE_TAGS) &&
> + dump_tags_message (notmuch, message, output_format, output,
>  , _size))
>   return EXIT_FAILURE;

I'd like to include this two line patch in 0.24.2, along with Mark's fix
2d79d38a0. Any objections? Any other similar fixes that should be
included in 0.24.2?

d
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch