diff --git a/README.md b/README.md index 7baf0aa..2e02855 100644 --- a/README.md +++ b/README.md @@ -197,6 +197,7 @@ or with `!compare-fn` if that's non-nil. (!contains? '(1 2 3) 4) ;; => nil ``` + ## Development Run the tests with diff --git a/examples-to-docs.el b/examples-to-docs.el index a5685e3..760c57c 100644 --- a/examples-to-docs.el +++ b/examples-to-docs.el @@ -55,29 +55,22 @@ (delete-char 7) (insert "'")))) +(defun goto-and-remove (s) + (goto-char (point-min)) + (search-forward s) + (delete-char (- (length s)))) + (defun create-docs-file () (let ((functions (nreverse functions))) (with-temp-file "./README.md" - (insert-file-contents-literally "./readme-prefix.md") - (goto-char (point-max)) - (newline) - (insert "## Available functions") - (newline 2) - (insert "```cl") - (newline) + (insert-file-contents-literally "./readme-template.md") + + (goto-and-remove "[[ function-list ]]") (insert (mapconcat 'function-summary functions "\n")) - (newline) - (insert "```") - (newline 2) - (insert "There are also anaphoric versions of these -functions where that makes sense, prefixed with two bangs -instead of one.") - (newline 2) - (insert "## Documentation and examples") - (newline 2) + + (goto-and-remove "[[ function-docs ]]") (insert (mapconcat 'function-to-md functions "\n")) - (newline) - (insert-file-contents-literally "./readme-postfix.md") + (simplify-quotes)))) (defun three-first (list) diff --git a/readme-prefix.md b/readme-prefix.md deleted file mode 100644 index 1211751..0000000 --- a/readme-prefix.md +++ /dev/null @@ -1,31 +0,0 @@ -# bang.el [![Build Status](https://secure.travis-ci.org/magnars/bang.el.png)](http://travis-ci.org/magnars/bang.el) - -The startings of a modern list api for Emacs. Does not require 'cl. - -We're looking to Clojure for naming and signatures. - -## Warning - -This is so much a work in progress that you should definitely not be using it yet. - -## Anaphoric functions - -While `!filter` takes a function to filter the list by, you can also use the -anaphoric form with double bangs - which will then be executed with `it` exposed -as the list item. Here's an example: - -```cl -(!filter (lambda (num) (= 0 (% num 2))) '(1 2 3 4)) ;; normal version - -(!!filter (= 0 (% it 2)) '(1 2 3 4)) ;; anaphoric version -``` - -of course the original can also be written like - -```cl -(defun even? (num) (= 0 (% num 2))) - -(!filter even? '(1 2 3 4)) -``` - -which demonstrates the usefulness of both versions. diff --git a/readme-postfix.md b/readme-template.md similarity index 52% rename from readme-postfix.md rename to readme-template.md index c3a9786..836a22b 100644 --- a/readme-postfix.md +++ b/readme-template.md @@ -1,3 +1,49 @@ +# bang.el [![Build Status](https://secure.travis-ci.org/magnars/bang.el.png)](http://travis-ci.org/magnars/bang.el) + +The startings of a modern list api for Emacs. Does not require 'cl. + +We're looking to Clojure for naming and signatures. + +## Warning + +This is so much a work in progress that you should definitely not be using it yet. + +## Anaphoric functions + +While `!filter` takes a function to filter the list by, you can also use the +anaphoric form with double bangs - which will then be executed with `it` exposed +as the list item. Here's an example: + +```cl +(!filter (lambda (num) (= 0 (% num 2))) '(1 2 3 4)) ;; normal version + +(!!filter (= 0 (% it 2)) '(1 2 3 4)) ;; anaphoric version +``` + +of course the original can also be written like + +```cl +(defun even? (num) (= 0 (% num 2))) + +(!filter even? '(1 2 3 4)) +``` + +which demonstrates the usefulness of both versions. + +## Available functions + +```cl +[[ function-list ]] +``` + +There are also anaphoric versions of these +functions where that makes sense, prefixed with two bangs +instead of one. + +## Documentation and examples + +[[ function-docs ]] + ## Development Run the tests with