Modified definitions for EmacsEverywhere
authoradefaria <adefaria@adefaria-lt.audience.local>
Tue, 19 Aug 2014 17:09:11 +0000 (10:09 -0700)
committeradefaria <adefaria@adefaria-lt.audience.local>
Tue, 19 Aug 2014 17:09:11 +0000 (10:09 -0700)
etc/EmacsEverywhere.txt [new file with mode: 0644]

diff --git a/etc/EmacsEverywhere.txt b/etc/EmacsEverywhere.txt
new file mode 100644 (file)
index 0000000..906f046
--- /dev/null
@@ -0,0 +1,132 @@
+;\r
+; AutoHotkey Version: 1.x\r
+; Language:       English\r
+; Platform:       Win9x/NT\r
+; Author:         David <tchepak@gmail.com>\r
+; Modified:       Andrew DeFaria <Andrew@ClearSCM.com>\r
+;\r
+; Script Function:\r
+;   Provides an Emacs-like keybinding emulation mode that can be toggled on and off using\r
+;   the ScrollLoke key.\r
+\r
+;==========================\r
+;Initialise\r
+;==========================\r
+#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.\r
+SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.\r
+SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.\r
+SetTitleMatchMode, RegEx\r
+\r
+enabledIcon := "emacs_everywhere_16.ico"\r
+disabledIcon := "emacs_everywhere_disabled_16.ico"\r
+IsInEmacsMode := false\r
+SetEmacsMode(false)\r
+\r
+;==========================\r
+;Functions\r
+;==========================\r
+SetEmacsMode(toActive) {\r
+  local iconFile := toActive ? enabledIcon : disabledIcon\r
+  local state := toActive ? "ON" : "OFF"\r
+\r
+  IsInEmacsMode := toActive\r
+  TrayTip, Emacs Everywhere, Emacs mode is %state%, 10, 1\r
+  Menu, Tray, Icon, %iconFile%,\r
+  Menu, Tray, Tip, Emacs Everywhere`nEmacs mode is %state%  \r
+\r
+  Send {Shift Up}\r
+}\r
+\r
+SendCommand(emacsKey, translationToWindowsKeystrokes, secondWindowsKeystroke="") {\r
+  global IsInEmacsMode\r
+  if (IsInEmacsMode) {\r
+    Send, %translationToWindowsKeystrokes%\r
+    if (secondWindowsKeystroke<>"") {\r
+      Send, %secondWindowsKeystroke%\r
+    }\r
+  } else {\r
+    Send, %emacsKey% ;passthrough original keystroke\r
+  }\r
+  return\r
+}\r
+\r
+;==========================\r
+;Emacs mode toggle\r
+;==========================\r
+ScrollLock::\r
+  SetEmacsMode(!IsInEmacsMode)\r
+return\r
+\r
+;==========================\r
+;Character navigation\r
+;==========================\r
+\r
+#IfWinActive ahk_class Chrome_WidgetWin_1\r
+$^f::SendCommand("^f","{Right}")\r
+$^s::SendCommand("^s","^g")\r
+#IfWinActive\r
+\r
+$^p::SendCommand("^p","{Up}")\r
+$^n::SendCommand("^n","{Down}")\r
+$^b::SendCommand("^b","{Left}")\r
+$^f::SendCommand("^f","{Right}")\r
+\r
+;==========================\r
+;Word Navigation\r
+;==========================\r
+\r
+$!p::SendCommand("!p","^{Up}")\r
+$!n::SendCommand("!n","^{Down}")\r
+$!f::SendCommand("!f","^{Right}")\r
+\r
+$!b::SendCommand("!b","^{Left}")\r
+\r
+;==========================\r
+;Line Navigation\r
+;==========================\r
+$^a::SendCommand("^a","{Home}")\r
+$^e::SendCommand("^e","{End}")\r
+\r
+;==========================\r
+;Page Navigation\r
+;==========================\r
+\r
+;Ctrl-V disabled. Too reliant on that for pasting :$\r
+$^v::SendCommand("^v","{PgDn}")\r
+$!v::SendCommand("!v","{PgUp}")\r
+$!<::SendCommand("!<","^{Home}")\r
+$!>::SendCommand("!>","^{End}")\r
+\r
+;==========================\r
+;Undo\r
+;==========================\r
+\r
+;==========================\r
+;===\r
+\r
+\r
+\r
+#IfWinNotActive ahk_class SWT_Window0\r
+$^/::SendCommand("^_","^z")\r
+#IfWinNotActive\r
+\r
+;==========================\r
+;Killing and Deleting\r
+;==========================\r
+#IfWinNotActive ahk_class mintty\r
+$^d::SendCommand("^d","{Delete}")\r
+\r
+$!d::SendCommand("!d","^+{Right}","{Delete}")\r
+$^h::SendCommand("^h","{Backspace}")\r
+\r
+$!Delete::SendCommand("!{Del}","^+{Left}","{Del}")\r
+\r
+#IfWinNotActive ahk_class (mintty|SWT_Window0)\r
+$^k::SendCommand("^k","+{End}","+{Delete}") ;cut region\r
+#IfWinNotActive\r
+\r
+$^w::SendCommand("^w","+{Delete}","{Shift Up}") ;cut region\r
+\r
+$!w::SendCommand("!w","^{Insert}","{Shift Up}") ;copy region\r
+\r
+$^y::SendCommand("^y","+{Insert}") ;paste
\ No newline at end of file