From: Ergus <spacibba@aol.com>
To: help-gnu-emacs@gnu.org
Subject: C style alist question?
Date: Sat, 6 Apr 2019 05:26:38 +0200 [thread overview]
Message-ID: <20190406032636.7ftf2ua54uhy2k7e@Ergus> (raw)
Hi all:
I usually edit code in two styles; the linux kernel style and now the
emacs style. But I have seen that there are some mismatches between the
style alists and the "official" styles. Which is very uncomfortable when
I need to switch constantly or I have open different styled files at the
same time because I set some variables that then are not taken from the
style.
In the emacs wiki (I know is not official, but is the first we use
because there are more examples to copy-paste-test) they set some of the
variables outside the style, so when the user switches he gets a wrong
style.
For example:
When I open an emacs' C source code I see details like the fill-column
is 70 instead of 78.
In the kernel style the indent-tabs-mode is not set to t.
So, is it possible to fix this in order to bring a better and easier
user initial experience with the right default values?
In fact in the linux kernel coding style page there is a fix for the
default style that has been there for years:
```
(defun c-lineup-arglist-tabs-only (ignored)
"Line up argument lists by tabs, not spaces"
(let* ((anchor (c-langelem-pos c-syntactic-element))
(column (c-langelem-2nd-pos c-syntactic-element))
(offset (- (1+ column) anchor))
(steps (floor offset c-basic-offset)))
(* (max steps 1)
c-basic-offset)))
(add-hook 'c-mode-common-hook
(lambda ()
;; Add kernel style
(c-add-style
"linux-tabs-only"
'("linux" (c-offsets-alist
(arglist-cont-nonempty
c-lineup-gcc-asm-reg
c-lineup-arglist-tabs-only))))))
(add-hook 'c-mode-hook
(lambda ()
(let ((filename (buffer-file-name)))
;; Enable kernel mode for the appropriate files
(when (and filename
(string-match (expand-file-name "~/src/linux-trees")
filename))
(setq indent-tabs-mode t)
(setq show-trailing-whitespace t)
(c-set-style "linux-tabs-only")))))
```
I know all this can be customized by the user, (now I know more or less
how). But in the beginning it was a bit difficult to start, and still
there are some details that takes a lot of time to know how to
configure.
For example: c-lineup-gcc-asm-reg, c-lineup-close-parenm,
c-lineup-arglist-intro-after-paren... what are those, where are them?
But also: what's the point with bringing a linux style that needs to be
fixed by all the users that needs it?
Could anyone help me to fix this, or fix the defaults in Emacs to follow
the specifications?
What's the recommended configuration when we need to switch constantly?
Because now as I set the tabwidth and the indent-style outside a style,
when I switch I only get a mixed useless style.
Thanks in advance
Ergus.
next reply other threads:[~2019-04-06 3:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-06 3:26 Ergus [this message]
2019-04-06 4:10 ` C style alist question? Óscar Fuentes
2019-04-06 6:48 ` Eli Zaretskii
2019-04-11 1:16 ` Ergus
2019-04-11 8:28 ` Alan Mackenzie
2019-04-11 14:22 ` Eli Zaretskii
2019-04-11 15:00 ` Ergus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190406032636.7ftf2ua54uhy2k7e@Ergus \
--to=spacibba@aol.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.