(w32_menu_show): Set widget call_data to 0 if definition is nil.
[bpt/emacs.git] / lisp / files.el
index 6e7e889..07c64a2 100644 (file)
@@ -203,7 +203,9 @@ breaks any hard links between it and other files."
 t means make numeric backup versions unconditionally.
 nil means make them for files that have some already.
 `never' means do not make them."
-  :type 'boolean
+  :type '(choice (const :tag "Never" never)
+                (const :tag "If existing" nil)
+                (other :tag "Always" t))
   :group 'backup
   :group 'vc)
 
@@ -218,7 +220,7 @@ nil means make them for files that have some already.
 If nil, ask confirmation.  Any other value prevents any trimming."
   :type '(choice (const :tag "Delete" t)
                 (const :tag "Ask" nil)
-                (sexp :tag "Leave" :format "%t\n" other))
+                (other :tag "Leave" other))
   :group 'backup)
 
 (defcustom kept-old-versions 2
@@ -238,7 +240,7 @@ Non-nil but not t says ask user whether to add a newline when there isn't one.
 nil means don't add newlines."
   :type '(choice (const :tag "Off" nil)
                 (const :tag "Add" t)
-                (sexp :tag "Ask" :format "%t\n" ask))
+                (other :tag "Ask" ask))
   :group 'editing-basics)
 
 (defcustom auto-save-default t
@@ -329,7 +331,7 @@ The command \\[normal-mode] always obeys file local variable
 specifications and ignores this variable."
   :type '(choice (const :tag "Obey" t)
                 (const :tag "Ignore" nil)
-                (sexp :tag "Query" :format "%t\n" other))
+                (other :tag "Query" other))
   :group 'find-file)
 
 (defvar local-enable-local-variables t
@@ -347,7 +349,7 @@ The command \\[normal-mode] always obeys local-variables lists
 and ignores this variable."
   :type '(choice (const :tag "Obey" t)
                 (const :tag "Ignore" nil)
-                (sexp :tag "Query" :format "%t\n" other))
+                (other :tag "Query" other))
   :group 'find-file)
 
 ;; Avoid losing in versions where CLASH_DETECTION is disabled.
@@ -890,6 +892,7 @@ Optional second arg RAWFILE non-nil means the file is read literally."
            (if (or find-file-existing-other-name find-file-visit-truename)
                (setq buf other))))
       (if buf
+         ;; We are using an existing buffer.
          (progn
            (or nowarn
                (verify-visited-file-modtime buf)
@@ -948,19 +951,24 @@ Optional second arg RAWFILE non-nil means the file is read literally."
                      (find-file-noselect-1 buf filename nowarn
                                            rawfile truename number)
                    (error (if rawfile "File already visited non-literally"
-                            "File already visited literally")))))))
-       (progn
-         (setq buf (create-file-buffer filename))
-         (set-buffer-major-mode buf)
-         (find-file-noselect-1 buf filename nowarn rawfile truename number)))
-      buf)))
+                            "File already visited literally"))))))
+           ;; Return the buffer we are using.
+           buf)
+       ;; Create a new buffer.
+       (setq buf (create-file-buffer filename))
+       (set-buffer-major-mode buf)
+       ;; find-file-noselect-1 may use a different buffer.
+       (find-file-noselect-1 buf filename nowarn
+                             rawfile truename number)))))
 
 (defun find-file-noselect-1 (buf filename nowarn rawfile truename number)
   (let ((inhibit-read-only t)
        error)
     (with-current-buffer buf
       (kill-local-variable 'find-file-literally)
-      (setq buffer-file-coding-system nil)
+      ;; Needed in case we are re-visiting the file with a different
+      ;; text representation.
+      (setq buffer-file-coding-system default-buffer-file-coding-system)
       (erase-buffer)
       (and (default-value 'enable-multibyte-characters)
           (not rawfile)
@@ -1018,8 +1026,8 @@ Optional second arg RAWFILE non-nil means the file is read literally."
            (setq buffer-file-coding-system 'no-conversion)
            (make-local-variable 'find-file-literally)
            (setq find-file-literally t))
-       (after-find-file error (not nowarn))
-       (setq buf (current-buffer))))))
+       (after-find-file error (not nowarn)))
+      (current-buffer))))
 \f
 (defun insert-file-contents-literally (filename &optional visit beg end replace)
   "Like `insert-file-contents', but only reads in the file literally.
@@ -1263,6 +1271,7 @@ run `normal-mode' explicitly."
     ("\\.lex\\'" . c-mode)
     ("\\.oak\\'" . scheme-mode)
     ("\\.sgml?\\'" . sgml-mode)
+    ("\\.xml\\'" . sgml-mode)
     ("\\.dtd\\'" . sgml-mode)
     ("\\.ds\\(ss\\)?l\\'" . dsssl-mode)
     ;; .emacs following a directory delimiter