unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* What's the line length limit in the Emacs codebase?
@ 2020-12-23  9:58 Philipp Stephani
  2020-12-23 15:42 ` Eli Zaretskii
  0 siblings, 1 reply; 25+ messages in thread
From: Philipp Stephani @ 2020-12-23  9:58 UTC (permalink / raw)
  To: Emacs developers

Hi,

There seem to be conflicting settings for the line length limit in the
Emacs codebase: .dir-locals.el sets fill-column to 70, but large areas
of the source code (including comments) seem to use 80. Can we pick
one value and use it consistently (for new/changed code)?

Thanks,
Philipp



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: What's the line length limit in the Emacs codebase?
  2020-12-23  9:58 What's the line length limit in the Emacs codebase? Philipp Stephani
@ 2020-12-23 15:42 ` Eli Zaretskii
  2020-12-23 16:55   ` Stefan Monnier
  2020-12-25 17:10   ` Philipp Stephani
  0 siblings, 2 replies; 25+ messages in thread
From: Eli Zaretskii @ 2020-12-23 15:42 UTC (permalink / raw)
  To: Philipp Stephani; +Cc: emacs-devel

> From: Philipp Stephani <p.stephani2@gmail.com>
> Date: Wed, 23 Dec 2020 10:58:32 +0100
> 
> There seem to be conflicting settings for the line length limit in the
> Emacs codebase: .dir-locals.el sets fill-column to 70, but large areas
> of the source code (including comments) seem to use 80. Can we pick
> one value and use it consistently (for new/changed code)?

70 is it, we just don't necessarily enforce it religously.

Where did you see significant deviations from that standard?



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: What's the line length limit in the Emacs codebase?
  2020-12-23 15:42 ` Eli Zaretskii
@ 2020-12-23 16:55   ` Stefan Monnier
  2020-12-23 21:21     ` Karl Fogel
  2020-12-25 17:11     ` Philipp Stephani
  2020-12-25 17:10   ` Philipp Stephani
  1 sibling, 2 replies; 25+ messages in thread
From: Stefan Monnier @ 2020-12-23 16:55 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Philipp Stephani, emacs-devel

>> There seem to be conflicting settings for the line length limit in the
>> Emacs codebase: .dir-locals.el sets fill-column to 70, but large areas
>> of the source code (including comments) seem to use 80. Can we pick
>> one value and use it consistently (for new/changed code)?
>
> 70 is it, we just don't necessarily enforce it religously.
>
> Where did you see significant deviations from that standard?

Indeed.  I'd say that we it's a kind of progressive limit:
- it's OK to have all lines ≤ 70-columns wide
- it's not OK to have most lines >70-columns
- we tolerate reaching the area between 70 and 80 columns every once in
  a while, tho.
- ≥80 columns OTOH should really be rare, limited to the exceptional
  cases where the alternative is really worse.


        Stefan




^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: What's the line length limit in the Emacs codebase?
  2020-12-23 16:55   ` Stefan Monnier
@ 2020-12-23 21:21     ` Karl Fogel
  2020-12-24  3:37       ` Eli Zaretskii
  2020-12-25 17:11     ` Philipp Stephani
  1 sibling, 1 reply; 25+ messages in thread
From: Karl Fogel @ 2020-12-23 21:21 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Eli Zaretskii, Philipp Stephani, emacs-devel

On 23 Dec 2020, Stefan Monnier wrote:
>Indeed.  I'd say that we it's a kind of progressive limit:
>- it's OK to have all lines ≤ 70-columns wide
>- it's not OK to have most lines >70-columns
>- we tolerate reaching the area between 70 and 80 columns every once in
>  a while, tho.
>- ≥80 columns OTOH should really be rare, limited to the exceptional
>  cases where the alternative is really worse.

Do we want this documented in CONTRIBUTE?



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: What's the line length limit in the Emacs codebase?
  2020-12-23 21:21     ` Karl Fogel
