emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Marcin Borkowski <mbork@mbork.pl>
To: Tim Cross <theophilusx@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: From macros to elisp programming?
Date: Tue, 07 Dec 2021 10:30:17 +0100	[thread overview]
Message-ID: <877dcgn4nq.fsf@mbork.pl> (raw)
In-Reply-To: <875ys1ba9n.fsf@gmail.com>

On 2021-12-06, at 23:10, Tim Cross <theophilusx@gmail.com> wrote:

> It is difficult to recommend resources as a lot depends on your own
> experience, what level you want to dive into and what you want to be
> able to do. There is a big difference in knowing enough emacs lisp to
> tweak your Emacs configuration and knowing enough emacs lisp to write
> the next great package. The good news is that there are some great free
> resources out there, so the main investment will be in time.


> If you have not yet read it, a good starting point is Mastering Emacs by
> Mickey Petersen  https://www.masteringemacs.org/

Agreed, though AFAIR it doesn't talk about coding in Elisp, only /using/

> There is also an Introduction to Emacs Lisp, which is part of the GNU
> Emacs distribution.

I second that.  It is a great book for beginners.

> For getting to understand lisp programming at a much deeper level, there
> are some excellent resources out there, many of which are free. The
> trick is to not limit yourself to searching just for Emacs lisp. Emacs
> lisp is a dialect of lisp - a domain specific language for an editor if
> you like. Most of the concepts associated with lisp are applicable to
> emacs lisp. almost any resource teaching lisp will teach you things
> applicable to emacs lisp. Therefore, if you really want to learn how to
> program in emacs lisp, search for resources on learning to program in
> lisp.

On the other hand, Elisp has quite a few quirks which make it stand
out.  These mare mainly related to the fact that Emacs is a text editor
and not an interpreter for a general-purpose language.  Things like
point, windows, buffers, using buffers to process text (as opposed to
strings in 99% langauges), buffer-local variables, advice system...

> There is a somewhat famous book called 'The Structure and Interpretation
> of Computer Programs" (SCIP), which is based on a course in computer
> science taught at MIT. It is an excellent book. Even better, videos from
> the course are also available on-line. While the focus is on
> programming, it uses a lisp dialect to demonstrate the core principals,
> which it makes very clear. A must watch for anyone really keen to
> understand programming.

+100.  Those videos are great (the book is more in-depth, though).

> Another great book about lisp which is also freely available is Paul
> Graham's 'On Lisp', which I think gives a pretty good overview of the
> power and flexibility of lisp and functional programming. 

Yes, though it it way more advanced - I probably wouldn't give it to
a beginner.

> A book which I really like and which I think really shows off the power
> of lisp macros is Doug Hoyte's "Let over Lambda". Not only does this book
> show the wonderful power and possibilities of macros, it also shows some
> of the dangers and pitfalls. However, it is pretty hard core computer
> science focused and can take some effort to really digest. 

Also, one can go a really long way /without/ macros.  I'd argue that the
main reason a beginning Elisper should learn the basics of (Elisp)
macros is to be able to (roughly) understand what is going on when s/he
sees them in other people's code.

> If you really want to learn emacs lisp, there is really only one route
> you can take - sit down and start using it to write simple programs to
> solve some basic problems. Maybe you would like to automate some of what
> you do or maybe you would like to modify how Emacs does something or
> maybe you want to create a new command to do something. Open a new
> window and start trying to implement your idea. You will run into road
> blocks and you will often be frustrated, but eventually the penny will
> drop. The other big advantage is that when you run into problems, you
> will have concrete issues which you can take to a forum for help. It is
> much easier for people to help with something concrete than something
> more vague or conceptual. The only real way to learn is to do - if you
> want to learn emacs lisp, you need to use emacs lisp to solve
> problems.

Again, very solid advice.  Though for some people at least some guidance
may be valuable.  One example would be "Writing GNU Emacs Extensions" by
Bob Glickstein.  It is fairly old, but from what I heard most of it
should be still relevant.  Word of caution: I'm not sure I'd agree with
Glickstein's selection of topics.  For example, he writes about writing
major modes or autoloading.  The former is IMO not very useful unless
you are doing something /extremely/ atypical.  The latter is very
advanced (and not really essential for 99.99% or even 100% use-cases),
and by the time the learner /needs/ it, s/he will be advanced enough to
learn it from the GNU Emacs Lisp Reference Manual anyway.

Speaking of which, it also an excellent resource not to be overlooked -
and it comes with Emacs itself.

Another thing I'd like to add here is that asking on this list is
usually a good idea.  I learned a lot (and I'm still learning a lot)
just by reading emails here.

Other resources I'd mention are:
- Emacs source code (though it is very complicated in some places...)
- source code of various packages
- Emacs blogs (https://planet.emacslife.com/)


Marcin Borkowski

  reply	other threads:[~2021-12-07  9:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-06 13:42 From macros to elisp programming? Ypo
2021-12-06 18:08 ` András Simonyi
2021-12-06 18:58   ` Ypo
2021-12-06 22:10 ` Tim Cross
2021-12-07  9:30   ` Marcin Borkowski [this message]
2021-12-07  2:11 ` Eduardo Ochs
2021-12-07 12:55   ` Ypo
2021-12-07 15:16     ` Eduardo Ochs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877dcgn4nq.fsf@mbork.pl \
    --to=mbork@mbork.pl \
    --cc=emacs-orgmode@gnu.org \
    --cc=theophilusx@gmail.com \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).