]> code.delx.au - gnu-emacs/blobdiff - lisp/files.el
(revert-buffer): Fix previous change.
[gnu-emacs] / lisp / files.el
index fdc4464da869d95bd36441df90dd00c7c26391d7..9228e5476423b5e1d629e0bd5a21276987d11b89 100644 (file)
@@ -514,6 +514,9 @@ using \\[toggle-read-only]."
   :type 'boolean
   :group 'view)
 
+(defvar file-name-history nil
+  "History list of file names entered in the minibuffer.")
+\f
 (put 'ange-ftp-completion-hook-function 'safe-magic t)
 (defun ange-ftp-completion-hook-function (op &rest args)
   "Provides support for ange-ftp host name completion.
@@ -540,13 +543,21 @@ is a valid DOS file name, but c:/bar/c:/foo is not.
 
 This function's standard definition is trivial; it just returns
 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
+characters.  On DOS, make sure to obey the 8.3 limitations.
+In the native Windows build, turn Cygwin names into native names,
+and also turn slashes into backslashes if the shell requires it (see
 `w32-shell-dos-semantics').
 
 See Info node `(elisp)Standard File Names' for more details."
-  filename)
+  (if (eq system-type 'cygwin)
+      (let ((name (copy-sequence filename))
+           (start 0))
+       ;; Replace invalid filename characters with !
+       (while (string-match "[?*:<>|\"\000-\037]" name start)
+         (aset name (match-beginning 0) ?!)
+         (setq start (match-end 0)))
+       name)
+    filename))
 
 (defun read-directory-name (prompt &optional dir default-dirname mustmatch initial)
   "Read directory name, prompting with PROMPT and completing in directory DIR.
@@ -1109,13 +1120,15 @@ expand wildcards (if any) and visit multiple files."
                (mapcar 'switch-to-buffer (cdr value))))
       (switch-to-buffer-other-frame value))))
 
