Yuan Fu [Mon, 9 Jan 2023 04:30:07 +0000 (20:30 -0800)]
Minor improvement for tree-sitter explorer
If you open an empty python buffer and type
1 + 2
a
b
Currently the explorer only displays the top-level node at point, ie,
only 1 + 2, only a, or only b. That's kind of awkward, so if the
buffer is small, show the entire parse tree.
* lisp/treesit.el (treesit--explorer-refresh): See above.
Yuan Fu [Mon, 9 Jan 2023 03:05:19 +0000 (19:05 -0800)]
Make sure NODE is not the root node in tree-sitter indent (bug#60602)
There are two possible ways to solve the problem raised in the bug
report: either make sure NODE is never the root (so that parent is
never nil), or allow parent to be nil.
If we go with the latter, a lot of matcher and anchor functions need
change (they need to guard against a null parent). I tried it, and
needing to check for null parent is pretty annoying. In comparison,
if NODE is never the root, it is very convenient for the user, and it
doesn't complicate the rule that much (and it's rather intuitive,
people usually don't think of the case where NODE is the root node).
So that's what I choose.
* doc/lispref/modes.texi (Parser-based Indentation): Update manual.
* lisp/treesit.el (treesit-indent-function): Update docstring.
(treesit--indent-1): Make sure NODE is not the root.
Yuan Fu [Mon, 9 Jan 2023 00:57:29 +0000 (16:57 -0800)]
Fix label indent of GNU and Linux style in c-ts-mode (bug#60543)
The previous fix isn't correct.
* lisp/progmodes/c-ts-mode.el:
(c-ts-mode--indent-styles): New indent rule. Fix the rule for Linux
style.
(c-ts-mode--top-level-label-matcher): New function.
Tad Fisher [Wed, 4 Jan 2023 21:40:17 +0000 (13:40 -0800)]
; * src/pgtkfns.c (parse_resource_key): Use recursive schema lookup
XDG_DATA_DIRS may consist of multiple directories, and
g_settings_schema_source_get_default composes these into a recursive
schema source. One must pass TRUE to g_settings_schema_source_lookup,
otherwise only the first directory in XDG_DATA_DIRS is searched.
It follows that in the case that the directory containing the compiled
GSettings schema for Emacs is not the first in XDG_DATA_DIRS,
parse_resource_key will not accept any resource key, which causes
pgtk_get_defaults_value and pgtk_set_defaults_value to fail.
This impacts systems that compose multiple GSettings schema sources
via XDG_DATA_DIRS, such Flatpak and NixOS.
Supporting GIO documentation for g_settings_schema_source_get_default:
> The returned source may actually consist of multiple schema sources
> from different directories, depending on which directories were given
> in `XDG_DATA_DIRS` and `GSETTINGS_SCHEMA_DIR`. For this reason, all
> lookups performed against the default source should probably be done
> recursively.
Benson Chu [Sun, 1 Jan 2023 01:45:43 +0000 (19:45 -0600)]
Add back renamed function 'font-lock-fontify-syntactically-region'
A more accurate replacement for font-lock-fontify-syntactically-region
would be a function that funcalls the
font-lock-fontify-syntactically-function variable. That way, callers
of the function can inherit new behavior, if the value of that variable
changes.
* lisp/font-lock.el (font-lock-fontify-syntactically-region):
Add function back, remove its obsolete alias.
Eli Zaretskii [Sun, 8 Jan 2023 10:23:26 +0000 (12:23 +0200)]
Improve options and docs of M-x command completion
* lisp/simple.el (read-extended-command-predicate): Expand the
doc string. Add 2 more selectable values.
(command-completion-using-modes-and-keymaps-p): New function.
(execute-extended-command): Mention
'read-extended-command-predicate' in the doc string. (Bug#60645)
Yuan Fu [Sun, 8 Jan 2023 02:38:24 +0000 (18:38 -0800)]
Fix string-interpolation feature of python-ts-mode (bug#60599)
* lisp/progmodes/python.el:
(python--treesit-fontify-string-interpolation): New function.
(python--treesit-settings): Use the new function for
string-interpolation.
Fix highlighting of variable-declarations in typescript-ts-mode
(bug#60546)
- Highlight variable declarations in catch-clauses.
- Remove highlighting of variables where not declarations (improve
consistency with other *-ts-modes).
* lisp/progmodes/typescript-ts-mode.el:
(typescript-ts-mode--font-lock-settings): See above.
Yuan Fu [Sun, 8 Jan 2023 01:46:27 +0000 (17:46 -0800)]
Remove duplicate entries in c-ts-mode's Imenu
Right now the Class subindex includes top-level functions, which is
wrong. This change ensures the Class subindex only contain classes and
functions nested in those classes.
* lisp/progmodes/c-ts-mode.el:
(c-ts-mode--defun-for-class-in-imenu-p): New function.
* lisp/progmodes/c-ts-mode.el (c-ts-base-mode): Use the new function.
Dmitry Gutov [Sun, 8 Jan 2023 01:56:32 +0000 (03:56 +0200)]
(ruby-ts--font-lock-settings): Improve highlighting in patterns
* lisp/progmodes/ruby-ts-mode.el (ruby-ts--font-lock-settings):
Improve highlighting in patterns: highlight values not keys as
variable in the usual case; highlight keys when no value;
highlight the "as pattern" variable.
Yuan Fu [Sat, 7 Jan 2023 23:26:56 +0000 (15:26 -0800)]
Fix c-ts-mode--looking-at-star
Not the topic of bug#60270 but reported in one of the replies.
* lisp/progmodes/c-ts-mode.el (c-ts-mode--looking-at-star): Check not
the character after point but character after BOL. Otherwise
indentation is wrong when point is not at BOL.
Eli Zaretskii [Sat, 7 Jan 2023 17:57:30 +0000 (19:57 +0200)]
Document the 'definition-name' property.
* doc/lispref/symbols.texi (Standard Properties): Document
'definition-name'.
* doc/lispref/functions.texi (Defining Functions): Describe how to
use 'definition-name' when generating function definitions at run
time. (Bug#60568)
kobarity [Sun, 1 Jan 2023 12:09:10 +0000 (21:09 +0900)]
Fix 'python-shell-buffer-substring' when START is in middle of 1st line
* lisp/progmodes/python.el (python-shell-buffer-substring): Instead
of checking whether START is point-min, check whether START is in
the first line. (Bug#60466)
* test/lisp/progmodes/python-tests.el
(python-shell-buffer-substring-18): New test.
Dmitry Gutov [Sat, 7 Jan 2023 00:44:07 +0000 (02:44 +0200)]
(treesit--indent-rules-optimize): Optimize 'and' and 'or' matcher forms
* lisp/treesit.el (treesit--indent-rules-optimize):
Optimize 'and' and 'or' matcher forms. When 'and' has a 'query'
matcher inside (as is the case in ruby-ts--indent-rules, many
times over), this yields a significant performance boost.
Dmitry Gutov [Sat, 7 Jan 2023 00:02:25 +0000 (02:02 +0200)]
(treesit-simple-indent-presets): Short-circuit 'and' and 'or'
* lisp/treesit.el (treesit-simple-indent-presets):
Short-circuit the 'and' and 'or' matchers. To avoid calling all
fns after one returned nil or truthy value, respectively.
Dmitry Gutov [Fri, 6 Jan 2023 17:56:20 +0000 (19:56 +0200)]
(font-lock-regexp-face): New face
* lisp/font-lock.el (font-lock-regexp-face): New face.
* lisp/progmodes/typescript-ts-mode.el
(typescript-ts-mode--font-lock-settings):
* lisp/progmodes/ruby-ts-mode.el (ruby-ts--font-lock-settings):
* lisp/progmodes/js.el (js--treesit-font-lock-settings):
Use it for regexps.
Dmitry Gutov [Fri, 6 Jan 2023 13:38:00 +0000 (15:38 +0200)]
ruby-ts-mode: Highlight more kinds of parameters
* lisp/progmodes/ruby-ts-mode.el
(ruby-ts--font-lock-settings): Highlight destructured parameters,
lambda parameters, identifiers in pattern matching clauses
(array/hash) and exception variables.
Move the 'symbol' matchers lower to make 'hash_key_symbol' lower
priority than hash keys in match patterns.
Robert Pluim [Fri, 6 Jan 2023 08:00:00 +0000 (09:00 +0100)]
Fix `pr-interface'
`pr-interface' specifies `inline' for its menu items, which is not
necessary, but it causes `widget-choice-value-create' to bug
out. (Bug#60501)
* lisp/wid-edit.el (widget-choice-value-create): Allow the value to be
a non-list.
* test/lisp/wid-edit-tests.el (widget-test-handle-spurious-inline):
Add test to ensure that unnecessary :inline is allowed.
Perry Smith [Fri, 6 Jan 2023 02:20:02 +0000 (04:20 +0200)]
ruby-ts-mode: Highlight variable assignments
* lisp/progmodes/ruby-ts-mode.el (ruby-ts--font-lock-settings):
Bring back the 'assignment' feature.
(ruby-ts-mode): Replace the unused 'variable' with 'assignment'. Use
the level 3 for consistency with other ts modes.
Update the Commentary as well.
Dmitry Gutov [Fri, 6 Jan 2023 01:12:20 +0000 (03:12 +0200)]
(ruby-ts-mode): Split font-lock feature 'builtin' into two
* lisp/progmodes/ruby-ts-mode.el (ruby-ts-mode):
Split the 'builtin' feature in two: 'builtin-constant' and
'builtin-variable'.
(ruby-ts-highlight-predefined-constants):
Drop the user option, the highlighting granularity can be chosen
using treesit-font-lock-recompute-features.
(ruby-ts--font-lock-settings): Update accordingly.
(ruby-ts--predefined-constants, ruby-ts--predefined-variables):
Fix docstrings.
Eli Zaretskii [Thu, 5 Jan 2023 20:33:51 +0000 (22:33 +0200)]
Avoid assertion violation due to fill-column indicator face
* src/xdisp.c (extend_face_to_end_of_line): Use the original
iterator metrics for the stretch glyph, the one unaffected by the
'fill-column-indicator' face. (Bug#60580)
Juri Linkov [Wed, 4 Jan 2023 07:57:06 +0000 (09:57 +0200)]
Tree-sitter doc fixes (bug#60524)
* doc/lispref/modes.texi (Parser-based Font Lock):
Replace :lang with :language.
* doc/lispref/parsing.texi (Language Grammar): Replace
treesit-load-suffixes with dynamic-library-suffixes.
(Retrieving Nodes): Fix function names.
(Tree-sitter Major Modes): Fix treesit-ready-p args.
Fix pxref to Parser-based Indentation.
(Tree-sitter C API): Fix function names.
* lisp/treesit.el (treesit--simple-indent-eval): Remove cond BODY
duplicated from CONDITION.
(treesit)<define-short-documentation-group>: Fix function names.
Daniel Martín [Tue, 3 Jan 2023 21:08:13 +0000 (22:08 +0100)]
Fontify C++ function definitions in c-ts-mode (bug#60529)
* lisp/progmodes/c-ts-mode.el (c-ts-mode--declarator-identifier):
Teach the code how to extract the declarator of a node of type
"qualified_identifier".
(c-ts-mode--fontify-declarator): Consider the case where the
identifier in a function declarator is buried inside
"qualifier_identifier" nodes.
Dmitry Gutov [Tue, 3 Jan 2023 22:37:43 +0000 (00:37 +0200)]
(ruby-ts-add-log-current-function): Fix when between two methods
* lisp/progmodes/ruby-ts-mode.el
(ruby-ts-add-log-current-function): Fix the case when point is
between two methods. 'treesit-node-at' returs the 'def' node of
the method after point in such case, so it behaved like point was
inside the method below.
* test/lisp/progmodes/ruby-ts-mode-tests.el
(ruby-ts-add-log-current-method-outside-of-method):
Update the test case.
* test/lisp/progmodes/ruby-mode-tests.el
(ruby-add-log-current-method-outside-of-method):
Mirror that change.
Dmitry Gutov [Tue, 3 Jan 2023 01:10:49 +0000 (03:10 +0200)]
Extract common code into ruby-base-mode to derive from
* lisp/progmodes/ruby-mode.el (ruby-base-mode):
New major base mode, to set up common vars and hooks.
(ruby-mode-variables): Delete. Move most code to ruby-base-mode.
And some -- to ruby-mode body.
(ruby-mode): Derive from ruby-base-mode. Also move some setup
to there.
* lisp/progmodes/ruby-ts-mode.el (ruby-ts-mode):
Derive from ruby-base-mode. Remove duplicating settings.
Dmitry Gutov [Tue, 3 Jan 2023 00:26:00 +0000 (02:26 +0200)]
ruby-ts-mode: Indentation fixes
* lisp/progmodes/ruby-ts-mode.el (ruby-ts--align-keywords):
Fix for 'def' (which was misread as 'method' in the check).
(ruby-ts--indent-rules): Indent the curly block closer the same
way as the 'do ... end' closer.
Dmitry Gutov [Mon, 2 Jan 2023 22:41:25 +0000 (00:41 +0200)]
ruby-ts--font-lock-settings: Use more standard faces
* lisp/progmodes/ruby-ts-mode.el (ruby-ts--font-lock-settings):
Use more standard faces for regexp literals and string
interpolation delimiters (following js-ts-mode).
Dmitry Gutov [Mon, 2 Jan 2023 21:26:39 +0000 (23:26 +0200)]
ruby-ts-mode: Standardize the string literal highlights
* lisp/progmodes/ruby-ts-mode.el (ruby-ts--font-lock-settings):
Use font-lock-string-face for %w() and `...`.
Use font-lock-constant-face (just like we do for symbol literals)
for symbol array literals, %i().
Combine the matchers for string content and heredocs.
Fontification improvements in typescript-ts-mode (bug#60500)
- highlight method-definitins in interfaces.
- only highlight variable-declarations, not variables
everywhere (consistency with other modes).
- move highlighting of method invocations to level 4
Eli Zaretskii [Mon, 2 Jan 2023 15:02:05 +0000 (17:02 +0200)]
Fix shrinking of the tab-bar
* src/haikufns.c (haiku_change_tab_bar_height):
* src/pgtkfns.c (pgtk_change_tab_bar_height):
* src/nsfns.m (ns_change_tab_bar_height):
* src/w32fns.c (w32_change_tab_bar_height):
* src/xfns.c (x_change_tab_bar_height): Don't let the number of
tab-bar lines degenerate to zero due to integer division.
(Bug#60210)
F. Jason Park [Thu, 29 Dec 2022 14:43:19 +0000 (06:43 -0800)]
Fix default-port regression in erc-select-read-args
* lisp/erc/erc.el (erc--warn-unencrypted): New function, likely
temporary, to warn new users connecting interactively to the default
server, "irc.libara.chat", via the default non-TLS port, 6667.
(erc-select-read-args): Remove stray code from incomplete feature
introduced by bug#56514. Ensure connecting always works with default
port, which is non-TLS. Respect `erc-prompt-for-password' when user
pastes URL containing password component into "server" prompt. Maybe
add `erc--warn-unencrypted' as one-off hook for impending connection.
* test/lisp/erc/erc-tests.el (erc-select-read-args): Always expect
password prompt and sometimes a non-TLS port when `erc' called
interactively. (Bug#60428.)
Daniel Martín [Sat, 31 Dec 2022 00:45:27 +0000 (01:45 +0100)]
Fix fontification of C++ reference return types (bug#60441)
* lisp/progmodes/c-ts-mode.el (c-ts-fontify-error): Treat
reference_declarator nodes the same as pointer_declarator nodes when
calculating the identifier to fontify.
Adjust function-call fontification in csharp-ts-mode (bug#60376)
- Ensure method-invocations are highlighted only on level 4.
- Ensure consistent fontification of variable declarations
(don't highlight usage of all variables).
- Fix issues with highlighting types in new() expressions.
- Fix issues with generic types in variable-declarations not using "var".
- Use fewer, more general queries for function-invocations. simplify code.