jlebon / textern

A Firefox add-on for editing text in your favourite external editor!
GNU General Public License v3.0
138 stars 21 forks source link

Dynamic file extension for temporary files #26

Open jbuttery opened 6 years ago

jbuttery commented 6 years ago

It would be nice to be able to specify the file extension of Textern's temporary file on the fly (i.e. per editing session). This is so that editors that do auto-configuration based on file extension (for example, syntax highlighting) can do their thing.

The most obvious (well, to me anyway) way to do this is to have a context menu like "It's All Text!", where you can manually pick from a list of file extensions. This would require having a context menu, though, which may or may not be trivial to implement (I've never made an add-on).

Another way to do it would be to have a configuration file where you could pick a file extension automatically based on a regex match of the page URI, HTML element name, CSS id/class, etc. That'd be a pretty cool way to have the hotkey "do the right thing" out of the box in a lot of cases.

Personally, I'd rather have both (but of course I would, users always ask for everything :P) where the hotkey launches with the default and/or pattern-matched file extension, and choosing from the menu explicitly uses that one, overriding the other logic.

jlebon commented 6 years ago

Not too keen on adding a context menu, seeing as a big part of the idea is avoiding the mouse in the first place :). The filename is already named based on the URL of the page, right? Adding some DOM-related naming schemes to make it more specific is doable.