joe editor -> newlisp.jsf generator

Started by newdep, November 18, 2008, 04:05:22 PM

Previous topic - Next topic

newdep

Well based on the creative arts of m35 I though it was very odd i did not have such a thing for JOE editor?

('how to forget to automate the things you works with daily!?')



#!/usr/bin/newlisp

;-- to get the original symbols from newlisp
;-- thow shall only use the magic list

(setq sugar (string "newlisp-" (sys-info -2) ".jsf"))

;-- Round and round the garden walkes a teddy beer..
(setq tea (join (exec {newlisp -e "(dump)"}) "n"))

;-- one step...
(find-all "type=263 contents=(.*) <" tea (push $1 bag))

;-- two step...
(setq spoon (last (sort (map length bag))))

(delete-file sugar)

(append-file sugar
[text]# (Automated) JOE syntax highlight file for newLISP

# These colors are for the text console.
# You will definitely need different colors for a terminal under X.
# The range of colors is found in your c.jsf file.
# Deprecated commands will blink annoyingly ]
# Thanks to Norman (newdep)
# 10 Nov 2004
# 27 Jan 2005, L.M. updated to v.8.4.1
# 28 Jan 2005, L.M. made comments (did not work om Joe 3.1)
[/text]
)

(append-file sugar
{#                   made [text] .. [/text] tags work}
)

(append-file sugar  
[text]
# 25 June 2008, L.M updated for version 9.4.0
# 22 Sept 2008, L.M updated for version 9.9.x -> 10.0 added setf
# 29 Sept 2008, L.M updated for version 9.9.x -> 10.0 added copy
# 21 Oct 2008, L.M. exclude MAIN from highlighting
# 18 Nov 2008, Norman, created the automated newlisp.jsf generator
#  
# usage:  
# cp newlisp-xxxx.jsf /etc/joe/syntax/newlisp.jsf
# and adjust the /etc/joe/ftyperc
#
# version 1.4

=Idle
=Comment        green
=String         bold black
=Text           bold black
=Escape         bold green
=Paren          red
=Quote          bold
=Prim           cyan
=Tag            bold blue
=Depr           blink

:idle Idle
    *       idle
    ";"     comment         recolor=-1
    "#"     comment         recolor=-1
    """    string          recolor=-1
    "{"     brace_string    recolor=-1
    "()"    paren           recolor=-1
    "'"     quote           recolor=-1
    "["     tag_o1          recolor=-1
    "!=%&*+/<>^|~a-zA-Z_-" ident       buffer

:comment Comment
    *           comment
    "n"        idle

:string String
    *           string
    """        idle
    "\"        string_escape   recolor=-1

:string_escape Escape
    *           string
    "n"        string      recolor=-2

:brace_string String
    *           brace_string
    "}"         idle

:paren Paren
    *           idle        noeat

:quote Quote
    *           idle        noeat
   
:ident Idle
    *           idle        noeat strings

[/text]
)
   
;-- tidely tidely there...
(setq bag (sort bag))
(dolist (x bag)
  (append-file sugar (string (dup " ") {"} x {"} (dup " " (+ (- spoon (length x)) 2)) "primn")))

 
;-- there is always a happy end with newlisp ;-)
(append-file sugar
[text]
done        
    "-"a-zA-Z_0-9!#@$%^&*+={}|/\:';,.<>/?~`" ident


:prim Prim
    *           idle        noeat

:tag_o1 Tag
    *           idle        noeat
    "t"         tag_o2
   
:tag_o2 Tag
    *           idle        noeat
    "e"         tag_o3
   
:tag_o3 Tag
    *           idle        noeat
    "x"         tag_o4
   
:tag_o4 Tag
    *           idle        noeat
    "t"         tag_o5
   
:tag_o5 Tag
    *           idle        noeat
    "]"         long_text
   
:long_text      Text
    *           long_text
    "["         close_tag   buffer recolor=-1
   
:close_tag Tag
    *           long_text   noeat strings
[/text]
)

(append-file sugar
{   "[/text]"   tag_closed

done
    "[]/etx"    close_tag
   
:tag_closed Tag
    *           idle        noeat
       
:depr Depr
  *  idle       noeat
}
)

;-- oH yes.. enjoy!
(exit)

-- (define? (Cornflakes))

newdep

#1
final version 1.0

http://www.nodep.nl/downloads/newlisp/jsf.lsp">//http://www.nodep.nl/downloads/newlisp/jsf.lsp
-- (define? (Cornflakes))

unixtechie

#2
Great that you generate the list of functions automatically, but I disliked the colours. So I changed them ;)



My idea is that it should be very readable and very clean rather than simply looking like a rainbow.



here's my joe newlisp colouring file (which I did quite some time ago, so it might miss any add-ons in the lage 9.9.x series if any)



