Function: python-syntax-context

python-syntax-context is a byte-compiled function defined in python.el.gz.

Signature

(python-syntax-context TYPE &optional SYNTAX-PPSS)

Documentation

Return non-nil if point is on TYPE using SYNTAX-PPSS.

TYPE can be comment, string, single-quoted-string, triple-quoted-string or paren. It returns the start character address of the specified TYPE.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/python.el.gz
(defun python-syntax-context (type &optional syntax-ppss)
  "Return non-nil if point is on TYPE using SYNTAX-PPSS.
TYPE can be `comment', `string', `single-quoted-string',
`triple-quoted-string' or `paren'.  It returns the start
character address of the specified TYPE."
  (declare (compiler-macro python-syntax--context-compiler-macro))
  (let ((ppss (or syntax-ppss (syntax-ppss))))
    (pcase type
      ('comment (and (nth 4 ppss) (nth 8 ppss)))
      ('string (and (nth 3 ppss) (nth 8 ppss)))
      ('single-quoted-string (and (characterp (nth 3 ppss)) (nth 8 ppss)))
      ('triple-quoted-string (and (eq t (nth 3 ppss)) (nth 8 ppss)))
      ('paren (nth 1 ppss))
      (_ nil))))