[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: master 6b7ff60a5e7: Highlight the suffix in *Completions* buffer in
From: |
Eshel Yaron |
Subject: |
Re: master 6b7ff60a5e7: Highlight the suffix in *Completions* buffer in 'basic' style too |
Date: |
Fri, 14 Jun 2024 09:35:32 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Hi Juri,
Juri Linkov <juri@linkov.net> writes:
>> Something like the following should fix this issue:
>> [...]
>> @@ -3816,7 +3816,9 @@ completion-basic-all-completions
>> 'point
>> (substring afterpoint 0 (cdr bounds)))))
>> (all (completion-pcm--all-completions prefix pattern table pred)))
>> - (completion-pcm--hilit-commonality pattern all)))
>> + (when all
>> + (nconc (completion-pcm--hilit-commonality pattern all)
>> + (car bounds)))))
>
> This fixes file name completion, but at the cost of breaking icomplete-mode:
>
> Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
> >(19 nil)
> (if (> (length string) pos) (add-face-text-property pos (1+ pos)
> 'completions-first-difference nil string))
> (let* ((md (and regexp (string-match regexp string) (cdr (cdr (match-data
> t))))) ...)
> completion--hilit-from-re("it-window-to-buffer" "\\`f\\(.*?\\)" 1)
> completion-lazy-hilit("it-window-to-buffer")
> icomplete-completions("f" ...)
> icomplete-exhibit()
> completing-read-default("M-x " ...)
> read-extended-command-1("M-x " nil)
> read-extended-command()
> command-execute(execute-extended-command)
Hmm that's quite curious... I can reproduce it also without my change
in 56537ab0228, FWIW. AFAICT the issue is that icomplete trims the
prefix from completion candidates before passing them to
completion-lazy-hilit, while completion--hilit-from-re expects the full
candidate (prefix included). I'm not deeply familiar with icomplete,
but maybe calling completion-lazy-hilit before trimming the candidates
as in the diff below should do the trick?
diff --git a/lisp/icomplete.el b/lisp/icomplete.el
index 44bbe9772e4..d03e315fdc8 100644
--- a/lisp/icomplete.el
+++ b/lisp/icomplete.el
@@ -1043,7 +1043,8 @@ icomplete-completions
(setq determ (concat open-bracket "" close-bracket)))
(while (and comps (not limit))
(setq comp
- (if prefix-len (substring (car comps) prefix-len) (car
comps))
+ (let ((cur (completion-lazy-hilit (car comps))))
+ (if prefix-len (substring cur prefix-len) cur))
comps (cdr comps))
(setq prospects-len
(+ (string-width comp)
@@ -1052,8 +1053,7 @@ icomplete-completions
(if (< prospects-len prospects-max)
(push comp prospects)
(setq limit t)))
- (setq prospects
- (nreverse (mapcar #'completion-lazy-hilit prospects)))
+ (setq prospects (nreverse prospects))
;; Decorate first of the prospects.
(when prospects
(let ((first (copy-sequence (pop prospects))))