Commit graph

8376 commits

Author SHA1 Message Date
Lars Ingebrigtsen
0d383b592c Fix ;;;###autoload scanning from (some) packages
* lisp/emacs-lisp/loaddefs-gen.el (loaddefs-generate--parse-file):
Fix autoloads scanning from packages.
2022-06-15 14:05:17 +02:00
Mattias Engdegård
1ac74e2862 Simplify byte-compiler assuming cconv normalisations
* lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker)
(byte-optimize-let-form, byte-optimize-letX):
* lisp/emacs-lisp/bytecomp.el (byte-compile-unwind-protect):
Simplify source optimisation and codegen code that can now rely on
normalised let/let* and unwind-protect forms.
2022-06-14 20:19:59 +02:00
Mattias Engdegård
d6600481ae Run cconv for dynbound code as well
Make cconv work for dynamically bound code and always run it.
This allows later stages to benefit from transformations and
normalisations in cconv.

* lisp/emacs-lisp/bytecomp.el (byte-compile-preprocess): Always run
cconv.
* lisp/emacs-lisp/cconv.el (cconv--analyze-function)
(cconv-analyze-form): In dynbound code, treat all variable bindings
as dynamic (lambda, let, let* and condition-case).
2022-06-14 20:19:59 +02:00
Mattias Engdegård
6825e5686a Normalise setq during macro-expansion
Early normalisation of setq during macroexpand-all allows later
stages, cconv, byte-opt and codegen, to be simplified and duplicated
checks to be eliminated.

