Permalink
Browse files

Whitespace tweaks

  • Loading branch information...
1 parent 1ed1afb commit 372339b54609396e93d6610e9ea4c69f58cfd99e @genehack committed Jan 5, 2013
Showing with 16 additions and 2 deletions.
  1. +1 −1 etc/keys.el
  2. +15 −1 etc/misc.el
View
@@ -14,7 +14,7 @@
(global-set-key (kbd "C-c C-h") 'genehack/split-horizontally-or-delete-other-windows)
(global-set-key (kbd "C-c C-j") 'projectile-jump-to-project-file)
(global-set-key (kbd "C-c C-o") 'projectile-multi-occur)
-(global-set-key (kbd "C-c C-t") 'delete-trailing-whitespace)
+(global-set-key (kbd "C-c C-t") 'genehack/strip-whitespace-and-indent)
(global-set-key (kbd "C-c C-v") 'genehack/split-vertically-or-delete-other-windows)
(global-set-key (kbd "C-c C-x") 'maximize-frame)
(global-set-key (kbd "C-c M-x") 'execute-extended-command)
View
@@ -300,10 +300,24 @@
)
"List of modes where trailing whitespace should be stripped when saving files.")
+;;;; inspired by http://whattheemacsd.com/buffer-defuns.el-01.html
+(defun genehack/strip-whitespace ()
+ "Untabify, strip white space, set file coding to UTF8"
+ (interactive)
+ (untabify (point-min) (point-max))
+ (delete-trailing-whitespace)
+ (set-buffer-file-coding-system 'utf-8))
+
+(defun genehack/strip-whitespace-and-indent ()
+ "Strip various whitespaces and reindent whole file"
+ (interactive)
+ (genehack/strip-whitespace)
+ (indent-region (point-min) (point-max)))
+
(add-hook 'before-save-hook
(lambda ()
(if (find major-mode genehack/strip-trailing-whitespace-in-these-modes)
- (delete-trailing-whitespace))))
+ (genehack/strip-whitespace))))
;;; TEMPLATE
(require 'template-mode)

0 comments on commit 372339b

Please sign in to comment.