emacs lisp,如何获取缓冲区主要模式? [英] emacs lisp, how to get buffer major mode?

查看:137
本文介绍了emacs lisp,如何获取缓冲区主要模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图搜索Google并查看手册,但是仍然找不到如何获得缓冲区对象的主要模式。你可以帮我一个例子或参考。感谢

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. Thanks

只有解决方案我可以找到是在更改缓冲区然后更改回原始缓冲区后查询主模式。有更好的方法吗?

only solution I could find was to query major-mode after changing the buffer and then changing back to original buffer. Is there a better way to do it?

推荐答案

是否有问题?

(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 将在返回时恢复缓冲区。

with-current-buffer will restore your buffer when it returns.

这篇关于emacs lisp,如何获取缓冲区主要模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