diff -bw -u tmp-lisp-206/.#w32-fns.el.1.1.1.1.2.3 lisp/.#w32-fns.el.1.1.1.1.2.3 --- tmp-lisp-206/.#w32-fns.el.1.1.1.1.2.3 Sat Jan 20 15:43:32 2001 +++ lisp/.#w32-fns.el.1.1.1.1.2.3 Sat Jan 20 16:34:10 2001 @@ -269,15 +269,8 @@ (expand-file-name ".." exec-directory))))) ;; Avoid creating auto-save file names containing invalid characters. -;; the symbol property 'w32-fns flags that we should do this only -;; once. => This file can be "loaded" multiple times. -;; -(if (and (not (get 'make-auto-save-file-name 'w32-fns)) - (not (fboundp 'original-make-auto-save-file-name))) - (progn (fset 'original-make-auto-save-file-name (symbol-function 'make-auto-save-file-name)) - (put 'make-auto-save-file-name 'w32-fns t))) (defun make-auto-save-file-name () "Return file name to use for auto-saves of current buffer. Only in lisp: .cvsignore Common subdirectories: tmp-lisp-206/CVS and lisp/CVS diff -bw -u tmp-lisp-206/ChangeLog lisp/ChangeLog --- tmp-lisp-206/ChangeLog Sat Jan 20 16:56:50 2001 +++ lisp/ChangeLog Sat Jan 20 17:32:36 2001 @@ -1,3 +1,129 @@ +2001-01-20 Sat Jari Aalto + + * w32-fns.el (w32-cygwin-mount-table): New var. + (w32-cygwin-mount-table): New. + (w32-cygwin-mount-point-to-dos): New. + (w32-cygwin-path-to-dos): Handle als o cygwin mount + directories. + +2001-01-03 Wed Jari Aalto + + * w32-fns.el (and): NT Emacs dies or error if run like this: + (load-library w32.fns.el) (load-library w32.fns.el), yes, + to times and the C-x C-f ~/txt/file.txt --> error. The cause was, + that `make-auto-save-file-name' was taken second time + (symbol-function 'make-auto-save-file-name) causing circular + reference. Added extra code to make sure it will never happen. + +2001-01-02 Tue Jari Aalto + + * comint.el (comint-dynamic-complete-as-filename): + Rearranged the code to take into account dirtrack.el + which must be called before comint-dynamic-complete-as-filename-1 + or that function will die on error trying to complete + cygwin //c/temp name: + (file-error (Opening directory invalid argument //c/)) + (comint-dynamic-complete-as-filename-1): handle special + case: cygwin-p + + + * w32-fns.el (w32-cygwin-path-to-dos): + Made regexps more strict Based on Eli's comment. + Now a slash is required after drive letter in cygwin + path. path like /cygdrive/some or //some are illegal + (w32-dos-path-to-cygwin): New. + (w32-cygwin-path-p): New. + +2000-12-19 Tue Jari Aalto + + * comint.el (comint-dynamic-complete-as-filename-1): was + `comint-dynamic-complete-as-filename' + (comint-dynamic-complete-as-filename): New. The completion + fails to see the changed directory if user calls an shell alias to + change the directory. The path however will show the changed + location. This function calls dirtrack (if available) to make + a second guess before giving up. + +2000-12-17 Sun Jari Aalto + + * w32-fns.el (w32-cygwin-path-to-dos): New. + Corrected handling of special cases //c and //c/ in addition + to /cygdrive/c and /cygdrive/c/ + + * dirtrack.el (dirtrack): Remove `dirtrack-path-to-standard' + and moved to w32-fns.el under name `w32-cygwin-path-to-dos' + Added test for w32 based Emacs where the function is only + used. + +2000-12-15 Fri Jari Aalto + + * w32-fns.el (w32-cygwin-path-to-dos): New. + + * dirtrack.el (dirtrack-path-to-standard): Fixed the + regexps to be more accurate. Require [a-z] drive letter + after cygwin paths. Anchored to the beginning. + (dirtrack-path-to-standard): Moved to w32-fns.el + (dirtrack): Call `w32-cygwin-path-to-dos'. + + * comint.el (comint-directory-sep-char): Changed to use + `w32-system-shell-p' to check if running under DOS type + command shell. + +2000-12-14 Thu Jari Aalto + + * dirtrack.el (dirtrack): Call `dirtrack-path-to-standard' + (dirtrack-path-to-standard): New. When running Cygwin inside + NTEmacs, the ptah name can be //c/temp or /cygdrive/d/temp. This + function converts them to understandable c:/temp which can + be tested with `file-accessible-directory-p' in function + `dirtrack' + + * comint.el (comint-directory-sep-char): New. + Added w32 support for completing directorynames with \ + in the comint shell buffer when `comint-completion-addsuffix' + was set to true. + (comint-dynamic-complete-as-filename): Call ´comint-directory-sep-char' + to find out the + (comint-dos-shell-file-name-regexp): New. Regexp to match + sos based shell named like cmd.*\\.exe + 2000-02-26 Gerd Moellmann * Version 20.6 released. Common subdirectories: tmp-lisp-206/calendar and lisp/calendar diff -bw -u tmp-lisp-206/comint.el lisp/comint.el --- tmp-lisp-206/comint.el Sat Jan 20 16:56:54 2001 +++ lisp/comint.el Sat Jan 20 17:09:02 2001 @@ -147,6 +147,11 @@ ;; comint-completion-autolist boolean completion behavior ;; comint-completion-recexact boolean ... +(eval-and-compile + (autoload 'w32-system-shell-p "w32-fns") + (autoload 'w32-cygwin-path-p "w32-fns") + (autoload 'w32-cygwin-path-to-dos "w32-fns")) + (defgroup comint nil "General command interpreter in a window stuff." :group 'processes) @@ -2131,9 +2136,58 @@ (message "Completing file name...")) (comint-dynamic-complete-as-filename))) +(defun comint-directory-sep-char () + "Return appropriate `directory-sep-char' which see. +The value depends on the current value of `shell-file-name'. +If this is cmd.*exe, then suppose w32 type dos shell." + ;; The shel may also be Vygwin based bash.exe, but for + ;; cmd.exe, cmdproxy.exe and the like, the separatr must be \ + (if (w32-system-shell-p (file-name-nondirectory shell-file-name)) + ?\\ + ?/)) + + (defun comint-dynamic-complete-as-filename () + "Call `comint-dynamic-complete-as-filename-1'. Return t on success." + (if (not (fboundp 'dirtrack)) + (comint-dynamic-complete-as-filename-1) + (let* ((point (point)) + (path (buffer-substring + (save-excursion + (skip-chars-backward "^ \t\r\n") + (point)) + point)) + ) + ;; It is possible that user uses an shell alias that changes the + ;; the current directory and the dirtrack.el didn't have a chance + ;; to see the "cd ..." prompt to set correct directory. + ;; + ;; bashrc: alias goemacs='cd $EMACS_HOME' + ;; + ;; But after this command, the path hopefully shows the current location + ;; and we can make a second guess abount completion. + ;; + (cond + ((not (string-match "^/" path)) + ;; this is relative completion, calculate ROOT + (dirtrack (buffer-substring + (line-beginning-position) + (line-end-position))))) + + ;; Now the default-directory is ready, but user may be now requesting + ;; and absolute CD. The PATH-HERE was fixed by dirtrack for relative + ;; completions. + ;; + ;; promt PATH-HERE > cd //c/temp[TAB] + ;; + (comint-dynamic-complete-as-filename-1)))) + + + + +(defun comint-dynamic-complete-as-filename-1 () "Dynamically complete at point as a filename. -See `comint-dynamic-complete-filename'. Returns t if successful." +See `comint-dynamic-complete-filename'. Return message string id succesful." (let* ((completion-ignore-case (memq system-type '(ms-dos windows-nt))) (completion-ignored-extensions comint-completion-fignore) ;; If we bind this, it breaks remote directory tracking in rlogin.el. @@ -2145,7 +2199,7 @@ (dirsuffix (cond ((not comint-completion-addsuffix) "") ((not (consp comint-completion-addsuffix)) - (char-to-string directory-sep-char)) + (char-to-string (comint-directory-sep-char))) (t (car comint-completion-addsuffix)))) (filesuffix (cond ((not comint-completion-addsuffix) @@ -2155,8 +2209,16 @@ (t (cdr comint-completion-addsuffix)))) (filename (or (comint-match-partial-filename) "")) - (pathdir (file-name-directory filename)) - (pathnondir (file-name-nondirectory filename)) + (cygwin-p (and (memq system-type '(windows-nt ms-dos)) + (w32-cygwin-path-p filename))) + (pathdir (file-name-directory + (if cygwin-p + (w32-cygwin-path-to-dos filename) + filename))) + (pathnondir (file-name-nondirectory + (if cygwin-p + (w32-cygwin-path-to-dos filename) + filename))) (directory (if pathdir (comint-directory pathdir) default-directory)) (completion (file-name-completion pathnondir directory))) (cond ((null completion) diff -bw -u tmp-lisp-206/dirtrack.el lisp/dirtrack.el --- tmp-lisp-206/dirtrack.el Sat Jan 20 16:56:56 2001 +++ lisp/dirtrack.el Sat Jan 20 17:09:04 2001 @@ -119,6 +119,7 @@ ;;; Code: (eval-when-compile + (autoload 'w32-cygwin-path-to-dos "w32-fns") (require 'comint) (require 'shell)) @@ -271,7 +272,8 @@ " (if (null dirtrackp) nil - (let (prompt-path + (let (prompt-path1 + prompt-path matched (current-dir default-directory) (dirtrack-regexp (nth 0 dirtrack-list)) @@ -298,15 +300,18 @@ (and dirtrack-debug (dirtrack-debug-message "Match is empty string")) ;; Transform prompts into canonical forms - (setq prompt-path (funcall dirtrack-directory-function + (setq prompt-path1 (funcall dirtrack-directory-function prompt-path)) + (if (memq system-type '(windows-nt ms-dos)) + (setq prompt-path (w32-cygwin-path-to-dos prompt-path1)) + (setq prompt-path prompt-path1)) (setq current-dir (funcall dirtrack-canonicalize-function current-dir)) (and dirtrack-debug (dirtrack-debug-message (format - "Prompt is %s\nCurrent directory is %s" - prompt-path current-dir))) + "Prompt is %s -> %s\nCurrent directory is %s" + prompt-path1 prompt-path current-dir))) ;; Compare them (if (or (string= current-dir prompt-path) (string= current-dir Common subdirectories: tmp-lisp-206/emacs-lisp and lisp/emacs-lisp Common subdirectories: tmp-lisp-206/emulation and lisp/emulation Common subdirectories: tmp-lisp-206/gnus and lisp/gnus Common subdirectories: tmp-lisp-206/international and lisp/international Common subdirectories: tmp-lisp-206/language and lisp/language Common subdirectories: tmp-lisp-206/mail and lisp/mail Common subdirectories: tmp-lisp-206/play and lisp/play Common subdirectories: tmp-lisp-206/progmodes and lisp/progmodes Common subdirectories: tmp-lisp-206/term and lisp/term Common subdirectories: tmp-lisp-206/textmodes and lisp/textmodes Only in lisp: tmp diff -bw -u tmp-lisp-206/w32-fns.el lisp/w32-fns.el --- tmp-lisp-206/w32-fns.el Sat Jan 20 16:57:24 2001 +++ lisp/w32-fns.el Sat Jan 20 19:09:18 2001 @@ -51,6 +51,7 @@ "ndos" "ndos.exe") "List of strings recognized as Windows NT/9X system shells.") + (defun w32-using-nt () "Return t if literally running on Windows NT (i.e., not Windows 9X)." (and (eq system-type 'windows-nt) (getenv "SystemRoot"))) @@ -63,6 +64,116 @@ (and (w32-using-nt) "cmd.exe") "command.com")) + +(defun w32-cygwin-path-p (path) + "Check PATH is like cygwin //c /cygdrive/c." + (and path + (string-match "^//[a-z]\\|^/cygdrive/" path))) + +(defun w32-dos-path-to-cygwin (path) + "Convert dos PATH c:/temp to cygwin v1.1+ like /cygdrive/c/temp." + (and path + (if (not (string-match "^\\([a-z]\\):\\(.*\\)" path)) + path + (setq path (format "/cygdrive/%s%s" + (match-string 1 path) + (match-string 2 path))) + (subst-char-in-string ?\\ ?/ path)))) + + + + +(defun w32-cygwin-mount-table () + "Return Cygwin mount table '((CYGWIN . DOS) ..) using `mount' command." + (when (memq system-type '(ms-dos windows-nt)) + ;; specifically request the .exe which must be along PATH + (let ((bin (executable-find "mount.exe"))) + (when bin + (let (list) + (with-temp-buffer + (call-process bin nil (current-buffer)) + (goto-char (point-min)) + (while (re-search-forward + ;; Search lines with backslash + ;; f:\\u\\bin /usr/bin user binmode + (concat + "^\\([^ \t\r\n]*[\\][^ \t\r\n]*\\)" + "[ \t]+" + "\\([^ \t\r\n]+\\)" + ) + nil t) + (push (cons (match-string 2) + (match-string 1)) + list)) + (unless list + (error "Comint: Cygwin mount.exe output parsing fail:\n%s" + (buffer-string))) + list)))))) + +(defun w32-cygwin-mount-point-to-dos (path) + "Convert Cygwin mount filename /tmp to DOS." + (let* (last-choice + try + ) + (dolist (cygwin w32-cygwin-mount-table) + (when (string-match (concat "^" (car cygwin) "\\(.*\\)") + path) + (setq try + ;; expand will ensure that slashes are after glue + ;; to the same direction + (expand-file-name + (concat (file-name-as-directory (cdr cygwin) ) + (match-string 1 path)))) + ;; It is difficult to expand the file name correctly because + ;; user can make any mount points. That's wht we compare which + ;; mount point gives the longest match and return it. + ;; + ;; E.g the root / will always match, but it is not necessarily + ;; the final answer given path /tmp/something where there is + ;; separate mount point for longer match /tmp + ;; + (if (null last-choice) + (setq last-choice (cons (car cygwin) try)) + (if (length (> (car cygwin) (car last-choice))) + (setq last-choice (cons (car cygwin) try)))))) + (if (null last-choice) + path + (cdr last-choice)))) + + +(defun w32-cygwin-path-to-dos (path) + "Convert cygwin like //c/temp or /cygdrive/c/temp path to +dos notation c:/temp." + ;; NOTE for cygwin and bash shell prompt + ;; We can't require a slash after the drive letter, because + ;; //c and /cygdrive/c are all top level roots. + ;; + ;; The bash shell's PS1 setting \w (The current working directory) + ;; Does not add trailing slash. + ;; + ;; FIXME: What about NT network drive paths in format UNC + ;; which do work in Cygwin + ;; + ;; //server/path/and/more + ;; + (cond + ((or (string-match "^//\\([a-z]\\)/?$" path) + (string-match "^/cygdrive/\\([a-z]\\)/?$" path)) + (concat (match-string 1 path) ":/")) + ((or (string-match "^//\\([a-z]\\)\\(/.*\\)" path) + (string-match "^/cygdrive/\\([a-z]\\)\\(/.*\\)" path)) + (concat (match-string 1 path) ":" (match-string 2 path))) + ((string-match "^\\(/.*\\)" path) + ;; /tmp/compile => f:/unix-root/cygwin/tmp/compile + (if (null w32-cygwin-mount-table) + path + (w32-cygwin-mount-point-to-dos path))) + ((string-match "^(/cygdrive/./\\|//" path) + ;; if previous regexps couldn't handle it, this is severe error. + (error "Invalid path format for cygwin %s" path)) + (t + path))) + (defun w32-system-shell-p (shell-name) (and shell-name (member (downcase (file-name-nondirectory shell-name)) @@ -229,8 +340,15 @@ (expand-file-name ".." exec-directory))))) ;; Avoid creating auto-save file names containing invalid characters. +;; the symbol property 'w32-fns flags that we should do this only +;; once. => This file can be "loaded" multiple times. +;; +(if (and (not (get 'make-auto-save-file-name 'w32-fns)) + (not (fboundp 'original-make-auto-save-file-name))) + (progn (fset 'original-make-auto-save-file-name (symbol-function 'make-auto-save-file-name)) + (put 'make-auto-save-file-name 'w32-fns t))) (defun make-auto-save-file-name () "Return file name to use for auto-saves of current buffer. @@ -283,6 +401,15 @@ default)))) (check-coding-system coding-system) (setq w32-system-coding-system coding-system)) + + +(defvar w32-cygwin-mount-table + ;; Just extra protection if someone mistakently does load-library in Unix... + (if (memq system-type '(ms-dos windows-nt)) + (w32-cygwin-mount-table)) + "Cygwin mount.exe mapping. See `w32-cygwin-mount-table'.") + + ;; Set system coding system initially to iso-latin-1 (set-w32-system-coding-system 'iso-latin-1)