From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.devel Subject: Re: Allow indentation styles by use of function in tree-sitter Date: Mon, 7 Nov 2022 01:13:28 -0800 Message-ID: References: <871qqgjldz.fsf@thornhill.no> <68532D98-E888-4F12-8C20-8CAA911C7D8B@gmail.com> <87y1sni489.fsf@thornhill.no> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39891"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Theodor Thornhill Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Nov 07 10:14:17 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oryCv-000A6h-Mo for ged-emacs-devel@m.gmane-mx.org; Mon, 07 Nov 2022 10:14:17 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oryCF-0001fR-RC; Mon, 07 Nov 2022 04:13:35 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oryCD-0001es-NA for emacs-devel@gnu.org; Mon, 07 Nov 2022 04:13:33 -0500 Original-Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oryCC-00017n-84 for emacs-devel@gnu.org; Mon, 07 Nov 2022 04:13:33 -0500 Original-Received: by mail-pj1-x102c.google.com with SMTP id b1-20020a17090a7ac100b00213fde52d49so9708720pjl.3 for ; Mon, 07 Nov 2022 01:13:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=3EAttSozGTpOFf3ivp9RFrAhx8dtmZxtdXLsSPPqQfM=; b=BOzaSXEFT3922acLOlE9qE1jKojx8t17TNJsD4easU4Jwn7ELFNGydtd0/MYHS+Yqn o0TlvtjZfHwRYYastR51LgF75ghny2LQnpt8OG472Fp24T8HD5A//rF/KREhv5/d8wPX gU6lIMtd/IxRUGc6U1QStot7NbjvVSN7Vpv8u2wpaD1CoR3CQ5KYG9QRrhpY0bOlBava upBmp8lSSU7SilEv2xID+cPvJftzdI3rGaAwnJPO/PonzcWDeiXzsdYpgCiQPYhgV2Xg xQhcdXpZakrrTVaecW/WNjQiQ5OTnQRv5KmyN7FLrSsrbN4bEFpP6By4CDG6+h5ONl9m gy1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3EAttSozGTpOFf3ivp9RFrAhx8dtmZxtdXLsSPPqQfM=; b=h5pKVso8Gr3cntlC//k2bfMRktm/rt+T/UZIo8CjqCg8A9MrLDwxSQqXH6qXj7NfRW hjrMQWYtOV5XxraP8J0F75+z2JBqExguKo/K2nI39YPw20XMFSatxz4sKKdNjTLitAIZ KStuICsN/diC8ab+QHBq0Lo/Qgic8MUAQ+CNOzuqscsJB4pRnmwopkUSclul3to/celN WjtDucBC///6jhBTYVt0Wg3eOGhM1qzeF4JP/YFsJdYGzZjWVGfhbxmGOSt1270Ma9PT 4Do1/SP4QzHAYvXf/t1uWHICja7Iin7y03YyAWMXdDqTjYWzf4h1qLEmYA7i/rX05QV7 iCig== X-Gm-Message-State: ACrzQf0DOtuoFcu6TJhXTfFFM9w1rnO92/CZ86h4qK06x6koQwPiSkcM 2QQiR5BUUs3IEdj/cpB+ZrIgdPUPI5o= X-Google-Smtp-Source: AMsMyM60Md3u0l2JRL18eZ0oSQjNvE5lC5YyE7RYdDCxBFOq0cju0T6FwP8TySSsRtl3ryGA2PeFrw== X-Received: by 2002:a17:90a:b8f:b0:213:c985:b5e5 with SMTP id 15-20020a17090a0b8f00b00213c985b5e5mr45921987pjr.57.1667812410501; Mon, 07 Nov 2022 01:13:30 -0800 (PST) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id ik12-20020a170902ab0c00b00187197c499asm4525900plb.164.2022.11.07.01.13.29 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Nov 2022 01:13:30 -0800 (PST) In-Reply-To: <87y1sni489.fsf@thornhill.no> X-Mailer: Apple Mail (2.3696.120.41.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=casouri@gmail.com; helo=mail-pj1-x102c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:299284 Archived-At: > On Nov 7, 2022, at 12:00 AM, Theodor Thornhill = wrote: >=20 > Yuan Fu writes: >=20 >>> On Nov 6, 2022, at 4:52 AM, Theodor Thornhill = wrote: >>>=20 >>>=20 >>> Hi Yuan! >>>=20 >>> I was thinking that a quick way to enable indentation styles and >>> customizable indentation styles is to also accept a function in >>> tree-sitter-simple-indent. >>>=20 >>> What do you think of the suggested patch? >>>=20 >>> That would allow a defcustom such as >>> ``` >>> (defcustom c-ts-mode-indent-rule-function = #'c-ts-mode--some-specific-style >>> "Indentation style of choice" >>> :group 'c) >>> ``` >>>=20 >>> and in the major-mode init: >>> ``` >>> (setq-local treesit-simple-indent-rules = c-ts-mode-indent-rule-function) >>> ``` >>=20 >> Hmmm, does assigning treesit-indent-function fit the bill? >>=20 >=20 > I might be misunderstanding what you mean, but I don't want to change > the architecture, I just want the user to set their own as a > customization option in a major mode. The function will just return = the > same stuff as it does now, but with a function as an available option > that will be a little more flexible. See [0] for an example. The = user > can just set [1] to change the indent style. A quick workaround could > be that each major mode just does this: > ``` > (setq-local treesit-simple-indent-rules > (funcall c-ts-mode-indent-rule-function)) > ``` > But that is a little less nice :-) Ah, I see what you mean. I think funcall is perfectly fine. I also think = you can just define those styles as variables and use symbol-value. Yuan=