emacs-devel
[Top][All Lists]
Advanced

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

Re: search files with conversion but fundamental mode, no handlers, no f


From: Eli Zaretskii
Subject: Re: search files with conversion but fundamental mode, no handlers, no file-local vars
Date: Thu, 20 Dec 2012 23:35:24 +0200

> From: "Drew Adams" <address@hidden>
> Cc: <address@hidden>
> Date: Thu, 20 Dec 2012 11:42:55 -0800
> 
> > What's wrong with insert-file-contents?
> 
> I'm not sure, now that I try it again!  Thanks for asking.

I think insert-file-contents _is_ the proper way of doing what you
want.  You can see many examples of its usage in Emacs Lisp packages
bundled with Emacs.

> I don't have the C code defining `insert-file-contents', to compare.  but that
> doc string does seem to suggest that, _unlike_ `insert-file-contents', it
> inhibits the use of "`file-name-handlers,..., `find-file-hooks', etc."  I do 
> not
> need/want handlers, hooks, etc. to kick in here.

FWIW, I think most, if not all, things inhibited by
mm-insert-file-contents are either not needed or incorrect.

> (letf* ((format-alist nil)
>          (auto-mode-alist (if inhibit nil (mm-auto-mode-alist)))

auto-mode-alist is not consulted by insert-file-contents, AFAIK.

>          ((default-value 'major-mode) 'fundamental-mode)

Why? to protect from someone who overrides the default?

>          (enable-local-variables nil)

insert-file-contents does not evaluate file-local variables, AFAIK.

>          (after-insert-file-functions nil)

This decodes the file, which you do want.

>          (enable-local-eval nil)

See above.

>          (inhibit-file-name-operation (if inhibit
>                                           'insert-file-contents
>                                         inhibit-file-name-operation))
>          (inhibit-file-name-handlers
>           (if inhibit
>               (append mm-inhibit-file-name-handlers
>                       inhibit-file-name-handlers)
>             inhibit-file-name-handlers))

This is a bug, IMO, at least in the general case: why should any code
like what you wanted to write be prevented from working on remote
files?

>          (ffh (if (boundp 'find-file-hook)
>                   'find-file-hook
>                 'find-file-hooks))
>          (val (symbol-value ffh)))
>     (set ffh nil)

I don't think find-file-hook/hooks is relevant, as you don't invoke
find-file here.



reply via email to

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