I am implementing a feature to automatically generate a bookmark name by extracting information from the current context. Many packages provide such info. For example which-func (through (which-function)) and semantic/find (through (semantic-current-tag)).

How do I detect availability/support of which-func or semantic/find for the current buffer?

Is this exposed by the mode writer through modes so from (eq major-mode DESIRED-FEATURE-mode) and DESIRED-FEATURE-minor-mode variable?


You can check if which-func feature is useful in a major-mode by checking the value of the variable which-func-functions.

From the documentation:

List of functions for which-function to call with no arguments. It calls them sequentially, and if any returns non-nil, which-function uses that name and stops looking for the name.

If the major-mode does not use which-func, the value of this variable will be nil and you will see [???] in the mode-line in bottom-right when you enable the which-function-mode.

If the major-mode makes use of which-func, you will see a list of function names assigned to this variable.

The which-func package is not required by default and is autoloaded when you call the which-function-mode command. After that you will be able to access the which-func-functions variable.

  • 1
    For instance, verilog-mode does not have which-func support but I added my own support by writing functions to parse strings for which-func: Apr 20 '15 at 19:04
  • The link in above comment points to a specific commit of my setup-verilog.el. If interested in the latest (with probably lesser bugs), see here. Jul 16 '15 at 14:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.