* Automatic matching parenthesis
@ 2009-03-15 23:31 christopher.morris.cm
2009-03-16 10:24 ` Andy Stewart
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: christopher.morris.cm @ 2009-03-15 23:31 UTC (permalink / raw)
To: help-gnu-emacs
Hi,
added these lines to my .emacs-file, so that parenthesis are
automatically matched:
(setq skeleton-pair t)
(global-set-key (kbd "(") 'skeleton-pair-insert-maybe)
(global-set-key (kbd "{") 'skeleton-pair-insert-maybe)
But it does not work in cc-mode. Any idea?
Regards,
Chris
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Automatic matching parenthesis
2009-03-15 23:31 Automatic matching parenthesis christopher.morris.cm
@ 2009-03-16 10:24 ` Andy Stewart
[not found] ` <mailman.3311.1237199154.31690.help-gnu-emacs@gnu.org>
2009-03-16 11:36 ` Alan Mackenzie
2 siblings, 0 replies; 6+ messages in thread
From: Andy Stewart @ 2009-03-16 10:24 UTC (permalink / raw)
To: help-gnu-emacs
"christopher.morris.cm@googlemail.com"
<christopher.morris.cm@googlemail.com> writes:
> Hi,
>
> added these lines to my .emacs-file, so that parenthesis are
> automatically matched:
> (setq skeleton-pair t)
> (global-set-key (kbd "(") 'skeleton-pair-insert-maybe)
> (global-set-key (kbd "{") 'skeleton-pair-insert-maybe)
>
> But it does not work in cc-mode. Any idea?
Why not use paredit.el?
At http://www.emacswiki.org/emacs/ParEdit
It can complete your parenthesis, it won't complete paranthesis when you
type in comment.
I think paredit.el is very nice for parenthesis completion.
Regards,
-- Andy
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Automatic matching parenthesis
[not found] ` <mailman.3311.1237199154.31690.help-gnu-emacs@gnu.org>
@ 2009-03-16 11:02 ` christopher.morris.cm
2009-03-16 11:24 ` Alan Mackenzie
2009-03-18 4:05 ` Kevin Rodgers
0 siblings, 2 replies; 6+ messages in thread
From: christopher.morris.cm @ 2009-03-16 11:02 UTC (permalink / raw)
To: help-gnu-emacs
On 16 Mrz., 11:24, Andy Stewart <lazycat.mana...@gmail.com> wrote:
> "christopher.morris...@googlemail.com"
>
> <christopher.morris...@googlemail.com> writes:
> > Hi,
>
> > added these lines to my .emacs-file, so that parenthesis are
> > automatically matched:
> > (setq skeleton-pair t)
> > (global-set-key (kbd "(") 'skeleton-pair-insert-maybe)
> > (global-set-key (kbd "{") 'skeleton-pair-insert-maybe)
>
> > But it does not work in cc-mode. Any idea?
>
> Why not use paredit.el?
> Athttp://www.emacswiki.org/emacs/ParEdit
>
> It can complete your parenthesis, it won't complete paranthesis when you
> type in comment.
>
> I think paredit.el is very nice for parenthesis completion.
>
> Regards,
>
> -- Andy
Thanks alot. But I cant figure out, how to enable paredit alway in c-
mode. I tried:
(add-hook c-mode-hook (lambda () (paredit-mode +1))). I get an error
message starting up emacs. Any idea?
Regards,
Chris
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Automatic matching parenthesis
2009-03-16 11:02 ` christopher.morris.cm
@ 2009-03-16 11:24 ` Alan Mackenzie
2009-03-18 4:05 ` Kevin Rodgers
1 sibling, 0 replies; 6+ messages in thread
From: Alan Mackenzie @ 2009-03-16 11:24 UTC (permalink / raw)
To: help-gnu-emacs
christopher.morris.cm@googlemail.com <christopher.morris.cm@googlemail.com> wrote:
> On 16 Mrz., 11:24, Andy Stewart <lazycat.mana...@gmail.com> wrote:
>> "christopher.morris...@googlemail.com"
>> <christopher.morris...@googlemail.com> writes:
>> > Hi,
> Thanks alot. But I cant figure out, how to enable paredit alway in c-
> mode. I tried:
> (add-hook c-mode-hook (lambda () (paredit-mode +1))). I get an error
> message starting up emacs. Any idea?
Yes. You've forgotten the tick. Try this:
(add-hook 'c-mode-hook (lambda () (paredit-mode +1)))
^
HOWEVER: just as a tip for the future, you're more likely to get useful
help if you post the actual error message rather than just saying "I get
an error message ....".
> Regards,
> Chris
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Automatic matching parenthesis
2009-03-15 23:31 Automatic matching parenthesis christopher.morris.cm
2009-03-16 10:24 ` Andy Stewart
[not found] ` <mailman.3311.1237199154.31690.help-gnu-emacs@gnu.org>
@ 2009-03-16 11:36 ` Alan Mackenzie
2 siblings, 0 replies; 6+ messages in thread
From: Alan Mackenzie @ 2009-03-16 11:36 UTC (permalink / raw)
To: help-gnu-emacs
christopher.morris.cm@googlemail.com <christopher.morris.cm@googlemail.com> wrote:
> Hi,
> added these lines to my .emacs-file, so that parenthesis are
> automatically matched:
> (setq skeleton-pair t)
> (global-set-key (kbd "(") 'skeleton-pair-insert-maybe)
> (global-set-key (kbd "{") 'skeleton-pair-insert-maybe)
> But it does not work in cc-mode. Any idea?
Yes. You've bound these keys in the global keymap. However, CC Mode has
bound these keys in its local keymaps, and these take precedence over the
global keymap. This is explained (a bit) on page "Keymaps" in the Emacs
manual, and explained much more thoroughly on the page "Keymaps" in the
Elisp manual.
Be aware that the CC Mode bindings for '(' and '{' have "electric"
action: they optionally trigger things like (re)indentation of the
current line, when appropriate. This is explained in the CC Mode manual
on the page "Electric Keys". If you rebind these keys, you will lose
this electric action.
> Regards,
> Chris
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Automatic matching parenthesis
2009-03-16 11:02 ` christopher.morris.cm
2009-03-16 11:24 ` Alan Mackenzie
@ 2009-03-18 4:05 ` Kevin Rodgers
1 sibling, 0 replies; 6+ messages in thread
From: Kevin Rodgers @ 2009-03-18 4:05 UTC (permalink / raw)
To: help-gnu-emacs
christopher.morris.cm@googlemail.com wrote:
> On 16 Mrz., 11:24, Andy Stewart <lazycat.mana...@gmail.com> wrote:
>> "christopher.morris...@googlemail.com"
>>
>> <christopher.morris...@googlemail.com> writes:
>>> Hi,
>>> added these lines to my .emacs-file, so that parenthesis are
>>> automatically matched:
>>> (setq skeleton-pair t)
>>> (global-set-key (kbd "(") 'skeleton-pair-insert-maybe)
>>> (global-set-key (kbd "{") 'skeleton-pair-insert-maybe)
>>> But it does not work in cc-mode. Any idea?
>> Why not use paredit.el?
>> Athttp://www.emacswiki.org/emacs/ParEdit
>>
>> It can complete your parenthesis, it won't complete paranthesis when you
>> type in comment.
>>
>> I think paredit.el is very nice for parenthesis completion.
>>
>> Regards,
>>
>> -- Andy
>
> Thanks alot. But I cant figure out, how to enable paredit alway in c-
> mode. I tried:
> (add-hook c-mode-hook (lambda () (paredit-mode +1))). I get an error
> message starting up emacs. Any idea?
emacs --debug-init will show you the error, and then you can show us so
we don't have to guess.
But one thing is apparent: add-hook is a function, so all its arguments
are evaluated, so you need to quote the c-mode-hook symbol:
(add-hook 'c-mode-hook (lambda () (paredit-mode +1)))
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-03-18 4:05 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-15 23:31 Automatic matching parenthesis christopher.morris.cm
2009-03-16 10:24 ` Andy Stewart
[not found] ` <mailman.3311.1237199154.31690.help-gnu-emacs@gnu.org>
2009-03-16 11:02 ` christopher.morris.cm
2009-03-16 11:24 ` Alan Mackenzie
2009-03-18 4:05 ` Kevin Rodgers
2009-03-16 11:36 ` Alan Mackenzie
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.