Article View: gnu.emacs.bug
Article #100043Completing filenames in shell-mode
From: Rob Austein
Date: Fri, 16 Mar 1990 05:45
Date: Fri, 16 Mar 1990 05:45
47 lines
2170 bytes
2170 bytes
Here's a feature I've wanted for a while. The following hack allows
filename completion in a shell-mode buffer. The behavior is basicly
like tcsh's completion. It doesn't do pop-up windows because there's
no good way to clean them up automaticly except from the minibuffer.
;;; allspice.lcs.mit.edu:/u/sra/shell-file-complete.el, 15-Mar-1990 21:50, sra
(defvar shell-filename-chars
"/~a-zA-Z0-9---_#=+.,"
"*Characters that shell-filename-complete considers legitimate.")
(defun shell-filename-complete ()
(interactive)
(let (start name directory file completion)
(save-excursion
(beginning-of-line)
(setq start (point)))
(save-excursion
(skip-chars-backward shell-filename-chars start)
(setq start (point)))
(setq name (buffer-substring start (point))
directory (file-name-directory name)
file (file-name-nondirectory name))
(cond
((string= name "")
(beep))
((and directory (not (file-directory-p directory)))
(beep))
((not (setq completion
(file-name-completion file (or directory default-directory))))
(beep))
((eq t completion)
(message "[Sole completion]"))
((string= completion file)
(message
(mapconcat 'identity
(file-name-all-completions
file (or directory default-directory)) " ")))
(t
(insert (substring completion (length file)))))))
(setq shell-mode-hook
(function
(lambda ()
(define-key shell-mode-map "\C-c\C-i" 'shell-filename-complete))))
--Rob Austein
Technical Details
Message-ID:
<1990Mar16.054548.26107@mintaka.lcs.mit.edu>Path:
arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!bu.edu!bloom-beacon!mintaka!mintaka.lcs.mit.edu!sraShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fb2f1,271ed0a85ea1bf11,start X-Google-Attributes: gidfb2f1,public X-Google-ArrivalTime: 1990-03-15 21:45:48 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!bu.edu!bloom-beacon!mintaka!mintaka.lcs.mit.edu!sra From: sra@lcs.mit.edu (Rob Austein) Newsgroups: gnu.emacs.bug Subject: Completing filenames in shell-mode Message-ID: <1990Mar16.054548.26107@mintaka.lcs.mit.edu> Date: 16 Mar 90 05:45:48 GMT Sender: news@mintaka.lcs.mit.edu Distribution: gnu Organization: ITS Preservation Society Lines: 47 Posted: Fri Mar 16 06:45:48 1990