From 284232a02bc53efb14ca1463153cbccbf076c605 Mon Sep 17 00:00:00 2001 From: Axel Forsman Date: Thu, 24 Aug 2023 10:56:27 +0200 Subject: [PATCH 1/4] Do not silence unused evil-define-command argument --- evil-commands.el | 78 ++++++++++++++++++++++----------------------- evil-common.el | 1 - evil-integration.el | 10 +++--- evil-macros.el | 27 ++++++++-------- evil-tests.el | 4 +-- evil-types.el | 2 +- 6 files changed, 60 insertions(+), 62 deletions(-) diff --git a/evil-commands.el b/evil-commands.el index 7dfc1e0a..3d625a79 100644 --- a/evil-commands.el +++ b/evil-commands.el @@ -654,7 +654,7 @@ to the beginning of buffer if the end is reached." (evil--next-mark nil)) (evil-first-non-blank)) -(evil-define-command evil-set-col-0-mark (beg end mark) +(evil-define-command evil-set-col-0-mark (_beg end mark) "Set MARK at column 0 of line of END. Default is cursor line." (interactive "") @@ -813,7 +813,7 @@ To go the other way, press \ \\\\[evil-jump-backward]." (evil--jump-forward count)) -(evil-define-motion evil-jump-backward-swap (count) +(evil-define-motion evil-jump-backward-swap (_count) "Go to the previous position in jump list. The current position is placed in the jump list." (let ((pnt (point))) @@ -1236,124 +1236,124 @@ the left edge." ;; in the buffer, and thus exact movement to object boundaries is ;; required.) -(evil-define-text-object evil-a-word (count &optional beg end type) +(evil-define-text-object evil-a-word (count &optional beg end _type) "Select a word." (evil-select-a-restricted-object 'evil-word beg end type count)) -(evil-define-text-object evil-inner-word (count &optional beg end type) +(evil-define-text-object evil-inner-word (count &optional beg end _type) "Select inner word." (evil-select-inner-restricted-object 'evil-word beg end type count)) -(evil-define-text-object evil-a-WORD (count &optional beg end type) +(evil-define-text-object evil-a-WORD (count &optional beg end _type) "Select a WORD." (evil-select-a-restricted-object 'evil-WORD beg end type count)) -(evil-define-text-object evil-inner-WORD (count &optional beg end type) +(evil-define-text-object evil-inner-WORD (count &optional beg end _type) "Select inner WORD." (evil-select-inner-restricted-object 'evil-WORD beg end type count)) -(evil-define-text-object evil-a-symbol (count &optional beg end type) +(evil-define-text-object evil-a-symbol (count &optional beg end _type) "Select a symbol." (evil-select-an-object 'evil-symbol beg end type count)) -(evil-define-text-object evil-inner-symbol (count &optional beg end type) +(evil-define-text-object evil-inner-symbol (count &optional beg end _type) "Select inner symbol." (evil-select-inner-object 'evil-symbol beg end type count)) -(evil-define-text-object evil-a-sentence (count &optional beg end type) +(evil-define-text-object evil-a-sentence (count &optional beg end _type) "Select a sentence." (evil-select-an-object 'evil-sentence beg end type count)) -(evil-define-text-object evil-inner-sentence (count &optional beg end type) +(evil-define-text-object evil-inner-sentence (count &optional beg end _type) "Select inner sentence." (evil-select-inner-object 'evil-sentence beg end type count)) -(evil-define-text-object evil-a-paragraph (count &optional beg end type) +(evil-define-text-object evil-a-paragraph (count &optional beg end _type) "Select a paragraph." :type line (evil-select-an-object 'evil-paragraph beg end type count t)) -(evil-define-text-object evil-inner-paragraph (count &optional beg end type) +(evil-define-text-object evil-inner-paragraph (count &optional beg end _type) "Select inner paragraph." :type line (evil-select-inner-object 'evil-paragraph beg end type count t)) -(evil-define-text-object evil-a-paren (count &optional beg end type) +(evil-define-text-object evil-a-paren (count &optional beg end _type) "Select a parenthesis." :extend-selection nil (evil-select-paren ?\( ?\) beg end type count t)) -(evil-define-text-object evil-inner-paren (count &optional beg end type) +(evil-define-text-object evil-inner-paren (count &optional beg end _type) "Select inner parenthesis." :extend-selection nil (evil-select-paren ?\( ?\) beg end type count)) -(evil-define-text-object evil-a-bracket (count &optional beg end type) +(evil-define-text-object evil-a-bracket (count &optional beg end _type) "Select a square bracket." :extend-selection nil (evil-select-paren ?\[ ?\] beg end type count t)) -(evil-define-text-object evil-inner-bracket (count &optional beg end type) +(evil-define-text-object evil-inner-bracket (count &optional beg end _type) "Select inner square bracket." :extend-selection nil (evil-select-paren ?\[ ?\] beg end type count)) -(evil-define-text-object evil-a-curly (count &optional beg end type) +(evil-define-text-object evil-a-curly (count &optional beg end _type) "Select a curly bracket (\"brace\")." :extend-selection nil (evil-select-paren ?{ ?} beg end type count t)) -(evil-define-text-object evil-inner-curly (count &optional beg end type) +(evil-define-text-object evil-inner-curly (count &optional beg end _type) "Select inner curly bracket (\"brace\")." :extend-selection nil (evil-select-paren ?{ ?} beg end type count)) -(evil-define-text-object evil-an-angle (count &optional beg end type) +(evil-define-text-object evil-an-angle (count &optional beg end _type) "Select an angle bracket." :extend-selection nil (evil-select-paren ?< ?> beg end type count t)) -(evil-define-text-object evil-inner-angle (count &optional beg end type) +(evil-define-text-object evil-inner-angle (count &optional beg end _type) "Select inner angle bracket." :extend-selection nil (evil-select-paren ?< ?> beg end type count)) -(evil-define-text-object evil-a-single-quote (count &optional beg end type) +(evil-define-text-object evil-a-single-quote (count &optional beg end _type) "Select a single-quoted expression." :extend-selection t (evil-select-quote ?' beg end type count t)) -(evil-define-text-object evil-inner-single-quote (count &optional beg end type) +(evil-define-text-object evil-inner-single-quote (count &optional beg end _type) "Select inner single-quoted expression." :extend-selection nil (evil-select-quote ?' beg end type count)) -(evil-define-text-object evil-a-double-quote (count &optional beg end type) +(evil-define-text-object evil-a-double-quote (count &optional beg end _type) "Select a double-quoted expression." :extend-selection t (evil-select-quote ?\" beg end type count t)) -(evil-define-text-object evil-inner-double-quote (count &optional beg end type) +(evil-define-text-object evil-inner-double-quote (count &optional beg end _type) "Select inner double-quoted expression." :extend-selection nil (evil-select-quote ?\" beg end type count)) -(evil-define-text-object evil-a-back-quote (count &optional beg end type) +(evil-define-text-object evil-a-back-quote (count &optional beg end _type) "Select a back-quoted expression." :extend-selection t (evil-select-quote ?\` beg end type count t)) -(evil-define-text-object evil-inner-back-quote (count &optional beg end type) +(evil-define-text-object evil-inner-back-quote (count &optional beg end _type) "Select inner back-quoted expression." :extend-selection nil (evil-select-quote ?\` beg end type count)) -(evil-define-text-object evil-a-tag (count &optional beg end type) +(evil-define-text-object evil-a-tag (count &optional beg end _type) "Select a tag block." :extend-selection nil (evil-select-xml-tag beg end type count t)) -(evil-define-text-object evil-inner-tag (count &optional beg end type) +(evil-define-text-object evil-inner-tag (count &optional beg end _type) "Select inner tag block." :extend-selection nil (evil-select-xml-tag beg end type count)) @@ -1400,12 +1400,12 @@ the left edge." ;; e.g. operator pending... (t (list evil-ex-search-match-beg evil-ex-search-match-end))))) -(evil-define-text-object evil-next-match (count &optional beg end type) +(evil-define-text-object evil-next-match (count &optional _beg _end _type) "Select next match." :extend-selection t (evil-match 'forward count)) -(evil-define-text-object evil-previous-match (count &optional beg end type) +(evil-define-text-object evil-previous-match (count &optional _beg _end _type) "Select previous match." :extend-selection t (evil-match 'backward count)) @@ -1536,7 +1536,7 @@ Save in REGISTER or in the kill-ring with YANK-HANDLER." (interactive "") (evil-delete beg end type register)) -(evil-define-command evil-delete-backward-char-and-join (count) +(evil-define-command evil-delete-backward-char-and-join (_count) "Delete previous character and join lines. If point is at the beginning of a line then the current line will be joined with the previous line if and only if @@ -1604,7 +1604,7 @@ given." (interactive "") (evil-ex-delete-or-yank nil beg end type register count yank-handler)) -(evil-define-command evil-ex-put (beg end ex-arg &optional force) +(evil-define-command evil-ex-put (_beg end ex-arg &optional force) (interactive "") (let* ((arg-chars (remove ?\s (string-to-list ex-arg))) (reg (or (car arg-chars) ?\")) @@ -1922,7 +1922,7 @@ Surround line denoted by BORDERLINE with dashes if non-nil." (interactive "") (evil--ex-print beg end count t)) -(evil-define-command evil-ex-z (beg end &optional zmarks bang) +(evil-define-command evil-ex-z (_beg end &optional zmarks _bang) "Display several lines of text surrounding the line specified by range. BEG and END represent the range, ZMARKS represents the args in string form. With a count supplied in the args, display that number of lines. Without a @@ -2122,7 +2122,7 @@ the current line." (evil-delete-indentation)) (evil-shift-left (line-beginning-position) (line-beginning-position 2) count t))) -(evil-define-operator evil-align-left (beg end type &optional width) +(evil-define-operator evil-align-left (beg end _type &optional width) "Left-align lines in the region at WIDTH columns. The default for width is the value of `fill-column'." :motion evil-line @@ -2132,7 +2132,7 @@ The default for width is the value of `fill-column'." (string-to-number width) 0))) -(evil-define-operator evil-align-right (beg end type &optional width) +(evil-define-operator evil-align-right (beg end _type &optional width) "Right-align lines in the region at WIDTH columns. The default for width is the value of `fill-column'." :motion evil-line @@ -2142,7 +2142,7 @@ The default for width is the value of `fill-column'." (string-to-number width) fill-column))) -(evil-define-operator evil-align-center (beg end type &optional width) +(evil-define-operator evil-align-center (beg end _type &optional width) "Center lines in the region between WIDTH columns. The default for width is the value of `fill-column'." :motion evil-line @@ -3246,7 +3246,7 @@ See also `evil-open-fold'." ;;; Ex -(evil-define-operator evil-write (beg end type file-or-append &optional bang) +(evil-define-operator evil-write (beg end _type file-or-append &optional bang) "Save the current buffer, from BEG to END, to FILE-OR-APPEND. If FILE-OR-APPEND is of the form \">> FILE\", append to FILE instead of overwriting. The current buffer's filename is not @@ -3470,7 +3470,7 @@ is closed." (set-process-query-on-exit-flag process nil)) (kill-emacs))))) -(evil-define-command evil-quit-all-with-error-code (&optional force) +(evil-define-command evil-quit-all-with-error-code (&optional _force) "Exit Emacs without saving, returning an non-zero error code. The FORCE argument is only there for compatibility and is ignored. This function fails with an error if Emacs is run in server mode." @@ -3500,7 +3500,7 @@ This function fails with an error if Emacs is run in server mode." (evil-quit)) (evil-define-operator evil-shell-command - (beg end type command &optional previous) + (beg end _type command &optional previous) "Execute a shell command. If BEG, END and TYPE is specified, COMMAND is executed on the region, which is replaced with the command's output. Otherwise, the diff --git a/evil-common.el b/evil-common.el index 9504cda2..e266e1b1 100644 --- a/evil-common.el +++ b/evil-common.el @@ -321,7 +321,6 @@ last, sorting in between." `(defun ,command ,args ,@(when doc `(,doc)) ,interactive - (ignore ,@(cl-set-difference args '(&optional &rest))) ,@body)) ,(when (and command doc-form) `(put ',command 'function-documentation ,doc-form)) diff --git a/evil-integration.el b/evil-integration.el index 02f7e52a..e7f156a2 100644 --- a/evil-integration.el +++ b/evil-integration.el @@ -308,7 +308,7 @@ the mark and entering `recursive-edit'." (remove-hook 'post-command-hook #'evil-ace-jump-exit-recursive-edit) (exit-recursive-edit)))) -(evil-define-motion evil-ace-jump-char-mode (count) +(evil-define-motion evil-ace-jump-char-mode (_count) "Jump visually directly to a char using ace-jump." :type inclusive (evil-without-repeat @@ -325,7 +325,7 @@ the mark and entering `recursive-edit'." ((eq evil-this-type 'exclusive) 'inclusive) ((eq evil-this-type 'inclusive) 'exclusive))))))) -(evil-define-motion evil-ace-jump-char-to-mode (count) +(evil-define-motion evil-ace-jump-char-to-mode (_count) "Jump visually to the char in front of a char using ace-jump." :type inclusive (evil-without-repeat @@ -343,7 +343,7 @@ the mark and entering `recursive-edit'." ((eq evil-this-type 'inclusive) 'exclusive)))) (backward-char))))) -(evil-define-motion evil-ace-jump-line-mode (count) +(evil-define-motion evil-ace-jump-line-mode (_count) "Jump visually to the beginning of a line using ace-jump." :type line :repeat abort @@ -351,7 +351,7 @@ the mark and entering `recursive-edit'." (evil-enclose-ace-jump-for-motion (call-interactively 'ace-jump-line-mode)))) -(evil-define-motion evil-ace-jump-word-mode (count) +(evil-define-motion evil-ace-jump-word-mode (_count) "Jump visually to the beginning of a word using ace-jump." :type exclusive :repeat abort @@ -396,7 +396,7 @@ Based on `evil-enclose-ace-jump-for-motion'." (declare (indent defun) (debug t)) (let ((name (intern (format "evil-%s" command)))) - `(evil-define-motion ,name (count) + `(evil-define-motion ,name (_count) ,(format "Evil motion for `%s'." command) :type ,type :jump t diff --git a/evil-macros.el b/evil-macros.el index 1a60051e..86eb8677 100644 --- a/evil-macros.el +++ b/evil-macros.el @@ -137,17 +137,17 @@ Optional keyword arguments are: interactive '(""))) ;; collect docstring (when (and (> (length body) 1) - (or (eq (car-safe (car-safe body)) 'format) - (stringp (car-safe body)))) + (or (eq (car-safe (car body)) #'format) + (stringp (car body)))) (setq doc (pop body))) ;; collect keywords (setq keys (plist-put keys :repeat 'motion)) - (while (keywordp (car-safe body)) + (while (keywordp (car body)) (setq key (pop body) arg (pop body) keys (plist-put keys key arg))) ;; collect `interactive' specification - (when (eq (car-safe (car-safe body)) 'interactive) + (when (eq (car-safe (car body)) 'interactive) (setq interactive (cdr (pop body)))) ;; macro expansion `(progn @@ -368,27 +368,26 @@ Optional keyword arguments: (let* ((args (delq '&optional args)) (count (or (pop args) 'count)) (args (when args `(&optional ,@args))) - (interactive '((interactive ""))) - arg doc key keys) + (interactive '(interactive "")) + doc keys) ;; collect docstring - (when (stringp (car-safe body)) + (when (stringp (car body)) (setq doc (pop body))) ;; collect keywords (setq keys (plist-put keys :extend-selection t)) - (while (keywordp (car-safe body)) - (setq key (pop body) - arg (pop body) - keys (plist-put keys key arg))) + (while (keywordp (car body)) + (setq keys (plist-put keys (pop body) (pop body)))) ;; interactive - (when (eq (car-safe (car-safe body)) 'interactive) - (setq interactive (list (pop body)))) + (when (eq (car-safe (car body)) 'interactive) + (setq interactive (pop body))) ;; macro expansion `(evil-define-motion ,object (,count ,@args) ,@(when doc `(,doc)) ,@keys - ,@interactive + ,interactive (setq ,count (or ,count 1)) (when (/= ,count 0) + ;; FIXME: These let-bindings shadow variables in args (let ((type (evil-type ',object evil-visual-char)) (extend (and (evil-visual-state-p) (evil-get-command-property diff --git a/evil-tests.el b/evil-tests.el index b1b3f797..1bc68781 100644 --- a/evil-tests.el +++ b/evil-tests.el @@ -9573,9 +9573,9 @@ parameter set." (let ((inner-name (make-symbol (concat "evil-inner-" name))) (outer-name (make-symbol (concat "evil-a-" name)))) `(progn - (evil-define-text-object ,inner-name (count &optional beg end type) + (evil-define-text-object ,inner-name (count &optional beg end _type) (evil-select-paren ,start-regex ,end-regex beg end type count nil)) - (evil-define-text-object ,outer-name (count &optional beg end type) + (evil-define-text-object ,outer-name (count &optional beg end _type) (evil-select-paren ,start-regex ,end-regex beg end type count t)) (define-key evil-inner-text-objects-map ,key #',inner-name) (define-key evil-outer-text-objects-map ,key #',outer-name)))) diff --git a/evil-types.el b/evil-types.el index 0e347d00..33f73c41 100644 --- a/evil-types.el +++ b/evil-types.el @@ -311,7 +311,7 @@ directly." (evil-operator-range t)) (evil-define-interactive-code "" - "Typed motion range of visual range(BEG END TYPE). + "Typed motion range of visual range (BEG END TYPE). If visual state is inactive then those values are nil." (if (evil-visual-state-p) (let ((range (evil-visual-range))) From b6daa765878d66154d7580c3e9be486f12e62bc8 Mon Sep 17 00:00:00 2001 From: Axel Forsman Date: Sun, 13 Aug 2023 13:52:45 +0200 Subject: [PATCH 2/4] Add evil-command-line-map There was a lot of duplication between evil-ex-completion-map and evil-ex-search-keymap, which meant that any rebinds had to be done twice. This commit fixes that by introducing evil-command-line-map as a common ancestor of the two keymaps. Also renames evil-ex-map to evil-ex-shortcut-map to avoid confusion, as its purpose is more niche than evil-ex-completion-map which functions the same as any other keymap passed to read-from-minibuffer. --- evil-ex.el | 7 ++--- evil-maps.el | 72 ++++++++++++++++++++------------------------- evil-vars.el | 83 ++++++++++++++++++++++++++++------------------------ 3 files changed, 79 insertions(+), 83 deletions(-) diff --git a/evil-ex.el b/evil-ex.el index f91c1a14..246aa0d7 100644 --- a/evil-ex.el +++ b/evil-ex.el @@ -32,7 +32,7 @@ ;; `evil-ex-define-cmd', which creates a binding from a string ;; to an interactive function. It is also possible to define key ;; sequences which execute a command immediately when entered: -;; such shortcuts go in `evil-ex-map'. +;; such shortcuts go in `evil-ex-shortcut-map'. ;; To provide buffer and filename completion, as well as interactive ;; feedback, Ex defines the concept of an argument handler, specified @@ -415,8 +415,7 @@ actions during Ex state." (defun evil-ex-teardown () "Deinitialize Ex minibuffer. Clean up everything set up by `evil-ex-setup'." - (let ((runner (evil-ex-argument-handler-runner - evil--ex-argument-handler))) + (let ((runner (evil-ex-argument-handler-runner evil--ex-argument-handler))) (when runner (funcall runner 'stop)))) (put 'evil-ex-teardown 'permanent-local-hook t) @@ -431,7 +430,7 @@ hook. If BEG is non-nil (which is the case when called from `after-change-functions'), then an error description is shown in case of incomplete or unknown commands." (when (and beg (eq this-command #'self-insert-command)) - (let ((cmd (lookup-key evil-ex-map (minibuffer-contents-no-properties)))) + (let ((cmd (lookup-key evil-ex-shortcut-map (minibuffer-contents-no-properties)))) (when (commandp cmd) (setq evil--ex-expression `(call-interactively #',cmd)) (exit-minibuffer)))) diff --git a/evil-maps.el b/evil-maps.el index fbf5af16..b24cee61 100644 --- a/evil-maps.el +++ b/evil-maps.el @@ -591,51 +591,43 @@ included in `evil-insert-state-bindings' by default." (evil-ex-define-cmd "tabn[ext]" 'tab-bar-switch-to-next-tab) (evil-ex-define-cmd "tabp[revious]" 'tab-bar-switch-to-prev-tab)) +;; Command-line editing +(define-key evil-command-line-map "\d" #'evil-ex-delete-backward-char) +(define-key evil-command-line-map "\t" #'completion-at-point) +(define-key evil-command-line-map [tab] #'completion-at-point) +(define-key evil-command-line-map "\C-a" #'completion-at-point) +(define-key evil-command-line-map "\C-b" #'move-beginning-of-line) +(define-key evil-command-line-map "\C-c" #'abort-recursive-edit) +(define-key evil-command-line-map "\C-d" #'completion-at-point) +(define-key evil-command-line-map "\C-g" #'abort-minibuffers) +(define-key evil-command-line-map "\C-k" 'evil-insert-digraph) +(define-key evil-command-line-map "\C-l" #'completion-at-point) +(define-key evil-command-line-map "\C-n" #'next-history-element) +(define-key evil-command-line-map "\C-p" #'previous-history-element) +(define-key evil-command-line-map "\C-r" 'evil-paste-from-register) +(define-key evil-command-line-map "\C-u" 'evil-delete-whole-line) +(define-key evil-command-line-map "\C-v" #'quoted-insert) +(when evil-want-C-w-delete + (define-key evil-command-line-map "\C-w" #'backward-kill-word)) +(define-key evil-command-line-map [escape] #'abort-recursive-edit) +(define-key evil-command-line-map [S-left] #'backward-word) +(define-key evil-command-line-map [S-right] #'forward-word) +(define-key evil-command-line-map [up] #'previous-complete-history-element) +(define-key evil-command-line-map [down] #'next-complete-history-element) +(define-key evil-command-line-map [prior] #'previous-history-element) +(define-key evil-command-line-map [next] #'next-history-element) +(define-key evil-command-line-map [return] #'exit-minibuffer) +(define-key evil-command-line-map (kbd "RET") #'exit-minibuffer) + ;; search command line -(define-key evil-ex-search-keymap "\d" #'evil-ex-delete-backward-char) -(define-key evil-ex-search-keymap "\C-b" 'move-beginning-of-line) -(define-key evil-ex-search-keymap "\C-c" 'abort-recursive-edit) -(define-key evil-ex-search-keymap "\C-g" 'abort-recursive-edit) -(define-key evil-ex-search-keymap "\C-k" 'evil-insert-digraph) +(set-keymap-parent evil-ex-search-keymap evil-command-line-map) (define-key evil-ex-search-keymap "\C-f" 'evil-ex-search-command-window) -(define-key evil-ex-search-keymap "\C-r" 'evil-paste-from-register) -(define-key evil-ex-search-keymap "\C-n" 'next-history-element) -(define-key evil-ex-search-keymap "\C-p" 'previous-history-element) -(define-key evil-ex-search-keymap "\C-u" 'evil-delete-whole-line) -(define-key evil-ex-search-keymap "\C-v" #'quoted-insert) -(if evil-want-C-w-delete - (define-key evil-ex-search-keymap "\C-w" 'backward-kill-word) +(unless evil-want-C-w-delete (define-key evil-ex-search-keymap "\C-w" 'evil-search-yank-word)) -;; ex command line -(define-key evil-ex-completion-map "\d" #'evil-ex-delete-backward-char) -(define-key evil-ex-completion-map "\t" 'completion-at-point) -(define-key evil-ex-completion-map [tab] 'completion-at-point) -(define-key evil-ex-completion-map "\C-a" 'completion-at-point) -(define-key evil-ex-completion-map "\C-b" 'move-beginning-of-line) -(define-key evil-ex-completion-map "\C-c" 'abort-recursive-edit) -(define-key evil-ex-completion-map "\C-d" 'completion-at-point) +;; Ex command line +(set-keymap-parent evil-ex-completion-map evil-command-line-map) (define-key evil-ex-completion-map "\C-f" 'evil-ex-command-window) -(define-key evil-ex-completion-map "\C-g" 'abort-recursive-edit) -(define-key evil-ex-completion-map "\C-k" 'evil-insert-digraph) -(define-key evil-ex-completion-map "\C-l" 'completion-at-point) -(define-key evil-ex-completion-map "\C-p" #'previous-complete-history-element) -(define-key evil-ex-completion-map "\C-r" 'evil-paste-from-register) -(define-key evil-ex-completion-map "\C-n" #'next-complete-history-element) -(define-key evil-ex-completion-map "\C-u" 'evil-delete-whole-line) -(define-key evil-ex-completion-map "\C-v" #'quoted-insert) -(if evil-want-C-w-delete - (define-key evil-ex-completion-map "\C-w" 'backward-kill-word) - (define-key evil-ex-completion-map "\C-w" nil)) -(define-key evil-ex-completion-map [escape] 'abort-recursive-edit) -(define-key evil-ex-completion-map [S-left] 'backward-word) -(define-key evil-ex-completion-map [S-right] 'forward-word) -(define-key evil-ex-completion-map [up] 'previous-complete-history-element) -(define-key evil-ex-completion-map [down] 'next-complete-history-element) -(define-key evil-ex-completion-map [prior] 'previous-history-element) -(define-key evil-ex-completion-map [next] 'next-history-element) -(define-key evil-ex-completion-map [return] 'exit-minibuffer) -(define-key evil-ex-completion-map (kbd "RET") 'exit-minibuffer) ;; eval prompt (the `=' register) (define-key evil-eval-map "\C-b" 'move-beginning-of-line) diff --git a/evil-vars.el b/evil-vars.el index f9de9074..bd2b29eb 100644 --- a/evil-vars.el +++ b/evil-vars.el @@ -539,41 +539,39 @@ ubiquity of prefix arguments." "Whether `C-w' deletes a word in Insert/Ex/Search state." :type 'boolean :group 'evil - :set #'(lambda (sym value) - (set-default sym value) - (when (and (boundp 'evil-insert-state-map) - (boundp 'evil-replace-state-map)) - (cond - ((and (not value) - (eq (lookup-key evil-insert-state-map (kbd "C-w")) - '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)))) - (when (boundp 'evil-ex-search-keymap) - (cond - ((and (not value) - (eq (lookup-key evil-ex-search-keymap (kbd "C-w")) - #'backward-kill-word)) - (define-key evil-ex-search-keymap (kbd "C-w") 'evil-search-yank-word)) - ((and value - (eq (lookup-key evil-ex-search-keymap (kbd "C-w")) - 'evil-search-yank-word)) - (define-key evil-ex-search-keymap (kbd "C-w") #'backward-kill-word)))) - (when (boundp 'evil-ex-completion-map) - (cond - ((and (not value) - (eq (lookup-key evil-ex-completion-map (kbd "C-w")) - #'backward-kill-word)) - (define-key evil-ex-completion-map (kbd "C-w") nil)) - ((and value - (eq (lookup-key evil-ex-completion-map (kbd "C-w")) - nil)) - (define-key evil-ex-completion-map (kbd "C-w") #'backward-kill-word)))))) + :set (lambda (sym value) + (set-default sym value) + (when (and (boundp 'evil-insert-state-map) + (boundp 'evil-replace-state-map)) + (cond + ((and (not value) + (eq (lookup-key evil-insert-state-map (kbd "C-w")) + '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)))) + (when (boundp 'evil-command-line-map) + (cond + ((and (not value) + (eq (lookup-key evil-command-line-map (kbd "C-w")) + #'backward-kill-word)) + (define-key evil-command-line-map (kbd "C-w") nil)) + ((and value + (null (lookup-key evil-command-line-map (kbd "C-w")))) + (define-key evil-command-line-map (kbd "C-w") #'backward-kill-word)))) + (when (boundp 'evil-ex-search-keymap) + (cond + ((and (not value) + (null (lookup-key evil-ex-search-keymap (kbd "C-w")))) + (define-key evil-ex-search-keymap (kbd "C-w") 'evil-search-yank-word)) + ((and value + (eq (lookup-key evil-ex-search-keymap (kbd "C-w")) + 'evil-search-yank-word)) + (define-key evil-ex-search-keymap (kbd "C-w") nil)))))) (defcustom evil-want-C-h-delete nil "Whether `C-h' deletes a char in Insert state." @@ -1891,12 +1889,21 @@ would ignore `:close-all' actions and invoke the provided functions on ;;; Ex -(defvar evil-ex-map (make-sparse-keymap) +(define-obsolete-variable-alias 'evil-ex-map 'evil-ex-shortcut-map "1.15.0") +(defvar evil-ex-shortcut-map (make-sparse-keymap) "Keymap for Ex. Key sequences bound in this map are immediately executed.") +;; Intentionally does not inherit from `minibuffer-local-map', as users +;; are encouraged to instead set this as the parent of that keymap. +(defvar evil-command-line-map (make-sparse-keymap) + "Keymap used for the various Evil command-lines. +Modifying this keymap corresponds to using the \":cmap\" Vim command. +See `evil-ex-completion-map' and `evil-ex-search-keymap' which inherit +from this keymap.") + (defvar evil-ex-completion-map (make-sparse-keymap) - "Completion keymap for Ex.") + "Keymap for Ex.") (defvar evil-ex-initial-input nil "Additional initial content of the Ex command line. @@ -1997,8 +2004,6 @@ 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) -(set-keymap-parent evil-ex-search-keymap minibuffer-local-map) (defcustom evil-want-empty-ex-last-command t "Whether to default to evil-ex-previous-command at empty ex prompt." From 1102686bd309cdc39647c395e67117803fd73eb4 Mon Sep 17 00:00:00 2001 From: Axel Forsman Date: Fri, 25 Aug 2023 13:41:39 +0200 Subject: [PATCH 3/4] Reselect minibuffer when quitting command-line win Pressing C-f while editing an Ex command to open the command-line window and later quitting that window used to not reselect the Ex command line, but instead just continue the recursive edit in some previous window. This was specially confusing before commit 02004bce6884619e687654d333b75c90f8fc27d0, as the evil-ex-abort hack did not trigger, leaving you in a bad state with evil-ex-current-buffer set to t. This commit fixes that by setting the delete-window window parameter on the command-line window to a function that switches back to the minibuffer after deleting the window, which closes #1379. This commit also replaces the split-window call with a display-buffer invocation, to always spawn the window at the bottom of the frame, but also allow the user to override this behavior. --- evil-command-window.el | 210 +++++++++++++++++++++-------------------- evil-tests.el | 74 +++------------ evil-vars.el | 10 +- 3 files changed, 124 insertions(+), 170 deletions(-) diff --git a/evil-command-window.el b/evil-command-window.el index c364e418..dd148822 100644 --- a/evil-command-window.el +++ b/evil-command-window.el @@ -1,4 +1,4 @@ -;;; evil-command-window.el --- Evil command line window implementation -*- lexical-binding: t -*- +;;; evil-command-window.el --- Evil command-line window -*- lexical-binding: t -*- ;; Author: Emanuel Evans ;; Maintainer: Vegard Øye @@ -26,162 +26,170 @@ ;;; Commentary: -;; This provides an implementation of the vim command line window for -;; editing and repeating past ex commands and searches. +;; This provides an implementation of the Vim command-line window for +;; editing and repeating past Ex commands and searches. ;;; Code: (require 'evil-vars) (require 'evil-common) -(require 'evil-search) (require 'evil-ex) +(require 'evil-search) (defvar evil-search-module) (defvar evil-command-window-current-buffer nil - "The buffer from which the command line window was called.") + "The buffer from which the command-line window was called.") + +(defvar evil-command-window-execute-fn nil + "The command to execute when exiting the command-line window.") + +(defvar evil--command-window-prompt nil + "The key for the command that opened the command-line window (:, /, or ?).") (define-derived-mode evil-command-window-mode fundamental-mode "Evil-cmd" - "Major mode for the Evil command line window." - (auto-fill-mode 0) - (add-hook 'after-change-functions #'evil-command-window-draw-prefix nil t)) - -(defun evil-command-window (history cmd-key execute-fn) - "Open a command line window for HISTORY with CMD-KEY and EXECUTE-FN. -HISTORY should be a list of commands. CMD-KEY should be the string of -the key whose history is being shown (one of \":\", \"/\" or \"?\"). -EXECUTE-FN should be a function of one argument to execute on the -result that the user selects." - (when (eq major-mode 'evil-command-window-mode) - (user-error "Cannot recursively open command line window")) - (dolist (win (window-list)) - (when (equal (buffer-name (window-buffer win)) "*Command Line*") - (kill-buffer (window-buffer win)) - (delete-window win))) - (split-window nil - (unless (zerop evil-command-window-height) - evil-command-window-height) - 'above) - (setq evil-command-window-current-buffer (current-buffer)) - (ignore-errors (kill-buffer "*Command Line*")) - (switch-to-buffer "*Command Line*") - (setq-local evil-command-window-execute-fn execute-fn) - (setq-local evil-command-window-cmd-key cmd-key) - (evil-command-window-mode) - (evil-command-window-insert-commands history)) + "Major mode for the Evil command-line window." + (add-hook 'after-change-functions #'evil--command-window-draw-prefix nil t) + (auto-fill-mode 0)) + +(defun evil-command-window (history prompt execute-fn) + "Open a command-line window for HISTORY with PROMPT and EXECUTE-FN. +HISTORY should be a list of commands. PROMPT should be the +command-line prompt (one of \":\", \"/\" or \"?\"). EXECUTE-FN should +be a unary function to execute on the result that the user selects." + (when (derived-mode-p 'evil-command-window-mode) + (user-error "Command-line window is already open")) + (let ((previous-buffer (current-buffer)) + (buffer (get-buffer-create "*Command Line*"))) + (with-current-buffer buffer + (erase-buffer) + (evil-command-window-mode) + (setq-local evil-command-window-current-buffer previous-buffer) + (setq-local evil-command-window-execute-fn execute-fn) + (setq-local evil--command-window-prompt prompt) + (evil--command-window-insert-commands history)) + + (let* ((action + `((display-buffer-reuse-window display-buffer-at-bottom) + ,@(unless (zerop evil-command-window-height) + `((window-height body-lines . ,evil-command-window-height) + (preserve-size nil . t))) + (dedicated . t))) + (window (display-buffer buffer action)) + (delete-window-fun + (lambda (window) + (set-window-parameter window 'delete-window nil) + (delete-window window) + (switch-to-minibuffer)))) + (when (minibufferp) + (set-window-parameter window 'delete-window delete-window-fun)) + (select-window window))) + (goto-char (point-max)) + (unless (bobp) (backward-char) (evil-adjust-cursor))) + +(defun evil--command-window-draw-prefix (beg end _old-len) + "Display `evil--command-window-prompt' as a prefix of the changed lines." + (let ((prefix (propertize evil--command-window-prompt + 'font-lock-face 'minibuffer-prompt))) + (put-text-property beg end 'line-prefix prefix))) + +(defun evil--command-window-insert-commands (history) + "Insert the commands in HISTORY." + (let ((inhibit-modification-hooks t)) + (dolist (cmd (reverse history)) (insert cmd "\n")) + (evil--command-window-draw-prefix (point-min) (point-max) nil))) + +(defun evil-command-window-execute () + "Execute the command on the current line in the appropriate buffer. +The local variable `evil-command-window-execute-fn' determines which +function to execute." + (interactive) + (let ((result (buffer-substring-no-properties + (line-beginning-position) (line-end-position))) + (original-buffer evil-command-window-current-buffer) + (execute-fn evil-command-window-execute-fn)) + (let ((ignore-window-parameters t)) + (ignore-errors (kill-buffer-and-window))) + (unless (buffer-live-p original-buffer) + (user-error "Originating buffer is no longer active")) + (let ((window (get-buffer-window original-buffer))) + (when window (select-window window))) + (with-current-buffer original-buffer (funcall execute-fn result)))) (defun evil-command-window-ex (&optional current-command execute-fn) - "Open a command line window for editing and executing ex commands. -If CURRENT-COMMAND is present, it will be inserted under the -cursor as the current command to be edited. If EXECUTE-FN is given, -it will be used as the function to execute instead of + "Open a command-line window for editing and executing Ex commands. +If CURRENT-COMMAND is present, it will be inserted under the cursor as +the current command to be edited. If EXECUTE-FN is given, it will be +used as the function to execute instead of `evil-command-window-ex-execute', the default." (interactive) (evil-command-window (cons (or current-command "") evil-ex-history) ":" - (or execute-fn 'evil-command-window-ex-execute))) + (or execute-fn #'evil-command-window-ex-execute))) (defun evil-ex-command-window () - "Start command window with ex history and current minibuffer content." + "Start command window with Ex history and current minibuffer content." (interactive) - (let ((current (minibuffer-contents)) - (config (current-window-configuration))) - (evil-ex-teardown) - (select-window (minibuffer-selected-window) t) - (evil-command-window-ex current (apply-partially 'evil-ex-command-window-execute config)))) + (evil-ex-teardown) + (let ((execute-fn (apply-partially #'evil-ex-command-window-execute + (current-window-configuration)))) + (evil-command-window-ex (minibuffer-contents) execute-fn))) (defun evil-ex-search-command-window () "Start command window with search history and current minibuffer content." (interactive) - (let ((current (minibuffer-contents)) - (config (current-window-configuration))) - (select-window (minibuffer-selected-window) t) - (evil-command-window (cons current evil-ex-search-history) + (let ((execute-fn (apply-partially #'evil-ex-command-window-execute + (current-window-configuration)))) + (evil-command-window (cons (minibuffer-contents) evil-ex-search-history) (evil-search-prompt (eq evil-ex-search-direction 'forward)) - (apply-partially 'evil-ex-command-window-execute config)))) - -(defun evil-command-window-execute () - "Execute the command on the current line in the appropriate buffer. -The local variable `evil-command-window-execute-fn' determines which -function to execute." - (interactive) - (let ((result (buffer-substring (line-beginning-position) - (line-end-position))) - (execute-fn evil-command-window-execute-fn) - (command-window (get-buffer-window))) - (select-window (previous-window)) - (unless (equal evil-command-window-current-buffer (current-buffer)) - (user-error "Originating buffer is no longer active")) - (kill-buffer "*Command Line*") - (delete-window command-window) - (funcall execute-fn result) - (setq evil-command-window-current-buffer nil))) + execute-fn))) (defun evil-command-window-ex-execute (result) "Execute RESULT as an Ex command." - (unless (string-match-p "^ *$" result) + (unless (string-match-p "\\`[ \t\n\r]*\\'" result) (unless (equal result (car evil-ex-history)) (push result evil-ex-history)) (evil-ex-execute result))) (defun evil-ex-command-window-execute (config result) - (select-window (active-minibuffer-window) t) (set-window-configuration config) (delete-minibuffer-contents) (insert result) (exit-minibuffer)) +(defun evil--command-window-search (forward) + "Open a command-line window for searches." + (evil-command-window + (cons "" (cond ((eq evil-search-module 'evil-search) + evil-ex-search-history) + (forward evil-search-forward-history) + (t evil-search-backward-history))) + (evil-search-prompt forward) + (lambda (result) (evil-command-window-search-execute result forward)))) + (defun evil-command-window-search-forward () - "Open a command line window for forward searches." + "Open a command-line window for forward searches." (interactive) - (evil-command-window - (cons "" (if (eq evil-search-module 'evil-search) - evil-ex-search-history - evil-search-forward-history)) - "/" - (lambda (result) (evil-command-window-search-execute result t)))) + (evil--command-window-search t)) (defun evil-command-window-search-backward () - "Open a command line window for backward searches." + "Open a command-line window for backward searches." (interactive) - (evil-command-window - (cons "" (if (eq evil-search-module 'evil-search) - evil-ex-search-history - evil-search-backward-history)) - "?" - (lambda (result) (evil-command-window-search-execute result nil)))) + (evil--command-window-search nil)) (defun evil-command-window-search-execute (result forward) "Search for RESULT using FORWARD to determine direction." - (unless (zerop (length result)) + (unless (string= result "") (if (eq evil-search-module 'evil-search) (progn (setq evil-ex-search-pattern (evil-ex-make-search-pattern result) evil-ex-search-direction (if forward 'forward 'backward)) - (unless (equal result (car-safe evil-ex-search-history)) + (unless (equal result (car evil-ex-search-history)) (push result evil-ex-search-history)) (evil-ex-search)) (evil-push-search-history result forward) (evil-search result forward evil-regexp-search)))) -(defun evil-command-window-draw-prefix (&rest _) - "Display `evil-command-window-cmd-key' as a prefix of the current line." - (let ((prefix (propertize evil-command-window-cmd-key - 'font-lock-face 'minibuffer-prompt))) - (set-text-properties (line-beginning-position) (line-beginning-position 2) - (list 'line-prefix prefix)))) - -(defun evil-command-window-insert-commands (hist) - "Insert the commands in HIST." - (let ((inhibit-modification-hooks t)) - (mapc (lambda (cmd) (insert cmd) (newline)) (reverse hist))) - (let ((prefix (propertize evil-command-window-cmd-key - 'font-lock-face 'minibuffer-prompt))) - (set-text-properties (point-min) (point-max) (list 'line-prefix prefix))) - (goto-char (point-max)) - (and (bolp) (not (bobp)) (backward-char)) - (evil-adjust-cursor)) - (provide 'evil-command-window) ;;; evil-command-window.el ends here diff --git a/evil-tests.el b/evil-tests.el index 1bc68781..2e03df93 100644 --- a/evil-tests.el +++ b/evil-tests.el @@ -8866,74 +8866,31 @@ Source ;;; Command line window (ert-deftest evil-test-command-window-ex () - "Test command line window for ex commands" - (skip-unless (not noninteractive)) - (let (evil-ex-history) - (evil-test-buffer - "[f]oo foo foo" - (":s/foo/bar" [return]) - "[b]ar foo foo" - (":s/foo/baz" [return]) - "[b]ar baz foo" + "Test command line window for Ex commands." + (let ((evil-ex-history (list "s/foo/baz" "s/foo/bar"))) + (evil-test-buffer "[b]ar baz foo" ("q:") "s/foo/bar\ns/foo/baz\n[]\n" ("kk:s/bar/quz" [return]) "[s]/foo/quz\ns/foo/baz\n" - ("fzrx") - "s/foo/qu[x]\ns/foo/baz\n" - ([return]) + ("fzrx" [return]) "[b]ar baz qux" - (should (equal (car evil-ex-history) - "s/foo/qux"))))) - -(ert-deftest evil-test-command-window-recursive () - "Test that recursive command windows shouldn't be allowed" - (skip-unless (not noninteractive)) - (let ((evil-command-window-height 0)) - (evil-test-buffer - "[f]oo foo foo" - (":s/foo/bar" [return]) - ("q:") - (should-error (execute-kbd-macro "q:"))))) + (should (equal (car evil-ex-history) "s/foo/qux"))))) (ert-deftest evil-test-command-window-noop () - "Test that executing a blank command does nothing" - (skip-unless (not noninteractive)) - (evil-test-buffer - "[f]oo foo foo" + "Test that executing a blank command does nothing." + (evil-test-buffer "[f]oo foo foo" ("q:") "[]\n" ([return]) "[f]oo foo foo")) -(ert-deftest evil-test-command-window-multiple () - "Test that multiple command line windows can't be visible at the same time" - (skip-unless (not noninteractive)) - (let ((evil-command-window-height 0)) - (evil-test-buffer - "[f]oo foo foo" - ("q:") - (let ((num-windows (length (window-list)))) - (select-window (previous-window)) - (execute-kbd-macro "q:") - (should (= (length (window-list)) num-windows)))))) - (ert-deftest evil-test-command-window-search-history () - "Test command window with forward and backward search history" - (skip-unless (not noninteractive)) - (let ((evil-search-module 'isearch)) - (evil-test-buffer - "[f]oo bar baz qux one two three four" - ("/qux" [return]) - "foo bar baz [q]ux one two three four" - ("/three" [return]) - "foo bar baz qux one two [t]hree four" - ("?bar" [return]) - "foo [b]ar baz qux one two three four" - ("/four" [return]) - "foo bar baz qux one two three [f]our" - ("?baz" [return]) - "foo bar [b]az qux one two three four" + "Test command window with forward and backward search history." + (let ((evil-search-module 'isearch) + (evil-search-forward-history (list "four" "three" "qux")) + (evil-search-backward-history (list "baz" "bar"))) + (evil-test-buffer "foo bar [b]az qux one two three four" ("q/") "qux\nthree\nfour\n[]\n" ("k" [return]) @@ -8944,14 +8901,11 @@ Source "bar\nbaz\n[]\n" ("k$rr" [return]) "foo [b]ar baz qux one two three four" - (should-error - (progn (execute-kbd-macro "q/iNOT THERE") - (execute-kbd-macro [return]))) + (error 'user-error "q/iNOT THERE" [return]) "foo [b]ar baz qux one two three four"))) (ert-deftest evil-test-command-window-search-word () - "Test command window history when searching for word under cursor" - (skip-unless (not noninteractive)) + "Test command window history when searching for word under cursor." (let ((evil-search-module 'isearch)) (evil-test-buffer "[f]oo bar foo bar foo" diff --git a/evil-vars.el b/evil-vars.el index bd2b29eb..873d1a66 100644 --- a/evil-vars.el +++ b/evil-vars.el @@ -1351,7 +1351,7 @@ line. If this option is non-nil, this behavior is reversed." "Face for interactive replacement text." :group 'evil) -(defcustom evil-command-window-height 8 +(defcustom evil-command-window-height 7 "Height (in lines) of the command line window. Set to 0 to use the default height for `split-window'." :type 'integer @@ -1987,14 +1987,6 @@ when Ex is started interactively.") "Non-nil if the previous was a search. Otherwise the previous command is assumed as substitute.") -;;; Command line window - -(evil-define-local-var evil-command-window-execute-fn nil - "The command to execute when exiting the command line window.") - -(evil-define-local-var evil-command-window-cmd-key nil - "The key for the command that opened the command line window (:, /, or ?).") - ;; The lazy-highlighting framework (evil-define-local-var evil-ex-active-highlights-alist nil "An alist of currently active highlights.") From 079cbc64479c4b7ac1d68434152726b8f7c5eb85 Mon Sep 17 00:00:00 2001 From: Axel Forsman Date: Fri, 25 Aug 2023 17:43:51 +0200 Subject: [PATCH 4/4] Support command-line window for any minibuffer arg Introspection of the current minibuffer argument history and prompt is possible, hence there is no need for the specialized evil-ex-command-window and evil-ex-search-command-window functions. --- evil-command-window.el | 50 +++++++++++++++++++----------------------- evil-maps.el | 3 +-- 2 files changed, 24 insertions(+), 29 deletions(-) diff --git a/evil-command-window.el b/evil-command-window.el index dd148822..ef22be02 100644 --- a/evil-command-window.el +++ b/evil-command-window.el @@ -56,9 +56,16 @@ "Open a command-line window for HISTORY with PROMPT and EXECUTE-FN. HISTORY should be a list of commands. PROMPT should be the command-line prompt (one of \":\", \"/\" or \"?\"). EXECUTE-FN should -be a unary function to execute on the result that the user selects." +be a unary function to execute on the result that the user selects. + +If called interactively, edit this minibuffer argument." + (interactive + (list (cons (minibuffer-contents) (minibuffer-history-value)) + (or (minibuffer-prompt) (user-error "Minibuffer is inactive")) + #'evil--command-window-minibuffer-execute)) (when (derived-mode-p 'evil-command-window-mode) (user-error "Command-line window is already open")) + (when (evil-ex-p) (evil-ex-teardown)) (let ((previous-buffer (current-buffer)) (buffer (get-buffer-create "*Command Line*"))) (with-current-buffer buffer @@ -116,33 +123,28 @@ function to execute." (when window (select-window window))) (with-current-buffer original-buffer (funcall execute-fn result)))) -(defun evil-command-window-ex (&optional current-command execute-fn) +(defun evil--command-window-minibuffer-execute (result) + "Terminate this minibuffer argument with RESULT." + (delete-minibuffer-contents) + (insert result) + (exit-minibuffer)) + +(defun evil-command-window-ex (&optional current-command) "Open a command-line window for editing and executing Ex commands. If CURRENT-COMMAND is present, it will be inserted under the cursor as -the current command to be edited. If EXECUTE-FN is given, it will be -used as the function to execute instead of -`evil-command-window-ex-execute', the default." +the current command to be edited." (interactive) (evil-command-window (cons (or current-command "") evil-ex-history) ":" - (or execute-fn #'evil-command-window-ex-execute))) + #'evil-command-window-ex-execute)) -(defun evil-ex-command-window () - "Start command window with Ex history and current minibuffer content." - (interactive) - (evil-ex-teardown) - (let ((execute-fn (apply-partially #'evil-ex-command-window-execute - (current-window-configuration)))) - (evil-command-window-ex (minibuffer-contents) execute-fn))) +(define-obsolete-function-alias + 'evil-ex-command-window #'evil-command-window "1.15.0" + "Start command window with Ex history and current minibuffer content.") -(defun evil-ex-search-command-window () - "Start command window with search history and current minibuffer content." - (interactive) - (let ((execute-fn (apply-partially #'evil-ex-command-window-execute - (current-window-configuration)))) - (evil-command-window (cons (minibuffer-contents) evil-ex-search-history) - (evil-search-prompt (eq evil-ex-search-direction 'forward)) - execute-fn))) +(define-obsolete-function-alias + 'evil-ex-search-command-window #'evil-command-window "1.15.0" + "Start command window with search history and current minibuffer content.") (defun evil-command-window-ex-execute (result) "Execute RESULT as an Ex command." @@ -151,12 +153,6 @@ used as the function to execute instead of (push result evil-ex-history)) (evil-ex-execute result))) -(defun evil-ex-command-window-execute (config result) - (set-window-configuration config) - (delete-minibuffer-contents) - (insert result) - (exit-minibuffer)) - (defun evil--command-window-search (forward) "Open a command-line window for searches." (evil-command-window diff --git a/evil-maps.el b/evil-maps.el index b24cee61..f263a63e 100644 --- a/evil-maps.el +++ b/evil-maps.el @@ -599,6 +599,7 @@ included in `evil-insert-state-bindings' by default." (define-key evil-command-line-map "\C-b" #'move-beginning-of-line) (define-key evil-command-line-map "\C-c" #'abort-recursive-edit) (define-key evil-command-line-map "\C-d" #'completion-at-point) +(define-key evil-command-line-map "\C-f" 'evil-command-window) (define-key evil-command-line-map "\C-g" #'abort-minibuffers) (define-key evil-command-line-map "\C-k" 'evil-insert-digraph) (define-key evil-command-line-map "\C-l" #'completion-at-point) @@ -621,13 +622,11 @@ included in `evil-insert-state-bindings' by default." ;; search command line (set-keymap-parent evil-ex-search-keymap evil-command-line-map) -(define-key evil-ex-search-keymap "\C-f" 'evil-ex-search-command-window) (unless evil-want-C-w-delete (define-key evil-ex-search-keymap "\C-w" 'evil-search-yank-word)) ;; Ex command line (set-keymap-parent evil-ex-completion-map evil-command-line-map) -(define-key evil-ex-completion-map "\C-f" 'evil-ex-command-window) ;; eval prompt (the `=' register) (define-key evil-eval-map "\C-b" 'move-beginning-of-line)