edit fixes, new :edit word
parent
aa8fe942ee
commit
e4ae52028f
|
@ -26,7 +26,7 @@ namespaces parser prettyprint sequences strings words shells ;
|
|||
write
|
||||
] with-stream ;
|
||||
|
||||
: jedit-line/file ( file line -- )
|
||||
: jedit-location ( file line -- )
|
||||
number>string "+line:" swap append 2array
|
||||
make-jedit-request send-jedit-request ;
|
||||
|
||||
|
@ -34,6 +34,6 @@ namespaces parser prettyprint sequences strings words shells ;
|
|||
1array make-jedit-request send-jedit-request ;
|
||||
|
||||
: jedit ( defspec -- )
|
||||
where first2 >r ?resource-path r> jedit-line/file ;
|
||||
where first2 jedit-location ;
|
||||
|
||||
[ jedit ] edit-hook set-global
|
||||
[ jedit-location ] edit-hook set-global
|
||||
|
|
|
@ -1 +1 @@
|
|||
PROVIDES: "jedit" { "jedit.factor" "jedit.facts" } { } ;
|
||||
PROVIDE: jedit { "jedit.factor" "jedit.facts" } { } ;
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
IN: vim
|
||||
USING: definitions embedded io kernel parser prettyprint process
|
||||
sequences ;
|
||||
sequences namespaces ;
|
||||
|
||||
: file-modified stat fourth ;
|
||||
|
||||
: vim-line/file ( file line -- )
|
||||
>r "vim " swap append r> unparse " +" swap append3 system drop ;
|
||||
: vim-location ( file line -- )
|
||||
>r [ file-modified ] keep r>
|
||||
[ "vim \"" % over % "\" +" % # ] "" make system drop
|
||||
file-modified = [ drop ] [ run-file ] if ;
|
||||
|
||||
: vim ( spec -- )
|
||||
#! Edit the file in vim. Rerun the file if the timestamp is changed.
|
||||
dup where first2 >r ?resource-path [ file-modified ] keep r>
|
||||
dupd vim-line/file file-modified = [ drop ] [ reload ] if ;
|
||||
dup where first2 vim-location ;
|
||||
|
||||
[ vim ] edit-hook set-global
|
||||
[ vim-location ] edit-hook set-global
|
||||
|
||||
: vim-syntax
|
||||
#! Generate a new factor.vim file for syntax highlighting
|
||||
|
|
|
@ -7,7 +7,7 @@ $terpri
|
|||
$terpri
|
||||
"If any file names are specified at all, the first one must be the image name; otherwise, the default image file is used, which is usually a file named " { $snippet "factor.image" } " in the same directory as the runtime executable (on Windows and Mac OS X) or the current directory (on Unix)."
|
||||
$terpri
|
||||
"All file names other than the first one are source file names which will be run using " { $link try-run-file } " when Factor starts up."
|
||||
"All file names other than the first one are source file names which will be run using " { $link ?run-file } " when Factor starts up."
|
||||
$terpri
|
||||
"Finally, switches can take one of the following three forms:"
|
||||
{ $list
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
USING: definitions errors help image inspector io kernel
|
||||
listener memory modules parser prettyprint sequences test
|
||||
words jedit shells ;
|
||||
words shells ;
|
||||
|
||||
ARTICLE: "tools" "Development tools"
|
||||
"This section covers words which are used during development, and not usually invoked directly by user code."
|
||||
|
@ -136,7 +136,7 @@ $terpri
|
|||
{ $subsection where }
|
||||
{ $subsection subdefs }
|
||||
"Editing definitions:"
|
||||
{ $subsection jedit }
|
||||
{ $subsection edit }
|
||||
{ $subsection reload }
|
||||
"Removing definitions:"
|
||||
{ $subsection forget } ;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
! Copyright (C) 2004, 2006 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: compiler errors generic help io io-internals kernel
|
||||
kernel-internals listener math memory namespaces optimizer
|
||||
parser sequences sequences-internals words ;
|
||||
USING: command-line compiler errors generic help io io-internals
|
||||
kernel kernel-internals listener math memory namespaces
|
||||
optimizer parser sequences sequences-internals words ;
|
||||
|
||||
[
|
||||
! Wrap everything in a catch which starts a listener so you
|
||||
|
@ -64,34 +64,36 @@ parser sequences sequences-internals words ;
|
|||
H{ } clone parent-graph set-global xref-help
|
||||
H{ } clone term-index set-global index-help
|
||||
] when
|
||||
|
||||
[
|
||||
boot
|
||||
run-user-init
|
||||
"shell" get "shells" lookup execute
|
||||
0 exit
|
||||
] set-boot
|
||||
|
||||
f error set-global
|
||||
f error-continuation set-global
|
||||
] no-parse-hook
|
||||
|
||||
[ compiled? ] word-subset length
|
||||
number>string write " compiled words" print
|
||||
|
||||
[ symbol? ] word-subset length
|
||||
number>string write " symbol words" print
|
||||
|
||||
all-words length
|
||||
number>string write " words total" print
|
||||
|
||||
"Total bootstrap GC time: " write gc-time
|
||||
number>string write " ms" print
|
||||
|
||||
"Bootstrapping is complete." print
|
||||
"Now, you can run ./f factor.image" print flush
|
||||
|
||||
"factor.image" resource-path save-image
|
||||
] [ print-error :c ] recover
|
||||
] no-parse-hook
|
||||
run-bootstrap-init
|
||||
|
||||
[
|
||||
boot
|
||||
run-user-init
|
||||
"shell" get "shells" lookup execute
|
||||
0 exit
|
||||
] set-boot
|
||||
|
||||
f error set-global
|
||||
f error-continuation set-global
|
||||
|
||||
[ compiled? ] word-subset length
|
||||
number>string write " compiled words" print
|
||||
|
||||
[ symbol? ] word-subset length
|
||||
number>string write " symbol words" print
|
||||
|
||||
all-words length
|
||||
number>string write " words total" print
|
||||
|
||||
"Total bootstrap GC time: " write gc-time
|
||||
number>string write " ms" print
|
||||
|
||||
"Bootstrapping is complete." print
|
||||
"Now, you can run ./f factor.image" print flush
|
||||
|
||||
"factor.image" resource-path save-image
|
||||
] [ print-error :c ] recover
|
||||
|
||||
0 exit
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
! Copyright (C) 2004, 2006 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
IN: kernel-internals
|
||||
USING: assembler errors io io-internals kernel math namespaces
|
||||
parser threads words ;
|
||||
USING: assembler command-line errors io io-internals kernel math
|
||||
namespaces parser threads words ;
|
||||
|
||||
: boot ( -- )
|
||||
init-namespaces
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
! Copyright (C) 2003, 2006 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
IN: kernel
|
||||
USING: errors hashtables io kernel-internals namespaces
|
||||
IN: command-line
|
||||
USING: errors hashtables io kernel kernel-internals namespaces
|
||||
parser sequences strings ;
|
||||
|
||||
: run-user-init ( -- )
|
||||
#! Run user init file if it exists
|
||||
: run-bootstrap-init ( -- )
|
||||
"user-init" get [
|
||||
"~" get "/.factor-rc" append dup exists?
|
||||
[ try-run-file ] [ drop ] if
|
||||
"~" get "/.factor-boot-rc" append ?run-file
|
||||
] when ;
|
||||
|
||||
: run-user-init ( -- )
|
||||
"user-init" get [
|
||||
"~" get "/.factor-rc" append ?run-file
|
||||
] when ;
|
||||
|
||||
: cli-var-param ( name value -- ) swap set-global ;
|
||||
|
@ -52,4 +55,4 @@ parser sequences strings ;
|
|||
|
||||
: parse-command-line ( -- )
|
||||
cli-args [ cli-arg ] subset
|
||||
ignore-cli-args? [ drop ] [ [ try-run-file ] each ] if ;
|
||||
ignore-cli-args? [ drop ] [ [ ?run-file ] each ] if ;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
! Copyright (C) 2006 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
IN: definitions
|
||||
USING: kernel sequences ;
|
||||
USING: kernel sequences namespaces errors ;
|
||||
|
||||
GENERIC: see ( defspec -- )
|
||||
|
||||
GENERIC: where ( defspec -- loc )
|
||||
GENERIC: where* ( defspec -- loc )
|
||||
|
||||
GENERIC: subdefs ( defspec -- seq )
|
||||
|
||||
|
@ -14,10 +14,3 @@ GENERIC: subdefs ( defspec -- seq )
|
|||
GENERIC: forget ( defspec -- )
|
||||
|
||||
GENERIC: synopsis ( defspec -- str )
|
||||
|
||||
TUPLE: no-edit-hook ;
|
||||
|
||||
SYMBOL: edit-hook
|
||||
|
||||
: edit ( defspec -- )
|
||||
edit-hook get [ call ] [ <no-edit-hook> throw ] if* ;
|
||||
|
|
|
@ -46,8 +46,8 @@ TUPLE: check-method class generic ;
|
|||
: implementors ( class -- seq )
|
||||
[ "methods" word-prop ?hash* nip ] word-subset-with ;
|
||||
|
||||
M: method-spec where
|
||||
dup first2 method method-loc [ ] [ second where ] ?if ;
|
||||
M: method-spec where*
|
||||
dup first2 method method-loc [ ] [ second where* ] ?if ;
|
||||
|
||||
M: method-spec subdefs drop f ;
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ DEFER: $subsection
|
|||
all-articles [ children ] parent-graph get build-graph ;
|
||||
|
||||
! Definition protocol
|
||||
M: link where link-name article article-loc ;
|
||||
M: link where* link-name article article-loc ;
|
||||
|
||||
M: link (synopsis)
|
||||
\ ARTICLE: pprint-word
|
||||
|
@ -87,7 +87,7 @@ M: link see (see) ;
|
|||
|
||||
PREDICATE: link word-link link-name word? ;
|
||||
|
||||
M: word-link where link-name "help-loc" word-prop ;
|
||||
M: word-link where* link-name "help-loc" word-prop ;
|
||||
|
||||
M: word-link (synopsis)
|
||||
\ HELP: pprint-word
|
||||
|
|
|
@ -39,7 +39,8 @@ SYMBOL: parse-hook
|
|||
: no-parse-hook ( quot -- )
|
||||
[ parse-hook off call ] with-scope ; inline
|
||||
|
||||
: try-run-file ( file -- ) [ [ run-file ] keep ] try drop ;
|
||||
: ?run-file ( file -- )
|
||||
dup exists? [ [ [ run-file ] keep ] try ] when drop ;
|
||||
|
||||
: eval>string ( str -- str )
|
||||
[ [ [ eval ] keep ] try drop ] string-out ;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
USING: compiler help io jedit parser ;
|
||||
USING: compiler help io parser definitions ;
|
||||
|
||||
HELP: file-vocabs
|
||||
{ $description "Installs the initial the vocabulary search path for parsing a file." } ;
|
||||
|
@ -45,14 +45,14 @@ HELP: run-file
|
|||
{ $description "Parses the Factor source code stored in a file and runs it. The initial vocabulary search path is used." }
|
||||
{ $errors "Throws an error if loading the file fails, there input is malformed, or if a runtime error occurs while calling the parsed quotation." } ;
|
||||
|
||||
HELP: try-run-file
|
||||
HELP: ?run-file
|
||||
{ $values { "file" "a path name string" } }
|
||||
{ $description "Forgiving variant of " { $link run-file } " which logs errors to the default stream without re-throwing them." } ;
|
||||
{ $description "Forgiving variant of " { $link run-file } " which does nothing if the file does not exist, and logs errors to the default stream without re-throwing them." } ;
|
||||
|
||||
HELP: parse-resource
|
||||
{ $values { "path" "a resource name string" } { "quot" "a new quotation" } }
|
||||
{ $description "Parses a library resource." }
|
||||
{ $notes "the source file name given to the parser is special for resources and begins with " { $snippet "resource:" } ". This allows words that operate on source files, like " { $link jedit } ", to use a different resource path at run time than was used at parse time." }
|
||||
{ $notes "the source file name given to the parser is special for resources and begins with " { $snippet "resource:" } ". This allows words that operate on source files, like " { $link edit } ", to use a different resource path at run time than was used at parse time." }
|
||||
{ $errors "Throws an I/O error if there was an error reading the resource. Throws a parse error if the input is malformed." } ;
|
||||
|
||||
HELP: run-resource
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
! Copyright (C) 2004, 2006 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: arrays generic hashtables help inspector io kernel
|
||||
kernel-internals math namespaces parser prettyprint sequences
|
||||
sequences-internals strings styles vectors words ;
|
||||
USING: arrays definitions generic hashtables help inspector io
|
||||
kernel kernel-internals math namespaces parser prettyprint
|
||||
sequences sequences-internals strings styles vectors words ;
|
||||
IN: errors
|
||||
|
||||
PREDICATE: array kernel-error ( obj -- ? )
|
||||
|
@ -36,6 +36,10 @@ SYMBOL: restarts
|
|||
: :res ( n -- )
|
||||
restarts get nth first3 continue-with ;
|
||||
|
||||
: :edit ( -- )
|
||||
error get dup parse-error-file swap parse-error-line
|
||||
edit-location ;
|
||||
|
||||
: (:help-multi)
|
||||
"This error has multiple delegates:" print help-outliner ;
|
||||
|
||||
|
@ -72,6 +76,11 @@ SYMBOL: restarts
|
|||
":s - data stack at exception time" [ :s ] print-input
|
||||
":r - retain stack at exception time" [ :r ] print-input
|
||||
":c - call stack at exception time" [ :c ] print-input
|
||||
|
||||
error get [ parse-error? ] is? [
|
||||
":edit - jump to source location" [ :edit ] print-input
|
||||
] when
|
||||
|
||||
":get ( var -- value ) accesses variables at time of the error" print
|
||||
flush ;
|
||||
|
||||
|
|
|
@ -1,14 +1,26 @@
|
|||
! Copyright (C) 2006 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
IN: definitions
|
||||
USING: arrays generic hashtables io kernel math namespaces
|
||||
parser prettyprint sequences styles words ;
|
||||
USING: arrays errors generic hashtables io kernel math
|
||||
namespaces parser prettyprint sequences styles words ;
|
||||
|
||||
: ?resource-path ( path -- path )
|
||||
"resource:/" ?head [ resource-path ] when ;
|
||||
|
||||
: where ( defspec -- loc )
|
||||
where* first2 >r ?resource-path r> 2array ;
|
||||
|
||||
: reload ( defspec -- )
|
||||
where first [ ?resource-path run-file ] when* ;
|
||||
where first [ run-file ] when* ;
|
||||
|
||||
TUPLE: no-edit-hook ;
|
||||
|
||||
SYMBOL: edit-hook
|
||||
|
||||
: edit-location ( file line -- )
|
||||
edit-hook get [ call ] [ <no-edit-hook> throw ] if* ;
|
||||
|
||||
: edit ( defspec -- ) where first2 edit-location ;
|
||||
|
||||
GENERIC: (synopsis) ( defspec -- )
|
||||
|
||||
|
|
|
@ -187,7 +187,7 @@ TUPLE: check-create name vocab ;
|
|||
all-words [ word-name = ] subset-with ;
|
||||
|
||||
! Definition protocol
|
||||
M: word where "loc" word-prop ;
|
||||
M: word where* "loc" word-prop ;
|
||||
|
||||
M: word subdefs drop f ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue