Gnus development mailing list
 help / color / mirror / Atom feed
* How to make gnus read something besides .gnus in batch mode
@ 2003-06-29 17:24 Harry Putnam
  2003-06-29 20:47 ` Harry Putnam
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Harry Putnam @ 2003-06-29 17:24 UTC (permalink / raw)



I want to run batch commands but not read my standard .emacs .gnus
site-start.el.   I've learned from the past that things in any init
files that write to standard out like (message) can cause I/O errors.
But I like having some of those in there... so:

I compile an init file on the fly for gnus (or emacs) to read.  But
how can I aim gnus at only that file?

I've tinkered with the batch command shown in gnus manual:
 From manual version:
  emacs -batch -l ~/.emacs -f -l ~/.gnus.el gnus-agent-batch >/dev/null 2>&1

 To my version:
  emacs -q -no-site-file -batch -l ~/.my_gnus.el -f gnus-agent-batch

It still tries to load ~/.gnus:
  emacs -q -no-site-file -batch -l ~/.my_gnus.el -f gnus-agent-batch
  hello world -- ~/.gnus
Reading /home/reader/.newsrc-enews.newsguy.com.eld...
[...]

The formulation in the manual has a `-f -l  ~/.gnus.el' before 
agent-fetch but when I try that it give me this error:

   emacs -q -no-site-file -batch -l ~/.my_gnus.el -f -l \
    ~/.my_gnus.el  gnus-agent-batch
  Symbol's function definition is void: -l

So how can I tell the function `gnus-agent-batch' which code to load
and prevent it from automatically reading ~/.gnus.

I know about the behavior where if both ~/.gnus and ~/.gnus.el are
present then ~/.gnus.el is read, but that seems likely to lead to a
running gnus reading from ~/.gnus.el too.  

Even if I create it for the batch run, then destroy it.  Still seems
sooner or later it would get inadvertantly read by a possible running
gnus process during the batch fetch.




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to make gnus read something besides .gnus in batch mode
  2003-06-29 17:24 How to make gnus read something besides .gnus in batch mode Harry Putnam
@ 2003-06-29 20:47 ` Harry Putnam
  2003-06-30  4:32   ` John Paul Wallington
  2003-06-29 21:22 ` lawrence mitchell
  2003-07-01  0:15 ` Harry Putnam
  2 siblings, 1 reply; 10+ messages in thread
From: Harry Putnam @ 2003-06-29 20:47 UTC (permalink / raw)


Harry Putnam <reader@newsguy.com> writes:

> So how can I tell the function `gnus-agent-batch' which code to load
> and prevent it from automatically reading ~/.gnus.

Alternatively, maybe examine the call to ~/.gnus on the first line of
~/.gnus  to see if it is a batch command.

Will gnus be aware of some thing like shell $@ when .gnus is read,
where I could look for the `-batch' flag and load certain stuff if its
pressent?

Any example how that might be done?








^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to make gnus read something besides .gnus in batch mode
  2003-06-29 17:24 How to make gnus read something besides .gnus in batch mode Harry Putnam
  2003-06-29 20:47 ` Harry Putnam
@ 2003-06-29 21:22 ` lawrence mitchell
  2003-07-01  0:15 ` Harry Putnam
  2 siblings, 0 replies; 10+ messages in thread
From: lawrence mitchell @ 2003-06-29 21:22 UTC (permalink / raw)
  Cc: ding

Harry Putnam wrote:

> I want to run batch commands but not read my standard .emacs .gnus
> site-start.el.   I've learned from the past that things in any init
> files that write to standard out like (message) can cause I/O errors.
> But I like having some of those in there... so:

> I compile an init file on the fly for gnus (or emacs) to read.  But
> how can I aim gnus at only that file?

[...]

How about something along the lines of:

emacs -batch --eval '(setq gnus-init-file "~/.not-dot-gnus")' \
 -f gnus-agent-batch

-- 
lawrence mitchell <s0198183+ding@sms.ed.ac.uk>



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to make gnus read something besides .gnus in batch mode
  2003-06-29 20:47 ` Harry Putnam
@ 2003-06-30  4:32   ` John Paul Wallington
  2003-06-30  6:25     ` Harry Putnam
  0 siblings, 1 reply; 10+ messages in thread
From: John Paul Wallington @ 2003-06-30  4:32 UTC (permalink / raw)


Harry Putnam <reader@newsguy.com> wrote:

> Will gnus be aware of some thing like shell $@ when .gnus is read,
> where I could look for the `-batch' flag and load certain stuff if its
> pressent?

