воскресенье, 3 февраля 2008 г.

create executable file from lisp source (sbcl)

This is a very simple lisp file:

(print "Hello. World!")

At first, need compile this file:

:~$ sbcl --noinform
* (compile-file "helloworld.lisp" :output-file "helloworld")

; compiling file "/home/asimakov/helloworld.lisp" (written 04 FEB 2008 12:44:58 AM):
; compiling (PRINT "Hello. World!")

; /home/asimakov/helloworld.fasl written
; compilation finished in 0:00:00
#P"/home/asimakov/helloworld.fasl"
NIL
NIL
*

Next, load module binfmt_misc and mount binfmt_misc filesystem:

:~$ sudo modprobe binfmt_misc
:~$ sudo mount -t binfmt_misc none /proc/sys/fs/binfmt_misc

At last, register fasl filetype (from root of course) by the specyfing a byte pattern:

:~$ echo ":lisp:M::\x23\x20FASL::/usr/lib/sbcl/sbcl-run:" > /proc/sys/fs/binfmt_misc/register

or by extension:

:~$ echo ':lisp:E::fasl::/usr/lib/sbcl/sbcl-run:' > /proc/sys/fs/binfmt_misc/register

That's all, you can execute fasl from command line:

:~$ chmod +x helloworld.fasl ; ./helloworld.fasl
"Hello. World!"


See also:
Documentation for binfmt_misc: http://www.kernel.org/doc/Documentation/binfmt_misc.txt

среда, 28 ноября 2007 г.

read stream in sbcl

(with-open-stream (files
(sb-ext:process-output
(sb-ext:run-program "/usr/bin/cat" '("/path/to/file")
:output :stream)))
(loop :for line = (read-line files nil nil)
:while (and
(my-mega-condition-p line))
line) :do (princ line) (terpri)))

понедельник, 5 ноября 2007 г.

imap, gnus & gmail.com

~/.gnus.el

(setq user-mail-address "asimakov@gmail.com")
(setq user-full-name "Alexey Simakov")
(load-library "smtpmail")
(load-library "nnimap")
(load-library "starttls")
(setq gnus-select-method '(nnimap "imap.gmail.com"
(nnimap-address "imap.gmail.com")
(nnimap-server-port 993)
(nnimap-authinfo-file "~/.imap-authinfo")
(nnimap-stream ssl)))

(setq smtpmail-starttls-credentials '(("smtp.gmail.com" 587 nil nil))
smtpmail-smtp-server "smtp.gmail.com"
smtpmail-default-smtp-server "smtp.gmail.com"
send-mail-function 'smtpmail-send-it
message-send-mail-function 'smtpmail-send-it
smtpmail-smtp-service 587
smtpmail-auth-credentials '(("smtp.gmail.com"
587
"asimakov@gmail.com"
nil)))
(add-hook 'gnus-topic-mode-hook 'gnus-topic-mode)

~/.imap-authinfo
machine imap.gmail.com login asimakov@gmail.com password MyPassword port 993


get CA certificates and put them in ~/Mail/certs/

$ cd ~/Mail/
$ wget http://members.cox.net/mynameisdavid/archive/certificates.zip
$ unzip certificates.zip
$ mv cer certs

суббота, 28 июля 2007 г.

remote swank server, emacs & unicode

.emacs:
(add-to-list 'load-path "~/elisp/slime")
(require 'slime)
(setq slime-net-coding-system 'utf-8-unix)
(set-language-environment "utf-8")
(slime-setup)

swank.lisp:
(require 'asdf)
(asdf:oos 'asdf:load-op 'swank)
(setq swank:*use-dedicated-output-stream* nil)
(swank:create-server :coding-system "utf-8-unix")

On remote host:
$ sbcl --load swank.lisp

ssh tunnel for slime using putty:
Putty Configuration Menu->New Session->Connection->SSH->Tunnels:
Source port: 4005
Destination: localhost:4005

Putty Configuration Menu->Session:
Host name or ip: user@host-with-swank

ssh tunnel for slime using ssh:
ssh -2 -N -f -L 4005:localhost:4005 user@host-with-swank

Connect to slime:
M-x slime-connect


Links:
Emacs for Windows
SLIME