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:
- Code: Select all
- Reference the Commands in MenuData.csv (siblings are pipe-separated). Header and first line of MenuData.csv would look like:
- Code: Select all
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 <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>)
- 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?
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