Add symbol properties to -first-item so the byte-compiler compiles
calls to the car opcode. This ensures that -first-item has the same
performance as car.
For example, given the following function:
(defun wh/call-first-item (x)
(-first-item x))
This would compile to:
byte code for wh/call-first-item:
args: (arg1)
0 constant -first-item
1 stack-ref 1
2 call 1
3 return
Whereas it now compiles to:
byte code for wh/call-first-item:
args: (arg1)
0 dup
1 car
2 return
With a symbol, only the file providing the feature triggers the
eval-after-load. With a string, any file named the same way triggers
it. This is problematic for custom configurations named after
packages.
`gv-define-simple-setter` is not defined on Emacs 23, so we need to use
the macro `defsetf` on Emacs 23. `defsetf` is not autoloaded, so we must
require 'cl before using it. We don't need to load 'cl on later Emacs
versions.
However, the whole form is macro-expanded on all Emacs versions. Emacs
24+ assumes that `(defsetf ...)` is a function call because it hasn't
loaded 'cl. This generates byte-compile warnings about unused variables
and nonexistent functions, so silence those.
Otherwise, Emacs cannot show helpful signatures, and just uses ARG1 ARG2
instead.
For example, prior to this change, `-drop` was described as:
-drop is an alias for `nthcdr' in `dash.el'.
(-drop ARG1 ARG2)
Return the tail of LIST without the first N items.
Adding the declaration (pure t) enables the byte-compiler to evaluate
calls at compile-time. Adding the declaration (side-effect-free t)
allows the byte-compiler to remove calls entirely if the result is not
used.
For functions that take a predicate as an argument, we cannot know
whether that predicate is pure, so we do not annotate those.
We also don't annotate functions that depend on `-compare-fn`, as that
may change at runtime.
Fixes#198.
Given an elisp expression of the form:
(->> (+ 1 1)
(+ 2)
(* 3)
(format "%s"))
Edebug now knows that the first argument is an expression, so users can
step through it. This is an improvement over the current situation,
where users cannot step through any part of a threaded form.
Note that this debugging behaviour matches thread-first in Emacs 25:
http://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/emacs-lisp/subr-x.el?id=emacs-25.0.95#n49
Renamed argument `list1` to `list` in description to match function signature.
Followup on pull #171 (which I incorrectly submitted against the derived documentation).
* Add -doto macro (like Clojure's doto)
Here is its documentation in clojuredocs:
(doto x & forms)
Evaluates x then calls all of the methods and functions with the
value of x supplied at the front of the given arguments. The forms
are evaluated in order. Returns x.
(doto (new java.util.HashMap) (.put "a" 1) (.put "b" 2))
Documentation:
https://clojuredocs.org/clojure.core/doto
Source (clojure):
https://github.com/clojure/clojure/blob/clojure-1.7.0/src/clj/clojure/core.clj#L3700
* Use make-symbol instead of gensym to stay consistent
Consistent with other code in dash.el
* Fix referring to rest from cl.el in -doto
* Add doto example with setcar and setcdr
* Clarify -doto docstring: eval-initial-value evalled only once
Also mention all arguments in the docstring to please checkdoc
* Make -doto documentation more in line with Emacs standards
This adds `-each-indexed` and an anaphoric variant `--each-indexed`,
equivalent to `-map-indexed`.
Whilst `--each` already defines `it-index`, it's not documented. Having
a separate version is more explicit and more discoverable because it's
similarly named to `-map-indexed`.
Fixes#175.
Hey guys.
Probably ill-advised on my part but I changed my GitHub username so if it's not too much trouble here's a PR to update the contributors section of the README