* [PATCH] notmuch-reply: Use a shorter 'On, X Y wrote:' line @ 2010-03-02 12:37 Sebastian Spaeth 2010-03-02 14:01 ` martin f krafft ` (2 more replies) 0 siblings, 3 replies; 8+ messages in thread From: Sebastian Spaeth @ 2010-03-02 12:37 UTC (permalink / raw) To: notmuch Previously, we would output: 'On Thu, 25 Feb 2010 14:32:54 +0100, Sebastian Spaeth <Sebastian@SSpaeth.de> wrote:' now it is: 'On 2010-02-25, Sebastian Spaeth wrote:' In case we don't find a '<' (as indicator for 'Realname <email>'), we still use the whole from address. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de> --- This probably shows my lack of C skills quite nicely but it does the job for me. notmuch-reply.c | 21 ++++++++++++++++++--- 1 files changed, 18 insertions(+), 3 deletions(-) diff --git a/notmuch-reply.c b/notmuch-reply.c index 98f6442..929572f 100644 --- a/notmuch-reply.c +++ b/notmuch-reply.c @@ -288,9 +288,12 @@ notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_ GMimeMessage *reply; notmuch_messages_t *messages; notmuch_message_t *message; - const char *subject, *from_addr = NULL; + const char *subject, *from_addr = NULL, *short_from; const char *in_reply_to, *orig_references, *references; char *reply_headers; + time_t date; + struct tm *datetm; + char *datestr; for (messages = notmuch_query_search_messages (query); notmuch_messages_has_more (messages); @@ -346,10 +349,21 @@ notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_ g_object_unref (G_OBJECT (reply)); reply = NULL; + date = notmuch_message_get_date(message); + datetm = gmtime( &date ); + datestr = talloc_array(ctx, char, 11); + strftime(datestr, 11, "%Y-%m-%d", datetm); + + /* If from contains '<' (not as first char), + * only use the preceding real name */ + short_from = talloc_strdup(ctx, from_addr); + if (strstr(short_from, "<") > short_from) { + *(strstr(short_from, "<")-1) = 0; + } + printf ("On %s, %s wrote:\n", - notmuch_message_get_header (message, "date"), - notmuch_message_get_header (message, "from")); + datestr, + short_from); show_message_body (notmuch_message_get_filename (message), reply_part); -- 1.6.3.3 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] notmuch-reply: Use a shorter 'On, X Y wrote:' line 2010-03-02 12:37 [PATCH] notmuch-reply: Use a shorter 'On, X Y wrote:' line Sebastian Spaeth @ 2010-03-02 14:01 ` martin f krafft 2010-03-02 18:38 ` Sebastian Spaeth 2010-03-03 7:14 ` Michal Sojka 2010-03-03 6:20 ` Michal Sojka 2010-03-04 14:41 ` Michal Sojka 2 siblings, 2 replies; 8+ messages in thread From: martin f krafft @ 2010-03-02 14:01 UTC (permalink / raw) To: Sebastian Spaeth; +Cc: notmuch [-- Attachment #1: Type: text/plain, Size: 787 bytes --] also sprach Sebastian Spaeth <Sebastian@SSpaeth.de> [2010.03.02.1337 +0100]: > Previously, we would output: 'On Thu, 25 Feb 2010 14:32:54 +0100, > Sebastian Spaeth <Sebastian@SSpaeth.de> wrote:' now it is: 'On > 2010-02-25, Sebastian Spaeth wrote:' > > In case we don't find a '<' (as indicator for 'Realname <email>'), > we still use the whole from address. This makes me cringe. I don't think replying should be notmuch-functionality in the first place. -- martin | http://madduck.net/ | http://two.sentenc.es/ "if builders built buildings the way programmers wrote programs, then the first woodpecker that came along would destroy civilization." -- gerald weinberg spamtraps: madduck.bogus@madduck.net [-- Attachment #2: Digital signature (see http://martin-krafft.net/gpg/) --] [-- Type: application/pgp-signature, Size: 198 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] notmuch-reply: Use a shorter 'On, X Y wrote:' line 2010-03-02 14:01 ` martin f krafft @ 2010-03-02 18:38 ` Sebastian Spaeth 2010-03-03 7:14 ` Michal Sojka 1 sibling, 0 replies; 8+ messages in thread From: Sebastian Spaeth @ 2010-03-02 18:38 UTC (permalink / raw) To: notmuch On Tue, 2 Mar 2010 15:01:58 +0100, martin f krafft <madduck@madduck.net> wrote: > > In case we don't find a '<' (as indicator for 'Realname <email>'), > > we still use the whole from address. > > This makes me cringe. I don't think replying should be > notmuch-functionality in the first place. :-) I just posted this patch FYI, not because I seriously expect Carl to take it. And I agree that replying should not be notmuch's job. The MUA should take care of it, but my elisp is too weak to implement that. Sebastian ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] notmuch-reply: Use a shorter 'On, X Y wrote:' line 2010-03-02 14:01 ` martin f krafft 2010-03-02 18:38 ` Sebastian Spaeth @ 2010-03-03 7:14 ` Michal Sojka 1 sibling, 0 replies; 8+ messages in thread From: Michal Sojka @ 2010-03-03 7:14 UTC (permalink / raw) To: martin f krafft, Sebastian Spaeth; +Cc: notmuch On Tue, 2 Mar 2010 15:01:58 +0100, martin f krafft <madduck@madduck.net> wrote: > also sprach Sebastian Spaeth <Sebastian@SSpaeth.de> [2010.03.02.1337 +0100]: > > Previously, we would output: 'On Thu, 25 Feb 2010 14:32:54 +0100, > > Sebastian Spaeth <Sebastian@SSpaeth.de> wrote:' now it is: 'On > > 2010-02-25, Sebastian Spaeth wrote:' > > > > In case we don't find a '<' (as indicator for 'Realname <email>'), > > we still use the whole from address. > > This makes me cringe. I don't think replying should be > notmuch-functionality in the first place. Hi, I also see it a little bit strange to have reply in notmuch, but I don't care if it works (which is unfortunately not the case, see my next mail). You needn't use it if your MUA provides a different way of replying. There is indeed one interesting functionality in notmuch reply - replying to multiple messages based on a search term. Currently it is a little bit rough, but I can imagine I could use it some day. Bye Michal ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] notmuch-reply: Use a shorter 'On, X Y wrote:' line 2010-03-02 12:37 [PATCH] notmuch-reply: Use a shorter 'On, X Y wrote:' line Sebastian Spaeth 2010-03-02 14:01 ` martin f krafft @ 2010-03-03 6:20 ` Michal Sojka 2010-03-03 12:01 ` Sebastian Spaeth 2010-03-04 14:41 ` Michal Sojka 2 siblings, 1 reply; 8+ messages in thread From: Michal Sojka @ 2010-03-03 6:20 UTC (permalink / raw) To: Sebastian Spaeth, notmuch On Tue, 2 Mar 2010 13:37:42 +0100, Sebastian Spaeth <Sebastian@SSpaeth.de> wrote: > Previously, we would output: > 'On Thu, 25 Feb 2010 14:32:54 +0100, Sebastian Spaeth <Sebastian@SSpaeth.de> wrote:' now it is: > 'On 2010-02-25, Sebastian Spaeth wrote:' > > In case we don't find a '<' (as indicator for 'Realname <email>'), we still use the whole from address. > > Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de> > --- > This probably shows my lack of C skills quite nicely but it does the job for me. > > notmuch-reply.c | 21 ++++++++++++++++++--- > 1 files changed, 18 insertions(+), 3 deletions(-) > > diff --git a/notmuch-reply.c b/notmuch-reply.c > index 98f6442..929572f 100644 > --- a/notmuch-reply.c > +++ b/notmuch-reply.c > @@ -288,9 +288,12 @@ notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_ > GMimeMessage *reply; > notmuch_messages_t *messages; > notmuch_message_t *message; > - const char *subject, *from_addr = NULL; > + const char *subject, *from_addr = NULL, *short_from; > const char *in_reply_to, *orig_references, *references; > char *reply_headers; > + time_t date; > + struct tm *datetm; > + char *datestr; > > for (messages = notmuch_query_search_messages (query); > notmuch_messages_has_more (messages); > @@ -346,10 +349,21 @@ notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_ > g_object_unref (G_OBJECT (reply)); > reply = NULL; > > + date = notmuch_message_get_date(message); > + datetm = gmtime( &date ); > + datestr = talloc_array(ctx, char, 11); > + strftime(datestr, 11, "%Y-%m-%d", datetm); > + > + /* If from contains '<' (not as first char), > + * only use the preceding real name */ > + short_from = talloc_strdup(ctx, from_addr); I do not see, where do you assign a value to from_addr (besides the initial NULL). Michal ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] notmuch-reply: Use a shorter 'On, X Y wrote:' line 2010-03-03 6:20 ` Michal Sojka @ 2010-03-03 12:01 ` Sebastian Spaeth 0 siblings, 0 replies; 8+ messages in thread From: Sebastian Spaeth @ 2010-03-03 12:01 UTC (permalink / raw) To: Michal Sojka, notmuch On Wed, 03 Mar 2010 07:20:47 +0100, Michal Sojka <sojkam1@fel.cvut.cz> wrote: > > + /* If from contains '<' (not as first char), > > + * only use the preceding real name */ > > + short_from = talloc_strdup(ctx, from_addr); > > I do not see, where do you assign a value to from_addr (besides the > initial NULL). It is set way up earlier in that function. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] notmuch-reply: Use a shorter 'On, X Y wrote:' line 2010-03-02 12:37 [PATCH] notmuch-reply: Use a shorter 'On, X Y wrote:' line Sebastian Spaeth 2010-03-02 14:01 ` martin f krafft 2010-03-03 6:20 ` Michal Sojka @ 2010-03-04 14:41 ` Michal Sojka 2010-03-05 12:51 ` Sebastian Spaeth 2 siblings, 1 reply; 8+ messages in thread From: Michal Sojka @ 2010-03-04 14:41 UTC (permalink / raw) To: Sebastian Spaeth, notmuch Hi again, On Tue, 02 Mar 2010, Sebastian Spaeth wrote: > Previously, we would output: > 'On Thu, 25 Feb 2010 14:32:54 +0100, Sebastian Spaeth <Sebastian@SSpaeth.de> wrote:' now it is: > 'On 2010-02-25, Sebastian Spaeth wrote:' > > In case we don't find a '<' (as indicator for 'Realname <email>'), we still use the whole from address. > > Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de> > --- > This probably shows my lack of C skills quite nicely but it does the job for me. > > notmuch-reply.c | 21 ++++++++++++++++++--- > 1 files changed, 18 insertions(+), 3 deletions(-) > > diff --git a/notmuch-reply.c b/notmuch-reply.c > index 98f6442..929572f 100644 > --- a/notmuch-reply.c > +++ b/notmuch-reply.c > @@ -288,9 +288,12 @@ notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_ > GMimeMessage *reply; > notmuch_messages_t *messages; > notmuch_message_t *message; > - const char *subject, *from_addr = NULL; > + const char *subject, *from_addr = NULL, *short_from; > const char *in_reply_to, *orig_references, *references; > char *reply_headers; > + time_t date; > + struct tm *datetm; > + char *datestr; > > for (messages = notmuch_query_search_messages (query); > notmuch_messages_has_more (messages); > @@ -346,10 +349,21 @@ notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_ I tried your patch. The first problem is that it doesn't apply. I had to change the number 10 to 9 in the line above. > + /* If from contains '<' (not as first char), > + * only use the preceding real name */ > + short_from = talloc_strdup(ctx, from_addr); > + if (strstr(short_from, "<") > short_from) { > + *(strstr(short_from, "<")-1) = 0; > + } > + > printf ("On %s, %s wrote:\n", > - notmuch_message_get_header (message, "date"), > - notmuch_message_get_header (message, "from")); > + datestr, > + short_from); The second problem is that the value of from_addr doesn't (always?) contain sender's addres. When I wanded to reply to this email with you patch applied, I got: "On 2010-03-02, Michal Sojka wrote:". So I fixed that in your patch and added removal of "" around name. From 0555ba560fdaad3780c186b01b102670451585fb Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth <Sebastian@SSpaeth.de> Date: Tue, 2 Mar 2010 13:37:42 +0100 Subject: [PATCH] notmuch-reply: Use a shorter 'On, X Y wrote:' line Previously, we would output: 'On Thu, 25 Feb 2010 14:32:54 +0100, Sebastian Spaeth <Sebastian@SSpaeth.de> wrote:' now it is: 'On 2010-02-25, Sebastian Spaeth wrote:' In case we don't find a '<' (as indicator for 'Realname <email>'), we still use the whole from address. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de> Modified to use proper From header and strip "". Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz> --- notmuch-reply.c | 28 +++++++++++++++++++++++++--- 1 files changed, 25 insertions(+), 3 deletions(-) diff --git a/notmuch-reply.c b/notmuch-reply.c index 98f6442..0ef4954 100644 --- a/notmuch-reply.c +++ b/notmuch-reply.c @@ -288,9 +288,12 @@ notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_ GMimeMessage *reply; notmuch_messages_t *messages; notmuch_message_t *message; - const char *subject, *from_addr = NULL; + const char *subject, *from_addr = NULL, *short_from; const char *in_reply_to, *orig_references, *references; char *reply_headers; + time_t date; + struct tm *datetm; + char *datestr, *angle; for (messages = notmuch_query_search_messages (query); notmuch_messages_has_more (messages); @@ -346,9 +349,28 @@ notmuch_reply_format_default(void *ctx, notmuch_config_t *config, notmuch_query_ g_object_unref (G_OBJECT (reply)); reply = NULL; + date = notmuch_message_get_date(message); + datetm = gmtime( &date ); + datestr = talloc_array(ctx, char, 11); + strftime(datestr, 11, "%Y-%m-%d", datetm); + + /* If from contains '<' (not as first char), only use the + * preceding real name without "" (if present). */ + short_from = notmuch_message_get_header (message, "from"); + if ((angle = strchr(short_from, '<')) > short_from) { + while (angle-1 >= short_from && *(angle-1) == ' ') + angle--; + *angle = '\0'; + if (*short_from == '"' && *(angle-1) == '"' && + angle-1 > short_from) { + short_from++; + *(angle-1) = '\0'; + } + } + printf ("On %s, %s wrote:\n", - notmuch_message_get_header (message, "date"), - notmuch_message_get_header (message, "from")); + datestr, + short_from); show_message_body (notmuch_message_get_filename (message), reply_part); -- 1.7.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] notmuch-reply: Use a shorter 'On, X Y wrote:' line 2010-03-04 14:41 ` Michal Sojka @ 2010-03-05 12:51 ` Sebastian Spaeth 0 siblings, 0 replies; 8+ messages in thread From: Sebastian Spaeth @ 2010-03-05 12:51 UTC (permalink / raw) To: Michal Sojka, notmuch On 2010-03-04, Sebastian Spaeth wrote: > The second problem is that the value of from_addr doesn't (always?) > contain sender's addres. When I wanded to reply to this email with you > patch applied, I got: "On 2010-03-02, Michal Sojka wrote:". So I fixed > that in your patch and added removal of "" around name. Cool thanks. Yes, I noticed that my patch was deeply flawed, so I appreciate having it fixed. I am not proud of my C skills... :) Sebastian ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-03-05 12:51 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-03-02 12:37 [PATCH] notmuch-reply: Use a shorter 'On, X Y wrote:' line Sebastian Spaeth 2010-03-02 14:01 ` martin f krafft 2010-03-02 18:38 ` Sebastian Spaeth 2010-03-03 7:14 ` Michal Sojka 2010-03-03 6:20 ` Michal Sojka 2010-03-03 12:01 ` Sebastian Spaeth 2010-03-04 14:41 ` Michal Sojka 2010-03-05 12:51 ` Sebastian Spaeth
Code repositories for project(s) associated with this public inbox https://yhetil.org/notmuch.git/ This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).