Function: semantic-ctxt-current-symbol-default

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

Signature

(semantic-ctxt-current-symbol-default &optional POINT)

Documentation

Return the current symbol the cursor is on at POINT in a list.

This will include a list of type/field names when applicable. Depends on semantic-type-relation-separator-character.

Source Code

;; Defined in /usr/src/emacs/lisp/cedet/semantic/ctxt.el.gz
(defun semantic-ctxt-current-symbol-default (&optional point)
  "Return the current symbol the cursor is on at POINT in a list.
This will include a list of type/field names when applicable.
Depends on `semantic-type-relation-separator-character'."
  (save-excursion
    (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)
	   (symlist nil)
	   end)
      (with-syntax-table semantic-lex-syntax-table
	(save-excursion
	  (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)))
		 (setq symlist (list ""))
		 (forward-sexp -1)
		 ;; Skip array expressions.
		 (while (looking-at "\\s(") (forward-sexp -1))
		 (forward-sexp 1))
		)
	  ;; Set our end point.
	  (setq end (point))

	  ;; Now that we have gotten started, let's do the rest.
	  (condition-case nil
	      (while (save-excursion
		       (forward-char -1)
		       (looking-at "\\w\\|\\s_"))
		;; We have a symbol.. Do symbol things
		(forward-sexp -1)
		(setq symlist (cons (buffer-substring-no-properties (point) end)
				    symlist))
		;; Skip the next syntactic expression backwards, then go forwards.
		(let ((cp (point)))
		  (forward-sexp -1)
		  (forward-sexp 1)
		  ;; If we end up at the same place we started, we are at the
		  ;; beginning of a buffer, or narrowed to a command and
		  ;; have to stop.
		  (if (<= cp (point)) (error nil)))
		(if (looking-at fieldsep)
		    (progn
		      (forward-sexp -1)
		      ;; Skip array expressions.
		      (while (and (looking-at "\\s(") (not (bobp)))
			(forward-sexp -1))
		      (forward-sexp 1)
		      (setq end (point)))
		  (error nil))
		)
	    (error nil)))
	symlist))))