XEmacs 21.2.14.
[chise/xemacs-chise.git.1] / lisp / files.el
index 591648d..186043f 100644 (file)
@@ -76,8 +76,7 @@ and FROM the name it is linked to."
                       (regexp :tag "To")))
   :group 'find-file)
 
                       (regexp :tag "To")))
   :group 'find-file)
 
-;;; Turn off backup files on VMS since it has version numbers.
-(defcustom make-backup-files (not (eq system-type 'vax-vms))
+(defcustom make-backup-files t
   "*Non-nil means make a backup of a file the first time it is saved.
 This can be done by renaming the file or by copying.
 
   "*Non-nil means make a backup of a file the first time it is saved.
 This can be done by renaming the file or by copying.
 
@@ -414,8 +413,7 @@ of the same functionality is available as `split-path', which see."
   "Change current directory to given absolute file name DIR."
   ;; Put the name into directory syntax now,
   ;; because otherwise expand-file-name may give some bad results.
   "Change current directory to given absolute file name DIR."
   ;; Put the name into directory syntax now,
   ;; because otherwise expand-file-name may give some bad results.
-  (if (not (eq system-type 'vax-vms))
-      (setq dir (file-name-as-directory dir)))
+  (setq dir (file-name-as-directory dir))
   ;; XEmacs change: stig@hackvan.com
   (if find-file-use-truenames
       (setq dir (file-truename dir)))
   ;; XEmacs change: stig@hackvan.com
   (if find-file-use-truenames
       (setq dir (file-truename dir)))
@@ -790,46 +788,40 @@ If optional argument HACK-HOMEDIR is non-nil, then this also substitutes
        ;; If any elt of directory-abbrev-alist matches this name,
        ;; abbreviate accordingly.
        (while tail
        ;; If any elt of directory-abbrev-alist matches this name,
        ;; abbreviate accordingly.
        (while tail
-         (if (string-match (car (car tail)) filename)
-             (setq filename
-                   (concat (cdr (car tail)) (substring filename (match-end 0)))))
+         (when (string-match (car (car tail)) filename)
+           (setq filename
+                 (concat (cdr (car tail)) (substring filename (match-end 0)))))
          (setq tail (cdr tail))))
          (setq tail (cdr tail))))
-      (if hack-homedir
-         (progn
-           ;; Compute and save the abbreviated homedir name.
-           ;; We defer computing this until the first time it's needed, to
-           ;; give time for directory-abbrev-alist to be set properly.
-           ;; We include a slash at the end, to avoid spurious matches
-           ;; such as `/usr/foobar' when the home dir is `/usr/foo'.
-           (or abbreviated-home-dir
-               (setq abbreviated-home-dir
-                     (let ((abbreviated-home-dir "$foo"))
-                       (concat "\\`" (regexp-quote (abbreviate-file-name
-                                                    (expand-file-name "~")))
-                               "\\(/\\|\\'\\)"))))
-           ;; If FILENAME starts with the abbreviated homedir,
-           ;; make it start with `~' instead.
-           (if (and (string-match abbreviated-home-dir filename)
-                    ;; If the home dir is just /, don't change it.
-                    (not (and (= (match-end 0) 1) ;#### unix-specific
-                              (= (aref filename 0) ?/)))
-                    (not (and (or (eq system-type 'ms-dos)
-                                  (eq system-type 'windows-nt))
-                              (save-match-data
-                                (string-match "^[a-zA-Z]:/$" filename)))))
-               (setq filename
-                     (concat "~"
-                             (substring filename
-                                        (match-beginning 1) (match-end 1))
-                             (substring filename (match-end 0)))))))
+      (when hack-homedir
+       ;; Compute and save the abbreviated homedir name.
+       ;; We defer computing this until the first time it's needed, to
+       ;; give time for directory-abbrev-alist to be set properly.
+       ;; We include a slash at the end, to avoid spurious matches
+       ;; such as `/usr/foobar' when the home dir is `/usr/foo'.
+       (or abbreviated-home-dir
+           (setq abbreviated-home-dir
+                 (let ((abbreviated-home-dir "$foo"))
+                   (concat "\\`" (regexp-quote (abbreviate-file-name
+                                                (expand-file-name "~")))
+                           "\\(/\\|\\'\\)"))))
+       ;; If FILENAME starts with the abbreviated homedir,
+       ;; make it start with `~' instead.
+       (if (and (string-match abbreviated-home-dir filename)
+                ;; If the home dir is just /, don't change it.
+                (not (and (= (match-end 0) 1) ;#### unix-specific
+                          (= (aref filename 0) ?/)))
+                (not (and (memq system-type '(ms-dos windows-nt))
+                          (save-match-data
+                            (string-match "^[a-zA-Z]:/$" filename)))))
+           (setq filename
+                 (concat "~"
+                         (substring filename
+                                    (match-beginning 1) (match-end 1))
+                         (substring filename (match-end 0))))))
       filename)))
 
 (defcustom find-file-not-true-dirname-list nil
       filename)))
 
 (defcustom find-file-not-true-dirname-list nil
-  "*List of logical names for which visiting shouldn't save the true dirname.
-On VMS, when you visit a file using a logical name that searches a path,
-you may or may not want the visited file name to record the specific
-directory where the file was found.  If you *do not* want that, add the logical
-name to this list as a string."
+  "*List of logical names for which visiting shouldn't save the true dirname."
   :type '(repeat (string :tag "Name"))
   :group 'find-file)
 
   :type '(repeat (string :tag "Name"))
   :group 'find-file)
 
@@ -976,65 +968,60 @@ If RAWFILE is non-nil, the file is read literally."
 ;;;            (message "Symbolic link to file in buffer %s"
 ;;;                     (buffer-name linked-buf))))
          (setq buf (create-file-buffer filename))
 ;;;            (message "Symbolic link to file in buffer %s"
 ;;;                     (buffer-name linked-buf))))
          (setq buf (create-file-buffer filename))
-         (set-buffer-major-mode buf)
-         (set-buffer buf)
-         (erase-buffer)
-         (if rawfile
-             (condition-case ()
-                 (insert-file-contents-literally filename t)
-               (file-error
-                (when (and (file-exists-p filename)
-                           (not (file-readable-p filename)))
-                  (kill-buffer buf)
-                  (signal 'file-error (list "File is not readable" filename)))
-                ;; Unconditionally set error
-                (setq error t)))
-           (condition-case ()
-               (insert-file-contents filename t)
-             (file-error
-              (when (and (file-exists-p filename)
-                         (not (file-readable-p filename)))
-                (kill-buffer buf)
-                (signal 'file-error (list "File is not readable" filename)))
-              ;; Run find-file-not-found-hooks until one returns non-nil.
-              (or (run-hook-with-args-until-success 'find-file-not-found-hooks)
-                  ;; If they fail too, set error.
-                  (setq error t)))))
-         ;; Find the file's truename, and maybe use that as visited name.
-         ;; automatically computed in XEmacs, unless jka-compr was used!
-         (unless buffer-file-truename
-           (setq buffer-file-truename truename))
-         (setq buffer-file-number number)
-         ;; On VMS, we may want to remember which directory in a search list
-         ;; the file was found in.
-         (and (eq system-type 'vax-vms)
-              (let (logical)
-                (if (string-match ":" (file-name-directory filename))
-                    (setq logical (substring (file-name-directory filename)
-                                             0 (match-beginning 0))))
-                (not (member logical find-file-not-true-dirname-list)))
-              (setq buffer-file-name buffer-file-truename))
-         (and find-file-use-truenames
-              ;; This should be in C.  Put pathname abbreviations that have
-              ;; been explicitly requested back into the pathname.  Most
-              ;; importantly, strip out automounter /tmp_mnt directories so
-              ;; that auto-save will work
-              (setq buffer-file-name (abbreviate-file-name buffer-file-name)))
-         ;; Set buffer's default directory to that of the file.
-         (setq default-directory (file-name-directory buffer-file-name))
-         ;; Turn off backup files for certain file names.  Since
-         ;; this is a permanent local, the major mode won't eliminate it.
-         (and (not (funcall backup-enable-predicate buffer-file-name))
-              (progn
-                (make-local-variable 'backup-inhibited)
-                (setq backup-inhibited t)))
-         (if rawfile
-             ;; #### FSF 20.3 sets buffer-file-coding-system to
-             ;; `no-conversion' here.  Should we copy?  It also makes
-             ;; `find-file-literally' a local variable and sets it to t.
-             nil
-           (after-find-file error (not nowarn))
-           (setq buf (current-buffer)))))
+         ;; Catch various signals, such as QUIT, and kill the buffer
+         ;; in that case.
+         (condition-case data
+             (progn
+               (set-buffer-major-mode buf)
+               (set-buffer buf)
+               (erase-buffer)
+               (condition-case ()
+                   (if rawfile
+                       (insert-file-contents-literally filename t)
+                     (insert-file-contents filename t))
+                 (file-error
+                  (when (and (file-exists-p filename)
+                             (not (file-readable-p filename)))
+                    (signal 'file-error (list "File is not readable" filename)))
+                  (if rawfile
+                      ;; Unconditionally set error
+                      (setq error t)
+                    (or
+                     ;; Run find-file-not-found-hooks until one returns non-nil.
+                     (run-hook-with-args-until-success 'find-file-not-found-hooks)
+                     ;; If they fail too, set error.
+                     (setq error t)))))
+               ;; Find the file's truename, and maybe use that as visited name.
+               ;; automatically computed in XEmacs, unless jka-compr was used!
+               (unless buffer-file-truename
+                 (setq buffer-file-truename truename))
+               (setq buffer-file-number number)
+               (and find-file-use-truenames
+                    ;; This should be in C.  Put pathname
+                    ;; abbreviations that have been explicitly
+                    ;; requested back into the pathname.  Most
+                    ;; importantly, strip out automounter /tmp_mnt
+                    ;; directories so that auto-save will work
+                    (setq buffer-file-name (abbreviate-file-name buffer-file-name)))
+               ;; Set buffer's default directory to that of the file.
+               (setq default-directory (file-name-directory buffer-file-name))
+               ;; Turn off backup files for certain file names.  Since
+               ;; this is a permanent local, the major mode won't eliminate it.
+               (and (not (funcall backup-enable-predicate buffer-file-name))
+                    (progn
+                      (make-local-variable 'backup-inhibited)
+                      (setq backup-inhibited t)))
+               (if rawfile
+                   ;; #### FSF 20.3 sets buffer-file-coding-system to
+                   ;; `no-conversion' here.  Should we copy?  It also
+                   ;; makes `find-file-literally' a local variable
+                   ;; and sets it to t.
+                   nil
+                 (after-find-file error (not nowarn))
+                 (setq buf (current-buffer))))
+           (t
+            (kill-buffer buf)
+            (signal (car data) (cdr data))))))
       buf)))
 \f
 ;; FSF has `insert-file-literally' and `find-file-literally' here.
       buf)))
 \f
 ;; FSF has `insert-file-literally' and `find-file-literally' here.
@@ -1143,51 +1130,50 @@ run `normal-mode' explicitly."
 
 (defvar auto-mode-alist
   '(("\\.te?xt\\'" . text-mode)
 
 (defvar auto-mode-alist
   '(("\\.te?xt\\'" . text-mode)
-    ("\\.[ch]\\'" . c-mode)
+    ("\\.[chi]\\'" . c-mode)
     ("\\.el\\'" . emacs-lisp-mode)
     ("\\.el\\'" . emacs-lisp-mode)
-    ("\\.\\([CH]\\|cc\\|hh\\)\\'" . c++-mode)
+    ("\\.\\(?:[CH]\\|cc\\|hh\\)\\'" . c++-mode)
     ("\\.[ch]\\(pp\\|xx\\|\\+\\+\\)\\'" . c++-mode)
     ("\\.java\\'" . java-mode)
     ("\\.idl\\'" . idl-mode)
     ("\\.[ch]\\(pp\\|xx\\|\\+\\+\\)\\'" . c++-mode)
     ("\\.java\\'" . java-mode)
     ("\\.idl\\'" . idl-mode)
-    ("\\.f\\(or\\)?\\'" . fortran-mode)
-    ("\\.F\\(OR\\)?\\'" . fortran-mode)
+    ("\\.f\\(?:or\\)?\\'" . fortran-mode)
+    ("\\.F\\(?:OR\\)?\\'" . fortran-mode)
     ("\\.[fF]90\\'" . f90-mode)
 ;;; Less common extensions come here
 ;;; so more common ones above are found faster.
     ("\\.[fF]90\\'" . f90-mode)
 ;;; Less common extensions come here
 ;;; so more common ones above are found faster.
-    ("\\.p[lm]\\'" . perl-mode)
+    ("\\.\\([pP][Llm]\\|al\\)\\'" . perl-mode)
     ("\\.py\\'" . python-mode)
     ("\\.py\\'" . python-mode)
-    ("\\.texi\\(nfo\\)?\\'" . texinfo-mode)
+    ("\\.texi\\(?:nfo\\)?\\'" . texinfo-mode)
     ("\\.ad[abs]\\'" . ada-mode)
     ("\\.ad[abs]\\'" . ada-mode)
-    ("\\.c?l\\(i?sp\\)?\\'" . lisp-mode)
-    ("\\.p\\(as\\)?\\'" . pascal-mode)
+    ("\\.c?l\\(?:i?sp\\)?\\'" . lisp-mode)
+    ("\\.p\\(?:as\\)?\\'" . pascal-mode)
     ("\\.ltx\\'" . latex-mode)
     ("\\.[sS]\\'" . asm-mode)
     ("\\.ltx\\'" . latex-mode)
     ("\\.[sS]\\'" . asm-mode)
-    ("[Cc]hange.?[Ll]og?\\(.[0-9]+\\)?\\'" . change-log-mode)
+    ("[Cc]hange.?[Ll]og?\\(?:.[0-9]+\\)?\\'" . change-log-mode)
     ("\\$CHANGE_LOG\\$\\.TXT" . change-log-mode)
     ("\\.scm?\\(?:\\.[0-9]*\\)?\\'" . scheme-mode)
     ("\\.e\\'" . eiffel-mode)
     ("\\.mss\\'" . scribe-mode)
     ("\\$CHANGE_LOG\\$\\.TXT" . change-log-mode)
     ("\\.scm?\\(?:\\.[0-9]*\\)?\\'" . scheme-mode)
     ("\\.e\\'" . eiffel-mode)
     ("\\.mss\\'" . scribe-mode)
-    ("\\.m\\([mes]\\|an\\)\\'" . nroff-mode)
+    ("\\.m\\(?:[mes]\\|an\\)\\'" . nroff-mode)
     ("\\.icn\\'" . icon-mode)
     ("\\.icn\\'" . icon-mode)
-    ("\\.\\([ckz]?sh\\|shar\\)\\'" . sh-mode)
+    ("\\.\\(?:[ckz]?sh\\|shar\\)\\'" . sh-mode)
     ;; #### Unix-specific!
     ;; #### Unix-specific!
-    ("/\\.\\(bash_\\|z\\)?\\(profile\\|login\||logout\\)\\'" . sh-mode)
-    ("/\\.\\([ckz]sh\\|bash\\|tcsh\\|es\\|xinit\\|startx\\)rc\\'" . sh-mode)
-    ("/\\.\\([kz]shenv\\|xsession\\)\\'" . sh-mode)
+    ("/\\.\\(?:bash_\\|z\\)?\\(profile\\|login\\|logout\\)\\'" . sh-mode)
+    ("/\\.\\(?:[ckz]sh\\|bash\\|tcsh\\|es\\|xinit\\|startx\\)rc\\'" . sh-mode)
+    ("/\\.\\(?:[kz]shenv\\|xsession\\)\\'" . sh-mode)
     ;; The following come after the ChangeLog pattern for the sake of
     ;; ChangeLog.1, etc. and after the .scm.[0-9] pattern too.
     ("\\.[12345678]\\'" . nroff-mode)
     ("\\.[tT]e[xX]\\'" . tex-mode)
     ;; The following come after the ChangeLog pattern for the sake of
     ;; ChangeLog.1, etc. and after the .scm.[0-9] pattern too.
     ("\\.[12345678]\\'" . nroff-mode)
     ("\\.[tT]e[xX]\\'" . tex-mode)
-    ("\\.\\(sty\\|cls\\|bbl\\)\\'" . latex-mode)
+    ("\\.\\(?:sty\\|cls\\|bbl\\)\\'" . latex-mode)
     ("\\.bib\\'" . bibtex-mode)
     ("\\.article\\'" . text-mode)
     ("\\.letter\\'" . text-mode)
     ("\\.bib\\'" . bibtex-mode)
     ("\\.article\\'" . text-mode)
     ("\\.letter\\'" . text-mode)
-    ("\\.\\(tcl\\|exp\\)\\'" . tcl-mode)
+    ("\\.\\(?:tcl\\|exp\\)\\'" . tcl-mode)
     ("\\.wrl\\'" . vrml-mode)
     ("\\.awk\\'" . awk-mode)
     ("\\.prolog\\'" . prolog-mode)
     ("\\.wrl\\'" . vrml-mode)
     ("\\.awk\\'" . awk-mode)
     ("\\.prolog\\'" . prolog-mode)
-    ("\\.tar\\'" . tar-mode)
-    ("\\.\\(arc\\|zip\\|lzh\\|zoo\\)\\'" . archive-mode)
+    ("\\.\\(?:arc\\|zip\\|lzh\\|zoo\\)\\'" . archive-mode)
     ;; Mailer puts message to be edited in /tmp/Re.... or Message
     ;; #### Unix-specific!
     ("\\`/tmp/Re" . text-mode)
     ;; Mailer puts message to be edited in /tmp/Re.... or Message
     ;; #### Unix-specific!
     ("\\`/tmp/Re" . text-mode)
@@ -1201,7 +1187,7 @@ run `normal-mode' explicitly."
     ("\\.oak\\'" . scheme-mode)
     ("\\.s?html?\\'" . html-mode)
     ("\\.htm?l?3\\'" . html3-mode)
     ("\\.oak\\'" . scheme-mode)
     ("\\.s?html?\\'" . html-mode)
     ("\\.htm?l?3\\'" . html3-mode)
-    ("\\.\\(sgml?\\|dtd\\)\\'" . sgml-mode)
+    ("\\.\\(?:sgml?\\|dtd\\)\\'" . sgml-mode)
     ("\\.c?ps\\'" . postscript-mode)
     ;; .emacs following a directory delimiter in either Unix or
     ;; Windows syntax.
     ("\\.c?ps\\'" . postscript-mode)
     ;; .emacs following a directory delimiter in either Unix or
     ;; Windows syntax.
@@ -1214,11 +1200,8 @@ run `normal-mode' explicitly."
     ("\\.X\\(defaults\\|environment\\|resources\\|modmap\\)\\'" . xrdb-mode)
     ;; #### The following three are Unix-specific (but do we care?)
     ("/app-defaults/" . xrdb-mode)
     ("\\.X\\(defaults\\|environment\\|resources\\|modmap\\)\\'" . xrdb-mode)
     ;; #### The following three are Unix-specific (but do we care?)
     ("/app-defaults/" . xrdb-mode)
-    ("\\.[^/]*wm\\'" . winmgr-mode)
-    ("\\.[^/]*wm2?rc" . winmgr-mode)
-    ("\\.[Jj][Pp][Ee]?[Gg]\\'" . image-mode)
-    ("\\.[Pp][Nn][Gg]\\'" . image-mode)
-    ("\\.[Gg][Ii][Ff]\\'" . image-mode)
+    ("\\.[^/]*wm2?\\(?:rc\\)?\\'" . winmgr-mode)
+    ("\\.\\(?:jpe?g\\|JPE?G\\|png\\|PNG\\|gif\\|GIF\\|tiff?\\|TIFF?\\)\\'" . image-mode)
     )
 "Alist of filename patterns vs. corresponding major mode functions.
 Each element looks like (REGEXP . FUNCTION) or (REGEXP FUNCTION NON-NIL).
     )
 "Alist of filename patterns vs. corresponding major mode functions.
 Each element looks like (REGEXP . FUNCTION) or (REGEXP FUNCTION NON-NIL).
