Skip to content
This repository
Browse code

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

… or number and add better search support
  • Loading branch information...
commit e2dadc147009ee08756fede23dd97b2b31c2e4be 1 parent 60966f3
Roberto Ostinelli authored
4 CHANGELOG.md
Source Rendered
... ... @@ -1,5 +1,9 @@
1 1 # SublimErl Changelog
2 2
  3 +### 0.5:
  4 + * added function search
  5 + * added error panel when compilation errors are encountered
  6 +
3 7 ### 0.4:
4 8 * added auto-indenting
5 9 * major code refactoring
2  README.md
Source Rendered
@@ -10,6 +10,7 @@ SublimErl is a plugin for the text editor [Sublime Text 2](http://www.sublimetex
10 10 * Run **Eunit** tests ( all tests for module / single test )
11 11 * Run **Common Tests** ( all tests for module / single test )
12 12 * Run **Dialyzer** tests ( single module )
  13 +* Goto any function of your project easily
13 14
14 15 All within your test editor.
15 16
@@ -38,6 +39,7 @@ Usage
38 39 * Run **Dialyzer** on file: view the file and hit `Command-Shift-F9`
39 40 * Re-Run the **previous test**: hit `Command-F8` ( you do not need to be viewing the test to launch it )
40 41 * View **Common Tests results** in browser: hit `Command-Option-F8` (OSX) | `Command-Alt-F8` (Linux/Win)
  42 +* Goto any function of your project easily: git `Command-Option-P` (OSX) | `Command-Alt-P` (Linux/Win) and select a function
41 43
42 44 A brief introduction video can be seen [here](http://www.youtube.com/watch?v=T0rD0CQM4Yg):
43 45
4 bindings/Default (Linux).sublime-keymap
@@ -3,6 +3,6 @@
3 3 { "keys": ["ctrl+shift+f9"], "command": "sublim_erl_dialyzer", "context": [{ "key": "selector", "operator": "equal", "operand": "source.erlang" }] },
4 4 { "keys": ["ctrl+f8"], "command": "sublim_erl_redo" },
5 5 { "keys": ["ctrl+alt+f8"], "command": "sublim_erl_ct_results" },
6   - { "keys": ["ctrl+alt+l"], "command": "sublim_erl_auto_format" },
7   - { "keys": ["ctrl+alt+p"], "command": "sublim_erl_function_search" }
  6 + { "keys": ["ctrl+alt+l"], "command": "sublim_erl_auto_format", "context": [{ "key": "selector", "operator": "equal", "operand": "source.erlang" }] },
  7 + { "keys": ["ctrl+alt+p"], "command": "sublim_erl_function_search", "context": [{ "key": "selector", "operator": "equal", "operand": "source.erlang" }] }
8 8 ]
4 bindings/Default (OSX).sublime-keymap
@@ -3,6 +3,6 @@
3 3 { "keys": ["super+shift+f9"], "command": "sublim_erl_dialyzer", "context": [{ "key": "selector", "operator": "equal", "operand": "source.erlang" }] },
4 4 { "keys": ["super+f8"], "command": "sublim_erl_redo" },
5 5 { "keys": ["super+alt+f8"], "command": "sublim_erl_ct_results" },
6   - { "keys": ["super+alt+l"], "command": "sublim_erl_auto_format" },
7   - { "keys": ["super+alt+p"], "command": "sublim_erl_function_search" }
  6 + { "keys": ["super+alt+l"], "command": "sublim_erl_auto_format", "context": [{ "key": "selector", "operator": "equal", "operand": "source.erlang" }] },
  7 + { "keys": ["super+alt+p"], "command": "sublim_erl_function_search", "context": [{ "key": "selector", "operator": "equal", "operand": "source.erlang" }] }
8 8 ]
6,120 completion/Erlang-Libs.disasm
3,060 additions, 3,060 deletions not shown
5 sublimerl_completion.py
@@ -155,8 +155,9 @@ def run(self):
155 155 # different erlang libs -> regenerate
156 156 this.status("Regenerating Erlang lib completions...")
157 157 # set cwd
158   - os.chdir(SUBLIMERL.completions_path)
  158 + os.chdir(SUBLIMERL.support_path)
159 159 # start gen
  160 + print "python sublimerl_libparser.py %s %s" % (this.shellquote(SUBLIMERL.erlang_libs_path), this.shellquote(dest_file_base))
160 161 this.execute_os_command("python sublimerl_libparser.py %s %s" % (this.shellquote(SUBLIMERL.erlang_libs_path), this.shellquote(dest_file_base)))
161 162 # rename file to .full
162 163 os.rename("%s.sublime-completions" % dest_file_base, "%s.sublime-completions.full" % dest_file_base)
@@ -188,7 +189,7 @@ def run(self):
188 189 # get dir
189 190 dest_file_base = os.path.join(SUBLIMERL.completions_path, "Current-Project")
190 191 # set cwd
191   - os.chdir(SUBLIMERL.completions_path)
  192 + os.chdir(SUBLIMERL.support_path)
