all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to
@ 2009-10-10 18:33 Decebal
  2009-10-10 20:06 ` Andreas Röhler
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Decebal @ 2009-10-10 18:33 UTC (permalink / raw)
  To: help-gnu-emacs

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.


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

* Re: How to
  2009-10-10 18:33 How to Decebal
@ 2009-10-10 20:06 ` Andreas Röhler
  2009-10-10 20:55 ` How to [write sequentially numbered lines] Vassil Nikolov
       [not found] ` <mailman.8511.1255205222.2239.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 8+ messages in thread
From: Andreas Röhler @ 2009-10-10 20:06 UTC (permalink / raw)
  To: Decebal; +Cc: help-gnu-emacs

Decebal wrote:
> 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...

it's in files.el, save-buffer, AFAIS


    (if (and modp (buffer-file-name))
	(message "Saving file %s..." (buffer-file-name)))

commenting out these lines should cancel the message

HTH

Andreas

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





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

* Re: How to [write sequentially numbered lines]
  2009-10-10 18:33 How to Decebal
  2009-10-10 20:06 ` Andreas Röhler
@ 2009-10-10 20:55 ` Vassil Nikolov
  2009-10-10 21:20   ` Decebal
       [not found] ` <mailman.8511.1255205222.2239.help-gnu-emacs@gnu.org>
  2 siblings, 1 reply; 8+ messages in thread
From: Vassil Nikolov @ 2009-10-10 20:55 UTC (permalink / raw)
  To: help-gnu-emacs


