* Disable undo in batch mode
@ 2009-10-11 1:49 Decebal
2009-10-11 3:18 ` Vassil Nikolov
2009-10-11 10:14 ` Xah Lee
0 siblings, 2 replies; 6+ messages in thread
From: Decebal @ 2009-10-11 1:49 UTC (permalink / raw)
To: help-gnu-emacs
I am doing a lot of work on a big buffer (65 MB). I understood that
there is a possibility to disable the undo functionality. Something
that is not used in batch-mode. So this could give a performance
boost.
How can I disable undo?
Are there other things that could be usefull performance wise?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Disable undo in batch mode
2009-10-11 1:49 Disable undo in batch mode Decebal
@ 2009-10-11 3:18 ` Vassil Nikolov
2009-10-11 12:51 ` Decebal
2009-10-11 10:14 ` Xah Lee
1 sibling, 1 reply; 6+ messages in thread
From: Vassil Nikolov @ 2009-10-11 3:18 UTC (permalink / raw)
To: help-gnu-emacs
On Sat, 10 Oct 2009 18:49:35 -0700 (PDT), Decebal <cldwesterhof@gmail.com> said:
> ...
> How can I disable undo?
Does the apropos command (for "undo") help you find out?
---Vassil.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Disable undo in batch mode
2009-10-11 1:49 Disable undo in batch mode Decebal
2009-10-11 3:18 ` Vassil Nikolov
@ 2009-10-11 10:14 ` Xah Lee
2009-10-11 14:22 ` Decebal
1 sibling, 1 reply; 6+ messages in thread
From: Xah Lee @ 2009-10-11 10:14 UTC (permalink / raw)
To: help-gnu-emacs
On Oct 10, 6:49 pm, Decebal <cldwester...@gmail.com> wrote:
> I am doing a lot of work on a big buffer (65 MB). I understood that
> there is a possibility to disable the undo functionality. Something
> that is not used in batch-mode. So this could give a performance
> boost.
> How can I disable undo?
> Are there other things that could be usefull performance wise?
buffer-disable-undo
you find it by calling “elisp-index-search” with search word “undo”.
for batch processing, you want to disable undo, also turn off syntax
coloring, possibly turn off auto save, auto back up, auto major mode
selection, ...etc.
best do it with temp buffer
e.g.
(defun my-process-file (fpath)
"Process the file at path FPATH ..."
(let ()
;; create temp buffer without undo record.
;; first space in temp buff name is necessary
(set-buffer (get-buffer-create " myTemp"))
(insert-file-contents fpath nil nil nil t)
;; process it ...
;; (goto-char 0) ; move to begining of file's content
;; ...
;; (write-file fpath) ;; write back to the file
(kill-buffer " myTemp")))
or use with-temp-buffer or with-temp-file.
for more tips on using elisp as a text processing lang like perl,
python, see:
• Text Processing with Emacs Lisp
http://xahlee.org/emacs/elisp_idioms_batch.html
Xah
∑ http://xahlee.org/
☄
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Disable undo in batch mode
2009-10-11 3:18 ` Vassil Nikolov
@ 2009-10-11 12:51 ` Decebal
0 siblings, 0 replies; 6+ messages in thread
From: Decebal @ 2009-10-11 12:51 UTC (permalink / raw)
To: help-gnu-emacs
On Oct 11, 5:18 am, Vassil Nikolov <vniko...@pobox.com> wrote:
> > How can I disable undo?
>
> Does the apropos command (for "undo") help you find out?
Yes, quit logical: buffer-disable-undo.
It went from 36 seconds to 24 seconds. So it was worth it.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Disable undo in batch mode
2009-10-11 10:14 ` Xah Lee
@ 2009-10-11 14:22 ` Decebal
2009-10-13 17:05 ` Xah Lee
0 siblings, 1 reply; 6+ messages in thread
From: Decebal @ 2009-10-11 14:22 UTC (permalink / raw)
To: help-gnu-emacs
On Oct 11, 12:14 pm, Xah Lee <xah...@gmail.com> wrote:
> (defun my-process-file (fpath)
> "Process the file at path FPATH ..."
> (let ()
> ;; create temp buffer without undo record.
> ;; first space in temp buff name is necessary
> (set-buffer (get-buffer-create " myTemp"))
> (insert-file-contents fpath nil nil nil t)
I am afraid that this does not work. When using:
(switch-to-buffer (find-file-noselect input-file t t))
(buffer-disable-undo)
my script takes 24 seconds.
When I change those two lines to:
(set-buffer (get-buffer-create " myTemp"))
(insert-file-contents input-file nil nil nil t)
it takes 592 seconds. About 25 times as long.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Disable undo in batch mode
2009-10-11 14:22 ` Decebal
@ 2009-10-13 17:05 ` Xah Lee
0 siblings, 0 replies; 6+ messages in thread
From: Xah Lee @ 2009-10-13 17:05 UTC (permalink / raw)
To: help-gnu-emacs
On Oct 11, 7:22 am, Decebal <cldwester...@gmail.com> wrote:
> On Oct 11, 12:14 pm,XahLee <xah...@gmail.com> wrote:
>
> > (defun my-process-file (fpath)
> > "Process the file at path FPATH ..."
> > (let ()
> > ;; create temp buffer without undo record.
> > ;; first space in temp buff name is necessary
> > (set-buffer (get-buffer-create " myTemp"))
> > (insert-file-contents fpath nil nil nil t)
>
> I am afraid that this does not work. When using:
> (switch-to-buffer (find-file-noselect input-file t t))
> (buffer-disable-undo)
> my script takes 24 seconds.
> When I change those two lines to:
> (set-buffer (get-buffer-create " myTemp"))
> (insert-file-contents input-file nil nil nil t)
> it takes 592 seconds. About 25 times as long.
am annoyed by your feedback.
you asked for some tips about batch text processing. I gave you quite
a few, including a explicit answer to you question of how to disable
undo, and a explicit method to locate that answer, as well as a full
tutorial on batch text processing.
you shot back by saying a specific code i suggested, that it “does not
work”, in comparsion to a code you have used but have not disclosed
before, nor what exactly what your code is doing, and no mention of
thanks nor whether my other tips was or was not helpful.
What is the purpose of your message?
technically, the entire content of your message is about my code “does
not work”, with a specific timing result in seconds. Huh? Is this
supposed to be a helpful info for me? If so, perhaps you would be more
specific. For example, do some research, and do a conclusive report
on:
why this code:
> (switch-to-buffer (find-file-noselect input-file t t))
> (buffer-disable-undo)
is “25 times” faster than
> (set-buffer (get-buffer-create " myTemp"))
> (insert-file-contents input-file nil nil nil t)
For example, in what condition? why it is so? what tips you might
give, as a choice between these two? and further, i suggested with-
temp-buffer, with-temp-file, have you explored them?
Xah
∑ http://xahlee.org/
☄
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-10-13 17:05 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-11 1:49 Disable undo in batch mode Decebal
2009-10-11 3:18 ` Vassil Nikolov
2009-10-11 12:51 ` Decebal
2009-10-11 10:14 ` Xah Lee
2009-10-11 14:22 ` Decebal
2009-10-13 17:05 ` Xah Lee
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 read-only IMAP folder(s) and NNTP newsgroup(s).