[PATCH] WIP: pass through errors to structured output

2017-11-09 Thread David Bremner
---

like the subject says, work in progress.

The idea is to include an optional error reporting dictionary in
structured output to help clients figure out wth went wrong without
attempting to parse stderr. It's a new key so it shouldn't break sane
clients. Or even notmuch-emacs ;).

Some things to complete/bikeshed.

 - some of the names are clearly terrible. "message", I'm looking at you.
 - make most of the NULL returns here return a node with some
   error info.
 - possibly still print to stderr for non-structured formats.
 - maybe think about a future consolidation of all of the status info
 
 
 mime-node.c  | 13 +
 notmuch-client.h |  4 
 notmuch-show.c   | 10 ++
 3 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/mime-node.c b/mime-node.c
index e1aca969..dafa8eb2 100644
--- a/mime-node.c
+++ b/mime-node.c
@@ -272,11 +272,16 @@ _mime_node_create (mime_node_t *parent, GMimeObject *part)
notmuch_status_t status;
status = _notmuch_crypto_get_gmime_ctx_for_protocol (node->ctx->crypto,
 protocol, 
);
-   if (status) /* this is a warning, not an error */
-   fprintf (stderr, "Warning: %s (%s).\n", notmuch_status_to_string 
(status),
+   if (status) {
+   node->message = talloc_asprintf (node, "Warning: %s (%s).\n", 
notmuch_status_to_string (status),
 protocol ? protocol : "NULL");
-   if (!cryptoctx)
+   node->status = status;
+   }
+   if (!cryptoctx) {
+
+
return node;
+   }
 }
 #endif
 
@@ -300,7 +305,7 @@ _mime_node_create (mime_node_t *parent, GMimeObject *part)
node_verify (node, part, cryptoctx);
}
 }
-
+node->status = NOTMUCH_STATUS_SUCCESS;
 return node;
 }
 
