4

I was wondering if there is a way to permanently remove a major mode let's say vhdl-mode from Emacs? I have already checked " How do I turn off vhdl-mode in emacs? " but I am wondering if I want to write my own distribution how can I removed some of these modes permanently from Emacs?

-- Experimental only and so no licensing issues or etc.

Community
  • 1
  • 1
Daniel
  • 611
  • 5
  • 15

2 Answers2

8

You can effectively disable a mode by removing it from the auto-mode-alist variable. Once removed, the mode will never be automatically chosen by emacs but it may still be started manually. This removes vhdl-mode:

(rassq-delete-all 'vhdl-mode auto-mode-alist)
ataylor
  • 64,891
  • 24
  • 161
  • 189
  • Just curious: What is 'rassq' ? What does it signify? – aartist Jul 25 '12 at 02:00
  • 2
    The root is "assoc" (shortened to "ass") for association list, aka alist. The leading "r" indicates it's a reverse operation, so operates on the list values rather than the keys. The "q" means it uses `eq` (identity) for comparisons rather than `equal` (equality). – ataylor Jul 25 '12 at 04:20
  • [Documentation](https://www.gnu.org/software/emacs/manual/html_node/elisp/Association-Lists.html) of `rassq-delete-all`. – user272735 Dec 28 '20 at 08:47
4

All modes are available as files. On my machine, VHDL mode is at /usr/share/emacs/23.4/lisp/progmodes/vhdl-mode.el.gz. If you delete this file, there's no way to turn that on at all. If other modes depend on functionality implemented in this mode, they will suffer too.

Also, modes might be spread across mutliple files so you might have to remove more than one.

Noufal Ibrahim
  • 71,383
  • 13
  • 135
  • 169
  • Excellent thanks, how can I know what depends on this mode and what files it does use? if possible can you include them as edit in your answer? you are awesome .. – Daniel Jul 24 '12 at 11:20
  • 1
    I'm not aware of any way short of reading the source code. Look for all `require` statements and look at other files that `require` what this mode `provide`s. That's a start. – Noufal Ibrahim Jul 24 '12 at 11:22
  • This isn't great because you need to do it every re-install/upgrade. – ideasman42 Jun 29 '19 at 01:36