I'm working on enterpriseware for which we define and package some customizations through CSV files, later on deployed by the customer. For example, to create a Menu containing two Commands, I would:
- Create two lines in CommandData.csv
, containing (among other stuff) their names. Header and first lines of CommandData.csv would look like:
- Reference the Commands in MenuData.csv
(siblings are pipe-separated). Header and first line of MenuData.csv would look like:
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 +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.
After a look at the API Reference, I'd go this way:
- Bindings should be easy with the definition of a button/press_command/press_args
. If I stumble on problems with overriding the crowded +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, ) only searches the current buffer, right? Is there a way to do something like find(buffer, pattern, fromPosition, )? Or I could first openFile(CommandData.xls, , ), 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, )
What do you think?
In particular, any idea to solve point 2?
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