@@ -1254,8 +1237,31 @@ The car of each element is a regular expression which is compared
 with the name of the interpreter specified in the first line.
 If it matches, mode MODE is selected.")
 
 with the name of the interpreter specified in the first line.
 If it matches, mode MODE is selected.")
 
-(defvar inhibit-first-line-modes-regexps (purecopy '("\\.tar\\'" "\\.tgz\\'"
-                                                    "\\.tar\\.gz\\'"))
+(defvar binary-file-regexps
+  (purecopy
+   '("\\.\\(?:bz2\\|elc\\|g\\(if\\|z\\)\\|jp\\(eg\\|g\\)\\|png\\|t\\(ar\\|gz\\|iff\\)\\|[Zo]\\)\\'"))
+  "List of regexps of filenames containing binary (non-text) data.")
+
+;   (eval-when-compile
+;     (require 'regexp-opt)
+;     (list
+;      (format "\\.\\(?:%s\\)\\'"
+;            (regexp-opt
+;             '("tar"
+;               "tgz"
+;               "gz"
+;               "bz2"
+;               "Z"
+;               "o"
+;               "elc"
+;               "png"
+;               "gif"
+;               "tiff"
+;               "jpg"
+;               "jpeg"))))))
+  
+(defvar inhibit-first-line-modes-regexps
+  (purecopy binary-file-regexps)
   "List of regexps; if one matches a file name, don't look for `-*-'.")
 
 (defvar inhibit-first-line-modes-suffixes nil
   "List of regexps; if one matches a file name, don't look for `-*-'.")
 
 (defvar inhibit-first-line-modes-suffixes nil
@@ -1305,7 +1311,7 @@ and we don't even do that unless it would come from the file name."
                   (mode nil))
               ;; Find first matching alist entry.
              (let ((case-fold-search
                   (mode nil))
               ;; Find first matching alist entry.
              (let ((case-fold-search
-                    (memq system-type '(vax-vms windows-nt))))
+                    (memq system-type '(windows-nt))))
                (while (and (not mode) alist)
                  (if (string-match (car (car alist)) name)
                      (if (and (consp (cdr (car alist)))
                (while (and (not mode) alist)
                  (if (string-match (car (car alist)) name)
                      (if (and (consp (cdr (car alist)))
@@ -1338,17 +1344,12 @@ and we don't even do that unless it would come from the file name."
                          (setq alist (cdr alist)))))))
               (if mode
                  (if (not (fboundp mode))
                          (setq alist (cdr alist)))))))
               (if mode
                  (if (not (fboundp mode))
-                     (progn
-                       (if (or (not (boundp 'package-get-base))
-                               (not package-get-base))
-                           (load "package-get-base"))
-                       (require 'package-get)
-                       (let ((name (package-get-package-provider mode)))
-                         (if name
-                             (message "Mode %s is not installed.  Download package %s" mode name)
-                           (message "Mode %s either doesn't exist or is not a known package" mode))
-                         (sit-for 2)
-                         (error "%s" mode)))
+                      (let ((name (package-get-package-provider mode)))
+                        (if name
+                            (message "Mode %s is not installed.  Download package %s" mode name)
+                          (message "Mode %s either doesn't exist or is not a known package" mode))
+                        (sit-for 2)
+                        (error "%s" mode))
                    (unless (and just-from-file-name
                                 (or
                                  ;; Don't reinvoke major mode.
                    (unless (and just-from-file-name
                                 (or
                                  ;; Don't reinvoke major mode.
@@ -1723,8 +1724,6 @@ the old visited file has been renamed to the new name FILENAME."
        (let ((new-name (file-name-nondirectory buffer-file-name)))
          (if (string= new-name "")
              (error "Empty file name"))
        (let ((new-name (file-name-nondirectory buffer-file-name)))
          (if (string= new-name "")
              (error "Empty file name"))
-         (if (eq system-type 'vax-vms)
-             (setq new-name (downcase new-name)))
          (setq default-directory (file-name-directory buffer-file-name))
          (or (string= new-name (buffer-name))
              (rename-buffer new-name t))))
          (setq default-directory (file-name-directory buffer-file-name))
          (or (string= new-name (buffer-name))
              (rename-buffer new-name t))))
@@ -1918,9 +1917,7 @@ of the new file to agree with the old modes."
                          ;; Now delete the old versions, if desired.
                          (if delete-old-versions
                              (while targets
                          ;; Now delete the old versions, if desired.
                          (if delete-old-versions
                              (while targets
-                               (condition-case ()
-                                   (delete-file (car targets))
-                                 (file-error nil))
+                               (ignore-file-errors (delete-file (car targets)))
                                (setq targets (cdr targets))))
                          setmodes)
                      (file-error nil)))))))))
                                (setq targets (cdr targets))))
                          setmodes)
                      (file-error nil)))))))))
