comparison lisp/comint.el @ 4675:f4ab5299a1e4

(comint-filename-prefix): New variable. (comint-replace-by-expanded-filename, comint-dynamic-complete, comint-dynamic-list-completions): Prepend it to absolute file names before completing.
author Roland McGrath <roland@gnu.org>
date Wed, 08 Sep 1993 06:59:23 +0000
parents 0563affb6b38
children 628cbf7e7005
comparison
equal deleted inserted replaced
4674:8db3c141cb62 4675:f4ab5299a1e4
1146 (if (not (looking-at "[~/A-Za-z0-9_.$#,=-]")) (error "")) 1146 (if (not (looking-at "[~/A-Za-z0-9_.$#,=-]")) (error ""))
1147 (re-search-forward "[~/A-Za-z0-9_.$#,=-]+") 1147 (re-search-forward "[~/A-Za-z0-9_.$#,=-]+")
1148 (substitute-in-file-name 1148 (substitute-in-file-name
1149 (buffer-substring (match-beginning 0) (match-end 0))))) 1149 (buffer-substring (match-beginning 0) (match-end 0)))))
1150 1150
1151 (defvar comint-filename-prefix nil
1152 "Prefix prepended to all absolute file names taken from process input.
1153 This is used by the completion functions, and by directory tracking in shell
1154 mode.")
1151 1155
1152 (defun comint-replace-by-expanded-filename () 1156 (defun comint-replace-by-expanded-filename ()
1153 "Expand the filename at point. 1157 "Expand the filename at point.
1154 Replace the filename with an expanded, canonicalised, and completed 1158 Replace the filename with an expanded, canonicalised, and completed
1155 replacement. 1159 replacement.
1160 `comint-dynamic-complete'." 1164 `comint-dynamic-complete'."
1161 (interactive) 1165 (interactive)
1162 (let* ((pathname (comint-match-partial-pathname)) 1166 (let* ((pathname (comint-match-partial-pathname))
1163 (pathdir (file-name-directory pathname)) 1167 (pathdir (file-name-directory pathname))
1164 (pathnondir (file-name-nondirectory pathname)) 1168 (pathnondir (file-name-nondirectory pathname))
1165 (completion (file-name-completion pathnondir 1169 (completion (file-name-completion
1166 (or pathdir default-directory)))) 1170 pathnondir
1171 (if pathdir
1172 ;; It is important to expand PATHDIR because
1173 ;; default-directory might be a handled name, and
1174 ;; the unexpanded PATHDIR won't necessarily match
1175 ;; the handler regexp.
1176 (expand-file-name (concat
1177 (if (file-name-absolute-p pathdir)
1178 comint-filename-prefix)
1179 pathdir))
1180 default-directory))))
1167 (cond ((null completion) 1181 (cond ((null completion)
1168 (message "No completions of %s" pathname) 1182 (message "No completions of %s" pathname)
1169 (ding)) 1183 (ding))
1170 ((eql completion t) 1184 ((eql completion t)
1171 (message "Sole completion")) 1185 (message "Sole completion"))
1187 (let* ((pathname (comint-match-partial-pathname)) 1201 (let* ((pathname (comint-match-partial-pathname))
1188 (pathdir (file-name-directory pathname)) 1202 (pathdir (file-name-directory pathname))
1189 (pathnondir (file-name-nondirectory pathname)) 1203 (pathnondir (file-name-nondirectory pathname))
1190 (completion (file-name-completion 1204 (completion (file-name-completion
1191 pathnondir 1205 pathnondir
1192 ;; It is important to expand PATHDIR because
1193 ;; default-directory might be a handled name, and the
1194 ;; unexpanded PATHDIR won't necessarily match the
1195 ;; handler regexp.
1196 (if pathdir 1206 (if pathdir
1197 (expand-file-name pathdir) 1207 ;; It is important to expand PATHDIR because
1208 ;; default-directory might be a handled name, and
1209 ;; the unexpanded PATHDIR won't necessarily match
1210 ;; the handler regexp.
1211 (expand-file-name
1212 (concat (if (file-name-absolute-p pathdir)
1213 comint-filename-prefix)
1214 pathdir))
1198 default-directory)))) 1215 default-directory))))
1199 (cond ((null completion) 1216 (cond ((null completion)
1200 (message "No completions of %s" pathname) 1217 (message "No completions of %s" pathname)
1201 (ding)) 1218 (ding))
1202 ((eql completion t) 1219 ((eql completion t)
1210 (interactive) 1227 (interactive)
1211 (let* ((pathname (comint-match-partial-pathname)) 1228 (let* ((pathname (comint-match-partial-pathname))
1212 (pathdir (file-name-directory pathname)) 1229 (pathdir (file-name-directory pathname))
1213 (pathnondir (file-name-nondirectory pathname)) 1230 (pathnondir (file-name-nondirectory pathname))
1214 (completions 1231 (completions
1215 (file-name-all-completions pathnondir 1232 (file-name-all-completions
1216 (if pathdir 1233 pathnondir
1217 (expand-file-name pathdir) 1234 (if pathdir
1218 default-directory)))) 1235 ;; It is important to expand PATHDIR because
1236 ;; default-directory might be a handled name, and
1237 ;; the unexpanded PATHDIR won't necessarily match
1238 ;; the handler regexp.
1239 (expand-file-name
1240 (concat (if (file-name-absolute-p pathdir)
1241 comint-filename-prefix)
1242 pathdir))
1243 default-directory))))
1219 (cond ((null completions) 1244 (cond ((null completions)
1220 (message "No completions of %s" pathname) 1245 (message "No completions of %s" pathname)
1221 (ding)) 1246 (ding))
1222 (t 1247 (t
1223 (let ((conf (current-window-configuration))) 1248 (let ((conf (current-window-configuration)))