192 193 # start gen
193 194 this.execute_os_command("python sublimerl_libparser.py %s %s" % (this.shellquote(this.project_root), this.shellquote(dest_file_base)))
194 195 # release lock
3  sublimerl_core.py
@@ -26,6 +26,9 @@
26 26 # POSSIBILITY OF SUCH DAMAGE.
27 27 # ==========================================================================================================
28 28
  29 +# globals
  30 +SUBLIMERL_VERSION = '0.5'
  31 +
29 32 # imports
30 33 import sublime, sublime_plugin
31 34 import os, subprocess, re
16 sublimerl_tests_integration.py
@@ -26,13 +26,11 @@
26 26 # POSSIBILITY OF SUCH DAMAGE.
27 27 # ==========================================================================================================
28 28
29   -# globals
30   -SUBLIMERL_VERSION = '0.4.1-dev'
31 29
32 30 # imports
33 31 import sublime
34 32 import os, subprocess, re, threading, webbrowser
35   -from sublimerl_core import SUBLIMERL, SublimErlTextCommand, SublimErlProjectLoader
  33 +from sublimerl_core import SUBLIMERL_VERSION, SUBLIMERL, SublimErlTextCommand, SublimErlProjectLoader
36 34
37 35
38 36 # test runner
@@ -227,13 +225,13 @@ def get_test_function_name(self):
227 225 cursor_position = self.view.sel()[0].a
228 226
229 227 # find all regions with a test function definition
230   - function_regions = self.view.find_all(r"(%.*)?([a-zA-Z0-9_]*_test(_)?\s*\(\s*\)\s*->[^.]*\.)")
  228 + function_regions = self.view.find_all(r"(%.*)?([a-z0-9][a-zA-Z0-9_]*_test(_)?\s*\(\s*\)\s*->[^.]*\.)")
231 229
232 230 # loop regions
233 231 matching_region = None
234 232 for region in function_regions:
235 233 region_content = self.view.substr(region)
236   - if not re.match(r"%.*((?:[a-zA-Z0-9_]*)_test(_)?)\s*\(\s*\)\s*->", region_content):
  234 + if not re.match(r"%.*((?:[a-z0-9][a-zA-Z0-9_]*)_test(_)?)\s*\(\s*\)\s*->", region_content):
237 235 # function is not commented out, is cursor included in region?
238 236 if region.a <= cursor_position and cursor_position <= region.b:
239 237 matching_region = region
@@ -242,7 +240,7 @@ def get_test_function_name(self):
242 240 # get function name
243 241 if matching_region != None:
244 242 # get function name and arguments
245   - m = re.match(r"((?:[a-zA-Z0-9_]*)_test(_)?)\s*\(\s*\)\s*->(?:.|\n)", self.view.substr(matching_region))
  243 + m = re.match(r"((?:[a-z0-9][a-zA-Z0-9_]*)_test(_)?)\s*\(\s*\)\s*->(?:.|\n)", self.view.substr(matching_region))
246 244 if m != None:
247 245 return m.group(1)
248 246
@@ -330,13 +328,13 @@ def get_test_function_name(self):
330 328 cursor_position = self.view.sel()[0].a
331 329
332 330 # find all regions with a test function definition
333   - function_regions = self.view.find_all(r"(%.*)?([a-zA-Z0-9_]*\s*\([\w\s_]+\)\s*->[^.]*\.)")
  331 + function_regions = self.view.find_all(r"(%.*)?([a-z0-9][a-zA-Z0-9_]*\s*\([\w\s_]+\)\s*->[^.]*\.)")
334 332
335 333 # loop regions
336 334 matching_region = None
337 335 for region in function_regions:
338 336 region_content = self.view.substr(region)
339   - if not re.match(r"%.*((?:[a-zA-Z0-9_]*))\s*\([\w\s_]+\)\s*->", region_content):
  337 + if not re.match(r"%.*((?:[a-z0-9][a-zA-Z0-9_]*))\s*\([\w\s_]+\)\s*->", region_content):
340 338 # function is not commented out, is cursor included in region?
341 339 if region.a <= cursor_position and cursor_position <= region.b:
342 340 matching_region = region
@@ -345,7 +343,7 @@ def get_test_function_name(self):
345 343 # get function name
346 344 if matching_region != None:
347 345 # get function name and arguments
348   - m = re.match(r"((?:[a-zA-Z0-9_]*))\s*\([\w\s_]+\)\s*->(?:.|\n)", self.view.substr(matching_region))
  346 + m = re.match(r"((?:[a-z0-9][a-zA-Z0-9_]*))\s*\([\w\s_]+\)\s*->(?:.|\n)", self.view.substr(matching_region))
349 347 if m != None:
350 348 return m.group(1)
351 349
0  completion/sublimerl_libparser.py → support/sublimerl_libparser.py
File renamed without changes

0 comments on commit e2dadc1

Please sign in to comment.
Something went wrong with that request. Please try again.