32
votes
Accepted
Proper way to enable minor mode
It depends on which version(s) of Emacs you are using (or targeting). Iff you are exclusively using Emacs 24+ then you can safely use variant A:
* Incompatible Lisp Changes in Emacs 24.1
** Passing ...
- 45.5k
31
votes
Is there an Emacs mode which highlights differences from the committed version?
Dmitry Gutov's diff-hl library provides diff-hl-mode, which gives you the fringe highlighting shown in the top window in the following screenshot (with the actual diff displayed in the bottom window ...
- 45.5k
21
votes
Accepted
Hide list of minor modes in mode-line
Diminish mode (available in Melpa) will do this.
(diminish 'projectile-mode)
- 619
19
votes
Hide list of minor modes in mode-line
As mbork commented, you can use delight.el to selectively modify or disable minor (and indeed major) mode text in the mode line.
One of the advantages is that it takes care of the eval-after-load (...
- 45.5k
19
votes
Accepted
Disable minor mode in all open buffers
This does require a custom elisp function unless the minor mode has a (global-*-mode) function attached to it.
Luckily, it is a pretty simple function:
(defun global-disable-mode (mode-fn)
"...
- 2,575
19
votes
Get list of active minor modes in buffer
If you're just looking to see what minor modes are being used in a buffer, but don't need to use the list programmatically use:
M-x describe-mode
This command will open a new buffer that begins with ...
- 291
15
votes
How do you update a minor mode definition as you develop it?
I think the best answer I can give you is to stay away from the "inline keybindings feature" of define-minor-mode. Use
(defvar borked-mode-map
(let ((map (make-sparse-keymap)))
(define-key map ...
- 25.8k
15
votes
Accepted
Disabling electric-indent-mode for one mode (latex mode) only
The command you need is electric-indent-local-mode. You can use this to turn off electric-indent-mode in any buffer by calling it manually: M-x electric-indent-local-mode. This is a toggle, so calling ...
- 21.1k
14
votes
global-auto-revert-mode doesn't seem to work?
A minor mode is not enabled/disabled by setting a variable. The minor mode variable should be used to check the "mode enabled" status, not to set the mode state. If its value is t, the minor mode is ...
- 24.8k
13
votes
Accepted
How do you update a minor mode definition as you develop it?
The first time you evaluate your define-minor-mode it defines a variable borked-mode-map with the key bindings you specified. Once that symbol has been defined, however, re-evaluating your define-...
- 19.8k
12
votes
Accepted
Disable Minor Mode in Major Mode
As per comments, this is because you're using a globalized minor mode: https://stackoverflow.com/questions/6837511/automatically-disable-a-global-minor-mode-for-a-specific-major-mode
C-hf global-...
- 45.5k
11
votes
Is there an Emacs mode which highlights differences from the committed version?
You don't specify what version control system you're using, but if it's git, ou can use git-gutter to put an indicator in the margins when a line has been added, deleted or modified. It's available ...
- 12.5k
11
votes
Accepted
Disable hl-line-mode only for eshell and ansi-term
global-hl-line-mode sets variable global-hl-line-mode to t. The global mode is separate from the non-global (hl-line-mode).
The following will disable it in the selected mode:
(add-hook 'eshell-...
- 4,257
10
votes
Is there an Emacs mode which highlights differences from the committed version?
You should check out Ediff. It can both display diffs and act as a (3-way) merge tool. It lets you easily revert changes, and also highlights refined differences to show you only the parts of each ...
- 375
10
votes
Accepted
Is there a 'caps-lock-mode' for those of us who've rebound the key?
Try the caps-lock minor mode package:
Summary: Caps-lock as a minor mode
Homepage: http://elpa.gnu.org/packages/caps-lock.html
- 19.8k
10
votes
Accepted
List all buffers with specific mode?
You can do this easily in ibuffer.
In an ibuffer buffer, run M-x ibuffer-filter-by-predicate and it will prompt you for a form. For minor modes, just enter the minor mode name variable as the ...
- 12.2k
9
votes
Proper way to enable minor mode
Why would you define a new command that does exactly what bar-minor-mode does?
Starting with 24.1, all of these are completely equivalent, so just use the less redundant one: option A
(add-hook '...
- 22.6k
9
votes
Hide list of minor modes in mode-line
Use Rich-minority with config:
(require 'rich-minority)
(rich-minority-mode 1)
(setf rm-blacklist "")
I also have the thought like you, but I shorten the mode-line more paranoid:
Remove all ...
- 980
9
votes
Accepted
How to look up documentation for a minor mode?
You've seen the basics, really. Your main problem was that this documentation was wrong, not that you weren't looking in the right place.
The slightly more direct way to read that documentation for a ...
- 45.5k
9
votes
Accepted
How to automatically remove a hook provided by a minor mode after disabling that mode?
The minor mode's hook is called both when activating and deactivating the minor mode, so how 'bout
(add-hook 'my-minor-mode-name-hook
(lambda ()
(if my-minor-mode-name
...
- 25.8k
8
votes
Accepted
Global minor mode not global?
The problem is that you are leaving out the required argument DOC when you call define-minor-mode. (Or more accurately, you are passing :global as the DOC parameter)
Either provide a doc string or ...
- 19.8k
8
votes
Hide list of minor modes in mode-line
Here is what worked for me:
(defvar hidden-minor-modes ; example, write your own list of hidden
'(abbrev-mode ; minor modes
auto-fill-function
flycheck-mode
flyspell-mode
...
- 4,843
8
votes
Get list of active minor modes in buffer
Try this:
(mapcar #'car minor-mode-alist)
In fact, you will find that this value often differs from minor-mode-list.
- 10.1k
7
votes
Accepted
Enabling a minor mode with a file-local variable prop line
Take a look at the variables enable-local-eval and enable-local-variables. If you've changed one or both of these from their default values it could explain the behavior you are seeing.
For example ...
- 19.8k
7
votes
Proper way to enable minor mode
Here's one more way to do it that has some advantages,
assuming that you're editing your own config, not a package that
you distribute.
(add-hook 'foo-mode-hook
#'custom-foo-hook)
(defun ...
- 13.8k
7
votes
Accepted
Turn off fringes in text-mode
The documentation offers a couple of options: https://www.gnu.org/software/emacs/manual/html_node/elisp/Fringe-Size_002fPos.html
One of the options mentioned uses buffer-local variables -- i.e., ...
- 18.3k
7
votes
Accepted
How can I 'layer' a keybinding?
There are various ways you could approach this, but one in particular seems more or less designed for the purpose.
You define the key using the menu-item syntax, with a :filter function that returns ...
- 45.5k
7
votes
Accepted
How to make a specific read-only buffer writable?
Use (read-only-mode -1), not (read-only-mode nil).
See the doc string of macro define-minor-mode (C-h f define-minor-mode) for more info about the argument to a minor-mode function.
And see the doc ...
- 72.7k
6
votes
Accepted
File mode name with -mode suffix or not?
Don't name your file x-mode.el if it does not actually provide a mode of some sort: that seems confusing. If you are providing library x, just call the file x.el.
From what I've seen, most modes (...
- 19.8k
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
minor-mode × 167major-mode × 23
key-bindings × 22
hooks × 21
keymap × 10
org-mode × 9
customize × 6
init-file × 5
mode-line × 5
buffers × 4
variables × 4
help × 4
buffer-local × 4
spacemacs × 3
font-lock × 3
text-properties × 3
scrolling × 3
python × 2
debugging × 2
window × 2
faces × 2
syntax-highlighting × 2
region × 2
auto-complete-mode × 2
abbrev × 2