unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Ted Zlatanov <tzz@lifelogs.com>
To: emacs-devel@gnu.org
Subject: Re: map-file-lines
Date: Tue, 03 Feb 2009 07:57:47 -0600	[thread overview]
Message-ID: <864ozb7hd0.fsf@lifelogs.com> (raw)
In-Reply-To: jwvbptkwjf5.fsf-monnier+emacs@gnu.org

On Mon, 02 Feb 2009 17:42:31 -0500 Stefan Monnier <monnier@iro.umontreal.ca> wrote: 

SM> How would you use map-file-lines to implement the "large file viewing
SM> and searching"?
...
SM> I know about the large-file problem, obviously, but I wonder what kind
SM> of UI you expect to provide, in order for it to be able to work just one
SM> line at a time.
...
SM> I don't se how such a "line-at-a-time" or "chunk-at-a-time" processing
SM> (i.e. stream processing) will enable Emacs to let you conveniently edit
SM> a large binary file.
...
SM> OK, that's indeed how I imagine it as well, but I fail to see how this
SM> relates to map-file-lines.  All you need for that is to use the BEG and
SM> END args of insert-file-contents (and maybe also to extend those args
SM> so they can be floats, in case Emacs's ints are too limited).

On Tue, 03 Feb 2009 08:27:01 +0100 joakim@verona.se wrote: 

j> That being said, how would the insert-file-contents solution work in
j> practice? Has something been done along these lines already? Would it be
j> possible to make some kind of generic solution that would make for
j> instance hexl mode work on large files?

I tried to condense the various messages into one reply.

map-file-lines as it stands is just a stream processor, and not useful
to *view* a large file.  Unfortunately Emacs does almost everything in
the buffer, so true large-file view and edit requires core-level work to
make the buffer able to address the whole file.  In addition, almost
every Emacs package assumes that the buffer is small and can be scanned
quickly; imagine how slow it will be to open and edit a 20GB gzipped
file.

map-file-lines was much easier to implement, and (just like
`grep' and many other utilities) can be useful on its own despite the
single-line limitations.

So to answer your and Joakim's questions, based on what I know so far,
the best approach is to have a special narrowing mode to view large
files.  It won't use map-file-lines, but like it, it will fetch the next
chunk only when needed.  It needs to be special because the normal
narrow/widen calls should not widen to the whole file.  It's best, in
fact, if the decision to move the "window" into the file back and forth
is only left to the user and to special motion commands, and normal
packages can not move that window.

Writing inserted text, in particular, is very slow with large files.  A
binary editor is not so hard to implement, but inserting text may need
special permission (like the motion commands above) to make the user
experience bearable.

Ted





  reply	other threads:[~2009-02-03 13:57 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-02 17:20 map-file-lines Ted Zlatanov
2009-02-02 18:54 ` map-file-lines Stefan Monnier
2009-02-02 19:22   ` map-file-lines Ted Zlatanov
2009-02-02 19:52     ` map-file-lines joakim
2009-02-02 20:54       ` map-file-lines Ted Zlatanov
2009-02-02 22:42         ` map-file-lines Stefan Monnier
2009-02-03 13:57           ` Ted Zlatanov [this message]
2009-02-02 22:41       ` map-file-lines Stefan Monnier
2009-02-02 23:59         ` map-file-lines joakim
2009-02-03  4:13           ` map-file-lines Stefan Monnier
2009-02-03  7:27             ` map-file-lines joakim
2009-02-03 14:50               ` map-file-lines Stefan Monnier
2009-02-04  7:04                 ` map-file-lines Richard M Stallman
2009-02-04 15:38                   ` map-file-lines Ted Zlatanov
2009-02-05  5:40                     ` map-file-lines Richard M Stallman
2009-02-06 18:42                       ` view/edit large files (was: map-file-lines) Ted Zlatanov
2009-02-06 21:06                         ` view/edit large files Ted Zlatanov
2009-02-06 21:49                           ` Miles Bader
     [not found]                             ` <864oz3nyj8.fsf@lifelogs.com>
2009-02-10  1:58                               ` Stefan Monnier
2009-02-10  8:46                                 ` Eli Zaretskii
2009-02-10  9:23                                   ` Miles Bader
2009-02-10  9:54                                     ` Eli Zaretskii
2009-02-10 10:02                                       ` Miles Bader
2009-02-10 11:50                                         ` Eli Zaretskii
2009-02-10 15:08                                           ` Ted Zlatanov
2009-02-17 19:23                                             ` Stefan Monnier
2009-02-17 19:47                                               ` Eli Zaretskii
2009-02-17 20:18                                                 ` Miles Bader
2009-02-17 20:51                                                   ` Eli Zaretskii
2009-02-17 21:19                                                     ` Miles Bader
2009-02-17 21:21                                                       ` Miles Bader
2009-02-18  4:09                                                         ` Eli Zaretskii
2009-02-18  1:56                                                 ` Stefan Monnier
2009-02-20 19:23                                                   ` Ted Zlatanov
2009-02-10 12:28                                     ` Eli Zaretskii
2009-02-10 12:46                                       ` Miles Bader
2009-02-07  9:14                         ` view/edit large files (was: map-file-lines) Richard M Stallman
2009-02-09 20:26                           ` view/edit large files Ted Zlatanov
2009-02-10 20:02                             ` Richard M Stallman
2009-02-06 13:20                 ` map-file-lines Mathias Dahl
2009-02-02 22:40     ` map-file-lines Stefan Monnier
2009-02-03  4:11       ` map-file-lines Stefan Monnier
2009-02-02 20:48 ` map-file-lines Ted Zlatanov
2009-02-03  8:08   ` map-file-lines Thien-Thi Nguyen
2009-02-03 14:00     ` map-file-lines Ted Zlatanov
2009-02-03 14:17       ` map-file-lines Miles Bader
2009-02-03 10:45   ` map-file-lines Thierry Volpiatto
2009-02-03 14:06     ` map-file-lines Ted Zlatanov
2009-02-03 14:56       ` map-file-lines Thierry Volpiatto

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=864ozb7hd0.fsf@lifelogs.com \
    --to=tzz@lifelogs.com \
    --cc=emacs-devel@gnu.org \
    /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 public inbox

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

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