emacs-personal/lisp/init-editing-utils.el
Jesús bb80ec4def
add-hook is a function, so all of its args are evaluated before it does its thing (using their values).
The value of the sexp you passed as its second arg is the symbol delete-trailing-whitespace,
because the arg to when is a non-nil list (because you quoted it). So the when condition is always true.

And you never invoke function delete-trailing-whitespace; you just return the symbol that names that function.
2018-11-08 13:19:42 -05:00

58 lines
2.3 KiB
EmacsLisp

;;----------------------------------------------------------------------------
;; Remove whitespaces
;;----------------------------------------------------------------------------
;; Delete trailing whitespace before saving fil → all modes
;; (add-hook 'before-save-hook 'delete-trailing-whitespace)
;; Delete-trailing-whitespace-when-saving-except-certain-modes
(add-hook 'before-save-hook
(lambda ()
(unless (eq major-mode 'diff-mode)
(delete-trailing-whitespace))))
;;----------------------------------------------------------------------------
;; Automatic pairs open symbols (, {, [...
;; Disable for default.
;; Uncomment the next 4 lines if you want to enable the pairs-mode
;;(when (fboundp 'electric-pair-mode)
;; (electric-pair-mode))
;;(when (eval-when-compile (version< "24.4" emacs-version))
;; (electric-indent-mode 1))
;; Active auto-revert-mode that automatically reloads modified files out of Emacs.
;; It is very useful to see logs (like auto-revert-tail-mode) among many other cases.
(global-auto-revert-mode)
(setq global-auto-revert-non-file-buffers t
auto-revert-verbose nil)
;;----------------------------------------------------------------------------
;; Show matching parens
;;----------------------------------------------------------------------------
(show-paren-mode 1)
;;----------------------------------------------------------------------------
;; More useful things - only one line
;;----------------------------------------------------------------------------
(set-default 'truncate-lines t)
(setq show-trailing-whitespace nil)
;;----------------------------------------------------------------------------
;; Some basic preferences
;;----------------------------------------------------------------------------
(setq-default
indent-tabs-mode nil)
;;----------------------------------------------------------------------------
;; Undo-tree
;;----------------------------------------------------------------------------
(use-package undo-tree
:diminish undo-tree-mode
:config
(progn
(global-undo-tree-mode)
(setq undo-tree-visualizer-timestamps nil)
(setq undo-tree-visualizer-diff nil)))
;;----------------------------------------------------------------------------
(myemacs/elapsed-time)
(provide 'init-editing-utils)