The first is the old library, the second is the new one.
The old one defines things like defstruct, symbol-macrolet, incf, whereas the second defines instead cl-defstruct, cl-symbol-macrolet, and cl-incf.
The old one is deprecated because it does not obey the general rule that packages should use a "package prefix" for all their definitions to try and ...
Symbols for functions and macros have a lisp-indent-function property which you can set with declare or in your case, since if is already defined, you can just use put.
You can read about the possible property values here:
M-: (info "(elisp) Indenting Macros") return
if's default setting is 2 which means the second form get's special treatment ...
Yes, this behavior is explained by differences in Variable Scoping between Emacs Lisp and Common Lisp.
In Common Lisp (a lexically scoped lisp) a lambda returned by complement you defined is turned into a closure, i.e. it captures the lexical environment that existed when it was created.
Here's what I get from SBCL:
(defun my-complement (f)
cl-case uses eql for comparisons, so string get tested for identity not for equality in the sense of string=. You can fix this by just switching to pcase (or, if you really want to use case, convert to symbols instead: match (intern mymachine) against 'HP, etc.).
What @Constantine said about lexical and dynamic scoping is true, and it explains the difference from Common Lisp behavior.
However, there is something misleading in your question. This really has nothing to do with macros. Here is a definition using defun instead of defmacro. Note that you need a quote mark (') before the use of ,function: ',function, ...
You can use indentation provided by a SLIME contribution:
You may want to add that to the list slime-contribs- see Loading Contribs in the SLIME manual.
One can add it to the list of SLIME contributions:
(add-to-list 'slime-contribs 'slime-cl-indent)
Emacs lisp is a programming language designed to be used to provide Emacs extensions and to program Emacs. Common Lisp is a programming language that was designed to be practical Lisp useful as production language. Therefore, Emacs Lisp is sometimes "a bit strange"(this may be an opinion), since you have to care about environment - Emacs - while Common Lisp ...
From the CL side the function you are looking for is swank::eval-in-emacs to which you pass a the code you want to evaluate in emacs. You can see an example here, to make emacs run the graphivz command and open the resulting png in a buffer. From the emacs side the function you are looking for is slime-eval (found in slime.el)
Emacs Lisp doesn't really have "Best Practices". Judging from all the code I've read so far, people instead go for what is most convenient for them. And given that Emacs Lisp and Common Lisp are reasonably close (both are of the Lisp-2 variety), it is no wonder either the older and unprefixed cl.el or the newer and prefixed cl-lib library are used when the ...
Not as far as I can tell, no.
I've always questioned the usefulness of having both defvar and defparameter in Common Lisp. If you don't mind, leave a comment explaining why having both forms is useful - I'm honestly interested to know. I know what they do, I just don't know why the difference is important enough for both forms to be in the standard.
In Emacs Lisp, defconst doesn't actually enforce constness, and therefore works pretty much like Common Lisp's defparameter:
it unconditionally sets the variable;
it marks it as special;
it avoids any warnings due to setting unbound variables.
Learn Emacs Lisp through the official tutorial and by customizing your Emacs environment. Being hands-on is a huge advantage when learning, and learning Emacs Lisp gives you the opportunity to apply your knowledge immediately to do useful things.
The main language difference is that Common Lisp has lexical scope by default, whereas Emacs only supports ...
Afterwards, you can use e.g.
C-c C-l (lisp-load-file) to eval a source file.
C-c C-e (lisp-eval-defun) to eval a statement.
Still, I can't imagine why someone wouldn't want to run SLIME.
I remember myself being in a similar situation some years ago. First of all, I didn't understand the relation between Emacs Lisp and ANSI Common Lisp (sometimes also referred to as simply Common Lisp, or even more ambiguously, just Lisp). I ended up learning Common Lisp and eventually writing something to help myself with ...
Perhaps, they could be called align or alignWith, as in the these Haskell package.
alignWith takes a function which decides how to combine all the variants of the non-uniform tuples (which arise after you continue when the shortest list ran out):
align :: f a -> f b -> f (These a b)
alignWith :: (These a b -> c) -> f a -> f b -> f c
I think the following should mostly do what you want
(defvar w3m-dedicated-window nil)
(defun w3m-browse-url-dedicated-window (url &optional new-session)
(let ((w3m-pop-up-windows t))
(if (and w3m-dedicated-window
(w3m-browse-url url ...
Your second version would more typically be written as a cond form:
(cond ((string= system-name "HP")
(setq package-user-dir (concat user-emacs-directory "packages/hp")))
((string= system-name "DELL")
(setq package-user-dir (concat user-emacs-directory "packages/dell")))
((string= system-name "MBP.local")
Drew's answer is correct, but it should also be mentioned that the reason cl-lib doesn't include a cl-defsetf (or cl-setf) is because the setf machinery has been moved to gv.el. The docstring of defsetf suggests gv-define-simple-setter and gv-define-setter as alternatives.
Where does it say that you're not supposed to use library cl.el? That would be silly (IMHO). The text you quote says that code distributed with GNU Emacs must not load cl at runtime. That does not say that you should not use cl.el (at runtime or any other time).
Some people don't want to load all of cl.el at runtime. That's one reason cl-lib.el was created: ...
I found, it is more appropriate to add into contribs 'slime-indentation. it will load slime-cl-indent.
And after that, you can use this code to choose required indentation style:
(setq lisp-indent-function 'common-lisp-indent-function)
(setq common-lisp-style-default "sbcl")
Available styles are: basic, classic, modern and sbcl. All of them are defined in ...
The examples I'm aware of use either XEmacs or SXEmacs (a fork of XEmacs) and their module/FFI support to extend them with C or existing C functions.
wand-mode: Combines FFI and the imagemagick library for simple image manipulation, such as red-eyes removal.
xwem: Emacs as window manager. Nuff said.
I recall Steve Youngs (the SXEmacs maintainer) speaking ...
Your problem is that the timer runs the function when the loop has finished.
The lexically bound variables index and value have for all calls the values after the last iteration.
One solution is to evaluate the variables at iteration time and pass just the values as arguments to the function.
(let ((my-list '(a b c)))
(cl-loop for index below (length my-...
The easiest way is to parametrize the call slime-eval, using funcall and a defvar/defcustom and take advantage use of sly's retro contrib, which allows the user to refer to the slynk pacage by the name of swank. Besides the replacing (slime-eval ...) with (funcall org-babel-lisp-eval-fn ...) the other thing we must do is to require slime or sly when ...
I actually use Common Lisp indent, with the Elisp indent for if. You could customize some code similar to mine:
(setq lisp-indent-function 'common-lisp-indent-function)
(put 'cl-flet 'common-lisp-indent-function
(get 'flet 'common-lisp-indent-function))
(put 'cl-labels 'common-lisp-indent-function
If you indent your code, you should end up with the following:
(ert-deftest pp-test-process-function ()
(setq dc-current-buffer "/")
(lambda (&rest params) "test"))
(should (equal (dc-test-stub-process "a" "d" "c") "test2")))))
Which should make clear that you are actually binding a ...
Another option is to use backquoting to substitute the values for each loop iteration directly into the lambda form:
;;; foo.el --- -*- lexical-binding: t; -*-
(let ((my-list '(a b c)))
(cl-loop for index below (length my-list)
for value = (seq-elt my-list index)
do (run-at-time 0 nil