reddit / emacs

How can I find out all the modes in Emacs, whether major or minor?

steve-ddit · 2022-10-27 20:40
big_lentil · 2022-10-27 21:37
You can do C-h f and then search with a regexp E.g. with emacs -q, C-h f, typing *mode and pressing tab works, but there are some false positives and it seems like how the regexp is interpreted depends on the completion framework you're using. With helm I can get a more accurate list with .mode$, but seems like *mode$ doesn't work with emacs -q
J-ky · 2022-10-27 23:42
C-h m or C-h b should do what you want.
andyjda · 2022-10-27 23:44
If you want to know all the modes active in the current buffer, do M-x describe-mode, or C-h m. If you want to know all of the available modes, then the other reply is what you’re looking for, but the amount of information you’d get is quite large and non-descriptive
[deleted] · 2022-10-27 23:44
[deleted]
sr105 · 2022-10-28 03:13
In the last month, someone posted a small package that not only lists all of the modes but hierarchically, too. https://github.com/jdtsmith/mode-minder
arthurno1 · 2022-10-28 03:16
> How can I find out all the modes in Emacs, whether major or minor? Depends on what do you mean with "all the modes". To find all the modes in a buffer, as already suggested, use C-h m. To find all the modes currently loaded in Emacs, you will have to do some acrobatics by going through all the symbols in global symbol table, check [mapatoms function](https://www.gnu.org/software/emacs/manual/html_node/elisp/Creating-Symbols.html), then you will have to check some plist properties for each symbol. I am not sure if it is even possible to find them all that way, or how reliable it would be. Finally there are modes avialable in libraries but not loaded. Minor-modes that features are usually autoloaded, buI am not sure if all minor-modes are autoloaded?
holgerschurig · 2022-10-28 05:09
Get the source of Emacs,and recursively grep for define-minor-mode and define-major-mode there.
steve-ddit · 2022-10-28 07:20
We can consider that "File Modes" is always associated with a major-mode?
big_lentil · 2022-10-28 11:54
Looks like this is how mode-minder does it
arthurno1 · 2022-10-28 14:07
Possible. Never heard of that package so no idea, but you are probably correct..
JDRiverRun · 2022-10-29 03:27
Yep [that's it](https://github.com/jdtsmith/mode-minder/blob/0746fbe3205f18a50c1314512db9573d10df7f87/mode-minder.el#L77-L81).
[deleted] · 2022-10-29 03:30
[deleted]
JDRiverRun · 2022-10-29 21:12
>Finally there are modes avialable in libraries but not loaded. Minor-modes that features are usually autoloaded, buI am not sure if all minor-modes are autoloaded? mode-minder works around this by loading all modes it is aware of. If you are using native-comp, this is also a nice way to get "everything compiled". I recently added a few tweaks to find even more minor modes. Many were created before define-minor-mode macro existed, so are not on minor-modes-list.
bikenaga · 2022-10-29 23:47
There's a list [here](https://www.emacswiki.org/emacs/List_Of_Major_And_Minor_Modes) for emacs 24. The description notes that the list was obtained by running `emacs -Q`, then doing `M-x rgrep` and searching on `define-derived-mode` and `define-minor-mode`. You have to do this in a directory containing the elisp source. I tried this in the top level `emacs` directory where I built emacs 29, and I got 600 - 700 matches for each. However, the output was pretty messy, and there were surely duplicates. Maybe someone who is interested can try this and figure out a good way to clean up the output.
arthurno1 · 2022-10-31 00:14
I didn't want to answer before I had time to check your app. It looks very nice indeed! It does find even none autoloaded minor modes, like emms-playing-time-display-mode and alike. Good job.
arthurno1 · 2022-10-31 00:18
I just answered in another comment, it does look nice. Though if you wish to compile everything, why not just M-: (native-compile-async package-user-dir t) and (native-compile-async source-directory t) Or when you build Emacs: $ make NATIVE_FULL_AOT=1 -jN