emacs.d / dss-whitespace-and-linelen.el

Full commit
(load-library "col-highlight") ; for highlighting the current col

(setq require-final-newline t) ; auto-insert final newlines in all files

(require 'lineker)
(defun dss/load-lineker-mode ()
  (setq lineker-column-limit 90)

;; whitespace highlighting and cleanup

(require 'show-wspace)
(defun dss/show-ws ()
  (setq show-trailing-whitespace t)
  ;; (hl-line-mode 1)

(defun dss/del-last-space (&optional replacement)
  (let ((replacement (or replacement "")))
      (search-backward-regexp "\\([^ ]\\)\\( +\\)")
      (replace-match replacement nil nil nil 2))))

(defun dss/del-last-space-2 ()
    (if (string-equal (char-to-string (char-before)) " ")
        (progn (backward-word) (dss/del-last-space))
  (if (not (string-equal (char-to-string (char-before)) " "))
      (insert " ")))

(defun dss/less-space ()
  (dss/del-last-space " "))

(defun dss/whitespace-cleanup ()
  "Trim all trailing whitespace in the current buffer, and untabify."
    (untabify (point-min) (point-max))))

(defun dss/install-whitespace-cleanup-hook ()
  "Add this to any major mode hook to show whitespace during editing
   and trip it before saving"
  (add-hook 'before-save-hook 'dss/whitespace-cleanup nil t))

(add-hook 'emacs-lisp-mode-hook 'dss/install-whitespace-cleanup-hook)

(provide 'dss-whitespace-and-linelen)