[comp.emacs] File insertion in a batch mode.

saito@sdrvx2.sinet.slb.com (Naoki Saito, ISD-002, 203-431-5534) (03/09/91)

Dear, GNU emacs gurus,

I would like to use emacs with a batch mode.  And what I would like to do is
as follows:

(1) Find a specific word in the input file.
(2) Delete from the top to that word.
(3) Insert another file over there.
(3) Save that file.

I thought it's simple.  So I wrote the following function and executed

$ emacs input.txt -batch -l ins -f ins -kill

But it didn't work.


;;;
;;; ins.el: Insert specific file after the word "Key"
;;;
(defun ins ()
  "Delete the top portion of the file to the key and replace by ok.txt."
  (interactive)
  (search-forward "Key")
  (beginning-of-line)
  (next-line)
  (kill-region)
  (insert-file "ok.txt")
  (save-buffer))


I don't know much about the Emacs lisp.  I would appreciate if you could
help me to do this kind of simple task.  Also I would like to hear whether
it's better to do the alternative way without using emacs.


Thanks in advance,

Naoki Saito (saito@sdr.slb.com)
Schlumberger-Doll Research