39

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 Melpa and make use of bind-key* or bind-keys* macro that's part of the bind-key package that ships with use-package. From the documentation of bind-key.el: ;;...


30

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 for comparison): It uses the generic vc functionality in Emacs in order to be VCS-agnostic. The readme says "Tested with Git, Mercurial, Bazaar and SVN. May ...


26

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 a nil argument to a minor mode function call now ENABLES the minor mode unconditionally. This is so that you can write e.g. (add-hook 'text-mode-hook 'foo-...


25

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 override all bindings: Defining your own minor mode and key map as shown below. Activate your minor mode globally (define-key my-mode-map (kbd "C-j") #'newline-and-...


24

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.


19

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) "Disable `MODE-FN' in ALL buffers." (interactive "a") (dolist (buffer (buffer-list)) (with-current-buffer buffer (funcall mode-fn -1)))) To use (for ...


15

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 (which you need to write manually with diminish.el in most use-cases), which makes the configuration cleaner. You still need the same information -- the name of ...


15

Diminish mode (available in Melpa) will do this. (diminish 'projectile-mode)


14

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 on, else the mode is off. See the below snippets to see how to control any minor mode. Replace MINOR-MODE-NAME with the actual minor mode name you are dealing ...


11

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-minor-mode won't change it. You could delete the various borked-mode-xxx symbols using unintern and then re-evaluate your code. Try: (unintern 'borked-mode-map) ...


11

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 [b] 'previous-line) ... map)) (define-minor-mode borked-mode "A mode defined with a broken key binding" :global nil ...) Instead. Then you can ...


10

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 hunk that actually changed. ediff-revision will let you easily compare against the most recent commit, or any previous commits.


10

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 in MELPA via M-x package-install git-gutter.


10

Try the caps-lock minor mode package: Summary: Caps-lock as a minor mode Homepage: http://elpa.gnu.org/packages/caps-lock.html


9

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 predicate and it will only show you buffers with that minor mode activated. By default ibuffer-filter-by-predicate is bound to / e in ibuffer-mode You can also ...


9

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-flycheck-mode led me to C-hf flycheck-may-enable-mode and C-hv flycheck-global-modes which tells me: flycheck-global-modes is a variable defined in `flycheck.el'. ...


8

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 unwanted spaces Remove all spaces and "min-width" of the buffer position info field. ;; Remove all unwanted spaces (setq-default mode-line-format '("%e" ...


8

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 mode is by calling describe-function: C-hf outline-minor-mode And the bit you missed is that, should the mode in question be indexed in the manual, you can ...


8

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 nil as the second argument: (define-minor-mode global-foo-mode nil :global t :lighter " FOO") Note that define-minor-mode is a macro. You can see how it is ...


7

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-mode-hook (lambda () (setq-local global-hl-line-mode nil))) (add-hook 'term-...


7

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 'foo-mode-hook #'bar-minor-mode)


7

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 custom-foo-hook () (bar-minor-mode 1) (baz-minor-mode 1) ;; ... (define-key foo-mode-map "C-c C-b" #'foobar)) The advantage is that everything is stored ...


7

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 a full list of your minor modes, as well as giving a brief description of the major modes, and any parent modes that may have been run.


7

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 the command to be called. If the function returns nil, Emacs treats it as undefined in that keymap, and continues looking for a binding in the lower-priority ...


7

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 it again in the same buffer turns it back on again. To do this automatically from your init file, you need to set up a hook. First, define the hook: (defun ...


6

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., left-window-fringe and right-window-fringe. However, the documentation discusses some exceptions when those settings will not take effect immediately. The ...


6

Try this: (mapcar #'car minor-mode-alist) In fact, you will find that this value often differs from minor-mode-list.


5

You are looking for visual-line-mode. To enable, do M-x visual-line-mode. To enable it globally, do M-x global-visual-line-mode (or in your init file, place: (global-visual-line-mode 1)). From the docstring: When Visual Line mode is enabled, `word-wrap' is turned on in this buffer, and simple editing commands are redefined to act on visual lines, not ...


5

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 if enable-local-eval is nil then that eval line in your file would be ignored.


5

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 inf-haskell-mode haskell-indent-mode haskell-doc-mode smooth-scroll-mode)) (defun purge-minor-modes () (interactive) (dolist (x hidden-minor-...


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