[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] scratch/evil d3b7b6f5d4: Various code cleanups
From: |
Stefan Monnier |
Subject: |
[nongnu] scratch/evil d3b7b6f5d4: Various code cleanups |
Date: |
Thu, 29 Jun 2023 15:32:48 -0400 (EDT) |
branch: scratch/evil
commit d3b7b6f5d408054a766295cb3edd512061030c10
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
Various code cleanups
The original motivation was to fix the misuse of `eval` in `evil-delay`
by turning it into a macro (name `evil-with-delay`). But it includes
various generic changes such as prefering #' to quote function names and
fixing some incorrect uses of ' in docstrings (many warnings remain about
this).
The patch also enables `lexical-binding` in the remaining files.
`lexical-binding` in `evil-ex.el` has had a tumultuous life, the last commit
of which sets it explicitly to nil while stating confusingly in the commit
message that it re-enables it. In any case, I still found some changes
needed to account for `lexical-binding`, so there might be more.
Detailed changes below.
* evil-common.el (evil-unquote): Delete function, not used (luckily:
it reeked of a bad hack to work around a misunderstood bug).
(evil--with-delay): New helper function.
(evil-with-delay): New macro to replace `evil-delay`.
(evil-delay): Rewrite using `evil-with-delay` and mark as obsolete.
(evil-signal-at-bob-or-eob): Fix typos in docstring.
* evil-core.el (window-configurakion-change-hook): Add FIXME.
(evil-define-key): Use `evil-with-delay`.
* evil-states.el (evil-visual-activate-hook): Use `evil-with-delay`.
* evil-commands.el (evil-match): Use `pcase` since the branch patterns
used are those of `pcase` rather than those of `cl-case`.
(evil-execute-in-normal-state): Use `evil-with-delay`.
* evil-digraphs.el (evil-digraphs-table-user): Remove redundant
`:group` arg.
* evil-ex.el: Enable `lexical-binding` like the last commit that
touched this cookie said that it was doing (even though it didn't).
(evil-ex-info-string): Declare.
(evil-ex-update): Mark `end` and `len` as ignored.
(evil-ex-init-shell-argument-completion): Mark `arg` as ignored.
(evil-flatten-syntax-tree): Mark `char` as ignored.
(evil-parser): Rename `context` to `evil--context` and declare it
as dynbound. Remove unused var `last`.
Move shared `setq result` out of some `if`s and `cond`s.
* evil-jumps.el: Remove redundant :group` arguments.
* evil-macros.el (evil-define-interactive-code): Move shared `setq func`
out of `cond`. Move the insertion of quote around `func` to the `cond`
so the `quote` is not incorrectly added around lambda forms.
* evil-pkg.el: Remove file. Move its contents to the pseudo headers of
`evil.el` so (M|NonGNU)ELPA can auto-generate this file appropriately.
* evil.el: Enable `lexical-binding`. Synchronize metadata with what
was in `evil-pkg.el`.
* evil-tests.el: Enable `lexical-binding`.
(evil-test-change-state): Move `let` to obviate the need for `setq`.
Remove unused vars `keymap` and `local-keymap`.
(evil-test-auxiliary-maps): Rename `map` to `evil--map` and declare it
as dynbound so `evil-define-key` can access it.
(evil-test-exclusive-type): Mark `third-line` as unused.
(evil-test-text-object): Mark `type` arg as unused.
(evil-with-both-search-modules): Move macro before its first use.
(evil-test-properties): Rename `alist` to `evil--alist` and declare it
as dynbound so `evil-put-property` can access it.
* evil-command-window.el (evil-command-window-draw-prefix):
Mark `ignored` as, well, ignored.
---
evil-command-window.el | 2 +-
evil-commands.el | 85 +++++++++++++++----------------
evil-common.el | 61 +++++++++++++----------
evil-core.el | 32 ++++++------
evil-digraphs.el | 3 +-
evil-ex.el | 4 +-
evil-jumps.el | 15 ++----
evil-keybindings.el | 2 +-
evil-macros.el | 18 +++----
evil-pkg.el | 7 ---
evil-search.el | 4 +-
evil-states.el | 21 ++++----
evil-tests.el | 133 +++++++++++++++++++++++++------------------------
evil-vars.el | 55 +++++++++++---------
evil.el | 2 +-
15 files changed, 226 insertions(+), 218 deletions(-)
diff --git a/evil-command-window.el b/evil-command-window.el
index 21299a2dc0..566ee3a79e 100644
--- a/evil-command-window.el
+++ b/evil-command-window.el
@@ -164,7 +164,7 @@ function to execute."
(push result evil-search-backward-history)))
(evil-search result forward evil-regexp-search))))
-(defun evil-command-window-draw-prefix (&rest ignored)
+(defun evil-command-window-draw-prefix (&rest _ignored)
"Display `evil-command-window-cmd-key' as a prefix to the current line.
Parameters passed in through IGNORED are ignored."
(let ((prefix (propertize evil-command-window-cmd-key
diff --git a/evil-commands.el b/evil-commands.el
index 68e9663e4b..dbe67751d1 100644
--- a/evil-commands.el
+++ b/evil-commands.el
@@ -307,8 +307,7 @@ If called after a change operator, i.e. cw or cW,
then both behave like ce or cE.
If point is at the end of the buffer and cannot be moved signal
-'end-of-buffer is raised.
-"
+`end-of-buffer' is raised."
:type exclusive
(let ((thing (if bigword 'evil-WORD 'evil-word))
(orig (point))
@@ -591,7 +590,7 @@ and jump to the corresponding one."
(evil-next-flyspell-error (- (or count 1))))
(evil-define-motion evil-previous-open-paren (count)
- "Go to [count] previous unmatched '('."
+ "Go to [count] previous unmatched \"(\"."
:type exclusive
(evil-up-paren ?\( ?\) (- (or count 1))))
@@ -3079,7 +3078,7 @@ Calls `evil-complete-previous-line-func'."
(defun evil-repeat-search (flag)
"Called to record a search command.
-FLAG is either 'pre or 'post if the function is called before resp.
+FLAG is either `pre' or `post' if the function is called before resp.
after executing the command."
(cond
((and (evil-operator-state-p) (eq flag 'pre))
@@ -3264,7 +3263,7 @@ not interfere with another."
(if (null list)
(user-error
"Enable one of the following modes for folding to work: %s"
- (mapconcat 'symbol-name (mapcar 'caar evil-fold-list) ", "))
+ (mapconcat #'symbol-name (mapcar #'caar evil-fold-list) ", "))
(let* ((modes (caar list)))
(if (evil--mode-p modes)
(let* ((actions (cdar list))
@@ -5176,9 +5175,9 @@ if the previous state was Emacs state."
"No insert-state repeat info is recorded after executing in normal state.
Restore the disabled repeat hooks on insert-state exit."
(evil-repeat-stop)
- (add-hook 'pre-command-hook 'evil-repeat-pre-hook)
- (add-hook 'post-command-hook 'evil-repeat-post-hook)
- (remove-hook 'evil-insert-state-exit-hook 'evil--restore-repeat-hooks))
+ (add-hook 'pre-command-hook #'evil-repeat-pre-hook)
+ (add-hook 'post-command-hook #'evil-repeat-post-hook)
+ (remove-hook 'evil-insert-state-exit-hook #'evil--restore-repeat-hooks))
(defvar evil--execute-normal-return-state nil
"The state to return to after executing in normal state.")
@@ -5189,39 +5188,41 @@ Restore the disabled repeat hooks on insert-state exit."
(defun evil-execute-in-normal-state ()
"Execute the next command in Normal state."
(interactive)
- (evil-delay '(not (memq this-command
- '(nil
- evil-execute-in-normal-state
- evil-replace-state
- evil-use-register
- digit-argument
- negative-argument
- universal-argument
- universal-argument-minus
- universal-argument-more
- universal-argument-other-key)))
- `(with-current-buffer ,(current-buffer)
- ;; If cursor was after EOL before CTRL-O and is now at EOL,
- ;; put it after EOL.
- (and (or (when evil--execute-normal-eol-pos
- (= (1+ (point)) (save-excursion
- (goto-char evil--execute-normal-eol-pos)
- (set-marker evil--execute-normal-eol-pos
nil)
- (line-end-position))))
- (and (eq (or goal-column temporary-goal-column)
most-positive-fixnum)
- (memq this-command '(next-line previous-line))))
- (not (eolp))
- (not (memq this-command
- '(evil-insert evil-beginning-of-line
evil-first-non-blank)))
- (forward-char))
- (unless (memq evil-state '(replace insert))
- (evil-change-state ',evil-state))
- (when (eq 'insert evil-state)
- (remove-hook 'pre-command-hook 'evil-repeat-pre-hook)
- (remove-hook 'post-command-hook 'evil-repeat-post-hook)
- (add-hook 'evil-insert-state-exit-hook 'evil--restore-repeat-hooks))
- (setq evil-execute-normal-keys nil))
- 'post-command-hook)
+ (let ((buf (current-buffer))
+ (estate evil-state))
+ (evil-with-delay (not (memq this-command
+ '(nil
+ evil-execute-in-normal-state
+ evil-replace-state
+ evil-use-register
+ digit-argument
+ negative-argument
+ universal-argument
+ universal-argument-minus
+ universal-argument-more
+ universal-argument-other-key)))
+ post-command-hook
+ (with-current-buffer buf
+ ;; If cursor was after EOL before CTRL-O and is now at EOL,
+ ;; put it after EOL.
+ (and (or (when evil--execute-normal-eol-pos
+ (= (1+ (point)) (save-excursion
+ (goto-char evil--execute-normal-eol-pos)
+ (set-marker evil--execute-normal-eol-pos
nil)
+ (line-end-position))))
+ (and (eq (or goal-column temporary-goal-column)
most-positive-fixnum)
+ (memq this-command '(next-line previous-line))))
+ (not (eolp))
+ (not (memq this-command
+ '(evil-insert evil-beginning-of-line
evil-first-non-blank)))
+ (forward-char))
+ (unless (memq evil-state '(replace insert))
+ (evil-change-state estate))
+ (when (eq 'insert evil-state)
+ (remove-hook 'pre-command-hook #'evil-repeat-pre-hook)
+ (remove-hook 'post-command-hook #'evil-repeat-post-hook)
+ (add-hook 'evil-insert-state-exit-hook #'evil--restore-repeat-hooks))
+ (add-hook 'evil-insert-state-exit-hook 'evil--restore-repeat-hooks))))
(setq evil-insert-count nil
evil--execute-normal-return-state evil-state
evil--execute-normal-eol-pos (when (eolp) (point-marker))
@@ -5232,7 +5233,7 @@ Restore the disabled repeat hooks on insert-state exit."
(defun evil-stop-execute-in-emacs-state ()
(when (and (not (eq this-command #'evil-execute-in-emacs-state))
(not (minibufferp)))
- (remove-hook 'post-command-hook 'evil-stop-execute-in-emacs-state)
+ (remove-hook 'post-command-hook #'evil-stop-execute-in-emacs-state)
(when (buffer-live-p evil-execute-in-emacs-state-buffer)
(with-current-buffer evil-execute-in-emacs-state-buffer
(if (and (eq evil-previous-state 'visual)
diff --git a/evil-common.el b/evil-common.el
index 49a5456d9c..aa4183528d 100644
--- a/evil-common.el
+++ b/evil-common.el
@@ -49,29 +49,38 @@
(if (fboundp 'gui-set-selection) 'gui-set-selection 'x-set-selection))
;; macro helper
-(eval-and-compile
- (defun evil-unquote (exp)
- "Return EXP unquoted."
- (while (eq (car-safe exp) 'quote)
- (setq exp (cadr exp)))
- exp))
+(defun evil--with-delay (cond-fun body-fun hook &optional append local name)
+ (if (and cond-fun (funcall cond-fun))
+ (funcall body-fun)
+ (let* ((name (or name (format "evil-delay-in-%s" hook)))
+ (fun (make-symbol name)))
+ (fset fun (lambda (&rest _)
+ (when (or (null cond-fun) (funcall cond-fun))
+ (remove-hook hook fun local)
+ (funcall body-fun))))
+ (put fun 'permanent-local-hook t)
+ (add-hook hook fun append local))))
+
+(defmacro evil-with-delay (condition hook &rest body)
+ "Execute BODY when CONDITION becomes true, checking with HOOK.
+HOOK can be a simple symbol or it can be of the form
+\(HOOK APPEND LOCAL NAME) where:
+NAME specifies the name of the entry added to HOOK.
+If APPEND is non-nil, the entry is appended to the hook.
+If LOCAL is non-nil, the buffer-local value of HOOK is modified."
+ (declare (debug (form sexp body)) (indent 2))
+ (unless (consp hook) (setq hook (list hook)))
+ `(evil--with-delay ,(if condition `(lambda () ,condition))
+ (lambda () ,@body)
+ ,@(mapcar #'macroexp-quote hook)))
(defun evil-delay (condition form hook &optional append local name)
"Execute FORM when CONDITION becomes true, checking with HOOK.
NAME specifies the name of the entry added to HOOK. If APPEND is
non-nil, the entry is appended to the hook. If LOCAL is non-nil,
the buffer-local value of HOOK is modified."
- (if (and (not (booleanp condition)) (eval condition))
- (eval form)
- (let* ((name (or name (format "evil-delay-form-in-%s" hook)))
- (fun (make-symbol name))
- (condition (or condition t)))
- (fset fun `(lambda (&rest args)
- (when ,condition
- (remove-hook ',hook #',fun ',local)
- ,form)))
- (put fun 'permanent-local-hook t)
- (add-hook hook fun append local))))
+ (declare (obsolete evil-with-delay "2022"))
+ (eval `(evil-with-delay ,condition (,hook ,append ,local ,name) ,form) t))
(put 'evil-delay 'lisp-indent-function 2)
;;; List functions
@@ -123,7 +132,7 @@ otherwise add at the end of the list."
"Delete by side-effect all items satisfying PREDICATE in LIST.
Stop when reaching POINTER. If the first item satisfies PREDICATE,
there is no way to remove it by side-effect; therefore, write
-\(setq foo (evil-filter-list 'predicate foo)) to be sure of
+\(setq foo (evil-filter-list #\\='predicate foo)) to be sure of
changing the value of `foo'."
(let ((tail list) elt head)
(while (and tail (not (eq tail pointer)))
@@ -345,11 +354,11 @@ last, sorting in between."
,(when (and command doc-form)
`(put ',command 'function-documentation ,doc-form))
;; set command properties for symbol or lambda function
- (let ((func ',(if (and (null command) body)
- `(lambda ,args
- ,interactive
- ,@body)
- command)))
+ (let ((func #',(if (and (null command) body)
+ `(lambda ,args
+ ,interactive
+ ,@body)
+ command)))
(apply #'evil-set-command-properties func ',keys)
func))))
@@ -1086,9 +1095,9 @@ immediately quits.
(defun evil-signal-at-bob-or-eob (&optional count)
"Signal error if `point' is at boundaries.
-If `point' is at bob and COUNT is negative this function signal
-`beginning-of-buffer'. If `point' is at eob and COUNT is positive
-this function singal `end-of-buffer'. This function should be used
+If `point' is at bob and COUNT is negative this function signals
+`beginning-of-buffer'. If `point' is at eob and COUNT is positive
+this function signals `end-of-buffer'. This function should be used
in motions. COUNT defaults to 1."
(setq count (or count 1))
(cond
diff --git a/evil-core.el b/evil-core.el
index fae8bcdff0..7026d9c4e3 100644
--- a/evil-core.el
+++ b/evil-core.el
@@ -126,12 +126,12 @@
(evil-initialize-state)
(add-hook 'input-method-activate-hook #'evil-activate-input-method t t)
(add-hook 'input-method-deactivate-hook #'evil-deactivate-input-method
t t)
- (add-hook 'activate-mark-hook 'evil-visual-activate-hook nil t)
+ (add-hook 'activate-mark-hook #'evil-visual-activate-hook nil t)
;; FIXME: Add these hooks buffer-locally
- (add-hook 'pre-command-hook 'evil-repeat-pre-hook)
- (add-hook 'post-command-hook 'evil-repeat-post-hook))
+ (add-hook 'pre-command-hook #'evil-repeat-pre-hook)
+ (add-hook 'post-command-hook #'evil-repeat-post-hook))
(evil-refresh-mode-line)
- (remove-hook 'activate-mark-hook 'evil-visual-activate-hook t)
+ (remove-hook 'activate-mark-hook #'evil-visual-activate-hook t)
(remove-hook 'input-method-activate-hook #'evil-activate-input-method t)
(remove-hook 'input-method-deactivate-hook #'evil-deactivate-input-method
t)
(activate-input-method evil-input-method)
@@ -348,6 +348,7 @@ then this function does nothing."
;; Refresh cursor color.
;; Cursor color can only be set for each frame but not for each buffer.
+;; FIXME: Shouldn't this belong in `evil-(local-)mode'?
(add-hook 'window-configuration-change-hook #'evil-refresh-cursor)
(defadvice select-window (after evil activate)
(evil-refresh-cursor))
@@ -988,16 +989,17 @@ mode, in which case `evil-define-minor-mode-key' is used."
((and (consp keymap) (eq (car keymap) 'quote))
`(evil-define-minor-mode-key ,state ,keymap ,key ,def ,@bindings))
(t
- `(evil-delay ',(if (symbolp keymap)
- `(and (boundp ',keymap) (keymapp ,keymap))
- `(keymapp ,keymap))
- '(condition-case-unless-debug err
- (evil-define-key* ,state ,keymap ,key ,def ,@bindings)
- (error (message "error in evil-define-key: %s"
- (error-message-string err))))
- 'after-load-functions t nil
- (format "evil-define-key-in-%s"
- ',(if (symbolp keymap) keymap 'keymap))))))
+ `(evil-with-delay ,(if (symbolp keymap)
+ `(and (boundp ',keymap) (keymapp ,keymap))
+ `(keymapp ,keymap))
+ (after-load-functions t nil
+ ,(format "evil-define-key-in-%s"
+ (if (symbolp keymap) keymap
+ 'keymap)))
+ (condition-case-unless-debug err
+ (evil-define-key* ,state ,keymap ,key ,def ,@bindings)
+ (error (message "error in evil-define-key: %s"
+ (error-message-string err))))))))
(defalias 'evil-declare-key #'evil-define-key)
(defun evil-define-key* (state keymap key def &rest bindings)
@@ -1040,7 +1042,7 @@ The use is nearly identical to `evil-define-key' with the
exception that this is a function and not a macro (and so will
not be expanded when compiled which can have unintended
consequences). `evil-define-key*' also does not defer any
-bindings like `evil-define-key' does using `evil-delay'. This
+bindings like `evil-define-key' does using `evil-with-delay'. This
allows errors in the bindings to be caught immediately, and makes
its behavior more predictable."
(declare (indent defun))
diff --git a/evil-digraphs.el b/evil-digraphs.el
index 7344bd9d00..180a57626b 100644
--- a/evil-digraphs.el
+++ b/evil-digraphs.el
@@ -42,8 +42,7 @@ where the digraph is a list of two characters.
See also `evil-digraphs-table'."
:type '(alist :key-type (list character character)
:value-type character)
- :require 'evil-digraphs
- :group 'evil-digraphs)
+ :require 'evil-digraphs)
(defconst evil-digraphs-table
'(((?N ?U) . ?\x00)
diff --git a/evil-ex.el b/evil-ex.el
index d1e3f42663..356ecd81f8 100644
--- a/evil-ex.el
+++ b/evil-ex.el
@@ -335,6 +335,8 @@ The following symbols have reserved meanings within a
grammar:
"Whether Ex is currently active."
(when evil-ex-current-buffer t))
+(defvar evil-ex-info-string) ;; FIXME: Where is it used?
+
(evil-define-command evil-ex (&optional initial-input)
"Enter an Ex command.
The ex command line is initialized with the value of
@@ -751,7 +753,7 @@ argument handler that requires shell completion."
(define-obsolete-function-alias
'evil-ex-shell-command-completion-at-point
- 'comint-completion-at-point "1.2.13")
+ #'comint-completion-at-point "1.2.13")
(evil-ex-define-argument-type shell
"Shell argument type, supports completion."
diff --git a/evil-jumps.el b/evil-jumps.el
index 93bf4cbcb6..2fadb8b205 100644
--- a/evil-jumps.el
+++ b/evil-jumps.el
@@ -38,28 +38,23 @@
(defcustom evil-jumps-cross-buffers t
"When non-nil, the jump commands can cross borders between buffers.
Otherwise the jump commands act only within the current buffer."
- :type 'boolean
- :group 'evil-jumps)
+ :type 'boolean)
(defcustom evil-jumps-max-length 100
"The maximum number of jumps to keep track of."
- :type 'integer
- :group 'evil-jumps)
+ :type 'integer)
(defcustom evil-jumps-pre-jump-hook nil
"Hooks to run just before jumping to a location in the jump list."
- :type 'hook
- :group 'evil-jumps)
+ :type 'hook)
(defcustom evil-jumps-post-jump-hook nil
"Hooks to run just after jumping to a location in the jump list."
- :type 'hook
- :group 'evil-jumps)
+ :type 'hook)
(defcustom evil-jumps-ignored-file-patterns '("COMMIT_EDITMSG$" "TAGS$")
"List of regexps to exclude file path from inclusion in the jump list."
- :type '(repeat string)
- :group 'evil-jumps)
+ :type '(repeat string))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
diff --git a/evil-keybindings.el b/evil-keybindings.el
index 8534ec856d..c63890b05a 100644
--- a/evil-keybindings.el
+++ b/evil-keybindings.el
@@ -42,7 +42,7 @@
;; FIXME: probably etags-select should be recomended in docs
(eval-after-load 'etags-select
'(progn
- (define-key evil-motion-state-map "g]" 'etags-select-find-tag-at-point)))
+ (define-key evil-motion-state-map "g]" #'etags-select-find-tag-at-point)))
;;; Buffer-menu
diff --git a/evil-macros.el b/evil-macros.el
index 1ba6e51c18..0d9d4ea161 100644
--- a/evil-macros.el
+++ b/evil-macros.el
@@ -763,19 +763,19 @@ via KEY-VALUE pairs. BODY should evaluate to a list of
values.
(while (keywordp (car-safe body))
(setq properties
(append properties (list (pop body) (pop body)))))
- (cond
- (args
- (setq func `(lambda ,args
+ (setq func (cond
+ (args
+ `(lambda ,args
,@(when doc `(,doc))
- ,@body)))
- ((> (length body) 1)
- (setq func `(progn ,@body)))
- (t
- (setq func (car body))))
+ ,@body))
+ ((> (length body) 1)
+ `'(progn ,@body))
+ (t
+ `',(car body))))
`(eval-and-compile
(let* ((code ,code)
(entry (assoc code evil-interactive-alist))
- (value (cons ',func ',properties)))
+ (value (cons ,func ',properties)))
(if entry
(setcdr entry value)
(push (cons code value) evil-interactive-alist))
diff --git a/evil-pkg.el b/evil-pkg.el
deleted file mode 100644
index 0ab78cb335..0000000000
--- a/evil-pkg.el
+++ /dev/null
@@ -1,7 +0,0 @@
-(define-package
- "evil"
- "1.15.0"
- "Extensible Vi layer for Emacs."
- '((emacs "24.1")
- (goto-chg "1.6")
- (cl-lib "0.5")))
diff --git a/evil-search.el b/evil-search.el
index e26325c666..57b8181208 100644
--- a/evil-search.el
+++ b/evil-search.el
@@ -65,8 +65,8 @@ To swap out relevant keybindings, see
`evil-select-search-module' function."
:type '(radio (const :tag "Emacs built-in isearch." :value isearch)
(const :tag "Evil interactive search." :value evil-search))
:group 'evil
- :set 'evil-select-search-module
- :initialize 'evil-custom-initialize-pending-reset)
+ :set #'evil-select-search-module
+ :initialize #'evil-custom-initialize-pending-reset)
(defun evil-push-search-history (string forward)
"Push STRING into the appropriate search history (determined by FORWARD)."
diff --git a/evil-states.el b/evil-states.el
index abade4c6df..0f20c62869 100644
--- a/evil-states.el
+++ b/evil-states.el
@@ -390,17 +390,16 @@ otherwise exit Visual state."
(defun evil-visual-activate-hook (&optional _command)
"Enable Visual state if the region is activated."
(unless (evil-visual-state-p)
- (evil-delay nil
- ;; the activation may only be momentary, so re-check
- ;; in `post-command-hook' before entering Visual state
- '(unless (or (evil-visual-state-p)
- (evil-insert-state-p)
- (evil-emacs-state-p))
- (when (and (region-active-p)
- (not deactivate-mark))
- (evil-visual-state)))
- 'post-command-hook nil t
- "evil-activate-visual-state")))
+ (evil-with-delay nil
+ (post-command-hook nil t "evil-activate-visual-state")
+ ;; the activation may only be momentary, so re-check
+ ;; in `post-command-hook' before entering Visual state
+ (unless (or (evil-visual-state-p)
+ (evil-insert-state-p)
+ (evil-emacs-state-p))
+ (when (and (region-active-p)
+ (not deactivate-mark))
+ (evil-visual-state))))))
(put 'evil-visual-activate-hook 'permanent-local-hook t)
(defun evil-visual-deactivate-hook (&optional command)
diff --git a/evil-tests.el b/evil-tests.el
index 9e8f8589ec..4e8816916b 100644
--- a/evil-tests.el
+++ b/evil-tests.el
@@ -1,4 +1,4 @@
-;; evil-tests.el --- unit tests for Evil -*- coding: utf-8 -*-
+;; evil-tests.el --- unit tests for Evil -*- coding: utf-8; lexical-binding:
t; -*-
;; Author: Vegard Øye <vegard_oye at hotmail.com>
;; Maintainer: Vegard Øye <vegard_oye at hotmail.com>
@@ -200,13 +200,12 @@ with `M-x evil-tests-run'"))
(defun evil-test-change-state (state)
"Change state to STATE and check keymaps"
- (let (mode keymap local-mode local-keymap tag)
- (evil-change-state state)
- (setq mode (evil-state-property state :mode)
- keymap (evil-state-property state :keymap t)
- local-mode (evil-state-property state :local)
- local-keymap (evil-state-property state :local-keymap t)
- tag (evil-state-property state :tag t))
+ (evil-change-state state)
+ (let ((mode (evil-state-property state :mode))
+ ;; (keymap (evil-state-property state :keymap t))
+ (local-mode (evil-state-property state :local))
+ ;; (local-keymap (evil-state-property state :local-keymap t))
+ (tag (evil-state-property state :tag t)))
(when (functionp tag)
(setq tag (funcall tag)))
(ert-info ("Update `evil-state'")
@@ -442,14 +441,15 @@ when exiting Operator-Pending state")
(ert-deftest evil-test-auxiliary-maps ()
"Test auxiliary keymaps"
:tags '(evil state)
- (let ((map (make-sparse-keymap)) aux)
+ (defvar evil--map)
+ (let ((evil--map (make-sparse-keymap)) aux)
(ert-info ("Create a new auxiliary keymap")
- (evil-define-key 'normal map "f" 'foo)
- (setq aux (evil-get-auxiliary-keymap map 'normal))
+ (evil-define-key 'normal evil--map "f" 'foo)
+ (setq aux (evil-get-auxiliary-keymap evil--map 'normal))
(should (evil-auxiliary-keymap-p aux))
(should (eq (lookup-key aux "f") 'foo)))
(ert-info ("Add to auxiliary keymap")
- (evil-define-key 'normal map "b" 'bar)
+ (evil-define-key 'normal evil--map "b" 'bar)
(should (eq (lookup-key aux "f") 'foo))
(should (eq (lookup-key aux "b") 'bar)))))
@@ -493,7 +493,7 @@ when exiting Operator-Pending state")
(second-line (progn
(forward-line)
(point)))
- (third-line (progn
+ (_third-line (progn
(forward-line)
(point))))
(ert-info ("Return the beginning and end unchanged \
@@ -1948,7 +1948,7 @@ New Tex[t]
";; [T]his buffer is for notes you don't want to save.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer."
- (define-key evil-operator-state-local-map "s" 'evil-test-square-motion)
+ (define-key evil-operator-state-local-map "s" #'evil-test-square-motion)
("y3s")
(should (string= (current-kill 0) "Thi\nIf \nthe"))
(should (eq (car-safe (get-text-property 0 'yank-handler
@@ -2056,7 +2056,7 @@ New Tex[t]
"[;]; This buffer is for notes you don't want to save.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer."
- (define-key evil-operator-state-local-map "s" 'evil-test-square-motion)
+ (define-key evil-operator-state-local-map "s" #'evil-test-square-motion)
("d3s")
"[T]his buffer is for notes you don't want to save.
If you want to create a file, visit that file with C-x C-f,
@@ -2301,7 +2301,7 @@ for this test."))
"[;]; This buffer is for notes you don't want to save.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer."
- (define-key evil-operator-state-local-map "s" 'evil-test-square-motion)
+ (define-key evil-operator-state-local-map "s" #'evil-test-square-motion)
("c3sABC" [escape])
"AB[C]This buffer is for notes you don't want to save.
ABCIf you want to create a file, visit that file with C-x C-f,
@@ -2614,7 +2614,7 @@ This bufferThis bufferThis buffe[r];; and for Lisp
evaluation."))
"[;]; This buffer is for notes you don't want to save.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer."
- (define-key evil-operator-state-local-map "s" 'evil-test-square-motion)
+ (define-key evil-operator-state-local-map "s" #'evil-test-square-motion)
("3ysP")
"[;]; ;; This buffer is for notes you don't want to save.
;; ;; If you want to create a file, visit that file with C-x C-f,
@@ -2624,7 +2624,7 @@ This bufferThis bufferThis buffe[r];; and for Lisp
evaluation."))
"[;]; This buffer is for notes you don't want to save.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer."
- (define-key evil-operator-state-local-map "s" 'evil-test-square-motion)
+ (define-key evil-operator-state-local-map "s" #'evil-test-square-motion)
("3ys2P")
"[;]; ;; ;; This buffer is for notes you don't want to save.
;; ;; ;; If you want to create a file, visit that file with C-x C-f,
@@ -2634,7 +2634,7 @@ This bufferThis bufferThis buffe[r];; and for Lisp
evaluation."))
"[;]; Above some line
;; Below some empty line"
- (define-key evil-operator-state-local-map "s" 'evil-test-square-motion)
+ (define-key evil-operator-state-local-map "s" #'evil-test-square-motion)
("3ys2P")
"[;]; ;; ;; Above some line
\n\
@@ -2644,7 +2644,7 @@ This bufferThis bufferThis buffe[r];; and for Lisp
evaluation."))
"[;]; This buffer is for notes you don't want to save.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer."
- (define-key evil-operator-state-local-map "s" 'evil-test-square-motion)
+ (define-key evil-operator-state-local-map "s" #'evil-test-square-motion)
("3ysj")
";; This buffer is for notes you don't want to save.
\[;]; If you want to create a file, visit that file with C-x C-f,
@@ -2659,7 +2659,7 @@ This bufferThis bufferThis buffe[r];; and for Lisp
evaluation."))
"[;]; This buffer is for notes you don't want to save.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer."
- (define-key evil-operator-state-local-map "s" 'evil-test-square-motion)
+ (define-key evil-operator-state-local-map "s" #'evil-test-square-motion)
("3ys$")
";; This buffer is for notes you don't want to save[.]
;; If you want to create a file, visit that file with C-x C-f,
@@ -2741,7 +2741,7 @@ This bufferThis bufferThis buffe[r];; and for Lisp
evaluation."))
"[;]; This buffer is for notes you don't want to save.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer."
- (define-key evil-operator-state-local-map "s" 'evil-test-square-motion)
+ (define-key evil-operator-state-local-map "s" #'evil-test-square-motion)
("3ysp")
";[;]; ; This buffer is for notes you don't want to save.
;;; ; If you want to create a file, visit that file with C-x C-f,
@@ -2751,7 +2751,7 @@ This bufferThis bufferThis buffe[r];; and for Lisp
evaluation."))
"[;]; This buffer is for notes you don't want to save.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer."
- (define-key evil-operator-state-local-map "s" 'evil-test-square-motion)
+ (define-key evil-operator-state-local-map "s" #'evil-test-square-motion)
("3ys2p")
";[;]; ;; ; This buffer is for notes you don't want to save.
;;; ;; ; If you want to create a file, visit that file with C-x C-f,
@@ -2761,7 +2761,7 @@ This bufferThis bufferThis buffe[r];; and for Lisp
evaluation."))
"[;]; Above some line
;; Below some empty line"
- (define-key evil-operator-state-local-map "s" 'evil-test-square-motion)
+ (define-key evil-operator-state-local-map "s" #'evil-test-square-motion)
("3ys2p")
";;; ;; ; Above some line
@@ -2771,7 +2771,7 @@ This bufferThis bufferThis buffe[r];; and for Lisp
evaluation."))
"[;]; This buffer is for notes you don't want to save.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer."
- (define-key evil-operator-state-local-map "s" 'evil-test-square-motion)
+ (define-key evil-operator-state-local-map "s" #'evil-test-square-motion)
("3ysj")
";; This buffer is for notes you don't want to save.
\[;]; If you want to create a file, visit that file with C-x C-f,
@@ -2786,7 +2786,7 @@ This bufferThis bufferThis buffe[r];; and for Lisp
evaluation."))
"[;]; This buffer is for notes you don't want to save.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer."
- (define-key evil-operator-state-local-map "s" 'evil-test-square-motion)
+ (define-key evil-operator-state-local-map "s" #'evil-test-square-motion)
("3ys$")
";; This buffer is for notes you don't want to save[.]
;; If you want to create a file, visit that file with C-x C-f,
@@ -2816,7 +2816,7 @@ This bufferThis bufferThis buffe[r];; and for Lisp
evaluation."))
"[;]; This buffer is for notes you don't want to save.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer."
- (define-key evil-operator-state-local-map "s" 'evil-test-square-motion)
+ (define-key evil-operator-state-local-map "s" #'evil-test-square-motion)
("y2e2yyy3sj")
";; This buffer is for notes you don't want to save.
\[;]; If you want to create a file, visit that file with C-x C-f,
@@ -2831,7 +2831,7 @@ This bufferThis bufferThis buffe[r];; and for Lisp
evaluation."))
"[;]; This buffer is for notes you don't want to save.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer."
- (define-key evil-operator-state-local-map "s" 'evil-test-square-motion)
+ (define-key evil-operator-state-local-map "s" #'evil-test-square-motion)
("y2e2yyy3sjP\C-p")
";; This buffer is for notes you don't want to save.
\[;]; This buffer is for notes you don't want to save.
@@ -2843,7 +2843,7 @@ This bufferThis bufferThis buffe[r];; and for Lisp
evaluation."))
"[;]; This buffer is for notes you don't want to save.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer."
- (define-key evil-operator-state-local-map "s" 'evil-test-square-motion)
+ (define-key evil-operator-state-local-map "s" #'evil-test-square-motion)
("y2e2yyy3sjP\C-p\C-p")
";; This buffer is for notes you don't want to save.
;; Thi[s];; If you want to create a file, visit that file with C-x C-f,
@@ -2853,7 +2853,7 @@ This bufferThis bufferThis buffe[r];; and for Lisp
evaluation."))
"[;]; This buffer is for notes you don't want to save.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer."
- (define-key evil-operator-state-local-map "s" 'evil-test-square-motion)
+ (define-key evil-operator-state-local-map "s" #'evil-test-square-motion)
("y2e2yyy3sjP2\C-p")
";; This buffer is for notes you don't want to save.
;; Thi[s];; If you want to create a file, visit that file with C-x C-f,
@@ -2863,7 +2863,7 @@ This bufferThis bufferThis buffe[r];; and for Lisp
evaluation."))
"[;]; This buffer is for notes you don't want to save.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer."
- (define-key evil-operator-state-local-map "s" 'evil-test-square-motion)
+ (define-key evil-operator-state-local-map "s" #'evil-test-square-motion)
("y2e2yyy3sjP2\C-p\C-n")
";; This buffer is for notes you don't want to save.
\[;]; This buffer is for notes you don't want to save.
@@ -2875,7 +2875,7 @@ This bufferThis bufferThis buffe[r];; and for Lisp
evaluation."))
"[;]; This buffer is for notes you don't want to save.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer."
- (define-key evil-operator-state-local-map "s" 'evil-test-square-motion)
+ (define-key evil-operator-state-local-map "s" #'evil-test-square-motion)
("y2e2yyy3sjP\C-p\C-p2\C-n")
";; This buffer is for notes you don't want to save.
\[;]; ;; If you want to create a file, visit that file with C-x C-f,
@@ -2890,7 +2890,7 @@ This bufferThis bufferThis buffe[r];; and for Lisp
evaluation."))
"[;]; This buffer is for notes you don't want to save.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer."
- (define-key evil-operator-state-local-map "s" 'evil-test-square-motion)
+ (define-key evil-operator-state-local-map "s" #'evil-test-square-motion)
("y2e2yyy3sj")
";; This buffer is for notes you don't want to save.
\[;]; If you want to create a file, visit that file with C-x C-f,
@@ -2905,7 +2905,7 @@ This bufferThis bufferThis buffe[r];; and for Lisp
evaluation."))
"[;]; This buffer is for notes you don't want to save.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer."
- (define-key evil-operator-state-local-map "s" 'evil-test-square-motion)
+ (define-key evil-operator-state-local-map "s" #'evil-test-square-motion)
("y2e2yyy3sjp\C-p")
";; This buffer is for notes you don't want to save.
;; If you want to create a file, visit that file with C-x C-f,
@@ -2917,7 +2917,7 @@ This bufferThis bufferThis buffe[r];; and for Lisp
evaluation."))
"[;]; This buffer is for notes you don't want to save.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer."
- (define-key evil-operator-state-local-map "s" 'evil-test-square-motion)
+ (define-key evil-operator-state-local-map "s" #'evil-test-square-motion)
("y2e2yyy3sjp\C-p\C-p")
";; This buffer is for notes you don't want to save.
;;; Thi[s]; If you want to create a file, visit that file with C-x C-f,
@@ -2927,7 +2927,7 @@ This bufferThis bufferThis buffe[r];; and for Lisp
evaluation."))
"[;]; This buffer is for notes you don't want to save.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer."
- (define-key evil-operator-state-local-map "s" 'evil-test-square-motion)
+ (define-key evil-operator-state-local-map "s" #'evil-test-square-motion)
("y2e2yyy3sjp2\C-p")
";; This buffer is for notes you don't want to save.
;;; Thi[s]; If you want to create a file, visit that file with C-x C-f,
@@ -2937,7 +2937,7 @@ This bufferThis bufferThis buffe[r];; and for Lisp
evaluation."))
"[;]; This buffer is for notes you don't want to save.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer."
- (define-key evil-operator-state-local-map "s" 'evil-test-square-motion)
+ (define-key evil-operator-state-local-map "s" #'evil-test-square-motion)
("y2e2yyy3sjp2\C-p\C-n")
";; This buffer is for notes you don't want to save.
;; If you want to create a file, visit that file with C-x C-f,
@@ -2949,7 +2949,7 @@ This bufferThis bufferThis buffe[r];; and for Lisp
evaluation."))
"[;]; This buffer is for notes you don't want to save.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer."
- (define-key evil-operator-state-local-map "s" 'evil-test-square-motion)
+ (define-key evil-operator-state-local-map "s" #'evil-test-square-motion)
("y2e2yyy3sjp\C-p\C-p2\C-n")
";; This buffer is for notes you don't want to save.
;[;]; ; If you want to create a file, visit that file with C-x C-f,
@@ -2965,7 +2965,7 @@ This bufferThis bufferThis buffe[r];; and for Lisp
evaluation."))
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer."
(setq buffer-undo-list t)
- (define-key evil-operator-state-local-map "s" 'evil-test-square-motion)
+ (define-key evil-operator-state-local-map "s" #'evil-test-square-motion)
("y2e2yyy3sjP\C-p\C-p2\C-n")
";; This buffer is for notes you don't want to save.
\[;]; ;; If you want to create a file, visit that file with C-x C-f,
@@ -6032,7 +6032,7 @@ Line 2"))
(ert-deftest evil-test-text-object ()
"Test `evil-define-text-object'"
:tags '(evil text-object)
- (let ((object (evil-define-text-object nil (count &optional beg end type)
+ (let ((object (evil-define-text-object nil (count &optional beg end _type)
(let ((sel (and beg end (evil-range beg end))))
(when (and sel (> count 0)) (forward-char 1))
(let ((range (if (< count 0)
@@ -7449,7 +7449,7 @@ golf h[o]>tel")))
([backspace backspace backspace backspace backspace backspace backspace])
";; This buffer is for [n]otes"))
(ert-info ("Replace from line below and restore")
- (define-key evil-replace-state-map (kbd "C-e") 'evil-copy-from-below)
+ (define-key evil-replace-state-map (kbd "C-e") #'evil-copy-from-below)
(evil-test-buffer
";; [f]oo bar\n;; qux quux"
("R\C-e\C-e\C-e")
@@ -7458,7 +7458,7 @@ golf h[o]>tel")))
";; [f]oo bar\n;; qux quux")
(define-key evil-replace-state-map (kbd "C-e") nil))
(ert-info ("Replace from line above and restore")
- (define-key evil-replace-state-map (kbd "C-y") 'evil-copy-from-above)
+ (define-key evil-replace-state-map (kbd "C-y") #'evil-copy-from-above)
(evil-test-buffer
";; foo bar\n;; [q]ux quux"
("R\C-y\C-y\C-y")
@@ -8524,6 +8524,15 @@ maybe we need one line more with some text\n")
("vj!sort" [return])
"line 5\n[l]ine 3\nline 4\nline 2\nline 1\n")))
+(defmacro evil-with-both-search-modules (&rest body)
+ `(mapc (lambda (search-module)
+ (setq evil-search-forward-history nil
+ evil-search-backward-history nil
+ evil-ex-search-history nil)
+ (evil-select-search-module 'evil-search-module search-module)
+ ,@body)
+ '(isearch evil-search)))
+
(ert-deftest evil-test-global ()
"Test `evil-ex-global'."
:tags '(evil ex global)
@@ -8892,15 +8901,6 @@ Source
(execute-kbd-macro "q:")
(should (= (length (window-list)) num-windows))))))
-(defmacro evil-with-both-search-modules (&rest body)
- `(mapc (lambda (search-module)
- (setq evil-search-forward-history nil
- evil-search-backward-history nil
- evil-ex-search-history nil)
- (evil-select-search-module 'evil-search-module search-module)
- ,@body)
- '(isearch evil-search)))
-
(ert-deftest evil-test-command-window-search-history ()
"Test command window with forward and backward search history"
(skip-unless (not noninteractive))
@@ -9105,25 +9105,26 @@ parameter set."
(ert-deftest evil-test-properties ()
"Test `evil-get-property' and `evil-put-property'"
:tags '(evil util)
- (let (alist)
+ (defvar evil--alist)
+ (let (evil--alist)
(ert-info ("Set properties")
- (evil-put-property 'alist 'wibble :foo t)
- (should (equal alist '((wibble . (:foo t)))))
- (evil-put-property 'alist 'wibble :bar nil)
- (should (equal alist '((wibble . (:foo t :bar nil)))))
- (evil-put-property 'alist 'wobble :foo nil :bar nil :baz t)
- (should (equal alist '((wobble . (:foo nil :bar nil :baz t))
+ (evil-put-property 'evil--alist 'wibble :foo t)
+ (should (equal evil--alist '((wibble . (:foo t)))))
+ (evil-put-property 'evil--alist 'wibble :bar nil)
+ (should (equal evil--alist '((wibble . (:foo t :bar nil)))))
+ (evil-put-property 'evil--alist 'wobble :foo nil :bar nil :baz t)
+ (should (equal evil--alist '((wobble . (:foo nil :bar nil :baz t))
(wibble . (:foo t :bar nil))))))
(ert-info ("Get properties")
- (should (evil-get-property alist 'wibble :foo))
- (should-not (evil-get-property alist 'wibble :bar))
- (should-not (evil-get-property alist 'wobble :foo))
- (should-not (evil-get-property alist 'wibble :baz))
- (should (equal (evil-get-property alist t :foo)
+ (should (evil-get-property evil--alist 'wibble :foo))
+ (should-not (evil-get-property evil--alist 'wibble :bar))
+ (should-not (evil-get-property evil--alist 'wobble :foo))
+ (should-not (evil-get-property evil--alist 'wibble :baz))
+ (should (equal (evil-get-property evil--alist t :foo)
'((wibble . t) (wobble . nil))))
- (should (equal (evil-get-property alist t :bar)
+ (should (equal (evil-get-property evil--alist t :bar)
'((wibble . nil) (wobble . nil))))
- (should (equal (evil-get-property alist t :baz)
+ (should (equal (evil-get-property evil--alist t :baz)
'((wobble . t)))))))
(ert-deftest evil-test-filter-list ()
@@ -9482,7 +9483,7 @@ parameter set."
(ert-info ("Find file at point with line and column numbers")
(let* ((line-number 3)
(column-number 5)
- (file-content (mapconcat 'identity
+ (file-content (mapconcat #'identity
(make-list (* 2 line-number)
(make-string (* 2
column-number) ?\s))
"\n")))
diff --git a/evil-vars.el b/evil-vars.el
index df1b413a1b..f2d8f2b490 100644
--- a/evil-vars.el
+++ b/evil-vars.el
@@ -70,8 +70,8 @@ the :initialize property of `defcustom'.")
See `evil-pending-custom-initialize'."
(dolist (init evil-pending-custom-initialize)
(apply (car init) (cdr init)))
- (remove-hook 'evil-after-load-hook 'evil-run-pending-custom-initialize))
-(add-hook 'evil-after-load-hook 'evil-run-pending-custom-initialize)
+ (remove-hook 'evil-after-load-hook #'evil-run-pending-custom-initialize))
+(add-hook 'evil-after-load-hook #'evil-run-pending-custom-initialize)
;;; Setters
@@ -467,11 +467,12 @@ Otherwise, `C-i' inserts a tab character."
(cond
((and (not value)
(eq (lookup-key evil-motion-state-map (kbd "C-i"))
- 'evil-jump-forward))
+ #'evil-jump-forward))
(define-key evil-motion-state-map (kbd "C-i") nil))
((and value
(not (lookup-key evil-motion-state-map (kbd "C-i"))))
- (define-key evil-motion-state-map (kbd "C-i")
'evil-jump-forward))))))
+ (define-key evil-motion-state-map (kbd "C-i")
+ #'evil-jump-forward))))))
(defcustom evil-want-C-u-scroll nil
"Whether `C-u' scrolls up (like Vim).
@@ -486,11 +487,12 @@ ubiquity of prefix arguments."
(cond
((and (not value)
(eq (lookup-key evil-motion-state-map (kbd "C-u"))
- 'evil-scroll-up))
+ #'evil-scroll-up))
(define-key evil-motion-state-map (kbd "C-u") nil))
((and value
(not (lookup-key evil-motion-state-map (kbd "C-u"))))
- (define-key evil-motion-state-map (kbd "C-u")
'evil-scroll-up))))))
+ (define-key evil-motion-state-map (kbd "C-u")
+ #'evil-scroll-up))))))
(defcustom evil-want-C-d-scroll t
"Whether `C-d' scrolls down (like Vim)."
@@ -502,11 +504,12 @@ ubiquity of prefix arguments."
(cond
((and (not value)
(eq (lookup-key evil-motion-state-map (kbd "C-d"))
- 'evil-scroll-down))
+ #'evil-scroll-down))
(define-key evil-motion-state-map (kbd "C-d") nil))
((and value
(not (lookup-key evil-motion-state-map (kbd "C-d"))))
- (define-key evil-motion-state-map (kbd "C-d")
'evil-scroll-down))))))
+ (define-key evil-motion-state-map (kbd "C-d")
+ #'evil-scroll-down))))))
(defcustom evil-want-C-u-delete nil
"Whether `C-u' deletes back to indentation in insert state.
@@ -522,13 +525,15 @@ ubiquity of prefix arguments."
(cond
((and (not value)
(eq (lookup-key evil-insert-state-map (kbd "C-u"))
- 'evil-delete-back-to-indentation))
+ #'evil-delete-back-to-indentation))
(define-key evil-insert-state-map (kbd "C-u") nil)
(define-key evil-replace-state-map (kbd "C-u") nil))
((and value
(not (lookup-key evil-insert-state-map (kbd "C-u"))))
- (define-key evil-insert-state-map (kbd "C-u")
'evil-delete-back-to-indentation)
- (define-key evil-replace-state-map (kbd "C-u")
'evil-delete-back-to-indentation))))))
+ (define-key evil-insert-state-map (kbd "C-u")
+ #'evil-delete-back-to-indentation)
+ (define-key evil-replace-state-map (kbd "C-u")
+ #'evil-delete-back-to-indentation))))))
(defcustom evil-want-C-w-delete t
"Whether `C-w' deletes a word in Insert/Ex/Search state."
@@ -541,7 +546,7 @@ ubiquity of prefix arguments."
(cond
((and (not value)
(eq (lookup-key evil-insert-state-map (kbd "C-w"))
- 'evil-delete-backward-word))
+ #'evil-delete-backward-word))
(define-key evil-insert-state-map (kbd "C-w") 'evil-window-map)
(define-key evil-replace-state-map (kbd "C-w")
'evil-window-map))
((and value
@@ -581,13 +586,15 @@ ubiquity of prefix arguments."
(cond
((and (not value)
(eq (lookup-key evil-insert-state-map (kbd "C-h"))
- 'evil-delete-backward-char-and-join))
+ #'evil-delete-backward-char-and-join))
(define-key evil-insert-state-map (kbd "C-h") nil)
(define-key evil-replace-state-map (kbd "C-h") nil))
((and value
(not (lookup-key evil-insert-state-map (kbd "C-h"))))
- (define-key evil-insert-state-map (kbd "C-h")
'evil-delete-backward-char-and-join)
- (define-key evil-replace-state-map (kbd "C-h")
'evil-replace-backspace))))))
+ (define-key evil-insert-state-map (kbd "C-h")
+ #'evil-delete-backward-char-and-join)
+ (define-key evil-replace-state-map (kbd "C-h")
+ #'evil-replace-backspace))))))
(defcustom evil-want-C-g-bindings nil
"Whether `C-g' postfix can be used in bindings."
@@ -971,7 +978,7 @@ overridden."
'override-state
'evil-make-overriding-map
values))
- :initialize 'evil-custom-initialize-pending-reset)
+ :initialize #'evil-custom-initialize-pending-reset)
(add-hook 'after-load-functions #'evil-update-pending-maps)
@@ -991,7 +998,7 @@ intercepted."
'intercept-state
'evil-make-intercept-map
values))
- :initialize 'evil-custom-initialize-pending-reset)
+ :initialize #'evil-custom-initialize-pending-reset)
(defcustom evil-motions
'(back-to-indentation
@@ -1090,8 +1097,8 @@ intercepted."
"Non-Evil commands to initialize to motions."
:type '(repeat symbol)
:group 'evil
- :set 'evil-set-custom-motions
- :initialize 'evil-custom-initialize-pending-reset)
+ :set #'evil-set-custom-motions
+ :initialize #'evil-custom-initialize-pending-reset)
(defcustom evil-visual-newline-commands
'(LaTeX-section
@@ -1100,8 +1107,8 @@ intercepted."
These commands work better without this newline."
:type '(repeat symbol)
:group 'evil
- :set 'evil-set-visual-newline-commands
- :initialize 'evil-custom-initialize-pending-reset)
+ :set #'evil-set-visual-newline-commands
+ :initialize #'evil-custom-initialize-pending-reset)
(defcustom evil-want-visual-char-semi-exclusive nil
"DEPRECATED. Will be removed in a future version.
@@ -2036,7 +2043,7 @@ Otherwise the previous command is assumed as substitute.")
(defvar evil-ex-search-keymap (make-sparse-keymap)
"Keymap used in ex-search-mode.")
-(define-key evil-ex-search-keymap [escape] 'abort-recursive-edit)
+(define-key evil-ex-search-keymap [escape] #'abort-recursive-edit)
(set-keymap-parent evil-ex-search-keymap minibuffer-local-map)
(defcustom evil-want-empty-ex-last-command t
@@ -2087,8 +2094,8 @@ This variable must be set before evil is loaded."
:set #'(lambda (sym value)
(set-default sym value)
(if value
- (add-hook 'minibuffer-setup-hook 'evil-initialize)
- (remove-hook 'minibuffer-setup-hook 'evil-initialize))))
+ (add-hook 'minibuffer-setup-hook #'evil-initialize)
+ (remove-hook 'minibuffer-setup-hook #'evil-initialize))))
(defun evil--redo-placeholder (_count)
(user-error "Customize `evil-undo-system' for redo functionality."))
diff --git a/evil.el b/evil.el
index dc13a828c0..769f29dd1d 100644
--- a/evil.el
+++ b/evil.el
@@ -1,4 +1,4 @@
-;;; evil.el --- extensible vi layer
+;;; evil.el --- Extensible Vi layer for Emacs -*- lexical-binding: t; -*-
;; The following list of authors was kept up to date until the beginning of
;; 2017, when evil moved under new maintainers. For authors since then, please