Kévin Le Gouguec [Sun, 29 Jan 2023 10:23:01 +0000 (11:23 +0100)]
Avoid spurious pause in kill-ring-save (Bug#60841)
'indicate-copied-region' checks whether the region is "highlighted"
and if not, briefly moves point to mark to give a visual cue of the
extent of text that was saved to the kill ring.
The region is considered "highlighted" if (a) it is active and (b) its
face specifies a :background. That latter condition does not account
for the multiple ways in which the face can make the region "visually
distinct" from the default face, so switch to the more extensive
predicate face-differs-from-default-p.
The patch also fixes a couple of issues with the predicate's
implementation, and introduces a new user option in case anyone
happened to enjoy unconditional blinking.
* lisp/faces.el (face-differs-from-default-p): Filter out :extend; add
rationale for the attributes we ignore.
* lisp/simple.el (copy-region-blink-predicate): Add option to let
users explicitly opt into or out of blinking point and mark.
(region-indistinguishable-p): New function to detect
"if there is currently no active region highlighting", leveraging
face-differs-from-default-p.
(indicate-copied-region): Use it.
* src/xfaces.c (merge_face_ref): Allow :stipple to be nil, since it is
a documented valid value for that attribute.
* etc/NEWS: Announce user option.
Alan Mackenzie [Mon, 30 Jan 2023 20:02:36 +0000 (20:02 +0000)]
CC Mode: Fix a coding bug in c-make-keywords-re. This should fix bug #61135
* lisp/progmodes/cc-defs.el (c-make-keywords-re): Generate "\>" components in
result regexp when argument ADORN is `appendable'. This fully fixes a bug
which was half-fixed on 2019-01-22.
Robert Pluim [Mon, 30 Jan 2023 09:51:30 +0000 (10:51 +0100)]
Fix interactive use of `keymap-local-set' and `keymap-global-set'
* lisp/keymap.el (keymap-global-set, keymap-local-set): Convert the
read key sequence to a string when called interactively. Based on a
patch from Stephen Berman <stephen.berman@gmx.net>. (Bug#61149)
Eli Zaretskii [Mon, 30 Jan 2023 12:22:19 +0000 (14:22 +0200)]
; Fix build and startup without tree-sitter
* lisp/treesit.el (treesit--font-lock-level-setter): Don't loop
over all the buffers if tree-sitter is not built-in, or else
initialization of defcustom will fail. (Bug#61155)
* lisp/progmodes/rust-ts-mode.el (treesit-node-parent):
* lisp/progmodes/c-ts-common.el (treesit-node-parent): Declare, to
* avoid byte-compilation warnings.
Eli Zaretskii [Sun, 29 Jan 2023 13:22:20 +0000 (15:22 +0200)]
Document tree-sitter features in the user manual
* lisp/progmodes/c-ts-mode.el (c-ts-mode-map): Bind "C-c .", for
consistency with CC mode.
* lisp/treesit.el (treesit-font-lock-level): Doc fix.
* doc/emacs/programs.texi (C Indent, Custom C Indent): Document
the indentation features of 'c-ts-mode'.
(Moving by Defuns): Document 'treesit-defun-tactic'.
* doc/emacs/files.texi (Visiting): Document
'treesit-max-buffer-size'.
* doc/emacs/display.texi (Traditional Font Lock)
(Parser-based Font Lock): New subsections.
* doc/emacs/emacs.texi (Top): Update top-level menu.
Randy Taylor [Sun, 29 Jan 2023 02:21:29 +0000 (21:21 -0500)]
Fix dockerfile-ts-mode line continuation indentation (bug#61131)
Without this rule, line continuations are only indented after entering
the contents for the line and hitting TAB or RET.
For example:
```
EXPOSE 1 \
```
After hitting RET to go to the next line, point would end up at BOL
instead of lining up with the previous entry, like so:
```
EXPOSE 1 \
2
```
The new rule will indent it as so:
```
EXPOSE 1 \
2
```
* lisp/progmodes/dockerfile-ts-mode.el:
(dockerfile-ts-mode--indent-rules): New rule.
(dockerfile-ts-mode--line-continuation-p)
(dockerfile-ts-mode--line-continuation-anchor): New functions.
Yuan Fu [Sun, 29 Jan 2023 08:07:46 +0000 (00:07 -0800)]
Use treesit-subtree-stat to determine treesit--font-lock-fast-mode
* lisp/treesit.el:
(treesit--children-covering-range-recurse): Return nil if LIMIT is
exceeded.
(treesit--font-lock-fast-mode): Change to a ternary value.
(treesit-font-lock-fontify-region): Enable fast mode based on the
result of treesit-subtree-stat.
Yuan Fu [Sun, 29 Jan 2023 01:08:53 +0000 (17:08 -0800)]
Move c-ts-mode--statement-offset to c-ts-common.el
Now it can be used by other C-like languages.
* lisp/progmodes/c-ts-common.el (c-ts-common-indent-offset):
(c-ts-common-indent-block-type-regexp):
(c-ts-common-indent-bracketless-type-regexp): New variables.
(c-ts-common-statement-offset):
(c-ts-mode--fix-bracketless-indent):
(c-ts-mode--close-bracket-offset): New functions.
* lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-styles): Change
c-ts-mode--statement-offset to c-ts-common-statement-offset.
The (parent-is "if_statement") rules are now handled by (node-is
"compound_statement").
(c-ts-mode--statement-offset-post-processr):
(c-ts-mode--statement-offset):
(c-ts-mode--fix-bracketless-indent): Move to c-ts-common.el.
(c-ts-base-mode): Setup c-ts-common stuff.
* test/lisp/progmodes/c-ts-mode-resources/indent.erts: Make the test
more challenging.
Yuan Fu [Fri, 27 Jan 2023 01:49:45 +0000 (17:49 -0800)]
Fix <> syntax in rust-ts-mode
Similar to bug#60351, the angle brackets in rust-ts-mode are not
recognized as pairs when they should be. This change copies the
function used by c++-ts-mode and adapts it to rust-ts-mode.
* lisp/progmodes/rust-ts-mode.el:
(rust-ts-mode--syntax-propertize): New function.
(rust-ts-mode): Set up syntax-propertize-function.
Add c-ts-mode-set-style and :set for c-ts-mode-indent-style
* lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-style-setter): New
setter for the indent style defcustom.
(c-ts-mode-indent-style): Don't quote the values and refer to the
setter.
(c-ts-mode-set-style): New command to interactively set the indent
style.
(c-ts-mode--get-indent-style): New function renamed from
'c-ts-mode--set-indent-style'.
Eli Zaretskii [Fri, 27 Jan 2023 17:01:49 +0000 (19:01 +0200)]
Improve documentation of 'shell-command-dont-erase-buffer'
* doc/emacs/misc.texi (Single Shell):
* lisp/simple.el (shell-command, shell-command-on-region):
Document that non-nil value of 'shell-command-dont-erase-buffer'
affects what is displayed in the echo area after the command.
(Bug#61100)
Fix errors in fontification of JavaScript import-statements (bug#61083)
Currently js-ts-mode handles imports with aliases incorrectly. To be
consistent with how we otherwise do things, we should only highlight
the variable which is new and/or introduced, in this case "someAlias".
Attached is a patch which fontifies import-declarations somewhat more
correctly.
The following cases have been tested and all fontify properly:
import gnu from "fsf"; // highlights gnu
import { gnu2 } from "fsf2"; // highlights gnu2
import { gnu as gnu3 } from "fsf3"; // highlights gnu3
import * as gnu4 from "fsf4"; // highlights gnu4
* lisp/progmodes/js.el (js--treesit-font-lock-settings): Add new
import_clause rules that adhere to the comment above.
Fix fontification TypeScript of import-statements (bug#61081)
Currently typescript-ts-mode and tsx-ts-mode handles imports with
aliases incorrectly.
Consider the following case:
import { someFunc as someAlias } from "module";
In this case the entire import ("someFunc as someAlias") will be
highlighted as a variable name. "as" is also highlighted as a
variable, rather than a reserved keyword.
To be consistent with how we otherwise do things, we should only
highlight the variable which is new and/or introduced, in this case
"someAlias".
Attached is a patch which fontifies import-declarations somewhat more
correctly.
The following cases have been tested and all fontify properly:
import gnu from "fsf"; // highlights gnu
import { gnu2 } from "fsf2"; // highlights gnu2
import { gnu as gnu3 } from "fsf3"; // highlights gnu3
import * as gnu4 from "fsf4"; // highlights gnu4
* lisp/progmodes/typescript-ts-mode.el
(typescript-ts-mode--font-lock-settings): Tweak import_clause rules to
adhere to the comment above.
Eglot already depends transitively on Xref 1.4.0 via Project,
but package.el doesn't pick up on this in Emacs 28
(which has Xref 1.3.0).
* lisp/progmodes/eglot.el (Version): Bump to 1.11.
(Package-Requires): Explicitly require Xref 1.4.0, which is
the version already required by Project, for the benefit of
Emacs 28 (bug#61048).
Eli Zaretskii [Thu, 26 Jan 2023 08:54:43 +0000 (10:54 +0200)]
Fix xt-mouse on terminals that report UTF-8 encoded coordinates
* lisp/xt-mouse.el (xterm-mouse--read-coordinate): Fix conversion
of mouse coordinates in rxvt-unicode. Patches by Vladimir
Panteleev <git@cy.md> and Jared Finder <jared@finder.org>.
(Bug#61022)
Randy Taylor [Wed, 25 Jan 2023 02:20:48 +0000 (21:20 -0500)]
Fix go-ts-mode indentation and set indent offset to 8 (Bug#61006)
* lisp/progmodes/go-ts-mode.el (go-ts-mode-indent-offset): Change
default value to 8.
(go-ts-mode--indent-rules): Add indentation for parameters and
interfaces.
Yuan Fu [Thu, 26 Jan 2023 07:47:27 +0000 (23:47 -0800)]
Fix indentation for c-ts-mode (bug#61026)
Fix indentation for things like
while (true)
if (true)
{
puts ("Hello");
}
Note that the outer while loop omits brackets.
* lisp/progmodes/c-ts-mode.el:
(c-ts-mode--statement-offset-post-processr): New variable.
(c-ts-mode--statement-offset): Use the new function.
(c-ts-mode--fix-bracketless-indent): New function.
(c-ts-base-mode): Use the new function.
* test/lisp/progmodes/c-ts-mode-resources/indent.erts: New tests.
* lisp/dired.el (dired-font-lock-keywords): Fontify directory
symlinks with the value of dired-directory-face rather than its name
as a (nonexistent) face (bug#60977).
* src/xfaces.c (font_maybe_unset_attribute): Move definition...
[HAVE_WINDOW_SYSTEM] (font_maybe_unset_attribute): ...to here, since
the function is used only when we HAVE_WINDOW_SYSTEM (bug#61049).
F. Jason Park [Tue, 24 Jan 2023 10:34:29 +0000 (02:34 -0800)]
; Fix filename mismatches in prop lines of ERC tests
* test/lisp/erc/erc-scenarios-base-compat-rename-bouncer.el: Fix file
name in prop line and footer.
* test/lisp/erc/erc-scenarios-base-local-modules.el: Fix file name in
prop line and footer.
* test/lisp/erc/erc-scenarios-base-netid-samenet.el: Fix file name in
prop line and footer.
* test/lisp/erc/erc-scenarios-base-upstream-recon-soju.el: Fix file
name in prop line and footer.
* test/lisp/erc/erc-scenarios-base-upstream-recon-znc.el: Fix file
name in prop line and footer.
Juri Linkov [Tue, 24 Jan 2023 18:48:20 +0000 (20:48 +0200)]
Handle relative file names in vc-resynch-window and vc-resynch-buffer
* lisp/vc/vc-dispatcher.el (vc-resynch-window, vc-resynch-buffer):
While comparing with `buffer-file-name' if `file' is not absolute
use `expand-file-name' in `vc-root-dir'. This fixes the case of
refreshing the buffers after typing `C-x v = C-x v u' (bug#60897).
* lisp/outline.el (outline-button-icon-map)
(outline-overlay-button-map, outline-inserted-button-map):
Keymaps refactored from outline--create-button-icons and
outline--insert-button.
(outline--create-button-icons, outline--insert-button): Move
keymaps to separate variables.
* lisp/international/mule.el (sgml-xml-auto-coding-function): Avoid
signaling an error from coding-system-equal when the XML encoding tag
specifies an encoding whose type is 'charset'. (Bug#61005)
This is the same fix as in #df7ed10e for
sgml-xml-auto-coding-function.
Eli Zaretskii [Sun, 22 Jan 2023 13:07:55 +0000 (15:07 +0200)]
Avoid crashes in batch Emacs sub-processes on MS-Windows
* src/w32.c (shutdown_handler): When run in a separate thread,
don't call functions that only the main (a.k.a. "Lisp") thread can
call; instead, arrange for maybe_quit to kill Emacs.
* src/w32fns.c (emacs_abort): Don't show GUI Abort dialogs in
non-interactive sessions. (Bug#60556)
* lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-styles): Simplify
rules.
* test/lisp/progmodes/c-ts-mode-resources/indent-bsd.erts: New
testfile with bsd style indentation examples.
* test/lisp/progmodes/c-ts-mode-tests.el
(c-ts-mode-test-indentation-bsd): Add a test for the new style.
Move c-like common utils into own library (bug#60961)
* lisp/progmodes/c-ts-common.el: New file.
* lisp/progmodes/c-ts-mode.el (treesit-induce-sparse-tree): Remove
unused declaration.
(c-ts-mode--indent-styles): Refer to the new library.
(c-ts-mode--looking-at-star,
c-ts-mode--comment-start-after-first-star,
c-ts-mode--comment-2nd-line-matcher,
c-ts-mode--comment-2nd-line-anchor, c-ts-mode--comment-regexp,
c-ts-mode--fill-paragraph, c-ts-mode--fill-block-comment): Move to
c-ts-common and expose as public.
(c-ts-mode-comment-setup): Move to c-ts-common.
* lisp/progmodes/csharp-mode.el (c-ts-common): Require new library.
(csharp-ts-mode--indent-rules): Refer to the new symbols.
(csharp-ts-mode): Use new function.
* lisp/progmodes/java-ts-mode.el (c-ts-common): Require new library.
(java-ts-mode--indent-rules): Refer to the new symbols.
(java-ts-mode): Use new function.
* lisp/progmodes/js.el (c-ts-common): Require new library.
(js--treesit-indent-rules): Refer to the new symbols.
(js-ts-mode): Use new function.
* lisp/progmodes/rust-ts-mode.el (c-ts-common): Require new library.
(rust-ts-mode--indent-rules): Refer to the new symbols.
(rust-ts-mode): Use new function.
* lisp/progmodes/typescript-ts-mode.el (c-ts-common): Require new
library.
(typescript-ts-mode--indent-rules): Refer to the new symbols.
(typescript-ts-base-mode): Use new function.