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

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

Re: C-mode electric braces


From: Carsten Burstedde
Subject: Re: C-mode electric braces
Date: Wed, 11 Sep 2002 17:07:11 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020607

> So, what you can do is something like follows:

,----
| (local-set-key (kbd "C-7") #'(lambda ()
|                               (interactive)
|                               ;; inserting the first electric { with
|                               ;; behavior as customized with cc-mode
|                               ;; options
|                               (execute-kbd-macro "{")
|                               (save-excursion
| ;; inserting a temporary ; so the following
|                                 ;; closing brace is working correctly
|                                 (execute-kbd-macro ";")
|                                 ;; inserting the closing electric } with
|                                 ;; behavior as customized with cc-mode
|                                 ;; options
|                                 (execute-kbd-macro "}"))
|                               ;; now we remove the temp. inserted ;
|                               (delete-char 1)))
`----

Thanks, this does precisely what I wanted!

Just curious: How do I make execute-kbd-macro simulate a return press? I made several tries, but it did not work. And what does the # in front of the '(lambda ?

Carsten





reply via email to

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