On Sat, 10 Oct 2009 11:33:17 -0700 (PDT), Decebal <cldwesterhof@gmail.com> said:
> ...
>       local i
>       local length=${#1}
>       for i in $(seq ${1}) ; do
>         printf "       Regel %${length}d voor de test\n" ${i}
>       done  >${2}

  translates to

    emacs -Q -batch -eval '
      (dotimes (i '"${1}"')
        (princ (format "       Regel %'"${#1}"'d voor de test\n" (1+ i))))
    ' > "${2}"

  ---Vassil.



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

* Re: How to
       [not found] ` <mailman.8511.1255205222.2239.help-gnu-emacs@gnu.org>
@ 2009-10-10 20:57   ` Decebal
  2009-10-11  1:41     ` Decebal
  0 siblings, 1 reply; 8+ messages in thread
From: Decebal @ 2009-10-10 20:57 UTC (permalink / raw)
  To: help-gnu-emacs

On Oct 10, 10:06 pm, Andreas Röhler <andreas.roeh...@easy-emacs.de>
wrote:
> > The Emacs batch gives output like:
> >     Saving file /home/cecil/temp/inputEmacs...
>
> it's in files.el, save-buffer, AFAIS
>
>     (if (and modp (buffer-file-name))
>         (message "Saving file %s..." (buffer-file-name)))
>
> commenting out these lines should cancel the message

The problem with that is that it only works for me. But I found a way.
I replaced:
    (write-file output-file))
with:
    (set-visited-file-name output-file)
    (basic-save-buffer))

But maybe there should be more consideration for the possibility that
Emacs is used as a batch program.


> >     Wrote /home/cecil/temp/inputEmacs

I still have to find something for this.


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

* Re: How to [write sequentially numbered lines]
  2009-10-10 20:55 ` How to [write sequentially numbered lines] Vassil Nikolov
@ 2009-10-10 21:20   ` Decebal
  0 siblings, 0 replies; 8+ messages in thread
From: Decebal @ 2009-10-10 21:20 UTC (permalink / raw)
  To: help-gnu-emacs

On Oct 10, 10:55 pm, Vassil Nikolov <vniko...@pobox.com> wrote:
> >       local i
> >       local length=${#1}
> >       for i in $(seq ${1}) ; do
> >         printf "       Regel %${length}d voor de test\n" ${i}
> >       done  >${2}
>
>   translates to
>
>     emacs -Q -batch -eval '
>       (dotimes (i '"${1}"')
>         (princ (format "       Regel %'"${#1}"'d voor de test\n" (1+ i))))
>     ' > "${2}"

That works like a charm. Now it takes 19 seconds. More as 3 times as
fast as my version and more as 15 times as fast as the Bash version.

Thanks.


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

* Re: How to
  2009-10-10 20:57   ` How to Decebal
@ 2009-10-11  1:41     ` Decebal
  2009-10-11  8:11       ` Andreas Röhler
       [not found]       ` <mailman.8527.1255248737.2239.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 8+ messages in thread
From: Decebal @ 2009-10-11  1:41 UTC (permalink / raw)
  To: help-gnu-emacs

On Oct 10, 10:57 pm, Decebal <cldwester...@gmail.com> wrote:
> > >     Wrote /home/cecil/temp/inputEmacs
>
> I still have to find something for this.

That is not possible I am afraid. In the C-source there is a call to
message_with_string.


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

* Re: How to
  2009-10-11  1:41     ` Decebal
@ 2009-10-11  8:11       ` Andreas Röhler
       [not found]       ` <mailman.8527.1255248737.2239.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 8+ messages in thread
From: Andreas Röhler @ 2009-10-11  8:11 UTC (permalink / raw)
  To: Decebal; +Cc: help-gnu-emacs

Decebal wrote:
> On Oct 10, 10:57 pm, Decebal <cldwester...@gmail.com> wrote:
>>>>     Wrote /home/cecil/temp/inputEmacs
>> I still have to find something for this.
> 
> That is not possible I am afraid. In the C-source there is a call to
> message_with_string.
> 


AFAIS it's that piece of code in files.el

    message_with_string ((INTEGERP (append)
			  ? "Updated %s"
			  : ! NILP (append)
			  ? "Added to %s"
			  : "Wrote %s"),
			 visit_file, 1);

Looks like a twofold "if", where the second "else"
should not be executed in your case.

Should be possible to add an option "--quiet" to batch
mode, thus suppressing these messages.

If it's that urgend for you, deleting the second "else"
and recompile might be an option to for the moment.


Andreas

--
https://code.launchpad.net/s-x-emacs-werkstatt/
http://bazaar.launchpad.net/~a-roehler/python-mode/python-mode.el/





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

* Re: How to
       [not found]       ` <mailman.8527.1255248737.2239.help-gnu-emacs@gnu.org>
@ 2009-10-11 16:20         ` Decebal
  0 siblings, 0 replies; 8+ messages in thread
From: Decebal @ 2009-10-11 16:20 UTC (permalink / raw)
  To: help-gnu-emacs

On Oct 11, 10:11 am, Andreas Röhler <andreas.roeh...@easy-emacs.de>
wrote:
> Decebal wrote:
> > On Oct 10, 10:57 pm, Decebal <cldwester...@gmail.com> wrote:
> >>>>     Wrote /home/cecil/temp/inputEmacs
> >> I still have to find something for this.
>
> > That is not possible I am afraid. In the C-source there is a call to
> > message_with_string.
>
> AFAIS it's that piece of code in files.el
>
>     message_with_string ((INTEGERP (append)
>                           ? "Updated %s"
>                           : ! NILP (append)
>                           ? "Added to %s"
>                           : "Wrote %s"),
>                          visit_file, 1);
>
> Looks like a twofold "if", where the second "else"
> should not be executed in your case.
>
> Should be possible to add an option "--quiet" to batch
> mode, thus suppressing these messages.

'emacs --quiet' is possible, but 'emacs --quiet -batch' or 'emacs -
batch --quiet' gives:
    Unknown option `--quiet'


> If it's that urgend for you, deleting the second "else"
> and recompile might be an option to for the moment.

I'll prefer the redirect to /dev/null. Otherwise the code only runs on
my system.


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

end of thread, other threads:[~2009-10-11 16:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-10 18:33 How to Decebal
2009-10-10 20:06 ` Andreas Röhler
2009-10-10 20:55 ` How to [write sequentially numbered lines] Vassil Nikolov
2009-10-10 21:20   ` Decebal
     [not found] ` <mailman.8511.1255205222.2239.help-gnu-emacs@gnu.org>
2009-10-10 20:57   ` How to Decebal
2009-10-11  1:41     ` Decebal
2009-10-11  8:11       ` Andreas Röhler
     [not found]       ` <mailman.8527.1255248737.2239.help-gnu-emacs@gnu.org>
2009-10-11 16:20         ` Decebal

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.