Teach term the difference between an unset foreground or
background color and a color that happens to match an existing
color. This way, when we insert text after a color
reset:(e.g. from an SGR0), we insert it without :foreground or
:background (whichever we've reset) face properties, allowing
that inserted text to inherit the colors of the underlying face.
This way, if we change, e.g., the background color of a buffer,
the background color of already-inserted text from the term
child changes along with that of the buffer instead of being
"locked" to whatever the background color of the buffer was at
the time the text was inserted.
This change aligns term.el with other terminal emulators.
Dmitry Gutov [Thu, 3 Oct 2024 01:17:35 +0000 (04:17 +0300)]
Make xref-find-references work in Help buffers outside of projects
* lisp/help-fns.el (xref-backend-references):
New context-dependent override. Don't call project-current and
use elisp-load-path-roots directly (bug#69462).
(help-fns--setup-xref-backend): No need to set
project-vc-external-roots-function then.
Sean Whitton [Wed, 2 Oct 2024 07:23:06 +0000 (15:23 +0800)]
New function shell-command-do-open
* lisp/dired-aux.el (shell-command-do-open): Factor out of
dired-do-open.
(dired-do-open): Call shell-command-do-open.
* etc/NEWS: Announce the new function.
Sean Whitton [Wed, 2 Oct 2024 01:22:52 +0000 (09:22 +0800)]
Move error check from vc-next-action to diff-vc-deduce-fileset
* lisp/vc/diff-mode.el (diff-vc-deduce-fileset): Signal
user-error when the buffer is narrowed.
* lisp/vc/vc.el (vc-next-action): Remove code signalling a
user-error when the buffer is narrowed.
Stefan Kangas [Wed, 2 Oct 2024 00:28:52 +0000 (02:28 +0200)]
Warn about bad defcustom :local keyword at compile time
* lisp/emacs-lisp/bytecomp.el (bytecomp--custom-declare): Warn about
invalid values for the defcustom :local keyword.
* test/lisp/emacs-lisp/bytecomp-tests.el
(bytecomp-test-defcustom-local): New test.
Stefan Kangas [Tue, 1 Oct 2024 23:03:08 +0000 (01:03 +0200)]
New value 'permanent-only' for defcustom :local keyword
* lisp/custom.el (custom-declare-variable): Make the :local keyword
accept the symbol 'permanent-local', meaning that the variable is
permanent but not marked as automatically buffer-local.
(defcustom):
* doc/lispref/customize.texi (Variable Definitions): Document the
above change.
* test/lisp/custom-tests.el
(custom-tests-defcustom-:local-keyword): New test.
Stefan Monnier [Tue, 1 Oct 2024 18:46:06 +0000 (14:46 -0400)]
* lisp/emacs-lisp/package.el (package-isolate): Use `package-activate-all`
`package-initialize` is used to initialize the whole machinery needed
to list/download/install/remove packages, whereas here we only need to use
the installed packages.
Sean Whitton [Mon, 30 Sep 2024 13:08:38 +0000 (21:08 +0800)]
New command diff-delete-other-hunks
* lisp/vc/diff-mode.el (diff-delete-other-hunks): New
command (bug#73387).
(diff-mode-map): Bind the new command to C-c RET n.
(diff-mode-menu): New entry for the new command.
(vc-next-action): Stop, and warn, if the user attempts to commit
a patch from a narrowed buffer (bug#73387).
* doc/emacs/files.texi (Diff Mode):
* etc/NEWS: Document the new command.
oscar [Mon, 23 Sep 2024 21:04:36 +0000 (23:04 +0200)]
Fix redirection of read when _FORTIFY_SOURCE is defined
When _FORTIFY_SOURCE is defined mingw-w64 provides an inline definition
of read in io.h. This makes our previous redirection to sys_read
ineffective. The prototype of sys_read is now required because we don't
touch the prototype of read.
* nt/inc/ms-w32.h (read): Move the redirection after io.h. Add prototype
for sys_read (Bug#73444)
F. Jason Park [Sun, 29 Sep 2024 18:02:48 +0000 (11:02 -0700)]
Remove erc-fill binding for cycling visual movement
* etc/ERC-NEWS: Announce removal of troublesome key binding first
introduced in ERC 5.6 as part of the `erc-fill-wrap' module.
* lisp/erc/erc-fill.el (erc-fill-wrap-mode-map): Remove key binding for
`erc-fill-wrap-cycle-visual-movement'.
* test/lisp/erc/erc-fill-tests.el (erc-fill-wrap-visual-keys--body)
(erc-fill-wrap-visual-keys--prompt): Replace "C-c a" key simulations.
(Bug#73553)
F. Jason Park [Mon, 23 Sep 2024 20:48:19 +0000 (13:48 -0700)]
Skip indentation when gathering faces in erc-track
* lisp/erc/erc-nicks.el (erc-nicks-mode, erc-nicks-enable)
(erc-nicks-disable): Use correct name for `track' module hook.
(erc-nicks--check-normals): Remove falsity from doc string.
* lisp/erc/erc-track.el (erc-make-mode-line-buffer-name): Don't error
when optional COUNT is nil.
(erc-track-modified-channels): Use new name for preferred face-finding
function.
(erc-track--get-faces-in-current-message, erc-track--collect-faces-in):
Rename former to latter to better reflect expanded utility, which now
includes spanning gaps, including newlines and indentation that may be
lacking in face-related properties.
* test/lisp/erc/erc-track-tests.el (erc-track--collect-faces-in): New
test. (Bug#73443)
F. Jason Park [Mon, 9 Sep 2024 22:23:46 +0000 (15:23 -0700)]
Make erc-keep-place-indicator aware of erc-truncate
* etc/ERC-NEWS: Entry mentioning `erc-keep-place-indicator-truncation'.
* lisp/erc/erc-goodies.el (erc-keep-place-indicator-truncation): New
option. Something like this should have accompanied the module's
introduction.
(erc-keep-place-indicator-mode, erc-keep-place-indicator-enable)
(erc-keep-place-indicator-disable): Arrange to take necessary measures
to avoid losing the indicator on `erc--clear-function'. This module was
first introduced by bug#59943.
(erc--keep-place-move-hook): New variable.
(erc--keep-place-indicator-adjust-on-clear): New function.
(erc-keep-place-move): Try to ensure the overlay resides at the
beginning of a message. Run hook `erc--keep-place-move-hook'.
* test/lisp/erc/erc-scenarios-keep-place-indicator-trunc.el: New file.
* test/lisp/erc/erc-scenarios-keep-place-indicator.el
(erc-scenarios-keep-place-indicator--follow): Fix missing test
description. (Bug#72736)
F. Jason Park [Tue, 27 Aug 2024 08:00:04 +0000 (01:00 -0700)]
Redo ERC truncation and /CLEAR hook mechanism
* etc/ERC-NEWS: Mention option `erc-truncate-padding-size'.
* lisp/erc/erc-fill.el (erc-fill-wrap-mode, erc-fill-wrap-enable)
(erc-fill-wrap-disable): Manage membership in the `erc--clear-function'
advice stack for own function that massages a buffer's oldest inserted
message, post truncation.
(erc-fill--wrap-massage-initial-message-post-clear): New function.
* lisp/erc/erc-log.el (erc-log-mode, erc-log-enable): Don't add
`erc-save-buffer-in-logs' to `erc--pre-clear-functions'. Use local
advice around common interface variable instead, as noted below.
(erc-log-disable): Likewise, don't remove `erc-save-buffer-in-logs' from
`erc--pre-clear-functions'.
(erc-log-setup-logging): Add `erc-log--save-on-clear' to
`erc--clear-function'.
(erc-log-disable-logging): Remove `erc-log--save-on-clear' to
`erc-clear-function'.
(erc-save-buffer-in-logs): Abort when `erc--insert-marker' is non-nil.
(erc-log--save-on-clear): New function, a thin wrapper around
`erc-save-buffer-in-logs', adapting it to the `erc--clear-function'
advice interface.
* lisp/erc/erc-stamp.el (erc-stamp-mode, erc-stamp-enable): Don't
add `erc-stamp--reset-on-clear' to `erc--pre-clear-functions'.
(erc-stamp-disable): Don't remove `erc-stamp--reset-on-clear' from
`erc--pre-clear-functions'.
(erc-stamp--find-insertion-point): Account for initial position being
`bobp'.
(erc-stamp--defer-date-insertion-on-post-modify): Accommodate the rare
non-list `erc-insert-post-hook' when shadowing.
(erc-stamp--setup): Add and remove `erc-stamp--reset-on-clear' to and
from `erc--clear-function' advice stack.
(erc-stamp--redo-right-stamp-post-clear): New function.
(erc-stamp--update-saved-position): Remove unused function. This was
originally added along with `erc-stamp--reset-on-clear' as part of
bug#60936.
(erc-stamp--reset-on-clear): Expect end of truncation boundary to be at
`erc-insert-marker'. Rework to use new `erc--clear-function' interface
and run on `erc-timer-hook' instead of `erc-insert-done-hook'.
* lisp/erc/erc-truncate.el (erc-truncate-padding-size): New option to
help tamp down on disruptions when reading scroll back caused by overly
frequent truncation.
(erc-truncate-enable, erc-truncate-disable): Add and remove
`erc-truncate--setup' to and from `erc-mode-hook', and run it when
needed.
(erc-truncate--buffer-size): New variable.
(erc-truncate--setup): New function.
(erc-truncate-buffer-to-size): Guard execution with
`erc-truncate--padding-size' and `erc--inhibit-clear-p'. Reflow for
readability, removing obsolete comments. Call hooks with marker instead
of buffer position, as per the new `erc--clear-function' interface.
(erc-truncate-buffer): Defer execution to `erc-timer-hook' when running
post-insertion via a response handler.
(erc-truncate--inhibit-when-local-and-interactive): New function.
* lisp/erc/erc.el (erc-mode): Add `erc--skip-past-headroom-on-clear'
to `erc--clear-function' in all ERC buffers.
(erc--with-spliced-insertion): Account for marker being `bobp'.
(erc--insert-before-markers-transplanting-hidden): Make more robust by
accommodating initial `point' possibly being `bobp'.
(erc--clear-function): New variable, a function-valued local-advice
interface to replace `erc--pre-clear-functions'.
(erc--pre-clear-functions): Remove unused variable.
(erc--skip-past-headroom-on-clear): New function.
(erc--inhibit-clear-p): New variable.
(erc-cmd-CLEAR): Call hooks with markers instead of position. Signal
`user-error' when `erc--inhbiit-clear-p' is non-nil.
* test/lisp/erc/erc-scenarios-log.el (erc-scenarios-log--clear-stamp)
(erc-scenarios-log--cmd-clear/date-stamps): Rename former to latter,
update assertions, and use common helper.
(erc-scenarios-log--cmd-clear/left-stamps): New test.
(erc-scenarios-log--truncate): Move body to function of the same name,
and update assertions.
(erc-scenarios-log--truncate/left-stamps): New test. (Bug#72736)
F. Jason Park [Wed, 28 Aug 2024 06:05:35 +0000 (23:05 -0700)]
Fix overlooked case in erc--get-inserted-msg-beg-at
* lisp/erc/erc.el (erc--get-inserted-msg-beg-at): Account for the start
of a props header being `bobp' when searching backwards.
(erc--get-inserted-msg-prop): Add optional `point' parameter.
* test/lisp/erc/erc-goodies-tests.el
(erc--get-inserted-msg-beg/truncated/readonly): New test.
* test/lisp/erc/erc-tests.el (erc--get-inserted-msg-beg/truncated): New
test.
* test/lisp/erc/resources/erc-tests-common.el
(erc-tests-common-assert-get-inserted-msg/truncated): New test helper.
(Bug#72736)
F. Jason Park [Mon, 19 Aug 2024 05:58:11 +0000 (22:58 -0700)]
Improve inconsistent handling of ban lists in ERC
* etc/ERC-NEWS: Mention new function `erc-sync-banlist' in new section
for ERC 5.6.1.
* lisp/erc/erc-backend.el (erc-server-MODE): Don't call
`erc-banlist-update'.
* lisp/erc/erc-fill.el (erc--determine-fill-column-function): New
method for `fill' and `fill-wrap' modules.
* lisp/erc/erc-pcomplete.el (pcomplete/erc-mode/BANLIST)
(pcomplete/erc-mode/BL)
(pcomplete/erc-mode/MASSUNBAN, pcomplete/erc-mode/MUB):
New functions.
* lisp/erc/erc.el: Map ERC 5.6.1 to Emacs 31.1 in
`customize-package-emacs-version-alist'.
(erc-channel-banlist): Deprecate practice of using the symbol property
`received-from-server' of as a state flag because it's error-prone and
bleeds into other connections.
(erc--channel-banlist-synchronized-p): New variable to indicate
whether the ban list has been initialized. The presence of a local
binding for `erc-channel-banlist' could probably be used for the same
purpose but would surely require rewriting `erc-cmd-BANLIST' and
`erc-cmd-MASSUNBAN'.
(erc-sync-banlist): New function, announced in ERC-NEWS.
(erc--wrap-banlist-cmd): New function.
(erc-banlist-fill-padding): New variable.
(erc--determine-fill-column-function): New generic function.
(erc-cmd-BANLIST): Move forward declaration of `erc-fill-column' from
top level into function body. Always reset `received-from-server' to
nil. Improve column calculations.
(erc-cmd-MASSUNBAN): Always reset `received-from-server' to nil.
(erc-banlist-finished): Deprecate function unused since 2003.
(erc--banlist-update): New function.
(erc-banlist-update): Deprecate function because its logic is faulty
and it doesn't handle mixed mode letters, like "MODE #foobar
+mb *@127.0.0.1". See https://modern.ircdocs.horse/#mode-message. It
also depends on an obsolete convention regarding the symbol property
`received-from-server' of `erc-channel-banlist'. Basically, this
function used to run upon receipt of any "MODE" command from the
server. However, actual updates to the variable `erc-channel-banlist'
only happened if `received-from-server' was t, which could only be the
case after the user issued a /MASSUNBAN. And that behavior was
determined to be a bug. This mode framework stuff was introduced as
part of bug#67220 for ERC 5.6.
(erc--handle-channel-mode): New function, a method for standard
channel-mode letter "b".
* test/lisp/erc/erc-tests.el (erc--channel-modes)
(erc--channel-modes/graphic-p): Assert contents of
`erc-channel-banlist' updated on "MODE". (Bug#72736)
F. Jason Park [Mon, 19 Aug 2024 06:50:58 +0000 (23:50 -0700)]
Bind current erc-response around all handlers
* lisp/erc/erc-backend.el (erc--parsed-response): New variable to be
the internal version of the ancient `erc-message-parsed', which is
only available during `erc-display-message', and therefore of somewhat
limited utility.
(erc-call-hooks): Bind `erc--parsed-response' to the parsed
`erc-response' object for the duration of its handling. Bind
`erc--msg-prop-overrides' around all hooks to allow response handlers
to influence inserted msg props for any `erc-display-message' calls.
(Bug#72736)
F. Jason Park [Wed, 7 Aug 2024 02:13:51 +0000 (19:13 -0700)]
Store one string per user in erc--spkr msg prop
* lisp/erc/erc.el (erc--msg-props): Mention that the `erc--spkr'
msg-prop value is taken from the `nickname' slot of the user's
`erc-server-users' entry.
(erc--speakerize-nick): Avoid using the provided NICK parameter for
the `erc--spkr' property. Instead, use the version from the
`nickname' slot of its `erc-server-users' item, which is itself an
`erc-server-user' object. These text props were originally introduced
in ERC 5.6 as part of bug#67677.
* test/lisp/erc/erc-tests.el (erc--refresh-prompt)
(erc--check-prompt-input-functions, erc-send-current-line)
(erc--check-prompt-input-for-multiline-blanks)
(erc-send-whitespace-lines): Use more convenient helper utility to
create fake server buffer where possible.
(erc--speakerize-nick): New test.
* test/lisp/erc/resources/erc-tests-common.el
(erc-tests-common-make-server-buf): Don't use ERT temp buffer's name
for dialed server, etc., because it contains unwanted chars.
(erc-tests-common-with-process-input-spy): Defer to each test to set
up its own prompt, etc. (Bug#72736)
Stefan Kangas [Sun, 29 Sep 2024 21:29:54 +0000 (23:29 +0200)]
Try "python" before "python3" in python-mode
Prefer whatever version of Python that "python" might point to; use
"python3" if it doesn't exist. On recent versions of typical GNU/Linux
distributions, "python" either does not exist or it points to Python 3.
In (presumed rare) cases where "python" points to Python 2 instead,
users are now expected to manually customize these variables if they
want to use Python 3.
* lisp/progmodes/python.el (python-interpreter)
(python-shell-interpreter): Prefer "python" to "python3".
This attribute keyword has been non-working in defface for 14 years,
thus warning about it is both safe and decent.
* lisp/emacs-lisp/bytecomp.el (bytecomp--check-cus-face-spec):
Warn and suggest :inverse-video to be used instead.
* test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-test-defface-spec):
Add a test case.
* etc/NEWS: Notify the user.
Sean Allred [Sun, 29 Sep 2024 01:00:32 +0000 (04:00 +0300)]
project--vc-list-files: Use '--sparse' with 'git ls-files'
When dealing with exceptionally large Git repositories, the
performance of `project-find-file` can suffer dramatically as
the list of files is collected for completion. This adds insult
to injury when you consider cases where the developer has
configured the repository to use a sparse checkout where the
vast majority of these files are not even present on disk and
are not valid candidates for completion.
* lisp/progmodes/project.el (project--vc-list-files):
Pass 'sparse' to 'git ls-files' when Git is recent enough.
Filter out file names that end with '/' (bug#73320).
Morgan Willcock [Tue, 24 Sep 2024 19:19:08 +0000 (20:19 +0100)]
Require ert-x for use by 'ert-font-lock-deftest-file'
This fixes a void-function error when 'ert-font-lock-deftest-file'
is called when ert-x has not already been loaded.
* lisp/emacs-lisp/ert-font-lock.el (ert): Require ert-x so that
'ert-resource-file' is available for use within
'ert-font-lock-deftest-file'. (Bug#73254)
Fix php-ts-mode font-lock for latest PHP grammar (bug#73516)
Version 0.23 of the PHP grammar introduced some changes that
affect the font lock.
* lisp/progmodes/php-ts-mode.el
(php-ts-mode--language-source-alist): Update php, html, js and css
grammars version.
(php-ts-mode--parent-html-heuristic): Fix docstring
(php-ts-mode--test-namespace-name-as-prefix-p): New function.
(php-ts-mode--test-namespace-aliasing-clause-p): New function.
(php-ts-mode--test-namespace-use-group-clause-p): New function.
(php-ts-mode--font-lock-settings): Use the new functions.
Stefan Monnier [Fri, 27 Sep 2024 14:35:18 +0000 (10:35 -0400)]
eieio.texi: Fix bug#73505
* doc/misc/eieio.texi (Introduction): Remove "missing features" which
aren't missing any more.
(Generics, Methods): Delete sections.
(Inheritance): Adjust reference accordingly.
(Static Methods): Merge into the parent node.
(Writing Methods): Refer to the ELisp manual for `cl-defmethod/defgeneric`.
Thomas Voss [Wed, 25 Sep 2024 00:17:49 +0000 (02:17 +0200)]
Align columns in which-key with wide characters properly
In the case that a character takes up multple columns (such as
`…' when used as a truncation character), make sure that the
columns are still aligned properly.
* lisp/which-key.el (which-key--pad-column): Use `string-width'
instead of `length'. (Bug#73463)
Use black-on-white by default for doc-view-svg-face.
* lisp/doc-view.el (doc-view-svg-face): Define black on white as
default value instead of using the current theme's values.
* etc/NEWS: Adjust entry for doc-view-svg-face.
etags-regen-file-extensions: Enable for more extensions
* lisp/progmodes/etags-regen.el (etags-regen-file-extensions):
Add more extensions, but remove "a". From the ones recognized by
etags, also omit "t", "ml", "l", "def" and "inc", see
https://lists.gnu.org/archive/html/emacs-devel/2024-09/msg00735.html.
(etags-regen--all-files): Use 'string-match-p' for performance.
Bind 'case-fold-search' to t to match extensions in any case.
Insert correct commit data into VC package descriptions
* lisp/emacs-lisp/package-vc.el (package-vc-commit): Rename
argument from PKG to PKG-DESC.
(package-vc--generate-description-file): Update the "extras"
section of the package description with the revision string at
generation time.
Warn about bad face specs in `defface` at compile time
* lisp/emacs-lisp/bytecomp.el (byte-compile--custom-declare-face):
Byte-compile `defface` forms, or the byte-compile handler won't
be called.
(bytecomp--check-cus-face-spec): New.
(bytecomp--custom-declare): Call it.
* test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-test-defface-spec):
New tests.
Alan Mackenzie [Fri, 27 Sep 2024 13:42:40 +0000 (13:42 +0000)]
CC Mode: Parse C++ lambda functions more correctly
This fixes bug#72695.
* lisp/progmodes/cc-align.el (c-lineup-topmost-intro-cont): Do
not indent further a line following a closing brace of a
requires clause.
* lisp/progmodes/cc-engine.el (c-forward-keyword-clause):
Separate the handling of "any-paren-kwds" into
"type-paren-kwds" and "nontype-paren-kwds", simplifying the
handling of the latter.
(c-forward-primary-expression): Recognize (...) followed by {
as a primary expression.
(c-looking-at-or-maybe-in-bracelist): No longer recognize an
enum list as a brace list. Remove the handling of enum lists.
(c-looking-at-c++-lambda-expression)
(c-backward-over-lambda-expression): New functions.
(c-c++-vsemi-p): Don't recognize the end of requires clauses as
virtual semicolons.
(c-guess-basic-syntax): CASE 5U - new cond arm to recognize
being after a requires clause. These lines now get syntax
topmost-intro-cont rather than topmost-intro, and their anchor
positions are now on the topmost-intro line rather than the
previous topmost-intro-cont.
Throughout the file: simplify handling of
c-fun-name-substitute-key, where there is no need to check for
a following _ character, and introduce c-requires-clause-key
for greater accuracy in parsing, even though both of these are
just "requires".
* lisp/progmodes/cc-fonts.el (c-get-fontification-context):
Tidy up the handling of c-fun-name-substitue-key, as in
cc-engine.el.
* lisp/progmodes/cc-langs.el (c-lambda-spec-kwds)
(c-lambda-spec-key): New lang vars.
(c-fun-name-substitute-key): Now an adorned expression.
(c-requires-clause-kwds, c-requires-clause-key): New lang vars.
Move to start of current header in diff-{file,hunk}-prev
If point was after a file or hunk header, the diff-file-prev and
diff-hunk-prev commands would move to the start of that header.
But if point was *within* the header, they would not move, and
would report "No previous file" or "No previous hunk". This
differs from the behavior of most other movement commands,
e.g. backward-sexp or backward-sentence.
This commit fixes diff-file-prev and diff-hunk-prev, as well as
other easy-mmode-define-navigation BASE-prev commands. Now
these commands move to the start of the containing "thing" just
like other movement commands.
* lisp/emacs-lisp/easy-mmode.el (easy-mmode--prev):
Move to start of current match first. (bug#73172)
* etc/NEWS: Document the behavior change.
Move easy-mmode-define-navigation logic to helper functions
The functions defined by easy-mmode-define-navigation are useful
even if the easy-mmode-define-navigation macro is not used.
Let's take a step towards exposing them by moving them out as
helpers.
This also makes the macro much easier to modify and work on.
* lisp/emacs-lisp/easy-mmode.el (easy-mmode--prev)
(easy-mmode--next): Add (bug#73172).
(easy-mmode-define-navigation): Use easy-mmode--prev and
easy-mmode--next.
Sean Whitton [Tue, 24 Sep 2024 08:38:43 +0000 (09:38 +0100)]
New command diff-revert-and-kill-hunk
* lisp/vc/diff-mode.el (diff-revert-and-kill-hunk): New
command (bug#73407).
(diff-ask-before-revert-and-kill-hunk): New user option.
(diff-apply-buffer): New optional BEG, END and REVERSE
arguments. Return nil if buffers were saved, or the number of
failed applications.
(diff-mode-map): Bind the new command to C-c M-r.
(diff-mode-menu): New entry for the new command.
* doc/emacs/files.texi (Diff Mode):
* etc/NEWS: Document the change.