[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] `completing-read` - allow history=t, sorting improvements
From: |
Stefan Monnier |
Subject: |
Re: [PATCH] `completing-read` - allow history=t, sorting improvements |
Date: |
Mon, 19 Apr 2021 18:55:08 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> Btw, I attached the updated patch for the boundaries. I am not sure if the
> approach I took there is a good one, this works only in restricted set of
> scenarios (not with partial-completion/initials unfortunately). So this
> should be discussed.
See my comment below.
> Then you mentioned test cases - to clarify, do you want to see some kind of
> integration test where a mockup minibuffer-completion-table is set-up and
> the results of `completion-all-sorted-completions` are checked,
I think that's what we'd want, yes.
> I looked briefly into
> test/lisp/minibuffer.el - the test should probably go there?
^^^
-tests
Yes, indeed.
> +(defun minibuffer--sort-preprocess-history (start string)
> + "Preprocess history, remove completion prefixes.
> +STRING is the minibuffer content.
> +START is the start position of the completion."
> + (let* ((def (car-safe minibuffer-default))
> + (hist (symbol-value minibuffer-history-variable))
> + (hist (if def (cons def hist) hist))
> + (bounds (completion-boundaries
> + (substring string 0 (- (point) start))
> + minibuffer-completion-table
> + minibuffer-completion-predicate
> + ""))
Actually, the caller has the info we need already in the (cdr last),
which it throws away in:
(when last
(setcdr last nil)
This info also has the advantage of working with partial-completion
because it comes from the completion-style output rather than from the
completion-table.
[ If (cdr last) is nil it's equivalent to 0. ]
> + (pre (substring string 0 (car bounds)))
> + (pre-len (length pre)))
> + ;; Preprocess history if completion boundaries are used
> + (cond
> + ;; Special handling of file name candidates.
> + ;; Drop prefix and everything after the first "/".
> + (minibuffer-completing-file-name
I hope that using (cdr last) will make it unnecessary to use such a hack.
If not, then please try and use the `category` from `md` rather than
`minibuffer-completing-file-name` which I consider as obsolete (tho it's
not marked as such yet).
Stefan
- [PATCH] `completing-read` - allow history=t, sorting improvements, Daniel Mendler, 2021/04/19
- Re: [PATCH] `completing-read` - allow history=t, sorting improvements, Stefan Monnier, 2021/04/19
- Re: [PATCH] `completing-read` - allow history=t, sorting improvements, Daniel Mendler, 2021/04/19
- Re: [PATCH] `completing-read` - allow history=t, sorting improvements, Stefan Monnier, 2021/04/19
- Re: [PATCH] `completing-read` - allow history=t, sorting improvements, Daniel Mendler, 2021/04/19
- Re: [PATCH] `completing-read` - allow history=t, sorting improvements, Stefan Monnier, 2021/04/19
- Re: [PATCH] `completing-read` - allow history=t, sorting improvements, Daniel Mendler, 2021/04/19
- Re: [PATCH] `completing-read` - allow history=t, sorting improvements,
Stefan Monnier <=
- Re: [PATCH] `completing-read` - allow history=t, sorting improvements, Daniel Mendler, 2021/04/19
- Re: [PATCH] `completing-read` - allow history=t, sorting improvements, Stefan Monnier, 2021/04/19