Does it mean that C programming is running under prog-mode
and c-mode
?
No, because, as you later quote:
Major modes are mutually exclusive; each buffer has one and only one major mode at any time.
So your buffer can only be in one or the other.
Is prog-mode
a universal mode for all the programs?
No, it is a universal parent mode for all programming modes.
It additionally implies that prog-mode
is a major mode like c-mode
.
Yes, prog-mode
is a normal major mode derived from fundamental-mode
. Similarly c-mode
is a normal major mode derived from prog-mode
. The difference is that prog-mode
alone is quite bare, and is not intended to be enabled directly.
What does prog-mode
do here, is it a minor mode but stated vastly in the major mode part?
No, it is a normal major mode. It is provided as a convention for major mode authors to derive their modes from, and as a convenience for users to more easily customise all their programming modes.
For example, if a user wants to enable show-trailing-whitespace
in all their programming modes, they may first define a hook like the following:
(defun my-show-trailing-space ()
"Enable `show-trailing-whitespace' in the current buffer."
(setq show-trailing-whitespace t))
Instead of adding this function to the mode hook of every programming mode they use, like so:
(mapc (lambda (hook)
(add-hook hook #'my-show-trailing-space))
'(c-mode-common-hook
emacs-lisp-mode-hook
perl-mode-hook
prolog-mode-hook
...))
They can instead simply add it to the mode hook of the parent mode, i.e. prog-mode-hook
:
(add-hook 'prog-mode-hook #'my-show-trailing-space)
As such, prog-mode
provides common settings for all programming modes derived from it.