Mercurial > hg > xemacs-beta
comparison lisp/files.el @ 318:afd57c14dfc8 r21-0b57
Import from CVS: tag r21-0b57
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:45:36 +0200 |
parents | c9fe270a4101 |
children | 19dcec799385 |
comparison
equal
deleted
inserted
replaced
317:a2fc9afbef65 | 318:afd57c14dfc8 |
---|---|
974 ;;; (get-file-buffer link-name)))) | 974 ;;; (get-file-buffer link-name)))) |
975 ;;; (if (bufferp linked-buf) | 975 ;;; (if (bufferp linked-buf) |
976 ;;; (message "Symbolic link to file in buffer %s" | 976 ;;; (message "Symbolic link to file in buffer %s" |
977 ;;; (buffer-name linked-buf)))) | 977 ;;; (buffer-name linked-buf)))) |
978 (setq buf (create-file-buffer filename)) | 978 (setq buf (create-file-buffer filename)) |
979 (set-buffer-major-mode buf) | 979 ;; Catch various signals, such as QUIT, and kill the buffer |
980 (set-buffer buf) | 980 ;; in that case. |
981 (erase-buffer) | 981 (condition-case data |
982 (if rawfile | 982 (progn |
983 (condition-case () | 983 (set-buffer-major-mode buf) |
984 (insert-file-contents-literally filename t) | 984 (set-buffer buf) |
985 (file-error | 985 (erase-buffer) |
986 (when (and (file-exists-p filename) | 986 (condition-case () |
987 (not (file-readable-p filename))) | 987 (if rawfile |
988 (kill-buffer buf) | 988 (insert-file-contents-literally filename t) |
989 (signal 'file-error (list "File is not readable" filename))) | 989 (insert-file-contents filename t)) |
990 ;; Unconditionally set error | 990 (file-error |
991 (setq error t))) | 991 (when (and (file-exists-p filename) |
992 (condition-case () | 992 (not (file-readable-p filename))) |
993 (insert-file-contents filename t) | 993 (signal 'file-error (list "File is not readable" filename))) |
994 (file-error | 994 (if rawfile |
995 (when (and (file-exists-p filename) | 995 ;; Unconditionally set error |
996 (not (file-readable-p filename))) | 996 (setq error t) |
997 (kill-buffer buf) | 997 (or |
998 (signal 'file-error (list "File is not readable" filename))) | 998 ;; Run find-file-not-found-hooks until one returns non-nil. |
999 ;; Run find-file-not-found-hooks until one returns non-nil. | 999 (run-hook-with-args-until-success 'find-file-not-found-hooks) |
1000 (or (run-hook-with-args-until-success 'find-file-not-found-hooks) | 1000 ;; If they fail too, set error. |
1001 ;; If they fail too, set error. | 1001 (setq error t))))) |
1002 (setq error t))))) | 1002 ;; Find the file's truename, and maybe use that as visited name. |
1003 ;; Find the file's truename, and maybe use that as visited name. | 1003 ;; automatically computed in XEmacs, unless jka-compr was used! |
1004 ;; automatically computed in XEmacs, unless jka-compr was used! | 1004 (unless buffer-file-truename |
1005 (unless buffer-file-truename | 1005 (setq buffer-file-truename truename)) |
1006 (setq buffer-file-truename truename)) | 1006 (setq buffer-file-number number) |
1007 (setq buffer-file-number number) | 1007 ;; On VMS, we may want to remember which directory in |
1008 ;; On VMS, we may want to remember which directory in a search list | 1008 ;; a search list the file was found in. |
1009 ;; the file was found in. | 1009 (and (eq system-type 'vax-vms) |
1010 (and (eq system-type 'vax-vms) | 1010 (let (logical) |
1011 (let (logical) | 1011 (if (string-match ":" (file-name-directory filename)) |
1012 (if (string-match ":" (file-name-directory filename)) | 1012 (setq logical (substring (file-name-directory filename) |
1013 (setq logical (substring (file-name-directory filename) | 1013 0 (match-beginning 0)))) |
1014 0 (match-beginning 0)))) | 1014 (not (member logical find-file-not-true-dirname-list))) |
1015 (not (member logical find-file-not-true-dirname-list))) | 1015 (setq buffer-file-name buffer-file-truename)) |
1016 (setq buffer-file-name buffer-file-truename)) | 1016 (and find-file-use-truenames |
1017 (and find-file-use-truenames | 1017 ;; This should be in C. Put pathname |
1018 ;; This should be in C. Put pathname abbreviations that have | 1018 ;; abbreviations that have been explicitly |
1019 ;; been explicitly requested back into the pathname. Most | 1019 ;; requested back into the pathname. Most |
1020 ;; importantly, strip out automounter /tmp_mnt directories so | 1020 ;; importantly, strip out automounter /tmp_mnt |
1021 ;; that auto-save will work | 1021 ;; directories so that auto-save will work |
1022 (setq buffer-file-name (abbreviate-file-name buffer-file-name))) | 1022 (setq buffer-file-name (abbreviate-file-name buffer-file-name))) |
1023 ;; Set buffer's default directory to that of the file. | 1023 ;; Set buffer's default directory to that of the file. |
1024 (setq default-directory (file-name-directory buffer-file-name)) | 1024 (setq default-directory (file-name-directory buffer-file-name)) |
1025 ;; Turn off backup files for certain file names. Since | 1025 ;; Turn off backup files for certain file names. Since |
1026 ;; this is a permanent local, the major mode won't eliminate it. | 1026 ;; this is a permanent local, the major mode won't eliminate it. |
1027 (and (not (funcall backup-enable-predicate buffer-file-name)) | 1027 (and (not (funcall backup-enable-predicate buffer-file-name)) |
1028 (progn | 1028 (progn |
1029 (make-local-variable 'backup-inhibited) | 1029 (make-local-variable 'backup-inhibited) |
1030 (setq backup-inhibited t))) | 1030 (setq backup-inhibited t))) |
1031 (if rawfile | 1031 (if rawfile |
1032 ;; #### FSF 20.3 sets buffer-file-coding-system to | 1032 ;; #### FSF 20.3 sets buffer-file-coding-system to |
1033 ;; `no-conversion' here. Should we copy? It also makes | 1033 ;; `no-conversion' here. Should we copy? It also |
1034 ;; `find-file-literally' a local variable and sets it to t. | 1034 ;; makes `find-file-literally' a local variable |
1035 nil | 1035 ;; and sets it to t. |
1036 (after-find-file error (not nowarn)) | 1036 nil |
1037 (setq buf (current-buffer))))) | 1037 (after-find-file error (not nowarn)) |
1038 (setq buf (current-buffer)))) | |
1039 (t | |
1040 (kill-buffer buf) | |
1041 (signal (car data) (cdr data)))))) | |
1038 buf))) | 1042 buf))) |
1039 | 1043 |
1040 ;; FSF has `insert-file-literally' and `find-file-literally' here. | 1044 ;; FSF has `insert-file-literally' and `find-file-literally' here. |
1041 | 1045 |
1042 (defvar after-find-file-from-revert-buffer nil) | 1046 (defvar after-find-file-from-revert-buffer nil) |
1152 ("\\.f\\(or\\)?\\'" . fortran-mode) | 1156 ("\\.f\\(or\\)?\\'" . fortran-mode) |
1153 ("\\.F\\(OR\\)?\\'" . fortran-mode) | 1157 ("\\.F\\(OR\\)?\\'" . fortran-mode) |
1154 ("\\.[fF]90\\'" . f90-mode) | 1158 ("\\.[fF]90\\'" . f90-mode) |
1155 ;;; Less common extensions come here | 1159 ;;; Less common extensions come here |
1156 ;;; so more common ones above are found faster. | 1160 ;;; so more common ones above are found faster. |
1157 ("\\.p[lm]\\'" . perl-mode) | 1161 ("\\.\\([pP][Llm]\\|al\\)\\'" . perl-mode) |
1158 ("\\.py\\'" . python-mode) | 1162 ("\\.py\\'" . python-mode) |
1159 ("\\.texi\\(nfo\\)?\\'" . texinfo-mode) | 1163 ("\\.texi\\(nfo\\)?\\'" . texinfo-mode) |
1160 ("\\.ad[abs]\\'" . ada-mode) | 1164 ("\\.ad[abs]\\'" . ada-mode) |
1161 ("\\.c?l\\(i?sp\\)?\\'" . lisp-mode) | 1165 ("\\.c?l\\(i?sp\\)?\\'" . lisp-mode) |
1162 ("\\.p\\(as\\)?\\'" . pascal-mode) | 1166 ("\\.p\\(as\\)?\\'" . pascal-mode) |