unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Adding Key bindings
@ 2006-07-20 12:51 Paulo J. Matos
  2006-07-21  0:40 ` Paulo J. Matos
  0 siblings, 1 reply; 6+ messages in thread
From: Paulo J. Matos @ 2006-07-20 12:51 UTC (permalink / raw)


Hi all,

In C++ user mode, TAB key indents the current line, but I would also
like it to auto-complete if possible the current symbol. I would like
it to call: semantic-ia-complete-symbol

Can you possibly tell me how to do this? and if you know, where is the
reference to this topic in GNU Emacs Manual. All places I've searched
on this go on talking about keymaps, keybindings, xmodmap, xev, etc
but are no direct to the point.

Thanks in advance,
-- 
Paulo Jorge Matos - pocm at sat inesc-id pt
Web: http://sat.inesc-id.pt/~pocm
Computer and Software Engineering
INESC-ID - SAT Group

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Adding Key bindings
  2006-07-20 12:51 Adding Key bindings Paulo J. Matos
@ 2006-07-21  0:40 ` Paulo J. Matos
  2006-07-21 15:56   ` Kevin Rodgers
  0 siblings, 1 reply; 6+ messages in thread
From: Paulo J. Matos @ 2006-07-21  0:40 UTC (permalink / raw)


On 20/07/06, Paulo J. Matos <pocmatos@gmail.com> wrote:
> Hi all,
>
> In C++ user mode, TAB key indents the current line, but I would also
> like it to auto-complete if possible the current symbol. I would like
> it to call: semantic-ia-complete-symbol
>

Hi all,

I did:
(add-hook 'c++-mode-hook
	  '(lambda ()
	     (define-key c++-mode-map "\011" 'semantic-ia-complete-symbol)))

However, this rebinds TAB to semantic-ia-complete-symbol and it will
not indent anymore. I don't want previous actions to disappear, I want
to add semantic-ia-complete-symbol action to the TAB key. How can I
mend this?

Cheers,

-- 
Paulo Jorge Matos - pocm at sat inesc-id pt
Web: http://sat.inesc-id.pt/~pocm
Computer and Software Engineering
INESC-ID - SAT Group

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Adding Key bindings
  2006-07-21  0:40 ` Paulo J. Matos
@ 2006-07-21 15:56   ` Kevin Rodgers
  2006-07-22  1:36     ` Paulo J. Matos
  2006-07-26 22:35     ` Paulo J. Matos
  0 siblings, 2 replies; 6+ messages in thread
From: Kevin Rodgers @ 2006-07-21 15:56 UTC (permalink / raw)


Paulo J. Matos wrote:
> I did:
> (add-hook 'c++-mode-hook
>       '(lambda ()
>          (define-key c++-mode-map "\011" 'semantic-ia-complete-symbol)))
> 
> However, this rebinds TAB to semantic-ia-complete-symbol and it will
> not indent anymore. I don't want previous actions to disappear, I want
> to add semantic-ia-complete-symbol action to the TAB key. How can I
> mend this?

How about:

(defun c++-complete-or-indent ()
   (interactive)
   "Try to complete the current symbol at point, otherwise indent."
   ;; Kludge this because semantic-ia-complete-symbol really doesn't
   ;; return anything useful:
   (when (equal (semantic-ia-complete-symbol (point))
	       "No smart completions found.")
     (c-indent-command current-prefix-arg)))

(add-hook 'c++-mode-hook
	  (lambda ()
	    (local-set-key "\t" c++-complete-or-indent)))

-- 
Kevin

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Adding Key bindings
  2006-07-21 15:56   ` Kevin Rodgers
@ 2006-07-22  1:36     ` Paulo J. Matos
  2006-07-26 22:35     ` Paulo J. Matos
  1 sibling, 0 replies; 6+ messages in thread
From: Paulo J. Matos @ 2006-07-22  1:36 UTC (permalink / raw)


