Emacs Setting which
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 Mx 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 'Mx 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.
You probably need a hook to automatically turn which-func-mode
on whenever you load a file.
Try something like:
(add-hook 'c++-mode-hook '(lambda () (which-func-mode t)))
In your init.el or wherever you store your emacs configuration simply place the following line:
(which-function-mode 1)
It should only work for progamming modes and org mode. I only tested in a .txt file to make sure it didn't show up. If you need granularity do something like:
(add-hook 'python-mode-hook (lambda() (which-function-mode 1)))
上一篇: C ++关键字在Emacs中不着色
下一篇: Emacs设置哪个