GNU bug report logs - #46055
[PATCH] Add rust lang to etags

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Pierre-Antoine Rouby <contact@HIDDEN>; Keywords: patch; dated Sat, 23 Jan 2021 19:03:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 23 Jan 2021 19:02:14 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 23 14:02:14 2021
Received: from localhost ([127.0.0.1]:35292 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1l3OAo-0004a6-5Z
	for submit <at> debbugs.gnu.org; Sat, 23 Jan 2021 14:02:14 -0500
Received: from lists.gnu.org ([209.51.188.17]:45444)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <contact@HIDDEN>) id 1l3OAl-0004Zy-V5
 for submit <at> debbugs.gnu.org; Sat, 23 Jan 2021 14:02:12 -0500
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 <contact@HIDDEN>)
 id 1l3OAk-0000Au-90
 for bug-gnu-emacs@HIDDEN; Sat, 23 Jan 2021 14:02:11 -0500
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 <contact@HIDDEN>)
 id 1l3OAi-0005BF-2t
 for bug-gnu-emacs@HIDDEN; Sat, 23 Jan 2021 14:02:09 -0500
Received: from player755.ha.ovh.net (unknown [10.108.54.52])
 by mo5.mail-out.ovh.net (Postfix) with ESMTP id 1982D2A8514
 for <bug-gnu-emacs@HIDDEN>; Sat, 23 Jan 2021 20:01:57 +0100 (CET)
Received: from parouby.fr (91-175-17-70.subs.proxad.net [91.175.17.70])
 (Authenticated sender: contact@HIDDEN)
 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@HIDDEN
X-OVh-ClientIp: 91.175.17.70
From: Pierre-Antoine Rouby <contact@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: [PATCH] Add rust lang to etags
Date: Sat, 23 Jan 2021 20:01:43 +0100
Message-Id: <20210123190143.29246-1-contact@HIDDEN>
X-Mailer: git-send-email 2.29.2
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
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@HIDDEN;
 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-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
Cc: Pierre-Antoine Rouby <contact@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

* 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





Acknowledgement sent to Pierre-Antoine Rouby <contact@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#46055; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sat, 23 Jan 2021 19:15:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.