From ba5b3220252365190b2130863620c255f052f071 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Fri, 30 Sep 2022 17:49:26 -0400 Subject: [PATCH] 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 | 76 ++++++++++++----------- evil-common.el | 65 +++++++++++--------- evil-core.el | 58 +++++++++--------- evil-digraphs.el | 3 +- evil-ex.el | 103 ++++++++++++++++--------------- evil-jumps.el | 15 ++--- evil-keybindings.el | 2 +- evil-macros.el | 20 +++--- evil-pkg.el | 7 --- evil-search.el | 4 +- evil-states.el | 21 +++---- evil-tests.el | 135 +++++++++++++++++++++-------------------- evil-vars.el | 61 +++++++++++-------- evil.el | 3 +- 15 files changed, 295 insertions(+), 280 deletions(-) delete mode 100644 evil-pkg.el diff --git a/evil-command-window.el b/evil-command-window.el index 21299a2d..566ee3a7 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 b704ba73..fa9d71c8 100644 --- a/evil-commands.el +++ b/evil-commands.el @@ -321,8 +321,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)) @@ -645,7 +644,7 @@ and jump to the corresponding one." (evil--next-flyspell-error nil))) (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)))) @@ -2944,7 +2943,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)) @@ -3129,7 +3128,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)) @@ -4872,9 +4871,9 @@ This var stores the eol position, so it can be restored when necessary.") "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.") @@ -4882,34 +4881,37 @@ 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))) - `(progn - (with-current-buffer ,(current-buffer) - (when (and evil--execute-normal-eol-pos - (= (point) (1- evil--execute-normal-eol-pos)) - (not (memq this-command '(evil-insert - evil-goto-mark)))) - (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-move-cursor-back ',evil-move-cursor-back - evil-move-beyond-eol ',evil-move-beyond-eol - evil-execute-normal-keys nil))) - 'post-command-hook) + (let ((buf (current-buffer)) + (estate evil-state) + (emcb evil-move-cursor-back) + (embe evil-move-beyond-eol)) + (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 + (when (and evil--execute-normal-eol-pos + (= (point) (1- evil--execute-normal-eol-pos)) + (not (memq this-command '(evil-insert + evil-goto-mark)))) + (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)) + (setq evil-move-cursor-back emcb + evil-move-beyond-eol embe + evil-execute-normal-keys nil)))) (setq evil-insert-count nil evil--execute-normal-return-state evil-state evil--execute-normal-eol-pos (when (eolp) (point)) @@ -4922,7 +4924,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 e8dd7056..f7757615 100644 --- a/evil-common.el +++ b/evil-common.el @@ -65,29 +65,38 @@ no arguments. In Emacs 23.2 and newer, it takes one argument." "Git commit 222b791") ;; 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 @@ -139,7 +148,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))) @@ -305,7 +314,7 @@ If three or more arguments are given, place the smallest value in the first argument and the largest in the last, sorting in between." (let ((sorted (make-symbol "sortvar"))) - `(let ((,sorted (sort (list ,min ,max ,@vars) '<))) + `(let ((,sorted (sort (list ,min ,max ,@vars) #'<))) (setq ,min (pop ,sorted) ,max (pop ,sorted) ,@(apply #'append @@ -374,11 +383,11 @@ 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)))) @@ -413,7 +422,7 @@ See also `evil-get-command-property'." To set multiple properties at once, see `evil-set-command-properties' and `evil-add-command-properties'." (evil-put-property 'evil-command-properties command property value)) -(defalias 'evil-put-command-property 'evil-set-command-property) +(defalias 'evil-put-command-property #'evil-set-command-property) (defun evil-add-command-properties (command &rest properties) "Add PROPERTIES to COMMAND. @@ -1203,9 +1212,9 @@ the loop immediately quits. See also `evil-loop'. (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 1e338252..86f8040e 100644 --- a/evil-core.el +++ b/evil-core.el @@ -127,8 +127,8 @@ emulation-mode-map-alists)) (evil-initialize-local-keymaps) ;; restore the proper value of `major-mode' in Fundamental buffers - (when (eq major-mode 'turn-on-evil-mode) - (setq major-mode 'fundamental-mode)) + (when (eq major-mode #'turn-on-evil-mode) + (setq major-mode #'fundamental-mode)) (when (minibufferp) (setq-local evil-default-state 'insert) (setq-local evil-echo-state nil)) @@ -138,16 +138,16 @@ ;; initialization is only for the case when `evil-local-mode' is ;; called directly for the first time in a buffer. (unless evil-state (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 'pre-command-hook 'evil-repeat-pre-hook) - (add-hook 'post-command-hook 'evil-repeat-post-hook)) + (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 'pre-command-hook #'evil-repeat-pre-hook) + (add-hook 'post-command-hook #'evil-repeat-post-hook)) (t (evil-refresh-mode-line) - (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) + (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) (evil-change-state nil)))) ;; Make the variable permanent local. This is particular useful in @@ -375,7 +375,8 @@ then this function does nothing." ;; Refresh cursor color. ;; Cursor color can only be set for each frame but not for each buffer. -(add-hook 'window-configuration-change-hook 'evil-refresh-cursor) +;; 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)) @@ -453,14 +454,14 @@ then this function does nothing." This allows input methods to be used in normal-state." `(unwind-protect (progn - (remove-hook 'input-method-activate-hook 'evil-activate-input-method t) + (remove-hook 'input-method-activate-hook #'evil-activate-input-method t) (remove-hook 'input-method-deactivate-hook - 'evil-deactivate-input-method t) + #'evil-deactivate-input-method t) ,@body) (progn - (add-hook 'input-method-activate-hook 'evil-activate-input-method nil t) + (add-hook 'input-method-activate-hook #'evil-activate-input-method nil t) (add-hook 'input-method-deactivate-hook - 'evil-deactivate-input-method nil t)))) + #'evil-deactivate-input-method nil t)))) (defadvice toggle-input-method (around evil) "Refresh `evil-input-method'." @@ -1048,18 +1049,19 @@ 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)))))) -(defalias 'evil-declare-key 'evil-define-key) + `(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) "Create a STATE binding from KEY to DEF for KEYMAP. @@ -1101,7 +1103,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 7344bd9d..180a5762 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 083fbdbe..df41c07e 100644 --- a/evil-ex.el +++ b/evil-ex.el @@ -1,4 +1,4 @@ -;;; evil-ex.el --- Ex-mode -*- lexical-binding: nil -*- +;;; evil-ex.el --- Ex-mode -*- lexical-binding: t -*- ;; Author: Frank Fischer ;; Maintainer: Vegard Øye @@ -143,6 +143,8 @@ of the syntax.") "Whether Ex is currently active." (and 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 @@ -275,7 +277,7 @@ Clean up everything set up by `evil-ex-setup'." (funcall runner 'stop))))) (put 'evil-ex-teardown 'permanent-local-hook t) -(defun evil-ex-update (&optional beg end len string) +(defun evil-ex-update (&optional beg _end _len string) "Update Ex variables when the minibuffer changes. This function is usually called from `after-change-functions' hook. If BEG is non-nil (which is the case when called from @@ -372,7 +374,7 @@ in case of incomplete or unknown commands." (when evil-ex-echo-overlay (delete-overlay evil-ex-echo-overlay) (setq evil-ex-echo-overlay nil)) - (remove-hook 'pre-command-hook 'evil--ex-remove-echo-overlay t)) + (remove-hook 'pre-command-hook #'evil--ex-remove-echo-overlay t)) (defun evil-ex-completion () "Complete the current ex command or argument." @@ -573,7 +575,7 @@ keywords and function: (declare-function shell-completion-vars "shell" ()) -(defun evil-ex-init-shell-argument-completion (flag &optional arg) +(defun evil-ex-init-shell-argument-completion (flag &optional _arg) "Prepare the current minibuffer for completion of shell commands. This function must be called from the :runner function of some argument handler that requires shell completion." @@ -586,14 +588,14 @@ argument handler that requires shell completion." (shell-completion-vars)) (t (set (make-local-variable 'minibuffer-default-add-function) - 'minibuffer-default-add-shell-commands))) + #'minibuffer-default-add-shell-commands))) (setq completion-at-point-functions '(evil-ex-command-completion-at-point evil-ex-argument-completion-at-point)))) (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." @@ -920,7 +922,7 @@ for the corresponding string index (counted from zero)." (traverse #'(lambda (tree path) (if (stringp tree) - (dotimes (char (length tree)) + (dotimes (_char (length tree)) (push path result)) (let ((path (cons (car tree) path))) (dolist (subtree (cdr tree)) @@ -1027,6 +1029,7 @@ one can determine how each character was parsed. The following symbols have reserved meanings within a grammar: `\\?', `*', `+', `&', `!', `function', `alt', `seq' and nil." + (defvar evil--context) (let ((string (or string "")) func pair result rules tail) (cond @@ -1052,15 +1055,15 @@ The following symbols have reserved meanings within a grammar: (setcar pair result))))) ;; symbol ((symbolp symbol) - (let ((context symbol)) + (let ((evil--context symbol)) (setq rules (cdr-safe (assq symbol grammar))) (setq pair (evil-parser string `(alt ,@rules) grammar greedy syntax)) (when (and syntax pair) (setq result (car pair)) - (if (and (listp result) (sequencep (car result))) - (setq result `(,symbol ,@result)) - (setq result `(,symbol ,result))) + (setq result (if (and (listp result) (sequencep (car result))) + `(,symbol ,@result) + `(,symbol ,result))) (setcar pair result)))) ;; function ((eq (car-safe symbol) 'function) @@ -1132,7 +1135,7 @@ The following symbols have reserved meanings within a grammar: ;; sequence (t (setq func (or func 'list)) - (let ((last (car-safe (last rules))) + (let (;; (last (car-safe (last rules))) current results rule) (catch 'done (while rules @@ -1149,49 +1152,51 @@ The following symbols have reserved meanings within a grammar: (setq result (car-safe current) tail (cdr-safe current)) (unless (memq (car-safe rule) '(& !)) - (if (and syntax - (or (null result) - (and (listp result) - (listp rule) - ;; splice in single-element - ;; (\? ...) expressions - (not (and (eq (car-safe rule) '\?) - (eq (length rule) 2)))))) - (setq results (append results result)) - (setq results (append results (list result))))) + (setq results + (append results + (if (and syntax + (or (null result) + (and (listp result) + (listp rule) + ;; splice in single-element + ;; (\? ...) expressions + (not (and (eq (car-safe rule) '\?) + (eq (length rule) 2)))))) + result + (list result))))) (setq string (or tail "")))))) (when results (setq pair (cons results tail)))))) ;; semantic action (when (and pair func (not syntax)) (setq result (car pair)) - (cond - ((null func) - (setq result nil)) - ;; lambda function - ((eq (car-safe func) 'lambda) - (if (memq symbol '(+ seq)) - (setq result `(funcall ,func ,@result)) - (setq result `(funcall ,func ,result)))) - ;; string replacement - ((or (stringp func) (stringp (car-safe func))) - (let* ((symbol (or (car-safe (cdr-safe func)) - (and (boundp 'context) context) - (car-safe (car-safe grammar)))) - (string (if (stringp func) func (car-safe func)))) - (setq result (car-safe (evil-parser string symbol grammar - greedy syntax))))) - ;; dollar expression - ((evil-parser--dexp func) - (setq result (evil-parser--dval func result))) - ;; function call - ((listp func) - (setq result (evil-parser--dval func result))) - ;; symbol - (t - (if (memq symbol '(+ seq)) - (setq result `(,func ,@result)) - (setq result `(,func ,result))))) + (setq result + (cond + ((null func) nil) + ;; lambda function + ((eq (car-safe func) 'lambda) + (if (memq symbol '(+ seq)) + `(funcall ,func ,@result) + `(funcall ,func ,result))) + ;; string replacement + ((or (stringp func) (stringp (car-safe func))) + (let* ((symbol (or (car-safe (cdr-safe func)) + (and (boundp 'evil--context) evil--context) + (car-safe (car-safe grammar)))) + (string (if (stringp func) func (car-safe func)))) + (car-safe (evil-parser string symbol grammar + greedy syntax)))) + ;; dollar expression + ((evil-parser--dexp func) + (evil-parser--dval func result)) + ;; function call + ((listp func) + (evil-parser--dval func result)) + ;; symbol + (t + (if (memq symbol '(+ seq)) + `(,func ,@result) + `(,func ,result))))) (setcar pair result)))) ;; weed out incomplete matches (when pair diff --git a/evil-jumps.el b/evil-jumps.el index de10b8da..f4563ec1 100644 --- a/evil-jumps.el +++ b/evil-jumps.el @@ -37,28 +37,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$") "A list of pattern regexps to match on the file path to exclude from being included in the jump list." - :type '(repeat string) - :group 'evil-jumps) + :type '(repeat string)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/evil-keybindings.el b/evil-keybindings.el index baafaf88..4e2c33e7 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 71bf1227..78050e90 100644 --- a/evil-macros.el +++ b/evil-macros.el @@ -599,7 +599,7 @@ RETURN-TYPE is non-nil." (setq keys (listify-key-sequence keys)) (dotimes (var (length keys)) (define-key evil-operator-shortcut-map - (vconcat (nthcdr var keys)) 'evil-line-or-visual-line))) + (vconcat (nthcdr var keys)) #'evil-line-or-visual-line))) ;; read motion from keyboard (setq command (evil-read-motion motion) motion (nth 0 command) @@ -775,19 +775,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 0ab78cb3..00000000 --- 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 4b147315..f5f8a3e4 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 9686062b..e208fd4b 100644 --- a/evil-states.el +++ b/evil-states.el @@ -379,17 +379,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 a9b3a796..0257c4dc 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 ;; Maintainer: Vegard Øye @@ -199,13 +199,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'") @@ -433,14 +432,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))))) @@ -484,7 +484,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 \ @@ -1920,7 +1920,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 @@ -2028,7 +2028,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, @@ -2268,7 +2268,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, @@ -2535,7 +2535,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, @@ -2545,7 +2545,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, @@ -2555,7 +2555,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\ @@ -2565,7 +2565,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, @@ -2580,7 +2580,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, @@ -2662,7 +2662,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, @@ -2672,7 +2672,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, @@ -2682,7 +2682,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 @@ -2692,7 +2692,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, @@ -2707,7 +2707,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, @@ -2737,7 +2737,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, @@ -2752,7 +2752,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. @@ -2764,7 +2764,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, @@ -2774,7 +2774,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, @@ -2784,7 +2784,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. @@ -2796,7 +2796,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, @@ -2811,7 +2811,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, @@ -2826,7 +2826,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, @@ -2838,7 +2838,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, @@ -2848,7 +2848,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, @@ -2858,7 +2858,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, @@ -2870,7 +2870,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, @@ -2886,7 +2886,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, @@ -5932,7 +5932,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) @@ -7324,7 +7324,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") @@ -7333,7 +7333,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") @@ -8407,6 +8407,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) @@ -8730,15 +8739,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)) @@ -8993,25 +8993,26 @@ Source (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 () @@ -9375,7 +9376,7 @@ Source (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"))) @@ -9581,7 +9582,7 @@ main(argc, argv) char **argv; { ;; is sufficient for `evil-initial-state-for-buffer' to work. (should-error (evil-initial-state-for-buffer))) (put 'test-1-mode 'derived-mode-parent 'prog-mode)))) - (defalias 'test-1-alias-mode 'test-1-mode) + (defalias 'test-1-alias-mode #'test-1-mode) (define-derived-mode test-3-mode test-1-alias-mode "Test3") (evil-set-initial-state 'test-1-mode 'insert) (ert-info ("Check inheritance from major mode aliases") diff --git a/evil-vars.el b/evil-vars.el index 8bd40117..1813b188 100644 --- a/evil-vars.el +++ b/evil-vars.el @@ -67,8 +67,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 state." @@ -541,14 +546,16 @@ 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 (eq (lookup-key evil-insert-state-map (kbd "C-w")) 'evil-window-map)) - (define-key evil-insert-state-map (kbd "C-w") 'evil-delete-backward-word) - (define-key evil-replace-state-map (kbd "C-w") 'evil-delete-backward-word)))))) + (define-key evil-insert-state-map (kbd "C-w") + #'evil-delete-backward-word) + (define-key evil-replace-state-map (kbd "C-w") + #'evil-delete-backward-word)))))) (defcustom evil-want-C-h-delete nil "Whether `C-h' deletes a char in Insert state." @@ -561,13 +568,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." @@ -951,7 +960,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) @@ -971,7 +980,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 @@ -1070,8 +1079,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 @@ -1080,8 +1089,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. @@ -1998,7 +2007,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 @@ -2049,8 +2058,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 8a8a3f35..c286bf49 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 @@ -59,6 +59,7 @@ ;; mailing list (see below). ;; Created: 2011-03-01 ;; Version: 1.15.0 +;; Package-Requires: ((emacs "24.1") (goto-chg "1.6") (cl-lib "0.5")) ;; Keywords: emulation, vim ;; URL: https://github.com/emacs-evil/evil ;; Repository: https://github.com/emacs-evil/evil.git