Re: Lisp Questions - reading a file and processes stalling

From:

Jeff Clough

Subject:

Re: Lisp Questions - reading a file and processes stalling

Date:

Tue, 04 May 2010 15:43:06 -0000

User-agent:

Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

address@hidden (Pascal J. Bourguignon) writes:
> insert-file-contents is really the lightest weight of getting the
> content of a file into a buffer. Why do you doubt it?
When I step through my function with the debugger I see
insert-file-contents doing a lot of work. I haven't counted, but
there's at least a dozen calls going on and that overhead
seems...excessive. For instance, I can see it trying to match file
extensions in several batches, I assume as an attempt to determine the
correct mode for the buffer.
I can't seem to find a way of telling Emacs to put the contents of the
file in a buffer then move along.
> Otherwise you may like find-file-literally, but it does more work.
Interesting, and I see the related function
insert-file-contents-literally. I'll take a look at it, but the
statement "it does more work" probably means it's not going to be much
different.
> Openning thousands of files will be slow anyways.
>
> The standard solution is to build an index with the data you need, so
> that you can just open one index file.
Yeah, that's what I'm doing now. Realistically, it's unlikely that I'll
ever have to process the entire set of files more than once (to generate
the index), and can just process additions as they come.
I'm just poking at the code, trying to figure out both what's going on
under the hood and how to do things better.
>> Second, I have Emacs running an external program as a process. When
>> some other lengthy operation is happening elsewhere in Emacs (like Gnus
>> is trying to display the headers for a group*), that process stalls,
>> then picks up where it left off once the operation is done. Is there
>> any way to make Emacs not steal the resources from this process, or am I
>> doing something hopelessly wrong?
>
> No, there's no way. GNU emacs is not multi-threaded.
>
> My solution is to run ERC and GNUS each in its own instance of emacs.
Yeah, I didn't think so but it was worth asking the gurus. I'll
probably just deal with it since I'm generally happier with just one
instance of emacs. For now, at least.
Thanks!
Jeff