[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/5] tildify.el: Optimise environments regexes
From: |
Michal Nazarewicz |
Subject: |
[PATCH 3/5] tildify.el: Optimise environments regexes |
Date: |
Sun, 2 Mar 2014 22:55:33 +0100 |
From: Michal Nazarewicz <address@hidden>
Each time beginning of an environment to ignore is found,
`tildify-find-env' needs to identify regexp for the ending
of the environment. This is done by trying all the opening
regexes on matched text in a loop, so to speed that up, this
loop should have fewer things to match, which can be done by
using alternatives in the opening regexes.
Coincidentally, this should make matching of the opening
regexp faster as well thanks to the use of `regexp-opt' and
having common prefix pulled from many regexes.
---
lisp/textmodes/tildify.el | 41 +++++++++++++++++++----------------------
1 file changed, 19 insertions(+), 22 deletions(-)
diff --git a/lisp/textmodes/tildify.el b/lisp/textmodes/tildify.el
index dc23fbe..9accce8 100644
--- a/lisp/textmodes/tildify.el
+++ b/lisp/textmodes/tildify.el
@@ -3,7 +3,7 @@
;; Copyright (C) 1997-2014 Free Software Foundation, Inc.
;; Author: Milan Zamazal <address@hidden>
-;; Version: 4.5.2
+;; Version: 4.5.3
;; Keywords: text, TeX, SGML, wp
;; This file is part of GNU Emacs.
@@ -119,38 +119,35 @@ mode, the item for the mode SYMBOL is looked up in the
alist instead."
(symbol :tag "Like other")))))
(defcustom tildify-ignored-environments-alist
- '((latex-mode
+ `((latex-mode
("\\\\\\\\" . "") ; do not remove this
- ("\\\\begin{verbatim}" . "\\\\end{verbatim}")
+ (,(eval-when-compile (concat
+ "\\\\begin{\\("
+ (regexp-opt '("verbatim" "math" "displaymath"
+ "equation" "eqnarray" "eqnarray*"))
+ "}"))
+ "\\\\end{" 1 "}")
("\\\\verb\\*?\\(.\\)" . (1))
- ("\\$\\$" . "\\$\\$")
- ("\\$" . "\\$")
+ ("\\$\\$?" 0)
("\\\\(" . "\\\\)")
("\\\\[[]" . "\\\\[]]")
- ("\\\\begin{math}" . "\\\\end{math}")
- ("\\\\begin{displaymath}" . "\\\\end{displaymath}")
- ("\\\\begin{equation}" . "\\\\end{equation}")
- ("\\\\begin{eqnarray\\*?}" . "\\\\end{eqnarray\\*?}")
("\\\\[a-zA-Z]+\\( +\\|{}\\)[a-zA-Z]*" . "")
("%" . "$"))
(plain-tex-mode . latex-mode)
(html-mode
- ("<pre[^>]*>" . "</pre>")
- ("<dfn>" . "</dfn>")
- ("<code>" . "</code>")
- ("<samp>" . "</samp>")
- ("<kbd>" . "</kbd>")
- ("<var>" . "</var>")
- ("<PRE[^>]*>" . "</PRE>")
- ("<DFN>" . "</DFN>")
- ("<CODE>" . "</CODE>")
- ("<SAMP>" . "</SAMP>")
- ("<KBD>" . "</KBD>")
- ("<VAR>" . "</VAR>")
+ (,(eval-when-compile (concat
+ "<\\("
+ (regexp-opt '("pre" "dfn" "code" "samp" "kbd" "var"
+ "PRE" "DFN" "CODE" "SAMP" "KBD"
"VAR"))
+ "\\)\\>[^>]*>"))
+ "</" 1 ">")
("<! *--" . "-- *>")
("<" . ">"))
(sgml-mode . html-mode)
- (t nil))
+ (xml-mode
+ ("<! *--" . "-- *>")
+ ("<" . ">"))
+ (nxml-mode . html-mode))
"Alist specifying ignored structured text environments.
Parts of text defined in this alist are skipped without performing hard space
insertion on them. These setting allow skipping text parts like verbatim or
--
1.9.0.279.gdc9e3eb
- [PATCH 0/5] Auto tildify improvements, Michal Nazarewicz, 2014/03/02
- [PATCH 2/5] tildify.el: Change XML hard space to numeric reference., Michal Nazarewicz, 2014/03/02
- [PATCH 3/5] tildify.el: Optimise environments regexes,
Michal Nazarewicz <=
- [PATCH 1/5] tildify.el: Improve defcustom's types., Michal Nazarewicz, 2014/03/02
- [PATCH 4/5] tildify.el: Rewrite `tildify-region' and co., add foreach function., Michal Nazarewicz, 2014/03/02
- [PATCH 5/5] tildify.el: Add `auto-tildify' and `auto-tildify-mode'., Michal Nazarewicz, 2014/03/02