AutoHotkey Mode for Emacs (xahk-mode)

Xah Lee, 2010-01-09, 2010-02-17

This is the home page of xahk-mode, a emacs mode for editing AutoHotkey (AHK) scripts. (If you don't know what's AHK or emacs, see AutoHotkey Basics or Emacs Tutorial. )

Features

Buy xahk-mode Now

Use the Paypal button below and pay $3. In the Paypal description field, put “emacs xahk mode”. And i'll pass you the location to download as soon as i got your email. Please be sure to include your correct email address.

I can be contacted at xah@xahlee.org.

The code is licensed by GNU General Public License.

Usage and Features

Menu

autohotkey emacs xahk-mode

xahk-mode, showing its menu.

Reference Lookup

To lookup documentation of the word under cursor, type “Ctrl+c Ctrl+r” (xahk-lookup-ahk-ref). It'll switch you to the web browser of the function's documentation page at “autohotkey.com”.

Comment Uncomment Code

Type “Alt+;” (comment-dwim) to comment or uncomment current line or text selection in a smart way.

Keyword Completion

Typing “Esc Tab” will try to complete the word to the left of cursor to one of AHK's keyword. All the language's words are supported.

xahk-mode autocompletion

xahk-mode showing name completion.

Tip: If you are looking for a built-in word that has a name “key” in it, but you don't remember how it starts, you can type “Esc Tab” on a blank line, then it will list all AHK's buildin words. Then, you can switch cursor to the completion panel and do standard search.

Customizing xahk-mode

xahk-mode follows emacs's convention in choices of keyboard shortcuts. Many of them are not very convenient. If you prefer easier keys, or other conveniences, put the following code in your emacs init file “.emacs”.

(defun my-xahk-mode-customizations ()
  "Some customization for xahk-mode."
  (define-key xahk-mode-map (kbd "M-t") 'xahk-complete-symbol) ; Alt+t for completion
  (define-key xahk-mode-map (kbd "<f9>") 'xahk-lookup-ahk-ref)
)

(add-hook 'xahk-mode-hook 'my-xahk-mode-customizations)

You need to restart emacs.

If you would like emacs to display keyword completion suggestions using the color as shown in screenshot here, type “Alt+x customize-group Enter completion Enter”. Then, emacs will show a GUI for you to tweak. Edit the “Completions Common Part”. After you are done, click on “Save for Future Sessions” then “Finish”. Emacs will add elisp code to your emacs init file. The following is my personal settings.

(show-paren-mode 1) ; highlight matching pairs
(setq show-paren-style 'expression) ; highlight all code inbetween
(cua-mode 1) ; Ctrl + x c v keys for Cut Copy Paste

(custom-set-faces
  ;; custom-set-faces was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 '(completions-common-part ((t (:inherit default :foreground "red"))))
 '(show-paren-match ((((class color) (background light)) (:background "azure2")))))

Bugs and Wishlist

If you have any bug report or feature request, please post to the ErgoEmacs issues track at: http://code.google.com/p/ergoemacs/issues/list. (xahk-mode is part of ErgoEmacs distro.)

There is another AHK mode, but that mode has some problems. See: Emacs Ahk Mode Problems.

Home
Terms of Use
About
Advertise
Subscribe
Google
2009-06
© 2009 by Xah Lee.