Eshel Yaron [Sat, 6 Jan 2024 12:31:23 +0000 (13:31 +0100)]
Support sorting file name completions list by last modified time
(minibuffer--sort-file-names-by-last-modified-time): New function.
(read-file-name-default): Add it to
'minibuffer-completions-sort-orders' buffer-locally.
* doc/emacs/mini.texi (Completion Commands): Elaborate about
'minibuffer-sort-completions'.
Eshel Yaron [Fri, 5 Jan 2024 18:03:13 +0000 (19:03 +0100)]
Add completion annotations for file name completion
* lisp/minibuffer.el (completion-file-name-affixation): New function.
(completion-file-name-table): Use it as 'affixation-function'.
* doc/emacs/help.texi (Name Help): Move doc of 'completions-detailed'
from here to...
* doc/emacs/mini.texi (Completion Options): ...here. Improve wording.
* etc/NEWS: Announce.
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.
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.
Eshel Yaron [Sun, 14 Jan 2024 14:47:05 +0000 (15:47 +0100)]
New commands for cycling completions and restoring completed input
This adds two new minibuffer commands, 'minibuffer-cycle-completion'
and 'minibuffer-restore-completion-input', bound to 'C-o' and 'C-l',
respectively.
* lisp/minibuffer.el (completion--input): New local variable.
(minibuffer--cache-completion-input)
(completion-switch-cycling-direction): New functions.
(completion-all-sorted-completions): Respect
'minibuffer-completions-sort-function', and...
(minibuffer-completion-help)
(completion--do-completion): Cache completion input.
(completions-auto-update): Preserve 'completion--input'.
(minibuffer-force-complete): Highlight inserted candidate in
completions list if *Completions* is already visible.
(minibuffer-cycle-completion)
(minibuffer-restore-completion-input): New commands.
(minibuffer-local-completion-map): Bind them.
Eshel Yaron [Wed, 10 Jan 2024 09:56:09 +0000 (10:56 +0100)]
New command 'minibuffer-set-completion-styles'
Add an interactive command for setting completion styles in the
current minibuffer.
* lisp/minibuffer.el (completion-style)
(completion--matching-style, completion-local-styles): New vars.
(completion--styles): Use 'completion-local-styles' when it's non-nil.
(completion--nth-completion): Set 'completion--matching-style' to the
matching completion style.
(completion-styles-affixation, completion-styles-table): New funs.
(minibuffer-set-completion-styles): New command.
(minibuffer-local-completion-map): Bind it.
(minibuffer-completion-help): Set 'completion-style' in the
"*Completions*" buffer.
* lisp/simple.el (completion-setup-function): Keep 'completion-style'.
(completion-list-mode): Display 'completion-style' in mode line.
* doc/emacs/mini.texi (Completion Commands, Completion Styles):
Document new command.
* doc/lispref/minibuf.texi (Completion Commands)
(Completion Variables): Document new command and variable.
Eshel Yaron [Mon, 8 Jan 2024 15:25:36 +0000 (16:25 +0100)]
; Fix 'crm-change-separator'
* lisp/emacs-lisp/crm.el (crm-current-separator): New variable.
(crm-complete-and-exit, crm-change-separator)
(completions-multi-mode): Use it instead of 'crm-separator'.
(completing-read-multiple): Let-bind 'crm-current-separator' to the
current value of 'crm-separator'.
Eshel Yaron [Wed, 3 Jan 2024 15:04:59 +0000 (16:04 +0100)]
; Bind 'minibuffer-complete-and-exit' in "Minibuf" menu
* lisp/menu-bar.el (minibuffer-local-completion-map): Bind
'minibuffer-complete-and-exit' in "Minibuf" menu bar menu, shadowing
the binding of 'exit-minibuffer' in that menu.
Eshel Yaron [Wed, 3 Jan 2024 13:13:17 +0000 (14:13 +0100)]
Improve 'completing-read-multiple'
This simplifies the implementation of crm.el, making it a thin wrapper
around 'completing-read'. This obviates the need for bespoke commands
such as 'crm-complete' and 'crm-completion-help', and allows us to
remove incorrect code in minibuffer.el that tried to accommodate for
both 'completing-read' and 'completing-read-multiple'.
'crm-complete-and-exit' is still required to get the right behavior.
While we're at it, also add a command for changing 'crm-separator'
interactively, and an indication of 'completing-read-multiple' in
the *Completions* buffer mode line.
* lisp/emacs-lisp/crm.el (crm-local-completion-map)
(crm-local-must-match-map): No longer used, replace with obsolete
aliases of 'completing-read-multiple-mode-map' in favor of third party
code that uses these variables.
(crm-completion-table, crm--current-element)
(crm--completion-command, crm-completion-help)
(crm-complete, crm-complete-word)
(crm--choose-completion-string): No longer used, remove.
(crm-complete-and-exit): Update.
(read-string-matching-regexp): New local variable.
(read-string-matching-try-exit)
(crm-change-separator): New commands.
(read-string-matching-mode-map)
(completing-read-multiple-mode-map): New keymap variables.
(read-string-matching-mode)
(completing-read-multiple-mode)
(completions-multi-mode): New minor modes.
(read-string-matching, crm-completion-setup): New functions.
(completing-read-multiple): Update.
Eshel Yaron [Wed, 27 Dec 2023 09:11:36 +0000 (10:11 +0100)]
Support interactively sorting minibuffer completions
* lisp/minibuffer.el (minibuffer-completions-sort-function): New var.
(minibuffer-read-sort-order-with-completion)
(minibuffer-completions-sort-orders): New user options.
(minibuffer-sort-completions): New command.
(minibuffer-local-completion-map): Bind it to 'C-x C-v'.
(display-completion-list, minibuffer-completion-help): Take
'minibuffer-completions-sort-function' into account.
(completions-header-format): Add '%t' format spec construct,
substituted with a description of the current sort order.
* lisp/menu-bar.el (minibuffer-local-completion-map): Add menu bar
menu entry for sorting completions candidates.
* doc/emacs/mini.texi (Completion Commands): Document new command.
Improve documentation and indexing of 'minibuffer-complete-and-exit'.
(Completion Exit, Completion Options): Update
* doc/lispref/minibuf.texi (Completion Commands): Document new user
options and command.
* etc/NEWS: Announce new feature.
Eshel Yaron [Mon, 25 Dec 2023 11:24:51 +0000 (12:24 +0100)]
; Support removing individual completions restrictions
* lisp/minibuffer.el (minibuffer-widen-completions): New optional
argument ALL, if nil prompt for individual restrictions to remove.
Also, take into account completions boundaries when calling
'minibuffer-completion-help'.
* doc/emacs/mini.texi (Completion Commands, Narrow Completions):
Update documentation.
* lisp/menu-bar.el (map): Update help text.
Eshel Yaron [Mon, 25 Dec 2023 10:59:49 +0000 (11:59 +0100)]
; Respect 'completion-boundaries' in narrow-completions commands
* lisp/minibuffer.el (minibuffer--completion-boundaries): New helper
function, return 'completion-boundaries' for minibuffer input as
a pair of buffer positions in the minibuffer.
(minibuffer--add-completions-predicate)
(minibuffer-narrow-completions-by-regexp)
(minibuffer-narrow-completions-to-current): Use it.
Eshel Yaron [Sat, 23 Dec 2023 09:13:51 +0000 (10:13 +0100)]
Add Completions Auto Update minor mode
This adds a new global minor that updates the *Completions* buffer as
you type in the minibuffer.
* lisp/minibuffer.el (completions-auto-update-idle-time): New option.
(completions-auto-update-timer): New buffer-local variable.
(completions-auto-update)
(completions-auto-update-start-timer)
(completions-auto-update-setup)
(completions-auto-update-exit): New functions.
(completions-auto-update-mode): New global minor mode.
* doc/emacs/mini.texi (Completion Options): Document it.
* etc/NEWS: Announce it.
Eshel Yaron [Thu, 21 Dec 2023 19:43:59 +0000 (20:43 +0100)]
Support narrowing (restricting) minibuffer completions
Add new minibuffer commands for restricting the list of possible
completion candidates.
* lisp/minibuffer.el (completion-fail-discreetly): Fix docstring typo.
(minibuffer-narrow-completions-function): New variable.
(completion--fail, minibuffer-narrow-completions-p)
(minibuffer-narrow-completions-by-regexp)
(minibuffer--completion-predicate-description)
(minibuffer--add-completions-predicate): New functions.
(minibuffer-narrow-completions-to-current)
(minibuffer-narrow-completions)
(minibuffer-widen-completions): New commands.
(minibuffer-narrow-completions-map): New prefix keymap. Bind new
commands to 'n', 'm' and 'w', respectively.
(minibuffer-local-completion-map): Bind new prefix keymap to 'C-x n'.
(completions-header-format, completion--do-completion)
(display-completion-list, minibuffer-completion-help): Update.
* lisp/simple.el (completions-narrow-mode): New minor mode.
(completion-setup-function): Enable it in *Completions* buffer when
there are completions restrictions in place.
* lisp/menu-bar.el (minibuffer-local-completion-map): Add completions
narrowing commands to "Minibuf" menu.
* lisp/help-fns.el (help--symbol-completion-table): Provide bespoke
'narrow-completions-function' that keeps only symbols with a given
symbol property.
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.
* 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.
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`.
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.
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.