aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2010-11-09 19:57:32 -0800
committerGlenn Morris2010-11-09 19:57:32 -0800
commit73171bd4cc3333a43ef8810ba4f7d0a864f20fa8 (patch)
treea00e6939b432aa45fc7b18096a4f8baf7e77ab93
parent13e7256f9425c09c827827302fda440f95fe5c43 (diff)
downloademacs-73171bd4cc3333a43ef8810ba4f7d0a864f20fa8.tar.gz
emacs-73171bd4cc3333a43ef8810ba4f7d0a864f20fa8.zip
Replace some eshell functions that duplicate standard functions.
* lisp/eshell/esh-util.el (eshell-time-less-p, eshell-time-to-seconds): Remove. (eshell-read-passwd, eshell-read-hosts): Use time-less-p. * lisp/eshell/esh-test.el (eshell-test, eshell-show-usage-metrics): * lisp/eshell/em-unix.el (eshell-show-elapsed-time, eshell/time): * lisp/eshell/em-pred.el (eshell-pred-file-time): Use float-time. * lisp/eshell/em-ls.el (eshell-ls-sort-entries): Use time-less-p.
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/eshell/em-ls.el7
-rw-r--r--lisp/eshell/em-pred.el7
-rw-r--r--lisp/eshell/em-unix.el6
-rw-r--r--lisp/eshell/esh-test.el10
-rw-r--r--lisp/eshell/esh-util.el18
6 files changed, 22 insertions, 34 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 8bffe3f1067..3fa23066963 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,13 @@
12010-11-10 Glenn Morris <rgm@gnu.org> 12010-11-10 Glenn Morris <rgm@gnu.org>
2 2
3 * eshell/esh-util.el (eshell-time-less-p, eshell-time-to-seconds):
4 Remove.
5 (eshell-read-passwd, eshell-read-hosts): Use time-less-p.
6 * eshell/esh-test.el (eshell-test, eshell-show-usage-metrics):
7 * eshell/em-unix.el (eshell-show-elapsed-time, eshell/time):
8 * eshell/em-pred.el (eshell-pred-file-time): Use float-time.
9 * eshell/em-ls.el (eshell-ls-sort-entries): Use time-less-p.
10
3 * eshell/em-unix.el (eshell-remove-entries, eshell/rm) 11 * eshell/em-unix.el (eshell-remove-entries, eshell/rm)
4 (eshell-shuffle-files, eshell-shorthand-tar-command) 12 (eshell-shuffle-files, eshell-shorthand-tar-command)
5 (eshell-mvcpln-template, eshell/mv, eshell/cp, eshell/ln): 13 (eshell-mvcpln-template, eshell/mv, eshell/cp, eshell/ln):
diff --git a/lisp/eshell/em-ls.el b/lisp/eshell/em-ls.el
index db2a21cd319..84af53efe58 100644
--- a/lisp/eshell/em-ls.el
+++ b/lisp/eshell/em-ls.el
@@ -612,11 +612,11 @@ In Eshell's implementation of ls, ENTRIES is always reversed."
612 (let ((result 612 (let ((result
613 (cond 613 (cond
614 ((eq sort-method 'by-atime) 614 ((eq sort-method 'by-atime)
615 (eshell-ls-compare-entries l r 4 'eshell-time-less-p)) 615 (eshell-ls-compare-entries l r 4 'time-less-p))
616 ((eq sort-method 'by-mtime) 616 ((eq sort-method 'by-mtime)
617 (eshell-ls-compare-entries l r 5 'eshell-time-less-p)) 617 (eshell-ls-compare-entries l r 5 'time-less-p))
618 ((eq sort-method 'by-ctime) 618 ((eq sort-method 'by-ctime)
619 (eshell-ls-compare-entries l r 6 'eshell-time-less-p)) 619 (eshell-ls-compare-entries l r 6 'time-less-p))
620 ((eq sort-method 'by-size) 620 ((eq sort-method 'by-size)
621 (eshell-ls-compare-entries l r 7 '<)) 621 (eshell-ls-compare-entries l r 7 '<))
622 ((eq sort-method 'by-extension) 622 ((eq sort-method 'by-extension)
@@ -941,5 +941,4 @@ to use, and each member of which is the width of that column
941;; generated-autoload-file: "esh-groups.el" 941;; generated-autoload-file: "esh-groups.el"
942;; End: 942;; End:
943 943
944;; arch-tag: 9295181c-0cb2-499c-999b-89f5359842cb
945;;; em-ls.el ends here 944;;; em-ls.el ends here
diff --git a/lisp/eshell/em-pred.el b/lisp/eshell/em-pred.el
index 15a3deea30c..2b5cb1a0dc4 100644
--- a/lisp/eshell/em-pred.el
+++ b/lisp/eshell/em-pred.el
@@ -427,7 +427,7 @@ returning the resultant string."
427 (forward-char)) 427 (forward-char))
428 (if (looking-at "[0-9]+") 428 (if (looking-at "[0-9]+")
429 (progn 429 (progn
430 (setq when (- (eshell-time-to-seconds (current-time)) 430 (setq when (- (float-time)
431 (* (string-to-number (match-string 0)) 431 (* (string-to-number (match-string 0))
432 quantum))) 432 quantum)))
433 (goto-char (match-end 0))) 433 (goto-char (match-end 0)))
@@ -444,7 +444,7 @@ returning the resultant string."
444 (attrs (file-attributes file))) 444 (attrs (file-attributes file)))
445 (unless attrs 445 (unless attrs
446 (error "Cannot stat file `%s'" file)) 446 (error "Cannot stat file `%s'" file))
447 (setq when (eshell-time-to-seconds (nth attr-index attrs)))) 447 (setq when (float-time (nth attr-index attrs))))
448 (goto-char (1+ end))) 448 (goto-char (1+ end)))
449 `(lambda (file) 449 `(lambda (file)
450 (let ((attrs (file-attributes file))) 450 (let ((attrs (file-attributes file)))
@@ -453,7 +453,7 @@ returning the resultant string."
453 '< 453 '<
454 (if (eq qual ?+) 454 (if (eq qual ?+)
455 '> 455 '>
456 '=)) ,when (eshell-time-to-seconds 456 '=)) ,when (float-time
457 (nth ,attr-index attrs)))))))) 457 (nth ,attr-index attrs))))))))
458 458
459(defun eshell-pred-file-type (type) 459(defun eshell-pred-file-type (type)
@@ -605,5 +605,4 @@ that 'ls -l' will show in the first column of its display. "
605;; generated-autoload-file: "esh-groups.el" 605;; generated-autoload-file: "esh-groups.el"
606;; End: 606;; End:
607 607
608;; arch-tag: 8b5ce022-17f3-4c40-93c7-5faafaa63f31
609;;; em-pred.el ends here 608;;; em-pred.el ends here
diff --git a/lisp/eshell/em-unix.el b/lisp/eshell/em-unix.el
index 36a89e33fb6..d4f62415084 100644
--- a/lisp/eshell/em-unix.el
+++ b/lisp/eshell/em-unix.el
@@ -912,9 +912,7 @@ Summarize disk usage of each FILE, recursively for directories.")
912(defvar eshell-time-start nil) 912(defvar eshell-time-start nil)
913 913
914(defun eshell-show-elapsed-time () 914(defun eshell-show-elapsed-time ()
915 (let ((elapsed (format "%.3f secs\n" 915 (let ((elapsed (format "%.3f secs\n" (- (float-time) eshell-time-start))))
916 (- (eshell-time-to-seconds (current-time))
917 eshell-time-start))))
918 (set-text-properties 0 (length elapsed) '(face bold) elapsed) 916 (set-text-properties 0 (length elapsed) '(face bold) elapsed)
919 (eshell-interactive-print elapsed)) 917 (eshell-interactive-print elapsed))
920 (remove-hook 'eshell-post-command-hook 'eshell-show-elapsed-time t)) 918 (remove-hook 'eshell-post-command-hook 'eshell-show-elapsed-time t))
@@ -940,7 +938,7 @@ Summarize disk usage of each FILE, recursively for directories.")
940 :show-usage 938 :show-usage
941 :usage "COMMAND... 939 :usage "COMMAND...
942Show wall-clock time elapsed during execution of COMMAND.") 940Show wall-clock time elapsed during execution of COMMAND.")
943 (setq eshell-time-start (eshell-time-to-seconds (current-time))) 941 (setq eshell-time-start (float-time))
944 (add-hook 'eshell-post-command-hook 'eshell-show-elapsed-time nil t) 942 (add-hook 'eshell-post-command-hook 'eshell-show-elapsed-time nil t)
945 ;; after setting 943 ;; after setting
946 (throw 'eshell-replace-command 944 (throw 'eshell-replace-command
diff --git a/lisp/eshell/esh-test.el b/lisp/eshell/esh-test.el
index 971d0cd63e6..50d0a8e861c 100644
--- a/lisp/eshell/esh-test.el
+++ b/lisp/eshell/esh-test.el
@@ -150,7 +150,7 @@
150(defun eshell-test (&optional arg) 150(defun eshell-test (&optional arg)
151 "Test Eshell to verify that it works as expected." 151 "Test Eshell to verify that it works as expected."
152 (interactive "P") 152 (interactive "P")
153 (let* ((begin (eshell-time-to-seconds (current-time))) 153 (let* ((begin (float-time))
154 (test-buffer (get-buffer-create "*eshell test*"))) 154 (test-buffer (get-buffer-create "*eshell test*")))
155 (set-buffer (let ((inhibit-redisplay t)) 155 (set-buffer (let ((inhibit-redisplay t))
156 (save-window-excursion (eshell t)))) 156 (save-window-excursion (eshell t))))
@@ -176,8 +176,7 @@
176 (with-current-buffer test-buffer 176 (with-current-buffer test-buffer
177 (insert (format "\n\n--- %s --- (completed in %d seconds)\n" 177 (insert (format "\n\n--- %s --- (completed in %d seconds)\n"
178 (current-time-string) 178 (current-time-string)
179 (- (eshell-time-to-seconds (current-time)) 179 (- (float-time) begin)))
180 begin)))
181 (message "Eshell test suite completed: %s failure%s" 180 (message "Eshell test suite completed: %s failure%s"
182 (if (> eshell-test-failures 0) 181 (if (> eshell-test-failures 0)
183 (number-to-string eshell-test-failures) 182 (number-to-string eshell-test-failures)
@@ -223,14 +222,13 @@
223 (if (eq eshell-show-usage-metrics t) 222 (if (eq eshell-show-usage-metrics t)
224 (- eshell-metric-after-command 223 (- eshell-metric-after-command
225 eshell-metric-before-command 7) 224 eshell-metric-before-command 7)
226 (- (eshell-time-to-seconds 225 (- (float-time
227 eshell-metric-after-command) 226 eshell-metric-after-command)
228 (eshell-time-to-seconds 227 (float-time
229 eshell-metric-before-command)))) 228 eshell-metric-before-command))))
230 "\n")))) 229 "\n"))))
231 nil t)) 230 nil t))
232 231
233(provide 'esh-test) 232(provide 'esh-test)
234 233
235;; arch-tag: 6e32275a-8285-4a4e-b7cf-819aa7c86b8e
236;;; esh-test.el ends here 234;;; esh-test.el ends here
diff --git a/lisp/eshell/esh-util.el b/lisp/eshell/esh-util.el
index 17db2f71f9e..0a2ebba528f 100644
--- a/lisp/eshell/esh-util.el
+++ b/lisp/eshell/esh-util.el
@@ -341,20 +341,6 @@ Prepend remote identification of `default-directory', if any."
341 "Flatten and stringify all of the ARGS into a single string." 341 "Flatten and stringify all of the ARGS into a single string."
342 (mapconcat 'eshell-stringify (eshell-flatten-list args) " ")) 342 (mapconcat 'eshell-stringify (eshell-flatten-list args) " "))
343 343
344;; the next two are from GNUS, and really should be made part of Emacs
345;; some day
346(defsubst eshell-time-less-p (t1 t2)
347 "Say whether time T1 is less than time T2."
348 (or (< (car t1) (car t2))
349 (and (= (car t1) (car t2))
350 (< (nth 1 t1) (nth 1 t2)))))
351
352(defsubst eshell-time-to-seconds (time)
353 "Convert TIME to a floating point number."
354 (+ (* (car time) 65536.0)
355 (cadr time)
356 (/ (or (car (cdr (cdr time))) 0) 1000000.0)))
357
358(defsubst eshell-directory-files (regexp &optional directory) 344(defsubst eshell-directory-files (regexp &optional directory)
359 "Return a list of files in the given DIRECTORY matching REGEXP." 345 "Return a list of files in the given DIRECTORY matching REGEXP."
360 (directory-files (or directory default-directory) 346 (directory-files (or directory default-directory)
@@ -468,7 +454,7 @@ list."
468 "Read the contents of /etc/passwd for user names." 454 "Read the contents of /etc/passwd for user names."
469 (if (or (not (symbol-value result-var)) 455 (if (or (not (symbol-value result-var))
470 (not (symbol-value timestamp-var)) 456 (not (symbol-value timestamp-var))
471 (eshell-time-less-p 457 (time-less-p
472 (symbol-value timestamp-var) 458 (symbol-value timestamp-var)
473 (nth 5 (file-attributes file)))) 459 (nth 5 (file-attributes file))))
474 (progn 460 (progn
@@ -522,7 +508,7 @@ list."
522 "Read the contents of /etc/passwd for user names." 508 "Read the contents of /etc/passwd for user names."
523 (if (or (not (symbol-value result-var)) 509 (if (or (not (symbol-value result-var))
524 (not (symbol-value timestamp-var)) 510 (not (symbol-value timestamp-var))
525 (eshell-time-less-p 511 (time-less-p
526 (symbol-value timestamp-var) 512 (symbol-value timestamp-var)
527 (nth 5 (file-attributes file)))) 513 (nth 5 (file-attributes file))))
528 (progn 514 (progn