Commit graph

7649 commits

Author SHA1 Message Date
Stefan Monnier
236aad4f8c * lisp/emacs-lisp/cl-macs.el (cl--self-tco): Optimize the "return nil" case 2021-03-18 17:54:43 -04:00
Mattias Engdegård
52270aa0dc Optimise tail calls in and and or forms in cl-labels functions
* lisp/emacs-lisp/cl-macs.el (cl--self-tco): Handle `and` and `or`.
* test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs--labels):
Add test cases.
2021-03-18 13:35:55 +01:00
Lars Ingebrigtsen
4eb0303197 Compute chart-face-list dynamically
* lisp/emacs-lisp/chart.el (chart-face-list): Allow a function as
the value (bug#47133) so that we can compute the faces dynamically
on different displays.
(chart--face-list): New function.
(chart-draw-data): Use it.
2021-03-18 11:15:50 +01:00
Lars Ingebrigtsen
21e1a126b5 Make memory-report work with buffer-local unbound vars
* lisp/emacs-lisp/memory-report.el (memory-report--buffer-data):
Protect against buffer-local unbound variables (bug#47057).
2021-03-18 08:33:40 +01:00
Stefan Monnier
82c3bd1e4a * lisp/emacs-lisp/benchmark.el (benchmark-call): New function
(benchmark-run, benchmark-run-compiled, benchmark): Use it.
(benchmark--adaptive): New internal function.
2021-03-17 19:04:28 -04:00
Andrea Corallo
3e133cc050 Fix `no-byte-compile' native compilation interaction (bug#47169)
* lisp/emacs-lisp/comp.el (comp-spill-lap-function): Throw
	no-native-compile when `byte-native-qualities' are null.
	* lisp/emacs-lisp/bytecomp.el (byte-compile-from-buffer): No need
	to consider `no-byte-compile'.
2021-03-16 19:02:57 +01:00
Andrea Corallo
f3abb17118 Have no-byte-compile' implies also no-native-compile'.
* lisp/emacs-lisp/comp.el (no-native-compile): Update doctring.
	* lisp/emacs-lisp/bytecomp.el (byte-compile-from-buffer): when
	`no-byte-compile' is set to non-nil it overrides this.
2021-03-16 09:12:46 +01:00
Eli Zaretskii
6810635bdd * lisp/emacs-lisp/byte-opt.el: Fix native re-compilation (bug#47161). 2021-03-15 19:24:20 +02:00
Andrea Corallo
7f74ed4912 * lisp/emacs-lisp/bytecomp.el: Fix native re-compilation (bug#47161). 2021-03-15 16:46:16 +01:00
Eli Zaretskii
aabda4263b Prefer expand-file-name to concat in native-compilation code
* lisp/emacs-lisp/comp.el (comp-eln-load-path-eff):
* src/comp.c (Fcomp_el_to_eln_filename)
(eln_load_path_final_clean_up): Prefer expand-file-name to concat.
(Bug#43725)
2021-03-15 16:56:08 +02:00
Gabriel do Nascimento Ribeiro
2d12df3926 Init archive and add noconfirm to 'package-install-selected-packages'
* lisp/emacs-lisp/package.el (package-install-selected-packages):
Add call to 'package--archives-initialize' and add optional argument
NOCONFIRM to skip user confirmation when installing packages.  (Bug#47124)
2021-03-15 03:09:02 +01:00
Andrea Corallo
5e4ec4d3c9 Fix some entry in `comp-known-type-specifiers' (bug#46847)
* lisp/emacs-lisp/comp.el (comp-known-type-specifiers): Some
	fix.
	* test/src/comp-tests.el (comp-tests-46670-1): Update test.
2021-03-14 22:05:02 +01:00
Andrea Corallo
d018584814 * Fix circular dependecy when loading a modified comp.el (bug#47049)
* lisp/emacs-lisp/comp.el (comp-subr-trampoline-install): Move it
	before other functional code.
2021-03-12 22:35:23 +01:00
Glenn Morris
1feddd35ab Merge from origin/emacs-27
02a5cfce47 (origin/emacs-27) * lisp/mouse.el: Fix mouse-1-clock-follo...
c881e990e3 * lisp/emacs-lisp/gv.el (edebug-after): Don't run the gett...
2021-03-12 08:47:41 -08:00
Andrea Corallo
82bd6d57d5 Merge remote-tracking branch 'savannah/master' into native-comp 2021-03-12 16:42:51 +01:00
Andrea Corallo
d9cd55a4f1 Implement `no-native-compile' (bug#46983)
* lisp/emacs-lisp/bytecomp.el (byte-compile-from-buffer): Capture
	`no-native-compile'.
	* lisp/emacs-lisp/comp.el (no-native-compile): Define new
	variable.
	(comp-spill-lap-function): Throw when `no-native-compile' was
	captured non-nil.
	(comp--native-compile): Catch `no-native-compile' if necessary and
	return nil in case.
2021-03-12 13:11:45 +01:00
Mattias Engdegård
a0854f939c ; Fix typos in doc strings 2021-03-12 12:12:14 +01:00
Andrea Corallo
0144764d1d * Fix error reporting for async native compilation (bug#47024)
* lisp/emacs-lisp/comp.el (comp--native-compile): During async
	compilation if we catch an error print it in a parsable way so we
	can report it to the user.
2021-03-12 10:03:09 +01:00
Stefan Monnier
ba6ae500f1 * lisp/emacs-lisp/cconv.el (cconv--analyze-use): Simplify (doh!) 2021-03-11 22:31:39 -05:00
Stefan Monnier
009bc7c9d8 * lisp/emacs-lisp/cconv.el (cconv--analyze-use): Tune down the warning
Don't warn for always-nil bindings if the binding is made explicit.
Fixes bug#47080.
2021-03-11 22:27:41 -05:00
Stefan Monnier
7109307c1a * lisp/emacs-lisp/syntax.el (syntax-propertize-rules): Use macroexp-let2
This also silences the recently introduced compilation warning.
2021-03-11 21:47:10 -05:00
Lars Ingebrigtsen
d0125959d7 Make byte-compiled uses of `define-minor-mode' more compatible
* lisp/emacs-lisp/easy-mmode.el (define-minor-mode): Be more
defensive about accessing minor mode variables.
2021-03-12 00:41:54 +01:00
Stefan Monnier
b21f6193fe * lisp: Remove yet more always-nil variables
* lisp/align.el (align-region):
Remove always-nil variable `group-c`.
* lisp/ido.el (ido-make-prompt): Remove always-nil variable `prefix`.

* lisp/xdg.el (xdg-mime-collect-associations):
Remove always-nil variable `end`.

* lisp/calc/calc-yank.el (calc-edit):
Remove always-nil variable `flag`.

* lisp/calendar/todo-mode.el (todo-edit-item--header):
Remove always-nil variable `dayname`.
(todo-show-categories-table):
Remove always-nil variable `sortkey`.

* lisp/emacs-lisp/checkdoc.el (checkdoc-ispell-docstring-engine):
Remove always-nil variable `err`.

* lisp/emacs-lisp/tcover-ses.el: Remove always-nil variable `pause`.

* lisp/eshell/em-ls.el (eshell-ls-files):
Remove always-nil variable `ignore`.

* lisp/net/ange-ftp.el (ange-ftp-copy-file-internal): Remove always-nil
variable `temp2`.

* lisp/progmodes/cperl-mode.el (cperl-tags-hier-init): Remove
always-nil variables `l1`, `l2`, `l3`.
(cperl-tags-treeify): Remove always-nil variable `l1`.

* lisp/progmodes/ebrowse.el (ebrowse-tags-read-member+class-name):
Remove always-nil variable `class`.

* lisp/textmodes/artist.el (artist-draw-ellipse-with-0-height):
Remove always-nil variable `fill-info`.

* lisp/textmodes/flyspell.el (flyspell-emacs-popup):
Remove always-nil variable `show-affix-info`.

* lisp/textmodes/rst.el (rst-Ado):
Remove always-nil variable `char`.

* lisp/vc/vc.el (vc-diff-build-argument-list-internal):
Remove always-nil variable `rev2-default`.
2021-03-11 13:29:14 -05:00
Stefan Monnier
e13c30132a * lisp/emacs-lisp/cconv.el (cconv--analyze-use): Warn never-initialized vars
(byte-compile-not-lexical-var-p): Remove Emacs<24 compatibility.
2021-03-11 13:01:59 -05:00
Lars Ingebrigtsen
4b47eb32c6 Fix byte-compilation warning in benchmark-run
* lisp/emacs-lisp/benchmark.el (benchmark-run): Avoid a
byte-compilation warning about an empty let body (bug#46819).
2021-03-10 15:52:54 +01:00
Andrea Corallo
fe1c081c38 * Fix truncated warnings (bug#47024)
* lisp/emacs-lisp/comp.el (comp-run-async-workers): Bind
	`warning-fill-column' to `most-positive-fixnum'.
2021-03-10 15:50:58 +01:00
Mattias Engdegård
7add330903 Mark string predicates side-effect-free
* lisp/emacs-lisp/byte-opt.el (side-effect-free-fns): Add string>,
string-greaterp, string-empty-p, string-prefix-p, string-suffix-p
and string-blank-p, all recently marked pure.
2021-03-10 14:08:41 +01:00
Stefan Kangas
4cb52200cb Fix duplicate ":" in ert-find-test-other-window prompt
* lisp/emacs-lisp/ert.el (ert-find-test-other-window): Don't insert
duplicate ":" in prompt.
2021-03-10 04:34:53 +01:00
Stefan Kangas
dc2688acb3 Do mode tagging in ert.el 2021-03-10 04:34:32 +01:00
Stefan Monnier
7561c01380 * lisp/emacs-lisp/cconv.el: Don't confuse a string for a docstring
(cconv--convert-funcbody): Check there's something after a docstring.

* test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-string-vs-docstring):
New corresponding test.
2021-03-09 11:04:03 -05:00
Andrea Corallo
43b0df62cd Merge commit '9cbdf20316' into native-comp 2021-03-09 10:03:47 +01:00
Philipp Stephani
f4452bb814 Fix structure of condition object in nested 'ert-fail'.
See the test 'ert-test-fail' for the expected structure.

* lisp/emacs-lisp/ert.el (ert--should-signal-hook): Condition list
should be (SYMBOL . DATA), not (SYMBOL DATA).
* test/lisp/emacs-lisp/ert-tests.el (ert-test-fail-inside-should): Fix
unit test.
2021-03-08 14:30:24 +01:00
Mauro Aranda
a01166562c Make checkdoc--next-docstring use the doc-string-elt property
This follows from a fix for Bug#46918 and a discussion to use
doc-string-elt:
https://lists.gnu.org/archive/html/emacs-devel/2021-03/msg00232.html

* lisp/emacs-lisp/checkdoc.el (checkdoc--next-docstring): Check for a
non-nil doc-string-elt property, instead of hard-coding the
supported symbols.  Use that property to position point at the
doc-string.
2021-03-08 08:12:23 -03:00
Stefan Kangas
0e4a2dca83 Normalize version specifiers for make-obsolete and friends
* lisp/auth-source.el (auth-source-forget-user-or-password)
(auth-source-user-or-password, auth-source-hide-passwords):
* lisp/calendar/icalendar.el (icalendar--datetime-to-noneuropean-date):
* lisp/cedet/semantic/db-el.el (semanticdb-elisp-sym-function-arglist):
* lisp/emacs-lisp/debug.el (debugger-insert-backtrace):
* lisp/obsolete/nnir.el (nnir-swish-e-index-file):
* lisp/obsolete/starttls.el (starttls-any-program-available):
Normalize version specifiers for make-obsolete and friends.
2021-03-08 05:09:27 +01:00
Stefan Monnier
251dea693a * lisp/emacs-lisp/bytecomp.el: Warn about unprefixed vars in boundp
(byte-compile--check-prefixed-var): New fun,
extracted from `byte-compile--declare-var`.
(byte-compile--declare-var): Use it.
(byte-compile-maybe-guarded): Use it as well.
2021-03-07 19:00:47 -05:00
Andrea Corallo
9809f7ed2c Use `length=' and family where possible in native comp code
* lisp/emacs-lisp/comp-cstr.el (comp-intersect-typesets)
	(comp-cstr-imm): Use Use `length=' and family where possible.
	* lisp/emacs-lisp/comp.el (comp-add-cond-cstrs-target-block)
	(comp-compute-dominator-frontiers)
	(batch-byte-native-compile-for-bootstrap): Likewise.
2021-03-07 21:33:53 +01:00
Andrea Corallo
b6f06c32b4 * lisp/emacs-lisp/comp.el (w32-get-nproc): Suppress warning declaring it.
For non Windows system.
2021-03-07 20:26:46 +01:00
Andrea Corallo
dbdc44db15 Allow for `comp-native-driver-options' to work as a file-local variable. 2021-03-07 20:19:20 +01:00
Eli Zaretskii
619f66f423 Use MS-Windows system APIs to get number of processors
* lisp/emacs-lisp/comp.el: Use 'w32-get-nproc' instead of the
environment variable NUMBER_OF_PROCESSORS.

* src/w32proc.c (Fw32_get_nproc): New primitive.
* src/w32.c (w32_get_nproc): New function.
(sample_system_load): Call w32_get_nproc to initialize the number
of processors on this system.
* src/w32.h (w32_get_nproc): Add prototype.
2021-03-07 15:32:55 +02:00
Andrea Corallo
c60f2f458a Fix `comp-cstr-intersection-no-hashcons' for negated result cstr
* lisp/emacs-lisp/comp-cstr.el
	(comp-cstr-intersection-no-hashcons): When negated and
	necessary relax dst to t.
	* test/src/comp-tests.el (comp-tests-type-spec-tests): Add a test.
2021-03-06 23:17:14 +01:00
Pip Cet
6c73418c95 Fix miscompilation of funcall forms in some cases (bug#46974)
* lisp/emacs-lisp/comp.el (comp-call-optim-func): Call
comp-cstr-imm-vld-p before relying on comp-cstr-imm to return the
right value.
2021-03-06 20:53:57 +00:00
Andrea Corallo
3848f3bff0 * lisp/emacs-lisp/comp.el (comp-add-cond-cstrs-simple): Suppress warning. 2021-03-06 20:52:34 +01:00
Andrea Corallo
05259c4a23 Fix `=' propagation to handle -0.0 0.0 case
* lisp/emacs-lisp/comp-cstr.el
	(comp-cstr-intersection-homogeneous): Fix indent + use `memql'.
	(comp-cstr-=): Handle 0.0 -0.0 idiosyncrasy
	* test/src/comp-tests.el (comp-tests-type-spec-tests): Add two
	tests and fix enumeration.
2021-03-06 20:38:00 +01:00
Stefan Monnier
b24c21e82c * lisp/emacs-lisp/bindat.el (bindat-struct): Fix Edebug def 2021-03-06 13:19:46 -05:00
Basil L. Contovounesios
d925121b1e Various map.el improvements
* lisp/emacs-lisp/seq.el (seq-do-indexed): Return nil as per doc.

* lisp/emacs-lisp/map.el: Require Emacs >= 26 due to dependence on
5-arg alist-get.  Bump package to version 3.0.  Fix other
headers.  (Bug#46754)
(map--plist-p): Detect list starting with nil as plist, not alist.
(map-elt, map-filter, map-apply, map--make-pcase-bindings)
(map--make-pcase-patterns): Simplify.
(map-let, map-put, map-nested-elt, mapp): Update docstring for plist
support.
(map-delete): Fix OBOE on arrays.  Split into cl-defmethods.
(map-values, map-values-apply): Specialize for arrays.
(map-pairs, map-keys-apply, map-put!): Improve docstring.
(map-length): Clarify docstring w.r.t. duplicate keys.  Split into
cl-defmethods.  Optimize default implementation.
(map-copy): Use copy-alist on alists.  Split into cl-defmethods.
(map-contains-key): Add plist support.  Clarify docstring
w.r.t. optional argument.  Simplify default implementation.
(map-some, map-every-p, map-merge, map-merge-with, map--into-hash):
Don't use map-apply for side effects.
(map-into): Preserve plist ordering.  Improve docstrings.
(map-insert): Add hash-table and array support.
(map-inplace): Remove unused error symbol.
(map-do): Return nil as per doc.

* etc/NEWS: Announce new user-visible behavior.

* test/lisp/emacs-lisp/map-tests.el: Prefer should-not
over (should (not ...)) in general.
(with-maps-do): Fix docstring.
(with-empty-maps-do): New macro.
(test-map-elt-default, test-mapp, test-map-keys, test-map-values)
(test-map-pairs, test-map-length, test-map-copy, test-map-apply)
(test-map-do, test-map-keys-apply, test-map-values-apply)
(test-map-filter, test-map-remove, test-map-empty-p)
(test-map-contains-key, test-map-some, test-map-every-p):
Use it.

(test-map-plist-p, test-map-put!-new-keys, test-map-insert-empty)
(test-map-insert, test-map-delete-empty, test-map-copy-alist)
(test-map-contains-key-testfn, test-map-into-hash-test)
(test-map-into-empty, test-map-merge, test-map-merge-empty):
New tests.

(test-map-elt): Test array key that is within bounds but not fixnum.
(test-map-put!): Use map--plist-p.  Remove redundant tests.
(test-map-put-alist-new-key): Don't modify list literal.
(test-map-put-testfn-alist, test-map-put-return-value): Silence
obsoletion warnings.
(test-map-delete): Check for OBOE on arrays.
(test-map-delete-return-value): Remove test made redundant by
test-map-delete.
(test-map-nested-elt, test-map-into): Test plists too.
2021-03-06 16:00:52 +00:00
Stefan Kangas
4b5155673d ; Fix typo. 2021-03-06 04:10:45 +01:00
Stefan Monnier
533c659b6c Bindat: new macro-expansion based data layout language
Thorough redesign of the Bindat system, which makes it possible
to define new Bindat type forms, define recursive types, control
the values returned when unpacking, freely mix arbitrary computations
with type definitions, as well as support for arbitrary sized
integers.

This also reverts the recent addition of the `bindat-spec` macro and
the support for 64bit integers in the old Bindat language since that
is now considered obsolete anyway.

* doc/lispref/processes.texi (Bindat Types): Rename from `Bindat Spec`
and rewrite for the new sublanguage.
(Bindat Functions): Adjust to the new terminology.
(Bindat Computed Types): New node.

* lisp/emacs-lisp/bindat.el (bindat--type): New type.
(bindat--unpack-u64, bindat--unpack-u64r): Delete functions.
(bindat--unpack-item, bindat--pack-item, bindat--fixed-length-alist):
Revert addition of support for 64bit integers.
(bindat--unpack-group, bindat--length-group, bindat--pack-group):
Handle the new `bindat--type` values.
(bindat-spec): Revert addition of this macro.
(bindat--unpack-uint, bindat--unpack-uintr, bindat--pack-uint)
(bindat--pack-uintr): New functions.
(bindat-type, bindat-defmacro, bindat--pcase): New macros.
(bindat-type): New Edebug elem.
(bindat--type): New generic function.
(bindat--primitives): New constant.
(bindat--macroenv, bindat--op): New vars.
(bindat--make-docstring, bindat--fun, bindat--makefun, bindat--toplevel):
New functions.

* test/lisp/emacs-lisp/bindat-tests.el: Use `bindat-type`.
(ip): New Bindat type.
(header-bindat-spec, data-bindat-spec, packet-bindat-spec): Adjust to
new `bindat-type` macro.
(bindat-test-unpack): Simplify now that the order of fields is preserved.
(bindat-test--int-websocket-type, bindat-test--LEB128): New consts.
(bindat-test--pack-val, bindat-test--sint, bindat-test--recursive):
New tests.
2021-03-05 19:56:31 -05:00
Mattias Engdegård
1362a9fec4 Make lambda-lifting work again
* lisp/emacs-lisp/cconv.el (cconv--analyze-use): Fix typo.
* test/lisp/emacs-lisp/cconv-tests.el (cconv-convert-lambda-lifted):
Add test case.
2021-03-05 21:41:58 +01:00
Stefan Monnier
03ada27cb8 * lisp/emacs-lisp/bindat.el: Minor refactoring
(bindat--unpack-str, bindat--unpack-strz, bindat--unpack-bits):
New functions, extracted from `bindat--unpack-item`.
(bindat--unpack-item): Use them.
(bindat--align): New function.
(bindat--unpack-group, bindat--length-group, bindat--pack-group): Use it.
(bindat-get-field): Allow integers to index both lists (as returned by
`repeat`) and vectors (as returned by `vec`).
(bindat--pack-str, bindat--pack-bits): New functions, extracted from
`bindat--pack-item`.
(bindat--pack-item): Use them.

* test/lisp/emacs-lisp/bindat-tests.el (struct-bindat): Place the fields
in the order in which they appear in the structs.
2021-03-05 13:31:16 -05:00
Stefan Monnier
c881e990e3 * lisp/emacs-lisp/gv.el (edebug-after): Don't run the getter in the setter
This fixes bug#46573 which was introduced by commit
d79cf638f2.
The new code is a middle ground, which makes sure the instrumentation
point is used (so the coverage checker won't have ghost unreachable
instrumentation points) yet without artificially running the getter
when we only need to run the setter.
2021-03-05 12:39:27 -05:00