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: c-ts-mode style customization Date: Thu, 23 Mar 2023 16:44:31 -0700 Message-ID: References: <87355wu4hn.fsf@dancol.org> <45CB19FB-4D80-4C71-8083-D836F51DFB49@gmail.com> <1870bc95688.2829.cc5b3318d7e9908e2c46732289705cb0@dancol.org> <1870cd213f8.2829.cc5b3318d7e9908e2c46732289705cb0@dancol.org> <79B5F13D-6718-4B47-9CDA-485A07AF36BC@gmail.com> <187104b7b78.2829.cc5b3318d7e9908e2c46732289705cb0@dancol.org> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.400.51.1.1\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34788"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Daniel Colascione Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Mar 24 01:18:36 2023 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 1pfV8e-0008mP-Jc for ged-emacs-devel@m.gmane-mx.org; Fri, 24 Mar 2023 01:18:36 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pfV7l-00066O-2E; Thu, 23 Mar 2023 20:17:41 -0400 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 1pfV7j-00065s-6v for emacs-devel@gnu.org; Thu, 23 Mar 2023 20:17:39 -0400 Original-Received: from mail-oi1-x22f.google.com ([2607:f8b0:4864:20::22f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pfV7g-0002ab-WB for emacs-devel@gnu.org; Thu, 23 Mar 2023 20:17:38 -0400 Original-Received: by mail-oi1-x22f.google.com with SMTP id bk5so184364oib.6 for ; Thu, 23 Mar 2023 17:17:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679617056; 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=zt+mNwFVvFuf9kBpgcwdlW3wF1zyMJv1+JP1NZa65D0=; b=bJMNZNnRQIQGMP8NHjTPESpwyAvmh5t5zKy7F9POdWORANQqxvJehiDVbbkaHvcz5l P/HQNrf9cTRTglP0iJK03ycd3pk5MIG2gTEw3Ml0eIZhKxeuwIikN6W7LnLRsEzUsyQI 527/HxnT9GbE4BFoYqsRcu9hQTC+8bNo0BFJiQWiltxRDNhwYyxoxz5tmXVLzylfFi0t gXWlbn3stJEJc8vAZyviPz23Bdp20MoQGtojrMtqvqBWnykUyRmkKBl9s/4l0heZfYwq F4ljcDGutF3Qi5pgaUycnyIFmSOVC1hQkJ2wHxk8VZU9e2ANHI6nvStc1GAWkkkFjosP iGpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679617056; 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=zt+mNwFVvFuf9kBpgcwdlW3wF1zyMJv1+JP1NZa65D0=; b=hDJFfl4NhA/xEVe8MS4Y8K43R5OmrS0y37j7pCgHGkCEOzfLFLQAKqdDhLmsiIAmY7 nRyBMJNdvjrmDWWiHq8+cIL0U440Z2VrKigLUXvHvxk8KyFu3NJEH4l/hEYydUbwa08L +kyDgeNbpXiQiD7G54qBTlUoxTUeuYj1XgBaP2knJojVhIB02ZLCSfQT8AK6wHqqWylb GOFBYcQqMbRJ4/FcpOY7qPlKgyc/obvJrtQM3xFvBecEhVX1ek/hKrf3HTFg5yZ/qq07 dG56TXhZd0/uuXSHo/SQjG4yK5yqkl93yD3OuYXdFz9TBR+IiPJk4uMUwJArmYJfQ2eZ uH2A== X-Gm-Message-State: AO0yUKVsXe3LdwRxN+5wJyohor1DdFlKj2yMT5A0sB/KIY1Ou97ImmTc JcxaBdUeab2YM7IF3kOTrhzZ/+UM56A= X-Google-Smtp-Source: AKy350Y9OTophAnQJ45s1mAB4GMT2Yw1uEfs96X0sGXzyPHVrb4fpNH3FLX3p7dUUWjy/B68SDjhsQ== X-Received: by 2002:a17:90b:4c86:b0:237:c565:7bc6 with SMTP id my6-20020a17090b4c8600b00237c5657bc6mr727905pjb.10.1679615083462; Thu, 23 Mar 2023 16:44:43 -0700 (PDT) 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 e15-20020a17090ac20f00b0023fa2773aa5sm1811204pjt.26.2023.03.23.16.44.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Mar 2023 16:44:43 -0700 (PDT) In-Reply-To: <187104b7b78.2829.cc5b3318d7e9908e2c46732289705cb0@dancol.org> X-Mailer: Apple Mail (2.3731.400.51.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::22f; envelope-from=casouri@gmail.com; helo=mail-oi1-x22f.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:304744 Archived-At: > On Mar 23, 2023, at 2:06 PM, Daniel Colascione = wrote: >=20 >=20 >=20 > On March 23, 2023 15:20:50 Yuan Fu wrote: >=20 >>> On Mar 22, 2023, at 9:55 PM, Daniel Colascione = wrote: >>>=20 >>>=20 >>>=20 >>> On March 22, 2023 20:21:22 Yuan Fu wrote: >>>=20 >>>>> On Mar 22, 2023, at 5:05 PM, Daniel Colascione = wrote: >>>>>=20 >>>>>=20 >>>>>=20 >>>>> On March 22, 2023 19:58:22 Yuan Fu wrote: >>>>>=20 >>>>>>> On Mar 22, 2023, at 8:53 AM, Daniel Colascione = wrote: >>>>>>>=20 >>>>>>> Shouldn't customization of styles in c-ts-mode look more like = cc-mode's >>>>>>> style machinery? Right now, the closest thing we have to = defining a new >>>>>>> style is add-advice on c-ts-mode--indent-styles, which isn't >>>>>>> particularly convenient or future-proof. You can't drop a new = style in, >>>>>>> say, .dir-locals. >>>>>>>=20 >>>>>>=20 >>>>>> Actually, you can define a custom function, say, = c-ts-mode-my-style, and set c-ts-mode-indent-style to the name of it. >>>>>>=20 >>>>>> Yuan >>>>>=20 >>>>>=20 >>>>> But that doesn't add the new style to the UI selection menu and = doesn't let you define a style in dir-locals. IMHO, cc-mode got this = right. >>>>=20 >>>> You can set c-ts-mode-indent-style in dir-locals, no? >>>=20 >>>=20 >>> No, because I can set that variable only to one of the predefined = styles or to a function, and a function isn't a safe value of a = directory local variable. >>=20 >> I see, then an alist should solve this. >>=20 >>>=20 >>>> You have a point for UI selection, we can add a = c-ts-mode-indent-style-alist that maps style names to rules/functions = that returns rules, like c-style-alist. >>>=20 >>> Why this emphasis on functions? Why would we want the alist values = to be functions instead of just lists of rules? >>=20 >> Nothing except that that=E2=80=99s how it is right now. It certainly = wouldn=E2=80=99t harm to allow functions, no? >>=20 >> Anyway, I agree with the general idea. I=E2=80=99ll add the option to = set a rule alist. >=20 >=20 > I gave you a concrete example of a disadvantage of using functions = that return data over just using plain data. The principle of least = power applies here. Still, it=E2=80=99s largely harmless, and could prove useful for some = people, also it=E2=80=99s too late to remove it from emacs-29. And since = it=E2=80=99s in emacs-29, I don=E2=80=99t want to go through the trouble = removing it in emacs-30 in a backward-compatible way. Yuan=