Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have question regarding when running emacs with cygwin. I have installed emacs which comes with cygwin. How can I get cygwin to run emacs in its own window instead from the cygwin's console window.

I like how it is in ubuntu when I run emacs from the terminal it will open emacs's GUI.

share|improve this question
I'm curious: Why don't you install the windows version of Emacs? – jgomo3 Nov 1 '11 at 22:08
That's certainly an option, but if you work mostly in the Cygwin environment it's useful to have an Emacs that understands Cygwin-style paths (/home/username/foo.txt vs. C:\cygwin\home\username\foo.txt). – Keith Thompson Nov 1 '11 at 22:15
Because cygwin gives me the feel of unix in windows box. And your response should be a comment rather than an answer. – starcorn Nov 1 '11 at 22:16
up vote 4 down vote accepted

Need to have an X-server running and install the x-version of emacs, cygwin includes both (if you select the correct packages during installation).

The X-server is probably started with the command startx once it's installed.

share|improve this answer
Is it necessary to install xemacs? latest version of xemacs is only v21, while emacs is v23. The emacs version i'm running on ubuntu is also v23 which can open up in a separate window – starcorn Jan 5 '11 at 20:34
@klw - No xemacs is a different flavour of emacs (another very similar program). It's not emacs with the X-libraries included. The namning is a bit confusing. – Nifle Jan 5 '11 at 20:36
@klw - You want the emacs-X11 packages – Nifle Jan 5 '11 at 20:40
@Nifle - i got that installed, but I can't find the package for x-server. could possible give me a name for it as well? btw, you don't happen to know if Xming can be used instead for cygwin's X-server? – starcorn Jan 5 '11 at 20:49
@klw - Another x-server is perfectly fine, that's what I have used most of the time, but a quick look at the cygwin packages I think you want the X11 package called xorg-server – Nifle Jan 5 '11 at 20:56

A non-X solution is emacs-w32 package under Editors in the cygwin setup. It runs emacs as a native Windows application but is still pure Cygwin. If you launch it directly from a shortcut, you'll maybe like these settings in ~/.emacs:

Add cygwin to path and exec path if cygwin isn't in your PATH by default:

(setenv "PATH" (concat "/bin:/usr/bin:/usr/local/bin:" (getenv "PATH")))
(nconc exec-path '("/bin" "/usr/bin" "/usr/local/bin"))

If you compile java or other things that generate filenames like C:\whatever, you may first like to edit /etc/fstab and add a mount from C:\ to /c such as:

C: /c ntfs binary,user 1 1

And then treat files beginning with C: as "magic filenames" that get translated to Cygwin style filenames with this in ~/.emacs. Here I'm simply doing two regex replacements on the first argument and ignoring the rest. Someone probably should create an .el for this, make it more robust and post it to :

; When in cygwin, allow C:\whatever to turn into /c/whatever
(defun cygwin-name-hook (operation &rest args)
  "Turn Windows filenames into Cygwin filenames."
  ;; Handle all operations the same
  (let ((first (car args))
         (cons 'cygwin-name-hook
               (and (eq inhibit-file-name-operation operation)
        (inhibit-file-name-operation operation))
    (setq first (replace-regexp-in-string "^C:" "/c" first t))
    (setq first (replace-regexp-in-string "\\\\" "/" first t))
    (apply operation (cons first (cdr args)))))

(add-to-list 'file-name-handler-alist '("^[Cc]:" . cygwin-name-hook))

Then if you run emacs -nw inside mintty, you may like it to recognize more keys, place into ~/.emacs:

;***** For mintty
(define-key function-key-map "\e[1;5m" [(control ?-)])
(define-key function-key-map "\e[1;5k" [(control ?=)])
(define-key function-key-map "\e[1;5q" [(control ?1)])
(define-key function-key-map "\e[1;5s" [(control ?3)])
(define-key function-key-map "\e[1;5t" [(control ?4)])
(define-key function-key-map "\e[1;5u" [(control ?5)])
(define-key function-key-map "\e[1;5w" [(control ?7)])
(define-key function-key-map "\e[1;5x" [(control ?8)])
(define-key function-key-map "\e[1;5y" [(control ?9)])
(define-key function-key-map "\e[1;5p" [(control ?0)])
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .