summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
Commit message (Collapse)AuthorAgeFilesLines
* Don't let pp fall back to prin1 for consesMichael Heerdegen2024-05-271-1/+1
| | | | | | * lisp/emacs-lisp/pp.el (pp--insert-lisp): Don't `prin1' non-list conses; use our pp function for cons and list printing `pp--format-list' instead.
* Don't try to pretty-print non-lists as binding listMichael Heerdegen2024-05-271-1/+2
| | | | | | | * lisp/emacs-lisp/pp.el (pp--format-definition): Ensure that what we try to print as a list of bindings has an appropriate format. This avoids raising an error for SEXPs like (let X Y) inside `pcase' forms where our heuristic expects a binding list in the X position.
* Further tweak pp code printingMichael Heerdegen2024-05-261-6/+3
| | | | | | | This fixes an aspect of Bug#70868. * lisp/emacs-lisp/pp.el (pp--insert-lisp): Print characters with `prin1-char'. In all other cases consistently print with `prin1'.
* Address compilation errors and warnings on x86 Solaris 10 systemsPo Lu2024-05-261-2/+2
| | | | | | | | | | | | | | | | * doc/misc/ede.texi (Extending EDE): * doc/misc/flymake.texi (Top, Using Flymake): Insert punctuation after xrefs. * lisp/emacs-lisp/loaddefs-gen.el (loaddefs-generate): Print number of files being scraped. * src/dired.c (directory_files_internal): * src/eval.c (Fmake_interpreted_closure, Fdefvaralias): * src/fns.c (Fassoc): Work around optimizer failures.
* Improve navigation to cl-defgeneric usesDmitry Gutov2024-05-261-1/+1
| | | | | | * lisp/emacs-lisp/cl-generic.el (cl--generic-find-defgeneric-regexp): Use "symbol end" boundary (bug#71068).
* * lisp/emacs-lisp/pcase.el (pcase--subtype-bitsets): Fix bootstrap failureStefan Monnier2024-05-221-1/+2
| | | | | | | `rm lisp/emacs-lisp/cl-preloaded.elc src/bootstrap-emacs` followed by `make` ended up loading right after defining `built-in-class-p` but before actually defining the built-in-classes so the computation of bitsets failed.
* Silence 3 warnings for non sqlite buildsAndrea Corallo2024-05-191-0/+3
| | | | | * lisp/emacs-lisp/multisession.el (sqlite-commit) (sqlite-transaction, sqlite-rollback): Declare.
* Make 'vtable-insert-object' more versatileJoost Kremers2024-05-181-23/+75
| | | | | | | | | | | | | | * lisp/emacs-lisp/vtable.el (vtable-insert-object): Rename argument AFTER-OBJECT to LOCATION; allow use of index to refer to the insertion position; add argument BEFORE. (Bug#70664). * etc/NEWS: * doc/misc/vtable.texi (Interface Functions): Document the change. * test/lisp/emacs-lisp/vtable-tests.el (test-vtable-insert-object): New test.
* (describe-package-1): Handle (nil . "string") in `:maintainer`Stefan Monnier2024-05-161-1/+1
| | | | | | * lisp/emacs-lisp/package.el (describe-package-1): Refine the check to distinguish the old single-maintainer format from the new multi-maintainer format. (bug#69712)
* * Fix bootstrap with checking enabledAndrea Corallo2024-05-161-1/+2
| | | | | * lisp/emacs-lisp/comp.el (comp--limplify-top-level): Set function safety.
* * Allow for optional function name parameter in 'ftype' declarationAndrea Corallo2024-05-141-1/+5
| | | | | * lisp/emacs-lisp/byte-run.el (defun-declarations-alist): Allow for optional function name parameter in 'ftype' declaration.
* Change 'type' declaration to 'ftype'Andrea Corallo2024-05-144-5/+5
| | | | | | | | | | | | | | | | | * lisp/window.el (get-lru-window, get-largest-window) (one-window-p): Update function type declaration. * lisp/subr.el (ignore, error, zerop, fixnump, bignump, lsh) (last, eventp, mouse-movement-p, log10, memory-limit) (internal-pop-keymap): Likewise. * lisp/simple.el (count-lines, mark, string-empty-p): Likewise. * lisp/files.el (parse-colon-path): Likewise. * lisp/env.el (getenv): Likewise. * lisp/emacs-lisp/regexp-opt.el (regexp-opt): Likewise. * lisp/emacs-lisp/lisp.el (buffer-end): Likewise. * lisp/emacs-lisp/comp.el (comp--final): Likewise. * lisp/custom.el (custom-variable-p): Likewise. * lisp/emacs-lisp/byte-run.el (defun-declarations-alist): Rename 'type' -> 'ftype'.
* ; Fix documentation of recently-installed changesEli Zaretskii2024-05-141-4/+7
| | | | | | | | | | | * lisp/emacs-lisp/bytecomp.el (compilation-safety): Doc fix. * etc/NEWS: Fix wording of the 'compilation-safety' entry. * doc/lispref/functions.texi (Declare Form): Fix cross-reference and wording. * doc/lispref/compile.texi (Native-Compilation Variables): Add the missing @anchor. Fix wording.
* Add some 'compilation-safety' documentationAndrea Corallo2024-05-131-1/+5
| | | | | | | * lisp/emacs-lisp/bytecomp.el (compilation-safety): Better doc. * doc/lispref/functions.texi (Declare Form): Add 'safety'. * doc/lispref/compile.texi (Native-Compilation Variables): Add 'compilation-safety'.
* Add 'safety' function declarationAndrea Corallo2024-05-133-0/+19
| | | | | | | | | | | * lisp/emacs-lisp/comp.el (comp-known-predicates): Use 'comp-func-safety'. (comp-ctxt, comp-mvar-type-hint-match-p): New 'safety' slot. (comp-c-func-name): New function. (comp--spill-lap-function, comp--intern-func-in-ctxt): Update. * lisp/emacs-lisp/bytecomp.el (byte-compile-from-buffer): Spill safety. * lisp/emacs-lisp/byte-run.el (byte-run--set-completion): New alias. (defun-declarations-alist): Update.
* Introduce 'compilation-safety' variableAndrea Corallo2024-05-131-0/+6
| | | | | | | * lisp/emacs-lisp/bytecomp.el (compilation-safety): New customize. * src/comp.c (comp_t): Add func_safety. (emit_call_with_type_hint, emit_call2_with_type_hint): Make use of. (compile_function): Set 'comp.func_safety'.
* * lisp/emacs-lisp/comp.el (comp--get-function-cstr): Fix it.Andrea Corallo2024-05-131-6/+5
|
* Safer and faster string sortingMattias Engdegård2024-05-121-1/+4
| | | | | | * lisp/emacs-lisp/cl-seq.el (cl-sort): Don't use string mutation when sorting the characters in a string. This avoids O(n^2) run time and makes it future-safe.
* Don't mutate strings in cl-substituteMattias Engdegård2024-05-081-4/+5
| | | | | | | | | This fixes cl-substitute, cl-substitute-if, cl-substitute-if-not, cl-nsubstitute, cl-nsubstitute-if and cl-nsubstitute-if-not, when called with a string sequence argument. * lisp/emacs-lisp/cl-seq.el (cl-nsubstitute): Avoid running in O(n^2) time and make future-safe.
* Correct earlier change to map-ynpPo Lu2024-05-081-2/+4
| | | | | * lisp/emacs-lisp/map-ynp.el (map-y-or-n-p): Don't call set-text-conversion-style if not bound.
* ; * lisp/emacs-lisp/map-ynp.el (map-y-or-n-p): Add commentary.Eli Zaretskii2024-05-071-0/+5
|
* Disable text-conversion in map-ynpPo Lu2024-05-071-1/+8
| | | | | | * lisp/emacs-lisp/map-ynp.el (map-y-or-n-p): Bind overriding-text-conversion-style to nil around read-event and arrange that the input method be reset.
* edebug.el: Fix `edebug-remove-instrumentation` (bug#70791)Stefan Monnier2024-05-061-0/+6
| | | | | * lisp/emacs-lisp/edebug.el (edebug-unwrap*): Traverse interpreted functions.
* * lisp/emacs-lisp/warnings.el (display-warning): Add guardrails for window.Juri Linkov2024-05-061-2/+2
| | | | | Check for non-nil 'window' returned from 'display-buffer' for the case when users decide to use 'allow-no-window' in 'display-buffer-alist' (#70795).
* Revert "Disable text conversion in map-ynp"Eli Zaretskii2024-05-061-1/+1
| | | | | This reverts commit f50a58123a3d386b9bba7c4ba14df62479887bd4. Please don't make such changes without discussing them.
* ; Avoid byte-compiler warning in comp.elEli Zaretskii2024-05-061-5/+5
| | | | | * lisp/emacs-lisp/comp.el (comp--symbol-func-to-fun): Move to before its first use.
* Disable text conversion in map-ynpPo Lu2024-05-061-1/+1
| | | | | * lisp/emacs-lisp/map-ynp.el (map-y-or-n-p): Read response with read-key, not read-char.
* Remove unnecessary cons in function-type propertyAndrea Corallo2024-05-053-3/+3
| | | | | | | | * lisp/emacs-lisp/comp-common.el (comp-function-type-spec): Remove unnecessary car. * lisp/emacs-lisp/comp.el (comp--intern-func-in-ctxt): Likewise. * lisp/emacs-lisp/byte-run.el (byte-run--set-function-type): Update lambda list.
* Fix intra compilation unit function type declarationAndrea Corallo2024-05-051-2/+7
| | | | | | * lisp/emacs-lisp/comp.el (comp-func): Add 'slot'. (comp--intern-func-in-ctxt): Update. (comp--get-function-cstr): Update.
* eglot.el: Require `track-changes` unconditionallyStefan Monnier2024-05-051-1/+7
| | | | | | | | | | * lisp/emacs-lisp/track-changes.el: Bump version. * lisp/progmodes/eglot.el: Require `track-changes` unconditionally. (Package-Requires:): Add `track-changes`. (eglot--track-changes-signal, eglot--signal-textDocument/didChange) (eglot--managed-mode): Remove non-track-changes alternative code. (eglot--before-change, eglot--after-change): Delete functions.
* * lisp/emacs-lisp/track-changes.el (track-changes-inconsistent-state-p): TypoStefan Monnier2024-05-031-1/+1
|
* track-changes.el: Add a workaround for bug#70541Stefan Monnier2024-05-031-0/+11
| | | | | | * lisp/emacs-lisp/track-changes.el (track-changes-inconsistent-state-p): New function. * lisp/progmodes/eglot.el (eglot--track-changes-signal): Use it.
* Merge branch 'lisp-func-type-decls' into 'master'Andrea Corallo2024-05-025-55/+47
|\
| * * lisp/emacs-lisp/regexp-opt.el (regexp-opt): Fix type declaration.Andrea Corallo2024-04-301-1/+1
| |
| * Rename property 'declared-type' to 'function-type'Andrea Corallo2024-04-293-5/+5
| | | | | | | | | | | | * lisp/emacs-lisp/byte-run.el (byte-run--set-function-type): Rename. (defun-declarations-alist): Update. * lisp/emacs-lisp/comp.el (comp--get-function-cstr): Likewise.
| * Move lisp function arg type declarations to the functions itselfAndrea Corallo2024-04-294-38/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/emacs-lisp/comp-common.el (comp-primitive-type-specifiers): Remove type declaration of lisp functions. * lisp/window.el (get-lru-window, get-largest-window) (one-window-p): Declare type. * lisp/subr.el (ignore, error, zerop, fixnump, bignump, lsh) (last, eventp, mouse-movement-p, log10, memory-limit) (interactive-p): Likewise. * lisp/simple.el (count-lines, mark, lax-plist-get): Likewise. * lisp/files.el (parse-colon-path): Likewise. * lisp/env.el (getenv): Likewise. * lisp/emacs-lisp/regexp-opt.el (regexp-opt): Likewise. * lisp/emacs-lisp/lisp.el (buffer-end): Likewise. * lisp/emacs-lisp/comp.el (comp-hint-fixnum, comp-hint-cons): Likewise. * lisp/custom.el (custom-variable-p): Likewise.
| * Make use of Lisp function declarationsAndrea Corallo2024-04-292-17/+30
| | | | | | | | | | | | | | | | | | | | * lisp/emacs-lisp/comp.el (comp-primitive-func-cstr-h): Rename. (comp--get-function-cstr): Define new function. (comp--add-call-cstr, comp--fwprop-call): Update. * lisp/emacs-lisp/comp-common.el (comp-function-type-spec): Update. * lisp/help-fns.el (help-fns--signature): Mention when a type is declared. * lisp/emacs-lisp/comp.el (comp-primitive-func-cstr-h): Rename.
| * * Add function type declarations for Lisp functionsAndrea Corallo2024-04-291-1/+7
| | | | | | | | | | * lisp/emacs-lisp/byte-run.el (byte-run--set-declared-type): Add alias. (defun-declarations-alist): Use it for 'type' declaration.
* | * lisp/emacs-lisp/warnings.el: Fix 'warning-display-at-bottom'.Juri Linkov2024-05-021-1/+1
| | | | | | | | | | (display-warning): Move point to the beginning of the last line instead of its end for 'warning-display-at-bottom' (bug#69983).
* | (disassemble): Fix case of `(byte-code ...)` argumentAndrea Corallo2024-05-011-5/+6
| | | | | | | | | | | | | | * lisp/emacs-lisp/disass.el (disassemble): Handle (byte-code ...) here.. (disassemble-internal): ...instead of here. (disassemble-1): Adjust text to reflect the existence of other compiled functions.
* | Assume match before calling help-xref-buttonBasil L. Contovounesios2024-05-011-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | help-xref-button fails if not preceded by a valid match, so a preceding unconditional search should not be allowed to fail silently. * lisp/emacs-lisp/ert.el (ert-describe-test): * lisp/help-fns.el (help-fns--compiler-macro) (help-fns-function-description-header, describe-variable) (help-fns--customize-variable, describe-face) (help-fns--face-attributes, describe-keymap): Let unconditional re-search-backward before help-xref-button fail early, as that would indicate a logic bug, and the backtrace would more accurately point to the actual source of the mistake.
* | * lisp/emacs-lisp/bytecomp.el (byte-compile-make-closure): Simplify.Mattias Engdegård2024-04-301-10/+7
| |
* | * lisp/emacs-lisp/bytecomp.el (byte-compile-lambda): Simplify.Mattias Engdegård2024-04-301-7/+5
| | | | | | | | Remove the add-lambda argument. All callers adapted.
* | Use the nthcdr byte-op for drop, and raise open-code limitMattias Engdegård2024-04-291-7/+9
| | | | | | | | | | * lisp/emacs-lisp/byte-opt.el (byte-optimize-nthcdr): Open-code for any integral N<5. Always use the byte-op otherwise.
* | (disassemble-internal): Handle new function valuesStefan Monnier2024-04-291-12/+10
| | | | | | | | | | * lisp/emacs-lisp/disass.el (disassemble-internal): Fix the `interpreted-function` case.
* | (byte-compile): Fix interaction with old `advice.el`Stefan Monnier2024-04-291-2/+4
|/ | | | | * lisp/emacs-lisp/bytecomp.el (byte-compile): Handle symbols whose function "value" is a bare lambda expression (bug#70368).
* Declare the variable `rx-constituents` obsolete.Mattias Engdegård2024-04-291-0/+7
| | | | | | | | | It has been effectively obsolete since Emacs 27, when the modern extension mechanism was introduced. * lisp/emacs-lisp/rx.el (rx-constituents): Make obsolete. * test/lisp/emacs-lisp/rx-tests.el (rx-constituents): Suppress warning. * etc/NEWS: Announce.
* Use a dedicated type to represent interpreted-function valuesStefan Monnier2024-04-2811-90/+129
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change `function` so that when evaluating #'(lambda ...) we return an object of type `interpreted-function` rather than a list starting with one of `lambda` or `closure`. The new type reuses the existing PVEC_CLOSURE (nee PVEC_COMPILED) tag and tries to align the corresponding elements: - the arglist, the docstring, and the interactive-form go in the same slots as for byte-code functions. - the body of the function goes in the slot used for the bytecode string. - the lexical context goes in the slot used for the constants of bytecoded functions. The first point above means that `help-function-arglist`, `documentation`, and `interactive-form`s don't need to distinguish interpreted and bytecode functions any more. Main benefits of the change: - We can now reliably distinguish a list from a function value. - `cl-defmethod` can dispatch on `interactive-function` and `closure`. Dispatch on `function` also works now for interpreted functions but still won't work for functions represented as lists or as symbols, of course. - Function values are now self-evaluating. That was alrready the case when byte-compiled, but not when interpreted since (eval '(closure ...)) signals a void-function error. That also avoids false-positive warnings about "don't quote your lambdas" when doing things like `(mapcar ',func ...)`. * src/eval.c (Fmake_interpreted_closure): New function. (Ffunction): Use it and change calling convention of `Vinternal_make_interpreted_closure_function`. (FUNCTIONP, Fcommandp, eval_sub, funcall_general, funcall_lambda) (Ffunc_arity, lambda_arity): Simplify. (funcall_lambda): Adjust to new representation. (syms_of_eval): `defsubr` the new function. Remove definition of `Qclosure`. * lisp/emacs-lisp/cconv.el (cconv-make-interpreted-closure): Change calling convention and use `make-interpreted-closure`. * src/data.c (Fcl_type_of): Distinguish `byte-code-function`s from `interpreted-function`s. (Fclosurep, finterpreted_function_p): New functions. (Fbyte_code_function_p): Don't be confused by `interpreted-function`s. (Finteractive_form, Fcommand_modes): Simplify. (syms_of_data): Define new type symbols and `defsubr` the two new functions. * lisp/emacs-lisp/cl-print.el (cl-print-object) <interpreted-function>: New method. * lisp/emacs-lisp/oclosure.el (oclosure): Refine the parent to be `closure`. (oclosure--fix-type, oclosure-type): Simplify. (oclosure--copy, oclosure--get, oclosure--set): Adjust to new representation. * src/callint.c (Fcall_interactively): Adjust to new representation. * src/lread.c (bytecode_from_rev_list): * lisp/simple.el (function-documentation): * lisp/help.el (help-function-arglist): Remove the old `closure` case and adjust the byte-code case so it handles `interpreted-function`s. * lisp/emacs-lisp/cl-preloaded.el (closure): New type. (byte-code-function): Add it as a parent. (interpreted-function): Adjust parent (the type itself was already added earlier by accident). * lisp/emacs-lisp/bytecomp.el (byte-compile--reify-function): Adjust to new representation. (byte-compile): Use `interpreted-function-p`. * lisp/emacs-lisp/byte-opt.el (byte-compile-inline-expand): Adjust to new representation. (side-effect-free-fns): Add `interpreted-function-p` and `closurep`. * src/profiler.c (trace_hash, ffunction_equal): Simplify. * lisp/profiler.el (profiler-function-equal): Simplify. * lisp/emacs-lisp/nadvice.el (advice--interactive-form-1): Use `interpreted-function-p`; adjust to new representation; and take advantage of the fact that function values are now self-evaluating. * lisp/emacs-lisp/lisp-mode.el (closure): Remove `lisp-indent-function` property. * lisp/emacs-lisp/disass.el (disassemble-internal): Adjust to new representation. * lisp/emacs-lisp/edebug.el (edebug--strip-instrumentation): Use `interpreted-function-p`. * lisp/emacs-lisp/comp-common.el (comp-known-type-specifiers): Add `closurep` and `interpreted-function-p`. * test/lisp/help-fns-tests.el (help-fns-test-lisp-defun): Adjust to more precise type info in `describe-function`. * test/lisp/erc/resources/erc-d/erc-d-tests.el (erc-d--render-entries): Use `interpreted-function-p`. * test/lisp/emacs-lisp/macroexp-resources/vk.el (vk-f4, vk-f5): Don't hardcode function values. * doc/lispref/functions.texi (Anonymous Functions): Don't suggest that function values are lists. Reword "self-quoting" to reflect the fact that #' doesn't return the exact same object. Update examples with the new shape of the return value. * doc/lispref/variables.texi (Lexical Binding): * doc/lispref/lists.texi (Rearrangement): * doc/lispref/control.texi (Handling Errors): Update examples to reflect new representation of function values.
* Refine the Custom type of generated '*-modes' optionsEshel Yaron2024-04-271-1/+14
| | | | | | * lisp/emacs-lisp/easy-mmode.el (define-globalized-minor-mode): Refine the Custom type of the '*-modes' option, generated when this macro is given a ':predicate' argument. (Bug#70589)
* Improve documentation of 'package-enable-at-startup'Eli Zaretskii2024-04-271-1/+7
| | | | | | | | * doc/emacs/package.texi (Package Installation): Clarify how to customize 'package-enable-at-startup'. * lisp/emacs-lisp/package.el (package-enable-at-startup): Add note about customization. (Bug#70402)