[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
What is the use of derived-mode-add-parents?
From: |
Pankaj Jangid |
Subject: |
What is the use of derived-mode-add-parents? |
Date: |
Mon, 18 Mar 2024 13:04:51 +0530 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
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.
- What is the use of derived-mode-add-parents?,
Pankaj Jangid <=