branch: externals/minuet
commit ebca9d72c09e040f12c6e56fbace58ba9c2ce532
Author: milanglacier <d...@milanglacier.com>
Commit: GitHub <nore...@github.com>

    feat: add numeric prefix support to minuet-accept-suggestion-line. (#12)
---
 README.md |  4 +++-
 minuet.el | 14 +++++++++-----
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/README.md b/README.md
index d9cce85300..e2a0593c20 100644
--- a/README.md
+++ b/README.md
@@ -75,7 +75,9 @@ Currently you need to install from github via `package-vc` or
      ("M-p" . #'minuet-previous-suggestion) ;; invoke completion or cycle to 
next completion
      ("M-n" . #'minuet-next-suggestion) ;; invoke completion or cycle to 
previous completion
      ("M-A" . #'minuet-accept-suggestion) ;; accept whole completion
-     ("M-a" . #'minuet-accept-suggestion-line) ;; accept current line 
completion
+     ;; Accept the first line of completion, or N lines with a numeric-prefix:
+     ;; e.g. C-u 2 M-a will accepts 2 lines of completion.
+     ("M-a" . #'minuet-accept-suggestion-line)
      ("M-e" . #'minuet-dismiss-suggestion))
 
     :init
diff --git a/minuet.el b/minuet.el
index f3e5780c5d..7f0abe625b 100644
--- a/minuet.el
+++ b/minuet.el
@@ -628,16 +628,20 @@ used to accumulate text output from a process.  After 
execution,
     (minuet--cleanup-suggestion))
 
 ;;;###autoload
-(defun minuet-accept-suggestion-line ()
-    "Accept only the first line of the current overlay suggestion."
-    (interactive)
+(defun minuet-accept-suggestion-line (&optional n)
+    "Accept N lines of the current suggestion.
+When called interactively with a numeric prefix argument, accept that
+many lines.  Without a prefix argument, accept only the first line."
+    (interactive "p")
     (when (and minuet--current-suggestions
                minuet--current-overlay)
         (let* ((suggestion (nth minuet--current-suggestion-index
                                 minuet--current-suggestions))
-               (first-line (car (split-string suggestion "\n"))))
+               (lines (split-string suggestion "\n"))
+               (n (or n 1))
+               (selected-lines (seq-take lines n)))
             (minuet--cleanup-suggestion)
-            (insert first-line))))
+            (insert (string-join selected-lines "\n")))))
 
 ;;;###autoload
 (defun minuet-complete-with-minibuffer ()

Reply via email to