@@ -1935,28 +1932,17 @@ we do not remove backup version numbers, only true file version numbers."
     (if handler
        (funcall handler 'file-name-sans-versions name keep-backup-version)
       (substring name 0
     (if handler
        (funcall handler 'file-name-sans-versions name keep-backup-version)
       (substring name 0
-                (if (eq system-type 'vax-vms)
-                    ;; VMS version number is (a) semicolon, optional
-                    ;; sign, zero or more digits or (b) period, option
-                    ;; sign, zero or more digits, provided this is the
-                    ;; second period encountered outside of the
-                    ;; device/directory part of the file name.
-                    (or (string-match ";[-+]?[0-9]*\\'" name)
-                        (if (string-match "\\.[^]>:]*\\(\\.[-+]?[0-9]*\\)\\'"
-                                          name)
-                            (match-beginning 1))
-                        (length name))
-                  (if keep-backup-version
-                      (length name)
-                    (or (string-match "\\.~[0-9.]+~\\'" name)
-                        ;; XEmacs - VC uses extensions like ".~tagname~" or ".~1.1.5.2~"
-                        (let ((pos (string-match "\\.~\\([^.~ \t]+\\|[0-9.]+\\)~\\'" name)))
-                          (and pos
-                               ;; #### - is this filesystem check too paranoid?
-                               (file-exists-p (substring name 0 pos))
-                               pos))
-                        (string-match "~\\'" name)
-                        (length name))))))))
+                (if keep-backup-version
+                    (length name)
+                  (or (string-match "\\.~[0-9.]+~\\'" name)
+                      ;; XEmacs - VC uses extensions like ".~tagname~" or ".~1.1.5.2~"
+                      (let ((pos (string-match "\\.~\\([^.~ \t]+\\|[0-9.]+\\)~\\'" name)))
+                        (and pos
+                             ;; #### - is this filesystem check too paranoid?
+                             (file-exists-p (substring name 0 pos))
+                             pos))
+                      (string-match "~\\'" name)
+                      (length name)))))))
 
 (defun file-ownership-preserved-p (file)
   "Return t if deleting FILE and rewriting it would preserve the owner."
 
 (defun file-ownership-preserved-p (file)
   "Return t if deleting FILE and rewriting it would preserve the owner."
@@ -2031,8 +2017,6 @@ the index in the name where the version number begins."
       (string-to-int (substring fn bv-length -1))
       0))
 
       (string-to-int (substring fn bv-length -1))
       0))
 
-;; I believe there is no need to alter this behavior for VMS;
-;; since backup files are not made on VMS, it should not get called.
 (defun find-backup-file-name (fn)
   "Find a file name for a backup file, and suggestions for deletions.
 Value is a list whose car is the name for the backup file
 (defun find-backup-file-name (fn)
   "Find a file name for a backup file, and suggestions for deletions.
 Value is a list whose car is the name for the backup file
@@ -2097,8 +2081,7 @@ then it returns FILENAME."
                       (expand-file-name (or directory default-directory))))
       ;; On Microsoft OSes, if FILENAME and DIRECTORY have different
       ;; drive names, they can't be relative, so return the absolute name.
                       (expand-file-name (or directory default-directory))))
       ;; On Microsoft OSes, if FILENAME and DIRECTORY have different
       ;; drive names, they can't be relative, so return the absolute name.
-      (if (and (or (eq system-type 'ms-dos)
-                  (eq system-type 'windows-nt))
+      (if (and (memq system-type '(ms-dos windows-nt))
               (not (string-equal (substring fname  0 2)
                                  (substring directory 0 2))))
          filename
               (not (string-equal (substring fname  0 2)
                                  (substring directory 0 2))))
          filename
@@ -2168,9 +2151,7 @@ since the last real save, but optional arg FORCE non-nil means delete anyway."
        (not (string= buffer-file-name buffer-auto-save-file-name))
        (or force (recent-auto-save-p))
        (progn
        (not (string= buffer-file-name buffer-auto-save-file-name))
        (or force (recent-auto-save-p))
        (progn
-        (condition-case ()
-            (delete-file buffer-auto-save-file-name)
-          (file-error nil))
+        (ignore-file-errors (delete-file buffer-auto-save-file-name))
         (set-buffer-auto-saved))))
 
 ;; XEmacs change (from Sun)
         (set-buffer-auto-saved))))
 
 ;; XEmacs change (from Sun)
@@ -2212,19 +2193,6 @@ After saving the buffer, run `after-save-hook'."
        (set-buffer (buffer-base-buffer)))
     (if (buffer-modified-p)
        (let ((recent-save (recent-auto-save-p)))
        (set-buffer (buffer-base-buffer)))
     (if (buffer-modified-p)
        (let ((recent-save (recent-auto-save-p)))
-         ;; On VMS, rename file and buffer to get rid of version number.
-         (if (and (eq system-type 'vax-vms)
-                  (not (string= buffer-file-name
-                                (file-name-sans-versions buffer-file-name))))
-             (let (buffer-new-name)
-               ;; Strip VMS version number before save.
-               (setq buffer-file-name
-                     (file-name-sans-versions buffer-file-name))
-               ;; Construct a (unique) buffer name to correspond.
-               (let ((buf (create-file-buffer (downcase buffer-file-name))))
-                 (setq buffer-new-name (buffer-name buf))
-                 (kill-buffer buf))
-               (rename-buffer buffer-new-name)))
          ;; If buffer has no file name, ask user for one.
          (or buffer-file-name
              (let ((filename
          ;; If buffer has no file name, ask user for one.
          (or buffer-file-name
              (let ((filename
@@ -2783,12 +2751,11 @@ non-nil, it is called instead of rereading visited file contents."
                 (not (file-exists-p file-name)))
               (error "Auto-save file %s not current" file-name))
              ((save-window-excursion
                 (not (file-exists-p file-name)))
               (error "Auto-save file %s not current" file-name))
              ((save-window-excursion
-                (if (not (eq system-type 'vax-vms))
-                    (with-output-to-temp-buffer "*Directory*"
-                      (buffer-disable-undo standard-output)
-                      (call-process "ls" nil standard-output nil
-                                    (if (file-symlink-p file) "-lL" "-l")
-                                    file file-name)))
+                (with-output-to-temp-buffer "*Directory*"
+                  (buffer-disable-undo standard-output)
+                  (call-process "ls" nil standard-output nil
+                                (if (file-symlink-p file) "-lL" "-l")
+                                file file-name))
                 (yes-or-no-p (format "Recover auto save file %s? " file-name)))
               (switch-to-buffer (find-file-noselect file t))
               (let ((buffer-read-only nil))
                 (yes-or-no-p (format "Recover auto save file %s? " file-name)))
               (switch-to-buffer (find-file-noselect file t))
               (let ((buffer-read-only nil))
@@ -3088,16 +3055,12 @@ by `sh' are supported."
     ;; not its part.  Make the regexp say so.
     (concat "\\`" result "\\'")))
 \f
     ;; not its part.  Make the regexp say so.
     (concat "\\`" result "\\'")))
 \f
