Stefan Monnier [Thu, 17 Nov 2022 23:09:37 +0000 (18:09 -0500)]
itree.c: Get rid of the old iterator code
Only use the new iterator which relies on a fixed size (and small)
state in the iterator.
This makes non-local exits safe within ITREE_FOREACH loops.
* src/itree.c (make_nav, nav_nodeptr, nav_flag, itree_stack_clear)
(itree_stack_push_flagged): Delete functions.
(nodeptr_and_flag): Delete type.
(struct itree_stack): Make the array hold plain pointers instead.
(itree_stack_push): Inline the former code of `itree_stack_push_flagged`.
(itree_stack_pop): Change return type.
(itree_contains): Don't call `ITREE_FOREACH_ABORT` any more.
(itree_insert_gap): Simplify access to the stack of nodes.
(itree_delete_gap, itree_insert_gap): Adjust code to new return type of
`itree_stack_pop`.
(itree_iterator_finish): Delete function.
(itree_iterator_start): Don't setup the `stack` field any more.
(itree_iterator_next): Delete function.
(itree_iter_next): Rename to `itree_iterator_next` and make it non-static.
(itree_iterator_narrow): Don't check the `running` flag any more.
* src/itree.h (itree_iterator_finish): Remove declaration.
(struct itree_iterator): Remove the `stack` and `running` fields.
(ITREE_FOREACH_ABORT): Delete macro.
(ITREE_FOREACH): Don't call `itree_iterator_finish` any more.
* src/xdisp.c (strings_with_newlines):
* src/buffer.c (overlays_in, next_overlay_change, overlay_touches_p):
Don't call `ITREE_FOREACH_ABORT` any more.
Stefan Monnier [Thu, 17 Nov 2022 22:00:22 +0000 (17:00 -0500)]
itree.c: Make the iterator reentrant (bug#59183)
Get rid of the global iterator object and instead allocate
a separate iterator for every loop. This still uses the "duplicate
iterator" code, including the old iterator which needs a stack,
make ITREE_FOREACH a bit more expensive than we'd like.
* src/itree.h (init_itree, forget_itree, itree_iterator_busy_p):
Delete declarations.
(itree_iterator_start): Add iterator arg and remove `line` and `file` args.
(struct itree_iterator): Move from `itree.c`. Remove `line` and
`file` fields.
(ITREE_FOREACH): Stack allocate an iterator object and pass it to
`itree_iterator_start`.
* src/itree.c (struct itree_iterator): Move to itree.h.
(iter): Delete global variable.
(itree_iterator_create, init_itree, forget_itree, itree_iterator_busy_p):
Delete functions.
(itree_contains): Adjust assertion.
(itree_iterator_finish): Deallocate the iterator's stack.
(itree_iterator_start): Take the (uninitialized) iterator as argument.
Allocate a fresh new stack. Remove `file` and `line` arguments.
Don't check `running` any more since the iterator is not expected to be
initialized at all.
* src/eval.c (signal_or_quit):
* src/alloc.c (garbage_collect): Don't check `itree_iterator_busy_p`
any more.
* src/emacs.c (main): No need to `init_itree` any more.
(Fdump_emacs): No need to `forget_itree` any more.
Fix issues related to 'package-vc-install-from-checkout'
* lisp/emacs-lisp/package-vc.el (package-vc--main-file): Ensure the
package name is a string.
(package-vc--unpack-1): Use pkg-dir instead of the empty return value
of 'package-lisp-dir'.
(package-vc-install-from-checkout): Fix file name handling.
* lisp/emacs-lisp/package-vc.el (package-vc-update): Ensure that the
command is only invoked with installed packages. that the hook is
always removed and that 'vc-pull' is always called in the right
directory.
* lisp/emacs-lisp/package-vc.el (package-vc-prepare-patch): Use
'vc-prepare-patch-prompt-revisions'.
* lisp/vc/vc.el (vc-prepare-patch-prompt-revisions): Extract common
function and handle prefix arguments.
(vc-prepare-patch): Pull logic out to
'vc-prepare-patch-prompt-revisions'.
Have 'package-vc-selected-packages' consider all installed packages
* lisp/emacs-lisp/package-vc.el
(package-vc-install-selected-packages): Consider more than just one
value in `package-alist', in case there are multiple installations.
* lisp/emacs-lisp/package.el (package--download-one-archive): Only add
the archive that is actually being downloaded to
'package--downloads-in-progress'.
Track 'default-directory' while updating source packages
* lisp/emacs-lisp/package-vc.el (package-vc-update): Add the source
directory to the identifier list, in case the remaining
'vc-do-command' arguments are all read-time constants.
Respect :lisp-dir in package specs by loading a sub-directory
* lisp/emacs-lisp/package-vc.el (package-vc-repository-store): Remove
obsolete variable.
(package-vc--unpack-1): Respect :lisp-dir.
(package-vc--unpack): Add :lisp-dir to the package description if
necessary.
* lisp/emacs-lisp/package.el (package--delete-directory): Check if a
directory is a symbolic link.
* lisp/emacs-lisp/package-vc.el (package-vc-selected-packages): Remove
reference to non-existent function and add an explanation that the
value won't override an existing source package installation.
* lisp/emacs-lisp/package-vc.el (package-vc--sourced-packages-list):
Remove function in favour of 'package-vc--read-package-name'.
(package-vc--read-package-name):
Extract out common functionality.
(package-vc--read-package-desc): Add auxiliary function based on
'package-vc--read-package-name'.
(package-vc-update): Add interactive spec using
'package-vc--read-package-desc'.
(package-vc-install): Use 'package-vc--read-package-desc'.
(package-vc-checkout): Use 'package-vc--read-package-desc'.
(package-vc--read-pkg): Remove in favour of 'package-vc--read-package-desc'.
(package-vc-refresh): Use 'package-vc--read-package-desc'.
(package-vc-prepare-patch): Use 'package-vc--read-package-desc'.
* lisp/emacs-lisp/package-vc.el (package-vc-ensure-packages): Add an
autoload cookie.
(package-vc-selected-packages): Set
:initialize to 'custom-initialize-default'.
Stefan Monnier [Thu, 17 Nov 2022 14:08:24 +0000 (09:08 -0500)]
itree.c: Add new "stateless" iterator code and post-order traversal
This still uses the old iterator code, but runs the new code
alongside to make sure they behave identically.
* src/itree.c (struct itree_iterator): New field `node`.
(itree_iterator_create): Give it a sane default value.
(itree_iterator_busy_p, itree_iterator_start, itree_iterator_finish):
Move down to the "iterator" section of the file.
(itree_iter_next_in_subtree, itree_iterator_first_node)
(itree_iter_next): New functions.
(itree_iterator_start): Initialize the new `node` field.
(itree_iterator_next): Add post-order case.
Call the new "stateless" `itree_iter_next` function and check that it
agrees.
* src/itree.h (enum itree_order): New value for post-order traversals.
Andrea Monaco [Mon, 7 Nov 2022 14:13:13 +0000 (15:13 +0100)]
Improve progressive summaries in Rmail
* lisp/mail/rmailsum.el (rmail-summary-progressively-narrow):
Renamed from 'rmail-summary-apply-filters-consecutively'. Doc
fix.
(rmail-summary-invert): Renamed from 'rmail-summary-negate'. Doc
fix.
(rmail-summary-currently-displayed-msgs): Doc fix.
(rmail-summary--exists-1): New function.
(rmail-summary-by-labels, rmail-summary-by-recipients)
(rmail-summary-by-regexp, rmail-summary-by-topic)
(rmail-summary-by-senders): Call 'rmail-summary-exists' to verify
that the summary is usable.
Alan Mackenzie [Thu, 17 Nov 2022 10:34:41 +0000 (10:34 +0000)]
CC Mode: Make implicit int types following specifiers fontify correctly
This fixes bug #59267. It applies to C Mode only, and refers to constructs
like "register count;" which are implicitly of int type.
* lisp/progmodes/cc-engine.el (c-forward-type): Use the new regexp
c-maybe-typeless-specifier-re in place of c-opt-type-modifier-prefix-key. Add
an extra arm to the main cond form to handle the construct, and another to
handle "extern "C" foo_t my_foo;".
(c-forward-decl-or-cast-1): Adapt to handle the result no-id from
c-forward-type.
* lisp/progmodes/cc-langs.el (c-maybe-typeless-specifier-re): New lang
const/var.
Olivier Certner [Thu, 10 Nov 2022 17:57:27 +0000 (18:57 +0100)]
ediff: Merges with ancestor: Fix computation of hunks and proposed merge
Hunks were not computed correctly because the diff3 command was
invoked with arguments in an incorrect order. The correct order is
the local file first, the base (or "ancestor") second and the other
file third. This erroneous behavior had two consequences. First, the
output of diff3 would change, since it tries to merge chunks according
to maximal matches between the second and first files, and the second
and third files. Second, ediff, more precisely, `ediff-do-merge',
would consequently try to merge the reverse of the changes from the
base to the other file.
* lisp/vc/ediff-diff.el (ediff-setup-diff-regions3): In the arguments
to `ediff-exec-process', swap the other file with the ancestor (only
when merging with an ancestor).
(ediff-extract-diffs3): Match the hunk data for the ancestor and the
other file correctly. The local variable `three-way-comp' indicates
this is a merge with ancestors when it is nil.
Eli Zaretskii [Thu, 17 Nov 2022 09:21:01 +0000 (11:21 +0200)]
Fix display of mode line when the right divider is used
* src/xdisp.c (init_iterator): For the mode-line, adjust
last_visible_x due to the right divider and the 'box' attribute,
if any, of the mode-line face.
(display_min_width): Update current_x after producing the stretch
glyph, to mimic PRODUCE_GLYPHS.
(display_mode_line): Widen the last glyph to account for adding
the right box line to it. (Bug#5930)
Juri Linkov [Thu, 17 Nov 2022 07:25:42 +0000 (09:25 +0200)]
* lisp/keymap.el (defvar-keymap): Add support for repeat-mode.
Put symbol properties 'repeat-map' on commands from the keymap
when a ':repeat' keyword is non-nil. Also include/exclude commands
according to ':repeat (:enter (commands ...) :exit (commands ...))'.
https://lists.gnu.org/archive/html/emacs-devel/2022-11/msg00968.html
Juri Linkov [Thu, 17 Nov 2022 07:20:15 +0000 (09:20 +0200)]
* lisp/repeat.el (describe-repeat-maps): Improve the output.
Print the table of keybindings and a list of commands that
enter and exit repeat-map. Use default outline headings.
https://lists.gnu.org/archive/html/emacs-devel/2022-11/msg00969.html
Po Lu [Thu, 17 Nov 2022 07:12:16 +0000 (15:12 +0800)]
Fix treatment of input focus on MPX setups
* src/xterm.c (x_ewmh_activate_frame): Use x_set_input_focus
instead of XSetInputFocus.
(x_set_input_focus): New function. Take into account the
``client pointer'' chosen by Emacs.
(x_focus_frame): Use x_set_input_focus instead of
XSetInputFocus.
F. Jason Park [Mon, 11 Jul 2022 12:14:57 +0000 (05:14 -0700)]
Improve new connections in erc-handle-irc-url
* doc/misc/erc.texi: Add new Integrations section to the info manual
under Advanced Usage.
* etc/ERC-NEWS: Add new section mentioning improved UX when clicking
on irc:// links.
* lisp/erc/erc.el (erc-handle-irc-url): Add optional "scheme"
parameter. Fix `erc-open' invocation so that the server buffer is
named correctly by deferring to a new customizable opener. Arrange
for JOINing a channel in a manner similar to ERC's autojoin module.
(erc-url-connect-function): Add new option for creating a new ERC
connection based on info parsed from a URL.
(erc--url-default-connect-function): New function to serve as an
interactive-only fallback when a user hasn't specified a URL connect
function.
* lisp/erc/erc-compat.el (erc-compat--29-browse-url--irc): Add new
compatibility function for `browse-url-irc' and include it in
`browse-url-default-handlers' on Emacs versions below 29.
F. Jason Park [Mon, 11 Jul 2022 12:14:57 +0000 (05:14 -0700)]
Default to TLS port when calling erc-tls from lisp
* lisp/erc/erc.el (erc-normalize-port): Add standard IANA port-name
mappings for 6667 and 6697.
(erc-open): Add note to doc string explaining that params `connect'
and `channel' are mutually exclusive.
(erc-tls): Call `erc-compute-port' with override.
(erc-compute-port): Call `erc-normalize-port' with result'.
* test/lisp/erc/erc-tests.el (erc-tls): Add simplistic test focusing
on default parameters. (Bug#56514.)
F. Jason Park [Mon, 11 Jul 2022 12:14:57 +0000 (05:14 -0700)]
Refactor erc-select-read-args
* lisp/erc/erc-backend.el (erc--server-connect-dumb-ipv6-regexp): Add
liberal pattern for matching bracketed IPv6 addresses.
(erc-server-connect): Remove brackets from IPv6 hosts before
connecting.
* lisp/erc/erc.el (erc--ensure-url): Add compat adapter to massage
partial URLs given as input that may be missing the scheme:// portion.
(erc-select-read-args): Keep bracketed IPv6 hosts
intact. Make this function fully URL-aware (was only partially so).
Accept optional `input' argument.
* lisp/erc/erc-tests.el (erc-tests--ipv6-examples,
erc--server-connect-dumb-ipv6-regexp, erc-select-read-args): Add test
reading user input during interactive invocations of entry points.
(Bug#56514.)
F. Jason Park [Mon, 11 Jul 2022 12:14:57 +0000 (05:14 -0700)]
Accommodate ircs:// URLs in url-irc and browse-url
* lisp/url/url-irc.el (url-irc-function): Change signature of function
interface to expect a final "scheme" argument, such as "ircs".
(url-irc): Call `url-irc-function' with new positional argument, the
scheme extracted via `url-type' from the input URL.
(url-irc-erc, url-irc-rcirc, url-irc-zenirc): Accept a URL scheme as a
sixth positional arg.
(url-ircs-default-port, url-ircs): Add new autoloaded constant and
alias for `url-scheme-get-property' to recognize. Do this to avoid
having to add another file.
* lisp/net/browse-url.el (browse-url-irc-function): Add new option.
(browse-url--irc): Add new function to call `browse-url-irc-function'.
(browse-url-default-handlers): Add "irc://" entry.
(browse-url-irc): Add new function to serve as general handler for
"irc://" URLS. Accept trailing variadic args to accommodate
non-browse-url interfaces as well.
* test/lisp/net/browse-url-tests.el
(browse-url-tests-select-handler-irc): Add test for "irc://" URL
pattern.
* etc/NEWS: Mention select browse-url and url-irc
changes. (Bug#56514.)
F. Jason Park [Tue, 25 Oct 2022 05:58:13 +0000 (22:58 -0700)]
Warn of future breaking change to erc-response.tags
* lisp/erc/erc-backend.el (erc-parse-tags-format): New option to
determine type of the `erc-response' "tags" field.
(erc-parse-tags): Defer to internal generic function.
(erc--parse-tags): New function to hold original `erc-parse-tags'
implementation.
(erc--parse-message-tags): New generic function that conditionally
calls `erc--parse-tags', perhaps emitting a warning beforehand.
(erc-parse-server-response): Call `erc--parse-message-tags'.
(Bug#58797.)
F. Jason Park [Thu, 27 Oct 2022 07:21:10 +0000 (00:21 -0700)]
Improve auto-reconnect visibility in ERC
* lisp/erc/erc-backend.el (erc--server-reconnect-timer): New variable.
(erc-server-reconnect-function): New user option.
(erc-process-sentinel-2): Display time remaining until next
reconnection attempt. Also remove condition case and move bulk of
else condition logic to `erc-schedule-reconnect'. More importantly,
no longer set `erc--server-reconnecting here').
(erc-server-connect): Initialize `erc--server-reconnect-timer' to nil.
(erc-server-reconnect): Set `erc-server--reconnecting' here.
(erc--mode-line-process-reconnecting): New constant to store value for
"reconnect" state of `mode-line-process'.
(erc--cancel-auto-reconnect-timer): New function to cancel
auto-reconnect timer and print message.
(erc-schedule-reconnect): New function for scheduling another
reconnect attempt.
* lisp/erc/erc.el (erc-open): Only update mode line for target
buffers. For server buffers, let `erc-login' and/or process sentinels
take care of it.
(erc--cmd-reconnect, erc-cmd-RECONNECT): Rename latter to former, a
new function, but repurpose existing to recognize newly allowed
additional arguments and act accordingly. In new internal function,
cancel an existing auto-reconnect timer, if any, before proceeding.
Defer to `erc-server-reconnect' to set `erc--server-reconnecting'.
Fix `with-suppressed-warnings' form.
(erc-update-mode-line-buffer): Show "reconnecting in Ns" for
`mode-line-process' when awaiting an automatic reconnect attempt.
(erc-message-english-reconnecting,
erc-message-english-reconnect-canceled): Add new message functions to
English catalog.
* lisp/erc/erc-pcomplete.el (pcomplete/erc-mode/RECONNECT): Perform
completion for newly subcommand-aware `erc-cmd-RECONNECT'.
* lisp/erc/erc-scenarios-base-reconnect
(erc-scenarios-base-cancel-reconnect): Add new test case for canceling
reconnect timers. (Bug#58840.)
F. Jason Park [Wed, 16 Nov 2022 09:21:20 +0000 (01:21 -0800)]
; Make some ERC test fixtures a bit more courteous
* test/lisp/erc/erc-dcc-tests.el (erc-dcc-tests--pcomplete-common):
Only emit messages when interactive.
* test/lisp/erc/resources/erc-d/erc-d-tests.el
(erc-d-tests-with-server): Shadow `erc-after-connect' so
`erc-autojoin-channels' doesn't affect other tests.
test/lisp/erc/resources/erc-scenarios-common.el
(erc-scenarios-common--make-bindings): Shadow `erc-after-connect' here
as well. Also require erc instead of erc-backend to silence some new
compiler warnings the cropped up after the creation of erc-common.el.
F. Jason Park [Sun, 24 Apr 2022 13:20:09 +0000 (06:20 -0700)]
Support auth-source-pass in ERC
* doc/misc/erc.texi: Mention that the auth-source-pass backend is
supported.
* lisp/erc/erc-compat.el (erc-compat--29-auth-source-pass-search,
erc-compat--29-auth-source-pass--build-result-many,
erc-compat--29-auth-source-pass--retrieve-parsed,
erc-compat--29-auth-source-pass-backend-parse,
erc-compat--auth-source-backend-parser-functions): Adapt some yet
unreleased functions from auth-source-pass that mimic the netrc
backend, and add forward declarations to support them.
Jim Porter [Wed, 2 Nov 2022 16:22:43 +0000 (09:22 -0700)]
Enable/disable 'server-mode' when starting/stopping the server
* lisp/server.el (server-mode-map): New keymap...
(server-mode): ... use it.
(server-start): Update the 'server-mode' variable (and sync to
'global-minor-modes') when starting/stopping the server.
* test/lisp/server-tests.el: New file (bug#58909).
Matt Armstrong [Tue, 15 Nov 2022 18:33:00 +0000 (10:33 -0800)]
Reduce buffer-tests noisiness when run in batch mode.
* test/src/buffer-tests.el (overlay-modification-hooks): Remove noisy
`message' calls and use `ert-info' to log context of test
failures. (bug#59028)
(overlay-tests-start-recording-modification-hooks): ditto.