emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/files.el [emacs-unicode-2]


From: Miles Bader
Subject: [Emacs-diffs] Changes to emacs/lisp/files.el [emacs-unicode-2]
Date: Mon, 28 Jun 2004 04:55:38 -0400

Index: emacs/lisp/files.el
diff -c emacs/lisp/files.el:1.666.2.2 emacs/lisp/files.el:1.666.2.3
*** emacs/lisp/files.el:1.666.2.2       Fri Apr 16 12:49:50 2004
--- emacs/lisp/files.el Mon Jun 28 07:28:39 2004
***************
*** 293,299 ****
    :group 'auto-save)
  
  (defcustom auto-save-file-name-transforms
!   `(("\\`/[^/]*:\\(.+/\\)*\\(.*\\)"
       ;; Don't put "\\2" inside expand-file-name, since it will be
       ;; transformed to "/2" on DOS/Windows.
       ,(concat temporary-file-directory "\\2") t))
--- 293,299 ----
    :group 'auto-save)
  
  (defcustom auto-save-file-name-transforms
!   `(("\\`/[^/]*:\\([^/]*/\\)*\\([^/]*\\)\\'"
       ;; Don't put "\\2" inside expand-file-name, since it will be
       ;; transformed to "/2" on DOS/Windows.
       ,(concat temporary-file-directory "\\2") t))
