551 |
If SUFFIXES is non-nil, it should be a list of suffixes to append to |
If SUFFIXES is non-nil, it should be a list of suffixes to append to |
552 |
file name when searching. If SUFFIXES is nil, it is equivalent to '(\"\"). |
file name when searching. If SUFFIXES is nil, it is equivalent to '(\"\"). |
553 |
If non-nil, PREDICATE is used instead of `file-readable-p'. |
If non-nil, PREDICATE is used instead of `file-readable-p'. |
554 |
PREDICATE can also be an integer to pass to the access(2) function, |
PREDICATE can also be an integer to pass to the `access' system call, |
555 |
in which case file-name-handlers are ignored (this use is deprecated). |
in which case file-name handlers are ignored. This usage is deprecated. |
556 |
For compatibility with XEmacs, PREDICATE can also be a symbol among |
|
557 |
`executable', `readable', `writable', or `exists' or a list of one |
For compatibility, PREDICATE can also be one of the symbols |
558 |
of those symbols." |
`executable', `readable', `writable', or `exists', or a list of |
559 |
|
one or more of those symbols." |
560 |
(if (and predicate (symbolp predicate) (not (functionp predicate))) |
(if (and predicate (symbolp predicate) (not (functionp predicate))) |
561 |
(setq predicate (list predicate))) |
(setq predicate (list predicate))) |
562 |
(when (and (consp predicate) (not (functionp predicate))) |
(when (and (consp predicate) (not (functionp predicate))) |
769 |
(pop-to-buffer buffer t norecord) |
(pop-to-buffer buffer t norecord) |
770 |
(raise-frame (window-frame (selected-window))))) |
(raise-frame (window-frame (selected-window))))) |
771 |
|
|
772 |
|
(defun find-file-read-args (prompt) |
773 |
|
(list (let ((find-file-default |
774 |
|
(and buffer-file-name |
775 |
|
(abbreviate-file-name buffer-file-name))) |
776 |
|
(minibuffer-setup-hook |
777 |
|
'((lambda () |
778 |
|
(setq minibuffer-default find-file-default) |
779 |
|
;; Clear out this hook so it does not interfere |
780 |
|
;; with any recursive minibuffer usage. |
781 |
|
(setq minibuffer-setup-hook nil))))) |
782 |
|
(read-file-name prompt nil default-directory)) |
783 |
|
current-prefix-arg)) |
784 |
|
|
785 |
(defun find-file (filename &optional wildcards) |
(defun find-file (filename &optional wildcards) |
786 |
"Edit file FILENAME. |
"Edit file FILENAME. |
787 |
Switch to a buffer visiting file FILENAME, |
Switch to a buffer visiting file FILENAME, |
788 |
creating one if none already exists. |
creating one if none already exists. |
789 |
|
Interactively, the default if you just type RET is the current directory, |
790 |
|
but the visited file name is available through the minibuffer history: |
791 |
|
type M-n to pull it into the minibuffer. |
792 |
|
|
793 |
Interactively, or if WILDCARDS is non-nil in a call from Lisp, |
Interactively, or if WILDCARDS is non-nil in a call from Lisp, |
794 |
expand wildcards (if any) and visit multiple files. Wildcard expansion |
expand wildcards (if any) and visit multiple files. Wildcard expansion |
795 |
can be suppressed by setting `find-file-wildcards'." |
can be suppressed by setting `find-file-wildcards'." |
796 |
(interactive "FFind file: \np") |
(interactive |
797 |
|
(find-file-read-args "Find file: ")) |
798 |
(let ((value (find-file-noselect filename nil nil wildcards))) |
(let ((value (find-file-noselect filename nil nil wildcards))) |
799 |
(if (listp value) |
(if (listp value) |
800 |
(mapcar 'switch-to-buffer (nreverse value)) |
(mapcar 'switch-to-buffer (nreverse value)) |
804 |
"Edit file FILENAME, in another window. |
"Edit file FILENAME, in another window. |
805 |
May create a new window, or reuse an existing one. |
May create a new window, or reuse an existing one. |
806 |
See the function `display-buffer'. |
See the function `display-buffer'. |
807 |
|
|
808 |
|
Interactively, the default if you just type RET is the current directory, |
809 |
|
but the visited file name is available through the minibuffer history: |
810 |
|
type M-n to pull it into the minibuffer. |
811 |
|
|
812 |
Interactively, or if WILDCARDS is non-nil in a call from Lisp, |
Interactively, or if WILDCARDS is non-nil in a call from Lisp, |
813 |
expand wildcards (if any) and visit multiple files." |
expand wildcards (if any) and visit multiple files." |
814 |
(interactive "FFind file in other window: \np") |
(interactive (find-file-read-args "FFind file in other window: ")) |
815 |
(let ((value (find-file-noselect filename nil nil wildcards))) |
(let ((value (find-file-noselect filename nil nil wildcards))) |
816 |
(if (listp value) |
(if (listp value) |
817 |
(progn |
(progn |
824 |
"Edit file FILENAME, in another frame. |
"Edit file FILENAME, in another frame. |
825 |
May create a new frame, or reuse an existing one. |
May create a new frame, or reuse an existing one. |
826 |
See the function `display-buffer'. |
See the function `display-buffer'. |
827 |
|
|
828 |
|
Interactively, the default if you just type RET is the current directory, |
829 |
|
but the visited file name is available through the minibuffer history: |
830 |
|
type M-n to pull it into the minibuffer. |
831 |
|
|
832 |
Interactively, or if WILDCARDS is non-nil in a call from Lisp, |
Interactively, or if WILDCARDS is non-nil in a call from Lisp, |
833 |
expand wildcards (if any) and visit multiple files." |
expand wildcards (if any) and visit multiple files." |
834 |
(interactive "FFind file in other frame: \np") |
(interactive (find-file-read-args "FFind file in other frame: ")) |
835 |
(let ((value (find-file-noselect filename nil nil wildcards))) |
(let ((value (find-file-noselect filename nil nil wildcards))) |
836 |
(if (listp value) |
(if (listp value) |
837 |
(progn |
(progn |
842 |
|
|
843 |
(defun find-file-read-only (filename &optional wildcards) |
(defun find-file-read-only (filename &optional wildcards) |
844 |
"Edit file FILENAME but don't allow changes. |
"Edit file FILENAME but don't allow changes. |
845 |
Like `find-file' but marks buffer as read-only. |
Like \\[find-file] but marks buffer as read-only. |
846 |
Use \\[toggle-read-only] to permit editing." |
Use \\[toggle-read-only] to permit editing." |
847 |
(interactive "fFind file read-only: \np") |
(interactive (find-file-read-args "fFind file read-only: ")) |
848 |
(find-file filename wildcards) |
(find-file filename wildcards) |
849 |
(toggle-read-only 1) |
(toggle-read-only 1) |
850 |
(current-buffer)) |
(current-buffer)) |
853 |
"Edit file FILENAME in another window but don't allow changes. |
"Edit file FILENAME in another window but don't allow changes. |
854 |
Like \\[find-file-other-window] but marks buffer as read-only. |
Like \\[find-file-other-window] but marks buffer as read-only. |
855 |
Use \\[toggle-read-only] to permit editing." |
Use \\[toggle-read-only] to permit editing." |
856 |
(interactive "fFind file read-only other window: \np") |
(interactive (find-file-read-args "fFind file read-only other window: ")) |
857 |
(find-file-other-window filename wildcards) |
(find-file-other-window filename wildcards) |
858 |
(toggle-read-only 1) |
(toggle-read-only 1) |
859 |
(current-buffer)) |
(current-buffer)) |
862 |
"Edit file FILENAME in another frame but don't allow changes. |
"Edit file FILENAME in another frame but don't allow changes. |
863 |
Like \\[find-file-other-frame] but marks buffer as read-only. |
Like \\[find-file-other-frame] but marks buffer as read-only. |
864 |
Use \\[toggle-read-only] to permit editing." |
Use \\[toggle-read-only] to permit editing." |
865 |
(interactive "fFind file read-only other frame: \np") |
(interactive (find-file-read-args "fFind file read-only other frame: ")) |
866 |
(find-file-other-frame filename wildcards) |
(find-file-other-frame filename wildcards) |
867 |
(toggle-read-only 1) |
(toggle-read-only 1) |
868 |
(current-buffer)) |
(current-buffer)) |