From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Larry Kohlman Newsgroups: gmane.emacs.help Subject: Re: elisp: Text-based file-chooser Date: Wed, 05 Jan 2011 16:16:35 -0600 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: dough.gmane.org 1294267253 22228 80.91.229.12 (5 Jan 2011 22:40:53 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 5 Jan 2011 22:40:53 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jan 05 23:40:49 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Pac2C-0008MJ-M6 for geh-help-gnu-emacs@m.gmane.org; Wed, 05 Jan 2011 23:40:48 +0100 Original-Received: from localhost ([127.0.0.1]:51621 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pac2C-0001iH-2R for geh-help-gnu-emacs@m.gmane.org; Wed, 05 Jan 2011 17:40:48 -0500 Original-Path: usenet.stanford.edu!postnews.google.com!news2.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.supernews.com!news.supernews.com.POSTED!not-for-mail Original-NNTP-Posting-Date: Wed, 05 Jan 2011 16:16:35 -0600 Original-Newsgroups: gnu.emacs.help Original-Lines: 121 Original-X-Trace: sv3-O3e3BbXl2NrJ566og+m0awqKEHj4oirAMaeRWsMU3tkx9gwn39z2ijKgd4pM/LpmacWuRXmMJwLD3YD!YusqVxzunagzhzL3rCdpz4Qd/GBcfjBhSiFH9qagNYw6LYDdEywxrIFfmRaZfJ2iwJaIwaqHkUGK!fb8txs5N Original-X-Complaints-To: www.supernews.com/docs/abuse.html X-DMCA-Complaints-To: www.supernews.com/docs/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 6257 Original-Xref: usenet.stanford.edu gnu.emacs.help:184037 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:78237 Archived-At: On Wed, 05 Jan 2011 11:06:59 -0800, Drew Adams wrote: >> > 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. Dialog boxes don't have to be graphical. In fact Linux has an old utility called "dialog" that's used by scripts to put up different kinds of dialog boxes on a purely text console. Dialog's file selection would be perfect for what I want except that it lacks emacs keybindings and its UI is nonstandard in some rather annoying ways. I've already looked at the many dialog knockoffs but most lack a file-selector and the few that do have the same odd UI. > >> 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)'. That's an interesting feature that I'm sure to find a good use for, but it's not what I'm trying to do right now. > >> 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.) There are actually two flags that control that, use-file-dialog and use-dialog box. To get the GUI selector to pop up both have to be t, window-system must be t, AND read-file-name has to have been triggered by a mouse event. For anyone trying to go the opposite direction from mine who WANTS the GUI file-selector, here is how you persuade read-file-name to produce a graphical dialog: (defadvice read-file-name (around read-file-name act) "Substitute a GUI file picker-outer in read-file-name." (let ((last-nonmenu-event last-nonmenu-event)) (when (and use-file-dialog use-dialog-box window-system) (setq last-nonmenu-event nil)) ad-do-it )) > >> 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. Thanks, I didn't know that was there. It's rather clumsy if you don't have a mouse available but it's sufficient if nothing better comes along. > >> 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. "Browsing", to me, means one can see a list of files and directories and navigate through the list to select what they want. Seeing just one name at a time isn't what I'd consider browsing. Imagine "browsing" a web page by seeing only one line each time you press a key. > >> 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. Might have been clearer if I'd said "a text-mode dialog". >> 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). Thanks. I was wondering if it was just my installation or of they all did that. The documentation isn't real clear about how that's supposed to work.