Skip to content

Commit

Permalink
rewrite
Browse files Browse the repository at this point in the history
        (defun erl-find-module (&optional use-symbol-under-point-as-default-p)
  • Loading branch information
jixiuf committed Sep 20, 2012
1 parent c500dc7 commit 9e5e2d0
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions elisp/erl-service.el
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
;; erlang module, which does most of the work for us.

(require 'erlang)
(require 'thingatpt)
(eval-when-compile (require 'cl))
(require 'erl)

Expand Down Expand Up @@ -784,31 +785,27 @@ default.)"
(when (eq (char-after) ?:)
(forward-sexp)))

(defvar erl-loaded-modules nil
"Scary global variable containing a list of the modules
loaded on the Erlang node. Should only be set from
`erl-loaded-modules'.")

(defun erl-find-module ()
(interactive)
(completing-read "module: " (erl-loaded-modules)))

(defun erl-loaded-modules ()
(interactive)
(erl-loaded-modules-helper)
(mapcar (lambda (S) (symbol-name S)) erl-loaded-modules))

(defun erl-loaded-modules-helper ()
(defun erl-find-module (&optional use-symbol-under-point-as-default-p)
"find the source file of a module,with prefix `C-u'
use symbol under point as default module to find"
(interactive "P")
(let ((module (erlang-get-module))
(node (or erl-nodename-cache (erl-target-node))))
(erl-spawn
(erl-send-rpc node 'distel 'loaded_modules '())
(erl-receive ()
(erl-receive (use-symbol-under-point-as-default-p)
((['rex ['ok modules]]
(setq erl-loaded-modules modules))
(erl-find-function (completing-read "module: "
(mapcar (lambda (S) (symbol-name S)) modules)
nil nil
(if use-symbol-under-point-as-default-p (thing-at-point 'symbol) "")
))
)
(['rex ['error reason]]
(ring-remove erl-find-history-ring)
(message "Error: %s" reason)))))))
(message "Error: %s" reason))))))
)


(defun erl-find-function (module &optional function arity)
"Find the source code for MODULE in a buffer, loading it if necessary.
Expand Down Expand Up @@ -1335,4 +1332,9 @@ The match positions are erl-mfa-regexp-{module,function,arity}-match.")
(prog1 (progn (insert ,@body))
(add-text-properties ,start (point) ,props)))))

;; Local Variables:
;; coding: utf-8
;; indent-tabs-mode: nil
;; End:

(provide 'erl-service)

0 comments on commit 9e5e2d0

Please sign in to comment.