-(defcustom list-directory-brief-switches
-  (if (eq system-type 'vax-vms) "" "-CF")
+(defcustom list-directory-brief-switches "-CF"
   "*Switches for list-directory to pass to `ls' for brief listing."
   :type 'string
   :group 'dired)
 
   "*Switches for list-directory to pass to `ls' for brief listing."
   :type 'string
   :group 'dired)
 
-(defcustom list-directory-verbose-switches
-  (if (eq system-type 'vax-vms)
-      "/PROTECTION/SIZE/DATE/OWNER/WIDTH=(OWNER:10)"
-    "-l")
+(defcustom list-directory-verbose-switches "-l"
   "*Switches for list-directory to pass to `ls' for verbose listing,"
   :type 'string
   :group 'dired)
   "*Switches for list-directory to pass to `ls' for verbose listing,"
   :type 'string
   :group 'dired)
@@ -3167,8 +3130,6 @@ If WILDCARD, it also runs the shell specified by `shell-file-name'."
        (funcall handler 'insert-directory file switches
                 wildcard full-directory-p)
       (cond
        (funcall handler 'insert-directory file switches
                 wildcard full-directory-p)
       (cond
-       ((eq system-type 'vax-vms)
-       (vms-read-directory file switches (current-buffer)))
        ((and (fboundp 'mswindows-insert-directory)
             (eq system-type 'windows-nt))
        (mswindows-insert-directory file switches wildcard full-directory-p))
        ((and (fboundp 'mswindows-insert-directory)
             (eq system-type 'windows-nt))
        (mswindows-insert-directory file switches wildcard full-directory-p))