* Script output in mail-source directory :prescript
@ 2006-04-18 21:20 Timo Lilja
2006-04-23 14:09 ` Lars Magne Ingebrigtsen
0 siblings, 1 reply; 5+ messages in thread
From: Timo Lilja @ 2006-04-18 21:20 UTC (permalink / raw)
Is there a way to get the script output and some kind of a notice if
the exit status of the script is non-zero in a directory mail source
:prescript?
I have the following in ~/.gnus:
(setq mail-sources '((directory :path "~/path/to/mail-in"
:prescript "~/path/to/get-mail-script")))
Now, the problem is that if the get-mail-script has a non-zero exit or
produces some output, nothing is shown in the Emacs buffers.
The following patch almost does what I have in mind:
--- orig.mail-source.el 2005-03-18 06:35:29.000000000 +0200
+++ mail-source.el 2006-04-19 00:09:56.000000000 +0300
@@ -667,12 +667,9 @@
(sleep-for delay)))
(defun mail-source-call-script (script)
- (let ((background nil))
- (when (string-match "& *$" script)
- (setq script (substring script 0 (match-beginning 0))
- background 0))
- (call-process shell-file-name nil background nil
- shell-command-switch script)))
+ (let ((resize-mini-windows nil)
+ (max-mini-window-height 0))
+ (shell-command script)))
;;;
;;; Different fetchers
Unfortunately (shell-command) does not pop the output buffer if there
is only single line of output. It doesn't help to change the
`resize-mini-windows' or `max-mini-window-height' either.
If the script exist status is non-zero, (shell-command) produces no
output.
--
Timo Lilja
"It's a 106 miles to Chicago. We've got a full tank of gas,
half a pack of cigarettes, it's dark, and we're wearing sunglasses."
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Script output in mail-source directory :prescript
2006-04-18 21:20 Script output in mail-source directory :prescript Timo Lilja
@ 2006-04-23 14:09 ` Lars Magne Ingebrigtsen
2006-04-26 5:56 ` Timo Lilja
0 siblings, 1 reply; 5+ messages in thread
From: Lars Magne Ingebrigtsen @ 2006-04-23 14:09 UTC (permalink / raw)
Timo Lilja <timo.lilja@hut.fi> writes:
> Now, the problem is that if the get-mail-script has a non-zero exit or
> produces some output, nothing is shown in the Emacs buffers.
Try the following patch:
Index: mail-source.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/mail-source.el,v
retrieving revision 7.15
retrieving revision 7.16
diff -c -r7.15 -r7.16
*** mail-source.el 8 Feb 2006 04:17:15 -0000 7.15
--- mail-source.el 23 Apr 2006 14:09:14 -0000 7.16
***************
*** 678,689 ****
(sleep-for delay)))
(defun mail-source-call-script (script)
! (let ((background nil))
(when (string-match "& *$" script)
(setq script (substring script 0 (match-beginning 0))
background 0))
! (call-process shell-file-name nil background nil
! shell-command-switch script)))
;;;
;;; Different fetchers
--- 678,697 ----
(sleep-for delay)))
(defun mail-source-call-script (script)
! (let ((background nil)
! (stderr (get-buffer-create " *mail-source-stderr*"))
! result)
(when (string-match "& *$" script)
(setq script (substring script 0 (match-beginning 0))
background 0))
! (setq result
! (call-process shell-file-name nil background nil
! shell-command-switch script))
! (when (and result
! (not (zerop result)))
! (set-buffer stderr)
! (message "Mail source error: %s" (buffer-string)))
! (kill-buffer stderr)))
;;;
;;; Different fetchers
--
(domestic pets only, the antidote for overdose, milk.)
larsi@gnus.org * Lars Magne Ingebrigtsen
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Script output in mail-source directory :prescript
2006-04-23 14:09 ` Lars Magne Ingebrigtsen
@ 2006-04-26 5:56 ` Timo Lilja
2006-04-30 10:51 ` Lars Magne Ingebrigtsen
0 siblings, 1 reply; 5+ messages in thread
From: Timo Lilja @ 2006-04-26 5:56 UTC (permalink / raw)
Lars Magne Ingebrigtsen <larsi@gnus.org> writes:
>Timo Lilja <timo.lilja@hut.fi> writes:
>
>> Now, the problem is that if the get-mail-script has a non-zero exit or
>> produces some output, nothing is shown in the Emacs buffers.
>
>Try the following patch:
[...]
Nope, It didn't work for me but I modified it a bit and now it works:
--- orig.mail-source.el 2005-03-18 06:35:29.000000000 +0200
+++ mail-source.el 2006-04-26 08:48:59.000000000 +0300
@@ -667,12 +667,23 @@
(sleep-for delay)))
(defun mail-source-call-script (script)
- (let ((background nil))
+ (let ((background nil)
+ (stderr (get-buffer-create " *mail-source-stderr*"))
+ result)
(when (string-match "& *$" script)
(setq script (substring script 0 (match-beginning 0))
background 0))
- (call-process shell-file-name nil background nil
- shell-command-switch script)))
+ (setq result
+ (call-process shell-file-name nil stderr nil
+ shell-command-switch script))
+ (if (and result
+ (not (zerop result)))
+ (progn
+ (split-window-vertically)
+ (other-window 1)
+ (switch-to-buffer stderr)
+ (message "Mail source error: %s" (buffer-string)))
+ (kill-buffer stderr))))
;;;
;;; Different fetchers
>
>Index: mail-source.el
>===================================================================
>RCS file: /usr/local/cvsroot/gnus/lisp/mail-source.el,v
>retrieving revision 7.15
>retrieving revision 7.16
>diff -c -r7.15 -r7.16
>*** mail-source.el 8 Feb 2006 04:17:15 -0000 7.15
>--- mail-source.el 23 Apr 2006 14:09:14 -0000 7.16
>***************
>*** 678,689 ****
> (sleep-for delay)))
>
> (defun mail-source-call-script (script)
>! (let ((background nil))
> (when (string-match "& *$" script)
> (setq script (substring script 0 (match-beginning 0))
> background 0))
>! (call-process shell-file-name nil background nil
>! shell-command-switch script)))
>
> ;;;
> ;;; Different fetchers
>--- 678,697 ----
> (sleep-for delay)))
>
> (defun mail-source-call-script (script)
>! (let ((background nil)
>! (stderr (get-buffer-create " *mail-source-stderr*"))
>! result)
> (when (string-match "& *$" script)
> (setq script (substring script 0 (match-beginning 0))
> background 0))
>! (setq result
>! (call-process shell-file-name nil background nil
>! shell-command-switch script))
>! (when (and result
>! (not (zerop result)))
>! (set-buffer stderr)
>! (message "Mail source error: %s" (buffer-string)))
>! (kill-buffer stderr)))
>
> ;;;
> ;;; Different fetchers
>
>--
>(domestic pets only, the antidote for overdose, milk.)
> larsi@gnus.org * Lars Magne Ingebrigtsen
--
Timo Lilja
"It's a 106 miles to Chicago. We've got a full tank of gas,
half a pack of cigarettes, it's dark, and we're wearing sunglasses."
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Script output in mail-source directory :prescript
2006-04-26 5:56 ` Timo Lilja
@ 2006-04-30 10:51 ` Lars Magne Ingebrigtsen
2006-05-13 17:04 ` Timo Lilja
0 siblings, 1 reply; 5+ messages in thread
From: Lars Magne Ingebrigtsen @ 2006-04-30 10:51 UTC (permalink / raw)
Timo Lilja <timo.lilja@hut.fi> writes:
> Nope, It didn't work for me but I modified it a bit and now it works:
Could you send me a diff against the current sources?
--
(domestic pets only, the antidote for overdose, milk.)
larsi@gnus.org * Lars Magne Ingebrigtsen
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Script output in mail-source directory :prescript
2006-04-30 10:51 ` Lars Magne Ingebrigtsen
@ 2006-05-13 17:04 ` Timo Lilja
0 siblings, 0 replies; 5+ messages in thread
From: Timo Lilja @ 2006-05-13 17:04 UTC (permalink / raw)
Lars Magne Ingebrigtsen <larsi@gnus.org> writes:
>Timo Lilja <timo.lilja@hut.fi> writes:
>
>> Nope, It didn't work for me but I modified it a bit and now it works:
>
>Could you send me a diff against the current sources?
Okey, here is the diff against the latest CVS:
Index: mail-source.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/mail-source.el,v
retrieving revision 7.17
diff -u -r7.17 mail-source.el5A
--- mail-source.el 30 Apr 2006 09:44:06 -0000 7.17
+++ mail-source.el 13 May 2006 17:02:32 -0000
@@ -685,13 +685,16 @@
(setq script (substring script 0 (match-beginning 0))
background 0))
(setq result
- (call-process shell-file-name nil background nil
+ (call-process shell-file-name nil stderr nil
shell-command-switch script))
- (when (and result
+ (if (and result
(not (zerop result)))
- (set-buffer stderr)
- (message "Mail source error: %s" (buffer-string)))
- (kill-buffer stderr)))
+ (progn
+ (split-window-vertically)
+ (other-window 1)
+ (switch-to-buffer stderr)
+ (message "Mail source error: %s" (buffer-string)))
+ (kill-buffer stderr))))
;;;
;;; Different fetchers
Just occured to me that using routines from gnus-win.el might make
this task a bit easier.
--
Timo Lilja
"It's a 106 miles to Chicago. We've got a full tank of gas,
half a pack of cigarettes, it's dark, and we're wearing sunglasses."
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-05-13 17:04 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-18 21:20 Script output in mail-source directory :prescript Timo Lilja
2006-04-23 14:09 ` Lars Magne Ingebrigtsen
2006-04-26 5:56 ` Timo Lilja
2006-04-30 10:51 ` Lars Magne Ingebrigtsen
2006-05-13 17:04 ` Timo Lilja
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 NNTP newsgroup(s).