[PATCH] emacs: introduce notmuch-command-to-string, replace use of shell-command-to-string

2013-04-01 Thread David Bremner
david at tethera.net writes:

> From: David Bremner 
>
> This has two benefits: unified error handling, and avoiding tramp's
> hooking into shell-command-string.
>
> This seems to be a fix for id:874nguxbvq.fsf at tu-dortmund.de
> ---
>
> Simon: can you check if this fixes your bug?

I have pushed this to master, after adding a mysteriously missing
close-parenthesis.

d


Re: [PATCH] emacs: introduce notmuch-command-to-string, replace use of shell-command-to-string

2013-04-01 Thread David Bremner
da...@tethera.net writes:

> From: David Bremner 
>
> This has two benefits: unified error handling, and avoiding tramp's
> hooking into shell-command-string.
>
> This seems to be a fix for id:874nguxbvq@tu-dortmund.de
> ---
>
> Simon: can you check if this fixes your bug?

I have pushed this to master, after adding a mysteriously missing
close-parenthesis.

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


[PATCH] emacs: introduce notmuch-command-to-string, replace use of shell-command-to-string

2013-03-29 Thread Tomi Ollila
On Fri, Mar 29 2013, David Bremner  wrote:

> david at tethera.net writes:
>
>> From: David Bremner 
>>
>> This has two benefits: unified error handling, and avoiding tramp's
>> hooking into shell-command-string.
>>
>> This seems to be a fix for id:874nguxbvq.fsf at tu-dortmund.de
>> ---
>>
>> Simon: can you check if this fixes your bug?
>
> Anyone willing to sanity check my e-lisp?

LGTM. The implementation is quite much the same as in 
notmuch-call-notmuch-process, just that this function returns
the output as a string.

> d

Tomi


[PATCH] emacs: introduce notmuch-command-to-string, replace use of shell-command-to-string

2013-03-29 Thread David Bremner
david at tethera.net writes:

> From: David Bremner 
>
> This has two benefits: unified error handling, and avoiding tramp's
> hooking into shell-command-string.
>
> This seems to be a fix for id:874nguxbvq.fsf at tu-dortmund.de
> ---
>
> Simon: can you check if this fixes your bug?

Anyone willing to sanity check my e-lisp?

d


Re: [PATCH] emacs: introduce notmuch-command-to-string, replace use of shell-command-to-string

2013-03-29 Thread Tomi Ollila
On Fri, Mar 29 2013, David Bremner  wrote:

> da...@tethera.net writes:
>
>> From: David Bremner 
>>
>> This has two benefits: unified error handling, and avoiding tramp's
>> hooking into shell-command-string.
>>
>> This seems to be a fix for id:874nguxbvq@tu-dortmund.de
>> ---
>>
>> Simon: can you check if this fixes your bug?
>
> Anyone willing to sanity check my e-lisp?

LGTM. The implementation is quite much the same as in 
notmuch-call-notmuch-process, just that this function returns
the output as a string.

> d

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


Re: [PATCH] emacs: introduce notmuch-command-to-string, replace use of shell-command-to-string

2013-03-29 Thread David Bremner
da...@tethera.net writes:

> From: David Bremner 
>
> This has two benefits: unified error handling, and avoiding tramp's
> hooking into shell-command-string.
>
> This seems to be a fix for id:874nguxbvq@tu-dortmund.de
> ---
>
> Simon: can you check if this fixes your bug?

Anyone willing to sanity check my e-lisp?

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


[PATCH] emacs: introduce notmuch-command-to-string, replace use of shell-command-to-string

2013-03-08 Thread da...@tethera.net
From: David Bremner 

This has two benefits: unified error handling, and avoiding tramp's
hooking into shell-command-string.

This seems to be a fix for id:874nguxbvq.fsf at tu-dortmund.de
---

