;; platform.el - annotation, scheduling and life coding platform ;; Copyright (C) 2007 Martin Howse ;; Emacs Lisp Archive Entry ;; Filename: platform.el ;; Keywords: event ;; Author: Martin Howse (m AT 1010 DOT co DOT uk) ;; Maintainer: Martin Howse (m AT 1010 DOT co DOT uk) ;; Description: event life coding package ;; URL: http://www.1010.co.uk/platform.html ;; Compatibility: Emacs20, Emacs21, Emacs22 ;; This file is not part of GNU Emacs. ;; This is free software; you can redistribute it and/or modify it under ;; the terms of the GNU General Public License as published by the Free ;; Software Foundation; either version 2, or (at your option) any later ;; version. ;; ;; This is distributed in the hope that it will be useful, but WITHOUT ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ;; for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, ;; Boston, MA 02110-1301, USA. ;; handing off between parsing and buffer AS code --- macros also ;; link system after planner mode (links to/as anchors or any form of ;; markup in files) - see org-mode and linkd ;; possible relationships: [which can also change link parties - alter ;; text of link (esp.with regard for example to version control] ;; integration with version control filesystem:: rcs. C-x v v for next ;; logical step in version control (eg. check in/out) ;; functions here to access and diff and manipulate this ;; outputs: audio (play: play xad -f u -s b -t raw -r 8000, pd pipe - also for 8 channels) ;; using split to chop files//play to process ;; piping: process-send-string process-send-region // in case below for flite (defvar *flite* (start-process "flite" nil "flite")) (defun speak-start-flite () (if (eq (process-status *flite*) 'exit) (setq *flite* (start-process "flite" nil "flite" "-l")))) (defun speak-region (start end) (interactive "r") (speak-start-flite) (process-send-region *flite* start end) (process-send-string *flite* "\n") (process-send-eof *flite*) t) (defun sneakin-speak-line () (interactive) (speak-region (line-beginning-position) (line-end-position))) (defun speaky (string) (speak-start-flite) (process-send-string *flite* string) (process-send-string *flite* "\n") (process-send-eof *flite*) t) ;; (speaky "help me please") ;; inputs: rec: rec -w wav file.wav and play (play also in nyquist) ;; pd input ;; emacs - comint and pd console output ;; pd -stderr -- send printout to standard error instead of GUI ;;// added to .pdrc and then comint-run pd -- this gives us output ;;--- look again at pd, plenum, five software acts: ;;pd: -qlist.... but to specify exactly what we want ;; text (font code- goby) and images (thumbnails and show) collect resources (require 'goby) ;;(server-start) ;; emacs server ;;(goby-make-face 0 3 0) ;; make the correct goby type face ;;(put-text-property (point-min) (point) 'face 'goby-face:0:3:0) ;; for example ;;(put-text-property (point-min) (point) 'face ' 'default) ;; regular ;; for a chosen font and: ;; (set-face-attribute face nil :foreground color)) ;; -- link structure: org-mode ;; lisp communication ;; --------------------------------------------conceptual ;; - doubling ;; - (and how differs from) mirroring /and/ symmetry ;; - enframe/frames ;; - isa (within the category of) ;; - overlay ;; - transparency/opacity - and thus to opposition ;; - embedding (spatial relations - exteriority/expulsion/laying open in the world ;; - slots and properties (eg. devices, actors, cast and so on - live process) ;; -> original kodiak.lisp > dom (sub in PAIP), rel, ind, val, and [further] each, dif, when, not, and ;; dom/sub - (sub dog animal) dog is a kind of animal ;; rel - (rel birthday animal date) birthday relation holds between animal and some date ;; ind (ind fido dog) the individual fido is categorised as a dog ;; val (val birthday fido july-1) the birthday of ind fido is july-1 ;; and (and A B) bothe A and B are true // leave rest ... ;; from kodiak.lisp : ;;Syntax: ;; (a category [inst] (rel value)*) ;;Example: ;; (a person (name (a person-name (first Joe) (last Smith))) (age old)) ;; ==> ;; (and (ind person-1 Joe) (val name person-1 person-name-1) ;; (val age person-1 old) (val first person-name-1 Joe) ;; (val last person-name-1 Smith)) ;;Syntax: ;; (each category [(isa super*)] (rel constraint)*) ;; ;; Example: ;; (each person (isa animal) (name person-name) (age integer)) ;; ==> ;; (and (dom person animal) (rel name person person-name) ;; (rel age person integer)) ;;||# ;;______ mode stuff (defvar platform-mode-hook nil "*list of functions to call on entering platform mode") (defvar platform-mode-map nil "local keymap for platform") (setq platform-mode-map nil) (if platform-mode-map nil (setq platform-mode-map (make-sparse-keymap)) (define-key platform-mode-map "K" 'next-frame)) (defun platform-mode () "annotation and performance life coding platform" (interactive) (pop-to-buffer "*platform*" nil) (kill-all-local-variables) (defvar filename nil "filename") (setq major-mode 'platform-mode) (setq mode-name "platform") (use-local-map platform-mode-map)) ;;______ helping functions (defconst number-regexp "-?\\([0-9]+\\.?\\|\\.\\)[0-9]*\\(e[0-9]+\\)?" "Regular expression for recognizing numbers.") ;; saving list to file by way of intermediate buffer - borrowed from ;; dunnet.el: http://iep.water.ca.gov/d/bin/sbin/site/lib/xemacs-19.15/lisp/games/dunnet.el (defun make-save-buffer () (switch-to-buffer (get-buffer-create "*save*")) (erase-buffer)) (defun save-this-buffer (filename) (progn (goto-char (point-min)) (write-region 1 (point-max) filename nil 1) (kill-buffer (current-buffer)))) (defun minsert (string) (if (stringp string) (insert string) (insert (prin1-to-string string)))) (defun save_a_list (listy filename) (if (file-exists-p filename) (version-control-file filename)) (make-save-buffer) (minsert "(setq evaled '") (minsert listy) (minsert ")") (save-this-buffer filename) (switch-to-buffer "*platform*")) (defun read_a_list (filename) (let (old-buffer result) (setq result t) (setq old-buffer (current-buffer)) (switch-to-buffer (get-buffer-create "*load*")) (erase-buffer) (insert-file-contents filename) (eval-current-buffer) (kill-buffer (current-buffer))) (switch-to-buffer old-buffer) evaled) ;;_____ annotations ;; annotation - according to categories. categories become links to access other annotations ;; ;; text is annotated with actions/categories/images and so on which are then re-worked and include and extend knowledge rep system ;; see annotation02.el// experiment/lifecode/annotate110907.el ;; see org-mode//linkd mode for embedding hyperlinks in lisp code ;;split-string---= string-to-list ;; markup in situ after - annotation ;; categories backtracking. linking system a la planner ;;_____ scheduling - and some interface to Common Lisp processes (SLIME) (defvar processlist nil) ;;(setq processlist nil) (defun schedule (name time repeat function &rest arg) (setq processlist (cons (cons name (run-at-time time repeat function arg)) processlist))) ;; needs make assoc list for name and then we can lookup and do cancel-timer for this (defun unschedule (name) (cancel-timer (cdr (assoc name processlist)))) (defun func() (insert "n")) ;; whatever. maybe switch to schedule buffer and print string ;;(schedule "narty" 10 10 #'func) (defun scheduletext (name time repeat text) (schedule name time repeat (lambda(x) (insert x)) text)) ;;(scheduletext 'mint 2 4 "hello") ;;(unschedule 'mint) (defun scheduleprocess (name time repeat process args) (setq processlist (cons (cons name (run-at-time time repeat (lambda(x y) (start-process x "boo" x y)) process args)) processlist))) ;;(scheduleprocess 'minty 10 nil "display" "/root/kamera/image010.jpg") ;; markup for a processlist (schedule) - do this and save ;;_____ remote access - see prmisc and httpd.el // use of test.php for entry of remote data ;; also need way for remote client to view buffers here live! (defvar remprocess nil) (defvar the_buffer nil) (defvar host nil) (defvar port nil) (defun remserv-start (&optional port) (interactive (list (read-string "Serve requests on port: " "8080"))) (if (null port) (setq port 8080) (if (stringp port) (setq port (string-to-number port)))) (if remprocess (delete-process remprocess)) (setq the_buffer (generate-new-buffer "*remote*")) (setq remprocess (make-network-process :name "prm" :buffer the_buffer :host 'local :service port :server t :noquery t :filter 'remserve))) (defun rem-stop () (interactive) (when remprocess (message "networked.el server on port %d has stopped" (cadr (process-contact remprocess))) (delete-process remprocess) (setq remprocess nil))) (defun rem-serve (proc string) (let ((remprocess proc)) (switch-to-buffer-other-window the_buffer) (print (eval (read string)) the_buffer))) ;;______image -> this is for CL version ;;(defun displays (file) ;; (system (concatenate 'string "display -geometry 640x480+200+200! " file))) ;;(displays "~/kamera/image010.jpg") (defun displays (file) (start-process "my-process" nil "/usr/bin/display" file)) ;;(displays "/root/kamera/image010.jpg") ;;?? or we use iimage mode [[http://www.netlaputa.ne.jp/~kose/Emacs/iimage.html]] C-l to re-display them As minor mode with org-mode we use ‹foo.png› syntax for images which can be embedded under headings and so on. ;;_____ video - see gneve. in and out points in markup ;; video by way of marked up mplayer code (annotation using altered ;; gneve) (defun open-film (n) (interactive "ffilename:") (setq filename n) (start-process "my-process" "boo" "/root/MPlayer-1.0rc1/mplayer" "-slave" "-quiet" n)) (defun goto-point () ;; read string at point (setq string (read (current-buffer))) (interactive) (process-send-string "my-process" (format "seek %s 2\n" string))) ;; other - image management in emacs ;; -- iimage, image-dired ;;, w3m image support also - M-x w3m-toggle-inline-images ;; Further mage code: (defun eeimage-data (fname) (with-temp-buffer (set-buffer-multibyte nil) (insert-file-contents-literally fname) (buffer-string))) (defun eeimage-set (s e fname) (add-text-properties s e `(display (image :type ,(image-type-from-file-header fname) :data ,(eeimage-data fname))))) (defun find-eimage0 (fname &optional nlines nchars &rest ignored) "Display the image given by FNAME in place of the text between point and bol. This function is meant to be used with \\[eek-eval-sexp-eol], so by default it will change the appearance of the entire current line. If NLINES is non-nil then work on that number of lines instead - e.g., 5 means change this line and the four previous ones. A non-nil value of NCHARS means to use bol+NCHARS instead of bol." (eeimage-set (point) (+ (or nchars 0) (point-at-bol (- 2 (or nlines 1)))) (ee-expand fname))) (defun ee-expand (fname) "Expand \"~\"s and \"$ENVVAR\"s in file names, but only at the beginning of the string." (cond ((string-match "^\\$\\([A-Za-z_][0-9A-Za-z_]*\\)\\(.*\\)" fname) (concat (getenv (match-string 1 fname)) (match-string 2 fname))) ((string-match "^\\(~\\([a-z][0-9a-z_]*\\)?\\)\\(/.*\\)?$" fname) (concat (expand-file-name (match-string 1 fname)) (match-string 3 fname))) (t fname))) ;;(find-eimage0 "/root/texts/1010/1010.co.uk/images/nand.gif") ;; write directly into *remote* buffer - divide up frames according to ;; action(process), annotation, remote and so on ;; _____ integration with version control filesystem:: ;; RCS. C-x v v for next logical step in version control (eg. check ;; in/out) functions here to access and diff and manipulate these ;; also markup to denote varying versions and access ;; automatic entry of comments into RCS ;;_____ audio (flite or pd pipe - also for 8 channels - see plenum) -- ;; OSC connections to PD using commandline sendOSC tools wrapped up ;; see panel.lisp ;; flite above ;; PD from panel for Common Lisp: ;;(defmacro pd-speak (body) ;; `(system (concatenate 'string "sendOSC -notypetags -h 127.0.0.1 9999 \"/test, " ,@body " \""))) ;; run as shell ;;_____ lisp communication ;;_____ resource collections (view/directory/actions) ;; ______markup for knowledge base processing (open new buffer/throw ;; in markuped buffer/save as file and process) - interface to results ;; markup into new buffer//save new buffer//save also an alist//send ;; file to be evaluated and potentially parse results (ilisp) (defun markandsave (buffer) ) ;;Syntax: ;; (a category [inst] (rel value)*) ;; ;;Example: ;; (a person (name (a person-name (first Joe) (last Smith))) (age old)) ;; ==> ;; (and (ind person-1 Joe) (val name person-1 person-name-1) ;; (val age person-1 old) (val first person-name-1 Joe) ;; (val last person-name-1 Smith)) ;; ;;Syntax: ;; (each category [(isa super*)] (rel constraint)*) ;; ;;Example: ;; (each person (isa animal) (name person-name) (age integer)) ;; ==> ;; (and (dom person animal) (rel name person person-name) ;; (rel age person integer)) ;; ;;dom/sub- categories and hierarchy (sub mirror double) ;; ;;rel- slots. (rel device actor thing) ;; ;;ind- individual example of category (ind jekyll actor) ;; ;;val- filling slot(val device jekyll bottle) ;; ;;question is of category->relationship (active). eg mirror->mirroring, double->doubling ;;making new relationship. also of the attachment to the source/annotated text ;; ;;new relation as function/action attached - process or schedule ;; category (mirror) -> function/action (on a body of text) mirroring