Emacs using Common Lisp with cl-lib.el - emacs

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

Related

how do I jump to a function definition in emacs when using slime?

I have installed slime using https://github.com/thephoeron/slime-pack and want to explore the common-lisp a bit more.
How do I access the source for a particular function in emacs?
for example, if I have a function:
(type-of 1)
and I want to visit the source of type-of, how can this be done?
Meta .
It calls the function: slime-edit-definition
For jumping to functions inside your lisp implementation you may need to do something extra to point to the sources. In SBCL you have to sb-ext:set-sbcl-source-location to the correct place in .sbclrc:
(sb-ext:set-sbcl-source-location "/path/to/sbcl/")
You can edit .sbclrc with C-xC-f ~/.sbclrc in Emacs.

Autocompletion with Emacs and tags

Hi I work on a very large and complex C code base (complex not in a good way). The codebase dwarfs the linux kernel to give you an idea. I have set up emacs to do most of what I want. I get autocompletion on functions and variables but there are certain things which do not work (omni-completion).
I use cedet v2, xgtags, auto-complete, yastnippet, cscope and a few other tools all of which are installed via el-get on emacs-24. When I work on a smaller project, omni-completion in C works so I would get a list of the members of a struct when I access the object. However, in the very large "project", omni-completion does not work when accessing a struct. As I said, I get completion on functions and variables but not on structures.
My explanation is that auto-completion is using its parser which cannot handle the size and complexity of the codebase. However, gtags or etags can handle it.
Is there a way to make auto-complete look into the gtags (xgtags) database? My gtags are working very well indeed.
EDIT:
I am not an admin on my system and I cannot install packages easily. At the moment, I do not have clang. Having said that, I am quite capable of compiling from source and can get many packages this way.
Using clang+automplete is also an option:
http://truongtx.me/2013/03/06/emacs-ccpp-autocomplete-with-clang/
Edit: I see you've edited the question indicating you have no clang. I leave this answer here regardless, in case someone else finds it useful.
Have you tried ac-source-gtags that is comes together with auto-complete package? You can also combine several sources, like described in documentation...
I have found that cedet is really underwhelming.
I would recommend using just one tool which does everything
https://github.com/Andersbakken/rtags
It underlines errors as you type as well as using smart completions. Just add this to your init file after obtaining the required emacs packages
(require 'rtags)
(require 'popup)
(require 'rtags-ac)
(setq rtags-completions-enabled t)
(rtags-enable-standard-keybindings c-mode-base-map)
(add-hook 'c++-mode-hook
(lambda ()
(setq ac-sources '(ac-source-rtags)
)))

The major mode name of emacs-lisp

I want to load emacs init files faster, so I use the 'eval-after-load.
For example, when I load clojure file, I just put
(eval-after-load 'clojure-mode
'do-something)
It works.
But when I try
(eval-after-load 'emacs-lisp-mode
'do-something)
It doesn't work. I wonder to know the right major mode name of emacs-lisp.
Thanks.
Please read the documentation of eval-after-load:
eval-after-load LIBRARY FORM
This function arranges to evaluate form at the end of loading the file LIBRARY, each time LIBRARY is loaded. If LIBRARY is already loaded, it evaluates form right away. Don't forget to quote form!
[…] LIBRARY can also be a feature (i.e., a symbol), in which case form is evaluated at the end of any file where (provide LIBRARY) is called.
You have to pass the name of the file or library, which defines the major mode, as argument.
While some modes are defined in files of the same name (e.g. clojure-mode in clojure-mode.el), many files a different name, especially if the actually define multiple major modes.
emacs-lisp-mode is defined in lisp-mode.el, along with some other modes for Emacs Lisp editing (e.g. lisp-mode as a generic Lisp language mode, or lisp-interaction-mode for *scratch* buffers).
Hence, use (eval-after-load 'lisp-mode …)
Also, you have to give a single sexp as second argument, so you'll likely want to use (eval-after-load 'lisp-mode '(do-something)), to call the function do-something.
If you are using a snapshot build of Emacs, use with-eval-after-load, i.e. (with-eval-after-load 'lisp-mode (do-something)). It allows for more than a single form, and doesn't require quoting.
Just eval with M-: the variable major-mode. It actually is emacs-lisp-mode.
Note that *scratch* is actually in lisp-interaction-mode.
As to what you're trying to do, use (eval-after-load "lisp-mode").
As explained by #lunaryom, the arg passed to eval-after-load is not a function name but a feature name, which is basically a file name. So you need to find the name of the file from which the function is loaded.
We could provide a feature like eval-after-defun, and indeed it might be a good idea to do so. If you'd like such a thing, ask for it via M-x report-emacs-bug.

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

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

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