unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* What is the use of derived-mode-add-parents?
@ 2024-03-18  7:34 Pankaj Jangid
  2024-03-18 13:25 ` Eli Zaretskii
  0 siblings, 1 reply; 3+ messages in thread
From: Pankaj Jangid @ 2024-03-18  7:34 UTC (permalink / raw)
  To: Emacs Development

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.




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-03-19  4:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-18  7:34 What is the use of derived-mode-add-parents? Pankaj Jangid
2024-03-18 13:25 ` Eli Zaretskii
2024-03-19  4:49   ` Pankaj Jangid

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).