* lisp/emacs-lisp/macroexp.el (macroexp--expand-all):
Normalise all setq forms to a sequence of (setq VAR EXPR).
Emit warnings if necessary.
* lisp/emacs-lisp/cconv.el (cconv-convert, cconv-analyze-form):
* lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker):
* lisp/emacs-lisp/bytecomp.el (byte-compile-setq):
Simplify.
* test/lisp/emacs-lisp/bytecomp-tests.el: Adapt and add tests.
* test/lisp/emacs-lisp/bytecomp-resources/warn-variable-setq-nonvariable.el;
* test/lisp/emacs-lisp/bytecomp-resources/warn-variable-setq-odd.el:
New files.
2022-06-14 20:19:59 +02:00
Lars Ingebrigtsen
a02bb84c80 Leave the contents on the *Backtrace* buffer on `q'
* lisp/emacs-lisp/debug.el (debug): Don't clear the contents of
the buffer on `q' (bug#55863).
2022-06-14 14:38:05 +02:00
Mattias Engdegård
9fb80aee17 ; * lisp/emacs-lisp/cconv.el: Fix outdated comments. 2022-06-14 12:14:47 +02:00
Richard Hansen
86325f960a bindat (strz): Error on null byte if packing variable-length string
* lisp/emacs-lisp/bindat.el (strz): Signal an error if a null byte is
encountered while packing a string to a variable-length strz field.
* test/lisp/emacs-lisp/bindat-tests.el (strz): Add tests (bug#55938).
2022-06-13 15:33:12 +02:00
Lars Ingebrigtsen
0fdd37c7fb Make `/ a' in *Package* filter by name
* lisp/emacs-lisp/package.el (package-menu-filter-by-archive):
Filter by package name instead of by regexp, so that if the user
types "gnu", they won't get "nongnu", too (bug#55919).
2022-06-13 14:20:22 +02:00
Richard Hansen
c1829b307c bindat (str, strz): Reject non-ASCII, non-`eight-bit' characters
* lisp/emacs-lisp/bindat.el (str) (strz): Signal an error if the user
attempts to pack a multibyte string containing characters other than
ASCII and `eight-bit' characters (bug#55897).
* doc/lispref/processes.texi (Bindat Types): Update documentation.
* test/lisp/emacs-lisp/bindat-tests.el (str) (strz): Add tests.
2022-06-12 09:59:13 +03:00
Stefan Monnier
4a3a73dd32 * lisp/emacs-lisp/find-func.el (find-function-advised-original): Simplify 2022-06-11 23:50:35 -04:00
Basil L. Contovounesios
e53428994e Recognize processes as a CL type again
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.
2022-06-11 19:21:55 +03:00
Lars Ingebrigtsen
ad432c1644 Fix loaddefs installation of packages with no autoloads
* lisp/emacs-lisp/loaddefs-gen.el (loaddefs-generate): Always
generate an output file if we have EXTRA-DATA.  This fixes package
installation of packages with no ;;;###autoload forms.
2022-06-11 18:13:27 +02:00
Stefan Monnier
51def94e9c Bindat: Document sint; add le arg to uint; deprecate uintr
* lisp/emacs-lisp/bindat.el (bindat--type) <uint>: Add `le` optional arg.
(bindat--type) <uintr>: Delete method.
(uintr): Re-define as a bindat-macro instead.
(bindat-type): Update docstring accordingly.
(bindat--primitives): Update.
(sint): Simplify.

* doc/lispref/processes.texi (Bindat Types): Update `uint`, add `sint`,
and remove `uintr`.

* test/lisp/emacs-lisp/bindat-tests.el (data-bindat-spec): Use the new
`le` arg of `uint` instead of `uintr`.
2022-06-11 11:55:27 -04:00
Richard Hansen
0afaf53c6e ; bindat (bindat--length-group): Fix indentation 2022-06-10 11:53:32 +02:00
Richard Hansen
c7037219b0 ; bindat (strz): Consistent length type check, take two
Commit 30ec4a7347 is incorrect -- the
length computation logic uses a simple nilness test, not `numberp'.
The `numberp' case is just an optimization if `len' is a literal
number; it does not affect the behavior.

Revert that commit, add some comments to help future readers avoid the
same mistake, and update the pack logic to use the same optimization
as the length computation for consistency.
2022-06-10 11:53:30 +02:00
Michael Albinus
b2ed8a547a Factor out test configuration for remote files
* lisp/emacs-lisp/ert-x.el (tramp-methods)
(tramp-default-host-alist): Declare.
(ert-remote-temporary-file-directory): New defconst.

* test/README: Mention dnd-tests.el.

* test/lisp/autorevert-tests.el
(auto-revert-test-remote-temporary-file-directory): Remove.
Replace all uses by `ert-remote-temporary-file-directory'.

* test/lisp/dnd-tests.el (ert-x): Require.
(dnd-tests-temporary-file-directory): Remove.  Replace all uses by
`ert-remote-temporary-file-directory'.

* test/lisp/filenotify-tests.el
(file-notify-test-remote-temporary-file-directory): Remove.
Replace all uses by `ert-remote-temporary-file-directory'.

* test/lisp/shadowfile-tests.el (ert-x): Require.
(shadow-test-remote-temporary-file-directory): Remove.  Replace
all uses by `ert-remote-temporary-file-directory'.

* test/lisp/net/tramp-tests.el: Don't require ert.
(ert-remote-temporary-file-directory): Define if it doesn't exist.
(tramp-test-temporary-file-directory): Remove.  Replace all uses
by `ert-remote-temporary-file-directory'.
2022-06-08 12:06:56 +02:00
Mattias Engdegård
493ae66be0 Preserve doc string in byte-compile (bug#55830)
* lisp/emacs-lisp/bytecomp.el (byte-compile--reify-function):
Don't transpose doc string and interactive spec, which must come
in this order.
* test/lisp/emacs-lisp/bytecomp-tests.el
(bytecomp-function-attributes): New test.
2022-06-08 10:08:05 +02:00
Lars Ingebrigtsen
7815ebd25f Fix loaddefs-generate--rubric recorded name
* lisp/emacs-lisp/loaddefs-gen.el (loaddefs-generate--rubric): Fix
the name that's recorded in the file -- this is only used by
loaddefs-gen now, I think.
2022-06-07 18:51:15 +02:00
Stefan Monnier
a98413726f find-func.el: Fix bug#41104
* lisp/emacs-lisp/find-func.el (find-function-advised-original): Look
at the actual function definition rather than
`advice--symbol-function` which sometimes returns only the advice.

* test/lisp/emacs-lisp/find-func-tests.el
(find-func-tests--find-library-verbose): Add test.
2022-06-07 10:31:17 -04:00
Eli Zaretskii
f3062c4104 ; * lisp/emacs-lisp/lisp.el (raise-sexp): Doc fix. (Bug#55788) 2022-06-06 17:10:21 +03:00
Stefan Monnier
5ee4209f30 cl-typep: Emit warning when using a type not known to be a type
`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`.
2022-06-06 00:04:00 -04:00
Lars Ingebrigtsen
b1ed72fd70 Clarify syntax-ppss doc string
* lisp/emacs-lisp/syntax.el (syntax-ppss): Clarify doc string.
2022-06-05 22:37:32 +02:00
Lars Ingebrigtsen
8c00e21df2 Move two more variables from autoload.el to loaddefs-gen.el
* lisp/emacs-lisp/loaddefs-gen.el (generated-autoload-file)
(generated-autoload-load-name): Move the remaining two autoload.el
variables used by loaddefs-gen.el from autoload.el.
2022-06-05 20:32:01 +02:00
Lars Ingebrigtsen
98d454627c Rename generate-file to generate-lisp-file
* lisp/url/url-cookie.el (url-cookie-write-file):
* lisp/international/titdic-cnv.el (tit-process-header)
(miscdic-convert):
* lisp/international/ja-dic-cnv.el (skkdic-convert):
* lisp/international/emoji.el (emoji--generate-file):
* lisp/emacs-lisp/loaddefs-gen.el (loaddefs-generate--rubric):
* admin/unidata/unidata-gen.el (unidata-gen-file)
(unidata-gen-charprop): Adjust callers.

* lisp/emacs-lisp/generate-lisp-file.el: Renamed from
generate-file.el.  Also rename some keyword parameters and require
a generator function.
2022-06-05 17:48:39 +02:00
Lars Ingebrigtsen
9d2f4a8d5a Add convenience functions for generating Emacs Lisp files
* lisp/url/url-cookie.el (url-cookie-write-file):
* lisp/international/titdic-cnv.el (tit-process-header):
* lisp/international/ja-dic-cnv.el (skkdic-convert):
* lisp/international/emoji.el (emoji--generate-file):
* lisp/emacs-lisp/loaddefs-gen.el (loaddefs-generate--rubric)

* admin/unidata/unidata-gen.el (unidata-gen-file)
(unidata-gen-charprop): Use the new functions.

* lisp/emacs-lisp/generate-file.el: New file to provide
convenience functions for generated files.  It's not always
trivial to know which parts of the trailer that has to be
obfuscated to avoid not getting byte-compiled etc, and some parts
of the headers/trailers are usually forgotten when hand-coding
these.
2022-06-05 16:36:34 +02:00
Lars Ingebrigtsen
d8924e179e Extend file-expand-wildcards to allow regexps
* doc/lispref/files.texi (Contents of Directories): Document it.
* lisp/files.el (file-expand-wildcards): Extend to allow regexps.

* lisp/emacs-lisp/shortdoc.el (file): Expand the
file-expand-wildcards example.
2022-06-05 14:08:31 +02:00
Lars Ingebrigtsen
e74652386d Make loaddefs-generate--parse-file more robust
* lisp/emacs-lisp/loaddefs-gen.el (loaddefs-generate--parse-file):
Ensure that we don't have an autoload cookie on the first column
inside a string.
2022-06-04 18:41:10 +02:00
Lars Ingebrigtsen
d37d099ad7 Fix failing shortdoc test
* lisp/emacs-lisp/shortdoc.el (string): Each example section is
supposed to contain only examples of using the function in
question (as policed by the FAILED  shortdoc-examples test).
2022-06-04 14:04:49 +02:00
Lars Ingebrigtsen
f76f529524 Further raise-sexp doc string improvement
* lisp/emacs-lisp/lisp.el (raise-sexp): Fix the key binding syntax
in the doc string.
2022-06-04 14:00:10 +02:00
Lars Ingebrigtsen
b3dc23dd60 Improve the raise-sexp doc string
* lisp/emacs-lisp/lisp.el (raise-sexp): Try to explain what the
command does (bug#55788).
2022-06-04 13:57:08 +02:00
Lars Ingebrigtsen
a418730a1b Fix warnings introduced by the lisp-mode-autoload-regexp change
* lisp/emacs-lisp/lisp-mode.el (lisp-fdefs): The package name bit
in ###;;;foo-autoload may be missing, so do a lax match (bug#55784).
2022-06-04 13:50:07 +02:00
Lars Ingebrigtsen
f0189819d8 Add a face to \\= doc string escapes
* lisp/emacs-lisp/lisp-mode.el (lisp-fdefs): Add a face to \\= doc
string escapes (bug#55783).
2022-06-04 13:43:58 +02:00
Michael Albinus
acf27496cb * lisp/emacs-lisp/shortdoc.el (string): Add `string-collate-lessp'. 2022-06-04 11:23:53 +02:00
Lars Ingebrigtsen
977f3f27c5 Don't issue warnings for Unicode quotes for now
* lisp/emacs-lisp/bytecomp.el (byte-compile-docstring-style-warn):
Remove warning for "Unicode quotes" for now (bug#55780).
2022-06-03 13:09:25 +02:00
Lars Ingebrigtsen
8f279c8666 Make checkdoc-file-comments-engine match more ;;;### forms
* lisp/emacs-lisp/checkdoc.el (checkdoc-file-comments-engine): Use
the more general lisp-mode-autoload-regexp instead of
generate-autoload-cookie (i.e., also match ;;;###tramp-autoload).
2022-06-02 19:14:00 +02:00
Lars Ingebrigtsen
43b0210f83 Fix out-of-tree build problems with loaddefs.el
* lisp/Makefile.in ($(lisp)/loaddefs.el): Use the new function.

* lisp/emacs-lisp/loaddefs-gen.el (loaddefs-generate): Pass in
whether to inhibit a partial build (to make the code more general).
(loaddefs-generate--emacs-batch): Add a new function specially for
the Emacs build that has the special rules needed.  (This also
fixes out-of-tree builds.)
loaddefs-generate-batch can be used in general for packages etc.
(loaddefs-generate-batch): Remove the special code for Emacs builds.
2022-06-02 13:52:58 +02:00
Lars Ingebrigtsen
afc0bfd380 Speed up loaddefs-generate on slow disks
* lisp/emacs-lisp/loaddefs-gen.el (loaddefs-generate): Make file
update comparisons faster.
2022-06-02 11:13:20 +02:00
Stefan Monnier
804415b8cc Merge remote-tracking branch 'refs/remotes/origin/master' 2022-06-01 22:32:03 -04:00
Richard Hansen
5255fa452f bindat (strz): Fix wrong-type-argument error when unpacking
* lisp/emacs-lisp/bindat.el (strz): Fix (wrong-type-argument
number-or-marker-p nil) error when unpacking a strz with
unspecified (variable) length.
* test/lisp/emacs-lisp/bindat-tests.el (strz): Mark test as passing.
2022-06-01 22:24:05 -04:00
Richard Hansen
30ec4a7347 ; bindat (strz): Consistent length type check
The strz length computation uses `numberp' to switch between
fixed-length and variable-length modes, so packing should too.
2022-06-01 22:20:49 -04:00
Richard Hansen
e66d6b3793 bindat (strz): Fix off-by-one bug in computed length
* lisp/emacs-lisp/bindat.el (strz): Include null terminator when
computing packed string length.
* test/lisp/emacs-lisp/bindat-tests.el (strz): Mark tests as passing.
2022-06-01 22:18:24 -04:00
Lars Ingebrigtsen
c791a3e9f3 Fix up the loaddefs-gen updating logic
* lisp/emacs-lisp/loaddefs-gen.el (loaddefs-generate): Only do the
updating logic if we're really updating.
2022-06-01 14:50:16 +02:00
Lars Ingebrigtsen
45e65c7d92 Revert "Fix loaddefs generation"
This reverts commit 28358db930.

This has been fixed in a different way.
2022-06-01 14:14:02 +02:00
Lars Ingebrigtsen
a6322e7f13 Tweak how loaddefs-gen decides whether to do a full update
* lisp/emacs-lisp/loaddefs-gen.el (loaddefs-generate): Do a
complete build more often to avoid problems with going from old
loaddefs.el files to new ones.
2022-06-01 12:55:16 +02:00
Po Lu
28358db930 Fix loaddefs generation
* lisp/emacs-lisp/loaddefs-gen.el (loaddefs-generate): Prevent
one kind of string match error.
2022-06-01 18:21:41 +08:00
Lars Ingebrigtsen
7d1c44c2b3 Fix the loaddefs updating logic
* lisp/emacs-lisp/loaddefs-gen.el (loaddefs-generate): Fix the
logic of updating -- we update per loaddefs file.
2022-05-31 22:49:12 +02:00
Lars Ingebrigtsen
89404b4f69 Make partial loaddefs updates work again
* lisp/emacs-lisp/loaddefs-gen.el (loaddefs-generate): Only update
the loaddefs section for the files that have changed.  This makes
"git pull" (when few/no Lisp files have changed much faster).
2022-05-31 20:08:27 +02:00
Lars Ingebrigtsen
1d4e903417 Speed up generation of loaddefs files
* doc/lispref/loading.texi (Autoload, Autoload by Prefix): Refer
to loaddefs-generate instead of update-file-autoloads.

* lisp/Makefile.in (LOADDEFS): Remove, because all the loaddefs
files are created in one go now.
(COMPILE_FIRST): Add loaddefs-gen/radix-tree, and drop autoload.
($(lisp)/loaddefs.el): Use loaddefs-gen.
(MH_E_DIR, $(TRAMP_DIR)/tramp-loaddefs.el)
($(MH_E_DIR)/mh-loaddefs.el, $(CAL_DIR)/cal-loaddefs.el)
($(CAL_DIR)/diary-loaddefs.el, $(CAL_DIR)/hol-loaddefs.el): Remove.

* lisp/generic-x.el: Inhibit computing prefixes, because the
namespace here is all wonky.

* lisp/w32-fns.el (w32-batch-update-autoloads): Removed -- unused
function.

* lisp/calendar/holidays.el ("holiday-loaddefs"): Renamed from
hol-loaddefs to have a more regular name.

* lisp/cedet/ede/proj-elisp.el (ede-emacs-cedet-autogen-compiler):
Refer to loaddefs-gen instead of autoload.

* lisp/emacs-lisp/autoload.el (make-autoload, autoload-rubric)
(autoload-insert-section-header): Made into aliases of
loaddefs-gen functions.
(autoload--make-defs-autoload): Ditto.
(autoload-ignored-definitions, autoload-compute-prefixes): Moved
to loaddefs-gen.

* lisp/emacs-lisp/lisp-mode.el (lisp-mode-autoload-regexp): New
constant.
(lisp-fdefs, lisp-mode-variables, lisp-outline-level): Use it to
recognize all ;;;###autoload forms.

* lisp/emacs-lisp/loaddefs-gen.el: New file.

* lisp/emacs-lisp/package.el: Use loaddefs-generate instead of
make-directory-autoloads.

* test/lisp/vc/vc-bzr-tests.el (vc-bzr-test-faulty-bzr-autoloads):
Use loaddefs instead of autoloads.
2022-05-31 18:08:33 +02:00
Mattias Engdegård
c9aff6fe5a Traverse record literals in byte-compile--first-symbol-with-pos
* lisp/emacs-lisp/bytecomp.el (byte-compile--first-symbol-with-pos):
Traverse record literals as well as vectors.  Either is rather
pointless but there were some strong feelings about it.
2022-05-29 10:52:09 +02:00
Visuwesh
5d8b6ba89e pp--insert-lisp: Don't bug out on certain forms at beginning of buffer
* pp.el (pp--insert): Check if point is in beginning of buffer before
calling `looking-back' (bug#55677).
2022-05-28 18:39:43 +02:00