my-dos2cygwin-path
authorOleksandr Gavenko <gavenkoa@gmail.com>
Sun, 16 Oct 2011 00:39:28 +0300
changeset 731 5b6105640c0e
parent 730 995821d2a5cf
child 732 139665dd6ada
my-dos2cygwin-path
.emacs-my
--- a/.emacs-my	Sat Oct 15 23:15:40 2011 +0300
+++ b/.emacs-my	Sun Oct 16 00:39:28 2011 +0300
@@ -286,6 +286,22 @@
         0 -1)                           ; -1 for stripping final \0.
        ))))
 
+(defun my-dos2cygwin-path (path)
+  "Convert DOS path to Cygwin according to current mount table."
+  (interactive (list (read-directory-name "Enter new path for PYTHONPATH: ")))
+  (setq path (replace-regexp-in-string "\\\\" "/" (expand-file-name path)))
+  (let ( (table cygwin-mount-table--internal) item prefix )
+    (while table
+      (setq item (car table))
+      (setq prefix (concat "\\`" (regexp-quote (car item))))
+      (setq table (cdr table))
+      (when (string-match prefix path)
+        (setq path (replace-regexp-in-string prefix (cdr item) path))
+        (setq table nil)
+        ) )
+    path
+    ))
+
 (when (eq system-type 'windows-nt)
   (ignore-errors
     (require 'cygwin-mount)