Emacs AutoHotkey Mode Problems

By Xah Lee. Date: . Last updated: .

This page documents some problems of the “ahk-mode.el” for emacs by Robert Widhopf-Fenk.

(This is the one bundled with AHK as of 2009, version 1.0.48.3. The elisp package's version number is “Version: $Id: ahk-mode--main--1.0--patch-13$”)

If you are looking for a alternative AHK mode, you might try AutoHotkey Mode (xahk-mode.el) For Emacs (written by me.)

Syntax Coloring Problem

Letter Case Sensitivity

AHK is not case sensitive. “IfWinActive” is the same as “IFWINACTIVE”. However, the syntax coloring in this mode requires all the command/keywords/function etc names to be properly camel-cased for it to have syntax color. Compare:

#SingleInstance force
#singleInstance force

Some Function Names Not Colored

The packages misses some common functions used by the language, even if properly capitalized. Here are some example of words not syntax colored: IsFunc FileExist WinActive WinExist.

You can open file c:/Program Files (x86)/AutoHotkey/Extras/Editors/Syntax/Functions.txt and activate the ahk-mode and see all the function words it misses.

Other keywords are not colored. For example, the “force” and “on” keywords in:

#SingleInstance force
DetectHiddenWindows, on

Bad Syntax Coloring on Comments

Some comments are not correctly colored. Example:

; Home::
; WinGet, processName, processname, A
; if (processName = "safari.exe")
;   Send ^{Tab}
; Return

Bad Syntax Table

if you move cursor by word over “$F4::”, it thinks that “::” and “$” are part of the word.

Because AHK is primarily used to define hotkeys, so any AHK script has a lot such lines. This makes the package quite annoying.

Auto Formatting Breaks Code

When you press Enter, it tries to smartly format your line into mulitple lines with indentations, but this often is not desired, and sometimes break your string into separate lines, making a valid code into invalid code.

For example, suppose you have this line in a valid script:

Else If (WinActive("ahk_class Emacs") Or WinActive("ahk_class Chrome_WidgetWin_0")

When you press Enter at the end of line, it changes your code into this:

Else If (WinActive("ahk_class Emacs") Or WinActive("ahk_class
Chrome_WidgetWin_0")

If you save the file and reload the script, the compiler reports a error.

Reference Lookup Problem

It has a feature that lets you lookup the doc of keywords, but it assumes you have emacs's w3m package installed.

(w3m is a emacs interface to a text-based web browser program called W3m. The purpose is to allow you to browse the web in emacs. The emacs w3m package is not bundled in any major emacs distribution (not in GNU Emacs, Carbon Emacs, Aquamacs Emacs, NeXTStep emacs (aka “Emacs.app”), Lennart's EmacsW32, ErgoEmacs, or most Linux's packaged emacs.), nor is the required text browser w3m installed by default in any OS (possibly except some Linuxes.))

No Support For Keyword Completion

The package does not support language word completion. (this is a not a major problem, since many major language modes also do not support this by default. However, word completion is extremely convenient, because it is often used to find out which command to use or exist.)

Like it? Buy Xah Emacs Tutorial. Thanks.

or, buy something from Best Keyboard for Emacs