fordon_greeman / voidfiles

Branch: 2079ec5
Switch branches/tags
main
theidioticdev add emacs 2079ec5 21h ago
56 lines · 2 KB Raw Blame History
1 This package implements a macro named `##', which provides a compact way
2 to write short `lambda' expressions.
3
4 The signature of the macro is (## FN &rest BODY) and it expands to a
5 `lambda' expression, which calls the function FN with the arguments BODY
6 and returns the value of that. The arguments of the `lambda' expression
7 are derived from symbols found in BODY.
8
9 Each symbol from `%1' through `%9', which appears in an unquoted part
10 of BODY, specifies a mandatory argument. Each symbol from `&1' through
11 `&9', which appears in an unquoted part of BODY, specifies an optional
12 argument. The symbol `&*' specifies extra (`&rest') arguments.
13
14 The shorter symbol `%' can be used instead of `%1', but using both in
15 the same expression is not allowed. Likewise `&' can be used instead
16 of `&1'. These shorthands are not recognized in function position.
17
18 To support binding forms that use a vector as VARLIST (such as `-let'
19 from the `dash' package), argument symbols are also detected inside of
20 vectors.
21
22 The space between `##' and FN can be omitted because `##' is read-syntax
23 for the symbol whose name is the empty string. If you prefer you can
24 place a space there anyway, and if you prefer to not use this somewhat
25 magical symbol at all, you can instead use the alternative name `llama'.
26
27 Instead of:
28
29 (lambda (a &optional _ c &rest d)
30 (foo a (bar c) d))
31
32 you can use this macro and write:
33
34 (##foo %1 (bar &3) &*)
35
36 which expands to:
37
38 (lambda (%1 &optional _&2 &3 &rest &*)
39 (foo %1 (bar &3) &*))
40
41 Unused trailing arguments and mandatory unused arguments at the border
42 between mandatory and optional arguments are also supported:
43
44 (##list %1 _%3 &5 _&6)
45
46 becomes:
47
48 (lambda (%1 _%2 _%3 &optional _&4 &5 _&6)
49 (list %1 &5))
50
51 Note how `_%3' and `_&6' are removed from the body, because their names
52 begin with an underscore. Also note that `_&4' is optional, unlike the
53 explicitly specified `_%3'.
54
55 Consider enabling `llama-fontify-mode' to highlight `##' and its
56 special arguments.