From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Pankaj Jangid Newsgroups: gmane.emacs.devel Subject: What is the use of derived-mode-add-parents? Date: Mon, 18 Mar 2024 13:04:51 +0530 Message-ID: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20302"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: Emacs Development Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Mar 18 08:35:34 2024 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 1rm7Wu-0004wX-7T for ged-emacs-devel@m.gmane-mx.org; Mon, 18 Mar 2024 08:35:32 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rm7WT-0007Kv-Jm; Mon, 18 Mar 2024 03:35:05 -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 1rm7WP-0007Kh-Vr for emacs-devel@gnu.org; Mon, 18 Mar 2024 03:35:03 -0400 Original-Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rm7WM-0005Yj-Ga for emacs-devel@gnu.org; Mon, 18 Mar 2024 03:35:01 -0400 Original-Received: by mail-pg1-x529.google.com with SMTP id 41be03b00d2f7-5ce9555d42eso2252816a12.2 for ; Mon, 18 Mar 2024 00:34:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codeisgreat-com.20230601.gappssmtp.com; s=20230601; t=1710747295; x=1711352095; darn=gnu.org; h=mime-version:user-agent:message-id:date:mail-followup-to:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=wSCF758OBar9cHLuWwfL+TaCb39qD7RW5XimS8USp8Q=; b=rXpH7CNJzF3aMLqVdNV43jqYVMggt7kzEe2oZRpREou0+jLNZzIYwhqdTFfbbveE4n uF1IusqaFbxnxju6VB/hgKqZ0++GV8vwajwzvLdQepGTaXvnky+d2orZ9S0RwPGsLQYJ 9wyppJwDkL0lTwbjlnBDQNyU9cIEBe6hmcv+9Wcf3RsdbgLLQ8YL2seU/zVkHSBA2qZ0 lC8uOxj3un7NXZv1RtULDg4nXY4hZsdygGuISaQwjAhnEheuf9W3cTRRy1mizkUoR01u K1Ou/gJljtXmLyPAqVeZcQ20dowbw/dQrUMZ6YKW5qqdKSzd3RNf4f69pqpg7UQYv0N8 7lAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710747295; x=1711352095; h=mime-version:user-agent:message-id:date:mail-followup-to:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wSCF758OBar9cHLuWwfL+TaCb39qD7RW5XimS8USp8Q=; b=YkpEuMKelGX6McSzjanlawNix8BBzUcuXPFAf2VVBQbHkOZ5FKnipFmVdoMyGyEEkm uIQKWMMX4gz27FbfjO5xAUYl9v8qhibyxv+buNMmg5PgbOH84WyTKUG56rSjn1Ux+mR6 X/BbLtX5szPuSMc5Krk98C/qeUH+FYJf/L4qWo62eF8aXJbhaBj/gYlcK5l0VFlwFAuW n/9VAu6SFm3n/Byuf0G5cev8WeJrf/zQvrPSpVDn7FQrn86o3kU+XChDf9gfFyd3lcxD kLUvcipx/cb9wfiJJ+ws4UO5n1Nr0vBhf7idz9CjVtzjLPgBDLqbg77hQFJi9ia+IzRL KfYQ== X-Gm-Message-State: AOJu0YwBVQB+YnbbknOcdKJmAo2QY/F6daiwCK49U76Nwg2zaadbIUDA H3ztg6UzA7rDj0eI+Q2IVETYdCN7DckScT6KK+jOVzGSVgHGO3nbJHkDb2Sf4ScBjRREWCeT3mS g X-Google-Smtp-Source: AGHT+IGXA8+pBed6TBfUTDRxfV/HRzW1ha2J6p8OMxjlgqrt5wmUGQ8p3DnTyLIyMxGEGSB6rk4Vkg== X-Received: by 2002:a05:6a20:105a:b0:1a3:4591:1e9a with SMTP id gt26-20020a056a20105a00b001a345911e9amr9833369pzc.61.1710747295007; Mon, 18 Mar 2024 00:34:55 -0700 (PDT) Original-Received: from Pankajs-MacBook-Pro.local ([49.36.239.216]) by smtp.gmail.com with ESMTPSA id v1-20020a62c301000000b006e6f9e13a8csm5361776pfg.192.2024.03.18.00.34.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 00:34:54 -0700 (PDT) Mail-Followup-To: Emacs Development Received-SPF: none client-ip=2607:f8b0:4864:20::529; envelope-from=pankaj@codeisgreat.com; helo=mail-pg1-x529.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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:317159 Archived-At: I am working on a new -ts-mode for Move language. Rust is the closest language so I am looking at rust-ts-mode's code. There I encountered a call in the end, (derived-mode-add-parents 'rust-ts-mode '(rust-mode)) I need help in understanding what this call does. The docstring says this, --8<---------------cut here---------------start------------->8--- (defun derived-mode-add-parents (mode extra-parents) "Add EXTRA-PARENTS to the parents of MODE. Declares the parents of MODE to be its main parent (as defined in `define-derived-mode') plus EXTRA-PARENTS, which should be a list of symbols." (put mode 'derived-mode-extra-parents extra-parents) (derived-mode--flush mode)) --8<---------------cut here---------------end--------------->8--- Please help me understand, what is the use of parent modes? At the beginning of the file, there is --8<---------------cut here---------------start------------->8--- (define-derived-mode rust-ts-mode prog-mode "Rust" "Major mode for editing Rust, powered by tree-sitter." :group 'rust :syntax-table rust-ts-mode--syntax-table --8<---------------cut here---------------end--------------->8--- What I understand here is that we borrow certain features from parent modes. But it is not clear to me, how we borrow these features by simply calling defived-mode-add-parents or define-derived-mode.