unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* read-buffer-function exists, read-file-name-function doesn't
@ 2002-05-18 23:13 Kim F. Storm
  2002-05-18 22:38 ` Stefan Monnier
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Kim F. Storm @ 2002-05-18 23:13 UTC (permalink / raw)



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 <storm@cua.dk> http://www.cua.dk

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-05-19 22:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-05-18 23:13 read-buffer-function exists, read-file-name-function doesn't Kim F. Storm
2002-05-18 22:38 ` Stefan Monnier
2002-05-19  5:38 ` Eli Zaretskii
2002-05-19 22:24   ` Kim F. Storm
2002-05-19 19:40 ` Richard Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).