Function: c-backward-token-2
c-backward-token-2 is a byte-compiled function defined in
cc-engine.el.gz.
Signature
(c-backward-token-2 &optional COUNT BALANCED LIMIT)
Documentation
Move backward by tokens.
See c-forward-token-2 for details.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/cc-engine.el.gz
(defun c-backward-token-2 (&optional count balanced limit)
"Move backward by tokens.
See `c-forward-token-2' for details."
(or count (setq count 1))
(if (< count 0)
(- (c-forward-token-2 (- count) balanced limit))
(or limit (setq limit (point-min)))
(let ((jump-syntax (if balanced
c-jump-syntax-balanced
c-jump-syntax-unbalanced))
(last (point)))
(if (zerop count)
;; The count is zero so try to skip to the beginning of the
;; current token.
(if (> (point)
(progn (c-beginning-of-current-token) (point)))
(if (< (point) limit)
;; The limit is inside the same token, so return 1.
(setq count 1))
;; We're not in the middle of a token. If there's
;; whitespace after the point then we must move backward,
;; so set count to 1 in that case.
(and (looking-at c-syntactic-ws-start)
;; If we're looking at a '#' that might start a cpp
;; directive then we have to do a more elaborate check.
(or (/= (char-after) ?#)
(not c-opt-cpp-prefix)
(save-excursion
(and (= (point)
(progn (beginning-of-line)
(looking-at "[ \t]*")
(match-end 0)))
(or (bobp)
(progn (backward-char)
(not (eq (char-before) ?\\)))))))
(setq count 1))))
;; Use `condition-case' to avoid having to check for buffer
;; limits in `backward-char', `scan-sexps' and `goto-char' below.
(condition-case nil
(while (and
(> count 0)
(progn
(c-backward-syntactic-ws
limit)
(backward-char)
(if (looking-at jump-syntax)
(goto-char (scan-sexps (1+ (point)) -1))
;; This can be very inefficient if there's a long
;; sequence of operator tokens without any separation.
;; That doesn't happen in practice, anyway.
(c-beginning-of-current-token))
(>= (point) limit)))
(setq last (point)
count (1- count)))
(error (goto-char last)))
(if (< (point) limit)
(goto-char last))
count)))