ref: da15cf29739f5dc7f1699d561a8e388c391dffc0
parent: 362ffe51df8f1f4f8b3b9bff10c0def2d7aec9a0
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Tue Dec 24 13:14:20 EST 2024
repl: make prompt printing a func (*prompt*); better ~/.flisprc logic
--- a/flisp.boot
+++ b/flisp.boot
@@ -14,7 +14,8 @@
#fn("6000n201l:" #()) #fn("6000n201m:" #()) 0 #fn("8000z0700}2:" #(vector))
#fn("8000z0700}2:" #(aset!)) 0 0 0 0 0 0 0 0 0 0 0 #fn("9000n3012082>1|:" #(#fn("6000n1A061:" #())))
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #fn("8000z0700}2:" #(aref)) 0 0)
- *properties* #table(*funvars* #table(void? (x) length= (lst n) help (term) void rest vm-stats nil) *doc* #table(void? "Return #t if x is #<void> and #f otherwise." length= "Bounded length test.\nUse this instead of (= (length lst) n), since it avoids unnecessary\nwork and always terminates." help "Display documentation for the specified term, if available." void "Return the constant #<void> while ignoring any arguments.\n#<void> is mainly used when a function has side effects but does not\nproduce any meaningful value to return, so even though #t or nil could\nbe returned instead, in case of #<void> alone, REPL will not print\nit." vm-stats "Print various VM-related information, such as the number of GC calls\nso far, heap and stack size, etc." *properties* "All properties of symbols recorded with putprop are recorded in this table."))
+ *prompt* #fn("6000n0702161:" #(princ "#;> ")) *properties*
+ #table(*funvars* #table(void? (x) length= (lst n) help (term) void rest *prompt* nil vm-stats nil) *doc* #table(void? "Return #t if x is #<void> and #f otherwise." length= "Bounded length test.\nUse this instead of (= (length lst) n), since it avoids unnecessary\nwork and always terminates." help "Display documentation for the specified term, if available." void "Return the constant #<void> while ignoring any arguments.\n#<void> is mainly used when a function has side effects but does not\nproduce any meaningful value to return, so even though #t or nil could\nbe returned instead, in case of #<void> alone, REPL will not print\nit." *prompt* "Function called by REPL to signal the user input is required.\nDefault function prints \"#;> \"." vm-stats "Print various VM-related information, such as the number of GC calls\nso far, heap and stack size, etc." *properties* "All properties of symbols recorded with putprop are recorded in this table."))
*runestring-type* (array rune) *string-type* (array byte)
*syntax-environment* #table(unwind-protect #fn("A000n220502050218722q1e3e2e1232402286e12587e12686e2e3e3e387e1e3e3:" #(#fn(gensym)
let λ prog1 trycatch begin raise)) help #fn("<000n170021527002252853\\0738551474504863B07450475086P51@30O47450@B0732627051524745047860:" #(getprop
@@ -47,14 +48,13 @@
<= #fn("6000n210L;IB0470051;380470151S:" #(nan?) <=) >
#fn("6000n210L:" #() >) >= #fn("6000n201L;IB0470051;380470151S:" #(nan?) >=)
Instructions #table(call.l 81 trycatch 75 largc 79 loadg.l 68 aref2 23 box 90 cadr 36 argc 62 setg 71 load0 21 vector? 45 fixnum? 41 loadc0 17 loada0 0 div0 59 keyargs 89 call 5 loada.l 69 brt.l 50 sub2 78 add2 29 loadc.l 70 loadc 9 builtin? 43 set-car! 47 brt 25 ret 10 loadi8 66 tapply 77 loadvoid 93 loada1 1 shift 46 boolean? 39 atom? 24 cdr 13 brne.l 83 / 58 loadf 31 equal? 52 apply 54 dup 11 loadt 20 jmp.l 48 null? 38 not 35 = 60 set-cdr! 30 eq? 33 * 57 load1 27 bound? 42 brf 3 function? 44 box.l 91 < 28 brnn.l 84 jmp 16 loadv 2 for 76 lvargc 80 dummy_eof 94 + 55 brne 19 compare 61 neg 37 loadv.l 67 number? 40 vargc 74 brn 85 brbound 88 vector 63 loadc1 22 setg.l 72 cons? 18 brf.l 49 aref 92 symbol? 34 aset! 64 car 12 cons 32 tcall.l 82 - 56 brn.l 86 optargs 87 closure 14 pop 4 eqv? 51 list 53 seta 15 seta.l 73 brnn 26 loadnil 65 loadg 7 loada 8 tcall 6)
- __init_globals #fn("5000n020w1422w3474w5476w7478w9:" #("/" *directory-separator* "\n"
- *linefeed* *stdout*
- *output-stream* *stdin*
- *input-stream* *stderr*
- *error-stream*) __init_globals)
- __rcscript #fn(":000n0708421c37022@U08423c3A0242526512752@>0242528512952^12:84513907;8461:\x8d:" #(*os-name*
- "unknown" "" "plan9" #fn(string) #fn(os-getenv) "home" "/lib/flisprc" "HOME" "/.flisprc" #fn(path-exists?)
- load) __rcscript)
+ __init_globals #fn("5000n020w1422w3424w5476w7478w947:w;:" #(#fn("6000n0702161:" #(princ
+ "#;> ")) *prompt* "/" *directory-separator* "\n" *linefeed* *stdout* *output-stream* *stdin*
+ *input-stream* *stderr*
+ *error-stream*) __init_globals)
+ __rcscript #fn("<000n0708421c360O@A08422c37023@4024^125845185;3=042685772853863B02986513907:8661:O:" #(*os-name*
+ "unknown" "plan9" "home" "HOME" #fn(os-getenv) #fn(string)
+ *directory-separator* ".flisprc" #fn(path-exists?) load) __rcscript)
__script #fn("6000n1200>121{:" #(#fn("6000n070A61:" #(load))
#fn("6000n170051421K61:" #(top-level-exception-handler
#fn(exit)))) __script)
@@ -363,8 +363,8 @@
remprop #fn("8000n220711O5386;3F042286052;3:042386062:" #(#fn(get) *properties* #fn(has?)
#fn(del!)) remprop)
repl #fn(";000n0\x8d\x8d\x8a4\x8a5208421_5142085228485>2_51485<5047360:" #(#0#
- #fn("9000n0702151422735142425{267751S;3[04788451798551360O@=07:855147;50485w<47=60:" #(princ
- "> " #fn(io-flush) *output-stream* #fn("5000n02060:" #(#fn(read)))
+ #fn("9000n07050421725142324{257651S;3[04778451788551360O@=079855147:50485w;47<60:" #(*prompt*
+ #fn(io-flush) *output-stream* #fn("5000n02060:" #(#fn(read)))
#fn("6000n1207151422061:" #(#fn(io-discardbuffer) *input-stream* #fn(raise)))
#fn(io-eof?) *input-stream* load-process void? print newline that void) prompt)
#fn("6000n020A>121{370F<60:O:" #(#fn("5000n0A<60:" #())
--- a/system.lsp
+++ b/system.lsp
@@ -937,7 +937,8 @@
(define (repl)
(define (prompt)
- (princ "> ") (io-flush *output-stream*)
+ (*prompt*)
+ (io-flush *output-stream*)
(let ((v (trycatch (read)
(λ (e) (io-discardbuffer *input-stream*)
(raise e)))))
@@ -1069,6 +1070,9 @@
; initialize globals that need to be set at load time
(define (__init_globals)
+ (set! *prompt*
+ "Function called by REPL to signal the user input is required.
+Default function prints \"#;> \"." (λ () (princ "#;> ")))
(set! *directory-separator* "/")
(set! *linefeed* "\n")
(set! *output-stream* *stdout*)
@@ -1081,11 +1085,13 @@
(exit 1)))))
(define (__rcscript)
- (let ((fname (case *os-name*
- (("unknown") "")
- (("plan9") (string (os-getenv "home") "/lib/flisprc"))
- (else (string (os-getenv "HOME") "/.flisprc")))))
- (if (path-exists? fname) (load fname))))
+ (let* ((homevar (case *os-name*
+ (("unknown") #f)
+ (("plan9") "home")
+ (else "HOME")))
+ (home (os-getenv homevar))
+ (fname (and home (string home *directory-separator* ".flisprc"))))
+ (when (and fname (path-exists? fname)) (load fname))))
(define (__start argv)
(__init_globals)