]> code.delx.au - gnu-emacs/blobdiff - lisp/eshell/em-unix.el
Merge from origin/emacs-25
[gnu-emacs] / lisp / eshell / em-unix.el
index 60caf38710a9123ab49a5caffbf103cbc60304d8..c27c18c52baa2bcdd5384980e11c7eebb3bd5aaa 100644 (file)
@@ -1,6 +1,6 @@
-;;; em-unix.el --- UNIX command aliases
+;;; em-unix.el --- UNIX command aliases  -*- lexical-binding:t -*-
 
 
-;; Copyright (C) 1999-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2016 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <johnw@gnu.org>
 
 
 ;; Author: John Wiegley <johnw@gnu.org>
 
@@ -168,10 +168,10 @@ Otherwise, Emacs will attempt to use rsh to invoke du on the remote machine."
 
 (defun eshell/info (&rest args)
   "Run the info command in-frame with the same behavior as command-line `info', ie:
 
 (defun eshell/info (&rest args)
   "Run the info command in-frame with the same behavior as command-line `info', ie:
-  'info'           => goes to top info window
-  'info arg1'      => IF arg1 is a file, then visits arg1
-  'info arg1'      => OTHERWISE goes to top info window and then menu item arg1
-  'info arg1 arg2' => does action for arg1 (either visit-file or menu-item) and then menu item arg2
+  `info'           => goes to top info window
+  `info arg1'      => IF arg1 is a file, then visits arg1
+  `info arg1'      => OTHERWISE goes to top info window and then menu item arg1
+  `info arg1 arg2' => does action for arg1 (either visit-file or menu-item) and then menu item arg2
   etc."
   (eval-and-compile (require 'info))
   (let ((file (cond
   etc."
   (eval-and-compile (require 'info))
   (let ((file (cond
@@ -195,34 +195,34 @@ Otherwise, Emacs will attempt to use rsh to invoke du on the remote machine."
       (Info-menu (car args))
       (setq args (cdr args)))))
 
       (Info-menu (car args))
       (setq args (cdr args)))))
 
-(defun eshell-remove-entries (path files &optional top-level)
-  "From PATH, remove all of the given FILES, perhaps interactively."
+(defun eshell-remove-entries (files &optional toplevel)
+  "Remove all of the given FILES, perhaps interactively."
   (while files
     (if (string-match "\\`\\.\\.?\\'"
                      (file-name-nondirectory (car files)))
   (while files
     (if (string-match "\\`\\.\\.?\\'"
                      (file-name-nondirectory (car files)))
-       (if top-level
+       (if toplevel
            (eshell-error "rm: cannot remove `.' or `..'\n"))
       (if (and (file-directory-p (car files))
               (not (file-symlink-p (car files))))
          (progn
            (if em-verbose
            (eshell-error "rm: cannot remove `.' or `..'\n"))
       (if (and (file-directory-p (car files))
               (not (file-symlink-p (car files))))
          (progn
            (if em-verbose
-               (eshell-printn (format "rm: removing directory `%s'"
-                                      (car files))))
+               (eshell-printn (format-message "rm: removing directory `%s'"
+                                              (car files))))
            (unless
                (or em-preview
                    (and em-interactive
                         (not (y-or-n-p
            (unless
                (or em-preview
                    (and em-interactive
                         (not (y-or-n-p
-                              (format "rm: remove directory `%s'? "
-                                      (car files))))))
+                              (format-message "rm: remove directory `%s'? "
+                                              (car files))))))
              (eshell-funcalln 'delete-directory (car files) t t)))
        (if em-verbose
              (eshell-funcalln 'delete-directory (car files) t t)))
        (if em-verbose
-           (eshell-printn (format "rm: removing file `%s'"
-                                  (car files))))
+           (eshell-printn (format-message "rm: removing file `%s'"
+                                          (car files))))
        (unless (or em-preview
                    (and em-interactive
                         (not (y-or-n-p
        (unless (or em-preview
                    (and em-interactive
                         (not (y-or-n-p
-                              (format "rm: remove `%s'? "
-                                      (car files))))))
+                              (format-message "rm: remove `%s'? "
+                                              (car files))))))
          (eshell-funcalln 'delete-file (car files) t))))
     (setq files (cdr files))))
 
          (eshell-funcalln 'delete-file (car files) t))))
     (setq files (cdr files))))
 
@@ -260,42 +260,49 @@ Remove (unlink) the FILE(s).")
        (cond
        ((bufferp entry)
         (if em-verbose
        (cond
        ((bufferp entry)
         (if em-verbose
-            (eshell-printn (format "rm: removing buffer `%s'" entry)))
+            (eshell-printn (format-message "rm: removing buffer `%s'" entry)))
         (unless (or em-preview
                     (and em-interactive
         (unless (or em-preview
                     (and em-interactive
-                         (not (y-or-n-p (format "rm: delete buffer `%s'? "
-                                                entry)))))
+                         (not (y-or-n-p (format-message
+                                         "rm: delete buffer `%s'? "
+                                         entry)))))
           (eshell-funcalln 'kill-buffer entry)))
        ((eshell-processp entry)
         (if em-verbose
           (eshell-funcalln 'kill-buffer entry)))
        ((eshell-processp entry)
         (if em-verbose
-            (eshell-printn (format "rm: killing process `%s'" entry)))
+            (eshell-printn (format-message "rm: killing process `%s'" entry)))
         (unless (or em-preview
                     (and em-interactive
         (unless (or em-preview
                     (and em-interactive
-                         (not (y-or-n-p (format "rm: kill process `%s'? "
-                                                entry)))))
+                         (not (y-or-n-p (format-message
+                                         "rm: kill process `%s'? "
+                                         entry)))))
           (eshell-funcalln 'kill-process entry)))
        ((symbolp entry)
         (if em-verbose
           (eshell-funcalln 'kill-process entry)))
        ((symbolp entry)
         (if em-verbose
-            (eshell-printn (format "rm: uninterning symbol `%s'" entry)))
+            (eshell-printn (format-message
+                            "rm: uninterning symbol `%s'" entry)))
         (unless
             (or em-preview
                 (and em-interactive
         (unless
             (or em-preview
                 (and em-interactive
-                     (not (y-or-n-p (format "rm: unintern symbol `%s'? "
-                                            entry)))))
+                     (not (y-or-n-p (format-message
+                                     "rm: unintern symbol `%s'? "
+                                     entry)))))
           (eshell-funcalln 'unintern entry)))
        ((stringp entry)
           (eshell-funcalln 'unintern entry)))
        ((stringp entry)
-        (if (and (file-directory-p entry)
-                 (not (file-symlink-p entry)))
-            (if (or em-recursive
-                    eshell-rm-removes-directories)
-                (if (or em-preview
-                        (not em-interactive)
-                        (y-or-n-p
-                         (format "rm: descend into directory `%s'? "
-                                 entry)))
-                    (eshell-remove-entries nil (list entry) t))
-              (eshell-error (format "rm: %s: is a directory\n" entry)))
-          (eshell-remove-entries nil (list entry) t)))))
+        ;; -f should silently ignore missing files (bug#15373).
+        (unless (and force-removal
+                     (not (file-exists-p entry)))
+          (if (and (file-directory-p entry)
+                   (not (file-symlink-p entry)))
+              (if (or em-recursive
+                      eshell-rm-removes-directories)
+                  (if (or em-preview
+                          (not em-interactive)
+                          (y-or-n-p
+                           (format-message "rm: descend into directory `%s'? "
+                                           entry)))
+                    (eshell-remove-entries (list entry) t))
+                (eshell-error (format "rm: %s: is a directory\n" entry)))
+            (eshell-remove-entries (list entry) t))))))
      (setq args (cdr args)))
    nil))
 
      (setq args (cdr args)))
    nil))
 
@@ -366,8 +373,8 @@ Remove the DIRECTORY(ies), if they are empty.")
             (equal (nth 10 attr-target) (nth 10 attr))
             (nth 11 attr-target) (nth 11 attr)
             (equal (nth 11 attr-target) (nth 11 attr)))
             (equal (nth 10 attr-target) (nth 10 attr))
             (nth 11 attr-target) (nth 11 attr)
             (equal (nth 11 attr-target) (nth 11 attr)))
-       (eshell-error (format "%s: `%s' and `%s' are the same file\n"
-                             command (car files) target)))
+       (eshell-error (format-message "%s: `%s' and `%s' are the same file\n"
+                                     command (car files) target)))
        (t
        (let ((source (car files))
              (target (if is-dir
        (t
        (let ((source (car files))
              (target (if is-dir
@@ -458,6 +465,8 @@ Remove the DIRECTORY(ies), if they are empty.")
           (eshell-parse-command
            (format "tar %s %s" tar-args archive) args))))
 
           (eshell-parse-command
            (format "tar %s %s" tar-args archive) args))))
 
+(defvar ange-cache)                    ; XEmacs?  See esh-util
+
 ;; this is to avoid duplicating code...
 (defmacro eshell-mvcpln-template (command action func query-var
                                          force-var &optional preserve)
 ;; this is to avoid duplicating code...
 (defmacro eshell-mvcpln-template (command action func query-var
                                          force-var &optional preserve)
@@ -508,7 +517,7 @@ Remove the DIRECTORY(ies), if they are empty.")
      :usage "[OPTION]... SOURCE DEST
    or: mv [OPTION]... SOURCE... DIRECTORY
 Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.
      :usage "[OPTION]... SOURCE DEST
    or: mv [OPTION]... SOURCE... DIRECTORY
 Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.
-\[OPTION] DIRECTORY...")
+[OPTION] DIRECTORY...")
    (let ((no-dereference t))
      (eshell-mvcpln-template "mv" "moving" 'rename-file
                             eshell-mv-interactive-query
    (let ((no-dereference t))
      (eshell-mvcpln-template "mv" "moving" 'rename-file
                             eshell-mv-interactive-query
@@ -532,8 +541,10 @@ Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.
         "don't change anything on disk")
      (?p "preserve" nil preserve
         "preserve file attributes if possible")
         "don't change anything on disk")
      (?p "preserve" nil preserve
         "preserve file attributes if possible")
-     (?R "recursive" nil em-recursive
+     (?r "recursive" nil em-recursive
         "copy directories recursively")
         "copy directories recursively")
+     (?R nil nil em-recursive
+        "as for -r")
      (?v "verbose" nil em-verbose
         "explain what is being done")
      (nil "help" nil nil "show this usage screen")
      (?v "verbose" nil em-verbose
         "explain what is being done")
      (nil "help" nil nil "show this usage screen")
@@ -572,7 +583,7 @@ Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.")
 Create a link to the specified TARGET with optional LINK_NAME.  If there is
 more than one TARGET, the last argument must be a directory;  create links
 in DIRECTORY to each TARGET.  Create hard links by default, symbolic links
 Create a link to the specified TARGET with optional LINK_NAME.  If there is
 more than one TARGET, the last argument must be a directory;  create links
 in DIRECTORY to each TARGET.  Create hard links by default, symbolic links
-with '--symbolic'.  When creating hard links, each TARGET must exist.")
+with `--symbolic'.  When creating hard links, each TARGET must exist.")
    (let ((no-dereference t))
      (eshell-mvcpln-template "ln" "linking"
                             (if symbolic
    (let ((no-dereference t))
      (eshell-mvcpln-template "ln" "linking"
                             (if symbolic
@@ -712,6 +723,8 @@ available..."
          (goto-char (point-min))
          (resize-temp-buffer-window))))))
 
          (goto-char (point-min))
          (resize-temp-buffer-window))))))
 
+(defvar compilation-scroll-output)
+
 (defun eshell-grep (command args &optional maybe-use-occur)
   "Generic service function for the various grep aliases.
 It calls Emacs's grep utility if the command is not redirecting output,
 (defun eshell-grep (command args &optional maybe-use-occur)
   "Generic service function for the various grep aliases.
 It calls Emacs's grep utility if the command is not redirecting output,
@@ -987,7 +1000,7 @@ Show wall-clock time elapsed during execution of COMMAND.")
            (setq args nil)
          (setcdr (last args 3) nil))
        (with-current-buffer
            (setq args nil)
          (setcdr (last args 3) nil))
        (with-current-buffer
-           (condition-case err
+           (condition-case nil
                (diff-no-select
                 old new
                 (nil-blank-string (eshell-flatten-and-stringify args)))
                (diff-no-select
                 old new
                 (nil-blank-string (eshell-flatten-and-stringify args)))
@@ -1012,6 +1025,8 @@ Show wall-clock time elapsed during execution of COMMAND.")
 
 (put 'eshell/diff 'eshell-no-numeric-conversions t)
 
 
 (put 'eshell/diff 'eshell-no-numeric-conversions t)
 
+(defvar locate-history-list)
+
 (defun eshell/locate (&rest args)
   "Alias \"locate\" to call Emacs `locate' function."
   (if (or eshell-plain-locate-behavior
 (defun eshell/locate (&rest args)
   "Alias \"locate\" to call Emacs `locate' function."
   (if (or eshell-plain-locate-behavior