Check to see of you like bold brackets (I find them indispensable) and minimal colour distinction, only  between comments (green), built-in functions (blue), text strings (magenta) and "the rest' (black):



(NOTE: this config file may be redundant in some parts, as I simply re-edited an existing config)



# JOE syntax highlight file for newLISP 9.1


=Idle           black
=Comment        green
=String         magenta
=Text           magenta
=Escape         green:1
=Paren          bold
=Quote          bold
=Prim           bold blue
=Tag            bold
=Depr           blink

:idle Idle
        *               idle
        ";"             comment         recolor=-1
        "#"             comment         recolor=-1
        """    string          recolor=-1
        "{"             brace_string    recolor=-1
        "()"    paren           recolor=-1
        "'"             quote           recolor=-1
        "["             tag_o1          recolor=-1
        "!=%&*+/<>^|~a-zA-Z_-" ident           buffer

:comment Comment
        *               comment
        "n"            idle

:string String
        *               string
        """            idle
        "\"            string_escape   recolor=-1

:string_escape Escape
        *               string
        "n"            string          recolor=-2

:brace_string String
        *               brace_string
        "}"             idle

:paren Paren
        *               idle            noeat

:quote Quote
        *               idle            noeat

:ident Idle
        *               idle            noeat strings
        "!"     prim
        "!="    prim
        "$"     prim
        "%"     prim
        "&"     prim
        "*"     prim
        "+"     prim
        "-"     prim
        "/"     prim
        "<"     prim
        "<<"    prim
        "<="    prim
        "="     prim
        ">"     prim
        ">="    prim
        ">>"    prim
        "^"     prim
        "$0"    prim
        "$1"    prim
        "$2"    prim
        "$3"    prim
        "$4"    prim
        "$5"    prim
        "$6"    prim
        "$7"    prim
        "$8"    prim
        "$9"    prim
        "$10"   prim
        "$11"   prim
        "$12"   prim
        "$13"   prim
        "$14"   prim
        "$15"   prim
        "$args" prim
        "NaN?"  prim
        "abs"   prim
        "acos"  prim
        "acosh" prim
        "add"   prim
        "address"       prim
        "amb"   prim
        "and"   prim
        "append"        prim
        "append-file"   prim
        "apply" prim
        "args"  prim
        "array" prim
        "array-list"    prim
        "array?"        prim
        "asin"  prim
        "asinh" prim
        "assoc" prim
        "atan"  prim
        "atanh" prim
        "atan2" prim
        "atom?" prim
        "base"  prim
        "base64-enc"    prim
        "base64-dec"    prim
        "bayes-query"   prim
        "bayes-train"   prim
        "begin" prim
        "beta"  prim
        "betai" prim
        "binomial"      prim
        "break" prim
        "callback"      prim
        "case"  prim
        "catch" prim
        "ceil"  prim
        "change-dir"    prim
        "char"  prim
        "chop"  prim
        "clean" prim
        "close" prim
        "command-line"  prim
        "cond"  prim
        "connection"    prim
        "cons"  prim
        "constant"      prim
        "context"       prim
        "context?"      prim
        "copy-file"     prim
        "cos"   prim
        "cosh"  prim
        "count" prim
        "cpymem"        prim
        "crc32"         prim
        "crit-chi2"     prim
        "crit-z"        prim
        "current-line"  prim
        "date"  prim
        "date-value"    prim
        "debug" prim
        "dec"   prim
        "default"       prim
        "det"   prim
        "def-new"       prim
        "define"        prim
        "define-macro"  prim
        "delete"        prim
        "delete-file"   prim
        "delete-url"    prim
        "destroy"       prim
        "device"        prim
        "difference"    prim
        "directory"     prim
        "directory?"    prim
        "div"   prim
        "doargs"        prim
        "dolist"        prim
        "dotimes"       prim
        "dotree"        prim
        "do-while"      prim
        "do-until"      prim
        "dump"  prim
        "dup"   prim
        "empty?"        prim
        "encrypt"       prim
        "ends-with"     prim
        "env"   prim
        "environ"  depr
        "environment"   prim
        "error-event"   prim
        "error-number"  prim
        "error-text"    prim
        "erf"   prim
        "eval"  prim
        "eval-string"   prim
        "exec"  prim
        "exit"  prim
        "exp"   prim
        "expand"        prim
        "explode"       prim
        "factor"        prim
        "fft"   prim
        "file-info"     prim
        "file?" prim
        "filter"        prim
        "find"  prim
        "first" prim
        "flat"  prim
        "float" prim
        "float?"        prim
        "floor" prim
        "flt"   prim
        "fn"    prim
        "for"   prim
        "fork"  prim
        "format"        prim
        "fv"    prim
        "gammai"        prim
        "gammaln"       prim
        "gcd"   prim
        "get-char"      prim
        "get-long"      prim
        "getenv"  depr
        "get-float"     prim
        "get-int"       prim
        "get-integer"   depr
        "get-string"    prim
        "get-url"       prim
        "global"        prim
        "if"    prim
        "ifft"  prim
        "import"        prim
        "inc"   prim
        "index" prim
        "int"   prim
        "integer"       prim
        "integer?"      prim
        "intersect"     prim
        "invert"        prim
        "irr"   prim
        "join"  prim
        "lambda"        prim
        "lambda?"       prim
        "legal?"        prim
        "last"  prim
        "length"        prim
        "let"   prim
        "letex" prim
        "letn"  prim
        "list"  prim
        "list?" prim
        "load"  prim
        "local" prim
        "log"   prim
        "lookup"        prim
        "lower-case"    prim
        "macro?"        prim
        "main-args"     prim
        "make-dir"      prim
        "map"   prim
        "match" prim
        "max"   prim
        "member"        prim
        "min"   prim
        "mod"   prim
        "mul"   prim
        "multiply"      prim
        "name"  prim
        "net-accept"    prim
        "net-close"     prim
        "net-connect"   prim
        "net-error"     prim
        "net-eval"      prim
        "net-listen"    prim
        "net-local"     prim
        "net-lookup"    prim
        "net-peek"      prim
        "net-peer"      prim
        "net-ping"  prim
        "net-receive"   prim
        "net-receive-from"      prim
        "net-receive-udp"       prim
        "net-select"    prim
        "net-send"      prim
        "net-send-to"   prim
        "net-send-udp"  prim
        "net-service"   prim
        "net-sessions"  prim
        "new"   prim
        "nil" prim
        "null?" prim
        "normal"        prim
        "not"   prim
        "not-equal"     prim
        "now"   prim
        "nper"  prim
        "npv"   prim
        "nth"   prim
        "nth-set"       prim
        "number?"       prim
        "open"  prim
        "or"    prim
        "ostype"        prim
        "pack"  prim
        "parse" prim
        "peek"  prim
        "pipe"  prim
        "pmt"   prim
        "pop"   prim
        "post-url"      prim
        "pow"   prim
        "pretty-print"  prim
        "primitive?"    prim
        "print" prim
        "println"       prim
        "prob-chi2"     prim
        "prob-z"        prim
        "process"       prim
        "push"  prim
        "putenv"  depr
        "put-url"       prim
        "pv"    prim
        "quote" prim
        "quote?"        prim
        "radians"       prim
        "rand"  prim
        "random"        prim
        "randomize"     prim
        "read-buffer"   prim
        "read-char"     prim
        "read-file"     prim
        "read-key"      prim
        "read-line"     prim
        "real-path"     prim
        "ref"   prim
        "ref-all"       prim
        "regex" prim
        "remove-dir"    prim
        "rename-file"   prim
        "replace"       prim
        "replace-assoc" prim
        "reset" prim
        "rest"  prim
        "reverse"       prim
        "rotate"        prim
        "round" prim
        "save"  prim
        "search"        prim
        "seed"  prim
        "seek"  prim
        "select"        prim
        "semaphore"     prim
        "sequence"      prim
        "series"        prim
        "set!"  prim
        "set"   prim
        "set-locale"    prim
        "set-nth"       prim
        "setq"  prim
        "sgn"   prim
        "share" prim
        "signal"        prim
        "silent"        prim
        "sin"   prim
        "sinh"  prim
        "sleep" prim
        "slice" prim
        "socket"        prim
        "sort"  prim
        "source"        prim
        "sqrt"  prim
        "starts-with"   prim
        "string"        prim
        "string?"       prim
        "sub"   prim
        "swap"  prim
        "sym"   prim
        "symbol"        prim
        "symbol?"       prim
        "symbols"       prim
        "sys-error"     prim
        "sys-info"      prim
        "tan"   prim
        "tanh"  prim
        "throw" prim
        "throw-error"   prim
        "time"  prim
        "time-of-day"   prim
        "title-case"    prim
        "trace" prim
        "trace-highlight"       prim
        "transpose"     prim
        "trim"  prim
        "true"  prim
        "true?"  prim
        "unicode"       prim
        "unify" prim
        "unique"        prim
        "unless"        prim
        "unpack"        prim
        "until" prim
        "upper-case"    prim
        "utf8"  prim
        "utf8len"       prim
        "uuid"  prim
        "wait-pid"      prim
        "while" prim
        "write-buffer"  prim
        "write-char"    prim
        "write-file"    prim
        "write-line"    prim
        "xml-error"     prim
        "xml-parse"     prim
        "xml-type-tags" prim
        "zero?" prim
        "|"     prim
        "~"     prim

