From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Newsgroups: gmane.emacs.bugs Subject: bug#68246: 30.0.50; Add non-TS mode as extra parent of TS modes Date: Tue, 16 Jan 2024 22:00:35 +0000 Message-ID: References: <831qavvcbo.fsf@gnu.org> <33f46561-7830-424d-bfee-ba3748f977e2@gutov.dev> 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="26169"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 68246@debbugs.gnu.org, Eli Zaretskii , Yuan Fu , Stefan Monnier , Stefan Kangas To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jan 16 23:01:16 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1rPrUi-0006by-C8 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 16 Jan 2024 23:01:16 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rPrUa-0002eo-4x; Tue, 16 Jan 2024 17:01:08 -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 1rPrUW-0002eO-Ld for bug-gnu-emacs@gnu.org; Tue, 16 Jan 2024 17:01:05 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rPrUT-0001oU-4Z for bug-gnu-emacs@gnu.org; Tue, 16 Jan 2024 17:01:04 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rPrUT-0008E8-Nu for bug-gnu-emacs@gnu.org; Tue, 16 Jan 2024 17:01:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 16 Jan 2024 22:01:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68246 X-GNU-PR-Package: emacs Original-Received: via spool by 68246-submit@debbugs.gnu.org id=B68246.170544245631047 (code B ref 68246); Tue, 16 Jan 2024 22:01:01 +0000 Original-Received: (at 68246) by debbugs.gnu.org; 16 Jan 2024 22:00:56 +0000 Original-Received: from localhost ([127.0.0.1]:49908 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rPrUN-000848-OX for submit@debbugs.gnu.org; Tue, 16 Jan 2024 17:00:56 -0500 Original-Received: from mail-lj1-x235.google.com ([2a00:1450:4864:20::235]:45063) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rPrUL-0007rt-E5 for 68246@debbugs.gnu.org; Tue, 16 Jan 2024 17:00:54 -0500 Original-Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2cd2f472665so109603271fa.2 for <68246@debbugs.gnu.org>; Tue, 16 Jan 2024 14:00:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705442447; x=1706047247; darn=debbugs.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=yS1xa7u+8PKUAz6QNaXR2oF6MRxBiOI4yEJiras243c=; b=aNqQPu2WhB3T6EEJtFjszodp52JAHtglxMQobB551a+bDwMzU2GxWN1xABbun+fFBN qxLnIgmOIIOn5GGQ19nfCNz55obbAAZMQTh+/4sAGTJGV5rDeci+8sos92OUjXuwBjA9 6K/dVkhcJ4Y5SCXGGUZEFfpASpS2wkaY8xaYtCamBadTOEvQNgFTyRc+9EY4RnFyB1F4 WY3BhRlPv6Ypn2BUXI7BRPNBeFx+cqWVb4gYlT0laQ7O0u7Ev0Z+wMMmhX47sr+e9s4w bD+K8WvTEmLOLrQThFLjVPpQ+U5Ni9w5kjEj4yof8SM61T7lDKXGzfI0bgOOM9kSxVHL x34Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705442447; x=1706047247; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yS1xa7u+8PKUAz6QNaXR2oF6MRxBiOI4yEJiras243c=; b=MVpz8DEJ83JAPg6gX/etrdw5ogPxUz4LNogIjcb8C5O/rTQWH2G3T1y5af2qnCETXd FQawxulhkF3Vm/ANcVRvz1zq8iUABbquFuiwaffH72d8RP7jV+mv3h5dxwWwY1pj1/nA SgiNckmy+AlTq4VX6WPc0VqFIRYQ0rvXdmvgCZrMK3OcAOhdygHP8ry8BJlYc9LuLAOA AfozdL/aQg2r+NTm0o0Su/aOZGmhlxbY7PX/sX0TFwFUCqX33BB9fylmHnFhw+EkUqhC bhhhuCTjjbRBbWfieoCMCYG2SHtpk+K2j7ZPQyfl3wL/NsstwFpu/bt9CalV+U8eMBl3 w8xg== X-Gm-Message-State: AOJu0Yw6dN9IxX2zbYTXKJ5bDUMriMySbFZstmYjVNYLsHigfbsl06f0 h0vupxddDk+vA0avE16eSpRA9oFokBdwL+P0R/w= X-Google-Smtp-Source: AGHT+IGAQmT4YsnnI119ProHKywwxIEs+qCkBqRWYXJUHFBQx0OvBOaH68FqSDlS+oqzugN11RJyZ08e93BFzflmKlM= X-Received: by 2002:a2e:b706:0:b0:2cc:a710:f422 with SMTP id j6-20020a2eb706000000b002cca710f422mr3564790ljo.28.1705442446518; Tue, 16 Jan 2024 14:00:46 -0800 (PST) In-Reply-To: <33f46561-7830-424d-bfee-ba3748f977e2@gutov.dev> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:278364 Archived-At: On Tue, Jan 16, 2024, 17:45 Dmitry Gutov wrote: > > On 16/01/2024 12:34, Jo=C3=A3o T=C3=A1vora wrote: > > I see no real categorization or classification. I just see > > a many-to-one mapping of major modes to languages. > > It might even be many-to-many, at least in some cases. > > E.g. js-ts-mode being good for both :js and :jsx. > > Not sure how useful this -to-many relation is going to be in the above > cases, but it's probably a good illustration of the possibility. According to https://react.dev, jsx is a "JavaScript syntax extension". So it would seem JSX is a superset of JS. If js-ts-mode parses it perfectly, it could be called jsx-ts-mode instead. But does it? I see Emacs modes specific for jsx out there, I suppose people use them for a reason. There's also tsx-ts-mode and typescript-ts-mode. At the end of the day, a language is not so easy to define, but it's not that problematic either, especially in the editor (in the compiler, it's much more important). The best sources are a standard, when it exists, but each iteration, sometimes each compiler is also its own language. There's "GNU C", "ANSI C", C17, C23. All handled by the C modes we have and the best way we have to designate this is just "C". c++-mode also handles this code by the way, probably flawlessly, and yet we don't say c++-mode is for C and C++. But if you want, I don't think there's any big problem in making get-language-for-mode return a list, with the most important likely language at the top. I predict it'll be pretty rare, but I guess you could have this (excuse the ugly CamelCase for demo purposes) (setq auto-mode-alist '(("\\.js$" . :JavaScript) ("\\.jsx$" . :JavaScriptReact))) (setq m-m-remap-alist '((:JavaScript . js-ts-mode) (:JavaScriptReact . js-ts-mode))) And 'buffer-language' becomes more like: (or buffer-overriding-language-keyword (with-current-buffer buffer (get-language-for-mode major-mode)) (let (kw) (and buffer-file-name (keywordp (setq kw ;; yes I know this needs regexps (alist-get buffer-file-name auto-mode-alist))) kw)) (consult-oracles) (error "Don't know what language this is, sorry")) Jo=C3=A3o