changeset 15369:0c818ae83d43

(comint-dynamic-complete-as-filename) (omint-dynamic-simple-complete) (comint-dynamic-list-filename-completions) [ms-dos, windows-nt]: Set completion-ignore-case to t for these systems. (comint-substitute-in-file-name): New function. (comint-match-partial-filename): Use comint-substitute-in-file-name to handle system-specific syntax.
author Richard M. Stallman <rms@gnu.org>
date Sun, 09 Jun 1996 20:31:04 +0000
parents 6229fb866493
children b75fc8f3b376
files lisp/comint.el
diffstat 1 files changed, 26 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/comint.el	Sun Jun 09 20:15:20 1996 +0000
+++ b/lisp/comint.el	Sun Jun 09 20:31:04 1996 +0000
@@ -1,6 +1,6 @@
 ;;; comint.el --- general command interpreter in a window stuff
 
-;; Copyright (C) 1988, 90, 92, 93, 94, 95 Free Software Foundation, Inc.
+;; Copyright (C) 1988, 90, 92, 93, 94, 95, 96 Free Software Foundation, Inc.
 
 ;; Author: Olin Shivers <shivers@cs.cmu.edu>
 ;; Adapted-by: Simon Marshall <simon@gnu.ai.mit.edu>
@@ -1854,12 +1854,30 @@
 	  (progn (store-match-data (list (point) here))
 		 (match-string 0))))))
 
+(defun comint-substitute-in-file-name (filename)
+  "Return FILENAME with environment variables substituted.
+Supports additional environment variable syntax of the command
+interpreter (e.g., the percent notation of cmd.exe on NT)."
+  (let ((name (substitute-in-file-name filename)))
+    (if (memq system-type '(ms-dos windows-nt))
+	(let (env-var-name
+	      env-var-val)
+	  (save-match-data
+	    (while (string-match "%\\([^\\\\/]*\\)%" name)
+	      (setq env-var-name 
+		    (substring name (match-beginning 1) (match-end 1)))
+	      (setq env-var-val (if (getenv env-var-name)
+				    (getenv env-var-name)
+				  ""))
+	      (setq name (replace-match env-var-val nil nil name))))))
+    name))
 
 (defun comint-match-partial-filename ()
   "Return the filename at point, or nil if non is found.
 Environment variables are substituted.  See `comint-word'."
   (let ((filename (comint-word "~/A-Za-z0-9+@:_.$#%,={}-")))
-    (and filename (substitute-in-file-name (comint-unquote-filename filename)))))
+    (and filename (comint-substitute-in-file-name 
+		   (comint-unquote-filename filename)))))
 
 
 (defun comint-quote-filename (filename)
@@ -1923,7 +1941,8 @@
 (defun comint-dynamic-complete-as-filename ()
   "Dynamically complete at point as a filename.
 See `comint-dynamic-complete-filename'.  Returns t if successful."
-  (let* ((completion-ignore-case nil)
+  (let* ((completion-ignore-case 
+	  (if (memq system-type '(ms-dos windows-nt)) t nil))
 	 (completion-ignored-extensions comint-completion-fignore)
 	 (file-name-handler-alist nil)
 	 (minibuffer-p (window-minibuffer-p (selected-window)))
@@ -1997,7 +2016,8 @@
 Returns `listed' if a completion listing was shown.
 
 See also `comint-dynamic-complete-filename'."
-  (let* ((completion-ignore-case nil)
+  (let* ((completion-ignore-case
+	  (if (memq system-type '(ms-dos windows-nt)) t nil))
 	 (suffix (cond ((not comint-completion-addsuffix) "")
 		       ((not (consp comint-completion-addsuffix)) " ")
 		       (t (cdr comint-completion-addsuffix))))
@@ -2038,7 +2058,8 @@
 (defun comint-dynamic-list-filename-completions ()
   "List in help buffer possible completions of the filename at point."
   (interactive)
-  (let* ((completion-ignore-case nil)
+  (let* ((completion-ignore-case
+	  (if (memq system-type '(ms-dos windows-nt)) t nil))
 	 (file-name-handler-alist nil)
 	 (filename (or (comint-match-partial-filename) ""))
 	 (pathdir (file-name-directory filename))