On 21/07/06, Kevin Rodgers <ihs_4664@yahoo.com> wrote:
> Paulo J. Matos wrote:
> > I did:
> > (add-hook 'c++-mode-hook
> >       '(lambda ()
> >          (define-key c++-mode-map "\011" 'semantic-ia-complete-symbol)))
> >
> > However, this rebinds TAB to semantic-ia-complete-symbol and it will
> > not indent anymore. I don't want previous actions to disappear, I want
> > to add semantic-ia-complete-symbol action to the TAB key. How can I
> > mend this?
>
> How about:
>
> (defun c++-complete-or-indent ()
>    (interactive)
>    "Try to complete the current symbol at point, otherwise indent."
>    ;; Kludge this because semantic-ia-complete-symbol really doesn't
>    ;; return anything useful:
>    (when (equal (semantic-ia-complete-symbol (point))
>                "No smart completions found.")
>      (c-indent-command current-prefix-arg)))
>
> (add-hook 'c++-mode-hook
>           (lambda ()
>             (local-set-key "\t" c++-complete-or-indent)))
>

Loved it! Thanks, need to learn more about Emacs Lisp! :-)

> --
> Kevin
>
>
>
> _______________________________________________
> help-gnu-emacs mailing list
> help-gnu-emacs@gnu.org
> http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
>


-- 
Paulo Jorge Matos - pocm at sat inesc-id pt
Web: http://sat.inesc-id.pt/~pocm
Computer and Software Engineering
INESC-ID - SAT Group

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Adding Key bindings
  2006-07-21 15:56   ` Kevin Rodgers
  2006-07-22  1:36     ` Paulo J. Matos
@ 2006-07-26 22:35     ` Paulo J. Matos
  2006-07-27 16:03       ` Kevin Rodgers
  1 sibling, 1 reply; 6+ messages in thread
From: Paulo J. Matos @ 2006-07-26 22:35 UTC (permalink / raw)
  Cc: help-gnu-emacs

On 21/07/06, Kevin Rodgers <ihs_4664@yahoo.com> wrote:
> Paulo J. Matos wrote:
> > I did:
> > (add-hook 'c++-mode-hook
> >       '(lambda ()
> >          (define-key c++-mode-map "\011" 'semantic-ia-complete-symbol)))
> >
> > However, this rebinds TAB to semantic-ia-complete-symbol and it will
> > not indent anymore. I don't want previous actions to disappear, I want
> > to add semantic-ia-complete-symbol action to the TAB key. How can I
> > mend this?
>
> How about:
>
> (defun c++-complete-or-indent ()
>    (interactive)
>    "Try to complete the current symbol at point, otherwise indent."
>    ;; Kludge this because semantic-ia-complete-symbol really doesn't
>    ;; return anything useful:
>    (when (equal (semantic-ia-complete-symbol (point))
>                "No smart completions found.")
>      (c-indent-command current-prefix-arg)))
>
> (add-hook 'c++-mode-hook
>           (lambda ()
>             (local-set-key "\t" c++-complete-or-indent)))
>

Hi all,

There's a problem with this code which I'm not being able to solve.
When you are on an empty line, there's no autocompletion but the
cursor is not indented to the correct position either. Any way to
solve this?

Thanks,

Paulo Matos

> --
> Kevin
>
>
>
> _______________________________________________
> help-gnu-emacs mailing list
> help-gnu-emacs@gnu.org
> http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
>


-- 
Paulo Jorge Matos - pocm at sat inesc-id pt
Web: http://sat.inesc-id.pt/~pocm
Computer and Software Engineering
INESC-ID - SAT Group

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Adding Key bindings
  2006-07-26 22:35     ` Paulo J. Matos
@ 2006-07-27 16:03       ` Kevin Rodgers
  0 siblings, 0 replies; 6+ messages in thread
From: Kevin Rodgers @ 2006-07-27 16:03 UTC (permalink / raw)


Paulo J. Matos wrote:
> On 21/07/06, Kevin Rodgers <ihs_4664@yahoo.com> wrote:
>> (defun c++-complete-or-indent ()
>>    (interactive)
>>    "Try to complete the current symbol at point, otherwise indent."
>>    ;; Kludge this because semantic-ia-complete-symbol really doesn't
>>    ;; return anything useful:
>>    (when (equal (semantic-ia-complete-symbol (point))
>>                "No smart completions found.")
>>      (c-indent-command current-prefix-arg)))
>>
>> (add-hook 'c++-mode-hook
>>           (lambda ()
>>             (local-set-key "\t" c++-complete-or-indent)))
>>
> 
> Hi all,
> 
> There's a problem with this code which I'm not being able to solve.
> When you are on an empty line, there's no autocompletion but the
> cursor is not indented to the correct position either. Any way to
> solve this?

Assuming that "on an empty line" means "at the beginning of a line
with no characters (not even whitespace)":

(when (or (looking-at "^$")
	  (equal (semantic-ia-complete-symbol (point))
		 "No smart completions found."))
   (c-indent-command current-prefix-arg))

-- 
Kevin

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-07-27 16:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-20 12:51 Adding Key bindings Paulo J. Matos
2006-07-21  0:40 ` Paulo J. Matos
2006-07-21 15:56   ` Kevin Rodgers
2006-07-22  1:36     ` Paulo J. Matos
2006-07-26 22:35     ` Paulo J. Matos
2006-07-27 16:03       ` Kevin Rodgers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).