[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash ca3eea7 070/426: Fix examples-to-docs to support d
From: |
Phillip Lord |
Subject: |
[elpa] externals/dash ca3eea7 070/426: Fix examples-to-docs to support documenting macros. |
Date: |
Tue, 04 Aug 2015 19:36:46 +0000 |
branch: externals/dash
commit ca3eea79592713b03af808704839895a1235e4b9
Author: Magnar Sveen <address@hidden>
Commit: Magnar Sveen <address@hidden>
Fix examples-to-docs to support documenting macros.
---
README.md | 32 +++++++++++++++++++++++++++++++-
examples-to-docs.el | 18 ++++++++++++++----
2 files changed, 45 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index 5885998..d8081dc 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@ The startings of a modern list api for Emacs. No 'cl required.
## Installation
-It's available on [marmalade](http://marmalade-repo.org/):
+It's available on [marmalade](http://marmalade-repo.org/) and
[Melpa](http://melpa.milkbox.net/):
M-x package-install bang
@@ -23,6 +23,8 @@ Or you can just dump `bang.el` in your load path somewhere.
* [!first](#first-fn-list) `(fn list)`
* [!partial](#partial-fn-rest-args) `(fn &rest args)`
* [!rpartial](#rpartial-fn-rest-args) `(fn &rest args)`
+* [!->](#x-optional-form-rest-more) `(x &optional form &rest more)`
+* [!->>](#x-form-rest-more) `(x form &rest more)`
* [!difference](#difference-list-list2) `(list list2)`
* [!intersection](#intersection-list-list2) `(list list2)`
* [!distinct](#distinct-list) `(list)`
@@ -188,11 +190,39 @@ and returns a fn that takes a variable number of
additional `args`.
When called, the returned function calls `fn` with the additional
args first and then `args`.
+Requires Emacs 24 or higher.
+
```cl
(funcall (!rpartial '- 5) 8) ;; => 3
(funcall (!rpartial '- 5 2) 10) ;; => 3
```
+### !-> `(x &optional form &rest more)`
+
+Threads the expr through the forms. Inserts `x` as the second
+item in the first form, making a list of it if it is not a list
+already. If there are more forms, inserts the first form as the
+second item in second form, etc.
+
+```cl
+(!-> "Abc") ;; => "Abc"
+(!-> "Abc" (concat "def")) ;; => "Abcdef"
+(!-> "Abc" (concat "def") (concat "ghi")) ;; => "Abcdefghi"
+```
+
+### !->> `(x form &rest more)`
+
+Threads the expr through the forms. Inserts `x` as the last item
+in the first form, making a list of it if it is not a list
+already. If there are more forms, inserts the first form as the
+last item in second form, etc.
+
+```cl
+(!->> "Abc" (concat "def")) ;; => "defAbc"
+(!->> "Abc" (concat "def") (concat "ghi")) ;; => "ghidefAbc"
+(!->> 5 (- 8)) ;; => 3
+```
+
### !difference `(list list2)`
Return a new list with only the members of `list` that are not in `list2`.
diff --git a/examples-to-docs.el b/examples-to-docs.el
index 20fcda6..c343a8d 100644
--- a/examples-to-docs.el
+++ b/examples-to-docs.el
@@ -20,12 +20,22 @@
(setq examples (cddr (cdr examples))))
(nreverse result)))
+(defun docs--signature (cmd)
+ (if (eq 'macro (car cmd))
+ (car (cddr cmd))
+ (cadr cmd)))
+
+(defun docs--docstring (cmd)
+ (if (eq 'macro (car cmd))
+ (cadr (cddr cmd))
+ (car (cddr cmd))))
+
(defmacro defexamples (cmd &rest examples)
`(add-to-list 'functions (list
- ',cmd ;; command name
- (cadr (symbol-function ',cmd)) ;; signature
- (car (cddr (symbol-function ',cmd))) ;; docstring
- (examples-to-strings ',examples)))) ;; examples
+ ',cmd
+ (docs--signature (symbol-function ',cmd))
+ (docs--docstring (symbol-function ',cmd))
+ (examples-to-strings ',examples))))
(defun quote-and-downcase (string)
(format "`%s`" (downcase string)))
- [elpa] externals/dash d83ea8a 061/426: Add installation instructions., (continued)
- [elpa] externals/dash d83ea8a 061/426: Add installation instructions., Phillip Lord, 2015/08/04
- [elpa] externals/dash e1a362c 047/426: Update README to reflect changes in readme generation., Phillip Lord, 2015/08/04
- [elpa] externals/dash 5bd4593 067/426: Add note about !rpartial only working on Emacs 24+, Phillip Lord, 2015/08/04
- [elpa] externals/dash 05dec7a 062/426: Fix example., Phillip Lord, 2015/08/04
- [elpa] externals/dash 6f17346 068/426: Don't run !rpartial tests on Emacsen <24, Phillip Lord, 2015/08/04
- [elpa] externals/dash 4205e58 064/426: Add clojure threading macros, !-> and !->>, Phillip Lord, 2015/08/04
- [elpa] externals/dash cd2a793 069/426: Run travis-ci on both E23 and E24, Phillip Lord, 2015/08/04
- [elpa] externals/dash 1a7ad85 065/426: Mention Melpa in README, Phillip Lord, 2015/08/04
- [elpa] externals/dash 6be4c03 058/426: !first, Phillip Lord, 2015/08/04
- [elpa] externals/dash 0991c29 057/426: Added some common aliases, Phillip Lord, 2015/08/04
- [elpa] externals/dash ca3eea7 070/426: Fix examples-to-docs to support documenting macros.,
Phillip Lord <=
- [elpa] externals/dash a6323eb 059/426: Add some tests that verify that the lists are evaled by the anaphoric macros., Phillip Lord, 2015/08/04
- [elpa] externals/dash b29a5bb 071/426: Use make-symbol in macros to avoid names clashing., Phillip Lord, 2015/08/04
- [elpa] externals/dash 6520496 060/426: First release, remove warning., Phillip Lord, 2015/08/04
- [elpa] externals/dash 8bd82c7 051/426: Show empty lists as '() instead of nil in docs., Phillip Lord, 2015/08/04
- [elpa] externals/dash 66ffaa6 072/426: Add !interpose, Phillip Lord, 2015/08/04
- [elpa] externals/dash ec6a85f 074/426: Add threading macro !!-> with `it` as placeholder., Phillip Lord, 2015/08/04
- [elpa] externals/dash 6238f8f 077/426: Add !split-with, Phillip Lord, 2015/08/04
- [elpa] externals/dash 4e76865 075/426: Add !take-while, Phillip Lord, 2015/08/04
- [elpa] externals/dash 3802890 082/426: Simplify !concat, Phillip Lord, 2015/08/04
- [elpa] externals/dash ec835e4 081/426: Add !split-at, Phillip Lord, 2015/08/04