Function: python--f-string-p

python--f-string-p is a byte-compiled function defined in python.el.gz.

Signature

(python--f-string-p PPSS)

Documentation

Return non-nil if the pos where PPSS was found is inside an f-string.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/python.el.gz
(defun python--f-string-p (ppss)
  "Return non-nil if the pos where PPSS was found is inside an f-string."
  (and (nth 3 ppss)
       (let* ((spos (1- (nth 8 ppss)))
              (before-quote
               (buffer-substring-no-properties (max (- spos 4) (point-min))
                                               (min (+ spos 2) (point-max)))))
         (and (string-match-p python--f-string-start-regexp before-quote)
              (or (< (point-min) spos)
                  (not (memq (char-syntax (char-before spos)) '(?w ?_))))))))