Page MenuHomeFreeBSD

tools/tools/editing/freebsd.el: Add support for tree-sitter modes
AcceptedPublic

Authored by jrm on Fri, May 15, 2:41 AM.
Tags
None
Referenced Files
F157620880: D57008.diff
Sat, May 23, 12:33 PM
Unknown Object (File)
Tue, May 19, 5:35 PM
Unknown Object (File)
Tue, May 19, 5:35 PM
Unknown Object (File)
Tue, May 19, 5:35 PM
Unknown Object (File)
Tue, May 19, 5:35 PM
Unknown Object (File)
Tue, May 19, 5:35 PM
Unknown Object (File)
Tue, May 19, 5:35 PM
Unknown Object (File)
Tue, May 19, 5:35 PM

Details

Reviewers
cracauer
Summary
  • Add custom indent rules to implement the style(9) 4-space continuation indent for argument lists, parameter lists, multi-line expressions, and variable initializations.
  • Rename the interactive function from bsd to freebsd to avoid a name collision with c-ts-mode's built-in 'bsd style symbol.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 73121
Build 70004: arc lint + arc unit

Event Timeline

jrm requested review of this revision.Fri, May 15, 2:41 AM

Another minor comment tweak.

This revision is now accepted and ready to land.Fri, May 15, 11:39 AM
(defconst knf-c-style
  '((c-basic-offset . 8)
    (c-comment-only-line-offset . 0)
    (c-offsets-alist . ((statement-block-intro . +)
                        (knr-argdecl-intro . +)
                        (substatement-open . 0)
                        (label . 0)
                        (statement-cont . +)
                        (inline-open . 0)
                        (inexpr-class . 0)
                        (statement-cont . *)
                        (arglist-cont . *)
                        (arglist-cont-nonempty *))))
  "BSD KNF")
(c-add-style "knf" knf-c-style)

is what I use.

Thanks for sharing. I'm going to spend more time testing these three configurations (@imp's, the classic one in freebsd.el, and the tree-sitter configuration) by opening lots of source files and doing things like C-M-\.

Here’s mine if it helps with any ideas: https://git.sr.ht/~patmaddox/lab/tree/trunk/item/dotfiles/emacs/lisp/freebsd-style-ts.el

;; C/C++ (FreeBSD style(9))
(require 'freebsd-style-ts)
(add-hook 'c-ts-mode-hook 'freebsd-c-style-ts)
(add-hook 'c++-ts-mode-hook 'freebsd-c-style-ts)

I’ve also got a test suite for formatting languages I use: https://git.sr.ht/~patmaddox/lab/tree/trunk/item/dotfiles/emacs/tests.sh

Lastly, I had proposed a patch for simplifying tree-sitter grammar builds (and also getting a lot more grammars): https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=292973 I don’t know if there’s interest in switching grammar sources, or perhaps adding it as a second option, but I’ve been using it and it’s working well so far.