EMACS 25.1 + SLIME on Windows 10

Here is my Lisp Development Environment setup on Windows 10:

  1. Clozure Lisp http://ccl.clozure.com/
    Unzip the Windows Zip ftp://ftp.clozure.com/pub/release/1.11/ccl-1.11-windows.zip
    Add the Lisp path to PATH variable.
  2. EMACS 25.1
    Unzip the Windows 64 binaries emacs-25.1-x86_64-w64-mingw32.zip and run bin/runemacs.exe
  3. QuickLisp
    Download the QuickLisp lisp files https://beta.quicklisp.org/quicklisp.lisp
    Run

    wx86cl64.exe -load <path to quicklisp.lisp>
  4. SLIME
    Open your emacs configuration file in EmacsCTRL+X CTRL+F -then-> ~/.emacsThen insert following entries to enable MELPA repository

    (when (>= emacs-major-version 24)
     (require 'package)
     (add-to-list
     'package-archives
     '("melpa" . "http://melpa.org/packages/")
     t)
     (package-initialize))

    Now restart Emacs. After restart type  ALT+X and type

    package-install RET slime

    Then set following values in Emacs configuration file (“~/.emacs”)

    ;;; Lisp - SLIME
    
    (setq inferior-lisp-program "C:/ccl-1.11-windows/wx86cl64.exe")
    
    (setq slime-contribs '(slime-fancy))

    Now on restart of Emacs, when I type CTRL+X slime I get following SLIME prompt

screenshot-13

Enjoying Lisp + Emacs

Advertisements

Learning Lisp

Yesterday, I happen to read a comic based Lisp tutorial at www.lisperati.com. It was fun to go through the tutorial which very easily introduces to Lisp and creates a Text-based adventure game in Lisp.

After playing the game, I build up my first Emacs Lisp function to restart the game.

 

Restart function in Emacs Lisp

(defun restart ()
        (progn
         (setq object-locations
           (remove-if (lambda (x)
             (eq 'body (second x)))
              object-locations))
         (look)))

Explanations:
On line two I have used progn function, that takes a list of forms to execute and returns the result of last form execution. In this function, I have two forms, first one to clear from object-locations the user inventory i.e. items picked in the play. The second form starts the game with look function

To reset user inventory, I have used remove-if function to clear from object-locations list all items that belongs to user body and then set the result list back to object-locations. Even though this is not pure Functional programming, it is step towards it as instead of modifying the existing list, a list is created by filtering and assigned as new object-locations list.

Happy Lisping.

Emacs – 101

I have recently developed interest in learning Emacs editor. I have been learning Functional Programming languages like Haskell and lately Erlang and was looking for Editor/IDE for them. IntelliJ Idea have plugins for these languages but the IDE is very heavy. So came to Emacs and am learning it. Particularly like the idea that every thing can be done with keyboard shortcut so no need to move hands between mouse and keyboards.

A bit of warning for faint hearts, don’t try emacs as quick learning. It has steep learning curve.

I have started with basic navigation commands like (these are for WINDOWS) :

CTRL+c CTRL+f : Open a file

Move in file :

CTRL+f : move forward one character (RIGHT key)

CTRL+b : move back one character (LEFT key)

CTRL+n : move down on next line (DOWN key)

CTRL+p : move up on previous line (UP key)

CTRL+a : Move to the beginning of the lines (Home key)

CTRL+e : Move to the end of the lines (End key)

ALT+f : Move forward one word

ALT+b : Move backward one word

Other navigation:

ALT+r : Moves to center most line of window

ALT+< : Move to top of the buffer

ALT+> : Move to end of the buffer

CTRL+v : PageDown key

ALT+v : PageUp key

 

The other good feature is Org-mode. For beginners found the tutorial at http://orgmode.org/worg/org-tutorials/org4beginners.html

What is Org-mode?

From the website orgmode.org :

“Org mode is for keeping notes, maintaining TODO lists, planning projects, and authoring documents with a fast and effective plain-text system.”

The  Org-Babel model can be use to write Literate Programming Documents.

More to come…