Function: c-on-identifier

c-on-identifier is a byte-compiled function defined in cc-engine.el.gz.

Signature

(c-on-identifier)

Documentation

Return non-nil if the point is on or directly after an identifier.

Keywords are recognized and not considered identifiers. If an identifier is detected, the returned value is its starting position. If an identifier ends at the point and another begins at it (can only happen in Pike) then the point for the preceding one is returned.

Note that this function might do hidden buffer changes. See the comment at the start of cc-engine.el for more info.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cc-engine.el.gz
;; Tools for scanning identifiers and other tokens.

(defun c-on-identifier ()
  "Return non-nil if the point is on or directly after an identifier.
Keywords are recognized and not considered identifiers.  If an
identifier is detected, the returned value is its starting position.
If an identifier ends at the point and another begins at it (can only
happen in Pike) then the point for the preceding one is returned.

Note that this function might do hidden buffer changes.  See the
comment at the start of cc-engine.el for more info."

  ;; FIXME: Shouldn't this function handle "operator" in C++?

  (save-excursion
    (skip-syntax-backward "w_")

    (or

     ;; Check for a normal (non-keyword) identifier.
     (and (looking-at c-symbol-start)
	  (not (looking-at c-keywords-regexp))
	  (point))

     (when (c-major-mode-is 'pike-mode)
       ;; Handle the `<operator> syntax in Pike.
       (let ((pos (point)))
	 (skip-chars-backward "-!%&*+/<=>^|~[]()")
	 (and (if (< (skip-chars-backward "`") 0)
		  t
		(goto-char pos)
		(eq (char-after) ?\`))
	      (looking-at c-symbol-key)
	      (>= (match-end 0) pos)
	      (point))))

     ;; Handle the "operator +" syntax in C++.
     (when (and c-overloadable-operators-regexp
		(= (c-backward-token-2 0 nil (c-determine-limit 500)) 0))

       (cond ((and (looking-at c-overloadable-operators-regexp)
		   (or (not c-opt-op-identifier-prefix)
		       (and (= (c-backward-token-2 1) 0)
			    (looking-at c-opt-op-identifier-prefix))))
	      (point))

	     ((save-excursion
		(and c-opt-op-identifier-prefix
		     (looking-at c-opt-op-identifier-prefix)
		     (= (c-forward-token-2 1) 0)
		     (looking-at c-overloadable-operators-regexp)))
	      (point))))

     )))