I gave too much credit to the comment, and didn't realize that macro
was used in places that didn't obey the comment.
This macro is getting pretty hideous!
Eshel Yaron [Thu, 25 Jan 2024 06:54:03 +0000 (07:54 +0100)]
Highlight previously used completions (à la visited links)
* lisp/minibuffer.el (completions-previous-input): New face.
(completions-highlight-previous-inputs): New user option.
(minibuffer-completion-help): Highlight completion candidates that
occur in the minibuffer history, optionally.
* doc/emacs/mini.texi (Completion Options): Document new feature.
Stefan Monnier [Wed, 24 Jan 2024 17:57:33 +0000 (12:57 -0500)]
Take stock of the wheel-up/down confusion
While we're hopefully all aware of the usual confusion between
the scroll operation moving the document or moving the viewport, Emacs
has its very own instance of that confusion where the
`mouse-wheel-down-event` variable is the one that (used to) hold
the value `wheel-up` and vice versa.
Thanks for Po Lu's commit 957b4f826a4 which not only fixed my change
but brought that confusion to my attention.
This patch doesn't fix the problem, but tries to fix the other places
in the code where we did not take it into account.
* doc/lispref/commands.texi (Misc Events): Mention the
wheel-up/down confusion.
Stefan Monnier [Wed, 24 Jan 2024 13:16:11 +0000 (08:16 -0500)]
(struct composition): Remove dependency on hash-table internals
`struct composition` kept an index into the internal `key_and_value` array
of hash tables, which only worked because of details of how
hash-tables are handled. Replace it with a reference to the
key stored at that location in the hash-table, which saves us an
indirection while at it.
* src/composite.h (struct composition): Replace `hash_index` with
the actual `key`.
(COMPOSITION_KEY): Simplify accordingly.
(mark_composite): Declare.
* src/composite.c (get_composition_id): Adjust accordingly.
(mark_composite): New function.
Stefan Monnier [Wed, 24 Jan 2024 13:07:54 +0000 (08:07 -0500)]
(DOHASH): Change calling convention
This leads to simpler code in the users, and more efficient machine
code because we don't repeatedly need to fetch the `table_size`
and `key_and_value` fields of the hash table object.
Stefan Monnier [Wed, 24 Jan 2024 07:35:22 +0000 (23:35 -0800)]
Remove too-tricky make_lisp_symbol optimization
Simplify optimization for make_lisp_symbol, so that
it’s less tricky and works well enough for gcc -Og or -O2.
* src/lisp.h (lisp_h_builtin_lisp_symbol): Remove.
(builtin_lisp_symbol) [DEFINE_KEY_OPS_AS_MACROS]: Remove.
(make_lisp_symbol_nodebug): New internal static function,
which is like the old make_lisp_symbol but without the eassert.
(make_lisp_symbol, builtin_lisp_symbol): Use it, so that
make_lisp_symbol has the eassert but builtin_lisp_symbol doesn’t. Co-authored-by: Paul Eggert <eggert@cs.ucla.edu>
(cherry picked from commit 802821b81ac5ad0dee7f26caa519326251b262c1)
Stefan Monnier [Wed, 24 Jan 2024 03:30:13 +0000 (22:30 -0500)]
(struct charset): Remove dependency on hash-table internals
`struct charset` kept an index into the internal `key_and_value` array
of hash tables, which only worked because of details of how
hash-tables are handled. Replace it with a reference to the
value stored at that location in the hash-table, which saves us an
indirection while at it.
* src/charset.h (struct charset): Replace `hash_index` field with
`attributes` field.
(CHARSET_ATTRIBUTES): Simplify accordingly.
(CHARSET_HASH_INDEX): Delete unused macro.
* src/charset.c (Fdefine_charset_internal):
* src/pdumper.c (dump_charset): Adjust accordingly.
(dump_charset_table): Set the referrer since that's needed while
dumping Lisp_Object fields.
Po Lu [Tue, 23 Jan 2024 02:30:51 +0000 (10:30 +0800)]
Correct crash when executing IP within twilight zone
* src/sfnt.c (sfnt_address_zp2, sfnt_address_zp1)
(sfnt_address_zp0): Don't save into X or Y if the zone is set to
the twilight zone and they are NULL.
Po Lu [Mon, 22 Jan 2024 07:29:18 +0000 (15:29 +0800)]
Correct values of INSTCTRL flags tested
* src/sfnt.c (sfnt_mul_f26dot6_round): New function.
(sfnt_mul_f26dot6_fixed): Replace by call to
sfnt_mul_fixed_round.
(MUL): Round result, as the Apple and MS scalers do.
(sfnt_interpret_control_value_program): The instruction control
flag which reverts CVT modifications is 2, not 4.
Paul Eggert [Mon, 22 Jan 2024 04:34:03 +0000 (20:34 -0800)]
Add an eassert back to XSYMBOL
Problem reported by Alan Mackenzie in:
https://lists.gnu.org/r/emacs-devel/2024-01/msg00755.html
* src/lisp.h (XSYMBOL): If the arg is not a bare symbol, then
eassert (symbols_with_pos_enabled). This shouldn’t affect code
generated for regular builds, and could catch caller errors in
debug builds. For debug builds although this slows things down
XSYMBOL should still be faster than it was the day before
yesterday, as there’s still no need to eassert (SYMBOLP (a)).
Paul Eggert [Mon, 22 Jan 2024 01:18:23 +0000 (17:18 -0800)]
Speed up builtin_lisp_symbol when not optimizing
This should help when building with --enable-checking and
compiling with gcc -O0. Problem reorted by Stefan Monnier in:
https://lists.gnu.org/r/emacs-devel/2024-01/msg00770.html
* src/lisp.h (lisp_h_builtin_lisp_symbol): New macro,
with a body equivalent in effect to the old ‘builtin_lisp_symbol’
but faster when not optimizing.
(builtin_lisp_symbol): Use it.
If DEFINE_KEY_OPS_AS_MACROS, also define as macro.
Recent hash table changes reduced the range of sxhash, sxhash-eq etc
to [0,2**32) on platforms with 62-bit fixnums. This change makes them
use the full fixnum range again. Hash table hashing is unaffected.
* src/fns.c (sxhash_eq, sxhash_eql): New.
(hash_hash_to_fixnum): Replace with...
(reduce_emacs_uint_to_fixnum): ...this.
(hashfn_eq, hashfn_eql, Fsxhash_eq, Fsxhash_eql, Fsxhash_equal)
(Fsxhash_equal_including_properties): Use the new functions.
Clarify permitted mutation in `maphash` documentation
* doc/lispref/hash.texi (Hash Access):
* src/fns.c (Fmaphash):
Make it clear what the function passed as argument can do. Until now
these rules were unwritten, and are still unenforced.
Eshel Yaron [Mon, 22 Jan 2024 16:49:58 +0000 (17:49 +0100)]
; Fix bounds check in 'minibuffer-restore-completion-input'
* lisp/minibuffer.el (minibuffer-force-complete): Don't count the
length of the input-to-restore when checking the bounds of the current
minibuffer contents. Also, refresh the *Completions* buffer if it is
already visible.
Eshel Yaron [Mon, 22 Jan 2024 16:39:11 +0000 (17:39 +0100)]
; Allow completion tables to adjust 'minibuffer-completion-base'
This adds a new completion metadata function 'adjust-base-function'
that completion tables can provide in order to adjust
'minibuffer-completion-base' around calls to completions sorting and
annotation functions. In particular, this allows 'c-r-m' to remove
inputs that end before the current partial input from
'minibuffer-completion-base', to avoid throwing off functions that
treat 'minibuffer-completion-base' as a prefix of the set of
completion candidates, e.g. the directory part in file completion.
* lisp/minibuffer.el (completion-metadata): New completion metadata
entry 'adjust-base-function'.
(completion-all-sorted-completions, minibuffer-completion-help): Use
it to adjust 'minibuffer-completion-base'.
* lisp/emacs-lisp/crm.el (crm--table): Extend metadata with an
'adjust-base-function'.
Eshel Yaron [Mon, 22 Jan 2024 14:02:19 +0000 (15:02 +0100)]
Adjust completion un/requoting in 'completing-read-multiple'
Teach 'completing-read-multiple' about 'completion--unquote', so it
can be used with completion tables that perform quoting. Namely, this
allows reading multiple file names with:
Stefan Monnier [Sun, 21 Jan 2024 04:00:54 +0000 (23:00 -0500)]
(define-derived-mode): Fix bug#68600
* lisp/emacs-lisp/derived.el (define-derived-mode): Use a reference
to the mode symbol instead of the mode's "pretty" name in
the hook variable's docstring.
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.