[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master b7ed48c: Add seq-into as a public function
From: |
Nicolas Petton |
Subject: |
[Emacs-diffs] master b7ed48c: Add seq-into as a public function |
Date: |
Mon, 09 Mar 2015 11:50:59 +0000 |
branch: master
commit b7ed48c3ce8e77acc08d4948684333bef3238d2d
Author: Nicolas Petton <address@hidden>
Commit: Nicolas Petton <address@hidden>
Add seq-into as a public function
* lisp/emacs-lisp/seq.el: Make seq-into a public function (replacing
seq--into)
* test/automated/seq-tests.el: Add tests for seq-into
* doc/lispref/sequences.texi: Add documentation for seq-into
---
doc/lispref/ChangeLog | 5 +++++
doc/lispref/sequences.texi | 22 ++++++++++++++++++++++
lisp/ChangeLog | 5 +++++
lisp/emacs-lisp/seq.el | 12 +++++++-----
test/ChangeLog | 4 ++++
test/automated/seq-tests.el | 22 ++++++++++++++++++++++
6 files changed, 65 insertions(+), 5 deletions(-)
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index 42bff7c..260656c 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,8 @@
+2015-03-09 Nicolas Petton <address@hidden>
+
+ * sequences.texi (seq-into): Add documentation for the new
+ seq-into function.
+
2015-03-03 Eli Zaretskii <address@hidden>
* processes.texi (Synchronous Processes): Update documentation of
diff --git a/doc/lispref/sequences.texi b/doc/lispref/sequences.texi
index 04404f8..1af3535 100644
--- a/doc/lispref/sequences.texi
+++ b/doc/lispref/sequences.texi
@@ -740,6 +740,28 @@ of @var{sequence}. Keys are compared using @code{equal}.
@end example
@end defun
address@hidden seq-into sequence type
+ This function converts the sequence @var{sequence} into a sequence
+of type @var{type}. @var{type} can be one of the following symbols:
address@hidden, @code{string} or @code{list}.
+
address@hidden
address@hidden
+(seq-into [1 2 3] 'list)
address@hidden (1 2 3)
address@hidden group
address@hidden
+(seq-into nil 'vector)
address@hidden []
address@hidden group
address@hidden
+(seq-into "hello" 'vector)
address@hidden [104 101 108 108 111]
address@hidden group
address@hidden example
address@hidden defun
+
+
@defmac seq-doseq (var sequence [result]) address@hidden
@cindex sequence iteration
This macro is like @code{dolist}, except that @var{sequence} can be a list,
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index b284ef1..d8330a4 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2015-03-09 Nicolas Petton <address@hidden>
+
+ * emacs-lisp/seq.el (seq-into): New function.
+ Bump seq.el version to 1.3.
+
2015-03-09 Dmitry Gutov <address@hidden>
* progmodes/ruby-mode.el (ruby-font-lock-keywords): Don't consider
diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el
index ad4c353..59b9140 100644
--- a/lisp/emacs-lisp/seq.el
+++ b/lisp/emacs-lisp/seq.el
@@ -4,7 +4,8 @@
;; Author: Nicolas Petton <address@hidden>
;; Keywords: sequences
-;; Version: 1.2
+;; Version: 1.3
+;; Package: seq
;; Maintainer: address@hidden
@@ -171,7 +172,7 @@ The result is a sequence of the same type as SEQ."
(if (listp seq)
(sort (seq-copy seq) pred)
(let ((result (seq-sort pred (append seq nil))))
- (seq--into result (type-of seq)))))
+ (seq-into result (type-of seq)))))
(defun seq-contains-p (seq elt &optional testfn)
"Return the first element in SEQ that equals to ELT.
@@ -265,10 +266,11 @@ See also the function `nreverse', which is used more
often."
seq)
(if (listp seq)
result
- (seq--into result (type-of seq)))))))
+ (seq-into result (type-of seq)))))))
-(defun seq--into (seq type)
- "Convert the sequence SEQ into a sequence of type TYPE."
+(defun seq-into (seq type)
+ "Convert the sequence SEQ into a sequence of type TYPE.
+TYPE can be one of the following symbols: vector, string or list."
(pcase type
(`vector (vconcat seq))
(`string (concat seq))
diff --git a/test/ChangeLog b/test/ChangeLog
index 301cc40..876b946 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,7 @@
+2015-03-09 Nicolas Petton <address@hidden>
+
+ * automated/seq-tests.el (test-seq-into): Add a test for seq-into.
+
2015-03-08 Dmitry Gutov <address@hidden>
* indent/ruby.rb: Add an example for bug#20026.
diff --git a/test/automated/seq-tests.el b/test/automated/seq-tests.el
index badb326..d3536b6 100644
--- a/test/automated/seq-tests.el
+++ b/test/automated/seq-tests.el
@@ -228,5 +228,27 @@ Evaluate BODY for each created sequence.
(should (equal (type-of (seq-reverse seq))
(type-of seq)))))
+(ert-deftest test-seq-into ()
+ (let* ((vector [1 2 3])
+ (list (seq-into vector 'list)))
+ (should (same-contents-p vector list))
+ (should (listp list)))
+ (let* ((list '(hello world))
+ (vector (seq-into list 'vector)))
+ (should (same-contents-p vector list))
+ (should (vectorp vector)))
+ (let* ((string "hello")
+ (list (seq-into string 'list)))
+ (should (same-contents-p string list))
+ (should (stringp string)))
+ (let* ((string "hello")
+ (vector (seq-into string 'vector)))
+ (should (same-contents-p string vector))
+ (should (stringp string)))
+ (let* ((list nil)
+ (vector (seq-into list 'vector)))
+ (should (same-contents-p list vector))
+ (should (vectorp vector))))
+
(provide 'seq-tests)
;;; seq-tests.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master b7ed48c: Add seq-into as a public function,
Nicolas Petton <=