unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Memory-efficient way of opening large files in Emacs read-only
@ 2022-12-08  2:49 Mikhail Pomaznoy
  2022-12-08 14:13 ` Filipp Gunbin
  2022-12-08 14:27 ` Marcin Borkowski
  0 siblings, 2 replies; 5+ messages in thread
From: Mikhail Pomaznoy @ 2022-12-08  2:49 UTC (permalink / raw)
  To: help-gnu-emacs

Greetings!

In my daily workflows I commonly stumble upon a task of peeking into a 
header of a large (sometimes compressed) file. Those files can commonly 
be gigabytes in compressed form so can't fit into memory. I was 
wondering how can this be done in Emacs to leverage its search and 
navigate capabilities?

In a terminal this task is nicely accomplished with `less`, which loads 
file on demand while you scroll (memory-efficiently) and automatically 
detects at least gzip compression. However I am struggling to do 
something similar in Emacs for quite a long time.  I tried VLF (requires 
manually switching chunks loaded, encountered problems with 
compression), view-file (loads everything in memory), running less in 
Emacs terminals (I prefer outside-Emacs terminals) but for various 
reasons all this solutions are suboptimal and I usually end up with 
using `less`.

Is there something in Emacs I am missing? Is something like this makes 
sense to develop (I consider to write something for Emacs) ? I am using 
Emacs 28 and maybe in Emacs 29 there are novelties related to this issue?

Kind regards,

Mikhail




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Memory-efficient way of opening large files in Emacs read-only
  2022-12-08  2:49 Memory-efficient way of opening large files in Emacs read-only Mikhail Pomaznoy
@ 2022-12-08 14:13 ` Filipp Gunbin
  2022-12-08 14:27 ` Marcin Borkowski
  1 sibling, 0 replies; 5+ messages in thread
From: Filipp Gunbin @ 2022-12-08 14:13 UTC (permalink / raw)
  To: Mikhail Pomaznoy; +Cc: help-gnu-emacs

On 08/12/2022 09:49 +0700, Mikhail Pomaznoy wrote:

> In my daily workflows I commonly stumble upon a task of peeking into a
> header of a large (sometimes compressed) file. Those files can
> commonly be gigabytes in compressed form so can't fit into memory. I
> was wondering how can this be done in Emacs to leverage its search and
> navigate capabilities?
>
> In a terminal this task is nicely accomplished with `less`, which
> loads file on demand while you scroll (memory-efficiently) and
> automatically detects at least gzip compression. However I am
> struggling to do something similar in Emacs for quite a long time.  I
> tried VLF (requires manually switching chunks loaded, encountered
> problems with compression), view-file (loads everything in memory),
> running less in Emacs terminals (I prefer outside-Emacs terminals) but
> for various reasons all this solutions are suboptimal and I usually
> end up with using `less`.
>
> Is there something in Emacs I am missing? Is something like this makes
> sense to develop (I consider to write something for Emacs) ? I am
> using Emacs 28 and maybe in Emacs 29 there are novelties related to
> this issue?

Perhaps the best way is to report vlf bugs and fix them.

Filipp



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Memory-efficient way of opening large files in Emacs read-only
  2022-12-08  2:49 Memory-efficient way of opening large files in Emacs read-only Mikhail Pomaznoy
  2022-12-08 14:13 ` Filipp Gunbin
@ 2022-12-08 14:27 ` Marcin Borkowski
  2022-12-09  3:03   ` Mikhail Pomaznoy
  1 sibling, 1 reply; 5+ messages in thread
From: Marcin Borkowski @ 2022-12-08 14:27 UTC (permalink / raw)
  To: Mikhail Pomaznoy; +Cc: help-gnu-emacs


On 2022-12-08, at 03:49, Mikhail Pomaznoy <mikpom@mikpom.ru> wrote:

> Greetings!
>
> In my daily workflows I commonly stumble upon a task of peeking into
> a header of a large (sometimes compressed) file. Those files can
> commonly be gigabytes in compressed form so can't fit into
> memory. I was wondering how can this be done in Emacs to leverage its
> search and navigate capabilities?
>
> In a terminal this task is nicely accomplished with `less`, which
> loads file on demand while you scroll (memory-efficiently) and
> automatically detects at least gzip compression. However I am
> struggling to do something similar in Emacs for quite a long time.
> I tried VLF (requires manually switching chunks loaded, encountered
> problems with compression), view-file (loads everything in memory),
> running less in Emacs terminals (I prefer outside-Emacs terminals) but
> for various reasons all this solutions are suboptimal and I usually
> end up with using `less`.
>
> Is there something in Emacs I am missing? Is something like this makes
> sense to develop (I consider to write something for Emacs) ? I am
> using Emacs 28 and maybe in Emacs 29 there are novelties related to
> this issue?

I have no idea if Emacs has anything like this (I doubt), but the way
I'd go about it would be to either leverage `less' inside one of the
Emacs terminals or write some Elisp, colling to things like `gunzip' and
`head' and then putting the result into some buffer.  (I think you could
even make it so that scrolling down would load the next portion in the
background, à la modern Web.  While I /hate/ this behavior of websites,
here it could actually make sense.)

