hello list, this is my first post here. thank you very much for posting this marmorine! i'm not a coder but i have a "philosophical interest" in lisp, and i've also been planning a note-taking/organizing program that would use similar navigation to what you have there.
so this code is very good learning material for me. thanks again! cheers, mart 2015-01-16 17:33 GMT+02:00 marmorine <s.marmor...@gmx.de>: > I had been meaning to ask this same question myself (and thanks to dave > for bringing it up). I wrote a quick launcher namely for the console, > it uses rotate to select options and settings, that changes the options > list "in place" and worked really well actually, I like the effect. > > Then I wanted to insert INTO the options list using command line > switches, and there I was stumped at first, wondering what is > destructive, what is not and so forth (or what that even IS), finally > returned a rebuilt options list to an assignment, but thinking all > along that "there must be a better way". > > So made some changes using your suggestion with set and nth: > > Replaced this: > > #(de insert_opt (Id X) > # (setq *opts > # (make > # (for L *opts > # (if (= Id (car L)) > # (link (place 4 L (cons X (last L)))) > # (link L) ) ) ) ) ) > > with this: > > (de insert_opt (Id X) > (let L (nth (assoc Id *opts) 4) > (set L (cons X (car L))) ) ) > > (this uses a let because I couldn't get a @ or @@ working...) > > Usage: > > By the way, if you fire up ez_opts (its fun), use j and k to select > options, h and l to rotate presets (the car in a presets list is the > active setting), and if the car is itself a list, you can rotate it with > the i key. That's it! The opts menu here is for (what else!) a > flashcard-like program, but could be anything. > > *** > > #!/usr/bin/picolisp /usr/lib/picolisp/lib.l > > (setq > *ed2 "^[[2J" *cud3i "^[[3B " *cr "^M" *esc "^[" > *ezkeys '("h" "j" "k" "l" "i") ) > > (de cupyx (Y X) > (pack "^[[" Y ";" X "H") ) > > (de rotl (L) > (do (- (length L) 1) (rot L)) ) > > (de gopt (X) > (car (last (assoc X *opts))) ) > > (de ez_opts () > (loop > (prin *ed2 (cupyx 2 3) *title) > (for L (reverse *opts) > (prin (cupyx (cadr L) 3) (caddr L)) > (print (last L)) ) > (prin *cr) > (T (not (member (setq K (key)) *ezkeys)) K) > (case K > ("j" (rotl *opts)) > ("k" (rot *opts)) > ("l" (rot (last (car *opts)))) > ("h" (rotl (last (car *opts)))) > ("i" (rot (car (last (car *opts))))) ) ) ) > > #(de insert_opt (Id X) > # (setq *opts > # (make > # (for L *opts > # (if (= Id (car L)) > # (link (place 4 L (cons X (last L)))) > # (link L) ) ) ) ) ) > > (de insert_opt (Id X) > (let L (nth (assoc Id *opts) 4) > (set L (cons X (car L))) ) ) > > (de l () > (let X (any (opt)) > (when (info X) (load X)) ) ) > > ### end of "lib-able" ez_opts, start of cards ### > > (setq *title "CARDS: ") > > (setq *opts '( > (hst 4 "hosts: " (pc fb)) > (fil 6 "files: " (de dgs paz saz)) > (sel 8 "limit: " (5 10 20 50)) > (dsp 10 "views: " ((1 2) (d_ de) (p de) (sp 1) (v de))) > (sec 12 "times: " ((-1 2) (-1 -1) (3 2) (1 1))) > (duh 14 "lkeys: " ((l) (l NIL))) > (dia 16 "sshow: " (1 2 5)) )) > > (de main NIL > (seed (time)) > (while (<> (ez_opts) *esc) ) > # cards program code removed - exit with ESC! # > (prin *ed2 "^[[1;1H") > (raw NIL) ) > > # usage: -v "4 5" (adds (4 5) to views presets) > (de v () > (let X (str (opt)) > (when (lst? X) (insert_opt 'dsp X) ) ) ) > > # usage: -f xxx (file must exist, adds to presets) > (de f () > (let X (any (opt)) > (when (info X) (insert_opt 'fil X) ) ) ) > > (load T) > (main) > (bye) > -- > UNSUBSCRIBE: mailto:email@example.com?subject=Unsubscribe -- UNSUBSCRIBE: mailto:firstname.lastname@example.org?subject=Unsubscribe