Commit graph

6651 commits

Author SHA1 Message Date
Stefan Monnier
d41a4ad4ae * lisp/emacs-lisp/macroexp.el (macroexp--expand-all): Warn on empty let bodies 2021-02-15 12:07:52 -05:00
Stefan Monnier
fc4927fc3a * lisp/emacs-lisp/bindat.el: Expose the struct variable (bug#46534)
(bindat--unpack-group, bindat--length-group, bindat--pack-group):
Mark it as dynamically scoped.
2021-02-15 10:50:07 -05:00
Lars Ingebrigtsen
b535c8ba87 Add a new variable `global-minor-modes'
* doc/lispref/modes.texi (Minor Modes): Document it.
* lisp/simple.el (global-minor-modes): New variable.
(completion-in-mode-p): Use it.
(completion-with-modes-p): Use it.

* lisp/emacs-lisp/easy-mmode.el (define-minor-mode): Support it.
2021-02-15 13:08:21 +01:00
Lars Ingebrigtsen
0bd846c174 Rename minor-modes to local-minor-modes
* doc/lispref/modes.texi (Minor Modes): Update documentation.
* lisp/simple.el (completion-with-modes-p): Change usage.

* lisp/emacs-lisp/easy-mmode.el (define-minor-mode): Change usage.

* src/buffer.c: Rename from minor_modes to local_minor_modes
throughout.
(syms_of_buffer): Rename minor-modes to local-minor-modes.

* src/buffer.h (struct buffer): Rename minor_modes_.

* src/pdumper.c (dump_buffer): Update hash and usage.
2021-02-15 13:08:21 +01:00
Stefan Monnier
54e577fbc1 * lisp/emacs-lisp/edebug.el (edebug-&optional, edebug-&rest): Remove vars
According to my tests, `edebug-&optional` never has any effect.
And `edebug-&rest` can be replaced with a closure.

(edebug-&rest-wrapper): Remove function.
(edebug--match-&-spec-op): Use a closure to remember the `specs`.
2021-02-14 23:56:42 -05:00
Stefan Monnier
623e534e49 * lisp/emacs-lisp/byte-run.el (compiler-macro): Make it Edebuggable
* lisp/emacs-lisp/gv.el (gc-expander, gv-setter): Reuse the spec of
`compiler-macro`.
2021-02-14 23:03:04 -05:00
Stefan Monnier
b939f7ad35 * Edebug: Generalize &lookup, use it for cl-macrolet and cl-generic
This allows the use of (declare (debug ...)) in the lexical macros
defined with `cl-macrolet`.  It also fixes the names used by Edebug
for the methods of `cl-generic` so it doesn't need to use gensym
and so they don't include the formal arg names any more.

* lisp/emacs-lisp/edebug.el (edebug--match-&-spec-op):
Rename from `edebug--handle-&-spec-op`.
(edebug--match-&-spec-op <&interpose>): Rename from `&lookup` and
generalize so it can let-bind dynamic variables around the rest of the parse.
(edebug-lexical-macro-ctx): Rename from `edebug--cl-macrolet-defs` and
make it into an alist.
(edebug-list-form-args): Use the specs from `edebug-lexical-macro-ctx`
when available.
(edebug--current-cl-macrolet-defs): Delete var.
(edebug-match-cl-macrolet-expr, edebug-match-cl-macrolet-name)
(edebug-match-cl-macrolet-body): Delete functions.
(def-declarations): Use new `&interpose`.
(edebug--match-declare-arg): Rename from `edebug--get-declare-spec` and
adjust to new calling convention.

* lisp/subr.el (def-edebug-elem-spec): Fix docstring.
(eval-after-load): Use `declare`.

* lisp/emacs-lisp/cl-generic.el: Fix Edebug names so we don't need
gensym any more and we only include the specializers but not the formal
arg names.
(cl--generic-edebug-name): New var.
(cl--generic-edebug-remember-name, cl--generic-edebug-make-name): New funs.
(cl-defgeneric, cl-defmethod): Use them.

* lisp/emacs-lisp/cl-macs.el: Add support for `debug` declarations in
`cl-macrolet`.
(cl-declarations-or-string):
Fix use of `lambda-doc` and allow use of `declare`.
(edebug-lexical-macro-ctx): Declare var.
(cl--edebug-macrolet-interposer): New function.
(cl-macrolet): Use it to pass the right `lexical-macro-ctx` to the body.

* lisp/emacs-lisp/pcase.el (pcase-PAT): Use new `&interpose`.
(pcase--edebug-match-pat-args): Rename from `pcase--get-edebug-spec` and
adjust to new calling convention.

* test/lisp/emacs-lisp/cl-generic-tests.el (cl-defgeneric/edebug/method):
Adjust to the new names.

* test/lisp/emacs-lisp/edebug-tests.el (edebug-cl-defmethod-qualifier)
(edebug-tests-cl-flet): Adjust to the new names.

* doc/lispref/edebug.texi (Specification List): Document &interpose.
2021-02-14 21:34:09 -05:00
Lars Ingebrigtsen
c339691772 Fix byte-run--set-modes call signature
* lisp/emacs-lisp/byte-run.el (byte-run--set-modes): We take a
list of modes, not a single one (and fix the quoting).
2021-02-14 18:01:06 +01:00
Lars Ingebrigtsen
2f00a3435a Don't update `minor-modes' in global modes
* lisp/emacs-lisp/easy-mmode.el (define-minor-mode): There's no
point in setting the buffer-local `minor-modes' in global modes.
2021-02-14 16:51:14 +01:00
Lars Ingebrigtsen
869cdcf4e7 Really fix the syntax problem in define-minor-mode
* lisp/emacs-lisp/easy-mmode.el (define-minor-mode): Fix
interactive extension in previous change.
2021-02-14 14:13:38 +01:00
Lars Ingebrigtsen
07e6b29b12 Fix previous define-minor-mode change
* lisp/emacs-lisp/easy-mmode.el (define-minor-mode): Fix
interactive extension in previous change.
2021-02-14 14:12:08 +01:00
Lars Ingebrigtsen
40f7804ecb Allow define-minor-mode to take an :interactive keyword
* lisp/emacs-lisp/easy-mmode.el (define-minor-mode): Allow
specifying the :interactive state and the modes.
2021-02-14 14:06:16 +01:00
Lars Ingebrigtsen
c1ef7adeb6 Add 'read-extended-command-predicate'
* doc/emacs/m-x.texi (M-x): Document it.
* doc/lispref/commands.texi (Interactive Call): Document it further.

* lisp/simple.el (read-extended-command-predicate): New user option.
(read-extended-command-predicate): Use it.
(completion-in-mode-p): New function (the default predicate).
2021-02-14 13:56:53 +01:00
Lars Ingebrigtsen
2bfcd93e83 Mark easy-menu-do-define menus as "not interesting"
* lisp/emacs-lisp/easymenu.el (easy-menu-do-define): Mark menu
keymaps as "not interesting" when doing completion.
2021-02-14 13:31:10 +01:00
Lars Ingebrigtsen
9291e7316f Add new 'declare' forms for command completion predicates
* doc/lispref/functions.texi (Declare Form): Document the new
`completion' and `modes' declarations.
* lisp/simple.el (completion-with-modes-p): New helper functions.

* lisp/emacs-lisp/byte-run.el (byte-run--set-completion)
(byte-run--set-modes):
(defun-declarations-alist): New declarations for `completion' and
`modes'.
2021-02-14 13:29:35 +01:00
Lars Ingebrigtsen
58e0c8ee86 Extend the syntax of `interactive' to list applicable modes
* doc/lispref/commands.texi (Using Interactive): Document the
extended `interactive' form.
* doc/lispref/loading.texi (Autoload): Document list-of-modes
form.

* lisp/emacs-lisp/autoload.el (make-autoload): Pick the list of
modes from `interactive' out of the functions.

* lisp/emacs-lisp/bytecomp.el (byte-compile-lambda): Allow for the
extended `interactive' form.

* src/callint.c (Finteractive): Document the extended form.

* src/data.c (Finteractive_form): Return the interactive form in
the old format (even when there's an extended `interactive') to
avoid having other parts of Emacs be aware of this.
(Fcommand_modes): New defun.

* src/emacs-module.c (GCALIGNED_STRUCT): Allow for modules to
return command modes.

* src/lisp.h: New function module_function_command_modes.
2021-02-14 13:21:24 +01:00
Lars Ingebrigtsen
43ecde8578 Introduce an :interactive keyword for `defined-derived-mode'
* doc/lispref/modes.texi (Derived Modes): Document it.
* lisp/emacs-lisp/derived.el (define-derived-mode): Introduce a
new :interactive keyword.
2021-02-14 12:58:20 +01:00
Lars Ingebrigtsen
760910f491 Add a new buffer-local variable `minor-modes'
* lisp/emacs-lisp/easy-mmode.el (define-minor-mode): Keep
`minor-modes' updated.
* src/buffer.c (bset_minor_modes, Fmake_indirect_buffer)
(reset_buffer, init_buffer_once): Initialise `minor-modes'.
(syms_of_buffer): Add `minor-modes' as a new permanently-local
variable.

* src/buffer.h (struct buffer): Add minor_modes_.
2021-02-14 12:37:44 +01:00
Stefan Monnier
103039b06c * lisp/emacs-lisp/edebug.el (edebug-make-enter-wrapper): Reinstate.
Removed by accident.
2021-02-13 19:24:33 -05:00
Stefan Monnier
2d9ff601ab * lisp/emacs-lisp/edebug.el: Fix called-interactively-p
And get rid of the old special-case handling of `interactive-p`, which
is now redundant.

(edebug--called-interactively-skip): Fix lexical-binding case,
and adjust to some formerly missed call patterns.
(edebug-def-interactive, edebug-interactive-p): Remove vars.
(edebug-interactive-p-name, edebug-wrap-def-body)
(edebug-make-enter-wrapper): Remove functions.
(edebug-list-form): Don't special-case `interactive-p`.
2021-02-13 19:22:17 -05:00
Stefan Monnier
39a401ddae * lisp/emacs-lisp/edebug.el (edebug-match-lambda-expr): Delete function
(lambda-expr): Define with `def-edebug-elem-spec` instead.
(edebug--handle-&-spec-op): Remove left over code.
(interactive): Re-add mistakenly removed spec elem.

* doc/lispref/edebug.texi (Specification List): Remove `function-form`.
2021-02-13 17:50:31 -05:00
Stefan Monnier
2007afd21b * lisp/emacs-lisp/edebug.el (edebug--handle-&-spec-op <&name>): New method
(edebug--concat-name): New function.
(edebug-match-name, edebug-match-cl-generic-method-qualifier)
(edebug-match-cl-generic-method-args): Delete functions.

* doc/lispref/edebug.texi (Specification List): Document it.

* lisp/emacs-lisp/cl-generic.el (cl-defgeneric): Use `&name`.
(cl-generic--method-qualifier-p): New predicate.
(cl-defmethod): Use it and `&name`.
* lisp/emacs-lisp/cl-macs.el (cl-defun, cl-iter-defun, cl-flet):
* lisp/emacs-lisp/eieio-compat.el (defmethod):
* lisp/emacs-lisp/gv.el (gv-define-setter):
* lisp/emacs-lisp/ert.el (ert-deftest): Use `&name`.
* lisp/erc/erc-backend.el (define-erc-response-handler): Use `declare`
and `&name`.
2021-02-13 16:21:53 -05:00
Stefan Monnier
f65402f851 (backtrace-goto-source-functions): Make it a normal abnormal hook
* lisp/emacs-lisp/backtrace.el (backtrace-goto-source-functions):
Don't mark it as buffer-local any more.
(backtrace-goto-source): Use `run-hook-with-args-until-success`.

* lisp/emacs-lisp/edebug.el (edebug-pop-to-backtrace): Clarify that the
hook is only intended to be modified buffer-locally.
2021-02-13 10:41:45 -05:00
Stefan Monnier
ca0842347e Edebug: Make it possible to debug gv-expanders in declare
Arrange for declarations to be able to specify their own specs via
the `edebug-declaration-spec` property.

* lisp/emacs-lisp/edebug.el: (edebug--get-declare-spec): New function.
(def-declarations): New spec element.
(defun, defmacro): Use it in their spec.

* lisp/emacs-lisp/gv.el (gv-expander, gv-setter):
Set `edebug-declaration-spec`.

* test/lisp/emacs-lisp/edebug-tests.el (edebug-tests-gv-expander): New test.

* test/lisp/emacs-lisp/edebug-resources/edebug-test-code.el
(edebug-test-code-use-gv-expander): New test case.
2021-02-12 22:53:38 -05:00
Stefan Monnier
d1be48fded Edebug: Overload edebug-form-spec even less
The `edebug-form-spec` symbol property was used both to map forms's
head symbol to the corresponding spec, and to map spec element names
to their expansion.

This lead to name conflicts which break instrumentation of examples such as

    (cl-flet ((gate (x) x)) (gate 4))

because of the Edebug spec element `gate`.
So introduce a new symbol property `edebug-elem-spec`.

* lisp/subr.el (def-edebug-elem-spec): New function.

* lisp/emacs-lisp/edebug.el (edebug--get-elem-spec): New function.
(edebug-match-symbol): Use it.
(Core Edebug elems): Put them on `edebug-elem-spec` instead of
`edebug-form-spec`.
(ELisp special forms): Set their `edebug-form-spec` via dolist.
(Other non-core Edebug elems): Use `def-edebug-elem-spec`.
(edebug-\`): Use `declare`.

* lisp/emacs-lisp/pcase.el (pcase-PAT, pcase-FUN, pcase-QPAT):
* lisp/skeleton.el (skeleton-edebug-spec):
* lisp/emacs-lisp/cl-macs.el: Use `def-edebug-elem-spec`.

* test/lisp/emacs-lisp/edebug-tests.el
(edebug-tests--conflicting-internal-names): New test.
* test/lisp/emacs-lisp/edebug-resources/edebug-test-code.el
(edebug-test-code-cl-flet1): New test case.

* doc/lispref/edebug.texi (Specification List): Add `def-edebug-elem-spec`.
(Specification Examples): Use it.

* doc/lispref/loading.texi (Hooks for Loading): Avoid the use of
`def-edebug-spec` in example (better use `debug` declaration).
2021-02-12 19:28:25 -05:00
Basil L. Contovounesios
c3163069a1 Fix ElDoc setup for eval-expression
* lisp/emacs-lisp/eldoc.el (eldoc--eval-expression-setup): Don't set
global value of eldoc-documentation-strategy (bug#44886).
2021-02-12 21:28:47 +00:00
Stefan Monnier
f8dbefbaa5 Use declare instead of def-edebug-spec in most places
* lisp/speedbar.el: Use lexical-binding.
(speedbar-with-writable): Use `declare`.

* lisp/subr.el (def-edebug-spec): Use `declare`.

* lisp/cedet/ede/base.el: Use lexical-binding.
(ede-with-projectfile): Use `declare`.
(recentf-exclude): Declare var.

* lisp/cedet/ede/pmake.el: Use lexical-binding.
(ede-pmake-insert-variable-shared, ede-pmake-insert-variable-once):
Use `declare`.

* lisp/cedet/ede/proj-comp.el: Use lexical-binding.
(ede-compiler-begin-unique, ede-compiler-only-once)
(ede-linker-begin-unique, ede-linker-only-once): Use `declare`.

* lisp/cedet/semantic/ctxt.el: Use lexical-binding.
(semantic-with-buffer-narrowed-to-context)
(semantic-with-buffer-narrowed-to-command): Use `declare`.
(semantic--progress-reporter): Declare var.
(semantic-ctxt-end-of-symbol-default): Remove unused var `fieldsep`.

* lisp/cedet/semantic/lex-spp.el: Use lexical-binding.
(define-lex-spp-macro-declaration-analyzer)
(define-lex-spp-include-analyzer, semantic-lex-with-macro-used)
(define-lex-spp-macro-undeclaration-analyzer): Use `declare`.
(semantic-lex-spp-symbol-remove): Rename arg to avoid colliding with
dynamic variable `obarray`.
(semantic-lex-spp-symbol-pop): Remove unused var `oldvalue`.
(semantic-lex-spp-lex-text-string): Remove unused var `analyzer`.

* lisp/cedet/semantic/lex.el (define-lex)
(semantic-lex-unterminated-syntax-protection, define-lex-analyzer)
(define-lex-regex-analyzer, define-lex-block-analyzer)
(semantic-lex-catch-errors): Use `declare`.

* lisp/cedet/semantic/tag.el: Use lexical-binding.
(semantic-with-buffer-narrowed-to-current-tag)
(semantic-with-buffer-narrowed-to-tag): Use `declare`.

* lisp/cedet/semantic/wisent.el: Use lexical-binding.
(define-wisent-lexer): Use `declare`.

* lisp/emacs-lisp/cl-lib.el (cl-pushnew): The arg to :test can be any
form not just function form.

* lisp/org/ob-comint.el (org-babel-comint-in-buffer)
(org-babel-comint-with-output): Use `declare`.

* lisp/org/ob-core.el (org-babel-map-src-blocks): Use `declare`.
(org-babel-result-cond): Simplify edebug spec.

* lisp/org/org-clock.el (org-with-clock-position, org-with-clock):
* lisp/org/org-agenda.el (org-agenda-with-point-at-orig-entry):
* lisp/org/ob-tangle.el (org-babel-with-temp-filebuffer): Use `declare`.

* lisp/textmodes/rst.el (push): Remove redundant edebug spec.

* lisp/vc/pcvs-parse.el: Use lexical-binding.
(cvs-parse-buffer): Rename arg to avoid dynbound conflict.
(cvs-or): Use `declare`.
2021-02-12 16:08:01 -05:00
Mattias Engdegård
9518926220 Simplify expression in byte-code decompiler
* lisp/emacs-lisp/byte-opt.el (byte-decompile-bytecode-1):
Replace roundabout expression with what it essentially does.
2021-02-12 20:52:05 +01:00
Mattias Engdegård
5a11e9185c byte-opt.el: More concise expression
* lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker):
Refactor `setq` clause.
2021-02-12 20:52:05 +01:00
Mattias Engdegård
ea29908c18 Avoid traversing dead if branches in bytecode optimiser
There is no point in traversing conditional branches that are
statically known never to be executed.  This saves some optimisation
effort, but more importantly prevents variable assignments and
references in those branches from blocking effective constant
propagation.

Also attempt to traverse as much as possible in an unconditional
context, which enables constant-propagation through (linear)
assignments.

* lisp/emacs-lisp/byte-opt.el (byte-optimize-form):
Rewrite the (tail) recursion into an explicit loop.  Normalise a
return value of (quote nil) to nil, for easier subsequent
optimisations.
* lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker): Don't
traverse dead `if` branches.  Use unconditional traversion context
when possible.
2021-02-12 20:52:05 +01:00
Stefan Monnier
c7b35ea306 * lisp/emacs-lisp/edebug.el (edebug--handle-&-spec-op) <&lookup>: New method
* doc/lispref/edebug.texi (Specification List): Document it.

* lisp/emacs-lisp/pcase.el (pcase-PAT): Use it.
(pcase-MACRO): Remove Edebug element.
(pcase--get-edebug-spec): New function.
(pcase--edebug-match-macro): Remove function.
2021-02-12 12:17:40 -05:00
Stefan Monnier
6ae731e04f * lisp/emacs-lisp/cl-macs.el (cl-flet): Fix edebug spec 2021-02-12 11:37:49 -05:00
Stefan Monnier
1d2487b1fc * lisp/emacs-lisp/edebug.el: Misc cleanups.
Move all definitions under the `edebug-` prefix.

(edebug-get-spec): Rename from `get-edebug-spec`.
(edebug-move-cursor): Use `cl-callf`.
(edebug-spec-p): Remove unused function.
(def-edebug-spec, edebug-spec-list, edebug-spec): Remove unused specs
(nothing in there gets instrumented anyway).
(edebug-tracing): Use `declare`.
(edebug-cancel-on-entry): Rename from `cancel-edebug-on-entry`.
(edebug-global-prefix): Rename from `global-edebug-prefix`.
(edebug-global-map): Rename from `global-edebug-map`.

* lisp/emacs-lisp/pcase.el (pcase-PAT): Remove `let`.
(let): Use `declare` instead.
(pcase--edebug-match-macro): Use new name `edebug-get-spec`.
2021-02-12 11:13:39 -05:00
Stefan Monnier
3a4b65177f * lisp/emacs-lisp/gv.el (gv-place): Simplify 2021-02-11 19:06:30 -05:00
Stefan Monnier
29c47ac19a * lisp/emacs-lisp/macroexp.el (macroexp--fgrep): Break cycles
* test/lisp/emacs-lisp/macroexp-tests.el: New file.
2021-02-10 16:06:24 -05:00
Stefan Monnier
2e5d400ca6 * lisp/emacs-lisp/edebug.el: Tweak last change
Use generic functions i.s.o `edebug--spec-op-function`.

<toplevel>: No need to register the &foo and :foo handler any more.
(edebug--handle-&-spec-op, edebug--handle-:-spec-op): New generic functions.
(edebug-match-specs): Use them.
(edebug--get-spec-op): Remove function.
(edebug-match-&optional, edebug-match-&rest, edebug-match-&or)
(edebug-match-&not, edebug-match-&key, edebug-match-&error)
(edebug-match-&define): Turn functions into methods of
`edebug--handle-&-spec-op`.
(edebug-match-:name, edebug-match-:unique): Turn functions into methods of
`edebug--handle-:-spec-op`.
2021-02-10 13:12:09 -05:00
Stefan Monnier
d6eddf2c07 * list/emacs-lisp/edebug.el: Don't overload edebug-form-spec
The `edebug-form-spec` symbol property was used to store two different things:
the handlers for spec elements like `body` and the handlers for
spec operators like `&or`.  But these two sets use different calling
conventions, so they're fundamentally incompatible.

So, move the handlers to spec operators to the new property
`edebug--spec-op-function`.  This unbreaks Edebugging of:

    (cl-flet ((f (&rest x) x)) 3)

* lisp/emacs-lisp/edebug.el <toplevel>: Split the alist of built in
spec elements into normal spec element and spec ops.
(edebug--get-spec-op): New function.
(edebug-match-specs): Use it.
(edebug-match-:name): Rename from `edebug-match-colon-name`.
2021-02-10 12:36:36 -05:00
Mattias Engdegård
f3ae26cb2a Fix local defvar scoping error (bug#46387)
This bug was introduced by the lexical variable constant propagation
mechanism.  It was discovered by Michael Heerdegen.

* lisp/emacs-lisp/byte-opt.el (byte-optimize-let-form)
(byte-optimize-body): Let the effects of a local defvar declaration be
scoped by let and let*, not any arbitrary Lisp expression body (such
as progn).
* test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--get-vars)
(bytecomp-local-defvar): New test.
2021-02-10 14:47:40 +01:00
Stefan Monnier
6fd8548b16 * lisp/emacs-lisp/byte-opt.el (byte-optimize--pcase): New macro
(byte-optimize-form-code-walker): Use it.
2021-02-09 12:10:07 -05:00
Stefan Monnier
04fb1664a8 * lisp/emacs-lisp/macroexp.el: Break cycle with bytecomp/byte-opt
The recent change in macroexp triggered a cyclic dependency error
during eager macroexpansion when neither `bytecomp` nor `byte-opt` had
been byte-compiled yet.  This fixes it by moving the offending
function to macroexp.el.

* lisp/emacs-lisp/macroexp.el (macroexp--unfold-lambda): Move from
byte-opt.el and rename.
(macroexp--expand-all): Use it.

* lisp/emacs-lisp/byte-opt.el (byte-compile-unfold-lambda): Move to
macroexp.el.
(byte-compile-inline-expand, byte-optimize-form-code-walker):
* lisp/emacs-lisp/bytecomp.el (byte-compile-form):
Use `macroexp--unfold-lambda` instead.
2021-02-09 12:02:25 -05:00
Stefan Kangas
3c53d28ae1 Remove some dead, commented out code from lisp-mode.el
* lisp/emacs-lisp/lisp-mode.el (lisp-data-mode-syntax-table):
Remove code commented out since 2005.
2021-02-09 17:03:55 +01:00
Matt Armstrong
9c1e89a32c Preserve leading whitespace in `lm-commentary'.
* lisp/emacs-lisp/lisp-mnt.el (lm-commentary): Preserve leading
whitespace (bug#46364).
2021-02-09 09:10:45 +01:00
Lars Ingebrigtsen
0cc35e1431 Move all usages of values' to values--store-value'
* lisp/simple.el (eval-expression):
* lisp/progmodes/elisp-mode.el (eval-last-sexp):
* lisp/emacs-lisp/pp.el (pp-eval-expression):
* lisp/emacs-lisp/edebug.el (edebug-eval-expression):
* lisp/emacs-lisp/pp.el (pp-eval-expression):
* lisp/emacs-lisp/edebug.el (edebug-eval-expression):
* lisp/cedet/data-debug.el (data-debug-eval-expression): Use it
instead of pushing to `values' directly (bug#22066).

* lisp/subr.el (values--store-value): New function.
2021-02-09 09:04:47 +01:00
Stefan Kangas
ce35760b19 ; Minor license statement fixes 2021-02-08 09:10:57 +01:00
Mattias Engdegård
7e48430a43 ; * lisp/emacs-lisp/byte-opt.el: improved comment 2021-02-07 12:24:40 +01:00
Mattias Engdegård
765ffeb545 ; Improved commentary in the variable constprop mechanism
* lisp/emacs-lisp/byte-opt.el (byte-optimize--lexvars)
(byte-optimize--vars-outside-condition)
(byte-optimize-form-code-walker, byte-optimize-let-form):
Clarify various aspects in the variable constant-propagation code,
as kindly pointed out by Stefan Monnier.
2021-02-07 10:35:36 +01:00
Mattias Engdegård
83983b6b7a Constprop of lexical variables
Lexical variables bound to a constant value (symbol, number or string)
are substituted at their point of use and the variable then eliminated
if possible.  Example:

  (let ((x (+ 2 3))) (f x))  =>  (f 5)

This reduces code size, eliminates stack operations, and enables
further optimisations.  The implementation is conservative, and is
strongly curtailed by the presence of variable mutation, conditions
and loops.

* lisp/emacs-lisp/byte-opt.el
(byte-optimize-enable-variable-constprop)
(byte-optimize-warn-eliminated-variable): New constants.
(byte-optimize--lexvars, byte-optimize--vars-outside-condition)
(byte-optimize--vars-outside-loop, byte-optimize--dynamic-vars):
New dynamic variables.
(byte-optimize--substitutable-p, byte-optimize-let-form):
New functions.
(byte-optimize-form-code-walker): Adapt clauses for variable
constprop, and add clauses for 'setq' and 'defvar'.
* test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-test-var)
(bytecomp-test-get-var, bytecomp-test-identity)
(byte-opt-testsuite-arith-data): Add test cases.
2021-02-06 20:22:24 +01:00
Lars Ingebrigtsen
c4a6f81ca4 Fix previous change in testcover.el
* lisp/emacs-lisp/testcover.el
(testcover-analyze-coverage-edebug-after): The wrapper macro is
called `1value', not `testcover-1value'.
2021-02-06 15:04:52 +01:00
Lars Ingebrigtsen
cf0869d22b Rename the `1value' symbol in testcover.el
* lisp/emacs-lisp/testcover.el: Rename the symbol `1value'
throughout the file to `testcover-1value' to allow using the
variable in code that's to be tested (bug#25471).
2021-02-06 12:28:46 +01:00
Lars Ingebrigtsen
f853f2d428 Avoid a compilation warning in iter-do
* lisp/emacs-lisp/generator.el (iter-do): Avoid a compilation
warning on using variables marked for not using (bug#31641).
Eg. (iter-do (_ i))
2021-02-06 11:31:18 +01:00