jmickelin / vim-empty-lines-mode

Vim-like empty line indicator at end of files for Emacs.
GNU General Public License v3.0
10 stars 3 forks source link

A way to disable `global-vim-empty-lines-mode` on `shell-mode` or `eshell-mode`? #1

Closed sooheon closed 9 years ago

sooheon commented 9 years ago

How can I be selective about which modes global-vim-empty-lines-mode initialises on?

jmickelin commented 9 years ago

There are two ways:

  1. Initialize with global-vim-empty-lines-mode and selectively turn it off for certain modes, using:

    (add-hook 'eshell-mode-hook (lambda () (vim-empty-lines-mode -1))
    (add-hook 'shell-mode-hook (lambda () (vim-empty-lines-mode -1))
  2. Don't use the global initialization function, and use hooks to selectively call vim-empty-lines-mode in relevant modes, e.g.:

    (add-hook 'text-mode-hook 'vim-empty-lines-mode)

However, I should make it a bit more intelligent with the buffers where global-vim-empty-lines-mode should be ignored. I'll have to read up a bit on how packages conventionally do this, but I'll treat this as a bug for now. As a temporary fix, I'd go with method 2. above.

jmickelin commented 9 years ago

Sorry, I think I misunderstood you.

Did you mean to say that this was a bug or just your preferrence? If it's the latter, I'll remove the bug label and refer to the commands above, which should do the trick.

sooheon commented 9 years ago

Yep, these commands do the job, thanks. I think this issue can be closed, unless you want to keep it as a reminder for possible implementation of say a list of excluded global modes or something.

jmickelin commented 9 years ago

@sooheon I noticed that the code for selectively disabling the mode fails for shell-mode and eshell-mode if the corresponding shells haven't been previously loaded. Instead, run:

(eval-after-load 'esh-opt
    (add-hook 'eshell-mode-hook (lambda () (vim-empty-lines-mode -1))))
(eval-after-load 'shell
    (add-hook 'shell-mode-hook (lambda () (vim-empty-lines-mode -1))))