From: Juri Linkov <juri@jurta.org>
Subject: Re: find-alternate-file can't handle wildcards
Date: Wed, 08 Dec 2004 04:07:07 +0200 [thread overview]
Message-ID: <87is7dtrlb.fsf@jurta.org> (raw)
In-Reply-To: <87zn0wa1r8.fsf@jurta.org> (Juri Linkov's message of "Thu, 02 Dec 2004 22:22:52 +0200")
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/
next prev parent reply other threads:[~2004-12-08 2:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.2265.1101762244.27204.bug-gnu-emacs@gnu.org>
2004-12-01 18:19 ` find-alternate-file can't handle wildcards Jari Aalto
2004-12-02 20:22 ` Juri Linkov
2004-12-08 2:07 ` Juri Linkov [this message]
2004-12-02 17:51 ` Kevin Rodgers
2004-11-29 0:43 Dan Jacobson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87is7dtrlb.fsf@jurta.org \
--to=juri@jurta.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.