branch: elpa/clojure-mode
commit 9cee4ba3272ed4552d3e2b3c69ecea18aa5f271a
Author: Bozhidar Batsov <[email protected]>
Commit: Bozhidar Batsov <[email protected]>
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.
---
clojure-mode.el | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/clojure-mode.el b/clojure-mode.el
index 4dedf89d7e..5967353793 100644
--- a/clojure-mode.el
+++ b/clojure-mode.el
@@ -1263,14 +1263,18 @@ locking in def* forms that are not at top level."
(defun clojure--font-locked-as-string-p (&optional regexp)
"Non-nil if the char before point is font-locked as a string.
If REGEXP is non-nil, also check whether current string is
-preceeded by a #."
+preceded by a #."
(let ((face (get-text-property (1- (point)) 'face)))
- (and (or (and (listp face)
- (memq 'font-lock-string-face face))
- (eq 'font-lock-string-face face))
- (or (clojure-string-start t)
- (unless regexp
- (clojure-string-start nil))))))
+ (when (or (and (listp face)
+ (memq 'font-lock-string-face face))
+ (eq 'font-lock-string-face face))
+ (let* ((ppss (syntax-ppss))
+ (string-beg (nth 8 ppss)))
+ (when (and (nth 3 ppss) string-beg)
+ (if regexp
+ (when (eq ?# (char-before string-beg))
+ (1- string-beg))
+ string-beg))))))
(defun clojure-font-lock-escaped-chars (bound)
"Highlight \\escaped chars in strings.