Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve php-syntax-propertize-extend-region efficiency #789

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions lisp/php-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -1038,17 +1038,24 @@ HEREDOC-START."
(unwind-protect
(let (new-start new-end)
(goto-char start)
;; Consider bounding this backwards search by `beginning-of-defun'.
;; (Benchmarking for a wide range of cases may be needed to decide
;; whether that's an improvement, as `php-beginning-of-defun' also
;; uses `re-search-backward'.)
(when (re-search-backward php-heredoc-start-re nil t)
(let ((maybe (point)))
(when (and (re-search-forward (php-heredoc-end-re (match-string 0)) nil t)
(> (point) start))
(setq new-start maybe))))
(goto-char end)
(when (re-search-backward php-heredoc-start-re nil t)
(if (re-search-forward (php-heredoc-end-re (match-string 0)) nil t)
(setq new-start maybe)
(when (> (point) end)
(setq new-end (point)))
(setq new-end (point-max))))
(setq new-end (point))))))
(unless new-end
(goto-char end)
(when (re-search-backward php-heredoc-start-re start t)
(if (re-search-forward (php-heredoc-end-re (match-string 0)) nil t)
(when (> (point) end)
(setq new-end (point)))
(setq new-end (point-max)))))
(when (or new-start new-end)
(cons (or new-start start) (or new-end end))))
;; Cleanup
Expand Down