emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

search files with conversion but fundamental mode, no handlers, no file-


From: Drew Adams
Subject: search files with conversion but fundamental mode, no handlers, no file-local vars
Date: Thu, 20 Dec 2012 10:57:19 -0800

Suppose I want to check a set of files for one or more occurrences of a given
string.  I want the files to be code-converted, but not put in any mode other
than fundamental mode, not fontified, not handled by a file handler, and not
using any file-local variables.  Just a simple search of the file text (after
code conversion).

I thought there would be a simple, straightforward way to do this, but I didn't
find it.  A RAW-FILE arg to `find-file-noselect' is out, for instance, since
that bypasses code conversion.

I tried a few things and finally ended up using `find-buffer-visiting' or
`create-file-buffer', followed by `with-current-buffer' with a call to
`mm-insert-file-contents'.

That seems to work, but is there a simpler approach?  Am I missing something
obvious?

I finally found `mm-insert-file-contents' because I was little-by-little ending
up with code that looked like what it in fact does.  It seems to turn off quite
a lot of (unrelated?) things individually, just to get a simple file read-in
plus code conversion.

Is there some other function or macro that acts similarly and that is normally
used for the kind of thing described?

I'm kind of wondering why there is not some parameter combination for
`find-file-noselect' that does the job.  The available choices seem to be
completely raw or completely cooked.

I would think that just checking the content of files, with code conversion but
without also enabling hooks, handlers, modes, file-local variables..., would be
something not too uncommon.

And if `mm-insert-file-contents' is indeed the right approach, it seems a bit
odd that this functionality should be buried in a file that is specific to a
particular area ("utility functions for Mule and low level things") rather than
being in, say, `files.el'.

Anyway, please let me know if there is something better than
`mm-insert-file-contents' for this.  Thx.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]