Warn about code like (when SOME-CONDITION) because these may indicate
bugs. Warnings currently apply to `when`, `unless`, `ignore-error`,
`with-suppressed-warnings` and (as before) `let` and `let*`.
* lisp/emacs-lisp/byte-run.el (with-suppressed-warnings):
Update doc string.
* lisp/emacs-lisp/bytecomp.el: (byte-compile-warning-types)
(byte-compile-warnings): Add empty-body.
(byte-compile-initial-macro-environment):
Add empty-body warning for with-suppressed-warnings.
* lisp/emacs-lisp/macroexp.el (macroexp--expand-all):
Use the empty-body category for let and let*.
* lisp/subr.el (when, unless, ignore-error): Add empty-body warning.
* test/lisp/emacs-lisp/bytecomp-tests.el
(bytecomp-test--with-suppressed-warnings): Add test cases.
Stefan Kangas [Thu, 29 Dec 2022 05:30:09 +0000 (06:30 +0100)]
Merge from origin/emacs-29
909091d7578 ; Minor cleanup for tree-sitter font-lock rules in js-ts-... e78e69b3318 Clean up font-lock rules in js-ts-mode 0a61e4e2b71 ; * doc/lispref/parsing.texi (Using Parser): Minor improv... 398ed75c276 ; * lisp/progmodes/c-ts-mode.el (c-ts-mode--fill-paragrap... 19b8733aa27 Fix syntax for < and > in c++-ts-mode (bug#60351) f509246ba12 Call tree-sitter parser notifier on the first parse ec6feeaa191 Fix tree-sitter parser notifier recursion
Yuan Fu [Thu, 29 Dec 2022 00:52:47 +0000 (16:52 -0800)]
Clean up font-lock rules in js-ts-mode
Changes for each feature:
- string: Take out string-interpolation bits.
- string-interpolation: New.
- declaration: Rename to definition.
- identifier: Remove.
- property: Use a pred to filter out methods.
- expression: Rename to assignment.
- function: New.
- pattern: Merge into assignment.
* lisp/progmodes/js.el (js--treesit-font-lock-settings): See above.
(js--treesit-property-not-function-p)
(js--treesit-lhs-identifier-query): New variable.
(js--treesit-fontify-assignment-lhs): New functions.
(js-ts-mode): Update feature list.
Yuan Fu [Wed, 28 Dec 2022 23:44:26 +0000 (15:44 -0800)]
Fix syntax for < and > in c++-ts-mode (bug#60351)
< and > are usually punctuation, e.g., in ->. But when used for
templates, they should be considered pairs. Right now we always
consider them as pairs which is incorrect.
Yuan Fu [Wed, 28 Dec 2022 23:19:34 +0000 (15:19 -0800)]
Fix tree-sitter parser notifier recursion
See the comment for detail.
* src/treesit.c (treesit_ensure_parsed): Move the need_reparse short
circuit to the very beginning. Move the call to
treesit_call_after_change_functions to the very end.
Juri Linkov [Wed, 28 Dec 2022 18:48:40 +0000 (20:48 +0200)]
* lisp/help.el: Use 'C-h C-q' to toggle 'help-quick' window (bug#60249).
(help-map): Bind "C-q" to 'help-quick-toggle'. Rebind "q" to 'help-quit'.
(help-quick): Replace help-quit-or-quick with help-quick-toggle.
(help-quick-toggle): New command.
(help-quit-or-quick): Remove command.
(help-for-help): Replace help-quick-or-quit with help-quick-toggle.
Juri Linkov [Wed, 28 Dec 2022 18:27:07 +0000 (20:27 +0200)]
* lisp/isearch.el: Small fixes.
(isearch-wrap-pause): Mention the new feature of `no' and `no-ding'
in the docstring.
(isearch-lax-whitespace, isearch-forward-thing-at-point): Add the
group 'isearch' since another defgroup changed the default group.
(isearch-delete-char): Use 'isearch-invisible' instead of 'search-invisible'
since the users might change the current value with 'M-s i'.
Juri Linkov [Wed, 28 Dec 2022 18:14:43 +0000 (20:14 +0200)]
* lisp/vc/diff-mode.el (diff-minor-mode-prefix): Replace "ESC" with "\e".
"ESC" looks like an attempt to use kbd syntax in customization.
But actually now 'key-description' is used in 'diff-minor-mode-map'
to convert "\e" to "ESC".
We don't really need to rely on forward-sexp to define what to
transpose. In tree-sitter we can consider siblings as "balanced
expressions", and swap them without doing any movement to calculate
where the siblings in question are.
* lisp/simple.el (transpose-sexps-function): New defvar-local.
(transpose-sexps): Use the new defvar-local if available.
(transpose-subr): Check whether the mover function returns a cons of
conses, then run transpose-subr-1 on the position-pairs.
* lisp/treesit.el (treesit-transpose-sexps): New function.
F. Jason Park [Mon, 26 Dec 2022 05:36:53 +0000 (21:36 -0800)]
Warn of absent networks module in ERC
* doc/misc/erc.texi: Add linkable note in Modules chapter about some
modules being required. Also tweak markup in auth-source section.
* etc/ERC-NEWS: Mention the special role of `networks'.
* lisp/erc/erc-backend.el (erc--server-post-connect-hook): Add
internal hook for core modules to perform post-network-process,
pre-protocol config validation even when they haven't been loaded.
(erc--register-connection): Run `erc--server-post-connect-hook'.
* lisp/erc/erc-networks.el (erc-networks--bouncer-targets,
erc-networks-on-MOTD-end): Fix comments and doc strings. Also change
former from constant to internal variable in case adjustment needed
between releases.
(erc-networks--warn-on-connect): New function to warn about the
`networks' module being absent from `erc-modules'. This could
probably run at any time up to and including when the logical IRC
connection is established, but doing so at the process/protocol
boundary seems ideal.
* lisp/erc/erc-sasl.el (erc--register-connection): Defer to base
method instead of calling `erc-login' explicitly.
* lisp/erc/erc.el (erc-generate-new-buffer-name): Don't reconcile
buffer names when networks module not in play.
(erc-format-target-and/or-network): Don't assume networks module
loaded.
* test/lisp/erc/erc-scenarios-base-unstable.el:
(erc-scenarios-networks-no-module): New test.
* test/lisp/erc/resources/networks/no-module/basic.eld: New test data
file. (Bug#60331.)
F. Jason Park [Wed, 28 Dec 2022 14:18:01 +0000 (06:18 -0800)]
Avoid "already compiled" warning in erc-compat
* lisp/erc/erc-compat.el (erc-compat--29-auth-source-pass-search):
Don't `byte-compile' sub-29 secrets wrapper. This was especially
noisy in tests. Ditch closed-over vars via HOF instead of suppressing
because compiling emits "unused lexical" warning on Emacs 27.
Eli Zaretskii [Wed, 28 Dec 2022 13:10:39 +0000 (15:10 +0200)]
Make last change of w32 GUI dialogs conditional and reversible
* src/w32term.c (syms_of_w32term) <w32-yes-no-dialog-show-cancel>:
New boolean variable.
(w32_initialize): Fix query for visible system caret: 'bool' is a
single-byte data type, whereas SystemParametersInfo wants a BOOL,
which is a 32-bit int.
* src/w32menu.c (simple_dialog_show): Show "Cancel" button only if
'w32-yes-no-dialog-show-cancel' is non-nil.
Yuan Fu [Wed, 28 Dec 2022 04:37:29 +0000 (20:37 -0800)]
Add tree-sitter helper functions for Imenu
We didn't add an integration for Imenu because we aren't sure what
should it look like. Now we have a pretty good idea. All the major
modes copy-paste the two Imenu functions and tweaks them in a standard
way. With the addition of treesit-defun-type-regexp and
treesit-defun-name-function, now is a good time to standardize Imenu
integration.
In the next commit we update all the major modes to use this
integration.
* doc/lispref/modes.texi (Imenu): Add manual.
* doc/lispref/parsing.texi (Tree-sitter major modes): Update manual.
* lisp/treesit.el (treesit-simple-imenu-settings): New varaible.
(treesit--simple-imenu-1)
(treesit-simple-imenu): New functions.
(treesit-major-mode-setup): Setup Imenu.
Yuan Fu [Wed, 28 Dec 2022 01:02:03 +0000 (17:02 -0800)]
Fix treesit--things-around (bug#60355)
Current implementation of treesit--things-around only searches forward
for REGEXP and go up the tree until it finds a valid thing, if nothing
matches it gives up. This makes it sometimes miss defuns. The new
implementation tries multiple times (of search forward + go up) until
it exhausts all possible defun nodes.
* lisp/treesit.el (treesit--things-around): New implementation.
(treesit--navigate-defun): Refactor to use treesit-node-top-level to
simplify code, and add some guards in the predicate function.
* test/src/treesit-tests.el:
(treesit--ert-defun-navigation-elixir-program): New variable.
(treesit-defun-navigation-nested-4): New test.
Yuan Fu [Tue, 27 Dec 2022 23:07:03 +0000 (15:07 -0800)]
Improve treesit-node-top-level and treesit-parent-until
* lisp/treesit.el (treesit-node-top-level): Now it can accept a
predicate function. Add an optional argument INCLUDE-NODE.
(treesit-parent-until): Add an optional argument INCLUDE-NODE.
Stefan Kangas [Tue, 27 Dec 2022 16:24:18 +0000 (17:24 +0100)]
Make elide-head-headers-to-hide more forgiving
* lisp/elide-head.el (elide-head-headers-to-hide): Make regexp
more forgiving of line breaks and comment characters in address.
* test/lisp/elide-head-tests.el (gpl3-6): New test.
Rudolf Adamkovič [Sat, 24 Dec 2022 00:00:32 +0000 (01:00 +0100)]
Improve support for Scheme R6RS and R7RS libraries (bug#54704)
* etc/NEWS (Scheme mode): Document improved file-type auto-detection
and Imenu support for R6RS and R7RS Scheme libraries.
* lisp/files.el (auto-mode-alist): Associate the '.sls' (R6RS Scheme
Library Source) and '.sld' (R7RS Scheme Library Definition) file name
extensions with the Scheme mode.
* lisp/progmodes/scheme.el (scheme-imenu-generic-expression): Make
Imenu recognize the members nested (and so indented) inside of
'library' (R6RS) or 'define-library' (R7RS) forms.
Yuan Fu [Tue, 27 Dec 2022 01:16:59 +0000 (17:16 -0800)]
Add a new tree-sitter query predicate 'pred'
I realized that using an arbitrary function as the predicate in
queries is very helpful for some queries I'm writing for python and
javascript, and presumably most other languages[1].
Granted, we can already filter out unwanted nodes by using a function
instead of a face for the capture name, and (1) determine whether the
captured node is valid and (2) fontify that node if it's valid.
However, such approach is a bit more cumbersome and more importantly
gets in the way of another potential use of the fontification queries:
context extraction.
For example, I could use the query for the 'variable' feature to get
all the variables in a certain region. In this use-case, we want the
filtering happen before returning the captured nodes.
Besides, the change is relatively small and straightforward: most code
are already there, I just need to add some boilerplate.
[1] For a code like aa.bb(cc), we want bb to be in function face,
because obviously its a function. But for aa.bb, we want bb to be in
property face, because it's a property. In the AST, bb is always a
property, the difference between the two cases is the enclosing node:
in the first case, aa.bb is in a "call_expression" node, indicating
that bb is used as a function (a method). So we want a predicate
function that checks whether bb is used as a function or a property,
and determine whether it should be in function or property face.
* doc/lispref/parsing.texi (Pattern Matching): Update manual.
* src/treesit.c (Ftreesit_pattern_expand): Handle :pred.
(treesit_predicate_capture_name_to_node): A new function extracted
from treesit_predicate_capture_name_to_text.
(treesit_predicate_capture_name_to_text): Use the newly extracted
function.
(treesit_predicate_pred): New predicate function.
(treesit_eval_predicates): Add new predicate. Also fix a bug: we want
to AND the results of each predicate.
* test/src/treesit-tests.el (treesit--ert-pred-last-sibling): New
helper function.
(treesit-query-api): Test #pred predicate.
Stefan Kangas [Mon, 26 Dec 2022 20:22:42 +0000 (21:22 +0100)]
Improve gnutls-min-prime-bits docstring
* lisp/net/gnutls.el (gnutls-min-prime-bits): Doc fix: delete
out-of-date and now misleading sentence, added back when Emacs'
default minimum prime bits for a Diffie-Hellman handshake was only 256
bits. These days, the default is nil, which means to let GnuTLS
decide the value. (See also `nsm-protocol-check--dhe-prime-kx`.)
Gregory Heytings [Mon, 26 Dec 2022 00:20:59 +0000 (00:20 +0000)]
Improve handling of tab-bar height.
* src/xdisp.c (redisplay_tab_bar): When 'auto-resize-tab-bar' is
not 'grow-only', also consider the case when the tab-bar height
needs to shrink. Fixes bug#60210.
Paul Eggert [Mon, 26 Dec 2022 16:46:36 +0000 (08:46 -0800)]
Avoid duplicate inclusion of stdalign.h
* src/lisp.h: Do not include stdalign.h, as Gnulib now
approximates C23 (where stdalign.h does nothing) and config.h
already includes stdalign.h as needed on pre-C23 platforms.
Eli Zaretskii [Mon, 26 Dec 2022 13:26:48 +0000 (15:26 +0200)]
Simplify last change (bug#60311)
* src/json.c (json_available_p): Use original code. Always return
true for !WINDOWSNT.
(ensure_json_available): Now defined only on WINDOWSNT.
(Fjson_serialize, Fjson_insert, Fjson_parse_string)
(Fjson_parse_buffer): Call ensure_json_available only on
WINDOWSNT.
Kyle Meyer [Sun, 25 Dec 2022 20:31:33 +0000 (15:31 -0500)]
loaddefs-gen: Group results by absolute file name
loaddefs-generate produced an incomplete output file if 1) it
was called with a relative file name and 2) that same file was
specified via a generated-autoload-file cookie in a subset of
the input files. In that case, autoload entries were lost
because loaddefs-generate writes the same output file twice:
once for the relative name specified by the caller and once
for the absolute name that loaddefs-generate--parse-file
returns for the generated-autoload-file value.
This has been fixed. (Bug#60318)
* lisp/emacs-lisp/loaddefs-gen.el (loaddefs-generate): Expand file
names when grouping loaddef files.
Yuan Fu [Mon, 26 Dec 2022 09:39:02 +0000 (01:39 -0800)]
; Fix vindexes in parsing.texi
* doc/lispref/parsing.texi (Tree-sitter major modes): Replace vindex
with cross-reference to modes.texi. Add manual entry for
treesit-defun-type-regexp.
* lisp/treesit.el (treesit-defun-type-regexp): Use pred in docstring
since we use pred everywhere else.
Yuan Fu [Mon, 26 Dec 2022 09:01:41 +0000 (01:01 -0800)]
Fix imenu for c-ts-mode (bug#60296)
* lisp/progmodes/c-ts-mode.el (c-ts-mode--imenu-1): Use
c-ts-mode--defun-valid-p to filter out nested matches.
(c-ts-mode--defun-valid-p): Handle more types of nodes.
Yuan Fu [Mon, 26 Dec 2022 08:43:42 +0000 (00:43 -0800)]
Clean up python-ts-mode font-lock features
* lisp/progmodes/python.el (python--treesit-settings): Remove
unnecessary override flags, add function and variable feature, fix
assignment feature.
(python--treesit-variable-p)
(python--treesit-fontify-variable): New functions.
(python-ts-mode): Add function and variable feature.
Yuan Fu [Sun, 25 Dec 2022 19:21:50 +0000 (11:21 -0800)]
Add comment indent and filling to other tree-sitter major modes
Extract the setup into a function, and use it in other major modes.
* lisp/progmodes/c-ts-mode.el (c-ts-mode-comment-setup): New function.
(c-ts-base-mode): Extract out.
(c-ts-mode)
(c++-ts-mode): Remove old setup.
* lisp/progmodes/csharp-mode.el (csharp-ts-mode--indent-rules): New
indent rules.
(csharp-ts-mode): Use new setup function.
* lisp/progmodes/java-ts-mode.el (java-ts-mode--indent-rules): New
indent rules.
(java-ts-mode): Use new setup function.
* lisp/progmodes/js.el (js--treesit-indent-rules): New indent rules.
(js-ts-mode): Use new setup function.
* lisp/progmodes/rust-ts-mode.el (rust-ts-mode--indent-rules): New
indent rules.
(rust-ts-mode): Use new setup function.
* lisp/progmodes/typescript-ts-mode.el:
(typescript-ts-mode--indent-rules): New indent rules.
(typescript-ts-base-mode): Use new setup function.
Po Lu [Mon, 26 Dec 2022 07:57:06 +0000 (15:57 +0800)]
Redisplay "invisible" frames that are actually visible on modern X
* etc/NEWS: Document that "invisible" frames are now redisplayed
if the compositing manager is still displaying it as part of a
thumbnail out of Emacs's control.
* src/dispnew.c (Fredraw_display): Use FRAME_REDISPLAY_P.
* src/frame.h (FRAME_REDISPLAY_P): New macro.
* src/xdisp.c (clear_garbaged_frames, echo_area_display)
(prepare_menu_bars, redisplay_internal, display_and_set_cursor)
(gui_clear_cursor): Use FRAME_REDISPLAY_P to determine whether
or not a frame should be redisplayed.
* src/xfns.c (Fx_create_frame): Set visibility state initially.
* src/xterm.c (handle_one_xevent): Likewise.
* src/xterm.h (struct x_output): New field `visibility_state'.
; Always consider :lisp-dir when locating main file of VC packages
* lisp/emacs-lisp/package-vc.el (package-vc--main-file): Check the
:lisp-dir entry in the "extras" of a package description to find the
directory with a main file.
Yuan Fu [Sun, 25 Dec 2022 06:08:17 +0000 (22:08 -0800)]
Further generalize treesit-defun functions
Two new functions, treesit-beginning/end-of-thing. And
treesit-thing-at-point's signature changes.
* lisp/treesit.el (treesit-block-type-regexp): New variable.
(treesit-beginning-of-thing)
(treesit-end-of-thing): Generalized from
treesit-beginning/end-of-defun.
(treesit-beginning-of-defun)
(treesit-end-of-defun): Use the new functions.
(treesit-thing-at-point): Accept PATTERN rather than REGEXP and PRED.
(treesit-defun-at-point): Adjust for the new signature of
treesit-thing-at-point.
Yuan Fu [Sun, 25 Dec 2022 04:17:08 +0000 (20:17 -0800)]
Generalize treesit-defun functions to "things"
Change the "defun" in some functions (e.g. treesit--defuns-around) to
"thing". Add a function treesit-thing-at-point.
* lisp/treesit.el (treesit--thing-unpack-pattern): New subroutine.
(treesit-beginning-of-defun)
(treesit-end-of-defun): Use new function treesit--navigate-thing.
(treesit--defuns-around): Generalize into treesit--thing-around.
(treesit--top-level-defun): Generalize into treesit--top-level-thing.
(treesit--navigate-defun): Generalize into treesit--navigate-thing.
(treesit-thing-at-point): Generalized from treesit-defun-at-point.
(treesit-defun-at-point): Use treesit-thing-at-point to do tht work.
* lisp/emacs-lisp/package-vc.el (package-vc-install-dependencies): Add
new function.
(package-vc--unpack-1): Call 'package-vc-install-dependencies' instead
of 'package-compute-transaction' and 'package-download-transaction'.
It is unreasonable to abort the installation, since we cannot expect
all dependencies to be available in the regular archives. Instead we
note which packages couldn't be found, and warn the user that these
will be missing.
Stefan Kangas [Sun, 25 Dec 2022 05:30:21 +0000 (06:30 +0100)]
Merge from origin/emacs-29
c36fe3df17b Fix c-ts-mode imenu defun name (bug#60296) a24e350170e Fix treesit--children-covering-range-recurse (bug#60301) fbb4eb919b4 Support treesit-defun-name in tree-sitter major modes 6253184afc2 ; * lisp/treesit.el (treesit-defun-at-point): Guard again... f8e219ebfaa Add treesit-defun-name and friends 35c2ca2ca64 Make treesit-node-at/on guess language at point 7f7def2ae62 ; Add treesit-no-parser error b6a2e1ddf66 * nt/INSTALL.W64: update instructions for setting up W64 ... 265b91d891a Revert "; Bump minimum supported Windows version for MinG... 75155e45860 ; Bump minimum supported Windows version for MinGW64 to W... 677f6c79eb9 ; Update minimum requirements of MinGW-w64 7723af5e4aa ; * lisp/progmodes/c-ts-mode.el: quote literal string in ... 38866510c7c ; * src/xdisp.c (redisplay_internal): Reinstate the FRAME... a825aa0b135 Fix definition of CNS 11643-15 charset a42b20dd95e ; * lisp/progmodes/c-ts-mode.el: Add outline section head... e4e36345399 Improve c-ts-mode block comment indent (bug#60270) e30621caa2c ; Add treesit_recursion_limit 6a43af58802 Fix block comment indent and filling for c-ts-mode (bug#5... e492c21e810 Fix treesit_cursor_helper (bug#60267) 4437dbedf7b Fix restart-emacs alarms (Bug#60220) 121a9ff9f6f Fix alternate stack test in configure 84888080eea Add more functions to "string" shortdoc c90f97d4e5d Make the Contour terminal an alias of xterm-256color c3fac9465fa ; Fix punctuation in last change. 756bb422a49 Correct wrong info in (info)Go to node a8c3424d28b Fix typo in TUTORIAL.fr (bug#60261) 24cd2f0daf1 Add some diff-fixup-modifs tests d32091199ae Fix quoted argument in emacsclient-mail.desktop Exec key 286c48137f6 ert-x: Move window selection logic to its own macro 823c49cea85 ; ert-x: Simplify `ert-with-test-buffer-selected' 38c6abe4d0b ; ert-x: Add test for buffer read-only state 0e39ad6fa56 Fix crash after X error
Yuan Fu [Sun, 25 Dec 2022 02:59:39 +0000 (18:59 -0800)]
Fix c-ts-mode imenu defun name (bug#60296)
Extract out c-ts-mode--declarator-identifier from
c-ts-mode--fontify-declarator.
* lisp/progmodes/c-ts-mode.el (c-ts-mode--declarator-identifier): New
function.
(c-ts-mode--fontify-defun): Extract out.
(c-ts-mode--defun-name): Use the new function.
Yuan Fu [Sun, 25 Dec 2022 02:24:01 +0000 (18:24 -0800)]
Support treesit-defun-name in tree-sitter major modes
* lisp/progmodes/csharp-mode.el (csharp-ts-mode--defun-name): New
function.
(csharp-ts-mode--imenu-1): Extract into new function.
(csharp-ts-mode): Setup treesit-defun-name-function.
* lisp/progmodes/java-ts-mode.el (java-ts-mode--defun-name): New
function.
(java-ts-mode--imenu-1): Extract into new function.
(java-ts-mode): Setup treesit-defun-name-function.
* lisp/progmodes/js.el (js-treesit-current-defun): Remove function.
This function is not used (for a while already).
(js--treesit-defun-name): New function.
(js--treesit-imenu-1): Extract into new function.
(js-ts-mode): Setup treesit-defun-name-function.
* lisp/progmodes/json-ts-mode.el (json-ts-mode--defun-name): New
function.
(json-ts-mode--imenu-1): Extract into new function.
(json-ts-mode): Setup treesit-defun-name-function.
* lisp/progmodes/python.el (python--treesit-defun-name): New function.
(python--imenu-treesit-create-index-1): Extract into new function.
(python-ts-mode): Setup treesit-defun-name-function.
* lisp/progmodes/rust-ts-mode.el (rust-ts-mode--defun-name): New
function.
(rust-ts-mode--imenu-1): Extract into new function.
(rust-ts-mode): Setup treesit-defun-name-function.
* lisp/textmodes/css-mode.el (css--treesit-defun-name): New function.
(css--treesit-imenu-1): Extract into new function.
(css-ts-mode): Setup treesit-defun-name-function.
* lisp/textmodes/toml-ts-mode.el (toml-ts-mode--get-table-name):
Remove function.
(toml-ts-mode--defun-name): New function.
(toml-ts-mode--imenu-1): Extract into new function.
(toml-ts-mode): Setup treesit-defun-name-function.