help-gnu-emacs
[Top][All Lists]
Advanced

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

RE: elisp: Text-based file-chooser


From: Drew Adams
Subject: RE: elisp: Text-based file-chooser
Date: Wed, 5 Jan 2011 11:06:59 -0800

> > So I guess you're saying that you do not want (necessarily) 
> > to visit the file, you just want to read a file name.  
> 
> Exactly.
> 
> > But you do not want to use the
> > "GUI file selector", by which I suppose you mean a 
> > file-selection dialog box.  Is that it?
> 
> I want a file-browsing dialog box, but I want it to be text-mode so it
> can be used on a raw terminal or inside an xterm. 

Dunno what such an animal is or how you get it.  By "dialog box" I meant a
graphic dialog box, not available from a terminal.

> Something roughly like dired but that lets the user browse
> files and directories

So far, that sounds like Dired.

> and only returns the path with a selected or entered filename
> and does absolutely nothing else.

In Dired, you have the path in the buffer header.
You can also get the path as a string from variable `default-directory'.

If you are trying to get the absolute name of the file where the cursor is, as a
string, you can use `(dired-get-filename)'.

> I know it's out there because I've seen it before, but I
> just can't find the magic command or plugin.

Well it's not clear to me what you want.  And I'm probably not familiar with the
magic command or plugin anyway.  Perhaps someone else can help you.

> > If all you want is to read a file name without using a 
> > dialog box, then just use `read-file-name' with `use-file-dialog'
> > bound to `t'.
> > (let ((use-file-dialog  t))
> >   (read-file-name ...)...)

(All that does is ensure that you don't get a graphic dialog box.)

> All I get when I do that is a one-line prompt for a filename. It gives
> me completion

Which should show you a list of files that match your input.  With empty input,
TAB TAB should show you all files and subdirs in the directory.

> but I don't get a file list to browse.

You get a file list, but not to browse, depending on what you mean by browse.
You can explore the entire file system from `read-file-name', showing the
contents of any directory, and reading any file name.  I would call that
browsing, but you might not.

> The manual is vague on whether read-file-name even has a text 
> dialog. 

I don't know what a text dialog is, so I wouldn't know if the manual is vague
about it.  If you think it is, consider `M-x report-emacs-bug' to get it cleared
up.

> If it's bringing up a text dialog on some installations then 
> either there's some well-hidden secret to triggering one, or
> read-file-name may be redirecting the request to the function I need via
> read-file-name-function. 

`read-file-name' just reads a file name with completion.  It brings up a graphic
dialog box only in certain situations, and you are anyway not interested in
that.  Other than that it does just what you saw - on all installations (AFAIK).




reply via email to

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