F. Jason Park [Sat, 23 Dec 2023 02:18:20 +0000 (18:18 -0800)]
Optionally continue on error in erc-auth-source-search
* doc/misc/erc.texi (auth-source): Add new "Troubleshooting"
subsection.
* lisp/erc/erc.el (erc-open): Initialize markers before determining
session parameters. Otherwise, functions that rely on
`erc-inset-marker' being non-nil, like `erc-check-text-conversion',
may fail during auth-source lookups.
(erc-auth-source-search): When non-interactive, ask the user whether
to continue connecting anyway. (Bug#67978)
F. Jason Park [Wed, 20 Dec 2023 06:33:48 +0000 (22:33 -0800)]
Fix overlapping logs from erc-truncate-buffer-on-save
* lisp/erc/erc-button.el (erc-button--display-error-notice-with-keys):
Currently, internal "error notices" do not have timestamps. However,
this causes alignment issues for non-`fill-wrap' users of left-sided
stamps. The heuristic used by this change for detecting such stamps
is weak and prone to false negatives.
* lisp/erc/erc-log.el (erc-log-mode, erc-log-enable): Set explicit
depth for `erc--pre-clear-functions' to 50.
(erc-save-buffer-in-logs): Fix partial regression in which redundant
text would appear in logs that have undergone truncation via an
interactive call to this command when the deprecated option
`erc-truncate-on-save' is non-nil.
* lisp/erc/erc-stamp.el (erc-stamp-mode, erc-stamp-enable): Set
depth for `erc--pre-clear-functions' to 40.
(erc-stamp--reset-on-clear): Only add `erc-stamp--insert-date-hook'
when `erc-stamp--date-mode' is active.
* lisp/erc/erc.el (erc-cmd-CLEAR): Rework to honor but improve upon
the old behavior when called from lisp. Do this by attempting to find
the beginning of the current message and excluding it from the
truncated portion of the buffer. A NEWS entry describing this
behavior already exists for 5.6.
* test/lisp/erc/erc-scenarios-log.el
(erc-scenarios-log--save-buffer-in-logs/truncate-on-save): New test.
These changes originate from bug#60936.
F. Jason Park [Tue, 19 Dec 2023 04:50:26 +0000 (20:50 -0800)]
Replace some uses of erc-error
* lisp/erc/erc-button.el
(erc-button--display-error-notice-with-keys-and-warn): Use
`erc--lwarn' so the warnings buffer is overridable for testing.
* lisp/erc/erc-sasl.el (erc-sasl-mode, erc-sasl-enable): Signal an
`error' instead of calling `erc-error', which continues execution. In
this special case, the session cannot continue initializing, since
connection registration can't reasonably be expected to complete
successfully.
(erc-sasl--destroy): Don't run `erc-quit-hook', and issue a warning of
level `:error' to get users' attention instead of calling `ding'.
* lisp/erc/erc-speedbar.el
(erc-speedbar--emulate-sidebar-set-window-preserve-size): Don't set
window parameters. Doing this basically made
`erc-speedbar-toggle-nicknames-window-lock' unusable.
(erc-speedbar--toggle-nicknames-sidebar): Manually unlock the window
after toggling.
(erc-nickbar-mode, erc-nickbar-enable, erc-nickbar-disable): Don't
`ding' when called in a non-ERC buffer, and make sure to call
`erc-speedbar--ensure' from an ERC buffer. Also, don't disable
minor-mode var when speedbar buffer doesn't exist because that doesn't
ensure it'll be created the next time around, and users may count on
the activation state remaining consistent.
(erc-speedbar-toggle-nicknames-window-lock): Make usable from lisp
with explicit numeric arg.
* lisp/erc/erc-status-sidebar.el (erc-bufbar-mode, erc-bufbar-enable):
Only create the side window from an erc-mode buffer to ensure the
ratio is preserved when burying the current buffer, e.g., with
`custom-buffer-done'.
* lisp/erc/erc.el (erc--warnings-buffer-name, erc--lwarn): New
function, an analog of `lwarn', that allows for overriding the
warnings buffer with the new variable `erc--warnings-buffer-name'.
(erc-cmd-SERVER): Add comment.
* test/lisp/erc/erc-scenarios-sasl.el
(erc-scenarios-sasl--plain-fail): Expect warning instead of error.
* test/lisp/erc/erc-scenarios-status-sidebar.el
(erc-scenarios-status-sidebar--bufbar): Refresh when interactive as
well.
* test/lisp/erc/resources/sasl/plain-failed.eld: Expect EOF instead of
"CAP END". (Bug#63595)
F. Jason Park [Mon, 18 Dec 2023 05:49:13 +0000 (21:49 -0800)]
Populate erc--msg-prop-overrides for CTCP replies
* lisp/erc/erc-backend.el (erc-server-PRIVMSG): Don't set string
intended for insertion to the undefined return value of
`erc-process-ctcp-reply' and `erc-process-ctcp-query'. Rework control
flow slightly for clarity.
* lisp/erc/erc.el (erc-process-ctcp-reply): Bind
`erc--msg-prop-overrides' and populate with `erc--ctcp' and `erc--cmd'
"msg props" for the benefit of `erc-display-message' calls made by
the various CTCP reply handlers. (Bug#67677)
F. Jason Park [Tue, 19 Dec 2023 03:38:30 +0000 (19:38 -0800)]
; Fix some doc strings in ERC
* lisp/erc/erc-networks.el: Lose some unneeded forward declarations.
* lisp/erc/erc.el (erc-open-socks-tls-stream): Don't conflate SOCKS
with TOR by mentioning a ".onion" address for the `host' parameter.
* test/lisp/erc/erc-tests.el
(erc--check-prompt-input-for-multiline-blanks): Extend timeout.
Visuwesh [Tue, 12 Dec 2023 15:44:12 +0000 (21:14 +0530)]
Make ffap correctly guess remote file names at point
* lisp/ffap.el (ffap-lax-url): Set it to nil so that remote file
names may be matched.
(ffap-fixup-email): New function.
(ffap-guesser): Specially handle email addresses now that
'ffap-lax-url' is nil, as user@host fails to be matched as an
email address with that setting. (Bug#67688)
* etc/NEWS: Announce the new value of the defcustom.
Denis Zubarev [Sat, 11 Nov 2023 22:42:42 +0000 (01:42 +0300)]
Fix treesit test (bug#67117)
* test/src/treesit-tests.el (treesit-search-subtree-forward-1):
(treesit-search-subtree-backward-1): Replace treesit--thing-at with
treesit-query-capture (treesit--thing-at isn't available in Emacs 29).
Stefan Monnier [Sat, 23 Dec 2023 05:25:46 +0000 (00:25 -0500)]
Split safe_call between redisplay and non-redisplay versions
The `safe_call/eval` family of functions started its life in `xdisp.c`
for the needs of redisplay but quickly became popular outside of it.
This is not ideal because despite their name, they are somewhat
specific to the needs of redisplay.
So we split them into `safe_call/eval` (in `eval.c`) and `dsafe_call/eval`
(in `xdisp.c`). We took this opportunity to slightly change their
calling convention to be friendly to the CALLN-style macros.
While at it, we introduce a new `calln` macro as well which does
all that `call[1-8]` used to do.
* src/eval.c (safe_eval_handler, safe_funcall, safe_eval): New functions,
Copied from `xdisp.c`. Don't obey `inhibit_eval_during_redisplay` any more.
Adjust error message to not claim it happened during redisplay.
* src/lisp.h (calln): New macro.
(call1, call2, call3, call4, call5, call6, call7, call8): Turn them
into aliases of `calln`.
(safe_funcall): Declare.
(safe_calln): New macro.
(safe_call1, safe_call2): Redefine as compatibility macros.
(safe_call, safe_call1, safe_call2): Delete.
Replace all callers with calls to `safe_calln`.
* src/xdisp.c (dsafe_eval_handler): Rename from `safe_eval_handler`.
Adjust all users.
(dsafe__call): Rename from `safe_call` and change calling convention to
work with something like CALLMANY. Adjust all users.
(safe_call, safe__call1, safe_call2): Delete functions.
(SAFE_CALLMANY, dsafe_calln): New macros.
(dsafe_call1, dsafe_eval): Rename from `safe_call1` and `safe_eval`,
and rewrite using them. Adjust all users.
(clear_message, prepare_menu_bars, redisplay_window): Use `dsafe_calln`.
(run_window_scroll_functions): Don't let-bind `Qinhibit_quit`
since `safe_run_hooks_2` does it for us.
Po Lu [Sat, 23 Dec 2023 03:22:21 +0000 (11:22 +0800)]
Respect glyph metrics modified by instruction code
* src/sfnt.c (sfnt_read_glyph): Clear advance and origin
distortion returning an empty glyph.
(sfnt_build_instructed_outline): New parameter *ADVANCE_WIDTH,
in which the glyph's advance width is saved.
(sfnt_interpret_compound_glyph_1): Refine commentary.
(sfnt_verbose, main): Adjust tests.
* src/sfnt.h: Update prototypes correspondingly.
* src/sfntfont.c (sfntfont_get_glyph_outline): If an instructed
outline is available, derive the advance and lbearing from the
measurements within.
(sfntfont_probe_widths): Call sfntfont_measure_pcm to establish
average widths.
(sfntfont_open): Do so after instruction code initialization
completes.
(sfntfont_measure_pcm): Revise commentary.
Stefan Kangas [Sat, 23 Dec 2023 00:50:18 +0000 (01:50 +0100)]
Drop footer line warning for packages requiring Emacs 30.1
The reason for warning about a missing footer line (";;; foo.el ends
here") is that package.el up until version 27.1 would refuse to
install a package without it. Emacs 27.1 or later will install such
packages, but will issue a warning, the purpose of which is to
encourage package authors not to break backwards-compatibility.
However, if the minimum required Emacs version for a package is 30.1,
we do not need to worry about compatibility with earlier versions of
Emacs -- the package author has already explicitly said that the
package will not work on earlier versions. For such packages, there
is no need to warn about a missing footer line.
In the future, this warning could be removed, but it is premature to
do that now. (See Bug#26490.) Thus, for packages that does not
specify a minimum version of Emacs, we continue to issue the warning.
We will also continue to warn for packages requiring Emacs 27 to 29,
since those versions will themselves warn if the footer is missing.
* lisp/emacs-lisp/package.el (package-buffer-info): Don't warn if the
footer line is missing for packages requiring Emacs 30.1 or later.
Stefan Kangas [Fri, 22 Dec 2023 22:41:36 +0000 (23:41 +0100)]
Introduce new function lm-package-requires
* lisp/emacs-lisp/package.el (package--prepare-dependencies): Move
from here...
* lisp/emacs-lisp/lisp-mnt.el (lm--prepare-package-dependencies):
...to here.
(lm-package-requires): New function.
(package-buffer-info): Use above new function.
* test/lisp/emacs-lisp/lisp-mnt-tests.el
(lm--tests-lm-package-requires): New test.
Stefan Kangas [Fri, 22 Dec 2023 21:36:37 +0000 (22:36 +0100)]
Recommend customizing eglot for python-base-mode
* doc/misc/eglot.texi (Project-specific configuration): Recommend
setting directory local variables for 'python-base-mode' instead of
'python-mode'. This makes any customizations effective also for
'python-ts-mode'.
Michael Albinus [Fri, 22 Dec 2023 18:58:32 +0000 (19:58 +0100)]
Tramp's direct asynchronous processes use 'tramp-remote-path'
* doc/misc/tramp.texi (Remote processes): Remove item about
tramp-remote-path.
* etc/NEWS: Direct asynchronous processes use 'tramp-remote-path'.
* lisp/net/tramp-sh.el (tramp-get-remote-pipe-buf): New defun.
(tramp-set-remote-path): Use it.
(tramp-get-remote-path): Add ;;;###tramp-autoload cookie.
* lisp/net/tramp.el (tramp-handle-make-process):
Use `tramp-remote-path' for setting PATH environment.
* test/lisp/net/tramp-tests.el (tramp-test35-exec-path-direct-async)
(tramp-test35-remote-path-direct-async): New tests.
* src/eval.c (funcall_subr): Help the compiler by reducing aliasing
problems, and compensate for a missed-optimisation bug in LLVM where
switches sometimes forget to use variable range information (reported
in https://github.com/llvm/llvm-project/issues/76085).
Ensure proper mode of *Compile-Log* buffer (bug#67920)
Reported by OGAWA Hirofumi.
* lisp/emacs-lisp/bytecomp.el (displaying-byte-compile-warnings):
Move most of the innards to...
(bytecomp--displaying-warnings): ...this new function, for ease
of maintenance.
* lisp/emacs-lisp/bytecomp.el (byte-compile-file):
Wrap early warning about missing lexbind declaration in
`displaying-byte-compile-warnings` so that it doesn't cause the
creation of a compile-log buffer with the wrong mode.
* lisp/emacs-lisp/bytecomp.el (byte-compile-toplevel-file-form)
(byte-compile-form):
* lisp/emacs-lisp/macroexp.el (macroexp--expand-all):
Use `macroexp--with-extended-form-stack` instead of explicit
push and pop.
Po Lu [Fri, 22 Dec 2023 02:25:36 +0000 (10:25 +0800)]
Properly instruct compound glyphs with compound components
* src/sfnt.c (sfnt_interpret_compound_glyph_2): Don't grow the
compound decomposition context for saving compound points into,
since the space for them already exists.
Stefan Monnier [Thu, 21 Dec 2023 15:24:29 +0000 (10:24 -0500)]
doc/lispintro: Don't mention `set` (bug#67734)
* doc/lispintro/emacs-lisp-intro.texi (Using set): Delete.
(Using setq): Adjust accordingly.
(setq): Rename from "set & setq" and don't refer to `set` any more.
(Review): Don't mention `set` any more.
Po Lu [Thu, 21 Dec 2023 08:31:30 +0000 (16:31 +0800)]
Implement an undocumented TrueType "feature"
* src/sfnt.c (sfnt_move): Correct commentary.
(sfnt_interpret_control_value_program): Reset dual projection,
freedom and projection vectors, in addition to the reference
points, zone pointers and loop counter.
João Távora [Wed, 20 Dec 2023 18:11:53 +0000 (12:11 -0600)]
trace.el: use cl-print
Any non-trivial EIEO object in particular is impossible to read in the
*trace-output* buffer without this. Functions, hash-tables, etc now
print as they do in backtrace buffers.
* lisp/emacs-lisp/trace.el (cl-print): Require it
(trace-entry-message, trace-exit-message): Use cl-prin1-to-string
Matto Fransen [Tue, 19 Dec 2023 12:14:33 +0000 (13:14 +0100)]
Specific rcirc log file time stamp format
The time stamp format in the chat buffer may now
differ from the format in the log files.
* doc/misc/rcirc.texi: Document new variable
* lisp/net/rcirc.el (rcirc-log-time-format):
Custom variable for the format. (bug#67597)
Now with have :noconfirm no need to check for '(set modify) otherwise
we fail as well in kmacros when register-use-preview is t.
The conditions should not be hard coded in
register-read-with-preview-fancy but in the cl-defmethod
register-command-info for each command.
* lisp/register.el (register-read-with-preview-fancy): Remove now
unneeded condition.
Stefan Monnier [Mon, 18 Dec 2023 06:11:42 +0000 (07:11 +0100)]
Fix issue with register commands in kmacro
Using post-command-hook in minibuffer-setup-hook instead of a timer
allow running exit-minibuffer without delay and ensure the serie of
commands used in a kmacro run synchronously.
* lisp/register.el (register-read-with-preview-fancy): Do it.
It is now the default with a value of register-use-preview eq to
basic.
To change this one have now to customize register-use-preview to
another value.
* lisp/register.el (register-preview-delay): Remove obsolescence.
(register--read-with-preview-function): New.
(register-use-preview): New option basic, it is now the default.
(register-preview-default-1): New the register-preview-default used by
`register-read-with-preview-fancy`.
(register-preview-default): Restored (same as Emacs-29).
(register--preview-function): Generic fn that return the right
function for register--preview-function.
(register-preview): Restored (same behavior as Emacs-29).
(register-preview-1): Used by `register-read-with-preview-fancy'.
(register-read-with-preview-basic): The old
register-read-with-preview.
(register-read-with-preview-fancy): The new
register-read-with-preview.
Don't confirm with RET even when overwriting in register commands
This happen when register-use-preview is nil or never.
This reproduce what we had previously in 29.1 but with filtering in
the preview and default registers are provided for the commands of
type 'set'.
This is implemented with cl-defmethod to keep the code as much as
possible configurable.
* lisp/register.el (register-preview-info): New slot.
(register-command-info): Add new methods for copy-to-register,
point-to-register, number-to-register,
window-configuration-to-register, frameset-to-register and
copy-rectangle-to-register.
(register-read-with-preview): Bind noconfirm.
Dmitry Gutov [Wed, 20 Dec 2023 15:34:12 +0000 (17:34 +0200)]
project--read-file-cpd-relative: Don't abbreviate at all
* lisp/progmodes/project.el (project--read-file-cpd-relative):
Don't abbreviate at all, only suffixes are shown anyway.
And expand-file-name is slightly faster.
Dmitry Gutov [Wed, 20 Dec 2023 15:20:26 +0000 (17:20 +0200)]
Fix project-find-file history (with project--read-file-cpd-relative)
* lisp/progmodes/project.el (project--transplant-file-name):
Don't abbreviate here (bug#67901, bug#63829).
(project--read-file-cpd-relative): Do it here instead. The reader
functions should decide on the preferred format themselves.
Dmitry Gutov [Tue, 19 Dec 2023 22:22:47 +0000 (00:22 +0200)]
Add "back" button on top of the pre-rename vc-print-log buffer
* lisp/vc/vc.el (log-view-vc-prev-revision)
(log-view-vc-prev-fileset): New dynamic variables (bug#55871).
(vc-print-log-renamed-add-button): Extract from
'vc-print-log-setup-buttons'. Bind the above variables to convey
the current revision and fileset to 'vc-print-log-internal'.
(vc-print-log-internal): Use it also here, to print a "back"
button above the log when 'log-view-vc-prev-fileset' is set.
Calc: speed up math-read-preprocess-string (bug#67536)
`math-read-preprocess-string` is one of the bottlenecks of `calc-eval`
and was unnecessarily slow even with no substitutions made.
This affected org-mode in particular, where `calc-eval` is called
repeatedly to recalculate tables.
Reported by Raffael Stocker who also wrote the unit tests here.
* lisp/calc/calc-aent.el (math--read-preprocess-re-cache): New.
(math-read-preprocess-string):
Use math--read-preprocess-re-cache, first computing it if necessary.
* test/lisp/calc/calc-tests.el (calc-math-read-preprocess-string):
New test.
Po Lu [Tue, 19 Dec 2023 08:42:38 +0000 (16:42 +0800)]
Improve efficiency of operations involving font interpreter scale
* src/sfnt.c (sfnt_mul_f26dot6_fixed): Correct rounding
constant.
(sfnt_make_interpreter, SSW, WCVTF, sfnt_compute_phantom_points)
(sfnt_interpret_simple_glyph, sfnt_interpret_compound_glyph_1)
(sfnt_vary_interpreter, sfnt_check_ssw): Account for the
fractional bits in a f26dot6 when computing the interpreter
scale factor.
Po Lu [Tue, 19 Dec 2023 05:41:16 +0000 (13:41 +0800)]
Further corrections to font scaling
* src/sfnt.c (sfnt_dot_fix_14): Correct typo in final division.
(sfnt_compute_phantom_points): New parameters S1 and S2, into
which unrounded phantom point coordinates are saved.
(sfnt_interpret_simple_glyph, sfnt_interpret_compound_glyph_2)
(sfnt_interpret_compound_glyph_1): Adjust correspondingly.
Denis Zubarev [Sat, 11 Nov 2023 22:42:42 +0000 (01:42 +0300)]
Fix an issue when searching subtree backward (bug#67117)
* src/treesit.c (treesit_traverse_child_helper):
Do not call treesit_traverse_sibling_helper when the named node is
required and the last child is the named node.
Otherwise treesit_traverse_sibling_helper will move cursor to the
previous sibling and last node will be skipped.
* test/src/treesit-tests.el (treesit-search-subtree-forward-1):
(treesit-search-subtree-backward-1):
Add tests.
Stefan Monnier [Mon, 18 Dec 2023 22:42:37 +0000 (17:42 -0500)]
debug.el: Straighten the code that find the "base" of the backtrace
Let the caller tell us clearly where is the base of the backtrace,
if it's not `debug`. This is done by passing a new `:backtrace-base`
keyword argument to `debug`.
Then use this info systematically in all the places where we access
the real C-level backtrace, to try and avoid inconsistencies and brittle
code that tries to enumerate the expected frames we're in.
* src/eval.c (get_backtrace_starting_at): Add support for offsets in the
`base` argument.
(Fbacktrace_debug): Add optional `base` argument.
* lisp/emacs-lisp/debug.el (debug, debugger-frame, debugger-frame-clear):
Use `debugger--backtrace-base` when calling `backtrace-debug`.
(debugger-setup-buffer): Use `debugger--backtrace-base`
when calling `backtrace-get-frames`.
(debugger-frame-number): Drop `skip-base` arg, assume it's never nil.
Add sanity check.
(debugger--backtrace-base): Use the `:backtrace-base` info
in `debugger-args`.
(debugger-eval-expression): Adjust call to `debugger-frame-number`.
(debug--implement-debug-on-entry): Pass appropriate `:backtrace-base`.
Po Lu [Mon, 18 Dec 2023 14:14:22 +0000 (22:14 +0800)]
Further fixes for problems uncovered by the previous fix
* src/sfnt.c (sfnt_deltap): Enable deltap instructions again,
since they now serve a purpose.
(sfnt_compute_phantom_points): Round phantom points to match the
behavior of other TrueType scalers.
F. Jason Park [Tue, 12 Dec 2023 04:24:17 +0000 (20:24 -0800)]
Add erc-track integration to erc-nicks
* lisp/erc/erc-button.el (erc-button--nick): Add `face-cache' slot.
(erc-button-add-nickname-buttons): Pass `erc-button--nick' object, if
created', as the boolean NICK-P parameter when calling
`erc-button-add-button'. Keeping the latter function ignorant of
`erc-button--nick' is of course preferable, but some coordination is
now required to convey and use the "face cache". We can introduce an
abstraction, like a local variable, if this becomes an issue.
(erc-button-add-button): Use `erc--merge-prop' instead of
`erc-button-add-face' to apply button faces. Hold off on deprecating
the latter because it provides unique functionality for nesting faces.
Also, consult NICK-P if it's an `erc-button--nick' object for the
various overriding faces it knows about.
* lisp/erc/erc-nicks.el (erc-nicks-track-faces): New option.
(erc-nicks--get-face): Make generated face `:inherit' from
`erc-nicks-backing-face'.
(erc-nicks--highlight): Just return the generated face instead of
combining it with `erc-nicks-backing-face'.
(erc-nicks--highlight-button): Set the `face-cache' slot of the
`erc-button--nick' object when `track' is loaded and initialized.
(erc-nicks-mode, erc-nicks-enable, erc-nicks-disable): Add and remove
`track' integration.
(erc-nicks--reject-uninterned-faces): New function to remove faces
created by `nicks' from buttonized speakers and mentions. Conform
to `erc-track--face-reject-function' interface.
(erc-nicks--ourps, erc-nicks--check-normals): New function and helper
for `erc-track--alt-normals-function' interface.
(erc-nicks--setup-track-integration): New function.
(erc-nicks--remember-face-for-track): New function to cache
nick faces owned by this module.
* lisp/erc/erc.el (erc--merge-prop): Add new optional parameter
`cache-fn', and when non-nil, call it, assigning the returned value to
that of the merged property.
* test/lisp/erc/erc-nicks-tests.el (erc-nicks-list-faces): Skip
the "Inherit: " button. (Bug#67767)
F. Jason Park [Mon, 13 Jun 2022 07:26:22 +0000 (00:26 -0700)]
Cache shortened channel names in erc-track
* lisp/erc/erc-track.el (erc-track--shortened-names): New variable to
stash both the latest inputs and most recent result of
`erc-track-shorten-function'.
(erc-track--shortened-names-current-hash,
erc-track--shortened-names-set, erc-track--shortened-names-get): New
pair of generalized-variable functions and helper variable for
accessing and mutating `erc-track--shorten-prefixes'.
(erc-modified-channels-display): Avoid redundant calls to
`erc-track-shorten-function'. Mainly for use during batch processing.
* test/lisp/erc/erc-track-tests.el (erc-track--shortened-names): New
test. (Bug#67767)
F. Jason Park [Sun, 10 Dec 2023 13:33:48 +0000 (05:33 -0800)]
Promote "normal" faces in erc-track
* etc/ERC-NEWS: Add entry for new behavior involving the option
`erc-track-faces-normal-list'.
* lisp/erc/erc-button.el (erc-button-nick-default-face): New face to
serve as default for `erc-button-nickname-face'.
(erc-button-nickname-face): Change default value to
`erc-button-nick-default-face'.
* lisp/erc/erc-track.el (erc-track--massage-nick-button-faces): New
function to serve as Custom :set function for priority and "normal"
face-list options.
(erc-track-faces-normal-list): Fix Custom :type by loading
`erc-button' during validation so Customize chooses the correct UI
instead of a generic form field with "(mismatch)" printed alongside
the "STATE" button.
(erc-track-faces-priority-list, erc-track-faces-normal-list): Remove
values for "buttonized" `match' module faces that, if retained, would
need updating to feature `erc-button-nick-default-face' instead of
`erc-nick-default-face'. However, as noted in the NEWS entry, this
ordering of button face atop match face is not possible. Use :set
function to massage saved user values.
(erc-track-ignore-normal-contenders-p): New compatibility switch to
access pre-5.6 behavior, in which faces in
`erc-track-faces-normal-list' were only considered for promotion to
the mode line if the current face occupying that pole position wasn't
present.
(erc-track-mode, erc-track-enable, erc-track-disable): Add comments
regarding perceived futility of hooking on `erc-server-001-functions'
and likely unneeded hook removal. Run common buffer-local setup and
teardown.
(erc-track--normal-faces): New local variable, a snapshot of
`erc-track-faces-normal-list'.
(erc-track--setup): New function to stash
`erc-track-faces-normal-list' on init.
(erc-track-select-mode-line-face): Offer alternate explanation of
certain particulars in doc string.
(erc-track--alt-normals-function): New function-valued variable to
allow other modules to intervene in deciding whether to pursue and
promote a "normal" contending face.
(erc-track--select-mode-line-face): New function similar to its public
namesake except that it considers other viable candidates among the
"normal" alternatives.
(erc-track-modified-channels): Only run face selection portion when
faces are actually found. Use `erc-track--select-mode-line-face'
instead of `erc-track-select-mode-line-face'.
* test/lisp/erc/erc-track-tests.el
(erc-track-select-mode-line-face): New test.
(erc-track-tests--select-mode-line-face): New fixture function.
(erc-track--select-mode-line-face): New test. (Bug#67767)
F. Jason Park [Wed, 13 Dec 2023 03:06:52 +0000 (19:06 -0800)]
Forgo excess nick buttonizing on JOINs and QUITs
* etc/ERC-NEWS: Mention nick-button deduping.
* lisp/erc/erc-button.el (erc-button-highlight-nick-once): New
variable to specify commands and numerics for messages that ERC should
forgo redundant buttonizing atop, assuming the presence of a
"userhost".
(erc-button--fallback-cmem-function): Change default value to
`erc-button--get-user-from-spkr-prop'.
(erc-button--get-user-from-spkr-prop): New function to derive user
object from `erc--spkr' "msg prop". The point is to allow
`erc-speaker-from-channel-member-function' to return a display name
that differs from the speaker's actual nick as recorded by its
`erc-server-user' object.
(erc-button--get-phantom-cmem): Add `count' parameter.
(erc-button-add-nickname-buttons): Stop after first turn if the
current command appears in `erc-button-highlight-nick-once'. Pass
iteration count to `erc-button--fallback-cmem-function'. (Bug#67677)
F. Jason Park [Sun, 30 Apr 2023 15:09:29 +0000 (08:09 -0700)]
Rename erc-channel-users to erc-channel-members
* etc/ERC-NEWS: Mention name change.
* lisp/erc/erc-backend.el (erc-process-sentinel): Don't create an
empty `erc-channel-users' hash table in server buffers. This is
arguably a bug fix as well as a minor breaking change.
* lisp/erc/erc-common.el (erc-get-channel-user,
erc-get-channel-member): Rename and alias former to latter.
* lisp/erc/erc.el (erc-channel-users, erc-channel-members): Rename
former to latter. The old name invited much confusion because the
table's values are not mere `erc-channel-user' instances but cons
cells that include them and their corresponding server users.
F. Jason Park [Sun, 30 Apr 2023 14:45:01 +0000 (07:45 -0700)]
Consolidate status-prefix slots of erc-channel-user
* etc/ERC-NEWS: Mention change even though the API remains
undisturbed.
* lisp/erc/erc-common.el (erc-channel-user): "Encode" status prefix
slots `voice', `halfop', `op', `admin', and `owner' as single `status'
slot. Add backward-compatible constructor. Although the old layout
was overly sparse, since the vast majority of users have no membership
status at all, the point here is not to trade time for space but
rather to improve human readability of ERC buffer substrings
containing text props that reference `erc-channel-user' objects.
* lisp/erc/erc.el (erc--define-channel-user-status-compat-getter):
Helper macro for declaring compat-oriented "getters" for status-prefix
slots of `erc-channel-user'.
(erc-channel-user-voice, erc-channel-user-halfop, erc-channel-user-op,
erc-channel-user-admin, erc-channel-user-owner): Add compat getters.
These are not new functions. They were previously defined by the
`erc-channel-user' `cl-defstruct' in erc-common.el.
(erc--update-cusr-status-if-changed): New helper macro to make
`erc-update-current-channel-member' more readable.
(erc-update-current-channel-member): Collapse some overly verbose
"unrolled" forms using helper macro and more compact expressions.
* test/lisp/erc/erc-tests.el (erc-channel-user): New test.
F. Jason Park [Thu, 14 Dec 2023 06:45:06 +0000 (22:45 -0800)]
Demote erc-fill-line-spacing to a normal variable
* etc/ERC-NEWS: Remove section from 5.6 announcing user option
`erc-fill-line-spacing'.
* lisp/erc/erc-fill.el (erc-fill-line-spacing): Change from an option
to a variable and note unfortunate UX hiccups.
(erc-fill-wrap-merge, erc-fill-wrap-merge-indicator, fill-wrap):
Remove mention of the option, now variable, `erc-fill-line-spacing'.
(Bug#60936)
F. Jason Park [Mon, 27 Nov 2023 02:24:48 +0000 (18:24 -0800)]
Use templates for formatting chat messages in ERC
* doc/misc/erc.texi: Replace option `erc-format-nick-function' with
`erc-show-speaker-membership-status'.
* etc/ERC-NEWS: Mention shift to template-based speaker formatting.
Also mention in-buffer STATUSMSG support and various name changes and
new formatting-related options.
* lisp/erc/erc-backend.el (erc-format-privmessage): Remove forward
declaration.
(erc--determine-speaker-message-format-args): Add forward declaration.
(erc--statusmsg-target): New utility function for detecting whether
the current target is status-prefixed.
(erc-current-message-catalog): Move here from lisp/erc/erc.el.
(erc--message-speaker-catalog): New variable.
(erc--speaker-status-prefix-wanted-p): New variable specifically for
the function `erc-format-@nick' to signal it wants status-prefixes
prepended to the displayed nick.
(erc-server-PRIVMSG): Initialize `let'-bound value of
`erc--msg-prop-overrides' to a dummy `erc--tmp' property with a null
value that `erc-display-message' will "strip" before calling its
hooks. Move away from the rather blunt symbol `msg' as a useful value
for `erc--msg'. Instead, allow `erc-display-message' to assign the
most appropriate value based on context. Also, bind the variable
`erc-current-message-catalog' to whatever the buffer's
`erc--message-speaker-catalog' happens to be. Future internal modules
can set this to alternative catalogs as needed. Additionally, detect
STATUSMSG prefixes on targets and inform the formatting logic of the
verdict. Lastly, and most importantly, use the function
`erc--determine-speaker-message-format-args' instead of
`erc-format-privmessage' for message formatting. Pass along the
returned "catalog key" and spec parameters to `erc-display-message'.
However, for NOTICEs, continue to render the string, as before, for
the two "echo notice" hooks.
* lisp/erc/erc-common.el (erc--ctcp-response): New "subsclass" of
`erc-response' for smuggling extra information to CTCP query handlers
in a mostly backwards-compatible way. The same approach could be
taken with the "echo notice" hooks mentioned above.
* lisp/erc/erc-dcc.el (erc-dcc-chat-filter): Add `erc--spkr' and
`erc--speaker' properties even though these chat buffers are not
`erc-mode' buffers.
* lisp/erc/erc-fill.el (erc-fill--wrap-last-msg,
erc-fill--wrap-max-lull): Add doc strings.
(erc-fill--wrap-continued-message-p): Rework to look for `erc--spkr'-
`erc--msg' combinations as indicators of speaker continuity.
(erc-fill--wrap-rejigger-region): Remove reference to the no longer
relevant `erc-stamp-type'. Instead, use the `erc--msg' property
combined with the `erc-timestamp' field to detect date stamps because
all are currently left-sided.
* lisp/erc/erc-stamp.el (erc-stamp--propertize-left-date-stamp): Don't
add superfluous `erc-stamp-type' property.
* lisp/erc/erc.el (erc--msg-props): Revise purpose and meaning of
`erc--msg' by removing possible value `msg', which was previously
meant to indicate that a message had a "speaker". Instead, rely on
the separate `erc--spkr' property to convey this information, with
`erc--msg' now expressing a "type" or "role".
(erc--use-language-catalog-for-ctcp-action-p): New variable, a
compatibility switch to help transition from the `ACTION' entry of the
language catalog to the `ctcp-action' family of entries in the new
`-speaker' catalog.
(erc--ensure-spkr-prop): Update to include any passed-in environmental
overrides.
(erc--send-action-display): Restore pre-5.6 behavior when
compatibility flag enabled. Otherwise, use new `-speaker' catalog for
formatting inserted message.
(erc--send-message-external): Overhaul to behave more faithfully in
mimicking a line submitted at the prompt of the current target buffer.
(erc--own-property-names): Remove `erc-stamp-type'.
(erc-ensure-target-buffer-on-privmsg): Add new choice variant for old
default behavior and change meaning of default to mean "except for
STATUSMSGs". This option is newly revived for ERC 5.6.
(erc--message-speaker-statusmsg, erc--message-speaker-statusmsg-input,
erc--message-speaker-input, erc--message-speaker-input-chan-privmsg,
erc--message-speaker-input-chan-notice,
erc--message-speaker-input-query-privmsg,
erc--message-speaker-input-query-notice,
erc--message-speaker-chan-privmsg, erc--message-speaker-query-privmsg,
erc--message-speaker-chan-notice, erc--message-speaker-query-notice,
erc--message-speaker-ctcp-action,
erc--message-speaker-ctcp-action-input,
erc--message-speaker-ctcp-action-statusmsg,
erc--message-speaker-ctcp-action-statusmsg-input): New variables for
new `speaker' format-template catalog.
(erc--speakerize-nick): New helper function.
(erc--determine-speaker-message-format-args): New function to find the
appropriate format key from various contextual parameters. Could
become the default of a function-valued variable for internal use.
(erc-show-speaker-membership-status): New option.
(erc-format-nick-function, erc-speaker-from-channel-member-function):
Declare former as an obsolete alias for the latter, and redefine
purpose slightly.
(erc-format-nick-function, erc-determine-speaker-from-user): Rename
former to latter and obsolete the old name.
(erc-format-nick, erc-determine-speaker-from-user): Rename former to
latter and obsolete old name.
(erc-format-@nick): Deprecate and adapt for use with new
template-based formatting paradigm.
(erc-format-my-nick): Move `erc-speaker' text prop toward head of
list, meaning it will end up beneath `font-lock-face' in the final
output.
(erc--format-speaker-input-message): New function to replace
`erc-format-my-nick' in-tree.
(erc-process-ctcp-query): Don't bind `erc--msg' to `msg'. Instead,
rely on `erc-display-message' to set it to the current template key.
(erc-ctcp-query-ACTION): Prefer using formatting template, but attempt
to simulate pre-5.6 behavior when compatibility flag enabled.
(erc-display-msg): Use `erc--format-speaker-input-message' instead of
`erc-format-my-nick'. Ignore `erc--msg-prop-overrides' with null
values.
(erc-current-message-catalog): Move to erc-backend.el.
* test/lisp/erc/erc-scenarios-base-statusmsg.el: New file.
* test/lisp/erc/erc-scenarios-stamp.el
(erc-scenarios-stamp--left/display-margin-mode): Expect format catalog
key instead of unhelpful `msg' as value of `erc--msg' prop.
* test/lisp/erc/erc-tests.el (erc-message): Render format template in
mock function and expect string in assertions.
(erc-tests--format-privmessage): New function, a helper for the
following test.
(erc-format-privmessage, erc--determine-speaker-message-format-args):
Rename former to latter and suppress deprecation warning.
(erc--determine-speaker-message-format-args/queries,
erc--determine-speaker-message-format-args/queries-as-channel): New
tests.
(erc-tests--format-my-nick): New helper function for the following
test.
(erc--format-speaker-input-message): New test.
* test/lisp/erc/resources/base/display-message/statusmsg.eld: New
file. (Bug#67677)
; * test/lisp/erc/resources/fill/snapshots/merge-wrap-01.eld: Update.
; * test/lisp/erc/resources/fill/snapshots/merge-wrap-indicator-post-01.eld:
; Update.
; * test/lisp/erc/resources/fill/snapshots/merge-wrap-indicator-pre-01.eld:
; Update.
F. Jason Park [Tue, 5 Dec 2023 06:13:02 +0000 (22:13 -0800)]
Add erc--spkr text property to chat messages
* etc/ERC-NEWS: Mention combined face ordering for "/me" messages.
* lisp/erc/erc-backend.el (erc-server-PRIVMSG): Bind
`erc--msg-prop-overrides' for the extent of this function's execution,
which means a large amount of code will see this variable as being
non-nil. However, no calls to `erc-display-message' or
`erc-display-msg' should occur other than the one handling the final
insertion. Code needing to influence the current message's "msg
props" can push new pairs onto this value, which will override any
existing collisions.
* lisp/erc/erc-fill.el (erc-fill): Switch to `erc--spkr' as sentinel
property.
(erc-fill--wrap-continued-message-p): Look for `erc--spkr' property
instead of `erc-speaker'.
* lisp/erc/erc.el (erc--msg-props): Mention `erc--spkr' in doc.
(erc--send-action-perform-ctcp): Add `erc--spkr' property. Fix bug in
which `erc-my-nick-face' appeared below `erc-input-face' in the
speaker portion.
(erc--ensure-spkr-prop): New helper function to propagate speaker
metadata.
(erc--ranked-properties): Add `erc--spkr', `erc--ctcp', and
`erc--ephemeral'.
(erc-display-message): Use default hash table size when initializing.
Remove unnecessary assignment of `msg' to `erc--msg' for PRIVMSG and
NOTICE commands. Bind `string' below `erc--msg-props' so that
implementers of the function form of the `erc-format-message'
templating interface can read and write the current context's "msg
props".
(erc--own-property-names): Add all `erc--msg-props' props by
subsumation.
(erc--get-speaker-bounds): Use `erc--spkr' instead of `erc--msg' as a
sentinel to detect a chat message guaranteed to have an `erc--speaker'
text-property interval.
(erc-format-privmessage, erc-format-my-nick, erc-ctcp-query-ACTION):
Add `erc--spkr' to `erc--msg-prop-overrides' when available.
* test/lisp/erc/erc-fill-tests.el: (erc-fill-tests--insert-privmsg):
Bind `erc--msg-prop-overrides'.
(erc-fill-tests--compare): Require environment variable value to match
current test name exactly when saving snapshots. Add `erc--msg-props'
individually to white list.
* test/lisp/erc/erc-tests.el (erc--order-text-properties-from-hash):
Include `erc--spkr'. (Bug#60936) (Bug#67677)
; * test/lisp/erc/resources/fill/snapshots/merge-01-start.eld: Update.
; * test/lisp/erc/resources/fill/snapshots/merge-02-right.eld: Update.
; * test/lisp/erc/resources/fill/snapshots/merge-wrap-01.eld: Update.
; * test/lisp/erc/resources/fill/snapshots/merge-wrap-indicator-post-01.eld:
; Update.
; * test/lisp/erc/resources/fill/snapshots/merge-wrap-indicator-pre-01.eld:
; Update.
; * test/lisp/erc/resources/fill/snapshots/monospace-01-start.eld: Update.
; * test/lisp/erc/resources/fill/snapshots/monospace-02-right.eld: Update.
; * test/lisp/erc/resources/fill/snapshots/monospace-03-left.eld: Update.
; * test/lisp/erc/resources/fill/snapshots/monospace-04-reset.eld: Update.
; * test/lisp/erc/resources/fill/snapshots/spacing-01-mono.eld: Update.
; * test/lisp/erc/resources/fill/snapshots/stamps-left-01.eld: Update.
F. Jason Park [Tue, 12 Sep 2023 04:21:42 +0000 (21:21 -0700)]
Skip erc-ignored-user-p when erc-ignore-list is empty
* lisp/erc/erc-backend.el (erc-server-PRIVMSG): Don't bother running
`erc-ignored-user-p' and `erc-ignored-reply-p' when their associated
options are null. The option `erc-ignore-list' is buffer-local when
set, and `erc-ignored-user-p' looks for it in the server buffer.
Moreover, all functions that set it, like `erc-cmd-IGNORE' and
`erc-cmd-UNIGNORE', do so in the server buffer. And the response
handler in question only runs in server buffers, so this shouldn't
break anything. Also, remove stray call to reassign trailing response
contents.
* lisp/erc/erc-common.el (erc-get-server-user): Rearrange so
`erc-with-server-buffer' doesn't have to switch to the server buffer
because `erc-downcase' can run in channels as well.
* lisp/erc/erc.el (erc-ignored-user-p): Add comment. (Bug#67677)
F. Jason Park [Tue, 28 Nov 2023 06:53:00 +0000 (22:53 -0800)]
Make erc-get-user-mode-prefix more flexible
* etc/ERC-NEWS: Mention renaming of `erc-get-user-mode-prefix'.
* lisp/erc/erc-speedbar.el (erc-speedbar-insert-user): Use
`erc-get-channel-membership-prefix' so that nicks in the nickbar can
have prefixes beyond just those for "voice" and "op".
* lisp/erc/erc.el (erc-get-user-mode-prefix,
erc-get-channel-membership-prefix): Rename former to latter because
"user mode" suggests the function somehow involves user modes, but it
exclusively concerns channel modes. Also, overload the only parameter
in order to avoid redundantly looking up `erc-channel-user' object
with every predicate call. In the near future, ERC will likely need
to offer an alternate version of this function that returns multiple
prefixes instead of just one.
(erc-format-@nick): Actually use the `channel-data' parameter.
(erc-format-my-nick, erc--format-channel-status-prefix): Use new name
for function `erc-get-user-mode-prefix'. (Bug#63595) (Bug#67677)