summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
Commit message (Collapse)AuthorAgeFilesLines
* Mark easy-menu-do-define menus as "not interesting"Lars Ingebrigtsen2021-02-141-1/+4
| | | | | * lisp/emacs-lisp/easymenu.el (easy-menu-do-define): Mark menu keymaps as "not interesting" when doing completion.
* Add new 'declare' forms for command completion predicatesLars Ingebrigtsen2021-02-141-1/+14
| | | | | | | | | | | * 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'.
* Extend the syntax of `interactive' to list applicable modesLars Ingebrigtsen2021-02-142-19/+36
| | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* Introduce an :interactive keyword for `defined-derived-mode'Lars Ingebrigtsen2021-02-141-1/+6
| | | | | | * doc/lispref/modes.texi (Derived Modes): Document it. * lisp/emacs-lisp/derived.el (define-derived-mode): Introduce a new :interactive keyword.
* Add a new buffer-local variable `minor-modes'Lars Ingebrigtsen2021-02-141-0/+4
| | | | | | | | | | | * 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_.
* * lisp/emacs-lisp/edebug.el (edebug-make-enter-wrapper): Reinstate.Stefan Monnier2021-02-131-0/+27
| | | | Removed by accident.
* * lisp/emacs-lisp/edebug.el: Fix `called-interactively-p`Stefan Monnier2021-02-131-58/+12
| | | | | | | | | | | | 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`.
* * lisp/emacs-lisp/edebug.el (edebug-match-lambda-expr): Delete functionStefan Monnier2021-02-131-28/+8
| | | | | | | | (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`.
* * lisp/emacs-lisp/edebug.el (edebug--handle-&-spec-op <&name>): New methodStefan Monnier2021-02-136-57/+89
| | | | | | | | | | | | | | | | | | (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`.
* (backtrace-goto-source-functions): Make it a normal abnormal hookStefan Monnier2021-02-132-6/+5
| | | | | | | | | * 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.
* Edebug: Make it possible to debug `gv-expander`s in `declare`Stefan Monnier2021-02-122-4/+13
| | | | | | | | | | | | | | | | | 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.
* Edebug: Overload `edebug-form-spec` even lessStefan Monnier2021-02-123-214/+207
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* Fix ElDoc setup for eval-expressionBasil L. Contovounesios2021-02-121-1/+2
| | | | | * lisp/emacs-lisp/eldoc.el (eldoc--eval-expression-setup): Don't set global value of eldoc-documentation-strategy (bug#44886).
* Use `declare` instead of `def-edebug-spec` in most placesStefan Monnier2021-02-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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`.
* Simplify expression in byte-code decompilerMattias Engdegård2021-02-121-4/+1
| | | | | * lisp/emacs-lisp/byte-opt.el (byte-decompile-bytecode-1): Replace roundabout expression with what it essentially does.
* byte-opt.el: More concise expressionMattias Engdegård2021-02-121-10/+9
| | | | | * lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker): Refactor `setq` clause.
* Avoid traversing dead `if` branches in bytecode optimiserMattias Engdegård2021-02-121-32/+32
| | | | | | | | | | | | | | | | | | | | 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.
* * lisp/emacs-lisp/edebug.el (edebug--handle-&-spec-op) <&lookup>: New methodStefan Monnier2021-02-122-27/+30
| | | | | | | | | * 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.
* * lisp/emacs-lisp/cl-macs.el (cl-flet): Fix edebug specStefan Monnier2021-02-121-1/+1
|
* * lisp/emacs-lisp/edebug.el: Misc cleanups.Stefan Monnier2021-02-122-69/+62
| | | | | | | | | | | | | | | | | | 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`.
* * lisp/emacs-lisp/gv.el (gv-place): SimplifyStefan Monnier2021-02-111-1/+1
|
* * lisp/emacs-lisp/macroexp.el (macroexp--fgrep): Break cyclesStefan Monnier2021-02-101-14/+29
| | | | * test/lisp/emacs-lisp/macroexp-tests.el: New file.
* * lisp/emacs-lisp/edebug.el: Tweak last changeStefan Monnier2021-02-101-37/+22
| | | | | | | | | | | | | | | 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`.
* * list/emacs-lisp/edebug.el: Don't overload `edebug-form-spec`Stefan Monnier2021-02-101-13/+28
| | | | | | | | | | | | | | | | | | 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`.
* Fix local defvar scoping error (bug#46387)Mattias Engdegård2021-02-101-2/+2
| | | | | | | | | | | | 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.
* * lisp/emacs-lisp/byte-opt.el (byte-optimize--pcase): New macroStefan Monnier2021-02-091-20/+50
| | | | (byte-optimize-form-code-walker): Use it.
* * lisp/emacs-lisp/macroexp.el: Break cycle with bytecomp/byte-optStefan Monnier2021-02-093-78/+68
| | | | | | | | | | | | | | | | | 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.
* Remove some dead, commented out code from lisp-mode.elStefan Kangas2021-02-091-3/+0
| | | | | * lisp/emacs-lisp/lisp-mode.el (lisp-data-mode-syntax-table): Remove code commented out since 2005.
* Preserve leading whitespace in `lm-commentary'.Matt Armstrong2021-02-091-1/+1
| | | | | * lisp/emacs-lisp/lisp-mnt.el (lm-commentary): Preserve leading whitespace (bug#46364).
* Move all usages of `values' to `values--store-value'Lars Ingebrigtsen2021-02-092-5/+7
| | | | | | | | | | | | | * 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.
* ; Minor license statement fixesStefan Kangas2021-02-081-0/+2
|
* ; * lisp/emacs-lisp/byte-opt.el: improved commentMattias Engdegård2021-02-071-1/+1
|
* ; Improved commentary in the variable constprop mechanismMattias Engdegård2021-02-071-8/+13
| | | | | | | | * 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.
* Constprop of lexical variablesMattias Engdegård2021-02-061-70/+244
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Fix previous change in testcover.elLars Ingebrigtsen2021-02-061-4/+4
| | | | | | * lisp/emacs-lisp/testcover.el (testcover-analyze-coverage-edebug-after): The wrapper macro is called `1value', not `testcover-1value'.
* Rename the `1value' symbol in testcover.elLars Ingebrigtsen2021-02-061-30/+30
| | | | | | * 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).
* Avoid a compilation warning in iter-doLars Ingebrigtsen2021-02-061-9/+12
| | | | | | * lisp/emacs-lisp/generator.el (iter-do): Avoid a compilation warning on using variables marked for not using (bug#31641). Eg. (iter-do (_ i))
* * lisp/emacs-lisp/pcase.el (let): Reimplement as a pcase macroStefan Monnier2021-02-051-13/+6
| | | | | (pcase--macroexpand, pcase--u1): Remove handling of `let` from `pcase`s core.
* * lisp/emacs-lisp/checkdoc.el: Doc fix; don't mention built-ins.Stefan Kangas2021-02-051-7/+0
|
* Improve filling of Emacs Lisp doc stringsLars Ingebrigtsen2021-02-041-1/+18
| | | | | | * lisp/emacs-lisp/lisp-mode.el (lisp-fill-paragraph): When filling a Lisp string, try to avoid filling bits that follow it (bug#28937).
* Allow a :variable keyword in define-globalized-minor-modeLars Ingebrigtsen2021-02-041-1/+3
| | | | | | | * doc/lispref/modes.texi (Defining Minor Modes): Document it. * lisp/emacs-lisp/easy-mmode.el (define-globalized-minor-mode): Allow specifying a :variable to be used if the underlying mode has a divergent variable to store the state (bug#29081).
* Remove some unnecessary references to Emacs 19Stefan Kangas2021-02-041-2/+1
| | | | | | | | | * lisp/emacs-lisp/elp.el: * lisp/mouse-copy.el: * lisp/mouse-drag.el: * lisp/progmodes/simula.el (simula-mode-map): * lisp/term.el (term-matching-input-from-input-string): * lisp/vcursor.el: Doc fix; don't mention Emacs 19.
* Remove XEmacs compat code from edebug.elStefan Kangas2021-02-041-11/+14
| | | | | * lisp/emacs-lisp/edebug.el (edebug-window-live-p, edebug-mark): Make obsolete. Update callers.
* * lisp/gnus/gnus-art.el: Fix misuse of `standard-value`.Stefan Monnier2021-02-021-2/+1
| | | | | | | | | | * lisp/custom.el (custom--standard-value): New function. * lisp/gnus/gnus-art.el: (gnus-article-browse-html-parts) (gnus-article-browse-html-article): * lisp/dired-aux.el (dired-do-find-regexp-and-replace): * lisp/emacs-lisp/package-x.el (package-upload-buffer-internal): * lisp/startup.el (command-line): Use it.
* * lisp/emacs-lisp/lisp-mode.el (lisp-mode): Also set `comment-end-skip`Stefan Monnier2021-02-021-0/+1
|
* Fix |# fontification in lisp-modechuntaro2021-02-021-0/+1
| | | | | | | * lisp/emacs-lisp/lisp-mode.el (lisp-mode): Give the |# the correct (font-lock-comment-delimited-face) face (bug#39820). Copyright-paperwork-exempt: yes
* Prefer defvar-local in emacs-lisp/*.elStefan Kangas2021-01-316-20/+10
| | | | | | | | | | | | * lisp/emacs-lisp/chart.el (chart-local-object): * lisp/emacs-lisp/easy-mmode.el (define-minor-mode) (define-globalized-minor-mode): * lisp/emacs-lisp/edebug.el: * lisp/emacs-lisp/generic.el (generic-font-lock-keywords): * lisp/emacs-lisp/re-builder.el (reb-regexp, reb-regexp-src) (reb-overlays): * lisp/emacs-lisp/syntax.el (syntax-propertize-extend-region-functions): Prefer defvar-local.
* Revert "Improve fontifying of #| ... |# in `lisp-mode'"Lars Ingebrigtsen2021-01-311-1/+0
| | | | | | This reverts commit 1275dc4711af77c9c223063dcd149d782d497463. Setting comment-end isn't the correct thing to do -- it makes M-; insert that string.
* Improve fontifying of #| ... |# in `lisp-mode'Lars Ingebrigtsen2021-01-291-0/+1
| | | | | * lisp/emacs-lisp/lisp-mode.el (lisp-mode): Fontify the end delimiter in #| ... |# correctly (bug#39820).
* Fix position in empty buffers in checkdoc-file-comments-engineLars Ingebrigtsen2021-01-291-1/+3
| | | | | * lisp/emacs-lisp/checkdoc.el (checkdoc-file-comments-engine): Don't give invalid positions on empty buffers (bug#39987).