wbooze

this is my config

Sep 16th, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 29.29 KB | None | 0 0
  1. #.(declaim (optimize (safety 3) (debug 3) (space 0) (speed 0) (compilation-speed 0) (inhibit-warnings 0)))
  2.  
  3. (load "/home/oleo/common-lisp/source/asdf/build/asdf.lisp")
  4.  
  5. #- :quicklisp
  6. (defun init-quick ()
  7.   (let ((*read-eval* t))
  8.     (let ((quicklisp-init (merge-pathnames "/home/oleo/quicklisp/setup.lisp"
  9.                 (user-homedir-pathname))))
  10.       (if (probe-file quicklisp-init)
  11.     (load quicklisp-init)
  12.     (load "/home/oleo/quicklisp.lisp")))))
  13.  
  14. ;;(setq sb-ext:*evaluator-mode* :interpret)
  15.  
  16. (defun quick ()
  17.    ;;; Check for --no-linedit command-line option.
  18.   #+ :quicklisp
  19.   (if (member "--no-linedit" sb-ext:*posix-argv* :test 'equal)
  20.     (setf sb-ext:*posix-argv* (remove "--no-linedit" sb-ext:*posix-argv* :test 'equal))
  21.     (progn
  22.       (if (interactive-stream-p *standard-output*)
  23.     (require :sb-aclrepl)
  24.     (format *standard-output* "~&Not Interactive!~&"))
  25.       (if (find-package :sb-aclrepl)
  26.     (progn
  27.       (push :aclrepl cl:*features*)
  28.       (setq sb-aclrepl:*max-history* 100)
  29.       (setf (sb-aclrepl:alias "asdc") #'(lambda (sys) (asdf:operate 'asdf:compile-op sys)))
  30.       (sb-aclrepl:alias "l" (sys) (asdf:operate 'asdf:load-op sys))
  31.       (sb-aclrepl:alias "t" (sys) (asdf:operate 'asdf:test-op sys))
  32.       ;; The 1 below means that two characaters ("up") are required
  33.       (sb-aclrepl:alias ("up" 1 "Use package") (package) (use-package package))
  34.       ;; The 0 below means only the first letter ("r") is required, such as ":r base64"
  35.       (sb-aclrepl:alias ("require" 0 "Require module") (sys) (require sys)))
  36.     (setq cl:*features* (delete :aclrepl cl:*features*))))))
  37.  
  38. ;;;;;;;;;;;;;;;;;;
  39. #- :quicklisp
  40. (init-quick)
  41.  
  42. #+ :quicklisp
  43. (quick)
  44. ;;;;;;;;;;;;;;;;;;
  45. (asdf:clear-source-registry)
  46. (asdf:load-system :asdf)
  47.  
  48. #-asdf
  49. (error "You lose")
  50.  
  51. (defmethod asdf:perform :around ((o asdf:load-op)
  52.                                  (c asdf:cl-source-file))
  53.    (handler-case (call-next-method o c)
  54.       ;; If a fasl was stale, try to recompile and load (once).
  55.       (sb-ext:invalid-fasl ()
  56.          (asdf:perform (make-instance 'asdf:compile-op) c)
  57.          (when (next-method-p) (call-next-method)))))
  58.  
  59.  
  60. (asdf:initialize-source-registry
  61.  `(:source-registry
  62.    (:tree "/home/oleo/common-lisp/source/asdf/")
  63.    (:tree "/home/oleo/common-lisp/source/asdf/ext/")
  64.    (:tree "/home/oleo/source/quicklisp/software/")
  65.    (:tree "/home/oleo/source/clim-work/mcclim-0.9.7-imbolc/")
  66.    (:tree "/home/oleo/climacs-gitlab/")
  67.    (:tree "/home/oleo/prg/lisp/lisp/")
  68.    :default-registry
  69.    :inherit-configuration))
  70.  
  71. (asdf:initialize-output-translations
  72.  `(:output-translations
  73.    #.(let ((wild-subdir
  74.         (make-pathname :directory '(:relative :wild-inferiors)))
  75.        (wild-file
  76.         (make-pathname :name :wild :version :wild :type :wild)))
  77.        `((:root ,wild-subdir ,wild-file)
  78.      (:user-cache ,wild-subdir ,wild-file)))
  79.    :inherit-configuration))
  80.  
  81. (defun pds ()
  82.      (progn
  83.        (load "/home/oleo/prg/lisp/lisp/ppmx.lisp")
  84.        (load "/home/oleo/prg/lisp/lisp/dtrace.lisp")
  85.        (load "/home/oleo/prg/lisp/lisp/sdraw.lisp")))
  86.  
  87. (defun lold ()
  88.      (progn
  89.        (load "/home/oleo/prg/lisp/lisp/package.lisp")
  90.        (load "/home/oleo/prg/lisp/lisp/onlisp-util.lisp")
  91.        (load "/home/oleo/prg/lisp/lisp/onlisp-app.lisp")
  92.        (load "/home/oleo/prg/lisp/lisp/lol-working.lisp")
  93.        (load "/home/oleo/prg/lisp/lisp/generators.lisp")))
  94.  
  95. ;(defun acl2 ()
  96. ;  (load "/home/oleo/prg/lisp/lisp/acl2.lisp"))
  97.  
  98. (export 'cl-user::pds)
  99. (export 'cl-user::lold)
  100. ;(export 'cl-user::acl2)
  101.  
  102. (when (not (find-package :sb-aclrepl))
  103.   (require :sb-aclrepl))
  104.  
  105. (when (not (find-package :sb-posix))
  106.       (require :sb-posix))
  107.  
  108. (when (not (find-package :sb-bsd-sockets))
  109.   (require :sb-bsd-sockets))
  110.  
  111.  
  112. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  113.  
  114. (setf (logical-pathname-translations "norvig")
  115.   `(("norvig:**;*.*.*" "/home/oleo/prg/lisp/paip-pjb/norvig/**/*.*")))
  116.  
  117. (setq *default-pathname-defaults*
  118.   (merge-pathnames
  119.     *default-pathname-defaults*
  120.     (make-pathname :directory '(:relative "prg/lisp/paip-pjb/"))))
  121.  
  122. (in-package :cl-user)
  123.  
  124. (asdf:load-system :clx)
  125.  
  126. (in-package xlib)
  127.  
  128. (defun display-keyboard-mapping (display)
  129.   (declare (type display display))
  130.   (declare (clx-values (simple-array keysym (display-max-keycode keysyms-per-keycode))))
  131.   (setf (display-keysym-mapping display) (keyboard-mapping display)))
  132.  
  133. (in-package :cl-user)
  134.  
  135. ;;newlim-init.lisp
  136. (setq
  137.  *print-pretty* t
  138.  *print-escape* nil
  139.  *print-circle* nil
  140.  *print-right-margin* 110
  141.  *read-default-float-format* 'double-float
  142.  *readtable* (copy-readtable nil))
  143. ;;*break-on-signals* nil)
  144.  
  145. (if (not (member :rune-is-character *features*))
  146.     (push :rune-is-character *features*))
  147.  
  148. (defun compiler-policy () (funcall (lambda () (sb-ext:describe-compiler-policy))))
  149.  
  150. (defvar *last-package* nil)
  151. (defvar *cached-prompt* nil)
  152. (defvar *prompt* nil)
  153.  
  154. (defun package-prompt (stream)
  155.   (unless (eq *last-package* *package*)
  156.     (setf *cached-prompt*
  157.       (concatenate 'string (or (first (package-nicknames *package*))
  158.                    (package-name *package*))
  159.                "> "))
  160.     (setf *last-package* *package*))
  161.   (terpri)
  162.   (princ *cached-prompt* stream))
  163.  
  164. (setf sb-int:*repl-prompt-fun* #'package-prompt)
  165.  
  166. (defun date ()
  167. (progn (terpri t) (run-program "/usr/bin/date" '() :output t) (values)))
  168.  
  169. (defun datetime (&key (as-list nil) (time nil) (date nil))
  170.   (multiple-value-bind (second minute hour day month year day-of-week dst-p tz)
  171.       (get-decoded-time)
  172.     (let* ((day-names
  173.             '("Monday" "Tuesday" "Wednesday"
  174.               "Thursday" "Friday" "Saturday"
  175.               "Sunday"))
  176.            (now (format nil "~2,'0d:~2,'0d:~2,'0d" hour minute second))
  177.            (today (format nil "~a, ~2,'0d.~2,'0d.~d, GMT~@d" (nth day-of-week day-names) day month year (- tz)))
  178.            (result
  179.             (format nil "time: ~2,'0d:~2,'0d:~2,'0d~%date: ~a, ~2,'0d.~2,'0d.~d, GMT~@d" hour minute second
  180.                     (nth day-of-week day-names) day month year (- tz))))
  181.       (cond (as-list
  182.              (multiple-value-list
  183.               (with-input-from-string (s result) (values (intern (read-line s)) (intern (read-line s))))))
  184.             (time now)
  185.             (date today)
  186.             (t
  187.              (with-input-from-string (s result) (values (intern (read-line s)) (intern (read-line s)))))))))
  188.  
  189. (asdf:load-system :alexandria)
  190. (asdf:load-system :bordeaux-threads)
  191. (asdf:load-system :fiveam)
  192. (asdf:load-system :cl-fad)
  193. (asdf:load-system :trivial-garbage)
  194. (asdf:load-system :spatial-trees)
  195. (asdf:load-system :flexichain)
  196. (asdf:load-system :opticl)
  197. (asdf:load-system :mcclim)
  198. (asdf:load-system :mcclim-clx)
  199. (asdf:load-system :clouseau)
  200. (asdf:load-system :clim-debugger)
  201. (asdf:load-system :clim-listener)
  202. (asdf:load-system :climacs)
  203.  
  204. (defun my-climacs ()
  205.   (load "/home/oleo/quicklisp/local-projects/climacs/packages.lisp")
  206.   (load "/home/oleo/quicklisp/local-projects/climacs/text-syntax.lisp")
  207.   (load "/home/oleo/quicklisp/local-projects/climacs/typeout.lisp")
  208.  
  209.   (load "/home/oleo/quicklisp/local-projects/climacs/gui.lisp")
  210.   (load "/home/oleo/quicklisp/local-projects/climacs/core.lisp")
  211.   (load "/home/oleo/quicklisp/local-projects/climacs/groups.lisp")
  212.   (load "/home/oleo/quicklisp/local-projects/climacs/io.lisp")
  213.  
  214.   (load "/home/oleo/quicklisp/local-projects/climacs/developer-commands.lisp")
  215.  
  216.   (load "/home/oleo/quicklisp/local-projects/climacs/climacs-lisp-syntax.lisp")
  217.   (load "/home/oleo/quicklisp/local-projects/climacs/misc-commands.lisp")
  218.   (load "/home/oleo/quicklisp/local-projects/climacs/climacs-lisp-syntax-commands.lisp")
  219.   (load "/home/oleo/quicklisp/local-projects/climacs/structured-editing.lisp")
  220.  
  221.   (load "/home/oleo/quicklisp/local-projects/climacs/search-commands.lisp")
  222.   (load "/home/oleo/quicklisp/local-projects/climacs/window-commands.lisp")
  223.   (load "/home/oleo/quicklisp/local-projects/climacs/file-commands.lisp")
  224.   (load "/home/oleo/quicklisp/local-projects/climacs/climacs.lisp"))
  225.  
  226. (in-package :clim-user)
  227.  
  228. (setq
  229.   *print-pretty* t
  230.   *print-escape* nil
  231.   *print-circle* nil
  232.   *print-right-margin* 110
  233.   *read-default-float-format* 'double-float
  234.   *readtable* (copy-readtable nil))
  235. ;;*break-on-signals* nil)
  236.  
  237. (defun dohash (table)
  238.   (let (result)
  239.     (maphash (lambda (k v) (push (list k v) result)) table)
  240.     (nreverse result)))
  241.  
  242. (defun nil-as-list ()
  243.   (set-pprint-dispatch
  244.     '(eql nil)
  245.     (lambda (srm el)
  246.       (cond
  247.        ((null (cdr el))
  248.     (format srm "()"))
  249.        (t
  250.     (pprint-fill srm el t))))
  251.     2))
  252.  
  253. (defun remove-nil-as-list ()
  254.   (let*
  255.     ((*print-pretty* nil)
  256.       (dispatch-table (slot-value *print-pprint-dispatch* 'sb-pretty::entries)))
  257.     (dolist (x dispatch-table)
  258.       (cond
  259.     ((equal '(eql ()) (slot-value x 'sb-pretty::type))
  260.       (setf (slot-value *print-pprint-dispatch* 'sb-pretty::entries)
  261.         (remove x dispatch-table)))))))
  262.  
  263. (defun pprint-dispatch-entries (&optional p)
  264.   (let*
  265.       ((*print-pretty* nil)
  266.        (dispatch-table (slot-value *print-pprint-dispatch* 'sb-pretty::entries)))
  267.     (if p
  268.         (dolist (x dispatch-table)
  269.           (print x))
  270.         dispatch-table)))
  271.  
  272. (defun pprint-dispatch-cons-entries ()
  273.   (let*
  274.     ((*print-pretty* nil)
  275.       (dispatch-table (slot-value *print-pprint-dispatch* 'sb-pretty::cons-entries)))
  276.     (loop for key being the hash-keys of dispatch-table
  277.       using (hash-value value)
  278.       collect (list key value))))
  279.  
  280. (defun pprint-dispatch-find (term) ;; (pprint-dispatch-find '(eql ())) after (nil-as-list) for example
  281.   (let*
  282.     ((*print-pretty* nil)
  283.       (dispatch-table (slot-value *print-pprint-dispatch* 'sb-pretty::entries)))
  284.     (dolist (x dispatch-table)
  285.       (cond
  286.         ((equal term (slot-value x 'sb-pretty::type))
  287.          (return
  288.           (values :entry x
  289.                   :type (slot-value x 'sb-pretty::type)
  290.                   :priority (slot-value x 'sb-pretty::priority)
  291.                   :function (slot-value x 'sb-pretty::fun))))))))
  292.  
  293. (defun pprint-dispatch-cons-find (term)
  294.   (let* ((*print-pretty* nil) (dispatch-table (slot-value *print-pprint-dispatch* 'sb-pretty::cons-entries)))
  295.     (labels ((dohash (table)
  296.                (let (result)
  297.                  (maphash (lambda (k v) (push (list k v) result)) table)
  298.                  (nreverse result))))
  299.       (dolist (x (dohash dispatch-table))
  300.         (cond
  301.          ((equal term (first x))
  302.           (return
  303.            (values :entry x
  304.                    :type (slot-value (second x) 'type)
  305.                    :function (slot-value (second x) 'sb-pretty::fun)
  306.                    :priority (slot-value (second x) 'sb-pretty::priority)))))))))
  307.  
  308. (defun pprint-dispatch-remove-quote ()
  309.   (let ((dispatch-table (slot-value *print-pprint-dispatch* (quote sb-pretty::cons-entries))))
  310.     (loop for key being the hash-keys of dispatch-table using (hash-value hash-value)
  311.       collect (if (equal (quote (cons (eql quote))) (slot-value hash-value (quote type)))
  312.         (remhash key dispatch-table)))))
  313.  
  314.  
  315. (defun remove-from-pprint-dispatch (term)
  316.   (let ((dispatch-table (slot-value *print-pprint-dispatch* (quote sb-pretty::cons-entries))))
  317.     (loop for key being the hash-keys of dispatch-table using (hash-value hash-value)
  318.       collect (if (equal term (slot-value hash-value (quote type)))
  319.         (remhash key dispatch-table)))))
  320.  
  321. (defmacro do-hash ((key-var val-var hash-expr &optional result-form) &body body)
  322.   (let ((hash-var (gensym "HASH-")))
  323.     `(loop with ,hash-var = ,hash-expr
  324.        for ,key-var being the hash-keys of ,hash-var
  325.        for ,val-var being the hash-values of ,hash-var
  326.        do (progn ,@body)
  327.        finally (return ,result-form))))
  328.  
  329. ;;; usage like...
  330. ;;;(do-hash (k v table (dohash table))
  331. ;;;  (terpri)
  332. ;;;  #+:clim
  333. ;;;  (with-drawing-options (t :text-size 16 :text-face :bold)
  334. ;;    (format t "key: ~s, value: ~s" k v)))
  335.  
  336.  
  337. ;; don't forget if you want your 'a stuff to expand to (quote a) properly set *print-pretty* to nil (disable)
  338. ;; else lookups are made via the pprint dispatch tables and the pprinter has its own ways of printing stuff!
  339. ;; especially don't forget to disable it when using/defining macro character functions!
  340. ;; else expansions might not be the same as expected which will confuse just more....
  341. ;; http://www.lispworks.com/documentation/HyperSpec/Body/22_ab.htm
  342.  
  343. ;;;; and tho *print-pretty* is a special var disabling/enabling it from the listener won't affect it's value
  344. ;;;; in the sbcl repl! (threads ?)
  345. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;,;;;;;;;;;;;;;;;;;
  346.  
  347.  
  348. (defun current-view (&optional (pane-name *standard-output*))
  349.   (funcall
  350.     (lambda ()
  351.       (stream-default-view pane-name))))
  352.  
  353. (defun current-frame-name (&optional (frame *application-frame*))
  354.   (funcall
  355.     (lambda ()
  356.       (or
  357.     (type-of frame)
  358.     (slot-value frame 'climi::name)))))
  359.  
  360. (defun current-frame (&optional (frame *application-frame*))
  361.   (funcall
  362.     (lambda ()
  363.       (slot-value (frame-top-level-sheet frame) 'climi::frame))))
  364.  
  365. (defun current-frame-class (&optional (frame *application-frame*))
  366.   (funcall
  367.     (lambda ()
  368.       (class-of frame))))
  369.  
  370. (defun current-frame-class-description ()
  371.   (funcall
  372.     (lambda ()
  373.       (describe (current-frame-class)))))
  374.  
  375. (defun current-frame-instance (&optional (frame *application-frame*))
  376.   (funcall
  377.     (lambda ()
  378.       frame)))
  379.  
  380. (defun current-frame-instance-description ()
  381.   (funcall
  382.     (lambda ()
  383.       (describe (current-frame-instance)))))
  384.  
  385. (defun current-frame-panes (&optional (frame *application-frame*))
  386.   (funcall
  387.     (lambda ()
  388.       (slot-value frame 'climi::named-panes))))
  389.  
  390. (defun current-frame-layouts (&optional (frame *application-frame*))
  391.   (funcall
  392.     (lambda ()
  393.       (slot-value frame 'climi::layouts))))
  394.  
  395. (defun current-frame-layout (&optional (frame *application-frame*))
  396.   (funcall
  397.     (lambda ()
  398.       (slot-value frame 'climi::current-layout))))
  399.  
  400. (defun current-frame-layout-panes (&optional (frame *application-frame*))
  401.   (funcall
  402.     (lambda ()
  403.       (slot-value frame 'climi::panes-for-layout))))
  404.  
  405. ;;(defparameter *default-font-family-name* "-*-unifont-*-*-*-*-*-180-*-*-*-*-iso10646-1")
  406. (defparameter *default-font-family-name* "-*-dejavu sans mono-bold-r-normal-*-*-180-*-*-*-*-iso10646-1")
  407. ;;  (setq *default-font-family-name* (climi::make-text-style "misc-fixed" "medium-r" 18))
  408.  
  409. (defun update-map-for-face-with-name (map family name)
  410.   (let ((current-face (getf map family)))
  411.     (unless current-face
  412.       (error "family ~A not found!" family))
  413.     (substitute `(,name ,@(cdr current-face)) current-face map)))
  414.  
  415. (defun set-fix ()
  416.   (let ((*default-font-family-name* "-*-unifont-*-*-*-*-*-180-*-*-*-*-iso10646-1"))
  417.     (setf clim-clx::*clx-text-family+face-map*
  418.       (clim-user::update-map-for-face-with-name
  419.     clim-clx::*clx-text-family+face-map* :fix clim-user::*default-font-family-name*))))
  420.  
  421. ;#+nil
  422.  
  423. (defmethod asdf:perform :around ((o asdf:load-op) (c (eql (asdf:find-system :mcclim-clx))))
  424.   `(defmethod initialize-instance :around ((port ,(intern "CLX-PORT" :clim-clx)) &rest args)
  425.      (setf (symbol-value (intern "*CLX-TEXT-FAMILY+FACE-MAP*" :clim-clx))
  426.        (update-map-for-face-with-name
  427.         (symbol-value (intern "*CLX-TEXT-FAMILY+FACE-MAP*" :clim-clx))
  428.         :fix clim-user::*default-font-family-name* :large))
  429.      (sleep 0.01)
  430.      (when (next-method-p) (apply #'call-next-method port args))))
  431.  
  432. (in-package :cl-user)
  433.  
  434. (defun print-thread-info ()
  435.       (let* ((curr-thread (bt:current-thread))
  436.              (curr-thread-name (bt:thread-name curr-thread))
  437.              (all-threads (bt:all-threads)))
  438.         (format t "Current thread: ~a~%~%" curr-thread)
  439.         (format t "Current thread name: ~a~%~%" curr-thread-name)
  440.         (format t "All threads:~% ~{~a~%~}~%" all-threads))
  441.       nil)
  442.  
  443. (eval-when (:compile-toplevel :load-toplevel :execute)
  444.   (defun thread-list ()
  445.     (funcall
  446.       (let ()
  447.     (lambda ()
  448.       (sb-thread:list-all-threads)))))
  449.  
  450.   (defun current-threads ()
  451.     (let ()
  452.       (funcall
  453.       (lambda () (thread-list)))))
  454.  
  455.   (setf (symbol-value 'thread-list) (funcall (symbol-function 'thread-list)))
  456.   (setf (symbol-value 'current-threads) (current-threads))
  457.  
  458.   (defun kill-first-of ()
  459.     (sb-thread:terminate-thread (first (sb-thread:list-all-threads))))
  460.  
  461.   (defun kill-last-of ()
  462.     (sb-thread:terminate-thread (first (last (sb-thread:list-all-threads)))))
  463.  
  464.   (defun kill-nth-of (n)
  465.     (sb-thread:terminate-thread (nth n (sb-thread:list-all-threads)))))
  466.  
  467. (defun kill-listener ()
  468.   (let ((thread-list (sb-thread:list-all-threads)))
  469.     (dolist (x thread-list)
  470.       (cond ((equal "Listener" (sb-thread:thread-name x))
  471.           (sb-thread:terminate-thread x))))))
  472.  
  473. (defun kill-maxima ()
  474.   (let ((thread-list (sb-thread:list-all-threads)))
  475.     (dolist (x thread-list)
  476.       (cond ((equal "Maxima Listener" (sb-thread:thread-name x))
  477.           (sb-thread:terminate-thread x))))))
  478.  
  479. (defun kill-climacs ()
  480.   (let ((thread-list (sb-thread:list-all-threads)))
  481.     (dolist (x thread-list)
  482.       (cond ((equal (or "Climacs-RV" "Climacs") (sb-thread:thread-name x))
  483.           (sb-thread:terminate-thread x))))))
  484.  
  485. (defun kill-beirc ()
  486.   (let ((thread-list (sb-thread:list-all-threads)))
  487.     (dolist (x thread-list)
  488.       (cond ((equal "BEIRC GUI process" (sb-thread:thread-name x))
  489.           (sb-thread:terminate-thread x))))))
  490.  
  491. (defun kill-beirc-ticker ()
  492. (let ((thread-list (sb-thread:list-all-threads)))
  493.     (dolist (x thread-list)
  494.       (cond ((equal "Beirc Ticker" (sb-thread:thread-name x))
  495.           (sb-thread:terminate-thread x))))))
  496.  
  497. (defun kill-irc-message-muffling-loop ()
  498.   (let ((thread-list (sb-thread:list-all-threads)))
  499.     (dolist (x thread-list)
  500.       (cond ((equal "IRC Message Muffling Loop" (sb-thread:thread-name x))
  501.           (sb-thread:terminate-thread x))))))
  502.  
  503. (defun kill-closure ()
  504.   (let ((thread-list (sb-thread:list-all-threads)))
  505.     (dolist (x thread-list)
  506.       (cond ((equal "Closure" (sb-thread:thread-name x))
  507.           (sb-thread:terminate-thread x))))))
  508.  
  509.  
  510. (defun ucs-insert (&optional character (count 1))
  511.   "given a character returns the unicode symbol or reads input and then returns the symbol"
  512.  
  513.   (if character
  514.     (let ((result (or (string (code-char character)) (string character))))
  515.       (progn
  516.         (dotimes (i count)
  517.       (format t "~s" result))))
  518.  
  519.     (progn
  520.       (let* (
  521.           (character (read-char))
  522.           (result (or (string character) (string (code-char character)))))
  523.     (dotimes (i count)
  524.       (format t "~s" result))))))
  525.  
  526. (defun ascii-table ()
  527.   (let ((i -1))
  528.     (format t "~&ASCII characters 32 thru 127.~&~%")
  529.     (format t "   Dec  Hex  Char         |   Dec  Hex   Char         |   Dec  Hex   Char         |   Dec  Hex   Char~%")
  530.     (loop while (< i 31) do
  531.       (princ (format nil "~4d ~4x    ~12s | ~4d ~4x    ~12s | ~4d ~4x    ~12s | ~4d ~4x    ~12s~%"
  532.            (setq i (+ 33  i)) i (code-char i)
  533.            (setq i (+ 32 i)) i (code-char i)
  534.            (setq i (+ 32 i)) i (code-char i)
  535.            (setq i (+ 1 i)) i (code-char i)))
  536.       (setq i (- i 95)))) (values))
  537.  
  538. (defun ascii-table-s ()
  539.   (let ((i -1))
  540.     (format t "~&ASCII characters 32 thru 127.~&~%")
  541.     (format t "   Dec  Hex  Char         |   Dec  Hex   Char         |   Dec  Hex   Char         |   Dec  Hex   Char~%")
  542.     (loop while (< i 31) do
  543.       (princ (format nil "~4d ~4x    ~12s | ~4d ~4x    ~12s | ~4d ~4x    ~12s | ~4d ~4x    ~12s~%"
  544.            (setq i (+ 33  i)) i (string (code-char i))
  545.            (setq i (+ 32 i)) i (string (code-char i))
  546.            (setq i (+ 32 i)) i (string (code-char i))
  547.            (setq i (+ 1 i)) i (string (code-char i))))
  548.       (setq i (- i 95)))) (values))
  549.  
  550. (defun extended-table ()
  551.   (let ((i 128))
  552.     (format t "~&extended ASCII characters (unicode) 128 thru 256.~&~%")
  553.     (format t " Dec   Hex   Char  |  Dec   Hex   Char~%")
  554.     (loop while (< i 256) do
  555.       (princ (format nil "~4d ~4x ~50s  |  ~4d ~4x ~50s~%"
  556.            i i (code-char i)
  557.            (incf i) i (code-char i)))
  558.       (incf i))) (values))
  559.  
  560. (defun extended-table-s ()
  561.   (let ((i 128))
  562.     (format t "~&extended ascii characters (unicode) 128 thru 256.~&~%")
  563.     (format t " dec   hex   char  |  dec   hex   char~%")
  564.     (loop while (< i 256)
  565.       do (princ
  566.        (format nil "~4d ~4x ~50s  |  ~4d ~4x ~50s~%"
  567.          i i (string (code-char i))
  568.          (incf i) i (string (code-char i))))
  569.       (incf i))) (values))
  570.  
  571. (defun ucs-codes-t (start row col) ;; terminal version
  572.   (let ((x start) (somechars nil))
  573.     (do ((i 1 (1+ i)))
  574.       ((> i row))
  575.       (terpri)
  576.       (do ((j 1 (1+ j)))
  577.     ((> j col))
  578.     (format t "~s " (string (code-char x)))
  579.     (incf x)))))
  580.  
  581. (defun ucs-codes-tl (start row col) ;; terminal-list version
  582.   (let ((x start) (somechars nil))
  583.     (do ((i 1 (1+ i)))
  584.       ((> i row))
  585.       (do ((j 1 (1+ j)))
  586.     ((> j col))
  587.     (setq somechars (append somechars (list (string (code-char x)))))
  588.     (incf x))) somechars))
  589.  
  590. (defun change-directory (pathname)
  591.   "Ensure that the current directory seen by RUN-PROGRAM has changed, and update *default-pathname-defaults*"
  592.   #+CMU (unix:unix-chdir (namestring pathname))
  593.   #+scl (unix:unix-chdir (ext:unix-namestring pathname))
  594.   #+clisp (ext:cd pathname)
  595.   #+sbcl (sb-posix:chdir (pathname (namestring pathname)))
  596.   (setf *default-pathname-defaults* (pathname (namestring pathname))))
  597.  
  598. (defun list-dir (pathname)
  599.   ;; (list-dir '/home/oleo) for example
  600.   (loop for f in
  601.     (directory (make-pathname :directory (string-downcase pathname) :name :wild :type :wild))
  602.     collect f))
  603.  
  604. (defun print-dir (pathname)
  605.   ;; (print-directory '/home/oleo) for example
  606.   (loop for f in
  607.     (directory (make-pathname :directory (string-downcase pathname) :name :wild :type :wild))
  608.     do (print f)))
  609.  
  610. (in-package :clim-user)
  611. #+asdf
  612. #+clim
  613. (asdf:load-system :clim-examples)
  614.  
  615. (defun clim-demos ()
  616.    (clim-sys:make-process
  617.     (lambda () (clim-demo:demodemo)) :name "clim-examples"))
  618.  
  619. (in-package :clim-listener)
  620.  
  621.  
  622. (setf drei-lisp-syntax::+bold-face-drawing-options+
  623.       (drei:make-drawing-options :face (drei:make-face :ink +dark-goldenrod+ :style (climi::make-text-style nil :bold nil))))
  624. ;(setf drei::+default-drawing-options+
  625. ;      (drei:make-drawing-options :face (drei:make-face :ink +red+ :style (clim:make-text-style nil :bold nil))))
  626.  
  627. #+:asdf
  628. (asdf:oos 'asdf:load-op :functional-geometry)
  629.  
  630. (defmethod read-frame-command ((frame listener) &key (stream *standard-input*))  
  631.   "Specialized for the listener, read a lisp form to eval, or a command."
  632.   (multiple-value-bind (object type)
  633.       (let ((*command-dispatchers* '(#\,)))
  634.         (with-text-style (stream (make-text-style :fix nil :very-large))
  635.           (accept 'command-or-form :stream stream :prompt nil
  636.                   :default "hello" :default-type 'empty-input)))
  637.     (cond
  638.       ((presentation-subtypep type 'empty-input)
  639.        ;; Do nothing.
  640.        `(com-eval (values)))
  641.       ((presentation-subtypep type 'command) object)
  642.       (t `(com-eval ,object)))))
  643.  
  644.  
  645. (defun print-listener-prompt (stream frame)
  646.   (declare (ignore frame))
  647.   (with-text-style (stream (climi::make-text-style :fix :bold :very-large))
  648.   (with-output-as-presentation (stream *package* 'package :single-box t)
  649.     (print-package-name stream))
  650.   (princ "> " stream)
  651.   (let ((h (- (bounding-rectangle-height (stream-output-history stream))
  652.               (bounding-rectangle-height (or (pane-viewport stream) stream)))))
  653.     (scroll-extent stream 0 (max 0 h)))))
  654.  
  655. (define-application-frame listener (standard-application-frame)
  656.     ((system-command-reader :accessor system-command-reader
  657.                 :initarg :system-command-reader
  658.                 :initform t))
  659.     (:panes (interactor-container
  660.              (make-clim-stream-pane
  661.               :type 'listener-interactor-pane
  662.           :background +gray10+
  663.           :foreground +wheat4+
  664.           :width 1200
  665.           :height 768
  666.           :text-margin 1200
  667.               :name 'interactor :scroll-bars :both
  668.               :end-of-line-action :wrap
  669.           :end-of-page-action :scroll
  670.               :default-view +listener-view+))
  671.             (doc :pointer-documentation :default-view +listener-pointer-documentation-view+
  672.          :end-of-line-action :wrap :end-of-page-action :wrap :scroll-bars :both)
  673.             (wholine (make-pane 'wholine-pane
  674.                                 :display-function 'display-wholine :scroll-bars nil
  675.                                 :display-time :command-loop :end-of-page-action :wrap :end-of-line-action :wrap)))
  676.   (:top-level (default-frame-top-level :prompt 'print-listener-prompt))
  677.   (:command-table (listener
  678.                    :inherit-from (application-commands
  679.                                   lisp-commands
  680.                                   asdf-commands
  681.                                   filesystem-commands
  682.                                   show-commands)
  683.                    :menu (("Listener"   :menu application-commands)
  684.                           ("Lisp"       :menu lisp-commands)
  685.                           ("Filesystem" :menu filesystem-commands)
  686.                           ("Show"       :menu show-commands))))
  687.   (:disabled-commands com-pop-directory com-drop-directory com-swap-directory)
  688.   (:menu-bar t)
  689.   (:layouts (default
  690.           (vertically ()
  691.                 interactor-container
  692.                 (1/6 doc)
  693.                 wholine))))
  694.  
  695. (defun run-listener (&key (new-process nil)
  696.                           (debugger t)
  697.                           (width 1200)
  698.                           (height 768)
  699.                           port
  700.                           frame-manager
  701.               (text-margin 1200)
  702.               (end-of-line-action :wrap)
  703.               (end-of-page-action :wrap)
  704.                           (process-name "Listener")
  705.                           (package :clim-user))
  706.   (let* ((fm (or frame-manager (find-frame-manager :port (or port (find-port)))))
  707.          (frame (make-application-frame 'listener
  708.                     :frame-manager fm
  709.                     :width width
  710.                     :height height
  711.                     :text-margin text-margin
  712.                     :end-of-line-action end-of-line-action
  713.                     :end-of-page-action end-of-page-action))
  714.      (climi::*default-text-style* (climi::make-text-style :fix :roman :very-large)))
  715.     (flet ((run ()
  716.         (let ((*package* (find-package package)))
  717.           (unwind-protect
  718.               (if debugger
  719.               (clim-debugger:with-debugger () (run-frame-top-level frame))
  720.                         (run-frame-top-level frame))
  721.             (disown-frame fm frame)))))
  722.       (if new-process
  723.           (values (clim-sys:make-process #'run :name process-name)
  724.               frame)
  725.         (run)))))
  726.  
  727. (defmethod frame-standard-output ((frame listener))
  728.   (get-frame-pane frame 'interactor))
  729.  
  730.  
  731. (in-package :cl-user)
  732.  
  733. (setf climacs-gui::*climacs-text-style* (climi::make-text-style :fix :bold :very-large))
  734.  
  735. (defun clme ()
  736.   (unwind-protect
  737.       (sb-sys:without-interrupts                     
  738.        (sb-sys:with-local-interrupts   
  739.     (values
  740.      (sleep 0.01)
  741.      (let ((climacs-gui::*default-external-format* 'utf-8)
  742.            (climacs-gui::*climacs-text-style* (climi::make-text-style :fix :roman :very-large)))
  743.        (climacs:climacs-rv :new-process t :width 1500 :height 768))
  744.        (sleep 0.01))))))
  745.  
  746. #+clim
  747. (defun clmi ()
  748.   (unwind-protect
  749.       (sb-sys:without-interrupts                     
  750.        (sb-sys:with-local-interrupts   
  751.     (values
  752.      (sleep 0.01)
  753.      (let ((*debugger-hook* #'clim-debugger:debugger)
  754.            (*invoke-debugger-hook* #'clim-debugger:debugger)
  755.            (climi::*default-text-style* (climi::make-text-style :fix :roman :very-large))
  756.            (*trace-output* *standard-output*))
  757.        (clim-listener:run-listener :new-process t :width 1500 :height 768))
  758.        (sleep 0.01))))))
  759.  
  760. #+clim
  761. (defun clm ()
  762.   (sb-thread:release-foreground (clmi))
  763.   (sb-thread:release-foreground (clme)))
  764.  
  765. (defun next-epsi (epsi) (/ epsi 2))
  766.  
  767. (defun epsi-sig-single-p (epsi) (> (+ 1.0f0 epsi) 1.0f0))
  768. (defun epsi-sig-double-p (epsi) (> (+ 1.0d0 epsi) 1.0d0))
  769.  
  770. (defun is-epsi-single-p (epsi)
  771.   (and (epsi-sig-single-p epsi)
  772.     (not (epsi-sig-single-p (next-epsi epsi)))))
  773.  
  774. (defun is-epsi-double-p (epsi)
  775.   (and (epsi-sig-double-p epsi)
  776.     (not (epsi-sig-double-p (next-epsi epsi)))))
  777.  
  778. (defun find-epsi-single (&OPTIONAL (epsi 1.0f0))
  779.   (if (is-epsi-single-p epsi)  ; if the next epsi candidate isn't significant
  780.     epsi  ; we have found epsilon
  781.     (find-epsi-single (next-epsi epsi)))) ; otherwise, go smaller
  782.  
  783. (defun find-epsi-double (&OPTIONAL (epsi 1.0d0))
  784.   (if (is-epsi-double-p epsi)  ; if the next epsi candidate isn't significant
  785.     epsi  ; we have found epsilon
  786.     (find-epsi-double (next-epsi epsi)))) ; otherwise, go smaller
  787.  
  788. (in-package :cl-user)
  789.  
  790. (let ()
  791. (format t "~% machine-epsilon-single: ~a ~% machine-epsilon-double: ~a ~% epsi-sig-single-p? ~a ~% epsi-sig-double-p? ~a ~%"(find-epsi-single) (find-epsi-double) (epsi-sig-single-p (find-epsi-single)) (epsi-sig-double-p (find-epsi-double))) (values))
  792.  
  793. (let ()
  794. (terpri t)
  795. (let () (format t "Happy lisping!~%") (values))
  796. ;;(write-char #\Newline t) ;;is identical to (terpri t)
  797. (terpri t)
  798. (let () (format t "Machine: ~a~&" (machine-version)) (values))
  799. (let () (format t "OS: ~a ~a~&" (software-type) (software-version)) (values))
  800. (let () (format t "Host: ~a~&" (machine-instance)) (values))
  801. (let () (format t "Implementation: ~a~&" (lisp-implementation-type)) (values))
  802. (let () (format t "Type: ~a~&" (machine-type)) (values))
  803. (let () (format t "Version: ~a~&" (lisp-implementation-version)) (values))
  804. (terpri t)
  805. (let () (format t "Time: ~a Date: ~a" (datetime :time t) (datetime :date t)) (values))
  806. (terpri)
  807. (values))
  808.  
  809. (clm)
  810.  
Add Comment
Please, Sign In to add comment