aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/shell.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/shell.el')
-rw-r--r--lisp/shell.el37
1 files changed, 19 insertions, 18 deletions
diff --git a/lisp/shell.el b/lisp/shell.el
index cc83dcf1429..1817a1fd3b4 100644
--- a/lisp/shell.el
+++ b/lisp/shell.el
@@ -167,7 +167,7 @@ This is a fine thing to set in your `.emacs' file.")
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.
172This variable is used to initialize `comint-file-name-chars' in the 172This variable is used to initialize `comint-file-name-chars' in the
173shell buffer. The value may depend on the operating system or shell. 173shell buffer. The value may depend on the operating system or shell.
@@ -941,36 +941,37 @@ Returns t if successful."
941 "Dynamically complete at point as a command. 941 "Dynamically complete at point as a command.
942See `shell-dynamic-complete-filename'. Returns t if successful." 942See `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 " "))