Commit graph

8038 commits

Author SHA1 Message Date
Mattias Engdegård
45252ad8f9 Fix closure-conversion of shadowed captured lambda-lifted vars
Lambda-lifted variables (ones passed explicitly to lambda-lifted
functions) that are also captured in an outer closure and shadowed
were renamed incorrectly (bug#51982).

Reported by Paul Pogonyshev.

* lisp/emacs-lisp/cconv.el (cconv--lifted-arg): New.
(cconv-convert): Provide correct definiens for the closed-over
variable.
* test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--test-cases):
* test/lisp/emacs-lisp/cconv-tests.el (cconv-tests--intern-all)
(cconv-closure-convert-remap-var): Add tests.
2021-12-01 16:58:25 +01:00
Lars Ingebrigtsen
a8c067591e Autoload byte-compile-warning-enabled-p
* lisp/emacs-lisp/bytecomp.el (byte-compile-warning-enabled-p):
Autoloads (for easier use in macroexp etc).
2021-12-01 04:55:18 +01:00
Lars Ingebrigtsen
71f33b39cf Make "make force-autoloads" produce the correct result
* lisp/emacs-lisp/autoload.el (cl-lib): We need the cl-macs at
runtime to expand cl-defmacros to find declare indent forms.
2021-12-01 04:55:18 +01:00
Lars Ingebrigtsen
1f9834cd76 Don't include the other loaddef files in the no-autoloads section
* lisp/emacs-lisp/autoload.el (make-directory-autoloads): Don't
include the other loaddef files in the no-autoloads section.
2021-12-01 04:55:18 +01:00
Mattias Engdegård
3966a28454 Generalise CPS-conversion let optimisation
* lisp/emacs-lisp/generator.el (cps--transform-1):
Eliminate a temporary for the last of any `let` form, not just for
single-binding ones.  Suggested by Stefan Monnier.
2021-11-30 15:06:27 +01:00
Lars Ingebrigtsen
5fb9a033f8 Allow inhibiting warnings about obsolete macros again
* lisp/emacs-lisp/macroexp.el (macroexp-macroexpand): Inhibit
warning if requested (bug#50984).
2021-11-30 14:38:15 +01:00
Mattias Engdegård
68c09c6b74 Better CPS conversion of multi-binding let
* lisp/emacs-lisp/generator.el (cps--transform-1):
Don't translate single-binding `let` into `let*` with an extra
temporary variable; it just adds two more useless states.
2021-11-30 13:03:49 +01:00
Lars Ingebrigtsen
c623746241 Fix up generation of help text for ldefs-boot.el
* lisp/emacs-lisp/autoload.el (autoload-rubric): Don't put the
help text into cedet/*/loaddefs.el (bug#51744).
2021-11-29 22:39:57 +01:00
Lars Ingebrigtsen
4de13ef147 Signal a better error in tabulated-list-sort
* lisp/emacs-lisp/tabulated-list.el (tabulated-list-sort): Signal
error earlier on invalid column numbers (bug#52154).
2021-11-29 16:39:02 +01:00
Mattias Engdegård
9a0492ca7c ; Don't use remq (breaks bootstrapping) 2021-11-28 19:06:33 +01:00
Mattias Engdegård
d50e0bdbac Use compiler macros for the key syntax checks
Compile-time key string syntax checks are better written using
compiler macros than with byte-hunk-handlers inside the compiler
proper.

* lisp/emacs-lisp/bytecomp.el (byte-compile-define-keymap)
(byte-compile-define-keymap--define): Remove.
* lisp/keymap.el (keymap--compile-check): New.
(keymap-set, keymap-global-set, keymap-local-set, keymap-global-unset)
(keymap-local-unset, keymap-unset, keymap-substitute)
(keymap-set-after, key-translate, keymap-lookup, keymap-local-lookup)
(keymap-global-lookup): Use compiler-macro for argument checks.
* lisp/subr.el (define-keymap--compile): New.
(define-keymap--define): Fold into define-keymap.
(define-keymap): Use compiler-macro.
(defvar-keymap): Use define-keymap.
2021-11-28 18:10:23 +01:00
Mattias Engdegård
1e8074f5ea Avoid unused argument warnings in lambda compiler macros
* lisp/emacs-lisp/byte-run.el (byte-run--set-compiler-macro):
Don't warn when a compiler macro with lambda-form expander does not
use all the arguments of the function.  Nobody expected any warning
since the arguments look like free variables inside the lambda form.
2021-11-28 18:10:23 +01:00
Lars Ingebrigtsen
f1606047c4 Indent `closure' forms better
* lisp/emacs-lisp/lisp-mode.el (closure): Indent `closure' forms
better (bug#52063).
2021-11-25 14:41:45 +01:00
Lars Ingebrigtsen
e99bf27158 Remove APPEND argument from add-display-text-property
* doc/lispref/display.texi (Display Property): Update doc.
* lisp/emacs-lisp/subr-x.el (add-display-text-property): Remove
the append argument -- it's nonsensical.
2021-11-24 20:10:17 +01:00
Lars Ingebrigtsen
fde9363a57 Add new function 'add-display-text-property'
* doc/lispref/display.texi (Display Property): Document it.
* lisp/emacs-lisp/subr-x.el (add-display-text-property): New function.
2021-11-24 19:38:41 +01:00
Lars Ingebrigtsen
3a2eee6f74 Fix string-glyph-split infloop
* lisp/emacs-lisp/subr-x.el (string-glyph-split): Fix infloop when
applied to (string-glyph-split "✈️🌍") (bug#52067).
2021-11-24 08:27:22 +01:00
Stefan Kangas
a59e35d79f ; Further minor simplification of rx form in bytecomp.el
* lisp/emacs-lisp/bytecomp.el (byte-compile--wide-docstring-p):
Simplify even more.  Thanks to Mattias Engdegård <mattiase@acm.org>.
2021-11-22 16:14:01 +01:00
Stefan Kangas
487ddf466a ; Fix typo
* lisp/emacs-lisp/bytecomp.el (byte-compile--wide-docstring-p):
Fix typo.
2021-11-22 12:18:13 +01:00
Stefan Kangas
d1a2e78b8c ; Very minor simplification in bytecomp.el
* lisp/emacs-lisp/bytecomp.el (byte-compile--wide-docstring-p):
Very minor simplification of 'rx' form.
2021-11-22 12:04:19 +01:00
Stefan Kangas
4a3ba8528b Use substitute-command-keys for literal key sequences
* lisp/abbrev.el (expand-region-abbrevs):
* lisp/calc/calc-graph.el (calc-graph-show-dumb):
* lisp/calc/calc-help.el (calc-help-for-help):
* lisp/calc/calc-mode.el (calc-auto-why):
* lisp/calc/calc.el (calc-do):
* lisp/calculator.el (calculator-mode):
* lisp/dired-aux.el (dired-create-files)
(dired-do-create-files-regexp, dired-create-files-non-directory):
* lisp/dired-x.el (dired-virtual):
* lisp/dired.el (dired-mark-region, dired-unmark-all-files):
* lisp/emacs-lisp/map-ynp.el (map-y-or-n-p):
* lisp/emacs-lisp/re-builder.el (reb-enter-subexp-mode):
* lisp/epa-ks.el (epa-ks--display-keys):
* lisp/erc/erc.el (erc-toggle-debug-irc-protocol):
* lisp/files.el (save-some-buffers):
* lisp/gnus/gnus-dired.el (gnus-dired-find-file-mailcap)
(gnus-dired-print):
* lisp/gnus/gnus-group.el (gnus-keep-same-level):
* lisp/gnus/gnus-score.el (gnus-score-find-trace):
* lisp/gnus/gnus.el (to-list):
* lisp/gnus/message.el (message--send-mail-maybe-partially):
* lisp/mail/supercite.el (sc-set-variable):
* lisp/minibuffer.el (minibuffer-inactive-mode):
* lisp/progmodes/etags.el (select-tags-table):
* lisp/progmodes/idlw-shell.el (idlwave-shell-mode)
(idlwave-shell-char-mode-loop):
* lisp/replace.el (query-replace-help):
* lisp/simple.el (set-variable):
* lisp/subr.el (read-char-from-minibuffer):
* lisp/textmodes/ispell.el (ispell-help, ispell-message):
* lisp/textmodes/reftex-global.el (reftex-find-duplicate-labels):
* lisp/textmodes/reftex-vars.el
(reftex-toc-include-file-boundaries)
(reftex-toc-include-labels, reftex-toc-include-index-entries)
(reftex-toc-include-context, reftex-toc-follow-mode)
(reftex-index-include-context, reftex-index-follow-mode)
(reftex-enable-partial-scans)
(reftex-auto-update-selection-buffers)
(reftex-highlight-selection):
* lisp/time.el (display-time-update):
* lisp/vc/ediff-help.el (ediff-help-for-quick-help):
* lisp/vc/ediff-init.el (ediff-keep-variants):
* lisp/vc/ediff-ptch.el (ediff-fixup-patch-map)
(ediff-patch-file-internal):
* lisp/windmove.el (windmove-delete-default-keybindings): Use
'substitute-command-keys' for literal key sequences.

* lisp/userlock.el (userlock--fontify-key): Remove function.
(ask-user-about-lock, ask-user-about-lock-help)
(ask-user-about-supersession-threat)
(ask-user-about-supersession-help): Use 'substitute-command-keys' for
literal key sequences.

* lisp/ibuffer.el (ibuffer-unmark-all): Use 'substitute-command-keys'
for command.
2021-11-22 12:04:19 +01:00
Stefan Kangas
e91f71676c Avoid false positives about wide docstrings for key sequences
* lisp/emacs-lisp/bytecomp.el (byte-compile--wide-docstring-p):
Ignore literal key sequence substitutions.
* test/lisp/emacs-lisp/bytecomp-resources/warn-wide-docstring-ignore-substitutions.el:
New file.
* test/lisp/emacs-lisp/bytecomp-tests.el
("warn-wide-docstring-ignore-substitutions.el"): New test.
2021-11-22 12:04:19 +01:00
martin rudalics
61c254cafc Add new function buffer-text-pixel-size
* doc/lispref/display.texi (Size of Displayed Text): Document it.

* lisp/emacs-lisp/subr-x.el (string-pixel-width): Use
buffer-text-pixel-size (bug#51995).

* src/xdisp.c (window_text_pixel_size): Factor out from
Fwindow_text_pixel_size.
(Fbuffer_text_pixel_size): New function.
2021-11-22 12:02:42 +01:00
Lars Ingebrigtsen
3f096eb340 Make UCS compose/decompose functions more understandable
* lisp/international/ucs-normalize.el ()
(ucs-normalize-NFD-region, ucs-normalize-NFD-string)
(ucs-normalize-NFC-region, ucs-normalize-NFC-string)
(ucs-normalize-NFKD-region, ucs-normalize-NFKD-string)
(ucs-normalize-NFKC-region, ucs-normalize-NFKC-string): Make the
doc strings say what they actually do.
2021-11-19 07:46:06 +01:00
Filipp Gunbin
f8478dc133 Fixup for bug#51037
* lisp/emacs-lisp/ert.el (ert-batch-backtrace-line-length): Fix
docstring.
(ert-run-tests-batch): Remove redundand let-binding.
(ert-run-tests-interactively): Fix interactive spec.
2021-11-18 17:03:43 +03:00
Mattias Engdegård
67ffcc5c7f Signal an error for duplicated ERT tests (bug#51941)
Make `ert-deftest` fail with an error (in batch mode only) if an
existing test is redefined, because that is an easy mistake to make
and which leads to a test being discarded silently.

lisp/emacs-lisp/ert.el (ert-set-test, ert-deftest): Add check.
etc/NEWS: Announce.
2021-11-18 12:25:34 +01:00
Greg Minshall
1625123e4c Fix eldoc usage of newly introduced variable
* lisp/emacs-lisp/eldoc.el
(eldoc-display-message-no-interference-p): Make this function work
in older Emacs versions again (bug#51939).
2021-11-18 10:35:12 +01:00
Lars Ingebrigtsen
cde5dcd441 Change the call signature to keymap-substitute
* lisp/keymap.el (keymap-substitute): Make the keymap the first
parameter for symmetry with the other functions.
* lisp/emacs-lisp/shortdoc.el (keymaps):
* lisp/emacs-lisp/bytecomp.el (lambda): Adjust.
2021-11-17 08:34:35 +01:00
Michael Herstine
977f102a49 Make results details in ert-run-tests-batch configurable
* lisp/emacs-lisp/ert.el (ert-batch-print-length)
(ert-batch-print-level,.ert-batch-backtrace-line-length)
(ert-batch-test, ert-run-tests-interactively): Added the three
variables, bound them to these settings when formatting batch
test results including backtraces. Removed the optional
parameters output-buffer & message-fn from
ert-run-tests-interactively.
* test/lisp/emacs-lisp/ert-tests.el
(ert-test-run-tests-interactively, ert-test-run-tests-batch): use
cl-letf to capture output, new tests resp.
* test/lisp/ert-x-tests.el (ert-test-run-tests-interactively-2):
Changed to use cl-letf to capture output instead of using
message-fn.
* lisp/emacs-lisp/backtrace.el (backtrace--line-length-or-nil)
(backtrace--print-func-and-args): Fixed a bug when setting
backtrace-line-length to nil by adding a new function to check
for that case & having backtrace--print-func-and-args use it.
* doc/misc/ert.texi: document the new variables & their usage
(bug#51037).
2021-11-16 08:48:24 +01:00
Lars Ingebrigtsen
de477ec683 Add new 'keymap-*' functions
* lisp/keymap.el: New file with all the new keymap-* functions.

* lisp/loadup.el ("keymap"): Load.

* lisp/subr.el (kbd): Refactor out all the code to key-parse.
(define-key-after, keyboard-translate, global-set-key)
(local-set-key, global-unset-key, local-unset-key)
(local-key-binding, global-key-binding)
(substitute-key-definition): Note in doc strings that these are
legacy functions.
(define-keymap--define): Use keymap-set.

* lisp/emacs-lisp/byte-opt.el: Remove the optimizations for
defvar-keymap and define-keymap since the macros now only
understand the kbd syntax.
* lisp/emacs-lisp/bytecomp.el (byte-compile-define-keymap)
(byte-compile-define-keymap--define): Warn about invalid key
definitions in all keymap-* functions.

* lisp/emacs-lisp/shortdoc.el (keymaps): Add shortdocs form
keymap* functions.

* src/keymap.c (possibly_translate_key_sequence): Adjust callers
to key-valid-p and key-parse.
(syms_of_keymap): Adjust defs.
2021-11-16 08:26:24 +01:00
Stefan Kangas
18eec5720e * lisp/emacs-lisp/checkdoc.el (checkdoc-dired): Autoload. 2021-11-12 11:41:37 +01:00
Stefan Kangas
fc00fe53e1 Merge from origin/emacs-28
a6905e90cc Fix problem with temp buffer killing in package-install-file
144ad77fda Fix Lisp Intro markup error
24b86cb4f7 Fix ACL errors with WebDAV volumes on MS-Windows
2021-11-12 07:17:11 +01:00
Lars Ingebrigtsen
a6905e90cc Fix problem with temp buffer killing in package-install-file
* lisp/emacs-lisp/package.el (package-install-file): Allow killing
the temporary buffer without querying (bug#51769).
2021-11-12 04:44:09 +01:00
Miha Rihtaršič
0a93fb499b Set minibuffer-completion-* variables locally in more places
* lisp/calc/calc-store.el (calc-read-var-name):
* lisp/emacs-lisp/crm.el (completing-read-multiple):
* lisp/progmodes/cc-styles.el (c-read-offset):
* lisp/window.el (read-buffer-to-switch):
Set `minibuffer-completion-*` variables buffer-locally instead of
using a global let-binding (bug#48925).

Follow-up to commit
2021-05-01 "* lisp/minibuffer.el (completing-read-default): Fix bug#45474"
2021-11-11 06:16:52 +01:00
Lars Ingebrigtsen
6c405b7a49 Note that loaddefs.el is copied to ldefs-boot.el
* lisp/emacs-lisp/autoload.el (autoload-rubric): Add a comment to
the file noting what'll happen to it.
2021-11-11 04:08:51 +01:00
Robert Pluim
a491b73c76 Improve 'ensure-empty-lines' docstring
* lisp/emacs-lisp/subr-x.el (ensure-empty-lines): Fix typo and improve
wording.
2021-11-10 17:42:30 +01:00
Stefan Kangas
810fa21d26 Avoid another byte-compiler warning in package-quickstart.el
* lisp/emacs-lisp/package.el (package-quickstart-refresh): Avoid
byte-compiler warning "assignment to free variable" in
package-quickstart.el.
2021-11-10 15:24:29 +01:00
Stefan Kangas
1e7720d39a Avoid spurious byte-compiler warnings in package-quickstart.el
* lisp/emacs-lisp/package.el (package-quickstart-refresh): Disable the
"`make-variable-buffer-local' not called at toplevel" byte-compiler
warnings.  Given that we wrap it all in a let-form, these are mostly
false positives and not helpful.
2021-11-10 14:52:38 +01:00
Tom Levy
a28647a6b6 Remove spurious %S from 'define-error' messages
; The MESSAGE arg of 'define-error' does not support format specifiers
; (unlike the 'error' function). The signal data is automatically
; appended to the error message.

* lisp/emacs/lisp/cl-generic.el (cl--generic-cyclic-definition):
Remove spurious %S from error message.
* lisp/emacs-lisp/gv.el (gv-invalid-place): Remove spurious %S from
error message (and rephrase) (bug#51718).

Copyright-paperwork-exempt: yes
2021-11-10 01:16:16 +01:00
Lars Ingebrigtsen
2e6ed253ce Add new function 'file-name-split'
* doc/lispref/files.texi (File Name Components): Document it.
* lisp/files.el (file-name-split): New function (bug#50572).

* lisp/emacs-lisp/shortdoc.el (file-name): Mention it.
2021-11-10 00:26:32 +01:00
akater
3fd0e7fba6 ; * lisp/emacs-lisp/lisp-mode.el: Restore one check in flet handling
* lisp/emacs-lisp/lisp-mode.el (lisp--local-defform-body-p):
Do check backward-up-list executing without errors (bug#9622).
2021-11-09 04:26:05 +01:00
Stefan Monnier
4f365eec10 * lisp/emacs-lisp/cl-generic.el: Add reference to inspiration 2021-11-08 08:20:43 -05:00
akater
ca9fb109f7 lisp/emacs-lisp/lisp-mode.el: Fix parser state corruption.
* lisp/emacs-lisp/lisp-mode.el (lisp--local-defform-body-p): Preserve
the point.
* test/lisp/progmodes/elisp-mode-resources/flet.erts: Add corresponding
test example (bug#9622).
2021-11-08 07:38:41 +01:00
Lars Ingebrigtsen
67276f3403 Make debugging ert--erts-specifications easier
* lisp/emacs-lisp/ert.el (ert--erts-specifications): Strip text
properties from specs to make debugging easier.
2021-11-07 23:45:14 +01:00
Basil L. Contovounesios
e9a5084c45 ; Fix some recent typos/thinkos. 2021-11-07 12:59:18 +02:00
Lars Ingebrigtsen
d69b5a9caa Fix pp-emacs-lisp-code for `when' and related
* lisp/emacs-lisp/pp.el (pp--format-definition): Skip edebug specs
we don't understand at all.
2021-11-07 02:44:42 +01:00
Stefan Kangas
0cac4598a7 Ensure return value of ert-with-temp-directory
* lisp/emacs-lisp/ert-x.el (ert-with-temp-file): Ensure return
value when :directory is t is the directory name.
* test/lisp/emacs-lisp/ert-x-tests.el
(ert-x-tests-with-temp-directory): Extend test for the above.
2021-11-07 01:54:31 +01:00
Stefan Kangas
5dd27fef58 Add generated suffix to test temp file names
* lisp/emacs-lisp/ert-x.el
(ert-with-temp-file): Add temp file name suffix based on file name of
caller.  Reflow docstring.
(ert--with-temp-file-generate-suffix): New defun.
* test/lisp/emacs-lisp/ert-x-tests.el
(ert-x-tests--with-temp-file-generate-suffix): New test.
2021-11-07 01:54:30 +01:00
dickmao
9dfd945a2c Fix byte compilation of package built-ins
* lisp/emacs-lisp/package.el
(package--activate-autoloads-and-load-path):
(package--load-files-for-activation): Remove.
(package--library-stem): New function, because
file-name-sans-extension is insufficient.
(package--reload-previously-loaded): New function.
(package-activate-1): Reload directly.
(package--files-load-history):
(package--list-of-conflicts):
(package--list-loaded-files): Remove
(package-unpack): Adjust call.

* test/lisp/emacs-lisp/package-tests.el (macro-builtin-func): Test.
(macro-builtin-10-and-90): Test.
(package-test-macro-compilation): Test.
(package-test-macro-compilation-gz): Test (bug#49708).
2021-11-07 01:28:47 +01:00
Stefan Kangas
bf2e35c5d2 New convenience macros ert-with-temp-(file|directory)
* lisp/emacs-lisp/ert-x.el
(ert-with-temp-file)
(ert-with-temp-directory): New macros.
* test/lisp/emacs-lisp/ert-x-tests.el
(ert-x-tests-with-temp-directory)
ert-x-tests-with-temp-directory/text-signals-error
(ert-x-tests-with-temp-file)
(ert-x-tests-with-temp-file/handle-error)
(ert-x-tests-with-temp-file/prefix-and-suffix-kwarg)
(ert-x-tests-with-temp-file/text-kwarg)
(ert-x-tests-with-temp-file/unknown-kwargs-signals-error): New tests.
2021-11-06 19:16:05 +01:00
Lars Ingebrigtsen
82d0550648 Remove messaging in pp-display-expression.
* lisp/emacs-lisp/pp.el (pp-display-expression): Remove confusing
message -- we don't usually say that we've popped up a new buffer when
we do so.
2021-11-06 02:20:06 +01:00