English 中文(简体)
Emacs Setting which-function-mode
原标题:

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:

alt text

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)))





相关问题
suppress additional braces in emacs electric mode

I started using ruby-electric-mode. I like it except that I am used to closing open brackets myself (the other pairing are still useful to me). How can I make emacs suppress additional brackets when ...

Setting up an emacs environment in windows?

I am currently constrained to a windows dev box and I want to migrate my projects from eclipse to emacs. What are some good references on setting up an emacs dev environment for windows? Anything ...

Emacs Setting which-function-mode

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

Enabling go mode for emacs

I don t seem to be able to enable a go mode for emacs. C mode doesn t work without semicolons. The best I have found is the JavaScript mode by Karl Landstrom, since JavaScript also doesn t require ...

Custom Emacs key bindings are not working

The key bindings I ve defined in my .emacs file aren t working. Here s the file: ;init modes (menu-bar-mode 0) (tool-bar-mode 0) (cua-mode) (column-number-mode) (fset perl-mode cperl-mode) (cperl-...

eval during emacs lisp macro expansion

How can I fix the simple macro foo in (elisp)Eval During Expansion? None of the followings work: (defmacro foo1 (a) `(setq (eval ,a) t)) (defmacro foo2 (a) `(setq ,(eval a) t)) (defmacro foo3 (...

Get local cvs comment history when committing file/s in emacs

I often commit files with similar cvs comment but not in a single operation. I would like to able to bring up previous comments I ve used in a previous commit when I am in the process of writing a ...

热门标签