Many arguments are deleted from `command-line-args' as they are
processed.  How about checking the `noninteractive' variable ?




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to make gnus read something besides .gnus in batch mode
  2003-06-30  4:32   ` John Paul Wallington
@ 2003-06-30  6:25     ` Harry Putnam
  2003-06-30  7:01       ` John Paul Wallington
  0 siblings, 1 reply; 10+ messages in thread
From: Harry Putnam @ 2003-06-30  6:25 UTC (permalink / raw)


John Paul Wallington <jpw@gnu.org> writes:

> Many arguments are deleted from `command-line-args' as they are
> processed.  How about checking the `noninteractive' variable ?

probably being a horrible pest here but how would I make emacs cough
up the contents of `noninteractive'

something like:

emacs -batch -eval '(noninteractive)' but the syntax is all dorked up.




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to make gnus read something besides .gnus in batch mode
  2003-06-30  6:25     ` Harry Putnam
@ 2003-06-30  7:01       ` John Paul Wallington
  2003-06-30 15:07         ` Harry Putnam
  0 siblings, 1 reply; 10+ messages in thread
From: John Paul Wallington @ 2003-06-30  7:01 UTC (permalink / raw)


Harry Putnam <reader@newsguy.com> wrote:

>> Many arguments are deleted from `command-line-args' as they are
>> processed.  How about checking the `noninteractive' variable ?
>
> probably being a horrible pest here but how would I make emacs cough
> up the contents of `noninteractive'
>
> something like:
> emacs -batch -eval '(noninteractive)' but the syntax is all dorked up.

I don't think it makes sense to heed `noninteractive' in a form that
is passed to emacs -batch -eval because that would be redundant.

[Nevertheless, emacs -batch -eval 'noninteractive' is syntactically
correct at least, and to "make it do something" you could say emacs
-batch -eval '(print noninteractive)' or emacs -batch -eval '(if
noninteractive (print "foo"))'.]

It makes more sense to heed `noninteractive' in your .gnus file.

Also, wrt this invocation mentioned in your first post:

emacs -q -no-site-file -batch -l ~/.my_gnus.el -f gnus-agent-batch

Maybe it helps to frob the variable `gnus-init-file' to avoid loading
~/.gnus ?  For example, you could put (setq gnus-init-file
(expand-file-name "~/.my_gnus.el")) at the start of ~/.my_gnus.el
(untested).




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to make gnus read something besides .gnus in batch mode
  2003-06-30  7:01       ` John Paul Wallington
@ 2003-06-30 15:07         ` Harry Putnam
  2003-06-30 17:06           ` John Paul Wallington
  0 siblings, 1 reply; 10+ messages in thread
From: Harry Putnam @ 2003-06-30 15:07 UTC (permalink / raw)


John Paul Wallington <jpw@gnu.org> writes:

>>> Many arguments are deleted from `command-line-args' as they are
>>> processed.  How about checking the `noninteractive' variable ?

[...]

> I don't think it makes sense to heed `noninteractive' in a form that
> is passed to emacs -batch -eval because that would be redundant.
>
> [Nevertheless, emacs -batch -eval 'noninteractive' is syntactically
> correct at least, and to "make it do something" you could say emacs
> -batch -eval '(print noninteractive)' or emacs -batch -eval '(if
> noninteractive (print "foo"))'.]
>
> It makes more sense to heed `noninteractive' in your .gnus file.

Yes,  I was looking for the correct syntax to access it.  You've
supplied it.  Test for boolean value.

> emacs -q -no-site-file -batch -l ~/.my_gnus.el -f gnus-agent-batch
>
> Maybe it helps to frob the variable `gnus-init-file' to avoid loading
> ~/.gnus ?  For example, you could put (setq gnus-init-file
> (expand-file-name "~/.my_gnus.el")) at the start of ~/.my_gnus.el
> (untested).

L. Mitchell posted something that does that same thing I think:
emacs -batch --eval '(setq gnus-init-file "~/.not-dot-gnus")' \
 -f gnus-agent-batch

After being shown the proper stuff to look at and some experimentation.
It looks like one cannot slurp the contents of command-line-args even
by sticking it in a variable first thing:

 $ emacs -eval '(defvar myargs command-line-args)' \ 
   -q -no-site-file -batch  -eval '(print myargs)'

("emacs" "-eval" "(defvar myargs command-line-args)" "-eval" "(print
myargs)")

Still doesn't know about `-q', `-no-stite-file', or `-batch'

But noninteractive knows its a -batch command.

cat new.el
(message "Hello World from new.el")
(if noninteractive (print "Running noninteractive"))

=========

     $ emacs -q -no-site-file -batch -l ./new.el
   Hello World from new.el

   "Running noninteractive"

