]> code.delx.au - gnu-emacs/blobdiff - lisp/eshell/em-unix.el
* x-dnd.el (x-dnd-open-local-file, x-dnd-open-file): Improved error
[gnu-emacs] / lisp / eshell / em-unix.el
index c9b3d418b8350d3cfa9635829db87b96bf3cab7d..8446eb1aa9dde96d17d6feefebc5969d7b71cf02 100644 (file)
@@ -1,6 +1,6 @@
-;;; em-unix --- UNIX command aliases
+;;; em-unix.el --- UNIX command aliases
 
-;; Copyright (C) 1999, 2000 Free Software Foundation
+;; Copyright (C) 1999, 2000, 2001 Free Software Foundation
 
 ;; Author: John Wiegley <johnw@gnu.org>
 
@@ -76,7 +76,7 @@ receiving side of a command pipeline."
   :type 'boolean
   :group 'eshell-unix)
 
-(defcustom eshell-plain-locate-behavior nil
+(defcustom eshell-plain-locate-behavior (eshell-under-xemacs-p)
   "*If non-nil, standalone \"locate\" commands will behave normally.
 Standalone in this context means not redirected, and not on the
 receiving side of a command pipeline."
@@ -141,9 +141,7 @@ Otherwise, Emacs will attempt to use rsh to invoke du on the remote machine."
 
 (defun eshell-unix-initialize ()
   "Initialize the UNIX support/emulation code."
-  (make-local-hook 'eshell-post-command-hook)
   (when (eshell-using-module 'eshell-cmpl)
-    (make-local-hook 'pcomplete-try-first-hook)
     (add-hook 'pcomplete-try-first-hook
              'eshell-complete-host-reference nil t))
   (make-local-variable 'eshell-complex-commands)
@@ -166,6 +164,8 @@ Otherwise, Emacs will attempt to use rsh to invoke du on the remote machine."
   "Invoke man, flattening the arguments appropriately."
   (funcall 'man (apply 'eshell-flatten-and-stringify args)))
 
+(put 'eshell/man 'eshell-no-numeric-conversions t)
+
 (defun eshell-remove-entries (path files &optional top-level)
   "From PATH, remove all of the given FILES, perhaps interactively."
   (while files
@@ -276,6 +276,8 @@ Remove (unlink) the FILE(s).")
      (setq args (cdr args)))
    nil))
 
+(put 'eshell/rm 'eshell-no-numeric-conversions t)
+
 (defun eshell/mkdir (&rest args)
   "Implementation of mkdir in Lisp."
   (eshell-eval-using-options
@@ -290,6 +292,8 @@ Create the DIRECTORY(ies), if they do not already exist.")
      (setq args (cdr args)))
    nil))
 
+(put 'eshell/mkdir 'eshell-no-numeric-conversions t)
+
 (defun eshell/rmdir (&rest args)
   "Implementation of rmdir in Lisp."
   (eshell-eval-using-options
@@ -304,6 +308,8 @@ Remove the DIRECTORY(ies), if they are empty.")
      (setq args (cdr args)))
    nil))
 
+(put 'eshell/rmdir 'eshell-no-numeric-conversions t)
+
 (eval-when-compile
   (defvar no-dereference)
   (defvar preview)
@@ -334,9 +340,11 @@ Remove the DIRECTORY(ies), if they are empty.")
                 (eq system-type 'ms-dos))
             (setq attr (eshell-file-attributes (car files)))
             (nth 10 attr-target) (nth 10 attr)
-            (= (nth 10 attr-target) (nth 10 attr))
+            ;; Use equal, not -, since the inode and the device could
+            ;; cons cells.
+            (equal (nth 10 attr-target) (nth 10 attr))
             (nth 11 attr-target) (nth 11 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)))
        (t
@@ -358,12 +366,16 @@ Remove the DIRECTORY(ies), if they are empty.")
                (let (eshell-warn-dot-directories)
                  (if (and (not deep)
                           (eq func 'rename-file)
-                          (= (nth 11 (eshell-file-attributes
-                                      (file-name-directory
-                                       (expand-file-name source))))
-                             (nth 11 (eshell-file-attributes
-                                      (file-name-directory
-                                       (expand-file-name target))))))
+                          ;; Use equal, since the device might be a
+                          ;; cons cell.
+                          (equal (nth 11 (eshell-file-attributes
+                                          (file-name-directory
+                                           (directory-file-name
+                                            (expand-file-name source)))))
+                                 (nth 11 (eshell-file-attributes
+                                          (file-name-directory
+                                           (directory-file-name
+                                            (expand-file-name target)))))))
                      (apply 'eshell-funcalln func source target args)
                  (unless (file-directory-p target)
                    (if verbose
@@ -481,6 +493,8 @@ Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.
                             eshell-mv-interactive-query
                             eshell-mv-overwrite-files))))
 
+(put 'eshell/mv 'eshell-no-numeric-conversions t)
+
 (defun eshell/cp (&rest args)
   "Implementation of cp in Lisp."
   (eshell-eval-using-options
@@ -514,6 +528,8 @@ Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.")
                           eshell-cp-interactive-query
                           eshell-cp-overwrite-files preserve)))
 
+(put 'eshell/cp 'eshell-no-numeric-conversions t)
+
 (defun eshell/ln (&rest args)
   "Implementation of ln in Lisp."
   (eshell-eval-using-options
@@ -544,6 +560,8 @@ with '--symbolic'.  When creating hard links, each TARGET must exist.")
                             eshell-ln-interactive-query
                             eshell-ln-overwrite-files))))
 
+(put 'eshell/ln 'eshell-no-numeric-conversions t)
+
 (defun eshell/cat (&rest args)
   "Implementation of cat in Lisp.
 If in a pipeline, or the file is not a regular file, directory or
@@ -552,9 +570,12 @@ symlink, then revert to the system's definition of cat."
   (if (or eshell-in-pipeline-p
          (catch 'special
            (eshell-for arg args
-             (unless (let ((attrs (eshell-file-attributes arg)))
-                       (and attrs (memq (aref (nth 8 attrs) 0)
-                                        '(?d ?l ?-))))
+             (unless (or (and (stringp arg)
+                              (> (length arg) 0)
+                              (eq (aref arg 0) ?-))
+                         (let ((attrs (eshell-file-attributes arg)))
+                           (and attrs (memq (aref (nth 8 attrs) 0)
+                                            '(?d ?l ?-)))))
                (throw 'special t)))))
       (let ((ext-cat (eshell-search-path "cat")))
        (if ext-cat
@@ -591,6 +612,8 @@ Concatenate FILE(s), or standard input, to standard output.")
      ;; if the file does not end in a newline, do not emit one
      (setq eshell-ensure-newline-p nil))))
 
+(put 'eshell/cat 'eshell-no-numeric-conversions t)
+
 ;; special front-end functions for compilation-mode buffers
 
 (defun eshell/make (&rest args)
@@ -606,6 +629,8 @@ Concatenate FILE(s), or standard input, to standard output.")
           (eshell-parse-command "*make" (eshell-stringify-list
                                          (eshell-flatten-list args))))))
 
+(put 'eshell/make 'eshell-no-numeric-conversions t)
+
 (defun eshell-occur-mode-goto-occurrence ()
   "Go to the occurrence the current line describes."
   (interactive)
@@ -616,13 +641,12 @@ Concatenate FILE(s), or standard input, to standard output.")
 (defun eshell-occur-mode-mouse-goto (event)
   "In Occur mode, go to the occurrence whose line you click on."
   (interactive "e")
-  (let (buffer pos)
+  (let (pos)
     (save-excursion
       (set-buffer (window-buffer (posn-window (event-end event))))
       (save-excursion
        (goto-char (posn-point (event-end event)))
-       (setq pos (occur-mode-find-occurrence))
-       (setq buffer occur-buffer)))
+       (setq pos (occur-mode-find-occurrence))))
     (pop-to-buffer (marker-buffer pos))
     (goto-char (marker-position pos))))
 
@@ -658,7 +682,6 @@ available..."
                (if string (insert string))
                (setq string nil
                      files (cdr files)))))
-         (setq occur-buffer (current-buffer))
          (local-set-key [mouse-2] 'eshell-occur-mode-mouse-goto)
          (local-set-key [(control ?c) (control ?c)]
                         'eshell-occur-mode-goto-occurrence)
@@ -930,7 +953,7 @@ Show wall-clock time elapsed during execution of COMMAND.")
                      (not eshell-in-subcommand-p))))
        (throw 'eshell-replace-command
               (eshell-parse-command "*diff" orig-args))
-      (setq args (eshell-copy-list orig-args))
+      (setq args (copy-sequence orig-args))
       (if (< (length args) 2)
          (throw 'eshell-replace-command
                 (eshell-parse-command "*diff" orig-args)))
@@ -947,14 +970,22 @@ Show wall-clock time elapsed during execution of COMMAND.")
               (throw 'eshell-replace-command
                      (eshell-parse-command "*diff" orig-args))))
          (when (fboundp 'diff-mode)
-           (diff-mode)
-           (set (make-local-variable 'eshell-diff-window-config) config)
-           (local-set-key [?q] 'eshell-diff-quit)
-           (if (fboundp 'turn-on-font-lock-if-enabled)
-               (turn-on-font-lock-if-enabled))))
-       (other-window 1)
-       (goto-char (point-min))
-       nil))))
+           (make-local-variable 'compilation-finish-functions)
+           (add-hook
+            'compilation-finish-functions
+            `(lambda (buff msg)
+               (with-current-buffer buff
+                 (diff-mode)
+                 (set (make-local-variable 'eshell-diff-window-config)
+                      ,config)
+                 (local-set-key [?q] 'eshell-diff-quit)
+                 (if (fboundp 'turn-on-font-lock-if-enabled)
+                     (turn-on-font-lock-if-enabled))
+                 (goto-char (point-min))))))
+         (pop-to-buffer (current-buffer))))))
+  nil)
+
+(put 'eshell/diff 'eshell-no-numeric-conversions t)
 
 (defun eshell/locate (&rest args)
   "Alias \"locate\" to call Emacs `locate' function."
@@ -971,13 +1002,18 @@ Show wall-clock time elapsed during execution of COMMAND.")
       (let ((locate-history-list (list (car args))))
        (locate-with-filter (car args) (cadr args))))))
 
+(put 'eshell/locate 'eshell-no-numeric-conversions t)
+
 (defun eshell/occur (&rest args)
   "Alias \"occur\" to call Emacs `occur' function."
   (let ((inhibit-read-only t))
-    (if args
-       (error "usage: occur: (REGEXP)")
-      (occur (car args)))))
+    (if (> (length args) 2)
+       (error "usage: occur: (REGEXP &optional NLINES)")
+      (apply 'occur args))))
+
+(put 'eshell/occur 'eshell-no-numeric-conversions t)
 
 ;;; Code:
 
+;;; arch-tag: 2462edd2-a76a-4cf2-897d-92e9a82ac1c9
 ;;; em-unix.el ends here