Skip to content

Commit

Permalink
Fix eval:ing lexical variable plus cleanups
Browse files Browse the repository at this point in the history
Suggested cleanups:

* Remove commented dead code, e.g. keymap testing was moved to
  evil-test-state-keymaps.
* Implicitly use current buffer with buffer-file-name.
* vi should probably be capitalized as vi.
  • Loading branch information
axelf4 committed Jan 11, 2023
1 parent a659bf3 commit 53cc262
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 22 deletions.
2 changes: 1 addition & 1 deletion evil-core.el
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ To enable Evil globally, do (evil-mode)."
;; the `evil--fundamental-mode' alias, sidestepping the restriction.
(if evil-mode
(progn
(and (eval-when-compile (version< emacs-version "26.1"))
(and (eval-when-compile (< emacs-major-version 26))
(eq (default-value 'major-mode) #'fundamental-mode)
(setq-default major-mode #'evil--fundamental-mode))
(ad-enable-regexp "^evil")
Expand Down
3 changes: 1 addition & 2 deletions evil-ex.el
Original file line number Diff line number Diff line change
Expand Up @@ -1137,8 +1137,7 @@ The following symbols have reserved meanings within a grammar:
;; sequence
(t
(setq func (or func 'list))
(let (;; (last (car-safe (last rules)))
current results rule)
(let (current results rule)
(catch 'done
(while rules
(setq rule (pop rules)
Expand Down
5 changes: 2 additions & 3 deletions evil-macros.el
Original file line number Diff line number Diff line change
Expand Up @@ -594,10 +594,9 @@ RETURN-TYPE is non-nil."
;; Make linewise operator shortcuts. E.g., "d" yields the
;; shortcut "dd", and "g?" yields shortcuts "g??" and "g?g?".
(let ((keys (nth 2 (evil-extract-count (this-command-keys)))))
(setq keys (listify-key-sequence keys))
(dotimes (var (length keys))
(cl-loop for keys on (listify-key-sequence keys) do
(define-key evil-operator-shortcut-map
(vconcat (nthcdr var keys)) #'evil-line-or-visual-line)))
(vconcat keys) #'evil-line-or-visual-line)))
;; read motion from keyboard
(setq command (evil-read-motion motion)
motion (nth 0 command)
Expand Down
9 changes: 4 additions & 5 deletions evil-test-helpers.el
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,16 @@ raised. Remaining forms are evaluated as-is.
`(execute-kbd-macro
(apply #'vconcat
(mapcar #'listify-key-sequence
(mapcar #'eval ',form)))))
(list ,@form)))))
((memq (car-safe form) '(kbd vconcat))
`(execute-kbd-macro ,form))
(t
form))))
(t form))))
(if error-symbol
`(should-error ,result :type ',error-symbol)
result))))
body)))
(and (buffer-name buffer)
(kill-buffer buffer))))))
(when (buffer-live-p buffer)
(kill-buffer buffer))))))

(defmacro evil-test-selection (string &optional end-string
before-predicate after-predicate)
Expand Down
18 changes: 8 additions & 10 deletions evil-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,7 @@ with `M-x evil-tests-run'"))
"Change state to STATE and check keymaps"
(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)))
Expand Down Expand Up @@ -9472,26 +9470,26 @@ parameter set."
(evil-with-temp-file file-name ""
(evil-test-buffer
(vconcat "i" file-name [escape])
(should (not (equal file-name (buffer-file-name (current-buffer)))))
(should (not (equal file-name (buffer-file-name))))
("gf")
(should (equal file-name (buffer-file-name (current-buffer)))))))
(should (equal file-name (buffer-file-name))))))
(ert-info ("Find file at point (visual state)")
(evil-with-temp-file file-name ""
(evil-test-buffer
(vconcat "iuser@localhost:" file-name "$" [escape])
(should (not (equal file-name (buffer-file-name (current-buffer)))))
(should (not (equal file-name (buffer-file-name))))
("0f:lvt$gf")
(should (equal file-name (buffer-file-name (current-buffer)))))))
(should (equal file-name (buffer-file-name))))))
(ert-info ("Find file at point with line number")
(let* ((line-number 3)
(file-content (make-string (* 2 line-number) ?\n)))
(evil-with-temp-file file-name (insert file-content)
(evil-test-buffer
(vconcat "i" file-name (format ":%d" line-number) [escape])
(should (and (not (equal file-name (buffer-file-name (current-buffer))))
(should (and (not (equal file-name (buffer-file-name)))
(not (equal line-number (line-number-at-pos)))))
("gF")
(should (and (equal file-name (buffer-file-name (current-buffer)))
(should (and (equal file-name (buffer-file-name))
(equal line-number (line-number-at-pos))))))))
(ert-info ("Find file at point with line and column numbers")
(let* ((line-number 3)
Expand All @@ -9503,11 +9501,11 @@ parameter set."
(evil-with-temp-file file-name (insert file-content)
(evil-test-buffer
(vconcat "i" file-name (format ":%d:%d" line-number column-number) [escape])
(should (and (not (equal file-name (buffer-file-name (current-buffer))))
(should (and (not (equal file-name (buffer-file-name)))
(not (equal line-number (line-number-at-pos)))
(not (equal column-number (current-column)))))
("gF")
(should (and (equal file-name (buffer-file-name (current-buffer)))
(should (and (equal file-name (buffer-file-name))
(equal line-number (line-number-at-pos))
(equal column-number (1+ (current-column))))))))))

Expand Down
2 changes: 1 addition & 1 deletion evil.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; evil.el --- Extensible Vi layer for Emacs -*- lexical-binding: t; -*-
;;; 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
Expand Down

0 comments on commit 53cc262

Please sign in to comment.