diff options
| author | Juri Linkov | 2004-12-13 05:08:00 +0000 |
|---|---|---|
| committer | Juri Linkov | 2004-12-13 05:08:00 +0000 |
| commit | a9d6a617af3d615beb6b6174b3601a4325e3c986 (patch) | |
| tree | f06b745e8096739c9875893b270fadd328ffaa11 | |
| parent | 6a2067b24767992264b0dbb4584b7c190e7e3b42 (diff) | |
| download | emacs-a9d6a617af3d615beb6b6174b3601a4325e3c986.tar.gz emacs-a9d6a617af3d615beb6b6174b3601a4325e3c986.zip | |
(find-file-other-window, find-file-other-frame):
Add the first buffer to the returned value to return the complete
list of all visited buffers.
(find-file-read-only, find-file-read-only-other-window)
(find-file-read-only-other-frame): Use nil for `mustmatch' arg of
`find-file-read-args'. Signal an error about non-existent file
only if file name doesn't contain wildcards. Toggle read-only in
all visited buffers.
(find-alternate-file, find-alternate-file-other-window):
Add optional arg `wildcards'. Doc fix. Set `wildcards' to t when
called interactively. Pass arg `wildcards' to other functions.
(find-file-noselect): Doc fix.
| -rw-r--r-- | lisp/files.el | 88 |
1 files changed, 55 insertions, 33 deletions
diff --git a/lisp/files.el b/lisp/files.el index e80e8fc766b..37de166d522 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -932,8 +932,7 @@ suppress wildcard expansion by setting `find-file-wildcards'. | |||
| 932 | 932 | ||
| 933 | To visit a file without any kind of conversion and without | 933 | To visit a file without any kind of conversion and without |
| 934 | automatically choosing a major mode, use \\[find-file-literally]." | 934 | automatically choosing a major mode, use \\[find-file-literally]." |
| 935 | (interactive | 935 | (interactive (find-file-read-args "Find file: " nil)) |
| 936 | (find-file-read-args "Find file: " nil)) | ||
| 937 | (let ((value (find-file-noselect filename nil nil wildcards))) | 936 | (let ((value (find-file-noselect filename nil nil wildcards))) |
| 938 | (if (listp value) | 937 | (if (listp value) |
| 939 | (mapcar 'switch-to-buffer (nreverse value)) | 938 | (mapcar 'switch-to-buffer (nreverse value)) |
| @@ -955,8 +954,8 @@ expand wildcards (if any) and visit multiple files." | |||
| 955 | (if (listp value) | 954 | (if (listp value) |
| 956 | (progn | 955 | (progn |
| 957 | (setq value (nreverse value)) | 956 | (setq value (nreverse value)) |
| 958 | (switch-to-buffer-other-window (car value)) | 957 | (cons (switch-to-buffer-other-window (car value)) |
| 959 | (mapcar 'switch-to-buffer (cdr value))) | 958 | (mapcar 'switch-to-buffer (cdr value)))) |
| 960 | (switch-to-buffer-other-window value)))) | 959 | (switch-to-buffer-other-window value)))) |
| 961 | 960 | ||
| 962 | (defun find-file-other-frame (filename &optional wildcards) | 961 | (defun find-file-other-frame (filename &optional wildcards) |
| @@ -975,8 +974,8 @@ expand wildcards (if any) and visit multiple files." | |||
| 975 | (if (listp value) | 974 | (if (listp value) |
| 976 | (progn | 975 | (progn |
| 977 | (setq value (nreverse value)) | 976 | (setq value (nreverse value)) |
| 978 | (switch-to-buffer-other-frame (car value)) | 977 | (cons (switch-to-buffer-other-frame (car value)) |
| 979 | (mapcar 'switch-to-buffer (cdr value))) | 978 | (mapcar 'switch-to-buffer (cdr value)))) |
| 980 | (switch-to-buffer-other-frame value)))) | 979 | (switch-to-buffer-other-frame value)))) |
| 981 | 980 | ||
| 982 | (defun find-file-existing (filename &optional wildcards) | 981 | (defun find-file-existing (filename &optional wildcards) |
| @@ -991,35 +990,53 @@ Like \\[find-file] but only allow files that exists." | |||
| 991 | "Edit file FILENAME but don't allow changes. | 990 | "Edit file FILENAME but don't allow changes. |
| 992 | Like \\[find-file] but marks buffer as read-only. | 991 | Like \\[find-file] but marks buffer as read-only. |
| 993 | Use \\[toggle-read-only] to permit editing." | 992 | Use \\[toggle-read-only] to permit editing." |
| 994 | (interactive (find-file-read-args "Find file read-only: " t)) | 993 | (interactive (find-file-read-args "Find file read-only: " nil)) |
| 995 | (unless (file-exists-p filename) (error "%s does not exist" filename)) | 994 | (unless (or (and wildcards find-file-wildcards |
| 996 | (find-file filename wildcards) | 995 | (not (string-match "\\`/:" filename)) |
| 997 | (toggle-read-only 1) | 996 | (string-match "[[*?]" filename)) |
| 998 | (current-buffer)) | 997 | (file-exists-p filename)) |
| 998 | (error "%s does not exist" filename)) | ||
| 999 | (let ((value (find-file filename wildcards))) | ||
| 1000 | (mapc (lambda (b) (with-current-buffer b (toggle-read-only 1))) | ||
| 1001 | (if (listp value) value (list value))) | ||
| 1002 | value)) | ||
| 999 | 1003 | ||
| 1000 | (defun find-file-read-only-other-window (filename &optional wildcards) | 1004 | (defun find-file-read-only-other-window (filename &optional wildcards) |
| 1001 | "Edit file FILENAME in another window but don't allow changes. | 1005 | "Edit file FILENAME in another window but don't allow changes. |
| 1002 | Like \\[find-file-other-window] but marks buffer as read-only. | 1006 | Like \\[find-file-other-window] but marks buffer as read-only. |
| 1003 | Use \\[toggle-read-only] to permit editing." | 1007 | Use \\[toggle-read-only] to permit editing." |
| 1004 | (interactive (find-file-read-args "Find file read-only other window: " t)) | 1008 | (interactive (find-file-read-args "Find file read-only other window: " nil)) |
| 1005 | (unless (file-exists-p filename) (error "%s does not exist" filename)) | 1009 | (unless (or (and wildcards find-file-wildcards |
| 1006 | (find-file-other-window filename wildcards) | 1010 | (not (string-match "\\`/:" filename)) |
| 1007 | (toggle-read-only 1) | 1011 | (string-match "[[*?]" filename)) |
| 1008 | (current-buffer)) | 1012 | (file-exists-p filename)) |
| 1013 | (error "%s does not exist" filename)) | ||
| 1014 | (let ((value (find-file-other-window filename wildcards))) | ||
| 1015 | (mapc (lambda (b) (with-current-buffer b (toggle-read-only 1))) | ||
| 1016 | (if (listp value) value (list value))) | ||
| 1017 | value)) | ||
| 1009 | 1018 | ||
| 1010 | (defun find-file-read-only-other-frame (filename &optional wildcards) | 1019 | (defun find-file-read-only-other-frame (filename &optional wildcards) |
| 1011 | "Edit file FILENAME in another frame but don't allow changes. | 1020 | "Edit file FILENAME in another frame but don't allow changes. |
| 1012 | Like \\[find-file-other-frame] but marks buffer as read-only. | 1021 | Like \\[find-file-other-frame] but marks buffer as read-only. |
| 1013 | Use \\[toggle-read-only] to permit editing." | 1022 | Use \\[toggle-read-only] to permit editing." |
| 1014 | (interactive (find-file-read-args "Find file read-only other frame: " t)) | 1023 | (interactive (find-file-read-args "Find file read-only other frame: " nil)) |
| 1015 | (unless (file-exists-p filename) (error "%s does not exist" filename)) | 1024 | (unless (or (and wildcards find-file-wildcards |
| 1016 | (find-file-other-frame filename wildcards) | 1025 | (not (string-match "\\`/:" filename)) |
| 1017 | (toggle-read-only 1) | 1026 | (string-match "[[*?]" filename)) |
| 1018 | (current-buffer)) | 1027 | (file-exists-p filename)) |
| 1019 | 1028 | (error "%s does not exist" filename)) | |
| 1020 | (defun find-alternate-file-other-window (filename) | 1029 | (let ((value (find-file-other-frame filename wildcards))) |
| 1030 | (mapc (lambda (b) (with-current-buffer b (toggle-read-only 1))) | ||
| 1031 | (if (listp value) value (list value))) | ||
| 1032 | value)) | ||
| 1033 | |||
| 1034 | (defun find-alternate-file-other-window (filename &optional wildcards) | ||
| 1021 | "Find file FILENAME as a replacement for the file in the next window. | 1035 | "Find file FILENAME as a replacement for the file in the next window. |
| 1022 | This command does not select that window." | 1036 | This command does not select that window. |
| 1037 | |||
| 1038 | Interactively, or if WILDCARDS is non-nil in a call from Lisp, | ||
| 1039 | expand wildcards (if any) and replace the file with multiple files." | ||
| 1023 | (interactive | 1040 | (interactive |
| 1024 | (save-selected-window | 1041 | (save-selected-window |
| 1025 | (other-window 1) | 1042 | (other-window 1) |
| @@ -1030,17 +1047,21 @@ This command does not select that window." | |||
| 1030 | (setq file-name (file-name-nondirectory file) | 1047 | (setq file-name (file-name-nondirectory file) |
| 1031 | file-dir (file-name-directory file))) | 1048 | file-dir (file-name-directory file))) |
| 1032 | (list (read-file-name | 1049 | (list (read-file-name |
| 1033 | "Find alternate file: " file-dir nil nil file-name))))) | 1050 | "Find alternate file: " file-dir nil nil file-name) |
| 1051 | t)))) | ||
| 1034 | (if (one-window-p) | 1052 | (if (one-window-p) |
| 1035 | (find-file-other-window filename) | 1053 | (find-file-other-window filename wildcards) |
| 1036 | (save-selected-window | 1054 | (save-selected-window |
| 1037 | (other-window 1) | 1055 | (other-window 1) |
| 1038 | (find-alternate-file filename)))) | 1056 | (find-alternate-file filename wildcards)))) |
| 1039 | 1057 | ||
| 1040 | (defun find-alternate-file (filename) | 1058 | (defun find-alternate-file (filename &optional wildcards) |
| 1041 | "Find file FILENAME, select its buffer, kill previous buffer. | 1059 | "Find file FILENAME, select its buffer, kill previous buffer. |
| 1042 | If the current buffer now contains an empty file that you just visited | 1060 | If the current buffer now contains an empty file that you just visited |
| 1043 | \(presumably by mistake), use this command to visit the file you really want." | 1061 | \(presumably by mistake), use this command to visit the file you really want. |
| 1062 | |||
| 1063 | Interactively, or if WILDCARDS is non-nil in a call from Lisp, | ||
| 1064 | expand wildcards (if any) and replace the file with multiple files." | ||
| 1044 | (interactive | 1065 | (interactive |
| 1045 | (let ((file buffer-file-name) | 1066 | (let ((file buffer-file-name) |
| 1046 | (file-name nil) | 1067 | (file-name nil) |
| @@ -1049,7 +1070,8 @@ If the current buffer now contains an empty file that you just visited | |||
| 1049 | (setq file-name (file-name-nondirectory file) | 1070 | (setq file-name (file-name-nondirectory file) |
| 1050 | file-dir (file-name-directory file))) | 1071 | file-dir (file-name-directory file))) |
| 1051 | (list (read-file-name | 1072 | (list (read-file-name |
| 1052 | "Find alternate file: " file-dir nil nil file-name)))) | 1073 | "Find alternate file: " file-dir nil nil file-name) |
| 1074 | t))) | ||
| 1053 | (unless (run-hook-with-args-until-failure 'kill-buffer-query-functions) | 1075 | (unless (run-hook-with-args-until-failure 'kill-buffer-query-functions) |
| 1054 | (error "Aborted")) | 1076 | (error "Aborted")) |
| 1055 | (when (and (buffer-modified-p) (buffer-file-name)) | 1077 | (when (and (buffer-modified-p) (buffer-file-name)) |
| @@ -1077,7 +1099,7 @@ If the current buffer now contains an empty file that you just visited | |||
| 1077 | (setq buffer-file-truename nil) | 1099 | (setq buffer-file-truename nil) |
| 1078 | ;; Likewise for dired buffers. | 1100 | ;; Likewise for dired buffers. |
| 1079 | (setq dired-directory nil) | 1101 | (setq dired-directory nil) |
| 1080 | (find-file filename)) | 1102 | (find-file filename wildcards)) |
| 1081 | (when (eq obuf (current-buffer)) | 1103 | (when (eq obuf (current-buffer)) |
| 1082 | ;; This executes if find-file gets an error | 1104 | ;; This executes if find-file gets an error |
| 1083 | ;; and does not really find anything. | 1105 | ;; and does not really find anything. |
| @@ -1247,8 +1269,8 @@ Optional first arg NOWARN non-nil means suppress any warning messages. | |||
| 1247 | Optional second arg RAWFILE non-nil means the file is read literally. | 1269 | Optional second arg RAWFILE non-nil means the file is read literally. |
| 1248 | Optional third arg WILDCARDS non-nil means do wildcard processing | 1270 | Optional third arg WILDCARDS non-nil means do wildcard processing |
| 1249 | and visit all the matching files. When wildcards are actually | 1271 | and visit all the matching files. When wildcards are actually |
| 1250 | used and expanded, the value is a list of buffers | 1272 | used and expanded, return a list of buffers that are visiting |
| 1251 | that are visiting the various files." | 1273 | the various files." |
| 1252 | (setq filename | 1274 | (setq filename |
| 1253 | (abbreviate-file-name | 1275 | (abbreviate-file-name |
| 1254 | (expand-file-name filename))) | 1276 | (expand-file-name filename))) |