def __init__(self): # this needs to run before any user modes are imported self.epoll = select.epoll() self.timers = [] EventLoop.event_loop = self self.run = True self.events = collections.deque() self.eventsLock = Lock() self.eventSubscribers = {} self.fileSubscribers = {} self.dfly = DragonflyThread(('', 23133), self) self.win = WindowEventWatcher(self, filterWindows) self.subscribeEvent(RestartEvent, self.restart) self.subscribeEvent(ExitEvent, self.stop) mapping = { "restart mandimus": (lambda x: self.put(RestartEvent())), "completely exit mandimus": (lambda x: self.put(ExitEvent())) } self.MainControlRule = makeContextualRule( "MainControlRule", mapping, ruleType=RuleType.INDEPENDENT) self.MainControlRule.activate()
def _buildRule(self): mapping = {} for command in self.cmdWords: mapping[command] = None self.actionRule = makeHashedRule(self._actionRuleName, mapping, ruleType=RuleType.INDEPENDENT) pushEvent(RuleRegisterEvent(self.actionRule)) mapping = {} extras = [] for i in range(self.MAX_SUBWORDS): for j in range(i+1): phrase = [] for k in range(j, self.MAX_SUBWORDS): optional = (k != j) refString = "<" + self._wordListRefName(i, k) + ">" if optional: refString = "[%s]" % refString phrase.append(refString) extras.append(ListRef(self._wordListName(i, k), self._wordListRefName(i, k), [])) phrase = " ".join(phrase) mapping[phrase] = None self.wordRule = makeHashedRule(self._wordRuleName, mapping, extras, ruleType=RuleType.INDEPENDENT) pushEvent(RuleRegisterEvent(self.wordRule)) wordRulePart = "<%s>" % self._wordRuleRefName if self.allowNoChoice: wordRulePart = "[%s]" % wordRulePart phrase = ("<%s>" % self._actionRuleRefName) + " " + wordRulePart mapping = { phrase : self._onSelection } extras = [ RuleRef(self.actionRule, self._actionRuleRefName), RuleRef(self.wordRule, self._wordRuleRefName), ] self.rule = makeContextualRule(self._ruleName, mapping, extras, ruleType=self.ruleType) log.info("new crazy rule: [%s]" % self.rule.rule.rule.mapping) log.info("new crazy rule extras: [%s]" % self.rule.rule.rule.extras)
def _buildRule(self, requirements, keywords): listRule = makeKeywordListRule(self.name + "-list", keywords) pushEvent(RuleRegisterEvent(listRule)) verbRule = "_".join([self.name, "mode_verb_rule"]) kwRule = "_".join([self.name, "keyword"]) mapping = { ("<%s> <%s>" % (verbRule, kwRule)) : KeywordCmd(keywords, verbRule, kwRule), } extras = [ RuleRef(VerbRule, verbRule), RuleRef(listRule, kwRule), ] KeywordRule = makeContextualRule(self.name, mapping, extras) KeywordRule.context.addRequirement(IsEmacs) for r in self.requirements: KeywordRule.context.addRequirement(r) return KeywordRule
def __init__(self): # this needs to run before any user modes are imported self.epoll = select.epoll() self.timers = [] EventLoop.event_loop = self self.run = True self.events = collections.deque() self.eventsLock = Lock() self.eventSubscribers = {} self.fileSubscribers = {} self.dfly = DragonflyThread(('', 23133), self) self.win = WindowEventWatcher(self, filterWindows) self.subscribeEvent(RestartEvent, self.restart) self.subscribeEvent(ExitEvent, self.stop) mapping = { "restart mandimus" : (lambda x: self.put(RestartEvent())), "completely exit mandimus" : (lambda x: self.put(ExitEvent())) } self.MainControlRule = makeContextualRule("MainControlRule", mapping, ruleType=RuleType.INDEPENDENT) self.MainControlRule.activate()
def __init__(self, name, cmd, eventType, interval=1): self.cmd = cmd self.interval = 1 self.inFrame = True self.allowError = False self.logging = False self.lastOutput = None self.eventType = eventType self.toggle = Toggle() self.toggle.enable() self.context = Context(set([self])) self.context.addRequirement(IsEmacs) self.context.addRequirement(self.toggle) self.context.addRequirement(EmacsEventGenerator.clsToggle) _mapping = { "toggle " + name + " generator": self.toggleEnabled, "toggle " + name + " logging": self.toggleLogging, } self.toggleRule = makeContextualRule(name + "ToggleRule", _mapping) self.toggleRule.activate() # always on
def __init__(self, name, cmd, eventType, interval=1): self.cmd = cmd self.interval = 1 self.inFrame = True self.allowError = False self.logging = False self.lastOutput = None self.eventType = eventType self.toggle = Toggle() self.toggle.enable() self.context = Context(set([self])) self.context.addRequirement(IsEmacs) self.context.addRequirement(self.toggle) self.context.addRequirement(EmacsEventGenerator.clsToggle) _mapping = { "toggle " + name + " generator" : self.toggleEnabled, "toggle " + name + " logging" : self.toggleLogging, } self.toggleRule = makeContextualRule(name + "ToggleRule", _mapping) self.toggleRule.activate() # always on
# "show top" : Cmd("(etc-start-or-open-top)"), "open temp" : Cmd("(md-create-temp-file \"temp\")"), "toggle command logging" : toggleCommandLogging, "toggle refresh client" : toggleRefreshClientSources, "magnify [<i>]" : Key("c-t,c-plus:%(i)d"), "demagnify [<i>]" : Key("c-t,c-minus:%(i)d"), # "compile" : Minibuf("compile"), "visual line mode" : Minibuf("visual-line-mode"), "set indent <j>" : Cmd("(etc-set-indent-preference %(j)d)"), "toggle namespace indent" : Cmd("(etc-toggle-namespace-indent)"), "toggle read only" : Key("c-t,c-q"), } # EmacsIsolatedRule = makeContextualRule("EmacsIsolated", _mapping, emacsExtras, emacsDefaults, ruleType=RuleType.INDEPENDENT) EmacsIsolatedRule = makeContextualRule("EmacsIsolated", _mapping, emacsExtras, emacsDefaults) EmacsIsolatedRule.context.addRequirement(IsEmacs) _mapping = { "help function" : Key("c-h,f"), "help function slap" : Key("c-h,f,enter"), "help variable" : Key("c-h,v"), "help variable slap" : Key("c-h,v,enter"), "help key" : Key("c-h,k"), "help mode" : Key("c-h,m"), "help docks" : Key("c-h,d"), "help news" : Key("c-h,n"), "help info" : Key("c-h,i"), "help syntax" : Key("c-h,s"), "help bindings" : Key("c-h,b"),
import rules.BaseRules as BaseRules from rules.emacs.Cmd import CharCmd, Cmd, Minibuf, Key from rules.ContextualRule import makeContextualRule from requirements.Emacs import IsEmacs from rules.emacs.common import emacsExtras, emacsDefaults _mapping = { # hot "after" : Key("ca-f"), "before" : Key("ca-b"), "dive" : Key("ca-d"), "back dive" : Key("cs-d"), "away" : Key("ca-o"), "back away" : Key("cs-u"), "peak" : Key("ca-n"), "boo" : Key("ca-p"), "start" : Key("c-home"), "close" : Key("c-end"), "slurp" : Key("ca-y"), "back slurp" : Key("ca-g"), "peel" : Key("ca-j"), # cold "pair barf" : Key("ca-v"), "pair back barf" : Key("ca-k"), "pair split" : Key("ca-i"), "pair rewrap" : Key("ca-z"), } PairCmdRule = makeContextualRule("PairCmd", _mapping, emacsExtras, emacsDefaults) PairCmdRule.context.addRequirement(IsEmacs)
from requirements.ModeRequirement import ModeRequirement from rules.emacs.common import emacsExtras, emacsDefaults from rules.emacs.Cmd import Cmd from rules.emacs.Keywords import KeywordRule keywords = [ "always", "end", "ifnone", "or", "rpmos", "tranif1", "and", "endcase", "initial", "output", "rtran", "tri", "assign", "endmodule", "inout", "parameter", "rtranif0", "tri0", "begin", "endfunction", "input", "pmos", "rtranif1", "tri1", "buf", "endprimitive", "integer", "posedge", "scalared", "triand", "bufif0", "endspecify", "join", "primitive", "small", "trior", "bufif1", "endtable", "large", "pull0", "specify", "trireg", "case", "endtask", "macromodule", "pull1", "specparam", "vectored", "casex", "event", "medium", "pullup", "strong0", "wait", "casez", "for", "module", "pulldown", "strong1", "wand", "cmos", "force", "nand", "rcmos", "supply0", "weak0", "deassign", "forever", "negedge", "real", "supply1", "weak1", "default", "for", "nmos", "realtime", "table", "while", "defparam", "function", "nor", "reg", "task", "wire", "disable", "highz0", "not", "release", "time", "wor", "edge", "highz1", "notif0", "repeat", "tran", "xnor", "else", "if", "notif1", "rnmos", "tranif0", "xor" ] # VerilogKeywordRule = KeywordRule(["verilog-mode"], keywords) _mapping = {} VerilogRule = makeContextualRule("verilog", _mapping, emacsExtras, emacsDefaults) VerilogRule.context.addRequirement(IsEmacs) VerilogRule.context.addRequirement(ModeRequirement(modes=["verilog-mode"]))
"game facks [<text>]" : WebSearch("gfaqs"), "images [<text>]" : WebSearch("im"), "stack overflow [<text>]" : WebSearch("so"), "search <text>" : WebSearch(""), } _extras = [ Dictation("text"), Integer("n", 3, 20), ] _defaults = { 'n' : 1, } ChromeSearchRule = makeContextualRule("ChromeSearch", _mapping, _extras, _defaults, ruleType=RuleType.TERMINAL) ChromeSearchRule.context.addRequirement(IsChrome) _mapping = { "new tab" : Key("c-t"), "new window" : Key("c-n"), "new incognito window" : Key("cs-n"), "close [<n>]" : Key("c-w:%(n)d"), "address" : Key("c-l"), "next [<n>]" : Key("c-tab:%(n)d"), "previous [<n>]" : Key("cs-tab:%(n)d"), "(reopen tab | undo close tab)" : Key("cs-t"), "back [<i>]" : Key("a-left:%(i)d"), "forward [<i>]" : Key("a-right:%(i)d"), "refresh" : Key("F5"), "reopen tab" : Key("cs-t"),
from Actions import Key from rules.ContextualRule import makeContextualRule from requirements.Emacs import IsEmacs from requirements.ModeRequirement import ModeRequirement from rules.emacs.common import emacsExtras, emacsDefaults # Term mode issues: # -Can wreck prompt and previous output # -Completion won't work, because we need to emulate moving cursor and pressing TAB _mapping = { "line mode": Key("c-c,c-j"), "care mode": Key("c-c,c-k"), } TermRule = makeContextualRule("Term", _mapping, emacsExtras, emacsDefaults) TermRule.context.addRequirement(IsEmacs) TermRule.context.addRequirement(ModeRequirement(modes="term-mode"))
# "lesser" : "'angles", # } # mapping = { # "mark" : "'mark", # "cut" : "'cut", # "copy" : "'copy", # "dupe" : "'dupe", # "swap" : "'swap", # } _mapping = { "zap <charrule> [<i>]" : CharCmd("(zap-up-to-char 1 %s)"), "taze <charrule> [<i>]" : CharCmd("(zap-up-to-char -1 %s)"), #"fizz <charrule> [<i>]" : CharCmd("(md-copy-up-to-char 1 %s)"), #"buzz <charrule> [<i>]" : CharCmd("(md-copy-up-to-char -1 %s)"), "trans [<i>]" : Key("ca-t"), "rise [<n>]" : Key("a-up:%(n)d"), "drop [<n>]" : Key("a-down:%(n)d"), #"var <charrule> [<n>]" : CharCmd("(md-insert-text (char-to-string %s) t nil)"), "homophone" : Cmd("(md-cycle-homophones-at-point)"), "sort lines" : Cmd("(call-interactively #'sort-lines)"), "make score" : Key("c-c,m,s"), "make stud" : Key("c-c,m,c"), "make camel" : Key("c-c,m,l"), "make upper" : Key("c-c,m,u") } EditRule = makeContextualRule("Edit", _mapping, emacsExtras, emacsDefaults) EditRule.context.addRequirement(IsEmacs)
"wait", ["wc", "word count"], "which", "while", ["xargs", "X args"], ["zsh", "Z shell"], "crontab", "sleep", [">", "stood out"], ["2>", "stood err"], ["&>", "stood both"], ] EShellKeywordRule = KeywordRule(["eshell-mode"], _keywords) _mapping = { "back [<i>]" : Key("b,enter") * Repeat(extra="i"), "forward [<i>]" : Key("f,enter") * Repeat(extra="i"), "surface [<i>]" : (EmacsText("up") + Key("enter")) * Repeat(extra="i"), "history" : Key("a-r"), "interrupt" : Key("c-c,c-c"), "prompt up [<n>]" : Key("c-c,c-p:%(n)d"), "prompt down [<n>]" : Key("c-c,c-n:%(n)d"), } EShellRule = makeContextualRule("Shell", _mapping, emacsExtras, emacsDefaults) EShellRule.context.addRequirement(IsEmacs) EShellRule.context.addRequirement(ModeRequirement(modes=["eshell-mode"]))
"slap [<n>]": Key("enter:%(n)d"), "history": Key("c-r"), "background": Key("c-z"), "interrupt": Key("c-c,c-c"), "chip [<n>]": Key("c-w:%(n)d"), "pitch [<n>]": Key("a-d:%(n)d"), "run top": Text("top") + Key("enter"), "run H top": Text("htop") + Key("enter"), "switch user": Text("su - "), "C D": Text("cd "), "run D message": Text("dmesg") + Key("enter"), "S S H": Text("ssh "), # Also in the emacs rules, but since emacs rules are mutually exclusive with these # both definition should never be active at the same time. "view <charrule>": CharCmd("(md-select-window-with-glyph %s)"), } _extras = [ Dictation("text"), Integer("n", 3, 20), Integer("i", 3, 8), ] _defaults = { 'n': 1, 'i': 1, } TerminalRule = makeContextualRule("Terminal", _mapping, _extras, _defaults) TerminalRule.context.addRequirement(IsTerminal)
from rules.ContextualRule import makeContextualRule from requirements.Emacs import IsEmacs from requirements.ModeRequirement import ModeRequirement from rules.emacs.common import emacsExtras, emacsDefaults from rules.emacs.Cmd import Cmd from rules.emacs.Text import EmacsText from protocol import RuleType IsErcMode = ModeRequirement(modes="erc-mode") _mapping = { "slash join [<text>]" : EmacsText("/join #%(text)s"), "slash me [<text>]" : EmacsText("/me %(text)s"), } ERCTextRule = makeContextualRule("ERCText", _mapping, emacsExtras, emacsDefaults, ruleType=RuleType.TERMINAL) ERCTextRule.context.addRequirement(IsEmacs) ERCTextRule.context.addRequirement(IsErcMode) _mapping = { "prior" : Key("a-p"), "future" : Key("a-n"), "smiley wink" : EmacsText(";)"), "smiley tongue" : EmacsText(":P", lower=False), "smiley wink tongue" : EmacsText(";P", lower=False), "slash part" : EmacsText("/part"), "kick dragon" : EmacsText("/me kicks Dragon"), "slash message" : EmacsText("/msg"), "slash whois" : EmacsText("/whois"), }
"stack overflow [<text>]": WebSearch("so"), "search <text>": WebSearch(""), } _extras = [ Dictation("text"), Integer("n", 3, 20), ] _defaults = { 'n': 1, } ChromeSearchRule = makeContextualRule("ChromeSearch", _mapping, _extras, _defaults, ruleType=RuleType.TERMINAL) ChromeSearchRule.context.addRequirement(IsChrome) _mapping = { "new tab": Key("c-t"), "new window": Key("c-n"), "new incognito window": Key("cs-n"), "close [<n>]": Key("c-w:%(n)d"), "address": Key("c-l"), "next [<n>]": Key("c-tab:%(n)d"), "previous [<n>]": Key("cs-tab:%(n)d"), "(reopen tab | undo close tab)": Key("cs-t"), "back [<i>]": Key("a-left:%(i)d"), "forward [<i>]": Key("a-right:%(i)d"),
try: int(w, 16) newWords.remove(w) except ValueError: pass #log.info("Not filtering: [%s]" % w) return newWords _actions = [ "go", "doog", ] _wordActions = ["word"] + [w + " word" for w in _actions] _symbolActions = ["toke"] + [w + " toke" for w in _actions] _emacsWordNameSelector = EmacsWordNames("EmacsWordNames", _wordActions, EmacsWordEvent) _emacsSymbolNameSelector = EmacsWordNames("EmacsSymbolNames", _symbolActions, EmacsSymbolEvent) _mapping = { "again word": Cmd("(md-cycle-token 'word)"), "again toke": Cmd("(md-cycle-token 'symbol)"), } ControlWordsRule = makeContextualRule("ControlWordsRule", _mapping) ControlWordsRule.context.addRequirement(IsEmacs)
_extras = [ Integer("i", 3, 8), Integer("n", 3, 72), Integer("digit", 0, 10), Dictation("text"), RuleRef(AlphaRule, "alpharule"), RuleRef(CharRule, "charrule"), ] _defaults = { "n": 1, "i": 1, } AlwaysRule = makeContextualRule("Always", _mapping, _extras, _defaults) AlwaysRule.activate() _extras = [ Dictation("text") ] _mapping = { "type <text>" : Text("%(text)s", False), } TypingRule = makeContextualRule("TypingRule", _mapping, _extras, {}, RuleType.TERMINAL) TypingRule.context.addRequirement(NotEmacs) _mapping = { "camel <text>" : Camel("%(text)s"),
"set break point" : Key("c-t,c-a,c-b"), "delete break point" : Key("c-t,c-a,c-d"), "good step [<i>]" : Key("c-t,c-a,c-s") * Repeat(extra="i"), "good next [<i>]" : Key("c-t,c-a,c-n") * Repeat(extra="i"), "good instruction [<i>]" : Key("c-t,c-a,c-i") * Repeat(extra="i"), "good eval" : Key("c-t,c-a,c-p"), "good continue" : Key("c-t,c-a,c-r"), "good up" : Key("c-t,c-a,langle"), "good down" : Key("c-t,c-a,rangle"), "good until" : Key("c-t,c-a,c-u"), "good finish" : Key("c-t,c-a,c-f"), "good jump" : Key("c-t,c-a,c-j"), } # TODO: check gdb-running/gdb-stopped variable GnuDebuggerRule = makeContextualRule("GnuDebugger", _mapping, emacsExtras, emacsDefaults) GnuDebuggerRule.context.addRequirement(IsEmacs) GnuDebuggerRule.context.addRequirement(ModeRequirement(modes=["c-mode", "c++-mode"])) keywords = [ "all", "backtrace", "break", "catch", "clear", "commands", "condition", "continue", "delete", "disable", "enable",
from rules.emacs.Cmd import CharCmd, Cmd, runEmacsCmd from rules.ContextualRule import makeContextualRule from requirements.Emacs import IsEmacs from rules.emacs.common import emacsExtras, emacsDefaults from EventList import WordListEvent, MajorModeEvent from EventLoop import getLoop, pushEvent from protocol import ListRef import grammar _mapping = { "warp <charrule>" : CharCmd('(md-sn-find-slot %s)'), "blank" : Cmd('(md-sn-next-slot)'), "make blank" : Cmd('(md-sn-drop-slot)'), "funk call [<i>]" : Cmd("(md-insert-call-snippet %(i)d)"), "make <snippetList>" : Cmd("(md-insert-snippet \"%(snippetList)s\")"), } _extras = [ ListRef("SnippetList", "snippetList", []) ] SnippetRule = makeContextualRule("Snippet", _mapping, emacsExtras + _extras, emacsDefaults) SnippetRule.context.addRequirement(IsEmacs) def _onModeChange(self): snippetList = grammar.getStringList(runEmacsCmd("(md-get-snippet-names)")) log.info("Snippet names: [%s]" % snippetList) pushEvent(WordListEvent("SnippetList", snippetList)) getLoop().subscribeEvent(MajorModeEvent, _onModeChange)
from Actions import Key from rules.ContextualRule import makeContextualRule from requirements.Emacs import IsEmacs from requirements.ModeRequirement import ModeRequirement from rules.emacs.common import emacsExtras, emacsDefaults from rules.emacs.Cmd import Cmd from rules.emacs.Text import EmacsText _mapping = { "prior [<i>]" : Key("a-p:%(i)d"), "future [<i>]" : Key("a-n:%(i)d"), "history" : Key("a-r"), "interrupt" : Key("c-c,c-c"), "exit" : Key("c-d"), "prompt up [<n>]" : Key("c-c,c-p:%(n)d"), "prompt down [<n>]" : Key("c-c,c-n:%(n)d"), } ComintRule = makeContextualRule("Comint", _mapping, emacsExtras, emacsDefaults) ComintRule.context.addRequirement(IsEmacs) ComintRule.context.addRequirement(ModeRequirement(modes="comint-mode"))
_extras = [ Integer("i", 3, 8), Integer("n", 3, 72), Integer("digit", 0, 10), Dictation("text"), RuleRef(AlphaRule, "alpharule"), RuleRef(CharRule, "charrule"), ] _defaults = { "n": 1, "i": 1, } AlwaysRule = makeContextualRule("Always", _mapping, _extras, _defaults) AlwaysRule.activate() _extras = [ Dictation("text") ] _mapping = { "type <text>" : Text("%(text)s", False), } TypingRule = makeContextualRule("TypingRule", _mapping, _extras, {}, RuleType.TERMINAL) TypingRule.context.addRequirement(NotEmacs) _mapping = { "camel <text>" : Camel("%(text)s"),
from rules.emacs.Keywords import KeywordRule import keyword _mapping = { "align hash": Cmd("(align-dict)"), "align list": Cmd("(align-list)"), "mark block": Cmd("(er/mark-python-block)"), "mark state": Cmd("(er/mark-python-statement)"), "send funk": Key("ca-x"), "send buff": Key("c-c,c-c"), "send region": Key("c-c,c-r"), "interpreter": Key("c-c,c-z"), } PythonRule = makeContextualRule("Python", _mapping, emacsExtras, emacsDefaults) PythonRule.context.addRequirement(IsEmacs) PythonRule.context.addRequirement( ModeRequirement(modes=["python-mode", "inferior-python-mode"])) keywords = [ "True", "False", "set", "list", "dict", "None", "self", "print", "object", "len", "reversed", "enumerate", "range", ["__init__", "init"], "help", "type", ["__name__", "name"], ["str", "stir"], "unicode", "dir", "all", "any", ["isinstance", "is instance"], ["int", "integer"], "bool", "float", "nonlocal" ] + keyword.kwlist PythonKeywordRule = KeywordRule(["python-mode", "inferior-python-mode"], keywords)
#!/usr/bin/env python # -*- coding: utf-8 -*- from rules.ContextualRule import makeContextualRule from requirements.Emacs import IsEmacs from rules.emacs.common import emacsExtras, emacsDefaults from Actions import Key from protocol import RuleType _mapping = { "build menu": Key("c-u,c-c,b"), "run menu": Key("c-u,c-c,r"), "build only": Key("c-c,b"), "stop build": Key("c-c,s,b"), "stale run": Key("c-c,r"), "stop run": Key("c-c,s,r"), "execute": Key("c-c,c"), "new build script": Key("c-c,n,b"), "new run script": Key("c-c,n,r"), "open build script": Key("c-c,o,b"), "open run script": Key("c-c,o,r"), } BuildRule = makeContextualRule("Build", _mapping, emacsExtras, emacsDefaults, ruleType=RuleType.TERMINAL) BuildRule.context.addRequirement(IsEmacs)
class EmacsUnderscore(Underscore): pass EmacsCamel._print = emacsTextPrint EmacsHyphen._print = emacsTextPrint EmacsUnderscore._print = emacsTextPrint _extras = [ Dictation("text") ] _defaults = {} _mapping = { "type <text>" : EmacsText("%(text)s", False), } EmacsTypingRule = makeContextualRule("EmacsTypingRule", _mapping, _extras, _defaults, RuleType.TERMINAL) EmacsTypingRule.context.addRequirement(IsEmacs) _mapping = { "fasten <text>" : EmacsText("%(text)s", False, spaceCheck=False), "cap fasten <text>" : EmacsText("%(text)s", False, spaceCheck=False, allCaps=True), } EmacsFastenRule = makeContextualRule("EmacsFastenRule", _mapping, _extras, _defaults, RuleType.TERMINAL) EmacsFastenRule.context.addRequirement(IsEmacs) _mapping = { "camel <text>" : EmacsCamel("%(text)s"), } EmacsCamelRule = makeContextualRule("EmacsCamelRule", _mapping, _extras, _defaults, RuleType.TERMINAL)
["cdr", "could-er"], ["let*", "let star"], ["let*-values", "let star values"], ["require/typed", "typed require"], ["set!", "set"], "raise", "String", "unless", ["s-exp", "sexp"], ["#%%module-begin", "module begin"], "this", ] RacketKeywordRule = KeywordRule(["racket-mode", "racket-repl-mode"], keywords) _mapping = { "send buff": Key("c-c,c-c"), "send region": Key("c-c,c-r"), "interpreter": Key("c-c,c-z"), "help racket": Key("c-c,c-d"), "macro expand": Key("c-c,c-e,e"), "macro again": Key("c-c,c-e,a"), "macro region": Key("c-c,c-e,r"), "macro definition": Key("c-c,c-e,x"), } RacketRule = makeContextualRule("Racket", _mapping, emacsExtras, emacsDefaults) RacketRule.context.addRequirement(IsEmacs) RacketRule.context.addRequirement( ModeRequirement(modes=["racket-mode", "racket-repl-mode"]))
from Actions import Key from rules.ContextualRule import makeContextualRule from requirements.Emacs import IsEmacs from requirements.ModeRequirement import ModeRequirement from rules.emacs.common import emacsExtras, emacsDefaults # Term mode issues: # -Can wreck prompt and previous output # -Completion won't work, because we need to emulate moving cursor and pressing TAB _mapping = { "line mode" : Key("c-c,c-j"), "care mode" : Key("c-c,c-k"), } TermRule = makeContextualRule("Term", _mapping, emacsExtras, emacsDefaults) TermRule.context.addRequirement(IsEmacs) TermRule.context.addRequirement(ModeRequirement(modes="term-mode"))
"less context": Key("hyphen"), "discard": Key("k"), "branch": Key("b"), "merge": Key("m"), "diff": Key("d"), "push": Key("P"), "push remote": Key("c-u,P"), "remote update": Key("f"), "pull": Key("F"), } ## Turns out that since these are all single letter triggered, ## it's better to jus remember the letter and say the phrase for ## that. That way there's nothing different to remember between ## using voice vs. keyboard. So we comment out. # MagitRule = makeContextualRule("Magit", _mapping, emacsExtras, emacsDefaults) # MagitRule.context.addRequirement(IsEmacs) # MagitRule.context.addRequirement(ModeRequirement(modes="magit-status-mode")) _mapping = { "inquisition": Minibuf("magit-blame"), } MagitMiscRule = makeContextualRule("MagitMisc", _mapping, emacsExtras, emacsDefaults, ruleType=RuleType.INDEPENDENT) MagitMiscRule.context.addRequirement(IsEmacs)
from Actions import Key, Repeat from rules.ContextualRule import makeContextualRule from requirements.Emacs import IsEmacs from requirements.ModeRequirement import ModeRequirement from rules.emacs.common import emacsExtras, emacsDefaults _mapping = { "org save link" : Key("c-c,l"), "org agenda menu" : Key("c-c,a"), "org agenda" : Key("c-c,a,a"), "org list to do" : Key("c-c,a,t"), } OrgAnywhereRule = makeContextualRule("OrgAnywhere", _mapping, emacsExtras, emacsDefaults) OrgAnywhereRule.context.addRequirement(IsEmacs) # "scoot" -> expand section # "cap scoot" -> collapse all sections # "lima" -> log view to see record for the day _mapping = { "new" : Key("a-enter"), "new todo" : Key("as-enter"), "make headline" : Key("c-c,asterisk"), "make table" : Key("c-c,bar"), "archive [<i>]" : Key("c-c,c-t,c-a") * Repeat(extra="i"), "task [<i>]" : Key("c-c,c-x") * Repeat(extra="i"), "follow" : Key("c-c,c-o"), "insert link" : Key("c-c,c-l"), "schedule" : Key("c-c,c-s"), "increase priority [<i>]" : Key("s-up:%(i)d"),
from Actions import Key from rules.ContextualRule import makeContextualRule from requirements.Emacs import IsEmacs from requirements.ModeRequirement import ModeRequirement from rules.emacs.common import emacsExtras, emacsDefaults from rules.emacs.Cmd import Cmd from rules.emacs.Text import EmacsText _mapping = { "prior [<i>]": Key("a-p:%(i)d"), "future [<i>]": Key("a-n:%(i)d"), "history": Key("a-r"), "interrupt": Key("c-c,c-c"), "exit": Key("c-d"), "prompt up [<n>]": Key("c-c,c-p:%(n)d"), "prompt down [<n>]": Key("c-c,c-n:%(n)d"), } ComintRule = makeContextualRule("Comint", _mapping, emacsExtras, emacsDefaults) ComintRule.context.addRequirement(IsEmacs) ComintRule.context.addRequirement(ModeRequirement(modes="comint-mode"))
from rules.emacs.Cmd import Minibuf from rules.ContextualRule import makeContextualRule from requirements.Emacs import IsEmacs from rules.emacs.common import emacsExtras, emacsDefaults _mapping = { "profiler start" : Minibuf("profiler-start"), "profiler stop" : Minibuf("profiler-stop"), "profiler report" : Minibuf("profiler-report"), "instrument function" : Minibuf("elp-instrument-function"), "instrument results" : Minibuf("elp-results"), "instrument restore" : Minibuf("elp-restore-function"), "instrument restore all" : Minibuf("elp-restore-all"), "instrument master" : Minibuf("elp-set-master"), "instrument package" : Minibuf("elp-instrument-package"), "macro expand" : Minibuf("macroexpand-point"), } ProfilerRule = makeContextualRule("Profiler", _mapping, emacsExtras, emacsDefaults) ProfilerRule.context.addRequirement(IsEmacs)
"num <big>" : Text("%(big)d"), "per [<n>]" : Key("c-left:%(n)d"), "pro [<n>]" : Key("c-right:%(n)d"), "chip [<n>]" : Key("c-backspace:%(n)d"), "pitch [<n>]" : Key("c-delete:%(n)d"), "top side" : Key("c-home"), "bottom" : Key("c-end"), "save file" : Key("c-s"), "open file" : Key("c-o"), "new file" : Key("c-n"), # Also in the emacs rules, but since emacs rules are mutually exclusive with these # both definition should never be active at the same time. "view <charrule>" : CharCmd("(md-select-window-with-glyph %s)"), } _extras = [ Integer("n", 3, 100), Integer("i", 3, 8), Integer("big", 0, 2**14), ] _defaults = { "search_terms" : "", "n": 1, "i": 1, } CUARule = makeContextualRule("CUA", _mapping, _extras, _defaults) CUARule.context.addRequirement(NotEmacs)
from Actions import Key, Text from rules.ContextualRule import makeContextualRule from requirements.Emacs import IsEmacs from requirements.ModeRequirement import ModeRequirement from rules.emacs.common import emacsExtras, emacsDefaults _mapping = { "dired copy" : Key("c-c,a-w"), "dired cut" : Key("c-c,c-w"), "dired paste" : Key("c-c,c-y") } DiredRule = makeContextualRule("Dired", _mapping, emacsExtras, emacsDefaults) DiredRule.context.addRequirement(IsEmacs) DiredRule.context.addRequirement(ModeRequirement(modes="dired-mode"))
from Actions import Key from rules.ContextualRule import makeContextualRule from requirements.Emacs import IsEmacs from requirements.ModeRequirement import ModeRequirement from rules.emacs.common import emacsExtras, emacsDefaults _mapping = { "external" : Key("ampersand"), } EwwRule = makeContextualRule("Eww", _mapping, emacsExtras, emacsDefaults) EwwRule.context.addRequirement(IsEmacs) EwwRule.context.addRequirement(ModeRequirement(modes="eww-mode"))
#!/usr/bin/env python # -*- coding: utf-8 -*- from rules.ContextualRule import makeContextualRule from requirements.Emacs import IsEmacs from rules.emacs.common import emacsExtras, emacsDefaults from Actions import Key from protocol import RuleType _mapping = { "build menu" : Key("c-u,c-c,b"), "run menu" : Key("c-u,c-c,r"), "build only" : Key("c-c,b"), "stop build" : Key("c-c,s,b"), "stale run" : Key("c-c,r"), "stop run" : Key("c-c,s,r"), "execute" : Key("c-c,c"), "new build script" : Key("c-c,n,b"), "new run script" : Key("c-c,n,r"), "open build script" : Key("c-c,o,b"), "open run script" : Key("c-c,o,r"), } BuildRule = makeContextualRule("Build", _mapping, emacsExtras, emacsDefaults, ruleType=RuleType.TERMINAL) BuildRule.context.addRequirement(IsEmacs)
from rules.emacs.Cmd import CharCmd, Cmd from rules.ContextualRule import makeContextualRule from requirements.Emacs import IsEmacs from requirements.VarRequirement import VarRequirement from rules.emacs.common import emacsExtras, emacsDefaults _mapping = { "near <charrule> [<i>]" : CharCmd('(md-activate-belt-item "nearest" %s)'), "name <charrule> [<i>]" : CharCmd('(md-activate-belt-item "nick" %s)'), "jerk <charrule> [<i>]" : CharCmd('(md-activate-belt-item "kill" %s)'), "beat <charrule> [<i>]" : CharCmd('(md-activate-belt-item "frequency" %s)'), "chong <charrule> [<i>]" : CharCmd('(md-activate-belt-item "recent" %s)'), } BeltRule = makeContextualRule("Belt", _mapping, emacsExtras, emacsDefaults) BeltRule.context.addRequirement(VarRequirement("md-belt-mode", "t")) _mapping = { "toggle belt" : Cmd("(md-toggle-belt-mode)"), } BeltToggleRule = makeContextualRule("BeltToggle", _mapping, emacsExtras, emacsDefaults) BeltToggleRule.context.addRequirement(IsEmacs)
Integer("i", 3, 8), ] _defaults = { "n": 1, "i": 1, } # put the more dangerous stuff by itself _mapping = { "destroy window" : Key("ca-x"), "restart window manager" : Key("csa-q"), "launch emacs" : Key("csa-w"), } XMonadIndependentRule = makeContextualRule("XMonadIndependent", _mapping, _extras, _defaults, ruleType=RuleType.INDEPENDENT) XMonadIndependentRule.activate() _mapping = { # "mon (one | left)" : Key("ca-up"), # "mon (two | middle | center)" : Key("ca-left"), # "mon (three | right)" : Key("ca-right"), # "move mon one [<i>]" : Key("csa-up:%(i)d"), # "move mon two [<i>]" : Key("csa-left:%(i)d"), # "move mon three [<i>]" : Key("csa-right:%(i)d"), "East [<i>]" : Key("ca-space:%(i)d"), "move East [<i>]" : Key("csa-space:%(i)d"), "West [<i>]" : Key("ca-backspace:%(i)d"), "move West [<i>]" : Key("csa-backspace:%(i)d"), "desk <d>" : Key("ca-%(d)d"), "move desk <d>" : Key("csa-%(d)d"),
"level two" : Key("a-2"), "level three" : Key("a-3"), "level four" : Key("a-4"), "more context" : Key("plus"), "less context" : Key("hyphen"), "discard" : Key("k"), "branch" : Key("b"), "merge" : Key("m"), "diff" : Key("d"), "push" : Key("P"), "push remote" : Key("c-u,P"), "remote update" : Key("f"), "pull" : Key("F"), } ## Turns out that since these are all single letter triggered, ## it's better to jus remember the letter and say the phrase for ## that. That way there's nothing different to remember between ## using voice vs. keyboard. So we comment out. # MagitRule = makeContextualRule("Magit", _mapping, emacsExtras, emacsDefaults) # MagitRule.context.addRequirement(IsEmacs) # MagitRule.context.addRequirement(ModeRequirement(modes="magit-status-mode")) _mapping = { "inquisition" : Minibuf("magit-blame"), } MagitMiscRule = makeContextualRule("MagitMisc", _mapping, emacsExtras, emacsDefaults, ruleType=RuleType.INDEPENDENT) MagitMiscRule.context.addRequirement(IsEmacs)
"unsetopt", ["/usr/bin/", "user bin"], "up", "valgrind", "wait", ["wc", "word count"], "which", "while", ["xargs", "X args"], ["zsh", "Z shell"], "crontab", "sleep", "time", [">", "stood out"], ["2>", "stood err"], ["&>", "stood both"], ] ShellKeywordRule = KeywordRule(["shell-mode", "sh-mode"], _keywords) _mapping = { "back [<i>]": Key("b,enter") * Repeat(extra="i"), "forward [<i>]": Key("f,enter") * Repeat(extra="i"), "surface [<i>]": (EmacsText("up") + Key("enter")) * Repeat(extra="i"), } ShellRule = makeContextualRule("Shell", _mapping, emacsExtras, emacsDefaults) ShellRule.context.addRequirement(IsEmacs) ShellRule.context.addRequirement( ModeRequirement(modes=["shell-mode", "sh-mode"]))
"set break point": Key("c-t,c-a,c-b"), "delete break point": Key("c-t,c-a,c-d"), "good step [<i>]": Key("c-t,c-a,c-s") * Repeat(extra="i"), "good next [<i>]": Key("c-t,c-a,c-n") * Repeat(extra="i"), "good instruction [<i>]": Key("c-t,c-a,c-i") * Repeat(extra="i"), "good eval": Key("c-t,c-a,c-p"), "good continue": Key("c-t,c-a,c-r"), "good up": Key("c-t,c-a,langle"), "good down": Key("c-t,c-a,rangle"), "good until": Key("c-t,c-a,c-u"), "good finish": Key("c-t,c-a,c-f"), "good jump": Key("c-t,c-a,c-j"), } # TODO: check gdb-running/gdb-stopped variable GnuDebuggerRule = makeContextualRule("GnuDebugger", _mapping, emacsExtras, emacsDefaults) GnuDebuggerRule.context.addRequirement(IsEmacs) GnuDebuggerRule.context.addRequirement( ModeRequirement(modes=["c-mode", "c++-mode"])) keywords = [ "all", "backtrace", "break", "catch", "clear", "commands", "condition", "continue", "delete", "disable",
pass EmacsCamel._print = emacsTextPrint EmacsHyphen._print = emacsTextPrint EmacsUnderscore._print = emacsTextPrint _extras = [Dictation("text")] _defaults = {} _mapping = { "type <text>": EmacsText("%(text)s", False), } EmacsTypingRule = makeContextualRule("EmacsTypingRule", _mapping, _extras, _defaults, RuleType.TERMINAL) EmacsTypingRule.context.addRequirement(IsEmacs) _mapping = { "fasten <text>": EmacsText("%(text)s", False, spaceCheck=False), "cap fasten <text>": EmacsText("%(text)s", False, spaceCheck=False, allCaps=True), } EmacsFastenRule = makeContextualRule("EmacsFastenRule", _mapping, _extras, _defaults, RuleType.TERMINAL) EmacsFastenRule.context.addRequirement(IsEmacs) _mapping = { "camel <text>": EmacsCamel("%(text)s"),
"insert <charrule>": CharCmd("(insert-register %s)"), "bookmark <charrule>": CharCmd("(point-to-register %s)"), #"store buff <charrule>" : CharCmd("(window-configuration-to-register %s)"), "load <charrule>": CharCmd("(jump-to-register %s)"), "previous [<n>]": Cmd("(md-get-previous-instance-of-symbol)"), "next [<n>]": Cmd("(md-get-next-instance-of-symbol)"), "line <charrule> [<i>]": CharCmd("(md-find-line-starting-with-char 1 %s)"), "Nile <charrule> [<i>]": CharCmd("(md-find-line-starting-with-char -1 %s)"), # chopping block? "sym <charrule> [<i>]": CharCmd("(md-move-up-to-symbol-starting-with-char nil %s)"), # "sym <charrule> [<i>]" : Key("c-c,s,s,%(charrule)s"), "miss <charrule> [<i>]": CharCmd("(md-move-up-to-symbol-starting-with-char t %s)"), # "miss <charrule> [<i>]" : CharCmd("(md-move-up-to-symbol-starting-with-char -1 %s)"), "lookup": Key("a-dot"), "references": Key("a-comma"), } NavRule = makeContextualRule("Nav", _mapping, emacsExtras, emacsDefaults) NavRule.context.addRequirement(IsEmacs)
from rules.emacs.Cmd import CharCmd, Cmd, Minibuf, Key from rules.ContextualRule import makeContextualRule from requirements.Emacs import IsEmacs from rules.emacs.common import emacsExtras, emacsDefaults _mapping = { # hot "after": Key("ca-f"), "before": Key("ca-b"), "dive": Key("ca-d"), "back dive": Key("cs-d"), "away": Key("ca-o"), "back away": Key("cs-u"), "peak": Key("ca-n"), "boo": Key("ca-p"), "start": Key("c-home"), "close": Key("c-end"), "slurp": Key("ca-y"), "back slurp": Key("ca-g"), "peel": Key("ca-j"), # cold "pair barf": Key("ca-v"), "pair back barf": Key("ca-k"), "pair split": Key("ca-i"), "pair rewrap": Key("ca-z"), } PairCmdRule = makeContextualRule("PairCmd", _mapping, emacsExtras, emacsDefaults) PairCmdRule.context.addRequirement(IsEmacs)
"per [<n>]": Key("c-left:%(n)d"), "pro [<n>]": Key("c-right:%(n)d"), "chip [<n>]": Key("c-backspace:%(n)d"), "pitch [<n>]": Key("c-delete:%(n)d"), "top side": Key("c-home"), "bottom": Key("c-end"), "save file": Key("c-s"), "open file": Key("c-o"), "new file": Key("c-n"), # Also in the emacs rules, but since emacs rules are mutually exclusive with these # both definition should never be active at the same time. "view <charrule>": CharCmd("(md-select-window-with-glyph %s)"), } _extras = [ Integer("n", 3, 100), Integer("i", 3, 8), Integer("big", 0, 2**14), ] _defaults = { "search_terms": "", "n": 1, "i": 1, } CUARule = makeContextualRule("CUA", _mapping, _extras, _defaults) CUARule.context.addRequirement(NotEmacs) CUARule.context.addRequirement(NotTerminal)
_allBuffQuery = "(md-all-buffers-except %s)" % _appendCmd class GeneralBufferNames(BufferNames): phrase = "buff" query = "(md-all-buffers-except %s)" % _appendCmd _bufferQueryTable.append(GeneralBufferNames) _generators = [] _selectors = [] for e in _bufferQueryTable: _generators.append(BufferEventGenerator(e.phrase, e.query)) _selectors.append(e(e.phrase + "Names", e.phrase, e.query)) # Because uniquify buffer code will start naming things $shell<2>, $shell<3>, # but leaves the first shell as just $shell, we add this for voice command # uniformity _mapping = { "shell one" : Cmd("(switch-to-buffer \"$shell\")") } ShellOneRule = makeContextualRule("ShellOneRule", _mapping) ShellOneRule.context.addRequirement(IsEmacs) _mapping = {} for e in _bufferQueryTable: _mapping["last " + e.phrase] = Cmd("(md-switch-to-next-buffer-in-list %s)" % e.query) LastBufferRule = makeContextualRule("LastBufferRule", _mapping, [], {}, ruleType=RuleType.TERMINAL) LastBufferRule.context.addRequirement(IsEmacs)
from requirements.Emacs import IsEmacs from requirements.ModeRequirement import ModeRequirement from rules.emacs.common import emacsExtras, emacsDefaults from rules.emacs.Cmd import Cmd from rules.emacs.Keywords import KeywordRule keywords = [ "abs", "access", "after", "alias", "all", "and", "architecture", "array", "assert", "attribute", "begin", "block", "body", "buffer", "bus", "case", "component", "configuration", "constant", "disconnect", "downto", "else", "elsif", "end", "entity", "exit", "file", "for", "function", "generate", "generic", "group", "guarded", "if", "impure", "in", "inertial", "inout", "is", "label", "library", "linkage", "literal", "loop", "map", "mod", "nand", "new", "next", "nor", "not", "null", "of", "on", "open", "or", "others", "out", "package", "port", "postponed", "procedure", "process", "pure", "range", "record", "register", "reject", "rem", "report", "return", "rol", "ror", "select", "severity", "signal", "shared", "sla", "sll", "sra", "srl", "subtype", "then", "to", "transport", "type", "unaffected", "units", "until", "use", "variable", "wait", "when", "while", "with", "xnor", "xor", ["std_logic", "stood logic"], ["std_logic_vector", "stood logic vector"], "unsigned" ] # VhdlKeywordRule = KeywordRule(["vhdl-mode"], keywords) _mapping = {} VhdlRule = makeContextualRule("vhdl", _mapping, emacsExtras, emacsDefaults) VhdlRule.context.addRequirement(IsEmacs) VhdlRule.context.addRequirement(ModeRequirement(modes=["vhdl-mode"]))
# "show top" : Cmd("(etc-start-or-open-top)"), "open temp" : Cmd("(md-create-temp-file \"temp\")"), "toggle command logging" : toggleCommandLogging, "toggle refresh client" : toggleRefreshClientSources, "magnify [<i>]" : Key("c-t,c-plus:%(i)d"), "demagnify [<i>]" : Key("c-t,c-minus:%(i)d"), # "compile" : Minibuf("compile"), "visual line mode" : Minibuf("visual-line-mode"), "set indent <j>" : Cmd("(etc-set-indent-preference %(j)d)"), "toggle namespace indent" : Cmd("(etc-toggle-namespace-indent)"), "toggle read only" : Key("c-t,c-q"), } # EmacsIsolatedRule = makeContextualRule("EmacsIsolated", _mapping, emacsExtras, emacsDefaults, ruleType=RuleType.INDEPENDENT) EmacsIsolatedRule = makeContextualRule("EmacsIsolated", _mapping, emacsExtras, emacsDefaults) EmacsIsolatedRule.context.addRequirement(IsEmacs) _mapping = { "help function" : Key("c-h,f"), "help function slap" : Key("c-h,f,enter"), "help variable" : Key("c-h,v"), "help variable slap" : Key("c-h,v,enter"), "help key" : Key("c-h,k"), "help mode" : Key("c-h,m"), "help docks" : Key("c-h,d"), "help news" : Key("c-h,n"), "help info" : Key("c-h,i"), "help syntax" : Key("c-h,s"), "help bindings" : Key("c-h,b"),
def toggleLogging(self, ev=None): self.logging = not self.logging log.info("Setting %s watcher logging to: %s" % (type(self), self.logging)) def toggleEnabled(self, ev=None): self.toggle.flip() log.info("Setting %s watcher to: %s" % (type(self), self.toggle.satisfied)) @classmethod def toggleAllGenerators(cls, ev=None): cls.clsToggle.flip() log.info("Setting all generators to: %s" % cls.clsToggle.satisfied) @classmethod def toggleAllGeneratorsLogging(cls, ev=None): cls.clsLogging = not cls.clsLogging log.info("Setting all generators logging to: %s" % cls.clsLogging) # on by default EmacsEventGenerator.clsToggle.enable() _mapping = { "toggle emacs generators" : (lambda x: EmacsEventGenerator.toggleAllGenerators()), "toggle logging emacs generators" : (lambda x: EmacsEventGenerator.toggleAllGeneratorsLogging()), } MasterGeneratorToggleRule = makeContextualRule("MasterGeneratorToggleRule", _mapping) MasterGeneratorToggleRule.activate() # always on
from requirements.ModeRequirement import ModeRequirement from rules.emacs.common import emacsExtras, emacsDefaults from rules.emacs.Cmd import Cmd from rules.emacs.Text import EmacsText from protocol import RuleType IsErcMode = ModeRequirement(modes="erc-mode") _mapping = { "slash join [<text>]": EmacsText("/join #%(text)s"), "slash me [<text>]": EmacsText("/me %(text)s"), } ERCTextRule = makeContextualRule("ERCText", _mapping, emacsExtras, emacsDefaults, ruleType=RuleType.TERMINAL) ERCTextRule.context.addRequirement(IsEmacs) ERCTextRule.context.addRequirement(IsErcMode) _mapping = { "prior": Key("a-p"), "future": Key("a-n"), "smiley wink": EmacsText(";)"), "smiley tongue": EmacsText(":P", lower=False), "smiley wink tongue": EmacsText(";P", lower=False), "slash part": EmacsText("/part"), "kick dragon": EmacsText("/me kicks Dragon"), "slash message": EmacsText("/msg"), "slash whois": EmacsText("/whois"),
query = "(md-all-buffers-except %s)" % _appendCmd _bufferQueryTable.append(GeneralBufferNames) _generators = [] _selectors = [] for e in _bufferQueryTable: _generators.append(BufferEventGenerator(e.phrase, e.query)) _selectors.append(e(e.phrase + "Names", e.phrase, e.query)) # Because uniquify buffer code will start naming things $shell<2>, $shell<3>, # but leaves the first shell as just $shell, we add this for voice command # uniformity _mapping = {"shell one": Cmd("(switch-to-buffer \"*shell*\")")} ShellOneRule = makeContextualRule("ShellOneRule", _mapping) ShellOneRule.context.addRequirement(IsEmacs) # Because uniquify buffer code will start naming things $eshell<2>, $eshell<3>, # but leaves the first eshell as just $eshell, we add this for voice command # uniformity _mapping = {"eshell one": Cmd("(switch-to-buffer \"*eshell*\")")} EshellOneRule = makeContextualRule("EshellOneRule", _mapping) EshellOneRule.context.addRequirement(IsEmacs) _mapping = {} for e in _bufferQueryTable: _mapping["last " + e.phrase] = Cmd( "(md-switch-to-next-buffer-in-list %s)" % e.query) LastBufferRule = makeContextualRule("LastBufferRule",
mark = AccentRule.rule.mapping[extras['accentrule']["words"] [0]] if 'accentrule' in extras else None mark = ("#x%x" % mark) if mark else "nil" return '(%s "%s" %s "%s")' % (self.data, letter, mark, color) _mapping = { "<colorrule> <alpharule> [<accentrule>]": PickSymbol("md-hl-insert-symbol", 0), "jump <colorrule> <alpharule> [<accentrule>]": PickSymbol("md-hl-jump-symbol"), } _extras = emacsExtras + [ RuleRef(AccentRule, "accentrule"), RuleRef(ColorRule, "colorrule"), ] SymbolPickerRule = makeContextualRule("SymbolPicker", _mapping, _extras, emacsDefaults) SymbolPickerRule.context.addRequirement(IsEmacs) SymbolPickerRule.context.addRequirement( VarRequirement("md-symbol-picker-mode", "t")) _mapping = { "toggle picker": Cmd("(md-toggle-symbol-picker-mode)"), } SymbolPickerToggleRule = makeContextualRule("SymbolPickerToggle", _mapping, _extras, emacsDefaults) SymbolPickerToggleRule.context.addRequirement(IsEmacs)
pass try: int(w, 16) newWords.remove(w) except ValueError: pass #log.info("Not filtering: [%s]" % w) return newWords _actions = [ "go", "doog", ] _wordActions = ["word"] + [w + " word" for w in _actions] _symbolActions = ["toke"] + [w + " toke" for w in _actions] _emacsWordNameSelector = EmacsWordNames("EmacsWordNames", _wordActions, EmacsWordEvent) _emacsSymbolNameSelector = EmacsWordNames("EmacsSymbolNames", _symbolActions, EmacsSymbolEvent) _mapping = { "again word" : Cmd("(md-cycle-token 'word)"), "again toke" : Cmd("(md-cycle-token 'symbol)"), } ControlWordsRule = makeContextualRule("ControlWordsRule", _mapping) ControlWordsRule.context.addRequirement(IsEmacs)
from rules.emacs.Cmd import Minibuf from rules.ContextualRule import makeContextualRule from requirements.Emacs import IsEmacs from rules.emacs.common import emacsExtras, emacsDefaults _mapping = { "profiler start": Minibuf("profiler-start"), "profiler stop": Minibuf("profiler-stop"), "profiler report": Minibuf("profiler-report"), "instrument function": Minibuf("elp-instrument-function"), "instrument results": Minibuf("elp-results"), "instrument restore": Minibuf("elp-restore-function"), "instrument restore all": Minibuf("elp-restore-all"), "instrument master": Minibuf("elp-set-master"), "instrument package": Minibuf("elp-instrument-package"), "macro expand": Minibuf("macroexpand-point"), } ProfilerRule = makeContextualRule("Profiler", _mapping, emacsExtras, emacsDefaults) ProfilerRule.context.addRequirement(IsEmacs)
["add1", "add one"], ["cdr", "could-er"], ["let*", "let star"], ["let*-values", "let star values"], ["require/typed", "typed require"], ["set!", "set"], "raise", "String", "unless", ["s-exp", "sexp"], ["#%%module-begin", "module begin"], "this", ] RacketKeywordRule = KeywordRule(["racket-mode", "racket-repl-mode"], keywords) _mapping = { "send buff" : Key("c-c,c-c"), "send region" : Key("c-c,c-r"), "interpreter" : Key("c-c,c-z"), "help racket" : Key("c-c,c-d"), "macro expand" : Key("c-c,c-e,e"), "macro again" : Key("c-c,c-e,a"), "macro region" : Key("c-c,c-e,r"), "macro definition" : Key("c-c,c-e,x"), } RacketRule = makeContextualRule("Racket", _mapping, emacsExtras, emacsDefaults) RacketRule.context.addRequirement(IsEmacs) RacketRule.context.addRequirement(ModeRequirement(modes=["racket-mode", "racket-repl-mode"]))