Using Cygwin Emacs

Oleksandr Gavenko gavenko@bifit.com.ua
Wed May 25 08:34:00 GMT 2011


On 16.05.2011 4:27, Sayth Renshaw wrote:
> Before I venture down this path are there many people using
> this package? Is it advantageous to use this package(cygwin)?
Advantage is in full integration of Emacs and Cygwin tools.
Watching this list I found that many people use Cygwin Emacs package.

> Or is there not much upside to a user using the default 23.2 zip package?
I use native GNU Emacs. It's GIU look more pretty and Emacs understand
Windows-style path is good thing when you need "goto-error" feature
for MSVC compiler, etc...

With "cygwin-mount.el" native Emacs understand Cygwin-style path.

Also I use:

(when (eq system-type 'windows-nt)
   ;; Workaround for Cygwin shell, when set 'CYGWIN=noglob'. By default 
'shell-quote-argument'
   ;; quoted by double '\' chars, this cause failure.
   (defun shell-quote-argument (argument)
     (concat "'" argument "'")
     )
   ;; Workaround for Cygwin when 'shell-file-name' is 'bash'.
   (setq null-device "/dev/null")
   )
;; Use shell from Cygwin/MinGW.
(setq shell-file-name "bash")
(setenv "SHELL" "/bin/bash")
(setq explicit-bash-args '("-i"))
(setq explicit-sh-args '("-i"))

and some utils like "hg" require wrapper to make it .exe. Just compile:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#define MAX_STR_LEN  500

int main(int argc, char **argv)
{
     char cmd[MAX_STR_LEN] = "";
     char **cmdarg = malloc((argc+1) * sizeof(char *));
     char *start, *end;

     start = strrchr(*argv, '/');
     if (start)
         start++;
     else
         start = *argv;
     end = strrchr(start, '.');
     if (end) {
         memcpy(cmd, start, end - start);
         cmd[end - start] = '\0';
     } else
         strcpy(cmd, start);
     for (int i = 0; i < argc; i++)
         cmdarg[i] = argv[i];
     cmdarg[argc] = NULL;

     return execvp(cmd, cmdarg);
}

and take name to executable as shell/perl/python/... script
with ".exe" suffix.

Also I have troubles with quoting of " and {. For example
to make vc-hg.el work properly I patch it:

--- vc-hg.el	2011-01-08 19:45:14.000000000 +0200
+++ vc-hg-new.el	2011-03-17 17:20:26.187500000 +0200
@@ -218,7 +218,7 @@
  			 vc-hg-program nil t nil
  			 "--config" "alias.parents=parents"
  			 "--config" "defaults.parents="
-			 "parents" "--template" "{rev}" (file-relative-name file)))
+			 "parents" "--template" "\\{rev\\}" (file-relative-name file)))
                      ;; Some problem happened.  E.g. We can't find an `hg'
                      ;; executable.
                      (error nil)))))))
@@ -324,7 +324,7 @@
  (defun vc-hg-revision-table (files)
    (let ((default-directory (file-name-directory (car files))))
      (with-temp-buffer
-      (vc-hg-command t nil files "log" "--template" "{rev} ")
+      (vc-hg-command t nil files "log" "--template" "\\{rev\\} ")
        (split-string
         (buffer-substring-no-properties (point-min) (point-max))))))


That's all you need to friend native Emacs with Cygwin.

I am happy with this setup for 3 year with native Emacs from 22.1 to 23.3.


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list