49 votes
Accepted

How to override major mode bindings

There is a "shortcut" approach too for the same solution if you don't want to define your own minor mode (that I talk about in my first answer). You can install the use-package package available from ...
user avatar
  • 24.3k
36 votes

How to override major mode bindings

You can define your own minor mode and its key map and have that override all other modes (minor + major). That's exactly why I chose to write my own minor mode. Steps to have your key bindings ...
user avatar
  • 24.3k
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 ...
user avatar
  • 43.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 ...
user avatar
  • 43.5k
31 votes
Accepted

Synchronized scrolling in two windows

M-x scroll-all-mode does exactly that. You can also refer to the emacs wiki on scroll-all-mode and how to make synchronized scrolling work with mouse scrolling.
user avatar
  • 24.3k
21 votes
Accepted

Hide list of minor modes in mode-line

Diminish mode (available in Melpa) will do this. (diminish 'projectile-mode)
user avatar
20 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) "...
user avatar
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 ...
user avatar
  • 291
17 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 (...
user avatar
  • 43.5k
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 ...
user avatar
  • 25.3k
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 ...
user avatar
  • 24.3k
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-...
user avatar
  • 19.2k
13 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 ...
user avatar
  • 20.3k
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-...
user avatar
  • 43.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 ...
user avatar
  • 12.1k
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-...
user avatar
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 ...
user avatar
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
user avatar
  • 19.2k
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 ...
user avatar
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 ...
user avatar
  • 930
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 '...
user avatar
  • 22.4k
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 ...
user avatar
  • 43.5k
9 votes

List all buffers with specific mode?

The accepted answer is only the correct one in the case of simply wanting to see a user-viewable list of specific buffers in the list-buffers display. However, if you want to programmatically ...
user avatar
  • 191
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 ...
user avatar
  • 25.3k
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 ...
user avatar
  • 19.2k
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.
user avatar
  • 10k
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 ...
user avatar
  • 13.6k
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 ...
user avatar
  • 19.2k
7 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 ...
user avatar
  • 4,773
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., ...
user avatar
  • 17.7k

Only top scored, non community-wiki answers of a minimum length are eligible