def rescanForMajorModeChange(self): """Call the MajorModeMatcherDriver to determine the major mode This uses the current text of the major mode as the header text, rather than having the MajorModeMatcherDriver load bytes from the URL. """ # header must be in bytes, not unicode header = self.GetText().encode('utf-8') newcls = MajorModeMatcherDriver.match(self.buffer, header=header) return newcls
def rescanForMajorModeChange(self): """Call the MajorModeMatcherDriver to determine the major mode This uses the current text of the major mode as the header text, rather than having the MajorModeMatcherDriver load bytes from the URL. """ # header must be in bytes, not unicode header = self.GetText().encode('utf-8') newcls = MajorModeMatcherDriver.match(self.buffer, header=header) return newcls
def findKeywordHierarchy(self): """Return a list of keywords representing the major mode subclassing hierarchy of the current major mode. """ mode_classes = MajorModeMatcherDriver.findActiveModes() mode_classes.reverse() keywords = [] # Put the major mode first keywords.append(mode_classes.pop(0).keyword) mode_classes.sort(cmp=lambda a,b: cmp(a.keyword, b.keyword)) for cls in mode_classes: keywords.append(cls.keyword) return keywords
def getActiveModesAndNames(self): modes = [] names = [] for mode in MajorModeMatcherDriver.iterActiveModes(): modes.append(mode) names.append(mode.keyword) order = [(n, m) for n, m in zip(names, modes)] order.sort() # NOTE: interestingly, zip is its own unzip! n, m = zip(*order) names = ["All Major Modes"] names.extend(n) modes = [None] modes.extend(m) dprint(modes) dprint(names) return modes, names
def getActiveModesAndNames(self): modes = [] names = [] for mode in MajorModeMatcherDriver.iterActiveModes(): modes.append(mode) names.append(mode.keyword) order = [(n, m) for n, m in zip(names, modes)] order.sort() # NOTE: interestingly, zip is its own unzip! n, m = zip(*order) names = ["All Major Modes"] names.extend(n) modes = [None] modes.extend(m) dprint(modes) dprint(names) return modes, names