GNU bug report logs - #78658
30.1; [PATCH] Dired feature suggestion: dired-on-marked-files-in-all-buffers

Previous Next

Package: emacs;

Reported by: Phil Sainty <psainty <at> orcon.net.nz>

Date: Sun, 1 Jun 2025 03:20:06 UTC

Severity: normal

Tags: patch

Found in version 30.1

Full log


Message #59 received at 78658 <at> debbugs.gnu.org (full text, mbox):

From: Phil Sainty <psainty <at> orcon.net.nz>
To: Daniel Mendler <mail <at> daniel-mendler.de>
Cc: "Drew Adams via \"Bug reports for GNU Emacs, the Swiss army knife of
 text editors\"" <bug-gnu-emacs <at> gnu.org>, juri <at> linkov.net,
 Eli Zaretskii <eliz <at> gnu.org>, Drew Adams <drew.adams <at> oracle.com>,
 78658 <at> debbugs.gnu.org
Subject: Re: bug#78658: 30.1; [PATCH] Dired feature suggestion:
 dired-on-marked-files-in-all-buffers
Date: Wed, 04 Jun 2025 20:36:43 +1200
On 2025-06-04 08:09, Daniel Mendler wrote:
> Note that the `completion-styles' only affect
> `completion-try-completion' and `completion-all-completions', but not
> the primitive `try-completion', which always computes the common 
> prefix.

Thanks for confirming that.

There are a couple of edge-cases for `try-completion' which made me
think a new wrapper function for the "find the longest string prefix"
case would be a good thing, which are:

 (try-completion "" '())
 nil

 (try-completion "" '(""))
 t

Hence:

 (defun string-common-prefix (strings)
  "Return the largest common prefix from a list of STRINGS."
  (let ((prefix (try-completion "" strings)))
    (if (stringp prefix)
        prefix
      "")))

In both of the special cases, an empty string is what I'd want to get
from a function for finding the longest common prefix.

In the case of '("") that's because the empty string is the literal
correct result.

In the case of '() I think an empty string "" is the most useful
result for code expecting/requiring a string, avoiding any need to
test for a nil value.  One might argue for returning nil here -- but
any code wanting that can test the list argument instead, as the only
way for (try-completion "" list) to return nil is if `list' is nil (or
if it's not a list of strings, which I'd consider invalid enough to be
ignored).

I think this would be a more-discoverable and better-behaved function
for simple "find the longest common prefix" needs.


-Phil





This bug report was last modified 5 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.