all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Mathias Dahl <brakjoller@gmail.com>
Subject: Re: help editing huge files in emacs
Date: Wed, 15 Mar 2006 17:16:27 +0100	[thread overview]
Message-ID: <ulkvbptt0.fsf@gmail.com> (raw)
In-Reply-To: 87hd605jlx.fsf-monnier+gnu.emacs.help@gnu.org

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	other threads:[~2006-03-15 16:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.44.1142401192.9686.help-gnu-emacs@gnu.org>
2006-03-15  6:09 ` help editing huge files in emacs Stefan Monnier
2006-03-15 16:16   ` Mathias Dahl [this message]
2006-03-17 11:50   ` Eli Zaretskii
     [not found]   ` <mailman.9.1142596212.3794.help-gnu-emacs@gnu.org>
2006-03-21 16:27     ` Stefan Monnier
2006-03-14 19:10 Jesús Velazquez
2006-03-15 16:03 ` Kevin Rodgers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ulkvbptt0.fsf@gmail.com \
    --to=brakjoller@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.