Adding Color Themes to Lispbox - common-lisp

I'm new to using Common Lisp and currently using Lispbox.
I would like to add a color-theme package to Lispbox running on OSX to change the color theme.
I'm currently trying to use the command:
(add-to-list 'load-path "~/desktop/colortheme/")
However I keep getting the same error:
Undefined function ADD-TO-LIST called with arguments (LOAD-PATH "/desktop/colortheme/").
Can someone please help me as to what to do from here?
Thanks in advance,
Cameron

As far as I know, Lispbox is simply a preconfigured bundle of Emacs, Slime, and Clozure CL. I think that you might be confusing the Emacs Lisp and the Common Lisp parts of that bundle. You need to put the snippet you showed into the Emacs Lisp part, i.e. (to get that configuration at startup) the .emacs configuration file. The REPL, that is, the CL-USER > prompt, is the Common Lisp interface and has nothing to do with Emacs' inner workings.

Related

Using Swank functions in a library

I use SLIME/SBCL/Emacs and Quicklisp on Ubuntu Raring. I have the function defined below. I would like to add to my Lisp library's top .lisp file, i.e., the one every other one depends on, so that I can use it in all the functions I write with my library by just adding (update-swank) to a function instead of having to add the entire function below to each piece of code that uses it.
(defun update-swank ()
"Grabs SWANK connections and tells it to handle requests.
Call this every loop in the main loop of your program"
(continuable
(let ((connection (or swank::*emacs-connection*
(swank::default-connection))))
(when connection
(swank::handle-requests connection t)))))
When I do this and restart emacs, loading my library in the process because I have the asdf:load-op in my .sbclrc file, I get a
READ error during COMPILE-FILE:
;
; Package SWANK does not exist.
in inferior lisp, and SLIME is stuck polling because the library doesn't load because in my current setup SLIME/SBCL doesn't know what swank is at the time the .lisp file that update-swank is in is loaded. I tried adding (in-package :swank) to the file that update-swank is in, but got
The name "SWANK" does not designate any package.
in inferior lisp when my library is loaded at emacs startup.
I searched through CEPL (where i got update-swank from https://github.com/cbaggers/cepl/blob/master/cepl-utils.lisp) and then copied what the creator of CEPL did and exported the function in my packages.lisp. I made sure the function was added like he did on line 20 of cepl-utils here https://github.com/cbaggers/cepl/blob/master/cepl-utils.lisp......I load my library btw with
(asdf:operate 'asdf:load-op :cl-test)
(in-package #:cl-test)
in my .sbclrc file which i assume is loaded before my .emacs file loads slime at emacs start up (i have (slime) in my .emacs file) ...I just tested removing the adsf:load-op and in-package and from my .sbclrc and running the asdf:load-op after slime/swank has been loaded and what i've been trying to do here worked with no error....but i would like to be able load my library automatically at emacs startup and the way i usually do that is by adding the asdf:load-op to my .sbclrc....If someone could tell me another way to load my library automatically at emacs startup after swank has been loaded that would answer this ?
If there is not a package defined in a running Lisp, then this package can't be used. First you need to define the package and then you can read symbols from that package. Packages are not created when CL tries to read a symbol from an unknown package.
If (find-package "FOO") returns NIL, then you can not read a symbol like FOO::BAR.
Two solutions to that are:
execute the package definition before a symbol from that package is read
remove the symbols from the source code:
Example:
foo::*bar*
replace with
(symbol-value (find-symbol "*BAR*" "FOO"))
Above finds the symbol at runtime and retrieves the symbol value.
Also:
(foo::bar :baz t)
replace with
(funcall (symbol-function (find-symbol "BAR" "FOO")) :baz t)
Above finds the symbol at runtime, retrieves the function and calls it.
This was made to sit inside the main loop of the game/realtime-demo as that was what was blocking the repl from updating. Luckily we are in control of the loop so that is easy. Now you are wanting to use this in your library (probably with opencv) so you need to identify what is blocking the update, this is generally some kind of 'main loop' if you have access to the main loop then call update-swank from in there.
If the main loop is being controlled by a foreign library then perhaps you can put it in a function that gets called every 'loop'. All you really need is it to be called often enough that the repl feels responsive.
Other than that you can try changing the settings of swank to run on a separate thread though I have no experience doing that so I cant tell you how well that would work.
You can see it inside the main loop in the (run-demo) function of this example
Also I talk about it in this video. Though albeit perhaps not in enough detail :)
The fact you are getting "swank does not exist" is very odd. It suggest that swank is not loaded, but if you are using slime then swank must be there!
p.s. Remember that this is for use with Slime or Slim, which means you are using them with emacs or vim. If you are not using Slime+emacs or Slim+vim this function will not work!
[EDIT]
Ok so I duplicated your issue by putting (ql:quickload :cepl) at the end of quicklisp's setup.lisp file. This gave me the 'Package SWANK does not exist'. One quick way to address this is to specify swank as a dependency in your project's asd file. So for example:
(asdf:defsystem #:cepl
:serial t
:depends-on (#:cl-opengl
#:swank ;;<---HERE
#:lbm-sdl
#:varjo
#:cl-utilities
#:cl-ppcre
#:symbol-munger
#:classimp
#:temporary-file
#:md5)
:components ((:file "package")
(:file "maths/base-maths")
(:file "base-macros")
;; (:file "base-lispbuilder")
(:file "cepl-utils")
Hope it helps :)

r-autoyas in Emacs

I am trying to get r-autoyas to work on Emacs 23.3.1
I have installed yasnippet and it works fine on its own. For eg: TAB after 'for' in c++ mode auto expands as it should. I then went on the get r-autoyas to work. I have followed the instructions given in the github repository but am unable to get the TAB to expand even inbuilt functions in an R buffer.
If I type, rnorm( and then press TAB, a minibuffer opens which shows me the various arguments to the functions. Is this the default behavior? Or should it fill in the input arguments as default and let me change them one by one?
I searched online to see if anyone else had come across this problem. In one forum, it was mentioned that it could be because of the auto-completion feature in Emacs.
I have the following lines in my init.el file which were given in the instructions:
(require 'r-autoyas)
(add-hook 'ess-mode-hook 'r-autoyas-ess-activate)
(add-hook 'ess-mode 'yas/minor-mode-on)
You need to add your own yasnippets for ESS/R for any yasnippet expansion to work. By default there are none.
The behavior you are seeing when you type rnorm(<TAB> has nothing to do with yasnippet, this is behavior that ESS provides to make your R-coding-life easier.
So -- you will have to create your own snippets for R. You need to do this under the text-mode/ess-mode directory wherever your yasnippets are located (you'll have to create the ess-mode directory).
Here are some of my R snippets. I thought I'd use them more, but I only really ever use the setGeneric and setMethod snippets ... and those aren't all that bullet proof, either.

does clisp (Ubuntu port) has indent and parenthese completion

clisp interpreter come from Ubuntu package is very good with readline, editing single line of code is easy. Though work it with Slime most time it make me think if it's possible to get auto-indent and parentheses flashing/completion in clisp interpreter itself.
EDIT:
(ED "FILE.NAME.LISP") can call system editor, and start editing, the results will not AUTO loaded into the REPL.
clisp does flash back to matching paren as long as you stay on a single line. This limitation stems from readline which provides the feature.
clisp does not auto-indent on console.
the editor does not auto-load the edited file because your edit might be unsuccessful; you should try to compile the file first to uncover the errors.
EDIT: (ED "FILE.NAME.LISP") can call system editor, and start editing,
the results will not AUTO loaded into the REPL.
You can easily write a function that will call up your editor then load the file when you're done with it.
Something like this in your .clisprc.lisp, for example:
(defun edit-load-file (filename)
(ed filename)
(load filename))

A variable becomes undefined after referencing it in a defun

Hello good people of stackoverflow, I am having a weird problem while following Adam Peterson's Lisp for the Web tutorial. The problem in question is probably a problem with Clozure CL, however I just wanted to provide some background.
What's happening is simple. I declare the variable *games* by doing (defvar *games* '()). When I declare a function that references this variable, such as game-from-name, the compiler just yells at me undeclared free variable *games*.
Does anyone know why this is happening?
You could be executing in a different package. Try examining the value of the *in-package* variable at the points where you define and access the variable to check which package is current. You use the in-package macro to set the current package.

Emacs autocomplete-mode extension for ESS and R

Is there an R-extension to Emacs autocomplete-mode that can be used with ESS?
If the extension doesn't exist I'd also appreciate any hints for writing one!
There is an ac-source for R here. I recall struggling with it and finally wrote my own which at that time was much faster, but buggy since I didn't manage to make prefix regexp work properly.
EDIT: the newest ESS (only svn currently) has out-of-the-box integration with auto-complete. I have added the instructions to the wiki.
auto-complete-acr is auto-complete sources.
it is more useful than ac-R.
add to .emacs below.
(require ‘auto-complete)
(require ‘auto-complete-acr)

Resources