Paul Eggert [Sun, 21 Jan 2024 00:52:31 +0000 (16:52 -0800)]
Speed up make_lisp_symbol when debugging
* src/lisp.h (make_lisp_symbol): In eassert use XBARE_SYMBOL
rather than XSYMBOL. This is safe because the symbol must be
bare. The change speeds up make_lisp_symbol when debugging.
Paul Eggert [Sun, 21 Jan 2024 00:52:31 +0000 (16:52 -0800)]
Simplify and tune XSYMBOL
* src/lisp.h (XSYMBOL): Simplify and tune. There is no need to
examine symbols_with_pos_enabled here, since the arg must be a symbol
so if it's not a bare symbol then it must be a symbol_with_pos;
and checking whether a symbol is bare is cheap.
With Ubuntu 23.10 on a Xeon W-1350, this shrank Emacs’s executable
text size by 0.1% and sped up a default build of all *.elc files by
0.4%.
Remove unnecessary eassert, since XBARE_SYMBOL and XSYMBOL_WITH_POS
have easserts that suffice.
Paul Eggert [Sun, 21 Jan 2024 00:52:31 +0000 (16:52 -0800)]
Be more systematic about parens in C source code
Be more systematic about putting space before paren in calls,
and in avoiding unnecessary parentheses in macros.
This was partly inspired by my wading through gcc -E output
while debugging something else, and seeing too many parens.
This patch does not change the generated .o files on my platform.
Paul Eggert [Sun, 21 Jan 2024 00:52:31 +0000 (16:52 -0800)]
Omit some parens
* src/lisp.h (XBARE_SYMBOL, XSYMBOL): Omit parentheses that are no
longer needed now that we have symbols with positions and these
symbols are never macros.
Paul Eggert [Sun, 21 Jan 2024 00:26:45 +0000 (16:26 -0800)]
Fix autogen.sh’s spurious ‘git diff’ output
Problem reported by Gerd Möllmann (Bug#68464).
* .gitignore: Ignore files in exec that are now copied from build-aux.
* admin/merge-gnulib (avoided_flags): Instead of clearing
autom4te.cache here ...
* autogen.sh (do_git): ... clear it here.
Use config.guess, config.sub and install-sh from
the Emacs repository, as they are more likely to be up to date.
This avoids unnecessary differences among different builders,
and avoids unnecessary ‘git diff’ output after autogen.sh.
Also, copy these files from build-aux to exec since there
should be no difference between the two copies.
* exec/config.guess, exec/config.sub, exec/install-sh:
Remove from repository, as autogen.sh now copies them from build-aux.
Stefan Monnier [Sat, 13 Jan 2024 00:05:24 +0000 (19:05 -0500)]
mwheel.el: Code clean to reduce duplication
* lisp/mwheel.el (mouse-wheel-obey-old-style-wheel-buttons): New var,
extracted from `mouse-wheel-*-event` definitions.
(mouse-wheel-down-event, mouse-wheel-up-event)
(mouse-wheel-left-event, mouse-wheel-right-event): Use it.
Stefan Monnier [Fri, 12 Jan 2024 23:52:37 +0000 (18:52 -0500)]
mwheel.el: Remove `mouse-wheel-*-alternate-event` vars
Now that `wheel-DIR` events are hardcoded, we never need more than
one variable (which we actually never needed anyway, we could have
let `mouse-wheel-*-event` vars hold lists of events instead), so
remove the `mouse-wheel-*-alternate-event` vars by merging their
default value into that of the corresponding `mouse-wheel-*-event`.
* lisp/mwheel.el (mouse-wheel-down-event, mouse-wheel-up-event)
(mouse-wheel-left-event, mouse-wheel-right-event): Don't bother holding
`wheel-DIR` events since these are already handled anyway.
Hold the event that would have been held in
`mouse-wheel-DIR-alternate-event` instead.
(mouse-wheel-down-alternate-event, mouse-wheel-up-alternate-event)
(mouse-wheel-left-alternate-event, mouse-wheel-right-alternate-event):
Delete vars.
(mwheel--is-dir-p, mouse-wheel--setup-bindings):
* lisp/edmacro.el (edmacro-fix-menu-commands):
* lisp/completion-preview.el (completion-preview--mouse-map):
Don't use `mouse-wheel-up/down-alternate-event` any more.
* lisp/progmodes/flymake.el (flymake--mode-line-counter-map):
Do nothing, because it already ignored those vars.
Stefan Monnier [Fri, 12 Jan 2024 23:28:12 +0000 (18:28 -0500)]
mwheel.el: Unconditionally use the `wheel-up/down/...` events
The `mouse-wheel-DIR-event` vars were introduced because under X11
we get different `mouse-N` events depending on the users' mouse and
those same events can be used for other things for other rodents, so we
can't unconditionally treat those events as mouse-wheel events.
But this does not apply to the `wheel-up/down/...` events.
So hard code them.
* lisp/mwheel.el (mwheel--is-dir-p): Always consider the `wheel-DIR` events.
(mouse-wheel--setup-bindings): Always bind the `wheel-DIR` events.
* lisp/completion-preview.el (completion-preview--mouse-map):
Unconditionally bind the `wheel-DIR` events.
* lisp/edmacro.el (edmacro-fix-menu-commands): Hard code the
`wheel-DIR` events as mouse events regardless of `mouse-wheel-*-event`s.
* lisp/progmodes/flymake.el (flymake--mode-line-counter-map):
Do nothing, because it's already been done in commit e5be6c7ae309.
* doc/lispref/commands.texi (Misc Events): Document the need to use
`wheel-up/down/left/right` unconditionally.
Stefan Monnier [Fri, 12 Jan 2024 23:08:31 +0000 (18:08 -0500)]
* lisp/completion-preview.el: Fix use in non-GUI session
Fix loading in non-GUI sessions where `mwheel` is not preloaded.
Not requiring `mwheel` would be a lot more complex, since it would
require delaying the construction of `completion-preview--mouse-map`.
* lisp/completion-preview.el (<toplevel>): Require `mwheel`.
Remove correspondingly redundant `defvar`s.
(completion-preview--mouse-map): Use `key-description` rather than mimicking
it with `format`.
Paul Eggert [Sat, 20 Jan 2024 19:26:09 +0000 (11:26 -0800)]
Avoid Gnulib ‘access’ module
* admin/merge-gnulib (AVOIDED_MODULES): Add ‘access’,
since I don’t think Emacs cares about the Mac OS X 10.5
bug where faccessat ignores a trailing slash on a symlink
to a directory. This will matter the next time we run
admin/merge-gnulib.
Stefan Monnier [Tue, 9 Jan 2024 16:34:05 +0000 (11:34 -0500)]
(mouse-wheel-*-event): Minor cleanups
* lisp/mwheel.el (mwheel-event-button): Mark as obsolete alias.
Change all callers.
* lisp/edmacro.el (mouse-wheel-*-event): Move declarations to ...
(edmacro-fix-menu-commands): ... where we do know that they should
be defined. Obey `mouse-wheel-*-alternate-event`s as well.
Eshel Yaron [Sat, 20 Jan 2024 19:03:20 +0000 (20:03 +0100)]
Highlight input separators in 'c-r-m' minibuffers
* lisp/emacs-lisp/crm.el (crm-separator): New face.
(crm-highlight-separators): New function.
(crm-change-separator, completing-read-multiple-mode): Use it.
Gregory Heytings [Thu, 11 Jan 2024 23:38:22 +0000 (23:38 +0000)]
Fix blunder in labeled_narrow_to_region
* src/editfns.c (labeled_narrow_to_region): Record point before,
instead of after, calling narrow-to-region; otherwise point may
already have been changed. Fixes bug#66764.
Po Lu [Sat, 20 Jan 2024 01:30:04 +0000 (09:30 +0800)]
Round projs computed executing IP/ISECT instructions and improve IUP
* src/sfnt.c (sfnt_multiply_divide_rounded): New function.
(sfnt_multiply_divide_signed): Always round values, as fonts
which rely on IP to move points in concert with prior motion and
subsequently round such points with MDAP are sensitive to minor
deviations in the behavior of the former instruction.
(load_unscaled): New macro.
(IUP_SINGLE_PAIR, sfnt_interpret_iup_1): Compute ratio w/
unscaled points if possible.
Stefan Monnier [Fri, 19 Jan 2024 20:02:50 +0000 (15:02 -0500)]
trace.el: Make it usable in batch mode as well
While at it, this fixes a bug where a traced function was not
able to set `deactivate-mark`.
* lisp/emacs-lisp/trace.el (trace--insert): New function, extracted
from `trace-make-advice`. Output to stdout in batch mode.
(trace--entry-message): Rename from `trace-entry-message`.
Change calling convention. Do the insertion directly from here.
(trace--exit-message): Rename from `trace-exit-message`.
Change calling convention. Do the insertion directly from here.
(trace-make-advice, trace-values): Simplify accordingly.
Eshel Yaron [Sat, 20 Jan 2024 08:32:29 +0000 (09:32 +0100)]
New command 'crm-complete-and-insert-separator'
* lisp/emacs-lisp/crm.el (crm-complete-and-insert-separator): New
command.
(completing-read-multiple-mode-map): Bind it to 'C-,'.
(crm-canonical-separator, crm-common-separators): New variables.
(completions-multi-mode): Adapt mode line lighter.
(crm-complete-and-exit): Only suggest in 'M-x' in 'minibuffer-mode'.
(crm-change-separator): (Re)set canonical separator.
F. Jason Park [Sun, 14 Jan 2024 21:02:27 +0000 (13:02 -0800)]
Redo doc strings for ERC's entry point commands
* lisp/erc/erc.el: Bump Compat version in Package-Requires header to
29.1.4.4.
(erc-select-read-args): Revise doc string, and update name of internal
`--interactive-env--' entry-point parameter.
(erc, erc-tls): Don't use `&interactive-env' as a variable name, in
case it confuses persons or programs. Overhaul doc string in response
to user complaints. For `erc' specifically, include literal
`:keyword' symbols to help non-Emacs users understand the required
syntax, which isn't obvious without an example, like `erc-tls' has,
and with only "&key" and upcased metasynctatic variables to go by.
(erc--current-buffer-joined-p): Remove assertion.
* test/lisp/erc/erc-scenarios-keep-place-indicator.el
(erc-scenarios-keep-place-indicator--follow): Try waiting for
intermittently failing condition.
* test/lisp/erc/erc-tests.el (erc-select-read-args): Update name of
internal keyword variable.
Stefan Monnier [Thu, 18 Jan 2024 19:00:15 +0000 (14:00 -0500)]
* test/lisp/emacs-lisp/comp-cstr-tests.el: Use macros in a simpler way
(comp-cstr-test-ts): Move out of `cl-eval-when`.
(comp-cstr-typespec-test): Delete.
(comp-cstr-synthesize-tests): Make it take the tests as an argument.
(comp-cstr-typespec-tests-alist): Delete var, pass its value to the
macro instead.
Eric Abrahamsen [Thu, 18 Jan 2024 15:24:39 +0000 (07:24 -0800)]
Avoid font-lock reset in `gnus-message-citation-mode'
* lisp/gnus/gnus-cite.el (gnus-message-citation-mode): Use
`font-lock-add-keywords' and `font-lock-remove-keywords' instead of
modifying font-lock defaults. Make no font-lock changes until
`font-lock-mode' is active.
Eshel Yaron [Fri, 19 Jan 2024 06:38:46 +0000 (07:38 +0100)]
Show completions category in heading line
Extend 'completions-header-format' with a placeholder for the
completions category. Stop hard-coding the 'shadow' face for the
heading line default value, instead define a derived face.
* lisp/minibuffer.el (completions-header-format): Extend.
(completions-heading): New face.
(completion-category): New variable.
(minibuffer-completion-help): Let-bind it.
(display-completion-list): Use it.
* src/fns.c (hash_table_thaw): Don't allocate anything for empty
tables. Don't initialise the next vector twice.
(maybe_resize_hash_table): Factor out min_size constant.
Eshel Yaron [Wed, 17 Jan 2024 11:01:55 +0000 (12:01 +0100)]
Improve 'read-face-name' completions alignment
* lisp/faces.el (read-face-name-sample-text): Add new possible values
that specify whether to show sample text before, or after, face names.
(completion-face-name-affixation): Pixel-align face names and samples.
Mike Kupfer [Mon, 15 Jan 2024 19:47:43 +0000 (11:47 -0800)]
Fix folder creation error (Bug#67361)
* lisp/mh-e/mh-funcs.el (mh-kill-folder), lisp/mh-e/mh-search.el
(mh-index-new-folder), lisp/mh-e/mh-utils.el (mh-prompt-for-folder):
Check for existence of speedbar-buffer rather than
mh-speed-folder-map. The latter can exist if mh-speed has only been
loaded but not displayed.
Stefan Monnier [Mon, 15 Jan 2024 03:17:13 +0000 (22:17 -0500)]
(js-json-mode): Don't derive from `js-mode` (bug#67463)
* lisp/progmodes/js.el (js--mode-setup): New function, extracted from
`js-mode`.
(js-mode): Use it.
(js-json-mode): Use it instead of inheriting from `js-mode`.
Eshel Yaron [Tue, 16 Jan 2024 12:39:39 +0000 (13:39 +0100)]
; Provide metadata for 'recentf' completions
* lisp/recentf.el (recentf-completion-table): New function.
(recentf-open): Use it. Allow specifying file names that are not in
'recentf-list', after confirmation.
Eshel Yaron [Tue, 16 Jan 2024 09:44:46 +0000 (10:44 +0100)]
; Align completion annotations with spaces for multi-column format
Use actual spaces to align completion annotations instead of
"specified space" display properties, since that allows
'completion--insert-strings' to correctly align multiple completion
columns when 'completions-format' is not 'one-column'.
* lisp/faces.el (completion-face-name-affixation)
* lisp/minibuffer.el (completion-styles-affixation)
(completion-file-name-affixation)
(minibuffer-narrow-buffer-completions)
(completion-buffer-name-affixation)
* lisp/simple.el (read-extended-command--affixation): Align
annotations with spaces instead of using '(space :align-to ...)'
display properties.
Eshel Yaron [Mon, 15 Jan 2024 19:50:01 +0000 (20:50 +0100)]
; Avoid attempting to restore stale previous completion input
* lisp/minibuffer.el (minibuffer--cache-completion-input): Accept the
minibuffer base contents, not just its length.
(minibuffer-restore-completion-input): Ensure cached minibuffer base
is up to date before restoring.
(completion--do-completion, completion-all-sorted-completions)
(minibuffer-completion-help): Adapt.
Retype traverse_interval arg type from Lisp_Object to void *
This is a refactoring. It eliminates a few unnecessary conses and
allows for further improvements.
* src/intervals.c (traverse_intervals):
Change argument type. All callers adapted.
* src/fns.c (collect_interval, Fsxhash_equal_including_properties)
(Fobject_intervals):
* src/print.c (print_check_string_charset_prop)
(print_prune_string_charset, print_object, print_interval):
Pass a pointer to a Lisp_Object instead of a Lisp_Object.
Po Lu [Sun, 14 Jan 2024 13:06:10 +0000 (21:06 +0800)]
Correct implementations of FLIPRGON and FLIPRGOFF
* src/sfnt.c (sfnt_interpret_fliprgoff)
(sfnt_interpret_fliprgon): Reorder arguments to match
the order in which arguments are popped by macro wrappers.
Fix sundry typos.
Po Lu [Sun, 14 Jan 2024 00:26:27 +0000 (08:26 +0800)]
Fix bug#65116
* src/xterm.c (xi_focus_handle_for_device): Correct typo.
(x_focus_frame): Don't focus frames Emacs believes to be
focused if they are frames with independent minibuffer
frames. (bug#65116)
* lisp/emacs-lisp/shortdoc.el (hash-table): Remove hash-table-size entry.
* doc/lispref/hash.texi (Other Hash):
* src/fns.c (Fhash_table_size): Make it clear that hash-table-size is
probably not worth using.
This saves a lot of memory and is quite sufficient. Hash functions
are adapted to produce a hash_hash_t eventually, which eliminates some
useless and information-destroying intermediate hash reduction steps.
We still use EMACS_UINT for most of the actual hashing steps before
producing the final value; this may be slightly wasteful on 32-bit
platforms with 64-bit EMACS_UINT.
* src/lisp.h (hash_hash_t): Change to uint32_t.
* src/fns.c (reduce_emacs_uint_to_hash_hash): New.
(hashfn_eq, hashfn_equal, hashfn_user_defined): Reduce return values
to hash_hash_t.
(sxhash_string): Remove. Caller changed to hash_string.
(sxhash_float, sxhash_list, sxhash_vector, sxhash_bool_vector)
(sxhash_bignum): Remove wasteful calls to SXHASH_REDUCE.
(hash_hash_to_fixnum): New.
(Fsxhash_eq, Fsxhash_eql, Fsxhash_equal)
(Fsxhash_equal_including_properties): Convert return values to fixnum.
Use key Qunbound instead of hash value hash_unused for free entries
Previously, free hash table entries were indicated by both hash value
hash_unused and key Qunbound; we now rely on the latter only.
This allows us to change the hash representation to one that does not
have an unused value.
* src/lisp.h (hash_unused): Remove.
All uses adapted to calling hash_unused_entry_key_p on the key instead.
The hash values for unused hash table entries are now undefined; all
initialisation and assignment to hash_unused has been removed.
The dumper uses a hash table to keep track of dumped objects but as
this clashes with the use of Qunbound for marking unused hash table
entries, don't dump that value at all. The symbol name is fixed up
after loading.
An alternative solution would be to use a different unique value for
unused entries.
* src/pdumper.c (dump_object_needs_dumping_p): Skip Qunbound.
(dump_vectorlike_generic): New function.
(pdumper_load): Call it.
The algorithms no longer use the rehash_threshold and rehash_size
float constants, but vary depending on size. In particular, the table
now grows faster, especially from smaller sizes.
The default size is now 0, starting empty, which effectively postpones
allocation until the first insertion (unless make-hash-table was
called with a positive :size); this is a clear gain as long as the
table remains empty. The first inserted item will use an initial size
of 8 because most tables are small.
* src/fns.c (std_rehash_size, std_rehash_threshold): Remove.
(hash_index_size): Integer-only computation.
(maybe_resize_hash_table): Grow more aggressively.
(Fhash_table_rehash_size, Fhash_table_rehash_threshold):
Use the constants directly.
* src/lisp.h (DEFAULT_HASH_SIZE): New value.
This saves several words in the hash table object at the cost of an
indirection at runtime. This seems to be a gain in overall
performance.
FIXME: We cache hash test objects in a rather clumsy way. A better
solution is sought.
* src/lisp.h (struct Lisp_Hash_Table): Use a pointer to the test
struct. All references adapted.
* src/alloc.c (garbage_collect):
* src/fns.c (struct hash_table_user_test, hash_table_user_tests)
(mark_fns, get_hash_table_user_test): New state for caching test
structs, and functions managing it.
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.