done
        "-"a-zA-Z_0-9!#@$%^&*+={}|/\:';,.<>/?~`" ident


:prim Prim
        *               idle            noeat

:tag_o1 Tag
        *               idle            noeat
        "t"             tag_o2

:tag_o2 Tag
        *               idle            noeat
        "e"             tag_o3

:tag_o3 Tag
        *               idle            noeat
        "x"             tag_o4

:tag_o4 Tag
        *               idle            noeat
        "t"             tag_o5

:tag_o5 Tag
        *               idle            noeat
        "]"             long_text

:long_text      Text
        *               long_text
        "["             close_tag       buffer recolor=-1

:close_tag Tag
        *               long_text       noeat strings
        "[/text]"       tag_closed
done
        "[]/etx"        close_tag

:tag_closed Tag
        *               idle            noeat


:depr Depr
        *               idle            noeat





newdep

#3
oke fair is fair, eveyone his colorscheme! ;-)



how about this ->

http://www.nodep.nl/downloads/newlisp/jsf.lsp">//http://www.nodep.nl/downloads/newlisp/jsf.lsp
-- (define? (Cornflakes))

unixtechie

#4
# (Automated) JOE syntax highlight file for newLISP

# original newlisp.jsf by L Wix [xman-et-myrealbox-dot-com]

