Now hash_idx_t is a typedef for ptrdiff_t so there is no actual code
change, but this allows us to decouple the index width from the Lisp
word size.
* src/lisp.h (hash_idx_t): New typedef for ptrdiff_t.
(struct Lisp_Hash_Table): Use it for indices and sizes:
index, next, table_size, index_size, count and next_free.
All uses adapted.
Store hash values as integers instead of Lisp_Object
This improves typing, saves pointless tagging and untagging, and
prepares for further changes. The new typedef hash_hash_t is an alias
for EMACS_UINT, and hash values are still limited to the fixnum range.
We now use hash_unused instead of Qnil to mark unused entries.
* src/lisp.h (hash_hash_t): New typedef for EMACS_UINT.
(hash_unused): New constant.
(struct hash_table_test): `hashfn` now returns
hash_hash_t. All callers and implementations changed.
(struct Lisp_Hash_Table): Retype hash vector to an array of
hash_hash_t. All code using it changed accordingly.
(HASH_HASH, hash_from_key):
* src/fns.c (set_hash_index_slot, hash_index_index)
(hash_lookup_with_hash, hash_lookup_get_hash, hash_put):
(hash_lookup, hash_put): Retype hash value arguments
and return values. All callers adapted.
Use non-Lisp allocation for internal hash-table vectors
Using xmalloc for allocating these arrays is much cheaper than using
Lisp vectors since they are no longer marked or swept by the GC, and
deallocated much sooner. This makes GC faster and less frequent, and
improves temporal locality.
Zero-sized tables use NULL for their (0-length) vectors except the
index vector which has size 1 and uses a shared constant static vector
since it cannot be modified anyway. This makes creation and
destruction of zero-sized hash tables very fast; they consume no
memory outside the base object.
* src/lisp.h (struct Lisp_Hash_Table): Retype the index, next, hash
and key_and_value vectors from Lisp_Object to appropriately typed
arrays (although hash values are still stored as Lisp fixnums). Add
explicit table_size and index_size members. All users updated.
* src/alloc.c (gcstat): Add total_hash_table_bytes.
(hash_table_allocated_bytes): New.
(cleanup_vector): Free hash table vectors when sweeping
the object.
(hash_table_alloc_bytes, hash_table_free_bytes): New.
(sweep_vectors): Update gcstat.total_hash_table_bytes.
(total_bytes_of_live_objects): Use it.
(purecopy_hash_table): Adapt allocation of hash table vectors.
(process_mark_stack): No more Lisp slots in the struct to trace.
* src/fns.c (empty_hash_index_vector): New.
(allocate_hash_table): Allocate without automatically GCed slots.
(alloc_larger_vector): Remove.
(make_hash_table, copy_hash_table, maybe_resize_hash_table):
Adapt vector allocation and initialisation.
* src/pdumper.c (hash_table_freeze, hash_table_thaw, dump_hash_table)
(dump_hash_table_contents):
Adapt dumping and loading to field changes.
This avoids any extra allocation for such vectors, including empty
tables read by the Lisp reader, and provides extra safety essentially
for free.
* src/fns.c (make_hash_table): Allow tables to be 0-sized. The index
will always have at least one entry, to avoid extra look-up costs.
* src/alloc.c (process_mark_stack): Don't mark pure objects,
because empty vectors are pure.
Only dump the actual data, and the test encoded as an enum. This
simplifies dumping, makes dump files smaller and saves space at run
time.
* src/lisp.h (hash_table_std_test_t): New enum.
(struct Lisp_Hash_Table): Add frozen_test member, consuming no extra space.
* src/fns.c (hashfn_user_defined): Now static.
(hash_table_test_from_std): New.
(hash_table_rehash): Rename to...
(hash_table_thaw): ...this and rewrite.
* src/pdumper.c (hash_table_contents): Only include actual data, not
unused space.
(hash_table_std_test): New.
(hash_table_freeze): Set frozen_test from test.
(dump_hash_table): Dump frozen_test, not the whole test struct.
Don't bother other dumping fields that can be derived.
Remove rehash-threshold and rehash-size struct members
These parameters have no visible semantics and are hardly ever used,
so just use the default values for all hash tables. This saves
memory, shrinks the external representation, and will improve
performance.
* src/fns.c (std_rehash_size, std_rehash_threshold): New.
(hash_index_size): Use std_rehash_threshold. Remove table argument.
All callers updated.
(make_hash_table): Remove rehash_size and rehash_threshold args.
All callers updated.
(maybe_resize_hash_table)
(Fhash_table_rehash_size, Fhash_table_rehash_threshold):
Use std_rehash_size and std_rehash_threshold.
(Fmake_hash_table): Ignore :rehash-size and :rehash-threshold args.
* src/lisp.h (struct Lisp_Hash_Table):
Remove rehash_size and rehash_threshold fields.
(DEFAULT_REHASH_THRESHOLD, DEFAULT_REHASH_SIZE): Remove.
* src/lread.c (hash_table_from_plist): Don't read rehash-size or
rehash-threshold.
(syms_of_lread): Remove unused symbols.
* src/print.c (print_object): Don't print rehash-size or rehash-threshold.
* src/pdumper.c (dump_hash_table): Don't dump removed fields.
It's not a meaningful part of the external representation.
This allows for faster printing and reading, smaller
external representation, and less memory consumption.
* src/print.c (print_object): Omit size.
* src/lread.c (hash_table_from_plist): Take size from the data.
Eli Zaretskii [Sat, 13 Jan 2024 10:36:16 +0000 (05:36 -0500)]
Merge from origin/emacs-29
99efe5c80f9 Fix count of no-op functions (bug#68375) 0c01f97b73c Wrap @pxref of Abbrevs in parentheses (bug#68375) 70a09325d65 ; Fix last change in widget.texi 63411709a8d ; Fix typos 824cf54951c ; * etc/TODO: Add item to make play-sound non-blocking. 4fadbfe300a Add examples to the Widget manual 1bbb610821e Implement missing functions for custom-icon widget 29af214a75a Fix fontification of cgroup2 in fstab (bug#68367)
Eli Zaretskii [Sat, 13 Jan 2024 10:36:15 +0000 (05:36 -0500)]
Merge from origin/emacs-29
d58d0fa52ff Introduce 'let' using lexical binding in the Lisp Introdu... 1b123972636 ; Don't record multiple versions of use-package 8729a2a10d9 Fix 'rmail-summary-by-thread' 2a8c00bfc07 * doc/emacs/back.texi: Fix a typo.
Steven Allen [Sat, 6 Jan 2024 17:19:12 +0000 (09:19 -0800)]
Set the 'name' prop in 'define-advice'
In addition to naming the advice function `symbol@name', set
the 'name' property to NAME.
* lisp/emacs-lisp/nadvice.el (define-advice): set the 'name'
property to NAME (requested in Bug#68114). Fixes Bug#68294.
* doc/lispref/functions.texi (Advising Named Functions): Document
that 'define-advice' installs the advice with the specified name.
Po Lu [Sat, 13 Jan 2024 01:51:59 +0000 (09:51 +0800)]
Properly sort results for partial font specs
* src/sfntfont.c (sfntfont_compare_font_entities): New function.
(sfntfont_list): Sort matching font entities by the number of
fields set, and mention why.
Abstract predicate and constant for unused hash keys
Qunbound is used for many things; using a predicate and constant for
the specific purpose of unused hash entry keys allows us to locate
them and make changes much more easily.
* src/fns.c (larger_vecalloc): Remove.
(larger_vector): Simplify.
(alloc_larger_vector): New.
(maybe_resize_hash_table): Use alloc_larger_vector as a simpler and
faster replacement for larger_vecalloc.
The profiler stored data being collected in Lisp hash tables but
relied heavily on their exact internal representation, which made it
difficult and error-prone to change the hash table implementation.
In particular, the profiler has special run-time requirements that are
not easily met using standard Lisp data structures: accesses and
updates are made from async signal handlers in almost any messy
context you can think of and are therefore very constrained in what
they can do.
The new profiler tables are designed specifically for their purpose
and are more efficient and, by not being coupled to Lisp hash tables,
easier to keep safe.
The old profiler morphed internal hash tables to ones usable from Lisp
and thereby made them impossible to use internally; now export_log
just makes new hash table objects for Lisp. The Lisp part of the
profiler remains entirely unchanged.
* src/alloc.c (garbage_collect): Mark profiler tables.
* src/eval.c (get_backtrace): Fill an array of Lisp values instead of
a Lisp vector.
* src/profiler.c (log_t): No longer a Lisp hash table but a custom
data structure: a fully associative fixed-sized cache that maps
fixed-size arrays of Lisp objects to counts.
(make_log): Build new struct.
(mark_log, free_log, get_log_count, set_log_count, get_key_vector)
(log_hash_index, remove_log_entry, trace_equal, trace_hash)
(make_profiler_log, free_profiler_log, mark_profiler): New.
(cmpfn_profiler, hashtest_profiler, hashfn_profiler)
(syms_of_profiler_for_pdumper): Remove.
(approximate_median, evict_lower_half, record_backtrace, export_log)
(Fprofiler_cpu_log, Fprofiler_memory_log, syms_of_profiler):
Adapt to the new data structure.
Stefan Monnier [Fri, 12 Jan 2024 03:12:34 +0000 (22:12 -0500)]
sh-script.el: Add support for `case FOO {...}` (bug#55764)
* lisp/progmodes/sh-script.el (sh-font-lock-paren): Also recognize
`FOO)` after `{`.
(sh-smie-sh-rules): Make `for` rule apply to `case FOO { ...}` as well.
john muhl [Sat, 6 Jan 2024 15:36:33 +0000 (09:36 -0600)]
Support indented continuation lines in lua-ts-mode
* lisp/progmodes/lua-ts-mode.el (lua-ts--simple-indent-rules):
Add a rule to indent multi-line assignments and if statements.
(lua-ts-indent-continuation-lines): New user option.
* test/lisp/progmodes/lua-ts-mode-resources/indent.erts: Add
tests. (Bug#68279)
* lisp/emacs-lisp/bytecomp.el (byte-compile-output-docform):
Note that let-binding a buffer local variable leaves it buffer
local, hence to transfer the binding of
byte-compile-dynamic-docstrings to the output buffer, an
intermediate variable is needed. Implement this.
Michael Albinus [Thu, 11 Jan 2024 11:30:05 +0000 (12:30 +0100)]
Support numeric port numbers in auth-source-macos-keychain
* lisp/auth-source.el (auth-source-macos-keychain-search):
Support numeric port numbers (bug#68376).
(auth-source-macos-keychain-search-items): Make regexp more robust.
F. Jason Park [Tue, 9 Jan 2024 22:50:43 +0000 (14:50 -0800)]
; Fix overridden erc--input-split slot definition
* lisp/erc/erc-common.el (erc--input-split): Don't set the
default value to `:read-only'.
* test/lisp/erc/erc-tests.el (erc--channel-modes,
erc--channel-modes/graphic-p): Use `char-displayable-p' instead of
`display-graphic-p' to prevent the first test from failing on Unicode
terminal emulators.
Augusto Stoffel [Wed, 27 Sep 2023 16:35:32 +0000 (18:35 +0200)]
Use auth-info-mode for non-hidden authinfo and netrc files
* files.el (auto-mode-alist): Match non-hidden authinfo and netrc
files, since it is reasonable to store passwords in
~/.emacs.d/authinfo.gpg or a similarly named file. (Bug#66241)
Mauro Aranda [Sun, 5 Nov 2023 10:23:55 +0000 (07:23 -0300)]
Implement missing functions for custom-icon widget
* lisp/cus-edit.el (custom-icon-reset-saved, custom-icon-mark-to-save)
(custom-icon-state-set-and-redraw, custom-icon-reset-standard)
(custom-icon-mark-to-reset-standard): New functions.
(custom-icon, custom-icon-extended-menu): Register and add them to the
menu. (Bug#66947)
* lisp/progmodes/compile.el (compilation-error-regexp-alist-alist):
Translate `lua' and `lua-stack' to rx, and change two unnecessary
non-greedy operators to greedy.
Handle package versions that are not version strings
* lisp/emacs-lisp/package.el (package-menu--version-predicate): Ignore
any errors raised by 'version-to-list', thus falling back to the
default version list. (Bug#68317)
Emacs comes with built-in support for the Lua programming language in
the form of the Lua mode and now also the Lua Tree-sitter mode. This
patch further improves Lua support in Emacs by making the Compilation
mode recognize Lua errors and stack traces.
* lisp/progmodes/compile.el (compilation-error-regexp-alist-alist):
Add regexps to aid Lua development, namely the 'lua' regexp that
matches Lua errors and the 'lua-stack' regexp that matches Lua stack
frames. (Bug#60830)
* etc/compilation.txt (Lua): Add an example of a Lua error message
with a stack trace.
* test/lisp/progmodes/compile-tests.el (compile-tests--test-regexps-data):
(compile-test-error-regexps): Test the new 'lua' and 'lua-stack'
regexps added to the 'compilation-error-regexp-alist-alist'.
* lisp/net/tramp.el (tramp-build-completion-file-name-regexp):
Do not use `tramp-volume-letter-regexp'. (Bug#68320)
(tramp-completion-handle-expand-file-name): Simplify regexp.
* test/lisp/net/tramp-tests.el (tramp-test26-file-name-completion)
(tramp-test26-interactive-file-name-completion): Run also on MS Windows.
Handle package versions that are not version strings
* lisp/emacs-lisp/package.el (package-menu--version-predicate): Ignore
any errors raised by 'version-to-list', thus falling back to the
default version list. (Bug#68317)
Juri Linkov [Wed, 10 Jan 2024 07:34:47 +0000 (09:34 +0200)]
Support :category in completion-extra-properties (bug#68214)
* doc/lispref/minibuf.texi (Completion Variables): Add :category
to the table of completion-extra-properties.
* lisp/minibuffer.el (completion--metadata-get-1): New internal function.
(completion-metadata-get): Use 'completion--metadata-get-1'.
Thanks to Daniel Mendler <mail@daniel-mendler.de>.
(completion-extra-properties): Mention :category in the docstring.
* lisp/calendar/calendar.el (calendar-read-date): Use more
user-friendly let-binding of completion-extra-properties
with :category.
Jim Porter [Thu, 26 Oct 2023 03:43:57 +0000 (20:43 -0700)]
Introduce 'let' using lexical binding in the Lisp Introduction
* doc/lispintro/emacs-lisp-intro.texi (Prevent confusion): Rework the
explanation to discuss how things work under lexical binding.
(How let Binds Variables): Describe the differences between lexical
and dynamic binding (including how to configure it).
(defvar): Mention that 'defvar' declares variables as always
dynamically-bound (bug#66756).
Juri Linkov [Tue, 9 Jan 2024 17:57:50 +0000 (19:57 +0200)]
Support more metadata properties in completion-extra-properties (bug#68214)
* doc/lispref/minibuf.texi (Completion Variables): Add
to the table of completion-extra-properties new items:
`group-function', `display-sort-function', `cycle-sort-function'.
* lisp/icomplete.el (icomplete--augment): Remove unnecessary
plist-get from completion-extra-properties since now
completion-metadata-get does this.
* lisp/minibuffer.el (completion-metadata-get): Use plist-get to
get prop from completion-extra-properties and cache the keyword.
Thanks to Daniel Mendler <mail@daniel-mendler.de>.
(completion-extra-properties): Mention new properties in docstring.
(minibuffer-completion-help): Remove unnecessary
plist-get from completion-extra-properties since now
completion-metadata-get does this.
* lisp/net/eww.el (eww-switch-to-buffer):
* test/lisp/minibuffer-tests.el (completions-affixation-navigation-test):
Unquote lambda in completion-extra-properties.
Juri Linkov [Tue, 9 Jan 2024 17:22:40 +0000 (19:22 +0200)]
* lisp/tab-bar.el: Fixes for point in window configuration (bug#68235)
(tab-bar--tab): Instead of 'point-marker', use 'copy-marker' with the TYPE
argument set to 'window-point-insertion-type'. This will allow point to
follow the output after switching tabs when point is at the end of
a comint/compilation buffer.
(tab-bar-select-tab): Remove ad-hoc rule for the reverted dired buffer.
Harald Jörg [Mon, 8 Jan 2024 15:12:19 +0000 (16:12 +0100)]
cperl-mode.el: Make sure cperl-file-style is set buffer-local
* lisp/progmodes/cperl-mode.el (cperl-file-style): Add description
what the options actually do.
(cperl-menu): Split the menu entry "Indent styles" into "Default
indent styles" and "Indent styles for current buffer"
(cperl--set-file-style): call `cperl-file-style' instead of
`cperl-set-style'. This completes the fix for Bug#17948.
(cperl-set-style): Explain when to use `cperl-file-style'.
Use `set-default-toplevel-value' instead of `set'.
(cperl-set-style-back): Use `set-default-toplevel-value' instead
of `set'.
(cperl-file-style): New command to set the file style for the
current buffer.
* etc/NEWS: Announce the new command cperl-file-style.
Po Lu [Mon, 8 Jan 2024 07:32:07 +0000 (15:32 +0800)]
Properly instruct Italic Arial or BS Mono at small PPEM sizes
* src/sfnt.c (sfnt_read_simple_glyph): Correct alignment errors.
(PUSH2_UNCHECKED): Don't shift negative signed value to the
left.
(SLOOP): Permit LOOP to be set to 0, which inhibits the
execution of instructions it affects.
(sfnt_address_zp2, sfnt_address_zp1, sfnt_address_zp0): Permit X
and Y to be NULL.
(sfnt_dot_fix_14): Guarantee that the final value is rounded to
negative infinity, not zero.
(sfnt_project_zp1_zp0_org): New function.
(sfnt_interpret_mdrp): Avoid rounding issues by computing
original distance from unscaled coordinates, if at all possible.
(sfnt_interpret_simple_glyph, sfnt_interpret_compound_glyph_2):
Set zone->simple.
(all_tests) <LOOP>: Update test.
(sfnt_identify_instruction, main): Adjust tests.
* src/sfnt.h (struct sfnt_interpreter_zone): New field simple.
F. Jason Park [Fri, 5 Jan 2024 15:20:34 +0000 (07:20 -0800)]
Clarify purpose of module aliases in ERC
* doc/misc/erc.texi: Mention that aliases should not be defined for
new modules.
* lisp/erc/erc-common.el (define-erc-module): Refactor slightly for
readability.
(erc-with-all-buffers-of-server): Redo doc string.
* lisp/erc/erc-pcomplete.el: Declare `completion' module's feature and
group as being `erc-pcomplete'.
* test/lisp/erc/erc-tests.el (erc--find-group--real): Assert group
lookup works for "normalized" module name `completion' of
`erc-pcomplete-mode'.
F. Jason Park [Thu, 4 Jan 2024 07:10:55 +0000 (23:10 -0800)]
Make ERC's format catalogs more extensible
* lisp/erc/erc-common.el (erc--define-catalog): Accept a `:parent'
keyword to allow for extending an existing catalog by overriding some
subset of defined entries.
(erc-define-message-format-catalog): Add edebug spec.
* lisp/erc/erc.el (erc-retrieve-catalog-entry): Check parent for
definition before looking to `default-toplevel-value'.
* test/lisp/erc/erc-tests.el (erc-retrieve-catalog-entry): Add test
case for inheritance.
* test/lisp/erc/resources/erc-tests-common.el
(erc-tests-common-pp-propertized-parts): Fix bug in convenience
command. (Bug#67677)