def tellEmacs(self): # this isn't ideal, because it only takes into account one type of requirement # however that is the most common kind keywordString = "'(" + " ".join([("\"%s\"" % x[0]) for x in self.keywords]) + ")" for m in self.requirements: if isinstance(m, ModeRequirement): for mode in m.modes: runEmacsCmd("(md-register-mode-keywords '%s %s)" % (mode, keywordString))
def _print(self, words): # There's no good elisp way to handle putting characters into # the search box AFAIK. You can get text in there but giving it # focus disables search as you type. inSearchMode = runEmacsCmd("isearch-mode") != 'nil' inMiniBuffer = '*Minibuf-' in runEmacsCmd("(with-current-buffer (buffer-name))") words = words if not self.allCaps else [i.upper() for i in words] if inSearchMode or inMiniBuffer: Text._print(self, words) else: runEmacsCmd("(md-insert-text \"%s\" %s %s)" % (words, emacsBool(self.spaceCheck), emacsBool(self.capitalCheck)), dolog=True, queryOnly=False)
def _select(self, cmd, choice): if runEmacsCmd("(md-at-start-of-erc-input-line)") == 't': # we're addressing them, include the colon EmacsText("%s: " % choice, lower=False, capitalCheck=False)() else: # we're referring to them, omit the colon EmacsText("%s" % choice, lower=False, capitalCheck=False)()
def _updateMajorMode(ev): global _majorMode, _oldMajorMode _majorMode = runEmacsCmd("(md-get-all-modes)") _majorMode = _getEmacsList(_majorMode) if _majorMode != _oldMajorMode: pushEvent(MajorModeEvent(_majorMode)) _oldMajorMode = _majorMode
def _print(self, words): # There's no good elisp way to handle putting characters into # the search box AFAIK. You can get text in there but giving it # focus disables search as you type. inSearchMode = runEmacsCmd("isearch-mode") != 'nil' inMiniBuffer = '*Minibuf-' in runEmacsCmd( "(with-current-buffer (buffer-name))") words = words if not self.allCaps else [i.upper() for i in words] if inSearchMode or inMiniBuffer: Text._print(self, words) else: runEmacsCmd("(md-insert-text \"%s\" %s %s)" % (words, emacsBool( self.spaceCheck), emacsBool(self.capitalCheck)), dolog=True, queryOnly=False)
def _updateMajorMode(ev): global _majorMode, _oldMajorMode _majorMode = runEmacsCmd("(md-get-all-modes)") _majorMode = _getEmacsList(_majorMode) if _majorMode != _oldMajorMode: log.info("Switching major mode: {}".format(_majorMode)) pushEvent(MajorModeEvent(_majorMode)) _oldMajorMode = _majorMode
def _query(self, ev=None): output = runEmacsCmd(self.var) try: output = int(output) except ValueError: pass self._met(output == self.value)
def update(self, ev=None): window = ev.window if ev else getFocusedWindow() newOutput = runEmacsCmd(self.cmd, inFrame=self.inFrame, allowError=self.allowError, dolog=(self.logging or self.clsLogging)) newOutput = self._postProcess(newOutput) if newOutput == self.lastOutput: return self.lastOutput = newOutput #log.info("New output!") pushEvent(self._makeEvent(newOutput))
def _select(self, cmd, choice): runEmacsCmd("(switch-to-buffer \"%s\")" % choice, queryOnly=False)
def _currentChoice(self): buf = runEmacsCmd("(buffer-name (current-buffer))") return buf.strip().strip('"')
def tellEmacs(self, state): # log.info("telling emacs cursor state: %s" % state) runEmacsCmd("(md-new-mic-state \"%s\")" % state)
def _onModeChange(self): snippetList = grammar.getStringList(runEmacsCmd("(md-get-snippet-names)")) log.info("Snippet names: [%s]" % snippetList) pushEvent(WordListEvent("SnippetList", snippetList))
def _noChoice(self): runEmacsCmd("(switch-to-buffer nil)", queryOnly=False)
def onWordEvent(ev): runEmacsCmd(u"(mandimus-word-event \"%s\")" % ev.words)
def _currentChoice(self): return runEmacsCmd("(when (md-current-path) (file-relative-name (md-current-path) (projectile-project-root))))").strip("\"")
def _select(self, cmd, choice): runEmacsCmd("(projectile-switch-project-by-name \"%s\")" % choice, queryOnly=False)
def _currentChoice(self): return runEmacsCmd("(projectile-project-name)").strip("\"")
def _noChoice(self): runEmacsCmd("(md-switch-to-next-buffer-in-list %s)" % self.query, queryOnly=False)
def _noChoice(self): runEmacsCmd("(md-folder-switch)", queryOnly=False)
def _select(self, cmd, choice): runEmacsCmd(_openProjetileFileEl % choice)