Adding a bit of Clojure's sugar to Elisp22 Jan 2015
I just wanted to highlight my latest submission to emacs-devel.
Here's an excerpt from the Clojure reader docs
Anonymous function literal (
(fn [args] (...))
where args are determined by the presence of argument literals taking the form
%is a synonym for
%ndesignates the nth arg (1-based), and
%&designates a rest arg. This is not a replacement for
fn- idiomatic used would be for very short one-off mapping/filter fns and the like.
#()forms cannot be nested.
What the patch does
It makes it possible to write this in Elisp:
(mapc #(put % 'disabled nil) '(upcase-region downcase-region narrow-to-region))
You can also do this and other things that you would expect, if you're familiar with Clojure:
(cl-mapcar #(concat %1 " are " %2) '("roses" "violets") '("red" "blue")) ;; => ("roses are red" "violets are blue")
Or you could replace this snippet from
(mapcar (lambda (x) (and (member (car x) matchers) (nth 1 x))) org-latex-regexps)
with this sugar-coated code:
(mapcar #(and (member (car %) matchers) (nth 1 %)) org-latex-regexps)
I hope that this gets accepted, although there are some conservative people that protest against this change. Let me know if you would like to have this option for your Elisp setups. And remember that you can try out the patch if you're familiar with building Emacs from source.