I'm a newcomer to Emacs from Vim, I use rsjx-mode
for react files. Its major mode calls itself RJSX
, but I would like to call it React
, so how can I overwrite the rjsx package major mode name?
2 Answers
If you don't want to use the delight
package, you can also just do it by hand:
(add-hook 'rsjx-mode-hook
(lambda ()
(setq mode-name "React")))
-
Agreed, but noting that
delight
additionally arranges for the original (real) name to still be shown when you do things likeC-h m
(describe-mode
), with the custom name only used in the mode-line. Conversely a simple(setq mode-name "React")
would causedescribe-mode
to say something like "React mode defined in rsjx.el", which (IMHO) is potentially confusing. YMMV.– philsFeb 1, 2020 at 23:40
If you install the delight
package:
M-x package-install
RET delight
RET
You can then add this configuration to your init file:
(delight 'rsjx-mode "React" :major)
in order to change the name displayed in the mode line.
-
n.b. The change will affect new buffers; any pre-existing buffers in this major mode would need to be reverted for them to show the change.– philsFeb 1, 2020 at 23:46
major-mode
, variablemode-name
, or something else? (UseC-h v
to see what those variables are about.)