Skip to content

Commit 078f591

Browse files
authored
[Fix #589] Improve font locking performance on strings with escaped characters (#591)
1 parent 512e285 commit 078f591

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
### Changes
1212

13+
* [#589](https://github.com/clojure-emacs/clojure-mode/issues/589): Improve font-locking performance on strings with escaped characters.
1314
* [#571](https://github.com/clojure-emacs/clojure-mode/issues/571): Remove `project.el` integration.
1415
* [#574](https://github.com/clojure-emacs/clojure-mode/issues/574): Remove `clojure-view-grimoire` command.
1516
* Stop `clojure-sort-ns` from calling `redisplay`.

clojure-mode.el

+5-11
Original file line numberDiff line numberDiff line change
@@ -1662,17 +1662,11 @@ If REGEX is non-nil, return the position of the # that begins the
16621662
regex at point. If point is not inside a string or regex, return
16631663
nil."
16641664
(when (nth 3 (syntax-ppss)) ;; Are we really in a string?
1665-
(save-excursion
1666-
(save-match-data
1667-
;; Find a quote that appears immediately after whitespace,
1668-
;; beginning of line, hash, or an open paren, brace, or bracket
1669-
(re-search-backward "\\(\\s-\\|^\\|#\\|(\\|\\[\\|{\\)\\(\"\\)")
1670-
(let ((beg (match-beginning 2)))
1671-
(when beg
1672-
(if regex
1673-
(and (char-before beg) (eq ?# (char-before beg)) (1- beg))
1674-
(when (not (eq ?# (char-before beg)))
1675-
beg))))))))
1665+
(let* ((beg (nth 8 (syntax-ppss)))
1666+
(hash (eq ?# (char-before beg))))
1667+
(if regex
1668+
(and hash (1- beg))
1669+
(and (not hash) beg)))))
16761670

16771671
(defun clojure-char-at-point ()
16781672
"Return the char at point or nil if at buffer end."

0 commit comments

Comments
 (0)