From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Marcin Borkowski Newsgroups: gmane.emacs.help Subject: Re: My humble additions to AUCTeX Date: Mon, 13 Jan 2014 19:11:57 +0100 Organization: WMI UAM Message-ID: <20140113191157.6d5e0491@aga-netbook> References: <0b7644c6-18c5-4b4c-b5c6-1c08fecd1918@googlegroups.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1389636741 13643 80.91.229.3 (13 Jan 2014 18:12:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 13 Jan 2014 18:12:21 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jan 13 19:12:29 2014 Return-path: Envelope-to: geh-help-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 1W2lzv-0008EB-JE for geh-help-gnu-emacs@m.gmane.org; Mon, 13 Jan 2014 19:12:27 +0100 Original-Received: from localhost ([::1]:44407 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2lzv-0000qe-39 for geh-help-gnu-emacs@m.gmane.org; Mon, 13 Jan 2014 13:12:27 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60028) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2lzc-0000ol-GZ for help-gnu-emacs@gnu.org; Mon, 13 Jan 2014 13:12:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W2lzW-0000S5-Tz for help-gnu-emacs@gnu.org; Mon, 13 Jan 2014 13:12:08 -0500 Original-Received: from msg.wmi.amu.edu.pl ([2001:808:114:2::50]:47300) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2lzW-0000Rx-NF for help-gnu-emacs@gnu.org; Mon, 13 Jan 2014 13:12:02 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by msg.wmi.amu.edu.pl (Postfix) with ESMTP id DB27C71154 for ; Mon, 13 Jan 2014 19:12:00 +0100 (CET) Original-Received: from msg.wmi.amu.edu.pl ([127.0.0.1]) by localhost (msg.wmi.amu.edu.pl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pKrNKL5UukIq for ; Mon, 13 Jan 2014 19:12:00 +0100 (CET) Original-Received: from aga-netbook (101-138.echostar.pl [213.156.101.138]) by msg.wmi.amu.edu.pl (Postfix) with ESMTPSA id EDADE71151 for ; Mon, 13 Jan 2014 19:11:59 +0100 (CET) In-Reply-To: <0b7644c6-18c5-4b4c-b5c6-1c08fecd1918@googlegroups.com> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.17; i686-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:808:114:2::50 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:95373 Archived-At: Dnia 2014-01-13, o godz. 08:35:32 jack-mac napisa=C5=82(a): >=20 > Le lundi 13 janvier 2014 00:28:18 UTC+1, Marcin Borkowski a =C3=A9crit=C2= =A0: > > Also, I still consider myself an Elisp newbie, so it is well > > possible that I did violate some conventions ar good style... > >=20 > > http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski >=20 > In this file, you wrote: > (defun TeX+-letter (&optional at-is-letter) > "Returns a character class matching letters (including \"@\" if > AT-IS-LETTER is true)." > (concat "a-zA-Z" > (if at-is-letter "@"))) >=20 > (defun TeX+-looking-at-letter (&optional at-is-letter) > "Returns t if the point is at a letter (including \"@\" if > AT-IS-LETTER; default is not)." > (looking-at (concat "[" (TeX+-letter at-is-letter) "]"))) >=20 >=20 > These function create a new string each time they are called (even if > at-is-letter is nil). >=20 > For efficiency purpose, I would suggest to "compile" them by hand > into something like: >=20 > (defconst TeX+-letter-ccml "a-zA-Z" > "A character class matching letters") >=20 > (defconst TeX+-letter-and-at-ccml (concat TeX+-letter-ccml "@") > "A character class matching letters including \"@\"") >=20 > (defconst TeX+-letter-re (concat "[" TeX+-letter-ccml > "]") "A regexp for character class matching letters") >=20 > (defconst TeX+-letter-and-at-re (concat "[" TeX+-letter-and-at-ccml > "]") "A regexp for character class matching letters including \"@\"") >=20 > (defun TeX+-letter (&optional at-is-letter) > "Returns a character class matching letters (including \"@\" if > AT-IS-LETTER is true)." > (if at-is-letter TeX+-letter-and-at-ccml TeX+-letter-ccml)) >=20 >=20 > (defun TeX+-looking-at-letter (&optional at-is-letter) > "Returns t if the point is at a letter (including \"@\" if > AT-IS-LETTER; default is not)." > (looking-at (if at-is-letter TeX+-letter-and-at-re TeX+-letter-re))) >=20 > HTH >=20 > )jack( Thanks a lot! In a case of a trade-of between efficiency and code legibility, I'm in favor of code legibility (unless actual tests prove that optimization is really needed), but here I can see no problems like that. (Well, apart from the a bit more complex situation of LaTeX3, where there are more characters with the "letter" catcode in TeXspeak, but still there are at most 3 cases of what "letter" means.) Best, --=20 Marcin Borkowski http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski Adam Mickiewicz University