[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 9efc43f: * lisp/pcomplete.el: Improve heuristic to
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] master 9efc43f: * lisp/pcomplete.el: Improve heuristic to rely less on c-t-subvert. |
Date: |
Wed, 20 Mar 2019 12:30:59 -0400 (EDT) |
branch: master
commit 9efc43f34adfff2f00162fb85685824557d00eb1
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>
* lisp/pcomplete.el: Improve heuristic to rely less on c-t-subvert.
(pcomplete-completions-at-point): Try and take \ escapes into account
when guessing the beginning of the text we're completing.
---
lisp/pcomplete.el | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/lisp/pcomplete.el b/lisp/pcomplete.el
index d0f2a2e..e080074 100644
--- a/lisp/pcomplete.el
+++ b/lisp/pcomplete.el
@@ -444,10 +444,28 @@ Same as `pcomplete' but using the standard completion UI."
;; table which expects strings using a prefix from the
;; buffer's text but internally uses the corresponding
;; prefix from pcomplete-stub.
+ ;;
+ (argbeg (pcomplete-begin))
+ ;; When completing an envvar within an argument in Eshell
+ ;; (e.g. "cd /home/$US TAB"), `pcomplete-stub' will just be
+ ;; "US" whereas `argbeg' will point to the first "/".
+ ;; We could rely on c-t-subvert to handle the difference,
+ ;; but we try here to guess the "real" beginning so as to
+ ;; rely less on c-t-subvert.
(beg (max (- (point) (length pcomplete-stub))
- (pcomplete-begin)))
- (buftext (pcomplete-unquote-argument
- (buffer-substring beg (point)))))
+ argbeg))
+ buftext)
+ ;; Try and improve our guess of `beg' in case the difference
+ ;; between pcomplete-stub and the buffer's text is simply due to
+ ;; some chars removed by unquoting. Again, this is not
+ ;; 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))))
+ (and (> beg argbeg)
+ (> (length pcomplete-stub) (length buftext))))
+ (setq beg (max argbeg (- beg (- (length pcomplete-stub)
+ (length buftext))))))
(when completions
(let ((table
(completion-table-with-quoting
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 9efc43f: * lisp/pcomplete.el: Improve heuristic to rely less on c-t-subvert.,
Stefan Monnier <=