From: shuhei-k Date: Tue, 22 Jun 1999 23:17:33 +0000 (+0000) Subject: Require 'emu for backward compatibility. X-Git-Tag: apel-9_20~12 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=41b0ecebd0ca2bac4f0f7ca4f3c6aa70201b7b97;p=elisp%2Fapel.git Require 'emu for backward compatibility. (defun-maybe): New macro; imported from poe.el. (make-directory-internal, make-directory): New functions; imported from poe-18.el. --- diff --git a/install.el b/install.el index 2d66b19..8c3f49b 100644 --- a/install.el +++ b/install.el @@ -25,9 +25,53 @@ ;;; Code: -(require 'poe) ; make-directory (for v18) +;; for historical reason, we do (require 'emu) in this file. +;; but you should do (require 'emu) explicitly if you use functions and/or +;; variables defined in emu module. +(require 'emu) (require 'path-util) ; default-load-path +;; verbatim copy of `defun-maybe' from poe.el, and +;; `make-directory-internal' and `make-directory' from poe-18.el +(defmacro defun-maybe (name &rest everything-else) + "Define NAME as a function if NAME is not defined. +See also the function `defun'." + (or (and (fboundp name) + (not (get name 'defun-maybe))) + (` (or (fboundp (quote (, name))) + (prog1 + (defun (, name) (,@ everything-else)) + (put (quote (, name)) 'defun-maybe t)))))) + +(defun-maybe make-directory-internal (dirname) + "Create a directory. One argument, a file name string." + (let ((dir (expand-file-name dirname))) + (if (file-exists-p dir) + (error "Creating directory: %s is already exist" dir) + (call-process "mkdir" nil nil nil dir)))) + +(defun-maybe make-directory (dir &optional parents) + "Create the directory DIR and any nonexistent parent dirs. +The second (optional) argument PARENTS says whether +to create parent directories if they don't exist." + (let ((len (length dir)) + (p 0) p1 path) + (catch 'tag + (while (and (< p len) (string-match "[^/]*/?" dir p)) + (setq p1 (match-end 0)) + (if (= p1 len) + (throw 'tag nil)) + (setq path (substring dir 0 p1)) + (if (not (file-directory-p path)) + (cond ((file-exists-p path) + (error "Creating directory: %s is not directory" path)) + ((null parents) + (error "Creating directory: %s is not exist" path)) + (t + (make-directory-internal path)))) + (setq p p1))) + (make-directory-internal dir))) + ;;; @ compile Emacs Lisp files ;;;