Skip to content

Improve font locking performance on strings with escaped characters #591

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

Merged
merged 2 commits into from
May 2, 2021
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

### Changes

* [#589](https://github.com/clojure-emacs/clojure-mode/issues/589): Improve font-locking performance on strings with escaped characters.
* [#571](https://github.com/clojure-emacs/clojure-mode/issues/571): Remove `project.el` integration.
* [#574](https://github.com/clojure-emacs/clojure-mode/issues/574): Remove `clojure-view-grimoire` command.
* Stop `clojure-sort-ns` from calling `redisplay`.
Expand Down
16 changes: 5 additions & 11 deletions clojure-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -1662,17 +1662,11 @@ If REGEX is non-nil, return the position of the # that begins the
regex at point. If point is not inside a string or regex, return
nil."
(when (nth 3 (syntax-ppss)) ;; Are we really in a string?
(save-excursion
(save-match-data
;; Find a quote that appears immediately after whitespace,
;; beginning of line, hash, or an open paren, brace, or bracket
(re-search-backward "\\(\\s-\\|^\\|#\\|(\\|\\[\\|{\\)\\(\"\\)")
(let ((beg (match-beginning 2)))
(when beg
(if regex
(and (char-before beg) (eq ?# (char-before beg)) (1- beg))
(when (not (eq ?# (char-before beg)))
beg))))))))
(let* ((beg (nth 8 (syntax-ppss)))
(hash (eq ?# (char-before beg))))
(if regex
(and hash (1- beg))
(and (not hash) beg)))))

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