Subject: RE: [External] : Re: bug#78658: 30.1; [PATCH] Dired feature suggestion: dired-on-marked-files-in-all-buffers

From: Drew Adams <[email-masked]>
Date: Tue, 3 Jun 2025 19:55:27 +0000

> > >     (let ((common  (try-completion "" files)))
> >
> > My brain had failed to make the connection between "completion"
> > and programmatically obtaining a common prefix from list of
> > strings.  It makes perfect sense in hindsight, but I'd simply
> > never thought about completion in non-interactive terms, and was
> > surprised when I hadn't found a documented function for doing
> > this (but I wasn't looking under Completion at all).
> >
> > Eli, I reckon this is worth either documenting somewhere under
> > (info "(elisp) Strings and Characters") or else creating a
> > slightly more string-centric wrapper, something like:
> 
> Feel free to suggest patches for the documentation, but please
> remember that results of calling completion functions can depend on
> the completion styles in effect, so if we want to advertise this as a
> way of producing the largest common prefix, we should probably bind
> completion-styles to something specific around this call.

That may be a good point.  In a way it's too bad that
`completion-styles' affects `try-completion'.

Or maybe I should say that it's too bad we don't have a
better primitive for this purpose than `try-completion'.
In a way, we're reusing something that wasn't really
designed for this use.

There's also `fill-common-string-prefix', but that
just takes two strings as arg.  What's called for is
a function that takes a list of strings as arg (like
`try-completion' does).

In the code that I show in my reply today to Phil, I
too didn't bother to bind `completion-styles'.  But
I agree that if we use `try-completion' in this way
then maybe we should do that.