diff options
| author | Basil L. Contovounesios | 2018-07-09 18:46:33 -0700 |
|---|---|---|
| committer | Paul Eggert | 2018-07-09 19:00:43 -0700 |
| commit | 2fde6275b69fd113e78243790bf112bbdd2fe2bf (patch) | |
| tree | f28a04fdabc51d275689066b41b9149422d9f3cb /doc | |
| parent | e4ad2d1a8fad8c8c786b61083b05cfaa1ea5669c (diff) | |
| download | emacs-2fde6275b69fd113e78243790bf112bbdd2fe2bf.tar.gz emacs-2fde6275b69fd113e78243790bf112bbdd2fe2bf.zip | |
Add predicate proper-list-p
For discussion, see emacs-devel thread starting at
https://lists.gnu.org/archive/html/emacs-devel/2018-04/msg00460.html.
* lisp/subr.el (proper-list-p): New function.
Implementation suggested by Paul Eggert <eggert@cs.ucla.edu> in
https://lists.gnu.org/archive/html/emacs-devel/2018-06/msg00138.html.
* doc/lispref/lists.texi (List Elements):
* etc/NEWS: Document proper-list-p.
* lisp/org/ob-core.el (org-babel-insert-result):
* lisp/emacs-lisp/byte-opt.el (byte-optimize-if):
* lisp/emacs-lisp/cl-macs.el (cl--make-usage-args): Use proper-list-p.
* lisp/emacs-lisp/ert.el (ert--proper-list-p): Remove.
Replaced by proper-list-p in lisp/subr.el.
(ert--explain-equal-rec): Use proper-list-length.
* lisp/format.el (format-proper-list-p): Remove.
Replaced by proper-list-p in lisp/subr.el.
(format-annotate-single-property-change): Use proper-list-p.
* test/lisp/emacs-lisp/ert-tests.el (ert-test-proper-list-p):
Move from here...
* test/lisp/subr-tests.el (subr-tests--proper-list-length):
...to here, mutatis mutandis.
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/lispref/lists.texi | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/doc/lispref/lists.texi b/doc/lispref/lists.texi index 761750eb20c..57cefeac962 100644 --- a/doc/lispref/lists.texi +++ b/doc/lispref/lists.texi | |||
| @@ -153,6 +153,22 @@ considered a list and @code{not} when it is considered a truth value | |||
| 153 | @end example | 153 | @end example |
| 154 | @end defun | 154 | @end defun |
| 155 | 155 | ||
| 156 | @defun proper-list-p object | ||
| 157 | This function returns the length of @var{object} if it is a proper | ||
| 158 | list, @code{nil} otherwise (@pxref{Cons Cells}). In addition to | ||
| 159 | satisfying @code{listp}, a proper list is neither circular nor dotted. | ||
| 160 | |||
| 161 | @example | ||
| 162 | @group | ||
| 163 | (proper-list-p '(a b c)) | ||
| 164 | @result{} 3 | ||
| 165 | @end group | ||
| 166 | @group | ||
| 167 | (proper-list-p '(a b . c)) | ||
| 168 | @result{} nil | ||
| 169 | @end group | ||
| 170 | @end example | ||
| 171 | @end defun | ||
| 156 | 172 | ||
| 157 | @node List Elements | 173 | @node List Elements |
| 158 | @section Accessing Elements of Lists | 174 | @section Accessing Elements of Lists |