emacs lisp, how to get buffer major mode?

后端 未结 7 2181
执笔经年
执笔经年 2020-12-07 23:04

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

7条回答
  •  庸人自扰
    2020-12-07 23:16

    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.

提交回复
热议问题