Przeglądaj źródła

do not define autoload function if feature is not found

pull/1/head
10sr 13 lat temu
rodzic
commit
a219445b82
1 zmienionych plików z 16 dodań i 15 usunięć
  1. +16
    -15
      emacs.el

+ 16
- 15
emacs.el Wyświetl plik

@@ -73,7 +73,7 @@ otherwise the path where the library installed."
;; autoload ;; autoload


(defmacro lazy-load-eval (feature &optional functions &rest body) (defmacro lazy-load-eval (feature &optional functions &rest body)
"Define FUNCTIONS to autoload from FEATURE.
"Define each FUNCTIONS to autoload from FEATURE.
FEATURE is a symbol. FUNCTIONS is a list of symbols. If FUNCTIONS is nil, FEATURE is a symbol. FUNCTIONS is a list of symbols. If FUNCTIONS is nil,
the function same as FEATURE is defined as autoloaded function. BODY is passed the function same as FEATURE is defined as autoloaded function. BODY is passed
to `eval-after-load'. to `eval-after-load'.
@@ -81,20 +81,21 @@ When this macro is evaluated, this returns the path to library if FEATURE
found, otherwise returns nil." found, otherwise returns nil."
(let* ((libname (symbol-name (eval feature))) (let* ((libname (symbol-name (eval feature)))
(libpath (locate-library libname))) (libpath (locate-library libname)))
`(progn
,@(mapcar (lambda (f)
`(autoload (quote ,f)
,libname
,(concat "Autoloaded function defined in \""
libpath
"\".")
t))
(or (eval functions)
`(,(eval feature))))
(eval-after-load ,feature
'(progn
,@body))
,libpath)))
(and libpath
`(progn
,@(mapcar (lambda (f)
`(autoload (quote ,f)
,libname
,(concat "Autoloaded function defined in \""
libpath
"\".")
t))
(or (eval functions)
`(,(eval feature))))
(eval-after-load ,feature
'(progn
,@body))
,libpath))))
(put 'lazy-load-eval 'lisp-indent-function 2) (put 'lazy-load-eval 'lisp-indent-function 2)


;; (macroexpand '(f-autoload 'autosave '(a-f b-f) (message "1") (message "2"))) ;; (macroexpand '(f-autoload 'autosave '(a-f b-f) (message "1") (message "2")))


Ładowanie…
Anuluj
Zapisz