What a great question! Here is the path I've taken:
Step 0: Read the Emacs Tutorial
Read the Emacs Tutorial before anything else. It sounds like you've done this. Good on ya! However, for anyone coming to this at a later time, this is the place to start your Emacs journey. There are a lot of misleading blog posts out there. They over complicate ...
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 ...
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 ...
In my experience, the included tutorial on Emacs Lisp was not too helpful (I tried twice over the years and failed). Instead, I finally used the included Emacs Lisp Reference.
What finally did work:
Realize that there are two aspects to Emacs Lisp: The basic language itself, and the interaction with Emacs. Separate these two in your mind. Focus first on ...
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.).
I recommend the "Emacs Lisp Intro".
The "Emacs Lisp Intro" might be already available in info format within your Emacs. Try C-h i m Emacs Lisp Intro RET or evaluate (info "(eintr) Top") in Emacs.
If this fails search the web for "Emacs Lisp Intro".
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 ...
Start with the Emacs Wiki page Learn Emacs Lisp.
Not that that page itself will teach you Emacs Lisp. It will instead point to learning resources -- exactly what you're looking for here, with your question. Many users have contributed to it and edited it over a period of years. That presents advantages as well as disadvantages wrt one user's blog. 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.
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
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 ...
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 ...
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.
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: ...
As a refresher on Lisp I highly recommend the first three chapters of Peter Norvigs Paradigms of Artificial Intelligence Programming. Those give you a great and fast pace (re)introduction to Lisp which will get you back on track quickly.
For total noobs there is COMMON LISP: A Gentle Introduction to Symbolic Computation which teaches you the same concepts ...
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 ...