Change default method for opening files of a certain type



I’m trying to develop a package which uses a disassembler for viewing .class files instead of showing their raw contents in the text editor. It works when I use the right-click option that I added to the menu, but I would like for it to be used when a user left-clicks on a .class file too.

So far I have kind of made it work by adding the following code to the activate function of the package:

$(".tree-view").delegate(".file", "click", function(e){
	var fileName = $('name') ? $('name') : $('').data('name');
	if(atom.config.get("Java-Bytecode-Disassembler.openOnClick") && fileName.endsWith(".class"))
		aThis.disassemble(e, true);

This works but unfortunately the text-editor version gets opened as well. I would like to avoid this, but I can’t figure out how.

PS: also if there is a better way of doing what I’m trying to do, please let me know.

Thanks in advance.


I think that you’re overthinking it. Atom has a built-in method for adding openers for files.


You’re absolutely right. Thank you @DamnedScholar for pointing me in the right direction :thumbsup:.