[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil 657af37c55 4/4: Support command-line window for any m
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil 657af37c55 4/4: Support command-line window for any minibuffer arg |
Date: |
Sun, 27 Aug 2023 09:59:23 -0400 (EDT) |
branch: elpa/evil
commit 657af37c5570caab487e9e73d7b95696437e664d
Author: Axel Forsman <axel@axelf.se>
Commit: Axel Forsman <axelsfor@gmail.com>
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 dd148822db..ef22be0235 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 b24cee615a..f263a63ee4 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)