Commit graph

9745 commits

Author SHA1 Message Date
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
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
Eli Zaretskii
1475e3c3b5 ; Fix doc strings of recent changes
* src/comp.c (syms_of_comp) <comp-sanitizer-active>:
* lisp/emacs-lisp/comp.el (comp-sanitizer-emit): Doc fixes.
2024-03-20 14:27:25 +02:00
Andrea Corallo
e8d2bc7531 ; * lisp/emacs-lisp/comp-cstr.el (comp--normalize-typeset0): Fix comment. 2024-03-20 12:01:10 +01:00
Andrea Corallo
0b0c7da8c8 Add native compiler sanitizer
* src/comp.c (ABI_VERSION): Bump new version.
(CALL0I): Uncomment.
(helper_link_table, declare_runtime_imported_funcs): Add
'helper_sanitizer_assert'.
(Fcomp__init_ctxt): Register emitter for
'helper_sanitizer_assert'.
(helper_sanitizer_assert): New function.
(syms_of_comp): 'helper_sanitizer_assert' defsym.
(syms_of_comp): 'comp-sanitizer-error' define error.
(syms_of_comp): 'comp-sanitizer-active' defvar.

* lisp/emacs-lisp/comp.el (comp-passes): Add 'comp--sanitizer'.
(comp-sanitizer-emit): Define var.
(comp--sanitizer): Define function.

* lisp/emacs-lisp/comp-run.el (comp-run-async-workers): Forward
'comp-sanitizer-emit'.
2024-03-20 09:51:10 +01:00
Robert Pluim
5bdc2436c6 ; * lisp/emacs-lisp/cl-macs.el (cl-labels): Fix stray diff marker. 2024-03-20 09:37:09 +01:00
Andrea Corallo
0f76baeac0 * Use 'cl-type-of' in comp-cstr.el
* lisp/emacs-lisp/comp-cstr.el (comp-cstr-union-homogeneous-no-range)
(comp-cstr-union-1-no-mem, comp-cstr-intersection-no-hashcons):
Make use of 'cl-type-of' in place of 'type-of'.
2024-03-19 11:05:40 +01:00
Eli Zaretskii
ce29ae32d0 ; * lisp/vc/vc-git.el (vc-git--out-str): Doc fix. 2024-03-18 15:59:54 +02:00
Stefan Monnier
70ac815ece * lisp/emacs-lisp/cl-preloaded.el (user-ptr): Add predicate 2024-03-18 09:38:23 -04:00
Stefan Monnier
63e67916b0 Followup changes to cl-type-of
These changes came up while working on `cl-type-of` but are not
directly related to the new `cl-type-of`.
The BASE_PURESIZE bump was needed at some point on one of my
machine, not sure why.

* src/puresize.h (BASE_PURESIZE): Bump up.
* src/sqlite.c (bind_value): Don't use `Ftype_of`.
* lisp/emacs-lisp/seq.el (seq-remove-at-position): Simplify.
* lisp/emacs-lisp/cl-preloaded.el (finalizer):
New (previously missing) type.
* doc/lispref/objects.texi (Type Predicates): Minor tweaks.
2024-03-18 09:32:53 -04:00
Stefan Monnier
e624bc6275 (primitive-function): New type
The type hierarchy and `cl-type-of` code assumed that `subr-primitive`
only applies to functions, but since it also accepts special-forms it makes
it an unsuitable choice since it can't be a subtype of `compiled-function`.
So, use a new type `primitive-function` instead.

