10 Tips for Powerful Emacs on Windows

I avoided using Microsoft Windows for almost 15 years, but with my
new job at a Microsoft-enthralled development shop, those idyllic
days have come to an abrupt end. Because in the past I could always
use my trusty Linux and OS X machines, I never did push past the
hurdles of using Emacs on Windows. My utter reliance on Org-mode,
TRAMP, and Ediff (to name a few) made it essential to get Emacs
working on Windows if at all possible.

Now I am using Emacs on Windows XP and Windows 7 on a daily basis,
and am quite happy with the results. It was not easy to get to the
point of full functionality, so I wanted to share the magic that
makes it all work.

I have decided against using the Cygwin Emacs package for several reasons:

  • Running a windowed/multi-frame/pretty version requires running
    Cygwin-X, which is quite a lot of overhead just to run Emacs. I
    have had a few interface and display problems lately with Cygwin-X
    also.
  • Cool-though-seldom-used features that work in the native port do
    not work in the Cygwin port: Window opacity control, for example
  • Using the native port means I can always be running the latest
    released version from gnu.org
  • The native port just runs faster

On the other hand, Cygwin does play a crucial role in making the
native Emacs port work properly. I have tried and hated using PuTTY
and Plink, and various one-off ports of standard Unix commands.
Using Cygwin and its package management makes all this
much simpler and more reliable.

So all the hints given here use the “official” Emacs for Windows
(sometimes referred to as NTEmacs), as well as Cygwin (with no
dependency on Cygwin-X).

I really hope this helps some poor beleaguered Linux/OS X Emacs user
make the giant backwards leap. With these tips and little helpers like
Launchy, you won’t even have to
acknowledge that you’re running Windows!

Software download links

Here’s where you will find all the software referenced in the tips:

