Commit graph

251 commits

Author SHA1 Message Date
Daniel Colascione
8af3e1848c Add cl-iter-defun
* lisp/emacs-lisp/cl-macs.el (cl-iter-defun): Add cl-iter-defun.
2015-03-02 16:41:59 -08:00
Stefan Monnier
e846bbf360 * lisp/emacs-lisp/macroexp.el (macroexp-parse-body): Handle cl-declare
and :documentation.  Change return value format accordingly.
* lisp/emacs-lisp/cl-generic.el (cl--generic-lambda):
* lisp/emacs-lisp/pcase.el (pcase-lambda): Adjust accordingly.
* lisp/emacs-lisp/cl-macs.el (cl--transform-lambda): Use macroexp-parse-body.
2015-02-22 23:50:03 -05:00
Stefan Monnier
235c3cb105 * lisp/emacs-lisp/cl-macs.el (cl-struct-slot-value): Handle a nil type. 2015-02-19 13:14:51 -05:00
Stefan Monnier
6bf61df8ab * lisp/emacs-lisp/cl-macs.el (cl-defstruct): Keep type=nil by default.
* lisp/emacs-lisp/cl-preloaded.el (cl-struct-define): Add sanity checks
about relationship between `type', `named', and `slots'.
* lisp/emacs-lisp/cl-generic.el (cl--generic-struct-tagcode): Adjust to new
value of `cl-struct-type' property.
2015-02-16 01:37:57 -05:00
Stefan Monnier
61b4c22c6e * lisp/emacs-lisp/cl*.el: Use define-inline and move some code
* lisp/emacs-lisp/cl-lib.el: Move autoloaded code to cl-preload.

* lisp/emacs-lisp/cl-preloaded.el (cl-struct-define): Register as children
of the parent.
(cl--assertion-failed): New function.
(cl-assertion-failed): Move in from cl-lib.el.

* lisp/emacs-lisp/cl-macs.el (cl-defstruct): Don't generate code to register
as children of its parents.
(cl--make-type-test, cl--compiler-macro-typep): Remove functions.
(cl-typep): Reimplement using define-inline.
(cl-assert): Use cl--assertion-failed.
(cl-struct-slot-value): Use define-inline.
2015-02-14 00:46:29 -05:00
Stefan Monnier
2668ac1aae Tighten up the tagcode used for eieio and cl-struct objects
* lisp/emacs-lisp/eieio-core.el (eieio-defclass-internal): Set the function
slot of the tag symbol to :quick-object-witness-check.
(eieio-object-p): Use :quick-object-witness-check.
(eieio--generic-tagcode): Use cl--generic-struct-tag.
* lisp/emacs-lisp/cl-preloaded.el: New file.
* lisp/emacs-lisp/cl-macs.el (cl--bind-inits): Remove, unused.
(cl--transform-lambda, cl-destructuring-bind): Remove cl--bind-inits.
(cl--make-usage-args): Strip away &aux args.
(cl-case, cl-typecase, cl--parse-loop-clause): Use macroexp-let2.
(cl-the, cl-check-type): Use macroexp-let2 and cl-typep.
(cl-defstruct): Use `declare' and cl-struct-define.
* lisp/emacs-lisp/cl-generic.el (cl--generic-struct-tag): New function.
(cl--generic-struct-tagcode): Use it to tighten the tagcode.
* lisp/loadup.el: Load cl-preloaded.
* src/lisp.mk (lisp): Add cl-preloaded.
2015-01-27 22:41:31 -05:00
Stefan Monnier
69f36afa11 * lisp/emacs-lisp/cl-macs.el: Fix last change.
(cl--labels-magic): New constant.
(cl--labels-convert): Use it to ask the macro what is its replacement
in the #'f case.
2015-01-16 17:49:00 -05:00
Stefan Monnier
9def17e92b * lisp/emacs-lisp/cl-generic.el: New file.
* lisp/emacs-lisp/cl-macs.el (cl-flet): Allow (FUN EXP) forms.
(cl-load-time-value, cl-labels): Use closures rather than
backquoted lambdas.
(cl-macrolet): Use `eval' to create the function value, and support CL
style arguments in for the defined macros.
* test/automated/cl-generic-tests.el: New file.
2015-01-14 14:37:10 -05:00
Paul Eggert
7e09ef09a4 Update copyright year to 2015
Run admin/update-copyright.
2015-01-01 14:26:41 -08:00
Leo Liu
6dbaf04719 New macro macroexp-let2*
* emacs-lisp/macroexp.el (macroexp-let2*): New macro.

* window.el (with-temp-buffer-window)
(with-current-buffer-window, with-displayed-buffer-window):
* emacs-lisp/cl-macs.el (cl--compiler-macro-adjoin):
* emacs-lisp/cl-lib.el (substring):
* emacs-lisp/cl-extra.el (cl-getf): Use it.
2014-11-24 23:01:05 +08:00
Stefan Monnier
57db3f3adc Fix bootstrap failure after last change to eval-and-compile.
* lisp/emacs-lisp/bytecomp.el (byte-compile-initial-macro-environment):
Don't call byte-compile-preprocess since the result will go through cconv.
(byte-compile-output-docform): Handle uninterned `name' correctly.
* lisp/emacs-lisp/cl-macs.el (cl-define-compiler-macro): Use interned name
to circumvent byte-compiler bug.

