help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: expand/collapse{} in c++


From: Kevin Rodgers
Subject: Re: expand/collapse{} in c++
Date: Fri, 26 Aug 2005 16:39:38 -0600
User-agent: Mozilla Thunderbird 0.9 (X11/20041105)

Jason Dufair wrote:
> Baloff <address@hidden> writes:
>>in a .emacs-c++ file to be loaded from inside .emacs, I have
>>(local-set-key [f4] "\C-c @ \C-c") ;toggles block hide/show
>>
>>restart emacs, when I open .cpp file, f4 does nothing.
>
> First, the 2nd argument to 'local-set-key should be a function
> definition, not another set of key bindings.  Use C-h k to see what
> function "address@hidden" calls and use that function name as your second
> argument.

The 2nd argument must be a command, which can be an interactive function
or a keyboard macro, or a symbol with such a function binding -- see the
"What is a Function?" and "Command [Loop] Overview" sections of the
Emacs Lisp manual.  The proper representation of the key sequence `C-c a
C-c' as a keyboard macro is any of:

"address@hidden" ; no spaces!
[?\C-c ?@ ?\C-a]
[(control ?c) ?@ (control ?a)]
(kbd "C-c @ C-a")

(see the "Init Rebinding" node of the Emacs manual and the "Changing Key
Bindings" node of the Emacs Lisp manual)

> Also, local-set-key only works on the current local keymap.  If you only
> want that binding available in c++-mode, you probably have set the
> binding in the mode hook

That's what I recommend, but some people prefer to use define-key and
specify the keymap by name:

(define-key c++-mode-map [f4] (kbd "C-c @ C-a"))

--
Kevin Rodgers





reply via email to

[Prev in Thread] Current Thread [Next in Thread]