0

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?

  • 1
    Why and where do you want to "overwrite the...major mode name"? And what do you mean by "overwrite" here? Is this about the value of variable major-mode, variable mode-name, or something else? (Use C-h v to see what those variables are about.) – Drew Feb 1 at 15:56
  • 2
    Is it the way the mode is named in the mode line that you want to change? If so, please consider rewording the post title. – JeanPierre Feb 1 at 20:17
0

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")))
| improve this answer | |
  • Agreed, but noting that delight additionally arranges for the original (real) name to still be shown when you do things like C-h m (describe-mode), with the custom name only used in the mode-line. Conversely a simple (setq mode-name "React") would cause describe-mode to say something like "React mode defined in rsjx.el", which (IMHO) is potentially confusing. YMMV. – phils Feb 1 at 23:40
1

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.

| improve this answer | |
  • 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. – phils Feb 1 at 23:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.