unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: read-buffer-function exists, read-file-name-function doesn't
  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 19:40 ` Richard Stallman
  2 siblings, 0 replies; 5+ messages in thread
From: Stefan Monnier @ 2002-05-18 22:38 UTC (permalink / raw)
  Cc: emacs-devel

> 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.

Maybe because you can simply redefine read-file-name-internal ?
Admittedly, it's not quite the same (it only influences the
completion behavior), but it works 100% in the sense that this
function is never directly called from C.


	Stefan

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

* 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

* Re: read-buffer-function exists, read-file-name-function doesn't
  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
  2 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2002-05-19  5:38 UTC (permalink / raw)
  Cc: emacs-devel


On 19 May 2002 storm@cua.dk wrote:

> +       RETURN_UNGCPRO (Ffuncall (6, args));

Why not use call6 instead?

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

* Re: read-buffer-function exists, read-file-name-function doesn't
  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 19:40 ` Richard Stallman
  2 siblings, 0 replies; 5+ messages in thread
From: Richard Stallman @ 2002-05-19 19:40 UTC (permalink / raw)
  Cc: emacs-devel

This seems like a good idea, for the sake of enabling and disabling
ido cleanly.  Please install it.

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

* Re: read-buffer-function exists, read-file-name-function doesn't
  2002-05-19  5:38 ` Eli Zaretskii
@ 2002-05-19 22:24   ` Kim F. Storm
  0 siblings, 0 replies; 5+ messages in thread
From: Kim F. Storm @ 2002-05-19 22:24 UTC (permalink / raw)
  Cc: emacs-devel

Eli Zaretskii <eliz@is.elta.co.il> writes:

> On 19 May 2002 storm@cua.dk wrote:
> 
> > +       RETURN_UNGCPRO (Ffuncall (6, args));
> 
> Why not use call6 instead?

Actually, the code I wrote also included the READ-DIR argument
I proposed, so I actually needed 7 arguments -- and there is
no call7.

The consensus now seems that we want something more generic than
READ-DIR, so I'll work on that...

-- 
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).