diff options
| author | Stefan Monnier | 2019-03-20 12:30:53 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2019-03-20 12:30:53 -0400 |
| commit | 9efc43f34adfff2f00162fb85685824557d00eb1 (patch) | |
| tree | 40052bb29e0e416f34f03fd3261eb9e54aab8f56 | |
| parent | d081450f379686a7794ff3484116fbc510c86fc0 (diff) | |
| download | emacs-9efc43f34adfff2f00162fb85685824557d00eb1.tar.gz emacs-9efc43f34adfff2f00162fb85685824557d00eb1.zip | |
* 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.
| -rw-r--r-- | lisp/pcomplete.el | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/lisp/pcomplete.el b/lisp/pcomplete.el index d0f2a2e24d1..e0800749273 100644 --- a/lisp/pcomplete.el +++ b/lisp/pcomplete.el | |||
| @@ -444,10 +444,28 @@ Same as `pcomplete' but using the standard completion UI." | |||
| 444 | ;; table which expects strings using a prefix from the | 444 | ;; table which expects strings using a prefix from the |
| 445 | ;; buffer's text but internally uses the corresponding | 445 | ;; buffer's text but internally uses the corresponding |
| 446 | ;; prefix from pcomplete-stub. | 446 | ;; prefix from pcomplete-stub. |
| 447 | ;; | ||
| 448 | (argbeg (pcomplete-begin)) | ||
| 449 | ;; When completing an envvar within an argument in Eshell | ||
| 450 | ;; (e.g. "cd /home/$US TAB"), `pcomplete-stub' will just be | ||
| 451 | ;; "US" whereas `argbeg' will point to the first "/". | ||
| 452 | ;; We could rely on c-t-subvert to handle the difference, | ||
| 453 | ;; but we try here to guess the "real" beginning so as to | ||
| 454 | ;; rely less on c-t-subvert. | ||
| 447 | (beg (max (- (point) (length pcomplete-stub)) | 455 | (beg (max (- (point) (length pcomplete-stub)) |
| 448 | (pcomplete-begin))) | 456 | argbeg)) |
| 449 | (buftext (pcomplete-unquote-argument | 457 | buftext) |
| 450 | (buffer-substring beg (point))))) | 458 | ;; Try and improve our guess of `beg' in case the difference |
| 459 | ;; between pcomplete-stub and the buffer's text is simply due to | ||
| 460 | ;; some chars removed by unquoting. Again, this is not | ||
| 461 | ;; indispensable but reduces the reliance on c-t-subvert and | ||
| 462 | ;; improves corner case behaviors. | ||
| 463 | (while (progn (setq buftext (pcomplete-unquote-argument | ||
| 464 | (buffer-substring beg (point)))) | ||
| 465 | (and (> beg argbeg) | ||
| 466 | (> (length pcomplete-stub) (length buftext)))) | ||
| 467 | (setq beg (max argbeg (- beg (- (length pcomplete-stub) | ||
| 468 | (length buftext)))))) | ||
| 451 | (when completions | 469 | (when completions |
| 452 | (let ((table | 470 | (let ((table |
| 453 | (completion-table-with-quoting | 471 | (completion-table-with-quoting |