So for example a path like:
c:\code\haskell\cats\monkeys
Needs to be converted to:
/cygdrive/c/code/haskell/cats/monkeys
The following interactive elisp function does that with the currently selected text:
(defun win32-to-cygwin-path()
"Converts a win32 path into a cygwin happy one"
(interactive)
(save-excursion
(save-restriction
(narrow-to-region (point) (mark))
(goto-char (point-min))
(insert "/cygdrive/")
(goto-char (point-min))
(while (search-forward ":" nil t)
(replace-match "" nil t))
(while (search-forward "\\" nil t)
(replace-match "/" nil t)))))
Nothing much clever going on here, just two search and replaces for the slashes and to removed the colon, and I insert the cygdrive prefix.
4 comments:
Cygwin has a tool that you might want to try, `cygpath`. See the online docs for cygpath.
Thanks Bruce
Any time I post publicly about something I've done in emacs I find that someone has done it before me, so this is no surprise. I'll check it out.
Justin
Great read, thank you
Post a Comment