Browse Source

emacs.el: Do not download libraries for test

pull/2/head
10sr 10 years ago
parent
commit
f14ef46d6c
2 changed files with 19 additions and 4 deletions
  1. +2
    -2
      Makefile
  2. +17
    -2
      emacs.el

+ 2
- 2
Makefile View File

@@ -90,5 +90,5 @@ $(test_shs): test_%: %
sh -exc 'for sh in $(shrc_loadables); do $$sh -n $<; done'

test_el: emacs.el
$(emacs) -q --debug-init --batch --eval "(setq debug-on-error t)" \
--load $< --kill
EMACS_EL_DRY_RUN=t $(emacs) -q --debug-init --batch \
--eval "(setq debug-on-error t)" --load $< --kill

+ 17
- 2
emacs.el View File

@@ -44,17 +44,25 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; download library from web

(defvar fetch-library-enabled-p t
"Set nil to skip downloading with `fetch-library'.")
(defun fetch-library (url &optional byte-compile-p force-download-p)
"Download a library from URL and locate it in \"~/emacs.d/lisp/\".
Return nil if library unfound and failed to download,
otherwise the path where the library installed.
If BYTE-COMPILE-P is t byte compile the file after downloading.
If FORCE-DOWNLOAD-P it t ignore exisiting library and always download."
If FORCE-DOWNLOAD-P it t ignore exisiting library and always download.

This function also checks the value of `fetch-library-enabled-p' and do not
fetch libraries if this value is nil. In this case all arguments (including
FORCE-DOWNLOAD-P) will be ignored."
(let* ((dir (expand-file-name (concat user-emacs-directory "lisp/")))
(lib (file-name-sans-extension (file-name-nondirectory url)))
(lpath (concat dir lib ".el"))
(locate-p (locate-library lib)))
(if (or force-download-p (not locate-p))
(if (and fetch-library-enabled-p
(or force-download-p
(not locate-p)))
(if (progn (message "Downloading %s..."
url)
(download-file url
@@ -76,6 +84,13 @@ If FORCE-DOWNLOAD-P it t ignore exisiting library and always download."
(message "Downloading %s...failed"
url))))
(locate-library lib)))
;; If EMACS_EL_DRY_RUN is set and it is not an empty string, fetch-library
;; does not actually fetch library.
(setq fetch-library-enabled-p
(let ((dryrun (getenv "EMACS_EL_DRY_RUN")))
(not (and dryrun
(eq 0
(length dryrun))))))

(defun download-file (url path &optional ok-if-already-exists)
"Download file from URL and output to PATH.


Loading…
Cancel
Save