[19.25, efs 1.9] dired-handler-fn

Denis Howe (dbh@doc.ic.ac.uk)
Thu, 14 Jul 94 16:48:50 BST


> Date: Thu, 14 Jul 1994 10:36:00 -0400
> From: "jeff (j.d.) sparkes" <jsparkes@bnr.ca>
>
> Is there a way to stop dired from adding that file-name-handler for
> all files?

I do 

	(eval-after-load "dired" '(progn
	  ... lots of wicked stuff ...
	  (setq file-name-handler-alist '(
	    ;; Remove dired-handler-fn
	    ("^/[^/:]+:" . efs-file-handler-function)
	    ("^/$" . efs-root-handler-function)))
	))

which is OK for a temporary hack except that stubborn old
dired-check-file-name-handler-alist occasionally hooks it back in.  Is
this really necessary?

Sandy says no-one else has complained about dired-handler-fn slowing
down file ops but I found it pretty annoying - eg. find-file went from
being instantaneous to taking about one second on my SPARCstation ELC.
There are a LOT of file ops involved in one find-file (even without
find-file-visit-truename set) and they all call dired-handler-fn,
mostly for nothing.  All those function calls take time.

> What do I lose if I turn it off?

The nice automatic updating of your dired buffers whenever emacs does
anything to a file in one of them.

I think the solution is to allow handlers to be called only for
certain operations.  The files could be specified by regexp as they
are now and the operations could be specified by attaching properties
to the operation's symbol.

find-file-name-handler already gets the operation as an argument (to
see if it currently has any inhibited handlers) so it could proceed as
follows:

	match the filename against each car of file-name-handler-alist

	for each match, look at the cdr (HANDLER)

	if HANDLER has a function value then funcall it as before

	otherwise do (get file-op HANDLER)

	If get returns something then funcall that as the real handler
	else do nothing.

This scheme is good because

* it avoids calling Lisp handler functions which are not interested
in the current operation.

* it doesn't have to search through a long list of operations, just a
short property list.

* it is backward compatible with the old defintion of
file-name-handler-alist.

* it would still be easy to have a handler which handled all
operations, you wouldn't have to add it to every operation's p-list.

Comments?

-- 
Denis Howe <dbh@doc.ic.ac.uk>
Free On-Line Dictionary of Computing
WWW URL http://wombat.doc.ic.ac.uk/