From 28bcae37f4780e0d92e5ce6825ccac470e597d77 Mon Sep 17 00:00:00 2001 From: bd Date: Thu, 3 Apr 2025 23:35:18 -0400 Subject: Remove autoformat mode --- .config/emacs/init.el | 1 + .config/emacs/libraries/autoformat.el | 53 ----------------------------------- 2 files changed, 1 insertion(+), 53 deletions(-) delete mode 100644 .config/emacs/libraries/autoformat.el (limited to '.config/emacs') diff --git a/.config/emacs/init.el b/.config/emacs/init.el index 9fcb6e3..441fd6e 100644 --- a/.config/emacs/init.el +++ b/.config/emacs/init.el @@ -58,6 +58,7 @@ (scroll-bar-mode -1) (tool-bar-mode -1) (tooltip-mode -1) +(add-hook #'before-save-hook #'delete-trailing-whitespace) (keymap-global-set "C-c m" #'gnus) (setopt readmail-command 'gnus diff --git a/.config/emacs/libraries/autoformat.el b/.config/emacs/libraries/autoformat.el deleted file mode 100644 index de17a0d..0000000 --- a/.config/emacs/libraries/autoformat.el +++ /dev/null @@ -1,53 +0,0 @@ -;;; -*- lexical-binding: t; -*- -;;; Commentary: -;;; Code: - - -(defcustom autoformat-do-untabify t - "If the value is t, then `autoformat-mode' will replace all tabs -with spaces upon saving a file. Else, the function greedily replaces -spaces with tabs." - :type 'boolean - :group 'quality - :safe 'booleanp) - -(defun autoformat-toggle-space-rule (&optional ARG) - "Toggles the formatting behavior of variable -`autoformat-do-untabify'." - (interactive (list 'toggle)) - (setq autoformat-do-untabify - (if (eq ARG 'toggle) - (not autoformat-do-untabify) - ARG)) - - (message "Autoformatter will %suse spaces!" - (if autoformat-do-untabify - "" "no longer "))) - -(defun autoformat--before-save-handler () - "Automatically reformats spacing of the current buffer." - (when autoformat-mode - (delete-trailing-whitespace) - (if autoformat-do-untabify - (untabify (point-min) (point-max)) - (tabify (point-min) (point-max))))) - -(defun autoformat--prog-mode-hook () - (add-hook 'before-save-hook #'autoformat--before-save-handler nil t)) - -(define-minor-mode autoformat-mode - "Toggles global autoformat-mode." - :init-value nil - :global t - :group 'quality - :lighter " Autoformatter" - :keymap (list - (cons (kbd "C-z f") #'autoformat-toggle-space-rule)) - - (if autoformat-mode - (add-hook 'prog-mode-hook #'autoformat--prog-mode-hook) - (remove-hook 'prog-mode-hook #'autoformat--prog-mode-hook))) - - -(provide 'autoformat) -;;; autoformat.el ends here -- cgit v1.2.3