tildify.el: Optimise environments regexes
* lisp/textmodes/tildify.el (tildify-ignored-environments-alist): 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.
This commit is contained in:
parent
eb54c73a9d
commit
df344ab435
2 changed files with 29 additions and 22 deletions
|
@ -1,5 +1,19 @@
|
|||
2014-06-05 Michal Nazarewicz <mina86@mina86.com>
|
||||
|
||||
* textmodes/tildify.el (tildify-ignored-environments-alist):
|
||||
Optimise environments regexes
|
||||
|
||||
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.
|
||||
|
||||
* textmodes/tildify.el (tildify-string-alist)
|
||||
(tildify-ignored-environments-alist): Add `nxml-mode' to the list
|
||||
of supported modes since `xml-mode' is no longer a thing but just
|
||||
|
|
|
@ -119,42 +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)
|
||||
(xml-mode
|
||||
("<! *--" . "-- *>")
|
||||
("<" . ">"))
|
||||
(nxml-mode . xml-mode)
|
||||
(t nil))
|
||||
(nxml-mode . xml-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
|
||||
|
|
Loading…
Add table
Reference in a new issue