comparison lisp/shell.el @ 53402:7e645ea92195

(shell-file-name-chars): Add []. (shell-dynamic-complete-as-command): Rename local vars.
author Richard M. Stallman <rms@gnu.org>
date Mon, 29 Dec 2003 19:13:28 +0000
parents 0f1ef5c0e5d7
children c157250db02c
comparison
equal deleted inserted replaced
53401:3cf88b19f762 53402:7e645ea92195
165 This is a fine thing to set in your `.emacs' file.") 165 This is a fine thing to set in your `.emacs' file.")
166 166
167 (defvar shell-file-name-chars 167 (defvar shell-file-name-chars
168 (if (memq system-type '(ms-dos windows-nt cygwin)) 168 (if (memq system-type '(ms-dos windows-nt cygwin))
169 "~/A-Za-z0-9_^$!#%&{}@`'.,:()-" 169 "~/A-Za-z0-9_^$!#%&{}@`'.,:()-"
170 "~/A-Za-z0-9+@:_.$#%,={}-") 170 "[]~/A-Za-z0-9+@:_.$#%,={}-")
171 "String of characters valid in a file name. 171 "String of characters valid in a file name.
172 This variable is used to initialize `comint-file-name-chars' in the 172 This variable is used to initialize `comint-file-name-chars' in the
173 shell buffer. The value may depend on the operating system or shell. 173 shell buffer. The value may depend on the operating system or shell.
174 174
175 This is a fine thing to set in your `.emacs' file.") 175 This is a fine thing to set in your `.emacs' file.")
939 939
940 (defun shell-dynamic-complete-as-command () 940 (defun shell-dynamic-complete-as-command ()
941 "Dynamically complete at point as a command. 941 "Dynamically complete at point as a command.
942 See `shell-dynamic-complete-filename'. Returns t if successful." 942 See `shell-dynamic-complete-filename'. Returns t if successful."
943 (let* ((filename (or (comint-match-partial-filename) "")) 943 (let* ((filename (or (comint-match-partial-filename) ""))
944 (pathnondir (file-name-nondirectory filename)) 944 (filenondir (file-name-nondirectory filename))
945 (paths (cdr (reverse exec-path))) 945 (path-dirs (cdr (reverse exec-path)))
946 (cwd (file-name-as-directory (expand-file-name default-directory))) 946 (cwd (file-name-as-directory (expand-file-name default-directory)))
947 (ignored-extensions 947 (ignored-extensions
948 (and comint-completion-fignore 948 (and comint-completion-fignore
949 (mapconcat (function (lambda (x) (concat (regexp-quote x) "$"))) 949 (mapconcat (function (lambda (x) (concat (regexp-quote x) "$")))
950 comint-completion-fignore "\\|"))) 950 comint-completion-fignore "\\|")))
951 (path "") (comps-in-path ()) (file "") (filepath "") (completions ())) 951 (dir "") (comps-in-dir ())
952 ;; Go thru each path in the search path, finding completions. 952 (file "") (abs-file-name "") (completions ()))
953 (while paths 953 ;; Go thru each dir in the search path, finding completions.
954 (setq path (file-name-as-directory (comint-directory (or (car paths) "."))) 954 (while path-dirs
955 comps-in-path (and (file-accessible-directory-p path) 955 (setq dir (file-name-as-directory (comint-directory (or (car path-dirs) ".")))
956 (file-name-all-completions pathnondir path))) 956 comps-in-dir (and (file-accessible-directory-p dir)
957 (file-name-all-completions filenondir dir)))
957 ;; Go thru each completion found, to see whether it should be used. 958 ;; Go thru each completion found, to see whether it should be used.
958 (while comps-in-path 959 (while comps-in-dir
959 (setq file (car comps-in-path) 960 (setq file (car comps-in-dir)
960 filepath (concat path file)) 961 abs-file-name (concat dir file))
961 (if (and (not (member file completions)) 962 (if (and (not (member file completions))
962 (not (and ignored-extensions 963 (not (and ignored-extensions
963 (string-match ignored-extensions file))) 964 (string-match ignored-extensions file)))
964 (or (string-equal path cwd) 965 (or (string-equal dir cwd)
965 (not (file-directory-p filepath))) 966 (not (file-directory-p abs-file-name)))
966 (or (null shell-completion-execonly) 967 (or (null shell-completion-execonly)
967 (file-executable-p filepath))) 968 (file-executable-p abs-file-name)))
968 (setq completions (cons file completions))) 969 (setq completions (cons file completions)))
969 (setq comps-in-path (cdr comps-in-path))) 970 (setq comps-in-dir (cdr comps-in-dir)))
970 (setq paths (cdr paths))) 971 (setq path-dirs (cdr path-dirs)))
971 ;; OK, we've got a list of completions. 972 ;; OK, we've got a list of completions.
972 (let ((success (let ((comint-completion-addsuffix nil)) 973 (let ((success (let ((comint-completion-addsuffix nil))
973 (comint-dynamic-simple-complete pathnondir completions)))) 974 (comint-dynamic-simple-complete filenondir completions))))
974 (if (and (memq success '(sole shortest)) comint-completion-addsuffix 975 (if (and (memq success '(sole shortest)) comint-completion-addsuffix
975 (not (file-directory-p (comint-match-partial-filename)))) 976 (not (file-directory-p (comint-match-partial-filename))))
976 (insert " ")) 977 (insert " "))
977 success))) 978 success)))
978 979