I have enough to solve my problme but still wondered if there just is
no way to grab all of command-line-args before processing begins?
Oh, and where is the extra newline coming from in the above output?




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to make gnus read something besides .gnus in batch mode
  2003-06-30 15:07         ` Harry Putnam
@ 2003-06-30 17:06           ` John Paul Wallington
  0 siblings, 0 replies; 10+ messages in thread
From: John Paul Wallington @ 2003-06-30 17:06 UTC (permalink / raw)


Harry Putnam <reader@newsguy.com> wrote:

> I have enough to solve my problme but still wondered if there just is
> no way to grab all of command-line-args before processing begins?

I don't think so.

> Oh, and where is the extra newline coming from in the above output?

The `print' function.  Probably `message' is better.




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to make gnus read something besides .gnus in batch mode
  2003-06-29 17:24 How to make gnus read something besides .gnus in batch mode Harry Putnam
  2003-06-29 20:47 ` Harry Putnam
  2003-06-29 21:22 ` lawrence mitchell
@ 2003-07-01  0:15 ` Harry Putnam
  2003-07-01 14:17   ` Harry Putnam
  2 siblings, 1 reply; 10+ messages in thread
From: Harry Putnam @ 2003-07-01  0:15 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 4061 bytes --]

Harry Putnam <reader@newsguy.com> writes:

> I want to run batch commands but not read my standard .emacs .gnus
> site-start.el.   I've learned from the past that things in any init
> files that write to standard out like (message) can cause I/O errors.
> But I like having some of those in there... so:
>
> I compile an init file on the fly for gnus (or emacs) to read.  But
> how can I aim gnus at only that file?

Even with the kind help I've gotten on this, I'm still having
problems with it.  I think the general mechanism is sound but have
trouble figuring out why it fails, or partially fails.

The init file created is attached as text/plain at the end so you
should be able to inline it with a <RET>.

The full command line:
emacs -q -no-site-file -batch \
 -eval '(setq gnus-init-file "/tmp/my_gnus_init.el")'\
   -f gnus-agent-batch

If I run this as is, I get these kind of errors:

 $ emacs -q -no-site-file -batch -eval '(setq gnus-init-file "/tmp/my_gnus_init.el")'  -f gnus-agent-batch
Reading /home/reader/.newsrc-enews.newsguy.com.eld...
Reading active file from enews.newsguy.com via nntp...
Reading active file via nnml...
Opening nnml server...
nnml: Reading incoming mail from directory...
Wrote /home/reader/Mail/bperl/12471
1)**Mail source error ((void-function nnheader-parse-naked-head)).  Continue? (yes or no) yes
nnml: Reading incoming mail from file...
Processing mail from ~/.emacs-mail-crash-box...
Creating mail directory /home/reader/Mail/mail/misc/
Wrote /home/reader/Mail/mail/misc/8
2)**Symbol's function definition is void: nnheader-parse-naked-head

[Errors marked by `N)**'
Two things of note here

  1) I never had a mail box named `/home/reader/Mail/mail/misc/'
     before and there is nothing in the lone init file to suggest it.

  2) Even if I delete .emacs-mail-crash-box.  It will give the same
     message.

So changing the command line to make sure all gnusy like stuff is
loaded by saying -f gnus before -f gnus-agent-batch:
 emacs -q -no-site-file -batch \
  -eval '(setq gnus-init-file "/tmp/my_gnus_init.el")' 
  -f gnus -f gnus-agent-batch

And deleting .emacs-mail-crash-box, removing Mail/mail/misc and
removing the reference to it in .newsrc.eld. Produces a different kind
of error:
(Also note that the init file can be evalled with no errors)

 $ emacs -q -no-site-file -batch \
> -eval '(setq gnus-init-file "/tmp/my_gnus_init.el")' \
>  -f gnus  -f gnus-agent-batch
Reading /home/reader/.newsrc-enews.newsguy.com.eld...
Reading active file from enews.newsguy.com via nntp...
Generating the cache active file...
Generating the cache active file...done
No new newsgroups
Checking new news...
Opening nntp server on nntp.perl.org...
Opening nndir server on /anex/mail.bk...
Opening nndir server on /home/reader/Mail/prinb...
Opening nndraft server...
Opening nntp server on news.gmane.org...
Opening nntp server on news.easysw.com...
Opening nntp server on news.gmane.org...
Opening nntp server on news.west.cox.net...
Opening nntp server on news.gmane.org...
Opening nntp server on news.west.cox.net...
Opening nndir server on /tmp/mns...
Opening nndir server on /tmp/mns1...
Checking new news...done
Opening nntp server on enews.newsguy.com...
Reading active file from enews.newsguy.com via nntp...
Checking new news...
Opening nntp server on nntp.perl.org...
Opening nndir server on /anex/mail.bk...
Opening nndir server on /home/reader/Mail/prinb...
Opening nntp server on news.gmane.org...
Opening nntp server on news.easysw.com...
Opening nntp server on news.gmane.org...
Opening nntp server on news.west.cox.net...
Opening nntp server on news.gmane.org...
Opening nntp server on news.west.cox.net...
Opening nndir server on /tmp/mns...
Opening nndir server on /tmp/mns1...
Checking new news...done
Error ((wrong-type-argument number-or-marker-p nil)).  Continue? (y or n) y
Error ((wrong-type-argument number-or-marker-p nil)).  Continue? (y or n) Please answer y or n.  Error ((wrong-type-argument number-or-marker-p nil)).  Continue? (y or n) y
Finished fetching articles into the Gnus agent


