GNU bug report logs -
#76603
30.1; multi-file-replace-regexp-as-diff won't end prompting with icomplete-show-matches-on-no-input
Previous Next
Full log
Message #26 received at 76603 <at> debbugs.gnu.org (full text, mbox):
>> I vaguely remember there exists such a function that reads a glob pattern,
>> but can't find it right away.
>
> Neither did I :(
Now I remembered the name of this function: 'file-expand-wildcards'.
Like is used in 'multi-isearch-read-matching-files'.
> Do you think two more functions with extended
> functionality are worth a patch?
A patch would be nice later, when you will get a working version
with using more core functions.
> (defun glob-to-regexp (glob)
> "Convert a GLOB pattern (e.g., '*.el') to a regexp that `directory-files-recursively` can use."
> (concat "^" (replace-regexp-in-string
> (rx (any "*?."))
> (lambda (match)
> (pcase match
> ("*" ".*")
> ("?" ".")
> ("." "\\\\.") ; Properly escape the dot
> (_ match)))
> glob)
> "$"))
There is already the core function 'wildcard-to-regexp'
and its duplicate 'dired-glob-regexp'.
> (defun expand-directories (items)
> "Expand ITEMS to include all files within directories (recursively).
> Directories themselves are excluded from the final list."
> (cl-loop for item in items
> if (file-directory-p item)
> append (let ((files (directory-files-recursively item ".*" t)))
> (cl-remove-if #'file-directory-p files))
> else if (file-regular-p item) ; Ensure only regular files are included
> collect item))
I don't remember such a core function, so maybe the function above could be added.
This bug report was last modified 152 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.