How to obtain major mode of current buffer

You can obtain the major mode by using following snippet:

(buffer-local-value 'major-mode (current-buffer))