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: Extending define-derived-mode Date: Fri, 2 Jun 2023 00:45:31 -0700 Message-ID: References: <20F07C52-6B39-4B24-8433-82E2226EADA6@gmail.com> <83zg5mf62s.fsf@gnu.org> <88498EC5-0870-45ED-802D-85286FB2E9FC@gmail.com> <83edmventk.fsf@gnu.org> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.600.7\)) 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="693"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Stefan Monnier , emacs-devel@gnu.org, mickey@masteringemacs.org, theo@thornhill.no, dgutov@yandex.ru To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jun 02 09:46:31 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 1q4zUT-000ASH-Ne for ged-emacs-devel@m.gmane-mx.org; Fri, 02 Jun 2023 09:46:29 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4zU2-0006ZO-S1; Fri, 02 Jun 2023 03:46:08 -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 1q4zTo-0006Xq-CZ for emacs-devel@gnu.org; Fri, 02 Jun 2023 03:45:48 -0400 Original-Received: from mail-oi1-x22e.google.com ([2607:f8b0:4864:20::22e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q4zTm-0001WG-6i; Fri, 02 Jun 2023 03:45:48 -0400 Original-Received: by mail-oi1-x22e.google.com with SMTP id 5614622812f47-39810ce3e13so1522761b6e.2; Fri, 02 Jun 2023 00:45:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685691943; x=1688283943; 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=Tyg/z+qmIBwdRyLnIxxnXD1GlsWXUjQXHm0+V5eda6Y=; b=BnodUXD+yUeZjze0dtie1YC1oyZj5hvo1YCWfmPhatXozHd4xI3N8OnphaDso7r/0u iyZCmIscgV5txX4LtcOU4LBtSVIyaLR0lW1xwMv00ZrK4zd1nlxzMekxiBgTg+M6/KKD TSDfQr36JUTdEk1ey1Cpoxo1OSjPoWyTpz4Y25Rw30+WV1d3/D18145K6IKBt5XelcNQ xz4hJzXk5/R0X27ulS7GeTwALhWYi6lwz6OKQzmybbOonhrz3hcCKyOh2JqJwLUAMhuc d1+d1+gWx1pS8fXHyadzztUJa/5ikULHSSCMjZ/mORhajBAYYDBGULLMCM8Oltf9pUjR /GGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685691943; x=1688283943; 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=Tyg/z+qmIBwdRyLnIxxnXD1GlsWXUjQXHm0+V5eda6Y=; b=EB03cGzrD7ss9KlHu3Flx/zimPT4dHwtlOdtrhv/zSXXa0ub37KrAKedIqBpq8xGr+ WXEl3cXyjNDOkJ7q4Wic4Ktd/oB5bNGJPBl7ITbNN+vs0zWdT+sbLJ/tAAHSYh9PaAAX chZ8HmvaL9XIAemXixn9Ix8aTxf8HNFXFC7ArnzNQpWhfidMboNK48g6OGibP5lIwKNH ZP2VgCV2qZBr2tLarF4xdYLmYUBdB/OtrgKqlqlfPQ6HAzbsow8zVjJJozx3malNdDo1 VQXcyeHraD/6S2Z0ijOEzF1PNj5IJ6d/hw2UW6GZp/4IjkhSWaDM7Eo4Sz5QV6yDm6oE 4paQ== X-Gm-Message-State: AC+VfDy0VXJKu302HsXfm3ywibqY48GDylkupkZpV31nY7H4f6bnqfr6 ZRM2LDpfoMYFPPANhB3jntpE6wYgBt8= X-Google-Smtp-Source: ACHHUZ5Zowhpkwihv0PjJ8YuMEIRkRBm1Q25GrMVK4Dmz8wLC9IFjZVO7jhy+0cZeJaaJrT7u7ucmg== X-Received: by 2002:a05:6808:684:b0:396:25be:bb91 with SMTP id k4-20020a056808068400b0039625bebb91mr1667941oig.16.1685691943132; Fri, 02 Jun 2023 00:45: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 q14-20020a170902dace00b001b03a1a3173sm654741plx.145.2023.06.02.00.45.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Jun 2023 00:45:42 -0700 (PDT) In-Reply-To: <83edmventk.fsf@gnu.org> X-Mailer: Apple Mail (2.3731.600.7) Received-SPF: pass client-ip=2607:f8b0:4864:20::22e; envelope-from=casouri@gmail.com; helo=mail-oi1-x22e.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.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, FREEMAIL_REPLY=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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:306546 Archived-At: > On May 31, 2023, at 10:47 PM, Eli Zaretskii wrote: >=20 >> From: Yuan Fu >> Date: Wed, 31 May 2023 13:48:56 -0700 >> Cc: Stefan Monnier , >> emacs-devel@gnu.org, >> mickey@masteringemacs.org, >> theo@thornhill.no, >> dgutov@yandex.ru >>=20 >>> This is not simple in practice. Ask yourself why don't the >>> FOO-ts-mode's simply run the (existing) hooks of FOO-mode? Look at >>> the code, and you will understand: the stuff people put in these = hooks >>> usually customizes aspects that are very different in each of the >>> modes: font-lock, indentation, syntax tables, supporting "electric" >>> sub-modes, styles of comments and other things, etc. The few places >>> where the new TS modes tried to run the same hooks and share most of >>> the initialization code (for example, bash-ts-mode and sh-mode, >>> python-ts-mode and python-mode) introduced subtle bugs which were = only >>> recently fixed. One problem with inheriting from the same base mode >>> is that doing initialization there could be problematic because the >>> mode stuff that gets automatically instantiated and initialized by >>> define-derived-mode, such as the mode's map and variable, is not yet >>> set up when the base mode's initialization runs, so you cannot do = some >>> of the things we are used to do there, like setting up the menu-bar >>> menus. >>>=20 >>> So it would seem that, for efficient and convenient facilities of = this >>> kind, we need some way of defining stuff in the base mode, which = will >>> be actually run later, when the child mode is set up. >>=20 >> I don=E2=80=99t entirely understand the example. Say I have a = xxx-base-mode, and I want to setup menu-bar menus in it to be shared by = xxx-mode and xxx-ts-mode. What is the problem that I=E2=80=99m gonna run = into? Couldn=E2=80=99t you just use the base-mode=E2=80=99s keymap? >=20 > A base mode usually doesn't have a map, only the actually used derived > modes do. We can create a map for the base mode, and the child mode=E2=80=99s map = will inherit from it. Yuan