* Re: Hungry delete for C, C++ and Java?
[not found] ` <68n36c.q5.ln@acm.acm>
@ 2004-04-20 22:27 ` William Payne
2004-04-22 11:54 ` Alan Mackenzie
2004-04-24 21:03 ` Kai Grossjohann
1 sibling, 1 reply; 7+ messages in thread
From: William Payne @ 2004-04-20 22:27 UTC (permalink / raw)
"Alan Mackenzie" <none@example.invalid> wrote in message
news:68n36c.q5.ln@acm.acm...
> William Payne <mikas_n_o_s_p_a_m_493@student.liu.se> wrote on Tue, 20 Apr
> 2004 17:35:30 +0200:
> > Hello, I am using a CVS version of Emacs (checked out three weeks ago),
>
> Just to be pedantic, if you checked it out from savannah.gnu.org, it will
> be (from the point of view of the CC Mode team) a released version with
> version number 5.30 or 5.30.n. If you got it by anonymous CVS from
> cc-mode.sourceforge.net, then it will indeed be a "CVS version", and will
> be the emerging version 5.31.
>
> > and I was wondering how I turn on hungry delete per default for C, C++
> > and Java?
>
> In an appropriate hook function (probably on c-mode-common-hook) include:
>
> (c-toggle-hungry-state 1)
>
> [, and as a matter of interest, C-c C-d will execute
> `c-toggle-hungry-state' interactively]. <backspace> and C-d (but not
> <del>) then do hungry deletion. It looks as thought the fine manual
> could do with some clarification on this point.
>
> > / WP
>
> --
> Alan Mackenzie (Munich, Germany)
> Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
> (like "aa"), remove half of them (leaving, say, "a").
>
Thanks for the reply, Alan. My .emacs file is as follows, where should I put
(c-toggle-hungry-state 1)? Under (defun my-c++-mode () (interactive) and
(defun my-java-mode () (interactive) ?
My .emacs file was created years and years ago by someone else, I wish I
understood it better...I am guessing it could be cleaned-up/improved alot.
Fyi, I am using CC-Mode 5.30.8.
/ WP
(add-to-list 'load-path "c:/emacs-21.3/cc-mode-5.30.8")
(standard-display-european t)
(global-font-lock-mode t)
(setq font-lock-maximum-decoration t)
(setq scroll-bar-mode-explicit t)
(set-scroll-bar-mode 'right)
(setq line-number-mode t) ; Show line number in status bar.
(setq column-number-mode t) ; Show column in status bar.
(setq tab-width 3)
(setq case-fold-search t) ; A and a differs in search.
(setq default-case-fold-search nil) ; A and a does not differ in search.
(setq default-major-mode 'text-mode) ; Mode for unknown file type.
(setq blink-matching-paren-distance nil) ; Always show corresponding
parenthesis.
(setq next-line-add-newlines nil) ; Don't add new lines after EOF
(setq inhibit-startup-message t) ; No start-up message
(setq ask-about-buffer-names t) ; Be helpful
(setq completion-auto-help t) ; ...with buffer names.
(setq display-time-day-and-date t)
(setq display-time-24hr-format t)
(display-time) ; Show time formatted as specified above.
(setq-default indent-tabs-mode nil) ; Use spaces, not tabs, for indentation.
;; Pre-selected colors.
(set-background-color "Black")
(set-foreground-color "White")
(set-cursor-color "Cyan")
;; Set mode depending on file type.
(setq auto-mode-alist
(append
(list
'("\\.c$" . my-c++-mode)
'("\\.q$" . my-c++-mode) ; equel
'("\\.h$" . my-c++-mode)
'("\\.cs$" . my-c++-mode) ; C-mode for C* programs
'("\\.hs$" . my-c++-mode) ; C-mode for C* headers
'("\\.hpp$" . my-c++-mode)
'("\\.cpp$" . my-c++-mode)
'("\\.lpc$" . my-c++-mode)
'("\\.pike$" . my-c++-mode)
'("\\.a$" . ada-mode)
'("\\.cc$" . my-c++-mode)
'("\\.y$" . my-c++-mode)
'("\\.el$" . emacs-lisp-mode)
'("\\.java$" . my-java-mode)
; So any file beginning with Makefile is opened in
Makefile-mode
'("\\Makefile" . makefile-mode) ; Maybe use \\Makefile$ ?
)
auto-mode-alist
)
)
;; C++-mode. Full (?) control on indentation.
(defun my-c++-mode () (interactive)
(c++-mode)
(setq c-basic-offset 3) ; Indent three columns.
(c-toggle-hungry-state 1)
(setq c-offsets-alist
'(
(string . +)
(c . c-lineup-C-comments)
(defun-open . 0)
(defun-close . 0)
(defun-block-intro . +)
(class-open . 0)
(class-close . 0)
(inline-open . 0)
(inline-close . 0)
(ansi-funcdecl-cont . +)
(catch-clause . 0)
(knr-argdecl-intro . +)
(knr-argdecl . 0)
(topmost-intro . 0)
(topmost-intro-cont . 0)
(member-init-intro . +)
(member-init-cont . 0)
(inher-intro . +)
(inher-cont . c-lineup-multi-inher)
(block-open . 0)
(block-close . 0)
(brace-list-open . 0)
(brace-list-close . 0)
(brace-list-intro . +)
(brace-list-entry . 0)
(statement . 0)
(statement-cont . +) ; Strings over multiple lines looks good.
(statement-block-intro . +)
(statement-case-intro . +)
(statement-case-open . 0)
(namespace-open . 0)
(namespace-close . 0)
(innamespace . +)
(substatement . +)
(substatement-open . 0)
(case-label . +)
(access-label . -)
(label . 2)
(do-while-closure . 0)
(else-clause . 0)
(comment-intro . c-lineup-comment)
(arglist-intro . +)
(arglist-cont . 0)
(arglist-cont-nonempty . c-lineup-arglist)
(arglist-close . +)
(stream-op . c-lineup-streamop)
(inclass . +)
(cpp-macro . -1000)
(friend . 0)
(objc-method-intro . -1000)
(objc-method-args-cont . c-lineup-ObjC-method-args)
(objc-method-call-cont . c-lineup-ObjC-method-call)
)))
(defun my-java-mode () (interactive)
(java-mode)
(require 'jdok)
(c-toggle-hungry-state 1)
(setq c-basic-offset 3) ; Indent three columns.
(setq c-offsets-alist
'(
(string . +)
(c . c-lineup-C-comments)
(defun-open . 0)
(defun-close . 0)
(defun-block-intro . +)
(class-open . 0)
(class-close . 0)
(inline-open . 0)
(inline-close . 0)
(func-decl-cont . +) ; 'throws' declarations.
(catch-clause . 0)
(ansi-funcdecl-cont . +)
(knr-argdecl-intro . +)
(knr-argdecl . 0)
(topmost-intro . 0)
(topmost-intro-cont . 0)
(member-init-intro . +)
(member-init-cont . 0)
(inher-intro . +)
(inher-cont . c-lineup-multi-inher)
(block-open . 0)
(block-close . 0)
(brace-list-open . 0)
(brace-list-close . 0)
(brace-list-intro . +)
(brace-list-entry . 0)
(brace-entry-open . 0)
(statement . 0)
(statement-cont . +) ; Strings over multiple lines looks good.
(statement-block-intro . +)
(statement-case-intro . +)
(statement-case-open . 0)
(substatement . 0)
(substatement-open . 0)
(case-label . +)
(access-label . -)
(label . 2)
(do-while-closure . 0)
(else-clause . 0)
(namespace-open . 0)
(namespace-close . 0)
(innamespace . 0)
(comment-intro . c-lineup-comment)
(arglist-intro . +)
(arglist-cont . 0)
(arglist-cont-nonempty . c-lineup-arglist)
(arglist-close . +)
(stream-op . c-lineup-streamop)
(inclass . +)
(template-args-cont . 0)
(cpp-macro . -1000)
(cpp-macro-cont . 0)
(friend . 0)
(extern-lang-open . 0)
(extern-lang-close . 0)
(inextern-lang . 0)
(inlambda . 0)
(lambda-intro-cont . 0)
(inexpr-statement . 0)
(inexpr-class . 0)
(objc-method-intro . -1000)
(objc-method-args-cont . c-lineup-ObjC-method-args)
(objc-method-call-cont . c-lineup-ObjC-method-call)
)))
;; Change order of CR/LF. Will indent every new line.
(setq foo (global-key-binding "\C-m")) ; Save CR binding.
(global-set-key "\C-m" (global-key-binding "\C-j")) ; Set CR to LF.
(global-set-key "\C-j" foo) ; Set LF to old CR.
(custom-set-variables)
(custom-set-faces
'(font-lock-comment-face ((t (:italic t :foreground "Green"))))
'(font-lock-reference-face ((((class color) (background light))
(:foreground "LightGreen"))))
'(font-lock-string-face ((t (:italic t :foreground "Gray"))))
'(font-lock-keyword-face ((t (:bold t :foreground "Cyan"))))
'(font-lock-constant-face ((t (:foreground "Yellow"))))
'(font-lock-type-face ((t (:bold t :foreground "White"))))
'(font-lock-variable-name-face ((t (:foreground "Yellow"))))
'(font-lock-function-name-face ((t (:foreground "Cyan"))))
'(font-lock-builtin-face ((t (:bold t :foreground "LightGreen")))))
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Hungry delete for C, C++ and Java?
2004-04-20 22:27 ` Hungry delete for C, C++ and Java? William Payne
@ 2004-04-22 11:54 ` Alan Mackenzie
2004-04-22 16:18 ` William Payne
0 siblings, 1 reply; 7+ messages in thread
From: Alan Mackenzie @ 2004-04-22 11:54 UTC (permalink / raw)
William Payne <mikas_n_o_s_p_a_m_493@student.liu.se> wrote on Wed, 21 Apr
2004 00:27:06 +0200:
>> > .... and I was wondering how I turn on hungry delete per default for
>> > C, C++ and Java?
>> In an appropriate hook function (probably on c-mode-common-hook) include:
>> (c-toggle-hungry-state 1)
>> [, and as a matter of interest, C-c C-d will execute
>> `c-toggle-hungry-state' interactively]. <backspace> and C-d (but not
>> <del>) then do hungry deletion. It looks as thought the fine manual
>> could do with some clarification on this point.
> Thanks for the reply, Alan. My .emacs file is as follows, where should
> I put (c-toggle-hungry-state 1)? Under (defun my-c++-mode ()
> (interactive) and (defun my-java-mode () (interactive) ?
> My .emacs file was created years and years ago by someone else, I wish I
> understood it better...I am guessing it could be cleaned-up/improved alot.
> Fyi, I am using CC-Mode 5.30.8.
A stable released version without bugs. (hah! :-)
OK, a few comments on your .emacs file:
> '("\\.pike$" . my-c++-mode) ; element of auto-mode-alist
There is actually a Pike Mode within CC Mode. If that's the same
language that your files.pike are, it would be better than c++-mode.
Also, you're using C++ Mode for C files. Also not _so_ bad, but not
quite optimal.
> (defun my-java-mode () (interactive)
> (java-mode)
> (require 'jdok)
> (c-toggle-hungry-state 1) ; <====================================
> (setq c-basic-offset 3) ; Indent three columns.
> (setq c-offsets-alist
It looks like you've already got c-toggle-hungry-state turned on, here.
Does it work? Have you inserted this line here in the last day or two,
perhaps? It ought to work.
If it now works and you're happy about it, that's great, and just ignore
what follows.
#########################################################################
However, if you're interested in getting to know Emacs and CC Mode a bit
better, the way you've got CC Mode configured is highly unusual, and
suggests the person who wrote the .emacs didn't fully understand the way
Emacs works.
Your setup for C++ Mode looks like this in outline:
(defun my-c++-mode ()
(c++-mode)
(williams-customizations))
This compels you to add entries to auto-mode-alist (this is the list
which tells Emacs which mode to use for a filename). Normally C++ Mode
is configured by using "hooks" - you give c++-mode a list of functions
you want to get called whenever c++-mode runs. You then get the
customizations you want without need to have functions like my-c++-mode.
You could reformulate your code like this:
(defun williams-c++-hook ()
(williams-customizations))
(add-hook 'c++-mode-hook 'williams-c++-hook)
That way, you could get rid of all these entries to auto-mode-alist.
Customizations which are common to C, C++, Java, Pike, (such as the
call of c-toggle-hungry-state) you need only write once, in
c-mode-common-hook, like this:
(defun williams-common-hook ()
(c-toggle-hungry-state 1)
(other-customizations))
(add-hook 'c-mode-common-hook 'williams-common-hook)
This is extensively described on the page "Hooks" in the CC Mode manual,
and the page "Sample .emacs File" would also be of interest.
> / WP
--
Alan Mackenzie (Munich, Germany)
Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Hungry delete for C, C++ and Java?
2004-04-22 11:54 ` Alan Mackenzie
@ 2004-04-22 16:18 ` William Payne
2004-04-22 16:36 ` William Payne
0 siblings, 1 reply; 7+ messages in thread
From: William Payne @ 2004-04-22 16:18 UTC (permalink / raw)
"Alan Mackenzie" <none@example.invalid> wrote in message
news:ipb86c.q5.ln@acm.acm...
> William Payne <mikas_n_o_s_p_a_m_493@student.liu.se> wrote on Wed, 21 Apr
> 2004 00:27:06 +0200:
>
> >> > .... and I was wondering how I turn on hungry delete per default for
> >> > C, C++ and Java?
>
> >> In an appropriate hook function (probably on c-mode-common-hook)
include:
>
> >> (c-toggle-hungry-state 1)
>
> >> [, and as a matter of interest, C-c C-d will execute
> >> `c-toggle-hungry-state' interactively]. <backspace> and C-d (but not
> >> <del>) then do hungry deletion. It looks as thought the fine manual
> >> could do with some clarification on this point.
>
> > Thanks for the reply, Alan. My .emacs file is as follows, where should
> > I put (c-toggle-hungry-state 1)? Under (defun my-c++-mode ()
> > (interactive) and (defun my-java-mode () (interactive) ?
>
> > My .emacs file was created years and years ago by someone else, I wish I
> > understood it better...I am guessing it could be cleaned-up/improved
alot.
>
> > Fyi, I am using CC-Mode 5.30.8.
>
> A stable released version without bugs. (hah! :-)
>
> OK, a few comments on your .emacs file:
>
> > '("\\.pike$" . my-c++-mode) ; element of auto-mode-alist
>
> There is actually a Pike Mode within CC Mode. If that's the same
> language that your files.pike are, it would be better than c++-mode.
Thanks for noticing this. I have removed this entry completely.
> Also, you're using C++ Mode for C files. Also not _so_ bad, but not
> quite optimal.
>
Yes, I guess I should change that. First I will have to convert all my c++
header files to end in .hpp instead of .h. I also have to fix the
indentation in some cases, it's not behaving as I want it to behave.
> > (defun my-java-mode () (interactive)
> > (java-mode)
> > (require 'jdok)
> > (c-toggle-hungry-state 1) ; <====================================
> > (setq c-basic-offset 3) ; Indent three columns.
> > (setq c-offsets-alist
>
> It looks like you've already got c-toggle-hungry-state turned on, here.
> Does it work? Have you inserted this line here in the last day or two,
> perhaps? It ought to work.
>
I added that after your first reply and, yes, it works. =)
> If it now works and you're happy about it, that's great, and just ignore
> what follows.
>
> #########################################################################
>
> However, if you're interested in getting to know Emacs and CC Mode a bit
> better, the way you've got CC Mode configured is highly unusual, and
> suggests the person who wrote the .emacs didn't fully understand the way
> Emacs works.
>
> Your setup for C++ Mode looks like this in outline:
>
> (defun my-c++-mode ()
> (c++-mode)
> (williams-customizations))
>
> This compels you to add entries to auto-mode-alist (this is the list
> which tells Emacs which mode to use for a filename). Normally C++ Mode
> is configured by using "hooks" - you give c++-mode a list of functions
> you want to get called whenever c++-mode runs. You then get the
> customizations you want without need to have functions like my-c++-mode.
> You could reformulate your code like this:
>
> (defun williams-c++-hook ()
> (williams-customizations))
> (add-hook 'c++-mode-hook 'williams-c++-hook)
>
> That way, you could get rid of all these entries to auto-mode-alist.
> Customizations which are common to C, C++, Java, Pike, (such as the
> call of c-toggle-hungry-state) you need only write once, in
> c-mode-common-hook, like this:
>
> (defun williams-common-hook ()
> (c-toggle-hungry-state 1)
> (other-customizations))
> (add-hook 'c-mode-common-hook 'williams-common-hook)
>
> This is extensively described on the page "Hooks" in the CC Mode manual,
> and the page "Sample .emacs File" would also be of interest.
>
> > / WP
>
I am very interested in cleaning up my .emacs-file and understanding emacs
and cc-mode better. I am not quite sure I follow you on the hooks (having
done zero lisp coding), but I will try to understand it and incorporate your
suggestions.
> --
> Alan Mackenzie (Munich, Germany)
> Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
> (like "aa"), remove half of them (leaving, say, "a").
>
/ William Payne
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Hungry delete for C, C++ and Java?
2004-04-22 16:18 ` William Payne
@ 2004-04-22 16:36 ` William Payne
2004-04-22 17:55 ` William Payne
0 siblings, 1 reply; 7+ messages in thread
From: William Payne @ 2004-04-22 16:36 UTC (permalink / raw)
"William Payne" <mikas_n_o_s_p_a_m_493@student.liu.se> wrote in message
news:c68r8g$3k9$1@news.island.liu.se...
>
> "Alan Mackenzie" <none@example.invalid> wrote in message
> news:ipb86c.q5.ln@acm.acm...
> > William Payne <mikas_n_o_s_p_a_m_493@student.liu.se> wrote on Wed, 21
Apr
> > 2004 00:27:06 +0200:
> >
> > >> > .... and I was wondering how I turn on hungry delete per default
for
> > >> > C, C++ and Java?
> >
> > >> In an appropriate hook function (probably on c-mode-common-hook)
> include:
> >
> > >> (c-toggle-hungry-state 1)
> >
> > >> [, and as a matter of interest, C-c C-d will execute
> > >> `c-toggle-hungry-state' interactively]. <backspace> and C-d (but not
> > >> <del>) then do hungry deletion. It looks as thought the fine manual
> > >> could do with some clarification on this point.
> >
> > > Thanks for the reply, Alan. My .emacs file is as follows, where should
> > > I put (c-toggle-hungry-state 1)? Under (defun my-c++-mode ()
> > > (interactive) and (defun my-java-mode () (interactive) ?
> >
> > > My .emacs file was created years and years ago by someone else, I wish
I
> > > understood it better...I am guessing it could be cleaned-up/improved
> alot.
> >
> > > Fyi, I am using CC-Mode 5.30.8.
> >
> > A stable released version without bugs. (hah! :-)
> >
> > OK, a few comments on your .emacs file:
> >
> > > '("\\.pike$" . my-c++-mode) ; element of auto-mode-alist
> >
> > There is actually a Pike Mode within CC Mode. If that's the same
> > language that your files.pike are, it would be better than c++-mode.
>
> Thanks for noticing this. I have removed this entry completely.
>
> > Also, you're using C++ Mode for C files. Also not _so_ bad, but not
> > quite optimal.
> >
>
> Yes, I guess I should change that. First I will have to convert all my c++
> header files to end in .hpp instead of .h. I also have to fix the
> indentation in some cases, it's not behaving as I want it to behave.
>
> > > (defun my-java-mode () (interactive)
> > > (java-mode)
> > > (require 'jdok)
> > > (c-toggle-hungry-state 1) ; <====================================
> > > (setq c-basic-offset 3) ; Indent three columns.
> > > (setq c-offsets-alist
> >
> > It looks like you've already got c-toggle-hungry-state turned on, here.
> > Does it work? Have you inserted this line here in the last day or two,
> > perhaps? It ought to work.
> >
>
> I added that after your first reply and, yes, it works. =)
>
> > If it now works and you're happy about it, that's great, and just ignore
> > what follows.
> >
> >
#########################################################################
> >
> > However, if you're interested in getting to know Emacs and CC Mode a bit
> > better, the way you've got CC Mode configured is highly unusual, and
> > suggests the person who wrote the .emacs didn't fully understand the way
> > Emacs works.
> >
> > Your setup for C++ Mode looks like this in outline:
> >
> > (defun my-c++-mode ()
> > (c++-mode)
> > (williams-customizations))
> >
> > This compels you to add entries to auto-mode-alist (this is the list
> > which tells Emacs which mode to use for a filename). Normally C++ Mode
> > is configured by using "hooks" - you give c++-mode a list of functions
> > you want to get called whenever c++-mode runs. You then get the
> > customizations you want without need to have functions like my-c++-mode.
> > You could reformulate your code like this:
> >
> > (defun williams-c++-hook ()
> > (williams-customizations))
> > (add-hook 'c++-mode-hook 'williams-c++-hook)
> >
> > That way, you could get rid of all these entries to auto-mode-alist.
> > Customizations which are common to C, C++, Java, Pike, (such as the
> > call of c-toggle-hungry-state) you need only write once, in
> > c-mode-common-hook, like this:
> >
> > (defun williams-common-hook ()
> > (c-toggle-hungry-state 1)
> > (other-customizations))
> > (add-hook 'c-mode-common-hook 'williams-common-hook)
> >
> > This is extensively described on the page "Hooks" in the CC Mode manual,
> > and the page "Sample .emacs File" would also be of interest.
> >
> > > / WP
> >
>
> I am very interested in cleaning up my .emacs-file and understanding emacs
> and cc-mode better. I am not quite sure I follow you on the hooks (having
> done zero lisp coding), but I will try to understand it and incorporate
your
> suggestions.
> > --
> > Alan Mackenzie (Munich, Germany)
> > Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
> > (like "aa"), remove half of them (leaving, say, "a").
> >
>
> / William Payne
>
>
Ok, I have added a C++ hook now and it seems to work but why doesn't give it
me the same indentation rules as it does for a c++-file? I don't mind it, I
just don't understand it...
/ WP
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Hungry delete for C, C++ and Java?
2004-04-22 16:36 ` William Payne
@ 2004-04-22 17:55 ` William Payne
0 siblings, 0 replies; 7+ messages in thread
From: William Payne @ 2004-04-22 17:55 UTC (permalink / raw)
"William Payne" <mikas_n_o_s_p_a_m_493@student.liu.se> wrote in message
news:c68saj$3sr$1@news.island.liu.se...
>
> "William Payne" <mikas_n_o_s_p_a_m_493@student.liu.se> wrote in message
> news:c68r8g$3k9$1@news.island.liu.se...
> >
> > "Alan Mackenzie" <none@example.invalid> wrote in message
> > news:ipb86c.q5.ln@acm.acm...
> > > William Payne <mikas_n_o_s_p_a_m_493@student.liu.se> wrote on Wed, 21
> Apr
> > > 2004 00:27:06 +0200:
> > >
> > > >> > .... and I was wondering how I turn on hungry delete per default
> for
> > > >> > C, C++ and Java?
> > >
> > > >> In an appropriate hook function (probably on c-mode-common-hook)
> > include:
> > >
> > > >> (c-toggle-hungry-state 1)
> > >
> > > >> [, and as a matter of interest, C-c C-d will execute
> > > >> `c-toggle-hungry-state' interactively]. <backspace> and C-d (but
not
> > > >> <del>) then do hungry deletion. It looks as thought the fine
manual
> > > >> could do with some clarification on this point.
> > >
> > > > Thanks for the reply, Alan. My .emacs file is as follows, where
should
> > > > I put (c-toggle-hungry-state 1)? Under (defun my-c++-mode ()
> > > > (interactive) and (defun my-java-mode () (interactive) ?
> > >
> > > > My .emacs file was created years and years ago by someone else, I
wish
> I
> > > > understood it better...I am guessing it could be cleaned-up/improved
> > alot.
> > >
> > > > Fyi, I am using CC-Mode 5.30.8.
> > >
> > > A stable released version without bugs. (hah! :-)
> > >
> > > OK, a few comments on your .emacs file:
> > >
> > > > '("\\.pike$" . my-c++-mode) ; element of auto-mode-alist
> > >
> > > There is actually a Pike Mode within CC Mode. If that's the same
> > > language that your files.pike are, it would be better than c++-mode.
> >
> > Thanks for noticing this. I have removed this entry completely.
> >
> > > Also, you're using C++ Mode for C files. Also not _so_ bad, but not
> > > quite optimal.
> > >
> >
> > Yes, I guess I should change that. First I will have to convert all my
c++
> > header files to end in .hpp instead of .h. I also have to fix the
> > indentation in some cases, it's not behaving as I want it to behave.
> >
> > > > (defun my-java-mode () (interactive)
> > > > (java-mode)
> > > > (require 'jdok)
> > > > (c-toggle-hungry-state 1) ;
<====================================
> > > > (setq c-basic-offset 3) ; Indent three columns.
> > > > (setq c-offsets-alist
> > >
> > > It looks like you've already got c-toggle-hungry-state turned on,
here.
> > > Does it work? Have you inserted this line here in the last day or
two,
> > > perhaps? It ought to work.
> > >
> >
> > I added that after your first reply and, yes, it works. =)
> >
> > > If it now works and you're happy about it, that's great, and just
ignore
> > > what follows.
> > >
> > >
> #########################################################################
> > >
> > > However, if you're interested in getting to know Emacs and CC Mode a
bit
> > > better, the way you've got CC Mode configured is highly unusual, and
> > > suggests the person who wrote the .emacs didn't fully understand the
way
> > > Emacs works.
> > >
> > > Your setup for C++ Mode looks like this in outline:
> > >
> > > (defun my-c++-mode ()
> > > (c++-mode)
> > > (williams-customizations))
> > >
> > > This compels you to add entries to auto-mode-alist (this is the list
> > > which tells Emacs which mode to use for a filename). Normally C++
Mode
> > > is configured by using "hooks" - you give c++-mode a list of functions
> > > you want to get called whenever c++-mode runs. You then get the
> > > customizations you want without need to have functions like
my-c++-mode.
> > > You could reformulate your code like this:
> > >
> > > (defun williams-c++-hook ()
> > > (williams-customizations))
> > > (add-hook 'c++-mode-hook 'williams-c++-hook)
> > >
> > > That way, you could get rid of all these entries to auto-mode-alist.
> > > Customizations which are common to C, C++, Java, Pike, (such as the
> > > call of c-toggle-hungry-state) you need only write once, in
> > > c-mode-common-hook, like this:
> > >
> > > (defun williams-common-hook ()
> > > (c-toggle-hungry-state 1)
> > > (other-customizations))
> > > (add-hook 'c-mode-common-hook 'williams-common-hook)
> > >
> > > This is extensively described on the page "Hooks" in the CC Mode
manual,
> > > and the page "Sample .emacs File" would also be of interest.
> > >
> > > > / WP
> > >
> >
> > I am very interested in cleaning up my .emacs-file and understanding
emacs
> > and cc-mode better. I am not quite sure I follow you on the hooks
(having
> > done zero lisp coding), but I will try to understand it and incorporate
> your
> > suggestions.
> > > --
> > > Alan Mackenzie (Munich, Germany)
> > > Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
> > > (like "aa"), remove half of them (leaving, say, "a").
> > >
> >
> > / William Payne
> >
> >
>
> Ok, I have added a C++ hook now and it seems to work but why doesn't give
it
> me the same indentation rules as it does for a c++-file? I don't mind it,
I
> just don't understand it...
>
> / WP
>
>
Lol, nevermind it wasn't using the C++ indentation rules. I know have two
hooks, one for C and one for C++. I am trying to remove the syntactic
symbols from the C hook that have no meaning in C code. Next I will add a
Java hook I guess, but I haven't been using Java anything at all for the
past two years.
I still have some indentation tweaks to do (when writing a preprocessor
macro in c or c++, I want it to align to column zero).
Also, can I output a string telling me which hook I am using?
/ WP
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Hungry delete for C, C++ and Java?
[not found] ` <68n36c.q5.ln@acm.acm>
2004-04-20 22:27 ` Hungry delete for C, C++ and Java? William Payne
@ 2004-04-24 21:03 ` Kai Grossjohann
2004-04-25 6:33 ` Alan Mackenzie
1 sibling, 1 reply; 7+ messages in thread
From: Kai Grossjohann @ 2004-04-24 21:03 UTC (permalink / raw)
Alan Mackenzie<none@example.invalid> writes:
> William Payne <mikas_n_o_s_p_a_m_493@student.liu.se> wrote on Tue, 20 Apr
> 2004 17:35:30 +0200:
>> Hello, I am using a CVS version of Emacs (checked out three weeks ago),
>
> Just to be pedantic, if you checked it out from savannah.gnu.org, it will
> be (from the point of view of the CC Mode team) a released version with
> version number 5.30 or 5.30.n. If you got it by anonymous CVS from
> cc-mode.sourceforge.net, then it will indeed be a "CVS version", and will
> be the emerging version 5.31.
William said he's using a CVS version *of Emacs*, and I doubt that
this can be fetched from cc-mode.sourceforge.net. From that site, one
can fetch CVS versions *of CC mode*...
Just to be very pedantic,
Kai
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Hungry delete for C, C++ and Java?
2004-04-24 21:03 ` Kai Grossjohann
@ 2004-04-25 6:33 ` Alan Mackenzie
0 siblings, 0 replies; 7+ messages in thread
From: Alan Mackenzie @ 2004-04-25 6:33 UTC (permalink / raw)
Kai Grossjohann <kai@emptydomain.de> wrote on Sat, 24 Apr 2004 23:03:48 +0200:
> Alan Mackenzie<none@example.invalid> writes:
>> William Payne <mikas_n_o_s_p_a_m_493@student.liu.se> wrote on Tue, 20 Apr
>> 2004 17:35:30 +0200:
>>> Hello, I am using a CVS version of Emacs (checked out three weeks ago),
>>
>> Just to be pedantic, if you checked it out from savannah.gnu.org, it will
>> be (from the point of view of the CC Mode team) a released version with
>> version number 5.30 or 5.30.n. If you got it by anonymous CVS from
>> cc-mode.sourceforge.net, then it will indeed be a "CVS version", and will
>> be the emerging version 5.31.
> William said he's using a CVS version *of Emacs*, and I doubt that
> this can be fetched from cc-mode.sourceforge.net. From that site, one
> can fetch CVS versions *of CC mode*...
> Just to be very pedantic,
OK, you win!
> Kai
--
Alan Mackenzie (Munich, Germany)
Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2004-04-25 6:33 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <c63fvv$g2j$1@news.island.liu.se>
[not found] ` <68n36c.q5.ln@acm.acm>
2004-04-20 22:27 ` Hungry delete for C, C++ and Java? William Payne
2004-04-22 11:54 ` Alan Mackenzie
2004-04-22 16:18 ` William Payne
2004-04-22 16:36 ` William Payne
2004-04-22 17:55 ` William Payne
2004-04-24 21:03 ` Kai Grossjohann
2004-04-25 6:33 ` Alan Mackenzie
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).