unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: "Brennan Vincent" <brennan@umanwizard.com>
To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org
Subject: Re: [PATCH] emacs: Introduce notmuch-draftify-buffer command.
Date: Sat, 28 Sep 2024 20:36:45 -0400	[thread overview]
Message-ID: <875xqfi9cy.fsf@denver.mail-host-address-is-not-set> (raw)
In-Reply-To: <87msjvl71g.fsf@tethera.net>

David Bremner <david@tethera.net> writes:

> Brennan Vincent <brennan@umanwizard.com> writes:
>
>> This command inserts the current buffer as a draft. It optionally
>> begins editing the draft.
>
> [nice commit message snipped]
>
> Here again, if possible we would like a test. For emacs tests it is a
> bit more laborious, but there are several options outlined in
> test/
Done, will be in the next revision of the patch series.
>
>>  will appear in a buffer named \"*Notmuch errors*\" and an error
>> -will be signaled."
>> +will be signaled.
>> +
>> +Otherwise, returns the output from the process as a string."
>>    (with-temp-buffer
>> -    (let ((status (notmuch-call-notmuch--helper t args)))
>> -      (notmuch-check-exit-status status (cons notmuch-command args)
>> -				 (buffer-string)))))
>> +    (let ((status (notmuch-call-notmuch--helper t args))
>> +	  (output (buffer-string)))
>> +      (and (notmuch-check-exit-status status (cons notmuch-command args)
>> +				      output)
>> +	   output))))
>
> Is it clear / documented what the return value of
> notmuch-check-exit-status is? If all you mean is that it completes
> without error, I think "progn" is clearer than "and"
Done, will be in the next revision of the patch series.
>
>> +Returns the message ID of the inserted message."
>> +  (let ((output (apply 'notmuch-call-notmuch-process
>> +		       :stdin-string (buffer-string) "insert"
>> +		       (append (and create (list "--create-folder"))
>> +			       (list (concat "--folder=" folder)
>> +				     "--emit-message-id")
>> +			       tags))))
>> +    (string-trim output)))
>
> One problem we have is that people merrily upgrade the emacs front end
> without updating the CLI. Recently (see devel/schemata) we have started
> bumping the output version for new command arguments, so at least the
> error reporting is clear.
That won't work here, since `notmuch insert` doesn't accept
--format-version at all, so people using older versions of the CLI would
just get an obscure error about --format-version being an unrecognized
arg.

What we can do is in notmuch-check-exit-status, search the error output
for "Unrecognized option: --emit-message-id" and translate it to
something friendlier. Searching for specific strings in error message is
a bit unsatisfying to me, but at least it works (and correct me if I'm
wrong, but I don't think notmuch has been localized to languages other
than English which would break it).

What do you think?

(Btw, I think in the future it would be good to make all commands accept
--format-version, even those whose output doesn't change today, to avoid
this sort of issue).
> _______________________________________________
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-leave@notmuchmail.org

  reply	other threads:[~2024-09-29  0:37 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-10 20:33 [PATCH] Add --emit-message-id flag to notmuch-insert Brennan Vincent
2024-09-11 15:00 ` [PATCH v2] " Brennan Vincent
2024-09-25 21:51   ` David Bremner
2024-10-03 17:35     ` When exactly is the post-insert hook called? Ralph Seichter
2024-10-03 17:59       ` Ralph Seichter
2024-09-11 16:09 ` [PATCH] emacs: Introduce notmuch-draftify-buffer command Brennan Vincent
2024-09-25 22:09   ` David Bremner
2024-09-29  0:36     ` Brennan Vincent [this message]
2024-09-26 20:25 ` [PATCH v3] Add --emit-message-id flag to notmuch-insert Brennan Vincent

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875xqfi9cy.fsf@denver.mail-host-address-is-not-set \
    --to=brennan@umanwizard.com \
    --cc=david@tethera.net \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).