From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#68246: 30.0.50; Add non-TS mode as extra parent of TS modes Date: Thu, 18 Jan 2024 02:47:16 +0200 Message-ID: <46a9581a-9c5b-4a55-8717-ffd7d1c0a4bc@gutov.dev> References: <83a5phskd5.fsf@gnu.org> <83h6joqz0t.fsf@gnu.org> <834jfoq86m.fsf@gnu.org> <831qarrbjx.fsf@gnu.org> <87a5p84nlh.fsf@gmail.com> <83edekfldq.fsf@gnu.org> <4105c743-45d0-48a0-a8bb-1ab457b9a256@gutov.dev> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15252"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird Cc: 68246@debbugs.gnu.org, Eli Zaretskii , casouri@gmail.com, Stefan Kangas , monnier@iro.umontreal.ca To: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jan 18 01:48:28 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 1rQGa2-0003ie-Cf for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 18 Jan 2024 01:48:27 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rQGZg-0002Wu-DI; Wed, 17 Jan 2024 19:48:04 -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 1rQGZd-0002VI-PK for bug-gnu-emacs@gnu.org; Wed, 17 Jan 2024 19:48:01 -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 1rQGZd-0000wu-H1 for bug-gnu-emacs@gnu.org; Wed, 17 Jan 2024 19:48:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rQGZe-0004xl-6H for bug-gnu-emacs@gnu.org; Wed, 17 Jan 2024 19:48:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 18 Jan 2024 00:48:02 +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.170553885018883 (code B ref 68246); Thu, 18 Jan 2024 00:48:02 +0000 Original-Received: (at 68246) by debbugs.gnu.org; 18 Jan 2024 00:47:30 +0000 Original-Received: from localhost ([127.0.0.1]:54001 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rQGZ7-0004uV-E9 for submit@debbugs.gnu.org; Wed, 17 Jan 2024 19:47:29 -0500 Original-Received: from out5-smtp.messagingengine.com ([66.111.4.29]:40493) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rQGZ5-0004uH-4P for 68246@debbugs.gnu.org; Wed, 17 Jan 2024 19:47:27 -0500 Original-Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id AB5B55C01E4; Wed, 17 Jan 2024 19:47:20 -0500 (EST) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 17 Jan 2024 19:47:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1705538840; x=1705625240; bh=iHTEoq2RjcPLmqNyw8ZblEXUbfnBteP2JmN/G43U7sk=; b= p4QL/JSTyrSo9Youtk2Pd4gRKGrtsH1qPZOjkmyx8r4yINBCh5Wewh+hL7+fgLdC Zc5V0+3COnZKuq8PuviTziWGvNbOai4ifqDeVC6B5ld5J8mR3zfEv+/OVQNmGQyb hGiEZTfKEwOnmp5u0qq4buqnJ0p5vSQM3dWL+LGSWsJ7/Q26FTvFx9r8ei0A/icu y+a0uLPTZ6CAVQWU9YqXBbLlguVFN8lHZgy9qQG3/MeacDO6e/eYx4uq+611OhdB oLnXr78sVJI8QdD7fF9ZobB9V6jzo/FJB08iNwYMQqGuHeq2W1YZu31kIY6J6cdx uh+PFVHNKlqArzc/z40mOw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1705538840; x= 1705625240; bh=iHTEoq2RjcPLmqNyw8ZblEXUbfnBteP2JmN/G43U7sk=; b=k rHnCbROd7smR2PYtou4ncgCjbdSRpm8ZH7wNLYayA9I/kZ6ho2cXHCkj2mO5qf/C u9pU1QyiDE6x1OnQZkWP/fVfdnhMK0Pq3g49EO8Cxh6ajkjadhMgbkQqDVLZpdQ1 vzxQ+TBYRAvq2th/5N9nVCnHz2p9sxpF76kJmpgyyeS2+6uW33Rocy2niBGwY3AZ LjVU06tosgpAjwxWkO7nxoFjt4d0eICyQmxz5KpgsAQQNMO53ghLT90dstA1Xmtl MrzJhy35dVr/qzIBJ3DLRtYi7pPl//FLACoAuw34kIhlDGDfZTvlwv1B9QK554fu Udwe4oHQsPSdOSs8c25aw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdejiedgvdegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtkeertddtvdejnecuhfhrohhmpeffmhhi thhrhicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdruggvvheqnecuggftrfgrth htvghrnhepgeelfeetkefghfdvhfdtgeevveevteetgeetveegtedthefhudekteehffeu keeknecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepug hmihhtrhihsehguhhtohhvrdguvghv X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 17 Jan 2024 19:47:18 -0500 (EST) Content-Language: en-US In-Reply-To: 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:278415 Archived-At: On 17/01/2024 12:20, João Távora wrote: > On Wed, Jan 17, 2024 at 2:41 AM Dmitry Gutov wrote: > >> An "abstract" mode is supposedly one that doesn't do anything. So it >> doesn't have to be callable. > > No. Not "abstract" as in "Java interface", abstract as in "Java > abstract class". > >> Anyway, that's +1 feature required for the implementation. > > Almost trivial feature. See patch after sig. It'll make this work: > > (define-derived-mode foo-mode prog-mode "Fooey" :abstract t > (message "Hey from foo-mode")) > (define-derived-mode bar-mode foo-mode "Barey" > (message "Hey from bar-mode")) > > 'foo-mode' can't be called, but 'bar-mode can, of course. And it > will call its parent. What would such an "abstract" parent do anyway? Still set up keymaps etc? >>> What if we filter by prog-mode? It would leave the ':ruby-base' and >>> ':python-base' as false positives, I guess. But then we could reasonably >>> say that anything ending with '-base' is abstract (or use the >>> aforementioned explicit abstract prop). >> >> We would also filter out :css, for example. > > Sure? I see a super-normal css-base-mode inheriting from > prog-mode. > >> TeX modes also do not derive >> from prog-mode. TeX does have an LSP server, however. > > At the end of the day we have to come to a conclusion of what > we want to do. I want to find major modes that correspond > to languages, right? So: Right. But I suppose it's more or less the set of modes that correspond to file types (files on disk). Even text-mode, often used as a fallback, could have a language ("plain text") - you can see this file type (or "language mode") in the dropdown list of choices in editors that support switching between them with a mouse (e.g. VS Code). > * these outliers start inheriting from prog-mode > * we inject new lang-mode between prog-mode and fundamental-mode and make > outliers derive from that. > * we say these outliers aren't languages > * we code exceptions for these outliers > > It could even be that > > (derived-mode-add-parents 'tex-mode '(prog-mode)) > > is exactly what's needed here, showcasing how I think this > particular heavy hammer should be used for the exception, not > the rule. Also, arguably, Makefile-mode should not be a prog-mode derivative because its indent-line-function is not meaningful. But we want to support it with LSP anyway (I think), and with other features that dispatch based on the current language. >>>> BTW, get-current-mode-for-language could be implemented in terms of >>>> set-buffer-language. >>> >>> What does get-current-mode-for-language do exactly? >> >> The major-mode currently configured to be used for the language (through >> m-m-a-alist, in the current proposal). set-auto-mode will choose it. > > Perfect. But the, "set-buffer-language" comment? Does a buffer object > have to exist for that job to be done? No, you could just do something like (defun get-current-mode-for-language (lang) (with-temp-buffer (set-buffer-language lang) major-mode))