On 2016-11-03, Kenny McCormack <
gaz...@shell.xmission.com> wrote:
> In article <
201611031...@kylheku.com>,
> Kaz Kylheku <
221-50...@kylheku.com> wrote:
> ...
>>
>>
http://www.kylheku.com/cgit/c-snippets/tree/autotab.c
>>
>>I got used to two character indents from coding in Lisp.
>>
>>Incidentally, autotab.c is a utility that calculates Vim indentation
>>settings based on sampling the file you're about to edit.
>>
>>With this, I instantly conform to the style of the given file
>>without having to fiddle with expandtab, tabstop and shiftwdith.
>
> This looks interesting. However, a couple of questions:
>
> 1) Do you provide any easier way to get (download) it? I tried first
> with 'wget' and got a file full of HTML garbage.
Try following CGIT's "plain" link: that serves up a raw form of it,
by navigating you to this URL:
http://www.kylheku.com/cgit/c-snippets/plain/autotab.c
^^^^^
CGIT also lets you download tarball snapshots from the main
page of a repo:
http://www.kylheku.com/cgit/c-snippets/
See the autotab-5.tar.gz links (also .zip and .bz2). These are generated
for all tags. Also any version you navigate to has downlaod links of the
form <160bit-hex-SHA1>.tar.gz, etc.
It's very friendly for people who don't have git installed or don't know
how/care to use it.
> $ wc autotab.c
> 766 2795 19479 autotab.c
That's what I get in my dev sandbox of that repo.
>
> 2) I'm a little surprised at how long/complex the code is. Care to say
> anything about how it came to be in its current form?
Shrug. The first git version (003) is 742 lines already and not
that different from the current verison. The first 200-300 lines of it
is support code: linked list of strings stuff, and tokenizing and
whatnot.
The logic is the way it is because this is a task which requires
a modicum of cunning. From the very beginning, it resembled its
current form; it didn't start out as some 100 line hack that grew.
At the time I wrote it, I was putting together a from-scratch embedded
Linux distro with quite a few packages, and had to go "down to the
elbows" in many of them, and the kernel of course, to patch many things.
It was a a PITA always adjusting the editor to match the indentation
style, not to mention figuring out what to adjust it to.
Amidst this distro work, I had a wide range of real-world test cases for
autotab. Over a period of some time, I tweaked it based on not getting
the right sort of behavior on this file or that until those situations
were rare enough not to care about. Those tweaks weren't large additions
to the code or rewrites.