C-h m gives you help on the current mode, and it typically tells you the name of the command that turns the mode on.
For example, in Emacs-Lisp mode C-h m tells you that you are in Emacs-Lisp mode. The command that turns the mode on is just emacs-lisp-mode.
C-h m also provides a link to the library that defines the mode, and if you click on that link it takes you to the definition of the mode command. For example, in Emacs-Lisp mode C-h m tells you:
Emacs-Lisp mode defined in `lisp-mode.el'
And if you click the link lisp-mode.el then Emacs takes you to the definition of command emacs-lisp-mode, which is the command that turns the mode on:
(define-derived-mode emacs-lisp-mode prog-mode "Emacs-Lisp"
"Major mode for editing Lisp code to run in Emacs.
...)
org-modefor example?(equal major-mode "org-mode")always returnnileven when I'm in org-mode. – Student Apr 21 '20 at 02:00"org-mode"is a string, whereas the value ofmajor-modeis a symbol, so naturally they are not (cannot be) equal.(equal major-mode 'org-mode)would betinorg-modebuffers. Generally to test the current buffer's major mode you would use(derived-mode-p 'org-mode), which will return non-nil not only fororg-modeitself, but also for any mode which was derived fromorg-mode. – phils Apr 21 '20 at 02:07(type-of major-mode)to check that it's actually a symbol but not a string! – Student Apr 21 '20 at 02:14