Oleksandr Gavenko's blog
2017-01-24 14:00 Emacs 25 under Windows

I haven't used Windows for a long time and my new job may require Windows environment. So I checked out new ways to use Emacs under Windows.

I used to prefer native Emacs over Cygwin because of native widgets and copy/paste. With cygwin-mount cross-compiling from Cygwin to native Windows application would be easy.

The only problem I've encountered is that hg is a Python script, not an executable and can't be called from native Emacs. To work around an issue I wrote simple Cygwin application that re-route call and arguments to the script.

Just rename this utility to $SCRIPT.exe and put it behind Cygwin in the PATH. It has a basic protection from infinite calling to itself and allows using of Cygwin scripts in native Windows application, like native Emacs.

Source code of utility is available on http://hg.defun.work/utils/file/tip/cygwin/cygrun/cygrun.c

But I constantly have issue with VC mode. Native Emacs is wrongly determining file revision and reported it as string rev. That it's due to quoting and wrong Emacs code assumption: Re: Using Cygwin Emacs.

Starting X for graphical Emacs seems too complicated, but possible. Especially by using multi-window:

XWin -multiwindow

but all programs should be started with DISPLAY set:

DISPLAY=:0 xterm

With some tweaking integration will be smoother:

XWin -clipboard -silent-dup-error -xkblayout "us,ru" -xkboptions "grp:caps_toggle"

Nowadays there is emacs-w32 build in Cygwin repository. It uses native widgets but in all other cases it is a regular Cygwin application. So I will have Hg/Git and TRAMP working out of the box!

The only issue with emacs-w32 executable is that all Cygwin executables compiled with --subsystem=console or -mconsole (which is by default). That causes opening Windows console window along with app GUI. That console window distracts me during Alt+TAB.

https://cygwin.com/ml/cygwin/2016-05/msg00375.html

Re: Is it possible to hide emacs-w32 console window?

Cygwin programs can't be compiled with -mwindows (or --subsystem=windows). Reason for this described in run(1) man page:

run - start programs with hidden console window

SYNOPSIS
     run [ -p path ] command [ --wait ] [ --quote ] arguments

     runcommand [ -p path ] [ --wait ] [ --quote ] arguments

DESCRIPTION

   Windows programs are either GUI programs or console programs. When started
   console programs will either attach to an existing console or create a new
   one. GUI programs can never attach to an exiting console. There is no way
   to attach to an existing console but hide it if started as GUI program.

   run will do this for you. It works as intermediate and starts a program but
   makes the console window hidden.

and run command helps to hide console window. So you should start Emacs as:

run emacs-w32

I have "smart" starter of Emacs with short and convenient name for quick typing: e and batch file e.bat. Because I switched to emacs-w32 as a default for Windows I updated e.bat implementation to use run goodies:

run emacsclient-w32 -a emacs-w32 %*

Full script is available at:: http://hg.defun.work/utils/file/tip/emacs/e.bat

emacs, win, cygwin

Feeds

all / emacs / java / python

Tags

adb(1), admin(1), android(1), anki(1), blog(1), c(1), css(2), cygwin(2), driver(1), emacs(3), fs(1), git(2), gradle(1), hardware(1), hg(2), html(1), interview(13), java(2), js(3), lang(2), lighttpd(1), mobile(1), naming(1), oracle(1), print(1), problem(5), quiz(6), rst(1), security(1), sql(2), srs(1), style(1), unit(1), utils(1), vcs(3), web(2), win(2), windows(1)

Archive