* lisp/emacs-lisp/cl-extra.el (cl-get): Silence compiler warning.

* lisp/emacs-lisp/macroexp.el (macroexp--expand-all): Fix typo.
(macroexp--compiler-macro): Remove left-over debug code.
2014-11-09 00:14:25 -05:00
Stefan Monnier
864d69a119 * lisp/emacs-lisp/cl-macs.el (cl-defstruct): Define an internal predicate
even if :predicate was nil, for the benefit of typep.
Record the name of the predicate for typep's use.
(cl--make-type-test): Use pcase.  Obey new cl-deftype-satisfies property.
2014-10-23 17:44:36 -04:00
Stefan Monnier
942501730f * lisp/emacs-lisp/eieio-base.el: Use lexical-binding and cl-lib.
* lisp/emacs-lisp/eieio-core.el: Use lexical-binding and cl-lib.
(list-of): New type.
(eieio--typep): Remove.
(eieio-perform-slot-validation): Use cl-typep instead.
* lisp/emacs-lisp/eieio.el: Use lexical-binding drop non-GV fallback.
(defclass, defgeneric, defmethod): Add doc-string position.
(with-slots): Require cl-lib.
* lisp/emacs-lisp/cl-macs.el (cl--make-type-test): Avoid ((lambda ..) ..).
2014-10-17 01:09:24 -04:00
Stefan Monnier
bb16bffbd2 Indentation, punctuation, and other nitpicks. 2014-07-20 21:41:59 -04:00
Glenn Morris
9ac6d28ab8 Merge from emacs-24; up to 2014-06-11T19:33:14Z!rgm@gnu.org 2014-06-25 23:55:15 -07:00
Glenn Morris
9fc9c8c639 Remove some function declarations, no longer needed or correct
* lisp/emacs-lisp/cl-macs.el (help-add-fundoc-usage):
* lisp/gnus/mm-util.el (help-function-arglist):
Remove outdated declarations.
2014-06-25 23:43:39 -07:00
Leo Liu
d4e355b45d * emacs-lisp/cl-macs.el (cl-macrolet): Simplify last change. 2014-06-06 07:08:59 +08:00
Leo Liu
14781f7f44 * emacs-lisp/cl-macs.el (cl-macrolet): Avoid excessive progn's. 2014-06-06 01:08:18 +08:00
Paul Eggert
3e9fa60a5c Merge from emacs-24; up to 2014-05-04T21:18:30Z!eggert@cs.ucla.edu 2014-05-04 12:37:56 -07:00
Leo Liu
157e8cfdd8 * emacs-lisp/cl-macs.el (cl-deftype): Fix indentation. 2014-05-02 19:11:35 +08:00
Stefan Monnier
ddc13efd70 * lisp/emacs-lisp/cl-macs.el (cl--loop-let): Fix last merge. 2014-04-22 21:40:35 -04:00
Paul Eggert
42e910349d Merge from emacs-24; up to 2014-04-22T20:19:17Z!eggert@cs.ucla.edu 2014-04-22 14:32:51 -07:00
Stefan Monnier
67c477ae67 * lisp/emacs-lisp/byte-run.el (function-put): New function.
(defun-declarations-alist): Use it.  Add `pure' and `side-effect-free'.
* lisp/emacs-lisp/cl-macs.el (cl-defstruct, cl-struct-sequence-type)
(cl-struct-slot-info, cl-struct-slot-offset, cl-struct-slot-value):
Use them.
2014-04-22 12:22:13 -04:00
Daniel Colascione
66fda7948f Optimize cl-struct-slot-value; fix test
2014-04-22  Daniel Colascione  <dancol@dancol.org>

	* emacs-lisp/cl-macs.el
	(cl-struct-sequence-type,cl-struct-slot-info): Declare pure.
	(cl-struct-slot-value): Conditionally use aref or nth so that the
	compiler produces optimal code.

