Source

pcl-cvs / pcl-cvs-compat.el

Full commit
;;; pcl-cvs-compat.el

(defconst rcsid-pcl-cvs-compat "$Id")

;; Copyright (C) 1999  Stefan Monnier <monnier@cs.yale.edu>
;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, write to the Free Software
;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

(require 'cl)
(require 'string)

;; recent versions of Emacs provide split-string
;; for other versions, we define it in terms of string's string-split
(unless (fboundp 'split-string)
  (defun split-string (str &optional sep)
    ;; this is not quite correct since we should only eliminate
    ;; a leading and a trailing empty string, but it's enough for our use.
    (delete-if (lambda (str) (string= str "")) (string-split sep str))))

(unless (fboundp 'set-keymap-parent)
  (defun set-keymap-parent (keymap parent)
    (unless (and (consp keymap) (eq 'keymap (car keymap)))
      (error "unknown keymap type"))
    (setf (cdr (last keymap)) parent)))

;; deal with custom-deprived Emacsen
(ignore-errors (require 'custom))
(unless (fboundp 'defgroup)
  (defmacro defgroup (&rest rest) ())
  (defmacro defcustom (sym val str &rest rest) `(defvar ,sym ,val ,str))
  (defmacro defface (sym val str &rest rest)
    `(defvar ,sym
       (let* ((face (make-face ',sym))
	      (plist (car (cdr (car ,val))))
	      (fg (plist-get plist ':foreground))
	      (bold (plist-get plist ':bold)))
	 (if fg (set-face-foreground face fg))
	 (if bold (set-face-bold-p face bold))
	 face)
       ,str)))

;; hopefully Emacs will end up providing this
(unless (fboundp 'read-directory-name)
  (defalias 'read-directory-name 'read-file-name))

;;
(provide 'pcl-cvs-compat)