Function: clojure--font-locked-as-string-p

clojure--font-locked-as-string-p is a byte-compiled function defined in clojure-mode.el.

Signature

(clojure--font-locked-as-string-p &optional REGEXP)

Documentation

Non-nil if the char before point is font-locked as a string.

If REGEXP is non-nil, also check whether current string is preceded by a #.

Source Code

;; Defined in ~/.emacs.d/elpa/clojure-mode-20260325.811/clojure-mode.el
(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
preceded by a #."
  ;; Check font-lock-string-face specifically (not font-lock-doc-face)
  ;; so that docstrings are excluded from matching.
  (let ((face (get-text-property (1- (point)) 'face)))
    (when (or (and (listp face)
                   (memq 'font-lock-string-face face))
              (eq 'font-lock-string-face face))
      ;; Single syntax-ppss call: nth 3 = in-string flag,
      ;; nth 8 = start position of the string.
      (let* ((ppss (syntax-ppss))
             (string-beg (nth 8 ppss)))
        (when (and (nth 3 ppss) string-beg)
          (if regexp
              ;; Regex strings are preceded by # (e.g. #"pattern").
              ;; Return position including the # prefix.
              (when (eq ?# (char-before string-beg))
                (1- string-beg))
            ;; When regexp is nil, match any string (both #"..." and "...").
            string-beg))))))