Fix `SPC i K` for the first line of buffer.

It feels like save-excursion should work for all cases.
But since I couldn't get it to work when you are on the first
character of the buffer, I jump to the appropriate point after.
This commit is contained in:
Travis B. Hartwell 2015-07-04 06:10:00 -06:00 committed by syl20bnr
parent 655b0102a5
commit 4d6b682f1a
1 changed files with 11 additions and 6 deletions

View File

@ -661,12 +661,17 @@ For instance pass En as source for english."
(defun spacemacs/insert-line-above-no-indent (count)
(interactive "p")
(save-excursion
(evil-previous-line)
(evil-move-end-of-line)
(while (> count 0)
(insert "\n")
(setq count (1- count)))))
(let ((p (+ (point) count)))
(save-excursion
(if (eq (line-number-at-pos) 1)
(evil-move-beginning-of-line)
(progn
(evil-previous-line)
(evil-move-end-of-line)))
(while (> count 0)
(insert "\n")
(setq count (1- count))))
(goto-char p)))
(defun spacemacs/insert-line-below-no-indent (count)
"Insert a new line below with no identation."