emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r102305: time-to-seconds related simp


From: Glenn Morris
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r102305: time-to-seconds related simplifications.
Date: Tue, 09 Nov 2010 20:08:15 -0800
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 102305
committer: Glenn Morris <address@hidden>
branch nick: trunk
timestamp: Tue 2010-11-09 20:08:15 -0800
message:
  time-to-seconds related simplifications.
  
  * lisp/gnus/gnus-util.el (with-no-warnings): Remove compat stub, now unused.
  (gnus-float-time): On Emacs, always an alias.
  
  * lisp/gnus/ecomplete.el (with-no-warnings): Remove compat stub, now unused.
  (ecomplete-add-item): Use float-time on Emacs, else gnus-float-time.
  
  * lisp/textmodes/remember.el (remember-time-to-seconds): Remove.
  (remember-store-in-mailbox): Use float-time.
  
  * lisp/calendar/timeclock.el (timeclock-time-to-seconds): Make it an alias.
  
  * lisp/calendar/time-date.el (time-to-seconds): Always an alias on Emacs,
  never a real function.
  (with-no-warnings): Remove compat stub, now unused.
  (time-less-p): Doc fix.
  (time-to-number-of-days): Simplify.
modified:
  lisp/ChangeLog
  lisp/calendar/time-date.el
  lisp/calendar/timeclock.el
  lisp/gnus/ChangeLog
  lisp/gnus/ecomplete.el
  lisp/gnus/gnus-util.el
  lisp/textmodes/remember.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2010-11-10 03:57:32 +0000
+++ b/lisp/ChangeLog    2010-11-10 04:08:15 +0000
@@ -1,5 +1,16 @@
 2010-11-10  Glenn Morris  <address@hidden>
 
+       * textmodes/remember.el (remember-time-to-seconds): Remove.
+       (remember-store-in-mailbox): Use float-time.
+
+       * calendar/timeclock.el (timeclock-time-to-seconds): Make it an alias.
+
+       * calendar/time-date.el (time-to-seconds): Always an alias on Emacs,
+       never a real function.
+       (with-no-warnings): Remove compat stub, now unused.
+       (time-less-p): Doc fix.
+       (time-to-number-of-days): Simplify.
+
        * eshell/esh-util.el (eshell-time-less-p, eshell-time-to-seconds):
        Remove.
        (eshell-read-passwd, eshell-read-hosts): Use time-less-p.

=== modified file 'lisp/calendar/time-date.el'
--- a/lisp/calendar/time-date.el        2010-09-29 01:09:50 +0000
+++ b/lisp/calendar/time-date.el        2010-11-10 04:08:15 +0000
@@ -112,27 +112,24 @@
 ;; Bit of a mess.  Emacs has float-time since at least 21.1.
 ;; This file is synced to Gnus, and XEmacs packages may have been written
 ;; using time-to-seconds from the Gnus library.
-;;;###autoload(if (and (fboundp 'float-time)
-;;;###autoload         (subrp (symbol-function 'float-time)))
+;;;###autoload(if (or (featurep 'emacs)
+;;;###autoload        (and (fboundp 'float-time)
+;;;###autoload             (subrp (symbol-function 'float-time))))
 ;;;###autoload    (progn
 ;;;###autoload      (defalias 'time-to-seconds 'float-time)
 ;;;###autoload      (make-obsolete 'time-to-seconds 'float-time "21.1"))
 ;;;###autoload  (autoload 'time-to-seconds "time-date"))
 
