Function: semantic-ctxt-end-of-symbol-default

semantic-ctxt-end-of-symbol-default is a byte-compiled function defined in ctxt.el.gz.

Signature

(semantic-ctxt-end-of-symbol-default &optional POINT)

Documentation

Move point to the end of the current symbol under POINT.

This will move past type/field names when applicable. Depends on semantic-type-relation-separator-character, and will work on C like languages.

Source Code

;; Defined in /usr/src/emacs/lisp/cedet/semantic/ctxt.el.gz
(defun semantic-ctxt-end-of-symbol-default (&optional point)
  "Move point to the end of the current symbol under POINT.
This will move past type/field names when applicable.
Depends on `semantic-type-relation-separator-character', and will
work on C like languages."
  (if point (goto-char point))
  (let* ((fieldsep1 (mapconcat (lambda (a) (regexp-quote a))
			       semantic-type-relation-separator-character
			       "\\|"))
	 ;; NOTE: The [ \n] expression below should used \\s-, but that
	 ;; doesn't work in C since \n means end-of-comment, and isn't
	 ;; really whitespace.
	 ;;(fieldsep (concat "[ \t\n\r]*\\(" fieldsep1 "\\)[ \t\n\r]*\\(\\w\\|\\s_\\)"))
	 (case-fold-search semantic-case-fold)
	 (continuesearch t)
	 (end nil)
	 )
      (with-syntax-table semantic-lex-syntax-table
	(cond ((looking-at "\\w\\|\\s_")
	       ;; In the middle of a symbol, move to the end.
	       (forward-sexp 1))
	      ((looking-at fieldsep1)
	       ;; We are in a fine spot.. do nothing.
	       nil
	       )
	      ((save-excursion
		 (and (condition-case nil
			  (progn (forward-sexp -1)
				 (forward-sexp 1)
				 t)
			(error nil))
		      (looking-at fieldsep1)))
	       (forward-sexp -1)
	       ;; Skip array expressions.
	       (while (looking-at "\\s(") (forward-sexp -1))
	       (forward-sexp 1))
	      )
	;; Set the current end marker.
	(setq end (point))

	;; Cursor is at the safe end of some symbol.  Look until we
	;; find the logical end of this current complex symbol.
	(condition-case nil
	    (while continuesearch
	      ;; If there are functional arguments, arrays, etc, skip them.
	      (when (looking-at "\\s(")
		(forward-sexp 1))

	      ;; If there is a field separator, then skip that, plus
	      ;; the next expected symbol.
	      (if (not (looking-at fieldsep1))
		  ;; We hit the end.
		  (error nil)

		;; Skip the separator and the symbol.
		(goto-char (match-end 0))

		(if (looking-at "\\w\\|\\s_")
		    ;; Skip symbols
		    (forward-sexp 1)
		  ;; No symbol, exit the search...
		  (setq continuesearch nil))

		(setq end (point)))

	      ;; Cont...
	      )

	  ;; Restore position if we go to far....
	  (error (goto-char end)) )

	)))