Skip to content

Commit

Permalink
Make erl-find-includes simpler.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin Osterberg authored and jixiuf committed Sep 20, 2012
1 parent 330cf37 commit 413b392
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions elisp/erlookup.el
Expand Up @@ -54,17 +54,14 @@
(defvar erl-include-pattern "-include\\(_lib(\\|(\\)\""
"Regexp for matching '-include' and '-include_lib' entries in a file.")

(defun erl-find-includes ()
(defun erl-find-includes (buffer)
"Collects included paths from a file and returns them in a list."
(let ((origin (point))
(paths nil)
(searching t))
(goto-char (point-min))
(while searching
(if (re-search-forward erl-include-pattern nil t)
(push (thing-at-point 'filename) paths)
(setq searching nil)))
(goto-char origin)
(let ((paths nil))
(save-excursion
(set-buffer buffer)
(goto-char (point-min))
(while (re-search-forward erl-include-pattern nil t)
(push (thing-at-point 'filename) paths)))
(nreverse paths)))

;; Yes, this is horribly horrible horribleness, but for now I can't
Expand Down Expand Up @@ -149,7 +146,7 @@ symbol."
(ring-insert-at-beginning erl-find-history-ring
(copy-marker (point-marker))))
(let ((origin (point))
(paths (if include-paths include-paths (erl-find-includes)))
(paths (if include-paths include-paths (erl-find-includes (file-name-nondirectory buffer-file-name))))
(extra-paths nil)
(already-open nil)
(already-tried nil)
Expand All @@ -167,7 +164,7 @@ symbol."

(when (get-buffer buffer-name-of-path)
(set-buffer buffer-name-of-path)
(setq extra-paths (remove-duplicates (append (erl-find-includes) extra-paths)))
(setq extra-paths (remove-duplicates (append (erl-find-includes buffer-name-of-path) extra-paths)))
(push buffer-name-of-path already-tried)
(push buffer-name-of-path already-open))

Expand All @@ -192,7 +189,7 @@ symbol."
(when (file-exists-p find-path)
(find-file find-path)
(set-buffer buffer-name-of-path)
(setq extra-paths (append (erl-find-includes) extra-paths))
(setq extra-paths (append (erl-find-includes buffer-name-of-path) extra-paths))
(push buffer-name-of-path already-tried)

(when (setq symbol (erl-find-pattern-in-file pattern arg))
Expand Down

0 comments on commit 413b392

Please sign in to comment.