emacs-devel
[Top][All Lists]
Advanced

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

read-buffer-function exists, read-file-name-function doesn't


From: Kim F. Storm
Subject: read-buffer-function exists, read-file-name-function doesn't
Date: 19 May 2002 01:13:34 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2.50

Since we allow lisp code to override the built-in read-buffer
function by setting read-buffer-function, I was wondering why
there is no equivalent read-file-name-function variable to
override read-file-name.  

One use would be for ido users who want reading of any file name in
the ido way; they could just set read-file-name-function to
ido-read-file-name.

The following patch to Fread_file_name implements this.

It makes the call to the read-file-name-function after it has
done all the initial processing of the various arguments, so
the called function doesn't need to do those things.

Any objections to committing this patch?


Index: fileio.c
===================================================================
RCS file: /cvs/emacs/src/fileio.c,v
retrieving revision 1.443
diff -c -r1.443 fileio.c
*** fileio.c    13 Apr 2002 17:49:28 -0000      1.443
--- fileio.c    18 May 2002 22:05:09 -0000
***************
*** 199,204 ****
--- 199,207 ----
  /* File name in which we write a list of all our auto save files.  */
  Lisp_Object Vauto_save_list_file_name;
  
+ /* Function to call to read a file name.  */
+ Lisp_Object Vread_file_name_function; 
+ 
  /* Nonzero means, when reading a filename in the minibuffer,
   start out by inserting the default directory into the minibuffer. */
  int insert_default_directory;
***************
*** 5993,5998 ****
--- 5997,6016 ----
    else
      insdef = Qnil;
  
+   if (!NILP (Vread_file_name_function))
+     {
+       Lisp_Object args[6];
+ 
+       GCPRO2 (insdef, default_filename);
+       args[0] = Vread_file_name_function;
+       args[1] = prompt;
+       args[2] = dir;
+       args[3] = default_filename;
+       args[4] = mustmatch;
+       args[5] = initial;
+       RETURN_UNGCPRO (Ffuncall (6, args));
+     }
+ 
    count = specpdl_ptr - specpdl;
  #ifdef VMS
    specbind (intern ("completion-ignore-case"), Qt);
***************
*** 6222,6227 ****
--- 6241,6250 ----
               Fcons (Qfile_error, Fcons (Qerror, Qnil))));
    Fput (Qfile_date_error, Qerror_message,
        build_string ("Cannot set file date"));
+ 
+   DEFVAR_LISP ("read-file-name-function", &Vread_file_name_function,
+              doc: /* If this is non-nil, `read-file-name' does its work by 
calling this function.  */);
+   Vread_file_name_function = Qnil;
  
    DEFVAR_BOOL ("insert-default-directory", &insert_default_directory,
               doc: /* *Non-nil means when reading a filename start with 
default dir in minibuffer.  */);

-- 
Kim F. Storm <address@hidden> http://www.cua.dk




reply via email to

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