Smarter delete-trailing-whitespace
This commit is contained in:
parent
81c58e0efa
commit
9577ec28c7
2 changed files with 4 additions and 13 deletions
|
@ -71,11 +71,11 @@
|
|||
|
||||
(defadvice delete-trailing-whitespace (around delete-trailing-whitespace-ignore-line activate)
|
||||
"Don't delete trailing whitespace on current line, if in insert mode."
|
||||
(let ((spaces (current-column))
|
||||
(first-col (1+ (save-excursion (evil-first-non-blank) (current-column)))))
|
||||
(let ((spaces (1- (current-column)))
|
||||
(linestr (buffer-substring-no-properties (line-beginning-position) (line-end-position))))
|
||||
ad-do-it
|
||||
(when (= spaces first-col)
|
||||
(insert (make-string (abs spaces) ? )))))
|
||||
(when (string-match-p "^[\s\t]*$" linestr)
|
||||
(insert linestr))))
|
||||
|
||||
;; Line wrapping
|
||||
(add-hook! text-mode 'narf|enable-hard-wrap)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue