Emacs设置哪个功能模式 [英] Emacs Setting which-function-mode

查看:185
本文介绍了Emacs设置哪个功能模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我打开Emacs时,我希望默认使用这个功能模式。我已将以下行添加到.emacs文件中。

 (setq which-func-mode t)
(setq which-function-mode t)

当我打开一个.cpp文件并导航到一个函数的正文时,我没有看到函数名在状态栏的底部就像我应该的。如果我然后运行M-x哪个功能模式,消息是禁用哪个功能模式,所以它看起来像我的.emacs文件中的行,但不是很有效。我在.emacs文件中设置了错误的东西,还是还有其他问题吗?


解决方案

不幸的是,setq不会为此工作,因为这是一个函数,而不是一个变量。您需要使用customize设置变量,或者调用传递值t的哪个功能模式函数。



'custom'是emacs处理配置大多数软件包功能的方式。通常,'M-x customize-apropos'后跟一个包的名称将为您提供该包的大部分配置选项。如果您知道配置参数的具体名称,还可以使用customize-variable来转到该特定参数。请注意,自定义变量中的项目本身并不总是变量 - 通常会自定义调用函数或执行某些其他活动来实际执行配置。



我认为你可能想要使用'定制'为此。

  M-x自定义变量< RET> 
which-function-mode

应该给你以下内容:





将值切换为开,然后设置为当前会话,并保存以备将来的会话。如果你不喜欢自定义,你可以调用.emacs中的函数:

 (哪个功能模式t )

这是在emacs 23,但我相信22应该是相似的....对于emacs 21 ,我不认为默认情况下是自定义的(已经很长时间了,但是我可能会出错),而您可能需要使用函数调用表单。


I would like to have which-function-mode on by default when I open up Emacs. I've added the following lines to my .emacs file.

(setq which-func-mode t) 
(setq which-function-mode t) 

When I open up a .cpp file and navigate to the body of a function, I'm not seeing the function name in the status bar at the bottom like I should. If I then run M-x which-function-mode, the message is "Which-Function mode disabled" so it looks like the line in my .emacs file takes but is not quite working.

Am I setting the wrong thing in my .emacs file or is something else going wrong?

解决方案

Unfortunately setq won't work for this, as this is a function, not a variable. You need to either use 'customize' to set the variable, or to call the 'which-function-mode' function passing a value of 't'.

'customize' is the way that emacs deals with configuring functionality for most packages nowadays. Often doing 'M-x customize-apropos' followed by a the name of the package will give you most of the configuration options for that package. If you know the specific name of the configuration parameter, you can also use 'customize-variable' to go to that specific parameter. Note that the items in 'customize-variable' are not always variables per se - often customize calls a function or performs some other activity to actually perform the configuration.

I think you probably want to use 'customize' for this.

M-x customize-variable<RET>
which-function-mode

should give you something like the following:

Toggle the value to 'on', then set for the current session and save for future sessions. If you don't like customize, you can just call the function from your .emacs:

(which-function-mode t)

This is in emacs 23, but I believe 22 should be similar.... For emacs 21, I don't believe customize was in there by default (it's been a long time, though so I could be wrong), and you might have to use the function call form instead.

这篇关于Emacs设置哪个功能模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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