2014-04-22  Daniel Colascione  <dancol@dancol.org>

	* automated/cl-lib.el (cl-lib-struct-accessors): Fix test to
	account for removal of `cl-struct-set-slot-value'.
2014-04-21 20:51:12 -07:00
Stefan Monnier
d6f14ca729 * lisp/emacs-lisp/cl-macs.el (cl-struct-slot-offset): Mark as pure.
(cl--set-elt): Don't proclaim as inline.
(cl-struct-slot-value): Remove explicit gv-setter and compiler-macro.
Define as inlinable instead.
(cl-struct-set-slot-value): Remove.
* doc/misc/cl.texi (Structures): Remove cl-struct-set-slot-value.
* lisp/emacs-lisp/cl-lib.el (cl--set-elt): Remove.
* lisp/emacs-lisp/cl-seq.el (cl-replace, cl-substitute, cl-nsubstitute):
Use setf instead.
2014-04-21 23:18:15 -04:00
Stefan Monnier
622eef687c * lisp/emacs-lisp/cl-macs.el (cl--loop-let): Avoid `nil' as var name. 2014-04-21 17:18:12 -04:00
Daniel Colascione
44faec1788 Remove excess parameters on cl--const-expr-val
2014-04-21  Daniel Colascione  <dancol@dancol.org>

	* emacs-lisp/cl-macs.el (cl--const-expr-val): We didn't need the
	last two parameters after all.
	(cl--expr-contains,cl--compiler-macro-typep,cl--compiler-macro-member)
	(cl--compiler-macro-assoc,cl-struct-slot-value)
	(cl-struct-set-slot-value): Stop using them.