-(defun find-file-existing (filename &optional wildcards)
-  "Edit the existing file FILENAME.
-Like \\[find-file] but only allow a file that exists."
-  (interactive (find-file-read-args "Find existing file: " t))
-  (unless (file-exists-p filename) (error "%s does not exist" filename))
-  (find-file filename wildcards)
-  (current-buffer))
+(defun find-file-existing (filename)
+   "Edit the existing file FILENAME.
+Like \\[find-file] but only allow a file that exists, and do not allow
+file names with wildcards."
+   (interactive (nbutlast (find-file-read-args "Find existing file: " t)))
+   (if (and (not (interactive-p)) (not (file-exists-p filename)))
+       (error "%s does not exist" filename)
+     (find-file filename)
+     (current-buffer)))
 
 (defun find-file-read-only (filename &optional wildcards)
   "Edit file FILENAME but don't allow changes.
@@ -1302,7 +1315,7 @@ removes automounter prefixes (see the variable `automount-dir-prefix')."
          (setq abbreviated-home-dir
                (let ((abbreviated-home-dir "$foo"))
                  (concat "^" (abbreviate-file-name (expand-file-name "~"))
-                         "\\(/\\|$\\)"))))
+                         "\\(/\\|\\'\\)"))))
 
       ;; If FILENAME starts with the abbreviated homedir,
       ;; make it start with `~' instead.
@@ -1357,7 +1370,7 @@ If there is no such live buffer, return nil."
                (number (nthcdr 10 attributes))
                (list (buffer-list)) found)
           (and buffer-file-numbers-unique
-               number
+               (car-safe number)       ;Make sure the inode is not just nil.
                (while (and (not found) list)
                  (with-current-buffer (car list)
                    (if (and buffer-file-name
@@ -1896,7 +1909,7 @@ in that case, this function acts as if `enable-local-variables' were t."
      ("\\.[sS]\\'" . asm-mode)
      ("\\.asm\\'" . asm-mode)
      ("[cC]hange\\.?[lL]og?\\'" . change-log-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)
      ("\\.[ck]?sh\\'\\|\\.shar\\'\\|/\\.z?profile\\'" . sh-mode)
@@ -2387,10 +2400,10 @@ asking you for confirmation."
 ;;
 ;; For variables defined in the C source code the declaration should go here:
 
-;; FIXME: Some variables should be moved according to the rules above.
 (mapc (lambda (pair)
        (put (car pair) 'safe-local-variable (cdr pair)))
-      '((fill-column                     . integerp) ;; C source code
+      '((buffer-read-only                . booleanp) ;; C source code
+       (fill-column                     . integerp) ;; C source code
        (indent-tabs-mode                . booleanp) ;; C source code
        (left-margin                     . integerp) ;; C source code
        (no-update-autoloads             . booleanp)
@@ -2688,8 +2701,8 @@ It is dangerous if either of these conditions are met:
 
  * Its name ends with \"hook(s)\", \"function(s)\", \"form(s)\", \"map\",
    \"program\", \"command(s)\", \"predicate(s)\", \"frame-alist\",
-   \"mode-alist\", \"font-lock-(syntactic-)keyword*\", or
-   \"map-alist\"."
+   \"mode-alist\", \"font-lock-(syntactic-)keyword*\",
+   \"map-alist\", or \"bindat-spec\"."
   ;; If this is an alias, check the base name.
   (condition-case nil
       (setq sym (indirect-variable sym))
@@ -2698,7 +2711,7 @@ It is dangerous if either of these conditions are met:
       (string-match "-hooks?$\\|-functions?$\\|-forms?$\\|-program$\\|\
 -commands?$\\|-predicates?$\\|font-lock-keywords$\\|font-lock-keywords\
 -[0-9]+$\\|font-lock-syntactic-keywords$\\|-frame-alist$\\|-mode-alist$\\|\
--map$\\|-map-alist$" (symbol-name sym))))
+-map$\\|-map-alist$\\|-bindat-spec$" (symbol-name sym))))
 
 (defun hack-one-local-variable-quotep (exp)
   (and (consp exp) (eq (car exp) 'quote) (consp (cdr exp))))
@@ -3720,9 +3733,15 @@ This requires the external program `diff' to be in your `exec-path'."
        (recursive-edit)
        ;; Return nil to ask about BUF again.
        nil)
-     "view this file")
-    (?d diff-buffer-with-file
-       "view changes in file"))
+     "view this buffer")
+    (?d (lambda (buf)
+         (save-window-excursion
+           (diff-buffer-with-file buf))
+         (view-buffer (get-buffer-create "*Diff*")
+                      (lambda (ignore) (exit-recursive-edit)))
+         (recursive-edit)
+         nil)
+       "view changes in this buffer"))
   "ACTION-ALIST argument used in call to `map-y-or-n-p'.")
 
 (defvar buffer-save-without-query nil
@@ -4075,6 +4094,16 @@ non-nil, it is called instead of rereading visited file contents."
                          (if auto-save-p 'auto-save-coding
                            (or coding-system-for-read
                                buffer-file-coding-system-explicit))))
+                    (if (and (not enable-multibyte-characters)
+                             coding-system-for-read
+                             (not (memq (coding-system-base
+                                         coding-system-for-read)
+                                        '(no-conversion raw-text))))
+                        ;; As a coding system suitable for multibyte
+                        ;; buffer is specified, make the current
+                        ;; buffer multibyte.
+                        (set-buffer-multibyte t))
+
                     ;; This force after-insert-file-set-coding
                     ;; (called from insert-file-contents) to set
                     ;; buffer-file-coding-system to a proper value.
@@ -4368,7 +4397,7 @@ See also `auto-save-file-name-p'."
                            "#")))
            ;; Make sure auto-save file names don't contain characters
            ;; invalid for the underlying filesystem.
-           (if (and (memq system-type '(ms-dos windows-nt))
+           (if (and (memq system-type '(ms-dos windows-nt cygwin))
                     ;; Don't modify remote (ange-ftp) filenames
                     (not (string-match "^/\\w+@[-A-Za-z0-9._]+:" result)))
                (convert-standard-filename result)
@@ -4403,7 +4432,7 @@ See also `auto-save-file-name-p'."
                      ((file-writable-p default-directory) default-directory)
                      ((file-writable-p "/var/tmp/") "/var/tmp/")
                      ("~/")))))
-              (if (and (memq system-type '(ms-dos windows-nt))
+              (if (and (memq system-type '(ms-dos windows-nt cygwin))
                        ;; Don't modify remote (ange-ftp) filenames
                        (not (string-match "^/\\w+@[-A-Za-z0-9._]+:" fname)))
                   ;; The call to convert-standard-filename is in case