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