unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Ergus <spacibba@aol.com>
To: emacs-devel@gnu.org
Cc: help-gnu-emacs@gnu.org
Subject: Re: C style alist question?
Date: Thu, 11 Apr 2019 03:16:59 +0200	[thread overview]
Message-ID: <20190411011659.zplon3n3lrtqmb2i@Ergus> (raw)
In-Reply-To: <837ec7bpe4.fsf@gnu.org>

(I send to both mailing lists because it is related with a previous
thread, but the right destination for this mail is the devels mailing
list)

Hi guys:

The issue I was facing with indentations was related actually with the
fact that once an offset is set (for example in the init file) it is
ignored in some cases by c-set-style because it is not "from style"
anymore.

Does it makes sense (or is not too difficult) to provide an option (or a
parameter in c-set-style) that allows the user to overwrite all the
previous offsets with the values from the new style, in spite of if it
is not "from style"? Maybe it already exist?

Another question:

Actually emacs C indentation with tabs follows the following policy:

It add as many tabs as possible and then align with spaces until the
desired column is reached.

====================
-------> is a tab
. is a space
====================

```
int function(int var1,
------->.....double b,
------->.....double c)
{
------->for (int i = 0; i < 10; ++i)
------->------->myprintf ("%d\n",
------->------->------->..i);
}
```

But other common policies around are:

1) add only tabs (and ignore the small mismatch in some cases)

int function(int var1,
------->double b,
------->double c)
{
------->for (int i = 0; i < 10; ++i)
------->------->myprintf ("%d\n",
------->------->------->i);
}

2) Use tabs (but only for indentation) and spaces to align

int function(int var1,
.............double b)
{
------->for (int i = 0; i < 10; ++i)
------->------->myprintf ("%d\n",
------->------->..........i);
}

The last one is specially useful in C++ where templates and long type
names usually forces to break functions and expressions (and templated
types inside functions declarations) on multiple lines; because they
keep the alignment in different editors (or different emacs with
different tab-width).

Is it some variable/policy or method to produce 1 or 2 with what is
already there??

Thanks in advance,
Ergus.

On Sat, Apr 06, 2019 at 09:48:19AM +0300, Eli Zaretskii wrote:
>> Date: Sat, 6 Apr 2019 05:26:38 +0200
>> From: Ergus <spacibba@aol.com>
>>
>> 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.
>
>Sorry, I don't understand what are "style alists" and the "official
>styles".  Please elaborate on that.
>
>> 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.
>
>Our style is defined by the .dir-locals.el file you see in the
>repository.  indent-tabs-mode is t only in Emacs Lisp mode.
>
>> So, is it possible to fix this in order to bring a better and easier
>> user initial experience with the right default values?
>
>Fix how?  Change our style?  I think that'd be a hard change to sell,
>because the current defaults were discussed several times and are a
>kind of compromise between different preferences, but you need to
>raise this on emacs-devel, not here.
>



       reply	other threads:[~2019-04-11  1:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20190406032636.7ftf2ua54uhy2k7e@Ergus>
     [not found] ` <837ec7bpe4.fsf@gnu.org>
2019-04-11  1:16   ` Ergus [this message]
2019-04-11  8:28     ` C style alist question? 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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190411011659.zplon3n3lrtqmb2i@Ergus \
    --to=spacibba@aol.com \
    --cc=emacs-devel@gnu.org \
    --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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).