Removed /usr/local from CDPATH
[clearscm.git] / etc / EmacsEverywhere.txt
1 ;\r
2 ; AutoHotkey Version: 1.x\r
3 ; Language:       English\r
4 ; Platform:       Win9x/NT\r
5 ; Author:         David <tchepak@gmail.com>\r
6 ; Modified:       Andrew DeFaria <Andrew@ClearSCM.com>\r
7 ;\r
8 ; Script Function:\r
9 ;   Provides an Emacs-like keybinding emulation mode that can be toggled on and off using\r
10 ;   the ScrollLoke key.\r
11 \r
12 ;==========================\r
13 ;Initialise\r
14 ;==========================\r
15 #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.\r
16 SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.\r
17 SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.\r
18 SetTitleMatchMode, RegEx\r
19 \r
20 enabledIcon := "emacs_everywhere_16.ico"\r
21 disabledIcon := "emacs_everywhere_disabled_16.ico"\r
22 IsInEmacsMode := false\r
23 SetEmacsMode(false)\r
24 \r
25 ;==========================\r
26 ;Functions\r
27 ;==========================\r
28 SetEmacsMode(toActive) {\r
29   local iconFile := toActive ? enabledIcon : disabledIcon\r
30   local state := toActive ? "ON" : "OFF"\r
31 \r
32   IsInEmacsMode := toActive\r
33   TrayTip, Emacs Everywhere, Emacs mode is %state%, 10, 1\r
34   Menu, Tray, Icon, %iconFile%,\r
35   Menu, Tray, Tip, Emacs Everywhere`nEmacs mode is %state%  \r
36 \r
37   Send {Shift Up}\r
38 }\r
39 \r
40 SendCommand(emacsKey, translationToWindowsKeystrokes, secondWindowsKeystroke="") {\r
41   global IsInEmacsMode\r
42   if (IsInEmacsMode) {\r
43     Send, %translationToWindowsKeystrokes%\r
44     if (secondWindowsKeystroke<>"") {\r
45       Send, %secondWindowsKeystroke%\r
46     }\r
47   } else {\r
48     Send, %emacsKey% ;passthrough original keystroke\r
49   }\r
50   return\r
51 }\r
52 \r
53 ;==========================\r
54 ;Emacs mode toggle\r
55 ;==========================\r
56 ScrollLock::\r
57   SetEmacsMode(!IsInEmacsMode)\r
58 return\r
59 \r
60 ;==========================\r
61 ;Character navigation\r
62 ;==========================\r
63 \r
64 #IfWinActive ahk_class Chrome_WidgetWin_1\r
65 $^f::SendCommand("^f","{Right}")\r
66 $^s::SendCommand("^s","^g")\r
67 #IfWinActive\r
68 \r
69 $^p::SendCommand("^p","{Up}")\r
70 $^n::SendCommand("^n","{Down}")\r
71 $^b::SendCommand("^b","{Left}")\r
72 $^f::SendCommand("^f","{Right}")\r
73 \r
74 ;==========================\r
75 ;Word Navigation\r
76 ;==========================\r
77 \r
78 $!p::SendCommand("!p","^{Up}")\r
79 $!n::SendCommand("!n","^{Down}")\r
80 $!f::SendCommand("!f","^{Right}")\r
81 \r
82 $!b::SendCommand("!b","^{Left}")\r
83 \r
84 ;==========================\r
85 ;Line Navigation\r
86 ;==========================\r
87 $^a::SendCommand("^a","{Home}")\r
88 $^e::SendCommand("^e","{End}")\r
89 \r
90 ;==========================\r
91 ;Page Navigation\r
92 ;==========================\r
93 \r
94 ;Ctrl-V disabled. Too reliant on that for pasting :$\r
95 $^v::SendCommand("^v","{PgDn}")\r
96 $!v::SendCommand("!v","{PgUp}")\r
97 $!<::SendCommand("!<","^{Home}")\r
98 $!>::SendCommand("!>","^{End}")\r
99 \r
100 ;==========================\r
101 ;Undo\r
102 ;==========================\r
103 \r
104 ;==========================\r
105 ;===\r
106 \r
107 \r
108 \r
109 #IfWinNotActive ahk_class SWT_Window0\r
110 $^/::SendCommand("^_","^z")\r
111 #IfWinNotActive\r
112 \r
113 ;==========================\r
114 ;Killing and Deleting\r
115 ;==========================\r
116 #IfWinNotActive ahk_class mintty\r
117 $^d::SendCommand("^d","{Delete}")\r
118 \r
119 $!d::SendCommand("!d","^+{Right}","{Delete}")\r
120 $^h::SendCommand("^h","{Backspace}")\r
121 \r
122 $!Delete::SendCommand("!{Del}","^+{Left}","{Del}")\r
123 \r
124 #IfWinNotActive ahk_class (mintty|SWT_Window0)\r
125 $^k::SendCommand("^k","+{End}","+{Delete}") ;cut region\r
126 #IfWinNotActive\r
127 \r
128 $^w::SendCommand("^w","+{Delete}","{Shift Up}") ;cut region\r
129 \r
130 $!w::SendCommand("!w","^{Insert}","{Shift Up}") ;copy region\r
131 \r
132 $^y::SendCommand("^y","+{Insert}") ;paste