Andrea Corallo
8fb9463013
Merge remote-tracking branch 'savannah/master' into HEAD
2020-12-27 17:54:57 +01:00
Daniel Martín
80420faf49
Improve "find definition" in *Help* buffers
...
* lisp/emacs-lisp/find-func.el (find-function-search-for-symbol): If
our regexp algorithm could not find a location for the symbol
definition, resort to find-function--search-by-expanding-macros.
* test/lisp/emacs-lisp/find-func-tests.el: Add a automatic test for a
function and variable generated by a macro.
* etc/NEWS: Advertise the improved functionality (bug#45443).
2020-12-27 09:04:56 +01:00
Lars Ingebrigtsen
af359de917
Allow `string-limit' to work on encoded strings
...
* doc/lispref/strings.texi (Creating Strings): Document it.
* lisp/emacs-lisp/subr-x.el (string-limit): Allow limiting on
encoded strings.
2020-12-25 05:58:09 +01:00
Lars Ingebrigtsen
269cec13a2
Remove `string-slice' -- it's not very well defined
...
* doc/lispref/strings.texi (Creating Strings): Ditto.
* lisp/emacs-lisp/subr-x.el (string-slice): Remove.
2020-12-25 05:16:46 +01:00
Andrea Corallo
672988e961
Symplify (not t) => nil and (not nil) => t
...
* lisp/emacs-lisp/comp-cstr.el (comp-cstr-negation): Symplify (not
t) => nil and (not nil) => t.
* test/lisp/emacs-lisp/comp-cstr-tests.el
(comp-cstr-typespec-tests-alist): Add two tests.
2020-12-24 15:36:46 +01:00
Andrea Corallo
b99a474482
Merge remote-tracking branch 'savannah/master' into HEAD
2020-12-23 19:49:58 +01:00
Lars Ingebrigtsen
22c1f00d99
Allow string-slice to take zero-length matches
...
* lisp/emacs-lisp/subr-x.el (string-slice): Allow zero-length
matches. Code adapted from s.el by Magnar Sveen.
2020-12-23 07:45:19 +01:00
Lars Ingebrigtsen
051d8f7535
Make string-pad take an optional START parameter
...
* lisp/emacs-lisp/subr-x.el (string-pad): Alter the calling
convention.
2020-12-22 06:59:25 +01:00
Lars Ingebrigtsen
9480169f1b
Change the string-limit parameter semantics
...
* lisp/emacs-lisp/subr-x.el (string-limit): Alter the calling
convention.
2020-12-22 06:54:32 +01:00
Lars Ingebrigtsen
d2b8611862
Further string-clean-whitespace tweaks
...
* lisp/emacs-lisp/subr-x.el (string-clean-whitespace): Put \r
back, which was mistakenly removed.
2020-12-22 04:24:25 +01:00
Lars Ingebrigtsen
f329a3180e
Add string-chop-newline
...
* doc/lispref/strings.texi (Creating Strings): Document it.
* lisp/emacs-lisp/subr-x.el (string-chop-newline): Add new function.
2020-12-21 22:05:37 +01:00
Lars Ingebrigtsen
fd9431dde4
Fix shorter-than-length case for string-limit
...
* lisp/emacs-lisp/subr-x.el (string-limit): Fix
shorter-than-length case.
2020-12-21 20:42:17 +01:00
Andrea Corallo
9bbe6eab6c
Fix native compiler tests when they are bytecompiled
...
* test/lisp/emacs-lisp/comp-cstr-tests.el (comp-cstr-test-ts)
(comp-cstr-typespec-test, comp-cstr-typespec-tests-alist): Eval
also at compile time.
* test/src/comp-tests.el (comp-tests-type-spec-tests)
(comp-tests-define-type-spec-test): Likewise.
2020-12-21 20:22:03 +01:00
Andrea Corallo
e0f20da6ec
Simplify correctly (or (integer 1 1) (not (integer 1 1))) as t
...
* lisp/emacs-lisp/comp-cstr.el (comp-cstr-union-1-no-mem): Logic
update.
* test/lisp/emacs-lisp/comp-cstr-tests.el
(comp-cstr-typespec-tests-alist): Add a test.
2020-12-21 20:22:03 +01:00
Andrea Corallo
8e816b0ad5
Symplify type specifier (not t) as nil
...
* lisp/emacs-lisp/comp-cstr.el (comp-cstr-intersection-no-mem):
Add logic.
* test/lisp/emacs-lisp/comp-cstr-tests.el
(comp-cstr-typespec-tests-alist): Add two tests.
2020-12-21 20:22:03 +01:00
Andrea Corallo
7074988d13
* Add a type specifier test to comp-cstr-tests.el
...
* test/lisp/emacs-lisp/comp-cstr-tests.el
(comp-cstr-typespec-tests-alist): Add a test.
2020-12-21 20:22:02 +01:00
Lars Ingebrigtsen
cf2e832185
Rename slice-string to string-slice
...
* lisp/emacs-lisp/subr-x.el (string-slice): Rename from slice-string.
* doc/lispref/strings.texi (Creating Strings): Ditto.
2020-12-21 20:18:57 +01:00
Lars Ingebrigtsen
b3dec31766
Add `string-pad'
...
* doc/lispref/strings.texi (Creating Strings): Document it.
* lisp/emacs-lisp/shortdoc.el (string): Add example.
* lisp/emacs-lisp/subr-x.el (string-pad): New function.
2020-12-21 20:01:28 +01:00
Andrea Corallo
a0c0daf7a1
* Fix a number of type specifier simplification tests
...
* test/lisp/emacs-lisp/comp-cstr-tests.el
(comp-cstr-typespec-tests-alist): Fix a number of tests.
2020-12-21 19:01:22 +01:00
Lars Ingebrigtsen
87e422f104
Beef up the Emacs string utility set a bit
...
* doc/lispref/strings.texi (Modifying Strings): Document them.
* lisp/emacs-lisp/shortdoc.el (string): Add examples.
* lisp/emacs-lisp/subr-x.el (string-clean-whitespace)
(string-fill, string-limit, string-lines, slice-string): New
functions.
2020-12-21 18:53:40 +01:00
Andrea Corallo
f244c21902
Merge remote-tracking branch 'savannah/master' into HEAD
2020-12-20 22:08:42 +01:00
Philipp Stephani
7fad959114
Ensure that byte compilation works for relative files (Bug#45287).
...
* lisp/emacs-lisp/bytecomp.el (byte-compile-file): Don’t fail if
target filename doesn’t contain a directory name.
* test/lisp/emacs-lisp/bytecomp-tests.el
(bytecomp-tests--target-file-no-directory): New unit test.
2020-12-17 12:19:27 +01:00
Philipp Stephani
fe50a8b9ba
Byte compilation: handle case where the output file is a mountpoint.
...
See Bug#44631. While testing for a readonly output directory has
slightly different semantics, in practice they should cover cases
where Emacs is sandboxed and can only write to the destination file,
not its directory.
* lisp/emacs-lisp/bytecomp.el (byte-compile-file): Handle the case
where the output directory is not writable.
* test/lisp/emacs-lisp/bytecomp-tests.el
(bytecomp-tests--not-writable-directory)
(bytecomp-tests--dest-mountpoint): New unit tests.
2020-12-13 17:17:21 +01:00
Andrea Corallo
0ded37fdad
* Add initial negated non-negegated intersection support
...
* lisp/emacs-lisp/comp-cstr.el (comp-range-intersection): Cosmetic.
(comp-cstr-intersection-homogeneous): Rename from
`comp-cstr-intersection'.
(comp-cstr-intersection): New function.
2020-12-13 00:58:12 +01:00
Andrea Corallo
6286945396
Normalize cstrs for cache hint effectiveness and test stability
...
* lisp/emacs-lisp/comp-cstr.el (comp-normalize-valset)
(comp-union-valsets, comp-intersection-valsets)
(comp-normalize-typeset): New functions.
(comp-union-typesets, comp-intersect-typesets)
(comp-cstr-union-homogeneous-no-range, comp-cstr-union-1-no-mem):
Update to return normalized results.
* test/lisp/emacs-lisp/comp-cstr-tests.el
(comp-cstr-typespec-tests-alist): Normalize expected type specifiers.
2020-12-12 16:30:16 +01:00
Andrea Corallo
725c7e1416
* Enumerate type specifier tests to ease debugging
...
* test/lisp/emacs-lisp/comp-cstr-tests.el
(comp-cstr-typespec-tests-alist): Enumerate tests.
Acked-by: Andrea Corallo <akrl@sdf.org>
2020-12-12 16:30:16 +01:00
Andrea Corallo
0474fda62d
Merge remote-tracking branch 'savannah/master' into HEAD
2020-12-12 15:31:33 +01:00
Lars Ingebrigtsen
3ed3a33cb1
Fix copyright line
2020-12-11 23:18:01 +01:00
Lars Ingebrigtsen
004d7e97e2
Add a new command `memory-report'
...
* doc/lispref/internals.texi (Garbage Collection): Document it.
* lisp/emacs-lisp/memory-report.el: New package.
2020-12-11 14:49:53 +01:00
Stefan Kangas
3b20c03316
Prefer setq-local in tests
...
* test/lisp/allout-tests.el (allout-test-resumption-prior-value-resumed)
(allout-test-resumption-multiple-holds)
(allout-test-resumption-unbinding):
* test/lisp/emacs-lisp/faceup-resources/faceup-test-mode.el
(faceup-test-mode):
* test/lisp/epg-tests.el (with-epg-tests):
* test/src/data-tests.el (binding-test-buffer-A): Prefer setq-local.
2020-12-08 08:57:22 +01:00
Philipp Stephani
0155bd0fdb
Fix bug in how ERT invokes its debugger.
...
The debugger needs to receive a list of the error symbol and data;
cf. the documentation of the `debugger' variable. This bug manifested
itself in ERT forms such as (should (integerp (ert-fail "Boo"))),
which resulted in an incorrect condition object. Note that forms such
as (should (ert-fail "Boo")) weren't affected because they wouldn't
use the `ert--should-signal-hook'.
* test/emacs-lisp/ert.el (ert--should-signal-hook): Call debugger with
the right arguments.
* test/lisp/emacs-lisp/ert-tests.el (ert-test-fail-inside-should): Add
unit test.
2020-12-07 21:41:40 +01:00
Philipp Stephani
2d989e81b7
Unbreak a few unit tests that rely on lack of backtraces
...
* test/lisp/emacs-lisp/gv-tests.el (gv-dont-define-expander-in-file)
(gv-dont-define-expander-other-file):
* test/lisp/emacs-lisp/edebug-tests.el (edebug-tests-with-default-config):
Suppress backtraces in batch mode to unbreak unit tests.
2020-12-07 11:59:06 +01:00
Andrea Corallo
715a1ca174
Merge remote-tracking branch 'savannah/master' into HEAD
2020-12-06 18:07:27 +01:00
Andrea Corallo
ac40a60696
Couple of `comp-cstr-union-1-no-mem' improvements for mixed neg pos union
...
* lisp/emacs-lisp/comp-cstr.el (comp-cstr-union-1-no-mem):
Generalize disjoint pos types vs neg values conditions.
(comp-cstr-union-1-no-mem): Do not propagate ranges when we are
already returning integer as generic type.
* test/lisp/emacs-lisp/comp-cstr-tests.el
(comp-cstr-typespec-tests-alist): Add corresponding tests.
2020-12-06 18:02:18 +01:00
Andrea Corallo
2eb41ec137
More improvements to `comp-cstr-union-1' for mixed positive/negative cases
...
* lisp/emacs-lisp/comp-cstr.el (comp-cstr-union-1): Better handle
mixed positive/negated cases.
* test/lisp/emacs-lisp/comp-cstr-tests.el
(comp-cstr-typespec-tests-alist): Add a number of tests.
2020-12-05 19:01:04 +01:00
Andrea Corallo
726e40fb7c
Fix union of homogeneously negated input constraints
...
* lisp/emacs-lisp/comp-cstr.el (comp-cstr-union-1): Fix logic.
* test/lisp/emacs-lisp/comp-cstr-tests.el
(comp-cstr-typespec-tests-alist): Add a couple of tests.
2020-12-05 19:01:03 +01:00
Andrea Corallo
7c1d90a41d
Initial support for union of negated constraints
...
* lisp/emacs-lisp/comp-cstr.el (comp-range-negation): New
function.
(comp-cstr-union-homogeneous-no-range): Rename from
`comp-cstr-union-no-range'.
(comp-cstr-union-homogeneous): Rename from `comp-cstr-union'.
(comp-cstr-union-1): New function.
(comp-cstr-union-no-range, comp-cstr-union): Rewrite in function
of `comp-cstr-union-1'.
* test/lisp/emacs-lisp/comp-cstr-tests.el
(comp-cstr-typespec-tests-alist): Add a bunch of tests.
2020-12-05 19:01:03 +01:00
Andrea Corallo
9b85ae6aa5
Initial constraint negation support
...
* lisp/emacs-lisp/comp-cstr.el (comp-cstr): Add `neg' slot.
(comp-range-negation, comp-cstr-negation)
(comp-cstr-negation-make): New functions.
(comp-type-spec-to-cstr): Enable `not` in type specifiers.
(comp-cstr-to-type-spec): Update logic to handle negation.
* test/lisp/emacs-lisp/comp-cstr-tests.el
(comp-cstr-typespec-tests-alist): Add a test.
2020-12-05 19:01:03 +01:00
Stefan Kangas
55300e6cdc
Add tests for several byte-compiler warnings
...
* test/lisp/emacs-lisp/bytecomp-tests.el
(bytecomp/warn-autoload-not-on-top-level\.el)
(bytecomp/warn-callargs\.el)
(bytecomp/warn-defcustom-nogroup\.el)
(bytecomp/warn-defcustom-notype\.el)
(bytecomp/warn-defvar-lacks-prefix\.el)
(bytecomp/warn-format\.el)
(bytecomp/warn-lambda-malformed-interactive-spec\.el)
(bytecomp/warn-make-variable-buffer-local\.el)
(bytecomp/warn-redefine-defun-as-macro\.el)
(bytecomp/warn-redefine-defun\.el)
(bytecomp/warn-redefine-macro-as-defun\.el)
(bytecomp/warn-save-excursion\.el)
(bytecomp/warn-variable-let-bind-constant\.el)
(bytecomp/warn-variable-let-bind-nonvariable\.el)
(bytecomp/warn-variable-set-constant\.el)
(bytecomp/warn-variable-set-nonvariable\.el): New tests.
* test/lisp/emacs-lisp/bytecomp-resources/warn-autoload-not-on-top-level.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-callargs.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-defcustom-nogroup.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-defcustom-notype.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-defvar-lacks-prefix.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-format.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-lambda-malformed-interactive-spec.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-make-variable-buffer-local.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-redefine-defun-as-macro.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-redefine-defun.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-redefine-macro-as-defun.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-save-excursion.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-variable-let-bind-constant.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-variable-let-bind-nonvariable.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-variable-set-constant.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-variable-set-nonvariable.el:
* test/lisp/emacs-lisp/bytecomp-tests.el: New files.
2020-12-03 17:08:28 +01:00
Stefan Kangas
17d9d90ec2
Improve sectioning in bytecomp-tests.el
...
* test/lisp/emacs-lisp/bytecomp-tests.el: Add section comments.
(test-eager-load-macro-expansion)
(test-eager-load-macro-expansion-eval-and-compile): Move definitions.
2020-12-02 13:11:07 +01:00
Stefan Kangas
ace6eba036
Fix byte-compiler warning for failed uses of lexical vars
...
* lisp/emacs-lisp/bytecomp.el (byte-compile-form): Fix byte-compiler
warning for failed uses of lexical vars. (Bug#44980)
* test/lisp/emacs-lisp/bytecomp-tests.el
(bytecomp--define-warning-file-test): Don't prefix tests with
'warn'.
(bytecomp/error-lexical-var-with-add-hook\.el)
(bytecomp/error-lexical-var-with-remove-hook\.el)
(bytecomp/error-lexical-var-with-run-hook-with-args-until-failure\.el)
(bytecomp/error-lexical-var-with-run-hook-with-args-until-success\.el)
(bytecomp/error-lexical-var-with-run-hook-with-args\.el)
(bytecomp/error-lexical-var-with-symbol-value\.el): New tests.
* test/lisp/emacs-lisp/bytecomp-resources/error-lexical-var-with-symbol-value.el:
* test/lisp/emacs-lisp/bytecomp-resources/error-lexical-var-with-run-hook-with-args.el:
* test/lisp/emacs-lisp/bytecomp-resources/error-lexical-var-with-run-hook-with-args-until-success.el:
* test/lisp/emacs-lisp/bytecomp-resources/error-lexical-var-with-run-hook-with-args-until-failure.el:
* test/lisp/emacs-lisp/bytecomp-resources/error-lexical-var-with-remove-hook.el:
* test/lisp/emacs-lisp/bytecomp-resources/error-lexical-var-with-add-hook.el:
New files.
2020-12-01 13:35:03 +01:00
Stefan Kangas
4457b9590c
Add tests for some byte-compiler warnings
...
* test/lisp/emacs-lisp/bytecomp-tests.el
(bytecomp-warn/warn-interactive-only\.el)
(bytecomp-warn/warn-obsolete-defun\.el)
(bytecomp-warn/warn-obsolete-hook\.el)
(bytecomp-warn/warn-obsolete-variable-same-file\.el)
(bytecomp-warn/warn-obsolete-variable\.el): New tests.
* test/lisp/emacs-lisp/bytecomp-resources/warn-interactive-only.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-obsolete-defun.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-obsolete-hook.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-obsolete-variable-same-file.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-obsolete-variable.el:
New files.
2020-12-01 04:49:10 +01:00
Stefan Kangas
a126c3684f
Test byte-compiler free variable warning
...
* test/lisp/emacs-lisp/bytecomp-tests.el (ert-x): Require.
(bytecomp--define-warning-file-test): New macro.
(bytecomp-warn/warn-free-setq\.el)
(bytecomp-warn/warn-free-variable-reference\.el): New tests.
* test/lisp/emacs-lisp/bytecomp-resources/warn-free-setq.el:
* test/lisp/emacs-lisp/bytecomp-resources/warn-free-variable-reference.el:
New files.
2020-11-30 22:43:37 +01:00
Andrea Corallo
6523b84015
Merge remote-tracking branch 'savannah/master' into HEAD
2020-11-29 15:11:38 +01:00
Andrea Corallo
2e0256e0a0
Add intersection support into comp-cstr.el
2020-11-27 23:30:02 +01:00
Andrea Corallo
949b49cf77
Move some tests from comp-tests.el to comp-cstr-tests.el
...
* test/lisp/emacs-lisp/comp-cstr-tests.el
(comp-cstr-typespec-tests-alist): Add tests covering what was in:
`range-simple-union', `union-types', `destructure-type-spec'.
* test/src/comp-tests.el (range-simple-intersection, union-types)
(destructure-type-spec): Remove tests.
2020-11-26 22:03:22 +01:00
Andrea Corallo
23c082638e
Add comp-cstr.el and comp-cstr-tests.el
...
As the constraint logic of the compiler is not trivial and largely
independent from the rest of the code move it into comp-cstr.el to
ease separation and maintainability.
This commit improve the conversion type
specifier -> constraint for generality.
Lastly this should help with bootstrap time as comp.el compilation
unit is slimmed down.
* lisp/emacs-lisp/comp-cstr.el: New file.
(comp--typeof-types, comp--all-builtin-types): Move from comp.el.
(comp-cstr, comp-cstr-f): Same + rename.
(comp-cstr-ctxt): New struct.
(comp-supertypes, comp-common-supertype-2)
(comp-common-supertype, comp-subtype-p, comp-union-typesets)
(comp-range-1+, comp-range-1-, comp-range-<, comp-range-union)
(comp-range-intersection): Move from comp.el.
(comp-cstr-union-no-range, comp-cstr-union): Move from comp.el and
rename.
(comp-cstr-union-make): New function.
(comp-type-spec-to-cstr, comp-cstr-to-type-spec): Move from
comp.el, rename it and rework it.
* lisp/emacs-lisp/comp.el (comp-known-func-cstr-h): Rework.
(comp-ctxt): Remove two fields and include `comp-cstr-ctxt'.
(comp-mvar, comp-fwprop-call): Update for `comp-cstr' being
renamed.
(comp-fwprop-insn): Use `comp-cstr-union-no-range' or
`comp-cstr-union'.
(comp-ret-type-spec): Use `comp-cstr-union' and rework.
* test/lisp/emacs-lisp/comp-cstr-tests.el: New file.
(comp-cstr-test-ts, comp-cstr-typespec-test): New functions.
(comp-cstr-typespec-tests-alist): New defconst to generate tests
on.
(comp-cstr-generate-tests): New macro.
* test/src/comp-tests.el (comp-tests-type-spec-tests): Update.
(ret-type-spec): Initialize constraint context.
2020-11-26 22:02:30 +01:00
Philipp Stephani
5804ac0b49
Add a (broken) unit test to exemplify Bug#11218.
...
* test/lisp/emacs-lisp/ert-tests.el
(ert-test-with-demoted-errors): New (broken) unit test.
2020-11-24 18:39:58 +01:00
Stefan Kangas
9490f12c4d
Test for byte-compiler warning "variable lacks prefix"
...
* test/lisp/emacs-lisp/bytecomp-tests.el
(bytecomp--with-warning-test): New macro.
(bytecomp-warn-wrong-args, bytecomp-warn-wrong-args-subr):
Use above new macro.
(bytecomp-warn-variable-lacks-prefix): New test.
2020-11-22 07:19:11 +01:00
Stefan Kangas
b6339fc19c
Test interactive-only spec of with-suppressed-warnings
...
* test/lisp/emacs-lisp/bytecomp-tests.el
(bytecomp-test--with-suppressed-warnings): Test suppressing warning
with interactive-only.
2020-11-22 03:24:26 +01:00