Re: [PATCH v2] emacs: Add notmuch-update-search-tags

2017-08-28 Thread David Bremner
Vladimir Panteleev  writes:

>  Speaking of which, I had a fun time trying to figure out why my test
>  didn't work before I discovered that notmuch-tag-deleted-formats is
>  reset in test-lib.el. That took quite a bit of debugging; I think it
>  would be good to fix this inconsistency to avoid other contributors
>  wasting time on this in the future.

Yes, I think you're probably right, although I haven't looked at the
resulting work to update all of relevant tests. There's probably a few
other places where we've accumulated "technical debt" by doing the easy
thing in the test suite.

Maybe I'm overthinking this, but it seems like we'd need some way to
recognize various faces. There is a package called faceup that is
targeted at roughly this problem.  I know that racket-mode uses it to
test highlighting. Perhaps that's an dependancy we can tolerate for the
test suite, at least optionally. Or perhaps some simpler approach can
work since we can choose the faces as well.

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


Re: [PATCH 1/2] emacs: maildir fcc make insert more flexible

2017-08-28 Thread David Edmondson
On Monday, 2017-08-28 at 12:27:03 +0100, Mark Walters wrote:

>>>  The fcc-header should be of the form \"folder +tag1 -tag2\" where
>>
>> I realise that this patch set didn't add this string, but it is mildly
>> ridiculous. There's no reason that we couldn't use a list, where a
>> leading “+” or “-” indicates a tag and anything else is a folder.
>>
>> Even two variables (one for folder and another for tags) would be an
>> improvement
>
> The reason for this choice is that, when writing the postpone code, I
> wanted to keep within the message mode compose world, which has the fcc
> header as a string.

You could add whatever headers you like.

> I think I would also only like to be queried once when inserting. Or are
> you suggesting that the user types in a lisp list?

If we prompt for it then we could do multiple prompts - we already have
a completion-capable reader for tags.

dme.
-- 
I'm catching up with myself!
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 2/2] emacs: show: allow user to insert rfc822 parts as messages

