holy-mode == (evil-mode -1)

The proper holy-mode (IMO). Simply disable evil-mode and reset the
cursor and mode-line settings.
This commit is contained in:
justbur 2015-10-22 13:01:49 -04:00 committed by syl20bnr
parent a5022743e5
commit 1d05f3887a
4 changed files with 34 additions and 73 deletions

View file

@ -204,6 +204,15 @@ or lists of these.")
;; UI
;; ---------------------------------------------------------------------------
(defface face-of-god
`((t (:background "SkyBlue2"
:foreground ,(face-background 'mode-line)
:box ,(face-attribute 'mode-line :box)
:inherit 'mode-line)))
"Face to use when `evil-mode' is disabled or `evil-state' is
nil."
:group 'spacemacs)
;; important for golden-ratio to better work
(setq window-combination-resize t)
;; fringes

View file

@ -28,15 +28,11 @@
;;; Code:
(defvar holy-mode-normal-state-modes-backup nil
"Backup of `evil-normal-state-modes'.")
(defvar holy-mode-motion-state-modes-backup nil
"Backup of `evil-motion-state-modes'.")
(defadvice evil-insert-state (around benedictus-dominus disable)
"Preparing the holy water flasks."
(evil-emacs-state))
(defvar holy-mode-modes-to-disable-alist
`((evil-escape-mode . ,(when (boundp 'evil-escape-mode) evil-escape-mode)))
"Alist of modes that should be disabled when activating
`holy-mode'. The cdr in each cell stores the state of the mode
before it was disabled.")
;;;###autoload
(define-minor-mode holy-mode
@ -47,65 +43,18 @@ The `insert state' is replaced by the `emacs state'."
:lighter " holy"
:group 'spacemacs
(if holy-mode
(in-nomine-patris-et-filii-et-spiritus-sancti)
(amen)))
(progn
(evil-mode -1)
(dolist (mode holy-mode-modes-to-disable-alist)
(when (boundp (car mode))
(setcdr mode (symbol-value (car mode)))
(funcall (car mode) -1)))
(setq cursor-type 'box)
(set-cursor-color "SkyBlue2")
(when (fboundp 'spacemacs//helm-hjkl-navigation)
(spacemacs//helm-hjkl-navigation nil)))
(when (fboundp 'spacemacs//helm-hjkl-navigation)
(spacemacs//helm-hjkl-navigation t))
(evil-mode 1)))
(defun in-nomine-patris-et-filii-et-spiritus-sancti ()
"Enter the church of Emacs (wash your hands)."
;; transfert all modes defaulting to `evilified state' to
;; `emacs state'
(setq evil-evilified-state-modes nil)
(mapc (lambda (x) (push x evil-emacs-state-modes))
evilified-state--modes)
;; allow to return to `normal state' with escape
(define-key evil-emacs-state-map [escape] 'evil-normal-state)
;; replace `insert state' by `emacs state'
(ad-enable-advice 'evil-insert-state 'around 'benedictus-dominus)
(ad-activate 'evil-insert-state)
;; start all buffers in `emacs state'
(setq evil-default-state 'emacs)
(setq holy-mode-normal-state-modes-backup evil-normal-state-modes)
(setq evil-normal-state-modes nil)
(setq holy-mode-motion-state-modes-backup evil-motion-state-modes)
(setq evil-motion-state-modes nil)
;; helm navigation
(when (fboundp 'spacemacs//helm-hjkl-navigation)
(spacemacs//helm-hjkl-navigation nil))
;; initiate `emacs state' and enter the church
(holy-mode//update-states-for-current-buffers))
(defun amen ()
"May the force be with you my son (or not)."
;; restore default `evilified state'
(mapc (lambda (x) (delq x evil-emacs-state-modes))
evilified-state--modes)
(setq evil-evilified-state-modes evilified-state--modes)
;; restore `insert state'
(ad-disable-advice 'evil-insert-state 'around 'benedictus-dominus)
(ad-activate 'evil-insert-state)
;; restore `normal state'
(setq evil-default-state 'normal)
;; restore per mode default states
(setq evil-normal-state-modes holy-mode-normal-state-modes-backup)
(setq evil-motion-state-modes holy-mode-motion-state-modes-backup)
;; restore helm navigation
(when (fboundp 'spacemacs//helm-hjkl-navigation)
(spacemacs//helm-hjkl-navigation t))
;; restore the states
(holy-mode//update-states-for-current-buffers t))
(defun holy-mode//update-states-for-current-buffers (&optional arg)
"Update the active state in all current buffers.
ARG non nil means that the editing style is `vim'."
(dolist (buffer (buffer-list))
(with-current-buffer buffer
;; switch to holy-mode
(when (and (not arg) (or (eq 'evilified evil-state)
(eq 'normal evil-state)))
(evil-emacs-state))
;; disable holy-mode
(when (and arg (eq 'emacs evil-state))
(cond
((memq major-mode evil-evilified-state-modes) (evil-evilified-state))
((memq major-mode evil-motion-state-modes) (evil-motion-state))
(t (evil-normal-state)))))))
(provide 'holy-mode)

View file

@ -220,7 +220,8 @@
(defun evil-insert-state-cursor-hide ()
(setq evil-insert-state-cursor '((hbar . 0))))
(evil-mode 1))
(unless (eq dotspacemacs-editing-style 'emacs)
(evil-mode 1)))
:config
(progn
;; bind function keys

View file

@ -1779,8 +1779,10 @@ Open junk file using helm, with `prefix-arg' search in junk files"
(setq spaceline-org-clock-p nil)
(defun spacemacs//evil-state-face ()
(let ((state (if (eq 'operator evil-state) evil-previous-state evil-state)))
(intern (format "spacemacs-%S-face" state))))
(if (bound-and-true-p evil-state)
(let ((state (if (eq 'operator evil-state) evil-previous-state evil-state)))
(intern (format "spacemacs-%S-face" state)))
'face-of-god))
(setq spaceline-highlight-face-func 'spacemacs//evil-state-face)
(let ((unicodep (dotspacemacs|symbol-value