Browse files

ensure regex look for function names starting with a lowercase letter…

… or number and add better search support
  • Loading branch information...
1 parent 60966f3 commit e2dadc147009ee08756fede23dd97b2b31c2e4be @ostinelli committed Oct 12, 2012
View
4 CHANGELOG.md
@@ -1,5 +1,9 @@
# SublimErl Changelog
+### 0.5:
+ * added function search
+ * added error panel when compilation errors are encountered
+
### 0.4:
* added auto-indenting
* major code refactoring
View
2 README.md
@@ -10,6 +10,7 @@ SublimErl is a plugin for the text editor [Sublime Text 2](http://www.sublimetex
* Run **Eunit** tests ( all tests for module / single test )
* Run **Common Tests** ( all tests for module / single test )
* Run **Dialyzer** tests ( single module )
+* Goto any function of your project easily
All within your test editor.
@@ -38,6 +39,7 @@ Usage
* Run **Dialyzer** on file: view the file and hit `Command-Shift-F9`
* Re-Run the **previous test**: hit `Command-F8` ( you do not need to be viewing the test to launch it )
* View **Common Tests results** in browser: hit `Command-Option-F8` (OSX) | `Command-Alt-F8` (Linux/Win)
+* Goto any function of your project easily: git `Command-Option-P` (OSX) | `Command-Alt-P` (Linux/Win) and select a function
A brief introduction video can be seen [here](http://www.youtube.com/watch?v=T0rD0CQM4Yg):
View
4 bindings/Default (Linux).sublime-keymap
@@ -3,6 +3,6 @@
{ "keys": ["ctrl+shift+f9"], "command": "sublim_erl_dialyzer", "context": [{ "key": "selector", "operator": "equal", "operand": "source.erlang" }] },
{ "keys": ["ctrl+f8"], "command": "sublim_erl_redo" },
{ "keys": ["ctrl+alt+f8"], "command": "sublim_erl_ct_results" },
- { "keys": ["ctrl+alt+l"], "command": "sublim_erl_auto_format" },
- { "keys": ["ctrl+alt+p"], "command": "sublim_erl_function_search" }
+ { "keys": ["ctrl+alt+l"], "command": "sublim_erl_auto_format", "context": [{ "key": "selector", "operator": "equal", "operand": "source.erlang" }] },
+ { "keys": ["ctrl+alt+p"], "command": "sublim_erl_function_search", "context": [{ "key": "selector", "operator": "equal", "operand": "source.erlang" }] }
]
View
4 bindings/Default (OSX).sublime-keymap
@@ -3,6 +3,6 @@
{ "keys": ["super+shift+f9"], "command": "sublim_erl_dialyzer", "context": [{ "key": "selector", "operator": "equal", "operand": "source.erlang" }] },
{ "keys": ["super+f8"], "command": "sublim_erl_redo" },
{ "keys": ["super+alt+f8"], "command": "sublim_erl_ct_results" },
- { "keys": ["super+alt+l"], "command": "sublim_erl_auto_format" },
- { "keys": ["super+alt+p"], "command": "sublim_erl_function_search" }
+ { "keys": ["super+alt+l"], "command": "sublim_erl_auto_format", "context": [{ "key": "selector", "operator": "equal", "operand": "source.erlang" }] },
+ { "keys": ["super+alt+p"], "command": "sublim_erl_function_search", "context": [{ "key": "selector", "operator": "equal", "operand": "source.erlang" }] }
]
View
6,120 completion/Erlang-Libs.disasm
3,060 additions, 3,060 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
5 sublimerl_completion.py
@@ -155,8 +155,9 @@ def run(self):
# different erlang libs -> regenerate
this.status("Regenerating Erlang lib completions...")
# set cwd
- os.chdir(SUBLIMERL.completions_path)
+ os.chdir(SUBLIMERL.support_path)
# start gen
+ print "python sublimerl_libparser.py %s %s" % (this.shellquote(SUBLIMERL.erlang_libs_path), this.shellquote(dest_file_base))
this.execute_os_command("python sublimerl_libparser.py %s %s" % (this.shellquote(SUBLIMERL.erlang_libs_path), this.shellquote(dest_file_base)))
# rename file to .full
os.rename("%s.sublime-completions" % dest_file_base, "%s.sublime-completions.full" % dest_file_base)
@@ -188,7 +189,7 @@ def run(self):
# get dir
dest_file_base = os.path.join(SUBLIMERL.completions_path, "Current-Project")
# set cwd
- os.chdir(SUBLIMERL.completions_path)
+ os.chdir(SUBLIMERL.support_path)
# start gen
this.execute_os_command("python sublimerl_libparser.py %s %s" % (this.shellquote(this.project_root), this.shellquote(dest_file_base)))
# release lock
View
3 sublimerl_core.py
@@ -26,6 +26,9 @@
# POSSIBILITY OF SUCH DAMAGE.
# ==========================================================================================================
+# globals
+SUBLIMERL_VERSION = '0.5'
+
# imports
import sublime, sublime_plugin
import os, subprocess, re
View
16 sublimerl_tests_integration.py
@@ -26,13 +26,11 @@
# POSSIBILITY OF SUCH DAMAGE.
# ==========================================================================================================
-# globals
-SUBLIMERL_VERSION = '0.4.1-dev'
# imports
import sublime
import os, subprocess, re, threading, webbrowser
-from sublimerl_core import SUBLIMERL, SublimErlTextCommand, SublimErlProjectLoader
+from sublimerl_core import SUBLIMERL_VERSION, SUBLIMERL, SublimErlTextCommand, SublimErlProjectLoader
# test runner
@@ -227,13 +225,13 @@ def get_test_function_name(self):
cursor_position = self.view.sel()[0].a
# find all regions with a test function definition
- function_regions = self.view.find_all(r"(%.*)?([a-zA-Z0-9_]*_test(_)?\s*\(\s*\)\s*->[^.]*\.)")
+ function_regions = self.view.find_all(r"(%.*)?([a-z0-9][a-zA-Z0-9_]*_test(_)?\s*\(\s*\)\s*->[^.]*\.)")
# loop regions
matching_region = None
for region in function_regions:
region_content = self.view.substr(region)
- if not re.match(r"%.*((?:[a-zA-Z0-9_]*)_test(_)?)\s*\(\s*\)\s*->", region_content):
+ if not re.match(r"%.*((?:[a-z0-9][a-zA-Z0-9_]*)_test(_)?)\s*\(\s*\)\s*->", region_content):
# function is not commented out, is cursor included in region?
if region.a <= cursor_position and cursor_position <= region.b:
matching_region = region
@@ -242,7 +240,7 @@ def get_test_function_name(self):
# get function name
if matching_region != None:
# get function name and arguments
- m = re.match(r"((?:[a-zA-Z0-9_]*)_test(_)?)\s*\(\s*\)\s*->(?:.|\n)", self.view.substr(matching_region))
+ m = re.match(r"((?:[a-z0-9][a-zA-Z0-9_]*)_test(_)?)\s*\(\s*\)\s*->(?:.|\n)", self.view.substr(matching_region))
if m != None:
return m.group(1)
@@ -330,13 +328,13 @@ def get_test_function_name(self):
cursor_position = self.view.sel()[0].a
# find all regions with a test function definition
- function_regions = self.view.find_all(r"(%.*)?([a-zA-Z0-9_]*\s*\([\w\s_]+\)\s*->[^.]*\.)")
+ function_regions = self.view.find_all(r"(%.*)?([a-z0-9][a-zA-Z0-9_]*\s*\([\w\s_]+\)\s*->[^.]*\.)")
# loop regions
matching_region = None
for region in function_regions:
region_content = self.view.substr(region)
- if not re.match(r"%.*((?:[a-zA-Z0-9_]*))\s*\([\w\s_]+\)\s*->", region_content):
+ if not re.match(r"%.*((?:[a-z0-9][a-zA-Z0-9_]*))\s*\([\w\s_]+\)\s*->", region_content):
# function is not commented out, is cursor included in region?
if region.a <= cursor_position and cursor_position <= region.b:
matching_region = region
@@ -345,7 +343,7 @@ def get_test_function_name(self):
# get function name
if matching_region != None:
# get function name and arguments
- m = re.match(r"((?:[a-zA-Z0-9_]*))\s*\([\w\s_]+\)\s*->(?:.|\n)", self.view.substr(matching_region))
+ m = re.match(r"((?:[a-z0-9][a-zA-Z0-9_]*))\s*\([\w\s_]+\)\s*->(?:.|\n)", self.view.substr(matching_region))
if m != None:
return m.group(1)
View
0 completion/sublimerl_libparser.py → support/sublimerl_libparser.py
File renamed without changes.

0 comments on commit e2dadc1

Please sign in to comment.