From: Stefan Monnier <monnier@iro.umontreal.ca>
Subject: Re: Reading huge files
Date: Thu, 11 Jan 2007 00:54:57 -0500 [thread overview]
Message-ID: <jwvk5zuglxn.fsf-monnier+gnu.emacs.help@gnu.org> (raw)
In-Reply-To: m2r6u3eq44.fsf@gmail.com
> ;;; vlf.el --- View Large Files
I like that.
> ;; (defun vlf-extract-part-of-file (file from to)
> ;; "Returns bytes in FILE from FROM to TO."
> ;; (let ((size (vlf-file-size file)))
> ;; (if (or (> from size)
> ;; (> to size))
> ;; (error "From or to is larger that the file size"))
> ;; (with-temp-buffer
> ;; (shell-command
> ;; (format "head --bytes %d %s | tail --bytes %d"
> ;; to file (+ (- to from) 1)) t)
> ;; (buffer-substring (point-min) (point-max)))))
You'll indeed need something like that. I'd recommend to use `dd' rather
than `split' or `head&tail'. But note that the problem is bigger than you
think: the above will need to work with floating-point arguments (since
fixnums suffer from the 2^28 limit) and the %d format also suffers from the
2^28 limit (or 2^31 in Emacs-CVS). That's another good reason to use `dd'
since you can use a 1048576 block size and thus divide your large floats by
1048576 before turning them into fixnums.
> (defvar vlf-mode-map (make-sparse-keymap)
> "Keymap for `vlf-mode'.")
> (defun vlf-define-keymap ()
> "Define keymap for `vlf-mode'."
> (define-key vlf-mode-map [next] 'vlf-next)
> (define-key vlf-mode-map [prior] 'vlf-prev)
> (define-key vlf-mode-map "q" 'vlf-quit))
Please just use
(defvar vlf-mode-map
(let ((map (make-sparse-keymap)))
(define-key map [next] 'vlf-next)
(define-key map [prior] 'vlf-prev)
(define-key map "q" 'vlf-quit)
map)
"Keymap for `vlf-mode'.")
Also, wrt features, it'd probably be good to "slide more smoothly":
e.g. always keep 2 or 3 blocks in the buffer at the same time so you can
comfortably look at the text at the boundaries between blocks.
Next step: use window-scroll-functions or jit-lock to detect when reaching
one of the ends so that we can automatically load in the next
consecutive block.
Stefan
next prev parent reply other threads:[~2007-01-11 5:54 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-08 22:17 Reading huge files Leonid Grinberg
2007-01-09 15:24 ` Kevin Rodgers
2007-01-09 22:03 ` Eli Zaretskii
2007-01-11 6:30 ` Kevin Rodgers
[not found] ` <mailman.2957.1168497037.2155.help-gnu-emacs@gnu.org>
2007-01-11 6:55 ` Stefan Monnier
[not found] ` <mailman.2912.1168380222.2155.help-gnu-emacs@gnu.org>
2007-01-09 23:29 ` Mathias Dahl
2007-01-10 0:14 ` Leonid Grinberg
[not found] ` <mailman.2922.1168388054.2155.help-gnu-emacs@gnu.org>
2007-01-10 0:23 ` Mathias Dahl
2007-01-10 4:11 ` Eli Zaretskii
[not found] ` <mailman.2923.1168402283.2155.help-gnu-emacs@gnu.org>
2007-01-10 7:39 ` Mathias Dahl
2007-01-10 20:27 ` Eli Zaretskii
[not found] ` <mailman.2938.1168460877.2155.help-gnu-emacs@gnu.org>
2007-01-10 22:33 ` Giorgos Keramidas
2007-01-11 5:54 ` Stefan Monnier [this message]
2007-01-11 9:49 ` Mathias Dahl
2007-01-11 18:06 ` Markus Triska
2007-01-12 8:36 ` Mathias Dahl
[not found] ` <mailman.2897.1168356311.2155.help-gnu-emacs@gnu.org>
2007-01-09 20:42 ` Andreas Roehler
2007-01-09 20:42 ` Andreas Roehler
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=jwvk5zuglxn.fsf-monnier+gnu.emacs.help@gnu.org \
--to=monnier@iro.umontreal.ca \
/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.
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).