emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/dash ca3eea7 070/439: Fix examples-to-docs to support d


From: Phillip Lord
Subject: [elpa] externals/dash ca3eea7 070/439: Fix examples-to-docs to support documenting macros.
Date: Tue, 04 Aug 2015 20:26:30 +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)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]