From e292c0973cf7a92819d312ea8a828b67e6adf1ab Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Tue, 12 Jun 2018 18:41:46 -0400 Subject: Fix #'fun handling inside `labels' (Bug#31792) * lisp/emacs-lisp/cl.el (labels): Apply the equivalent of the cl-labels change from 2015-01-16 "* lisp/emacs-lisp/cl-macs.el: Fix last change". * test/lisp/emacs-lisp/cl-tests.el (labels-function-quoting): New test. * lisp/emacs-lisp/cl-macs.el (cl-flet, cl-labels): Improve docstring, link to relevant manual page. * doc/misc/cl.texi (Function Bindings): Don't imply that function cells of symbols are modified by cl-flet. Don't claim that cl-flet or cl-labels affect references of the form (quote FUNC). --- lisp/emacs-lisp/cl-macs.el | 17 ++++++++++++----- lisp/emacs-lisp/cl.el | 7 +++++-- 2 files changed, 17 insertions(+), 7 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index 9c47ceae18e..0854e665b9b 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -1964,13 +1964,16 @@ a `let' form, except that the list of symbols can be computed at run-time." ;;;###autoload (defmacro cl-flet (bindings &rest body) "Make local function definitions. -Like `cl-labels' but the definitions are not recursive. -Each binding can take the form (FUNC EXP) where +Each definition can take the form (FUNC EXP) where FUNC is the function name, and EXP is an expression that returns the function value to which it should be bound, or it can take the more common form \(FUNC ARGLIST BODY...) which is a shorthand for (FUNC (lambda ARGLIST BODY)). +FUNC is defined only within FORM, not BODY, so you can't write +recursive function definitions. Use `cl-labels' for that. See +info node `(cl) Function Bindings' for details. + \(fn ((FUNC ARGLIST BODY...) ...) FORM...)" (declare (indent 1) (debug ((&rest (cl-defun)) cl-declarations body))) (let ((binds ()) (newenv macroexpand-all-environment)) @@ -2012,9 +2015,13 @@ Like `cl-flet' but the definitions can refer to previous ones. ;;;###autoload (defmacro cl-labels (bindings &rest body) - "Make temporary function bindings. -The bindings can be recursive and the scoping is lexical, but capturing them -in closures will only work if `lexical-binding' is in use. + "Make local (recursive) function definitions. +Each definition can take the form (FUNC ARGLIST BODY...) where +FUNC is the function name, ARGLIST its arguments, and BODY the +forms of the function body. FUNC is defined in any BODY, as well +as FORM, so you can write recursive and mutually recursive +function definitions. See info node `(cl) Function Bindings' for +details. \(fn ((FUNC ARGLIST BODY...) ...) FORM...)" (declare (indent 1) (debug cl-flet)) diff --git a/lisp/emacs-lisp/cl.el b/lisp/emacs-lisp/cl.el index d53c8e0bbcf..f6643158d2d 100644 --- a/lisp/emacs-lisp/cl.el +++ b/lisp/emacs-lisp/cl.el @@ -466,9 +466,12 @@ rather than relying on `lexical-binding'." (push var sets) (push (cons (car binding) `(lambda (&rest cl-labels-args) - (cl-list* 'funcall ',var - cl-labels-args))) + (if (eq (car cl-labels-args) cl--labels-magic) + (list cl--labels-magic ',var) + (cl-list* 'funcall ',var cl-labels-args)))) newenv))) + ;; `lexical-let' adds `cl--function-convert' (which calls + ;; `cl--labels-convert') as a macroexpander for `function'. (macroexpand-all `(lexical-let ,vars (setq ,@sets) ,@body) newenv))) ;; Generalized variables are provided by gv.el, but some details are -- cgit v1.2.3 From 3d2e3dc1ca8ee7226668ab5bbd35061d37bcbbec Mon Sep 17 00:00:00 2001 From: Simen Heggestøyl Date: Sun, 9 Apr 2017 11:06:44 +0200 Subject: Change name of `seqp' argument (Bug#26411) * lisp/emacs-lisp/seq.el (seqp): Change argument name. * doc/lispref/sequences.texi: Update the documentation for seqp. --- doc/lispref/sequences.texi | 4 ++-- lisp/emacs-lisp/seq.el | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/doc/lispref/sequences.texi b/doc/lispref/sequences.texi index f347cd9e980..76a4a468880 100644 --- a/doc/lispref/sequences.texi +++ b/doc/lispref/sequences.texi @@ -474,8 +474,8 @@ built-in sequence types, @code{seq-length} behaves like @code{length}. @xref{Definition of length}. @end defun -@defun seqp sequence - This function returns non-@code{nil} if @var{sequence} is a sequence +@defun seqp object + This function returns non-@code{nil} if @var{object} is a sequence (a list or array), or any additional type of sequence defined via @file{seq.el} generic functions. diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el index 5d6ab7e057f..b40c424e303 100644 --- a/lisp/emacs-lisp/seq.el +++ b/lisp/emacs-lisp/seq.el @@ -127,9 +127,9 @@ the sequence, and its index within the sequence." (setq index (1+ index))) sequence))) -(cl-defgeneric seqp (sequence) - "Return non-nil if SEQUENCE is a sequence, nil otherwise." - (sequencep sequence)) +(cl-defgeneric seqp (object) + "Return non-nil if OBJECT is a sequence, nil otherwise." + (sequencep object)) (cl-defgeneric seq-copy (sequence) "Return a shallow copy of SEQUENCE." -- cgit v1.2.3