Commit graph

9776 commits

Author SHA1 Message Date
Stefan Monnier
d67e08d6c3 Merge branch 'track-changes' 2024-04-13 09:44:12 -04:00
Stefan Monnier
d7a83e23d4 lisp/emacs-lisp/track-changes.el: New file (bug#70077)
This new package provides an API that is easier to use right than
our `*-change-functions` hooks.

The patch includes changes to `diff-mode.el` and `eglot.el` to
make use of this new package.

* lisp/emacs-lisp/track-changes.el: New file.
* test/lisp/emacs-lisp/track-changes-tests.el: New file.
* doc/lispref/text.texi (Tracking changes): New subsection.

* lisp/progmodes/eglot.el: Require `track-changes`.
(eglot--virtual-pos-to-lsp-position): New function.
(eglot--track-changes): New var.
(eglot--managed-mode): Use `track-changes-register` i.s.o
`after/before-change-functions` when available.
(eglot--track-changes-signal): New function, partly extracted from
`eglot--after-change`.
(eglot--after-change): Use it.
(eglot--track-changes-fetch): New function.
(eglot--signal-textDocument/didChange): Use it.

* lisp/vc/diff-mode.el: Require `track-changes`.
Also require `easy-mmode` before the `eval-when-compile`s.
(diff-unhandled-changes): Delete variable.
(diff-after-change-function): Delete function.
(diff--track-changes-function): Rename from `diff-post-command-hook`
and adjust to new calling convention.
(diff--track-changes): New variable.
(diff--track-changes-signal): New function.
(diff-mode, diff-minor-mode): Use it with `track-changes-register`.
2024-04-13 09:43:11 -04:00
Andrea Corallo
3eb462405e * lisp/emacs-lisp/comp-cstr.el (comp-cstr-type-p): Improve last change. 2024-04-10 18:45:47 +02:00
Andrea Corallo
ee03a73375 * lisp/emacs-lisp/comp-cstr.el (comp-cstr-type-p): New function. 2024-04-10 18:16:26 +02:00
Andrea Corallo
d4d8575bf0 * lisp/emacs-lisp/comp-cstr.el (comp-cstr-symbol-p): Simplify. 2024-04-10 18:16:26 +02:00
Andrea Corallo
219b98916b * lisp/emacs-lisp/comp-cstr.el (comp-cstr-fixnum-p): Fix. 2024-04-10 18:16:26 +02:00
Andrea Corallo
f471181129 * lisp/emacs-lisp/cl-macs.el (cl-typep): Add docstring. 2024-04-10 15:30:08 +02:00
Stefan Monnier
dd6b9c9426 (cl--describe-class-slots): Avoid cryptic t type
* lisp/emacs-lisp/cl-extra.el (cl--describe-class-slots): Use the empty
string for the trivial `t` type.

* lisp/emacs-lisp/cl-preloaded.el (cl-structure-class):
Fix non-existing `bool` => `boolean`.
2024-04-09 18:33:01 -04:00
Mattias Engdegård
cda5155c61 Inhibit flymake lexical cookie warning in *scratch* (bug#70068)
Add a hack to prevent flymake from complaining about a missing lexical
cookie when enabled in *scratch*.

* lisp/emacs-lisp/bytecomp.el
(bytecomp--inhibit-lexical-cookie-warning): New variable.
(byte-compile-file): Use it to gate the warning.
* lisp/progmodes/elisp-mode.el (elisp-flymake-byte-compile):
Set the inhibitor when spawning a check in lisp-interaction-mode.
2024-04-09 10:56:44 +02:00
Stefan Monnier
dc5fe95a48 (cl--describe-class): Improve based on dicussion in bug#70077
* lisp/emacs-lisp/cl-extra.el (cl--describe-class): Move docstring
after the class' slots.
(cl--describe-class-slots): Buttonize the types.
2024-04-08 13:59:58 -04:00
Stefan Monnier
9506b9392e (define-globalized-minor-mode): Fix bug#69431
* lisp/emacs-lisp/easy-mmode.el (define-globalized-minor-mode):
When `after-change-major-mode-hook` runs, enable the mode only
in the current buffer and not in other pending buffers.
2024-04-08 08:18:31 -04:00
Andrea Corallo
c9d7721db6 * Make comp ignore EIEIO classes (bug#70141)
* lisp/emacs-lisp/comp-cstr.el (comp--all-classes): Ignore EIEIO classes.
2024-04-08 12:07:22 +02:00
Eli Zaretskii
5f89da1423 Merge from origin/emacs-29
46b8746b38 Fix warning-suppress for list type "warning type"
910ea5f1e5 Make object init more robust (bug#69571)
2024-04-06 11:13:34 -04:00
Mattias Engdegård
fa9791fe6a Revert "Check if lexical-binding is enabled before warning"
This reverts commit 7de192680f.
The logic is wrong (bug#70068).
2024-04-03 11:28:49 +02:00
Philip Kaludercic
7de192680f Check if lexical-binding is enabled before warning
* lisp/emacs-lisp/bytecomp.el (byte-compile-file): Suppress "file
has no `lexical-binding' directive" is the variable is non-nil,
as is the case with 'lisp-interaction-mode'.  (Bug#70068)
2024-04-03 10:52:12 +02:00
Vladimir Kazanov
3f9263f791 Fix symbol list matching regexps.
Fix symbol list matching regexp performance

Allow empty face lists, improve the face list matching regexp (see
discussion in Bug#69714) based on relint's comments, add tests:
* test/lisp/emacs-lisp/ert-font-lock-tests.el: Add tests.
* lisp/emacs-lisp/ert-font-lock.el: Fix regexps.
2024-04-01 11:13:12 +02:00
Mattias Engdegård
155462a1bd Fix mutates-arguments warning for sort
* lisp/emacs-lisp/bytecomp.el (bytecomp--sort-call-in-place-p)
(bytecomp--mutargs-nconc, bytecomp--mutargs-sort): New.
(byte-compile-form, bytecomp--actually-important-return-value-p)
(mutating-fns):
Use a slightly more extendible scheme for specifying what arguments
a function mutates.  Give `sort` special treatment.
2024-04-01 09:42:46 +02:00
Xuan Wang
46b8746b38 Fix warning-suppress for list type "warning type"
Per the documentation of 'warning-suppress-types' and the
implementation of 'warning-suppress-p', a warning type can
be either a symbol or a list of symbols.  The previous
implementation could generate wrong 'warning-suppress-types':

  old behavior:
  type              warning-suppress-types
  pkg           ->    '((pkg))                  Correct
  (pkg subtype) ->    '(((pkg subtype)))        Incorrect

Now we check whether type is a cons cell first.  (Should not
use listp here, as listp returns t for nil.)

  new behavior:
  type              warning-suppress-types
  pkg           ->    '((pkg))                Correct
  (pkg subtype) ->    '((pkg subtype))        Correct

* lisp/emacs-lisp/warnings.el (warnings-suppress): Fix saving
warning types in 'warning-suppress-types'.  (Bug#70063)

Copyright-paperwork-exempt: yes
2024-03-31 12:06:15 +03:00
Stefan Monnier
717e7edc2a * lisp/emacs-lisp/comp.el (comp--add-cond-cstrs): Consolidate 2 cases 2024-03-29 15:36:45 -04:00
Mattias Engdegård
b20866c4b3 Better sort ignored-return-value warning
* lisp/emacs-lisp/bytecomp.el (byte-compile-form)
(bytecomp--actually-important-return-value-p):
Special handling of `sort` that takes into account that it may return
an important value depending on the :in-place keyword argument.
2024-03-29 11:39:38 +01:00
Mattias Engdegård
1232ab31c6 Add value< (bug#69709)
It's a general-purpose polymorphic ordering function, like `<` but
for any two values of the same type.

* src/data.c (syms_of_data): Add the `type-mismatch` error.
(bits_word_to_host_endian): Move...
* src/lisp.h (bits_word_to_host_endian): ...here, and declare inline.
* src/fns.c (Fstring_lessp): Extract the bulk of this function to...
(string_cmp): ...this 3-way comparison function, for use elsewhere.
(bool_vector_cmp, value_cmp, Fvaluelt): New.
* lisp/emacs-lisp/byte-opt.el (side-effect-free-fns, pure-fns):
Add `value<`, which is pure and side-effect-free.
* test/src/fns-tests.el (fns-value<-ordered, fns-value<-unordered)
(fns-value<-type-mismatch, fns-value<-symbol-with-pos)
(fns-value<-circle, ert-deftest fns-value<-bool-vector): New tests.
* doc/lispref/sequences.texi (Sequence Functions):
* doc/lispref/numbers.texi (Comparison of Numbers):
* doc/lispref/strings.texi (Text Comparison):
Document the new value< function.
* etc/NEWS: Announce.
2024-03-29 11:39:38 +01:00
Stefan Monnier
4cee95815b pp.el: Try and fix bug#70039
* lisp/emacs-lisp/pp.el (pp-fill): Avoid splitting `#N#` or `#[`.
* test/lisp/emacs-lisp/pp-tests.el (pp-tests--sanity): New test.
2024-03-28 15:31:04 -04:00
Stefan Monnier
de9e913f9e * lisp/emacs-lisp/cl-macs.el (list): Predefine predicate by hand 2024-03-28 12:27:54 -04:00
Vladimir Kazanov
cdd7093e17 Improve ert-font-lock assertion parser (Bug#69714)
Fail on files with no assertions, parser now accepts multiple
carets per line and face lists:
* lisp/emacs-lisp/ert-font-lock.el: Assertion parser fix.
* test/lisp/emacs-lisp/ert-font-lock-resources/no-asserts.js:
* test/lisp/emacs-lisp/ert-font-lock-tests.el
(test-parse-comments--no-assertion-error)
(test-syntax-highlight-inline--caret-negated-wrong-face)
(test-macro-test--file-no-asserts): New test cases.
* doc/misc/ert.texi (Syntax Highlighting Tests): More syntax examples.
2024-03-28 11:40:27 +02:00
Eli Zaretskii
35ae2c576b ; * lisp/emacs-lisp/pcase.el (pcase--subtype-bitsets): Doc fix. 2024-03-28 11:34:25 +02:00
Stefan Monnier
f1fe13ea05 (pcase-mutually-exclusive): Use auto-generated table
The `pcase-mutually-exclusive-predicates` table was not very
efficient since it grew like O(N²) with the number of
predicates.  Replace it with an O(N) table that's auto-generated
from the `built-in-class` objects.

* lisp/emacs-lisp/pcase.el (pcase-mutually-exclusive-predicates):
Delete variable.
(pcase--subtype-bitsets): New function and constant.
(pcase--mutually-exclusive-p): Use them.
* lisp/emacs-lisp/cl-preloaded.el (built-in-class): Don't inline.
2024-03-28 00:06:00 -04:00
Stefan Monnier
e5d824b632 cl-preloaded.el: Partly revert last change
The change caused type-check errors in auth-source where they use
`:type function` constraints on object slots and expect those to
be able to hold symbols.

* lisp/emacs-lisp/cl-preloaded.el (function): Revert last change.

* test/src/data-tests.el (data-tests--cl-type-of): Use `cl-functionp`
rather than `functionp` to test `function`.
2024-03-26 17:27:29 -04:00
Stefan Monnier
004f2493a5 cl-preloaded.el: Fix the type lattice
We generally want types to form not just a DAG but a lattice.
If objects can be both `keyword` and `symbol-with-pos`, this
means there should be a more precise type describing this intersection.
If we ever find the need for such a refinement, we could add
such a `keyword-with-pos` type, but here I took the simpler
route of treating `keyword` not as a proper built-in type but
as a second-class type like `natnum`.

While fixing this problem, also fix the problem we had where
`functionp` was not quite adequate to characterize objects of type
`function`, by introducing a new predicate `cl-functionp` for that.

* lisp/emacs-lisp/cl-preloaded.el (cl-functionp): New function.
(function): Use it.
(keyword): Don't declare it as a built-in type.
(user-ptrp): Remove redundant declaration.

* lisp/emacs-lisp/cl-generic.el (cl--generic--unreachable-types):
Delete constant.
(cl-generic-generalizers): Remove corresponding test.

* lisp/emacs-lisp/cl-macs.el (cl-deftype-satisfies): Add entry for
`keyword` type.

* lisp/emacs-lisp/comp.el (comp-known-predicates): Fix type for
negative result of `characterp`.  Remove duplicate `numberp` entry.
Fix types for `keywordp` now that `keyword` is not a built-in type any more.

* test/src/data-tests.el (data-tests--cl-type-of): Add a few cases.
Remove workaround for `function`.
2024-03-26 13:14:15 -04:00
Andrea Corallo
8cc67dbcec Fix native comp prediction on null functionp tested objects
* lisp/emacs-lisp/comp.el (comp-known-predicates)
(comp-known-predicates-h): Update.
(comp--pred-to-pos-cstr, comp--pred-to-neg-cstr): New functions.
(comp--add-cond-cstrs): Make use of them.

* test/src/comp-tests.el (comp-tests-type-spec-tests): Add a test.
2024-03-26 11:14:08 +01:00
Andrea Corallo
95d9e6eb6b * Don't install unnecessary trampolines (bug#69573) (don't merge)
* lisp/emacs-lisp/comp.el (comp-subr-trampoline-install):
Check that subr-name actually matches the target subr.
2024-03-26 08:32:37 +01:00
Stefan Monnier
83a6e80d66 (byte-optimize-form-code-walker): Simplify a bit
Eliminate a case that matches very rarely and where the default
handling works just as well anyway.

* lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker): Remove
redundant case.
2024-03-24 22:13:44 -04:00
Andrea Corallo
c5de73a95a Fix native compilation for circular immediates (bug#67883)
* test/src/comp-resources/comp-test-funcs.el
(comp-test-67883-1-f): New function.

* lisp/emacs-lisp/comp.el (comp--collect-rhs)
(comp--ssa-rename-insn): Handle setimm aside to avoid unnecessary
immediate manipulation.
(comp--copy-insn-rec): Rename.
(comp--copy-insn): New function.
(comp--dead-assignments-func): Handle setimm aside to avoid
unnecessary.
2024-03-24 12:16:11 +01:00
Po Lu
30b1b0d7cd ; * lisp/emacs-lisp/cl-preloaded.el (user-ptr): Fix typo.
Author:
2024-03-24 11:05:31 +08:00
Po Lu
7206a620af Don't define user-ptr type when user-ptrp is not present
* lisp/emacs-lisp/cl-preloaded.el (user-ptr): Condition on
presence of predicate function.
2024-03-24 11:03:51 +08:00
Stefan Monnier
a496378c94 cl-preloaded.el: Improve docstrings of "kinds"
* lisp/emacs-lisp/cl-preloaded.el (cl--class): Improve the docstring.
(built-in-class): Add a docstring.
2024-03-23 22:48:17 -04:00
Stefan Monnier
ef859d8b1b edebug.el: Better strip instrumentation from backtraces
Rework the code that "cleans" the backtrace for `edebug-pop-to-backtrace`.
The main changes are the following:

- Strip instrumentation from "everywhere" rather than trying to limit the
  effect to "code" and leave "data" untouched.  This is a worthy
  goal, but it is quite difficult to do since code contains data
  (so we ended up touching data anyway) and data can also
  contain code.
  The risk of accidentally removing something because it happens
  to look like instrumentation is very low, whereas it was very common
  for instrumentation to remain in the backtrace.

- Use a global hash-table to remember the work done, instead of
  using separate hash-table for each element.  By using a weak
  hash-table we avoid the risk of leaks, and save a lot of work
  since there's often a lot of subexpressions that appear
  several times in the backtrace.

* lisp/emacs-lisp/edebug.el (edebug-make-enter-wrapper): Tweak code
layout so the comments are more clear.
(edebug-unwrap): Remove redundant patterns for `closure` and `lambda`.
Add `:closure-dont-trim-context` to the `edebug-enter` pattern,
so it also gets removed (this should have been done in commit
750bc57cbb).
(edebug--unwrap-cache): New var.
(edebug-unwrap*): Use it.
(edebug--unwrap1): Delete function.  Merged into `edebug-unwrap*`.
Also apply unwrapping to the contents of byte-code functions since they
can refer to lambda expressions captured by the closure.
(edebug--symbol-prefixed-p): Rename from
`edebug--symbol-not-prefixed-p` and adjust meaning accordingly.
(edebug--strip-instrumentation): Adjust accordingly and simplify
a bit by unifying the "lambda" case and the "everything else" case.
(edebug--unwrap-frame): Use `cl-callf` and unwrap arguments even if
they've already been evaluated.
2024-03-23 19:21:26 -04:00
Stefan Monnier
0f04aa06a6 (describe-package-1): Fix bug#69712
* lisp/emacs-lisp/package.el (describe-package-1): Improve the test to
determine if `maintainers` contains a single cons or a list of conses.
2024-03-23 16:11:07 -04:00
Eli Zaretskii
e813c0fa3a Merge from origin/emacs-29
689f04a2dd Clarify description of format-spec truncation
759dedfab0 More accurate documentation of 'rmail-mail-new-frame'
fa79de7c6b ; * lisp/calendar/calendar.el: Remove extra space.
7f6e335f4b Fix documentation of M-SPC in user manual
5bdc2436c6 ; * lisp/emacs-lisp/cl-macs.el (cl-labels): Fix stray dif...
8014dbb2ad * admin/notes/bugtracker: Minor copyedit.
06a991e7e8 ; * admin/notes/bugtracker: Minor copyedit.
c890622e1a Tweak regexp for object initializers in csharp-mode (bug#...
f48babb112 `term-mode': mention the keymap to add keybindings to
8cf05d9be1 Fix 'shortdoc-copy-function-as-kill'
d5901f3f05 Improve documentation of 'edebug-print-*' variables
2024-03-23 06:51:39 -04:00
Stefan Monnier
7e32e8392a Fix recent test regressions
* lisp/emacs-lisp/pp.el (pp-fill): Don't cut between `#` and `(`.

* test/lisp/help-fns-tests.el (help-fns-test-built-in)
(help-fns-test-interactive-built-in, help-fns-test-lisp-defun)
(help-fns-test-lisp-defsubst):
* test/src/emacs-module-tests.el (module/describe-function-1):
Adjust tests to new wording in `describe-function`.
2024-03-22 18:44:54 -04:00
Stefan Monnier
7269a2f158 (pp-fill): Cut before parens and dots
The `pp-fill` code sometimes end up generating things like:

    (foo .
         bar)

instead of

    (foo
     .  bar)

so make sure we cut before rather than after the dot (and open
parens while we're at it).

* lisp/emacs-lisp/pp.el (pp-fill): Cut before parens and dots.

* test/lisp/emacs-lisp/pp-tests.el (pp-tests--dimensions): New function.
(pp-tests--cut-before): New test.
2024-03-22 16:46:28 -04:00
Stefan Monnier
accd79c939 (help-fns-function-description-header): Print functions' type
Instead of choosing English words to describe the kind of function,
use the actual type of the function object (from `cl-type-of`)
directly, and make it a button to display info about that type.

* lisp/help-fns.el (help-fns-function-description-header): Use the
function's type name in the description instead of "prose".
Use `insert` instead of `princ`, so as to preserve the text-properties
of the button.

* lisp/emacs-lisp/cl-extra.el (cl-help-type): Move to `help-mode.el`
and rename to `help-type`.
(cl--describe-class): Adjust accordingly.

* lisp/help-mode.el (help-type): New type, moved and renamed from
`cl-extra.el`.
2024-03-22 08:47:13 -04:00
Stefan Monnier
2000d6e0f2 (describe-symbol-backends): Fix addition of the "type" backend
That backend was added from `cl-extra.el` with no autoload, so
(describe-symbol `advice) failed to show the info about
the `advice` type unless `cl-extra.el` had been loaded beforehand.
`C-h o RET advice RET` worked by accident because the completion
table uses `cl-some` which is autoloaded from `cl-extra.el`.

* lisp/help-mode.el (describe-symbol-backends): Add the "type" backend.
* lisp/emacs-lisp/cl-extra.el (describe-symbol-backends): Don't add the
"type" backend here.
2024-03-21 18:27:03 -04:00
Stefan Monnier
05b8de54e3 byte-opt.el: Remove test that's not applicable any more
* lisp/emacs-lisp/byte-opt.el: Remove left-over test for ancient
byte-compiled representation.
2024-03-21 18:16:41 -04:00
Stefan Monnier
e819413e24 Speed up describe-char when a property has a large value
Doing `C-u C-x =` on a buffer position where the overlay/text
properties hold large values (e.g. inside the profiler report)
can be surprisingly slow because it pretty prints all those properties.
Change the code to do the pretty printing more lazily.
While at it, share that duplicated code between `descr-text.el` and
`wid-browse.el`.

* lisp/emacs-lisp/pp.el (pp-insert-short-sexp): New function.

* lisp/descr-text.el (describe-text-sexp): Delete function.
(describe-property-list): Use `pp-insert-short-sexp` instead.

* lisp/wid-browse.el (widget-browse-sexp): Use `pp-insert-short-sexp`
and `widget--allow-insertion`.
2024-03-21 12:28:54 -04:00
Andrea Corallo
51848e4731 * Fix missing `comp-files-queue' update (bug#63415).
* lisp/emacs-lisp/comp.el (native--compile-async): Update
`comp-files-queue' for real.
2024-03-21 12:02:33 +01:00
Adam Porter
393f58c85a 'vtable-update-object' can now be called with one argument
It's often necessary to update the representation of a single
object in a table (e.g a struct, whose identity does not change
when its slots'
values are changed).  To do so, now the function may be called
like this:

  (vtable-update-object table object)

Instead of like this:

  (vtable-update-object table object object)

This also documents the behavior of the just-discovered limitation filed
as bug#69837.
* lisp/emacs-lisp/vtable.el (vtable-update-object): Make 'old-object'
argument optional.  (Bug#69666)

* doc/misc/vtable.texi (Interface Functions): Update documentation.

* etc/NEWS: Add news entry.
2024-03-21 12:41:44 +02:00
Adam Porter
b3f04eb684 Avoid recomputing the whole table in 'vtable--recompute-numerical'
Each element of LINE being tested is a list, the first element of
which is the value actually being represented in the table.
Previously, the 'numberp' test would always fail, because it was
being compared with the list rather than the intended value in it;
that could cause the whole table to be recomputed, sometimes
unnecessarily.
* lisp/emacs-lisp/vtable.el (vtable--recompute-numerical): Test the
car of ELEM, not ELEM itself, which is a list.  (Bug#69927)
2024-03-21 09:43:07 +02:00
Andrea Corallo
0df28dc00e ; * lisp/emacs-lisp/comp-run.el (comp-run-async-workers): Fix indentation. 2024-03-20 16:59:33 +01:00
Eli Zaretskii
ae9d8eedfd ; Minor copyedits of last change. 2024-03-20 16:08:15 +02:00
Andrea Corallo
e2fec514fd ; * lisp/emacs-lisp/comp.el: Add a simple sanitizer usage example. 2024-03-20 14:55:44 +01:00