]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/pcomplete.el (pcomplete-completions-at-point): Add hack for bug#65089
authorStefan Monnier <monnier@iro.umontreal.ca>
Fri, 8 Sep 2023 15:31:35 +0000 (11:31 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Fri, 8 Sep 2023 15:31:35 +0000 (11:31 -0400)
Improve our guess for `end` and `buftext` when point is not at the end
of the current "thing to complete".

lisp/pcomplete.el

index 151611f94b70eff4df08d8c309036ff379e44e26..0457f1b00c0accc506e7a97be7ce059a547f0064 100644 (file)
@@ -470,6 +470,8 @@ Same as `pcomplete' but using the standard completion UI."
            ;; rely less on c-t-subvert.
            (beg (max (- (point) (length pcomplete-stub))
                      argbeg))
+           (end (point))
+           tmp
            buftext)
       ;; Try and improve our guess of `beg' in case the difference
       ;; between pcomplete-stub and the buffer's text is simply due to
@@ -477,11 +479,19 @@ Same as `pcomplete' but using the standard completion UI."
       ;; indispensable but reduces the reliance on c-t-subvert and
       ;; improves corner case behaviors.
       (while (progn (setq buftext (pcomplete-unquote-argument
-                                   (buffer-substring beg (point))))
+                                   (buffer-substring beg end)))
                     (and (> beg argbeg)
                          (> (length pcomplete-stub) (length buftext))))
         (setq beg (max argbeg (- beg (- (length pcomplete-stub)
                                         (length buftext))))))
+      ;; Try and improve our guess of `end' in case it's not point.
+      (while (and (< (length buftext) (length pcomplete-stub))
+                  (< end (point-max))
+                  (string-prefix-p (setq tmp (pcomplete-unquote-argument
+                                              (buffer-substring beg (1+ end))))
+                                   pcomplete-stub))
+        (setq end (1+ end))
+        (setq buftext tmp))
       (when completions
         (let ((table
                (completion-table-with-quoting
@@ -515,7 +525,7 @@ Same as `pcomplete' but using the standard completion UI."
                            seen)))))))
           (when completion-ignore-case
             (setq table (completion-table-case-fold table)))
-          (list beg (point) table
+          (list beg end table
                 :annotation-function
                 (lambda (cand)
                   (when (stringp cand)