]> code.delx.au - gnu-emacs/blobdiff - lisp/files.el
Merged in changes from CVS trunk.
[gnu-emacs] / lisp / files.el
index bfbf0cf39d0e29280f1640068e78e71854ff9a6b..62068b2f21798e66de737cd1f14a0b61b2a81960 100644 (file)
@@ -478,7 +478,7 @@ Runs the usual ange-ftp hook, but only for completion operations."
       (apply op args))))
 
 (defun convert-standard-filename (filename)
-  "Convert a standard file's name to something suitable for the current OS.
+  "Convert a standard file's name to something suitable for the OS.
 This means to guarantee valid names and perhaps to canonicalize
 certain patterns.
 
@@ -487,7 +487,9 @@ the argument.  However, on Windows and DOS, replace invalid
 characters.  On DOS, make sure to obey the 8.3 limitations.  On
 Windows, turn Cygwin names into native names, and also turn
 slashes into backslashes if the shell requires it (see
-`w32-shell-dos-semantics')."
+`w32-shell-dos-semantics').
+
+See Info node `(elisp)Standard File Names' for more details."
   filename)
 
 (defun read-directory-name (prompt &optional dir default-dirname mustmatch initial)
@@ -1759,16 +1761,17 @@ in that case, this function acts as if `enable-local-variables' were t."
      ;; Windows candidates may be opened case sensitively on Unix
      ("\\.\\(?:[iI][nN][iI]\\|[lL][sS][tT]\\|[rR][eE][gG]\\|[sS][yY][sS]\\)\\'" . conf-mode)
      ("\\.\\(?:desktop\\|la\\)\\'" . conf-unix-mode)
+     ("\\.ppd\\'" . conf-ppd-mode)
      ("java.+\\.conf\\'" . conf-javaprop-mode)
      ("\\.properties\\(?:\\.[a-zA-Z0-9._-]+\\)?\\'" . conf-javaprop-mode)
      ;; *.cf, *.cfg, *.conf, *.config[.local|.de_DE.UTF8|...], */config
      ("[/.]c\\(?:on\\)?f\\(?:i?g\\)?\\(?:\\.[a-zA-Z0-9._-]+\\)?\\'" . conf-mode)
-     ("\\`/etc/\\(?:DIR_COLORS\\|ethers\\|.?fstab\\|.*hosts\\|lesskey\\|login\\.?de\\(?:fs\\|vperm\\)\\|magic\\|mtab\\|permissions\\|protocols\\|rpc\\|services\\)\\'" . conf-space-mode)
-     ("\\`/etc/\\(?:aliases\\|hosts\\..+\\|ksysguarddrc\\|opera6rc\\)\\'" . conf-mode)
+     ("\\`/etc/\\(?:DIR_COLORS\\|ethers\\|.?fstab\\|.*hosts\\|lesskey\\|login\\.?de\\(?:fs\\|vperm\\)\\|magic\\|mtab\\|pam\\.d/.*\\|permissions\\|protocols\\|rpc\\|services\\)\\'" . conf-space-mode)
+     ("\\`/etc/\\(?:acpid?/.+\\|aliases\\|default/.+\\|group-?\\|hosts\\..+\\|inittab\\|ksysguarddrc\\|opera6rc\\|passwd-?\\|shadow-?\\)\\'" . conf-mode)
      ;; either user's dot-files or under /etc or some such
      ("/\\.?\\(?:gnokiirc\\|kde.*rc\\|mime\\.types\\|wgetrc\\)\\'" . conf-mode)
      ;; alas not all ~/.*rc files are like this
-     ("/\\.\\(?:enigma\\|gltron\\|hxplayer\\|net\\|neverball\\|qt/.+\\|realplayer\\|scummvm\\|sversion\\|sylpheed/.+\\|xmp\\)rc\\'" . conf-mode)
+     ("/\\.\\(?:enigma\\|gltron\\|gtk\\|hxplayer\\|net\\|neverball\\|qt/.+\\|realplayer\\|scummvm\\|sversion\\|sylpheed/.+\\|xmp\\)rc\\'" . conf-mode)
      ("/\\.\\(?:gdbtkinit\\|grip\\|orbital/.+txt\\|rhosts\\|tuxracer/options\\)\\'" . conf-mode)
      ("/\\.?X\\(?:default\\|resource\\|re\\)s\\>" . conf-xdefaults-mode)
      ("/X11.+app-defaults/" . conf-xdefaults-mode)
@@ -1866,13 +1869,19 @@ regular expression.  The mode is then determined as the mode associated
 with that interpreter in `interpreter-mode-alist'.")
 
 (defvar magic-mode-alist
-  '(;; The < comes before the groups (but the first) to reduce backtracking.
-    ;; Is there a nicer way of getting . including \n like Perl's //s?
+  `(;; The < comes before the groups (but the first) to reduce backtracking.
     ;; TODO: UTF-16 <?xml may be preceded by a BOM 0xff 0xfe or 0xfe 0xff.
-    ("\\(?:<\\?xml\\s +[^>]*>\\)?\\s *<\\(?:!--\\(?:.\\|\n\\)*?-->\\s *<\\)*\\(?:!DOCTYPE\\s +[^>]*>\\s *<\\)?\\s *\\(?:!--\\(?:.\\|\n\\)*?-->\\s *<\\)*[Hh][Tt][Mm][Ll]" . html-mode)
+    (,(let* ((incomment-re "\\(?:[^-]\\|-[^-]\\)")
+            (comment-re (concat "\\(?:!--" incomment-re "*-->\\s *<\\)")))
+       (concat "\\(?:<\\?xml\\s +[^>]*>\\)?\\s *<"
+               comment-re "*"
+               "\\(?:!DOCTYPE\\s +[^>]*>\\s *<\\s *" comment-re "*\\)?"
+               "[Hh][Tt][Mm][Ll]")) . html-mode)
     ;; These two must come after html, because they are more general:
     ("<\\?xml " . xml-mode)
-    ("\\s *<\\(?:!--\\(?:.\\|\n\\)*?-->\\s *<\\)*!DOCTYPE " . sgml-mode)
+    (,(let* ((incomment-re "\\(?:[^-]\\|-[^-]\\)")
+            (comment-re (concat "\\(?:!--" incomment-re "*-->\\s *<\\)")))
+       (concat "\\s *<" comment-re "*!DOCTYPE ")) . sgml-mode)
     ("%![^V]" . ps-mode)
     ("# xmcd " . conf-unix-mode))
   "Alist of buffer beginnings vs. corresponding major mode functions.
@@ -1884,9 +1893,8 @@ called, unless it is nil (to allow `auto-mode-alist' to override).")
 
 This checks for a -*- mode tag in the buffer's text, checks the
 interpreter that runs this file against `interpreter-mode-alist',
-compares the buffer beginning against `magic-mode-alist',
-or compares the filename against the entries in
-`auto-mode-alist'.
+compares the buffer beginning against `magic-mode-alist', or
+compares the filename against the entries in `auto-mode-alist'.
 
 It does not check for the `mode:' local variable in the
 Local Variables section of the file; for that, use `hack-local-variables'.
@@ -1897,13 +1905,11 @@ If `enable-local-variables' is nil, this function does not check for a
 If the optional argument KEEP-MODE-IF-SAME is non-nil, then we
 only set the major mode, if that would change it."
   ;; Look for -*-MODENAME-*- or -*- ... mode: MODENAME; ... -*-
-  (let (end done mode modes xml)
+  (let (end done mode modes)
     ;; Find a -*- mode tag
     (save-excursion
       (goto-char (point-min))
       (skip-chars-forward " \t\n")
-      ;; While we're at this point, check xml for later.
-      (setq xml (looking-at "<\\?xml \\|<!DOCTYPE"))
       (and enable-local-variables
           (setq end (set-auto-mode-1))
           (if (save-excursion (search-forward ":" end t))
@@ -1947,9 +1953,10 @@ only set the major mode, if that would change it."
            ;; same time.
            done (assoc (file-name-nondirectory mode)
                        interpreter-mode-alist))
+      ;; If we found an interpreter mode to use, invoke it now.
       (if done
          (set-auto-mode-0 (cdr done) keep-mode-if-same)))
-    ;; If we found an interpreter mode to use, invoke it now.
+    ;; If we didn't, match the buffer beginning against magic-mode-alist.
     (unless done
       (if (setq done (save-excursion
                       (goto-char (point-min))
@@ -1957,6 +1964,7 @@ only set the major mode, if that would change it."
                                      (lambda (re dummy)
                                        (looking-at re)))))
          (set-auto-mode-0 done keep-mode-if-same)
+       ;; Compare the filename against the entries in auto-mode-alist.
        (if buffer-file-name
            (let ((name buffer-file-name))
              ;; Remove backup-suffixes from file name.
@@ -1966,7 +1974,7 @@ only set the major mode, if that would change it."
                (let ((case-fold-search
                       (memq system-type '(vax-vms windows-nt cygwin))))
                  (if (and (setq mode (assoc-default name auto-mode-alist
-                                                'string-match))
+                                                    'string-match))
                           (consp mode)
                           (cadr mode))
                      (setq mode (car mode)
@@ -1975,7 +1983,6 @@ only set the major mode, if that would change it."
                (when mode
                  (set-auto-mode-0 mode keep-mode-if-same)))))))))
 
-
 ;; When `keep-mode-if-same' is set, we are working on behalf of
 ;; set-visited-file-name.  In that case, if the major mode specified is the
 ;; same one we already have, don't actually reset it.  We don't want to lose
@@ -1994,7 +2001,6 @@ same, do nothing and return nil."
     (funcall mode)
     mode))
 
-
 (defun set-auto-mode-1 ()
   "Find the -*- spec in the buffer.
 Call with point at the place to start searching from.
@@ -4634,7 +4640,7 @@ With prefix arg, silently save all file-visiting buffers, then kill."
 (define-key ctl-x-map "i" 'insert-file)
 (define-key esc-map "~" 'not-modified)
 (define-key ctl-x-map "\C-d" 'list-directory)
-(define-key ctl-x-map "\C-c" 'save-buffers-kill-emacs)
+(define-key ctl-x-map "\C-c" 'server-save-buffers-kill-display)
 (define-key ctl-x-map "\C-q" 'toggle-read-only)
 
 (define-key ctl-x-4-map "f" 'find-file-other-window)