2014-04-21 11:00:19 -07:00
Daniel Colascione
2fa1b97db0 Fix cl-loop destructuring under `with' clause 2014-04-20 18:03:39 -07:00
Daniel Colascione
e100022976 unbreak the build 2014-04-20 07:46:13 -07:00
Daniel Colascione
89a2e783c2 defstruct introspection 2014-04-19 19:34:22 -07:00
Daniel Colascione
544ab460f5 Backport &key-parsing improvement from trunk 2014-03-24 13:41:08 -07:00
Daniel Colascione
1edb4a2ec6 Improve performance of &key parsing 2014-03-23 20:06:35 -07:00
Daniel Colascione
7eab98da1b Fix keyword argument parsing. Please bootstrap. 2014-03-22 23:00:18 -07:00
Daniel Colascione
c6b0fbe7db Fix cl-defun keyword arg parsing. Please bootstrap. 2014-03-22 22:50:24 -07:00
Stefan Monnier
3d136b1b72 * lisp/emacs-lisp/cl-macs.el (cl-define-compiler-macro): Add indent rule.
Fixes: debbugs:16829
2014-02-21 12:45:26 -05:00
Stefan Monnier
d4f0427be7 * lisp/emacs-lisp/cl-macs.el: Improve type->predicate mapping.
(cl--macroexp-fboundp): New function.
(cl--make-type-test): Use it.

Fixes: debbugs:16520
2014-01-23 10:01:41 -05:00
Paul Eggert
ba3189039a Update copyright year to 2014 by running admin/update-copyright. 2014-01-01 07:43:34 +00:00
Stefan Monnier
3220d5279d * lisp/emacs-lisp/cl-macs.el (cl-symbol-macrolet): Use macroexp-progn.
(cl--block-wrapper): Fix last accidental change.
2013-11-07 14:30:43 -05:00
Nathan Trapuzzano
e6e4db3cac * lisp/emacs-lisp/cl-macs.el (cl-symbol-macrolet): Print warning for
malformed bindings form.

Fixes: debbugs:15814
2013-11-06 23:38:00 -05:00
Stefan Monnier
3b7b269256 * lisp/emacs-lisp/cl-macs.el:
(cl--loop-destr-temps): Remove.
(cl--loop-iterator-function): Rename from cl--loop-map-form and change
its convention.
(cl--loop-set-iterator-function): New function.
(cl-loop): Adjust accordingly, so as not to use cl-subst.
(cl--parse-loop-clause): Adjust all uses of cl--loop-map-form.
Bind `it' with `let' instead of substituting it with `cl-subst'.
(cl--unused-var-p): New function.
(cl--loop-let): Don't use the cl--loop-destr-temps hack any more.
Eliminate some unused variable warnings.

Fixes: debbugs:15326
2013-09-27 21:07:18 -04:00
Daniel Colascione
0057865926 * emacs-lisp/cl-macs.el (cl-type-spec): Tell edebug what type
specs are and that they're not evaluated.
2013-09-25 14:39:53 -08:00
Glenn Morris
a2c501b84e * lisp/emacs-lisp/cl-macs.el (cl-defsubst): Remove unused local `pbody'. 2013-09-19 16:31:54 -04:00
Stefan Monnier
e8dfd19797 * lisp/emacs-lisp/cl-macs.el (cl-defsubst): Make it clear that args
are immutable.  Don't use `unsafe' any more.
(cl--defsubst-expand): Don't substitute at the same time as keeping
a residual unused let-binding.  Don't use `unsafe' any more.
2013-08-28 23:49:10 -04:00
Stefan Monnier
5514cc4c84 * lisp/emacs-lisp/timer.el (timer--time-setter): New function.
(timer--time): Use it as gv-setter.
* lisp/emacs-lisp/gv.el (gv-define-simple-setter): Output warning when
setter is not a symbol.
2013-08-12 22:30:52 -04:00
Juanma Barranquero
1048af7c8f lisp/emacs-lisp/cl-macs.el: Fix typos in docstrings. 2013-07-12 03:11:22 +02:00
Stefan Monnier
120597093d * lisp/emacs-lisp/package.el: Include obsolete packages from archives.
Use lexical-binding.
(package-archive-contents): Change format; include obsolete packages.
(package-desc): Use `dir' to mark builtin packages.
(package--from-builtin): Set the `dir' field to `builtin'.
(generated-autoload-file, version-control): Declare.
(package-compute-transaction): Change first arg and return value to be
lists of package-descs.  Adjust to new package-archive-contents format.
(package--add-to-archive-contents): Adjust to new
package-archive-contents format.
(package-download-transaction): Arg is now a list of package-descs.
(package-install): If `pkg' is a package name, pass it as
a requirement, so it is subject to the usual (e.g. disabled) checks.
(describe-package): Accept package-desc as well.
(describe-package-1): Describe a specific package-desc.  Add links to
other package-descs for the same package name.
(package-menu-describe-package): Pass the actual package-desc.
(package-menu-mode): Add to tabulated-list-revert-hook so revert-buffer
works correctly.
(package-desc-status): New function.
(package-menu--refresh): New function, extracted
from package-menu--generate.
(package-menu--generate): Use it.
(package-delete): Update package-alist.
(package-menu-execute): Don't call package-initialize.

* lisp/progmodes/idlw-toolbar.el, lisp/progmodes/idlw-shell.el,
lisp/progmodes/idlw-help.el, lisp/progmodes/idlw-complete-structtag.el,
lisp/progmodes/ebnf-yac.el, lisp/progmodes/ebnf-otz.el,
lisp/progmodes/ebnf-iso.el, lisp/progmodes/ebnf-ebx.el,
lisp/progmodes/ebnf-dtd.el, lisp/progmodes/ebnf-bnf.el,
lisp/progmodes/ebnf-abn.el, lisp/emacs-lisp/package-x.el,
lisp/emacs-lisp/cl-seq.el, lisp/emacs-lisp/cl-macs.el
lisp/cedet/data-debug.el, lisp/cedet/cedet-idutils.el:
Neuter the "Version:" header.
2013-06-25 12:13:49 -04:00
Stefan Monnier
aff6371e32 * lisp/emacs-lisp/cl-loaddefs.el: Don't version-control any more.
* lisp/emacs-lisp/cl-lib.el: Load cl-macs when cl-loaddefs is not
yet available.
* lisp/Makefile.in (AUTOGEN_VCS): Move cl-loaddefs.el...
(AUTOGENEL): ... here.
* lisp/emacs-lisp/cl-macs.el (cl--sublis): New function.
(cl--defsubst-expand): Use it.
* .bzrignore: Don't unignore cl-loaddefs.el.
2013-06-20 16:01:51 -04:00
Stefan Monnier
cf4e5178a3 * lisp/help-fns.el (help-fns--compiler-macro): If the handler function is
named, then put a link to it.
* lisp/help-mode.el (help-function-cmacro): Adjust regexp for cl-lib names.
* lisp/emacs-lisp/cl-macs.el (cl--compiler-macro-typep): New function.
(cl-typep): Use it.
(cl-eval-when): Simplify debug spec.
(cl-define-compiler-macro): Use eval-and-compile.  Give a name to the
compiler-macro function instead of setting `compiler-macro-file'.
2013-06-11 22:16:02 -04:00
Stefan Monnier
208d0342a3 Fix compilation error with simultaneous dynamic+lexical scoping.
Add warning when a defvar appears after the first let-binding.
* lisp/emacs-lisp/bytecomp.el (byte-compile-lexical-variables): New var.
(byte-compile-close-variables): Initialize it.
(byte-compile--declare-var): New function.
(byte-compile-file-form-defvar)
(byte-compile-file-form-define-abbrev-table)
(byte-compile-file-form-custom-declare-variable): Use it.
(byte-compile-make-lambda-lexenv): Change the argument.  Simplify.
(byte-compile-lambda): Share call to byte-compile-arglist-vars.
(byte-compile-bind): Handle dynamic bindings that shadow
lexical bindings.
(byte-compile-unbind): Make arg non-optional.
(byte-compile-let): Simplify.
* lisp/emacs-lisp/cconv.el (byte-compile-lexical-variables): Declare var.
(cconv--analyse-function, cconv-analyse-form): Populate it.
Protect byte-compile-bound-variables to limit the scope of defvars.
(cconv-analyse-form): Add missing rule for (defvar <foo>).
Remove unneeded rule for `declare'.

* lisp/emacs-lisp/cl-macs.el (cl--compiler-macro-adjoin): Use macroexp-let2
so as to avoid depending on cl-adjoin at run-time.
* lisp/emacs-lisp/cl-lib.el (cl-pushnew): Use backquotes.

* lisp/emacs-lisp/macroexp.el (macroexp--compiling-p): New function.
(macroexp--warn-and-return): Use it.
2013-06-04 22:35:40 -04:00
Glenn Morris
d5837773e0 * lisp/emacs-lisp/cl-macs.el (cl-loop): Doc fix. 2013-05-09 22:01:12 -04:00