Hi Jeba, Hi Paul,
Paul Kinnucan <[EMAIL PROTECTED]> writes:
> Jeba Bhaskaran writes:
> > I am currently using dabbrev-completion to complete
> > variable names in a Java buffer. How difficult would
> > it be to add this functionality to the JDE Complete
> > Menu function? For example, if there is a ".", then
> > the jde-complete-menu as it now would be called and if
> > a "." is not present then dabbrev-completion function
> > would be called. Can this be added to the wish list?
> >
>
> This would be easy to do but I don't believe it is
> the right thing to do. I don't see the point of calling
> dabbrev to complete field and method names defined
> or inherited by the class in the current buffer.
>
> - Paul
I have a function `jde-indent-complete' which provides this
functionality.
Instead of dabbrev-expand I use hippie-expand, because of the support
semantic provides for it. Semantic automatically adds
`senator-try-expand-semantic' to your `hippie-expand-try-functions-list'.
This gives you local member name completion via semantic. If this fails,
hippie-expand calls abbrev-expand and dabbrev-expand afterwards.
For words with a dot in front `jde-complete' will be called.
I have bound this to function to TAB, so completion feels the same
as in the shell and in the rest of emacs. I couldn't live without it :-)
The function has gone though various changes/optimizations as my elisp
knowledge slowly grew from clueless to dilettante, here comes the
current version:
(defun jde-indent-complete ()
"A special indent/complete function. I calls three different
functions depending on context:
- The region is active:
reindent the region.
- The point is in front of the text on this line:
try to reindent the line.
- The point is directly after a dot character (\".\") or in/at
the end of a word starting with a dot:
call `jde-complete'
- Otherwise:
call `hippie-expand'
"
(interactive)
(if (mark-or-region-active)
(indent-region (mark) (point) nil)
(if (save-excursion (skip-chars-backward " \t") (bolp))
(indent-for-tab-command)
(if (not (equal major-mode 'jde-mode))
(hippie-expand 1)
(if (or (char-equal (char-before) ?.)
(save-excursion (backward-word 1)
(char-equal (char-before) ?.)))
(jde-complete)
(hippie-expand 1))))))
; you probably need this also:
(require 'hippie-exp)
(setq hippie-expand-try-functions-list
'(try-expand-all-abbrevs
try-expand-dabbrev
try-expand-dabbrev-all-buffers
try-expand-dabbrev-from-kill))
--
Ole Arndt http://www.sugarshark.com
-------------------------------------------------------