[-- Attachment #2: init file --]
[-- Type: text/plain, Size: 1119 bytes --]

(add-to-list 'load-path  "/usr/local/gnus/lisp")
 (setq mail-user-agent 'gnus-user-agent)
(setq  max-lisp-eval-depth 2000)
(setq message-syntax-checks
      '((sender . disabled)))
(defun message-make-fqdn ()
  "My  hacked message-id."
  "newsguy.com")
(setq gnus-expert-user t)
(setq gnus-agent-short-article 50)
(setq gnus-use-adaptive-scoring nil)
(setq mail-sources
           '((file :path "/var/spool/mail/reader")
             (directory :path "/home/reader/spool/"    :suffix ".in")))
      (setq gnus-extra-headers
            '(To Newsgroups Keywords ))
      (setq nnmail-extra-headers gnus-extra-headers)
           (setq gnus-ignored-from-addresses
            "Harry Putnam")
(setq message-user-organization "Still searching...")
(setq gnus-select-method '(nntp "enews.newsguy.com"))
(setq user-mail-address "reader@newsguy.com")
(setq gnus-check-new-newsgroups 'ask-server)
(setq gnus-agent-handle-level 3)
(setq gnus-activate-foreign-newsgroups 3)
(setq mail-source-delete-incoming t)
(setq gnus-use-long-file-name  t)
(setq nnmail-crosspost nil)
(setq gnus-secondary-select-methods
      '((nnml "")))

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to make gnus read something besides .gnus in batch mode
  2003-07-01  0:15 ` Harry Putnam
@ 2003-07-01 14:17   ` Harry Putnam
  0 siblings, 0 replies; 10+ messages in thread
From: Harry Putnam @ 2003-07-01 14:17 UTC (permalink / raw)


Harry Putnam <reader@newsguy.com> writes:

> Even with the kind help I've gotten on this, I'm still having
> problems with it.  I think the general mechanism is sound but have
> trouble figuring out why it fails, or partially fails.

It turned out to be a timing problem.  Gnus was getting invoked
before it knew which `gnus/lisp' to use and reverting to 5.9.0.

I found by loading this code a little sooner before gnus is called:
 (add-to-list 'load-path  "/usr/local/gnus/lisp")
     (setq gnus-init-file "/tmp/my_gnus_init.el") 

Fixed it all up.  Seems quite logical now but wasn't apparent what
was happening until I put this:

  (message gnus-version) 
in the single init file.

One final problem remains:

With this batch command running from cron:
emacs -q -no-site-file -batch -l $my_gnus_el \
 -f gnus-agent-batch

And the first few lines of $my_gnus.el:

  (add-to-list 'load-path  "/usr/local/gnus/lisp")
  (setq gnus-init-file "/tmp/my_gnus_init.el") 
  (load-library "gnus")
  (message gnus-version)
  [...]

With that command line.. and init file, the code actually gets loaded
twice, but doesn't seem to hurt anything.  And the right targets are
known in time.

The remaining promblem is that if I have closed gnus down for a time
and this batch job is run in the meantime.  When I start gnus, it
finds a dribble file and asks if it should load that. 

I'm pretty sure there is a line of code that will cause the batch job
to save everthing so that won't happen, but not sure what it would be.




^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2003-07-01 14:17 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-29 17:24 How to make gnus read something besides .gnus in batch mode Harry Putnam
2003-06-29 20:47 ` Harry Putnam
2003-06-30  4:32   ` John Paul Wallington
2003-06-30  6:25     ` Harry Putnam
2003-06-30  7:01       ` John Paul Wallington
2003-06-30 15:07         ` Harry Putnam
2003-06-30 17:06           ` John Paul Wallington
2003-06-29 21:22 ` lawrence mitchell
2003-07-01  0:15 ` Harry Putnam
2003-07-01 14:17   ` Harry Putnam

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).