Skip to content

Commit 061a794

Browse files
committed
Add php-mode-syntax-propertize-extend-region-limit for optimize syntax propertization
1 parent 8c60b69 commit 061a794

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

Diff for: CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,17 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this
1111
* Add `php-imenu-generic-expression-default` for default value or `php-imenu-generic-expression`
1212
* Add `php-imenu-generic-expression-legacy` for compatibility
1313
* Add `php-imenu-generic-expression-simple` for simple display
14+
* Add custom variables
15+
* Add `php-mode-syntax-propertize-extend-region-limit` for optimize syntax propertization
16+
* The number of search characters used to find the starting point of Heredoc and Nowdoc
1417

1518
### Changed
1619

1720
* Optimized propertize process ([#669])
1821
* Reimoplement `php-syntax-propertize-function` using `syntax-propertize-rules`
1922
* Make propertize PHP 8 `#[Attribute]` always enabled
2023
* Changed grouping of `php-heredoc-start-re`
24+
* Use limits on `php-mode-syntax-propertize-extend-region-limit` variable to find the starting point of Heredoc and Nowdoc
2125
* Re-organized `php-imenu-generic-expression`
2226
* Added `Import`, `Constants` and `Properties`
2327
* Removed `Anonymous Functions`

Diff for: lisp/php-mode.el

+19-8
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,15 @@ In that case set to `NIL'."
284284
:tag "PHP Mode Enable Project Local Variable"
285285
:type 'boolean)
286286

287+
(defcustom php-mode-syntax-propertize-extend-region-limit (* 100 syntax-propertize-chunk-size)
288+
"Boundary value of the number of search characters to propertize syntax.
289+
290+
Smaller values can improve performance with large buffers.
291+
If the value is too small, the syntax will not be displayed properly."
292+
:group 'php-mode
293+
:tag "PHP Mode Syntax Propertize Extend Region Limit"
294+
:type 'integer)
295+
287296
(defconst php-mode-cc-vertion
288297
(eval-when-compile c-version))
289298

@@ -987,22 +996,24 @@ this ^ lineup"
987996

988997
(defun php-syntax-propertize-extend-region (start end)
989998
"Extend the propertize region if START or END falls inside a PHP heredoc."
990-
(let ((pair (cons start end)))
999+
(let ((pair (cons start end))
1000+
(limit (max syntax-propertize-chunk-size php-mode-syntax-propertize-extend-region-limit))
1001+
new-start new-end maybe)
9911002
(when (not (member pair php-mode--propertize-extend-region-current))
9921003
;; re-search functions may trigger
9931004
;; syntax-propertize-extend-region-functions to be called again, which in
9941005
;; turn call this to be called again.
9951006
(push pair php-mode--propertize-extend-region-current)
9961007
(unwind-protect
997-
(let (new-start new-end)
1008+
(progn
9981009
(goto-char start)
999-
(when (re-search-backward php-heredoc-start-re nil t)
1000-
(let ((maybe (point)))
1001-
(when (and (re-search-forward (php-heredoc-end-re (match-string 0)) nil t)
1002-
(> (point) start))
1003-
(setq new-start maybe))))
1010+
(when (re-search-backward php-heredoc-start-re limit t)
1011+
(setq maybe (point))
1012+
(when (and (re-search-forward (php-heredoc-end-re (match-string 0)) nil t)
1013+
(> (point) start))
1014+
(setq new-start maybe)))
10041015
(goto-char end)
1005-
(when (re-search-backward php-heredoc-start-re nil t)
1016+
(when (re-search-backward php-heredoc-start-re limit t)
10061017
(if (re-search-forward (php-heredoc-end-re (match-string 0)) nil t)
10071018
(when (> (point) end)
10081019
(setq new-end (point)))

0 commit comments

Comments
 (0)