Emacs: Rename sanitize->fmt and add to lisp hook
parent
bf2dfc4e46
commit
fd80913a5e
|
@ -95,7 +95,8 @@ To view where the bindings are set in your config files, lookup
|
|||
;; Lisp
|
||||
;; Should not use tabs.
|
||||
(dolist (hook '(lisp-mode-hook emacs-lisp-mode-hook))
|
||||
(add-hook hook (lambda () (setq indent-tabs-mode nil))))
|
||||
(add-hook hook 'turn-on-fmt-before-save)
|
||||
(add-hook hook 'turn-off-indent-tabs))
|
||||
(define-key lisp-mode-shared-map "\M-." 'find-symbol-at-point)
|
||||
;; Common LISP
|
||||
(setq inferior-lisp-program "clisp")
|
||||
|
|
|
@ -116,6 +116,21 @@ TO-STRING."
|
|||
(find-variable sym)
|
||||
(find-function sym))))
|
||||
|
||||
(defun fmt ()
|
||||
"(Un)tabify, indent and delete trailing whitespace.
|
||||
Tabify if `indent-tabs-mode' is true, otherwise use spaces.
|
||||
Work on buffer or region. Require `tabify-leading'."
|
||||
(interactive)
|
||||
(let ((start (set-marker (make-marker) (if (use-region-p) (region-beginning) (point-min))))
|
||||
(end (set-marker (make-marker) (if (use-region-p) (region-end) (point-max)))))
|
||||
(if indent-tabs-mode
|
||||
(tabify-leading)
|
||||
(untabify start end))
|
||||
(indent-region start end)
|
||||
(save-restriction
|
||||
(narrow-to-region start end)
|
||||
(delete-trailing-whitespace))))
|
||||
|
||||
;; Fix forward-page. Previously, when the point was at the end of the page,
|
||||
;; going forward would skip 1 page. Changed:
|
||||
;;
|
||||
|
@ -346,20 +361,6 @@ WARNING: this may slow down editing on big files."
|
|||
(defun reset-fill-column ()
|
||||
"Reset `fill-column' to its default value."
|
||||
(setq fill-column (default-value 'fill-column)))
|
||||
(defun sanitize ()
|
||||
"(Un)tabify, indent and delete trailing whitespace.
|
||||
Tabify if `indent-tabs-mode' is true, otherwise use spaces.
|
||||
Work on buffer or region. Require `tabify-leading'."
|
||||
(interactive)
|
||||
(let ((start (set-marker (make-marker) (if (use-region-p) (region-beginning) (point-min))))
|
||||
(end (set-marker (make-marker) (if (use-region-p) (region-end) (point-max)))))
|
||||
(if indent-tabs-mode
|
||||
(tabify-leading)
|
||||
(untabify start end))
|
||||
(indent-region start end)
|
||||
(save-restriction
|
||||
(narrow-to-region start end)
|
||||
(delete-trailing-whitespace))))
|
||||
|
||||
(defun shell-last-command ()
|
||||
"Run last shell command."
|
||||
|
@ -506,6 +507,10 @@ This does not interfere with `subword-mode'."
|
|||
(modify-syntax-entry ?_ "_")
|
||||
(message "_ is a word delimiter")))
|
||||
|
||||
(defun turn-on-fmt-before-save ()
|
||||
"Unconditionally add the `fmt' function to `before-save-hook'."
|
||||
(add-hook 'before-save-hook 'fmt nil t))
|
||||
|
||||
(defun turn-off-indent-tabs ()
|
||||
"Unconditionally turn off tab indentation."
|
||||
(setq indent-tabs-mode nil))
|
||||
|
|
|
@ -111,8 +111,8 @@
|
|||
|
||||
;; WARNING: this can break some configuration files needing whitespaces at the
|
||||
;; end. This can also slow down saving on big files.
|
||||
; (require 'functions) ; for `sanitize'
|
||||
; (add-hook 'before-save-hook 'sanitize)
|
||||
; (require 'functions) ; for `fmt'
|
||||
; (add-hook 'before-save-hook 'fmt)
|
||||
(add-hook 'before-save-hook 'delete-trailing-whitespace)
|
||||
|
||||
;; Hippie expand.
|
||||
|
|
Loading…
Reference in New Issue