* lisp/subr.el (subr-primitive-p): Fix docstring (bug#69832).
(primitive-function-p): New function.

* lisp/emacs-lisp/cl-preloaded.el (primitive-function): Rename
from `subr-primitive` since `subr-primitive-p` means something else.

* src/data.c (Fcl_type_of): Return `primitive-function` instead
of `subr-primitive` for C functions.
(syms_of_data): Adjust accordingly.

* test/src/data-tests.el (data-tests--cl-type-of): Remove workaround.
2024-03-18 09:32:49 -04:00
Stefan Monnier
706403f2aa (cl-type-of): New function to return more precise types (bug#69739)
* src/data.c (Fcl_type_of): New function, extracted from `Ftype_of`.
Make it return more precise types for symbols, integers, and subrs.
(Ftype_of): Use it.
(syms_of_data): Define the corresponding new symbols and defsubr
the new function.

* doc/lispref/objects.texi (Type Predicates): Document it.

* src/comp.c (emit_limple_insn): Use `Fcl_type_of`.

* lisp/emacs-lisp/cl-preloaded.el (subr): Demote it to `atom`.
(subr-native-elisp, subr-primitive): Add `compiled-function` as
parent instead.
(special-form): New type.

* lisp/obsolete/eieio-core.el (cl--generic-struct-tag):
* lisp/emacs-lisp/cl-generic.el (cl--generic-typeof-generalizer):
Use `cl-type-of`.
cl--generic--unreachable-types): Update accordingly.

test/src/data-tests.el (data-tests--cl-type-of): New test.
2024-03-18 09:29:47 -04:00
Stefan Monnier
445e2499ba debug.el: Prevent re-entering the debugger for the same error
We can have several active `handler-bind`s that all want to invoke the
debugger, in which case we can have the following sequence:

- The more deeply nested handler calls the debugger.
- After a while the user invokes `debugger-continue`.
- `signal_or_quit` propagates the error up the stack to the
  second handler, which calls the debugger again.
- The user thus ends up right back at the same place, as if
  `debugger-continue` had not be processed.

Fix this by remembering the last processed error and skipping
the debugger if we bump into it again.

* lisp/emacs-lisp/debug.el (debugger--last-error): New var.
(debugger--duplicate-p): New function.
(debug): Use them.
2024-03-16 23:10:48 -04:00
Eli Zaretskii
8cf05d9be1 Fix 'shortdoc-copy-function-as-kill'
* lisp/emacs-lisp/shortdoc.el (shortdoc-copy-function-as-kill):
Fix handling of functions with no arguments.  (Bug#69720)
2024-03-16 13:07:52 +02:00
Eli Zaretskii
d5901f3f05 Improve documentation of 'edebug-print-*' variables
* lisp/emacs-lisp/edebug.el (edebug-print-length)
(edebug-print-level): Fix doc strings and customization labels.
Suggested by Matt Trzcinski <matt@excalamus.com>.  (Bug#69745)
2024-03-16 12:42:16 +02:00
Stefan Monnier
7231a89524 * lisp/emacs-lisp/bindat.el (sint): Burp in dynbind (bug#69749) 2024-03-15 12:45:09 -04:00
Andrea Corallo
0055362855 * Don't install unnecessary trampolines (bug#69573)
* lisp/emacs-lisp/comp-run.el (comp-subr-trampoline-install):
Check that subr-name actually matches the target subr.
2024-03-15 14:44:22 +01:00
Andrea Corallo
c393c04679 * lisp/emacs-lisp/advice.el (comp-subr-trampoline-install): Don't declare. 2024-03-15 14:43:40 +01:00
Adam Porter
c94d680f6e Handle the case where 'vtable-update-object' doesn't find old object
* lisp/emacs-lisp/vtable.el (vtable-update-object): If OLD-OBJECT
is not found, don't call ELT, since SEQ-POSITION may return nil.
(Bug#69664)
2024-03-14 12:46:46 +02:00
Tim Landscheidt
6d1c1fca0a ; Simplify (with-current-buffer (get-buffer ...) ...)
There's no need to call 'get-buffer', since 'with-current-buffer'
does that internally.
* lisp/calendar/todo-mode.el (todo-merge-category):
* lisp/comint.el (comint-dynamic-list-completions):
* lisp/emacs-lisp/checkdoc.el (checkdoc-error):
* lisp/emacs-lisp/debug.el (debug, debugger-record-expression):
* lisp/emacs-lisp/eieio-opt.el (eieio-browse):
* lisp/emacs-lisp/re-builder.el (reb-restart-font-lock):
* lisp/erc/erc-dcc.el (erc-dcc-do-LIST-command):
* lisp/eshell/em-unix.el (eshell-poor-mans-grep):
* lisp/gnus/gnus-group.el (gnus-add-mark):
* lisp/net/eww.el (eww-next-bookmark, eww-previous-bookmark):
* lisp/net/sieve.el (sieve-upload):
* lisp/net/tramp-cmds.el (tramp-cleanup-some-buffers):
* lisp/obsolete/quickurl.el (quickurl-list-populate-buffer):
* lisp/org/ob-calc.el: (org-babel-execute:calc):
* lisp/org/org-agenda.el (org-agenda-use-sticky-p):
* lisp/pcomplete.el (pcomplete-show-completions):
* lisp/progmodes/bug-reference.el
(bug-reference--try-setup-gnus-article):
* lisp/progmodes/idlw-help.el
(idlwave-highlight-linked-completions):
* lisp/progmodes/verilog-mode.el (verilog-preprocess):
* lisp/replace.el (occur-1):
* lisp/term.el (term-dynamic-list-completions):
* lisp/time.el (world-clock-update):
* lisp/url/url-cache.el (url-store-in-cache):
* lisp/vc/vc-cvs.el (vc-cvs-merge, vc-cvs-merge-news):
* lisp/vc/vc-rcs.el (vc-rcs-system-release):
* lisp/vc/vc-svn.el (vc-svn-merge, vc-svn-merge-news):
* test/lisp/calendar/icalendar-tests.el
(icalendar-tests--get-error-string-for-export):
* test/lisp/erc/erc-dcc-tests.el
(pcomplete/erc-mode/DCC--get-1flag)
(pcomplete/erc-mode/DCC--get-2flags)
(pcomplete/erc-mode/DCC--get-2flags-reverse):
* test/lisp/erc/erc-networks-tests.el
(erc-networks--rename-server-buffer--existing--noreuse):
* test/lisp/erc/erc-scenarios-services-misc.el
(erc-scenarios-services-misc--reconnect-retry-nick):
* test/lisp/erc/erc-tests.el (erc--refresh-prompt):
Replace (with-current-buffer (get-buffer ...) ...) with
(with-current-buffer ...).
2024-03-14 12:40:26 +02:00
Adam Porter
013114664e * lisp/emacs-lisp/vtable.el (vtable-update-object): Fix.
The order of the arguments to 'seq-position' was wrong, and it did not
compare the correct values.  (Bug#69664)
2024-03-14 10:48:29 +02:00
Stefan Monnier
4afafa0370 Try and avoid hardcoding lists of function types
* lisp/bind-key.el (bind-key--get-binding-description):
Show docstrings for compiled functions also.  Don't hardcode knowledge
about various particular kinds of functions.

* lisp/emacs-lisp/bytecomp.el (display-call-tree): Remove special
support for functions with a `byte-code` body since we never generate
that nowadays.  Don't hardcode knowledge
about various particular kinds of functions.
2024-03-12 16:09:23 -04:00
Stefan Monnier
8df6739077 Cleanup some type predicates
Use the new `cl--define-built-in-type` to reduce the manually
maintained list of built-in type predicates.
Also tweak docstrings to use "supertype" rather than "super type",
since it seems to be what we use elsewhere.

* lisp/subr.el (special-form-p): Remove redundant `fboundp` test.
(compiled-function-p): Don'Return nil for subrs that aren't functions.

* lisp/emacs-lisp/cl-macs.el (type predicates): Trim down the list.

* lisp/emacs-lisp/cl-preloaded.el (cl--define-built-in-type):
Register the corresponding predicate if applicable.
(atom, null): Specify the predicate name explicitly.
2024-03-12 15:43:43 -04:00
Stefan Monnier
3e96dd4f88 cl-generic: Signal an error when a type specializer won't work
* lisp/emacs-lisp/cl-generic.el (cl--generic--unreachable-types): New var.
(cl-generic-generalizers :extra "typeof"): Use it to signal an
error for those types we can't handle.
2024-03-12 12:00:17 -04:00
Stefan Monnier
d5773276fb (comp-known-predicates): Fix overly optimistic functionp
* lisp/emacs-lisp/comp.el (comp-known-predicates): `functionp` can also
be true for `cons` objects.
2024-03-12 08:48:09 -04:00
Basil L. Contovounesios
75cfc6c73f ; Fix error message in last change to bindat.el
Remove trailing period as per "(elisp) Error Symbols".

Relates to the following discussion:
https://lists.gnu.org/r/emacs-devel/2023-10/msg00473.html
https://lists.gnu.org/r/emacs-devel/2024-03/msg00340.html
2024-03-11 11:16:20 +01:00
Michael Heerdegen
bbc53e0bcf Improve pp-emacs-lisp-code backquote form printing
* lisp/emacs-lisp/pp.el (pp--quoted-or-unquoted-form-p): New helper
function.
(pp--insert-lisp): Take care of quoted, backquoted and
unquoted expressions; print using an recursive call.
(pp--format-list): Exclude more cases from printing as a function call
by default.  Print lists whose second-last element is an (un)quoting
symbol using dotted list syntax; e.g. (a b . ,c) instead of (a b \, c).
2024-03-11 05:24:59 +01:00
Michael Heerdegen
9a2ce74c37 Fix pp-emacs-lisp-code printing of symbols
* lisp/emacs-lisp/pp.el (pp--insert-lisp): Print symbols
readably (bug#69168).
2024-03-11 05:24:59 +01:00
Petteri Hintsanen
ed43ad5b56 (bindat--unpack-item): Sanitize vector length
Copyright-paperwork-exempt: yes

* lisp/emacs-lisp/bindat.el (bindat--unpack-item): Sanitize vector length
2024-03-10 23:30:11 -04:00
Stefan Monnier
345cdd7a70 (eieio--generic-subclass-specializers): Autoload class
* lisp/emacs-lisp/eieio-core.el (eieio--generic-subclass-specializers):
Don't forget to handle autoloaded classes.
2024-03-08 11:57:22 -05:00
Stefan Monnier
5beb56fb53 EIEIO: Fix regession (bug#69631)
Not sure why earlier tests did not catch it, but there are more
places where we bump into problems because `eieio--class-precedence-list`
now returns also non-EIEIO classes.

* lisp/obsolete/eieio-compat.el
(eieio--generic-static-object-generalizer):
* lisp/emacs-lisp/eieio-core.el (eieio--generic-generalizer)
(eieio--generic-subclass-specializers): Handle non-EIEIO parents.

* test/lisp/emacs-lisp/eieio-tests/eieio-test-methodinvoke.el
(eieio-test-method-order-list-7): Adjust test.
2024-03-08 11:24:18 -05:00
Stefan Monnier
055e31f1d0 eieio-core.el: Try and fix bug#69631
* lisp/emacs-lisp/eieio-core.el (eieio--class-precedence-c3)
(eieio--class-precedence-dfs, eieio--class-precedence-bfs): Use
`cl--class-parents` since some of the parents aren't EIEIO classes.
2024-03-08 10:47:01 -05:00
Andrea Corallo
966d0a62a1 * Fix capitalize entry in comp-known-type-specifiers (bug#69631)
* lisp/emacs-lisp/comp-common.el (comp-known-type-specifiers): Fix
'capitalize' entry.
2024-03-08 14:36:03 +01:00