Function: insert-directory-wildcard-in-dir-p
insert-directory-wildcard-in-dir-p is a byte-compiled function defined
in files.el.gz.
Signature
(insert-directory-wildcard-in-dir-p DIR)
Documentation
Return non-nil if DIR contains shell wildcards in its parent directory part.
The return value is a cons (DIRECTORY . WILDCARD), where DIRECTORY is the part of DIR up to and excluding the first component that includes wildcard characters, and WILDCARD is the rest of DIR's components. The DIRECTORY part of the value includes the trailing slash, to indicate that it is a directory.
Valid wildcards are *, ?, [abc] and [a-z].
Source Code
;; Defined in /usr/src/emacs/lisp/files.el.gz
(defun insert-directory-wildcard-in-dir-p (dir)
"Return non-nil if DIR contains shell wildcards in its parent directory part.
The return value is a cons (DIRECTORY . WILDCARD), where DIRECTORY is the
part of DIR up to and excluding the first component that includes
wildcard characters, and WILDCARD is the rest of DIR's components. The
DIRECTORY part of the value includes the trailing slash, to indicate that
it is a directory.
Valid wildcards are `*', `?', `[abc]' and `[a-z]'."
(let ((wildcards "[?*"))
(when (and (or (not (featurep 'ls-lisp))
ls-lisp-support-shell-wildcards)
(string-match (concat "[" wildcards "]") (file-name-directory dir))
(not (file-exists-p dir))) ; Prefer an existing file to wildcards.
(let ((regexp (format "\\`\\([^%s]*/\\)\\([^%s]*[%s].*\\)"
wildcards wildcards wildcards)))
(string-match regexp dir)
(cons (match-string 1 dir) (match-string 2 dir))))))