spacemacs-editing: refactor

- Refactored function
- Replaced unnecessary backquote construct with simple quotation
This commit is contained in:
Lucius Hu 2021-03-18 01:13:34 -04:00 committed by duianto
parent 55eda227c3
commit 46a02ed29b
2 changed files with 48 additions and 48 deletions

View file

@ -54,36 +54,35 @@ of the cleanup."
(defun spacemacs-whitespace-cleanup/on-message (&optional global) (defun spacemacs-whitespace-cleanup/on-message (&optional global)
"Return a string to display when the mode is activated." "Return a string to display when the mode is activated."
(pcase dotspacemacs-whitespace-cleanup (format "whitespace-cleanup enabled%s (%s)"
(`all (if global " globally" "")
(format "whitespace-cleanup enabled%s (all whitespace)" (pcase dotspacemacs-whitespace-cleanup
(if global " globally" ""))) ('all "all whitespace")
(`trailing ('trailing "trailing whitespace")
(format "whitespace-cleanup enabled%s (trailing whitespace)" ('changed "changed lines")
(if global " globally" ""))) (x (user-error
(`changed "%s is not a valid option for 'dotspacemacs-whitespace-cleanup'"
(format "whitespace-cleanup enabled%s (changed lines)" x)))))
(if global " globally" "")))))
(defun spacemacs-whitespace-cleanup//turn-on (&optional global) (defun spacemacs-whitespace-cleanup//turn-on (&optional global)
"Turn on `spacemacs-whitespace-cleanup-mode'." "Turn on `spacemacs-whitespace-cleanup-mode'."
(pcase dotspacemacs-whitespace-cleanup (pcase dotspacemacs-whitespace-cleanup
(`all ('all
(add-hook 'before-save-hook 'whitespace-cleanup nil (not global))) (add-hook 'before-save-hook 'whitespace-cleanup nil (not global)))
(`trailing ('trailing
(add-hook 'before-save-hook 'delete-trailing-whitespace nil (not global))) (add-hook 'before-save-hook 'delete-trailing-whitespace nil (not global)))
(`changed ('changed
(when (fboundp 'ws-butler-mode) (when (fboundp 'ws-butler-mode)
(if global (ws-butler-global-mode) (ws-butler-mode)))))) (if global (ws-butler-global-mode) (ws-butler-mode))))))
(defun spacemacs-whitespace-cleanup//turn-off (&optional global) (defun spacemacs-whitespace-cleanup//turn-off (&optional global)
"Turn off `spacemacs-whitespace-cleanup-mode'." "Turn off `spacemacs-whitespace-cleanup-mode'."
(pcase dotspacemacs-whitespace-cleanup (pcase dotspacemacs-whitespace-cleanup
(`all ('all
(remove-hook 'before-save-hook 'whitespace-cleanup (not global))) (remove-hook 'before-save-hook 'whitespace-cleanup (not global)))
(`trailing ('trailing
(remove-hook 'before-save-hook 'delete-trailing-whitespace (not global))) (remove-hook 'before-save-hook 'delete-trailing-whitespace (not global)))
(`changed ('changed
(when (fboundp 'ws-butler-mode) (when (fboundp 'ws-butler-mode)
(if global (ws-butler-global-mode -1) (ws-butler-mode -1)))))) (if global (ws-butler-global-mode -1) (ws-butler-mode -1))))))

View file

@ -585,38 +585,39 @@
:defer t :defer t
:init :init
(progn (progn
(pcase dotspacemacs-swap-number-row (setq evil-swap-keys-number-row-keys
(`qwerty-us (setq evil-swap-keys-number-row-keys '(("1" . "!") (pcase dotspacemacs-swap-number-row
("2" . "@") ('qwerty-us '(("1" . "!")
("3" . "#") ("2" . "@")
("4" . "$") ("3" . "#")
("5" . "%") ("4" . "$")
("6" . "^") ("5" . "%")
("7" . "&") ("6" . "^")
("8" . "*") ("7" . "&")
("9" . "(") ("8" . "*")
("0" . ")")))) ("9" . "(")
(`qwertz-de (setq evil-swap-keys-number-row-keys '(("1" . "!") ("0" . ")")))
("2" . "\"") ('qwerty-de '(("1" . "!")
("3" . "§") ("2" . "\"")
("4" . "$") ("3" . "§")
("5" . "%") ("4" . "$")
("6" . "&") ("5" . "%")
("7" . "/") ("6" . "&")
("8" . "(") ("7" . "/")
("9" . ")") ("8" . "(")
("0" . "=")))) ("9" . ")")
(`qwerty-ca-fr (setq evil-swap-keys-number-row-keys '(("1" . "!") ("0" . "=")))
("2" . "@") ('qwerty-ca-fr '(("1" . "!")
("3" . "#") ("2" . "@")
("4" . "$") ("3" . "#")
("5" . "%") ("4" . "$")
("6" . "?") ("5" . "%")
("7" . "&") ("6" . "?")
("8" . "*") ("7" . "&")
("9" . "(") ("8" . "*")
("0" . ")")))) ("9" . "(")
(_ (message "dotspacemacs-swap-number-row %s is not supported." dotspacemacs-swap-number-row))) ("0" . ")")))
(x (message "dotspacemacs-swap-number-row %s is not supported." x))))
(add-hook 'prog-mode-hook #'evil-swap-keys-swap-number-row)))) (add-hook 'prog-mode-hook #'evil-swap-keys-swap-number-row))))
(defun spacemacs-editing/init-persistent-scratch () (defun spacemacs-editing/init-persistent-scratch ()