]> gitweb.factorcode.org Git - factor.git/blob - basis/editors/emacs/emacs.factor
editors.emacs: pass alternative-editor param in case emacs isn't running
[factor.git] / basis / editors / emacs / emacs.factor
1 USING: combinators.short-circuit editors io.standard-paths
2 kernel make math.parser namespaces sequences system ;
3 IN: editors.emacs
4
5 SINGLETON: emacsclient
6 emacsclient editor-class set-global
7
8 SYMBOL: emacsclient-path
9
10 HOOK: find-emacsclient os ( -- path )
11
12 M: object find-emacsclient ( -- path )
13     "emacsclient" ?find-in-path ;
14
15 M: windows find-emacsclient
16     {
17         [ { "Emacs" } "emacsclientw.exe" find-in-applications ]
18         [ { "Emacs" } "emacsclient.exe" find-in-applications ]
19         [ "emacsclient.exe" ]
20     } 0|| ;
21
22 M: emacsclient editor-command ( file line -- command )
23     [
24         emacsclient-path get [ find-emacsclient ] unless* ,
25         "-a=emacs" ,
26         "--no-wait" ,
27         number>string "+" prepend ,
28         ,
29     ] { } make ;