-(eval-and-compile
- (defvar ps-print-emacs-type
- (cond ((string-match "XEmacs" emacs-version) 'xemacs)
- ((string-match "Lucid" emacs-version) 'lucid)
- ((string-match "Epoch" emacs-version) 'epoch)
- (t 'emacs)))
-
- (if (memq ps-print-emacs-type '(lucid xemacs))
- (if (< emacs-minor-version 12)
- (setq ps-print-color-p nil))
- (require 'faces)) ; face-font, face-underline-p,
- ; x-font-regexp
-
-
- ;; Return t if the device (which can be changed during an emacs session)
- ;; can handle colors.
- ;; This function is not yet implemented for GNU emacs.
- (cond ((and (eq ps-print-emacs-type 'xemacs)
- (>= emacs-minor-version 12)) ; xemacs
- (defun ps-color-device ()
- (eq (ps-x-device-class) 'color)))
-
- (t ; emacs
- (defun ps-color-device ()
- (if (fboundp 'color-values)
- (ps-e-color-values "Green")
- t))))
-
-
- (defun ps-mapper (extent list)
- (nconc list
- (list (list (ps-x-extent-start-position extent) 'push extent)
- (list (ps-x-extent-end-position extent) 'pull extent)))
- nil)
-
- (defun ps-extent-sorter (a b)
- (< (ps-x-extent-priority a) (ps-x-extent-priority b)))
-
- (defun ps-xemacs-face-kind-p (face kind kind-regex)
- (let* ((frame-font (or (ps-x-face-font-instance face)
- (ps-x-face-font-instance 'default)))
- (kind-cons
- (and frame-font
- (assq kind
- (ps-x-font-instance-properties frame-font))))
- (kind-spec (cdr-safe kind-cons))
- (case-fold-search t))
- (and kind-spec (string-match kind-regex kind-spec))))
-
- (defun ps-xemacs-color-name (color)
- (if (ps-x-color-specifier-p color)
- (ps-x-color-name color)
- color))
-
- (cond ((eq ps-print-emacs-type 'emacs) ; emacs
-
- (defun ps-color-values (x-color)
+(defun ps-comment-string (str value)
+ "Return a comment string like \";; STR = VALUE\"."
+ (format ";; %s = %s" str (ps-value-string value)))
+
+
+(defun ps-value (alist-sym key)
+ "Return value from association list ALIST-SYM which car is `eq' to KEY."
+ (cdr (assq key (symbol-value alist-sym))))
+
+
+(defun ps-get (alist-sym key)
+ "Return element from association list ALIST-SYM which car is `eq' to KEY."
+ (assq key (symbol-value alist-sym)))
+
+
+(defun ps-put (alist-sym key value)
+ "Store element (KEY . VALUE) into association list ALIST-SYM.
+If KEY already exists in ALIST-SYM, modify cdr to VALUE.
+It can be retrieved with `(ps-get ALIST-SYM KEY)'."
+ (let ((elt: (assq key (symbol-value alist-sym)))) ; to avoid name conflict
+ (if elt:
+ (setcdr elt: value)
+ (setq elt: (cons key value))
+ (set alist-sym (cons elt: (symbol-value alist-sym))))
+ elt:))
+
+
+(defun ps-del (alist-sym key)
+ "Delete by side effect element KEY from association list ALIST-SYM."
+ (let ((a:list: (symbol-value alist-sym)) ; to avoid name conflict
+ old)
+ (while a:list:
+ (if (eq key (car (car a:list:)))
+ (progn
+ (if old
+ (setcdr old (cdr a:list:))
+ (set alist-sym (cdr a:list:)))
+ (setq a:list: nil))
+ (setq old a:list:
+ a:list: (cdr a:list:)))))
+ (symbol-value alist-sym))
+
+
+(defun ps-time-stamp-locale-default ()
+ "Return the locale's \"preferred\" date as, for example, \"06/18/01\"."
+ (format-time-string "%x"))
+
+
+(defun ps-time-stamp-mon-dd-yyyy ()
+ "Return date as \"Jun 18 2001\"."
+ (format-time-string "%b %d %Y"))
+
+
+(defun ps-time-stamp-yyyy-mm-dd ()
+ "Return date as \"2001-06-18\" (ISO date)."
+ (format-time-string "%Y-%m-%d"))
+
+
+;; Alias for `ps-time-stamp-yyyy-mm-dd' (which see).
+(defalias 'ps-time-stamp-iso8601 'ps-time-stamp-yyyy-mm-dd)
+
+
+(defun ps-time-stamp-hh:mm:ss ()
+ "Return time as \"17:28:31\"."
+ (format-time-string "%T"))
+
+
+(and (featurep 'xemacs)
+ ;; XEmacs change: Need to check for emacs-major-version too.
+ (or (< emacs-major-version 19)
+ (and (= emacs-major-version 19) (< emacs-minor-version 12)))
+ (setq ps-print-color-p nil))
+
+
+;; Return t if the device (which can be changed during an emacs session)
+;; can handle colors.
+;; This function is not yet implemented for GNU emacs.
+(cond ((and (featurep 'xemacs)
+ ;; XEmacs change: Need to check for emacs-major-version too.
+ (or (> emacs-major-version 19)
+ (and (= emacs-major-version 19)
+ (>= emacs-minor-version 12)))) ; xemacs >= 19.12
+ (defun ps-color-device ()
+ (eq (ps-x-device-class) 'color)))
+
+ (t ; emacs
+ (defun ps-color-device ()
+ (if (fboundp 'color-values)
+ (ps-e-color-values "Green")
+ t))))
+
+
+(defun ps-mapper (extent list)
+ (nconc list
+ (list (list (ps-x-extent-start-position extent) 'push extent)
+ (list (ps-x-extent-end-position extent) 'pull extent)))
+ nil)
+
+(defun ps-extent-sorter (a b)
+ (< (ps-x-extent-priority a) (ps-x-extent-priority b)))
+
+(defun ps-xemacs-face-kind-p (face kind kind-regex)
+ (let* ((frame-font (or (ps-x-face-font-instance face)
+ (ps-x-face-font-instance 'default)))
+ (kind-cons
+ (and frame-font
+ (assq kind
+ (ps-x-font-instance-properties frame-font))))
+ (kind-spec (cdr-safe kind-cons))
+ (case-fold-search t))
+ (and kind-spec (string-match kind-regex kind-spec))))
+
+(cond ((featurep 'xemacs) ; xemacs
+
+ ;; to avoid XEmacs compilation gripes
+ (defvar coding-system-for-write nil)
+ (defvar coding-system-for-read nil)
+ (defvar buffer-file-coding-system nil)
+
+ (and (fboundp 'find-coding-system)
+ (or (ps-x-find-coding-system 'raw-text-unix)
+ (ps-x-copy-coding-system 'no-conversion-unix 'raw-text-unix)))
+
+ (defun ps-color-values (x-color)
+ (let ((color (ps-xemacs-color-name x-color)))