This page are tips about using Emacs on Microsoft Windows. The info on this page is tested on Windows 7 and Windows Vista.
Where to download a ready-to-use emacs for Windows?
How to start emacs?
For Windows users, after download, unzip it. Go to the folder, in the “bin” dir, then click on file runemacs.exe to launch.
If you want to run emacs inside Windows Console, then start like this:
C:\Users\mary\apps\emacs-24.1\bin\emacs.exe -nw.
How to start emacs with default dir at home dir?
Create a Windows shortcut, which lets you start emacs from your home dir properly.
to create a file shortcut:
%home%.%home%\apps\emacs-24.1\bin\runemacs.exe -q --load=%home%\ErgoEmacs_dev\init.el --load=%home%\.emacs. Here, i suppress loading init files by -q, but load ErgoEmacs init files, then load my personal init files.Where to get language modes for Visual Basic, JavaScript, “cmd.exe”, PowerShell?
If you are using ErgoEmacs, they are all installed.
Otherwise:
A JavaScript mode is bundled with emacs 23.2 〔☛ Emacs 23.2 Features〕
There are several packages for cmd.exe batch file, written by different people. You may want to try them in the order listed here:
See also: How to Install Emacs Packages.
Where is emacs's init file located?
That depends on whether if you have the environment variable named “HOME”. (“HOME” should not be confused with a default Windows environment variable named “HOMEPATH”.) If you do have “HOME”, then emacs will look for it there. If you don't have “HOME”, emacs will look for init file at:
%HOMEPATH%\AppData\Roaming\%HOMEPATH%\Application Data\What's emacs's init file name?
By default, it is %HOME%/.emacs, or %HOME%/.emacs.el, or %HOME%/.emacs.d/init.el.
The file can be byte-compiled, ending in “.elc”.
How to find out if my emacs's init is loaded?
Type some garbage in your init file, then restart emacs. If emacs starts with error, then you know it's loaded.
Or, you can put the following code in your init file:
(set-background-color "pink")
When i type 【Ctrl+Space】, Windows switches me to other language input. What to do?
You can disable the Windows shortcut that switches you among input methods of different languages. Here's the exact instruction for Windows Vista. Other Windows version should be similiar.
Go to 〖Start ▸ Control Panel〗. Choose Classic View on the left. Then, double click on the “Regional and Language Options” icon, then go to “Keyboards and Languages” tab, click on “Change Keyboards…”. Then, go to “Advanced Key Settings” tab, then, it should list Key sequences on the right column. Select a input choice that has shortcut key, then click the button “Change Key Sequence”.
When i type 【Ctrl+Alt+s】, HP System info came up. How to disable that?
See: Disable Ctrl+Alt+S of HP Support Information.
If you have other key combo that mysteriously launches some other program, basically, you want to find the shortcut file that launches it, right click and choose “Properties”, then in Shortcut tab, change the shoctcut key field there.
How to run Bash shell or PowerShell inside emacs?
By default, the command named shell will run the interface to “cmd.exe”.
ErgoEmacs has several shells bundled. You can find them in the menu 〖Tools ▸ Shell〗. You can also call them by name.
| Emacs Command Name | Shell Interface To |
|---|---|
shell | Windows cmd.exe |
powershell | Windows PowerShell |
msys-shell | Bash (from MSYS) |
cmd-shell | Windows cmd.exe |
eshell | bash-like shell written in emacs lisp |
See also: Emacs: What's eshell? eshell vs shell Difference? ◇ PowerShell Tutorial.
FTP in GNU Emacs for Windows does not work?
If you are using ErgoEmacs or Lennart's EmacsW32, it should work out of the box.
GNU Emacs for Windows's ftp facilities are broken out of the box. The problem is due to some incompatibility of emacs ftp interface with Windows's bundled FTP program at 〔C:/Windows/system32/ftp.exe〕.
To find out what ftp program emacs is trying to interface, type this code:
(executable-find "ftp") in a empty file, select it, then call eval-region.
Two environment variable important to emacs are HOME and PATH.
Note: by default Windows 7 and Windows Vista has HOMEPATH, but not HOME.
You should set a HOME env var. Here's how you do it in cmd.exe:
REM example of setting HOME env var setx HOME "C:\Users\mary"
If you are running emacs within Cygwin, then the init file will be at 〔~/〕.
See: Windows Environment Variables Basic Tutorial.
See: Emacs: Set Environment Variables within Emacs.
Some of emacs's features require unix utilities. For example, spell
checking requires “aspell”, image thumbnail preview requires
ImageMagick, checking difference between files require diff,
listing files with particular suffix requires unix find (used by
find-dired).
ErgoEmacs has the complete set of unix utility bundled. They are in the dir 〔C:\Program Files (x86)\ErgoEmacs\msys\bin〕.
If you came from a unix background, and is not using ErgoEmacs, you may want to install unix shell and utilities such as {“diff”, “find”, “grep”, …}. There are 2 good solutions: Cygwin and MinGW.
Cygwin is a complete unix solution. After installing Cygwin core, you'll have Bash and grep, cat, awk, sort, uniq etc. You can also install any extra unix packages, for example: vi, svn, rsync, unison, wget, curl, git, gcc, X11, or entire KDE or Gnome.
MinGW is a minimal system derived from Cygwin. It is designed for compiling unix software on Windows. It includes the suite of shell utils, and gcc environment.
See also: Installing Cygwin Tutorial.