Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emacs
emacs
Commits
6f4983e6
Commit
6f4983e6
authored
Dec 28, 1995
by
Richard M. Stallman
Browse files
(wildcard-to-regexp): New function.
(recover-session): Bind ls-lisp-support-shell-wildcards to t.
parent
f8250f01
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
1 deletion
+69
-1
lisp/files.el
lisp/files.el
+69
-1
No files found.
lisp/files.el
View file @
6f4983e6
...
...
@@ -2200,7 +2200,8 @@ previous sessions that you could recover from.
To choose one, move point to the proper line and then type C-c C-c.
Then you'll be asked about a number of files to recover."
(interactive)
(dired (concat auto-save-list-file-prefix "*"))
(let ((ls-lisp-support-shell-wildcards t))
(dired (concat auto-save-list-file-prefix "*")))
(goto-char (point-min))
(or (looking-at "Move to the session you want to recover,")
(let ((inhibit-read-only t))
...
...
@@ -2373,6 +2374,73 @@ See also `auto-save-file-name-p'."
FILENAME should lack slashes. You can redefine this for customization."
(string-match "^#.*#$" filename))
(defun wildcard-to-regexp (wildcard)
"Given a shell file name pattern WILDCARD, return an equivalent regexp.
The generated regexp will match a filename iff the filename
matches that wildcard according to shell rules. Only wildcards known
by `sh' are supported."
(let* ((i (string-match "[[.*+\\^$?]" wildcard))
;; Copy the initial run of non-special characters.
(result (substring wildcard 0 i))
(len (length wildcard)))
;; If no special characters, we're almost done.
(if i
(while (< i len)
(let ((ch (aref wildcard i))
j)
(setq
result
(concat result
(cond
((eq ch ?\[) ; [...] maps to regexp char class
(progn
(setq i (1+ i))
(concat
(cond
((eq (aref wildcard i) ?!) ; [!...] -> [^...]
(progn
(setq i (1+ i))
(if (eq (aref wildcard i) ?\])
(progn
(setq i (1+ i))
"[^]")
"[^")))
((eq (aref wildcard i) ?^)
;; Found "[^". Insert a `\0' character
;; (which cannot happen in a filename)
;; into the character class, so that `^'
;; is not the first character after `[',
;; and thus non-special in a regexp.
(progn
(setq i (1+ i))
"[\000^"))
((eq (aref wildcard i) ?\])
;; I don't think `]' can appear in a
;; character class in a wildcard, but
;; let's be general here.
(progn
(setq i (1+ i))
"[]"))
(t "["))
(prog1 ; copy everything upto next `]'.
(substring wildcard
i
(setq j (string-match
"]" wildcard i)))
(setq i (if j (1- j) (1- len)))))))
((eq ch ?.) "\\.")
((eq ch ?*) "[^\000]*")
((eq ch ?+) "\\+")
((eq ch ?^) "\\^")
((eq ch ?$) "\\$")
((eq ch ?\\) "\\\\") ; probably cannot happen...
((eq ch ??) "[^\000]")
(t (char-to-string ch)))))
(setq i (1+ i)))))
;; Shell wildcards should match the entire filename,
;; not its part. Make the regexp say so.
(concat "\\`" result "\\'")))
(defconst list-directory-brief-switches
(if (eq system-type 'vax-vms) "" "-CF")
"*Switches for list-directory to pass to `ls' for brief listing,")
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment