Browse Source

add lazyload-eval

pull/1/head
10sr 12 years ago
parent
commit
81638f2891
1 changed files with 26 additions and 8 deletions
  1. +26
    -8
      emacs.el

+ 26
- 8
emacs.el View File

@@ -69,14 +69,32 @@ otherwise the path where the library installed."
(locate-library lib))
locate-p)))

;; (defmacro f-autoload (feature functions &rest form)
;; `(,@(mapcar (lambda (f)
;; `(autoload ,f ,(symbol-name feature)))
;; functions)
;; (eval-after-load ,feature
;; ,@form)))

;; (f-autoload autosave (a b) (ddd) (ccc))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; autoload

(defmacro lazyload-eval (feature functions &rest form)
"Define FUNCTIONS to autoload from FEATURE.
FEATURE is a symbol. FUNCTIONS is a list of symbols.
FORM is passed to `eval-after-load'.
When this macro is evaluated, this returns the path to library if feature
found, otherwise returns nil."
`(progn
,@(mapcar (lambda (f)
`(autoload (quote ,f)
,(symbol-name (eval feature))
""
t))
(eval functions))
(eval-after-load ,feature
'(progn
,@form))
(locate-library ,(symbol-name (eval feature)))))

;; (macroexpand '(f-autoload 'autosave '(a-f b-f) (message "1") (message "2")))
(when (lazyload-eval 'tetris
'(tetris)
(message "tetris loaded!"))
(message "tetris found!"))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; start and quit


Loading…
Cancel
Save