Emacs AutoHotkey Mode (ahk-mode)

, , …,

This is the home page of xahk-mode, a emacs mode for editing AutoHotkey (AHK) scripts. (See also: AutoHotkey TutorialEmacs Tutorial. )

Features

Usage and Features

Menu

autohotkey emacs xahk-mode
xahk-mode, showing its menu.

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 pane and do standard search.

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 www.autohotkey.com.

Customizing xahk-mode

“xahk-mode” follows emacs's convention 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."
  (local-set-key (kbd "M-t") 'xahk-complete-symbol) ; Alt+t for name completion
  (local-set-key (kbd "<f9>") 'xahk-lookup-ahk-ref) ; F9 for reference lookup
)

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

Select the above code, then type 【Alt+x eval-buffer】. Then, close any ahk files and re-open them. Or, you can just 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.

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

Buy xahk-mode Now

Download the mode for $5. Use the paypal button below. In the comment field, put “emacs ahk mode”. I'll email you the download link. Make sure your email address is included and correct.

blog comments powered by Disqus