Skip to content

Instantly share code, notes, and snippets.

@cvmat
Last active October 9, 2015 13:18
Show Gist options
  • Save cvmat/3513287 to your computer and use it in GitHub Desktop.
Save cvmat/3513287 to your computer and use it in GitHub Desktop.
Function version of `eval-after-autoload-if-found'
;;
;; function version of `eval-after-autoload-if-found'
;;
;; Example with after-body.
;; (eval-after-autoload-if-found
;; '(cycle-buffer cycle-buffer-backward) "cycle-buffer" nil t nil
;; '((setq cycle-buffer-allow-visible t)
;; (setq cycle-buffer-show-length 12)
;; (setq cycle-buffer-show-format '(" <(%s)>" . " %s"))))
;; Example without after-body.
;; (eval-after-autoload-if-found
;; '(smooth-scrolling) "smooth-scrolling" nil t)
;;
(defun eval-after-autoload-if-found (functions file &optional docstring interactive type after-body)
"Set up autoload and eval-after-load for FUNCTIONS iff. FILE has found."
(when (locate-library file)
(mapc (lambda (func)
(autoload func file docstring interactive type))
(if (listp functions)
functions
(list functions)))
(when after-body
(eval-after-load file `(progn ,@after-body)))
t))
@takaxp
Copy link

takaxp commented Jan 12, 2013

L19 の functions があると,

Wrong number of arguments: mapc, 3

と表示されて動かないようです.消すと動きますけどもどうでしょう.

@cvmat
Copy link
Author

cvmat commented Aug 7, 2013

ありがとうございます。
(if (listp functions)以下を追加したときに消し忘れてたみたいです。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment