read-only mode bindings
This commit is contained in:
parent
6f0ac579aa
commit
04110f090f
|
@ -392,6 +392,17 @@ This is particularly useful for read-only modes."
|
||||||
[remap evil-shift-right] #'ignore
|
[remap evil-shift-right] #'ignore
|
||||||
[remap evil-invert-char] #'ignore))
|
[remap evil-invert-char] #'ignore))
|
||||||
|
|
||||||
|
(defun evil-collection-set-readonly-bindings (map-sym)
|
||||||
|
"Unmap insertion keys from normal state. Additionally q can `quit-window'.
|
||||||
|
This is particularly useful for read-only modes. Make sure it's
|
||||||
|
called before setting up other evil bindings so that it can be
|
||||||
|
overriden."
|
||||||
|
(evil-collection-inhibit-insert-state map-sym)
|
||||||
|
(evil-collection-define-key 'normal map-sym
|
||||||
|
"q" #'quit-window
|
||||||
|
"ZZ" #'quit-window
|
||||||
|
"ZQ" #'evil-quit))
|
||||||
|
|
||||||
(defun evil-collection--binding-lessp (a b)
|
(defun evil-collection--binding-lessp (a b)
|
||||||
"Comparison function used to sort bindings of the form (state key def)."
|
"Comparison function used to sort bindings of the form (state key def)."
|
||||||
(let ((a-state (symbol-name (nth 0 a)))
|
(let ((a-state (symbol-name (nth 0 a)))
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun evil-collection-simple-setup ()
|
(defun evil-collection-simple-setup ()
|
||||||
"Set up `evil' bindings for `simple'."
|
"Set up `evil' bindings for `simple'."
|
||||||
|
(evil-collection-set-readonly-bindings 'special-mode-map)
|
||||||
(evil-collection-define-key nil 'special-mode-map
|
(evil-collection-define-key nil 'special-mode-map
|
||||||
"g" nil
|
"g" nil
|
||||||
"gr" 'revert-buffer
|
"gr" 'revert-buffer
|
||||||
|
|
11
readme.org
11
readme.org
|
@ -256,11 +256,12 @@ more.
|
||||||
with ~<f3>~ and ~<f4>~.
|
with ~<f3>~ and ~<f4>~.
|
||||||
|
|
||||||
A good rule of thumb would be:
|
A good rule of thumb would be:
|
||||||
|
|
||||||
- Always bind ~ZZ~ and ~ZQ~ to the quitting function(s), ~evil-quit~ if nothing
|
- Always bind ~q~, ~ZZ~ and ~ZQ~ to the mode specific quitting functions. If there is none,
|
||||||
else makes sense.
|
|
||||||
|
- Bind ~q~ and ~ZZ~ to ~quit-window~
|
||||||
- Bind ~q~ to ~evil-quit~ if macros don't make sense in current mode.
|
|
||||||
|
- Bind ~ZQ~ to ~evil-quit~
|
||||||
|
|
||||||
- If macros don't make sense in current mode, then ~@~ is available.
|
- If macros don't make sense in current mode, then ~@~ is available.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue