summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/cl-macs.el
Commit message (Collapse)AuthorAge
* Faster and less wrong cl-defsubst inliningMattias Engdegård2023-04-13
| | | | | | | | | | | | | | | Always have inlining of functions defined by `cl-defsubst` let-bind arguments instead of making incorrect guesses when it might be safe to substitute them and then botching the substitution. This change generally results in better and safer code for all callers, in particular `cl-defstruct` constructors, accessors and mutators. * lisp/emacs-lisp/cl-macs.el (cl-defsubst): Remove outdated comment. (cl--defsubst-expand): Simplify: always let-bind. (cl--sublis): Remove. (cl-defstruct): Simplify: remove old hack that is no longer needed.
* Adjust side-effect-free declarationsMattias Engdegård2023-04-09
| | | | | | | | | | | | * lisp/emacs-lisp/byte-opt.el (side-effect-and-error-free-fns): Add `eql` here. * lisp/emacs-lisp/cl-macs.el (eql, cl-subst, cl-sublis): Don't set the `side-effect-free` property here. `cl-subst` and `cl-sublis` are not side-effect-free. * lisp/emacs-lisp/cl-extra.el (cl-revappend): Declare side-effect-free. * lisp/emacs-lisp/cl-lib.el (cl-copy-list): Declare side-effect-free and error-free.
* Avoid unwind-protect without unwind forms in cl-letfMattias Engdegård2023-03-29
| | | | | * lisp/emacs-lisp/cl-macs.el (cl--letf): Use unwind-protect only if necessary, avoiding a warning.
* Merge from origin/emacs-29Stefan Kangas2023-01-19
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | db727873803 ruby-ts-mode: Use font-lock-constant-face for true/false/nil 819719330ad (ruby-ts--indent-rules): Add a rule for continuation of a... 94b9cbf96fb (ruby-ts--parent-call-or-bol): Handle more cases with nes... ba33b83ce4b (ruby-ts--statement-container-regexp): Remove "parenthesi... f2bedf695c1 ruby-ts-mode: Handle indent in parenless calls much close... 758ac5eabbe Fix split-window-below for the case when split-window-kee... 8e9783b4ce4 Rebind in read-regexp-map ‘M-c’ to ‘M-s c’ compatible wit... 78f93d92b28 * lisp/vc/vc-dir.el: Make keys ‘% m’ and ‘* %’ compatible... dc3f85fd4b0 Use proper types for Eshell warnings 6a8338a8bc8 ; Avoid byte-compiler warning in cc-fonts.el. 9186be20aeb ; Clarify doc strings of some functions in files.el bd5ef3ef95e Improve the documentation of 'auto-mode-alist' search 1798ff5a663 ; Fix minor mistakes in documentation faee7e1f1bd ; * lisp/treesit.el (treesit-font-lock-fontify-region): M... 24f0dfd3731 Revert "Revert "Add c-or-c++-ts-mode (bug#59613)"" ac3bc775b6f Make it harder to misactivate tree-sitter font-lock fast ... bdd82fa7977 ; * src/treesit.c: Remove unused boilerplate. 343b9b3dfe3 ruby-ts-mode: Obey the option ruby-method-call-indent 045404d1aac ruby-ts-mode: Obey the option ruby-after-operator-indent 300ca6ac372 ruby-ts-mode: Fix indent after operator or conditional ac5516bd7d5 ruby-ts-mode: Fix/change indentation of a continuation me... 5e2e68a0c2d ruby-ts-mode: Fix indent inside parenthesized_expr and el... 9ed9ff4690a ruby-ts-mode: Fix the rules for hanging arrays and hashes c4f0b6ccea1 Add more detail about how to invoke Eshell commands dbac923b9df CC Mode: On removal of "typedef", remove pertinent types ... 56d69c2fc47 ; Relax timeouts for failing ERC test 183e7492702 Don't preserve non-module minor modes in erc-open 7b8322f6285 Use correct buffer for local-module vars in erc-open 7b13422298a ; Avoid plist-get as generalized var in erc-compat 09e9d7c7496 Fix display of warnings on w32 console bd094207c76 Fix buffer-list-update-hook for indirect buffers 9e7a5d58eea ; Fix tree-sitter indent anchor preset 7c61a304104 Fix treesit-node-first-child-for-pos (bug#60127) b36cc7e7bbb ; * src/treesit.c (Ftreesit_induce_sparse_tree): Minor ch... # Conflicts: # etc/NEWS
| * ; Fix minor mistakes in documentationIkumi Keita2023-01-18
| | | | | | | | | | | | | | | | * lisp/emacs-lisp/cl-macs.el (cl-letf): Correct Info reference. * doc/lispref/strings.texi (String Conversion): Fix typo. (Bug#60926)
* | Styled quotes in compiler warningsMattias Engdegård2023-01-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/emacs-lisp/byte-run.el (byte-run--parse-body) (byte-run--unescaped-character-literals-warning): * lisp/emacs-lisp/bytecomp.el (byte-compile-initial-macro-environment) (byte-compile-form, bytecomp--warn-dodgy-eq-arg): * lisp/emacs-lisp/cconv.el (cconv--warn-unused-msg): * lisp/emacs-lisp/cl-macs.el (cl-defstruct): * lisp/emacs-lisp/easy-mmode.el (define-minor-mode): * lisp/emacs-lisp/eieio.el (defclass): * lisp/emacs-lisp/macroexp.el (macroexp--unfold-lambda) (macroexp--expand-all): * lisp/emacs-lisp/pcase.el (pcase--u1): * lisp/subr.el (when, unless, ignore-error, lsh, sit-for) (with-demoted-errors): Use format-message to ensure properly styled quotes in compiler warning messages.
* | Merge from origin/emacs-29Eli Zaretskii2023-01-01
|\| | | | | | | | | | | | | | | | | | | | | cae528457c ; Add 2023 to copyright years. b394359261 Improve documentation of 'isearch-open-overlay-temporary' ab3210e709 Document 'use-package' in the 2 main manuals # Conflicts: # etc/refcards/ru-refcard.tex # lib/explicit_bzero.c # m4/explicit_bzero.m4
| * ; Add 2023 to copyright years.Eli Zaretskii2023-01-01
| |
* | * lisp/emacs-lisp/cl-macs.el (cl-flet): Optimize a bit moreStefan Monnier2022-12-02
|/ | | | Also optimize the case where we use `cl-flet` to introduce a local alias.
* Fix &key parameters called without arguments (bug#58714)Gerd Möllmann2022-11-11
| | | | | | * lisp/emacs-lisp/cl-macs.el (cl--do-arglist): Check for missing argument. * test/lisp/emacs-lisp/cl-macs-tests.el (cl-&key-arguments): New test.
* Improve check for misleading 'cl-case' cases (Bug#57915).Philipp Stephani2022-09-19
| | | | | | * lisp/emacs-lisp/cl-macs.el (cl-case): Check that the case is of the form (quote FOO), not just (quote). * test/lisp/emacs-lisp/cl-macs-tests.el (cl-case-no-warning): New unit test.
* Have 'cl-case' warn about suspicious casesPhilipp Stephani2022-09-13
| | | | | | | | | * lisp/emacs-lisp/cl-macs.el (cl-case): Warn if the user passes a nil key list (which would never match). Warn about quoted symbols that should probably be unquoted. * test/lisp/emacs-lisp/cl-macs-tests.el (cl-case-warning): New unit test (bug#51368).
* Signal an error if a fallback cl-case is misplacedPhilipp Stephani2022-09-13
| | | | | | | | | * lisp/emacs-lisp/cl-macs.el (cl-case): Warn if the user passes a nil key list (which would never match). Warn about quoted symbols that should probably be unquoted. * test/lisp/emacs-lisp/cl-macs-tests.el (cl-case-warning): New unit test (bug#51368).
* cl-symbol-macrolet: Fix recent regressionStefan Monnier2022-09-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The recent fix for bug#57397 introduced a regression, breaking the `cl-lib-symbol-macrolet-hide` test. It turned out that the origin of the problem was that `gv.el` uses `macroexpand-1` which does not (can't) use `macroexpand` but `cl-symbol-macrolet` failed to advise `macroexpand-1` the way it advised `macroexpand`. To fix this, we change `cl-symbol-macrolet` so it advises both, and we do that with a new `macroexpand` advice which delegates the bulk of the work to `macroexpand-1`. Along the way, I bumped into another bug in the interaction between `cl-letf` and `cl-symbol-macrolet`, which I tried to fix in `cl-letf`. I hear the war on `cl-symbol-macrolet` was a failure. Maybe ... just say no? * lisp/emacs-lisp/cl-macs.el (cl--sm-macroexpand-1): New function, extracted from `cl--sm-macroexpand`. (cl--sm-macroexpand): Rewrite completely. (cl-symbol-macrolet): Advise both `macroexpand` and `macroexpand-1`. (cl--letf): Don't use the "simple variable" code for symbol macros. * test/lisp/emacs-lisp/cl-lib-tests.el (cl-lib-symbol-macrolet-hide): Revert last change because the test was right. * test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs-test--symbol-macrolet): Add a test case.
* gv.el and cl-macs.el: Fix bug#57397Stefan Monnier2022-09-03
| | | | | | | | | * lisp/emacs-lisp/gv.el (gv-get): Obey symbol macros. * lisp/emacs-lisp/cl-macs.el (cl--letf): Remove workaround placed to try and handle symbol macros. * test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs-test--symbol-macrolet): Add new testcase.
* * lisp/emacs-lisp/cl-macs.el: Use `define-symbol-prop` (bug#50869)Stefan Monnier2022-09-03
| | | | | | (cl-define-compiler-macro, cl-defstruct, cl-deftype): Prefer `define-symbol-prop` over `put` so `unload-feature` can undo those definitions.
* (compiled-function-p): New function (bug#56648)Stefan Monnier2022-08-14
| | | | | | | | | | | | | | | | | | | | | | | | * lisp/subr.el (compiled-function-p): New function. * test/lisp/international/ucs-normalize-tests.el (ucs-normalize-part1): * lisp/gnus/gnus.el (gnus): * lisp/mh-e/mh-e.el (mh-version): * lisp/emacs-lisp/macroexp.el (emacs-startup-hook): * lisp/emacs-lisp/cl-macs.el (compiled-function): * lisp/emacs-lisp/bytecomp.el (byte-compile-fdefinition) (byte-compile, display-call-tree): * lisp/emacs-lisp/byte-opt.el (<toplevel-end>): * lisp/emacs-lisp/advice.el (ad-compiled-p): * lisp/cedet/semantic/bovine.el (semantic-bovinate-stream): * lisp/loadup.el (macroexpand-all): * admin/unidata/unidata-gen.el (unidata--ensure-compiled): Use it. * lisp/emacs-lisp/pcase.el (pcase-mutually-exclusive-predicates): Add entries for it. (pcase--split-pred): Use it. * lisp/help-fns.el (help-fns-function-description-header): Use `functionp`. (help-fns--var-safe-local): Use `compiled-function-p`.
* Fix up some prefix registration problems in doc stringsLars Ingebrigtsen2022-08-04
| | | | | | | | * lisp/uniquify.el (uniquify-buffer-name-style): * lisp/org/ob-core.el (org-src-sha): * lisp/emacs-lisp/cl-macs.el (cl--optimize): * lisp/battery.el (battery-update-functions): Avoid triggering the `register-definition-prefixes' in doc strings (bug#56968).
* Avoid cl-cXXXr compat aliasesStefan Kangas2022-08-03
| | | | | | | | * lisp/emacs-lisp/cl-lib.el (cl-third, cl-fourth): * lisp/emacs-lisp/cl-macs.el (cl--do-&aux, cl--do-arglist) (cl--parse-loop-clause, cl--loop-let, cl--loop-build-ands) (cl--do-proclaim, cl-defstruct): Prefer using cXXXr functions directly, instead of cl-cXXXr prefixed compat aliases.
* Fix cl byte-compile warning in cl-loaddefs.elLars Ingebrigtsen2022-07-31
| | | | | | * lisp/emacs-lisp/cl-macs.el (cl--optimize) (cl-struct-sequence-type, cl-struct-slot-offset): Autoload since they are referred to by code in cl-loaddefs.el.
* Merge from origin/emacs-28Stefan Kangas2022-06-18
|\ | | | | | | | | | | | | d671cd57c4 Update cl-struct-sequence-type doc string 017bdb1611 Fix a tagging problem in tramp.texi e0bac17bbc Mention face quirks after the final line in the lispref ma... ad74677cf3 Delete reference to obsolete library complete.el
| * Update cl-struct-sequence-type doc stringLars Ingebrigtsen2022-06-17
| | | | | | | | | | * lisp/emacs-lisp/cl-macs.el (cl-struct-sequence-type): Fix doc string to reflect what it does (bug#46523).
* | Recognize processes as a CL type againBasil L. Contovounesios2022-06-11
| | | | | | | | | | | | | | | | For discussion, see: https://lists.gnu.org/r/emacs-devel/2022-06/msg00567.html * lisp/emacs-lisp/cl-macs.el (cl-deftype-satisfies): Include process as a type, to avoid cl-typep complaining about process objects.
* | cl-typep: Emit warning when using a type not known to be a typeStefan Monnier2022-06-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `cl-typep` has used a heuristic that if there's a `<foo>-p` function, then <foo> can be used as a type. This made sense in the past where most types were not officially declared to be (cl-)types, but nowadays this just encourages abuses such as using `cl-typecase` with "types" like `fbound`. It's also a problem for EIEIO objects, where for historical reasons `<foo>-p` tests if the object is of type exactly `<foo>` whereas (cl-typep OBJ <foo>) should instead test if OBJ is a *subtype* of `<foo>`. So we change `cl-typep` to emit a warning whenever this "-p" heuristic is used, to discourage abuses, encourage the use of explicit `cl-deftype` declarations, and try and detect some misuses of `<foo>-p` for EIEIO objects. * lisp/emacs-lisp/eieio.el (defclass): Define as type not only at run-time but also for the current compilation unit. * lisp/emacs-lisp/eieio-core.el (class, eieio-object): Define as types. * lisp/emacs-lisp/cl-preloaded.el (cl-struct-define): Don't abuse the "-p" heuristic. * lisp/emacs-lisp/cl-macs.el (cl-deftype-satisfies): Add entries for frames, windows, markers, and overlays. (cl-typep): Emit a warning when using a predicate that is not known to correspond to a type. * lisp/files.el (file-relative-name): Fix error that can trigger if there's an(other) error between loading `files.el` and loading `minibuffer.el`.
* | CL types: Accept both `byte-code-function` and `compiled-function`Stefan Monnier2022-04-29
| | | | | | | | | | | | | | | | | | | | | | | | `type-of` returns `compiled-function` for bytecode functions, but the predicate for those objects is called `byte-code-function-p`, So accept both `compiled-function` and `byte-code-function` as type names for those objects. * lisp/emacs-lisp/cl-preloaded.el (cl--typeof-types): Add `byte-code-function`. * lisp/emacs-lisp/cl-macs.el (byte-code-function, compiled-function, subr): New types.
* | Audit quoting the quote character in doc stringsLars Ingebrigtsen2022-04-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * test/src/regex-emacs-tests.el (regex-tests-compare): (regex-tests-compare): (regex-tests-match): * test/lisp/xml-tests.el (xml-parse-tests--qnames): * test/lisp/mh-e/mh-thread-tests.el (mh-thread-tests-before-from): * test/lisp/cedet/srecode-utest-template.el (srecode-utest-map-reset): * test/lisp/calc/calc-tests.el (calc-tests-equal): * lisp/window.el (get-lru-window): (get-mru-window): (get-largest-window): (quit-restore-window): (display-buffer): * lisp/vc/vc-rcs.el (vc-rcs-consult-headers): * lisp/url/url-auth.el (url-digest-auth-build-response): * lisp/tutorial.el (tutorial--find-changed-keys): * lisp/transient.el (transient-suffix-object): * lisp/textmodes/rst.el (rst-insert-list-new-item): * lisp/textmodes/bibtex.el (bibtex-clean-entry): * lisp/tab-bar.el (tab-bar--key-to-number): (toggle-frame-tab-bar): * lisp/ses.el (ses-recalculate-cell): (ses-define-local-printer): (ses-prin1): * lisp/progmodes/xref.el (xref--find-ignores-arguments): * lisp/progmodes/verilog-mode.el (verilog-single-declaration-end): * lisp/progmodes/tcl.el (tcl-mode-hook): * lisp/progmodes/gdb-mi.el (gdb-get-buffer-create): * lisp/progmodes/elisp-mode.el (elisp--xref-make-xref): * lisp/play/dunnet.el (dun-room-objects): * lisp/outline.el (outline--cycle-state): * lisp/org/ox-publish.el (org-publish-find-property): * lisp/org/ox-html.el (org-html--unlabel-latex-environment): * lisp/org/org-table.el (org-table-collapse-header): * lisp/org/org-plot.el (org--plot/prime-factors): * lisp/org/org-agenda.el (org-agenda--mark-blocked-entry): (org-agenda-set-restriction-lock): * lisp/org/ob-lua.el (org-babel-lua-read-string): * lisp/org/ob-julia.el (org-babel-julia-evaluate-external-process): (org-babel-julia-evaluate-session): * lisp/org/ob-core.el (org-babel-default-header-args): * lisp/obsolete/mouse-sel.el (mouse-select): (mouse-select-secondary): * lisp/net/tramp.el (tramp-methods): * lisp/net/eww.el (eww-accept-content-types): * lisp/net/dictionary-connection.el (dictionary-connection-status): * lisp/minibuffer.el (completion-flex--make-flex-pattern): * lisp/mh-e/mh-mime.el (mh-have-file-command): * lisp/mh-e/mh-limit.el (mh-subject-to-sequence): (mh-subject-to-sequence-threaded): (mh-subject-to-sequence-unthreaded): * lisp/mail/feedmail.el (feedmail-queue-buffer-file-name): (feedmail-vm-mail-mode): * lisp/ls-lisp.el (ls-lisp--sanitize-switches): * lisp/keymap.el (key-valid-p): * lisp/international/ccl.el (ccl-compile-branch-blocks): * lisp/image/image-converter.el (image-convert): * lisp/gnus/spam.el (spam-backend-check): * lisp/gnus/nnselect.el (nnselect-generate-artlist): * lisp/gnus/nnmairix.el (nnmairix-widget-other): * lisp/gnus/message.el (message-mailto): * lisp/gnus/gnus-sum.el (gnus-collect-urls-from-article): * lisp/gnus/gnus-search.el (gnus-search-prepare-query): * lisp/frame.el (frame-size-history): * lisp/eshell/esh-var.el (eshell-parse-variable-ref): * lisp/eshell/em-dirs.el (eshell-expand-multiple-dots): * lisp/erc/erc-backend.el (erc-bounds-of-word-at-point): * lisp/emulation/cua-rect.el (cua--rectangle-operation): * lisp/emacs-lisp/text-property-search.el (text-property-search-forward): * lisp/emacs-lisp/package.el (package-desc-suffix): * lisp/emacs-lisp/faceup.el (faceup-test-explain): * lisp/emacs-lisp/comp.el (comp-curr-allocation-class): (comp-alloc-class-to-container): (comp-add-cstrs): (comp-remove-type-hints-func): (batch-byte+native-compile): * lisp/emacs-lisp/cl-macs.el (cl--optimize): * lisp/elec-pair.el (electric-pair--syntax-ppss): * lisp/doc-view.el (doc-view-doc-type): * lisp/cedet/semantic/symref.el (semantic-symref-tool-alist): (semantic-symref-hit-to-tag-via-db): (semantic-symref-hit-to-tag-via-buffer): * lisp/cedet/semantic/lex-spp.el (semantic-lex-spp-get-overlay): * lisp/cedet/semantic/java.el (semantic-java-doc-keywords-map): * lisp/cedet/semantic/find.el (semantic-brute-find-tag-by-function): * lisp/cedet/semantic/db.el (semanticdb-project-predicate-functions): * lisp/cedet/semantic.el (semantic-working-type): * lisp/cedet/ede/files.el (ede-flush-directory-hash): * lisp/calc/calc.el (calc--header-line): * lisp/auth-source.el (auth-source-pick-first-password): (auth-source--decode-octal-string): * etc/themes/modus-themes.el (modus-themes--paren): (modus-themes--agenda-habit): * admin/cus-test.el (cus-test-vars-with-changed-state): Fix quoting in doc strings. In code examples, the ' character is quoted with \\=, and regularize 'foo to `foo', and quote strings like "foo" instead of 'foo'.
* | Fix eager macroexpansion cycle in cl-once-onlySean Whitton2022-04-12
| | | | | | | | | | | | * lisp/emacs-lisp/cl-macs.el (cl-once-only): Use different cl-loop syntax, with no functional change, but such that the loop does not expand into cl-psetq.
* | Add two classic Common Lisp macro-writing macrosSean Whitton2022-04-11
| | | | | | | | * lisp/emacs-lisp/cl-macs.el (cl-with-gensyms, cl-once-only): New macros.
* | ; * lisp/emacs-lisp/cl-macs.el (cl-struct-slot-value): Fix typo.Philipp Stephani2022-04-03
| |
* | Remove some early-bootstrap dependencies for `advice`Stefan Monnier2022-03-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The dependencies between `advice`, cl-generic`, `bytecomp`, `cl-lib`, `simple`, `help`, ... were becoming unmanageable. Break the reliance on `advice` (which includes making sure the compiler is not needed during the early bootstrap). * lisp/simple.el (pre-redisplay-function): Set without using `add-function`. * lisp/loadup.el (advice, simple): Move to after `cl-generic`. * lisp/help.el (command-error-function): Set without using `add-function`. (help-command-error-confusable-suggestions): Explicitly call `command-error-default-function` instead. * lisp/emacs-lisp/cl-macs.el (pcase--mutually-exclusive-p): Don't optimize during early-bootstrap. * lisp/emacs-lisp/cl-generic.el (cl--generic-lambda): Tiny simplification. (cl-defmethod): Label the obsolescence warning as it should. (cl--generic-compiler): New variable. (cl--generic-get-dispatcher): Use it. (cl--generic-prefill-dispatchers): Make freshly made dispatchers.
* | * lisp/emacs-lisp/cl-macs.el (cl-defstruct): Simplify Edebug specStefan Monnier2022-03-14
| |
* | Make Edebug specification for 'cl-defstruct' more lenient.Philipp Stephani2022-03-14
| | | | | | | | | | | | | | | | | | For example, 'xref-item' uses the list form of ':noinline'. * lisp/emacs-lisp/cl-macs.el (cl-defstruct): Accept ':noinline' and ':named' with an argument. * test/lisp/emacs-lisp/cl-macs-tests.el (cl-defstruct/edebug): New unit test.
* | (cl-macro-list): Simplify by unifying the variantsStefan Monnier2022-03-07
| | | | | | | | | | | | | | | | * lisp/emacs-lisp/cl-macs.el (cl-macro-list): Add the &whole and the dotted tail cases from `cl-macro-list1`. (cl-macro-list1, cl-define-compiler-macro-list): Delete edebug elem specs. (cl-destructuring-bind, cl-define-compiler-macro): Use `cl-macro-list` instead, now that it covers all the cases we need.
* | Teach Edebug about the special '&whole' syntax for compiler macros.Philipp Stephani2022-03-03
| | | | | | | | | | | | | | | | | | * lisp/emacs-lisp/cl-macs.el (cl-define-compiler-macro-list): New Edebug element specification. (cl-define-compiler-macro): Use it. * test/lisp/emacs-lisp/cl-macs-tests.el (cl-define-compiler-macro/edebug): New unit test.
* | (macroexp-warn-and-return): Fix bug#53618Stefan Monnier2022-02-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/emacs-lisp/macroexp.el (macroexp-warn-and-return): Reorder arguments to preserve compatibility with that of Emacs-28. (macroexp--unfold-lambda, macroexp--expand-all): * lisp/emacs-lisp/pcase.el (pcase-compile-patterns, pcase--u1): * lisp/emacs-lisp/gv.el (gv-ref): * lisp/emacs-lisp/eieio.el (defclass): * lisp/emacs-lisp/eieio-core.el (eieio-oref, eieio-oref-default) (eieio-oset-default): * lisp/emacs-lisp/easy-mmode.el (define-minor-mode): * lisp/emacs-lisp/cl-macs.el (cl-symbol-macrolet, cl-defstruct): * lisp/emacs-lisp/cl-generic.el (cl-defmethod): * lisp/emacs-lisp/byte-run.el (defmacro, defun): * lisp/emacs-lisp/bindat.el (bindat--type): Adjust accordingly.
* | Commit fixes and enhancements to the scratch/correct-warning-pos branchAlan Mackenzie2022-01-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | No longer strip positions from symbols before each use of a form, instead relying on the low level C routines to do the right thing. Instead strip them from miscellaneous places where this is needed. Stip them alson in `function-put'. Push forms onto byte-compile-form-stack and pop them "by hand" rather than by binding the variable at each pushing, so that it will still have its data after an error has been thrown and caught by a condition case. This gives an source position to the ensuing error message. * lisp/emacs-lisp/byte-run.el (byte-run--ssp-seen, byte-run--circular-list-p) (byte-run--strip-s-p-1, byte-run-strip-symbol-positions): New functions and variables, which together implement stripping of symbol positions. The latest (?final) version modifies the argument in place rather than making a copy. (function-put): Strip symbol positions from all of the arguments before doing the `put'. * lisp/emacs-lisp/bytecomp.el (byte-compile--form-stack): has been renamed to byte-compile-form-stack and moved to macroexp.el. (byte-compile-initial-macro-environment (eval-and-compile)): Replace macroexpand-all-toplevel with macroexpand--all-toplevel. (displaying-byte-compile-warnings): bind byte-compile-form-stack here. (byte-compile-toplevel-file-form, byte-compile-form): Push the top level form onto byte-compile-form-stack (whereas formally the variable was bound at each pushing). Manually pop this from of the variable at the end of the function. * lisp/emacs-lisp/cl-macs.el (cl-define-compiler-macro): Remove the symbol stripping. * lisp/emacs-lisp/comp.el (comp--native-compile): Set max-specpdl-size to at least 5000 (previously it was 2500). Bind print-symbols-bare to t. * lisp/emacs-lisp/macroexp.el (byte-compile-form-stack): Definition move here from bytecomp.el for easier compilation. (byte-compile-strip-symbol-positions and associated functions): Removed. (macro--expand-all): push argument FORM onto byte-compile-form-stack at the start of this function, and pop it off at the end. (internal-macroexpand-for-load): No longer strip symbol positions. Bind symbols-with-pos-enabled and print-symbols-bare to t. * lisp/help.el (help--make-usage): Strip any position from argument ARG. * src/fns.c (Fput): No longer strip symbol positions from any of the arguments.
* | Merge branch 'master' into scratch/correct-warning-posAlan Mackenzie2022-01-11
|\ \
| * | Merge from origin/emacs-28Eli Zaretskii2022-01-01
| |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 836be7a112 ; * etc/refcards/ru-refcard.tex: Update Copyright year. 86cbc6ee4a * lisp/net/tramp-sh.el: Adapt copyright year ebe8772f65 ; Minor fixes related to copyright years 23c1ee6989 ; * test/manual/etags/ETAGS.good_N: Adjust to copyright ye... 8d3fc7ec89 * src/xfaces.c (face_for_font): Make 'hash' be uintptr_t. 19dcb237b5 ; Add 2022 to copyright years. # Conflicts: # etc/NEWS # etc/refcards/ru-refcard.tex # lib/cdefs.h # lisp/erc/erc-dcc.el # lisp/erc/erc-imenu.el # lisp/erc/erc-replace.el # lisp/image-dired.el # lisp/progmodes/xref.el # m4/alloca.m4 # m4/byteswap.m4 # m4/errno_h.m4 # m4/getopt.m4 # m4/gnulib-common.m4 # m4/inttypes.m4 # m4/stddef_h.m4 # m4/stdint.m4 # m4/sys_socket_h.m4
| | * ; Add 2022 to copyright years.Eli Zaretskii2022-01-01
| | |
| * | Fix bug#28557Stefan Monnier2021-12-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * test/lisp/emacs-lisp/cconv-tests.el: Remove `:expected-result :failed` from the bug#28557 tests. (cconv-tests-cl-function-:documentation): Account for the presence of the arglist (aka "usage") in the docstring. * lisp/emacs-lisp/cl-macs.el (cl--transform-lambda): * lisp/emacs-lisp/cl-generic.el (cl-defgeneric): Handle non-constant `:documentation`. * lisp/emacs-lisp/generator.el (iter-lambda): * lisp/emacs-lisp/cconv.el (cconv--convert-funcbody): Use `macroexp-parse-body`.
| * | ; * lisp/emacs-lisp/cl-macs.el (cl--self-tco): fix bootstrappingMattias Engdegård2021-12-20
| | |
| * | Body of dynamic let-bindings is not in tail positionMattias Engdegård2021-12-20
| | | | | | | | | | | | | | | | | | | | | | | | This fixes a known bug in `named-let`. * lisp/emacs-lisp/cl-macs.el (cl--self-tco): Prevent TCO from inside dynamic variable bindings. * test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs--labels): Add test.
| * | * lisp/emacs-lisp/cl-macs.el (natnum): Fix typoStefan Monnier2021-12-03
| | |
| * | * lisp/emacs-lisp/cl-macs.el (natnum): Define it as a typeStefan Monnier2021-12-03
| | |
| * | * lisp/emacs-lisp/cl-macs.el (cl-defstruct): Decl struct predicates as pureAndrea Corallo2021-12-01
| |/
* | Make symbols with positions work with native compilationAlan Mackenzie2021-12-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This version of the software should bootstrap Emacs successfully with native compilation enabled. * lisp/emacs-lisp/bytecomp.el (byte-compile-strip-s-p-1) (byte-compile-strip-symbol-positions): Rename and move to macroexp.el. Rename calls to these functions throughout the file. (byte-compile-initial-macro-environment): In the code sections for eval-when-compile and eval-and-compile, call macroexp-strip-symbol-positions before evaluating code. (byte-compile-file, byte-compile-output-file-form) (byte-compile-file-form-defmumble, byte-compile, batch-byte-compile): Call macroexp-strip-symbol-positions from code being passed to the native compiler. * lisp/emacs-lisp/cl-macs.el (cl-macs--strip-s-p-1) (cl-macs--strip-symbol-positions): Remove, replacing them with the renamed functions in macroexp.el. (cl-define-compiler-macro): Apply macroexp-strip-symbol-positions to ARGS and BODY. * lisp/emacs-lisp/comp.el (comp-limplify-lap-inst): Use `null' to compile byte-not rather than a compilation of `eq'. (comp--native-compile): bind symbols-with-pos-enabled to t. * lisp/emacs-lisp/macroexp.el (byte-compile--ssp-conses-seen) (byte-compile--ssp-vectors-seen, byte-compile--ssp-records-seen): Provisional auxiliary variables to support the following functions. (macroexp--strip-s-p-2, byte-compile-strip-s-p-1) (macroexp-strip-symbol-positions): Functions moved from bytecomp.el, renamed, and further developed. (macroexp--compiler-macro): Bind symbol-with-pos-enabled to t around the call to `handler'. (internal-macroexpand-for-load): Strip symbol positions from the form being eagerly expanded for macros. * src/comp.c (F_SYMBOLS_WITH_POS_ENABLED_RELOC_SYM): New macro for a relocation symbol. (comp_t): New elements bool_ptr_type, f_symbols_with_pos_enabled_ref, lisp_symbol_with_position, lisp_symbol_with_position_header, lisp_symbol_with_position_sym, lisp_symbol_with_position_pos, lisp_symbol_with_position_type, lisp_symbol_with_position_ptr_type, get_symbol_with_position. (helper_GET_SYMBOL_WITH_POSITION): New function. (emit_BASE_EQ): Function rename from emit_EQ. (emit_AND, emit_OR, emit_BARE_SYMBOL_P, emit_SYMBOL_WITH_POS_P) (emit_SYMBOL_WITH_POS_SYM): New functions. (emit_EQ): New function which handles symbols with position correctly. (emit_NILP): Use emit_BASE_EQ rather than emit_EQ. (emit_limple_insn): When emitting a conditional branch, check each operand for being a literal Qnil, and if one of them is, use emit_BASE_EQ rather than emit_EQ. (declare_runtime_imported_funcs): Declare helper_GET_SYMBOL_WITH_POSITION. (emit_ctxt_code): Export the global F_SYMBOLS_WITH_POS_ENABLED_RELOC_SYM. (define_lisp_symbol_with_position, define_GET_SYMBOL_WITH_POSITION): New functions. (Fcomp__init_ctxt): Initialise comp.bool_ptr_type, call the two new define_.... functions. (load_comp_unit): Initialise **f_symbols_with_pos_enabled_reloc. * src/fns.c (Fput): Strip positions from symbols in PROPNAME and VALUE.
* | Several amendments to scratch/correct-warning-pos.Alan Mackenzie2021-12-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The position return by read-positioning-symbols is now the position in the buffer, rather than the offset from the start of a form, enabling warning positions in other parts of the buffer to be output. * src/lisp.h (lisp_h_EQ): Add XLI casts so that it compiles cleanly. * src/data.c (Fremove_pos_from_symbol): New DEFUN. * src/lread.c (readchar_count): renamed to readchar_offset. (read_internal_start) Initialize readchar_offset to the buffer's point when STREAM is a buffer. * lisp/emacs-lisp/bytecomp.el (byte-compile-warning-prefix): Amend to use OFFSET as a buffer position, not an offset from the start of a form. (byte-compile-warn): Remove symbol positions from any shape of ARGS, not just a symbol with position. * lisp/emacs-lisp/cconv.c (cconv-convert): In the :unused case, position the new IGNORE symbol with the VAR it has replaced. * lisp/emacs-lisp/macroexp.el (macroexp--warn-wrap, macroexp-warn-and-return): Add an extra position parameter to each. * lisp/emacs-lisp/bindat.el (bindat-type), lisp/emacs-lisp/byte-run.el (defmacro, defun), lisp/emacs-lisp/cconv.el (cconv--convert-func-body) (cconv-convert), lisp/emacs-lisp/cl-generic.el (cl-defmethod), lisp/emacs-lisp/cl-macs.el (cl-symbol-macrolet, cl-defstruct), lisp/emacs-lisp/easy-mmode.el (define-minor-mode), lisp/emacs-lisp/eieio-core.el (eieio-oref, eieio-oref-default) (eieio-oset-default), lisp/emacs-lisp/eieio.el (defclass), lisp/emacs-lisp/gv.el (gv-ref), lisp/emacs-lisp/macroexp.el (macroexp-macroexpand, macroexp--unfold-lambda, macroexp--expand-all), lisp/emacs-lisp/pcase.el (pcase-compile-patterns, pcase--u1): Add an extra position argument to each call of macroexp-warn-and-return.
* | First commit of scratch/correct-warning-pos.Alan Mackenzie2021-11-29
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This branch is intended to generate correct position information in warning and error messages from the byte compiler, and is intended thereby to fix bugs It introduces a new mechanism, the symbol with position. This is taken over from the previous git branch scratch/accurate-warning-pos which was abandoned for being too slow. The main difference in the current branch is that the symbol `nil' is never given a position, thus speeding up NILP markedly. * lisp/emacs-lisp/byte-opt.el (byte-compile-inline-expand) (byte-optimize-form-code-walker, byte-optimize-let-form, byte-optimize-while) (byte-optimize-apply): Use byte-compile-warn-x in place of byte-compile-warn. * lisp/emacs-lisp/bytecomp.el (byte-compile--form-stack): New variable. (byte-compile-strip-s-p-1, byte-compile-strip-symbol-positions): New functions. (byte-compile-recurse-toplevel, byte-compile-initial-macro-environment) (byte-compile-preprocess, byte-compile-macroexpand-declare-function): Bind print-symbols-bare to non-nil. (byte-compile--first-symbol, byte-compile--warning-source-offset): New functions. (byte-compile-warning-prefix): Modify to output two sets of position information, the old (incorrect) set and the new set. (byte-compile-warn): Strip positions from symbols before outputting. (byte-compile-warn-x): New function which outputs a correct position supplied in an argument. (byte-compile-warn-obsolete, byte-compile-emit-callargs-warn) (byte-compile-format-warn, byte-compile-nogroup-warn) (byte-compile-arglist-warn, byte-compile-docstring-length-warn) (byte-compile-warn-about-unresolved-functions, byte-compile-file) (byte-compile--check-prefixed-var, byte-compile--declare-var) (byte-compile-file-form-defvar-function, byte-compile-file-form-defmumble) (byte-compile-check-lambda-list, byte-compile--warn-lexical-dynamic) (byte-compile-lambda, byte-compile-form, byte-compile-normal-call) (byte-compile-check-variable, byte-compile-free-vars-warn) (byte-compile-subr-wrong-args, byte-compile-fset, byte-compile-set-default) (byte-compile-condition-case, byte-compile-save-excursion) (byte-compile-defvar, byte-compile-autoload) (byte-compile-make-variable-buffer-local, byte-compile-define-symbol-prop) (byte-compile-define-keymap): Replace byte-compile-warn with byte-compile-warn-x. (byte-compile-file, compile-defun): Bind symbols-with-pos-enabled to non-nil. (compile-defun, byte-compile-from-buffer): Use `read-positioning-symbols' rather than plain `read'. (byte-compile-toplevel-file-form, byte-compile-form): Dynamically bind byte-compile--form-stack. (byte-compile-file-form-autoload, byte-compile-file-form-defvar) (byte-compile-file-form-make-obsolete, byte-compile-lambda) (byte-compile-push-constant, byte-compile-cond-jump-table) (byte-compile-define-keymap, byte-compile-annotate-call-tree): Strip positions from symbols where they are unwanted. (byte-compile-file-form-defvar): Strip positions from symbols using `bare-symbol'. (byte-compile-file-form-defmumble): New variable bare-name, a version of name without its position. (byte-compile-lambda): Similarly, new variable bare-arglist. (byte-compile-free-vars-warn): New argument arg supplying position information to byte-compile-warn-x. (byte-compile-push-constant): Manipulation of symbol positions. (display-call-tree): Strip positions from symbols. * lisp/emacs-lisp/cconv.el (cconv-convert, cconv--analyze-use) (cconv--analyze-function, cconv-analyze-form): Replace use of byte-compile-warn with byte-compile-warn-x. * lisp/emacs-lisp/cl-generic.el (cl-defmethod): New variable org-name which will supply position information to a new macroexp-warn-and-return. * lisp/emacs-lisp/cl-macs.el (cl-macs--strip-s-p-1) (cl-macs--strip-symbol-positions): New functions to strip positions from symbols in an expression. These duplicaate similarly named functions in bytecomp.el. * lisp/emacs-lisp/macroexpand.el (macroexp--warn-wrap): Calls byte-compile-warn-x in place of byte-compile-warn. (macroexp-warn-and-return): Commented out new position parameter _arg. * src/.gdbinit: Add in code to handle symbols with position. * src/alloc.c (XPNTR, set_symbol_name, valid_lisp_object_p, purecopy) (mark_char_table, mark_object, survives_gc_p, symbol_uses_obj): Use BARE_SYMBOL_P and XBARE_SYMBOL in place of the former SYMBOLP and XSYMBOL. (build_symbol_with_pos): New function. (Fgarbage_collect): Bind Qsymbols_with_pos_enabled to nil around the call to garbage_collect. * src/data.c (Ftype_of): Add case for PVEC_SYMBOL_WITH_POS. (Fbare_symbol_p, Fsymbol_with_pos_p, Fbare_symbol, Fsymbol_with_pos_pos) (Fposition_symbol): New functions. (symbols_with_pos_enabled): New boolean variable. * src/fns.c (internal_equal, hash_lookup): Handle symbols with position. * src/keyboard.c (recursive_edit_1): Bind Qsymbols_with_pos_enabled and Qprint_symbols_bare to nil. * src/lisp.h (lisp_h_PSEUDOVECTORP): New macro. (lisp_h_BASE_EQ): New name for the former lisp_h_EQ. (lisp_h_EQ): Extended to handle symbols with position. (lisp_h_NILP): Now uses BASE_EQ rather than EQ. (lisp_h_SYMBOL_WITH_POS_P, lisp_h_BARE_SYMBOL_P): New macros. (lisp_h_SYMBOLP): Redefined to handle symbols with position. (BARE_SYMBOL_P, BASE_EQ): New macros. (SYMBOLP (macro)): Removed. (SYMBOLP (function), XSYMBOL, make_lisp_symbol, builtin_lisp_symbol) (c_symbol_p): Moved to later in file. (struct Lisp_Symbol_With_Pos): New data type. (pvec_type): PVEC_SYMBOL_WITH_POS: New type code. (PSEUDOVECTORP): Redefined to use the lisp_h_PSEUDOVECTORP. (BARE_SYMBOL_P, SYMBOL_WITH_POS_P, SYMBOLP, XSYMBOL_WITH_POS, XBARE_SYMBOL) (XSYMBOL, make_lisp_symbol, builtin_lisp_symbol, c_symbol_p, CHECK_SYMBOL) (BASE_EQ): New functions, or functions moved from earlier in the file. (SYMBOL_WITH_POS_SYM, SYMBOL_WITH_POS_POS): New INLINE functions. * src/lread.c (read0, read1, read_list, read_vector, read_internal_start) (list2): Add a new bool parameter locate_syms. (Fread_positioning_symbols): New function. (Fread_from_string, read_internal_start, read0, read1, read_list): Pass around suitable values for locate_syms. (read1): Build symbols with position when locate_syms is true. * src/print.c (print_vectorlike): Add handling for PVEC_SYMBOL_WITH_POS. (print_object): Replace EQ with BASE_EQ. (print_symbols_bare): New boolean variable.
* Clarify the purpose of internal--format-docstring-lineStefan Kangas2021-10-03
| | | | | | | | | * test/lisp/subr-tests.el (subr-test-internal--format-docstring-line): * lisp/subr.el (internal--format-docstring-line): Make it more clear that this function is not intended for the first line of a docstring. * lisp/emacs-lisp/cl-macs.el (cl-defstruct): Add comment explaining why we use 'internal--format-docstring-line'. Problem pointed out by Stefan Monnier <monnier@iro.umontreal.ca>.
* Mention describe-symbol in cl-defstruct docstringStefan Kangas2021-09-28
| | | | | * lisp/emacs-lisp/cl-macs.el (cl-defstruct): Mention 'describe-symbol' in docstring.