;;; gnus-compat.el --- Compatability functions for Gnus
-;; Copyright (C) 2012 Free Software Foundation, Inc.
+;; Copyright (C) 2012-2015 Free Software Foundation, Inc.
;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
;; Keywords: compat
(lambda (process status)
(apply function process status args))))))
+;; XEmacs 21.4
+(unless (fboundp 'bound-and-true-p)
+ (defmacro bound-and-true-p (var)
+ "Return the value of symbol VAR if it is bound, else nil."
+ (and (boundp var)
+ (symbol-value var))))
+
+
+;; Emacs less than 24.3
+(unless (fboundp 'add-face)
+ (defun add-face (beg end face)
+ "Combine FACE BEG and END."
+ (let ((b beg))
+ (while (< b end)
+ (let ((oldval (get-text-property b 'face)))
+ (put-text-property
+ b (setq b (next-single-property-change b 'face nil end))
+ 'face (cond ((null oldval)
+ face)
+ ((and (consp oldval)
+ (not (keywordp (car oldval))))
+ (cons face oldval))
+ (t
+ (list face oldval)))))))))
+
+(unless (fboundp 'move-beginning-of-line)
+ (defun move-beginning-of-line (arg)
+ (interactive "p")
+ (unless (= arg 1)
+ (forward-line arg))
+ (beginning-of-line)))
+
+(unless (fboundp 'delete-dups)
+ (defun delete-dups (list)
+ "Destructively remove `equal' duplicates from LIST.
+Store the result in LIST and return it. LIST must be a proper list.
+Of several `equal' occurrences of an element in LIST, the first
+one is kept."
+ (let ((tail list))
+ (while tail
+ (setcdr tail (delete (car tail) (cdr tail)))
+ (setq tail (cdr tail))))
+ list))
+
+(unless (fboundp 'declare-function)
+ (defmacro declare-function (&rest r)))
+
+(unless (fboundp 'string-bytes)
+ (defun string-bytes (string)
+ (length (if (or (mm-coding-system-p 'utf-8)
+ (ignore-errors
+ (let (mucs-ignore-version-incompatibilities)
+ (require 'un-define))))
+ (mm-encode-coding-string string 'utf-8)
+ string))))
+
+(unless (fboundp 'process-live-p)
+ (defun process-live-p (process)
+ "Returns non-nil if PROCESS is alive.
+A process is considered alive if its status is `run', `open',
+`listen', `connect' or `stop'. Value is nil if PROCESS is not a
+process."
+ (and (processp process)
+ (memq (process-status process)
+ '(run open listen connect stop)))))
+
(provide 'gnus-compat)
;; gnus-compat.el ends here