This is not entirely trivial in Emacs. The simplest method which
almost-but-not-quite achieves what you want is to write a wrapper
function that calls semantic-complete-analyze-inline, tests if it fails,
and if so calls the other fall-back command you want to use. I leave
this simple Lisp function fragment as an exercise (mainly because I
don't have the documentation for semantic-complete-analyze-inline to
hand right now :) Of course, this hard-codes the fall-back command,
which isn't quite what you asked for.
If you really do need to fall back to whatever was originally bound to
TAB, then one approach is to bind the wrapper function to TAB in a
minor-mode keymap, and have the wrapper disable the keymap temporarily
if the call to semantic-complete-analyze-inline fails, lookup the
command now bound to TAB (which will no longer be masked by the disabled
binding), call that command, then re-enable the keymap. Yes, it's as
complicated as it sounds, and fraught with nasty bugs (e.g. it's easy to
end up with infinite recursion if you're not careful).
If you want to try this, my completion-UI package (available from
http://www.dr-qubit.org/emacs/php) uses this technique, and might give you the
hints you need to get it working, especially the
`completion-run-if-condition' command. In fact, that function provides a
general mechanism for doing this, and you could use it directly, once
you've written the wrapper function and set up the necessary minor-mode
keymap and binding.
On the other hand, completion-UI pretty much implements this feature
already, and as Eric mentioned in a recent post we've been bouncing a
basic version of completion-UI/Semantic integration back and forth
recently. I'll probably put this "glue" code on the Emacs wiki
completion-UI page soon, and include it in the next completion-UI
release. So if the above sounds too much, you could wait and see if that
does what you want...
Nathan Huesken wrote:
> I would like the following funcitonality:
> When I press "tab", semantic-complete-analyze-inline should be called. If it finds something - fine - if not, the nomrmal tab-operations should occure.
> In my case, this means that the yasnippet completion should be called (which is also bound to tab).
> Is this possible? I tried:
> (global-set-key [(tab)] 'semantic-complete-analyze-inline)
> Which makes even mini-buffer completion not work anymore.
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> cedet-semantic mailing list