Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com Reply-To: From: "Drew Moseley" To: Subject: cygwin32-mount.el Date: Wed, 27 Oct 1999 10:02:08 -0400 Message-ID: <000201bf2083$dba9dbd0$1e90e2cd@cygnus.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook 8.5, Build 4.71.2232.26 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 Importance: Normal Some time ago I found a reference to a piece of elisp called cygwin32-mount.el which give Emacs the ability to read files using their Cygwin mount names. Does anyone know if this is still being maintained by anyone? If so, where do I get the latest version. I have enhanced it as follows: 1. Added support for /cygdrive style drive maps. 2. Hacked a fix to a bug where ange-ftp would not work when this was loaded. Here is the code if anyone is interested. Drew mailto: dmoseley AT cygnus DOT com ;;; cygwin32-mount.el --- Teach EMACS about cygwin32 mount points. ;;; Michael Cook . ;;; modified Jun 18 1998 by Keisuke Mori ;;; to make it work with ange-ftp and enable mapping a drive letter ;;; modified Oct 25 1999 by Drew Moseley (drewmoseley AT mindspring DOT com) ;;; to support /cygdrive style drive maps and for better coexistence ;;; with ange-ftp. (defun cygwin32-mount-build-table () ;; Determine the cygwin mount points. (let ((buf (get-buffer-create " *mount*")) (case-fold-search t) mounts) (save-excursion (set-buffer buf) (erase-buffer) (call-process "mount" nil t) (goto-char (point-min)) (while (search-forward-regexp "^\\([a-z]:[^ \t\n]*\\) +\\([^ \t\n]+\\)" nil t) (let ((device (buffer-substring (match-beginning 1) (match-end 1))) (direct (buffer-substring (match-beginning 2) (match-end 2)))) (setq mounts (cons (cons device direct) mounts))))) (kill-buffer buf) mounts)) (defvar cygwin32-mount-table (cygwin32-mount-build-table) "Alist of cygwin32 mount points.") (or (assoc "^/[^/:]+\\(\\'\\|/\\)" file-name-handler-alist) (setq file-name-handler-alist (cons '("^/[^/:]+\\(\\'\\|/\\)" . cygwin32-mount-name-hook-function) file-name-handler-alist))) (or (assoc "^//[A-Za-z]/" file-name-handler-alist) (setq file-name-handler-alist (cons '("^//[A-Za-z]/" . cygwin32-mount-map-drive-hook-function) file-name-handler-alist))) ;;; Support cygdrive style drive maps. (or (assoc "^/cygdrive/[A-Za-z]" file-name-handler-alist) (setq file-name-handler-alist (cons '("^/cygdrive/[A-Za-z]" . cygwin32-mount-map-drive-hook-function) file-name-handler-alist))) (defun cygwin32-mount-name-hook-function (operation &rest args) (let ((fn (get operation 'cygwin32-mount-name))) (if fn (apply fn operation args) (cygwin32-mount-run-real-handler operation args)))) (defun cygwin32-mount-map-drive-hook-function (operation &rest args) (let ((fn (get operation 'cygwin32-mount-map-drive))) (if fn (apply fn operation args) (cygwin32-mount-run-real-handler operation args)))) (defun cygwin32-mount-run-real-handler (operation args) (let ((inhibit-file-name-handlers (cons 'cygwin32-mount-name-hook-function (cons 'cygwin32-mount-map-drive-hook-function (and (eq inhibit-file-name-operation operation) inhibit-file-name-handlers)))) (inhibit-file-name-operation operation)) (apply operation args))) ;;; ;;; Unbound the ange-ftp-run-real-handler and rebind it to ours ;;; This version also inhibits the cygwin file name expansion when ;;; we are doing ange-ftp expansion. ;;; ;;; This is a real hack. If the real definition of this function ;;; changes, we have to modify this function ;;; (require 'ange-ftp) (if (fboundp 'ange-ftp-run-real-handler) (fmakunbound 'ange-ftp-run-real-handler)) (defun ange-ftp-run-real-handler (operation args) (let ((inhibit-file-name-handlers (cons 'ange-ftp-hook-function (cons 'ange-ftp-completion-hook-function (cons 'cygwin32-mount-name-hook-function (cons 'cygwin32-mount-map-drive-hook-function (and (eq inhibit-file-name-operation operation) inhibit-file-name-handlers)))))) (inhibit-file-name-operation operation)) (apply operation args))) (put 'substitute-in-file-name 'cygwin32-mount-name 'cygwin32-mount-name-expand) (put 'expand-file-name 'cygwin32-mount-name 'cygwin32-mount-name-expand) (put 'substitute-in-file-name 'cygwin32-mount-map-drive 'cygwin32-mount-map-drive) (put 'expand-file-name 'cygwin32-mount-map-drive 'cygwin32-mount-map-drive) (require 'cl) (defun cygwin32-mount-name-expand (operation name &rest args) ;; If NAME uses a mount directory, substitute the mount device ;; and return the resulting string. Otherwise, return NAME. (let ((mounts cygwin32-mount-table) (len (length name)) match) (while mounts (let ((mount (file-name-as-directory (cdar mounts)))) (and (>= len (length mount)) (string= mount (substring name 0 (length mount))) (or (null match) (> (length (cdar mounts)) (length (cdr match)))) (setq match (car mounts)))) (setq mounts (cdr mounts))) (if match (concat (file-name-as-directory (car match)) (substring name (length (file-name-as-directory (cdr match))))) (cygwin32-mount-run-real-handler operation (cons name args))))) (defun cygwin32-mount-map-drive (operation name &rest args) ;; NAME must have the format looks like "^//[A-Za-z]/" here. ;; Support cygdrive style drive maps. (cygwin32-mount-run-real-handler operation (if (string-equal (substring name 0 2) "//") (cons (concat (substring name 2 3) ":" (substring name 3 nil)) args) (cons (concat (substring name 10 11) ":" (substring name 11 nil)) args) ) ) ) (provide 'cygwin32-mount) -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com