Questions tagged [minor-mode]

provides optional features that users may enable or disable independently of the choice of major mode. Minor modes can be enabled individually or in combination with other modes.

Filter by
Sorted by
Tagged with
38
votes
4answers
8k views

How to override major mode bindings

Sometimes my global keybindings are overridden by a major mode. An easy example is the following setting in my init file (global-set-key (kbd "C-j") 'newline-and-indent) But annoyingly this ...
31
votes
3answers
5k views

Is there an Emacs mode which highlights differences from the committed version?

One feature that Xcode has which I think is pretty neat is a "Comparison" mode, which continually shows differences between the current buffer and the most recent commit. Is there anything like this ...
24
votes
3answers
6k views

Proper way to enable minor mode

I have foo-mode and would enable bar-minor-mode for it. So which way is more common and preferable? A (add-hook 'foo-mode-hook 'bar-minor-mode) B (add-hook 'foo-mode-hook (lambda () ...
22
votes
8answers
6k views

Hide list of minor modes in mode-line

I use quite a few minor modes and usually I know which minor mode is enabled in every major mode. If I really want to see the full list, I can run C-h v minor-mode-list. At the same time, my mode ...
22
votes
1answer
4k views

Synchronized scrolling in two windows

Is there a way to reflect the navigation commands in the current window in another visible window. I have two related LaTeX files displayed in two windows and would like to scroll through them ...
12
votes
2answers
438 views

How do you update a minor mode definition as you develop it?

I started coding a minor mode to provide some keybindings. My initial attempt had a typo: (define-minor-mode borked-mode "A mode defined with a broken key binding" nil nil '(([b] . 'previous-...
12
votes
1answer
1k views

Disable minor mode in all open buffers

Often I have many buffers open and, for whatever reason, I no longer wish to use a particular minor mode with them. Is there currently a built-in way to disable a particular minor mode for all open ...
10
votes
2answers
2k views

Get list of active minor modes in buffer

How get a list of active minor modes in current buffer? Docs (info "(elisp)Minor Mode Conventions") say: Define a variable whose name ends in ‘-mode’. We call this the "mode variable". The minor ...
10
votes
1answer
731 views

Disabling electric-indent-mode for one mode (latex mode) only

I don't like the way electric indent mode works in latex-mode. Everywhere else (at least everywhere I use), it's great. How can I permanently disable electric indent mode for latex mode only, but ...
8
votes
1answer
580 views

Is there a 'caps-lock-mode' for those of us who've rebound the key?

Rebinding your caps-lock key to control is a popular thing to do (though there are arguments against it, even if a bit pedantic). However, the language I find a lot of my time in uses runs of ...
8
votes
2answers
1k views

Disable hl-line-mode only for eshell and ansi-term

I have global-hl-line-mode setup in my init file: (use-package hl-line :init (global-hl-line-mode 1)) Is it possible to disable it when I am in eshell and ansi-term? I tried adding a hook like ...
8
votes
3answers
2k views

Auto enable minor modes in fundamental-mode

By design, the fundamental-mode is bare bones as other major modes are supposed to derive from this one. From the info page (elisp) Major Modes, we have: This is the major mode command for ...
8
votes
2answers
846 views

How to activate semantic-mode for specific major modes only?

I've seen this question a lot. But none of the replies fixed my issue: the minor mode stays on in others modes. So far, I have tried: (use-package stickyfunc-enhance :config ;; (add-to-list '...
7
votes
3answers
2k views

global-auto-revert-mode doesn't seem to work?

My init file includes (setq global-auto-revert-mode t) and I can confirm it's true with C-h v. But I still have to manually revert all my files with revert-buffer whenever I change git branches. I ...
7
votes
1answer
511 views

Enabling a minor mode with a file-local variable prop line

The first line of a plain-text file reads: # -*- eval: (auto-revert-tail-mode 1); -*- Yet Emacs does not enable auto-revert-tail-mode after opening this file. What is wrong?
6
votes
2answers
3k views

Disable Minor Mode in Major Mode

I am trying to disable a minor mode (flycheck) for the latex major mode. This is what I have so far. (defun disable-flycheck-in-tex-src-block () (flycheck-mode -1)) (add-hook 'latex-mode-hook '...
6
votes
3answers
858 views

How to make electric-pair-mode buffer local?

I would like electric-pair-mode to be enabled only in the buffers where I am editing, say, Emacs Lisp. But it seems that electric-pair-mode is a "global minor mode": if it is activated in one buffer, ...
5
votes
2answers
1k views

Can I add highlighting in a minor mode?

I'm trying to understand minor modes with the goal of adding a minor mode for Jinja2 syntax highlighting (from jinja2-mode) to stuff like YAML. I'm running into problems though. When following a ...
4
votes
1answer
491 views

How to look up documentation for a minor mode?

I just decided that I should try the outline-minor-mode for showing and hiding Emacs lisp defun definitions in an Emacs Lisp file. So I typed M-x outline-minor-mode and then I would like to get an ...
4
votes
1answer
956 views

Turn off fringes in text-mode

How do I turn off fringes in text-mode? The closest I've gotten is this: (add-hook 'text-mode-hook (lambda () (set-fringe-mode '(0 . 0)))) But that turns off fringes ...
4
votes
1answer
1k views

(setq yas-snippet-dirs …) not working

I am unable to set up yasnippet the way I want to set it up. I only want to use yasnippet for a particular set of modes, so I don't want to use yas-global-mode. I only want to use my own snippets, ...
4
votes
2answers
125 views

Bind several minor modes together

This has been driving me crazy, I can't get this to work. I want to link the on-off status of a handful of minor modes, in particular evil-mode, evil-quickscope-mode, hl-paren-mode, and a few others. ...
4
votes
1answer
96 views

How to suppress a minor mode's key binding in only certain major modes?

Suppose that I use minor mode MIN with a whole bunch of major modes. In one of those major modes, call it MAJ1, MIN's binding for a specific key K is undesirable; I would therefore like to suppress ...
4
votes
0answers
52 views

How to do searches in MediaWiki mode?

How to do searches in MediaWiki mode? If I instead do searches in Web browser, and then copy the URI of the page into Emacs, it sort of defeats the purpose of using Emacs as and MediaWiki power ...
3
votes
1answer
126 views

How can I 'layer' a keybinding?

I'm trying to create an emmet-like minor mode that will trigger on SPC (or TAB) if the previous text is expandable, but I don't want to completely override bindings that already exist for the key. ...
3
votes
1answer
294 views

How to learn the stroke order of a kanji (or kana) character using Emacs

As a devoted Emacs user and a Japanese beginner learner, I've been using the Emacs' Japanese input method quite a lot during recent months. However, I've been looking for a way to leverage Emacs' ...
3
votes
1answer
694 views

how to disable all the minor modes (when a specific major mode is enabled) with elisp

Is there any function do disable all the minor modes if I enable a specific major mode (let's take the text-mode as an example)?
3
votes
1answer
117 views

save variable on exit

I have own minor-mode with 2 (for now) user specific variables (string and int). For now they are dropping to default values each emacs restart. Which is not convenient. How and where it is better to ...
3
votes
1answer
103 views

Minor markdown-mode for comments

I like to use the markdown-mode for READMEs. And I would like to use the markdown-mode as a minor-mode for comments in other major-modes like sh-mode. Is this possible somehow?
3
votes
2answers
709 views

Making it clearer I'm in god-mode

I've been using emacs for a while, but am being quite dismayed by some quite hectic pinky-pain, so have just started using Chris Done's god-mode, which is great, I like it so far. The problem is that ...
2
votes
3answers
706 views

List all buffers with specific mode?

list-buffers gives a list of all buffers. But, I want only buffers where a specific minor mode (say aggressive-indent-mode) mode is enabled. How can I filter them?
2
votes
1answer
499 views

Global minor mode not global?

I am trying to write a global minor mode. The following illustrates my problem: (define-minor-mode global-foo-mode :global t :lighter " FOO") then run M-x global-foo-mode The message displayed is ...
2
votes
3answers
126 views

pop-up a list of enabled minor modes in a readable format?

I like to keep my modeline pretty minimal, so I'm hiding most minor-mode lighters. Occasionally I want to check which minor-modes are enabled, and it would be nice if I could trigger a pop-up that ...
2
votes
1answer
89 views

How to automatically remove a hook provided by a minor mode after disabling that mode?

I want to write a minor which evaluates some code in the buffer after saving a file. I activate after-save-hook for this mode: (add-hook 'my-minor-mode-name-hook #'(lambda () (add-hook 'after-save-...
2
votes
2answers
105 views

Disable minor mode when keys not in it's keymap are pressed

I was using this to implement line duplication in emacs and decided to bind it to C-c d and it works without problems What would be cooler though is if I can use C-c d do duplicate a line and then be ...
2
votes
2answers
96 views

When Emacs loads variable customization?

I have a minor mode that declare a customizable variable as its keymap prefix: (defcustom mymode-keymap-prefix "C-c *" "Prefix for `mymode-mode'." :group 'mymode) (defvar mymode-mode-map (let (...
2
votes
1answer
560 views

Proper way to change prefix key for minor-mode map?

The package HideShow (hs-minor-mode) defines some key bindings with prefix key C-c @. What is the proper way to change this prefix key to C-c h? The new key binding should also replace the old key ...
2
votes
1answer
406 views

Make all text of a given face invisible

Is there a straightforward way to make all text with a given face invisible? I don't believe I can make invisibility be intrinsic to the face, but can I perhaps specify a minor mode that makes sure ...
2
votes
1answer
103 views

How to enable the superword minor mode globally?

I am just wondering how to enable the superword-mode globally? I tried to enable it following the answers found here: How to enable ido-mode forever? , using: (require 'superword-mode) (...
2
votes
1answer
44 views

Enable minor-mode during function call

Similar to the somewhat neat, but in the end too clunky, hydra-goto-line, I'd like to customize goto-line to enable linum-mode, but only during the function call. I tried add-advice, :before and :...
2
votes
1answer
122 views

How to detect if current major-mode supports which-function and semantic/find?

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-...
2
votes
1answer
47 views

How to use `recover-session` and `dired-omit-mode` in Emacs 26 and lower?

Using Emacs 26.1, I have enabled dired-omit-mode globally with (add-hook 'dired-mode-hook #'dired-omit-mode). When using recover-session, I don't see any files. How to fix this? Creating a .dir-...
2
votes
2answers
202 views

Are there hooks for leaving modes?

There seems to be a bug in clojure-mode (mentioned here) because it does things in a mode hook (for paredit-mode) but doesn't undo them when the mode is turned off. I understand that add-hook can ...
2
votes
2answers
60 views

How to conditionally abort a minor-mode invocation?

I have a minor mode definition like this, and I want to prevent it from being enabled when the config variable example-mode-config has not been defined. ;;; .... ;;;###autoload (define-minor-mode ...
2
votes
1answer
253 views

buffer-local advice

I am trying to create a buffer local advice to run some code when a minor mode is disabled. I looked through the documentation for add-function and saw this If PLACE is a symbol, its `default-value' ...
2
votes
1answer
684 views

How to disable `abbrev-mode`?

I am using Spacemacs and it always ask me to save .cache/abbrev_defs which is very annoying. I tried to put (abbrev-mode -1) in dotspacemacs/user-config function. But it still ask for save the ...
2
votes
1answer
69 views

Global minor mode that requires another during its lifetime

Say I'm developing a minor mode A that happens to need minor mode B enabled during its lifetime. The most straightforward way is to do something like: (define-minor-mode A-mode :global t :...
2
votes
1answer
907 views

How to make a specific read-only buffer writable?

The readonly status of the current buffer can be toggled with (read-only-mode) or pressing C-x C-q but I intend to make a buffer which is not current, writable. The below is what I am using (with-...
2
votes
1answer
95 views

Set buffer font with minor mode

I would like my minor mode to set the buffer font, but not the frame font (the font contains special characters I need, but the hinting is abysmal). I got to this point: (define-minor-mode transcribe-...
2
votes
1answer
203 views

Mode local variables

I frequently use file-local variables, but after writing some minor modes I find the need to implement mode-based behavior. Let's say I want to define a variable errors-list-regexp that varies ...