* Modify indention for C/C++
@ 2014-06-11 13:24 Florian Lindner
2014-06-11 13:31 ` Florian Lindner
2014-06-11 13:42 ` Teemu Likonen
0 siblings, 2 replies; 6+ messages in thread
From: Florian Lindner @ 2014-06-11 13:24 UTC (permalink / raw)
To: help-gnu-emacs
Hello,
what is the canonical way to modify indention for certain keywords? I've
found numerous ways in the internets. I want to change the linux style
so, that is does not do indention for namespaces.
(c-add-style "linux"
'(
(c-basic-offset . 2)
(c-offset-alist . (
(namespace-open . 0)
(namespace-close . 0)
(innamespace . 0)
))
))
(setq c-default-style "linux")
I tried that, and it seems to correctly c-style-alist but has no effect.
How can I change/modify an indention style?
Thanks,
Florian
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Modify indention for C/C++
2014-06-11 13:24 Modify indention for C/C++ Florian Lindner
@ 2014-06-11 13:31 ` Florian Lindner
2014-06-12 6:59 ` Kevin Rodgers
2014-06-11 13:42 ` Teemu Likonen
1 sibling, 1 reply; 6+ messages in thread
From: Florian Lindner @ 2014-06-11 13:31 UTC (permalink / raw)
To: help-gnu-emacs
Am 11.06.2014 15:24, schrieb Florian Lindner:
> Hello,
>
> what is the canonical way to modify indention for certain keywords?
> I've found numerous ways in the internets. I want to change the linux
> style so, that is does not do indention for namespaces.
> I tried that, and it seems to correctly c-style-alist but has no
> effect. How can I change/modify an indention style?
>
> Thanks,
> Florian
Documentation to c-style-alist says:
Do not change this variable directly. Use the function `c-add-style'
to add new styles or modify existing styles (it is not a good idea to
modify existing styles -- you should create a new style that inherits
the existing style).
But in the doc of c-add-style it does not mention how to inherit from a
style.
Another question: (statement-case-open . +) Why is there a dot . in the
middle of the clause?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Modify indention for C/C++
2014-06-11 13:24 Modify indention for C/C++ Florian Lindner
2014-06-11 13:31 ` Florian Lindner
@ 2014-06-11 13:42 ` Teemu Likonen
2014-06-11 14:23 ` Florian Lindner
1 sibling, 1 reply; 6+ messages in thread
From: Teemu Likonen @ 2014-06-11 13:42 UTC (permalink / raw)
To: Florian Lindner; +Cc: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 806 bytes --]
Florian Lindner [2014-06-11 15:24:34 +02:00] wrote:
> what is the canonical way to modify indention for certain keywords?
> I've found numerous ways in the internets. I want to change the linux
> style so, that is does not do indention for namespaces.
>
> (c-add-style "linux"
> '(
> (c-basic-offset . 2)
> (c-offset-alist . (
> (namespace-open . 0)
> (namespace-close . 0)
> (innamespace . 0)
> ))
> ))
How about this?
(c-add-style "my-linux"
'("linux"
(c-basic-offset . 2)
(c-offset-alist (namespace-open . 0)
(namespace-close . 0)
(innamespace . 0))))
This adds "my-linux" style, so the original is not overwritten.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 835 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Modify indention for C/C++
2014-06-11 13:42 ` Teemu Likonen
@ 2014-06-11 14:23 ` Florian Lindner
0 siblings, 0 replies; 6+ messages in thread
From: Florian Lindner @ 2014-06-11 14:23 UTC (permalink / raw)
To: Teemu Likonen; +Cc: help-gnu-emacs
Am 11.06.2014 15:42, schrieb Teemu Likonen:
> Florian Lindner [2014-06-11 15:24:34 +02:00] wrote:
>
>> what is the canonical way to modify indention for certain keywords?
>> I've found numerous ways in the internets. I want to change the linux
>> style so, that is does not do indention for namespaces.
>>
>> (c-add-style "linux"
>> '(
>> (c-basic-offset . 2)
>> (c-offset-alist . (
>> (namespace-open . 0)
>> (namespace-close . 0)
>> (innamespace . 0)
>> ))
>> ))
>
> How about this?
>
> (c-add-style "my-linux"
> '("linux"
> (c-basic-offset . 2)
> (c-offset-alist (namespace-open . 0)
> (namespace-close . 0)
> (innamespace . 0))))
>
> This adds "my-linux" style, so the original is not overwritten.
c-style-alist now has an entry:
("my-linux" "linux"
(c-basic-offset . 2)
(c-offset-alist
(namespace-open . 0)
(namespace-close . 0)
(innamespace . 0)))
Does that mean the mode is derived from linux?
Indention is still the same, after a namespace code is being indented.
I've activated the my-linux style.
Thx,
Florian
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Modify indention for C/C++
[not found] <mailman.3406.1402493094.1147.help-gnu-emacs@gnu.org>
@ 2014-06-11 15:07 ` Emanuel Berg
0 siblings, 0 replies; 6+ messages in thread
From: Emanuel Berg @ 2014-06-11 15:07 UTC (permalink / raw)
To: help-gnu-emacs
Florian Lindner <mailinglists@xgm.de> writes:
> what is the canonical way to modify indention for
> certain keywords? I've found numerous ways in the
> internets. I want to change the linux style so, that
> is does not do indention for namespaces.
I wrote a major mode [1] some times back (with a little
help from my friends, as always) and I remember I
wanted to have indentation just like in C because the
syntax was sort of, but not quite, as C.
So I wrote the following defun - perhaps it can be of
value to you:
(defun fpscalc-indent-line ()
"Indentation function."
(interactive)
(beginning-of-line)
(if (bobp) (indent-line-to 0)
(let ((not-indented t)
(cur-indent 0)
(indent-unit 2))
(if (looking-at "^[ \t]*}")
(progn
(save-excursion
(forward-line -1)
(setq cur-indent (- (current-indentation) indent-unit) ))
(if (< cur-indent 0) (setq cur-indent 0)) )
(save-excursion
(while not-indented
(forward-line -1)
(if (looking-at "^[ \t]*}")
(progn
(setq cur-indent (current-indentation))
(setq not-indented nil) )
(if (looking-at "^[ \t]*\\(system\\|declarations\\|semaphores\\|initialise\\|formulas\\)")
(progn
(setq cur-indent (+ (current-indentation) indent-unit))
(setq not-indented nil) )
(if (bobp) (setq not-indented nil) ))))))
(indent-line-to cur-indent) )))
Then somewhere:
(setq indent-line-function 'fpscalc-indent-line)
[1] project: http://user.it.uu.se/~embe8573/fps/
code: http://user.it.uu.se/~embe8573/fps/fpscalc.el
--
underground experts united:
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Modify indention for C/C++
2014-06-11 13:31 ` Florian Lindner
@ 2014-06-12 6:59 ` Kevin Rodgers
0 siblings, 0 replies; 6+ messages in thread
From: Kevin Rodgers @ 2014-06-12 6:59 UTC (permalink / raw)
To: help-gnu-emacs
On 6/11/14 7:31 AM, Florian Lindner wrote:
> Another question: (statement-case-open . +) Why is there a dot . in the middle
> of the clause?
M-: (info "(elisp)Cons Cells") ; C-s dotted
M-: (info "(elisp)Dotted Pair Notation")
Hope that helps,
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-06-12 6:59 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-11 13:24 Modify indention for C/C++ Florian Lindner
2014-06-11 13:31 ` Florian Lindner
2014-06-12 6:59 ` Kevin Rodgers
2014-06-11 13:42 ` Teemu Likonen
2014-06-11 14:23 ` Florian Lindner
[not found] <mailman.3406.1402493094.1147.help-gnu-emacs@gnu.org>
2014-06-11 15:07 ` Emanuel Berg
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.