does clisp (Ubuntu port) has indent and parenthese completion - common-lisp

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))

Related

How to switch to ESS mode manually?

I sometimes use emacs with the "It's all text" firefox extension to write in textareas, and
sometimes I need to insert R code into the file, which is usually named something like
"stackoverflow.com.231x234.txt", which is of course triggers the text mode. How can I switch
to ESS mode manually in this case? I know I can do "M-x python-mode" for python,
but I don't what the equivalent is for ESS.
M-x R-mode should do the trick.

emacs: using mmm-mode to combine markdown-mode and ESS for editing rmarkdown files

I'm playing with mmm-mode to combine markdown-mode and ESS for editing Rmarkdown files. I'm using gnu emacs 24.3 on Windows 7 and up-to-date version of the aforementioned modes. This is what I've got in my .emacs file:
(require 'mmm-mode) ;;; possibly init with (require 'mmm-auto) instead
(mmm-add-classes
'((rmarkdown
:submode r-mode
:face mmm-declaration-submode-face
:front "^```[{]r.*[}] *$"
:back "^``` *$")))
(setq mmm-global-mode 'maybe)
(mmm-add-mode-ext-class 'markdown-mode "\\.rmd\\'" 'rmarkdown)
That works so far as within a buffer showing an rmarkdown file, R code blocks are recognized and I get proper syntactically aware font-locking within both R code blocks and markdown blocks. More, when I have the point in an R code block I get ESS and Imenu-R menus and when it's in a markdown region I get a markdown menu. So far so good.
Here are my issues. Within R code blocks electric left assignment doesn't work. I can't simply hit the underscore key to get '<-' and to toggle between that and '_'.
Also, I don't get syntactically aware auto indentation for R code.
Both of these things work when I'm using ESS to edit files containing pure R code.
Any thoughts on how to tune this up? I'm aware of this previous post from nearly a year ago: How can I use Emacs ESS mode with R markdown? and the pointer to polymode, but polymode seems to be advancing slowly. I've also seen other pointers to org-mode for similar functionality and while that's a plunge I may take at some point, today my questions are about getting the most out of the combination of mmm-mode, markdown-mode and ESS. Thanks for your help.
Polymode is the way to go. Unfortunately still in development, but works for most of the things.

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.

Adding Color Themes to Lispbox

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.

Resources