Function: antlr-syntactic-context

antlr-syntactic-context is a byte-compiled function defined in antlr-mode.el.gz.

Signature

(antlr-syntactic-context &optional PPSS)

Documentation

Return some syntactic context information.

Return string if point is within a string, block-comment or comment if point is within a comment or the depth within all parenthesis-syntax delimiters at point otherwise. WARNING: this may alter match-data. Optional argument PPSS

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/antlr-mode.el.gz
;;;;##########################################################################
;;;;  The Code
;;;;##########################################################################



;;;===========================================================================
;;;  Context cache
;;;===========================================================================

(defun antlr-syntactic-context (&optional ppss)
  "Return some syntactic context information.
Return `string' if point is within a string, `block-comment' or
`comment' if point is within a comment or the depth within all
parenthesis-syntax delimiters at point otherwise.
WARNING: this may alter `match-data'.
Optional argument PPSS"  ; TODO: warning this valid?
  ;; does not work for negative depth
  (or ppss (setq ppss (syntax-ppss)))
  (cond ((nth 3 ppss) 'string)
        ((nth 4 ppss) 'comment)
        (t
         (let ((poss (nth 9 ppss)))        ; TODO Emacs: syntax-ppss-open-positions
           (while (and poss (memq (char-after (car poss)) '(nil ?\()))
             (setq poss (cdr poss)))
           (and poss (length poss)))))) ; depth if inside {} or []