* c++ and c common mode
@ 2006-12-13 2:43 Hadron Quark
2006-12-13 3:47 ` Leo
[not found] ` <mailman.1813.1165981695.2155.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 11+ messages in thread
From: Hadron Quark @ 2006-12-13 2:43 UTC (permalink / raw)
I am duplicating hook additions e.g
(add-hook 'c-mode-common-hook 'my-c-init)
(add-hook 'c++-mode-common-hook 'my-c-init)
Is there not a "common c/c++ hook" or have I messed up?
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: c++ and c common mode
2006-12-13 2:43 c++ and c common mode Hadron Quark
@ 2006-12-13 3:47 ` Leo
[not found] ` <mailman.1813.1165981695.2155.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 11+ messages in thread
From: Leo @ 2006-12-13 3:47 UTC (permalink / raw)
* [2006.12.13 03:43 +0100] Hadron Quark wrote:
^^^^^^^^^^^^
> I am duplicating hook additions e.g
>
> (add-hook 'c-mode-common-hook 'my-c-init)
I think this line is sufficient.
>
> (add-hook 'c++-mode-common-hook 'my-c-init)
>
I don't have this variable in Emacs CVS.
>
> Is there not a "common c/c++ hook" or have I messed up?
,----[ C-h v c-mode-common-hook RET ]
| c-mode-common-hook is a variable defined in `cc-vars.el'.
| *Hook called by all CC Mode modes for common initializations.
`----
--
Leo <sdl.web AT gmail.com> (GPG Key: 9283AA3F)
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: c++ and c common mode
[not found] ` <mailman.1813.1165981695.2155.help-gnu-emacs@gnu.org>
@ 2006-12-13 12:00 ` Hadron Quark
2006-12-13 13:52 ` Hadron Quark
1 sibling, 0 replies; 11+ messages in thread
From: Hadron Quark @ 2006-12-13 12:00 UTC (permalink / raw)
Leo <sdl.web@gmail.com> writes:
> * [2006.12.13 03:43 +0100] Hadron Quark wrote:
> ^^^^^^^^^^^^
>> I am duplicating hook additions e.g
>>
>> (add-hook 'c-mode-common-hook 'my-c-init)
>
> I think this line is sufficient.
A great example of not staying up too late when messing around with
your setup - you are quite correct. I was sure I had checked that. Works
fine. *slaps forehead*.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: c++ and c common mode
[not found] ` <mailman.1813.1165981695.2155.help-gnu-emacs@gnu.org>
2006-12-13 12:00 ` Hadron Quark
@ 2006-12-13 13:52 ` Hadron Quark
2006-12-13 15:32 ` Robert Thorpe
2006-12-13 17:57 ` David Hansen
1 sibling, 2 replies; 11+ messages in thread
From: Hadron Quark @ 2006-12-13 13:52 UTC (permalink / raw)
Leo <sdl.web@gmail.com> writes:
> * [2006.12.13 03:43 +0100] Hadron Quark wrote:
> ^^^^^^^^^^^^
>> I am duplicating hook additions e.g
>>
>> (add-hook 'c-mode-common-hook 'my-c-init)
>
> I think this line is sufficient.
The one line I *did* have to duplicate was the define-key to add to both
keyboard maps:
,----
| (let ((dl '(
| ([f1] . jump-man-page)
| ([backtab] . semantic-ia-complete-symbol)
| ([f5] . find-tag-noconfirm)
| ([f6] . find-tag-repeat)
| ([f7] . pop-tag-mark)
| ([f2] . gdb-restore-windows)
| ([f10] . compile)
| ([f11] . next-error)
| ([f12] . gdba))))
| (dolist (i dl)
| (define-key c-mode-map (car i) (cdr i))
| (define-key c++-mode-map (car i) (cdr i))
| ))
`----
is there a better way? Some common "subset" for "c like" files?
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: c++ and c common mode
2006-12-13 13:52 ` Hadron Quark
@ 2006-12-13 15:32 ` Robert Thorpe
2006-12-13 15:39 ` Hadron Quark
2006-12-13 17:57 ` David Hansen
1 sibling, 1 reply; 11+ messages in thread
From: Robert Thorpe @ 2006-12-13 15:32 UTC (permalink / raw)
Hadron Quark wrote:
> Leo <sdl.web@gmail.com> writes:
>
> > * [2006.12.13 03:43 +0100] Hadron Quark wrote:
> > ^^^^^^^^^^^^
> >> I am duplicating hook additions e.g
> >>
> >> (add-hook 'c-mode-common-hook 'my-c-init)
> >
> > I think this line is sufficient.
>
> The one line I *did* have to duplicate was the define-key to add to both
> keyboard maps:
>
>
> ,----
> | (let ((dl '(
> | ([f1] . jump-man-page)
> | ([backtab] . semantic-ia-complete-symbol)
> | ([f5] . find-tag-noconfirm)
> | ([f6] . find-tag-repeat)
> | ([f7] . pop-tag-mark)
> | ([f2] . gdb-restore-windows)
> | ([f10] . compile)
> | ([f11] . next-error)
> | ([f12] . gdba))))
> | (dolist (i dl)
> | (define-key c-mode-map (car i) (cdr i))
> | (define-key c++-mode-map (car i) (cdr i))
> | ))
> `----
>
> is there a better way? Some common "subset" for "c like" files?
Add-hook just adds a function, so why not put the above in a function?
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: c++ and c common mode
2006-12-13 15:32 ` Robert Thorpe
@ 2006-12-13 15:39 ` Hadron Quark
2006-12-13 15:47 ` Robert Thorpe
0 siblings, 1 reply; 11+ messages in thread
From: Hadron Quark @ 2006-12-13 15:39 UTC (permalink / raw)
"Robert Thorpe" <rthorpe@realworldtech.com> writes:
> Hadron Quark wrote:
>> Leo <sdl.web@gmail.com> writes:
>>
>> > * [2006.12.13 03:43 +0100] Hadron Quark wrote:
>> > ^^^^^^^^^^^^
>> >> I am duplicating hook additions e.g
>> >>
>> >> (add-hook 'c-mode-common-hook 'my-c-init)
>> >
>> > I think this line is sufficient.
>>
>> The one line I *did* have to duplicate was the define-key to add to both
>> keyboard maps:
>>
>>
>> ,----
>> | (let ((dl '(
>> | ([f1] . jump-man-page)
>> | ([backtab] . semantic-ia-complete-symbol)
>> | ([f5] . find-tag-noconfirm)
>> | ([f6] . find-tag-repeat)
>> | ([f7] . pop-tag-mark)
>> | ([f2] . gdb-restore-windows)
>> | ([f10] . compile)
>> | ([f11] . next-error)
>> | ([f12] . gdba))))
>> | (dolist (i dl)
>> | (define-key c-mode-map (car i) (cdr i))
>> | (define-key c++-mode-map (car i) (cdr i))
>> | ))
>> `----
>>
>> is there a better way? Some common "subset" for "c like" files?
>
> Add-hook just adds a function, so why not put the above in a function?
>
It is : it was just an extract to show the duplication of the define-key lines.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: c++ and c common mode
2006-12-13 15:39 ` Hadron Quark
@ 2006-12-13 15:47 ` Robert Thorpe
2006-12-13 16:10 ` Hadron Quark
0 siblings, 1 reply; 11+ messages in thread
From: Robert Thorpe @ 2006-12-13 15:47 UTC (permalink / raw)
Hadron Quark wrote:
> "Robert Thorpe" <rthorpe@realworldtech.com> writes:
> > Hadron Quark wrote:
> >> Leo <sdl.web@gmail.com> writes:
> >>
> >> > * [2006.12.13 03:43 +0100] Hadron Quark wrote:
> >> > ^^^^^^^^^^^^
> >> >> I am duplicating hook additions e.g
> >> >>
> >> >> (add-hook 'c-mode-common-hook 'my-c-init)
> >> >
> >> > I think this line is sufficient.
> >>
> >> The one line I *did* have to duplicate was the define-key to add to both
> >> keyboard maps:
> >>
> >>
> >> ,----
> >> | (let ((dl '(
> >> | ([f1] . jump-man-page)
> >> | ([backtab] . semantic-ia-complete-symbol)
> >> | ([f5] . find-tag-noconfirm)
> >> | ([f6] . find-tag-repeat)
> >> | ([f7] . pop-tag-mark)
> >> | ([f2] . gdb-restore-windows)
> >> | ([f10] . compile)
> >> | ([f11] . next-error)
> >> | ([f12] . gdba))))
> >> | (dolist (i dl)
> >> | (define-key c-mode-map (car i) (cdr i))
> >> | (define-key c++-mode-map (car i) (cdr i))
> >> | ))
> >> `----
> >>
> >> is there a better way? Some common "subset" for "c like" files?
> >
> > Add-hook just adds a function, so why not put the above in a function?
> >
>
> It is : it was just an extract to show the duplication of the define-key lines.
Ah, I'm with yer now. You could do:-
(defun define-key-c-and-c++-map (key x)
(define-key c-mode-map key x)
(define-key c++-mode-map key y))
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: c++ and c common mode
2006-12-13 15:47 ` Robert Thorpe
@ 2006-12-13 16:10 ` Hadron Quark
2006-12-13 16:28 ` Robert Thorpe
0 siblings, 1 reply; 11+ messages in thread
From: Hadron Quark @ 2006-12-13 16:10 UTC (permalink / raw)
"Robert Thorpe" <rthorpe@realworldtech.com> writes:
> Hadron Quark wrote:
>> "Robert Thorpe" <rthorpe@realworldtech.com> writes:
>> > Hadron Quark wrote:
>> >> Leo <sdl.web@gmail.com> writes:
>> >>
>> >> > * [2006.12.13 03:43 +0100] Hadron Quark wrote:
>> >> > ^^^^^^^^^^^^
>> >> >> I am duplicating hook additions e.g
>> >> >>
>> >> >> (add-hook 'c-mode-common-hook 'my-c-init)
>> >> >
>> >> > I think this line is sufficient.
>> >>
>> >> The one line I *did* have to duplicate was the define-key to add to both
>> >> keyboard maps:
>> >>
>> >>
>> >> ,----
>> >> | (let ((dl '(
>> >> | ([f1] . jump-man-page)
>> >> | ([backtab] . semantic-ia-complete-symbol)
>> >> | ([f5] . find-tag-noconfirm)
>> >> | ([f6] . find-tag-repeat)
>> >> | ([f7] . pop-tag-mark)
>> >> | ([f2] . gdb-restore-windows)
>> >> | ([f10] . compile)
>> >> | ([f11] . next-error)
>> >> | ([f12] . gdba))))
>> >> | (dolist (i dl)
>> >> | (define-key c-mode-map (car i) (cdr i))
>> >> | (define-key c++-mode-map (car i) (cdr i))
>> >> | ))
>> >> `----
>> >>
>> >> is there a better way? Some common "subset" for "c like" files?
>> >
>> > Add-hook just adds a function, so why not put the above in a function?
>> >
>>
>> It is : it was just an extract to show the duplication of the define-key lines.
>
> Ah, I'm with yer now. You could do:-
>
> (defun define-key-c-and-c++-map (key x)
> (define-key c-mode-map key x)
> (define-key c++-mode-map key y))
>
Thanks, but I realise that - not much of a saving IMO and more
cluttering up of name space. I guess I was asking if there is a "base
key map" shared by all "c like" file modes so I only have to define-key
once. No big deal I agree, but was just trying to tidy my emacs
libraries which are full of this & that at the moment as I built up my
emacs gdb support knowledge.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: c++ and c common mode
2006-12-13 16:10 ` Hadron Quark
@ 2006-12-13 16:28 ` Robert Thorpe
2006-12-14 18:28 ` Hadron Quark
0 siblings, 1 reply; 11+ messages in thread
From: Robert Thorpe @ 2006-12-13 16:28 UTC (permalink / raw)
Hadron Quark wrote:
> "Robert Thorpe" <rthorpe@realworldtech.com> writes:
> > Hadron Quark wrote:
> >> "Robert Thorpe" <rthorpe@realworldtech.com> writes:
> >> > Hadron Quark wrote:
> >> >> Leo <sdl.web@gmail.com> writes:
> >> >>
> >> >> > * [2006.12.13 03:43 +0100] Hadron Quark wrote:
> >> >> > ^^^^^^^^^^^^
> >> >> >> I am duplicating hook additions e.g
> >> >> >>
> >> >> >> (add-hook 'c-mode-common-hook 'my-c-init)
> >> >> >
> >> >> > I think this line is sufficient.
> >> >>
> >> >> The one line I *did* have to duplicate was the define-key to add to both
> >> >> keyboard maps:
> >> >>
> >> >>
> >> >> ,----
> >> >> | (let ((dl '(
> >> >> | ([f1] . jump-man-page)
> >> >> | ([backtab] . semantic-ia-complete-symbol)
> >> >> | ([f5] . find-tag-noconfirm)
> >> >> | ([f6] . find-tag-repeat)
> >> >> | ([f7] . pop-tag-mark)
> >> >> | ([f2] . gdb-restore-windows)
> >> >> | ([f10] . compile)
> >> >> | ([f11] . next-error)
> >> >> | ([f12] . gdba))))
> >> >> | (dolist (i dl)
> >> >> | (define-key c-mode-map (car i) (cdr i))
> >> >> | (define-key c++-mode-map (car i) (cdr i))
> >> >> | ))
> >> >> `----
> >> >>
> >> >> is there a better way? Some common "subset" for "c like" files?
> >> >
> >> > Add-hook just adds a function, so why not put the above in a function?
> >> >
> >>
> >> It is : it was just an extract to show the duplication of the define-key lines.
> >
> > Ah, I'm with yer now. You could do:-
> >
> > (defun define-key-c-and-c++-map (key x)
> > (define-key c-mode-map key x)
> > (define-key c++-mode-map key y))
> >
>
> Thanks, but I realise that - not much of a saving IMO and more
> cluttering up of name space. I guess I was asking if there is a "base
> key map" shared by all "c like" file modes so I only have to define-key
> once.
Inside CC-mode there is such a beast, it's called c-mode-base-map.
It would be generally useful if it were possible to change it in Emacs
configuration. Try asking the CC-mode maintainer if they would
consider making it a variable users can set.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: c++ and c common mode
2006-12-13 13:52 ` Hadron Quark
2006-12-13 15:32 ` Robert Thorpe
@ 2006-12-13 17:57 ` David Hansen
1 sibling, 0 replies; 11+ messages in thread
From: David Hansen @ 2006-12-13 17:57 UTC (permalink / raw)
On Wed, 13 Dec 2006 14:52:31 +0100 Hadron Quark wrote:
> The one line I *did* have to duplicate was the define-key to add to both
> keyboard maps:
>
>
> ,----
> | (let ((dl '(
> | ([f1] . jump-man-page)
> | ([backtab] . semantic-ia-complete-symbol)
> | ([f5] . find-tag-noconfirm)
> | ([f6] . find-tag-repeat)
> | ([f7] . pop-tag-mark)
> | ([f2] . gdb-restore-windows)
> | ([f10] . compile)
> | ([f11] . next-error)
> | ([f12] . gdba))))
> | (dolist (i dl)
> | (define-key c-mode-map (car i) (cdr i))
> | (define-key c++-mode-map (car i) (cdr i))
> | ))
> `----
>
> is there a better way? Some common "subset" for "c like" files?
Use `c-mode-base-map' or if needed `local-set-key'.
David
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: c++ and c common mode
2006-12-13 16:28 ` Robert Thorpe
@ 2006-12-14 18:28 ` Hadron Quark
0 siblings, 0 replies; 11+ messages in thread
From: Hadron Quark @ 2006-12-14 18:28 UTC (permalink / raw)
"Robert Thorpe" <rthorpe@realworldtech.com> writes:
> Hadron Quark wrote:
>> "Robert Thorpe" <rthorpe@realworldtech.com> writes:
>> > Hadron Quark wrote:
>> >> "Robert Thorpe" <rthorpe@realworldtech.com> writes:
>> >> > Hadron Quark wrote:
>> >> >> Leo <sdl.web@gmail.com> writes:
>> >> >>
>> >> >> > * [2006.12.13 03:43 +0100] Hadron Quark wrote:
>> >> >> > ^^^^^^^^^^^^
>> >> >> >> I am duplicating hook additions e.g
>> >> >> >>
>> >> >> >> (add-hook 'c-mode-common-hook 'my-c-init)
>> >> >> >
>> >> >> > I think this line is sufficient.
>> >> >>
>> >> >> The one line I *did* have to duplicate was the define-key to add to both
>> >> >> keyboard maps:
>> >> >>
>> >> >>
>> >> >> ,----
>> >> >> | (let ((dl '(
>> >> >> | ([f1] . jump-man-page)
>> >> >> | ([backtab] . semantic-ia-complete-symbol)
>> >> >> | ([f5] . find-tag-noconfirm)
>> >> >> | ([f6] . find-tag-repeat)
>> >> >> | ([f7] . pop-tag-mark)
>> >> >> | ([f2] . gdb-restore-windows)
>> >> >> | ([f10] . compile)
>> >> >> | ([f11] . next-error)
>> >> >> | ([f12] . gdba))))
>> >> >> | (dolist (i dl)
>> >> >> | (define-key c-mode-map (car i) (cdr i))
>> >> >> | (define-key c++-mode-map (car i) (cdr i))
>> >> >> | ))
>> >> >> `----
>> >> >>
>> >> >> is there a better way? Some common "subset" for "c like" files?
>> >> >
>> >> > Add-hook just adds a function, so why not put the above in a function?
>> >> >
>> >>
>> >> It is : it was just an extract to show the duplication of the define-key lines.
>> >
>> > Ah, I'm with yer now. You could do:-
>> >
>> > (defun define-key-c-and-c++-map (key x)
>> > (define-key c-mode-map key x)
>> > (define-key c++-mode-map key y))
>> >
>>
>> Thanks, but I realise that - not much of a saving IMO and more
>> cluttering up of name space. I guess I was asking if there is a "base
>> key map" shared by all "c like" file modes so I only have to define-key
>> once.
>
> Inside CC-mode there is such a beast, it's called c-mode-base-map.
> It would be generally useful if it were possible to change it in Emacs
> configuration. Try asking the CC-mode maintainer if they would
> consider making it a variable users can set.
>
It was changeable! Thanks for your help.
--
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2006-12-14 18:28 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-13 2:43 c++ and c common mode Hadron Quark
2006-12-13 3:47 ` Leo
[not found] ` <mailman.1813.1165981695.2155.help-gnu-emacs@gnu.org>
2006-12-13 12:00 ` Hadron Quark
2006-12-13 13:52 ` Hadron Quark
2006-12-13 15:32 ` Robert Thorpe
2006-12-13 15:39 ` Hadron Quark
2006-12-13 15:47 ` Robert Thorpe
2006-12-13 16:10 ` Hadron Quark
2006-12-13 16:28 ` Robert Thorpe
2006-12-14 18:28 ` Hadron Quark
2006-12-13 17:57 ` David Hansen
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).