X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=install.el;h=4ddd36cd928e205a91eba1a94327bd9c9a4e3bee;hb=10a702f45266811c6ae6ffbe8f3db4820abc9a6b;hp=2d66b19d32c56530e85e0b610d1e816d2ef9ec83;hpb=bcf8bba7e3bb60be21e0fbc00a5533d6ebe6986d;p=elisp%2Fapel.git diff --git a/install.el b/install.el index 2d66b19..4ddd36c 100644 --- a/install.el +++ b/install.el @@ -25,8 +25,53 @@ ;;; Code: -(require 'poe) ; make-directory (for v18) -(require 'path-util) ; default-load-path +;; 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 'poe) ; emacs-major-version, emacs-minor-version +(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