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:
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 ...
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-...
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-...
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."
(dolist (buffer (buffer-list))
(funcall mode-fn -1))))
To use (for ...
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 ...
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 ...
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:
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.
I think the best answer I can give you is to stay away from the "inline keybindings feature" of define-minor-mode. Use
(let ((map (make-sparse-keymap)))
(define-key map [b] 'previous-line)
"A mode defined with a broken key binding"
Instead. Then you can ...
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:
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.
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.
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'.
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 ...
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)
Use Rich-minority with config:
(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
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:
And the bit you missed is that, should the mode in question be indexed in the manual, you can ...
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 ...
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:
Here's one more way to do it that has some advantages,
assuming that you're editing your own config, not a package that
(defun custom-foo-hook ()
(define-key foo-mode-map "C-c C-b" #'foobar))
The advantage is that everything is stored ...
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 ()
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 ...
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 ...
Here is what worked for me:
(defvar hidden-minor-modes ; example, write your own list of hidden
'(abbrev-mode ; minor modes
(defun purge-minor-modes ()
(dolist (x hidden-minor-...
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 (major or minor) do not actually use x-mode.el either. That naming convention is generally used in multi-file packages where the core functionality is implemented ...
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 ...