Conflicting(?) 'FORMAT' function of emacs and SBCL - emacs

I have emacs with SLIME and SBCL. And I got stuck with the problem that emacs has definition of 'FORMAT' as format string &rest objects, so at REPL when I'm trying to evaluate something like (format t "hello"), I get error: Wrong type argument: stringp, t.
Is this the case of function to be overridden? How can I make emacs to use function defined in SBCL?
Guess that it's rather simple newbie problem, but it's really hard to google for 'format' keyword :)

Emacs Lisp and Common Lisp (SBCL is an implementation of it) are two different languages; it is as if you were asking how to call Java's System.out.println from your Emacs Lisp.
Emacs Lisp is used to extend and customize the behavior or Emacs.
Common Lisp is a general purpose programming language, of which there are several implementations, SBCL being one of them. It is not related to Emacs or Emacs Lisp (except, perhaps historically and culturally).
SLIME is a tool to talk to a running Common Lisp image from inside Emacs, you must first start it with M-x slime; after you have started SLIME, you can send forms to your running Common Lisp image (SBCL in your case) within the *slime-repl sbcl* buffer.
You will find another buffer named *scratch* where you can type and evaluate Emacs Lisp forms. Just remember that this has nothing to do with Common Lisp.
But, you need to be aware that there is an Emacs Lisp extension that adds many Common Lisp constructs to Emacs Lisp, but it is still Emacs Lisp, don't get confused if you read something about that.
Yeah it may be confusing at first, but don't worry, it's only temporal.
Edit:
I would like to add that if you are interested in Common Lisp, you should read one or all of the following books:
Common Lisp: A Gentle Introduction to Symbolic Computation
Land of Lisp
Practical Common Lisp
On the other hand, if you are interested in extending and customizing Emacs itself, you should read the following book:
http://www.gnu.org/software/emacs/emacs-lisp-intro/emacs-lisp-intro.pdf
Good luck.

After some investigation I found out that SLIME init script in .emacs config file was incorrect. So, while I was using inferior-lisp, it was not SBCL. Here's the link explaining the matter: slime-devel list.
So, I changed (setq inferior-lisp-program "/some/path/to/sbcl/executable.exe") to (setq inferior-lisp-program "sbcl") in config file. And that got me to SBCL in it's perfect nature :)

Related

Emacs using Common Lisp with cl-lib.el

