* find-alternate-file can't handle wildcards
@ 2004-11-29 0:43 Dan Jacobson
0 siblings, 0 replies; 5+ messages in thread
From: Dan Jacobson @ 2004-11-29 0:43 UTC (permalink / raw)
Make (find-alternate-file "/usr/share/doc/exim4-doc-*") handle wildcards
just like dired! Currently: File not found and directory write-protected
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: find-alternate-file can't handle wildcards
[not found] <mailman.2265.1101762244.27204.bug-gnu-emacs@gnu.org>
@ 2004-12-01 18:19 ` Jari Aalto
2004-12-02 20:22 ` Juri Linkov
2004-12-02 17:51 ` Kevin Rodgers
1 sibling, 1 reply; 5+ messages in thread
From: Jari Aalto @ 2004-12-01 18:19 UTC (permalink / raw)
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
It's not programmed to do any of that. See C-h f.
find-alternate-file is an interactive compiled Lisp function in `files'.
(find-alternate-file FILENAME)
Find file FILENAME, select its buffer, kill previous buffer.
If the current buffer now contains an empty file that you just visited
(presumably by mistake), use this command to visit the file you really want.
C-x C-v is used to replace the _current_ file, not to replace current
file with multiple files.
Jari
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: find-alternate-file can't handle wildcards
[not found] <mailman.2265.1101762244.27204.bug-gnu-emacs@gnu.org>
2004-12-01 18:19 ` Jari Aalto
@ 2004-12-02 17:51 ` Kevin Rodgers
1 sibling, 0 replies; 5+ messages in thread
From: Kevin Rodgers @ 2004-12-02 17:51 UTC (permalink / raw)
Dan Jacobson wrote:
> Make (find-alternate-file "/usr/share/doc/exim4-doc-*") handle wildcards
> just like dired! Currently: File not found and directory write-protected
2004-12-02 Kevin Rodgers <ihs_4664@yahoo.com>
* files.el (find-alternate-file, find-alternate-file-other-window):
Accept an optional WILDCARDS argument, describe it in the doc
string, bind it when called interactively, and pass it on to the
file-visiting functions.
*** emacs-21.3/lisp/files.el~ Thu Oct 24 07:07:56 2002
--- emacs-21.3/lisp/files.el Thu Dec 2 10:42:36 2004
***************
*** 794,802 ****
(toggle-read-only 1)
(current-buffer))
! (defun find-alternate-file-other-window (filename)
"Find file FILENAME as a replacement for the file in the next window.
! This command does not select that window."
(interactive
(save-selected-window
(other-window 1)
--- 794,804 ----
(toggle-read-only 1)
(current-buffer))
! (defun find-alternate-file-other-window (filename &optional wildcards)
"Find file FILENAME as a replacement for the file in the next window.
! This command does not select that window.
! Interactively, or if WILDCARDS is non-nil in a call from Lisp,
! expand wildcards (if any) and visit multiple files."
(interactive
(save-selected-window
(other-window 1)
***************
*** 807,823 ****
(setq file-name (file-name-nondirectory file)
file-dir (file-name-directory file)))
(list (read-file-name
! "Find alternate file: " file-dir nil nil file-name)))))
(if (one-window-p)
! (find-file-other-window filename)
(save-selected-window
(other-window 1)
! (find-alternate-file filename))))
! (defun find-alternate-file (filename)
"Find file FILENAME, select its buffer, kill previous buffer.
If the current buffer now contains an empty file that you just visited
! \(presumably by mistake), use this command to visit the file you
really want."
(interactive
(let ((file buffer-file-name)
(file-name nil)
--- 809,828 ----
(setq file-name (file-name-nondirectory file)
file-dir (file-name-directory file)))
(list (read-file-name
! "Find alternate file: " file-dir nil nil file-name)
! (prefix-numeric-value current-prefix-arg)))))
(if (one-window-p)
! (find-file-other-window filename wildcards)
(save-selected-window
(other-window 1)
! (find-alternate-file filename wildcards))))
! (defun find-alternate-file (filename &optional wildcards)
"Find file FILENAME, select its buffer, kill previous buffer.
If the current buffer now contains an empty file that you just visited
! \(presumably by mistake), use this command to visit the file you
really want.
! Interactively, or if WILDCARDS is non-nil in a call from Lisp,
! expand wildcards (if any) and visit multiple files."
(interactive
(let ((file buffer-file-name)
(file-name nil)
***************
*** 826,832 ****
(setq file-name (file-name-nondirectory file)
file-dir (file-name-directory file)))
(list (read-file-name
! "Find alternate file: " file-dir nil nil file-name))))
(and (buffer-modified-p) (buffer-file-name)
;; (not buffer-read-only)
(not (yes-or-no-p (format "Buffer %s is modified; kill anyway? "
--- 831,838 ----
(setq file-name (file-name-nondirectory file)
file-dir (file-name-directory file)))
(list (read-file-name
! "Find alternate file: " file-dir nil nil file-name)
! (prefix-numeric-value current-prefix-arg))))
(and (buffer-modified-p) (buffer-file-name)
;; (not buffer-read-only)
(not (yes-or-no-p (format "Buffer %s is modified; kill anyway? "
***************
*** 846,852 ****
(setq buffer-file-name nil)
(setq buffer-file-number nil)
(setq buffer-file-truename nil)
! (find-file filename))
(cond ((eq obuf (current-buffer))
(setq buffer-file-name ofile)
(setq buffer-file-number onum)
--- 852,858 ----
(setq buffer-file-name nil)
(setq buffer-file-number nil)
(setq buffer-file-truename nil)
! (find-file filename wildcards))
(cond ((eq obuf (current-buffer))
(setq buffer-file-name ofile)
(setq buffer-file-number onum)
--
Kevin Rodgers
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: find-alternate-file can't handle wildcards
2004-12-01 18:19 ` Jari Aalto
@ 2004-12-02 20:22 ` Juri Linkov
2004-12-08 2:07 ` Juri Linkov
0 siblings, 1 reply; 5+ messages in thread
From: Juri Linkov @ 2004-12-02 20:22 UTC (permalink / raw)
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.
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: find-alternate-file can't handle wildcards
2004-12-02 20:22 ` Juri Linkov
@ 2004-12-08 2:07 ` Juri Linkov
0 siblings, 0 replies; 5+ messages in thread
From: Juri Linkov @ 2004-12-08 2:07 UTC (permalink / raw)
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/
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2004-12-08 2:07 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-29 0:43 find-alternate-file can't handle wildcards Dan Jacobson
[not found] <mailman.2265.1101762244.27204.bug-gnu-emacs@gnu.org>
2004-12-01 18:19 ` Jari Aalto
2004-12-02 20:22 ` Juri Linkov
2004-12-08 2:07 ` Juri Linkov
2004-12-02 17:51 ` Kevin Rodgers
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.