aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2010-11-09 20:08:15 -0800
committerGlenn Morris2010-11-09 20:08:15 -0800
commit6f0d4bb6b2793e06eb445cd58be0e4797f1030c0 (patch)
tree2b2caed0460cd8d07e23d7ee830c9b7a4d1a1ad7
parent73171bd4cc3333a43ef8810ba4f7d0a864f20fa8 (diff)
downloademacs-6f0d4bb6b2793e06eb445cd58be0e4797f1030c0.tar.gz
emacs-6f0d4bb6b2793e06eb445cd58be0e4797f1030c0.zip
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.
-rw-r--r--lisp/ChangeLog11
-rw-r--r--lisp/calendar/time-date.el49
-rw-r--r--lisp/calendar/timeclock.el8
-rw-r--r--lisp/gnus/ChangeLog8
-rw-r--r--lisp/gnus/ecomplete.el15
-rw-r--r--lisp/gnus/gnus-util.el12
-rw-r--r--lisp/textmodes/remember.el14
7 files changed, 55 insertions, 62 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 3fa23066963..093dad1461c 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,16 @@
12010-11-10 Glenn Morris <rgm@gnu.org> 12010-11-10 Glenn Morris <rgm@gnu.org>
2 2
3 * textmodes/remember.el (remember-time-to-seconds): Remove.
4 (remember-store-in-mailbox): Use float-time.
5
6 * calendar/timeclock.el (timeclock-time-to-seconds): Make it an alias.
7
8 * calendar/time-date.el (time-to-seconds): Always an alias on Emacs,
9 never a real function.
10 (with-no-warnings): Remove compat stub, now unused.
11 (time-less-p): Doc fix.
12 (time-to-number-of-days): Simplify.
13
3 * eshell/esh-util.el (eshell-time-less-p, eshell-time-to-seconds): 14 * eshell/esh-util.el (eshell-time-less-p, eshell-time-to-seconds):
4 Remove. 15 Remove.
5 (eshell-read-passwd, eshell-read-hosts): Use time-less-p. 16 (eshell-read-passwd, eshell-read-hosts): Use time-less-p.
diff --git a/lisp/calendar/time-date.el b/lisp/calendar/time-date.el
index 84fc465f984..1bd04d7ed3b 100644
--- a/lisp/calendar/time-date.el
+++ b/lisp/calendar/time-date.el
@@ -112,27 +112,24 @@ If DATE lacks timezone information, GMT is assumed."
112;; Bit of a mess. Emacs has float-time since at least 21.1. 112;; Bit of a mess. Emacs has float-time since at least 21.1.
113;; This file is synced to Gnus, and XEmacs packages may have been written 113;; This file is synced to Gnus, and XEmacs packages may have been written
114;; using time-to-seconds from the Gnus library. 114;; using time-to-seconds from the Gnus library.
115;;;###autoload(if (and (fboundp 'float-time) 115;;;###autoload(if (or (featurep 'emacs)
116;;;###autoload (subrp (symbol-function 'float-time))) 116;;;###autoload (and (fboundp 'float-time)
117;;;###autoload (subrp (symbol-function 'float-time))))
117;;;###autoload (progn 118;;;###autoload (progn
118;;;###autoload (defalias 'time-to-seconds 'float-time) 119;;;###autoload (defalias 'time-to-seconds 'float-time)
119;;;###autoload (make-obsolete 'time-to-seconds 'float-time "21.1")) 120;;;###autoload (make-obsolete 'time-to-seconds 'float-time "21.1"))
120;;;###autoload (autoload 'time-to-seconds "time-date")) 121;;;###autoload (autoload 'time-to-seconds "time-date"))
121 122
122(eval-and-compile
123 (unless (and (fboundp 'float-time)
124 (subrp (symbol-function 'float-time)))
125 (defun time-to-seconds (time)
126 "Convert time value TIME to a floating point number."
127 (with-decoded-time-value ((high low micro time))
128 (+ (* 1.0 high 65536)
129 low
130 (/ micro 1000000.0))))))
131
132(eval-when-compile 123(eval-when-compile
133 (unless (fboundp 'with-no-warnings) 124 (or (featurep 'emacs)
134 (defmacro with-no-warnings (&rest body) 125 (and (fboundp 'float-time)
135 `(progn ,@body)))) 126 (subrp (symbol-function 'float-time)))
127 (defun time-to-seconds (time)
128 "Convert time value TIME to a floating point number."
129 (with-decoded-time-value ((high low micro time))
130 (+ (* 1.0 high 65536)
131 low
132 (/ micro 1000000.0))))))
136 133
137;;;###autoload 134;;;###autoload
138(defun seconds-to-time (seconds) 135(defun seconds-to-time (seconds)
@@ -143,7 +140,7 @@ If DATE lacks timezone information, GMT is assumed."
143 140
144;;;###autoload 141;;;###autoload
145(defun time-less-p (t1 t2) 142(defun time-less-p (t1 t2)
146 "Say whether time value T1 is less than time value T2." 143 "Return non-nil if time value T1 is earlier than time value T2."
147 (with-decoded-time-value ((high1 low1 micro1 t1) 144 (with-decoded-time-value ((high1 low1 micro1 t1)
148 (high2 low2 micro2 t2)) 145 (high2 low2 micro2 t2))
149 (or (< high1 high2) 146 (or (< high1 high2)
@@ -256,17 +253,15 @@ The Gregorian date Sunday, December 31, 1bce is imaginary."
256 (- (/ (1- year) 100)) ; - century years 253 (- (/ (1- year) 100)) ; - century years
257 (/ (1- year) 400)))) ; + Gregorian leap years 254 (/ (1- year) 400)))) ; + Gregorian leap years
258 255
259(eval-and-compile 256(defun time-to-number-of-days (time)
260 (if (and (fboundp 'float-time) 257 "Return the number of days represented by TIME.
261 (subrp (symbol-function 'float-time))) 258Returns a floating point number."
262 (defun time-to-number-of-days (time) 259 (/ (funcall (eval-when-compile
263 "Return the number of days represented by TIME. 260 (if (or (featurep 'emacs)
264The number of days will be returned as a floating point number." 261 (and (fboundp 'float-time)
265 (/ (float-time time) (* 60 60 24))) 262 (subrp (symbol-function 'float-time))))
266 (defun time-to-number-of-days (time) 263 'float-time
267 "Return the number of days represented by TIME. 264 'time-to-seconds)) time) (* 60 60 24)))
268The number of days will be returned as a floating point number."
269 (/ (with-no-warnings (time-to-seconds time)) (* 60 60 24)))))
270 265
271;;;###autoload 266;;;###autoload
272(defun safe-date-to-time (date) 267(defun safe-date-to-time (date)
diff --git a/lisp/calendar/timeclock.el b/lisp/calendar/timeclock.el
index 32e0bf61380..d28b0a56c3f 100644
--- a/lisp/calendar/timeclock.el
+++ b/lisp/calendar/timeclock.el
@@ -543,11 +543,8 @@ non-nil, the amount returned will be relative to past time worked."
543 (message "%s" string) 543 (message "%s" string)
544 string))) 544 string)))
545 545
546(defsubst timeclock-time-to-seconds (time) 546(defalias 'timeclock-time-to-seconds (if (fboundp 'float-time) 'float-time
547 "Convert TIME to a floating point number." 547 'time-to-seconds))
548 (+ (* (car time) 65536.0)
549 (cadr time)
550 (/ (or (nth 2 time) 0) 1000000.0)))
551 548
552(defsubst timeclock-seconds-to-time (seconds) 549(defsubst timeclock-seconds-to-time (seconds)
553 "Convert SECONDS (a floating point number) to an Emacs time structure." 550 "Convert SECONDS (a floating point number) to an Emacs time structure."
@@ -1419,5 +1416,4 @@ HTML-P is non-nil, HTML markup is added."
1419(if (file-readable-p timeclock-file) 1416(if (file-readable-p timeclock-file)
1420 (timeclock-reread-log)) 1417 (timeclock-reread-log))
1421 1418
1422;; arch-tag: a0be3377-deb6-44ec-b9a2-a7be28436a40
1423;;; timeclock.el ends here 1419;;; timeclock.el ends here
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 88143e927c9..7f0d9b5693c 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,11 @@
12010-11-10 Glenn Morris <rgm@gnu.org>
2
3 * gnus-util.el (with-no-warnings): Remove compat stub, now unused.
4 (gnus-float-time): On Emacs, always an alias.
5
6 * ecomplete.el (with-no-warnings): Remove compat stub, now unused.
7 (ecomplete-add-item): Use float-time on Emacs, else gnus-float-time.
8
12010-11-10 Katsumi Yamaoka <yamaoka@jpl.org> 92010-11-10 Katsumi Yamaoka <yamaoka@jpl.org>
2 10
3 * gnus-art.el (org-entities): Bind it. 11 * gnus-art.el (org-entities): Bind it.
diff --git a/lisp/gnus/ecomplete.el b/lisp/gnus/ecomplete.el
index 33d2ddd6a71..1f705674962 100644
--- a/lisp/gnus/ecomplete.el
+++ b/lisp/gnus/ecomplete.el
@@ -1,6 +1,7 @@
1;;; ecomplete.el --- electric completion of addresses and the like 1;;; ecomplete.el --- electric completion of addresses and the like
2 2
3;; Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 3;; Copyright (C) 2006, 2007, 2008, 2009, 2010
4;; Free Software Foundation, Inc.
4 5
5;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> 6;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6;; Keywords: mail 7;; Keywords: mail
@@ -27,11 +28,6 @@
27(eval-when-compile 28(eval-when-compile
28 (require 'cl)) 29 (require 'cl))
29 30
30(eval-when-compile
31 (unless (fboundp 'with-no-warnings)
32 (defmacro with-no-warnings (&rest body)
33 `(progn ,@body))))
34
35(defgroup ecomplete nil 31(defgroup ecomplete nil
36 "Electric completion of email addresses and the like." 32 "Electric completion of email addresses and the like."
37 :group 'mail) 33 :group 'mail)
@@ -61,11 +57,10 @@
61(defun ecomplete-add-item (type key text) 57(defun ecomplete-add-item (type key text)
62 (let ((elems (assq type ecomplete-database)) 58 (let ((elems (assq type ecomplete-database))
63 (now (string-to-number 59 (now (string-to-number
64 (format "%.0f" (if (and (fboundp 'float-time) 60 (format "%.0f" (if (featurep 'emacs)
65 (subrp (symbol-function 'float-time)))
66 (float-time) 61 (float-time)
67 (with-no-warnings 62 (require 'gnus-util)
68 (time-to-seconds (current-time))))))) 63 (gnus-float-time)))))
69 entry) 64 entry)
70 (unless elems 65 (unless elems
71 (push (setq elems (list type)) ecomplete-database)) 66 (push (setq elems (list type)) ecomplete-database))
diff --git a/lisp/gnus/gnus-util.el b/lisp/gnus/gnus-util.el
index e9e896963b3..cacca018fd5 100644
--- a/lisp/gnus/gnus-util.el
+++ b/lisp/gnus/gnus-util.el
@@ -39,11 +39,6 @@
39(eval-when-compile 39(eval-when-compile
40 (require 'cl)) 40 (require 'cl))
41 41
42(eval-when-compile
43 (unless (fboundp 'with-no-warnings)
44 (defmacro with-no-warnings (&rest body)
45 `(progn ,@body))))
46
47(defcustom gnus-completing-read-function 'gnus-emacs-completing-read 42(defcustom gnus-completing-read-function 'gnus-emacs-completing-read
48 "Function use to do completing read." 43 "Function use to do completing read."
49 :version "24.1" 44 :version "24.1"
@@ -320,13 +315,14 @@ Symbols are also allowed; their print names are used instead."
320 (> (nth 1 fdate) (nth 1 date)))))) 315 (> (nth 1 fdate) (nth 1 date))))))
321 316
322(eval-and-compile 317(eval-and-compile
323 (if (and (fboundp 'float-time) 318 (if (or (featurep 'emacs)
324 (subrp (symbol-function 'float-time))) 319 (and (fboundp 'float-time)
320 (subrp (symbol-function 'float-time))))
325 (defalias 'gnus-float-time 'float-time) 321 (defalias 'gnus-float-time 'float-time)
326 (defun gnus-float-time (&optional time) 322 (defun gnus-float-time (&optional time)
327 "Convert time value TIME to a floating point number. 323 "Convert time value TIME to a floating point number.
328TIME defaults to the current time." 324TIME defaults to the current time."
329 (with-no-warnings (time-to-seconds (or time (current-time))))))) 325 (time-to-seconds (or time (current-time))))))
330 326
331;;; Keymap macros. 327;;; Keymap macros.
332 328
diff --git a/lisp/textmodes/remember.el b/lisp/textmodes/remember.el
index d4de4e49b93..ab2c27563b0 100644
--- a/lisp/textmodes/remember.el
+++ b/lisp/textmodes/remember.el
@@ -1,7 +1,7 @@
1;;; remember --- a mode for quickly jotting down things to remember 1;;; remember --- a mode for quickly jotting down things to remember
2 2
3;; Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007, 3;; Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008,
4;; 2008, 2009, 2010 Free Software Foundation, Inc. 4;; 2009, 2010 Free Software Foundation, Inc.
5 5
6;; Author: John Wiegley <johnw@gnu.org> 6;; Author: John Wiegley <johnw@gnu.org>
7;; Created: 29 Mar 1999 7;; Created: 29 Mar 1999
@@ -315,12 +315,6 @@ With a prefix or a visible region, use the region as INITIAL."
315 (let ((remember-in-new-frame t)) 315 (let ((remember-in-new-frame t))
316 (remember initial))) 316 (remember initial)))
317 317
318(defsubst remember-time-to-seconds (time)
319 "Convert TIME to a floating point number."
320 (+ (* (car time) 65536.0)
321 (cadr time)
322 (/ (or (car (cdr (cdr time))) 0) 1000000.0)))
323
324(defsubst remember-mail-date (&optional rfc822-p) 318(defsubst remember-mail-date (&optional rfc822-p)
325 "Return a simple date. Nothing fancy." 319 "Return a simple date. Nothing fancy."
326 (if rfc822-p 320 (if rfc822-p
@@ -355,8 +349,7 @@ In which case `remember-mailbox' should be the name of the mailbox.
355Each piece of pseudo-mail created will have an `X-Todo-Priority' 349Each piece of pseudo-mail created will have an `X-Todo-Priority'
356field, for the purpose of appropriate splitting." 350field, for the purpose of appropriate splitting."
357 (let ((who (read-string "Who is this item related to? ")) 351 (let ((who (read-string "Who is this item related to? "))
358 (moment 352 (moment (format "%.0f" (float-time)))
359 (format "%.0f" (remember-time-to-seconds (current-time))))
360 (desc (remember-buffer-desc)) 353 (desc (remember-buffer-desc))
361 (text (buffer-string))) 354 (text (buffer-string)))
362 (with-temp-buffer 355 (with-temp-buffer
@@ -535,5 +528,4 @@ the data away for latter retrieval, and possible indexing.
535\\{remember-mode-map}" 528\\{remember-mode-map}"
536 (set-keymap-parent remember-mode-map nil)) 529 (set-keymap-parent remember-mode-map nil))
537 530
538;; arch-tag: 59312a05-06c7-4da1-b6f7-5ea41c9d5577
539;;; remember.el ends here 531;;; remember.el ends here