From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eshel Yaron Newsgroups: gmane.emacs.devel Subject: Re: On treesit preference for "consumer" modes Date: Sat, 26 Aug 2023 19:58:57 +0200 Message-ID: References: <7649A9B7-3697-4CA4-BCBE-BAC7DA814B12@gmail.com> Mime-Version: 1.0 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="12591"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-devel@gnu.org To: JD Smith Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Aug 26 20:00:03 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 1qZxZr-00033y-HW for ged-emacs-devel@m.gmane-mx.org; Sat, 26 Aug 2023 20:00:03 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZxZ5-0000Ow-HY; Sat, 26 Aug 2023 13:59:15 -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 1qZxZ3-0000Od-Sp for emacs-devel@gnu.org; Sat, 26 Aug 2023 13:59:13 -0400 Original-Received: from mail.eshelyaron.com ([107.175.124.16] helo=eshelyaron.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qZxZ1-0004Ac-0b for emacs-devel@gnu.org; Sat, 26 Aug 2023 13:59:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com; s=mail; t=1693072749; bh=nG/YXMrgIsWPbK/Yo2oEp5iT2KW1C0Bf9DyVl3xjoIs=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=ehvVSI/YhAMmcgSv+r8aWq8S6y1qV6BZeSuk0VxgDrAh0bFn421e71cQEDHYOxMRC oxsAD7LZL5UIr8Cj/YEw14bEtFxp/Dw1gpNgH6EFdjXji1XuMhhUJUQ/a3wiJZ3BMV Vi5Fp/m4mwFhfCt3JvK1o38cPIWWFb+OFIMuFItdfAeoSqeO86MPszfoYLLTVgrklR g4+8/Sv8B4+YWtEsILRnwLq+03kMtoGhZbvz+c7beU4ugdwKhnW0EYSDbnYNqszFMx MXRXlblEQbolC67I1kxY0dNe/vga26w+98oadKf0/2bOKvnKN6rpVbr/QfesQ6DPjz Y/2JMwuMBqJmg== In-Reply-To: <7649A9B7-3697-4CA4-BCBE-BAC7DA814B12@gmail.com> (JD Smith's message of "Sat, 26 Aug 2023 12:47:18 -0400") Received-SPF: pass client-ip=107.175.124.16; envelope-from=me@eshelyaron.com; helo=eshelyaron.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, SPF_HELO_PASS=-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:309268 Archived-At: Hi, JD Smith writes: > ...some modes are =E2=80=9Cconsumers=E2=80=9D of other majors modes. Tha= t is, they > have a different focus, but use LANG modes as subordinate helpers for > some aspect of their feature set. Examples: org-mode SRC block > highlighting, or a shell mode which wants to highlight and indent code > written at the shell prompt. In the pre-treesit era, such a =E2=80=9Ccon= sumer > mode=E2=80=9D simply reached for, e.g., LANG-mode for this, directly maki= ng > use of all the customizations users have applied. I think the last sentence is a slight over simplification: even before `foo-ts-mode`s, Emacs didn't have a clean abstraction for a (programming language) AFAICT, only major modes. And "competing" major modes for the same language are not a new problem. So these "consumer modes" would have to be more clever and, hopefully, already have the right methods in place to deal with the existence of multiple major modes per language. (Admittedly, `foo-ts-mode`s make this challenge much more pronounced.) Looking at the specific examples you mentioned: Org mode handles this well with `org-src-lang-modes`, which is quite more sophisticated than just reaching out for `LANG-mode`. (BTW in `sweeprolog.el` there's a similar mechanism for highlighting quasi-quoted content that leverages similar user option `sweeprolog-qq-mode-alist`.) The shell input example is more interesting since currently, IIUC, `shell-mode` really is naive in the sense that it always uses `sh-mode` without having a user option for specifying e.g. `bash-ts-mode` instead. Best, Eshel