예제 #1
0
파일: Words.py 프로젝트: sboosali/mandimus
 def _select(self, action, choice):
     if "go" in action["words"]:
         Cmd("(md-go-to-next \"%s\")" % choice)()
     elif "doog" in action["words"]:
         Cmd("(md-go-to-previous \"%s\")" % choice)()
     else:
         EmacsText("%s" % choice, lower=False)()
예제 #2
0
 def __init__(self, keywords, verbRule, kwRule, log=False):
     self.writtenForms = {}
     self.verbRule = verbRule
     self.kwRule = kwRule
     for i in keywords:
         self.writtenForms[i[1]] = i[0]
     Cmd.__init__(self, None, log)
예제 #3
0
 def __init__(self, data, leadingWords=1):
     self.leadingWords = leadingWords
     Cmd.__init__(self, data)
예제 #4
0
        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)
예제 #5
0
 def __init__(self, data):
     command = "(align-regexp (region-beginning) (region-end) \"%s\")"
     whitespace = "\\\(\\\s-*\\\)%s"
     command %= (whitespace % data)
     Cmd.__init__(self, command)
예제 #6
0
        Key("c-space")()
        return ""

class Comment(Cmd):
    def _lisp(self, extras={}):
        words = extras['words']
        for w in words:
            if w in UnitList:
                Mark()(extras)
        Key("a-semicolon")()
        return ""


_mapping = {
    "command"                     : Key("a-x"),
    "toggle emacs debug"          : Cmd("(toggle-debug-on-error)"),
    "exit debug"                  : Key("c-t,X,a"),
    # "debug function"              : Key("c-t,c-m") + Text("debug-on-entry") + Key("enter"),
    # "cancel debug function"       : Key("c-t,c-m") + Text("cancel-debug-on-entry") + Key("enter"),

    "go to line"                  : Key("a-g,a-g"),
    # "go to line <big>"          : Key("a-g,a-g") + Text("%(big)d") + Key("enter"),

    "new frame"                   : Cmd("(make-frame-command)"),
    "mini buffer"                 : Cmd("(md-select-minibuffer)"),

    "list buffs"                  : Key("c-t,c-b,c-t,o") + Cmd("(ace-jump-line-mode)"),

    # projectile commands
    "switch project"              : Key("c-c,p,p"),
    "root folder"                 : Key("c-c,p,d"),
예제 #7
0
파일: Python.py 프로젝트: sboosali/mandimus
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.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"],
예제 #8
0
파일: Edit.py 프로젝트: sboosali/mandimus
#         "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)
예제 #9
0
    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)

# 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)
예제 #10
0
파일: Nav.py 프로젝트: sboosali/mandimus
_mapping = {
    "home":
    Key("home"),
    "edge":
    Key("end"),
    "top side":
    Key("a-langle"),
    "bottom":
    Key("a-rangle"),
    "pro [<n>]":
    Key("a-f:%(n)d"),
    "per [<n>]":
    Key("a-b:%(n)d"),
    "over [<n>]":
    Cmd("(forward-symbol 1)"),
    "under [<n>]":
    Cmd("(forward-symbol -1)"),
    "leaf [<n>]":
    Key("pgdown:%(n)d"),
    "feel [<n>]":
    Key("pgup:%(n)d"),
    "gruff [<n>]":
    Key("a-lbrace:%(n)d"),
    "graph [<n>]":
    Key("a-rbrace:%(n)d"),
    "left [<n>]":
    Key("c-b:%(n)d"),
    "right [<n>]":
    Key("c-f:%(n)d"),
    "hike [<n>]":
예제 #11
0
class Comment(Cmd):
    def _lisp(self, extras={}):
        words = extras['words']
        for w in words:
            if w in UnitList:
                Mark()(extras)
        Key("a-semicolon")()
        return ""


_mapping = {
    "command":
    Key("a-x"),
    "toggle emacs debug":
    Cmd("(toggle-debug-on-error)"),
    "exit debug":
    Key("c-t,X,a"),
    # "debug function"              : Key("c-t,c-m") + Text("debug-on-entry") + Key("enter"),
    # "cancel debug function"       : Key("c-t,c-m") + Text("cancel-debug-on-entry") + Key("enter"),
    "go to line":
    Key("a-g,a-g"),
    # "go to line <big>"          : Key("a-g,a-g") + Text("%(big)d") + Key("enter"),
    "new frame":
    Cmd("(make-frame-command)"),
    "mini buffer":
    Cmd("(md-select-minibuffer)"),
    "list buffs":
    Key("c-t,c-b,c-t,o") + Cmd("(ace-jump-line-mode)"),

    # projectile commands
예제 #12
0
파일: Words.py 프로젝트: sboosali/mandimus
            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)
예제 #13
0
# -*- coding: utf-8 -*-

import mdlog
log = mdlog.getLogger(__name__)
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)
예제 #14
0
파일: Emacs.py 프로젝트: jgarvin/mandimus
 def __init__(self, data):
     command = "(align-regexp (region-beginning) (region-end) \"%s\")"
     whitespace = "\\\(\\\s-*\\\)%s"
     command %= (whitespace % data)
     Cmd.__init__(self, command)
예제 #15
0
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)