@ 2020-12-24  3:37       ` Eli Zaretskii
  0 siblings, 0 replies; 25+ messages in thread
From: Eli Zaretskii @ 2020-12-24  3:37 UTC (permalink / raw)
  To: Karl Fogel; +Cc: p.stephani2, monnier, emacs-devel

> From: Karl Fogel <kfogel@red-bean.com>
> Cc: Eli Zaretskii <eliz@gnu.org>,  Philipp Stephani <p.stephani2@gmail.com>,
>   emacs-devel@gnu.org
> Date: Wed, 23 Dec 2020 17:21:27 -0400
> 
> On 23 Dec 2020, Stefan Monnier wrote:
> >Indeed.  I'd say that we it's a kind of progressive limit:
> >- it's OK to have all lines ≤ 70-columns wide
> >- it's not OK to have most lines >70-columns
> >- we tolerate reaching the area between 70 and 80 columns every once in
> >  a while, tho.
> >- ≥80 columns OTOH should really be rare, limited to the exceptional
> >  cases where the alternative is really worse.
> 
> Do we want this documented in CONTRIBUTE?

Sounds too minor to be mentioned there.  CONTRIBUTE already has too
many minor details, which makes it harder to read and follow.

We have .dir-locals.el for that.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: What's the line length limit in the Emacs codebase?
  2020-12-23 15:42 ` Eli Zaretskii
  2020-12-23 16:55   ` Stefan Monnier
@ 2020-12-25 17:10   ` Philipp Stephani
  2020-12-25 19:04     ` Eli Zaretskii
  2020-12-26 10:24     ` Richard Stallman
  1 sibling, 2 replies; 25+ messages in thread
From: Philipp Stephani @ 2020-12-25 17:10 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Emacs developers

Am Mi., 23. Dez. 2020 um 16:42 Uhr schrieb Eli Zaretskii <eliz@gnu.org>:
>
> > From: Philipp Stephani <p.stephani2@gmail.com>
> > Date: Wed, 23 Dec 2020 10:58:32 +0100
> >
> > There seem to be conflicting settings for the line length limit in the
> > Emacs codebase: .dir-locals.el sets fill-column to 70, but large areas
> > of the source code (including comments) seem to use 80. Can we pick
> > one value and use it consistently (for new/changed code)?
>
> 70 is it, we just don't necessarily enforce it religously.
>
> Where did you see significant deviations from that standard?

Everywhere? When I last counted there were more than 1900 files in the
codebase that have lines longer than 70 characters. In src/emacs.c
alone there are over 160 such lines.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: What's the line length limit in the Emacs codebase?
  2020-12-23 16:55   ` Stefan Monnier
  2020-12-23 21:21     ` Karl Fogel
@ 2020-12-25 17:11     ` Philipp Stephani
  2020-12-25 17:43       ` Stefan Monnier
  2020-12-25 20:32       ` tomas
  1 sibling, 2 replies; 25+ messages in thread
From: Philipp Stephani @ 2020-12-25 17:11 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Eli Zaretskii, Emacs developers

Am Mi., 23. Dez. 2020 um 17:55 Uhr schrieb Stefan Monnier
<monnier@iro.umontreal.ca>:
>
> >> There seem to be conflicting settings for the line length limit in the
> >> Emacs codebase: .dir-locals.el sets fill-column to 70, but large areas
> >> of the source code (including comments) seem to use 80. Can we pick
> >> one value and use it consistently (for new/changed code)?
> >
> > 70 is it, we just don't necessarily enforce it religously.
> >
> > Where did you see significant deviations from that standard?
>
> Indeed.  I'd say that we it's a kind of progressive limit:
> - it's OK to have all lines ≤ 70-columns wide
> - it's not OK to have most lines >70-columns
> - we tolerate reaching the area between 70 and 80 columns every once in
>   a while, tho.
> - ≥80 columns OTOH should really be rare, limited to the exceptional
>   cases where the alternative is really worse.
>

This seems overly complicated, and people are unlikely to follow
complicated rules.
Let's just pick a number and stick to it consistently.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: What's the line length limit in the Emacs codebase?
  2020-12-25 17:11     ` Philipp Stephani
