Created
July 7, 2012 14:35
-
-
Save syohex/3066674 to your computer and use it in GitHub Desktop.
Get Perl module methods from Emacs Lisp
This file contains hidden or 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
ELISP> (pcomp:get-methods "Data::MessagePack") | |
("Data::MessagePack::utf8" "Data::MessagePack::unpack" "Data::MessagePack::true" "Data::MessagePack::prefer_integer" "Data::MessagePack::pack" "Data::MessagePack::new" "Data::MessagePack::get_utf8" "Data::MessagePack::get_prefer_integer" "Data::MessagePack::get_canonical" "Data::MessagePack::false" "Data::MessagePack::encode" "Data::MessagePack::decode" "Data::MessagePack::canonical" "Data::MessagePack::bootstrap" "Data::MessagePack::CLONE") |
This file contains hidden or 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
(defvar pcomp:get-method-oneliner-format | |
(concat "perl -MClass::Inspector -M%s -le " | |
"'print $_ for @{Class::Inspector->methods(\"%s\", \"full\", \"public\")}'")) | |
(defun pcomp:get-method-set-format (module) | |
(format pcomp:get-method-oneliner-format module module)) | |
(defun pcomp:get-methods (module) | |
(with-temp-buffer | |
(let ((cmd (pcomp:get-method-set-format module))) | |
(call-process-shell-command cmd nil t nil)) | |
(goto-char (point-min)) | |
(let ((lst nil)) | |
(while (re-search-forward "^\\(.+\\)$" nil t) | |
(push (buffer-substring-no-properties (match-beginning 1) (match-end 1)) lst)) | |
lst))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment