I already created a tmlanguage to highlight stuff, and the API looks yummy so now I'd like to do My Very First Plugin® to scratch some additional itches. For a first version, requirements are short: when <Modifier>+clicking (e.g. ctrl-shift-clicking) a command in MenuData.csv I want to jump to its definition in CommandData.csv. Just like Find Results jumps to the containing file@line/column when clicking a line.

Bindings should be easy with the definition of a button/press_command/press_args. If I stumble on problems with overriding the crowded <Modifier>+click space, I'll fallback to a keyboard shortcut, and will find the word at the current point with word(point). If the notion of "word" leads to problems with the pipe (|) character, I will just require the user to select the command before hitting the shortcut. So now I have my CommandName.

I want now to find the ^CommandName regex in CommandData.csv. Problem: if I understand correctly, find(pattern, fromPosition, <flags>) only searches the current buffer, right? Is there a way to do something like find(buffer, pattern, fromPosition, <flags>)? Or I could first openFile(CommandData.xls, <row>, <col>), but that would be ugly: I don't want to switch to CommandData.xls without even knowing the search results will be not null! How can I work around that?

If there is no match, fire a statusMessage(string) / errorMessage(string)If there is a matching Region, show(region, <showSurrounds>)

Questions:

What do you think?

In particular, any idea to solve point 2?

Other recommendations?

Does my needs look like something an existing plugins already does and where I could grab some clues?

Thanks for your help!

PS for those wondering (but given the audience here I'm sure I'll be understood): yes I'm editing CSV in a text editor with no "Column" notion, because Excel/LibreOffice messes with my data (commas, leading zeroes, etc.), CSVEd is unstable, and CSVEasy is neat but not very powerful. And SublimeText has lots to offer

Regarding point #2: find(...) is a method of the view object (what you are calling a buffer). If you want to do a search through another open view, you can access it from the window object. Perhaps something like iterating through self.view.window().views() and finding the view with the file_name() you want (CommandData.csv).

If you want to support the ability to examine the file without opening it, just use regular Python open() to open the file and search through it using python's re module or whatever is convenient. You can then call window.open_file() if you have a successful match, otherwise display your error.

sapphirehamster wrote:Regarding point #2: find(...) is a method of the view object (what you are calling a buffer). If you want to do a search through another open view, you can access it from the window object. Perhaps something like iterating through self.view.window().views() and finding the view with the file_name() you want (CommandData.csv).

If you want to support the ability to examine the file without opening it, just use regular Python open() to open the file and search through it using python's re module or whatever is convenient. You can then call window.open_file() if you have a successful match, otherwise display your error.