***************
*** 481,490 ****
  
  (defun convert-standard-filename (filename)
    "Convert a standard file's name to something suitable for the current OS.
! This function's standard definition is trivial; it just returns the argument.
! However, on some systems, the function is redefined with a definition
! that really does change some file names to canonicalize certain
! patterns and to guarantee valid names."
    filename)
  
  (defun read-directory-name (prompt &optional dir default-dirname mustmatch 
initial)
--- 481,495 ----
  
  (defun convert-standard-filename (filename)
    "Convert a standard file's name to something suitable for the current OS.
! This means to guarantee valid names and perhaps to canonicalize
! certain patterns.
! 
! 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
! `w32-shell-dos-semantics')."
    filename)
  
  (defun read-directory-name (prompt &optional dir default-dirname mustmatch 
initial)
***************
*** 521,528 ****
  Not actually set up until the first time you use it.")
  
  (defun parse-colon-path (cd-path)
!   "Explode a colon-separated search path into a list of directory names.
! \(For values of `colon' equal to `path-separator'.)"
    ;; We could use split-string here.
    (and cd-path
         (let (cd-list (cd-start 0) cd-colon)
--- 526,534 ----
  Not actually set up until the first time you use it.")
  
  (defun parse-colon-path (cd-path)
!   "Explode a search path into a list of directory names.
! Directories are separated by occurrences of `path-separator'
! \(which is colon in GNU and GNU-like systems)."
    ;; We could use split-string here.
    (and cd-path
         (let (cd-list (cd-start 0) cd-colon)
***************
*** 555,562 ****
  
  (defun cd (dir)
    "Make DIR become the current buffer's default directory.
! If your environment includes a `CDPATH' variable, try each one of that
! colon-separated list of directories when resolving a relative directory name."
    (interactive
     (list (read-directory-name "Change default directory: "
                         default-directory default-directory
--- 561,570 ----
  
  (defun cd (dir)
    "Make DIR become the current buffer's default directory.
! If your environment includes a `CDPATH' variable, try each one of
! that list of directories (separated by occurrences of
! `path-separator') when resolving a relative directory name.
! The path separator is colon in GNU and GNU-like systems."
    (interactive
     (list (read-directory-name "Change default directory: "
                         default-directory default-directory
***************
*** 616,621 ****
--- 624,631 ----
          (suffix (concat (regexp-opt (cdr path-and-suffixes) t) "\\'"))
          (string-dir (file-name-directory string)))
        (dolist (dir (car path-and-suffixes))
+       (unless dir
+         (setq dir default-directory))
        (if string-dir (setq dir (expand-file-name string-dir dir)))
        (when (file-directory-p dir)
          (dolist (file (file-name-all-completions
***************
*** 640,648 ****
  
  (defun file-remote-p (file)
    "Test whether FILE specifies a location on a remote system."
!   (let ((handler (find-file-name-handler file 'file-local-copy)))
      (if handler
!       (get handler 'file-remote-p))))
  
  (defun file-local-copy (file)
    "Copy the file FILE into a temporary file on this machine.
--- 650,659 ----
  
  (defun file-remote-p (file)
    "Test whether FILE specifies a location on a remote system."
!   (let ((handler (find-file-name-handler file 'file-remote-p)))
      (if handler
!       (funcall handler 'file-remote-p file)
!       nil)))
  
  (defun file-local-copy (file)
    "Copy the file FILE into a temporary file on this machine.
***************
*** 661,681 ****
  both at the level of the file and at the level of the directories
  containing it, until no links are left at any level.
  
! The arguments COUNTER and PREV-DIRS are used only in recursive calls.
! Do not specify them in other calls."
!   ;; COUNTER can be a cons cell whose car is the count of how many more links
!   ;; to chase before getting an error.
    ;; PREV-DIRS can be a cons cell whose car is an alist
    ;; of truenames we've just recently computed.
  
-   ;; The last test looks dubious, maybe `+' is meant here?  --simon.
-   (if (or (string= filename "") (string= filename "~")
-         (and (string= (substring filename 0 1) "~")
-              (string-match "~[^/]*" filename)))
-       (progn
-       (setq filename (expand-file-name filename))
-       (if (string= filename "")
-           (setq filename "/"))))
    (or counter (setq counter (list 100)))
    (let (done
        ;; For speed, remove the ange-ftp completion handler from the list.
--- 672,694 ----
  both at the level of the file and at the level of the directories
  containing it, until no links are left at any level.
  
! \(fn FILENAME)"
!   ;; COUNTER and PREV-DIRS are only used in recursive calls.
!   ;; COUNTER can be a cons cell whose car is the count of how many
!   ;; more links to chase before getting an error.
    ;; PREV-DIRS can be a cons cell whose car is an alist
    ;; of truenames we've just recently computed.
+   (cond ((or (string= filename "") (string= filename "~"))
+        (setq filename (expand-file-name filename))
+        (if (string= filename "")
+            (setq filename "/")))
+       ((and (string= (substring filename 0 1) "~")
+             (string-match "~[^/]*/?" filename))
+        (let ((first-part
+               (substring filename 0 (match-end 0)))
+              (rest (substring filename (match-end 0))))
+          (setq filename (concat (expand-file-name first-part) rest)))))
  
    (or counter (setq counter (list 100)))
    (let (done
        ;; For speed, remove the ange-ftp completion handler from the list.
***************
*** 901,908 ****
  type M-n to pull it into the minibuffer.
  
  Interactively, or if WILDCARDS is non-nil in a call from Lisp,
! expand wildcards (if any) and visit multiple files.  Wildcard expansion
! can be suppressed by setting `find-file-wildcards'."
    (interactive
     (find-file-read-args "Find file: " nil))
    (let ((value (find-file-noselect filename nil nil wildcards)))
--- 914,924 ----
  type M-n to pull it into the minibuffer.
  
  Interactively, or if WILDCARDS is non-nil in a call from Lisp,
! expand wildcards (if any) and visit multiple files.  You can
! suppress wildcard expansion by setting `find-file-wildcards'.
! 
! To visit a file without any kind of conversion and without
! automatically choosing a major mode, use \\[find-file-literally]."
    (interactive
     (find-file-read-args "Find file: " nil))
    (let ((value (find-file-noselect filename nil nil wildcards)))
***************
*** 1353,1373 ****
                                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)
        ;; Needed in case we are re-visiting the file with a different
        ;; text representation.
        (kill-local-variable 'buffer-file-coding-system)
        (kill-local-variable 'cursor-type)
!       (erase-buffer)
        (and (default-value 'enable-multibyte-characters)
           (not rawfile)
           (set-buffer-multibyte t))
        (if rawfile
          (condition-case ()
!             (insert-file-contents-literally filename t)
            (file-error
             (when (and (file-exists-p filename)
                        (not (file-readable-p filename)))
--- 1369,1390 ----
                                rawfile truename number))))))
  
  (defun find-file-noselect-1 (buf filename nowarn rawfile truename number)
!   (let (error)
      (with-current-buffer buf
        (kill-local-variable 'find-file-literally)
        ;; Needed in case we are re-visiting the file with a different
        ;; text representation.
        (kill-local-variable 'buffer-file-coding-system)
        (kill-local-variable 'cursor-type)
!       (let ((inhibit-read-only t))
!       (erase-buffer))
        (and (default-value 'enable-multibyte-characters)
           (not rawfile)
           (set-buffer-multibyte t))
        (if rawfile
          (condition-case ()
!             (let ((inhibit-read-only t))
!               (insert-file-contents-literally filename t))
            (file-error
             (when (and (file-exists-p filename)
                        (not (file-readable-p filename)))
***************
*** 1377,1383 ****
             ;; 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)))
--- 1394,1401 ----
             ;; Unconditionally set error
             (setq error t)))
        (condition-case ()
!           (let ((inhibit-read-only t))
!             (insert-file-contents filename t))
          (file-error
           (when (and (file-exists-p filename)
                      (not (file-readable-p filename)))
***************
*** 2325,2331 ****
  (defun set-visited-file-name (filename &optional no-query along-with-file)
    "Change name of file visited in current buffer to FILENAME.
  The next time the buffer is saved it will go in the newly specified file.
! nil or empty string as argument means make buffer not be visiting any file.
  Remember to delete the initial contents of the minibuffer
  if you wish to pass an empty string as the argument.
  
--- 2343,2349 ----
  (defun set-visited-file-name (filename &optional no-query along-with-file)
    "Change name of file visited in current buffer to FILENAME.
  The next time the buffer is saved it will go in the newly specified file.
! FILENAME nil or an empty string means make buffer not be visiting any file.
  Remember to delete the initial contents of the minibuffer
  if you wish to pass an empty string as the argument.
  
***************
*** 2897,2906 ****
          (file-name-as-directory (expand-file-name (or directory
                                                        default-directory))))
      (setq filename (expand-file-name filename))
!     (let ((hf (find-file-name-handler filename 'file-local-copy))
!           (hd (find-file-name-handler directory 'file-local-copy)))
!       (when (and hf (not (get hf 'file-remote-p))) (setq hf nil))
!       (when (and hd (not (get hd 'file-remote-p))) (setq hd nil))
        (if ;; Conditions for separate trees
          (or
           ;; Test for different drives on DOS/Windows
--- 2915,2922 ----
          (file-name-as-directory (expand-file-name (or directory
                                                        default-directory))))
      (setq filename (expand-file-name filename))
!     (let ((hf (find-file-name-handler filename 'file-remote-p))
!           (hd (find-file-name-handler directory 'file-remote-p)))
        (if ;; Conditions for separate trees
          (or
           ;; Test for different drives on DOS/Windows
***************
*** 3010,3016 ****
  
  (defcustom before-save-hook nil
    "Normal hook that is run before a buffer is saved to its file."
!   :options '(copyright-update)
    :type 'hook
    :group 'files)
  
--- 3026,3032 ----
  
  (defcustom before-save-hook nil
    "Normal hook that is run before a buffer is saved to its file."
!   :options '(copyright-update time-stamp)
    :type 'hook
    :group 'files)
  
***************
*** 3466,3472 ****
  The idea behind the NOCONFIRM argument is that it should be
  non-nil if the buffer is going to be reverted without asking the
  user.  In such situations, one has to be careful with potentially
! time consuming operations.")
  
  (defvar before-revert-hook nil
    "Normal hook for `revert-buffer' to run before reverting.
--- 3482,3491 ----
  The idea behind the NOCONFIRM argument is that it should be
  non-nil if the buffer is going to be reverted without asking the
  user.  In such situations, one has to be careful with potentially
! time consuming operations.
! 
! For more information on how this variable is used by Auto Revert mode,
! see Info node `(emacs-xtra)Supporting additional buffers'.")
  
  (defvar before-revert-hook nil
    "Normal hook for `revert-buffer' to run before reverting.
***************
*** 4019,4025 ****
    "Expand wildcard pattern PATTERN.
  This returns a list of file names which match the pattern.
  
! If PATTERN is written as an absolute relative file name,
  the values are absolute also.
  
  If PATTERN is written as a relative file name, it is interpreted
--- 4038,4044 ----
    "Expand wildcard pattern PATTERN.
  This returns a list of file names which match the pattern.
  
! If PATTERN is written as an absolute file name,
  the values are absolute also.
  
  If PATTERN is written as a relative file name, it is interpreted
***************
*** 4230,4236 ****
  whose name is in the variable `insert-directory-program'.
  If WILDCARD, it also runs the shell specified by `shell-file-name'.
  
! When SWITCHES contains the long `--dired' option,this function
  treats it specially, for the sake of dired.  However, the
  normally equivalent short `-D' option is just passed on to
  `insert-directory-program', as any other option."
--- 4249,4255 ----
  whose name is in the variable `insert-directory-program'.
  If WILDCARD, it also runs the shell specified by `shell-file-name'.
  
! When SWITCHES contains the long `--dired' option, this function
  treats it specially, for the sake of dired.  However, the
  normally equivalent short `-D' option is just passed on to
  `insert-directory-program', as any other option."
***************
*** 4307,4312 ****
--- 4326,4333 ----
  
          ;; If `insert-directory-program' failed, signal an error.
          (unless (eq 0 result)
+           ;; Delete the error message it may have output.
+           (delete-region beg (point))
            ;; On non-Posix systems, we cannot open a directory, so
            ;; don't even try, because that will always result in
            ;; the ubiquitous "Access denied".  Instead, show the
***************
*** 4329,4349 ****
              (when (looking-at "//SUBDIRED//")
                (delete-region (point) (progn (forward-line 1) (point)))
                (forward-line -1))
!           (let ((end (line-end-position)))
!             (forward-word 1)
!             (forward-char 3)
!             (while (< (point) end)
!               (let ((start (+ beg (read (current-buffer))))
!                     (end (+ beg (read (current-buffer)))))
!                 (if (= (char-after end) ?\n)
!                     (put-text-property start end 'dired-filename t)
!                   ;; It seems that we can't trust ls's output as to
!                   ;; byte positions of filenames.
!                   (put-text-property beg (point) 'dired-filename nil)
!                   (end-of-line))))
!             (goto-char end)
!             (beginning-of-line)
!             (delete-region (point) (progn (forward-line 2) (point)))))
  
          ;; Now decode what read if necessary.
          (let ((coding (or coding-system-for-read
--- 4350,4375 ----
              (when (looking-at "//SUBDIRED//")
                (delete-region (point) (progn (forward-line 1) (point)))
                (forward-line -1))
!           (if (looking-at "//DIRED//")
!               (let ((end (line-end-position)))
!                 (forward-word 1)
!                 (forward-char 3)
!                 (while (< (point) end)
!                   (let ((start (+ beg (read (current-buffer))))
!                         (end (+ beg (read (current-buffer)))))
!                     (if (= (char-after end) ?\n)
!                         (put-text-property start end 'dired-filename t)
!                       ;; It seems that we can't trust ls's output as to
!                       ;; byte positions of filenames.
!                       (put-text-property beg (point) 'dired-filename nil)
!                       (end-of-line))))
!                 (goto-char end)
!                 (beginning-of-line)
!                 (delete-region (point) (progn (forward-line 2) (point))))
!             (forward-line 1)
!             (if (looking-at "//DIRED-OPTIONS//")
!                 (delete-region (point) (progn (forward-line 1) (point)))
!               (forward-line 1))))
  
          ;; Now decode what read if necessary.
          (let ((coding (or coding-system-for-read
***************
*** 4416,4422 ****
    :type '(choice (const :tag "Ask with yes-or-no-p" yes-or-no-p)
                 (const :tag "Ask with y-or-n-p" y-or-n-p)
                 (const :tag "Don't confirm" nil))
!   :group 'emacs
    :version "21.1")
  
  (defun save-buffers-kill-emacs (&optional arg)
--- 4442,4448 ----
    :type '(choice (const :tag "Ask with yes-or-no-p" yes-or-no-p)
                 (const :tag "Ask with y-or-n-p" y-or-n-p)
                 (const :tag "Don't confirm" nil))
!   :group 'convenience
    :version "21.1")
  
  (defun save-buffers-kill-emacs (&optional arg)
***************
*** 4470,4476 ****
        ;; Get a list of the indices of the args which are file names.
        (file-arg-indices
         (cdr (or (assq operation
!                       ;; The first five are special because they
                        ;; return a file name.  We want to include the /:
                        ;; in the return value.
                        ;; So just avoid stripping it in the first place.
--- 4496,4502 ----
        ;; Get a list of the indices of the args which are file names.
        (file-arg-indices
         (cdr (or (assq operation
!                       ;; The first six are special because they
                        ;; return a file name.  We want to include the /:
                        ;; in the return value.
                        ;; So just avoid stripping it in the first place.
***************
*** 4479,4489 ****
                          (file-name-as-directory . nil)
                          (directory-file-name . nil)
                          (file-name-sans-versions . nil)
                          ;; `identity' means just return the first arg
!                         ;; as stripped of its quoting.
!                         (substitute-in-file-name . identity)
                          (file-name-completion 1)
                          (file-name-all-completions 1)
                          (rename-file 0 1)
                          (copy-file 0 1)
                          (make-symbolic-link 0 1)
--- 4505,4525 ----
                          (file-name-as-directory . nil)
                          (directory-file-name . nil)
                          (file-name-sans-versions . nil)
+                         (find-backup-file-name . nil)
                          ;; `identity' means just return the first arg
!                         ;; not stripped of its quoting.
!                         (substitute-in-file-name identity)
!                         ;; `add' means add "/:" to the result.
!                         (file-truename add 0)
!                         ;; `quote' means add "/:" to buffer-file-name.
!                         (insert-file-contents quote 0)
!                         ;; `unquote-then-quote' means set buffer-file-name
!                         ;; temporarily to unquoted filename.
!                         (verify-visited-file-modtime unquote-then-quote)
!                         ;; List the arguments which are filenames.
                          (file-name-completion 1)
                          (file-name-all-completions 1)
+                         (write-region 2 5)
                          (rename-file 0 1)
                          (copy-file 0 1)
                          (make-symbolic-link 0 1)
***************
*** 4491,4499 ****
                  ;; For all other operations, treat the first argument only
                  ;; as the file name.
                  '(nil 0))))
        ;; Copy ARGUMENTS so we can replace elements in it.
        (arguments (copy-sequence arguments)))
!     ;; Strip off the /: from the file names that have this handler.
      (save-match-data
        (while (consp file-arg-indices)
        (let ((pair (nthcdr (car file-arg-indices) arguments)))
--- 4527,4538 ----
                  ;; For all other operations, treat the first argument only
                  ;; as the file name.
                  '(nil 0))))
+       method
        ;; Copy ARGUMENTS so we can replace elements in it.
        (arguments (copy-sequence arguments)))
!     (if (symbolp (car file-arg-indices))
!       (setq method (pop file-arg-indices)))
!     ;; Strip off the /: from the file names that have it.
      (save-match-data
        (while (consp file-arg-indices)
        (let ((pair (nthcdr (car file-arg-indices) arguments)))
***************
*** 4504,4512 ****
                           "/"
                         (substring (car pair) 2)))))
        (setq file-arg-indices (cdr file-arg-indices))))
!     (if (eq file-arg-indices 'identity)
!       (car arguments)
!       (apply operation arguments))))
  
  (define-key ctl-x-map "\C-f" 'find-file)
  (define-key ctl-x-map "\C-r" 'find-file-read-only)
--- 4543,4563 ----
                           "/"
                         (substring (car pair) 2)))))
        (setq file-arg-indices (cdr file-arg-indices))))
!     (cond ((eq method 'identity)
!          (car arguments))
!         ((eq method 'add)
!          (concat "/:" (apply operation arguments)))
!         ((eq method 'quote)
!          (prog1 (apply operation arguments)
!            (setq buffer-file-name (concat "/:" buffer-file-name))))
!         ((eq method 'unquote-then-quote)
!          (let (res)
!            (setq buffer-file-name (substring buffer-file-name 2))
!            (setq res (apply operation arguments))
!            (setq buffer-file-name (concat "/:" buffer-file-name))
!            res))
!         (t
!          (apply operation arguments)))))
  
  (define-key ctl-x-map "\C-f" 'find-file)
  (define-key ctl-x-map "\C-r" 'find-file-read-only)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]