* [PATCH 2/3] emacs: Use S-exp format everywhere
2013-06-23 23:43 [PATCH 1/3] emacs: Introduce `notmuch-call-notmuch-sexp' Austin Clements
@ 2013-06-23 23:43 ` Austin Clements
2013-06-23 23:43 ` [PATCH 3/3] emacs: Remove `notmuch-call-notmuch-json' Austin Clements
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Austin Clements @ 2013-06-23 23:43 UTC (permalink / raw)
To: notmuch
This switches `notmuch-mua-reply' and `notmuch-query-get-threads' to
the S-exp format. These were the last two uses of the JSON format in
the Emacs frontend.
---
emacs/notmuch-mua.el | 4 ++--
emacs/notmuch-query.el | 4 ++--
test/emacs-show | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 24eebff..329d342 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -146,7 +146,7 @@ list."
(unless (bolp) (insert "\n")))
(defun notmuch-mua-reply (query-string &optional sender reply-all)
- (let ((args '("reply" "--format=json" "--format-version=1"))
+ (let ((args '("reply" "--format=sexp" "--format-version=1"))
reply
original)
(when notmuch-show-process-crypto
@@ -158,7 +158,7 @@ list."
(setq args (append args (list query-string)))
;; Get the reply object as JSON, and parse it into an elisp object.
- (setq reply (apply #'notmuch-call-notmuch-json args))
+ (setq reply (apply #'notmuch-call-notmuch-sexp args))
;; Extract the original message to simplify the following code.
(setq original (plist-get reply :original))
diff --git a/emacs/notmuch-query.el b/emacs/notmuch-query.el
index 6e9f406..51d427f 100644
--- a/emacs/notmuch-query.el
+++ b/emacs/notmuch-query.el
@@ -29,11 +29,11 @@ A thread is a forest or list of trees. A tree is a two element
list where the first element is a message, and the second element
is a possibly empty forest of replies.
"
- (let ((args '("show" "--format=json" "--format-version=1")))
+ (let ((args '("show" "--format=sexp" "--format-version=1")))
(if notmuch-show-process-crypto
(setq args (append args '("--decrypt"))))
(setq args (append args search-terms))
- (apply #'notmuch-call-notmuch-json args)))
+ (apply #'notmuch-call-notmuch-sexp args)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Mapping functions across collections of messages.
diff --git a/test/emacs-show b/test/emacs-show
index 9f2ccb0..ae70053 100755
--- a/test/emacs-show
+++ b/test/emacs-show
@@ -189,7 +189,7 @@ This is an error (see *Notmuch errors* for more details)
---
[XXX]
This is an error
-command: $PWD/notmuch_fail show --format\\=json --format-version\\=1 --exclude\\=false \\' \\* \\'
+command: $PWD/notmuch_fail show --format\\=sexp --format-version\\=1 --exclude\\=false \\' \\* \\'
exit status: 1
stderr:
This is an error
--
1.7.10.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/3] emacs: Remove `notmuch-call-notmuch-json'
2013-06-23 23:43 [PATCH 1/3] emacs: Introduce `notmuch-call-notmuch-sexp' Austin Clements
2013-06-23 23:43 ` [PATCH 2/3] emacs: Use S-exp format everywhere Austin Clements
@ 2013-06-23 23:43 ` Austin Clements
2013-06-24 15:35 ` [PATCH 1/3] emacs: Introduce `notmuch-call-notmuch-sexp' Tomi Ollila
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Austin Clements @ 2013-06-23 23:43 UTC (permalink / raw)
To: notmuch
This function is no longer used.
---
emacs/notmuch-lib.el | 22 ----------------------
1 file changed, 22 deletions(-)
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 36eacc1..da814d5 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -462,28 +462,6 @@ You may need to restart Emacs or upgrade your notmuch package."))
;; `notmuch-logged-error' does not return.
))))
-(defun notmuch-call-notmuch-json (&rest args)
- "Invoke `notmuch-command' with ARGS and return the parsed JSON output.
-
-The returned output will represent objects using property lists
-and arrays as lists. If notmuch exits with a non-zero status,
-this will pop up a buffer containing notmuch's output and signal
-an error."
-
- (with-temp-buffer
- (let ((err-file (make-temp-file "nmerr")))
- (unwind-protect
- (let ((status (apply #'call-process
- notmuch-command nil (list t err-file) nil args)))
- (notmuch-check-exit-status status (cons notmuch-command args)
- (buffer-string) err-file)
- (goto-char (point-min))
- (let ((json-object-type 'plist)
- (json-array-type 'list)
- (json-false 'nil))
- (json-read)))
- (delete-file err-file)))))
-
(defun notmuch-call-notmuch-sexp (&rest args)
"Invoke `notmuch-command' with ARGS and return the parsed S-exp output.
--
1.7.10.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] emacs: Introduce `notmuch-call-notmuch-sexp'
2013-06-23 23:43 [PATCH 1/3] emacs: Introduce `notmuch-call-notmuch-sexp' Austin Clements
2013-06-23 23:43 ` [PATCH 2/3] emacs: Use S-exp format everywhere Austin Clements
2013-06-23 23:43 ` [PATCH 3/3] emacs: Remove `notmuch-call-notmuch-json' Austin Clements
@ 2013-06-24 15:35 ` Tomi Ollila
2013-06-24 19:00 ` Mark Walters
2013-06-25 6:06 ` David Bremner
4 siblings, 0 replies; 8+ messages in thread
From: Tomi Ollila @ 2013-06-24 15:35 UTC (permalink / raw)
To: Austin Clements, notmuch
On Mon, Jun 24 2013, Austin Clements <amdragon@MIT.EDU> wrote:
> This is just like `notmuch-call-notmuch-json', but parses S-expression
> output. Note that, also like `notmuch-call-notmuch-json', this
> doesn't consider trailing data to be an error, which may or may not be
> what we want in the long run.
> ---
This series looks good (if not trivial), works in use and tests pass. +1
Tomi
> emacs/notmuch-lib.el | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
> index 534f217..36eacc1 100644
> --- a/emacs/notmuch-lib.el
> +++ b/emacs/notmuch-lib.el
> @@ -484,6 +484,23 @@ an error."
> (json-read)))
> (delete-file err-file)))))
>
> +(defun notmuch-call-notmuch-sexp (&rest args)
> + "Invoke `notmuch-command' with ARGS and return the parsed S-exp output.
> +
> +If notmuch exits with a non-zero status, this will pop up a
> +buffer containing notmuch's output and signal an error."
> +
> + (with-temp-buffer
> + (let ((err-file (make-temp-file "nmerr")))
> + (unwind-protect
> + (let ((status (apply #'call-process
> + notmuch-command nil (list t err-file) nil args)))
> + (notmuch-check-exit-status status (cons notmuch-command args)
> + (buffer-string) err-file)
> + (goto-char (point-min))
> + (read (current-buffer)))
> + (delete-file err-file)))))
> +
> (defun notmuch-start-notmuch (name buffer sentinel &rest args)
> "Start and return an asynchronous notmuch command.
>
> --
> 1.7.10.4
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] emacs: Introduce `notmuch-call-notmuch-sexp'
2013-06-23 23:43 [PATCH 1/3] emacs: Introduce `notmuch-call-notmuch-sexp' Austin Clements
` (2 preceding siblings ...)
2013-06-24 15:35 ` [PATCH 1/3] emacs: Introduce `notmuch-call-notmuch-sexp' Tomi Ollila
@ 2013-06-24 19:00 ` Mark Walters
2013-06-24 19:11 ` Austin Clements
2013-06-25 6:06 ` David Bremner
4 siblings, 1 reply; 8+ messages in thread
From: Mark Walters @ 2013-06-24 19:00 UTC (permalink / raw)
To: Austin Clements, notmuch
This series looks good to me +1.
Is it worth removing all the json (3 files with (require 'json) and the
async json parser) too?
Best wishes
Mark
On Mon, 24 Jun 2013, Austin Clements <amdragon@MIT.EDU> wrote:
> This is just like `notmuch-call-notmuch-json', but parses S-expression
> output. Note that, also like `notmuch-call-notmuch-json', this
> doesn't consider trailing data to be an error, which may or may not be
> what we want in the long run.
> ---
> emacs/notmuch-lib.el | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
> index 534f217..36eacc1 100644
> --- a/emacs/notmuch-lib.el
> +++ b/emacs/notmuch-lib.el
> @@ -484,6 +484,23 @@ an error."
> (json-read)))
> (delete-file err-file)))))
>
> +(defun notmuch-call-notmuch-sexp (&rest args)
> + "Invoke `notmuch-command' with ARGS and return the parsed S-exp output.
> +
> +If notmuch exits with a non-zero status, this will pop up a
> +buffer containing notmuch's output and signal an error."
> +
> + (with-temp-buffer
> + (let ((err-file (make-temp-file "nmerr")))
> + (unwind-protect
> + (let ((status (apply #'call-process
> + notmuch-command nil (list t err-file) nil args)))
> + (notmuch-check-exit-status status (cons notmuch-command args)
> + (buffer-string) err-file)
> + (goto-char (point-min))
> + (read (current-buffer)))
> + (delete-file err-file)))))
> +
> (defun notmuch-start-notmuch (name buffer sentinel &rest args)
> "Start and return an asynchronous notmuch command.
>
> --
> 1.7.10.4
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] emacs: Introduce `notmuch-call-notmuch-sexp'
2013-06-24 19:00 ` Mark Walters
@ 2013-06-24 19:11 ` Austin Clements
2013-06-24 19:29 ` Mark Walters
0 siblings, 1 reply; 8+ messages in thread
From: Austin Clements @ 2013-06-24 19:11 UTC (permalink / raw)
To: Mark Walters; +Cc: notmuch
Yes, and thanks for reminding me about the require's. I'll do that in
a follow up. I was thinking of just moving the streaming JSON parser
to a repo on my GitHub account, since maybe somebody some day will
find a use for it, or at least take inspiration from the API (I looked
into streaming JSON parser APIs before embarking on that one and
they're all terrible!) Mark, you're the only other person who has
touched that code. Is this plan good with you?
Quoth Mark Walters on Jun 24 at 8:00 pm:
>
> This series looks good to me +1.
>
> Is it worth removing all the json (3 files with (require 'json) and the
> async json parser) too?
>
> Best wishes
>
> Mark
>
> On Mon, 24 Jun 2013, Austin Clements <amdragon@MIT.EDU> wrote:
> > This is just like `notmuch-call-notmuch-json', but parses S-expression
> > output. Note that, also like `notmuch-call-notmuch-json', this
> > doesn't consider trailing data to be an error, which may or may not be
> > what we want in the long run.
> > ---
> > emacs/notmuch-lib.el | 17 +++++++++++++++++
> > 1 file changed, 17 insertions(+)
> >
> > diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
> > index 534f217..36eacc1 100644
> > --- a/emacs/notmuch-lib.el
> > +++ b/emacs/notmuch-lib.el
> > @@ -484,6 +484,23 @@ an error."
> > (json-read)))
> > (delete-file err-file)))))
> >
> > +(defun notmuch-call-notmuch-sexp (&rest args)
> > + "Invoke `notmuch-command' with ARGS and return the parsed S-exp output.
> > +
> > +If notmuch exits with a non-zero status, this will pop up a
> > +buffer containing notmuch's output and signal an error."
> > +
> > + (with-temp-buffer
> > + (let ((err-file (make-temp-file "nmerr")))
> > + (unwind-protect
> > + (let ((status (apply #'call-process
> > + notmuch-command nil (list t err-file) nil args)))
> > + (notmuch-check-exit-status status (cons notmuch-command args)
> > + (buffer-string) err-file)
> > + (goto-char (point-min))
> > + (read (current-buffer)))
> > + (delete-file err-file)))))
> > +
> > (defun notmuch-start-notmuch (name buffer sentinel &rest args)
> > "Start and return an asynchronous notmuch command.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] emacs: Introduce `notmuch-call-notmuch-sexp'
2013-06-24 19:11 ` Austin Clements
@ 2013-06-24 19:29 ` Mark Walters
0 siblings, 0 replies; 8+ messages in thread
From: Mark Walters @ 2013-06-24 19:29 UTC (permalink / raw)
To: Austin Clements; +Cc: notmuch
That is fine.
(I think I only moved your code from one file to another but in any case
what you suggest is fine.)
Best wishes
Mark
On Mon, 24 Jun 2013, Austin Clements <amdragon@MIT.EDU> wrote:
> Yes, and thanks for reminding me about the require's. I'll do that in
> a follow up. I was thinking of just moving the streaming JSON parser
> to a repo on my GitHub account, since maybe somebody some day will
> find a use for it, or at least take inspiration from the API (I looked
> into streaming JSON parser APIs before embarking on that one and
> they're all terrible!) Mark, you're the only other person who has
> touched that code. Is this plan good with you?
>
> Quoth Mark Walters on Jun 24 at 8:00 pm:
>>
>> This series looks good to me +1.
>>
>> Is it worth removing all the json (3 files with (require 'json) and the
>> async json parser) too?
>>
>> Best wishes
>>
>> Mark
>>
>> On Mon, 24 Jun 2013, Austin Clements <amdragon@MIT.EDU> wrote:
>> > This is just like `notmuch-call-notmuch-json', but parses S-expression
>> > output. Note that, also like `notmuch-call-notmuch-json', this
>> > doesn't consider trailing data to be an error, which may or may not be
>> > what we want in the long run.
>> > ---
>> > emacs/notmuch-lib.el | 17 +++++++++++++++++
>> > 1 file changed, 17 insertions(+)
>> >
>> > diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
>> > index 534f217..36eacc1 100644
>> > --- a/emacs/notmuch-lib.el
>> > +++ b/emacs/notmuch-lib.el
>> > @@ -484,6 +484,23 @@ an error."
>> > (json-read)))
>> > (delete-file err-file)))))
>> >
>> > +(defun notmuch-call-notmuch-sexp (&rest args)
>> > + "Invoke `notmuch-command' with ARGS and return the parsed S-exp output.
>> > +
>> > +If notmuch exits with a non-zero status, this will pop up a
>> > +buffer containing notmuch's output and signal an error."
>> > +
>> > + (with-temp-buffer
>> > + (let ((err-file (make-temp-file "nmerr")))
>> > + (unwind-protect
>> > + (let ((status (apply #'call-process
>> > + notmuch-command nil (list t err-file) nil args)))
>> > + (notmuch-check-exit-status status (cons notmuch-command args)
>> > + (buffer-string) err-file)
>> > + (goto-char (point-min))
>> > + (read (current-buffer)))
>> > + (delete-file err-file)))))
>> > +
>> > (defun notmuch-start-notmuch (name buffer sentinel &rest args)
>> > "Start and return an asynchronous notmuch command.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] emacs: Introduce `notmuch-call-notmuch-sexp'
2013-06-23 23:43 [PATCH 1/3] emacs: Introduce `notmuch-call-notmuch-sexp' Austin Clements
` (3 preceding siblings ...)
2013-06-24 19:00 ` Mark Walters
@ 2013-06-25 6:06 ` David Bremner
4 siblings, 0 replies; 8+ messages in thread
From: David Bremner @ 2013-06-25 6:06 UTC (permalink / raw)
To: Austin Clements, notmuch
Austin Clements <amdragon@MIT.EDU> writes:
> This is just like `notmuch-call-notmuch-json', but parses S-expression
> output. Note that, also like `notmuch-call-notmuch-json', this
> doesn't consider trailing data to be an error, which may or may not be
> what we want in the long run.
series pushed,
d
^ permalink raw reply [flat|nested] 8+ messages in thread