Commit graph

9705 commits

Author SHA1 Message Date
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
Stefan Monnier
bd017175d4 Simplify type hierarchy operations
Now that built-in types have classes that describe their
relationships exactly like struct/eieio/oclosure classes,
we can the code that navigates that DAG.

* lisp/emacs-lisp/cl-generic.el (cl--generic-struct-tag): Move to
`eieio-core.el`.
(cl--generic-type-specializers): Rename from
`cl--generic-struct-specializers`.  Make it work for any class.
(cl--generic-typeof-generalizer, cl--generic-oclosure-generalizer): Use it.
(cl--generic-struct-generalizer): Delete generalizer.
(cl-generic-generalizers :extra "cl-struct"): Delete method.
(prefill 0 cl--generic-generalizer): Move to after the typeof.
(cl-generic-generalizers :extra "typeof"): Rewrite to use
classes rather than `cl--all-builtin-types`.
(cl-generic--oclosure-specializers): Delete function.

* lisp/emacs-lisp/cl-preloaded.el (cl--direct-supertypes-of-type)
(cl--typeof-types, cl--all-builtin-types): Delete constants.

* lisp/emacs-lisp/comp-cstr.el (comp--typeof-builtin-types):
Delete constant.
(comp--cl-class-hierarchy): Simplify.
(comp--compute-typeof-types): Simplify now that
`comp--cl-class-hierarchy` and `comp--all-classes` work for built-in
types as well.
(comp--direct-supertypes): Just use `cl--class-parents`.
(comp-supertypes): Simplify since typeof-types should now be complete.

* lisp/emacs-lisp/eieio-core.el (eieio-defclass-autoload):
Use `superclasses` argument, so we can find parents before it's loaded.
(eieio--class-precedence-c3, eieio--class-precedence-dfs):
Don't add a `eieio-default-superclass` parent any more.
(eieio--class/struct-parents): Delete function.
(eieio--class-precedence-bfs): Use `eieio--class-parents` instead.
Don't stop when reaching `eieio-default-superclass`.
(cl--generic-struct-tag): Move from `cl-generic.el`.
2024-03-08 02:04:59 -05:00
Stefan Monnier
945af4d9d1 eieio-core.el: Always put a parent in the parents of a class
* lisp/emacs-lisp/eieio-core.el (eieio-defclass-internal):
Always put a parent in the `parents` slot of the class.

* lisp/emacs-lisp/eieio.el (eieio-class-parents): Remove the
`eieio-default-superclass` if it's the only parent.
(child-of-class-p): Handle all classes in the parents.
(eieio-default-superclass): Adjust docstring.
2024-03-08 02:04:59 -05:00
Stefan Monnier
7c127fc965 Make "parentless" structs inherit from their builtin type
* lisp/emacs-lisp/cl-preloaded.el (cl--struct-register-child):
Register child only in struct parents.
(cl-struct-define): Put the "type" as parent of parentless :type structs.
Copy slots only from struct parent classes.
(cl-structure-object): Set (manually) its parent to `record`
and remove assertion that it has no parents.
2024-03-08 02:04:57 -05:00
Stefan Monnier
76e9c761a4 * lisp/emacs-lisp/oclosure.el (oclosure): Make it a subtype of function 2024-03-08 02:04:11 -05:00
Stefan Monnier
4fdcbd09af cl-preloaded.el (built-in-class): New type
Add classes describing the built-in types.

* lisp/emacs-lisp/cl-preloaded.el (built-in-class): New type.
(cl--define-built-in-type): New aux macro.
(all built-in types): "Define" them with it.
(cl--builtin-type-p): New aux function.
(cl--struct-name-p): Use it.
(cl--direct-supertypes-of-type, cl--typeof-types, cl--all-builtin-types):
Move the definitions to after the built-in classes are defined,
and rewrite to make use of those classes.

* lisp/emacs-lisp/cl-extra.el (cl-describe-type):
Accept two (unused) optional args, for use with `describe-symbol-backends`.
(describe-symbol-backends): Simplify accordingly and
add ourselves at the end.
(cl--class-children): New function.
(cl--describe-class): Use it.  Also don't show a silly empty list of slots
for the built-in types.
2024-03-08 02:03:55 -05:00
Stefan Monnier
9830421e96 comp-cstr.el: Fix a minor error and prepare for upcoming changes
* lisp/emacs-lisp/comp-cstr.el (comp--cl-class-hierarchy): Add `atom`
and `t` only to those types whose "allparents" is clearly not complete.
(comp--compute--pred-type-h): Store the cstr rather than the type
in the hash-table, as expected by `comp--pred-to-cstr`.
2024-03-08 02:03:55 -05:00
Mattias Engdegård
61b2f5f96b Single string literal in body is return value only, not doc string
A function or macro body consisting of a single string literal now only
uses it as a return value.  Previously, it had the dual uses as return
value and doc string, which was never what the programmer wanted and
had some inconvenient consequences (bug#69387).

This change applies to `lambda`, `defun`, `defsubst` and `defmacro`
forms; most other defining forms already worked in the sensible way.

* lisp/emacs-lisp/bytecomp.el (byte-compile-lambda):
Don't use a lone string literal as doc string.
* test/lisp/emacs-lisp/bytecomp-resources/warn-wide-docstring-defun.el
(foo): Update docstring warning test.
* doc/lispref/functions.texi (Function Documentation): Update.
* etc/NEWS: Announce.
2024-03-07 13:47:53 +01:00
Stefan Monnier
218748c262 disass.el (disassemble-1): Minor simplification
* lisp/emacs-lisp/disass.el (disassemble-1): Remove code for functions
of the form (lambda ARGS (byte-code ...)) which we don't use any
more nowadays.
2024-03-04 23:42:50 -05:00
Stefan Monnier
418ad866bf cl-preloaded.el: Further fine-tuning
* lisp/emacs-lisp/cl-preloaded.el (cl--direct-supertypes-of-type):
Fix some left over issues:
- Remove redundant `number-or-marker` from `marker`s parents.
- Add `function` to the types, since it was missing.
(cl--typeof-types): Add a warning for missing type info.

* admin/syncdoc-type-hierarchy.el (syncdoc-hierarchy): Fix parent of
`oclosure`.

* doc/lispref/type_hierarchy.txt:
* doc/lispref/type_hierarchy.jpg: Update.
2024-03-04 23:12:29 -05:00
Mattias Engdegård
b9e8474a44 Repair miscompilation of single-arg apply (bug#69533)
* lisp/emacs-lisp/byte-opt.el (byte-optimize-apply):
Don't optimise single-argument `apply`; it's a legacy construct.
* test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--test-cases):
Add test case.
2024-03-04 14:13:26 +01:00
Stefan Monnier
1d9d07fb00 (cl--typeof-types): Rework to fix some regressions
Initialize the variables directly in their declaration, so
there no time where they exist but aren't yet initialized.
This also allows us to mark `cl--typeof-types` as a `defconst` again.

More importantly, specify the DAG by direct supertypes rather
than direct subtypes.  This is slightly less compact, but it's
necessary to let us specify the *order* of the supertypes,
which is necessary for example to preserve the desired ordering
of methods when several methods can be applied.

Fix a few more regressions, such as removing `atom` from the parents
of `function` since some lists are considered as functions,
adding `number-or-marker` as supertype of `integer-or-marker`,
and re-adding `native-comp-unit`.

I carefully compared all elements of `cl--typeof-types` to make
sure they are the same as before (with one exception for `null`).

* lisp/emacs-lisp/cl-preloaded.el (cl--type-hierarchy): Delete var.
(cl--direct-supertypes-of-type, cl--typeof-types):
Initialize directly in the declaration.
(cl--supertypes-lane, cl--supertypes-lanes-res): Delete vars.
(cl--supertypes-for-typeof-types-rec)
(cl--supertypes-for-typeof-types): Delete functions.
2024-03-03 18:08:50 -05:00
Andrea Corallo
8d11b7e427 * Fix 'cl--typeof-types' computation
* lisp/emacs-lisp/cl-preloaded.el (cl--supertypes-lane)
(cl--supertypes-lanes-res): Define vars.
(cl--supertypes-for-typeof-types-rec): Define function.
(cl--supertypes-for-typeof-types): Reimplement.
2024-03-03 17:49:14 +01:00
Andrea Corallo
8b96503b6e * lisp/emacs-lisp/cl-preloaded.el (cl--typeof-types): Define as var. 2024-03-01 18:58:44 +01:00
Andrea Corallo
c55694785e Merge branch 'feature/type-hierarchy' into 'master' 2024-03-01 09:30:44 +01:00
Andrea Corallo
0567f3b817 * Fix compilation warning in 'cl--supertypes-for-typeof-types'
* lisp/emacs-lisp/cl-preloaded.el (cl--supertypes-for-typeof-types): Fix
warning.
2024-03-01 09:16:38 +01:00
Juri Linkov
8305d0e0c9 Add tabulated-list-groups and Buffer-menu-group-by (bug#69305)
* doc/lispref/modes.texi (Tabulated List Mode):
Add defvar tabulated-list-groups.

* lisp/buff-menu.el (Buffer-menu-group-by): New defcustom.
(Buffer-menu-unmark-all-buffers): Use tabulated-list-get-entry
to check whether the current line contains an entry.
(list-buffers-noselect): Enable outline-minor-mode
for tabulated-list-groups.
(list-buffers--refresh): When Buffer-menu-group-by is non-nil,
set tabulated-list-groups.
(Buffer-menu-group-by-mode, Buffer-menu-group-by-root):
New functions.

* lisp/emacs-lisp/tabulated-list.el (tabulated-list-groups):
New buffer-local variable.
(tabulated-list-print-fake-header): Add distinct overlay
property 'fake-header'.
(tabulated-list-header-overlay-p): Filter out overlays that
don't have the property 'fake-header'.
(tabulated-list-print): Use the variable 'tabulated-list-groups'
to sort entries in groups separately.
(tabulated-list-print-entries): New function factored out from
'tabulated-list-print'.

* test/lisp/emacs-lisp/tabulated-list-tests.el (tabulated-list-groups):
New test.
2024-02-29 19:50:04 +02:00
Eli Zaretskii
3923998240 Improve documentation of recent changes in comp-run.el
* lisp/emacs-lisp/comp-run.el
(native-comp-async-warnings-errors-kind): Rename from
'native-comp-async-report-warnings-errors-kind', and rename
'importants' to 'important'; all users changed.  Doc fix.

* etc/NEWS: Announce the new option.
2024-02-29 15:37:19 +02:00
Andrea Corallo
8e5baaddec * Add 'native-comp-async-report-warnings-errors-kind'
* lisp/emacs-lisp/comp-run.el (native-comp-async-report-warnings-errors-kind):
Add new customize.
2024-02-29 11:54:24 +01:00
Andrea Corallo
b8ba3cb7f0 * Improve 'native-comp-async-report-warnings-errors' tag
* lisp/emacs-lisp/comp-run.el (native-comp-async-report-warnings-errors):
Improve tag.
2024-02-29 11:26:08 +01:00
Andrea Corallo
1fbe56c327 Merge remote-tracking branch 'origin/master' into 'feature/type-hierarchy' 2024-02-28 20:47:57 +01:00
Andrea Corallo
05195e129f * lisp/emacs-lisp/cl-macs.el (cl-deftype-satisfies): Add 'symbol-with-pos'. 2024-02-28 20:44:32 +01:00
Andrea Corallo
91b90885ac * lisp/emacs-lisp/comp.el (comp-known-predicates): Add 'symbol-with-pos-p'. 2024-02-28 20:44:24 +01:00
Eli Zaretskii
229b3edb07 Merge from origin/emacs-29
01ebc95114 Fix 'help-quick-toggle'
afe49c7e2a ; * admin/authors.el (authors-aliases): Fix last change.
8b1f10f8cf ; Normalize Morgan Smith's attributions.
70cf4b694b ; * etc/PROBLEMS: Describe input lags due to GTK IM (bug#...
f28a557c7d * doc/lispref/modes.texi (Tabulated List Mode): Update.
d6131b5902 * lisp/net/tramp.el (tramp-methods): Fix typo in docstrin...
2eb85a9de1 ; * lisp/emacs-lisp/pcase.el (pcase-let*, pcase-let): Ano...
4c6653f23a ; * lisp/emacs-lisp/pcase.el (pcase-let*, pcase-let): Doc...
5a64d2c759 java-ts-mode: Indentation for opening brace on a separate...
9e56bd5ed8 Removed decommissioned PGP keyservers
e56f0ef51b org: Fix security prompt for downloading remote resource
65ba327465 Revert "Update to Org 9.6.19"
07a392f445 Update to Org 9.6.19
2024-02-24 06:35:16 -05:00
Mattias Engdegård
90d3b3408e Warn about docstrings with control characters
It is easy to include control chars in doc strings by mistake, and the
result is often an unreadable mess.

* lisp/emacs-lisp/bytecomp.el (byte-compile-warning-types)
(byte-compile-warnings, byte-compile--docstring-style-warn):
Add `docstrings-control-chars` warning.
* etc/NEWS: Announce.
2024-02-23 15:16:30 +01:00
Mattias Engdegård
462d8ba813 Add a proper type for obarrays
The new opaque type replaces the previous use of vectors for obarrays.
`obarray-make` now returns objects of this type.  Functions that take
obarrays continue to accept vectors for compatibility, now just using
their first slot to store an actual obarray object.

obarray-size and obarray-default-size now obsolete.

* lisp/obarray.el (obarray-default-size, obarray-size):
Declare obsolete.
(obarray-make, obarrayp, obarray-clear): Remove from here.
* src/fns.c (reduce_emacs_uint_to_hash_hash): Remove from here.
* src/lisp.h (struct Lisp_Obarray, OBARRAYP, XOBARRAY, CHECK_OBARRAY)
(make_lisp_obarray, obarray_size, check_obarray)
(obarray_iter_t, make_obarray_iter, obarray_iter_at_end)
(obarray_iter_step, obarray_iter_symbol, DOOBARRAY, knuth_hash): New.
(reduce_emacs_uint_to_hash_hash): Moved here.
* src/lread.c (check_obarray): Renamed and reworked as...
(checked_obarray_slow): ...this.
(intern_sym, Funintern, oblookup, map_obarray)
(Finternal__obarray_buckets): Adapt to new type.
(obarray_index, allocate_obarray, make_obarray, grow_obarray)
(obarray_default_bits, Fobarray_make, Fobarrayp, Fobarray_clear): New.
* etc/emacs_lldb.py (Lisp_Object):
* lisp/emacs-lisp/cl-macs.el (`(,type . ,pred)):
* lisp/emacs-lisp/cl-preloaded.el (cl--typeof-types):
* lisp/emacs-lisp/comp-common.el (comp-known-type-specifiers):
* lisp/emacs-lisp/comp.el (comp-known-predicates):
* src/alloc.c (cleanup_vector, process_mark_stack):
* src/data.c (Ftype_of, syms_of_data):
* src/minibuf.c (Ftry_completion, Fall_completions, Ftest_completion):
* src/pdumper.c (dump_obarray_buckets, dump_obarray, dump_vectorlike):
* src/print.c (print_vectorlike_unreadable):
* test/lisp/abbrev-tests.el (abbrev-make-abbrev-table-test):
* test/lisp/obarray-tests.el (obarrayp-test)
(obarrayp-unchecked-content-test, obarray-make-default-test)
(obarray-make-with-size-test):
Adapt to new type.
2024-02-23 13:02:27 +01:00
Mattias Engdegård
aa82fe9931 Use obarray-make instead of make-vector to create obarrays
This prepares for the introduction of an actual obarray type.

* lisp/cedet/semantic/lex-spp.el (semantic-lex-spp-dynamic-map)
(semantic-lex-spp-dynamic-map-stack, semantic-lex-make-spp-table):
* lisp/cedet/semantic/lex.el (semantic-lex-make-keyword-table)
(semantic-lex-make-type-table):
* lisp/completion.el (cmpl-prefix-obarray, cmpl-obarray)
(clear-all-completions):
* lisp/emacs-lisp/checkdoc.el (checkdoc-defun-info):
* lisp/emacs-lisp/eldoc.el (eldoc-message-commands)
(eldoc-edit-message-commands):
* lisp/mail/mail-extr.el (mail-extr-all-top-level-domains):
* lisp/mail/rmailkwd.el (rmail-label-obarray):
* lisp/net/dns.el (dns-cache):
* lisp/net/eww.el (eww-suggested-uris):
* lisp/net/imap.el (imap-open, imap-mailbox-select-1)
(imap-message-copyuid-1, imap-message-appenduid-1):
* lisp/obsolete/pgg.el (pgg-passphrase-cache, pgg-pending-timers):
* lisp/play/cookie1.el (cookie-cache):
* lisp/progmodes/cc-defs.el (c-lang-constants, c-define-lang-constant):
* lisp/progmodes/cc-langs.el (c-keywords-obarray):
* lisp/vc/vc-hooks.el (vc-file-prop-obarray):
* test/lisp/obarray-tests.el (obarrayp-test):
* test/src/minibuf-tests.el (minibuf-tests--strings-to-obarray):
Use obarray-make instead of obarray-make.
2024-02-23 13:02:27 +01:00
Andrea Corallo
58ca91fe07 * Fix 'parse-colon-path' entry in 'comp-known-type-specifiers'
* lisp/emacs-lisp/comp-common.el (comp-known-type-specifiers): Fix
'parse-colon-path'.
2024-02-22 20:49:55 +01:00
Andrea Corallo
b214cb2843 ; * lisp/emacs-lisp/comp-run.el: Fix typo. 2024-02-21 21:38:11 +01:00
Andrea Corallo
44d5c667d7 * lisp/emacs-lisp/comp.el (comp--compute-function-types): Fix missing doc. 2024-02-21 17:52:52 +01:00
Andrea Corallo
88abbf00af ; Add two comments on comp-known-predicates cl-deftype-satisfies
* lisp/emacs-lisp/comp.el (comp-known-predicates): Add comment.
* lisp/emacs-lisp/cl-macs.el: Likewise.
2024-02-21 17:42:58 +01:00
Andrea Corallo
c65a59a9e9 * Add few missing entries in 'comp-known-predicates'
* lisp/emacs-lisp/comp.el (comp-known-predicates): Add framep, markerp,
number-or-marker-p, overlayp, processp, subrp and windowp and sort it
alphabetically.
2024-02-21 17:42:58 +01:00
Andrea Corallo
5aeea8dc2c * lisp/emacs-lisp/comp-cstr.el (comp-cstr): Rename constructors. 2024-02-21 17:42:58 +01:00
Andrea Corallo
1e1d3f3acd ; * lisp/emacs-lisp/comp.el (native-comp-debug): Fix spacing. 2024-02-21 17:42:58 +01:00
Andrea Corallo
7215c63fc0 * Make 'comp--compute-function-types' a pass
* lisp/emacs-lisp/comp.el (comp-passes): Add comp--compute-function-types.
(comp--compute-function-types): New function.
(comp--compute-function-type): Move it.
(comp--final): Update it.
2024-02-21 17:42:58 +01:00
Stefan Monnier
3b34c5e4a5 * lisp/emacs-lisp/map.el (map--make-pcase-bindings): Fix use in Emacs<30 2024-02-21 08:49:15 -05:00
Jonas Bernoulli
1acc7cb851
Do not attempt to check declarations in lock files
* lisp/emacs-lisp/check-declare.el (check-declare-directory): Do
not attempt to check declarations in lock files.  (Bug#69084)
2024-02-20 22:49:07 +01:00
Jonas Bernoulli
167d9b9040 Allow trivially autoloading uses of transient's define macros
Since 49e41991b2 transient-define-prefix itself was autoloaded, but
that meant that when ever an autoload file was loaded, which contained
an autoload for a command defined using that macro, transient itself
had to be loaded.

That shouldn't be necessary.  For commands using these macros, an
autoload that is identical to what would have been generated if it
had been defined using defun, works just fine.

* lisp/emacs-lisp/loaddefs-gen.el
(loaddefs-generate--make-autoload): Allow uses of
transient-define-prefix, transient-define-suffix,
transient-define-infix and transient-define-argument
to be autoloaded using just ";;;autoload".

* lisp/transient.el (transient-define-prefix): No longer autoload.
2024-02-20 22:04:51 +01:00
Andrea Corallo
bbf0b7d040 * Fix missing entry in 'cl--typeof-types'
* lisp/emacs-lisp/cl-preloaded.el (cl--typeof-types): Add
'native-comp-unit'.
2024-02-20 19:52:37 +01:00
Eli Zaretskii
2eb85a9de1 ; * lisp/emacs-lisp/pcase.el (pcase-let*, pcase-let): Another doc fix. 2024-02-20 19:15:38 +02:00
Eli Zaretskii
4c6653f23a ; * lisp/emacs-lisp/pcase.el (pcase-let*, pcase-let): Doc fix. 2024-02-20 15:44:13 +02:00