From 083586bd642a9ea8872e08672c94e7eb554fe06b Mon Sep 17 00:00:00 2001 From: Axel Forsman Date: Tue, 18 Jul 2023 10:48:18 +0200 Subject: Simplify evil-ex-parse --- evil-commands.el | 10 +++++----- evil-ex.el | 18 ++++++++---------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/evil-commands.el b/evil-commands.el index f8b9cd1..8a8599a 100644 --- a/evil-commands.el +++ b/evil-commands.el @@ -2718,7 +2718,7 @@ lines. This is the default behaviour for Visual-state insertion." (current-column) vcount)) evil-insert-skip-empty-lines skip-empty-lines) - (evil-insert-state))) + (evil-insert-state 1))) (defun evil-append (count &optional vcount skip-empty-lines) "Switch to Insert state just after point. @@ -2808,7 +2808,7 @@ The insertion will be repeated COUNT times." (unwind-protect (when evil-auto-indent (indent-according-to-mode)) - (evil-insert-state))) + (evil-insert-state 1))) (evil-define-command evil-open-below (count) "Insert a new line below point and switch to Insert state. @@ -2825,7 +2825,7 @@ The insertion will be repeated COUNT times." (unwind-protect (when evil-auto-indent (indent-according-to-mode)) - (evil-insert-state))) + (evil-insert-state 1))) (defun evil--insert-line (count vcount non-blank-p) "Switch to insert state at the beginning of the current line. @@ -2854,7 +2854,7 @@ in the next VCOUNT - 1 lines below the current one." (list (line-number-at-pos) (if non-blank-p #'evil-first-non-blank #'evil-beginning-of-line) vcount))) - (evil-insert-state)) + (evil-insert-state 1)) (defun evil-insert-line (count &optional vcount) "Switch to insert state at beginning of current line. @@ -2892,7 +2892,7 @@ next VCOUNT - 1 lines below the current one." (list (line-number-at-pos) #'end-of-line vcount))) - (evil-insert-state)) + (evil-insert-state 1)) (evil-define-command evil-insert-digraph (count) "Insert COUNT digraphs." diff --git a/evil-ex.el b/evil-ex.el index fa3aada..1b2d716 100644 --- a/evil-ex.el +++ b/evil-ex.el @@ -379,19 +379,17 @@ the initial input is the visual region '<,'> or `<,`>. The variable If STRING is nil, parse the text after point instead. If SYNTAX is non-nil, return a syntax tree instead. ENTRYPOINT is the start symbol, which defaults to `expression'." - (let ((parse - (lambda () - (let ((result (funcall (evil-parser evil-ex-grammar expression range) - (or entrypoint 'expression) syntax))) - (and result - ;; Disallow incomplete matches (ignore trailing WS) - (not (search-forward "[^ \t\n\r]" nil t)) - (car result)))))) - (if (not string) (funcall parse) + (if string (with-temp-buffer (insert string) (goto-char (point-min)) - (funcall parse))))) + (evil-ex-parse nil syntax entrypoint)) + (let ((result (funcall (evil-parser evil-ex-grammar expression range) + (or entrypoint 'expression) syntax))) + (and result + ;; Disallow incomplete matches (ignore trailing WS) + (not (search-forward "[^ \t\n\r]" nil t)) + (car result))))) (defun evil-ex-delete-backward-char () "Close the minibuffer if it is empty. -- cgit v1.0