Mercurial > emacs
comparison lisp/dired-aux.el @ 17205:a886f419a946
(dired-fun-in-all-buffers): New arg FILE. Don't operate on buffers
whose wildcard pattern does not accept FILE.
All callers changed.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 22 Mar 1997 03:39:39 +0000 |
parents | 91cf1da75ccd |
children | 5dd977f51652 |
comparison
equal
deleted
inserted
replaced
17204:2c684820d196 | 17205:a886f419a946 |
---|---|
760 ;; Replace space by old marker without moving point. | 760 ;; Replace space by old marker without moving point. |
761 ;; Faster than goto+insdel inside a save-excursion? | 761 ;; Faster than goto+insdel inside a save-excursion? |
762 (subst-char-in-region opoint (1+ opoint) ?\040 char)))) | 762 (subst-char-in-region opoint (1+ opoint) ?\040 char)))) |
763 (dired-move-to-filename)) | 763 (dired-move-to-filename)) |
764 | 764 |
765 (defun dired-fun-in-all-buffers (directory fun &rest args) | 765 (defun dired-fun-in-all-buffers (directory file fun &rest args) |
766 ;; In all buffers dired'ing DIRECTORY, run FUN with ARGS. | 766 ;; In all buffers dired'ing DIRECTORY, run FUN with ARGS. |
767 ;; If the buffer has a wildcard pattern, check that it matches FILE. | |
768 ;; (FILE does not include a directory component.) | |
769 ;; FILE may be nil, in which case ignore it. | |
767 ;; Return list of buffers where FUN succeeded (i.e., returned non-nil). | 770 ;; Return list of buffers where FUN succeeded (i.e., returned non-nil). |
768 (let ((buf-list (dired-buffers-for-dir (expand-file-name directory))) | 771 (let ((buf-list (dired-buffers-for-dir (expand-file-name directory) |
772 file)) | |
769 (obuf (current-buffer)) | 773 (obuf (current-buffer)) |
770 buf success-list) | 774 buf success-list) |
771 (while buf-list | 775 (while buf-list |
772 (setq buf (car buf-list) | 776 (setq buf (car buf-list) |
773 buf-list (cdr buf-list)) | 777 buf-list (cdr buf-list)) |
780 success-list)) | 784 success-list)) |
781 | 785 |
782 ;;;###autoload | 786 ;;;###autoload |
783 (defun dired-add-file (filename &optional marker-char) | 787 (defun dired-add-file (filename &optional marker-char) |
784 (dired-fun-in-all-buffers | 788 (dired-fun-in-all-buffers |
785 (file-name-directory filename) | 789 (file-name-directory filename) (file-name-nondirectory filename) |
786 (function dired-add-entry) filename marker-char)) | 790 (function dired-add-entry) filename marker-char)) |
787 | 791 |
788 (defun dired-add-entry (filename &optional marker-char) | 792 (defun dired-add-entry (filename &optional marker-char) |
789 ;; Add a new entry for FILENAME, optionally marking it | 793 ;; Add a new entry for FILENAME, optionally marking it |
790 ;; with MARKER-CHAR (a character, else dired-marker-char is used). | 794 ;; with MARKER-CHAR (a character, else dired-marker-char is used). |
885 (point))) | 889 (point))) |
886 | 890 |
887 ;;;###autoload | 891 ;;;###autoload |
888 (defun dired-remove-file (file) | 892 (defun dired-remove-file (file) |
889 (dired-fun-in-all-buffers | 893 (dired-fun-in-all-buffers |
890 (file-name-directory file) (function dired-remove-entry) file)) | 894 (file-name-directory file) (file-name-nondirectory file) |
895 (function dired-remove-entry) file)) | |
891 | 896 |
892 (defun dired-remove-entry (file) | 897 (defun dired-remove-entry (file) |
893 (save-excursion | 898 (save-excursion |
894 (and (dired-goto-file file) | 899 (and (dired-goto-file file) |
895 (let (buffer-read-only) | 900 (let (buffer-read-only) |
897 (save-excursion (forward-line 1) (point))))))) | 902 (save-excursion (forward-line 1) (point))))))) |
898 | 903 |
899 ;;;###autoload | 904 ;;;###autoload |
900 (defun dired-relist-file (file) | 905 (defun dired-relist-file (file) |
901 (dired-fun-in-all-buffers (file-name-directory file) | 906 (dired-fun-in-all-buffers (file-name-directory file) |
907 (file-name-nondirectory file) | |
902 (function dired-relist-entry) file)) | 908 (function dired-relist-entry) file)) |
903 | 909 |
904 (defun dired-relist-entry (file) | 910 (defun dired-relist-entry (file) |
905 ;; Relist the line for FILE, or just add it if it did not exist. | 911 ;; Relist the line for FILE, or just add it if it did not exist. |
906 ;; FILE must be an absolute pathname. | 912 ;; FILE must be an absolute pathname. |
958 (dired-rename-subdir from to)) | 964 (dired-rename-subdir from to)) |
959 | 965 |
960 (defun dired-rename-subdir (from-dir to-dir) | 966 (defun dired-rename-subdir (from-dir to-dir) |
961 (setq from-dir (file-name-as-directory from-dir) | 967 (setq from-dir (file-name-as-directory from-dir) |
962 to-dir (file-name-as-directory to-dir)) | 968 to-dir (file-name-as-directory to-dir)) |
963 (dired-fun-in-all-buffers from-dir | 969 (dired-fun-in-all-buffers from-dir nil |
964 (function dired-rename-subdir-1) from-dir to-dir) | 970 (function dired-rename-subdir-1) from-dir to-dir) |
965 ;; Update visited file name of all affected buffers | 971 ;; Update visited file name of all affected buffers |
966 (let ((expanded-from-dir (expand-file-name from-dir)) | 972 (let ((expanded-from-dir (expand-file-name from-dir)) |
967 (blist (buffer-list))) | 973 (blist (buffer-list))) |
968 (while blist | 974 (while blist |