#

# copy generated newlisp-xxxx.jsf /etc/joe/syntax/newlisp.jsf

# and adjust the /etc/joe/ftyperc

# version 1.111111, Unixtechie



# Dark, bright and bold the colours are easy on the eyes and completely functional:

# you'll know what is what at once. No need to wade bleak landscapes littered with

# bleak multicoloured spots of other colourizers' output which look like dead autumn

# leaves.

# And BRACKETS, fat, bold, black and maggoty brackets that stop the eye and tell you

# exactly what ends where and where it begins

#

# I.e. A TRUE PROGRAMMER's COLOURIZER, simple and effective. Version 1.111111

#



=Idle           black

=Comment        green

=String         magenta

=Text           magenta

=Escape         green:1

=Paren          bold

=Quote          bold

=Prim           bold blue

=Tag            bold

=Depr           blink

cormullion

#5
Quote from: "unixtechie"
# Dark, bright and bold the colours are easy on the eyes and completely functional:

# you'll know what is what at once. No need to wade bleak landscapes littered with

# bleak multicoloured spots of other colourizers' output which look like dead autumn

# leaves.

# And BRACKETS, fat, bold, black and maggoty brackets that stop the eye and tell you

# exactly what ends where and where it begins

#

# I.e. A TRUE PROGRAMMER's COLOURIZER, simple and effective. Version 1.111111


Ooops - You're going to hate the colours in the latest iteration of my introductory offering, I think.

I've just been making the parentheses lighter grey in colour, to match the generally pastel bleak mid-winter landscape colour scheme... :)



Still, I'm not a true programmer. :)

tom

#6
who the heck uses joe?



*ducks*

unixtechie

#7
Quote from: "tom"who the heck uses joe?


WE DO

It's the easiest and most intuitive small editor around.

No multi-key finger gymnastics of that incredible kludge of emacs (tens of megabytes for an editor???), no stumbling your finger against that escape key every time you want to do anything at all as in vi.

No undescribable vulgarity of software in Java, bloated, slow, and demanding more lines of code per some task compared to virtually any language except assembler.



No running X server  as a prerequisite as is the case with GUI-based editors.



Joe is simple, programming-oriented, includes all major functions, macros, bookmarks, some regexs etc. etc., is quite natural, and has built-in help, so you do not even need to remember how to do things in it.

unixtechie

#8
Quote from: "cormullion"
Ooops - You're going to hate the colours in the latest iteration of my introductory offering, I think.

I've just been making the parentheses lighter grey in colour, to match the generally pastel bleak mid-winter landscape colour scheme... :)



Still, I'm not a true programmer. :)


You know what - I found use for your colour scheme.

I tried it on BLACK background, and it's pretty good for that, quite clear etc.etc.



So I'll use yours whenever fancy takes me to write in a black term window, and use mine when the background is white or very light grey.



Now the peace is reestablished, can we unite and kick around in the hope to hit some  non-believer-in-greatness-of-the-Joe-editor that might wander accidentally in?

tom

#9
aw shucks, I was just kidding.

:-)



If I edit outside of X it's usually with jed--see, only a one letter difference!

m35

#10
Ah newdep! I know my approach wasn't every elegant, but you should warn people before shaming their code to oblivion :)



The (dump)ing of the symbols solves so many problems with preserving the namespace, I'm going to have to follow your superior approach.