Skip to content

Instantly share code, notes, and snippets.

@bowbow99
Created August 23, 2011 10:44
Show Gist options
  • Save bowbow99/1164828 to your computer and use it in GitHub Desktop.
Save bowbow99/1164828 to your computer and use it in GitHub Desktop.
autoload 指定されたシンボルを調べる #xyzzy
(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)))
;;; 使ってみる
;; 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