Function: wisent-python-forward-balanced-expression
wisent-python-forward-balanced-expression is a byte-compiled function
defined in python.el.gz.
Signature
(wisent-python-forward-balanced-expression)
Documentation
Move point to the end of the balanced expression at point.
Here “balanced expression” means anything matched by Emacs's open/close parenthesis syntax classes. We can't use forward-sexp for this because that Emacs built-in can't parse Python's triple-quoted string syntax.
Source Code
;; Defined in /usr/src/emacs/lisp/cedet/semantic/wisent/python.el.gz
(defun wisent-python-forward-balanced-expression ()
"Move point to the end of the balanced expression at point.
Here “balanced expression” means anything matched by Emacs's
open/close parenthesis syntax classes. We can't use forward-sexp
for this because that Emacs built-in can't parse Python's
triple-quoted string syntax."
(let ((end-char (cdr (syntax-after (point)))))
(forward-char 1)
(while (not (or (eobp) (eq (char-after (point)) end-char)))
(cond
;; Skip over python strings.
((looking-at wisent-python-string-start-re)
(wisent-python-forward-string))
;; At a comment start just goto end of line.
((looking-at "\\s<")
(end-of-line))
;; Skip over balanced expressions.
((looking-at "\\s(")
(wisent-python-forward-balanced-expression))
;; Skip over white space, word, symbol, punctuation, paired
;; delimiter (backquote) characters, line continuation, and end
;; of comment characters (AKA newline characters in Python).
((zerop (skip-syntax-forward "-w_.$\\>"))
(error "Can't figure out how to go forward from here"))))
;; Skip closing character. As a last resort this should raise an
;; error if we hit EOB before we find our closing character..
(forward-char 1)))