From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Pierre-Antoine Rouby Newsgroups: gmane.emacs.bugs Subject: bug#46055: [PATCH] Add rust lang to etags Date: Sat, 23 Jan 2021 20:01:43 +0100 Message-ID: <20210123190143.29246-1-contact@parouby.fr> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33959"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Pierre-Antoine Rouby To: 46055@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jan 23 20:03:18 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l3OBq-0008k1-AQ for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 23 Jan 2021 20:03:18 +0100 Original-Received: from localhost ([::1]:52142 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l3OBp-0000aq-D7 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 23 Jan 2021 14:03:17 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52672) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l3OBb-0000Z1-2n for bug-gnu-emacs@gnu.org; Sat, 23 Jan 2021 14:03:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:51979) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l3OBa-0005ZF-4z for bug-gnu-emacs@gnu.org; Sat, 23 Jan 2021 14:03:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l3OBa-0004bA-0l for bug-gnu-emacs@gnu.org; Sat, 23 Jan 2021 14:03:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Pierre-Antoine Rouby Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 23 Jan 2021 19:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 46055 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.161142853417618 (code B ref -1); Sat, 23 Jan 2021 19:03:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 23 Jan 2021 19:02:14 +0000 Original-Received: from localhost ([127.0.0.1]:35292 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l3OAo-0004a6-5Z for submit@debbugs.gnu.org; Sat, 23 Jan 2021 14:02:14 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:45444) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l3OAl-0004Zy-V5 for submit@debbugs.gnu.org; Sat, 23 Jan 2021 14:02:12 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52474) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l3OAk-0000Au-90 for bug-gnu-emacs@gnu.org; Sat, 23 Jan 2021 14:02:11 -0500 Original-Received: from 17.mo5.mail-out.ovh.net ([46.105.56.132]:52408) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l3OAi-0005BF-2t for bug-gnu-emacs@gnu.org; Sat, 23 Jan 2021 14:02:09 -0500 Original-Received: from player755.ha.ovh.net (unknown [10.108.54.52]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id 1982D2A8514 for ; Sat, 23 Jan 2021 20:01:57 +0100 (CET) Original-Received: from parouby.fr (91-175-17-70.subs.proxad.net [91.175.17.70]) (Authenticated sender: contact@parouby.fr) by player755.ha.ovh.net (Postfix) with ESMTPSA id 88AAA1A68A688; Sat, 23 Jan 2021 19:01:56 +0000 (UTC) Authentication-Results: garm.ovh; auth=pass (GARM-105G0066ad67cc1-f7c3-447d-90f6-fc8a3c7bac32, C852A40F96BA1AB9599DE0135A45900F0AB8A045) smtp.auth=contact@parouby.fr X-OVh-ClientIp: 91.175.17.70 X-Mailer: git-send-email 2.29.2 X-Ovh-Tracer-Id: 8261009092924945419 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeduledrudekgdduvdefucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucenucfjughrpefhvffufffkofgggfestdekredtredttdenucfhrhhomheprfhivghrrhgvqdetnhhtohhinhgvucftohhusgihuceotghonhhtrggtthesphgrrhhouhgshidrfhhrqeenucggtffrrghtthgvrhhnpeffteffgeekveekgeetudfghfdttdeigfeffffhhfdvveektdefvdeljeffudetudenucfkpheptddrtddrtddrtddpledurddujeehrddujedrjedtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmohguvgepshhmthhpqdhouhhtpdhhvghlohepphhlrgihvghrjeehhedrhhgrrdhovhhhrdhnvghtpdhinhgvtheptddrtddrtddrtddpmhgrihhlfhhrohhmpegtohhnthgrtghtsehprghrohhusgihrdhfrhdprhgtphhtthhopegsuhhgqdhgnhhuqdgvmhgrtghssehgnhhurdhorhhg Received-SPF: pass client-ip=46.105.56.132; envelope-from=contact@parouby.fr; helo=17.mo5.mail-out.ovh.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:198455 Archived-At: * lib-src/etags.c (Rust_functions): New function to make tags for rust files. (Rust_help, Rust_suffixes): New constant. --- lib-src/etags.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/lib-src/etags.c b/lib-src/etags.c index b5c18e0e01..8243861c69 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c @@ -366,6 +366,7 @@ #define xrnew(op, n, m) ((op) = xnrealloc (op, n, (m) * sizeof *(op))) static void Prolog_functions (FILE *); static void Python_functions (FILE *); static void Ruby_functions (FILE *); +static void Rust_functions (FILE *); static void Scheme_functions (FILE *); static void TeX_commands (FILE *); static void Texinfo_nodes (FILE *); @@ -752,6 +753,12 @@ #define STDIN 0x1001 /* returned by getopt_long on --parse-stdin */ static const char *Ruby_interpreters [] = { "ruby", NULL }; +static const char *Rust_suffixes [] = + { "rs", NULL }; +static const char Rust_help [] = + "In Rust code, tags anything defined with 'fn', 'enum', \n\ +'struct' or 'macro_rules!'."; + /* 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 }; @@ -836,6 +843,7 @@ #define STDIN 0x1001 /* returned by getopt_long on --parse-stdin */ NULL, Python_interpreters }, { "ruby", Ruby_help, Ruby_functions, Ruby_suffixes, Ruby_filenames, Ruby_interpreters }, + { "rust", Rust_help, Rust_functions, Rust_suffixes }, { "scheme", Scheme_help, Scheme_functions, Scheme_suffixes }, { "tex", TeX_help, TeX_commands, TeX_suffixes }, { "texinfo", Texinfo_help, Texinfo_nodes, Texinfo_suffixes }, @@ -5019,6 +5027,47 @@ Ruby_functions (FILE *inf) } } + +/* + * Rust support + * Look for: + * - fn: Function + * - struct: Structure + * - enum: Enumeration + * - macro_rules!: Macro + */ +static void +Rust_functions (FILE *inf) +{ + char *cp, *name; + + LOOP_ON_INPUT_LINES(inf, lb, cp) + { + cp = skip_spaces(cp); + name = cp; + + // Skip 'pub' keyworld + (void)LOOKING_AT (cp, "pub"); + + // Look for define + if (LOOKING_AT (cp, "fn") + || LOOKING_AT (cp, "enum") + || LOOKING_AT (cp, "struct") + || LOOKING_AT (cp, "macro_rules!")) + { + cp = skip_spaces (cp); + name = cp; + + while (!notinname (*cp)) + cp++; + + make_tag (name, cp - name, true, + lb.buffer, cp - lb.buffer + 1, + lineno, linecharno); + } + } +} + /* * PHP support -- 2.29.2