From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Francesco =?utf-8?Q?Potort=C3=AC?= Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] etags: Add a small list of interpretors for Python Date: Wed, 12 Jan 2011 17:43:25 +0100 Message-ID: References: <20100819153606.GO4157@google.com> <20101223141344.GB18711@google.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE X-Trace: dough.gmane.org 1294850681 30498 80.91.229.12 (12 Jan 2011 16:44:41 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 12 Jan 2011 16:44:41 +0000 (UTC) Cc: emacs-devel@gnu.org To: Iustin Pop Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jan 12 17:44:36 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Pd3oH-0001Qk-8y for ged-emacs-devel@m.gmane.org; Wed, 12 Jan 2011 17:44:33 +0100 Original-Received: from localhost ([127.0.0.1]:55167 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pd3oG-0001lU-Ij for ged-emacs-devel@m.gmane.org; Wed, 12 Jan 2011 11:44:32 -0500 Original-Received: from [140.186.70.92] (port=39477 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pd3oC-0001lP-GQ for emacs-devel@gnu.org; Wed, 12 Jan 2011 11:44:29 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pd3oB-0002um-5n for emacs-devel@gnu.org; Wed, 12 Jan 2011 11:44:28 -0500 Original-Received: from mx2.isti.cnr.it ([194.119.192.4]:1673) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pd3oA-0002uP-PA for emacs-devel@gnu.org; Wed, 12 Jan 2011 11:44:27 -0500 Original-Received: from SCRIPT-SPFWL-DAEMON.mx.isti.cnr.it by mx.isti.cnr.it (PMDF V6.5-x5 #31825) id <01NWJM61Q0U8O7JOLV@mx.isti.cnr.it> for emacs-devel@gnu.org; Wed, 12 Jan 2011 17:43:28 +0100 (MET) Original-Received: from conversionlocal.isti.cnr.it by mx.isti.cnr.it (PMDF V6.5-x5 #31825) id <01NWJM613FSGO7JNLK@mx.isti.cnr.it> for emacs-devel@gnu.org; Wed, 12 Jan 2011 17:43:26 +0100 (MET) Original-Received: from tucano.isti.cnr.it (tucano.isti.cnr.it [146.48.81.102]) by mx.isti.cnr.it (PMDF V6.5-x5 #31826) with ESMTPSA id <01NWJM5ZSUP6OBB61B@mx.isti.cnr.it>; Wed, 12 Jan 2011 17:43:24 +0100 (MET) Original-Received: from pot by tucano.isti.cnr.it with local (Exim 4.72) (envelope-from ) id 1Pd3nB-0006Qb-9w; Wed, 12 Jan 2011 17:43:25 +0100 In-reply-to: <20101223141344.GB18711@google.com> X-INSM-ip-source: 146.48.81.102 Auth Done X-fingerprint: 4B02 6187 5C03 D6B1 2E31 7666 09DF 2DC9 BE21 6115 X-detected-operating-system: by eggs.gnu.org: OpenVMS 7.2 (Multinet 4.3-4.4 stack) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:134465 Archived-At: > >On Wed, Sep 01, 2010 at 03:09:14PM +0200, Francesco Potort=C3=AC wro= te: >> >Currently, etags has no interpretors defined for Python, which pr= events >> >it from recognising Python scripts that have no extension. This p= atch >> >adds a small list of interpretors for this language, which while = not >> >perfect (e.g. it will fail on specific versions like python2.4), = it is >> >better than the current situation where all scripts without an ex= tension >> >will default to Fortran. >>=20 >> Sure. >>=20 >> >Note: I debated adding a more detailed list, but it would get out= dated >> >quickly, so I left just these three versions. A regular expressio= n for >> >the interpreter name would be much better here, would implementin= g that >> >make sense? >>=20 >> It is simpler than that, see below. > >Sorry for the very late response. > >> >+ static const char *Python_interpreters [] =3D >> >+ { "python", "python2", "python3", NULL }; >>=20 >> You just add "python" here. >>=20 >> >! { "python",Python_help,Python_functions,Python_suffixes,NULL,= Python_interpreters}, >>=20 >> This is allright. >>=20 >> Moreover, in get_language_from_interpreter you change this: >>=20 >> for (lang =3D lang_names; lang->name !=3D NULL; lang++) >> if (lang->interpreters !=3D NULL) >> for (iname =3D lang->interpreters; *iname !=3D NULL; iname++= ) >> if (streq (*iname, interpreter)) >> return lang; >>=20 >> to something like this: >>=20 >> for (lang =3D lang_names; lang->name !=3D NULL; lang++) >> if (lang->interpreters !=3D NULL) >> for (iname =3D lang->interpreters; *iname !=3D NULL; iname++= ) >> --> if (strneq (*iname, interpreter, strlen(*iname))) <-- >> return lang; > >I did this, but then: > >> This changes the semantics of get_language_from_interpreter so tha= t the >> list of interpreters is now a list of initial substrings that are >> accepted as interpreters names: I think that this new semantic is = more >> useful than the previous one. >>=20 >> If this change is done, one should look through the etags builtin = help, >> the man page and the info manual and update them with the new sema= ntics, >> if necessary. > >I looked but didn't find any documentation about this; probably due = the >fact that the interpretors are not user-customizable? > >If you can point me to which docs needs to be changed, I'll be glad = to. >Neither doc/man/etags.1 nor doc/emacs/maintaining.texi list anything >about it. I checked. The builtin help does not mention any details, so no need to update i= t. The man page does not mention the fact that etags looks for an interpreter in the first line of the source files, so no need to upda= te it. Same for the info help. In short, nothing to do in the documentation. >Interdiff from the previous patch: > >=3D=3D=3D modified file 'lib-src/etags.c' >--- lib-src/etags.c 2010-12-23 13:52:41 +0000 >+++ lib-src/etags.c 2010-12-23 14:05:35 +0000 >@@ -757,7 +757,7 @@ > static const char *Python_suffixes [] =3D > { "py", NULL }; > static const char *Python_interpreters [] =3D >- { "python", "python2", "python3", NULL }; >+ { "python", NULL }; > static const char Python_help [] =3D > "In Python code, `def' or `class' at the beginning of a line\n\ > generate a tag."; >@@ -1477,7 +1477,7 @@ > for (lang =3D lang_names; lang->name !=3D NULL; lang++) > if (lang->interpreters !=3D NULL) > for (iname =3D lang->interpreters; *iname !=3D NULL; iname++) >- if (streq (*iname, interpreter)) >+ if (strneq (*iname, interpreter, strlen(*iname))) > return lang; >=20 > return NULL; > >--=20 >thanks, >iustin > Comments should be updated in the source: char **interpreters;=09=09/* interpreters for this language */ This should probably read: char **interpreters;=09/* initial substr of interpreters for this l= anguage */ --=20 Francesco Potort=C3=AC (ricercatore) Voice: +39 050 315 3058 (= op.2111) ISTI - Area della ricerca CNR Fax: +39 050 315 2040 via G. Moruzzi 1, I-56124 Pisa Email: Potorti@isti.cnr.it (entrance 20, 1st floor, room C71) Web: http://fly.isti.cnr.it/