2017-08-28 Thread Mark Walters
>
>> +  (let* ((folder
>> +  (read-from-minibuffer "Folder/tags to insert part to: "
>> +notmuch-show-part-notmuch-insert-folder)))
>> +(mm-with-unibyte-buffer
>> + (mm-insert-part handle)
>> + (notmuch-maildir-fcc-with-notmuch-insert folder nil "Folder/tags to 
>> insert part to")
>> + (message nil
>
> Why this? It would be nice to have a comment explaining it.

Assuming you mean the message nil bit, This is actually me being dim. I
want to remove things like the retry message. But it would be much better
to make the insert-part function return something saying whether it
succeeded or not, and then give a useful message.

Best wishes

Mark

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


Re: [PATCH 1/2] emacs: maildir fcc make insert more flexible

2017-08-28 Thread Mark Walters

Hi

Thanks for the review.

On Mon, 28 Aug 2017, David Edmondson  wrote:
> On Monday, 2017-08-28 at 08:32:21 +0100, Mark Walters wrote:
>
>> This changeset makes the function
>> notmuch-maildir-fcc-with-notmuch-insert slightly more flexible by
>> allowing some of the prompts to be controlled by the caller.
>> ---
>>  emacs/notmuch-maildir-fcc.el | 16 ++--
>>  1 file changed, 10 insertions(+), 6 deletions(-)
>>
>> diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el
>> index 1551e8b..acff24d 100644
>> --- a/emacs/notmuch-maildir-fcc.el
>> +++ b/emacs/notmuch-maildir-fcc.el
>> @@ -227,7 +227,7 @@ should be a list of tag changes to apply to the inserted 
>> message."
>>  (apply 'notmuch-call-notmuch-process
>> :stdin-string (buffer-string) "insert" args)))
>>  
>> -(defun notmuch-maildir-fcc-with-notmuch-insert (fcc-header &optional create)
>> +(defun notmuch-maildir-fcc-with-notmuch-insert (fcc-header &optional create 
>> header-name)
>
> Given that this is not FCC specific, perhaps rename it?

Yes that might make sense.

>
>>"Store message with notmuch insert.
>>  
>>  The fcc-header should be of the form \"folder +tag1 -tag2\" where
>
> I realise that this patch set didn't add this string, but it is mildly
> ridiculous. There's no reason that we couldn't use a list, where a
> leading “+” or “-” indicates a tag and anything else is a folder.
>
> Even two variables (one for folder and another for tags) would be an
> improvement

The reason for this choice is that, when writing the postpone code, I
wanted to keep within the message mode compose world, which has the fcc
header as a string.

I think I would also only like to be queried once when inserting. Or are
you suggesting that the user types in a lisp list?

Best wishes

Mark




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


Re: [PATCH v1 1/1] test: Perform T170 tests that don't require dtach before any that do.

2017-08-28 Thread David Bremner
David Edmondson  writes:

> This avoids the later tests seeing different versions of the database
> depending on whether dtach is available.

pushed. I notice there still plenty of tests (in other files) that fail
rather than skip if dtach is missing, if someone wants a project mucking
about in the test suite...

d

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


Re: [PATCH 2/2] emacs: show: allow user to insert rfc822 parts as messages

2017-08-28 Thread David Edmondson
On Monday, 2017-08-28 at 08:32:22 +0100, Mark Walters wrote:

> This adds a part-handler function that uses notmuch-insert to insert
> an rfc822 part as a message in its own right. This allows the user to
> reply directly to that message.
>
> We use notmuch-maildir-fcc-with-notmuch-insert as that has builtin
> error handling/retry functionality, and it allows the user to specify
> tags to identify the inserted message.
>
> The format of the folder/tags line is the same as for Fcc: headers
> when using notmuch insert.
> ---
>  emacs/notmuch-show.el | 35 +++
>  1 file changed, 35 insertions(+)
>
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index cd901e4..b3717d0 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -143,6 +143,20 @@ indentation."
>(const :tag "View interactively"
>   notmuch-show-interactively-view-part)))
>  
> +(defcustom notmuch-show-part-notmuch-insert-folder ""
> +  "Default folder/tags to use when inserting rfc822 parts into the database.
> +
> +It should be of the form \"folder +tag1 -tag2\" where folder is

See previous comments.

> +the folder (relative to the notmuch mailstore) to store the
> +message in, and tag1 and tag2 are tag changes to apply to the
> +stored message. This string is split using
> +`split-string-and-unquote', so a folder name containing spaces
> +can be specified by quoting each space with an immediately
> +preceding backslash or surrounding the entire folder name in
> +double quotes."
> +  :group 'notmuch-show
> +  :type 'string)
> +
>  (defcustom notmuch-show-only-matching-messages nil
>"Only matching messages are shown by default."
>:type 'boolean
> @@ -1448,6 +1462,7 @@ reset based on the original query."
>  (define-key map "o" 'notmuch-show-interactively-view-part)
>  (define-key map "|" 'notmuch-show-pipe-part)
>  (define-key map "m" 'notmuch-show-choose-mime-of-part)
> +(define-key map "i" 'notmuch-show-notmuch-insert-part)
>  (define-key map "?" 'notmuch-subkeymap-help)
>  map)
>"Submap for part commands")
> @@ -2463,6 +2478,26 @@ part to be treated as if it had that mime-type."
>(interactive)
>(notmuch-show-apply-to-current-part-handle #'mm-pipe-part))
>  
> +(defun notmuch-show--notmuch-insert-handle (handle)
> +  "Notmuch insert the part associated with HANDLE."
> +  ;; This is based on mm-pipe-part

Missing a period.

> +  (let* ((folder
> +   (read-from-minibuffer "Folder/tags to insert part to: "
> + notmuch-show-part-notmuch-insert-folder)))
> +(mm-with-unibyte-buffer
> + (mm-insert-part handle)
> + (notmuch-maildir-fcc-with-notmuch-insert folder nil "Folder/tags to 
> insert part to")
> + (message nil

Why this? It would be nice to have a comment explaining it.

> +
> +(defun notmuch-show-notmuch-insert-part ()
> +  "If the current part is rfc822 then insert into the mailstore"
> +  (interactive)
> +  (let* ((part (notmuch-show-get-part-properties))
> +  (computed-type (plist-get part :computed-type)))
> +(if (notmuch-match-content-type computed-type "message/rfc822")
> + (notmuch-show-apply-to-current-part-handle
> +  #'notmuch-show--notmuch-insert-handle)
> +  (message "Not a message/rfc822 part."
>  
>  (defun notmuch-show--mm-display-part (handle)
>"Use mm-display-part to display HANDLE in a new buffer.
> -- 
> 2.1.4
>
> ___
> notmuch mailing list
> notmuch@notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch

dme.
-- 
All those lines and circles, to me, a mystery.
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 1/2] emacs: maildir fcc make insert more flexible

2017-08-28 Thread David Edmondson
On Monday, 2017-08-28 at 08:32:21 +0100, Mark Walters wrote:

> This changeset makes the function
> notmuch-maildir-fcc-with-notmuch-insert slightly more flexible by
> allowing some of the prompts to be controlled by the caller.
> ---
>  emacs/notmuch-maildir-fcc.el | 16 ++--
>  1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el
> index 1551e8b..acff24d 100644
> --- a/emacs/notmuch-maildir-fcc.el
> +++ b/emacs/notmuch-maildir-fcc.el
> @@ -227,7 +227,7 @@ should be a list of tag changes to apply to the inserted 
> message."
>  (apply 'notmuch-call-notmuch-process
>  :stdin-string (buffer-string) "insert" args)))
>  
> -(defun notmuch-maildir-fcc-with-notmuch-insert (fcc-header &optional create)
> +(defun notmuch-maildir-fcc-with-notmuch-insert (fcc-header &optional create 
> header-name)

Given that this is not FCC specific, perhaps rename it?

>"Store message with notmuch insert.
>  
>  The fcc-header should be of the form \"folder +tag1 -tag2\" where

I realise that this patch set didn't add this string, but it is mildly
ridiculous. There's no reason that we couldn't use a list, where a
leading “+” or “-” indicates a tag and anything else is a folder.

Even two variables (one for folder and another for tags) would be an
improvement

> @@ -239,7 +239,8 @@ quoting each space with an immediately preceding backslash
>  or surrounding the entire folder name in double quotes.
>  
>  If CREATE is non-nil then create the folder if necessary."
> -  (let* ((args (split-string-and-unquote fcc-header))
> +  (let* ((header-name (or header-name "Fcc header"))
> +  (args (split-string-and-unquote fcc-header))
>(folder (car args))
>(tags (cdr args)))
>  (condition-case nil
> @@ -250,14 +251,17 @@ If CREATE is non-nil then create the folder if 
> necessary."
>;; how to deal with it.
>(error
> (let ((response (notmuch-read-char-choice
> - "Insert failed: (r)etry, (c)reate folder, (i)gnore, or 
> (e)dit the header? "
> + (concat
> +  "Insert failed: (r)etry, (c)reate folder, (i)gnore, or 
> (e)dit the "
> +  header-name "? ")
>   '(?r ?c ?i ?e
>(case response
> -(?r (notmuch-maildir-fcc-with-notmuch-insert fcc-header))
> -(?c (notmuch-maildir-fcc-with-notmuch-insert fcc-header 't))
> +(?r (notmuch-maildir-fcc-with-notmuch-insert fcc-header nil 
> header-name))
> +(?c (notmuch-maildir-fcc-with-notmuch-insert fcc-header 't 
> header-name))
>  (?i 't)
>  (?e (notmuch-maildir-fcc-with-notmuch-insert
> - (read-from-minibuffer "Fcc header: " fcc-header)
> + (read-from-minibuffer (concat header-name ": ") fcc-header)
> + nil header-name
>  
>  
>  ;
> -- 
> 2.1.4
>
> ___
> notmuch mailing list
> notmuch@notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch

dme.
-- 
Walk without rhythm and it won't attract the worm.
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] python: deprecated add_message calls index_file correctly and returns result

2017-08-28 Thread Gaute Hope
The deprecated Database.add_message now calls the new index_file with
correct number of arguments (without an extra `self`), and returns the
tuple from index_file - as it used to do before.
---
 bindings/python/notmuch/database.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bindings/python/notmuch/database.py 
b/bindings/python/notmuch/database.py
index a2c025eb..6199f58b 100644
--- a/bindings/python/notmuch/database.py
+++ b/bindings/python/notmuch/database.py
@@ -471,7 +471,7 @@ class Database(object):
 def add_message(self, filename, sync_maildir_flags=False):
 """Deprecated alias for :meth:`index_file`
 """
-self.index_file(self, filename, sync_maildir_flags=sync_maildir_flags)
+return self.index_file(filename, sync_maildir_flags=sync_maildir_flags)
 
 _remove_message = nmlib.notmuch_database_remove_message
 _remove_message.argtypes = [NotmuchDatabaseP, c_char_p]
-- 
2.14.1

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


[PATCH 0/2] emacs: allow message/rfc822 to be inserted in the mailstore

2017-08-28 Thread Mark Walters
Several people including id:87bmnlko2o.fsf@len have asked to be able
to reply directly to message/rfc822 messages from the emacs
frontend. Doing that in emacs would be likely to be a little fragile
as all other replies are generated by the cli code.

This pair of patches provide an alternative approach: let the user
insert the attached message directly into the mailstore. Once it is
there, the user can reply as normal.

I have been running something like this for a long time (see
id:1463744295-12533-1-git-send-email-markwalters1...@gmail.com for my
earlier version) with no problems.

This new version includes some better error checking, and allows the
user to specify tags for the inserted message. The new version is not
heavily tested but seems to work.

Best wishes

Mark




Mark Walters (2):
  emacs: maildir fcc make insert more flexible
  emacs: show: allow user to insert rfc822 parts as messages

 emacs/notmuch-maildir-fcc.el | 16 ++--
 emacs/notmuch-show.el| 35 +++
 2 files changed, 45 insertions(+), 6 deletions(-)

-- 
2.1.4

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


[PATCH 1/2] emacs: maildir fcc make insert more flexible

2017-08-28 Thread Mark Walters
This changeset makes the function
notmuch-maildir-fcc-with-notmuch-insert slightly more flexible by
allowing some of the prompts to be controlled by the caller.
---
 emacs/notmuch-maildir-fcc.el | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el
index 1551e8b..acff24d 100644
--- a/emacs/notmuch-maildir-fcc.el
+++ b/emacs/notmuch-maildir-fcc.el
@@ -227,7 +227,7 @@ should be a list of tag changes to apply to the inserted 
message."
 (apply 'notmuch-call-notmuch-process
   :stdin-string (buffer-string) "insert" args)))
 
-(defun notmuch-maildir-fcc-with-notmuch-insert (fcc-header &optional create)
+(defun notmuch-maildir-fcc-with-notmuch-insert (fcc-header &optional create 
header-name)
   "Store message with notmuch insert.
 
 The fcc-header should be of the form \"folder +tag1 -tag2\" where
@@ -239,7 +239,8 @@ quoting each space with an immediately preceding backslash
 or surrounding the entire folder name in double quotes.
 
 If CREATE is non-nil then create the folder if necessary."
-  (let* ((args (split-string-and-unquote fcc-header))
+  (let* ((header-name (or header-name "Fcc header"))
+(args (split-string-and-unquote fcc-header))
 (folder (car args))
 (tags (cdr args)))
 (condition-case nil
@@ -250,14 +251,17 @@ If CREATE is non-nil then create the folder if necessary."
   ;; how to deal with it.
   (error
(let ((response (notmuch-read-char-choice
-   "Insert failed: (r)etry, (c)reate folder, (i)gnore, or 
(e)dit the header? "
+   (concat
+"Insert failed: (r)etry, (c)reate folder, (i)gnore, or 
(e)dit the "
+header-name "? ")
'(?r ?c ?i ?e
 (case response
-  (?r (notmuch-maildir-fcc-with-notmuch-insert fcc-header))
-  (?c (notmuch-maildir-fcc-with-notmuch-insert fcc-header 't))
+  (?r (notmuch-maildir-fcc-with-notmuch-insert fcc-header nil 
header-name))
+  (?c (notmuch-maildir-fcc-with-notmuch-insert fcc-header 't 
header-name))
   (?i 't)
   (?e (notmuch-maildir-fcc-with-notmuch-insert
-   (read-from-minibuffer "Fcc header: " fcc-header)
+   (read-from-minibuffer (concat header-name ": ") fcc-header)
+   nil header-name
 
 
 ;
-- 
2.1.4

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


[PATCH 2/2] emacs: show: allow user to insert rfc822 parts as messages

2017-08-28 Thread Mark Walters
This adds a part-handler function that uses notmuch-insert to insert
an rfc822 part as a message in its own right. This allows the user to
reply directly to that message.

We use notmuch-maildir-fcc-with-notmuch-insert as that has builtin
error handling/retry functionality, and it allows the user to specify
tags to identify the inserted message.

The format of the folder/tags line is the same as for Fcc: headers
when using notmuch insert.
---
 emacs/notmuch-show.el | 35 +++
 1 file changed, 35 insertions(+)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index cd901e4..b3717d0 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -143,6 +143,20 @@ indentation."
 (const :tag "View interactively"
notmuch-show-interactively-view-part)))
 
+(defcustom notmuch-show-part-notmuch-insert-folder ""
+  "Default folder/tags to use when inserting rfc822 parts into the database.
+
+It should be of the form \"folder +tag1 -tag2\" where folder is
+the folder (relative to the notmuch mailstore) to store the
+message in, and tag1 and tag2 are tag changes to apply to the
+stored message. This string is split using
+`split-string-and-unquote', so a folder name containing spaces
+can be specified by quoting each space with an immediately
+preceding backslash or surrounding the entire folder name in
+double quotes."
+  :group 'notmuch-show
+  :type 'string)
+
 (defcustom notmuch-show-only-matching-messages nil
   "Only matching messages are shown by default."
   :type 'boolean
@@ -1448,6 +1462,7 @@ reset based on the original query."
 (define-key map "o" 'notmuch-show-interactively-view-part)
 (define-key map "|" 'notmuch-show-pipe-part)
 (define-key map "m" 'notmuch-show-choose-mime-of-part)
+(define-key map "i" 'notmuch-show-notmuch-insert-part)
 (define-key map "?" 'notmuch-subkeymap-help)
 map)
   "Submap for part commands")
@@ -2463,6 +2478,26 @@ part to be treated as if it had that mime-type."
   (interactive)
   (notmuch-show-apply-to-current-part-handle #'mm-pipe-part))
 
+(defun notmuch-show--notmuch-insert-handle (handle)
+  "Notmuch insert the part associated with HANDLE."
+  ;; This is based on mm-pipe-part
+  (let* ((folder
+ (read-from-minibuffer "Folder/tags to insert part to: "
+   notmuch-show-part-notmuch-insert-folder)))
+(mm-with-unibyte-buffer
+ (mm-insert-part handle)
+ (notmuch-maildir-fcc-with-notmuch-insert folder nil "Folder/tags to 
insert part to")
+ (message nil
+
+(defun notmuch-show-notmuch-insert-part ()
+  "If the current part is rfc822 then insert into the mailstore"
+  (interactive)
+  (let* ((part (notmuch-show-get-part-properties))
+(computed-type (plist-get part :computed-type)))
+(if (notmuch-match-content-type computed-type "message/rfc822")
+   (notmuch-show-apply-to-current-part-handle
+#'notmuch-show--notmuch-insert-handle)
+  (message "Not a message/rfc822 part."
 
 (defun notmuch-show--mm-display-part (handle)
   "Use mm-display-part to display HANDLE in a new buffer.
-- 
2.1.4

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