@ 2020-12-25 17:43       ` Stefan Monnier
  2020-12-26 11:02         ` Philipp Stephani
  2020-12-25 20:32       ` tomas
  1 sibling, 1 reply; 25+ messages in thread
From: Stefan Monnier @ 2020-12-25 17:43 UTC (permalink / raw)
  To: Philipp Stephani; +Cc: Eli Zaretskii, Emacs developers

> This seems overly complicated, and people are unlikely to follow
> complicated rules.

I don't think there is a need for a simplistic rule that is
strictly enforced.  Where have you seen such a need?

IOW, I'm not sure what problem you're trying to solve.

AFAIK we already enforce the complicated rule discretely by setting
`fill-column` to 70 in `.dir-locals.el` and by re-wrapping or
complaining about lines that pass the 80-column limit.


        Stefan




^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: What's the line length limit in the Emacs codebase?
  2020-12-25 17:10   ` Philipp Stephani
@ 2020-12-25 19:04     ` Eli Zaretskii
  2020-12-26 11:09       ` Philipp Stephani
  2020-12-26 10:24     ` Richard Stallman
  1 sibling, 1 reply; 25+ messages in thread
From: Eli Zaretskii @ 2020-12-25 19:04 UTC (permalink / raw)
  To: Philipp Stephani; +Cc: emacs-devel

> From: Philipp Stephani <p.stephani2@gmail.com>
> Date: Fri, 25 Dec 2020 18:10:50 +0100
> Cc: Emacs developers <emacs-devel@gnu.org>
> 
> > Where did you see significant deviations from that standard?
> 
> Everywhere? When I last counted there were more than 1900 files in the
> codebase that have lines longer than 70 characters. In src/emacs.c
> alone there are over 160 such lines.

You are counting long strings and lines with long URLs?  Is that
reasonable?



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: What's the line length limit in the Emacs codebase?
  2020-12-25 17:11     ` Philipp Stephani
  2020-12-25 17:43       ` Stefan Monnier
@ 2020-12-25 20:32       ` tomas
  2020-12-26 10:38         ` Michael Albinus
  2020-12-26 11:12         ` Philipp Stephani
  1 sibling, 2 replies; 25+ messages in thread
From: tomas @ 2020-12-25 20:32 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 671 bytes --]

On Fri, Dec 25, 2020 at 06:11:57PM +0100, Philipp Stephani wrote:

[...]

> This seems overly complicated, and people are unlikely to follow
> complicated rules.

I tend to disagree.

> Let's just pick a number and stick to it consistently.

That doesn't make much sense, IMO. Most of the time it's
easy to stick to the recommended 70. More often than not,
it even helps to nudge oneself into structuring code
better.

