Jason Dufair wrote:
> Baloff <[EMAIL PROTECTED]> 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 "[EMAIL PROTECTED]" 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:

"[EMAIL PROTECTED]" ; 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



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

Reply via email to