[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: find-alternate-file can't handle wildcards
From: |
Juri Linkov |
Subject: |
Re: find-alternate-file can't handle wildcards |
Date: |
Wed, 08 Dec 2004 04:07:07 +0200 |
User-agent: |
Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux) |
Juri Linkov <juri@jurta.org> writes:
> Jari Aalto <jari.aalto@cante.net> writes:
>> Dan Jacobson <jidanni@jidanni.org> writes:
>> | Make (find-alternate-file "/usr/share/doc/exim4-doc-*") handle wildcards
>> | just like dired! Currently: File not found and directory write-protected
>>
>> C-x C-v is used to replace the _current_ file, not to replace current
>> file with multiple files.
>
> This is how it currently works. But I see no reason not to allow
> users to replace the current file with multiple files that match
> wildcards.
I noticed also that three commands find-file-read-only-* already have
`wildcards' argument which is completely disabled by the prompt and by
the error message that checks for file existence. I think it's better
to change these commands to allow them to open multiple files in
read-only mode:
Index: lisp/files.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/files.el,v
retrieving revision 1.730
diff -u -r1.730 files.el
--- lisp/files.el 1 Dec 2004 09:47:18 -0000 1.730
+++ lisp/files.el 8 Dec 2004 02:57:03 -0000
@@ -956,7 +955,7 @@
(progn
(setq value (nreverse value))
(switch-to-buffer-other-window (car value))
- (mapcar 'switch-to-buffer (cdr value)))
+ (cons (car value) (mapcar 'switch-to-buffer (cdr value))))
(switch-to-buffer-other-window value))))
(defun find-file-other-frame (filename &optional wildcards)
@@ -976,7 +975,7 @@
(progn
(setq value (nreverse value))
(switch-to-buffer-other-frame (car value))
- (mapcar 'switch-to-buffer (cdr value)))
+ (cons (car value) (mapcar 'switch-to-buffer (cdr value))))
(switch-to-buffer-other-frame value))))
(defun find-file-existing (filename &optional wildcards)
@@ -991,35 +990,53 @@
"Edit file FILENAME but don't allow changes.
Like \\[find-file] but marks buffer as read-only.
Use \\[toggle-read-only] to permit editing."
- (interactive (find-file-read-args "Find file read-only: " t))
- (unless (file-exists-p filename) (error "%s does not exist" filename))
- (find-file filename wildcards)
- (toggle-read-only 1)
- (current-buffer))
+ (interactive (find-file-read-args "Find file read-only: " nil))
+ (unless (or (and wildcards find-file-wildcards
+ (not (string-match "\\`/:" filename))
+ (string-match "[[*?]" filename))
+ (file-exists-p filename))
+ (error "%s does not exist" filename))
+ (let ((value (find-file filename wildcards)))
+ (mapc (lambda (b) (with-current-buffer b (toggle-read-only 1)))
+ (if (listp value) value (list value)))
+ value))
(defun find-file-read-only-other-window (filename &optional wildcards)
"Edit file FILENAME in another window but don't allow changes.
Like \\[find-file-other-window] but marks buffer as read-only.
Use \\[toggle-read-only] to permit editing."
- (interactive (find-file-read-args "Find file read-only other window: " t))
- (unless (file-exists-p filename) (error "%s does not exist" filename))
- (find-file-other-window filename wildcards)
- (toggle-read-only 1)
- (current-buffer))
+ (interactive (find-file-read-args "Find file read-only other window: " nil))
+ (unless (or (and wildcards find-file-wildcards
+ (not (string-match "\\`/:" filename))
+ (string-match "[[*?]" filename))
+ (file-exists-p filename))
+ (error "%s does not exist" filename))
+ (let ((value (find-file-other-window filename wildcards)))
+ (mapc (lambda (b) (with-current-buffer b (toggle-read-only 1)))
+ (if (listp value) value (list value)))
+ value))
(defun find-file-read-only-other-frame (filename &optional wildcards)
"Edit file FILENAME in another frame but don't allow changes.
Like \\[find-file-other-frame] but marks buffer as read-only.
Use \\[toggle-read-only] to permit editing."
- (interactive (find-file-read-args "Find file read-only other frame: " t))
- (unless (file-exists-p filename) (error "%s does not exist" filename))
- (find-file-other-frame filename wildcards)
- (toggle-read-only 1)
- (current-buffer))
+ (interactive (find-file-read-args "Find file read-only other frame: " nil))
+ (unless (or (and wildcards find-file-wildcards
+ (not (string-match "\\`/:" filename))
+ (string-match "[[*?]" filename))
+ (file-exists-p filename))
+ (error "%s does not exist" filename))
+ (let ((value (find-file-other-frame filename wildcards)))
+ (mapc (lambda (b) (with-current-buffer b (toggle-read-only 1)))
+ (if (listp value) value (list value)))
+ value))
(defun find-alternate-file-other-window (filename)
"Find file FILENAME as a replacement for the file in the next window.
--
Juri Linkov
http://www.jurta.org/emacs/