aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2010-11-09 20:28:16 -0800
committerGlenn Morris2010-11-09 20:28:16 -0800
commit6e4049508fd91343eb5f8e556e905adca2a3fde7 (patch)
tree5849d626693e1b4ec3751a74ccc5aee735eae785
parent72bc50c0291f14945d49f8bd39f19a75c95f26e3 (diff)
downloademacs-6e4049508fd91343eb5f8e556e905adca2a3fde7.tar.gz
emacs-6e4049508fd91343eb5f8e556e905adca2a3fde7.zip
Remove ls-lisp time-related functions that duplicate standard functions.
* lisp/ls-lisp.el (ls-lisp-time-lessp, ls-lisp-time-to-seconds): Remove. (ls-lisp-handle-switches): Use time-less-p. (ls-lisp-format-time): Use float-time.
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/ls-lisp.el27
2 files changed, 10 insertions, 21 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 2ab7e98c7dd..2560b7be083 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -23,6 +23,10 @@
23 23
24 * startup.el (package-initialize): Update declaration. 24 * startup.el (package-initialize): Update declaration.
25 25
26 * ls-lisp.el (ls-lisp-time-lessp, ls-lisp-time-to-seconds): Remove.
27 (ls-lisp-handle-switches): Use time-less-p.
28 (ls-lisp-format-time): Use float-time.
29
26 * textmodes/remember.el (remember-time-to-seconds): Remove. 30 * textmodes/remember.el (remember-time-to-seconds): Remove.
27 (remember-store-in-mailbox): Use float-time. 31 (remember-store-in-mailbox): Use float-time.
28 32
diff --git a/lisp/ls-lisp.el b/lisp/ls-lisp.el
index 15299bc304e..a319136fe02 100644
--- a/lisp/ls-lisp.el
+++ b/lisp/ls-lisp.el
@@ -1,7 +1,7 @@
1;;; ls-lisp.el --- emulate insert-directory completely in Emacs Lisp 1;;; ls-lisp.el --- emulate insert-directory completely in Emacs Lisp
2 2
3;; Copyright (C) 1992, 1994, 2000, 2001, 2002, 2003, 2004, 3;; Copyright (C) 1992, 1994, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
4;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 4;; 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
5 5
6;; Author: Sebastian Kremer <sk@thp.uni-koeln.de> 6;; Author: Sebastian Kremer <sk@thp.uni-koeln.de>
7;; Modified by: Francis J. Wright <F.J.Wright@maths.qmw.ac.uk> 7;; Modified by: Francis J. Wright <F.J.Wright@maths.qmw.ac.uk>
@@ -486,8 +486,8 @@ SWITCHES is a list of characters. Default sorting is alphabetic."
486 (nth 7 (cdr x))))) 486 (nth 7 (cdr x)))))
487 ((setq index (ls-lisp-time-index switches)) 487 ((setq index (ls-lisp-time-index switches))
488 (lambda (x y) ; sorted on time 488 (lambda (x y) ; sorted on time
489 (ls-lisp-time-lessp (nth index (cdr y)) 489 (time-less-p (nth index (cdr y))
490 (nth index (cdr x))))) 490 (nth index (cdr x)))))
491 ((memq ?X switches) 491 ((memq ?X switches)
492 (lambda (x y) ; sorted on extension 492 (lambda (x y) ; sorted on extension
493 (ls-lisp-string-lessp 493 (ls-lisp-string-lessp
@@ -585,14 +585,6 @@ FOLLOWED by null and full filename, SOLELY for full alpha sort."
585 (substring filename (1+ i) end)))) 585 (substring filename (1+ i) end))))
586 )) "\0" filename)) 586 )) "\0" filename))
587 587
588;; From Roland McGrath. Can use this to sort on time.
589(defun ls-lisp-time-lessp (time0 time1)
590 "Return t if time TIME0 is earlier than time TIME1."
591 (let ((hi0 (car time0)) (hi1 (car time1)))
592 (or (< hi0 hi1)
593 (and (= hi0 hi1)
594 (< (cadr time0) (cadr time1))))))
595
596(defun ls-lisp-format (file-name file-attr file-size switches time-index now) 588(defun ls-lisp-format (file-name file-attr file-size switches time-index now)
597 "Format one line of long ls output for file FILE-NAME. 589 "Format one line of long ls output for file FILE-NAME.
598FILE-ATTR and FILE-SIZE give the file's attributes and size. 590FILE-ATTR and FILE-SIZE give the file's attributes and size.
@@ -672,20 +664,14 @@ Return nil if no time switch found."
672 ((memq ?t switches) 5) ; last modtime 664 ((memq ?t switches) 5) ; last modtime
673 ((memq ?u switches) 4))) ; last access 665 ((memq ?u switches) 4))) ; last access
674 666
675(defun ls-lisp-time-to-seconds (time)
676 "Convert TIME to a floating point number."
677 (+ (* (car time) 65536.0)
678 (cadr time)
679 (/ (or (nth 2 time) 0) 1000000.0)))
680
681(defun ls-lisp-format-time (file-attr time-index now) 667(defun ls-lisp-format-time (file-attr time-index now)
682 "Format time for file with attributes FILE-ATTR according to TIME-INDEX. 668 "Format time for file with attributes FILE-ATTR according to TIME-INDEX.
683Use the same method as ls to decide whether to show time-of-day or year, 669Use the same method as ls to decide whether to show time-of-day or year,
684depending on distance between file date and NOW. 670depending on distance between file date and NOW.
685All ls time options, namely c, t and u, are handled." 671All ls time options, namely c, t and u, are handled."
686 (let* ((time (nth (or time-index 5) file-attr)) ; default is last modtime 672 (let* ((time (nth (or time-index 5) file-attr)) ; default is last modtime
687 (diff (- (ls-lisp-time-to-seconds time) 673 (diff (- (float-time time)
688 (ls-lisp-time-to-seconds now))) 674 (float-time now)))
689 ;; Consider a time to be recent if it is within the past six 675 ;; Consider a time to be recent if it is within the past six
690 ;; months. A Gregorian year has 365.2425 * 24 * 60 * 60 == 676 ;; months. A Gregorian year has 365.2425 * 24 * 60 * 60 ==
691 ;; 31556952 seconds on the average, and half of that is 15778476. 677 ;; 31556952 seconds on the average, and half of that is 15778476.
@@ -728,5 +714,4 @@ All ls time options, namely c, t and u, are handled."
728 714
729(provide 'ls-lisp) 715(provide 'ls-lisp)
730 716
731;; arch-tag: e55f399b-05ec-425c-a6d5-f5e349c35ab4
732;;; ls-lisp.el ends here 717;;; ls-lisp.el ends here