From d95e7d3ddaab67ffc9b01cdaef376fa22fe410cd Mon Sep 17 00:00:00 2001
From: Erik Osheim <erik@osheim.org>
Date: Tue, 17 Aug 2010 23:43:00 -0400
Subject: [PATCH] add initial tag support to some other languages as well

--HG--
branch : pmacs2
---
 method/tags.py     | 8 +++++---
 mode/erlang.py     | 6 ++++++
 mode/java.py       | 8 ++++++++
 mode/javascript.py | 6 ++++++
 mode/perl.py       | 5 +++++
 mode/python.py     | 6 ++++++
 mode/scheme.py     | 6 ++++++
 7 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/method/tags.py b/method/tags.py
index 55c1755..6355205 100644
--- a/method/tags.py
+++ b/method/tags.py
@@ -102,7 +102,9 @@ class InitTags(Method):
         if not b.path:
             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']:
             m = a.state['tags'][t]
             if m.is_outdated():
@@ -115,7 +117,7 @@ class InitTags(Method):
             return
 
         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)
             if not tail:
                 break
@@ -125,7 +127,7 @@ class InitTags(Method):
             elif os.path.exists(os.path.join(base, 'TAGS')):
                 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._prompt = "Enter source directory: "
             c = completer.get_completer('path')
diff --git a/mode/erlang.py b/mode/erlang.py
index dd5209e..8e4282b 100644
--- a/mode/erlang.py
+++ b/mode/erlang.py
@@ -4,6 +4,7 @@ from point import Point
 from lex import Grammar, PatternRule, RegionRule, OverridePatternRule
 from lex import NocasePatternRule, PatternMatchRule
 from method.shell import Interact
+from etags import TagManager
 
 class AtomGrammar(Grammar):
     rules = [
@@ -89,11 +90,16 @@ class ErlStart(Interact):
     def _execute(self, w, **vargs):
         Interact._execute(self, w, bname='*Erl*', cmd='erl')
 
+class ErlangTagManager(TagManager):
+    lang  = 'Erlang'
+    exts  = set(('.erl',))
+
 class Erlang(mode.Fundamental):
     name        = 'Erlang'
     extensions  = ['.erl']
     tabwidth    = 4
     tabbercls   = ErlangTabber
+    tagcls      = ErlangTagManager
     grammar     = ErlangGrammar
     commentc    = '%'
     opentokens  = ('delimiter',)
diff --git a/mode/java.py b/mode/java.py
index 6031f59..d97d162 100644
--- a/mode/java.py
+++ b/mode/java.py
@@ -3,6 +3,7 @@ import context
 from lex import Grammar, PatternRule, RegionRule, PatternMatchRule
 from mode.python import StringGrammar2
 from parse import Any, And, Or, Optional, Name, Match, Matchs
+from etags import TagManager
 
 class CommentGrammar(Grammar):
     rules = [
@@ -125,10 +126,17 @@ class JavaContext(context.Context):
             if curr: self.namelines[i] = (curr, tuple(stack))
             i += 1
 
+
+class JavaTagManager(TagManager):
+    lang  = 'Java'
+    exts  = set(('.java',))
+
+
 class Java(mode.Fundamental):
     name        = 'Java'
     extensions  = ['.java']
     tabbercls   = JavaTabber2
+    tagcls      = JavaTagManager
     grammar     = JavaGrammar
     commentc    = '//'
     opentokens  = ('delimiter',)
diff --git a/mode/javascript.py b/mode/javascript.py
index c9233be..99088e8 100644
--- a/mode/javascript.py
+++ b/mode/javascript.py
@@ -5,6 +5,7 @@ from mode import Fundamental
 from method.shell import Interact
 from lex import Grammar, PatternRule, RegionRule, PatternMatchRule
 from point import Point
+from etags import TagManager
 
 class StringGrammar1(Grammar):
     rules = [
@@ -110,11 +111,16 @@ class RhinoLoadFile(RhinoStart):
         time.sleep(0.5)
         b.pipe_write('load("%s");\n' % path)
 
+class JavascriptTagManager(TagManager):
+    lang  = 'Javascript'
+    exts  = set(('.js',))
+
 class Javascript(Fundamental):
     name        = 'Javascript'
     extensions  = ['.js']
     grammar     = JavascriptGrammar
     tabbercls   = JavascriptTabber2
+    tagcls      = JavascriptTagManager
     commentc    = '//'
     opentokens  = ('delimiter',)
     opentags    = {'(': ')', '[': ']', '{': '}'}
diff --git a/mode/perl.py b/mode/perl.py
index 76b35cd..a13df82 100644
--- a/mode/perl.py
+++ b/mode/perl.py
@@ -15,6 +15,7 @@ from method.introspect import TokenComplete
 from tab import StackTabber2
 from parse import Any, And, Or, Optional, Name, Match, Matchs
 import term
+from etags import TagManager
 
 strg1 = r"'(?:\\.|[^'\\])*'"
 strg2 = r'"(?:\\.|[^"\\])*"'
@@ -764,6 +765,10 @@ class PerlContext(context.Context):
             if curr: self.namelines[i] = (curr, tuple(stack))
             i += 1
 
+class PerlTagManager(TagManager):
+    lang  = 'Perl'
+    exts  = set(('.pl', '.pm'))
+
 # white is for delimiters, operators, numbers
 c_default = ('default', 'default')
 
diff --git a/mode/python.py b/mode/python.py
index 8528b19..3b821c2 100644
--- a/mode/python.py
+++ b/mode/python.py
@@ -7,6 +7,7 @@ from lex import Grammar, PatternRule, RegionRule, OverridePatternRule
 from parse import Any, And, Or, Optional, Name, Match, Matchs
 from method import Method, arg, Argument
 from method.shell import Exec
+from etags import TagManager
 
 class StringGrammar1(Grammar):
     rules = [
@@ -552,6 +553,10 @@ class PythonContext(context.Context):
                 for k in xrange(last, y2):
                     self.namelines[k] = (curr, None)
 
+class PythonTagManager(TagManager):
+    lang  = 'Python'
+    exts  = set(('.py',))
+
 # white is for delimiters, operators, numbers
 default = ('default', 'default')
 
@@ -596,6 +601,7 @@ class Python(mode.Fundamental):
     extensions  = ['.py']
     detection   = [re.compile('^#!(?:.+[/ ])python')]
     tabbercls   = PythonTabber
+    tagcls      = PythonTagManager
     grammar     = PythonGrammar
     opentokens  = ('delimiter',)
     opentags    = {'(': ')', '[': ']', '{': '}'}
diff --git a/mode/scheme.py b/mode/scheme.py
index 529fbdd..74b8ece 100644
--- a/mode/scheme.py
+++ b/mode/scheme.py
@@ -4,6 +4,7 @@ from point import Point
 from lex import Grammar, PatternRule, RegionRule, OverridePatternRule
 from lex import PatternMatchRule
 from mode.lisp import StringGrammar2, Lisp, LispTabber
+from etags import TagManager
 
 class SchemeGrammar(Grammar):
     rules = [
@@ -53,10 +54,15 @@ class GuileLoadFile(Interact):
         path = os.path.realpath(w.buffer.path)
         b.pipe_write('(load "%s")\n' % path)
 
+class SchemeTagManager(TagManager):
+    lang  = 'Scheme'
+    exts  = set(('.scm',))
+
 class Scheme(Lisp):
     name        = 'Scheme'
     extensions  = ['.scm']
     grammar     = SchemeGrammar
+    tagcls      = SchemeTagManager
     colors      = {
         'scheme_keyword': ('cyan', 'default', 'bold'),
         'scheme_char':    ('green', 'default', 'bold'),