* c-auto-newline question
@ 2013-01-10 8:42 Luca Ferrari
0 siblings, 0 replies; 7+ messages in thread
From: Luca Ferrari @ 2013-01-10 8:42 UTC (permalink / raw
To: help-gnu-emacs
Hi all,
I've configured c-auto-newline for my code editing, and it is great
but I'd like to have the newline added when ";" is typed only if the
following line is empty or not-existent yet. In other words, if I'm
editing a line in the middle of the code, I don't want ";" to add an
empty line if the following contains other code. Is this possible?
Thanks,
Luca
^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <mailman.17033.1357807327.855.help-gnu-emacs@gnu.org>]
* Re: c-auto-newline question
[not found] <mailman.17033.1357807327.855.help-gnu-emacs@gnu.org>
@ 2013-01-10 8:52 ` Damien Wyart
2013-01-10 9:22 ` Luca Ferrari
[not found] ` <mailman.17034.1357809745.855.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 7+ messages in thread
From: Damien Wyart @ 2013-01-10 8:52 UTC (permalink / raw
To: help-gnu-emacs
* Luca Ferrari <fluca1978@infinito.it> in gnu.emacs.help:
> I've configured c-auto-newline for my code editing, and it is great
> but I'd like to have the newline added when ";" is typed only if the
> following line is empty or not-existent yet. In other words, if I'm
> editing a line in the middle of the code, I don't want ";" to add an
> empty line if the following contains other code. Is this possible?
Yes, as explained here
http://www.gnu.org/software/emacs/manual/html_mono/ccmode.html#Hanging-Semicolons-and-Commas
this is possible.
You have to rely on the function c-semi&comma-no-newlines-before-nonblanks.
--
DW
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: c-auto-newline question
2013-01-10 8:52 ` Damien Wyart
@ 2013-01-10 9:22 ` Luca Ferrari
[not found] ` <mailman.17034.1357809745.855.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 7+ messages in thread
From: Luca Ferrari @ 2013-01-10 9:22 UTC (permalink / raw
To: Damien Wyart; +Cc: help-gnu-emacs
Thanks Damien,
that is what I was looking for, but I suspect I'm doing something
wrong since it is not working. In my .emacs file I've got:
(add-hook 'c-mode-common-hook
'(lambda ()
(c-set-style "java")
(setq c-auto-newline t)
(setq c-hungry-delete-key t)
(c-hanging-semi&comma-criteria
. (c-semi&comma-no-newlines-before-nonblanks
c-semi&comma-no-newlines-for-oneline-inliners
c-semi&comma-inside-parenlist))
))
but it still produces an auto-newline in every condition. What am I missing?
Thanks,
Luca
^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <mailman.17034.1357809745.855.help-gnu-emacs@gnu.org>]
* Re: c-auto-newline question
[not found] ` <mailman.17034.1357809745.855.help-gnu-emacs@gnu.org>
@ 2013-01-10 9:42 ` Damien Wyart
2013-01-10 14:46 ` Luca Ferrari
[not found] ` <mailman.17050.1357829207.855.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 7+ messages in thread
From: Damien Wyart @ 2013-01-10 9:42 UTC (permalink / raw
To: help-gnu-emacs
* Luca Ferrari <fluca1978@infinito.it> in gnu.emacs.help:
> that is what I was looking for, but I suspect I'm doing something
> wrong since it is not working. In my .emacs file I've got:
>
> (add-hook 'c-mode-common-hook
> '(lambda ()
> (c-set-style "java")
> (setq c-auto-newline t)
> (setq c-hungry-delete-key t)
> (c-hanging-semi&comma-criteria
> . (c-semi&comma-no-newlines-before-nonblanks
> c-semi&comma-no-newlines-for-oneline-inliners
> c-semi&comma-inside-parenlist))
> ))
> but it still produces an auto-newline in every condition. What am
> I missing?
c-hanging-semi&comma-criteria is a list, not a function.
(add-hook 'c-mode-common-hook
'(lambda ()
(c-set-style "java")
(setq c-auto-newline t)
(setq c-hungry-delete-key t)
(add-to-list 'c-hanging-semi&comma-criteria 'c-semi&comma-no-newlines-before-nonblanks)
(add-to-list 'c-hanging-semi&comma-criteria 'c-semi&comma-no-newlines-for-oneline-inliners)
))
--
DW
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: c-auto-newline question
2013-01-10 9:42 ` Damien Wyart
@ 2013-01-10 14:46 ` Luca Ferrari
[not found] ` <mailman.17050.1357829207.855.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 7+ messages in thread
From: Luca Ferrari @ 2013-01-10 14:46 UTC (permalink / raw
To: Damien Wyart; +Cc: help-gnu-emacs
My fault!
Anyway, even with your suggestion the feature is not working properly
and I've got still Emacs inserting a new blank line every time.
Moreover, now the RET does not completes the autocomplete suggestion
but works as a "bare" return. Could it be therefore something that
clashes among autocomplete and auto-state?
I'm using emacs 23.3.1.
Thanks,
Luca
^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <mailman.17050.1357829207.855.help-gnu-emacs@gnu.org>]
* Re: c-auto-newline question
[not found] ` <mailman.17050.1357829207.855.help-gnu-emacs@gnu.org>
@ 2013-01-10 16:30 ` Damien Wyart
2013-01-11 8:51 ` Luca Ferrari
0 siblings, 1 reply; 7+ messages in thread
From: Damien Wyart @ 2013-01-10 16:30 UTC (permalink / raw
To: help-gnu-emacs
* Luca Ferrari <fluca1978@infinito.it> in gnu.emacs.help:
> Anyway, even with your suggestion the feature is not working properly
> and I've got still Emacs inserting a new blank line every time.
I tested my snippet before posting it and it worked on my side (no blank
line when following line is not empty), so this might depend on many
other factors (Emacs version, other elisp packages, other .emacs
settings...).
> Moreover, now the RET does not completes the autocomplete suggestion
> but works as a "bare" return. Could it be therefore something that
> clashes among autocomplete and auto-state?
No idea, and I have to say I can't go further in debugging this, you
have to investigate on your side (cc-mode is not too hard to debug with
the elisp debugguer and breakpoints on the functions you want to trace,
then checking why the line gets inserted or not/removed or not after
typing ';'). Check if removing the two "add-to-list" statements in my
snippet brings back the autocomplete on RET, then you will now this
comes from this part... This is quite basic debugging, so I think you
will learn more by doing it by yourself.
Maybe if you want to tune more fully your cc-mode you need to define
your own style (it is easy to find lots of examples on the Web, for
example :
http://google-styleguide.googlecode.com/svn/trunk/google-c-style.el).
--
DW
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: c-auto-newline question
2013-01-10 16:30 ` Damien Wyart
@ 2013-01-11 8:51 ` Luca Ferrari
0 siblings, 0 replies; 7+ messages in thread
From: Luca Ferrari @ 2013-01-11 8:51 UTC (permalink / raw
To: Damien Wyart; +Cc: help-gnu-emacs
At last I got it:
1) I was using add-to-list in a wrong way, and therefore now the
auto-newline works as I want
2) the autocomplete problem with RET is not tied to auto-state but to
the autopair minor mode as reported also here:
http://code.google.com/p/autopair/issues/detail?id=8
So far, I've disabled autopair, since autocomplete is much more
important for my workflow.
Luca
On Thu, Jan 10, 2013 at 5:30 PM, Damien Wyart <damien.wyart@free.fr> wrote:
> * Luca Ferrari <fluca1978@infinito.it> in gnu.emacs.help:
>> Anyway, even with your suggestion the feature is not working properly
>> and I've got still Emacs inserting a new blank line every time.
>
> I tested my snippet before posting it and it worked on my side (no blank
> line when following line is not empty), so this might depend on many
> other factors (Emacs version, other elisp packages, other .emacs
> settings...).
>
>> Moreover, now the RET does not completes the autocomplete suggestion
>> but works as a "bare" return. Could it be therefore something that
>> clashes among autocomplete and auto-state?
>
> No idea, and I have to say I can't go further in debugging this, you
> have to investigate on your side (cc-mode is not too hard to debug with
> the elisp debugguer and breakpoints on the functions you want to trace,
> then checking why the line gets inserted or not/removed or not after
> typing ';'). Check if removing the two "add-to-list" statements in my
> snippet brings back the autocomplete on RET, then you will now this
> comes from this part... This is quite basic debugging, so I think you
> will learn more by doing it by yourself.
>
> Maybe if you want to tune more fully your cc-mode you need to define
> your own style (it is easy to find lots of examples on the Web, for
> example :
> http://google-styleguide.googlecode.com/svn/trunk/google-c-style.el).
>
> --
> DW
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-01-11 8:51 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-10 8:42 c-auto-newline question Luca Ferrari
[not found] <mailman.17033.1357807327.855.help-gnu-emacs@gnu.org>
2013-01-10 8:52 ` Damien Wyart
2013-01-10 9:22 ` Luca Ferrari
[not found] ` <mailman.17034.1357809745.855.help-gnu-emacs@gnu.org>
2013-01-10 9:42 ` Damien Wyart
2013-01-10 14:46 ` Luca Ferrari
[not found] ` <mailman.17050.1357829207.855.help-gnu-emacs@gnu.org>
2013-01-10 16:30 ` Damien Wyart
2013-01-11 8:51 ` Luca Ferrari
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.