Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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"))
# both definition should never be active at the same time.
"view " : 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)
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
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)
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)
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 [<i>]" : CharCmd('(md-activate-belt-item "nearest" %s)'),
"name [<i>]" : CharCmd('(md-activate-belt-item "nick" %s)'),
"jerk [<i>]" : CharCmd('(md-activate-belt-item "kill" %s)'),
"beat [<i>]" : CharCmd('(md-activate-belt-item "frequency" %s)'),
"chong [<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)
</i></i></i></i></i>
_extras = [
Dictation("text")
]
_mapping = {
"type