How to use the rules.emacs.common.emacsExtras function in rules

To help you get started, we’ve selected a few rules examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jgarvin / mandimus / rules / emacs / Emacs.py View on Github external
"prior [<i>]"                   : Key("a-p:%(i)d"),
    "future [<i>]"                  : Key("a-n:%(i)d"),

    "read e-mail"                   : Key("c-c,e"),
    "compose e-mail"                : Key("c-x,m"),
    "jabber roster"                 : Key("c-t,c-j,c-r"),
    "fill paragraph"                : Key("a-q"),

    "maggot find file"              : Key("c-c,m,h"),
    "maggot show origin master"     : Key("c-c,m,o"),

    "last change"                   : Key("c-period"),
    "next change"                   : Key("c-comma"),
}

EmacsRule = makeContextualRule("Emacs", _mapping, emacsExtras, emacsDefaults)
EmacsRule.context.addRequirement(IsEmacs)
</i></i>
github jgarvin / mandimus / rules / emacs / Magit.py View on Github external
}

## 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)
github jgarvin / mandimus / rules / emacs / Snippet.py View on Github external
from protocol import ListRef
import grammar

_mapping = {
    "warp "   : 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 " : 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)
</i>
github jgarvin / mandimus / rules / emacs / Nav.py View on Github external
"previous []"          : Cmd("(md-get-previous-instance-of-symbol)"),
    "next []"              : Cmd("(md-get-next-instance-of-symbol)"),

    "line  [<i>]"   : CharCmd("(md-find-line-starting-with-char 1 %s)"),
    "Nile  [<i>]"   : CharCmd("(md-find-line-starting-with-char -1 %s)"),
    # chopping block?
    "sym  [<i>]"    : CharCmd("(md-move-up-to-symbol-starting-with-char nil %s)"),
    # "sym  [<i>]"  : Key("c-c,s,s,%(charrule)s"),
    "miss  [<i>]"   : CharCmd("(md-move-up-to-symbol-starting-with-char t %s)"),
    # "miss  [<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)
</i></i></i></i></i></i>
github jgarvin / mandimus / rules / emacs / Build.py View on Github external
_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)
github jgarvin / mandimus / rules / emacs / Org.py View on Github external
"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"),
    "decrease priority [<i>]" : Key("s-down:%(i)d"),
    "priority one"            : Key("c-c,comma,a"),
    "priority two"            : Key("c-c,comma,b"),
    "priority three"          : Key("c-c,comma,c"),
}

OrgRule = makeContextualRule("Org", _mapping, emacsExtras, emacsDefaults)
OrgRule.context.addRequirement(IsEmacs)
OrgRule.context.addRequirement(ModeRequirement(modes=["org-mode", "org-agenda-mode"]))
</i></i></i></i>
github jgarvin / mandimus / rules / emacs / Eshell.py View on Github external
]

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 []"   : Key("c-c,c-p:%(n)d"),
    "prompt down []" : Key("c-c,c-n:%(n)d"),

}

EShellRule = makeContextualRule("Shell", _mapping, emacsExtras, emacsDefaults)
EShellRule.context.addRequirement(IsEmacs)
EShellRule.context.addRequirement(ModeRequirement(modes=["eshell-mode"]))
</i></i></i>
github jgarvin / mandimus / rules / emacs / ERC.py View on Github external
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"),
}

ERCRule = makeContextualRule("ERC", _mapping, emacsExtras, emacsDefaults)
ERCRule.context.addRequirement(IsEmacs)
ERCRule.context.addRequirement(IsErcMode)
github jgarvin / mandimus / rules / emacs / Python.py View on Github external
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)
github jgarvin / mandimus / rules / emacs / SymbolPicker.py View on Github external
self.leadingWords = leadingWords
        Cmd.__init__(self, data)

    def _lisp(self, extras={}):
        color = extras['colorrule']["words"][0]
        letter = BaseRules.lookup(extras)
        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 = {
    "  []"      : PickSymbol("md-hl-insert-symbol", 0),
    "jump   []" : 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)