Skip to content

Commit a4b0693

Browse files
committed
Refactor regexp pattern of auto-mode-alist
Merge regexp match counts at once. Although the number of lines is increasing, it is calculated at compile time, so it does not cost anything.
1 parent ae71870 commit a4b0693

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

php-mode.el

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,8 +1790,23 @@ The output will appear in the buffer *PHP*."
17901790

17911791

17921792
;;;###autoload
1793-
(dolist (pattern '("\\.php[s345t]?\\'" "/\\.php_cs\\(\\.dist\\)?\\'" "\\.phtml\\'" "/Amkfile\\'" "\\.amk\\'"))
1794-
(add-to-list 'auto-mode-alist `(,pattern . php-mode) t))
1793+
(add-to-list 'auto-mode-alist
1794+
(cons
1795+
(eval-when-compile
1796+
(rx (or
1797+
;; File name extensions (ex. "*.php", "*.phtml")
1798+
(: "."
1799+
(or (: "php" (? (in "s345t")))
1800+
"amk"
1801+
"phtml"))
1802+
;; Full file names (ex. "/Makefile", "/Amkfile")
1803+
(: "/"
1804+
(or "Amkfile"
1805+
".php_cs"
1806+
".php_cs.dist")))
1807+
string-end))
1808+
'php-mode)
1809+
t)
17951810

17961811
(provide 'php-mode)
17971812

0 commit comments

Comments
 (0)