XEmacs 21.2.25 "Hephaestus".
[chise/xemacs-chise.git.1] / lisp / files.el
index fd4585a..e643925 100644 (file)
@@ -788,37 +788,36 @@ 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 (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))))
-      (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 (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)))))))
+      (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
@@ -1131,7 +1130,7 @@ run `normal-mode' explicitly."
 
 (defvar auto-mode-alist
   '(("\\.te?xt\\'" . text-mode)
-    ("\\.[ch]\\'" . c-mode)
+    ("\\.[chi]\\'" . c-mode)
     ("\\.el\\'" . emacs-lisp-mode)
     ("\\.\\(?:[CH]\\|cc\\|hh\\)\\'" . c++-mode)
     ("\\.[ch]\\(pp\\|xx\\|\\+\\+\\)\\'" . c++-mode)
@@ -1159,7 +1158,7 @@ run `normal-mode' explicitly."
     ("\\.icn\\'" . icon-mode)
     ("\\.\\(?:[ckz]?sh\\|shar\\)\\'" . sh-mode)
     ;; #### Unix-specific!
-    ("/\\.\\(?:bash_\\|z\\)?\\(profile\\|login\||logout\\)\\'" . 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
@@ -1222,7 +1221,9 @@ REGEXP and search the list again for another match.")
     ("python" . python-mode)
     ("awk\\b" . awk-mode)
     ("rexx"   . rexx-mode)
-    ("scm"    . scheme-mode)
+    ("scm\\|guile" . scheme-mode)
+    ("emacs" . emacs-lisp-mode)
+    ("make" . makefile-mode)
     ("^:"     . sh-mode))
   "Alist mapping interpreter names to major modes.
 This alist is used to guess the major mode of a file based on the
@@ -1271,7 +1272,7 @@ When checking `inhibit-first-line-modes-regexps', we first discard
 from the end of the file name anything that matches one of these regexps.")
 
 (defvar user-init-file
-  "" ; set by command-line
+  nil ; set by command-line
   "File name including directory of user's initialization file.")
 
 (defun set-auto-mode (&optional just-from-file-name)
@@ -2212,19 +2213,21 @@ After saving the buffer, run `after-save-hook'."
              (error "Save not confirmed"))
          (save-restriction
            (widen)
-           (and (> (point-max) 1)
-                (/= (char-after (1- (point-max))) ?\n)
-                (not (and (eq selective-display t)
-                          (= (char-after (1- (point-max))) ?\r)))
-                (or (eq require-final-newline t)
-                    (and require-final-newline
-                         (y-or-n-p
-                          (format "Buffer %s does not end in newline.  Add one? "
-                                  (buffer-name)))))
-                (save-excursion
-                  (goto-char (point-max))
-                  (insert ?\n)))
-           ;;
+
+           ;; Add final newline if required.  See `require-final-newline'.
+           (when (and (not (eq (char-before (point-max)) ?\n)) ; common case
+                      (char-before (point-max))                ; empty buffer?
+                      (not (and (eq selective-display t)
+                                (eq (char-before (point-max)) ?\r)))
+                      (or (eq require-final-newline t)
+                          (and require-final-newline
+                               (y-or-n-p
+                                (format "Buffer %s does not end in newline.  Add one? "
+                                        (buffer-name))))))
+             (save-excursion
+               (goto-char (point-max))
+               (insert ?\n)))
+
            ;; Run the write-file-hooks until one returns non-null.
            ;; Bind after-save-hook to nil while running the
            ;; write-file-hooks so that if this function is called
@@ -2752,11 +2755,12 @@ 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
-                (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))
+                (if (not (eq system-type 'windows-nt))
+                    (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))