Mercurial > emacs
comparison lisp/files.el @ 45361:031bafbd4f7a
(locate-file): Doc fix.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 19 May 2002 15:55:04 +0000 |
parents | dcc56f49b739 |
children | 1450fcbbad57 |
comparison
equal
deleted
inserted
replaced
45360:68f66e6dd200 | 45361:031bafbd4f7a |
---|---|
549 (defun locate-file (filename path &optional suffixes predicate) | 549 (defun locate-file (filename path &optional suffixes predicate) |
550 "Search for FILENAME through PATH. | 550 "Search for FILENAME through PATH. |
551 If SUFFIXES is non-nil, it should be a list of suffixes to append to | 551 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 '(\"\"). | 552 file name when searching. If SUFFIXES is nil, it is equivalent to '(\"\"). |
553 If non-nil, PREDICATE is used instead of `file-readable-p'. | 553 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, | 554 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). | 555 in which case file-name handlers are ignored. This usage is deprecated. |
556 For compatibility with XEmacs, PREDICATE can also be a symbol among | 556 |
557 `executable', `readable', `writable', or `exists' or a list of one | 557 For compatibility, PREDICATE can also be one of the symbols |
558 of those symbols." | 558 `executable', `readable', `writable', or `exists', or a list of |
559 one or more of those symbols." | |
559 (if (and predicate (symbolp predicate) (not (functionp predicate))) | 560 (if (and predicate (symbolp predicate) (not (functionp predicate))) |
560 (setq predicate (list predicate))) | 561 (setq predicate (list predicate))) |
561 (when (and (consp predicate) (not (functionp predicate))) | 562 (when (and (consp predicate) (not (functionp predicate))) |
562 (setq predicate | 563 (setq predicate |
563 (logior (if (memq 'executable predicate) 1 0) | 564 (logior (if (memq 'executable predicate) 1 0) |
766 (interactive "BSwitch to buffer in other frame: ") | 767 (interactive "BSwitch to buffer in other frame: ") |
767 (let ((pop-up-frames t)) | 768 (let ((pop-up-frames t)) |
768 (pop-to-buffer buffer t norecord) | 769 (pop-to-buffer buffer t norecord) |
769 (raise-frame (window-frame (selected-window))))) | 770 (raise-frame (window-frame (selected-window))))) |
770 | 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 | |
771 (defun find-file (filename &optional wildcards) | 785 (defun find-file (filename &optional wildcards) |
772 "Edit file FILENAME. | 786 "Edit file FILENAME. |
773 Switch to a buffer visiting file FILENAME, | 787 Switch to a buffer visiting file FILENAME, |
774 creating one if none already exists. | 788 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 | |
775 Interactively, or if WILDCARDS is non-nil in a call from Lisp, | 793 Interactively, or if WILDCARDS is non-nil in a call from Lisp, |
776 expand wildcards (if any) and visit multiple files. Wildcard expansion | 794 expand wildcards (if any) and visit multiple files. Wildcard expansion |
777 can be suppressed by setting `find-file-wildcards'." | 795 can be suppressed by setting `find-file-wildcards'." |
778 (interactive "FFind file: \np") | 796 (interactive |
797 (find-file-read-args "Find file: ")) | |
779 (let ((value (find-file-noselect filename nil nil wildcards))) | 798 (let ((value (find-file-noselect filename nil nil wildcards))) |
780 (if (listp value) | 799 (if (listp value) |
781 (mapcar 'switch-to-buffer (nreverse value)) | 800 (mapcar 'switch-to-buffer (nreverse value)) |
782 (switch-to-buffer value)))) | 801 (switch-to-buffer value)))) |
783 | 802 |
784 (defun find-file-other-window (filename &optional wildcards) | 803 (defun find-file-other-window (filename &optional wildcards) |
785 "Edit file FILENAME, in another window. | 804 "Edit file FILENAME, in another window. |
786 May create a new window, or reuse an existing one. | 805 May create a new window, or reuse an existing one. |
787 See the function `display-buffer'. | 806 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 | |
788 Interactively, or if WILDCARDS is non-nil in a call from Lisp, | 812 Interactively, or if WILDCARDS is non-nil in a call from Lisp, |
789 expand wildcards (if any) and visit multiple files." | 813 expand wildcards (if any) and visit multiple files." |
790 (interactive "FFind file in other window: \np") | 814 (interactive (find-file-read-args "FFind file in other window: ")) |
791 (let ((value (find-file-noselect filename nil nil wildcards))) | 815 (let ((value (find-file-noselect filename nil nil wildcards))) |
792 (if (listp value) | 816 (if (listp value) |
793 (progn | 817 (progn |
794 (setq value (nreverse value)) | 818 (setq value (nreverse value)) |
795 (switch-to-buffer-other-window (car value)) | 819 (switch-to-buffer-other-window (car value)) |
798 | 822 |
799 (defun find-file-other-frame (filename &optional wildcards) | 823 (defun find-file-other-frame (filename &optional wildcards) |
800 "Edit file FILENAME, in another frame. | 824 "Edit file FILENAME, in another frame. |
801 May create a new frame, or reuse an existing one. | 825 May create a new frame, or reuse an existing one. |
802 See the function `display-buffer'. | 826 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 | |
803 Interactively, or if WILDCARDS is non-nil in a call from Lisp, | 832 Interactively, or if WILDCARDS is non-nil in a call from Lisp, |
804 expand wildcards (if any) and visit multiple files." | 833 expand wildcards (if any) and visit multiple files." |
805 (interactive "FFind file in other frame: \np") | 834 (interactive (find-file-read-args "FFind file in other frame: ")) |
806 (let ((value (find-file-noselect filename nil nil wildcards))) | 835 (let ((value (find-file-noselect filename nil nil wildcards))) |
807 (if (listp value) | 836 (if (listp value) |
808 (progn | 837 (progn |
809 (setq value (nreverse value)) | 838 (setq value (nreverse value)) |
810 (switch-to-buffer-other-frame (car value)) | 839 (switch-to-buffer-other-frame (car value)) |
811 (mapcar 'switch-to-buffer (cdr value))) | 840 (mapcar 'switch-to-buffer (cdr value))) |
812 (switch-to-buffer-other-frame value)))) | 841 (switch-to-buffer-other-frame value)))) |
813 | 842 |
814 (defun find-file-read-only (filename &optional wildcards) | 843 (defun find-file-read-only (filename &optional wildcards) |
815 "Edit file FILENAME but don't allow changes. | 844 "Edit file FILENAME but don't allow changes. |
816 Like `find-file' but marks buffer as read-only. | 845 Like \\[find-file] but marks buffer as read-only. |
817 Use \\[toggle-read-only] to permit editing." | 846 Use \\[toggle-read-only] to permit editing." |
818 (interactive "fFind file read-only: \np") | 847 (interactive (find-file-read-args "fFind file read-only: ")) |
819 (find-file filename wildcards) | 848 (find-file filename wildcards) |
820 (toggle-read-only 1) | 849 (toggle-read-only 1) |
821 (current-buffer)) | 850 (current-buffer)) |
822 | 851 |
823 (defun find-file-read-only-other-window (filename &optional wildcards) | 852 (defun find-file-read-only-other-window (filename &optional wildcards) |
824 "Edit file FILENAME in another window but don't allow changes. | 853 "Edit file FILENAME in another window but don't allow changes. |
825 Like \\[find-file-other-window] but marks buffer as read-only. | 854 Like \\[find-file-other-window] but marks buffer as read-only. |
826 Use \\[toggle-read-only] to permit editing." | 855 Use \\[toggle-read-only] to permit editing." |
827 (interactive "fFind file read-only other window: \np") | 856 (interactive (find-file-read-args "fFind file read-only other window: ")) |
828 (find-file-other-window filename wildcards) | 857 (find-file-other-window filename wildcards) |
829 (toggle-read-only 1) | 858 (toggle-read-only 1) |
830 (current-buffer)) | 859 (current-buffer)) |
831 | 860 |
832 (defun find-file-read-only-other-frame (filename &optional wildcards) | 861 (defun find-file-read-only-other-frame (filename &optional wildcards) |
833 "Edit file FILENAME in another frame but don't allow changes. | 862 "Edit file FILENAME in another frame but don't allow changes. |
834 Like \\[find-file-other-frame] but marks buffer as read-only. | 863 Like \\[find-file-other-frame] but marks buffer as read-only. |
835 Use \\[toggle-read-only] to permit editing." | 864 Use \\[toggle-read-only] to permit editing." |
836 (interactive "fFind file read-only other frame: \np") | 865 (interactive (find-file-read-args "fFind file read-only other frame: ")) |
837 (find-file-other-frame filename wildcards) | 866 (find-file-other-frame filename wildcards) |
838 (toggle-read-only 1) | 867 (toggle-read-only 1) |
839 (current-buffer)) | 868 (current-buffer)) |
840 | 869 |
841 (defun find-alternate-file-other-window (filename) | 870 (defun find-alternate-file-other-window (filename) |