Simon: can you check if this fixes your bug?

 emacs/notmuch-lib.el | 22 --
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 270e3dc..556b1a4 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -112,13 +112,25 @@ For example, if you wanted to remove an \"inbox\" tag and 
add an
  (select-window (posn-window (event-start last-input-event)))
  (button-activate button)))

+(defun notmuch-command-to-string (&rest args)
+  "Synchronously invoke \"notmuch\" with the given list of arguments.
+
+If notmuch exits with a non-zero status, output from the process
+will appear in a buffer named \"*Notmuch errors*\" and an error
+will be signaled.
+
+Otherwise the output will be returned"
+  (with-temp-buffer
+(let* ((status (apply #'call-process notmuch-command nil t nil args))
+  (output (buffer-string)))
+  (notmuch-check-exit-status status (cons notmuch-command args) output)
+  output)))
+
 (defun notmuch-version ()
   "Return a string with the notmuch version number."
   (let ((long-string
 ;; Trim off the trailing newline.
-(substring (shell-command-to-string
-(concat notmuch-command " --version"))
-   0 -1)))
+(substring (notmuch-command-to-string "--version") 0 -1))
 (if (string-match "^notmuch\\( version\\)? \\(.*\\)$"
  long-string)
(match-string 2 long-string)
@@ -127,9 +139,7 @@ For example, if you wanted to remove an \"inbox\" tag and 
add an
 (defun notmuch-config-get (item)
   "Return a value from the notmuch configuration."
   ;; Trim off the trailing newline
-  (substring (shell-command-to-string
- (concat notmuch-command " config get " item))
- 0 -1))
+  (substring (notmuch-command-to-string "config" "get" item) 0 -1))

 (defun notmuch-database-path ()
   "Return the database.path value from the notmuch configuration."
-- 
1.8.2.rc1



[PATCH] emacs: introduce notmuch-command-to-string, replace use of shell-command-to-string

2013-03-08 Thread david
From: David Bremner 

This has two benefits: unified error handling, and avoiding tramp's
hooking into shell-command-string.

This seems to be a fix for id:874nguxbvq@tu-dortmund.de
---

Simon: can you check if this fixes your bug?

 emacs/notmuch-lib.el | 22 --
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 270e3dc..556b1a4 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -112,13 +112,25 @@ For example, if you wanted to remove an \"inbox\" tag and 
add an
  (select-window (posn-window (event-start last-input-event)))
  (button-activate button)))
 
+(defun notmuch-command-to-string (&rest args)
+  "Synchronously invoke \"notmuch\" with the given list of arguments.
+
+If notmuch exits with a non-zero status, output from the process
+will appear in a buffer named \"*Notmuch errors*\" and an error
+will be signaled.
+
+Otherwise the output will be returned"
+  (with-temp-buffer
+(let* ((status (apply #'call-process notmuch-command nil t nil args))
+  (output (buffer-string)))
+  (notmuch-check-exit-status status (cons notmuch-command args) output)
+  output)))
+
 (defun notmuch-version ()
   "Return a string with the notmuch version number."
   (let ((long-string
 ;; Trim off the trailing newline.
-(substring (shell-command-to-string
-(concat notmuch-command " --version"))
-   0 -1)))
+(substring (notmuch-command-to-string "--version") 0 -1))
 (if (string-match "^notmuch\\( version\\)? \\(.*\\)$"
  long-string)
(match-string 2 long-string)
@@ -127,9 +139,7 @@ For example, if you wanted to remove an \"inbox\" tag and 
add an
 (defun notmuch-config-get (item)
   "Return a value from the notmuch configuration."
   ;; Trim off the trailing newline
-  (substring (shell-command-to-string
- (concat notmuch-command " config get " item))
- 0 -1))
+  (substring (notmuch-command-to-string "config" "get" item) 0 -1))
 
 (defun notmuch-database-path ()
   "Return the database.path value from the notmuch configuration."
-- 
1.8.2.rc1

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