* about auto indentation
@ 2010-08-07 11:22 fgr
2010-08-07 12:08 ` Teemu Likonen
0 siblings, 1 reply; 5+ messages in thread
From: fgr @ 2010-08-07 11:22 UTC (permalink / raw)
To: help-gnu-emacs
Hi,
I've got a bit question about automatic indentation.
Geany editor (consider a C style comment):
/*[1]
*/
[1] when I hit the return key in that point, Geany does an automatic
indent, add an "*" and a blank space. It's like this:
/*
*
*/
I've read <http://www.emacswiki.org/emacs/AutoIndentation> page, but
seems there isn't what I'm looking for.
TIA
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: about auto indentation
2010-08-07 11:22 about auto indentation fgr
@ 2010-08-07 12:08 ` Teemu Likonen
[not found] ` <20100807151110.5a60f768@bir-tawil.nul>
0 siblings, 1 reply; 5+ messages in thread
From: Teemu Likonen @ 2010-08-07 12:08 UTC (permalink / raw)
To: help-gnu-emacs
* 2010-08-07 13:22 (+0200), fgr@bir-tawil.nul.invalid wrote:
> I've got a bit question about automatic indentation.
There is wasn't any questions in your message.
> /*[1]
> */
>
> [1] when I hit the return key in that point, Geany does an automatic
> indent, add an "*" and a blank space. [...]
I guess you want command c-indent-new-comment-line which, by default, is
bound to M-j key in c-mode.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: about auto indentation
[not found] ` <20100807151110.5a60f768@bir-tawil.nul>
@ 2010-08-07 13:50 ` Teemu Likonen
2010-08-07 14:57 ` fgr
0 siblings, 1 reply; 5+ messages in thread
From: Teemu Likonen @ 2010-08-07 13:50 UTC (permalink / raw)
To: help-gnu-emacs
* 2010-08-07 15:11 (+0200), fgr@bir-tawil.nul.invalid wrote:
> 2010-08-07 15:08 +0300, Teemu Likonen wrote:
>> I guess you want command c-indent-new-comment-line which, by default,
>> is bound to M-j key in c-mode.
>
> That command does an indentation but doesn't add any "*" character.
Did you use M-j at the end of a comment line? The command should add a
newline, indent and then add a comment character. That's what it does in
my Emacs. Command's description:
M-j runs the command c-indent-new-comment-line, which is an
interactive compiled Lisp function in `cc-cmds.el'.
It is bound to M-j, C-M-j.
(c-indent-new-comment-line &optional SOFT ALLOW-AUTO-FILL)
Break line at point and indent, continuing comment or macro if
within one. If inside a comment and `comment-multi-line' is non-nil,
the indentation and line prefix are preserved (see the
`c-comment-prefix-regexp' and `c-block-comment-prefix' variables for
details). If inside a single line comment and `comment-multi-line'
is nil, a new comment of the same type is started on the next line
and indented as appropriate for comments. If inside a macro, a line
continuation backslash is inserted and aligned as appropriate, and
the new line is indented according to `c-syntactic-indentation'.
If a fill prefix is specified, it overrides all the above.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: about auto indentation
2010-08-07 13:50 ` Teemu Likonen
@ 2010-08-07 14:57 ` fgr
2010-08-07 15:20 ` fgr
0 siblings, 1 reply; 5+ messages in thread
From: fgr @ 2010-08-07 14:57 UTC (permalink / raw)
To: help-gnu-emacs
2010-08-07 16:50 +0300, Teemu Likonen wrote:
| * 2010-08-07 15:11 (+0200), fgr@bir-tawil.nul.invalid wrote:
|
| > 2010-08-07 15:08 +0300, Teemu Likonen wrote:
| >> I guess you want command c-indent-new-comment-line which, by
| default, >> is bound to M-j key in c-mode.
| >
| > That command does an indentation but doesn't add any "*"
| character.
|
| Did you use M-j at the end of a comment line? The command should
| add a newline, indent and then add a comment character. That's
| what it does in my Emacs. Command's description:
|
| M-j runs the command c-indent-new-comment-line, which is an
| interactive compiled Lisp function in `cc-cmds.el'.
|
| It is bound to M-j, C-M-j.
|
| (c-indent-new-comment-line &optional SOFT ALLOW-AUTO-FILL)
[...]
Well, you can take a look at the following:
,----
| ~ % locate cc-cmds.el
| /usr/share/emacs/24.0.50/lisp/progmodes/cc-cmds.el.gz
| /usr/share/emacs/24.0.50/lisp/progmodes/cc-cmds.elc
`----
Maybe some setting influences the command in question. I don't know.
What follows is an extract of my ~/emacs.d/init.el:
(global-set-key (kbd "RET") 'newline-and-indent)
(setq comment-auto-fill-only-comments t)
(add-hook 'c-mode-common-hook '(lambda () (c-toggle-auto-state 1)))
(add-hook 'c-mode-common-hook '(lambda () (c-toggle-hungry-state 1)))
(add-hook 'c-mode-common-hook '(lambda () (c-subword-mode 1)))
(c-set-offset 'case-label '+) ; see Emacs FAQ, 5.22
;; To automatically fill comments but not code in ProgrammingModes
(add-hook 'c-mode-common-hook
(lambda ()
(auto-fill-mode 1)
(set (make-local-variable 'fill-nobreak-predicate)
(lambda ()
(not (eq (get-text-property (point) 'face)
'font-lock-comment-face))))))
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: about auto indentation
2010-08-07 14:57 ` fgr
@ 2010-08-07 15:20 ` fgr
0 siblings, 0 replies; 5+ messages in thread
From: fgr @ 2010-08-07 15:20 UTC (permalink / raw)
To: help-gnu-emacs
solved! c-indent-new-comment-line works if the comment is like this:
/*
*
*/
That is, there must be a line that contains a "*" character while I
was hitting the return key on the first line of the comment.
anyway, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-08-07 15:20 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-07 11:22 about auto indentation fgr
2010-08-07 12:08 ` Teemu Likonen
[not found] ` <20100807151110.5a60f768@bir-tawil.nul>
2010-08-07 13:50 ` Teemu Likonen
2010-08-07 14:57 ` fgr
2010-08-07 15:20 ` fgr
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).