all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Daniel Mendler <daniel@mendler.net>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: [PATCH] `completing-read` - allow history=t, sorting improvements
Date: Tue, 20 Apr 2021 01:47:34 +0200	[thread overview]
Message-ID: <66a96995-10ec-f466-530c-87d173cdfaba@mendler.net> (raw)
In-Reply-To: <jwvv98hriy7.fsf-monnier+emacs@gnu.org>

On 4/20/21 12:55 AM, Stefan Monnier wrote:
>> +(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.

Yes, right. The base size, even better. I will use that instead!


> [ If (cdr last) is nil it's equivalent to 0.  ]

I stumbled over this just today, when I had assumed that the cdr always 
has an integer. But the docs say it "may" have that.


>> +         (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).

I will check. I still believe a tiny hack is needed because of the final 
slash. And the advantage of dropping everything behind the slash is that 
accesses to files influence the position of their parent directory (if 
one considers that an advantage).

Thanks for letting me know about the `minibuffer-completing-file-name` 
variable. There is also `minibuffer-completing-symbol`. Shall we mark 
them as obsolete? I wondered why they exist but I took them thankfully 
as an easy way to access the category. I will revert this then in my 
packages.

Daniel



  reply	other threads:[~2021-04-19 23:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-19 18:02 [PATCH] `completing-read` - allow history=t, sorting improvements Daniel Mendler
2021-04-19 19:14 ` Stefan Monnier
2021-04-19 19:36   ` Daniel Mendler
2021-04-19 20:15     ` Stefan Monnier
2021-04-19 20:44       ` Daniel Mendler
2021-04-19 21:52         ` Stefan Monnier
2021-04-19 22:29           ` Daniel Mendler
2021-04-19 22:55             ` Stefan Monnier
2021-04-19 23:47               ` Daniel Mendler [this message]
2021-04-20  1:55                 ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=66a96995-10ec-f466-530c-87d173cdfaba@mendler.net \
    --to=daniel@mendler.net \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.