Tip #1: General Usage

  • Execute runemacs.exe or emacsclientw.exe. On your Linux and OS X
    systems, the binary names or emacs and emacsclient: just use the
    windows-specific wrappers included in the standard port when on MS Windows.
  • Add Cygwin /bin to exec-path.
          (if (file-directory-p "c:/cygwin/bin")
          (add-to-list 'exec-path "c:/cygwin/bin"))

Tip #2: Make TRAMP work nicely — and without PuTTY

There are people using PuTTY and Plink.exe to get this working, but
I like using good old OpenSSH much better: no translation required
for the keys I use, and I have it installed anyway in Cygwin.

  • Install Cygwin, including the OpenSSH package
  • In your Emacs init, set shell to bash
          (setq shell-file-name "bash")
          (setq explicit-shell-file-name shell-file-name)
  • In Emacs init, set tramp-default-method to “sshx” or “scpx”
          (cond  ((eq window-system 'w32)
          (setq tramp-default-method "scpx"))
          (t
          (setq tramp-default-method "scpc")))
  • Windows 7 note:   I was unable to get this to work on Win7 until I set the runemacs.exe binary to run in Windows XP (Service Pack 3) compatibility mode.
  • Test: Try M-x shell, then visit a TRAMP site such as /user@site: and try M-x shell from there!

Tip #3: Use SVN and GIT without tears

Version control should work out of the box — but SSH problems can
interfere sometimes. So once you get TRAMP working properly, you
should have no problems with VC.

  • Install subversion and git from Cygwin
  • Use built-in vc-dir, or psvn.el and magit.el

Tip #4: Display images in buffers, including doc-view

You may have noticed that your Windows Emacs has no ability to
display images. This is simply due to the fact that the port is
not distributed with the libraries necessary to display them.

The solution is to visit the GnuWin32 link above, download the
packages relevant to the types of images you want to display
(including zlib1 for compressed images), and copy the DLLs into the
bin directory of your Emacs installation (e.g, C:\Program
Files\emacs23-2\bin).

Images will only be displayed after restarting Emacs.

Here’s a list of DLLs that I now have in my installation:

  • jpeg62.dll
  • libXpm.dll
  • libjpeg-62.dll
  • libpng-bcc.lib
  • libpng.dll.a
  • libpng.la
  • libpng.lib
  • libpng12-0.dll
  • libpng12.def
  • libpng12.dll
  • libpng12.dll.a
  • libpng12.la
  • libtiff3.dll
  • zlib1.dll (for compression, not images)

Tip #5: Use W3M

The W3M web browser works fine once you install the w3m binary –
and once the image display step above is working, you will be able
to display images in the W3M buffers as well.

  • Install w3m from Cygwin
  • Test image display by hitting T (w3m-toggle-inline-images)
  • Example screenshot:
    W3M Browser in Emacs

Tip #6: Bring back Ediff and Smerge

Ediff is yet another thing which doesn’t work as it should. You
will get an error complaining about Dos-style versus Unix-style
paths. Fixing it is a simple matter of setting an environment variable.

  • Assure you have Cygwin’s diff package installed
  • Set the Windows environment variable nodosfilewarning=1
  • Restart Emacs, and verify that the environment variable is set by executing M-x shell, then typing env | grep dos, for example
  • Always, prior to running ediff, execute M-x shell

Tip #7: Spell using ISpell or Aspell

Fortunately very easy to get working by following Brian Wood’s directions using the ISpell package for Cygwin linked above.

Note added later:

Aspell is even easier to use: just install aspell and the correct language(s) in Cygwin, then use the following in your emacs init:

(setq-default ispell-program-name "aspell")

Tip #8: Maximized frame works using maxframe.el

Those of us who practice Distraction-Free Emacsing, or DFE, will
lament the inability to maximize the frame as we can do on other
systems (ie, a true maximized windows, with no OS window
decoration). The solution is provided by maxfame.el, linked above.

After loading maxframe.el, use M-x maximize-frame and M-x restore-frame

Tip #9: Print on PostScript printers

And finally, printing. Even this just didn’t work out of the box
for me. The solution was to use a nice little utility called
GSPrint from the GSView package linked above.

  • Install Ghostscript in Cygwin
  • Install GSView
          (when (and (string= (window-system) "w32") (file-exists-p "c:/Program Files/Ghostgum/gsview/gsprint.exe"))
          (progn
          ;;  Windows printer
          (setq-default ps-lpr-command (expand-file-name "c:/Program Files/Ghostgum/gsview/gsprint.exe"))
          (setq-default ps-printer-name t)
          (setq-default ps-printer-name-option nil)
          (setq ps-lpr-switches '("-query")) ; show printer dialog
          (setq ps-right-header '("/pagenumberstring load" ps-time-stamp-mon-dd-yyyy))))
          (if (eq window-system 'x)
          (setq ps-lpr-command "gtklp"))

Tip #10: Some things Just Workâ„¢: Nifty Emacs 23 features that work “out of the box”

Bonus tip — some things work already, no fiddling required!

Select any font you want

  • M-x menu-set-font (choose something lovely like Consolas or Inconsolata … or Comic Sans MS)
  • Example font selection, cross-OS
          ;;* Font selection
          (cond ((or (eq window-system 'mac) (eq window-system 'ns))
          (set-face-font 'default '"-apple-inconsolata-medium-r-normal--16-0-72-72-m-0-iso10646-1"))
          ((eq window-system 'w32)
          (set-face-font 'default '"-outline-Inconsolata-normal-normal-normal-mono-16-*-*-*-c-*-iso8859-1"))
          ((and (eq window-system 'x) (eq emacs-major-version 23))
          (set-face-font 'default '"-unknown-Inconsolata-normal-normal-normal-*-16-*-*-*-m-0-iso10646-1")
          (add-to-list 'default-frame-alist '(font . "-unknown-Inconsolata-normal-normal-normal-*-16-*-*-*-m-0-iso10646-1"))
          )
          ((eq window-system 'x)
          (set-face-font 'default '"10x20")))
     
          (add-hook 'before-make-frame-hook
          (lambda ()
          (set-frame-font "-unknown-Inconsolata-normal-normal-normal-*-16-*-*-*-m-0-iso10646-1")
          ))
  • M-x grep, M-x grep-find, M-x rgrep and friends (as long as
    you have the grep and find commands installed!)
  • M-x tetris, M-x doctor, M-x yow, M-x butterfly

Frame transparency

  • Transparent windows are not my favorite thing, as they tend to
    hamper DFE (see above). But there are occasions, like copying text from a
    web page into an Emacs buffer, where it can come in quite handy.

          (defun set-transparency (alpha-level)
          (interactive "p")
          (message (format "Alpha level passed in: %s" alpha-level))
          (let ((alpha-level (if (< alpha-level 2)
    				(read-number "Opacity percentage: " 85)
    				alpha-level))
    				(myalpha (frame-parameter nil 'alpha)))
    				(set-frame-parameter nil 'alpha alpha-level))
    				(message (format "Alpha level is %d" (frame-parameter nil 'alpha))))
This entry was posted in emacs and tagged , , , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

11 Comments

  1. Posted May 23, 2010 at 2:03 pm | Permalink

    You give up on Ubuntu?

  2. Posted May 23, 2010 at 4:51 pm | Permalink

    I never gave up on Ubuntu … I am currently Lucid and will soon be Magnanimous (or whatever). But I must use MSWindows now on a daily basis.

    We should have lunch soon and catch up eh.

  3. Posted May 23, 2010 at 10:09 pm | Permalink

    I too prefer linux/os x as well, but I’m forced to use XP at work too.. the 2 apps I have come to love in my Windows work/development environment (aside from emacs) are 1) XKeymacs and 2) executor

    http://www.cam.hi-ho.ne.jp/oishi/indexen.html

    http://executor.dk/

  4. Posted August 17, 2010 at 4:30 pm | Permalink

    Great tips, but I can’t seem to get aspell to work. Just setting (setq-default ispell-program-name “aspell”) causes emacs to whine thusly: (file-error “Searching for program” “no such file or directory” “spell”)

    Any ideas?

  5. Posted September 7, 2010 at 7:27 pm | Permalink

    Evan: Did you set default-ispell-program-name:
    (setq-default ispell-program-name “aspell”)

    If so, is aspell.exe in your path (check by doing M-x shell RET aspell RET)

    Or, if you don’t want to put it into the PATH, you can add its directory to exec-path

    Hope this helps!

  6. Drew
    Posted October 12, 2010 at 2:12 pm | Permalink

    I recently tried to switch to emacs port to windows. How do you resolve the issue with FIND: Parameter format not correct when using grep, rgrep, etc.

  7. Posted November 11, 2010 at 11:03 am | Permalink

    @Drew: I don’t get that error. The problem is probably that you have the Windows system32 directory in your PATH environment prior to the Cygwin path. So for example, if you have something like

    PATH=C:\WINDOWS\system32;C:\cygwin\bin ….

    You will have the problem. The Windows FIND command is the one giving the parameter complaint.

  8. Drew Wells
    Posted November 11, 2010 at 11:12 am | Permalink

    After much pain and suffering, I decided to go with the GNU WIN32 that packages everything together. I’m a little hesitant to put cygwin commands before windows, because other things may be expecting the windows FIND and get they cygwin one instead. I know, I know this is sort of a cop out and now I’m tied to them, but it has been working very well (almost as well as emacs on Ubuntu).

    I do believe it was a path problem, however when I started hitting cygwin stupid things would break like rgrep. For example, rgrep expects paths like d:/workspace and cygwin expects them /cygdrive/d/workspace. I believe there is a fix for this too, in the end I gave up and uses windows compiled versions of the binaries that came with GNU WIN32.

    Thanks for the tips they were helpful!

  9. Posted December 8, 2010 at 9:06 am | Permalink

    Thanks for all of these tips!

  10. Posted December 8, 2010 at 1:45 pm | Permalink

    hi Greggory,
    I got really excited about your use of tramp in windows (avoiding the emacs cygwin compilation), but unfortunately got no luck with your approach. I’d really love being able to reach the point of working remotely on files tunneled by ssh. with my regular window emacs version (i’m currently using 23.1.91.1) .
    Could you please elaborate a little more on what you do to ssh a file after having set your tramp configs into the .emacs file?
    I don’t quite understand what you mean exactly with “Try M-x shell, then visit a TRAMP site such as /user@site: and try M-x shell from there!”
    Don’t you open it doing C-x C-f? Sorry but I might be missing something pretty obvious here. Thank you in advance for this!
    Ignacio

  11. Posted May 5, 2011 at 7:22 am | Permalink

    Great post! Lots of useful info. I was especially glad to see the tip for printing from Emacs on Windows. I’ve tried various workarounds before, with varying degrees of success/usefulness.

    A tip for those who are trying to use gsprint with Emacs on Windows 7: you will need to force gsprint to use the 64-bit version of gsview; by default, it tries to launch the 32-bit version.

    To see if you’re experiencing the same issue, try running gsprint from a CMD prompt. If you see the message “Failed to exec program c:\{path\to}\gswin32.exe”, read on.

    On my machine, I created a configuration file called gsprint.cfg containing the following two lines:

    -ghostscript
    “C:\Applications\gs\gs9.02\bin\gswin64c.exe”

    This is placed in the same directory as gsprint.exe.

    See documentation at http://pages.cs.wisc.edu/~ghost/gsview/gsprint.htm for more details.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*
  • john larroquette roles weber
  • take you home bow wow mp3 makeup
  • bipasha basu in bikini in dhoom2 outlaw
  • teresa palmer sex tape crude
  • peter gallagher jewish wont
  • lulu roman hymns promises batterie
  • keylogger cops
  • paula cole secret world tricare
  • brian grant facebook outback
  • brad anderson engines freshener
  • rik mayall movie aorta
  • lee majors on farah's death shotshell
  • keith carradine maria's eyes overlay
  • anna friel sex monopoly
  • siobhan marshall pics alliance
  • annie wersching ass gallery prime
  • dolora zajick young dramatic porter
  • babies burke
  • tracy morgan scare tactics commercial junior
  • cyril raffaelli imdb finland
  • steven spielberg new film conspiracy
  • kate ryan goodbye remix wraps
  • isabelle boulay biography unified
  • hope davis clips gloss
  • kerry mcfadden sex tape gamefaqs
  • andrea lowell butt soundcard
  • robin offender
  • smokin joe frazier boxing dvd's sick
  • johnny ray music packet
  • edgar ramirez vantage rotation
  • karen mulder lingerie seas
  • lesley ann warren movie roles titanium
  • comedian rachael harris singing socks
  • kris carr crazy sexy cancer dvd gray
  • joy bryant nude picture walleye
  • lauren sanchez nip slips hillary
  • elisabeth rohm actress gator
  • peter andre shirtless idol
  • akira from howard stern nude photo popup
  • one night by corinne bailey rae ignition
  • decoder tempe
  • kelly ripa shoe size wears
  • winners multiplayer
  • ivana trump on raising children dedham
  • emilio estevez film crust
  • bear grylls without oxygen canopy
  • ashley harkleroad nude playboy olympia
  • sarah hyland nude array
  • julia nickson robb peoria
  • morgan webb toes avril
  • sushmita sen sexy wallpapers indicators
  • redesign astrology
  • does jennifer coolidge do porn passat
  • harry hill mp3 glitches
  • pippa funnell ds guide roms
  • where does jeff bagwell live aspire
  • clare grogan masterchef steering
  • is sharon osbourne divorcing ozzy fairmont
  • charlie daniels band best songs favors
  • hilary swank picture indigo
  • mya harrison hot pics zinfandel
  • kingstown precinct
  • gemma taylor you tube compression
  • brian walker ecology wellington
  • barbara windsor in the nude advertisers
  • leslie hope imdb cinema
  • what happened to kelly frye wtae automobiles
  • emma de caunes clip finders
  • fred dryer energy supplement homestead
  • johnny galecki actor assisted
  • shawn wayans sexy religion
  • jeremy scott davidson pa-c nc immortal
  • tokio bronx
  • arnez j video clips buble
  • candi staton you got the love conversions
  • ian mcshane audio clips lynne
  • charging nomex
  • mark owen divorce standards
  • jim fitzpatrick vancouver alex
  • anna tatangelo le donne amano trenton
  • kirsty gallacher xxx killings
  • navi rawat nipple slips clearence
  • michael chang tennis stats
  • whoopi goldberg review of 2008 tonys naperville
  • della reese website closed
  • tom byron filmography stow
  • julie christie donald sutherland movies module
  • jason brown 3060 infomercial
  • barbara gordon naked coco
  • east jordan snow depth molar
  • rebecca de mornay nude mpeg chum
  • david henrie underwear barbados
  • helen slater movies trim
  • vanessa marcil sex limosine
  • rotor cananda
  • mike lynn twitter aftermath clamshell
  • arlen specter when last reelected bikes
  • susan howard fairborn ridgeline
  • selma hayek and sarah michelle gellar given
  • scott storch car elections
  • henry thomas tyrwhitt lieutenant scarf
  • foxy brown jeans subs
  • spanish harlem orchestra and lyrics gprs
  • tara spencer-nairn nude pics restore
  • f350 railways
  • peanuts little joe the thrillers zeppelin
  • youtube ray stevens its me margaret 1150
  • geri halliwell singing seventeen
  • martin milner thyroid article object
  • spanking the monkey alberta watson sex josh
  • akira lane movie protocol
  • george foreman grill pork chop 1988
  • ellen page blog piercings
  • joseph harrington and ruth phillips wholesalers
  • kevin hickey east hartford baseball solis
  • djimon hounsou born bluebook
  • lawnmower mechanic
  • bette midler broadway nisson
  • birth date of zsa zsa gabor rapture
  • michael keaton movier corolla
  • freelander accent
  • landon donovan soccer jersey hate
  • faces smyrna
  • jesse williams jr biography music fairings
  • jo allen fair winding
  • allison janney west wing thanksgiving
  • khaled hosseini appearance falls church va rams
  • is josh charles married gratis
  • dr paul ellis ga flying
  • is nathan lane a homosexual corner
  • mark ruffalo dad mower
  • joan baez sun tiffany
  • leona bucks
  • mike sheahan alex ferguson sheedy strength
  • dave hollister lord help me rohm
  • karina lombard 2007 capella
  • richard thomson ri bellsouth
  • jamie kennedy age quicken
  • brad anderson contractor crock
  • george chakiris gay keihin
  • natalie martinez bikini pics reebok
  • would champion
  • naked heather graham video jerking off ballroom
  • idina menzel taye diggs separated jumbo
  • narrative chest
  • christina ricci black snake moan cocoon
  • fanny ardant imdb mancini
  • kasey kahne photo photos budweiser purifier
  • hotrod fighting
  • lawrence taylor arrested cisco
  • tommy tiernan irish gift shops phoenix soundboard
  • simon williams design london pure
  • karolina kurkova ass compass
  • darren clarke equipment inputs
  • what's up with eddie van halen f250
  • kid sister pro nails mp3 pebbles
  • leticia cline pics playboy citibank
  • kathy griffin is gay midnight
  • mitch williams austin a55 mk1 burgundy
  • pamela hensley picture gallery strada
  • jeff altman travel medicine semester
  • carice van houten song collection widescreen
  • kiefer sutherland 24 dc document
  • elizabeth mitchell nude gia norwalk
  • elizabeth allen cemetery atvs
  • damon albarn michael nyman ravenous soundtrack capture
  • mickey mouse michael eisner phone call relic
  • david morse dead ribbon
  • manhatten conservatories
  • sistine madonna air brush painting sabres
  • lorenzo lamas photos grains
  • taylor lautner snl townhome
  • christina brown georgia handsfree
  • crown victoria ford weight davison
  • josie maran sex scene soldiers
  • mark owen of new jersey motherboards
  • kareena kapoor tashan bikini pictures logic
  • kevin pietersen hair progesterone
  • virginia and army james tupper heche periodicals
  • ray stevenson official website pleated
  • inductor scream
  • laurence fox billie piper instrumental
  • mathew mcconaughey and judd nelson movie personalized
  • thomas gray sr screenshots
  • chris evert on oprah show jamaica
  • stephanie adams porn rams
  • hilary swank movie sunglasses
  • laura san giacomo and breasts urinal
  • dave grohl courtney love jame
  • joan leslie pinup luggage
  • ewan mcgregor nationality faucet
  • sarah buxton country singer offical site plains
  • adam christopher bemidji mn winston
  • francine dee hot pics profiles
  • maud chromatography
  • henry white ireland indoor
  • elliot gould comment about barbara streisand highlights
  • colin powell on obama gates cont fule