Function: semantic-imenu-goto-function

semantic-imenu-goto-function is a byte-compiled function defined in imenu.el.gz.

Signature

(semantic-imenu-goto-function NAME POSITION &optional REST)

Documentation

Move point associated with NAME to POSITION.

Used to override function imenu-default-goto-function(var)/imenu-default-goto-function(fun) so that we can continue to use overlays to maintain the current position. Optional argument REST is some extra stuff.

Source Code

;; Defined in /usr/src/emacs/lisp/cedet/semantic/imenu.el.gz
(defun semantic-imenu-goto-function (name position &optional rest)
  "Move point associated with NAME to POSITION.
Used to override function `imenu-default-goto-function' so that
we can continue to use overlays to maintain the current position.
Optional argument REST is some extra stuff."
  (require 'pulse)
  (if (overlayp position)
      (let ((os (overlay-start position))
	    (ob (overlay-buffer position)))
	(if os
	    (progn
	      (if (not (eq ob (current-buffer)))
		  (switch-to-buffer ob))
	      (imenu-default-goto-function name os rest)
	      (pulse-momentary-highlight-one-line (point))
	      )
	  ;; This should never happen, but check anyway.
	  (message "Imenu is out of date, try again. (internal bug)")
	  (setq imenu--index-alist nil)))
    ;; When the POSITION is actually a pair of numbers in an array, then
    ;; the file isn't loaded into the current buffer.
    (if (vectorp position)
	(let ((file (aref position 0))
	      (pos (aref position 1)))
	  (and file (find-file file))
	  (imenu-default-goto-function name pos rest)
	  (pulse-momentary-highlight-one-line (point))
	  )
      ;; When the POSITION is the symbol 'file-only' it means that this
      ;; is a directory index entry and there is no tags in this
      ;; file. So just jump to the beginning of the file.
      (if (eq position 'file-only)
	  (progn
	    (find-file name)
	    (imenu-default-goto-function name (point-min) rest)
	    (pulse-momentary-highlight-one-line (point))
	    )
        ;; Probably POSITION don't came from a semantic imenu.  Try
        ;; the default imenu goto function.
        (condition-case nil
	    (progn
	      (imenu-default-goto-function name position rest)
	      (pulse-momentary-highlight-one-line (point))
	      )
          (error
           (message "Semantic Imenu override problem. (Internal bug)")
           (setq imenu--index-alist nil)))))
    ))