Red Antigua Logo slogan
Ads by Goooooogle
Search this site (by Google)
Menu
Home
About
Tools
Perl modules
Perl tutorials
C tutorials
Server configurations
UNIX on Windows
Misc. FreeBSD/UNIX
Redirect a web page
JavaScript
Virus list
Old stuff
Off topic

Tools    (top)
Your IP
Check a site for broken links
(W3C)

Perl modules    (top)
Tree::Numbered::Tools
(CPAN)
Perl tutorials    (top)
Perl modules
HTML::Template
CGI::Application
Mail::POP3Client
Mail::Send
MIME::Tools
Cookies with CGI::Application
Upload files with CGI::Application
Download files with CGI::Application
Redirect with CGI::Application
CPAN shell
Install DBD::mysql from the CPAN shell
Perl trim function
Validate an IP with Perl
Run suid Perl scripts under Apache
Perl taint mode
Perl date functions with Date::Calc

In Spanish
Curso de Perl

C tutorials    (top)
C - Introduction
C - Absolute beginner's Emacs
C - Examples for beginners
C - Makefile examples
C - Autotools examples
Server configurations    (top)
DNS
Apache
Apache Authentication and Access Control
mod_perl on FreeBSD
MySQL
MySQL add account
phpMyAdmin
Squid
DHCP

UNIX on Windows    (top)
Apache setup on Windows
MySQL setup on Windows
PHP setup on Windows
Perl setup on Windows
Emacs setup on Windows
UnxUtils
PuTTY
WinSCP
GIMP on Windows
MinGW - gcc on Windows
MSYS - make-in-a-shell on Windows
msysDTK - autotools on Windows
GDB for MinGW on Windows

Misc. FreeBSD/UNIX    (top)
CD and DVD creation on FreeBSD using 'k3b' on FreeBSD
'ipf' on FreeBSD
'pf' on FreeBSD
'su' on FreeBSD
Mount an ISO image under FreeBSD
Load the correct sound driver under FreeBSD without knowing what sound card you are using
Simultaneous sound channels on FreeBSD
Boot floppies for FreeBSD
Problems with old disks/controllers and the 'ata' driver
FreeBSD network stuff
DOS-to-UNIX file conversion
favicon.ico on UNIX
Emacs tips
Sendmail tips
GKrellm
Command Line Calculator
Save multimedia streams with 'mplayer'
xargs - solution to 'Argument list too long'
Process multiple images from the command line using 'ImageMagick'
Turn the system bell off under X Windows
Process each line in an input file from the command line (or in a shell script)
How to keep a program running in the background using 'nohup'
How to remove symbolic links in the current directory using 'find' and 'rm'
How to remove Emacs backup files in the current directory and all subdirectories using 'find' and 'rm'
How to execute .profile without logging in

Redirect a web page    (top)
Redirect to another web page
Apache redirect
C redirect
Perl redirect
PHP redirect
HTML redirect
JavaScript redirect

Javascript    (top)
Trim function
Login form
Register form
Popup window

Virus list    (top)
Latest viruses - Computer Virus HQ (external)
Latest 10 viruses - Sophos

Links    (top)
HTML and PHP Scripts - Html Web Template

Old stuff    (top)
POP3 server setup
About AnyMail
AnyMail downloads

Off topic    (top)
Personal links

Validated by
Valid HTML 4.01!
Valid CSS!
Powered by
apache.org
Emacs setup on Windows
Emacs setup on Windows

See also:
Emacs tips
Absolute beginner's Emacs

This tutorial describes how to setup Emacs on Windows (tested with Emacs 21.3 and Emacs W32 22.0.92.1 on Windows XP Professional).
In my case, Emacs 21.3 and Emacs W32 22.0.92.1 co-exist on the same Windows box.
That's why I use a (not so elegant) solution with 3 .emacs files:
  1. .emacs-win (save as .emacs on your local box)
  2. .emacs21.el
  3. .emacs22.el
See Emacs stuff for general Emacs info.

