Speed up JSON parsing substantially by only UTF-8-parsing string
literals and only exactly once. Previously, json-parse-string always
first parsed the entire input and copied it to a new string, and then
validated each string literal twice.
We no longer create an extra new string when interning an alist key,
nor do we garble plist keys with Unicode characters.
* src/lread.c (intern_c_multibyte): New.
* src/json.c (json_encode): Remove.
(utf8_error): New.
(json_parse_string): Faster and more careful UTF-8 decoding.
Create and return a new multibyte string or symbol without extra
decoding. All callers adapted.
(Fjson_parse_string): Skip expensive input pre-decoding.
* test/src/json-tests.el (json-parse-string/object-unicode-keys)
(json-parse-string/short): New.
(json-parse-string/string, json-parse-string/invalid-unicode):
Adapt tests.
* etc/NEWS: Mentioned change in errors.
Well, I'm not completely sure this will work right in all cases,
because I've been confused about this in the past.
It works in my test case, at least.
* lisp/progmodes/scheme.el (scheme-syntax-propertize-sexp-comment):
Look for nested `#;` and mark them appropriately.
This is a global variant of 'completion-preview-mode'.
* lisp/completion-preview.el (global-completion-preview-mode): New
global minor mode.
* doc/emacs/programs.texi (Symbol Completion): Document it.
* etc/NEWS: Announce it. (Bug#70010)
* doc/lispref/peg.texi (Parsing Expression Grammars)
(PEX Definitions, Parsing Actions, Writing PEG Rules): Fix markup,
indexing, and wording.
* etc/NEWS: Fix wording of PEG entry.
* test/lisp/progmodes/peg-tests.el: Move from test/lisp/, to match
the directory of peg.el.
* lisp/use-package/use-package-core.el (use-package-vc-prefer-newest):
User option to prefer the latest commit (as opposed to the latest
release) of a package.
(use-package-normalize--vc-arg): Check for
use-package-vc-prefer-newest.
* doc/misc/use-package.texi (Install package): Document
use-package-vc-prefer-newest.
* etc/NEWS: Document use-package-vc-prefer-newest.
* lisp/sort.el (sort-on):
* doc/lispref/sequences.texi (Sequence Functions):
* etc/NEWS:
Remove the `sort-on` function which is now completely superseded by
the extended `sort` in features, ease of use, and performance.
Add the :key, :lessp, :reverse and :in-place keyword arguments.
The old calling style remains available and is unchanged.
* src/fns.c (sort_list, sort_vector, Fsort):
* src/sort.c (tim_sort):
Add keyword arguments with associated new features.
All callers of Fsort adapted.
* test/src/fns-tests.el (fns-tests--shuffle-vector, fns-tests-sort-kw):
New test.
* doc/lispref/sequences.texi (Sequence Functions): Update manual.
* etc/NEWS: Announce.
It's a general-purpose polymorphic ordering function, like `<` but
for any two values of the same type.
* src/data.c (syms_of_data): Add the `type-mismatch` error.
(bits_word_to_host_endian): Move...
* src/lisp.h (bits_word_to_host_endian): ...here, and declare inline.
* src/fns.c (Fstring_lessp): Extract the bulk of this function to...
(string_cmp): ...this 3-way comparison function, for use elsewhere.
(bool_vector_cmp, value_cmp, Fvaluelt): New.
* lisp/emacs-lisp/byte-opt.el (side-effect-free-fns, pure-fns):
Add `value<`, which is pure and side-effect-free.
* test/src/fns-tests.el (fns-value<-ordered, fns-value<-unordered)
(fns-value<-type-mismatch, fns-value<-symbol-with-pos)
(fns-value<-circle, ert-deftest fns-value<-bool-vector): New tests.
* doc/lispref/sequences.texi (Sequence Functions):
* doc/lispref/numbers.texi (Comparison of Numbers):
* doc/lispref/strings.texi (Text Comparison):
Document the new value< function.
* etc/NEWS: Announce.
We generally want types to form not just a DAG but a lattice.
If objects can be both `keyword` and `symbol-with-pos`, this
means there should be a more precise type describing this intersection.
If we ever find the need for such a refinement, we could add
such a `keyword-with-pos` type, but here I took the simpler
route of treating `keyword` not as a proper built-in type but
as a second-class type like `natnum`.
While fixing this problem, also fix the problem we had where
`functionp` was not quite adequate to characterize objects of type
`function`, by introducing a new predicate `cl-functionp` for that.
* lisp/emacs-lisp/cl-preloaded.el (cl-functionp): New function.
(function): Use it.
(keyword): Don't declare it as a built-in type.
(user-ptrp): Remove redundant declaration.
* lisp/emacs-lisp/cl-generic.el (cl--generic--unreachable-types):
Delete constant.
(cl-generic-generalizers): Remove corresponding test.
* lisp/emacs-lisp/cl-macs.el (cl-deftype-satisfies): Add entry for
`keyword` type.
* lisp/emacs-lisp/comp.el (comp-known-predicates): Fix type for
negative result of `characterp`. Remove duplicate `numberp` entry.
Fix types for `keywordp` now that `keyword` is not a built-in type any more.
* test/src/data-tests.el (data-tests--cl-type-of): Add a few cases.
Remove workaround for `function`.
Now, when transforming an image, its :map is recomputed to fit.
Image map coordinates are integers, so when computing :map,
coordinates are rounded. To prevent an image from drifting from
its map after repeated transformations, 'create-image' now adds
a new image property :original-map, which is combined with the
image's transformation parameters to recompute :map.
* lisp/image.el (image-recompute-map-p): Add user option to
control whether :map is recomputed when an image is transformed.
(create-image): Create :map from :original-map and vice versa.
(image--delayed-change-size): Fix comment.
(image--change-size, image-rotate, image-flip-horizontally,
image-flip-vertically): Recompute image map after transformation
and mention 'image-recompute-map-p' in docstring.
(image--compute-map): Add function to compute a map from original
map.
(image--compute-original-map): Add function to compute an
original map from map.
(image--scale-map): Add function to scale a map based on :scale.
(image--rotate-map): Add function to rotate a map based on
:rotation.
(image--rotate-coord): Add function to rotate a map coordinate
pair.
(image--flip-map): Add function to flip a map based on :flip.
(image-increase-size, image-decrease-size, image-mouse-increase-size)
(image-mouse-decrease-size): Mention 'image-recompute-map-p' in
docstrings.
* etc/NEWS: Add NEWS entry.
* doc/lispref/display.texi (Image Descriptors): Document :original-map
and new user option 'image-recompute-map-p'.
* test/lisp/image-tests.el (image--compute-map-and-original-map):
Test 'image--compute-map' and 'image--compute-original-map'.
(image-tests--map-equal): Add equality predicate to compare image maps.
(image-create-image-with-map): Test that 'create-image' adds :map
and/or :original-map as appropriate.
(image-transform-map): Test functions related to transforming maps.
(Bug#69602)
* lisp/net/eww.el (eww-readable-urls): New option.
(eww-default-readable-p): New function...
(eww-display-html): ... use it.
* test/lisp/net/eww-tests.el (eww-test/readable/default-readable): New
test.
* doc/misc/eww.texi (Basics): Document 'eww-readable-urls'.
* etc/NEWS: Announce this change (bug#68254).
Additionally, add an option to prevent adding a new history entry for
each call of 'eww-readable' (bug#68254).
* lisp/net/eww.el (eww-retrieve):
* lisp/net/eww.el (eww-readable-adds-to-history): New option.
(eww-retrieve): Make sure we call CALLBACK in all configurations.
(eww-render): Simplify how to pass encoding.
(eww--parse-html-region, eww-display-document): New functions, extracted
from...
(eww-display-html): ... here.
(eww-document-base): New function.
(eww-readable): Toggle "readable" mode interactively, like with a minor
mode. Consult 'eww-readable-adds-to-history'.
(eww-reload): Use 'eshell-display-document'.
* test/lisp/net/eww-tests.el (eww-test--with-mock-retrieve): Fix indent.
(eww-test/display/html, eww-test/readable/toggle-display): New tests.
* doc/misc/eww.texi (Basics): Describe the new behavior.
* etc/NEWS: Announce this change.
In my benchmarking, for large dired buffers, using 'regexp-opt'
provides around a 3x speedup in omitting.
'regexp-opt' takes around 5 milliseconds, so to avoid slowing
down omitting in small dired buffers we cache the return value.
Since omitting is now 3x faster, increase 'dired-omit-size-limit'
by 3x. Also, document 'dired-omit-size-limit' better.
* doc/misc/dired-x.texi (Omitting Variables): Document
'dired-omit-size-limit'.
* etc/NEWS: Announce increase of 'dired-omit-size-limit'.
* lisp/dired-x.el (dired-omit--extension-regexp-cache): Add.
(dired-omit-regexp): Use 'regexp-opt'. (Bug#69775)
(dired-omit-size-limit): Increase and improve docs.
Consolidate code used in profiler and help--describe-command,
and improve it while we're at it.
Also use #' to quote a few function names along the way.
* lisp/help-fns.el (help-fns--function-numbers, help-fns--function-names):
New vars.
(help-fns--display-function): New aux function.
(help-fns-function-name): New function, inspired from
`help--describe-command`.
* lisp/help.el (help--describe-command): Use `help-fns-function-name`.
(help--for-help-make-sections): Remove redundant "" arg to `mapconcat`.
* lisp/profiler.el (profiler-format-entry, profiler-fixup-entry):
Delete functions.
(profiler-report-make-entry-part): Use `help-fns-function-name` instead.
(profiler-report-find-entry): Use `push-button`.
* lisp/transient.el (transient--debug): Use `help-fns-function-name`
when available.
It's often necessary to update the representation of a single
object in a table (e.g a struct, whose identity does not change
when its slots'
values are changed). To do so, now the function may be called
like this:
(vtable-update-object table object)
Instead of like this:
(vtable-update-object table object object)
This also documents the behavior of the just-discovered limitation filed
as bug#69837.
* lisp/emacs-lisp/vtable.el (vtable-update-object): Make 'old-object'
argument optional. (Bug#69666)
* doc/misc/vtable.texi (Interface Functions): Update documentation.
* etc/NEWS: Add news entry.
The type hierarchy and `cl-type-of` code assumed that `subr-primitive`
only applies to functions, but since it also accepts special-forms it makes
it an unsuitable choice since it can't be a subtype of `compiled-function`.
So, use a new type `primitive-function` instead.
* lisp/subr.el (subr-primitive-p): Fix docstring (bug#69832).
(primitive-function-p): New function.
* lisp/emacs-lisp/cl-preloaded.el (primitive-function): Rename
from `subr-primitive` since `subr-primitive-p` means something else.
* src/data.c (Fcl_type_of): Return `primitive-function` instead
of `subr-primitive` for C functions.
(syms_of_data): Adjust accordingly.
* test/src/data-tests.el (data-tests--cl-type-of): Remove workaround.
* src/data.c (Fcl_type_of): New function, extracted from `Ftype_of`.
Make it return more precise types for symbols, integers, and subrs.
(Ftype_of): Use it.
(syms_of_data): Define the corresponding new symbols and defsubr
the new function.
* doc/lispref/objects.texi (Type Predicates): Document it.
* src/comp.c (emit_limple_insn): Use `Fcl_type_of`.
* lisp/emacs-lisp/cl-preloaded.el (subr): Demote it to `atom`.
(subr-native-elisp, subr-primitive): Add `compiled-function` as
parent instead.
(special-form): New type.
* lisp/obsolete/eieio-core.el (cl--generic-struct-tag):
* lisp/emacs-lisp/cl-generic.el (cl--generic-typeof-generalizer):
Use `cl-type-of`.
cl--generic--unreachable-types): Update accordingly.
test/src/data-tests.el (data-tests--cl-type-of): New test.
(tab-bar-select-restore-windows): New function.
(tab-bar-select-tab): Let-bind window-restore-killed-buffer-windows
to tab-bar-select-restore-windows (bug#68235).
* doc/misc/modus-themes.org: Update the manual to better document
existing functionality and cover the new features.
* etc/themes/modus-operandi-deuteranopia-theme.el:
* etc/themes/modus-operandi-theme.el:
* etc/themes/modus-operandi-tinted-theme.el:
* etc/themes/modus-operandi-tritanopia-theme.el:
* etc/themes/modus-vivendi-deuteranopia-theme.el:
* etc/themes/modus-vivendi-theme.el:
* etc/themes/modus-vivendi-tinted-theme.el:
* etc/themes/modus-vivendi-tritanopia-theme.el: Update the
palette of each theme.
* etc/themes/modus-themes.el (require): Remove call to cl-lib
and do not use relevant functions.
(modus-themes-operandi-colors, modus-themes-vivendi-colors)
(modus-themes-version, modus-themes-report-bug): Remove old
calls to 'make-obsolete' and related.
(modus-themes--annotate-theme): Tweak the completion annotation function.
(modus-themes--org-block): Deprecate the user option 'modus-themes-org-blocks'.
(modus-themes-faces): Update faces.
(modus-themes-custom-variables): Update the list of custom
variables.
Detailed release notes are available here:
<https://protesilaos.com/codelog/2024-03-17-modus-themes-4-4-0/>.
* etc/NEWS: Announce 'window-restore-killed-buffer-windows'.
* src/buffer.h (struct buffer) : New field last_name_.
* src/buffer.c (Fbuffer_last_name): New function to return last
name of buffer before it was killed or renamed.
(bset_last_name, Fget_buffer_create, Fmake_indirect_buffer)
(Frename_buffer, Fkill_buffer, init_buffer_once): Set buffer's
last_name_ field accordingly.
* src/window.c (window_restore_killed_buffer_windows): New
variable replacing Vwindow_kept_windows_functions.
(Fset_window_configuration): Use
window_restore_killed_buffer_windows instead of
Vwindow_kept_windows_functions.
* lisp/window.el (window--state-put-2, window-state-put): Use
'window-restore-killed-buffer-windows' instead of
'window-kept-windows-functions'.
* doc/lispref/windows.texi (Window Configurations): Describe
'window-restore-killed-buffer-windows' which replaces
'window-kept-windows-functions'.
(flyspell--mode-on): Add flyspell-check-changes to post-command-hook
when flyspell-check-changes is non-nil.
(flyspell--mode-off): Remove flyspell-check-changes from post-command-hook.
(flyspell-check-changes): New function (bug#61874).
This fixes a bug that could make 'read-event', 'read-char', and
'read-char-exclusive' erroneously return -1, an internal magic return
value of 'read_char' leaked from C to lisp. Instead of returning -1, the
aforementioned lisp functions now transparently continue reading
available input (e.g., from the keyboard) when reaching the end of a
keyboard macro.
* src/keyboard.c (read_char, read_key_sequence): Move handling
of the end of a keyboard macro from 'read_char' to its caller
'read_key_sequence', which is the only caller that can
meaningfully deal with this case.
* src/macros.c (Fexecute_kbd_macro): Document how the end of keyboard
macro is processed.
* etc/NEWS: Announce this change.
Add classes describing the built-in types.
* lisp/emacs-lisp/cl-preloaded.el (built-in-class): New type.
(cl--define-built-in-type): New aux macro.
(all built-in types): "Define" them with it.
(cl--builtin-type-p): New aux function.
(cl--struct-name-p): Use it.
(cl--direct-supertypes-of-type, cl--typeof-types, cl--all-builtin-types):
Move the definitions to after the built-in classes are defined,
and rewrite to make use of those classes.
* lisp/emacs-lisp/cl-extra.el (cl-describe-type):
Accept two (unused) optional args, for use with `describe-symbol-backends`.
(describe-symbol-backends): Simplify accordingly and
add ourselves at the end.
(cl--class-children): New function.
(cl--describe-class): Use it. Also don't show a silly empty list of slots
for the built-in types.
A function or macro body consisting of a single string literal now only
uses it as a return value. Previously, it had the dual uses as return
value and doc string, which was never what the programmer wanted and
had some inconvenient consequences (bug#69387).
This change applies to `lambda`, `defun`, `defsubst` and `defmacro`
forms; most other defining forms already worked in the sensible way.
* lisp/emacs-lisp/bytecomp.el (byte-compile-lambda):
Don't use a lone string literal as doc string.
* test/lisp/emacs-lisp/bytecomp-resources/warn-wide-docstring-defun.el
(foo): Update docstring warning test.
* doc/lispref/functions.texi (Function Documentation): Update.
* etc/NEWS: Announce.
This resolves an issue where navigating back and then forward kept
adding new history entries so you could never hit the "end" (bug#69232).
* lisp/net/eww.el (eww-before-browse-history-function): New option.
(eww-history-position): Add docstring.
(eww-mode-map, eww-context-menu): Use correct predicates for when to
enable back/forward.
(eww-save-history): Save history entry in its original place when
viewing a historical page.
(eww--before-browse): New function...
(eww, eww-follow-link, eww-readable): ... call it.
(eww-render): Don't set 'eww-history-position' here...
(eww--before-browse): ... instead, set it here.
(eww-back-url): Set 'eww-history-position' based on the result of
'eww-save-history'.
(eww-forward-url): Set 'eww-history-position' directly, since
'eww-save-history' no longer adds a new entry in this case.
(eww-delete-future-history, eww-clone-previous-history): New functions.
* test/lisp/net/eww-tests.el: New file.
* etc/NEWS: Announce this change.
* lisp/iimage.el (iimage-mode-buffer): Set context-menu-functions
text property to '(image-context-menu)'.
* lisp/image.el (image-context-menu): New function.
(put-image): Set context-menu-functions overlay property
to '(image-context-menu)'.
(insert-image, insert-sliced-image): Set context-menu-functions
text property to '(image-context-menu)'.
* lisp/mouse.el (context-menu-map): Use mouse-posn-property
'context-menu-functions' and call its funs at the end.
While `major-mode-remap-alist` provides a way for users to indicate the
major mode of their choice, we need a similar variable for the
use of packages.
This patch adds a new `major-mode-remap-defaults` and changes various
packages to obey it or make use of it.
I think it nicely cleans the regexp duplication between CC-mode and
`c-ts-mode.el` and also makes it easier/cleaner for users to override
the changes made by `*-ts-mode.el`.
* lisp/files.el (major-mode-remap-defaults): New variable.
(major-mode-remap): New function.
(set-auto-mode-0): Use it.
* doc/lispref/modes.texi (Auto Major Mode): Document them.
* lisp/textmodes/tex-mode.el (tex--redirect-to-submode):
Use `major-mode-remap`.
(major-mode-remap-defaults): Set it to remap AUCTeX modes by default.
* lisp/progmodes/ruby-ts-mode.el (auto-mode-alist): Leave it alone.
(major-mode-remap-defaults): Set this one instead.
* lisp/progmodes/c-ts-mode.el (c-or-c++-ts-mode): Use `major-mode-remap`.
(auto-mode-alist): Leave it alone.
(major-mode-remap-defaults): Set this one instead.
* lisp/org/ox.el (org-export-to-buffer): Modernize docstring accordingly.
* lisp/progmodes/cc-mode.el (c-or-c++-mode):
* lisp/org/ox-latex.el (org-latex-export-as-latex):
* lisp/org/ox-koma-letter.el (org-koma-letter-export-as-latex):
* lisp/org/ox-beamer.el (org-beamer-export-as-latex):
Use `major-mode-remap` when available.