* 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.
Use point-min to anchor top-level constructs (bug#60602)
* lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-styles): New anchor.
* lisp/progmodes/java-ts-mode.el (java-ts-mode--indent-rules): New
anchor.
* lisp/progmodes/ruby-ts-mode.el (ruby-ts--indent-rules): New anchor.
* lisp/progmodes/typescript-ts-mode.el
(typescript-ts-mode--indent-rules): New anchor.
Robert Pluim [Thu, 19 Jan 2023 15:05:45 +0000 (16:05 +0100)]
Make `keymap-set-after' work for menus
It still doesn't work for an AFTER that's a key, though, since
`key-parse' produces vectors, and keymaps contain integers.
* lisp/keymap.el (keymap-set-after): Only parse AFTER as a key if it's
a string. For consistency, use `key-parse' on the definition if it's
a string, just like `keymap-set'.
* test/src/keymap-tests.el (keymap-tests--command-3): New dummy command.
(keymap-set-after-menus): New test. Check that we can insert a menu
item after a specific entry.
Robert Pluim [Thu, 19 Jan 2023 14:58:51 +0000 (15:58 +0100)]
Use `key-parse' in `keymap-lookup'
It's stricter than `kbd', and doesn't try to do anything with key
sequences that look like macros.
* lisp/keymap.el (keymap-lookup): Use `key-parse' instead of `kbd'.
* test/src/keymap-tests.el (keymap-set-after-menus): Test the
`keymap-set-after' API.
F. Jason Park [Fri, 20 Jan 2023 04:19:40 +0000 (20:19 -0800)]
Don't load erc-goodies atop erc.el
* lisp/erc/erc.el: Commit c2d657e7c4fd9685591f2120007eabf78745919d
"Move ERC's core dependencies to a separate file" ironed out ERC's
interwoven dependencies for the better but didn't cleanly sidestep the
goodies interdependency, specifically with regard to custom options.
This reverts the tiny portion impacting this aspect by once again
requiring `erc-goodies' at the very end of ERC's main library. Special
thanks to Libera.Chat user jrm for reporting this bug.
Eli Zaretskii [Fri, 20 Jan 2023 08:28:26 +0000 (10:28 +0200)]
Make tree-sitter based modes optional
* lisp/progmodes/c-ts-mode.el: Update Commentary. Make
'auto-mode-alist' update conditional on the tree-sitter and
grammar libraries being available.
* lisp/progmodes/cmake-ts-mode.el:
* lisp/progmodes/csharp-mode.el:
* lisp/progmodes/dockerfile-ts-mode.el:
* lisp/progmodes/go-ts-mode.el:
* lisp/progmodes/java-ts-mode.el:
* lisp/progmodes/js.el:
* lisp/progmodes/json-ts-mode.el:
* lisp/progmodes/python.el:
* lisp/progmodes/ruby-ts-mode.el:
* lisp/progmodes/typescript-ts-mode.el:
* lisp/textmodes/css-mode.el:
* lisp/textmodes/toml-ts-mode.el:
* lisp/textmodes/yaml-ts-mode.el: Make 'auto-mode-alist' update
for tree-sitter based modes be conditional on the tree-sitter and
grammar libraries being available. (Bug#60559)
Dmitry Gutov [Fri, 20 Jan 2023 02:14:38 +0000 (04:14 +0200)]
(ruby-ts-mode): Rename 'builtin-functions' to 'builtin-function'
* lisp/progmodes/ruby-ts-mode.el (ruby-ts--font-lock-settings)
(ruby-ts-mode): Rename 'builtin-functions' to 'builtin-function',
for consistency with similar features.
Dmitry Gutov [Fri, 20 Jan 2023 01:56:44 +0000 (03:56 +0200)]
ruby-ts-mode: Highlight builtin methods
* lisp/progmodes/ruby-mode.el (ruby-builtin-methods-with-reqs)
(ruby-builtin-methods-no-reqs): New constants, extracted.
(ruby-font-lock-keywords): Replace values with references.
* lisp/progmodes/ruby-ts-mode.el (ruby-ts--builtin-methods): New
variable. Construct regexp from aforementioned constants' values.
* lisp/progmodes/ruby-ts-mode.el (ruby-ts--font-lock-settings):
Use it.
* lisp/progmodes/ruby-ts-mode.el (ruby-ts-mode):
Add new font-lock feature: builtin-functions.
* lisp/progmodes/ruby-ts-mode.el (ruby-ts--predefined-constants)
(ruby-ts--predefined-variables): Unrelated to the rest of the
patch, add string-start and string-end anchors.
Yuan Fu [Thu, 19 Jan 2023 22:22:56 +0000 (14:22 -0800)]
Fix various problems in treesit-explore-mode (bug#60800)
* lisp/treesit.el:
(treesit--explorer-kill-explorer-buffer): New function.
(treesit-explore-mode):
1. Move prompt for language earlier, and terminate early if language
not available.
2. Make sure desktop-save doesn't save the explorer buffer.
3. Kill the explorer buffer when the source buffer is killed.
This fixes an oversight from 77c3c464a16: "* lisp/emacs-lisp/advice.el
(ad-advised-functions): Make it a plain list" that caused an issue as
reported in Bug#60893.
* lisp/emacs-lisp/advice.el (ad-read-advised-function): Adjust to
handle the new type of elements of `ad-advised-functions'.
Dmitry Gutov [Thu, 19 Jan 2023 16:31:57 +0000 (18:31 +0200)]
; ruby-ts--indent-rules: Minor cleanup
* lisp/progmodes/ruby-ts-mode.el (ruby-ts--indent-rules): Remove
the (match "begin" "assignment") rule. The catch-all has the same
effect. Update a comment referring to rules removed previously.
Alan Mackenzie [Thu, 19 Jan 2023 10:59:10 +0000 (10:59 +0000)]
CC Mode: Prevent two classes of "type" prematurely entering c-found-types
This fixes bug #60769. The two classes of "type" are foo and bar in
"foo d(bar () ...)", where the d could be a mistyped C-M-d.
* list/progmodes/cc-engine.el (c-forward-decl-or-cast-1): New local variable
got-arglist. Refactor a sequence of enclosed `if' forms into a `cond' form.
Set got-arglist when needed. In CASE 2, set unsafe-maybe to inhibit foo
being entered into c-found-types. In CASE 19, likewise set unsafe-maybe, to
inhibit bar entering c-found-types.
* lisp/progmodes/ruby-ts-mode.el
(ruby-ts--statement-container-regexp): Remove
"parenthesized_statements", it's not really a statement container,
not one we'd use for indentation alignment anyway.
Dmitry Gutov [Thu, 19 Jan 2023 01:38:58 +0000 (03:38 +0200)]
ruby-ts-mode: Handle indent in parenless calls much closer to ruby-mode
* lisp/progmodes/ruby-ts-mode.el (ruby-ts--parent-call-or-bol):
New function.
(ruby-ts--indent-rules): Use it for cases which need special
anchoring logic when inside a parenless method call.
Remove the ad-hoc handling of pair-hash-pair etc indentation,
which was there only for the parenless cases, apparently.
Have "No paren, ruby-parenless-call-arguments-indent is nil" case
align to the statement, if only because ruby-mode does that.
* test/lisp/progmodes/ruby-ts-mode-tests.el:
Run indent test for ruby-parenless-call-arguments-indent.rb.
Juri Linkov [Wed, 18 Jan 2023 18:24:26 +0000 (20:24 +0200)]
Fix split-window-below for the case when split-window-keep-point is nil.
* lisp/window.el (split-window-below): Don't try to move point when
split-window-keep-point is nil and window-to-split is not the selected window
or nil (that defaults to the selected window) because code makes sense
only for the selected window.
(split-window-below, split-window-right): Improve docstrings (bug#60886)
Juri Linkov [Wed, 18 Jan 2023 18:05:19 +0000 (20:05 +0200)]
Rebind in read-regexp-map ‘M-c’ to ‘M-s c’ compatible with search-map
Also it's compatible with 'M-s c' (isearch-toggle-case-fold)
used during Isearch. Also makes possible to use the global keybinding
'M-c' (capitalize-dwim) in the minibuffer.
* doc/lispref/minibuf.texi (Text from Minibuffer): Rename ‘M-c’ to ‘M-s c’.
* lisp/replace.el (read-regexp-map): Rebind ‘M-c’ to ‘M-s c’ (bug#60741).
(read-regexp-toggle-case-fold): Rename from read-regexp-toggle-case-folding
to more standard name.
Jim Porter [Wed, 18 Jan 2023 04:51:15 +0000 (20:51 -0800)]
Use proper types for Eshell warnings
* lisp/eshell/esh-var.el (eshell-get-variable):
* lisp/eshell/em-basic (eshell/echo): Don't use ':warning'; that's a
warning level, not a warning type.
Yuan Fu [Wed, 18 Jan 2023 06:26:21 +0000 (22:26 -0800)]
Make it harder to misactivate tree-sitter font-lock fast mode
This has been brought up in bug#60691 and bug#60223. I proposed a fix
by testing the size of the tree rather than measuring the query time.
But after some thought, I fear that just looking at the size will give
us false-negatives. So I kept the time-based activation, just added a
grace count to reduce false-positives.
* lisp/treesit.el:
(treesit--font-lock-fast-mode-grace-count): New variable.
(treesit--font-lock-notifier): Only activate fast mode after 5
offenses.
Dmitry Gutov [Wed, 18 Jan 2023 00:40:00 +0000 (02:40 +0200)]
ruby-ts-mode: Fix indent after operator or conditional
Make it match ruby-mode's indentation behavior.
* lisp/progmodes/ruby-ts-mode.el (ruby-ts--binary-indent-anchor):
New function.
(ruby-ts--indent-rules): Use it instead of a composite matcher.
Add a rule for 'conditional'.
(ruby-ts--assignment-ancestor, ruby-ts--is-in-condition)
(ruby-ts--endless-method): Remove.