I have tried to search Google and look in the manual, but still cannot find how to get major mode of a buffer object. Can you help me with an example or a reference. Thank
Is there a problem with that?
(defun buffer-mode (buffer-or-string) "Returns the major mode associated with a buffer." (with-current-buffer buffer-or-string major-mode))
with-current-buffer will restore your buffer when it returns.
with-current-buffer