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

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

Re: help editing huge files in emacs


From: Mathias Dahl
Subject: Re: help editing huge files in emacs
Date: Wed, 15 Mar 2006 17:16:27 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (windows-nt)

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> `insert-file-contents' takes two integer parameters BEG and END to allow
> getting only part of a file into a buffer.  The corresponding `write-region'
> takes an APPEND parameter which can be an integer indicating at which
> position in the file the text should be written.
>
> With those two elisp functions, you can read&write parts of files, so you
> can do what you want.  But it requires some coding on top of that to make it
> really usable (probably some kind of special major or minor mode, or maybe
> a file-name-handler) and I don't know of any package that does that.

Interesting idea! But it would only work in the situations where you
wanted the edited text (the text you inserted into emacs and edited
there) to be written at position X in the original file and could not
be used (easily) to overwrite the data that was originally extracted
with `insert-file-contents'. Right?

The above might be confusing, so I'll give an example. Say I have this
really huge file :)

-- huge file --
line 1
line 2
line 3
line 4
line 5
line 6
-- end --

We extract line 3 to 5 into Emacs:

-- emacs buffer --
line 3
line 4
line 5
-- end --

We might change some stuff and add stuff:

-- emacs buffer --
line 3
line 4 is changed
line 4.1 was added
line 5
-- end --

The result, if I use `write-region' and the `append' with the original
start position (X) as argument, would be:

-- huge file --
line 1
line 2
line 3
line 4 is changed
line 4.1 was added
line 5
line 3
line 4
line 5
line 6
-- end --

It would be cool if it could instead become:

-- huge file --
line 1
line 2
line 3
line 4 is changed
line 4.1 was added
line 5
line 6
-- end --

Possible?

Note: I have no need of doing this but I find it interesting
nevertheless.

/Mathias


reply via email to

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