I’ve seen the following code used hundreds of times:
(buffer-local-value 'major-mode buffer)
or
(with-current-buffer buffer ‘major-mode)
Why don’t we add the following function to Emacs and simplify a bit the lives of Elisp hackers:
(defun buffer-mode (buffer)
"Return the major mode associated with BUFFER."
(buffer-local-value ‘major-mode buffer))
Trivial, but useful.
--
Cheers,
Bozhidar