Function: electric-pair--syntax-ppss

electric-pair--syntax-ppss is a byte-compiled function defined in elec-pair.el.gz.

Signature

(electric-pair--syntax-ppss &optional POS WHERE)

Documentation

Like syntax-ppss, but maybe fall back to parse-partial-sexp.

WHERE is a list defaulting to '(string comment) and indicates when to fall back to parse-partial-sexp.

Source Code

;; Defined in /usr/src/emacs/lisp/elec-pair.el.gz
(defun electric-pair--syntax-ppss (&optional pos where)
  "Like `syntax-ppss', but maybe fall back to `parse-partial-sexp'.

WHERE is a list defaulting to \\='(string comment) and indicates
when to fall back to `parse-partial-sexp'."
  (let* ((pos (or pos (point)))
         (where (or where '(string comment)))
         (quick-ppss (syntax-ppss pos))
         (in-string (and (nth 3 quick-ppss) (memq 'string where)))
         (in-comment (and (nth 4 quick-ppss) (memq 'comment where)))
         (s-or-c-start (cond (in-string
                              (1+ (nth 8 quick-ppss)))
                             (in-comment
                              (goto-char (nth 8 quick-ppss))
                              (forward-comment (- (point-max)))
                              (skip-syntax-forward " >!")
                              (point)))))
    (if s-or-c-start
        (electric-pair--with-syntax s-or-c-start
          (parse-partial-sexp s-or-c-start pos))
      ;; HACK! cc-mode apparently has some `syntax-ppss' bugs
      (if (memq major-mode '(c-mode c++ mode))
          (parse-partial-sexp (point-min) pos)
        quick-ppss))))