I have been using ELISP for a while and now I have decided to use Common Lisp using cl-lib.el extension for Emacs. The question is does cl-lib.el provide a complete CLISP extension for Emacs or it partially supports CLISP? The other question, if I include cl-lib.el in one package (I have multiple packages), does that mean the cl-lib.el will also be applied to all other packages? For example, if I have:
(load "~/elisp/file1.el") ; (require 'cl-lib.el)
(load "~/elisp/file2.el") ; does it automatically use cl-lib.el or not?
No; neither cl-lib.el nor cl.el is equivalent to Common Lisp. Not at all.
Once a library has been loaded, it is loaded. If you load file1 and it loads cl-lib, then when you later load file2, cl-lib has already been loaded. All that matters is the order of loading.
If you were hoping that cl / cl-lib would provide more of Common Lisp than they do, you may be interested in https://www.emacswiki.org/emacs/EmacsCommonLisp

common lisp help equivalent to help in python

At a python interpreter, one can simply type help("name") to visit documentation for name.
What is the equivalent in a common-lisp REPL (I am using SBCL)?
Note that I am using SLIME in emacs 24.3
Thanks in advance.
Try these:
(documentation #'cons 'function)
(documentation 'most-positive-fixnum 'variable)
(describe #'cons)
Slime also has a bunch of shortcuts for looking at things: slime-describe-symbol, slime-inspect (and if you have the hyperspec sitting around, slime-documentation-lookup) might all be useful.

Python Interpretor in Emacs, removing the input reprinting

I am quite new to Emacs.
When running Emacs' python interpretor, it does
>>> print(24)
print(24)
24
Is there a way I can prevent the re-printing of my input and make it as below?
>>> print(24)
24
Thank you so much :)
The trick here is that the buffer you're running the python process in doesn't have comint-process-echoes set.
There are a couple of other questions that are relevant to your problem.
How to turn off the echoing
How to set emacs so it always turns off echoing
But the basic gist is you need to customize the value of comint-process-echoes. If you are new to emacs, you might not know that most customizations are done using emacs lisp, where setting a variable looks something like this:
(setq variable-name new-value)
In this case, the variable we want is comint-process-echoes so the lisp we want to evaluate is:
(setq comint-process-echoes t)
Where t is lisp-speak for "true."
So, to borrow the advice of the first link above, to actually tell emacs to evaluate this lisp code, use the M-: (meta+colon) command. From the python shell buffer, type meta+colon, then type (setq comint-process-echoes t) then hit return. Your problem should be solved.

Slime autodoc while in custom REPL

I'm using SLIME and EMACS for Common LISP, with the SBCL compiler. The autodoc feature of SLIME, where function arguments are shown in the minibuffer, works fine.
But when I execute a custom REPL like the following:
(defun game-repl ()
(let ((cmd (game-read)))
(unless (eq (car cmd) 'quit)
(game-print (game-eval cmd))
(game-repl))))
The autodoc feature doesn't work anymore. Not in LISP buffers, and not in my custom REPL. Probably because the SBCL process is busy with my REPL (waiting for input) and can't communicate with SLIME.
After I start another SBCL process with C-u M-x slime, the autodoc feature works again, but only in LISP buffers.
So, is there a way to get the SLIME autodoc in my custom REPL?
I think you're correct in concluding that the swank backend (in your sbcl process) is busy. IIRC slime has both synchronous and asynchronous commands, and your game-repl would be a synchronous command that wouldn't allow the asynchronous documentation commands to get through to the backend -- in contrast, while composing a regular command in the slime REPL, the backend is idle, so doc queries can get through.
But please forgive me for also wondering whether what you're doing in this particular case makes sense -- the purpose of a custom REPL is presumably one or both of:
Expose a limited or synthetic command set
Provide non-standard control/syntax structures
and in either case, input to the custom REPL might not be equivalent to regular code that slime could auto-doc for you.
Might an option be to provide a limited "game" namespace in which you could play around in the regular slime REPL, and then also provide a separate production-oriented REPL with a reader which would only allow access to symbols in that namespace? (There's a discussion of common-lisp sandboxing here.)

Emacs modes for flex and bison, or removing auto indent for these modes?

Emacs has poor handling of auto-indentation in Flex and Bison. In fact, it seems to have no support for flex mode. So, how does an emacs user cope with these? I like VIm but I would prefer not to switch because I am much faster and more comfortable in Emacs.
I had a third party elisp module for Bison a few months ago but when its indentation broke, it would never get fixed. In short, it was a bad hack.
Or is there a way I can turn off auto indentation for .l and .y files (so pressing would do one indent)? How would I also change this elisp setting for just emacs?
A nice and concise guide for elisp would be very helpful too. I wouldn't mind spending a few days to write my own flex and bison modes if I had the right documentation.
Emacs chooses the major mode mainly based on the file name extension. .l is a contended extension: some people use it for lex, others for lisp (and there are a few other rarer uses). Emacs associates .l with lisp, and .lex with lex (for which it uses C mode).
If the .l files you work with are more often lex than lisp, you can change what .l files are associated with the following line in your .emacs:
(add-to-list 'auto-mode-alist '("\\.l\\'" . c-mode))
You can also declare inside a file what mode you want Emacs to use when it opens the file. Put the following snippet on the first line of the file (typically in a comment):
-*-mode: c-mode-*-
This is a more general feature, offering other syntaxes and other possibilities; see “File Variables” in the Emacs manual for more information.
If you would like to get started with Emacs Lisp, read the Emacs Lisp intro (which may be included in your Emacs or OS distribution). Once you've played around with the basics of the language a bit, you can turn to the chapter on modes in the Emacs Lisp reference manual.
Additional tip: You might decide that what you want is Emacs' generic behavior -- what it uses when it doesn't have any special mode for a file format. That's called Fundamental mode in emacs lingo: so you can request it on the fly with M-x fundamental-mode, or put -*- mode: fundamental -*- on the first line of the file, or customize auto-mode-alist like so:
(add-to-list 'auto-mode-alist '("\\.l\\'" . fundamental-mode))
Another thing to try might be indented-text-mode (probably with auto-fill disabled).