Live data from Hacker News

My Emacs Lisp book is finished

mbork.pl

31–40 of 64 posts

Re: My Emacs Lisp book is finished

#31
post #21

i have used "Writing GNU Emacs Extensions" available here: https://www.oreilly.com/library/view/writing-gnu-emacs/97814... from a long time past for elisp programming. mentioning it here in the hope that it is is useful to others as well...

Since that book is over 20 years old, is it still relevant and useful?

Yes.

Emacs takes backwards compatibility seriously. Not kernel-level seriously, but seriously.

Moreover, a book written 20 years ago was still written more than 20 years after initial Emacs release. By then, a lot of best practices were already discovered and they remain common in Elisp code to this day.

There was a lot of development in that time and many things became easier to do, but the basics of writing Elisp programs didn't change.

IMO the book is especially worth a read if you want to change your perspective: it does a really good job at showing that Emacs is, in essence, a runtime environment and a development platform akin to web browsers, with a huge stdlib of libraries and applications, and focused on mostly-text display. Next time you find yourself reaching for ncurses, stop and go for Elisp instead. You'll get the (optional) GUI and sane defaults for free, along with rich text editing functionality where needed.

Re: My Emacs Lisp book is finished

#32

Earlier quoted context omitted.

Since that book is over 20 years old, is it still relevant and useful?

Yes. Emacs takes backwards compatibility seriously. Not kernel-level seriously, but seriously. Moreover, a book written 20 years ago was still written more than 20 years after initial Emacs release. By then, a lot of best practices were already discovered and they remain common in Elisp code to this day. There was a lot of development in that time and many things became easier to do, but the basics of writing Elisp p…

Ok, thanks, good to know.

Re: My Emacs Lisp book is finished

#33
post #13

Earlier quoted context omitted.

> I have been using Emacs for quite a while, but never mastered elisp You are not alone in that boat :-)

As a developer, I find it a bit embarassing that I started using Emacs in 2000, that at some point I even read my email with it, and that I never took the time to really learn emacs-lisp. Still, some day I will. This book might help me. :)

> Still, some day I will

I said I'd lean Spanish some_day® as well, according to duolingo that was 9 years ago :-)

Re: My Emacs Lisp book is finished

#34
post #11

Elisp is a really poor language compared to almost anything else, more work should be done to allow Emacs to be configured in other languages.

> Elisp is a really poor language compared to almost anything else

What makes Elisp a "poor language" in your opinion?

Elisp is actually a really good language. Especially compared to other languages used for scripting, like Lua or JS. In some areas Elisp is significantly more advanced than either: pattern matching (pcase, dash), object orientation (multimethods, multiple inheritance), iteration (loop), data types (Lua has 3, JS a bit more, while Elisp gives you lists (pairs, proplists, assoc lists, trees), vectors, maps, unicode strings with optional metadata, queues, rings, and more. While the lack of reader macros is unfortunate, the macro system along with hooks and advice allow for writing libraries that integrate seamlessly into the environment, and ones that cleanly hide a lot of complexity (ie. use-package). Additionally, Elisp performance is not very bad (though of course worse than JITed languages) and it got AOT native compiler recently, which should help improve upon it.

Namespaces are the only lacking feature at this point. I mean, there are lots of places where Elisp could and should be improved, but it's in quite good shape already. Definitely not "really poor", especially compared to the other scripting languages.

Re: My Emacs Lisp book is finished

#36
post #15

Congratulations! As a curiosity, how did you set the page width? I find it a bit wide, making it difficult to read.

Sokolof's comment elsewhere in this thread: Intro of the book confirms: “It is written in Org-mode, first made by Carsten Dominik and then developed by many other people. Diego Zamboni wrote the Org exporter to convert Org-mode syntax to Markua, expected by Leanpub.”

So the page width probably was set by Leanpub themselves during typesetting. I am assuming that the Markua language is converted to LaTeX, with the page size/layout being set in that language.

Re: My Emacs Lisp book is finished

#37
post #13

Earlier quoted context omitted.

> I have been using Emacs for quite a while, but never mastered elisp You are not alone in that boat :-)

As a developer, I find it a bit embarassing that I started using Emacs in 2000, that at some point I even read my email with it, and that I never took the time to really learn emacs-lisp. Still, some day I will. This book might help me. :)

I'm just a devops person, not a coder by any stretch of the imagination, but I found that maintaining my .init.el in git helped me to learn enough elisp to be useful/dangerous.

I really dig that it's a full on language used for the configuration files. It just makes so much sense to do it that way. (I also like VSCode's json prefs)

Also I love sharing snippets of my .init.el:

  40   │ ;; Taken from https://karl-voit.at/2017/02/11/my-system-is-foobar/
  41   │ ;; Check if system is Darwin/macOS
  42   │ (defun my-system-type-is-darwin ()
  43   │   "Return non-nil if system is darwin-based (Mac OS X)."
  44   │   (string-equal system-type "darwin")
  45   │   )
  ...
  65   │ 
  66   │ (when (my-system-type-is-darwin)
  67   │   ;; EXAMPLE: (global-set-key (kbd "C-z") 'shell)
  68   │   ;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Init-Rebinding.html#Init-Rebinding
  69   │   (global-set-key (kbd "s-/") 'comment-or-uncomment-region-or-line)
  70   │   (global-set-key (kbd "s-") '(lambda () (interactive) (kill-line 0)))
  71   │   )

Re: My Emacs Lisp book is finished

#38

Earlier quoted context omitted.

Since that book is over 20 years old, is it still relevant and useful?

Pretty much, yes. I'm sure there's a few things that have changed, and a newer book is welcome, but Emacs hasn't really changed much in 30 years.

I don't know my Emacs timeline very well, but I'd be nervous about lexical scope and the more recent cooperative async features of Emacs (lisp) not being represented in a 20 year old book.

EDIT: Yeah, Emacs 24 had support for lexical scope, and that was in 2012. You'd be doing a disservice to yourself, IMO, to write dynamically scoped Elisp today, unless you had a specific reason. And if you don't even KNOW that lexical scoping is an option, it would be unfortunate.

Re: My Emacs Lisp book is finished

#39
post #33

Earlier quoted context omitted.

As a developer, I find it a bit embarassing that I started using Emacs in 2000, that at some point I even read my email with it, and that I never took the time to really learn emacs-lisp. Still, some day I will. This book might help me. :)

> Still, some day I will I said I'd lean Spanish some_day® as well, according to duolingo that was 9 years ago :-)

Uh... well, it would be even more embarassing to admit how long I've been telling myself that I'd start learning emacs-lisp in earnest... so I won't. :)

Re: My Emacs Lisp book is finished

#40

Earlier quoted context omitted.

As a developer, I find it a bit embarassing that I started using Emacs in 2000, that at some point I even read my email with it, and that I never took the time to really learn emacs-lisp. Still, some day I will. This book might help me. :)

I'm just a devops person, not a coder by any stretch of the imagination, but I found that maintaining my .init.el in git helped me to learn enough elisp to be useful/dangerous. I really dig that it's a full on language used for the configuration files. It just makes so much sense to do it that way. (I also like VSCode's json prefs) Also I love sharing snippets of my .init.el: 40 │ ;; Taken from https://karl-voit.at/2…

system-type is actually a symbol, so you can do (eq system-type 'darwin) for the same effect. here's my macOS section: https://github.com/bklebe/.emacs.d/blob/b0ca255032d1240942ff...
Post reply on HN