]> gitweb.factorcode.org Git - factor.git/blob - basis/editors/acme/acme.factor
editors: allow them to be loaded in the load-all image
[factor.git] / basis / editors / acme / acme.factor
1 ! Copyright (C) 2020 Fred Alger
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: arrays editors environment io.files.info io.pathnames
4 kernel make math.parser namespaces sequences ;
5 IN: editors.acme
6
7 SINGLETON: acme
8
9 editor-class [ acme ] initialize
10
11 : plan9-path ( -- path )
12   \ plan9-path get [
13     "PLAN9" os-env [
14       "/usr/local/plan9"
15     ] unless*
16   ] unless* ;
17
18 : plan9-tool-path ( tool -- path )
19   [ plan9-path "/bin" append ] dip append-path ;
20
21 <PRIVATE
22
23 : (plumb-path) ( -- path )
24   "plumb" plan9-tool-path ;
25
26 : (massage-pathname) ( file line -- str )
27  over file-info regular-file?
28  [ number>string 2array ":" join ]
29  [ drop ] if ;
30
31 PRIVATE>
32
33 M: acme editor-command ( file line -- command )
34  [ (plumb-path) , "-d" , "edit" , (massage-pathname) , ] { } make ;