From 34b1ed3f5e560493d2b7cd72664ae1a5018d313f Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Fri, 8 Sep 2023 11:31:35 -0400 Subject: [PATCH] * lisp/pcomplete.el (pcomplete-completions-at-point): Add hack for bug#65089 Improve our guess for `end` and `buftext` when point is not at the end of the current "thing to complete". --- lisp/pcomplete.el | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lisp/pcomplete.el b/lisp/pcomplete.el index 151611f94b7..0457f1b00c0 100644 --- a/lisp/pcomplete.el +++ b/lisp/pcomplete.el @@ -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) -- 2.39.5