From 46a02ed29b6c482c42d2b6699623e5999b4b13af Mon Sep 17 00:00:00 2001 From: Lucius Hu Date: Thu, 18 Mar 2021 01:13:34 -0400 Subject: [PATCH] spacemacs-editing: refactor - Refactored function - Replaced unnecessary backquote construct with simple quotation --- .../spacemacs-whitespace-cleanup.el | 31 +++++---- .../+spacemacs/spacemacs-editing/packages.el | 65 ++++++++++--------- 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/layers/+spacemacs/spacemacs-editing/local/spacemacs-whitespace-cleanup/spacemacs-whitespace-cleanup.el b/layers/+spacemacs/spacemacs-editing/local/spacemacs-whitespace-cleanup/spacemacs-whitespace-cleanup.el index 7e3b7d121..63eea15d1 100644 --- a/layers/+spacemacs/spacemacs-editing/local/spacemacs-whitespace-cleanup/spacemacs-whitespace-cleanup.el +++ b/layers/+spacemacs/spacemacs-editing/local/spacemacs-whitespace-cleanup/spacemacs-whitespace-cleanup.el @@ -54,36 +54,35 @@ of the cleanup." (defun spacemacs-whitespace-cleanup/on-message (&optional global) "Return a string to display when the mode is activated." - (pcase dotspacemacs-whitespace-cleanup - (`all - (format "whitespace-cleanup enabled%s (all whitespace)" - (if global " globally" ""))) - (`trailing - (format "whitespace-cleanup enabled%s (trailing whitespace)" - (if global " globally" ""))) - (`changed - (format "whitespace-cleanup enabled%s (changed lines)" - (if global " globally" ""))))) + (format "whitespace-cleanup enabled%s (%s)" + (if global " globally" "") + (pcase dotspacemacs-whitespace-cleanup + ('all "all whitespace") + ('trailing "trailing whitespace") + ('changed "changed lines") + (x (user-error + "%s is not a valid option for 'dotspacemacs-whitespace-cleanup'" + x))))) (defun spacemacs-whitespace-cleanup//turn-on (&optional global) "Turn on `spacemacs-whitespace-cleanup-mode'." (pcase dotspacemacs-whitespace-cleanup - (`all + ('all (add-hook 'before-save-hook 'whitespace-cleanup nil (not global))) - (`trailing + ('trailing (add-hook 'before-save-hook 'delete-trailing-whitespace nil (not global))) - (`changed + ('changed (when (fboundp 'ws-butler-mode) (if global (ws-butler-global-mode) (ws-butler-mode)))))) (defun spacemacs-whitespace-cleanup//turn-off (&optional global) "Turn off `spacemacs-whitespace-cleanup-mode'." (pcase dotspacemacs-whitespace-cleanup - (`all + ('all (remove-hook 'before-save-hook 'whitespace-cleanup (not global))) - (`trailing + ('trailing (remove-hook 'before-save-hook 'delete-trailing-whitespace (not global))) - (`changed + ('changed (when (fboundp 'ws-butler-mode) (if global (ws-butler-global-mode -1) (ws-butler-mode -1)))))) diff --git a/layers/+spacemacs/spacemacs-editing/packages.el b/layers/+spacemacs/spacemacs-editing/packages.el index d62532fd6..11097046c 100644 --- a/layers/+spacemacs/spacemacs-editing/packages.el +++ b/layers/+spacemacs/spacemacs-editing/packages.el @@ -585,38 +585,39 @@ :defer t :init (progn - (pcase dotspacemacs-swap-number-row - (`qwerty-us (setq evil-swap-keys-number-row-keys '(("1" . "!") - ("2" . "@") - ("3" . "#") - ("4" . "$") - ("5" . "%") - ("6" . "^") - ("7" . "&") - ("8" . "*") - ("9" . "(") - ("0" . ")")))) - (`qwertz-de (setq evil-swap-keys-number-row-keys '(("1" . "!") - ("2" . "\"") - ("3" . "§") - ("4" . "$") - ("5" . "%") - ("6" . "&") - ("7" . "/") - ("8" . "(") - ("9" . ")") - ("0" . "=")))) - (`qwerty-ca-fr (setq evil-swap-keys-number-row-keys '(("1" . "!") - ("2" . "@") - ("3" . "#") - ("4" . "$") - ("5" . "%") - ("6" . "?") - ("7" . "&") - ("8" . "*") - ("9" . "(") - ("0" . ")")))) - (_ (message "dotspacemacs-swap-number-row %s is not supported." dotspacemacs-swap-number-row))) + (setq evil-swap-keys-number-row-keys + (pcase dotspacemacs-swap-number-row + ('qwerty-us '(("1" . "!") + ("2" . "@") + ("3" . "#") + ("4" . "$") + ("5" . "%") + ("6" . "^") + ("7" . "&") + ("8" . "*") + ("9" . "(") + ("0" . ")"))) + ('qwerty-de '(("1" . "!") + ("2" . "\"") + ("3" . "§") + ("4" . "$") + ("5" . "%") + ("6" . "&") + ("7" . "/") + ("8" . "(") + ("9" . ")") + ("0" . "="))) + ('qwerty-ca-fr '(("1" . "!") + ("2" . "@") + ("3" . "#") + ("4" . "$") + ("5" . "%") + ("6" . "?") + ("7" . "&") + ("8" . "*") + ("9" . "(") + ("0" . ")"))) + (x (message "dotspacemacs-swap-number-row %s is not supported." x)))) (add-hook 'prog-mode-hook #'evil-swap-keys-swap-number-row)))) (defun spacemacs-editing/init-persistent-scratch ()