Best,

-- 
Marcin Borkowski
http://mbork.pl



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Memory-efficient way of opening large files in Emacs read-only
  2022-12-08 14:27 ` Marcin Borkowski
@ 2022-12-09  3:03   ` Mikhail Pomaznoy
  2022-12-09  5:21     ` tomas
  0 siblings, 1 reply; 5+ messages in thread
From: Mikhail Pomaznoy @ 2022-12-09  3:03 UTC (permalink / raw)
  To: Marcin Borkowski; +Cc: help-gnu-emacs, fgunbin

Thanks for your replies. Seamless less-like viewing in Emacs (not 
terminals of any kind) is my ultimate goal and I will look into that per 
Marcin'c suggestion. If it will turn out not fun (too difficult), 
further investment into VLF makes total sense.

Thanks,

-Mikhail

On 12/8/22 21:27, Marcin Borkowski wrote:
> On 2022-12-08, at 03:49, Mikhail Pomaznoy <mikpom@mikpom.ru> wrote:
>
>> Greetings!
>>
>> In my daily workflows I commonly stumble upon a task of peeking into
>> a header of a large (sometimes compressed) file. Those files can
>> commonly be gigabytes in compressed form so can't fit into
>> memory. I was wondering how can this be done in Emacs to leverage its
>> search and navigate capabilities?
>>
>> In a terminal this task is nicely accomplished with `less`, which
>> loads file on demand while you scroll (memory-efficiently) and
>> automatically detects at least gzip compression. However I am
>> struggling to do something similar in Emacs for quite a long time.
>> I tried VLF (requires manually switching chunks loaded, encountered
>> problems with compression), view-file (loads everything in memory),
>> running less in Emacs terminals (I prefer outside-Emacs terminals) but
>> for various reasons all this solutions are suboptimal and I usually
>> end up with using `less`.
>>
>> Is there something in Emacs I am missing? Is something like this makes
>> sense to develop (I consider to write something for Emacs) ? I am
>> using Emacs 28 and maybe in Emacs 29 there are novelties related to
>> this issue?
> I have no idea if Emacs has anything like this (I doubt), but the way
> I'd go about it would be to either leverage `less' inside one of the
> Emacs terminals or write some Elisp, colling to things like `gunzip' and
> `head' and then putting the result into some buffer.  (I think you could
> even make it so that scrolling down would load the next portion in the
> background, à la modern Web.  While I /hate/ this behavior of websites,
> here it could actually make sense.)
>
> Best,
>



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Memory-efficient way of opening large files in Emacs read-only
  2022-12-09  3:03   ` Mikhail Pomaznoy
@ 2022-12-09  5:21     ` tomas
  0 siblings, 0 replies; 5+ messages in thread
From: tomas @ 2022-12-09  5:21 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1106 bytes --]

On Fri, Dec 09, 2022 at 10:03:15AM +0700, Mikhail Pomaznoy wrote:
> Thanks for your replies. Seamless less-like viewing in Emacs (not terminals
> of any kind) is my ultimate goal and I will look into that per Marcin'c
> suggestion. If it will turn out not fun (too difficult), further investment
> into VLF makes total sense.

The elephant in the room is file coding. Emacs tries to get that right,
so usually it has to transform the whole file into its internal coding
system (which is utf8-ish but can cope with non-UTF8 stuff as well).

Less just punts on the problem and leaves it to your terminal to
cope with the display of funny stuff (apart from filtering things
it thinks might break your display, cf. less's options -r, -R and
friends).

So I guess a good starting point for you would be to play with the
function `insert-file-contents-literally' or its interactive sister
`insert-file-literally', which bypass this.

The interesting part would be how Emacs displays potentially strange
stuff in this "raw" mode, I think.

Good luck and keep us posted :)

Cheers
-- 
t

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-12-09  5:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-08  2:49 Memory-efficient way of opening large files in Emacs read-only Mikhail Pomaznoy
2022-12-08 14:13 ` Filipp Gunbin
2022-12-08 14:27 ` Marcin Borkowski
2022-12-09  3:03   ` Mikhail Pomaznoy
2022-12-09  5:21     ` tomas

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