From 837105266e97d98f6aadb43449a9002b898349eb Mon Sep 17 00:00:00 2001 From: Taylor Bockman Date: Tue, 17 Nov 2015 09:23:32 -0800 Subject: [PATCH] More init.el changes regarding lines --- dotfiles/emacs.d/init.el | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/dotfiles/emacs.d/init.el b/dotfiles/emacs.d/init.el index 0832aec..11d0a26 100644 --- a/dotfiles/emacs.d/init.el +++ b/dotfiles/emacs.d/init.el @@ -29,6 +29,31 @@ (setq inhibit-splash-screen t) ;;-------------------------------------------------------------------------------------- +;; Handy editor stuff +;;-------------------------------------------------------------------------------------- + +(defun delete-trailing-blank-lines () + "Deletes all blank lines at the end of the file, even the last one" + (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) + +;; Comment this if you dont mind git diffs complaining about missing ending newlines. +(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) + +;;-------------------------------------------------------------------------------------- ;; Enable MELPA ;;-------------------------------------------------------------------------------------- @@ -85,7 +110,7 @@ (require 'helm-projectile) (helm-projectile-on) -;; Use ag instead of grep for in-file searches in helm-find-file +;; Use ag instead of grep for in-file searches in helm-find-file (when (executable-find "ag") (setq helm-grep-default-command "ag -H --nogroup --nocolor %e %p %f" @@ -93,7 +118,7 @@ ;;------------------------------------------------------------------------------------- ;; Enable Autocomplete -;; +;; ;; NOTE: You can replace the 't' in (setq ac-auto-start t) with a positive integer ;; to trigger autocompletion only after that number of characters. This will ;; improve performance on slower systems. @@ -166,6 +191,10 @@ (global-set-key (kbd "C-d s") 'delete-pair) +;; Delete word + +(global-set-key (kbd "C-d d") 'delete-whole-line) + ;; Git utility (global-set-key (kbd "C-m s") 'magit-status)