Emacs: Rename fmt -> prettify
parent
809572e0bf
commit
67808c69f2
|
@ -1 +1 @@
|
|||
((nil . ((ambrevar/fmt-inhibit-p . nil))))
|
||||
((nil . ((ambrevar/prettify-inhibit-p . nil))))
|
||||
|
|
|
@ -226,7 +226,7 @@
|
|||
(add-hook 'lispy-mode-hook 'lispyville-mode))
|
||||
(lispy-mode)))
|
||||
(dolist (hook '(lisp-mode-hook emacs-lisp-mode-hook))
|
||||
(add-hook hook 'ambrevar/turn-on-fmt-before-save)
|
||||
(add-hook hook 'ambrevar/turn-on-prettify-before-save)
|
||||
(add-hook hook 'ambrevar/turn-on-complete-filename)
|
||||
(add-hook hook 'ambrevar/turn-on-tab-width-to-8) ; Because some existing code uses tabs.
|
||||
(add-hook hook 'ambrevar/turn-off-indent-tabs) ; Should not use tabs.
|
||||
|
|
|
@ -50,17 +50,17 @@ TO-STRING."
|
|||
(while (re-search-forward regex (if (use-region-p) (region-end) (point-max)) t)
|
||||
(replace-match to-string)))
|
||||
|
||||
(defun ambrevar/fmt ()
|
||||
(defun ambrevar/prettify ()
|
||||
"(Un)tabify, indent and delete trailing whitespace.
|
||||
|
||||
Tabify if `indent-tabs-mode' is true, otherwise use spaces.
|
||||
Work on buffer or region.
|
||||
|
||||
If `ambrevar/fmt-inhinit-p' is non-nil, it does nothing.
|
||||
If `ambrevar/prettify-inhibit-p' is non-nil, it does nothing.
|
||||
|
||||
Require `ambrevar/tabify-leading'."
|
||||
(interactive)
|
||||
(unless ambrevar/fmt-inhibit-p
|
||||
(unless ambrevar/prettify-inhibit-p
|
||||
(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
|
||||
|
@ -71,9 +71,9 @@ Require `ambrevar/tabify-leading'."
|
|||
(narrow-to-region start end)
|
||||
(delete-trailing-whitespace)))))
|
||||
|
||||
(defcustom ambrevar/fmt-inhibit-p t
|
||||
"Do not run `ambrevar/fmt' if non-nil.
|
||||
As this is not friendly to foreign projects, `ambrevar/fmt' should be run
|
||||
(defcustom ambrevar/prettify-inhibit-p t
|
||||
"Do not run `ambrevar/prettify' if non-nil.
|
||||
As this is not friendly to foreign projects, `ambrevar/prettify' should be run
|
||||
selectively."
|
||||
:safe 'booleanp)
|
||||
|
||||
|
@ -373,13 +373,13 @@ This does not affect .csv files."
|
|||
"Unconditionally remove the `delete-trailing-whitespace' function to `before-save-hook'."
|
||||
(remove-hook 'before-save-hook 'delete-trailing-whitespace t))
|
||||
|
||||
(defun ambrevar/turn-on-fmt-before-save ()
|
||||
"Unconditionally add the `ambrevar/fmt' function to `before-save-hook'."
|
||||
(add-hook 'before-save-hook 'ambrevar/fmt nil t))
|
||||
(defun ambrevar/turn-on-prettify-before-save ()
|
||||
"Unconditionally add the `ambrevar/prettify' function to `before-save-hook'."
|
||||
(add-hook 'before-save-hook 'ambrevar/prettify nil t))
|
||||
|
||||
(defun ambrevar/turn-off-fmt-before-save ()
|
||||
"Unconditionally remove the `ambrevar/fmt' function to `before-save-hook'."
|
||||
(remove-hook 'before-save-hook 'ambrevar/fmt t))
|
||||
(defun ambrevar/turn-off-prettify-before-save ()
|
||||
"Unconditionally remove the `ambrevar/prettify' function to `before-save-hook'."
|
||||
(remove-hook 'before-save-hook 'ambrevar/prettify t))
|
||||
|
||||
(defun ambrevar/turn-off-indent-tabs ()
|
||||
"Unconditionally turn off tab indentation."
|
||||
|
|
|
@ -71,11 +71,11 @@ restored."
|
|||
(compile (format "make -k -C %s clean" (shell-quote-argument makefile-dir))))))
|
||||
|
||||
;;; It is tempting to add `ambrevar/cc-fmt' to the hook:
|
||||
;; (add-hook 'before-save-hook 'ambrevar/cc-fmt nil t)
|
||||
;; (add-hook 'before-save-hook 'ambrevar/cc-prettify nil t)
|
||||
;;; Unlike Go however, there is no formatting standard and thus this would break
|
||||
;;; the formatting rules of every third-party C file that does not follow the
|
||||
;;; same style.
|
||||
(defun ambrevar/cc-fmt ()
|
||||
(defun ambrevar/cc-prettify ()
|
||||
"Run uncrustify(1) on current buffer or region."
|
||||
(interactive)
|
||||
(let (status
|
||||
|
|
|
@ -117,8 +117,8 @@
|
|||
;;; Add formatting functions to the buffer-local `before-save-hook'.
|
||||
;;; WARNING: this can break some configuration files needing whitespaces at the
|
||||
;;; end. This can also slow down saving on big files. Some modes (e.g. lisp) run
|
||||
;;; `fmt' in their local hook, which is redundant with this.
|
||||
;; (add-hook 'find-file-hook 'ambrevar/turn-on-fmt-before-save)
|
||||
;;; `ambrevar/prettify' in their local hook, which is redundant with this.
|
||||
;; (add-hook 'find-file-hook 'ambrevar/turn-on-prettify-before-save)
|
||||
(add-hook 'find-file-hook 'ambrevar/turn-on-delete-trailing-whitespace)
|
||||
|
||||
;;; Cycle spacing instead of just-one-space. This frees M-\.
|
||||
|
|
|
@ -1 +1 @@
|
|||
((nil . ((ambrevar/fmt-inhibit-p . t))))
|
||||
((nil . ((ambrevar/prettify-inhibit-p . t))))
|
||||
|
|
Loading…
Reference in New Issue