Removing spaces when to leave insert state doesn't work except open command.
Nobody has claimed this yet.
- Dominant language
- Emacs Lisp
- Stars
- 3.9k
- Forks
- 307
- PR merge metrics
- No merged PRs in 30d
Description
Issue type
- Bug report
Environment
Emacs version: GNU Emacs 25.2.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.22.10)
Operating System: Arch Linux
Evil version: 1.2.12
Evil installation type: MELPA
Graphical/Terminal: X
Reproduction steps
(package-initialize)
(require 'evil)
(electric-indent-mode 0)
(define-key insert-state-map [return] #'newline-and-indent)
(evil-mode 1)
In scratch buffer
i (defvar e ( RET ESC
Expected behavior
Remove the spaces.
Actual behavior
The spaces remain.
Further notes
Similar cases, vim remove spaces.
Is that intended behavior?
this code change the behavior as I expect.
(defun evil-maybe-remove-spaces-fix (&optional do-remove)
(if do-remove
(progn
(when (and
evil-maybe-remove-spaces
(save-excursion
(beginning-of-line)
(looking-at "^\\s-*$")))
(delete-region (line-beginning-position) (line-end-position))
(setq evil-maybe-remove-spaces nil)))
(setq evil-maybe-remove-spaces (memq this-command '(
evil-open-above
evil-open-below
evil-append
evil-append-line
newline
newline-and-indent
indent-and-newline)))))
(advice-add #'evil-maybe-remove-spaces :override #'evil-maybe-remove-spaces-fix)
7/11 I edited above code because I made mistakes about parenthis. The range is
from line 9 (looking-at ...
to line 11 (setq evil-maybe-remove-spaces ...
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue in an Emacs scratch buffer using the supplied package setup, key binding, and insert-state sequence. Start by reading evil-maybe-remove-spaces and its handling of evil-open-above, evil-open-below, evil-append, evil-append-line, newline, newline-and-indent, and indent-and-newline; done means the spaces are removed when leaving insert state as expected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- emacs-lisp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100