Mercurial > emacs
comparison lisp/files.el @ 44279:7f0854961eb4
(file-expand-wildcards): Use save-match-data.
(format-alist): Mark as risky.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 01 Apr 2002 03:45:11 +0000 |
parents | 166f03d282d7 |
children | 974edbcc8ecd |
comparison
equal
deleted
inserted
replaced
44278:2f0122b0b947 | 44279:7f0854961eb4 |
---|---|
1923 (put 'frame-title-format 'risky-local-variable t) | 1923 (put 'frame-title-format 'risky-local-variable t) |
1924 (put 'global-mode-string 'risky-local-variable t) | 1924 (put 'global-mode-string 'risky-local-variable t) |
1925 (put 'header-line-format 'risky-local-variable t) | 1925 (put 'header-line-format 'risky-local-variable t) |
1926 (put 'icon-title-format 'risky-local-variable t) | 1926 (put 'icon-title-format 'risky-local-variable t) |
1927 (put 'input-method-alist 'risky-local-variable t) | 1927 (put 'input-method-alist 'risky-local-variable t) |
1928 (put 'format-alist 'risky-local-variable t) | |
1928 (put 'vc-mode 'risky-local-variable t) | 1929 (put 'vc-mode 'risky-local-variable t) |
1929 (put 'imenu-generic-expression 'risky-local-variable t) | 1930 (put 'imenu-generic-expression 'risky-local-variable t) |
1930 (put 'imenu-index-alist 'risky-local-variable t) | 1931 (put 'imenu-index-alist 'risky-local-variable t) |
1931 (put 'standard-input 'risky-local-variable t) | 1932 (put 'standard-input 'risky-local-variable t) |
1932 (put 'standard-output 'risky-local-variable t) | 1933 (put 'standard-output 'risky-local-variable t) |
3516 | 3517 |
3517 If PATTERN is written as a relative file name, it is interpreted | 3518 If PATTERN is written as a relative file name, it is interpreted |
3518 relative to the current default directory, `default-directory'. | 3519 relative to the current default directory, `default-directory'. |
3519 The file names returned are normally also relative to the current | 3520 The file names returned are normally also relative to the current |
3520 default directory. However, if FULL is non-nil, they are absolute." | 3521 default directory. However, if FULL is non-nil, they are absolute." |
3521 (let* ((nondir (file-name-nondirectory pattern)) | 3522 (save-match-data |
3522 (dirpart (file-name-directory pattern)) | 3523 (let* ((nondir (file-name-nondirectory pattern)) |
3523 ;; A list of all dirs that DIRPART specifies. | 3524 (dirpart (file-name-directory pattern)) |
3524 ;; This can be more than one dir | 3525 ;; A list of all dirs that DIRPART specifies. |
3525 ;; if DIRPART contains wildcards. | 3526 ;; This can be more than one dir |
3526 (dirs (if (and dirpart (string-match "[[*?]" dirpart)) | 3527 ;; if DIRPART contains wildcards. |
3527 (mapcar 'file-name-as-directory | 3528 (dirs (if (and dirpart (string-match "[[*?]" dirpart)) |
3528 (file-expand-wildcards (directory-file-name dirpart))) | 3529 (mapcar 'file-name-as-directory |
3529 (list dirpart))) | 3530 (file-expand-wildcards (directory-file-name dirpart))) |
3530 contents) | 3531 (list dirpart))) |
3531 (while dirs | 3532 contents) |
3532 (when (or (null (car dirs)) ; Possible if DIRPART is not wild. | 3533 (while dirs |
3533 (file-directory-p (directory-file-name (car dirs)))) | 3534 (when (or (null (car dirs)) ; Possible if DIRPART is not wild. |
3534 (let ((this-dir-contents | 3535 (file-directory-p (directory-file-name (car dirs)))) |
3535 ;; Filter out "." and ".." | 3536 (let ((this-dir-contents |
3536 (delq nil | 3537 ;; Filter out "." and ".." |
3537 (mapcar #'(lambda (name) | 3538 (delq nil |
3538 (unless (string-match "\\`\\.\\.?\\'" | 3539 (mapcar #'(lambda (name) |
3539 (file-name-nondirectory name)) | 3540 (unless (string-match "\\`\\.\\.?\\'" |
3540 name)) | 3541 (file-name-nondirectory name)) |
3541 (directory-files (or (car dirs) ".") full | 3542 name)) |
3542 (wildcard-to-regexp nondir)))))) | 3543 (directory-files (or (car dirs) ".") full |
3543 (setq contents | 3544 (wildcard-to-regexp nondir)))))) |
3544 (nconc | 3545 (setq contents |
3545 (if (and (car dirs) (not full)) | 3546 (nconc |
3546 (mapcar (function (lambda (name) (concat (car dirs) name))) | 3547 (if (and (car dirs) (not full)) |
3547 this-dir-contents) | 3548 (mapcar (function (lambda (name) (concat (car dirs) name))) |
3548 this-dir-contents) | 3549 this-dir-contents) |
3549 contents)))) | 3550 this-dir-contents) |
3550 (setq dirs (cdr dirs))) | 3551 contents)))) |
3551 contents)) | 3552 (setq dirs (cdr dirs))) |
3553 contents))) | |
3552 | 3554 |
3553 (defun list-directory (dirname &optional verbose) | 3555 (defun list-directory (dirname &optional verbose) |
3554 "Display a list of files in or matching DIRNAME, a la `ls'. | 3556 "Display a list of files in or matching DIRNAME, a la `ls'. |
3555 DIRNAME is globbed by the shell if necessary. | 3557 DIRNAME is globbed by the shell if necessary. |
3556 Prefix arg (second arg if noninteractive) means supply -l switch to `ls'. | 3558 Prefix arg (second arg if noninteractive) means supply -l switch to `ls'. |