How do I find the elisp code for the major mode in use in the current buffer?

1 Answer 1


The variable major-mode will be set to a symbol describing the mode.

If the mode was written anytime in recent history, that symbol will be a function that activates the mode.

So you can simply "find" the major mode's code.

(find-function major-mode)

Or interactively, run M-x describe-mode and click the link to the source file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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