But sometimes (e.g. you have long string literals where
breaks don't make sense -- but there are other examples),
it is rather counterproductive to stick religiously to
that rule.

Honestly, I perceive Stefan's criteria as pretty natural.

Cheers
 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: What's the line length limit in the Emacs codebase?
  2020-12-25 17:10   ` Philipp Stephani
  2020-12-25 19:04     ` Eli Zaretskii
@ 2020-12-26 10:24     ` Richard Stallman
  2020-12-26 11:04       ` Philipp Stephani
  1 sibling, 1 reply; 25+ messages in thread
From: Richard Stallman @ 2020-12-26 10:24 UTC (permalink / raw)
  To: Philipp Stephani; +Cc: eliz, emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > > 70 is it, we just don't necessarily enforce it religously.
  > >
  > > Where did you see significant deviations from that standard?

  > Everywhere? When I last counted there were more than 1900 files in the
  > codebase that have lines longer than 70 characters. In src/emacs.c
  > alone there are over 160 such lines.

Why argue about how rigid to be?  Relax, please.

If you see a clean way to eliminate some of those overlong lines,
please do it.  That way, we will move towards having fewer annoyingly
long lines, and we will avoid the need to adopt a rule about it.

-- 
Dr Richard Stallman
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: What's the line length limit in the Emacs codebase?
  2020-12-25 20:32       ` tomas
@ 2020-12-26 10:38         ` Michael Albinus
  2020-12-26 11:17           ` Yuri Khan
  2020-12-26 18:31           ` Drew Adams
  2020-12-26 11:12         ` Philipp Stephani
  1 sibling, 2 replies; 25+ messages in thread
From: Michael Albinus @ 2020-12-26 10:38 UTC (permalink / raw)
  To: tomas; +Cc: emacs-devel

<tomas@tuxteam.de> writes:

Hi Tomas,

> But sometimes (e.g. you have long string literals where
> breaks don't make sense -- but there are other examples),
> it is rather counterproductive to stick religiously to
> that rule.

In Lisp code, I break such long strings into substrings, wrapped by concat.
Just for the better readability with 80 columns.

> Cheers
>  - t

Best regards, Michael.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: What's the line length limit in the Emacs codebase?
  2020-12-25 17:43       ` Stefan Monnier
@ 2020-12-26 11:02         ` Philipp Stephani
  2020-12-26 16:30           ` Stefan Monnier
  2020-12-27  5:38           ` Richard Stallman
  0 siblings, 2 replies; 25+ messages in thread
From: Philipp Stephani @ 2020-12-26 11:02 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Eli Zaretskii, Emacs developers

Am Fr., 25. Dez. 2020 um 18:43 Uhr schrieb Stefan Monnier
<monnier@iro.umontreal.ca>:
>
> > This seems overly complicated, and people are unlikely to follow
> > complicated rules.
>
> I don't think there is a need for a simplistic rule that is
> strictly enforced.  Where have you seen such a need?

Nowhere, it's more of a question. I don't intend to introduce a
strictly enforced rule, but just having a statement saying "stay
within 70 columns until there are good reasons (mostly long URLs)
otherwise" would provide some guidance to people editing the codebase.

>
> IOW, I'm not sure what problem you're trying to solve.

Line length is a typical bikeshedding problem that's best solved by
picking a number and then sticking to it.

>
> AFAIK we already enforce the complicated rule discretely by setting
> `fill-column` to 70 in `.dir-locals.el` and by re-wrapping or
> complaining about lines that pass the 80-column limit.
>

We could then change the complaining/re-wrapping to start at 71
columns and would achieve the same effect.

I don't think we need to change too much here, maybe nothing at all:
let's just use the 70-column limit more consistently from now on in
new/changed code.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: What's the line length limit in the Emacs codebase?
  2020-12-26 10:24     ` Richard Stallman
@ 2020-12-26 11:04       ` Philipp Stephani
  2020-12-26 18:43         ` Drew Adams
  0 siblings, 1 reply; 25+ messages in thread
From: Philipp Stephani @ 2020-12-26 11:04 UTC (permalink / raw)
  To: Richard Stallman; +Cc: Eli Zaretskii, Emacs developers

Am Sa., 26. Dez. 2020 um 11:24 Uhr schrieb Richard Stallman <rms@gnu.org>:
>
> [[[ To any NSA and FBI agents reading my email: please consider    ]]]
> [[[ whether defending the US Constitution against all enemies,     ]]]
> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
>
>   > > 70 is it, we just don't necessarily enforce it religously.
>   > >
>   > > Where did you see significant deviations from that standard?
>
>   > Everywhere? When I last counted there were more than 1900 files in the
>   > codebase that have lines longer than 70 characters. In src/emacs.c
>   > alone there are over 160 such lines.
>
> Why argue about how rigid to be?  Relax, please.
>
> If you see a clean way to eliminate some of those overlong lines,
> please do it.  That way, we will move towards having fewer annoyingly
> long lines, and we will avoid the need to adopt a rule about it.


I don't think we should reformat existing code, that just adds
annoying whitespace changes that make 'git blame' etc. unnecessarily
hard. What I'd propose would be to stick to the 70-column limit a bit
more consistently in new or changed code.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: What's the line length limit in the Emacs codebase?
  2020-12-25 19:04     ` Eli Zaretskii
@ 2020-12-26 11:09       ` Philipp Stephani
  2020-12-26 11:14         ` Eli Zaretskii
  0 siblings, 1 reply; 25+ messages in thread
From: Philipp Stephani @ 2020-12-26 11:09 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Emacs developers

Am Fr., 25. Dez. 2020 um 20:04 Uhr schrieb Eli Zaretskii <eliz@gnu.org>:
>
> > From: Philipp Stephani <p.stephani2@gmail.com>
> > Date: Fri, 25 Dec 2020 18:10:50 +0100
> > Cc: Emacs developers <emacs-devel@gnu.org>
> >
> > > Where did you see significant deviations from that standard?
> >
> > Everywhere? When I last counted there were more than 1900 files in the
> > codebase that have lines longer than 70 characters. In src/emacs.c
> > alone there are over 160 such lines.
>
> You are counting long strings and lines with long URLs?  Is that
> reasonable?

If you look at emacs.c, you'll see lots of lines that are not long
URLs etc., but e.g. comment blocks that could easily be reflowed, and
I was wondering why that didn't happen when these comments were
introduced.
Just to give some context, I became aware of this when editing various
parts of the Emacs codebase while having the fill column indicator
enabled. I then realized that large parts of the code seem to use an
80-column limit, while others seem to use a 70-column limit, and I was
wondering why that's the case.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: What's the line length limit in the Emacs codebase?
  2020-12-25 20:32       ` tomas
  2020-12-26 10:38         ` Michael Albinus
@ 2020-12-26 11:12         ` Philipp Stephani
  1 sibling, 0 replies; 25+ messages in thread
From: Philipp Stephani @ 2020-12-26 11:12 UTC (permalink / raw)
  To: tomas; +Cc: Emacs developers

Am Fr., 25. Dez. 2020 um 23:01 Uhr schrieb <tomas@tuxteam.de>:
>
> On Fri, Dec 25, 2020 at 06:11:57PM +0100, Philipp Stephani wrote:
>
> [...]
>
> > This seems overly complicated, and people are unlikely to follow
> > complicated rules.
>
> I tend to disagree.
>
> > Let's just pick a number and stick to it consistently.
>
> That doesn't make much sense, IMO. Most of the time it's
> easy to stick to the recommended 70. More often than not,
> it even helps to nudge oneself into structuring code
> better.

Then why don't we just do that (for new code)? Why do we need two limits?

>
> But sometimes (e.g. you have long string literals where
> breaks don't make sense -- but there are other examples),
> it is rather counterproductive to stick religiously to
> that rule.

I'm not talking about such special cases, but about normal code or
comment blocks that could easily be reflowed.

> Honestly, I perceive Stefan's criteria as pretty natural.

I don't.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: What's the line length limit in the Emacs codebase?
  2020-12-26 11:09       ` Philipp Stephani
@ 2020-12-26 11:14         ` Eli Zaretskii
  0 siblings, 0 replies; 25+ messages in thread
From: Eli Zaretskii @ 2020-12-26 11:14 UTC (permalink / raw)
  To: Philipp Stephani; +Cc: emacs-devel

> From: Philipp Stephani <p.stephani2@gmail.com>
> Date: Sat, 26 Dec 2020 12:09:17 +0100
> Cc: Emacs developers <emacs-devel@gnu.org>
> 
> > You are counting long strings and lines with long URLs?  Is that
> > reasonable?
> 
> If you look at emacs.c, you'll see lots of lines that are not long
> URLs etc., but e.g. comment blocks that could easily be reflowed, and
> I was wondering why that didn't happen when these comments were
> introduced.

History, I suppose.  I usually reformat any comment line around the
code I change when it's too long.  It's a slow process.

> Just to give some context, I became aware of this when editing various
> parts of the Emacs codebase while having the fill column indicator
> enabled. I then realized that large parts of the code seem to use an
> 80-column limit, while others seem to use a 70-column limit, and I was
> wondering why that's the case.

The value of fill-column is not for judging the length of code lines,
it's for comments and strings.  Code lines can use 80 lines, provided
that they are broken in reasonable places, and that the continuation
lines are indented consistently with the code structure.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: What's the line length limit in the Emacs codebase?
  2020-12-26 10:38         ` Michael Albinus
@ 2020-12-26 11:17           ` Yuri Khan
  2020-12-26 11:22             ` Michael Albinus
  2020-12-26 18:31           ` Drew Adams
  1 sibling, 1 reply; 25+ messages in thread
From: Yuri Khan @ 2020-12-26 11:17 UTC (permalink / raw)
  To: Michael Albinus; +Cc: tomas, Emacs developers

On Sat, 26 Dec 2020 at 17:39, Michael Albinus <michael.albinus@gmx.de> wrote:

> > But sometimes (e.g. you have long string literals where
> > breaks don't make sense -- but there are other examples),
> > it is rather counterproductive to stick religiously to
> > that rule.
>
> In Lisp code, I break such long strings into substrings, wrapped by concat.
> Just for the better readability with 80 columns.

I’m used to doing the same, but some coding style guides present a
good reason to avoid doing that[1]:

    6.2: Strings that cause the line to go over 100 characters
    should not be written across multiple lines using string concatenation.

    > Why? Broken strings are painful to work with
    > and make code less searchable.

[1]: https://github.com/airbnb/javascript#strings--line-length

I have actually found myself trying to grep for an error message ang
failing to find it in code at first try because it was line-broken at
a non-obvious point.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: What's the line length limit in the Emacs codebase?
  2020-12-26 11:17           ` Yuri Khan
@ 2020-12-26 11:22             ` Michael Albinus
  2020-12-26 11:36               ` Yuri Khan
  0 siblings, 1 reply; 25+ messages in thread
From: Michael Albinus @ 2020-12-26 11:22 UTC (permalink / raw)
  To: Yuri Khan; +Cc: tomas, Emacs developers

Yuri Khan <yuri.v.khan@gmail.com> writes:

Hi Yuri,

>> In Lisp code, I break such long strings into substrings, wrapped by concat.
>> Just for the better readability with 80 columns.
>
> I’m used to doing the same, but some coding style guides present a
> good reason to avoid doing that[1]:
>
>     6.2: Strings that cause the line to go over 100 characters
>     should not be written across multiple lines using string concatenation.
>
>     > Why? Broken strings are painful to work with
>     > and make code less searchable.
>
> [1]: https://github.com/airbnb/javascript#strings--line-length
>
> I have actually found myself trying to grep for an error message ang
> failing to find it in code at first try because it was line-broken at
> a non-obvious point.

Yes, it is always a trade-off. However, I'm failing to find error
messages in the code much more often because they are produced by
format, which could be banned for the same reason.

Best regards, Michael.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: What's the line length limit in the Emacs codebase?
  2020-12-26 11:22             ` Michael Albinus
@ 2020-12-26 11:36               ` Yuri Khan
  2020-12-26 12:21                 ` tomas
  0 siblings, 1 reply; 25+ messages in thread
From: Yuri Khan @ 2020-12-26 11:36 UTC (permalink / raw)
  To: Michael Albinus; +Cc: tomas, Emacs developers

On Sat, 26 Dec 2020 at 18:22, Michael Albinus <michael.albinus@gmx.de> wrote:

> >     6.2: Strings that cause the line to go over 100 characters
> >     should not be written across multiple lines using string concatenation.
> >
> >     > Why? Broken strings are painful to work with
> >     > and make code less searchable.
> >
> > [1]: https://github.com/airbnb/javascript#strings--line-length
> >
> > I have actually found myself trying to grep for an error message ang
> > failing to find it in code at first try because it was line-broken at
> > a non-obvious point.
>
> Yes, it is always a trade-off. However, I'm failing to find error
> messages in the code much more often because they are produced by
> format, which could be banned for the same reason.

When you see an error message, most of the time, it’s easy to see
which parts are constant text and which are substituted variable text.
Whereas line breaks could be anywhere.

When I break string literals to fit line length limits, I go for any
embedded \n first, then sentence boundaries, and only if that does not
bring the parts within limits, then phrase boundaries and
intra-sentence punctuation. This way, any run of text that contains no
punctuation or variable info has a high probability to be unbroken in
code.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: What's the line length limit in the Emacs codebase?
  2020-12-26 11:36               ` Yuri Khan
@ 2020-12-26 12:21                 ` tomas
  0 siblings, 0 replies; 25+ messages in thread
From: tomas @ 2020-12-26 12:21 UTC (permalink / raw)
  To: Yuri Khan; +Cc: Michael Albinus, Emacs developers

[-- Attachment #1: Type: text/plain, Size: 1016 bytes --]

On Sat, Dec 26, 2020 at 06:36:29PM +0700, Yuri Khan wrote:
> On Sat, 26 Dec 2020 at 18:22, Michael Albinus <michael.albinus@gmx.de> wrote:

[break long strings to honour max source line width]

> > > I have actually found myself trying to grep for an error message ang
> > > failing to find it in code at first try because it was line-broken at
> > > a non-obvious point.
> >
> > Yes, it is always a trade-off. However, I'm failing to find error
> > messages in the code much more often because they are produced by
> > format, which could be banned for the same reason.
> 
> When you see an error message, most of the time, it’s easy to see
> which parts are constant text and which are substituted variable text.
> Whereas line breaks could be anywhere.
> 
> When I break string literals to fit line length limits, I go for any
> embedded \n first, then sentence boundaries [...]

That' similar to what I do. Suffice it to say that these are often
moments of great agony :)

Cheers
 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: What's the line length limit in the Emacs codebase?
  2020-12-26 11:02         ` Philipp Stephani
@ 2020-12-26 16:30           ` Stefan Monnier
  2020-12-27  5:38           ` Richard Stallman
  1 sibling, 0 replies; 25+ messages in thread
From: Stefan Monnier @ 2020-12-26 16:30 UTC (permalink / raw)
  To: Philipp Stephani; +Cc: Eli Zaretskii, Emacs developers

>> > This seems overly complicated, and people are unlikely to follow
>> > complicated rules.
>> I don't think there is a need for a simplistic rule that is
>> strictly enforced.  Where have you seen such a need?
> Nowhere, it's more of a question.

It doesn't look like it.

> Line length is a typical bikeshedding problem that's best solved by
> picking a number and then sticking to it.

You do realize that this discussion you've started *is* bikeshedding, right?

We have picked a number and stuck to it, many many years ago.
That doesn't stop bikeshedding.  The only thing that stops bikeshedding
is to stop participating in the discussion.

You got the answer to your question, and you yourself admit that there
is no problem to solve.  So please let's stop here.


        Stefan




^ permalink raw reply	[flat|nested] 25+ messages in thread

* RE: What's the line length limit in the Emacs codebase?
  2020-12-26 10:38         ` Michael Albinus
  2020-12-26 11:17           ` Yuri Khan
@ 2020-12-26 18:31           ` Drew Adams
  1 sibling, 0 replies; 25+ messages in thread
From: Drew Adams @ 2020-12-26 18:31 UTC (permalink / raw)
  To: Michael Albinus, tomas; +Cc: emacs-devel

> In Lisp code, I break such long strings into 
> substrings, wrapped by concat.
> Just for the better readability with 80 columns.

+1



^ permalink raw reply	[flat|nested] 25+ messages in thread

* RE: What's the line length limit in the Emacs codebase?
  2020-12-26 11:04       ` Philipp Stephani
@ 2020-12-26 18:43         ` Drew Adams
  0 siblings, 0 replies; 25+ messages in thread
From: Drew Adams @ 2020-12-26 18:43 UTC (permalink / raw)
  To: Philipp Stephani, Richard Stallman; +Cc: Eli Zaretskii, Emacs developers

> I don't think we should reformat existing code, that just adds
> annoying whitespace changes that make 'git blame' etc. unnecessarily
> hard.

This has always been the argument.

My opinion doesn't count here, as I don't often diff
versions of the source code etc.

But the downside to avoiding such refactoring (yes,
it's a kind of refactoring, but it should have no
semantic import) is that the code gets messier, not
cleaner.

Presumably however, such whitespace-only changes
would typically be once-only.  (But sure, diffs
with any pre-change versions would have the noise
problem.)
___

That said, I don't have a problem with long lines,
personally.

The main advantage I personally see for short lines
is when I copy them into web pages, emails, etc. when
trying to help others or otherwise communicate in
contexts where the "box" for code has limited width,
and so wraps or requires horizontal scrolling when
lines are wider than the box.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: What's the line length limit in the Emacs codebase?
  2020-12-26 11:02         ` Philipp Stephani
  2020-12-26 16:30           ` Stefan Monnier
@ 2020-12-27  5:38           ` Richard Stallman
  1 sibling, 0 replies; 25+ messages in thread
From: Richard Stallman @ 2020-12-27  5:38 UTC (permalink / raw)
  To: Philipp Stephani; +Cc: eliz, monnier, emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > Nowhere, it's more of a question. I don't intend to introduce a
  > strictly enforced rule, but just having a statement saying "stay
  > within 70 columns until there are good reasons (mostly long URLs)
  > otherwise" would provide some guidance to people editing the codebase.

I think that's a good statement -- not rigid, and no need to argue
about how to "obey" it.
-- 
Dr Richard Stallman
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2020-12-27  5:38 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-23  9:58 What's the line length limit in the Emacs codebase? Philipp Stephani
2020-12-23 15:42 ` Eli Zaretskii
2020-12-23 16:55   ` Stefan Monnier
2020-12-23 21:21     ` Karl Fogel
2020-12-24  3:37       ` Eli Zaretskii
2020-12-25 17:11     ` Philipp Stephani
2020-12-25 17:43       ` Stefan Monnier
2020-12-26 11:02         ` Philipp Stephani
2020-12-26 16:30           ` Stefan Monnier
2020-12-27  5:38           ` Richard Stallman
2020-12-25 20:32       ` tomas
2020-12-26 10:38         ` Michael Albinus
2020-12-26 11:17           ` Yuri Khan
2020-12-26 11:22             ` Michael Albinus
2020-12-26 11:36               ` Yuri Khan
2020-12-26 12:21                 ` tomas
2020-12-26 18:31           ` Drew Adams
2020-12-26 11:12         ` Philipp Stephani
2020-12-25 17:10   ` Philipp Stephani
2020-12-25 19:04     ` Eli Zaretskii
2020-12-26 11:09       ` Philipp Stephani
2020-12-26 11:14         ` Eli Zaretskii
2020-12-26 10:24     ` Richard Stallman
2020-12-26 11:04       ` Philipp Stephani
2020-12-26 18:43         ` Drew Adams

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