From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: lu4nx Newsgroups: gmane.emacs.bugs Subject: bug#22116: [PATCH] * etags.c: Add support for Ruby language. Date: Tue, 8 Dec 2015 18:56:04 +0800 Message-ID: <1449572164-19846-1-git-send-email-lx@shellcodes.org> NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1449592527 13541 80.91.229.3 (8 Dec 2015 16:35:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 8 Dec 2015 16:35:27 +0000 (UTC) Cc: lu4nx To: 22116@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Dec 08 17:35:15 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1a6LEP-00073a-Dn for geb-bug-gnu-emacs@m.gmane.org; Tue, 08 Dec 2015 17:35:13 +0100 Original-Received: from localhost ([::1]:60644 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a6LEO-0006Sa-Et for geb-bug-gnu-emacs@m.gmane.org; Tue, 08 Dec 2015 11:35:12 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42408) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a6LEK-0006QC-Ek for bug-gnu-emacs@gnu.org; Tue, 08 Dec 2015 11:35:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a6LEG-00006T-8P for bug-gnu-emacs@gnu.org; Tue, 08 Dec 2015 11:35:08 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:53712) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a6LEG-00006B-4I for bug-gnu-emacs@gnu.org; Tue, 08 Dec 2015 11:35:04 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1a6LEF-0007Ba-EU for bug-gnu-emacs@gnu.org; Tue, 08 Dec 2015 11:35:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: lu4nx Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 08 Dec 2015 16:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 22116 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.144959248027570 (code B ref -1); Tue, 08 Dec 2015 16:35:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 8 Dec 2015 16:34:40 +0000 Original-Received: from localhost ([127.0.0.1]:43417 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1a6LDr-0007Aa-2L for submit@debbugs.gnu.org; Tue, 08 Dec 2015 11:34:39 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:45874) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1a6Fwk-0005KK-3t for submit@debbugs.gnu.org; Tue, 08 Dec 2015 05:56:56 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a6Fwi-00017L-Qp for submit@debbugs.gnu.org; Tue, 08 Dec 2015 05:56:37 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:41653) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a6Fwi-00017H-Ox for submit@debbugs.gnu.org; Tue, 08 Dec 2015 05:56:36 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55867) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a6Fwh-0001qE-Of for bug-gnu-emacs@gnu.org; Tue, 08 Dec 2015 05:56:36 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a6Fwe-00016A-HU for bug-gnu-emacs@gnu.org; Tue, 08 Dec 2015 05:56:35 -0500 Original-Received: from smtpproxy19.qq.com ([184.105.206.84]:44371) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a6Fwe-00015i-9d for bug-gnu-emacs@gnu.org; Tue, 08 Dec 2015 05:56:32 -0500 X-QQ-mid: Xesmtp11t1449572184t103t0122 Original-Received: from lx-pc (unknown [182.138.102.86]) by esmtp4.qq.com (ESMTP) with id ; Tue, 08 Dec 2015 18:56:23 +0800 (CST) X-QQ-SSF: B1000000000000F0FF103F00000000Z X-QQ-FEAT: QX/rXDl9P1uGSSJSClE9xIv5li5QBuIVYLPV3ue0URbJH5fc3dchsAXODPMIo AhzzNbE7TaJqJ+1QlXkQu0QoPJtc3IIcxmBw6ElcGQIztCpuom377fQ84C3/F/LfhZ8Sls3 elDNI2CLXsOWhruanNtVH7tbVsz0jf6Zf1uBR4+Di8Wf1UyXWDboDv68P2RAFCmzlxajyc0 21zQeziIGF/s8ULGH4zkJ0cKJ0crZwSCwiSVXlcYmGoRAEXsKuP4tPnz54IjDuN4= X-QQ-GoodBg: 0 X-Mailer: git-send-email 2.5.0 X-QQ-SENDSIZE: 520 X-QQ-Bgrelay: 1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Mailman-Approved-At: Tue, 08 Dec 2015 11:34:37 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:109765 Archived-At: --- lib-src/etags.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/lib-src/etags.c b/lib-src/etags.c index 8b980d3..7c8c503 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c @@ -364,6 +364,7 @@ static void PHP_functions (FILE *); static void PS_functions (FILE *); static void Prolog_functions (FILE *); static void Python_functions (FILE *); +static void Ruby_functions (FILE *); static void Scheme_functions (FILE *); static void TeX_commands (FILE *); static void Texinfo_nodes (FILE *); @@ -722,6 +723,12 @@ static const char Python_help [] = "In Python code, 'def' or 'class' at the beginning of a line\n\ generate a tag."; +static const char *Ruby_suffixes [] = + { "rb", NULL }; +static const char Ruby_help [] = + "In Ruby code, 'def' or 'class' at the beginning of a line\n\ +generate a tag."; + /* Can't do the `SCM' or `scm' prefix with a version number. */ static const char *Scheme_suffixes [] = { "oak", "sch", "scheme", "SCM", "scm", "SM", "sm", "ss", "t", NULL }; @@ -800,6 +807,7 @@ static language lang_names [] = { "proc", no_lang_help, plain_C_entries, plain_C_suffixes }, { "prolog", Prolog_help, Prolog_functions, Prolog_suffixes }, { "python", Python_help, Python_functions, Python_suffixes }, + { "ruby", Ruby_help, Ruby_functions, Ruby_suffixes }, { "scheme", Scheme_help, Scheme_functions, Scheme_suffixes }, { "tex", TeX_help, TeX_commands, TeX_suffixes }, { "texinfo", Texinfo_help, Texinfo_nodes, Texinfo_suffixes }, @@ -4532,6 +4540,31 @@ Python_functions (FILE *inf) } } +/* + * Ruby support + * Idea by Xi Lu (2015) + */ +static void +Ruby_functions (FILE *inf) +{ + char *cp = NULL; + + LOOP_ON_INPUT_LINES (inf, lb, cp) + { + cp = skip_spaces (cp); + if (LOOKING_AT (cp, "def") || LOOKING_AT (cp, "class")) + { + char *name = cp; + + while (!notinname (*cp)) + cp++; + + make_tag(name, cp -name, true, + lb.buffer, cp - lb.buffer + 1, lineno, linecharno); + } + } +} + /* * PHP support @@ -4954,7 +4987,22 @@ Lua_functions (FILE *inf) (void)LOOKING_AT (bp, "local"); /* skip possible "local" */ if (LOOKING_AT (bp, "function")) - get_tag (bp, NULL); + { + char *tag_name, *tp_dot, *tp_colon; + + get_tag (bp, &tag_name); + /* If the tag ends with ".foo" or ":foo", make an additional tag for + "foo". */ + tp_dot = strrchr (tag_name, '.'); + tp_colon = strrchr (tag_name, ':'); + if (tp_dot || tp_colon) + { + char *p = tp_dot > tp_colon ? tp_dot : tp_colon; + int len_add = p - tag_name + 1; + + get_tag (bp + len_add, NULL); + } + } } } -- 2.5.0