Bladeren bron

add lazyload-eval

pull/1/head
10sr 11 jaren geleden
bovenliggende
commit
81638f2891
1 gewijzigde bestanden met toevoegingen van 26 en 8 verwijderingen
  1. +26
    -8
      emacs.el

+ 26
- 8
emacs.el Bestand weergeven

@@ -69,14 +69,32 @@ otherwise the path where the library installed."
(locate-library lib)) (locate-library lib))
locate-p))) 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 ;; start and quit


Laden…
Annuleren
Opslaan