Skip to content

Instantly share code, notes, and snippets.

@syohex
Created July 7, 2012 14:35
Show Gist options
  • Save syohex/3066674 to your computer and use it in GitHub Desktop.
Save syohex/3066674 to your computer and use it in GitHub Desktop.
Get Perl module methods from Emacs Lisp
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")
(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