Mercurial > emacs
comparison lisp/files.el @ 13879:4888716715e0
(wildcard-to-regexp): New function.
(recover-session): Bind ls-lisp-support-shell-wildcards to t.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 28 Dec 1995 19:24:16 +0000 |
parents | aa5e493a867d |
children | bcb436f256e3 |
comparison
equal
deleted
inserted
replaced
13878:2a71500dfb93 | 13879:4888716715e0 |
---|---|
2198 This command first displays a Dired buffer showing you the | 2198 This command first displays a Dired buffer showing you the |
2199 previous sessions that you could recover from. | 2199 previous sessions that you could recover from. |
2200 To choose one, move point to the proper line and then type C-c C-c. | 2200 To choose one, move point to the proper line and then type C-c C-c. |
2201 Then you'll be asked about a number of files to recover." | 2201 Then you'll be asked about a number of files to recover." |
2202 (interactive) | 2202 (interactive) |
2203 (dired (concat auto-save-list-file-prefix "*")) | 2203 (let ((ls-lisp-support-shell-wildcards t)) |
2204 (dired (concat auto-save-list-file-prefix "*"))) | |
2204 (goto-char (point-min)) | 2205 (goto-char (point-min)) |
2205 (or (looking-at "Move to the session you want to recover,") | 2206 (or (looking-at "Move to the session you want to recover,") |
2206 (let ((inhibit-read-only t)) | 2207 (let ((inhibit-read-only t)) |
2207 (insert "Move to the session you want to recover,\n" | 2208 (insert "Move to the session you want to recover,\n" |
2208 "then type C-c C-c to select it.\n\n" | 2209 "then type C-c C-c to select it.\n\n" |
2371 (defun auto-save-file-name-p (filename) | 2372 (defun auto-save-file-name-p (filename) |
2372 "Return non-nil if FILENAME can be yielded by `make-auto-save-file-name'. | 2373 "Return non-nil if FILENAME can be yielded by `make-auto-save-file-name'. |
2373 FILENAME should lack slashes. You can redefine this for customization." | 2374 FILENAME should lack slashes. You can redefine this for customization." |
2374 (string-match "^#.*#$" filename)) | 2375 (string-match "^#.*#$" filename)) |
2375 | 2376 |
2377 (defun wildcard-to-regexp (wildcard) | |
2378 "Given a shell file name pattern WILDCARD, return an equivalent regexp. | |
2379 The generated regexp will match a filename iff the filename | |
2380 matches that wildcard according to shell rules. Only wildcards known | |
2381 by `sh' are supported." | |
2382 (let* ((i (string-match "[[.*+\\^$?]" wildcard)) | |
2383 ;; Copy the initial run of non-special characters. | |
2384 (result (substring wildcard 0 i)) | |
2385 (len (length wildcard))) | |
2386 ;; If no special characters, we're almost done. | |
2387 (if i | |
2388 (while (< i len) | |
2389 (let ((ch (aref wildcard i)) | |
2390 j) | |
2391 (setq | |
2392 result | |
2393 (concat result | |
2394 (cond | |
2395 ((eq ch ?\[) ; [...] maps to regexp char class | |
2396 (progn | |
2397 (setq i (1+ i)) | |
2398 (concat | |
2399 (cond | |
2400 ((eq (aref wildcard i) ?!) ; [!...] -> [^...] | |
2401 (progn | |
2402 (setq i (1+ i)) | |
2403 (if (eq (aref wildcard i) ?\]) | |
2404 (progn | |
2405 (setq i (1+ i)) | |
2406 "[^]") | |
2407 "[^"))) | |
2408 ((eq (aref wildcard i) ?^) | |
2409 ;; Found "[^". Insert a `\0' character | |
2410 ;; (which cannot happen in a filename) | |
2411 ;; into the character class, so that `^' | |
2412 ;; is not the first character after `[', | |
2413 ;; and thus non-special in a regexp. | |
2414 (progn | |
2415 (setq i (1+ i)) | |
2416 "[\000^")) | |
2417 ((eq (aref wildcard i) ?\]) | |
2418 ;; I don't think `]' can appear in a | |
2419 ;; character class in a wildcard, but | |
2420 ;; let's be general here. | |
2421 (progn | |
2422 (setq i (1+ i)) | |
2423 "[]")) | |
2424 (t "[")) | |
2425 (prog1 ; copy everything upto next `]'. | |
2426 (substring wildcard | |
2427 i | |
2428 (setq j (string-match | |
2429 "]" wildcard i))) | |
2430 (setq i (if j (1- j) (1- len))))))) | |
2431 ((eq ch ?.) "\\.") | |
2432 ((eq ch ?*) "[^\000]*") | |
2433 ((eq ch ?+) "\\+") | |
2434 ((eq ch ?^) "\\^") | |
2435 ((eq ch ?$) "\\$") | |
2436 ((eq ch ?\\) "\\\\") ; probably cannot happen... | |
2437 ((eq ch ??) "[^\000]") | |
2438 (t (char-to-string ch))))) | |
2439 (setq i (1+ i))))) | |
2440 ;; Shell wildcards should match the entire filename, | |
2441 ;; not its part. Make the regexp say so. | |
2442 (concat "\\`" result "\\'"))) | |
2443 | |
2376 (defconst list-directory-brief-switches | 2444 (defconst list-directory-brief-switches |
2377 (if (eq system-type 'vax-vms) "" "-CF") | 2445 (if (eq system-type 'vax-vms) "" "-CF") |
2378 "*Switches for list-directory to pass to `ls' for brief listing,") | 2446 "*Switches for list-directory to pass to `ls' for brief listing,") |
2379 | 2447 |
2380 (defconst list-directory-verbose-switches | 2448 (defconst list-directory-verbose-switches |