Indentation style (was: [PATCH] notmuch-dump.c: Fix output file being closed twice)

classic Classic list List threaded Threaded
10 messages Options
Ralph Seichter-2 Ralph Seichter-2
Reply | Threaded
Open this post in threaded view
|

Indentation style (was: [PATCH] notmuch-dump.c: Fix output file being closed twice)

* David Bremner:

> I did have to revert one unrelated whitespace change.

I knew I might run afoul of that the minute I read "Indent is 4 spaces
with mixed tab/spaces and a tab width of 8" in the code style notes. ;-)

In my experience, it is error-prone to mix tabs and spaces. Perhaps it
would be useful to change to all spaces? Also, with an added editor mode
line, supporting that style would be more convenient (for Emacs and Vim
at least).

-Ralph
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|

Re: Indentation style (was: [PATCH] notmuch-dump.c: Fix output file being closed twice)

Ralph Seichter <[hidden email]> writes:

> * David Bremner:
>
>> I did have to revert one unrelated whitespace change.
>
> I knew I might run afoul of that the minute I read "Indent is 4 spaces
> with mixed tab/spaces and a tab width of 8" in the code style notes. ;-)
>
> In my experience, it is error-prone to mix tabs and spaces. Perhaps it
> would be useful to change to all spaces? Also, with an added editor mode
> line, supporting that style would be more convenient (for Emacs and Vim
> at least).

We're using more or less the default for Emacs (you can see the details
in .dir-locals.el).  I'm a bit dubious that we want to re-whitespace
everything, but I'd certainly be receptive to matching configuration for
other editors. Does anyone know if vim indentation can be configured per
project / directory?

d
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Thomas Schneider Thomas Schneider
Reply | Threaded
Open this post in threaded view
|

Re: Indentation style

David Bremner <[hidden email]> writes:

> We're using more or less the default for Emacs (you can see the details
> in .dir-locals.el).

Maybe I misunderstood, but this doesn’t really look like Emacs’ defaults
for C.

> I'm a bit dubious that we want to re-whitespace everything, but I'd
> certainly be receptive to matching configuration for other
> editors. Does anyone know if vim indentation can be configured per
> project / directory?

Yes, if you let Vim parse a per-directory .vimrc (similar to forbidding
Emacs to parse .dir-locals.el).

While we’re at it, how about a generic .editorconfig?  The world isn’t
split into good people and dea… uh, Emacs and Vim.

        --qsx
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Daniel Kahn Gillmor Daniel Kahn Gillmor
Reply | Threaded
Open this post in threaded view
|

Re: Indentation style

On Mon 2019-07-29 00:19:48 +0200, Thomas Schneider wrote:
> Maybe I misunderstood, but this doesn’t really look like Emacs’ defaults
> for C.

I think the question is less "emacs defaults" vs. "consistency with the
current codebase".

> While we’re at it, how about a generic .editorconfig?  The world isn’t
> split into good people and dea… uh, Emacs and Vim.

Anyone who submits a .editorconfig that allows us to drop .dir-locals.el
would get enthusiastic support from me.  notmuch has been a very
emacs-focused project for years, but it doesn't need to be, and generic
editor configuration rules are preferable to editor-specific rules.

here's what i suspect such an editorconfig would look like given our
current codebase, but i haven't tested it or tried to apply the changes
to the notmuch codebase and see if it changes anything.

----------------------
root = true
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8

[*.{c,h,cpp,sh,el}]
tab_width = 8
indent_style = tab
indent_size = 4
----------------------

That said, i don't know how to represent (fill-column . 70) in
editorconfig syntax (see e0d85656da7f4d6e7d0b66a7bece39724143bffe for
justification), or (c-file-style . "linux").

(fwiw, i would also be happy if we moved away from literal tabs and just
used spaces-only.  But i am not interested in setting off a flamewar,
so if anyone prefers the mixed-tabs-and-spaces situation we are in
today, i will never mention this again)

       --dkg


_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch

signature.asc (233 bytes) Download Attachment
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|

Re: Indentation style

In reply to this post by Thomas Schneider
Thomas Schneider <[hidden email]> writes:

> David Bremner <[hidden email]> writes:
>
>> We're using more or less the default for Emacs (you can see the details
>> in .dir-locals.el).
>
> Maybe I misunderstood, but this doesn’t really look like Emacs’ defaults
> for C.

Right, I should have been more precise, using tabs at the beginning of
the line, with tab-width 8, followed by less than 8 spaces is the emacs
default.

>
> Yes, if you let Vim parse a per-directory .vimrc (similar to forbidding
> Emacs to parse .dir-locals.el).
>
> While we’re at it, how about a generic .editorconfig?  The world isn’t
> split into good people and dea… uh, Emacs and Vim.

Sure, if someone is willing to provide .vimrc / .editorconfig, and
support it at least till we shake the bugs out, then I'm happy to
include them.

d
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|

Re: Indentation style

In reply to this post by Daniel Kahn Gillmor
Daniel Kahn Gillmor <[hidden email]> writes:

>
> (fwiw, i would also be happy if we moved away from literal tabs and just
> used spaces-only.  But i am not interested in setting off a flamewar,
> so if anyone prefers the mixed-tabs-and-spaces situation we are in
> today, i will never mention this again)
>

I mostly don't care, but the diff this would generate is daunting.

d
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Tomi Ollila-2 Tomi Ollila-2
Reply | Threaded
Open this post in threaded view
|

Re: Indentation style

In reply to this post by Daniel Kahn Gillmor
On Sun, Jul 28 2019, Daniel Kahn Gillmor wrote:

>
> (fwiw, i would also be happy if we moved away from literal tabs and just
> used spaces-only.  But i am not interested in setting off a flamewar,
> so if anyone prefers the mixed-tabs-and-spaces situation we are in
> today, i will never mention this again)

I like mixed tabs and spaces. for example cursor moves faster...

>
>        --dkg

Tomi
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Daniel Kahn Gillmor Daniel Kahn Gillmor
Reply | Threaded
Open this post in threaded view
|

Re: Indentation style

On Tue 2019-07-30 00:23:16 +0300, Tomi Ollila wrote:
> On Sun, Jul 28 2019, Daniel Kahn Gillmor wrote:
>> (fwiw, i would also be happy if we moved away from literal tabs and just
>> used spaces-only.  But i am not interested in setting off a flamewar,
>> so if anyone prefers the mixed-tabs-and-spaces situation we are in
>> today, i will never mention this again)
>
> I like mixed tabs and spaces. for example cursor moves faster...

Consider my proposal withdrawn :)

         --dkg

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch

signature.asc (233 bytes) Download Attachment
Ralph Seichter-2 Ralph Seichter-2
Reply | Threaded
Open this post in threaded view
|

Re: Indentation style

In reply to this post by Tomi Ollila-2
* Tomi Ollila:

> I like mixed tabs and spaces. for example cursor moves faster...

If that's the case, you're just not using the right keys to move around
the source code. :-) In Vim, keys like W/B, +/- etc. ignore whitespaces
anyway, and Emacs has equivalents. Rumour has it there are other editors
out in the wild, but then, some people believe anything... ;-)

I am aware this is a sensitive subject, but looking at the last 35+
years, I personally found that the only reliable way to avoid whitespace
related hassle is to stick to spaces only. I am not in a position to
decide this, of course, but I am glad that Python [1] even comes with a
command line option which turns mixed indentation into errors, making it
easy to spot these situations.

-Ralph

[1] https://www.python.org/dev/peps/pep-0008/#tabs-or-spaces
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Tomi Ollila-2 Tomi Ollila-2
Reply | Threaded
Open this post in threaded view
|

Re: Indentation style

On Tue, Jul 30 2019, Ralph Seichter wrote:

> * Tomi Ollila:
>
>> I like mixed tabs and spaces. for example cursor moves faster...
>
> If that's the case, you're just not using the right keys to move around
> the source code. :-) In Vim, keys like W/B, +/- etc. ignore whitespaces
> anyway, and Emacs has equivalents.

Perhaps... I just use arrow keys (no longer need to press c-p, c-n, c-b,
c-f so often ;D) and I can intuitively estimate how to use the keys to get
to a certain row-col position in emacs buffer -- and w/ tabs that usually
requires less keypresses... I've sometimes pressed M-b and M-f to move
over words but...

That's what leads to my opinion, which may or may not be general truth >;)


> Rumour has it there are other editors
> out in the wild, but then, some people believe anything... ;-)
>
> I am aware this is a sensitive subject, but looking at the last 35+
> years, I personally found that the only reliable way to avoid whitespace
> related hassle is to stick to spaces only.

I have only 30 years of experience in this (in 80's I did not have access
such machines where this would have been issue), so I have not had much
hassle with this (only when someone decides that tabs have only 4 character
width)

> I am not in a position to decide this, of course,

usually status quo prevails unless there is enough desire to change things
(preferably with good patches, when applicable)...

> but I am glad that Python [1] even comes with a
> command line option which turns mixed indentation into errors, making it
> easy to spot these situations.

What I've noticed python3 always fails if there is mixed tabs and spaces
used for indentation (used mg(1) in embedded device to patch python file);
I don't know whether indentation w/ tabs only would have worked there...

>
> -Ralph
>
> [1] https://www.python.org/dev/peps/pep-0008/#tabs-or-spaces

Hmm, pep8(1) has originally been checking just tabs and spaces?
No wonder it is being renamed to pycodestyle :D

Tomi

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch