Showing posts with label lisp. Show all posts
Showing posts with label lisp. Show all posts

Monday, December 16, 2013

Setup CLFSWM

This article is based on my previous post "Setup Common Lisp Environment". Please read that first if you have not.
For me, one way to learn a new language is to use it frequently. To learn common lisp, I try to use clfswm (Common Lisp FullScreen Window Manager: http://common-lisp.net/project/clfswm/) in one of my machine. It is written/configured with common lisp.
I use quick lisp to install clfswm as follow:
* (qlsetup)
* (ql:quickload "clfswm")
Gnome is my primary desktop now, to continue use gnome applications in clfswm, I add a .xsession file as follow in my home directory:
#!/bin/bash

# log for debugging, quite useful if you make some mistake in your configuration
exec &> $HOME/.clfswm.log

gnome-settings-daemon &
eval `gnome-keyring-daemon`
nm-applet &
# or some other panel application, I mainly use it for systray support
fbpanel &
# some applications I used everyday, so I start up them along with login
gnome-terminal &
emacs &

# to setup background, you can select other applications for it too
feh --bg-center /usr/share/wallpapers/joy/contents/images/1366x768.png
exec sbcl --noinform --no-userinit --no-sysinit --eval "(require :asdf)" \
    --eval "(require :clfswm)" --eval "(clfswm:main)" --quit
To adapt clfswm to my habit (mostly based on gnome), I customized clfswm a little via .clfswmrc. I changed fbpanel a little for clfswm too. Details will be in following posts.
In fact, I still have several issues with my clfswm, this prevents me to use it as my primary window manager in my laptop.

  • Sometimes modal dialog will make a frame "frozen" after covered by other window, that is, no reaction for hot key. I need to click another frame and back to the frame to switch to the modal dialog.
  • I do not find real full screen support. Some software need real full screen to display a full screen "edge menu" (such as virtualbox). Or maybe software thinks it is in full screen mode, I just can not activate the "edge menu".

Thursday, December 5, 2013

Setup Common Lisp Environment

Debian is my main Linux distribution, so usually it is an easy task to setup some programming language development and usage environment. At first, it looks like before for common lisp. I installed sbcl deb package according to the recommendation from cliki (http://www.cliki.net/).

 # apt-get install sbcl sbcl-doc 
 
Then I installed slime and several common lisp deb packages. But clfswm deb package does not work. And I found quicklisp provide much more common lisp systems than debian and it is actively maintained. So I decide to use quicklisp for all common lisp systems, only use sbcl deb package.
It is very easy to install quicklisp (from http://www.quicklisp.org/beta/).

 $ curl -O http://beta.quicklisp.org/quicklisp.lisp
 $ sbcl --load quicklisp.lisp
 * (quicklisp-quickstart:install)
 * (ql:add-to-init-file) 
 
Then you can use (ql:system-apropos) to search systems and install them with (ql:quickload "xxx"). But quicklisp take too long to initialize, so I put quicklisp initialize code in $HOME/.sbclrc into a function (qlsetup) and call it only when I want to install something with quicklisp. To make systems installed with quicklisp avaiable without quicklisp initialization. I add quicklisp software directory into asdf search path. Create a file named $HOME/.config/common-lisp/source-registry.conf.d/33-quicklisp.conf, its contents is:

 (:tree (:home #p"quicklisp/dists/quicklisp/software")) 
 
Then install and configure slime (from https://github.com/quicklisp/quicklisp-slime-helper),

 * (qlsetup) * (ql:quickload "quicklisp-slime-helper") 
 
Add the following to $HOME/.emacs

 (load (expand-file-name "~/quicklisp/slime-helper.el"))
 (setq inferior-lisp-program "sbcl") 
 
Then install hyperspec

 # apt-get install hyperspec 
 

Tuesday, December 3, 2013

Try to use Lisp As My Second Language

Linux kernel programming is my job, so C is my first language. But C is not high level enough for some work such as generating a HTML report from a git repository. So I use python as my second language.
Now I think about using lisp as my second language. Because
  • It is high level enough.
  • It has some interesting features like macro. It is said I can build my own mini-language with it.
  • I want to learn meta-programming and compiler. Lisp macro can be a start point of them.
  • I love Emacs, I need lisp to customize my Emacs.
The two main lisp dialects now are scheme and common lisp. I have learn something about basic scheme (without macro) and common lisp macro (through "On Lisp"). I will start with common lisp, because from google, it seems to be more practical than scheme, which is considered somewhat academic style.