]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/icomplete.el: Fix in-buffer completion.
authorJuri Linkov <juri@linkov.net>
Mon, 27 Feb 2023 18:32:53 +0000 (20:32 +0200)
committerJuri Linkov <juri@linkov.net>
Wed, 1 Mar 2023 17:52:35 +0000 (19:52 +0200)
(icomplete-force-complete-and-exit, icomplete-force-complete): Use
'icomplete--field-beg/end' when not in the minibuffer to not erase
the current buffer.  Also disable 'completion-in-region-mode' instead
of calling 'exit-minibuffer' (bug#45764, bug#51575, bug#61479).

Backport:
(cherry picked from commit a7a984c0ebebb891e2052d8416544f0bd7002007)

lisp/icomplete.el

index 014f38b2024da2f900abe07a6b3b8cc22a73e6f3..fd6a09e87026fa26516e41f6175fad821464d5a3 100644 (file)
@@ -215,15 +215,29 @@ the default otherwise."
        ;; calculated, This causes the first cached completion to
        ;; be taken (i.e. the one that the user sees highlighted)
        completion-all-sorted-completions)
-      (minibuffer-force-complete-and-exit)
+      (if (window-minibuffer-p)
+          (minibuffer-force-complete-and-exit)
+        (minibuffer-force-complete (icomplete--field-beg)
+                                   (icomplete--field-end)
+                                   'dont-cycle)
+        (completion-in-region-mode -1))
     ;; Otherwise take the faster route...
-    (minibuffer-complete-and-exit)))
+    (if (window-minibuffer-p)
+        (minibuffer-complete-and-exit)
+      (completion-complete-and-exit
+       (icomplete--field-beg)
+       (icomplete--field-end)
+       (lambda () (completion-in-region-mode -1))))))
 
 (defun icomplete-force-complete ()
   "Complete the icomplete minibuffer."
   (interactive)
   ;; We're not at all interested in cycling here (bug#34077).
-  (minibuffer-force-complete nil nil 'dont-cycle))
+  (if (window-minibuffer-p)
+      (minibuffer-force-complete nil nil 'dont-cycle)
+    (minibuffer-force-complete (icomplete--field-beg)
+                               (icomplete--field-end)
+                               'dont-cycle)))
 
 ;; Apropos `icomplete-scroll', we implement "scrolling icomplete"
 ;; within classic icomplete, which is "rotating", by contrast.