Re: c*-mode-agnostic basic-offset value

Alan Mackenzie <[email protected]> Thu, 4 Jul 2024 11:17:31 +0000
Newsgroups gmane.emacs.cc-mode.general
Message-ID <ZoaEy0DbUmVTHXR6@ACM>
Hello, JD.

Thanks for your post!

On Tue, Jul 02, 2024 at 11:32:45 -0400, JD Smith wrote:
>    I am the author of indent-bars[1], a mode providing indentation bars
>    across modes.  For its operation, indent-bars requires knowledge of the
>    indentation offset, and uses a heuristic to discover that information.


>    For c-modes it currently does a simple (in a large cond):

>    ((and (local-variable-p 'c-basic-offset) (numberp c-basic-offset))
>        c-basic-offset)

>    But that fails to gather the needed information for various
>    auto-configuration examples like 'set-from-style.   Can anyone
>    recommend a simple configuration that will work reliably across all the
>    various c*-modes and their various style options?  Indent-bars just
>    needs to know the indent multiple (2 chars, 4 chars, 8 chars???).  This
>    code runs in a hook like prog-mode-hook (or equivalent mode-specific
>    hooks) so initialization should already be done.

I'm a little puzzled as to what's going on.  In a fully initialised CC
Mode buffer, c-basic-offset should be a number, such as 2, 4, or 8.  Are
you evaluating that large cond before C Mode is fully initialised,
somehow?  I think (though I'm not quite sure) that c-basic-offset should
be set up before the mode hooks (including prog-mode-hook) get run.

Is there some way I can access indent-bars without having to allow
github's Javascript access to my machine?

It would be useful for me to be able to try to reproduce the bug.  Is
there anything else I need to know for this beyond what you've already
said (i.e. call indent-bars from a major mode hook)?

>    Thanks for the help.

>    [1] [1]https://github.com/jdtsmith/indent-bars

> References

>    1. https://github.com/jdtsmith/indent-bars

-- 
Alan Mackenzie (Nuremberg, Germany).