Mercurial > hg > xemacs-beta
comparison lisp/prim/files.el @ 16:0293115a14e9 r19-15b91
Import from CVS: tag r19-15b91
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:49:20 +0200 |
parents | 4b173ad71786 |
children | 8fc7fe29b841 |
comparison
equal
deleted
inserted
replaced
15:ad457d5f7d04 | 16:0293115a14e9 |
---|---|
767 On VMS, when you visit a file using a logical name that searches a path, | 767 On VMS, when you visit a file using a logical name that searches a path, |
768 you may or may not want the visited file name to record the specific | 768 you may or may not want the visited file name to record the specific |
769 directory where the file was found. If you *do not* want that, add the logical | 769 directory where the file was found. If you *do not* want that, add the logical |
770 name to this list as a string.") | 770 name to this list as a string.") |
771 | 771 |
772 ;(defun find-buffer-visiting (filename) | 772 ;; XEmacs -- why was this commented out?? -- Hrv |
773 ; "Return the buffer visiting file FILENAME (a string). | 773 (defun find-buffer-visiting (filename) |
774 ;This is like `get-file-buffer', except that it checks for any buffer | 774 "Return the buffer visiting file FILENAME (a string). |
775 ;visiting the same file, possibly under a different name. | 775 This is like `get-file-buffer', except that it checks for any buffer |
776 ;If there is no such live buffer, return nil." | 776 visiting the same file, possibly under a different name. |
777 ; (let ((buf (get-file-buffer filename)) | 777 If there is no such live buffer, return nil." |
778 ; (truename (abbreviate-file-name (file-truename filename)))) | 778 (let ((buf (get-file-buffer filename)) |
779 ; (or buf | 779 (truename (abbreviate-file-name (file-truename filename)))) |
780 ; (let ((list (buffer-list)) found) | 780 (or buf |
781 ; (while (and (not found) list) | 781 (let ((list (buffer-list)) found) |
782 ; (save-excursion | 782 (while (and (not found) list) |
783 ; (set-buffer (car list)) | 783 (save-excursion |
784 ; (if (and buffer-file-name | 784 (set-buffer (car list)) |
785 ; (string= buffer-file-truename truename)) | 785 (if (and buffer-file-name |
786 ; (setq found (car list)))) | 786 (string= buffer-file-truename truename)) |
787 ; (setq list (cdr list))) | 787 (setq found (car list)))) |
788 ; found) | 788 (setq list (cdr list))) |
789 ; (let ((number (nthcdr 10 (file-attributes truename))) | 789 found) |
790 ; (list (buffer-list)) found) | 790 (let ((number (nthcdr 10 (file-attributes truename))) |
791 ; (and buffer-file-numbers-unique | 791 (list (buffer-list)) found) |
792 ; number | 792 (and buffer-file-numbers-unique |
793 ; (while (and (not found) list) | 793 number |
794 ; (save-excursion | 794 (while (and (not found) list) |
795 ; (set-buffer (car list)) | 795 (save-excursion |
796 ; (if (and buffer-file-name | 796 (set-buffer (car list)) |
797 ; (equal buffer-file-number number) | 797 (if (and buffer-file-name |
798 ; ;; Verify this buffer's file number | 798 (equal buffer-file-number number) |
799 ; ;; still belongs to its file. | 799 ;; Verify this buffer's file number |
800 ; (file-exists-p buffer-file-name) | 800 ;; still belongs to its file. |
801 ; (equal (nthcdr 10 (file-attributes buffer-file-name)) | 801 (file-exists-p buffer-file-name) |
802 ; number)) | 802 (equal (nthcdr 10 (file-attributes buffer-file-name)) |
803 ; (setq found (car list)))) | 803 number)) |
804 ; (setq list (cdr list)))) | 804 (setq found (car list)))) |
805 ; found)))) | 805 (setq list (cdr list)))) |
806 found)))) | |
806 | 807 |
807 (defun insert-file-contents-literally (filename &optional visit beg end replace) | 808 (defun insert-file-contents-literally (filename &optional visit beg end replace) |
808 "Like `insert-file-contents', q.v., but only reads in the file. | 809 "Like `insert-file-contents', q.v., but only reads in the file. |
809 A buffer may be modified in several ways after reading into the buffer due | 810 A buffer may be modified in several ways after reading into the buffer due |
810 to advanced Emacs features, such as file-name-handlers, format decoding, | 811 to advanced Emacs features, such as file-name-handlers, format decoding, |
1051 ("\\.[ch]\\'" . c-mode) | 1052 ("\\.[ch]\\'" . c-mode) |
1052 ("\\.tex\\'" . tex-mode) | 1053 ("\\.tex\\'" . tex-mode) |
1053 ("\\.ltx\\'" . latex-mode) | 1054 ("\\.ltx\\'" . latex-mode) |
1054 ("\\.el\\'" . emacs-lisp-mode) | 1055 ("\\.el\\'" . emacs-lisp-mode) |
1055 ("\\.l\\(i?sp\\)?\\'" . lisp-mode) | 1056 ("\\.l\\(i?sp\\)?\\'" . lisp-mode) |
1056 ("\\.f\\(or\\)?\\'" . fortran-mode) | 1057 ("\\.[Ff]\\(or\\)?\\'" . fortran-mode) |
1057 ("\\.p\\(as\\)?\\'" . pascal-mode) | 1058 ("\\.p\\(as\\)?\\'" . pascal-mode) |
1058 ("\\.ad[abs]\\'" . ada-mode) | 1059 ("\\.ad[abs]\\'" . ada-mode) |
1059 ("\\.pl\\'" . perl-mode) | 1060 ("\\.pl\\'" . perl-mode) |
1061 ("\\.pm\\'" . perl-mode) | |
1060 ("\\.\\([CH]\\|cc\\|hh\\)\\'" . c++-mode) | 1062 ("\\.\\([CH]\\|cc\\|hh\\)\\'" . c++-mode) |
1061 ("\\.[ch]\\(pp\\|xx\\|\\+\\+\\)\\'" . c++-mode) | 1063 ("\\.[ch]\\(pp\\|xx\\|\\+\\+\\)\\'" . c++-mode) |
1062 ("\\.java\\'" . java-mode) | 1064 ("\\.java\\'" . java-mode) |
1063 ("\\.ma?k\\'" . makefile-mode) | 1065 ("\\.ma?k\\'" . makefile-mode) |
1064 ("[Mm]akefile\\(.in\\)?\\(.in\\)?\\'" . makefile-mode) | 1066 ("\\(M\\|m\\|GNUm\\)akefile\\(.in\\)?\\(.in\\)?\\'" . makefile-mode) |
1065 ;;; Less common extensions come here | 1067 ;;; Less common extensions come here |
1066 ;;; so more common ones above are found faster. | 1068 ;;; so more common ones above are found faster. |
1067 ("\\.texi\\(nfo\\)?\\'" . texinfo-mode) | 1069 ("\\.texi\\(nfo\\)?\\'" . texinfo-mode) |
1068 ("\\.s\\'" . asm-mode) | 1070 ("\\.[Ss]\\'" . asm-mode) |
1071 ("\\.asm\\'" . asm-mode) | |
1069 ("[Cc]hange.?[Ll]og?\\(.[0-9]+\\)?\\'" . change-log-mode) | 1072 ("[Cc]hange.?[Ll]og?\\(.[0-9]+\\)?\\'" . change-log-mode) |
1070 ("\\$CHANGE_LOG\\$\\.TXT" . change-log-mode) | 1073 ("\\$CHANGE_LOG\\$\\.TXT" . change-log-mode) |
1071 ("\\.scm\\(\\.[0-9]*\\)?\\'" . scheme-mode) | 1074 ("\\.scm\\(\\.[0-9]*\\)?\\'" . scheme-mode) |
1072 ("\\.py\\'" . python-mode) | 1075 ("\\.py\\'" . python-mode) |
1073 ("\\.e\\'" . eiffel-mode) | 1076 ("\\.e\\'" . eiffel-mode) |
1088 ("\\.article\\'" . text-mode) | 1091 ("\\.article\\'" . text-mode) |
1089 ("\\.letter\\'" . text-mode) | 1092 ("\\.letter\\'" . text-mode) |
1090 ("\\.\\(tcl\\|exp\\)\\'" . tcl-mode) | 1093 ("\\.\\(tcl\\|exp\\)\\'" . tcl-mode) |
1091 ("\\.wrl\\'" . vrml-mode) | 1094 ("\\.wrl\\'" . vrml-mode) |
1092 ("\\.f90\\'" . f90-mode) | 1095 ("\\.f90\\'" . f90-mode) |
1096 ("\\.lsp\\'" . lisp-mode) | |
1093 ("\\.awk\\'" . awk-mode) | 1097 ("\\.awk\\'" . awk-mode) |
1094 ("\\.prolog\\'" . prolog-mode) | 1098 ("\\.prolog\\'" . prolog-mode) |
1095 ("\\.tar\\'" . tar-mode) | 1099 ("\\.tar\\'" . tar-mode) |
1096 ("\\.\\(arc\\|zip\\|lzh\\|zoo\\)\\'" . archive-mode) | 1100 ("\\.\\(arc\\|zip\\|lzh\\|zoo\\)\\'" . archive-mode) |
1101 ("\\.\\(ARC\\|ZIP\\|LZH\\|ZOO\\)\\'" . archive-mode) | |
1097 ;; Mailer puts message to be edited in | 1102 ;; Mailer puts message to be edited in |
1098 ;; /tmp/Re.... or Message | 1103 ;; /tmp/Re.... or Message |
1099 ("^/tmp/Re" . text-mode) | 1104 ("^/tmp/Re" . text-mode) |
1100 ("^/tmp/L[0-9]+TMP\\.html" . text-mode) ; Lynx mail mode | 1105 ("^/tmp/L[0-9]+TMP\\.html" . text-mode) ; Lynx mail mode |
1101 ("/Message[0-9]*\\'" . text-mode) | 1106 ("/Message[0-9]*\\'" . text-mode) |
1126 calling FUNCTION (if it's not nil), we delete the suffix that matched | 1131 calling FUNCTION (if it's not nil), we delete the suffix that matched |
1127 REGEXP and search the list again for another match.") | 1132 REGEXP and search the list again for another match.") |
1128 | 1133 |
1129 (defconst interpreter-mode-alist | 1134 (defconst interpreter-mode-alist |
1130 (mapcar 'purecopy | 1135 (mapcar 'purecopy |
1131 '(("^#!.*[acjkwz]sh" . sh-mode) | 1136 '(("^#!.*[acjkwz]sh" . sh-mode) |
1132 ("^#!.*sh\\b" . sh-mode) | 1137 ("^#!.*sh\\b" . sh-mode) |
1133 ("^#!.*\\b\\(scope\\|wish\\|tcl\\|expect\\)" . tcl-mode) | 1138 ("^#!.*\\b\\(scope\\|wishx?\\|tcl\\|tclsh\\|expect\\)" . tcl-mode) |
1134 ("perl" . perl-mode) | |
1135 ("python" . python-mode) | 1139 ("python" . python-mode) |
1136 ("awk\\b" . awk-mode) | 1140 ("[mng]?awk\\b" . awk-mode) |
1137 ("rexx" . rexx-mode) | 1141 ("rexx" . rexx-mode) |
1138 ("scm" . scheme-mode) | 1142 ("scm" . scheme-mode) |
1139 ("^:" . sh-mode) | 1143 ("^:" . sh-mode) |
1144 ("tail" . text-mode) | |
1145 ("more" . text-mode) | |
1146 ("less" . text-mode) | |
1147 ("pg" . text-mode) | |
1140 )) | 1148 )) |
1141 "Alist mapping interpreter names to major modes. | 1149 "Alist mapping interpreter names to major modes. |
1142 This alist is used to guess the major mode of a file based on the | 1150 This alist is used to guess the major mode of a file based on the |
1143 contents of the first line. This line often contains something like: | 1151 contents of the first line. This line often contains something like: |
1144 #!/bin/sh | 1152 #!/bin/sh |
1248 (end-of-line (and (looking-at "^#!") 2)) | 1256 (end-of-line (and (looking-at "^#!") 2)) |
1249 (point)))) | 1257 (point)))) |
1250 ;; Parse the -*- line into the `result' alist. | 1258 ;; Parse the -*- line into the `result' alist. |
1251 (cond ((not (search-forward "-*-" end t)) | 1259 (cond ((not (search-forward "-*-" end t)) |
1252 ;; doesn't have one. | 1260 ;; doesn't have one. |
1253 nil) | 1261 (setq force t)) |
1254 ((looking-at "[ \t]*\\([^ \t\n\r:;]+\\)\\([ \t]*-\\*-\\)") | 1262 ((looking-at "[ \t]*\\([^ \t\n\r:;]+\\)\\([ \t]*-\\*-\\)") |
1255 ;; Antiquated form: "-*- ModeName -*-". | 1263 ;; Antiquated form: "-*- ModeName -*-". |
1256 (setq result | 1264 (setq result |
1257 (list (cons 'mode | 1265 (list (cons 'mode |
1258 (intern (buffer-substring | 1266 (intern (buffer-substring |
1284 (setq key 'mode)) | 1292 (setq key 'mode)) |
1285 (setq result (cons (cons key val) result)) | 1293 (setq result (cons (cons key val) result)) |
1286 (skip-chars-forward " \t;"))) | 1294 (skip-chars-forward " \t;"))) |
1287 (setq result (nreverse result)))))) | 1295 (setq result (nreverse result)))))) |
1288 | 1296 |
1289 (let ((set-any-p (or force (hack-local-variables-p t))) | 1297 (if result |
1290 (mode-p nil)) | 1298 (let ((set-any-p (or force (hack-local-variables-p t))) |
1291 (while result | 1299 (mode-p nil)) |
1292 (let ((key (car (car result))) | 1300 (while result |
1293 (val (cdr (car result)))) | 1301 (let ((key (car (car result))) |
1294 (cond ((eq key 'mode) | 1302 (val (cdr (car result)))) |
1295 (setq mode-p t) | 1303 (cond ((eq key 'mode) |
1296 (funcall (intern (concat (downcase (symbol-name val)) | 1304 (setq mode-p t) |
1297 "-mode")))) | 1305 (funcall (intern (concat (downcase (symbol-name val)) |
1298 (set-any-p | 1306 "-mode")))) |
1299 (hack-one-local-variable key val)) | 1307 (set-any-p |
1300 (t | 1308 (hack-one-local-variable key val)) |
1301 nil))) | 1309 (t |
1302 (setq result (cdr result))) | 1310 nil))) |
1303 mode-p))) | 1311 (setq result (cdr result))) |
1312 mode-p)))) | |
1304 | 1313 |
1305 (defvar hack-local-variables-hook nil | 1314 (defvar hack-local-variables-hook nil |
1306 "Normal hook run after processing a file's local variables specs. | 1315 "Normal hook run after processing a file's local variables specs. |
1307 Major modes can use this to examine user-specified local variables | 1316 Major modes can use this to examine user-specified local variables |
1308 in order to initialize other data structure based on them. | 1317 in order to initialize other data structure based on them. |