diff --git a/notmuch-client.h b/notmuch-client.h
index f7524e59..45451ecb 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -410,6 +410,10 @@ struct mime_node {
  * number to assign it (or -1 if unknown). */
 int next_child;
 int next_part_num;
+
+/* for error / warning reporting */
+notmuch_status_t status;
+char *message;
 };
 
 /* Construct a new MIME node pointing to the root message part of
diff --git a/notmuch-show.c b/notmuch-show.c
index 7afd3947..00108174 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -644,6 +644,16 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, 
mime_node_t *node,
 sp->map_key (sp, "id");
 sp->integer (sp, node->part_num);
 
+if (node->status != NOTMUCH_STATUS_SUCCESS) {
+   sp->map_key (sp, "error_info");
+   sp->begin_map (sp);
+   sp->map_key (sp, "status");
+   sp->integer (sp, node->status);
+   sp->map_key (sp, "message");
+   sp->string (sp, node->message);
+   sp->end (sp);
+}
+
 if (node->decrypt_attempted) {
sp->map_key (sp, "encstatus");
sp->begin_list (sp);
-- 
2.14.2

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


Re: bug: notmuch show --decrypt leads to SIGSEGV

2017-11-09 Thread David Bremner
Matt Armstrong  writes:

> I've been able to diagnose a SIGSEGV, and I have a workaround that
> satisfies me.  I'm unsure how to fix it, so I'll describe the problem
> and leave it at that.
>

This is fixed by either using gmime 3.0, notmuch 0.25.2, or notmuch master.

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


bounce/forward not working due to CR at line end

2017-11-09 Thread Kai Harries
Hello,

I am new to notmuch so excuse if the fault is on my end. For me
resending and forwarding of emails are not working if
message-forward-show-mml is enabled. The problems are CR at the line
endings. With the attached two patches I got it working for me. Maybe
someone more knowledgeable can see from it what the right solution would
be. 

My configuration:
notmuch 0.25.1
Emacs 25.3.1
on GNU/Linux (NixOS 17.09)


--- a/mml.el	2017-11-09 21:11:26.542291084 +0100
+++ b/mml.el	2017-11-09 21:12:18.838306315 +0100
@@ -929,10 +929,11 @@
 
 (defun mime-to-mml ( handles)
   "Translate the current buffer (which should be a message) into MML.
 If HANDLES is non-nil, use it instead reparsing the buffer."
   ;; First decode the head.
+  (save-excursion (icalendar--clean-up-line-endings))
   (save-restriction
 (message-narrow-to-head)
 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
   (mail-decode-encoded-word-region (point-min) (point-max
   (unless handles
--- a/notmuch-show.el	2017-11-09 21:17:05.791414308 +0100
+++ b/notmuch-show.el	2017-11-09 21:17:57.958437388 +0100
@@ -2011,20 +2011,21 @@
 (defun notmuch-show-view-raw-message ()
   "View the original source of the current message."
   (interactive)
   (let* ((id (notmuch-show-get-message-id))
 	 (buf (get-buffer-create (concat "*notmuch-raw-" id "*")))
 	 (inhibit-read-only t))
 (switch-to-buffer buf)
 (erase-buffer)
 (let ((coding-system-for-read 'no-conversion))
   (call-process notmuch-command nil t nil "show" "--format=raw" id))
+(save-excursion (icalendar--clean-up-line-endings))
 (goto-char (point-min))
 (set-buffer-modified-p nil)
 (setq buffer-read-only t)
 (view-buffer buf 'kill-buffer-if-not-modified)))
 
 (defun notmuch-show-resume-message ()
   "Resume EDITING the current draft message."
   (interactive)
   (notmuch-draft-resume (notmuch-show-get-message-id)))
 

Best regards

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


Re: buggy tags

2017-11-09 Thread Tom Hirschowitz

Great, thanks!
Tom

> On Thu, Nov 9, 2017 at 12:11 PM, Tom Hirschowitz
>  wrote:
>> I sometimes mistype some tags, e.g., collaegues instead of colleagues,
>> etc. Of course, I then replace them with the right version.
>>
>> But notmuch keeps track of these wrong tags (as of all others) and
>> proposes them when autocompleting, which after a few years of using
>> notmuch, starts being significantly annoying.
>
> Notmuch only completes to tags that are actually present in the
> database. So you've missed some.
>
>> Is there a way of getting rid of them?
>
> This will list all the tags you have:
>
> $ notmuch search --output=tags "*"
>
> And this will replace a wrong tag with the right tag:
>
> $ notmuch tag +right-tag -wrong-tag tag:wrong-tag
>
> BR,
> Jani.
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: what is the concept of archiving?

2017-11-09 Thread Jani Nikula
On Thu, Nov 9, 2017 at 11:56 AM, Linus Arver  wrote:
> Unfortunately, I cannot find enough information online about what any of
> these functions do, or what the concept of "archiving" means. From
> reading some of the sources in notmuch-tree.el I found out that
> archiving a message results in "applying the tag changes in
> `notmuch-archive-tags' to it" but I am not sure what this means.

Archiving, by default, simply means removing the inbox tag, either
from a single message or from all messages in a thread. You can use
notmuch-archive-tags to configure the tag change actions if you like.

> I found out that the key bindings are in that same file, which assigns
> "a" to notmuch-tree-archive-message-then-next; when I press "a" in my
> inbox view (all messages tagged "inbox"), it appears to just remove the
> "inbox" tag. I have some questions:
>
> (1) What is the point of archiving (what problem does it solve)?

Remove the messages from your inbox search. (At least I prefer to keep
this distinct from removing the unread tag; I archive tons of messages
without reading, and I have some messages with inbox tag that I've
already read.)

> (2) Do any other things happen to such archived messages, apart from the
> tag being removed?

No. Optionally, you can configure notmuch-archive-tags to remove more
or other tags, or add tags.

> (3) How do I un-archive these messages, if I press the "a" key by
> accident?

Find the message, hit "k k a". ("k" enters a submenu for doing
customizable tagging operations quickly, "k k" does the reverse
operation.)

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


Re: buggy tags

2017-11-09 Thread Jani Nikula
On Thu, Nov 9, 2017 at 12:11 PM, Tom Hirschowitz
 wrote:
> I sometimes mistype some tags, e.g., collaegues instead of colleagues,
> etc. Of course, I then replace them with the right version.
>
> But notmuch keeps track of these wrong tags (as of all others) and
> proposes them when autocompleting, which after a few years of using
> notmuch, starts being significantly annoying.

Notmuch only completes to tags that are actually present in the
database. So you've missed some.

> Is there a way of getting rid of them?

This will list all the tags you have:

$ notmuch search --output=tags "*"

And this will replace a wrong tag with the right tag:

$ notmuch tag +right-tag -wrong-tag tag:wrong-tag

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


buggy tags

2017-11-09 Thread Tom Hirschowitz

Hi all,

I sometimes mistype some tags, e.g., collaegues instead of colleagues,
etc. Of course, I then replace them with the right version.

But notmuch keeps track of these wrong tags (as of all others) and
proposes them when autocompleting, which after a few years of using
notmuch, starts being significantly annoying.

Is there a way of getting rid of them?

Thanks,
Tom


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


what is the concept of archiving?

2017-11-09 Thread Linus Arver

Hello,

I am curious about the following interactive functions --- they all deal
with archiving messages:

notmuch-tree-archive-thread
notmuch-show-archive-thread
notmuch-show-archive-message
notmuch-tree-archive-message
notmuch-search-archive-thread
notmuch-show-advance-and-archive
notmuch-show-stash-mlarchive-link
notmuch-show-archive-thread-then-next
notmuch-show-archive-thread-then-exit
notmuch-tree-archive-message-then-next
notmuch-show-stash-mlarchive-link-and-go
notmuch-show-archive-message-then-next-or-exit
notmuch-show-archive-message-then-next-or-next-thread

Unfortunately, I cannot find enough information online about what any of
these functions do, or what the concept of "archiving" means. From
reading some of the sources in notmuch-tree.el I found out that
archiving a message results in "applying the tag changes in
`notmuch-archive-tags' to it" but I am not sure what this means.

I found out that the key bindings are in that same file, which assigns
"a" to notmuch-tree-archive-message-then-next; when I press "a" in my
inbox view (all messages tagged "inbox"), it appears to just remove the
"inbox" tag. I have some questions:

(1) What is the point of archiving (what problem does it solve)?

(2) Do any other things happen to such archived messages, apart from the
tag being removed?

(3) How do I un-archive these messages, if I press the "a" key by
accident?

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