Update for the new CVS server.
[elisp/apel.git] / poe.el
diff --git a/poe.el b/poe.el
index 195fbea..b577da1 100644 (file)
--- a/poe.el
+++ b/poe.el
 
 ;;; Code:
 
-(provide 'poe)                         ; beware of circular dependency.
-                                       ; localhook.el depends on poe.el.
-(require 'pym)                         ; `static-*' and `def*-maybe'.
+(require 'product)
+(product-provide (provide 'poe) (require 'apel-ver))
+
+(require 'pym)
 
 
 ;;; @ Version information.
 ;;;
 
-(defconst-maybe emacs-major-version
-  (progn (string-match "^[0-9]+" emacs-version)
-        (string-to-int (substring emacs-version
-                                  (match-beginning 0)(match-end 0))))
-  "Major version number of this version of Emacs.")
-
-(defconst-maybe emacs-minor-version
-  (progn (string-match "^[0-9]+\\.\\([0-9]+\\)" emacs-version)
-        (string-to-int (substring emacs-version
-                                  (match-beginning 1)(match-end 1))))
-  "Minor version number of this version of Emacs.")
-
 (static-when (= emacs-major-version 18)
   (require 'poe-18))
 
 
 (static-when (featurep 'xemacs)
   (require 'poe-xemacs))
+
+;; must be load-time check to share .elc between different systems.
+(or (fboundp 'open-network-stream)
+    (require 'tcp))
 \f
 
 ;;; @ C primitives emulation.
 ;;;
 
-;; (require FEATURE &optional FILENAME NOERROR)
-;; Emacs 20.4 and later takes optional 3rd arg NOERROR.
+;; Emacs 20.3 and earlier: (require FEATURE &optional FILENAME)
+;; Emacs 20.4 and later: (require FEATURE &optional FILENAME NOERROR)
 (static-condition-case nil
     ;; compile-time check.
     (progn
       (require 'nofeature "nofile" 'noerror)
       (if (get 'require 'defun-maybe)
-         (error "")))                  ; already redefined.
+         (error "`require' is already redefined")))
   (error
    ;; load-time check.
    (or (fboundp 'si:require)
@@ -119,6 +112,7 @@ corresponding to the given PROP, or nil if PROP is not
 one of the properties on the list."
          (setplist 'plist-get-internal-symbol plist)
          (get 'plist-get-internal-symbol prop))
+       ;; for `load-history'.
        (setq current-load-list (cons 'plist-get current-load-list))
        (put 'plist-get 'defun-maybe t))))
 
@@ -156,6 +150,7 @@ The PLIST is modified by side effects."
          (setplist 'plist-put-internal-symbol plist)
          (put 'plist-put-internal-symbol prop val)
          (symbol-plist 'plist-put-internal-symbol))
+       ;; for `load-history'.
        (setq current-load-list (cons 'plist-put current-load-list))
        (put 'plist-put 'defun-maybe t))))
 
@@ -193,8 +188,8 @@ See `read-from-minibuffer' for details of HISTORY argument."
     ;; compile-time check.
     (if (= (string-to-number "1e1" 16) 481)
        (if (get 'string-to-number 'defun-maybe)
-           (error ""))                 ; already redefined.
-      (error ""))                      ; Emacs 20.3 and ealier.
+           (error "`string-to-number' is already redefined"))
+      (error "`string-to-number' is broken"))
   (error
    ;; load-time check.
    (or (fboundp 'si:string-to-number)
@@ -202,7 +197,9 @@ See `read-from-minibuffer' for details of HISTORY argument."
         (if (fboundp 'string-to-number)
             (fset 'si:string-to-number (symbol-function 'string-to-number))
           (fset 'si:string-to-number (symbol-function 'string-to-int))
-          (defalias 'string-to-int 'string-to-number))
+          ;; XXX: In v18, this causes infinite loop while bytecompiling.
+          ;; (defalias 'string-to-int 'string-to-number)
+          )
         (put 'string-to-number 'defun-maybe t)
         (defun string-to-number (string &optional base)
           "\
@@ -273,7 +270,7 @@ If the base used is not 10, floating point is not recognized."
     (progn
       (char-before)
       (if (get 'char-before 'defun-maybe)
-         (error "")))                  ; already defined.
+         (error "`char-before' is already defined")))
   (wrong-number-of-arguments            ; Mule.
    ;; load-time check.
    (or (fboundp 'si:char-before)
@@ -338,7 +335,7 @@ If POS is out of range, the value is nil."
     (progn
       (char-after)
       (if (get 'char-after 'defun-maybe)
-         (error "")))                  ; already defined.
+         (error "`char-after' is already redefined")))
   (wrong-number-of-arguments           ; v18, v19
    ;; load-time check.
    (or (fboundp 'si:char-after)
@@ -639,9 +636,13 @@ On those systems, it is automatically local in every buffer.
 On other systems, this variable is normally always nil.")
 
 ;; Emacs 20.1/XEmacs 20.3(?) and later: (save-current-buffer &rest BODY)
+;;
 ;; v20 defines `save-current-buffer' as a C primitive (in src/editfns.c)
 ;; and introduces a new bytecode Bsave_current_buffer(_1), replacing an
-;; obsolete bytecode Bread_char.
+;; obsolete bytecode Bread_char.  To make things worse, Emacs 20.1 and
+;; 20.2 have a bug that it will restore the current buffer without
+;; confirming that it is alive.
+;;
 ;; This is a source of incompatibility of .elc between v18/v19 and v20.
 ;; (XEmacs compiler takes care of it if compatibility mode is enabled.)
 (defmacro-maybe save-current-buffer (&rest body)
@@ -843,8 +844,8 @@ If PATTERN is omitted, it defaults to \"[ \\f\\t\\n\\r\\v]+\"."
  ((memq system-type '(windows-nt ms-dos))
   ;; should we do (require 'filename) at load-time ?
   ;; (require 'filename)
-  ;; filename.el requires many modules, so we do not want to load at
-  ;; compile-time. instead, suppress warnings by this.
+  ;; filename.el requires many modules, so we do not want to load it
+  ;; at compile-time. Instead, suppress warnings by these autoloads.
   (eval-when-compile
     (autoload 'filename-maybe-truncate-by-size "filename")
     (autoload 'filename-special-filter "filename"))
@@ -919,7 +920,7 @@ Otherwise, FACE-OR-NAME should be a symbol.  If there is no such face,
 nil is returned.  Otherwise the associated face object is returned."
   (car (memq face-or-name (face-list))))
 
-;; Emacs 20.5 defines this as an alias for `line-beginning-position'.
+;; Emacs 21.1 defines this as an alias for `line-beginning-position'.
 ;; Therefore, optional 2nd arg BUFFER is not portable.
 (defun-maybe point-at-bol (&optional n buffer)
   "Return the character position of the first character on the current line.
@@ -931,7 +932,7 @@ This function does not move point."
     (forward-line (1- (or n 1)))
     (point)))
 
-;; Emacs 20.5 defines this as an alias for `line-end-position'.
+;; Emacs 21.1 defines this as an alias for `line-end-position'.
 ;; Therefore, optional 2nd arg BUFFER is not portable.
 (defun-maybe point-at-eol (&optional n buffer)
   "Return the character position of the last character on the current line.