Paste: Startup Code

Author: Dave Carlton
Mode: factor
Date: Sat, 31 Dec 2022 15:51:43
Plain Text |
! -*- factor -*-
USING: accessors colors combinators.short-circuit continuations
debugger fuel.remote init io io.encodings.utf8 io.files io.styles
kernel libc listener math namespaces prettyprint sequences strings
tools.scaffold ui.theme.switching ui.tools.listener unix vectors words ;

t handle-ctrl-break set-global

USE: extensions
USE: editors.emacs
"/Applications/Applications/Emacs.app/Contents/MacOS/bin/emacsclient" emacsclient-path set-global
{ "--socket-name=/Users/davec/.emacs.d/server/server"  "--no-wait" } emacsclient-args set-global

IN: namespaces
SYMBOL: factor-history-path
factor-history-path [ "~/.factor-history" ] initialize

IN: extensions
"Dave Carlton" developer-name set-global
prompt-style COLOR: black foreground update-style

[ fuel-start-remote-listener* ]
[ { [ unix-system-call-error? ] [ errno>> EADDRINUSE = ] } 1&&
  dup [ "Never mind, address already in use" write nl flush ] when ]
ignore-error

: set-history ( -- )
    factor-history-path get utf8
    file-lines
    [ dequote input boa ] map >vector
    get-listener input>> history>> over >>elements
    swap length 1 + >>index
    drop
    ;

: startup-banner ( -- )
    {    "To rebuild factor enter in terminal:" 
         "make"
         "factor -i=boot.unix-x86.64.image"
         "To Startup factor UI"
         "\"unix-x86.64\" make-image"
    } [ print ] each ;


: save-history ( -- )
    factor-history-path get utf8
    [ get-listener input>> history>> elements>>
      [ string>> . ] each
    ] with-file-appender
    ;

: my-shutdown ( -- )
    [ save-history  ] try
;

: my-startup ( -- )
    [ scaffold-emacs
      set-history
      startup-banner
    ] try
    ;

[ my-shutdown ] "my-shutdown" add-shutdown-hook
[ my-startup ] "my-startup" add-startup-hook
! STARTUP-HOOK: my-startup

IN: ui.gadgets.editors
+filled+ caret-style set-global

! ! USE: ui.theme.tango
! tango-dark-mode

New Annotation

Summary:
Author:
Mode:
Body: