add initial tag support to some other languages as well
--HG-- branch : pmacs2
This commit is contained in:
parent
7cd3b7dda7
commit
d95e7d3dda
|
@ -102,7 +102,9 @@ class InitTags(Method):
|
||||||
if not b.path:
|
if not b.path:
|
||||||
raise Exception('Buffer %r has no path' % b.name())
|
raise Exception('Buffer %r has no path' % b.name())
|
||||||
|
|
||||||
t = b.settings['C'].get('tag-base')
|
mname = w.mode.name
|
||||||
|
|
||||||
|
t = b.settings[mname].get('tag-base')
|
||||||
if t and t in a.state['tags']:
|
if t and t in a.state['tags']:
|
||||||
m = a.state['tags'][t]
|
m = a.state['tags'][t]
|
||||||
if m.is_outdated():
|
if m.is_outdated():
|
||||||
|
@ -115,7 +117,7 @@ class InitTags(Method):
|
||||||
return
|
return
|
||||||
|
|
||||||
base = b.path
|
base = b.path
|
||||||
while 'tag-base' not in b.settings['C']:
|
while 'tag-base' not in b.settings[mname]:
|
||||||
base, tail = os.path.split(base)
|
base, tail = os.path.split(base)
|
||||||
if not tail:
|
if not tail:
|
||||||
break
|
break
|
||||||
|
@ -125,7 +127,7 @@ class InitTags(Method):
|
||||||
elif os.path.exists(os.path.join(base, 'TAGS')):
|
elif os.path.exists(os.path.join(base, 'TAGS')):
|
||||||
return self._save_manager(w, base)
|
return self._save_manager(w, base)
|
||||||
|
|
||||||
if 'tag-base' not in b.settings['C']:
|
if 'tag-base' not in b.settings[mname]:
|
||||||
self._old_window = w
|
self._old_window = w
|
||||||
self._prompt = "Enter source directory: "
|
self._prompt = "Enter source directory: "
|
||||||
c = completer.get_completer('path')
|
c = completer.get_completer('path')
|
||||||
|
|
|
@ -4,6 +4,7 @@ from point import Point
|
||||||
from lex import Grammar, PatternRule, RegionRule, OverridePatternRule
|
from lex import Grammar, PatternRule, RegionRule, OverridePatternRule
|
||||||
from lex import NocasePatternRule, PatternMatchRule
|
from lex import NocasePatternRule, PatternMatchRule
|
||||||
from method.shell import Interact
|
from method.shell import Interact
|
||||||
|
from etags import TagManager
|
||||||
|
|
||||||
class AtomGrammar(Grammar):
|
class AtomGrammar(Grammar):
|
||||||
rules = [
|
rules = [
|
||||||
|
@ -89,11 +90,16 @@ class ErlStart(Interact):
|
||||||
def _execute(self, w, **vargs):
|
def _execute(self, w, **vargs):
|
||||||
Interact._execute(self, w, bname='*Erl*', cmd='erl')
|
Interact._execute(self, w, bname='*Erl*', cmd='erl')
|
||||||
|
|
||||||
|
class ErlangTagManager(TagManager):
|
||||||
|
lang = 'Erlang'
|
||||||
|
exts = set(('.erl',))
|
||||||
|
|
||||||
class Erlang(mode.Fundamental):
|
class Erlang(mode.Fundamental):
|
||||||
name = 'Erlang'
|
name = 'Erlang'
|
||||||
extensions = ['.erl']
|
extensions = ['.erl']
|
||||||
tabwidth = 4
|
tabwidth = 4
|
||||||
tabbercls = ErlangTabber
|
tabbercls = ErlangTabber
|
||||||
|
tagcls = ErlangTagManager
|
||||||
grammar = ErlangGrammar
|
grammar = ErlangGrammar
|
||||||
commentc = '%'
|
commentc = '%'
|
||||||
opentokens = ('delimiter',)
|
opentokens = ('delimiter',)
|
||||||
|
|
|
@ -3,6 +3,7 @@ import context
|
||||||
from lex import Grammar, PatternRule, RegionRule, PatternMatchRule
|
from lex import Grammar, PatternRule, RegionRule, PatternMatchRule
|
||||||
from mode.python import StringGrammar2
|
from mode.python import StringGrammar2
|
||||||
from parse import Any, And, Or, Optional, Name, Match, Matchs
|
from parse import Any, And, Or, Optional, Name, Match, Matchs
|
||||||
|
from etags import TagManager
|
||||||
|
|
||||||
class CommentGrammar(Grammar):
|
class CommentGrammar(Grammar):
|
||||||
rules = [
|
rules = [
|
||||||
|
@ -125,10 +126,17 @@ class JavaContext(context.Context):
|
||||||
if curr: self.namelines[i] = (curr, tuple(stack))
|
if curr: self.namelines[i] = (curr, tuple(stack))
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
|
||||||
|
class JavaTagManager(TagManager):
|
||||||
|
lang = 'Java'
|
||||||
|
exts = set(('.java',))
|
||||||
|
|
||||||
|
|
||||||
class Java(mode.Fundamental):
|
class Java(mode.Fundamental):
|
||||||
name = 'Java'
|
name = 'Java'
|
||||||
extensions = ['.java']
|
extensions = ['.java']
|
||||||
tabbercls = JavaTabber2
|
tabbercls = JavaTabber2
|
||||||
|
tagcls = JavaTagManager
|
||||||
grammar = JavaGrammar
|
grammar = JavaGrammar
|
||||||
commentc = '//'
|
commentc = '//'
|
||||||
opentokens = ('delimiter',)
|
opentokens = ('delimiter',)
|
||||||
|
|
|
@ -5,6 +5,7 @@ from mode import Fundamental
|
||||||
from method.shell import Interact
|
from method.shell import Interact
|
||||||
from lex import Grammar, PatternRule, RegionRule, PatternMatchRule
|
from lex import Grammar, PatternRule, RegionRule, PatternMatchRule
|
||||||
from point import Point
|
from point import Point
|
||||||
|
from etags import TagManager
|
||||||
|
|
||||||
class StringGrammar1(Grammar):
|
class StringGrammar1(Grammar):
|
||||||
rules = [
|
rules = [
|
||||||
|
@ -110,11 +111,16 @@ class RhinoLoadFile(RhinoStart):
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
b.pipe_write('load("%s");\n' % path)
|
b.pipe_write('load("%s");\n' % path)
|
||||||
|
|
||||||
|
class JavascriptTagManager(TagManager):
|
||||||
|
lang = 'Javascript'
|
||||||
|
exts = set(('.js',))
|
||||||
|
|
||||||
class Javascript(Fundamental):
|
class Javascript(Fundamental):
|
||||||
name = 'Javascript'
|
name = 'Javascript'
|
||||||
extensions = ['.js']
|
extensions = ['.js']
|
||||||
grammar = JavascriptGrammar
|
grammar = JavascriptGrammar
|
||||||
tabbercls = JavascriptTabber2
|
tabbercls = JavascriptTabber2
|
||||||
|
tagcls = JavascriptTagManager
|
||||||
commentc = '//'
|
commentc = '//'
|
||||||
opentokens = ('delimiter',)
|
opentokens = ('delimiter',)
|
||||||
opentags = {'(': ')', '[': ']', '{': '}'}
|
opentags = {'(': ')', '[': ']', '{': '}'}
|
||||||
|
|
|
@ -15,6 +15,7 @@ from method.introspect import TokenComplete
|
||||||
from tab import StackTabber2
|
from tab import StackTabber2
|
||||||
from parse import Any, And, Or, Optional, Name, Match, Matchs
|
from parse import Any, And, Or, Optional, Name, Match, Matchs
|
||||||
import term
|
import term
|
||||||
|
from etags import TagManager
|
||||||
|
|
||||||
strg1 = r"'(?:\\.|[^'\\])*'"
|
strg1 = r"'(?:\\.|[^'\\])*'"
|
||||||
strg2 = r'"(?:\\.|[^"\\])*"'
|
strg2 = r'"(?:\\.|[^"\\])*"'
|
||||||
|
@ -764,6 +765,10 @@ class PerlContext(context.Context):
|
||||||
if curr: self.namelines[i] = (curr, tuple(stack))
|
if curr: self.namelines[i] = (curr, tuple(stack))
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
class PerlTagManager(TagManager):
|
||||||
|
lang = 'Perl'
|
||||||
|
exts = set(('.pl', '.pm'))
|
||||||
|
|
||||||
# white is for delimiters, operators, numbers
|
# white is for delimiters, operators, numbers
|
||||||
c_default = ('default', 'default')
|
c_default = ('default', 'default')
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ from lex import Grammar, PatternRule, RegionRule, OverridePatternRule
|
||||||
from parse import Any, And, Or, Optional, Name, Match, Matchs
|
from parse import Any, And, Or, Optional, Name, Match, Matchs
|
||||||
from method import Method, arg, Argument
|
from method import Method, arg, Argument
|
||||||
from method.shell import Exec
|
from method.shell import Exec
|
||||||
|
from etags import TagManager
|
||||||
|
|
||||||
class StringGrammar1(Grammar):
|
class StringGrammar1(Grammar):
|
||||||
rules = [
|
rules = [
|
||||||
|
@ -552,6 +553,10 @@ class PythonContext(context.Context):
|
||||||
for k in xrange(last, y2):
|
for k in xrange(last, y2):
|
||||||
self.namelines[k] = (curr, None)
|
self.namelines[k] = (curr, None)
|
||||||
|
|
||||||
|
class PythonTagManager(TagManager):
|
||||||
|
lang = 'Python'
|
||||||
|
exts = set(('.py',))
|
||||||
|
|
||||||
# white is for delimiters, operators, numbers
|
# white is for delimiters, operators, numbers
|
||||||
default = ('default', 'default')
|
default = ('default', 'default')
|
||||||
|
|
||||||
|
@ -596,6 +601,7 @@ class Python(mode.Fundamental):
|
||||||
extensions = ['.py']
|
extensions = ['.py']
|
||||||
detection = [re.compile('^#!(?:.+[/ ])python')]
|
detection = [re.compile('^#!(?:.+[/ ])python')]
|
||||||
tabbercls = PythonTabber
|
tabbercls = PythonTabber
|
||||||
|
tagcls = PythonTagManager
|
||||||
grammar = PythonGrammar
|
grammar = PythonGrammar
|
||||||
opentokens = ('delimiter',)
|
opentokens = ('delimiter',)
|
||||||
opentags = {'(': ')', '[': ']', '{': '}'}
|
opentags = {'(': ')', '[': ']', '{': '}'}
|
||||||
|
|
|
@ -4,6 +4,7 @@ from point import Point
|
||||||
from lex import Grammar, PatternRule, RegionRule, OverridePatternRule
|
from lex import Grammar, PatternRule, RegionRule, OverridePatternRule
|
||||||
from lex import PatternMatchRule
|
from lex import PatternMatchRule
|
||||||
from mode.lisp import StringGrammar2, Lisp, LispTabber
|
from mode.lisp import StringGrammar2, Lisp, LispTabber
|
||||||
|
from etags import TagManager
|
||||||
|
|
||||||
class SchemeGrammar(Grammar):
|
class SchemeGrammar(Grammar):
|
||||||
rules = [
|
rules = [
|
||||||
|
@ -53,10 +54,15 @@ class GuileLoadFile(Interact):
|
||||||
path = os.path.realpath(w.buffer.path)
|
path = os.path.realpath(w.buffer.path)
|
||||||
b.pipe_write('(load "%s")\n' % path)
|
b.pipe_write('(load "%s")\n' % path)
|
||||||
|
|
||||||
|
class SchemeTagManager(TagManager):
|
||||||
|
lang = 'Scheme'
|
||||||
|
exts = set(('.scm',))
|
||||||
|
|
||||||
class Scheme(Lisp):
|
class Scheme(Lisp):
|
||||||
name = 'Scheme'
|
name = 'Scheme'
|
||||||
extensions = ['.scm']
|
extensions = ['.scm']
|
||||||
grammar = SchemeGrammar
|
grammar = SchemeGrammar
|
||||||
|
tagcls = SchemeTagManager
|
||||||
colors = {
|
colors = {
|
||||||
'scheme_keyword': ('cyan', 'default', 'bold'),
|
'scheme_keyword': ('cyan', 'default', 'bold'),
|
||||||
'scheme_char': ('green', 'default', 'bold'),
|
'scheme_char': ('green', 'default', 'bold'),
|
||||||
|
|
Loading…
Reference in New Issue