unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Pankaj Jangid <pankaj@codeisgreat.org>
To: Emacs Development <emacs-devel@gnu.org>
Subject: What is the use of derived-mode-add-parents?
Date: Mon, 18 Mar 2024 13:04:51 +0530	[thread overview]
Message-ID: <m2sf0oc7s4.fsf@codeisgreat.org> (raw)

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.




             reply	other threads:[~2024-03-18  7:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-18  7:34 Pankaj Jangid [this message]
2024-03-18 13:25 ` What is the use of derived-mode-add-parents? Eli Zaretskii
2024-03-19  4:49   ` Pankaj Jangid

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2sf0oc7s4.fsf@codeisgreat.org \
    --to=pankaj@codeisgreat.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).