Search code examples
atom-editorfactor-lang

Using Atom as default editor for Factor listener


I'd like to use Atom as my default editor for the Factor listener, so that typing \ foo edit will open the definition of foo in Atom. But when I try it, I get this instead:

Launching failed with error:
Win32 error 0x2: The system cannot find the file specified.
Launch descriptor:

T{ process
    { command
        {
            "atom"
            "C:\\path\\to\\factor_directory\\Factor/work/file_directory/filename.factor:1"
        }
    }
    { detached t }
    { environment H{ } }
    { environment-mode +append-environment+ }
    { group +same-group+ }
}

But if I cd into directory and execute atom filename.factor from powershell (I'm on Windows 8.1), it works fine, which suggests there is something wrong with the command generated by Factor. So I opened C:\path\to\factor_directory\Factor\basis\editors\atom and found

! Copyright (C) 2014 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: editors kernel make math.parser namespaces sequences ;
IN: editors.atom

SINGLETON: atom-editor
atom-editor \ editor-class set-global

SYMBOL: atom-path

M: atom-editor editor-command ( file line -- command )
    [
        atom-path get "atom" or ,
        number>string ":" glue ,
    ] { } make ;

I have the vaguest idea about how this works. I guess I should change the definition of editor-command in some way, but I'm not sure what's wrong with it.

Any ideas?


Solution

  • The atom executable probably isn't in your path. If you look at the following line:

    atom-path get "atom" or ,
    

    The or word takes 2 items from the stack, and if one of them is true, it will output the first of which, otherwise, f (false) is returned (if you are using the GUI listener, you can actually look up documentation for a specific word in the Help Browser interactively by clicking on the word itself! So you can click on or and read the documentation to figure out how it works).

    Looking at the error message, "atom" is being returned, so we can deduce that

    atom-path get
    

    Must have returned f (false). So what you need to do is to set the editor's executable path to atom-path before executing the edit word:

    "C:/path/to/atom.exe" \ atom-path set-global
    

    Now I'm not certain if the path delimiter I used would work as-is in Windows, but you get the idea.