]> gitweb.factorcode.org Git - factor.git/commitdiff
Add support for plan9port acme editor
authorFred Alger <fred@fredalger.net>
Wed, 14 Oct 2020 05:45:34 +0000 (01:45 -0400)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 14 Oct 2020 14:52:00 +0000 (14:52 +0000)
basis/editors/acme/acme-docs.factor [new file with mode: 0644]
basis/editors/acme/acme-tests.factor [new file with mode: 0644]
basis/editors/acme/acme.factor [new file with mode: 0644]
basis/editors/acme/authors.txt [new file with mode: 0644]
basis/editors/acme/tags.txt [new file with mode: 0644]

diff --git a/basis/editors/acme/acme-docs.factor b/basis/editors/acme/acme-docs.factor
new file mode 100644 (file)
index 0000000..21f580a
--- /dev/null
@@ -0,0 +1,29 @@
+! Copyright (C) 2020 Fred Alger.
+! See http://factorcode.org/license.txt for BSD license.
+USING: editors.acme help.markup help.syntax ;
+IN: editors.acme
+
+ABOUT: "editors.acme"
+
+ARTICLE: "editors.acme" "Plan9 acme editor support"
+"This editor invokes the Plan9 `plumb` command. "
+"With the default Plan 9 plumbing, this will open acme."
+$nl
+"The path to the Plan9 installation is determined by "
+{ $link plan9-path }
+{ $see-also "editor" } ;
+
+HELP: plan9-path
+$description
+"Find the local installation of Plan9 from user space."
+"The " { $link plan9-path } " word will try to locate your Plan9"
+" installation. In order of preference this word checks:"
+$nl
+{
+ $list
+ { "The " { $link plan9-path } " global" }
+ "The PLAN9 environment variable"
+}
+$nl
+"Finally, if neither is available, falls back to "
+"/usr/local/plan9, the default installation path." ;
\ No newline at end of file
diff --git a/basis/editors/acme/acme-tests.factor b/basis/editors/acme/acme-tests.factor
new file mode 100644 (file)
index 0000000..2b9eed5
--- /dev/null
@@ -0,0 +1,12 @@
+! Copyright (C) 2020 Fred Alger.
+! See http://factorcode.org/license.txt for BSD license.
+USING: editors.acme environment namespaces tools.test ;
+IN: editors.acme.tests
+
+{ "/plan9" } [ "/plan9" \ plan9-path [ plan9-path ] with-variable ] unit-test
+
+{ "/plan9env" } [ f \ plan9-path [
+ "/plan9env" "PLAN9" [ plan9-path ] with-os-env ] with-variable ] unit-test
+
+{ "/usr/local/plan9" } [ f \ plan9-path [
+ f "PLAN9" [ plan9-path ] with-os-env ] with-variable ] unit-test
\ No newline at end of file
diff --git a/basis/editors/acme/acme.factor b/basis/editors/acme/acme.factor
new file mode 100644 (file)
index 0000000..ea476f6
--- /dev/null
@@ -0,0 +1,33 @@
+! Copyright (C) 2020 Fred Alger
+! See http://factorcode.org/license.txt for BSD license.
+USING: arrays editors environment io.files.info io.pathnames
+kernel make math.parser namespaces sequences ;
+IN: editors.acme
+
+SINGLETON: acme
+acme editor-class set-global
+
+: plan9-path ( -- path )
+  \ plan9-path get [
+    "PLAN9" os-env [
+      "/usr/local/plan9"
+    ] unless*
+  ] unless* ;
+
+: plan9-tool-path ( tool -- path )
+  [ plan9-path "/bin" append ] dip append-path ;
+
+<PRIVATE
+
+: (plumb-path) ( -- path )
+  "plumb" plan9-tool-path ;
+
+: (massage-pathname) ( file line -- str )
+ over file-info regular-file?
+ [ number>string 2array ":" join ]
+ [ drop ] if ;
+
+PRIVATE>
+
+M: acme editor-command ( file line -- command )
+ [ (plumb-path) , "-d" , "edit" , (massage-pathname) , ] { } make ;
diff --git a/basis/editors/acme/authors.txt b/basis/editors/acme/authors.txt
new file mode 100644 (file)
index 0000000..123ff3f
--- /dev/null
@@ -0,0 +1 @@
+Fred Alger
diff --git a/basis/editors/acme/tags.txt b/basis/editors/acme/tags.txt
new file mode 100644 (file)
index 0000000..ebb74b4
--- /dev/null
@@ -0,0 +1 @@
+not loaded