help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: My humble additions to AUCTeX


From: jack-mac
Subject: Re: My humble additions to AUCTeX
Date: Mon, 13 Jan 2014 08:35:32 -0800 (PST)
User-agent: G2/1.0

Le lundi 13 janvier 2014 00:28:18 UTC+1, Marcin Borkowski a écrit :
> Also, I still consider myself an Elisp newbie, so it is well possible
> that I did violate some conventions ar good style...
> 
> http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski

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 "@")))

(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) "]")))


These function create a new string each time they are called (even if 
at-is-letter is nil).

For efficiency purpose, I would suggest to "compile" them by hand into 
something like:

(defconst TeX+-letter-ccml        "a-zA-Z"
  "A character class matching letters")

(defconst TeX+-letter-and-at-ccml (concat TeX+-letter-ccml "@")
  "A character class matching letters including \"@\"")

(defconst TeX+-letter-re          (concat "[" TeX+-letter-ccml        "]")
  "A regexp for character class matching letters")

(defconst TeX+-letter-and-at-re   (concat "[" TeX+-letter-and-at-ccml "]")
  "A regexp for character class matching letters including \"@\"")

(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))


(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)))

HTH

)jack(


reply via email to

[Prev in Thread] Current Thread [Next in Thread]