This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Moving Cygwin

Tim Visher wrote:
> Maybe the context for my question would help.  I'm attempting to
> follow advice from [Steve Yegge's My .emacs File
> article]( in
> order to get useful cygwin bash interaction from within NT Emacs.  He
> seems to be of the opinion that the gentleman who responded in the
> comments about having the path interpolation code and installing
> cygwin in the default directory was mislead about what you need to get
> it to work.
> Are there A) Practical responses to Yegge's way of using Cygwin and NT
> Emacs? or B) A proven way to do what I'm trying to do without messing
> with cygwin's install directory (I would prefer this as I would like
> to keep cygwin safely secluded).

I don't know what specific problems Steve Yegge had that made him think
he needed to install in C:\, but I have cygwin installed in the default 
C:\cygwin and use bash without problem, including emacs correctly
tracking the current directory.  There's certainly no need to install 
cygwin into C:\

Using cygwin-mount.el, emacs understands cygwin paths.  You can get 
cygwin-mount.el here:
Install it into your site-lisp directory, and byte-compile it.

You can load a symbolic link, and emacs will open the target of the 
link.  The only thing I haven't figured out yet (without hacking the
C code) is how to get filename completion to follow symlinks, or to
load a file with a symlink in the middle of its path.  I.e., if 
/path/symlink.lnk points to /otherpath, you can load 
/path/symlink.lnk, and emacs loads /otherpath, but you can't load
/path/symlink/file.  (The symlink hack is likely to break with cygwin
1.7 if it uses utf-16 filenames for the symlink's target, so you 
might just want to skip that part of the code).

The pertinent bits from my .emacs are:

---- 8< --------------------------------------------------------

;;----------- use bash as the default shell ------------------
(setq shell-file-name "bash")
(setenv "SHELL" shell-file-name)
(setq explicit-shell-file-name shell-file-name)
(setq explicit-shell-args '("--login" "-i"))
(setq shell-command-switch "-ic")
(setq w32-quote-process-args t)
(defun bash ()
  (let ((binary-process-input t)
        (binary-process-output nil))

(setq process-coding-system-alist
  (cons '("bash" . (raw-text-dos . raw-text-unix))

;; avoid problems with DOS line endings
(setq-default buffer-file-coding-system 'raw-text-unix)

;;---------- teach emacs about cygwin mount points -----------
(load-library "cygwin-mount")

;;------- let find-file follow a cygwin symbolic link --------
;; This doesn't work for filename completion, so we can only load the 
;; file or directory pointed at by the .lnk file
(defun follow-cygwin-symlink ()
    (goto-char 0)
    (if (looking-at "L\0\0\0\1\x14\x2\0\0\0\0\0\xC0\0\0\0\0\0\0\F\xD")
          (re-search-forward "\x000\\([^\x000]+\\)$")
          (find-alternate-file (match-string 1)))
      (if (looking-at "!<symlink>")
        (re-search-forward "!<symlink>\\(.*\\)\0")
        (find-alternate-file (match-string 1))))

---- 8< --------------------------------------------------------

The only other cygwin-related bit adds cygwin's info directories to

It may not be important, but I use the vanilla NTemacs.  If you use 
Lennart Borgman's EmacsW32 and cannot get it to work, it's possible 
that his patched version has gone too native.  If so, try the unpatched
version.  If the unpatched version works, I'm sure Lennart would be 
interested to hear.  He's very keen to ensure his version doesn't
break existing code.  You can contact him via the help-emacs-windows
at mailing list.

My ~/.bashrc contains the following:

---- 8< --------------------------------------------------------
# set a simple prompt...
export PS1='\$ '
# ...and set the terminal's title (except when running in emacs)
if [ "$TERM" != "emacs" ];then
  PS1U=`id -nu`
  PS1H=`uname -n`
  PROMPT_COMMAND='echo -ne "\033]2;`id -un`@$PS1H:$PWD\007"'
---- 8< --------------------------------------------------------

Possibly significant system settings are:

/home is C:\home, set like this:
$ mount -f -s -b "C:/home" "/home"

HOME is a Windows _user_ environment variable, set to C:\home\<user>
This means Emacs can find ~/

The system environment variable "Path" starts with:

I think that's all.  (My .emacs is large and complex, so it's 
possible I may have missed something).


This email has been scanned by Ascribe Ltd using Microsoft Antigen for Exchange.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]