emacs-devel
[Top][All Lists]
Advanced

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

Re: Gnus and No Gnus


From: Katsumi Yamaoka
Subject: Re: Gnus and No Gnus
Date: Tue, 08 Sep 2009 14:15:41 +0900
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.1.50 (gnu/linux)

>>>>> Glenn Morris wrote:
> Katsumi Yamaoka wrote:

>> Today I tried synch'ing the Gnus trunk with the Emacs trunk and
>> found a problem concerning `float-time'.

> Sorry, I did my best to think about these issues.

>> In time-date.el, `define-obsolete-function-alias' is not available
>> in Emacs 21 that Gnus still supports.  It causes an error when
>> loading gnus-load.el.

> I'm not suggesting this as a solution to this issue, but does the very
> latest Gnus really need to run on 3 major versions of Emacs? When are
> you going to drop support for Emacs 21?

Basically I'm positive to drop old Emacsen.  It seems enough to
support the latest major version and one predecessor.  Those who
use Emacs 21 may perhaps not want to work on upgrading Gnus.
But in another thought, we don't have so much difficulty in
supporting Emacs 21 for the present.  Therefore I think it's not
time to drop Emacs 21.

>> In ecomplete.el, gnus-util.el and time-date.el, (featurep 'xemacs)
>> is used for checking if `float-time' is available like this:
>>
>>   (if (featurep 'xemacs)
>>       (time-to-seconds time)
>>     (float-time time))
>>
>> However, XEmacs may implement `float-time' in the future.

> I used featurep in preference to fboundp to avoid compilation
> warnings, and so that the compiler could optimise the test away.

Yes, I knew it.  (featurep 'xemacs) is useful in Emacs 22, 23
and XEmacs 21.5, so I hesitated to replace it with `fboundp'.
But it looks easy to provide `float-time' in XEmacs.

>> Therefore I made changes in those files as attached below.  WDYT?

> Fine. I would then stick a with-no-warnings around every use of
> time-to-seconds, and an eval-and-compile around the revised definition
> of gnus-float-time.

Unfortunately `with-no-warnings' is not available in Emacs 21
and XEmacs.  How about using macros like the following?  (For
warnings that old Emacsen and XEmacs issue, we can use lpath.el
and dgnushack.el.)

*** lisp/calendar/time-date.el~ 2009-09-02 21:50:25 +0000
--- lisp/calendar/time-date.el  2009-09-08 04:53:21 +0000
***************
*** 114,130 ****
  ;; 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 (featurep 'xemacs)
! ;;;###autoload     (autoload 'time-to-seconds "time-date")
! ;;;###autoload   (define-obsolete-function-alias 'time-to-seconds 'float-time 
"21.1"))
! 
! (if (featurep 'xemacs)
!     (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)
--- 114,132 ----
  ;; 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 (fboundp '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"))
! 
! (unless (fboundp '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)
***************
*** 248,259 ****
         (- (/ (1- year) 100))          ;       - century years
         (/ (1- year) 400))))           ;       + Gregorian leap years
  
  (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."
!   (/ (if (featurep 'xemacs)
!          (time-to-seconds time)
!        (float-time time)) (* 60 60 24)))
  
  ;;;###autoload
  (defun safe-date-to-time (date)
--- 250,266 ----
         (- (/ (1- year) 100))          ;       - century years
         (/ (1- year) 400))))           ;       + Gregorian leap years
  
+ (eval-when-compile
+   (defmacro time-date-float-time (time)
+     (if (and (fboundp 'float-time)
+            (subrp (symbol-function 'float-time)))
+       `(float-time ,time)
+       `(time-to-seconds (or ,time (current-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."
!   (/ (time-date-float-time time) (* 60 60 24)))
  
  ;;;###autoload
  (defun safe-date-to-time (date)
*** lisp/gnus/ecomplete.el~     2009-09-02 21:50:26 +0000
--- lisp/gnus/ecomplete.el      2009-09-08 04:53:21 +0000
***************
*** 53,64 ****
        (insert-file-contents ecomplete-database-file)
        (setq ecomplete-database (read (current-buffer)))))))
  
  (defun ecomplete-add-item (type key text)
    (let ((elems (assq type ecomplete-database))
!       (now (string-to-number
!             (format "%.0f" (if (featurep 'xemacs)
!                                (time-to-seconds (current-time))
!                              (float-time)))))
        entry)
      (unless elems
        (push (setq elems (list type)) ecomplete-database))
--- 53,68 ----
        (insert-file-contents ecomplete-database-file)
        (setq ecomplete-database (read (current-buffer)))))))
  
+ (eval-when-compile
+   (defmacro ecomplete-float-time ()
+     (if (and (fboundp 'float-time)
+            (subrp (symbol-function 'float-time)))
+       '(float-time)
+       '(time-to-seconds (current-time)))))
+ 
  (defun ecomplete-add-item (type key text)
    (let ((elems (assq type ecomplete-database))
!       (now (string-to-number (format "%.0f" (ecomplete-float-time))))
        entry)
      (unless elems
        (push (setq elems (list type)) ecomplete-database))
*** lisp/gnus/gnus-util.el~     2009-09-02 21:50:26 +0000
--- lisp/gnus/gnus-util.el      2009-09-08 04:53:21 +0000
***************
*** 285,296 ****
        (and (= (car fdate) (car date))
             (> (nth 1 fdate) (nth 1 date))))))
  
  (defun gnus-float-time (&optional time)
    "Convert time value TIME to a floating point number.
  TIME defaults to the current time."
!   (if (featurep 'xemacs)
!       (time-to-seconds (or time (current-time)))
!     (float-time time)))
  
  ;;; Keymap macros.
  
--- 285,301 ----
        (and (= (car fdate) (car date))
             (> (nth 1 fdate) (nth 1 date))))))
  
+ (eval-when-compile
+   (defmacro gnus-float-time-1 (time)
+     (if (and (fboundp 'float-time)
+            (subrp (symbol-function 'float-time)))
+       `(float-time ,time)
+       `(time-to-seconds (or ,time (current-time))))))
+ 
  (defun gnus-float-time (&optional time)
    "Convert time value TIME to a floating point number.
  TIME defaults to the current time."
!   (gnus-float-time-1 time))
  
  ;;; Keymap macros.
  

reply via email to

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