help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to


From: Decebal
Subject: How to
Date: Sat, 10 Oct 2009 11:33:17 -0700 (PDT)
User-agent: G2/1.0

In a Bash script I changed:
      local i
      local length=${#1}

      for i in $(seq ${1}) ; do
        printf "       Regel %${length}d voor de test\n" ${i}
      done  >${2}
to:
      emacs -batch -nw --eval='
        (let (
              (i)
              (nr-of-lines '${1}')
              (nr-of-lines-length)
              (output-file "'"${2}"'"))
          (setq nr-of-lines-length (length (number-to-string nr-of-
lines)))
          (dotimes (i nr-of-lines t)
           (insert (format (format "       Regel %%%dd voor de test\n"
nr-of-lines-length) (1+ i))))
          (write-file output-file))
      ' 2>/dev/null

The Bash version took 293 seconds and the Emacs Lisp version 59
seconds. So it is about 5 times as fast.
The Emacs batch gives output like:
    Saving file /home/cecil/temp/inputEmacs...
    Wrote /home/cecil/temp/inputEmacs
That is why I use the 2>/dev/null.
Is there a way to circumvent the generation of the above output?
Because when there is an error it is also thrown away and that is not
nice.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]