;;; Code:
-(provide 'poe) ; beware of circular dependency.
- ; localhook.el depends on poe.el.
+(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)
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))))
(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))))
;; 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)
(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)
"\
(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)
(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)
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. 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)
((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"))
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.
(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.