-(eval-and-compile
-  (unless (and (fboundp 'float-time)
-              (subrp (symbol-function 'float-time)))
-    (defun time-to-seconds (time)
-      "Convert time value TIME to a floating point number."
-      (with-decoded-time-value ((high low micro time))
-       (+ (* 1.0 high 65536)
-          low
-          (/ micro 1000000.0))))))
-
 (eval-when-compile
-  (unless (fboundp 'with-no-warnings)
-    (defmacro with-no-warnings (&rest body)
-      `(progn ,@body))))
+  (or (featurep 'emacs)
+      (and (fboundp 'float-time)
+           (subrp (symbol-function 'float-time)))
+      (defun time-to-seconds (time)
+        "Convert time value TIME to a floating point number."
+        (with-decoded-time-value ((high low micro time))
+          (+ (* 1.0 high 65536)
+             low
+             (/ micro 1000000.0))))))
 
 ;;;###autoload
 (defun seconds-to-time (seconds)
@@ -143,7 +140,7 @@
 
 ;;;###autoload
 (defun time-less-p (t1 t2)
-  "Say whether time value T1 is less than time value T2."
+  "Return non-nil if time value T1 is earlier than time value T2."
   (with-decoded-time-value ((high1 low1 micro1 t1)
                            (high2 low2 micro2 t2))
     (or (< high1 high2)
@@ -256,17 +253,15 @@
        (- (/ (1- year) 100))           ;       - century years
        (/ (1- year) 400))))            ;       + Gregorian leap years
 
-(eval-and-compile
-  (if (and (fboundp 'float-time)
-          (subrp (symbol-function 'float-time)))
-      (defun time-to-number-of-days (time)
-       "Return the number of days represented by TIME.
-The number of days will be returned as a floating point number."
-       (/ (float-time time) (* 60 60 24)))
-    (defun time-to-number-of-days (time)
-      "Return the number of days represented by TIME.
-The number of days will be returned as a floating point number."
-      (/ (with-no-warnings (time-to-seconds time)) (* 60 60 24)))))
+(defun time-to-number-of-days (time)
+  "Return the number of days represented by TIME.
+Returns a floating point number."
+  (/ (funcall (eval-when-compile
+                (if (or (featurep 'emacs)
+                        (and (fboundp 'float-time)
+                             (subrp (symbol-function 'float-time))))
+                    'float-time
+                  'time-to-seconds)) time) (* 60 60 24)))
 
 ;;;###autoload
 (defun safe-date-to-time (date)

=== modified file 'lisp/calendar/timeclock.el'
--- a/lisp/calendar/timeclock.el        2010-01-13 08:35:10 +0000
+++ b/lisp/calendar/timeclock.el        2010-11-10 04:08:15 +0000
@@ -543,11 +543,8 @@
        (message "%s" string)
       string)))
 
-(defsubst timeclock-time-to-seconds (time)
-  "Convert TIME to a floating point number."
-  (+ (* (car time) 65536.0)
-     (cadr time)
-     (/ (or (nth 2 time) 0) 1000000.0)))
+(defalias 'timeclock-time-to-seconds (if (fboundp 'float-time) 'float-time
+                                      'time-to-seconds))
 
 (defsubst timeclock-seconds-to-time (seconds)
   "Convert SECONDS (a floating point number) to an Emacs time structure."
@@ -1419,5 +1416,4 @@
 (if (file-readable-p timeclock-file)
     (timeclock-reread-log))
 
-;; arch-tag: a0be3377-deb6-44ec-b9a2-a7be28436a40
 ;;; timeclock.el ends here

=== modified file 'lisp/gnus/ChangeLog'
--- a/lisp/gnus/ChangeLog       2010-11-10 01:25:17 +0000
+++ b/lisp/gnus/ChangeLog       2010-11-10 04:08:15 +0000
@@ -1,3 +1,11 @@
+2010-11-10  Glenn Morris  <address@hidden>
+
+       * gnus-util.el (with-no-warnings): Remove compat stub, now unused.
+       (gnus-float-time): On Emacs, always an alias.
+
+       * ecomplete.el (with-no-warnings): Remove compat stub, now unused.
+       (ecomplete-add-item): Use float-time on Emacs, else gnus-float-time.
+
 2010-11-10  Katsumi Yamaoka  <address@hidden>
 
        * gnus-art.el (org-entities): Bind it.

=== modified file 'lisp/gnus/ecomplete.el'
--- a/lisp/gnus/ecomplete.el    2010-10-14 14:32:27 +0000
+++ b/lisp/gnus/ecomplete.el    2010-11-10 04:08:15 +0000
@@ -1,6 +1,7 @@
 ;;; ecomplete.el --- electric completion of addresses and the like
 
-;; Copyright (C) 2006, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
+;; Copyright (C) 2006, 2007, 2008, 2009, 2010
+;;   Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: mail
@@ -27,11 +28,6 @@
 (eval-when-compile
   (require 'cl))
 
-(eval-when-compile
-  (unless (fboundp 'with-no-warnings)
-    (defmacro with-no-warnings (&rest body)
-      `(progn ,@body))))
-
 (defgroup ecomplete nil
   "Electric completion of email addresses and the like."
   :group 'mail)
@@ -61,11 +57,10 @@
 (defun ecomplete-add-item (type key text)
   (let ((elems (assq type ecomplete-database))
        (now (string-to-number
-             (format "%.0f" (if (and (fboundp 'float-time)
-                                     (subrp (symbol-function 'float-time)))
+             (format "%.0f" (if (featurep 'emacs)
                                 (float-time)
-                              (with-no-warnings
-                                (time-to-seconds (current-time)))))))
+                              (require 'gnus-util)
+                              (gnus-float-time)))))
        entry)
     (unless elems
       (push (setq elems (list type)) ecomplete-database))

=== modified file 'lisp/gnus/gnus-util.el'
--- a/lisp/gnus/gnus-util.el    2010-11-02 04:06:44 +0000
+++ b/lisp/gnus/gnus-util.el    2010-11-10 04:08:15 +0000
@@ -39,11 +39,6 @@
 (eval-when-compile
   (require 'cl))
 
-(eval-when-compile
-  (unless (fboundp 'with-no-warnings)
-    (defmacro with-no-warnings (&rest body)
-      `(progn ,@body))))
-
 (defcustom gnus-completing-read-function 'gnus-emacs-completing-read
   "Function use to do completing read."
   :version "24.1"
@@ -320,13 +315,14 @@
             (> (nth 1 fdate) (nth 1 date))))))
 
 (eval-and-compile
-  (if (and (fboundp 'float-time)
-          (subrp (symbol-function 'float-time)))
+  (if (or (featurep 'emacs)
+         (and (fboundp 'float-time)
+              (subrp (symbol-function 'float-time))))
       (defalias 'gnus-float-time 'float-time)
     (defun gnus-float-time (&optional time)
       "Convert time value TIME to a floating point number.
 TIME defaults to the current time."
-      (with-no-warnings (time-to-seconds (or time (current-time)))))))
+      (time-to-seconds (or time (current-time))))))
 
 ;;; Keymap macros.
 

=== modified file 'lisp/textmodes/remember.el'
--- a/lisp/textmodes/remember.el        2010-01-13 08:35:10 +0000
+++ b/lisp/textmodes/remember.el        2010-11-10 04:08:15 +0000
@@ -1,7 +1,7 @@
 ;;; remember --- a mode for quickly jotting down things to remember
 
-;; Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007,
-;;   2008, 2009, 2010  Free Software Foundation, Inc.
+;; Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008,
+;;   2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 ;; Created: 29 Mar 1999
@@ -315,12 +315,6 @@
   (let ((remember-in-new-frame t))
     (remember initial)))
 
-(defsubst remember-time-to-seconds (time)
-  "Convert TIME to a floating point number."
-  (+ (* (car time) 65536.0)
-     (cadr time)
-     (/ (or (car (cdr (cdr time))) 0) 1000000.0)))
-
 (defsubst remember-mail-date (&optional rfc822-p)
   "Return a simple date.  Nothing fancy."
   (if rfc822-p
@@ -355,8 +349,7 @@
 Each piece of pseudo-mail created will have an `X-Todo-Priority'
 field, for the purpose of appropriate splitting."
   (let ((who (read-string "Who is this item related to? "))
-        (moment
-         (format "%.0f" (remember-time-to-seconds (current-time))))
+        (moment (format "%.0f" (float-time)))
         (desc (remember-buffer-desc))
         (text (buffer-string)))
     (with-temp-buffer
@@ -535,5 +528,4 @@
 \\{remember-mode-map}"
   (set-keymap-parent remember-mode-map nil))
 
-;; arch-tag: 59312a05-06c7-4da1-b6f7-5ea41c9d5577
 ;;; remember.el ends here


reply via email to

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