Browse Source

Make whitespace trimming work right with ws-butler

Taylor Bockman 7 years ago
parent
commit
155ab0b759
  1. 26
      dotfiles/emacs.d/init.el
  2. 4
      dotfiles/emacs.d/package.el

26
dotfiles/emacs.d/init.el

@ -70,8 +70,7 @@
;; Stuff all of the org files you want under ~/org and they will be loaded automatically ;; Stuff all of the org files you want under ~/org and they will be loaded automatically
;; and have their TODO items accessible by typing C-c a t ;; and have their TODO items accessible by typing C-c a t
(setq org-agenda-files '("~/org")) (setq org-agenda-files '("~/org"))
( (setq org-log-done t)
setq org-log-done t)
;;-------------------------------------------------------------------------------------- ;;--------------------------------------------------------------------------------------
;; Prefer unix style line endings ;; Prefer unix style line endings
@ -117,7 +116,8 @@ setq org-log-done t)
("Text" (or (filename . ".csv") ("Text" (or (filename . ".csv")
(filename . ".tsv") (filename . ".tsv")
(filename . ".txt") (filename . ".txt")
(filename . ".log"))) (filename . ".log")
(filename . ".json")))
("Emacs" (or (name . "^\\*scratch\\*$") ("Emacs" (or (name . "^\\*scratch\\*$")
(name . "^\\*Messages\\*$"))) (name . "^\\*Messages\\*$")))
@ -148,28 +148,12 @@ setq org-log-done t)
;; handy editor stuff ;; handy editor stuff
;;-------------------------------------------------------------------------------------- ;;--------------------------------------------------------------------------------------
(defun delete-trailing-blank-lines () (require 'ws-butler)
"Deletes all blank lines at the end of the file, even the last one" (ws-butler-global-mode)
(interactive)
(save-excursion
(save-restriction
(widen)
(goto-char (point-max))
(delete-blank-lines)
(let ((trailnewlines (abs (skip-chars-backward "\n\t"))))
(if (> trailnewlines 0)
(progn
(delete-char trailnewlines)))))))
(add-hook 'before-save-hook 'delete-trailing-whitespace)
(add-hook 'before-save-hook 'delete-trailing-blank-lines)
;; Comment this if you dont mind git diffs complaining about missing ending newlines. ;; Comment this if you dont mind git diffs complaining about missing ending newlines.
(setq require-final-newline t) (setq require-final-newline t)
;; Uncomment this if you dont mind git diffs complaining about missing ending newlines.
; (add-hook 'before-save-hook 'delete-trailing-blank-lines)
;; Add new line if using C-n navigates to the end of the buffer ;; Add new line if using C-n navigates to the end of the buffer
(setq next-line-add-newlines t) (setq next-line-add-newlines t)

4
dotfiles/emacs.d/package.el

@ -25,6 +25,10 @@
neotree neotree
;;;;;;;;;;;;; ;;;;;;;;;;;;;
;; Cleanup
ws-butler
;;;;;;;;;;
;; UI ;; UI
fill-column-indicator fill-column-indicator
golden-ratio golden-ratio

Loading…
Cancel
Save