branch: externals/orderless
commit 5e402282db0704abb0fb6b1c16861ecd306b16e3
Author: Omar Antolín <[email protected]>
Commit: Omar Antolín <[email protected]>

    Mostly (but not completely) fix the problem with file completion
---
 orderless.el | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/orderless.el b/orderless.el
index f431d6ce6b..087c80eb5f 100644
--- a/orderless.el
+++ b/orderless.el
@@ -43,8 +43,10 @@
 ;;; Code:
 
 (defun orderless-all-completions (string table pred point)
-  (let ((all (all-completions "" table pred))
-        (regexps (split-string string)))
+  (let* ((lim (car (completion-boundaries string table pred "")))
+         (prefix (substring string 0 lim))
+         (all (all-completions prefix table pred))
+         (regexps (split-string (substring string lim))))
     (when minibuffer-completing-file-name
       (setq all (completion-pcm--filename-try-filter all)))
     (condition-case err
@@ -54,12 +56,15 @@
                  collect candidate)
       (invalid-regexp nil))))
 
-(defun orderless-try-completion (string table pred point  &optional _metadata)
-  (let ((all (orderless-all-completions string table pred point)))
-    (cond
-     ((null all) nil)
-     ((null (cdr all)) (cons (car all) (length (car all))))
-     (t (cons string (length string))))))
+(defun orderless-try-completion (string table pred point &optional _metadata)
+  (let* ((lim (car (completion-boundaries string table pred "")))
+         (prefix (substring string 0 lim))
+         (all (orderless-all-completions string table pred point)))
+    (cl-flet ((point-at-end (str) (cons str (length str))))
+      (cond
+       ((null all) nil)
+       ((null (cdr all)) (point-at-end (concat prefix (car all))))
+       (t (point-at-end string))))))
 
 (push '(orderless
         orderless-try-completion orderless-all-completions

Reply via email to