Hi Eric, David,
i just found semantic-go-to-tag which does some things ECB currently
implements for itself. But in general i think ECB should throw away its =
implementation of this job and use instead this function because its
overloadable - which is most important advantage. Currently ECB =
quite the same stuff as the default-code of semantic-go-to-tag but of =
ECB could not profite from overloaded versions...
But to become useable by ECB `semantic-go-to-tag' has to be changed =
especially concerning finding files. ECB needs the full controll which
function is used for finding files wheres semantic-go-to-tag currently =
hard-coded `find-file' - but ECB sometimes wants files to being openend =
other window etc...
So i have patched `semantic-go-to-tag' and also =
as follows (these functions are currently the only ones using =
First i have introduced a new option:
;; TODO: Klaus Berndl <klaus.berndl@...>: Where to put this option??
;; currently used by semantic-imenu-goto-function and semantic-go-to-tag
(defcustom semantic-find-file-function 'find-file
"*Function used by semantic to find and display a file."
This option is currently placed in semantic.el - maybe there is a better =
Then i have ajusted `semantic-go-to-tag' and also
`semantic-imenu-goto-function' (i have only replaced the calls to =
by a more flexible solution):
(define-overload semantic-go-to-tag (&optional tag parent)
"Go to the location of TAG.
TAG may be a stripped element, in which case PARENT specifies a
parent tag that has position information.
Different behaviors are provided depending on the type of tag.
For example, dependencies (includes) will seek out the file that is
depended on (see `semantic-dependency-tag-file'."
(or tag (setq tag (car (semantic-find-tag-by-overlay nil))))
(unless (and (eq (semantic-tag-class tag) 'include)
(let ((f (semantic-dependency-tag-file tag))
(find-file-function (or (and (fboundp =
(if f (funcall find-file-function f))))
(if (semantic-tag-buffer tag)
;; If the tag has no buffer, it may be deoverlayed.
;; Assume the tool doing the finding knows that we came
;; in from a database, and use the current buffer.
(set-buffer (semantic-tag-buffer tag)))
(if (semantic-tag-with-position-p tag)
;; If it's a number, go there
(goto-char (semantic-tag-start tag))
;; Otherwise, it's a trimmed vector, such as a parameter,
;; or a structure part.
(if (not parent)
(if (semantic-tag-with-position-p parent)
(if (semantic-tag-buffer parent)
;; If this parent tag has no buffer, then it
;; may be deoverlayed.
(set-buffer (semantic-tag-buffer parent)))
(goto-char (semantic-tag-start parent))
;; Here we make an assumption that the text returned by
;; the parser and concocted by us actually exists
;; in the buffer.
(re-search-forward (semantic-tag-name tag) nil t))))))))
(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 =
to use overlays to maintain the current position.
Optional argument REST is some extra stuff."
(if (semantic-overlay-p position)
(let ((os (semantic-overlay-start position))
(ob (semantic-overlay-buffer position)))
(if (not (eq ob (current-buffer)))
(imenu-default-goto-function name os rest))
;; 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.
(let ((find-file-function (or (and (fboundp =
(if (vectorp position)
(let ((file (aref position 0))
(pos (aref position 1)))
(and file (funcall find-file-function file))
(imenu-default-goto-function name pos rest))
;; When the POSITION is the symbol 'file-only' it means that =
;; 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)
(funcall find-file-function name)
(imenu-default-goto-function name (point-min) rest))
;; Probably POSITION don't came from a semantic imenu. Try
;; the default imenu goto function.
(imenu-default-goto-function name position rest)
(message "Semantic Imenu override problem. (Internal bug)")
(setq imenu--index-alist nil)))))
Maybe there are additional function where this new option could be used =
With this new option and the changed functions tools like ECB could have
full-controll in which window (or even frame) semantic would "find" =
What do you think?