Install the Emacs binary
Download the precompiled Windows binary of Emacs from ftp://ftp.gnu.org/gnu/emacs/windows/.
Select the emacs-XX.Y-bin-i386.tar.gz file (emacs-21.3-bin-i386.tar.gz at the time of this writing).
Extract the downloaded .tar.gz file.
Two examples of freeware tools for GZIP-files are 7-Zip and UnxUtils (the latter is described in detail here).
The GZIP file contains one folder called emacs-XX.Y (emacs-21.3 in my case).
You can put the folder wherever you want; I chose C:\.
That's all what's needed, now run C:\emacs-21.3\bin\runemacs.exe (either by double-clicking the executable icon, or from the command prompt, both ways work fine).
If you want Emacs to appear in your Start Menu, run C:\emacs-21.3\bin\addpm.exe.

Install Emacs W32 using an installer
Download the latest Emacs W32 binary from http://www.ourcomments.org/cgi-bin/emacsw32-dl-latest.pl.
(I use the patched version.)
Just follow the instructions as with any Windows installer.

Configure Emacs to use packages
Most Emacs packages are written in Emacs Lisp (with the .el file extension), so they are platform independent and will thus work fine on Windows.
Let's say you have a friend using Emacs on any UNIX-like platform.
Just ask her/him for a copy of the folder of the Emacs packages.
(If you don't have any UNIX-like friends, you can also search the Net for Emacs packages. ;-)
Save the folder on your computer as C:\emacs-packages\.
Edit the C:\.emacs file (created automatically the first time you use Emacs).
Add the following lines, so Emacs can find the path to the packages:
(setq load-path
      (cons "c:\emacs-packages" load-path))
An example:
To use the package highlight-current-line.el, add the following lines to .emacs (requires the package to be installed as C:\emacs-packages\highlight-current-line.el):
(require 'highlight-current-line)
;; If you want to mark only to the end of line:
(highlight-current-line-whole-line-on nil)
;; switch highlighting on
(highlight-current-line-on t)
(highlight-current-line-set-bg-color "#dfdfe0")
(highlight-current-line-set-fg-color "#666666")
Exit and run Emacs again, the current line of editing should now be highlighted.

Configure Emacs to different setups depending on Emacs version
The reason why I installed two different versions of Emacs on the same box was because of the problems I had with setting up TRAMP properly (see below).
In my case, I mainly use Emacs to edit remote files on two different boxes:
  1. FreeBSD with SSH, without FTP
  2. AIX with SSH and FTP
In the case of the FreeBSD box, I had no other choice than using TRAMP.
In the case of AIX, I could choose between TRAMP and Ange-FTP.
For some reason, Emacs 21.3 and Ange-FTP was the best choice when connecting to the AIX box.
For some reason, Emacs 22.0.92.1 and TRAMP was the best choice when connecting to the FreeBSD box.
(I admit that using two versions of Emacs depending where you want to connect is a bit messy, but it was the only working solution at the moment. At the time of writing this, Emacs 22.1 is about to be released, and TRAMP will be included. I hope that will fix the mess.)
Resume:
  1. Edit remote files on FreeBSD: Use Emacs 22.0.92.1 and TRAMP
  2. Edit remote files on AIX: Use Emacs 21.3 and Ange-FTP
When Emacs starts, it loads it configuration from C:\.emacs, independent of version. That means Emacs has to be setup C:\.emacs to conditionally load TRAMP or Ange-FTP, depending on which Emacs version was invoked.
Add the following lines to .emacs:
(cond ((< emacs-major-version 21)
       ;; Emacs 20 customization. (non-existing)
       (setq custom-file "~/.emacs20.el"))
      ((and (= emacs-major-version 21) (< emacs-minor-version 4))
       ;; Emacs 21 customization, before version 21.4.
       (setq custom-file "~/.emacs21.el"))
      ((< emacs-major-version 22)
       ;; Emacs version 21.4 or later. (non-existing).
       (setq custom-file "~/.emacs21.4.el"))
      (t
       ;; Emacs version 22.1 or later.
       (setq custom-file "~/.emacs22.el")))

(load custom-file)

Create .emacs21.el (for Ange-FTP):
;; ange-ftp stuff
(require 'ange-ftp)

(setq ange-ftp-ftp-program-name "c:/programs/ftp.exe")
;; customize the temporary directory that ange-ftp uses to cache files
(setq ange-ftp-tmp-name-template
      (concat (expand-file-name (getenv "TEMP")) "/ange-ftp"))
(setq ange-ftp-gateway-tmp-name-template
      (concat (expand-file-name (getenv "TEMP")) "/ange-ftp"))

and .emacs22.el (for TRAMP):
;; tramp stuff - from http://www.jenandgreg.org/cgi-bin/gradwiki?Windows
(add-to-list 'load-path "c:/emacs-packages/tramp-2.1.4/lisp")
(add-to-list 'load-path "c:/emacs-packages/tramp-2.1.4/contrib")

;; shell-prompt-pattern stuff
(require 'tramp)
(setq tramp-default-method "plink")
(setq shell-prompt-pattern "^[^#$%>\n]*[#$%>] *")

;; change the remote path to match yours
(setq tramp-remote-path (append '("/home/redantig/bin"
				  ) tramp-remote-path  ))

;; for debugging
;;(setq tramp-verbose 10)
;;(setq tramp-debug-buffer t)

(setq tramp-auto-save-directory "c:/temp")

(setq password-cache-expiry nil)


Setup Ange-FTP on Windows
The ange.el package itself is included in Emacs, so you can use it out-of-the-box, but it is recommended to not use the default Microsoft FTP client.
Create the C:\programs folder and download ftp.exe to it (if you prefer another path, don't forget to change ange-ftp-ftp-program-name in .emacs21.el).


Setup TRAMP on Windows
Setting up TRAMP was a lot more tricky. As mentioned, it will be incorporated into Emacs in version 22.1, so probably you don't need follow all the steps I had to. First of all, you need a SSH client. PuTTY seems to be the one most popular one for Microsoft Windows. Don't forget to add
C:\Program Files\PuTTY
to your PATH environment variable (in Control Panel->System->Advanced), or Emacs will not find the PuTTY program plink, used as SSH client.

I tested forth and back with different TRAMP versions, before I finally used 2.1.4 (the newest version at writing time is 2.1.8).
You can download TRAMP from ftp://ftp.gnu.org/gnu/tramp/.
(Maybe you are luckier with newer versions than I was, always give a try.)
Unpack tramp-2.1.4.tar.gz in C:\emacs-packages\ with 7-Zip.
Now to the hack:
When trying to load TRAMP, Emacs complains about the missing file trampver.el.
You are supposed to generate it from trampver.el.in using configure. I have no tools to run configure on my Windows box, so instead I created trampver.el manually.
In the subdirectory tramp-2.1.4\lisp, copy trampver.el.in to trampver.el.
Edit trampver.el (at the end of the file).

Before:
(defconst tramp-version "@PACKAGE_VERSION@"
  "This version of Tramp.")

(defconst tramp-bug-report-address "@PACKAGE_BUGREPORT@"
  "Email address to send bug reports to.")

;; Check for (X)Emacs version.
(let ((x @TRAMP_EMACS_VERSION_CHECK@))
  (unless (string-match "\\`ok\\'" x) (error x)))

(provide 'trampver)
After:
(defconst tramp-version "2.1.4"
  "This version of Tramp.")

(defconst tramp-bug-report-address "tramp-devel@gnu.org"
  "Email address to send bug reports to.")

;; Check for (X)Emacs version.
;;(let ((x @TRAMP_EMACS_VERSION_CHECK@))
;;  (unless (string-match "\\`ok\\'" x) (error x)))

(provide 'trampver)
Exit from and start Emacs again (or reload C:\.emacs), and you should be able to edit remote files via SSH.
To edit a remote file (regardless of using Ange-FTP or TRAMP) the syntax for the full path is
C-x C-f /user@host:/path/to/file/or/dir
(First time you connect to the remote server, you are asked for a password, then it is like editing any local file.)

Sometimes the connection seems to "hang". Just press
C-g
and you should return to life. ;-)

By the way, the colorful configuration file sections on this page were mainly created using htmlize, included in Emacs W32.
Just select a region in any file, type
htmlize-region
and Emacs will create a new buffer with a HTML version of your file, with highlighted text and everything.


Read more about Emacs for Windows at:
http://www.gnu.org/software/emacs/windows/.
http://ourcomments.org/cgi-bin/emacsw32-dl-latest.pl

Last modified: Wed Nov 21 12:44:38 Romance Standard Time 2007