Skip to content

Commit

Permalink
add more def symbols for code navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
tonini committed Aug 12, 2015
1 parent 486e31d commit 4d735d5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 29 deletions.
11 changes: 4 additions & 7 deletions alchemist-goto.el
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@
(defvar alchemist-goto-callback nil)

(defconst alchemist-goto--symbol-def-extract-regex
"^\\s-*\\(defp?\\|defmacrop?\\|defmodule\\)[ \n\t]+\\([a-z_\?!]+\\)\\(.*\\)\\(do\\|\n\\)?$")
"^\\s-*\\(defp?\\|defmacrop?\\|defmodule\\|defimpl\\)[ \n\t]+\\([a-z_\?!]+\\)\\(.*\\)\\(do\\|\n\\)?$")

(defconst alchemist-goto--symbol-def-regex
"^[[:space:]]*\\(defmodule\\|defmacrop?\\|defp?\\)")
"^[[:space:]]*\\(defmodule\\|defmacrop?\\|defimpl\\|defp?\\)")

;; Faces

Expand Down Expand Up @@ -110,7 +110,7 @@

(defun alchemist-goto--fetch-symbols-from-propertize-list (symbol)
(-remove 'null (-map (lambda (e)
(when (string-match-p (format "^\\s-*\\(defp?\\|defmacrop?\\|defmodule\\)\s+%s\\((.*\\)?$" symbol) e)
(when (string-match-p (format "^\\s-*\\(defp?\\|defmacrop?\\|defimpl\\|defmodule\\)\s+%s\\((.*\\)?$" symbol) e)
e)) alchemist-goto--symbol-list)))

(defun alchemist-goto--goto-symbol (symbol)
Expand All @@ -136,7 +136,7 @@ It will jump to the position of the symbol definition after selection."
(goto-char (if (overlayp position) (overlay-start position) position))))

(defun alchemist-goto--fetch-symbol-definitions ()
(alchemist-goto--search-for-symbols "^\\s-*\\(defp?\\|defmacrop?\\|defmodule\\)\s.*"))
(alchemist-goto--search-for-symbols "^\\s-*\\(defp?\\|defmacrop?\\|defimpl\\|defstruct\\|defmodule\\)\s.*"))

(defun alchemist-goto--extract-symbol (str)
(save-match-data
Expand Down Expand Up @@ -249,9 +249,6 @@ It will jump to the position of the symbol definition after selection."
((alchemist-goto--erlang-file-p file)
(alchemist-goto--jump-to-erlang-source module function)))))

(defun alchemist-gogo--symbol-definition-regex (symbol)
(format "^\s+\\(defp?\s+%s\(?\\|defmacrop?\s+%s\(?\\)" symbol symbol))

(defun alchemist-goto--jump-to-elixir-source (module function)
(cond
(function
Expand Down
22 changes: 0 additions & 22 deletions test/alchemist-goto-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -81,28 +81,6 @@
(should (equal (alchemist-goto--extract-symbol "def __pubsub_server__, do: @pubsub_server")
"def __pubsub_server__")))

(ert-deftest match-functions-inside-buffer ()
(should (string-match-p (alchemist-gogo--symbol-definition-regex "cwd!")
" def cwd! do"))
(should (string-match-p (alchemist-gogo--symbol-definition-regex "delete")
" def delete(list, item) do"))
(should (string-match-p (alchemist-gogo--symbol-definition-regex "do_zip")
" defp do_zip(list, acc) do"))
(should (string-match-p (alchemist-gogo--symbol-definition-regex "keymember?")
" def keymember?(list, key, position) do"))
(should (string-match-p (alchemist-gogo--symbol-definition-regex "has_key?")
" def has_key?(map, key), do: :maps.is_key(key, map)"))
(should (string-match-p (alchemist-gogo--symbol-definition-regex "left")
" defmacro left or right do"))
(should (string-match-p (alchemist-gogo--symbol-definition-regex "defimpl!")
" defmacro defimpl!(name, opts, do_block \\ []) do"))
(should (string-match-p (alchemist-gogo--symbol-definition-regex "parse!")
" defmacro parse! do"))
(should (string-match-p (alchemist-gogo--symbol-definition-regex "has_key?")
" defmacrop has_key? do"))
(should (string-match-p (alchemist-gogo--symbol-definition-regex "read")
" defmacro read(source) do")))

(provide 'alchemist-goto-test)

;;; alchemist-goto-test.el ends here

0 comments on commit 4d735d5

Please sign in to comment.