Created
August 23, 2011 10:44
-
-
Save bowbow99/1164828 to your computer and use it in GitHub Desktop.
autoload 指定されたシンボルを調べる #xyzzy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun autoload-symbol-p (symbol) | |
(and (symbolp symbol) | |
(fboundp symbol) | |
(autoload-function-p symbol))) | |
(defun autoload-module (symbol) | |
(unless (autoload-symbol-p symbol) | |
(error "autoload 指定されたシンボルじゃないです: ~S" symbol)) | |
(let* ((def (or (macro-function symbol) | |
(si:closure-body (symbol-function symbol)))) | |
(hint (if (eql (car (third def)) 'ed:interactive) | |
(fourth def) | |
(third def)))) | |
(third (third hint)))) | |
(defun autoload-macro-p (symbol) | |
(and (autoload-symbol-p symbol) | |
(macro-function symbol))) | |
(defun autoload-command-p (symbol) | |
(and (autoload-symbol-p symbol) | |
(commandp symbol))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; 使ってみる | |
;; function | |
(autoload 'foo "foo") | |
=> foo | |
(autoload-module 'foo) | |
=> "foo" | |
(autoload-function-p 'foo) | |
=> t | |
(autoload-command-p 'foo) | |
=> nil | |
(autoload-macro-p 'foo) | |
=> nil | |
;; command | |
(autoload 'bar "bar" t) | |
=> bar | |
(autoload-module 'bar) | |
=> "bar" | |
(autoload-function-p 'bar) | |
=> t | |
(autoload-command-p 'bar) | |
=> t | |
(autoload-macro-p 'bar) | |
=> nil | |
;; macro | |
(autoload 'baz "baz" nil t) | |
=> baz | |
(autoload-module 'baz) | |
=> "baz" | |
(autoload-function-p 'baz) | |
=> t | |
(autoload-command-p 'baz) | |
=> nil | |
(autoload-macro-p 'baz) | |
=> (macro (&rest lisp::args) (block baz (lisp::load-and-go 'baz "baz" nil t lisp::args))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment