The use of fset makes this rather ugly.

If the idea is to put a function onto minibuffer-setup-hook just to
execute once, I see no reason to bind anything.  Just add the function
and design it to remove itself when run.  For safety's sake,
use an unwind-protect to remove the function from the list
in the case where an error prevented it from being run.
So how about this?

(defun find-file-read-args (prompt mustmatch)
  (list (let ((find-file-default
               (and buffer-file-name
                    (abbreviate-file-name buffer-file-name)))
              (find-file-read-args-hook-fn
               (lambda ()
                 ;; Clear out this hook so it does not interfere
                 ;; with any recursive minibuffer usage.
                 (remove-hook 'minibuffer-setup-hook
                              find-file-read-args-hook-fn)
                 (setq minibuffer-default find-file-default))))
          (unwind-protect
              (progn
                (add-hook 'minibuffer-setup-hook 
                          find-file-read-args-hook-fn)
                (read-file-name prompt nil default-directory mustmatch))
            (remove-hook 'minibuffer-setup-hook
                         find-file-read-args-hook-fn)))
        t))

Meanwhile, do you understand what the purpose of this function is?
Is this what arranges to make M-n bring in the default file name?


_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

Reply via email to