[Babel-users] emacs and "babeld style"

Dave Taht dave at taht.net
Mon Nov 12 05:26:03 GMT 2018



Antonin Décimo <antonin.decimo at gmail.com> writes:

> The code _style_ of babeld is mostly sane. I've never had any problem
> with Emacs auto-guessing the code style, and I can't help you on Lisp
> incantations. Cpp rules can be ignored.

In my case I tend to rely on having a set of rules because of the sheer
number of codebases I deal with...

>
> Here are some ground rules, extrapolated from what I've seen.
>
> function types on their own line.

So far, I haven't found a way to make clang-format do that.

Is there another tool?

> function braces on their own line.
> break arguments at the first column after the opening parenthesis.
> opening brace for constructs such as for, while, must follow on the
>   same line.
> closing brace always on its own line.
> 4 spaces indent.
> declare variables at the beginning of a block (function ?)

All these clang-format can do.

Something that babeld does inconsistently is this:

     if(i < 0 || SRC_TABLE_NUM <= i)
-        return 0;
+       return 0;

8 space indent, but in this case lining up 7 spaces with the (

I think I've seen though

     for(i < 0 || SRC_TABLE_NUM <= i)
-        return 0;
+       return 0;

or the reverse

> there are a few util functions in util.h.

I so dearly want to inline v4mapped... it's 4 asm instructions when
done right, no memory refs....

> store the return code of a syscall into an "int rc" variable, and test
> that result.
> no trailing spaces.

I'd like a git commit filter for these

> fully qualified types (no typedef)

I miss typedefs. Also I find "unsigned char", so 80s. "u8" induces
less cognitive overload and saves on typing.

> no bugs (enforced in the code style).

I note that I tend to write a lot of buggy code while seeking a solution
to something, and tend to share that (or inflict it) on others, while
making a lot of oft-useless noise (think, a pilot in a crash situation
shares every detail of the crash in the hope of saving future pilots)

I think juliusz often opens up his inbox with mail from me... with
dread.

> do loop-free routing.

Hah. :)

I note that babel doesn't actually do that, any more. All the distros
seem to have been putting in custom metrics for things like dhcp. So
for example, my latest ubuntu creates a default route with a metric of
100.

Babel inserts a default route with zero... but then when it retracts it
, gives it a metric of infinity, so the existing default route metric
100, wins.

(this is sort of why I suggested a few weeks ago we stop changing the
 metric when going unreachable)

>
> A commit message begins with an uppercase letter and ends with a dot.

Good to know.

>
>
> Beware the moment when you stop editing in Emacs, but Emacs starts
> editing *you*.

It's good to be spending more time in emacs. This email (on this account
was written in gnus. I just put a znc bouncer up for irc...




More information about the Babel-users mailing list