Skip to content

Commit 9cee4ba

Browse files
committed
Consolidate string detection into a single syntax-ppss call
clojure--font-locked-as-string-p previously delegated to clojure-string-start (potentially twice: once for regex, once for regular strings), with each call invoking syntax-ppss separately. Inline the logic with a single syntax-ppss call.
1 parent c9a6ca0 commit 9cee4ba

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

clojure-mode.el

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,14 +1263,18 @@ locking in def* forms that are not at top level."
12631263
(defun clojure--font-locked-as-string-p (&optional regexp)
12641264
"Non-nil if the char before point is font-locked as a string.
12651265
If REGEXP is non-nil, also check whether current string is
1266-
preceeded by a #."
1266+
preceded by a #."
12671267
(let ((face (get-text-property (1- (point)) 'face)))
1268-
(and (or (and (listp face)
1269-
(memq 'font-lock-string-face face))
1270-
(eq 'font-lock-string-face face))
1271-
(or (clojure-string-start t)
1272-
(unless regexp
1273-
(clojure-string-start nil))))))
1268+
(when (or (and (listp face)
1269+
(memq 'font-lock-string-face face))
1270+
(eq 'font-lock-string-face face))
1271+
(let* ((ppss (syntax-ppss))
1272+
(string-beg (nth 8 ppss)))
1273+
(when (and (nth 3 ppss) string-beg)
1274+
(if regexp
1275+
(when (eq ?# (char-before string-beg))
1276+
(1- string-beg))
1277+
string-beg))))))
12741278

12751279
(defun clojure-font-lock-escaped-chars (bound)
12761280
"Highlight \\escaped chars in strings.

0 commit comments

Comments
 (0)