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.
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.
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.
Yuan Fu [Sun, 25 Dec 2022 00:33:35 +0000 (16:33 -0800)]
Add treesit-defun-name and friends
1. We now have treesit-defun-name, powered by
treesit-defun-name-function.
2. We now have treesit-add-log-current-defun, which powers
add-log-current-defun.
3. c-ts-mode updates its code to take advantage of these new features.
4. Manual updates.
* doc/lispref/parsing.texi (Tree-sitter major modes): Add manual for
new functions.
* lisp/progmodes/c-ts-mode.el (c-ts-mode--defun-name): New function.
(c-ts-mode--imenu-1): Extract out into c-ts-mode--defun-name.
(c-ts-base-mode): Setup treesit-defun-name-function.
* lisp/treesit.el (treesit-defun-name-function)
(treesit-add-log-defun-delimiter): New variables.
(treesit-defun-at-point)
(treesit-defun-name): New functions.
(treesit-major-mode-setup): Setup add-log-current-defun-function.
Yuan Fu [Sat, 24 Dec 2022 23:31:03 +0000 (15:31 -0800)]
Make treesit-node-at/on guess language at point
If PARSER-OR-LANG is nil, it makes more sense to guess the language at
point by treesit-language-at than to simply use the first parser in
the parser list.
* doc/lispref/parsing.texi (Retrieving Nodes): Update manual.
* lisp/treesit.el (treesit-node-at)
(treesit-node-on): Guess language at point. Update docstring.
(treesit-buffer-root-node): Update docstring.
Eli Zaretskii [Sat, 24 Dec 2022 19:39:26 +0000 (21:39 +0200)]
Revert "; Bump minimum supported Windows version for MinGW64 to Windows 10."
This reverts commit 75155e458601a3597d382660d0be863ab4d512c0.
Evidently, some MSYS2/MinGW64 folks still think Windows 8.1
is the minimum supported version, even though MinGW-w64 switched
to Windows 10 as the default target in January 2022.
(condition-case X E (:success)) should return nil; the compiler
behaves correctly in this case.
* src/eval.c (internal_lisp_condition_case):
Evaluate an empty :success handler as nil instead of pretending it
isn't there.
* test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--test-cases):
Add test case.
(condition-case x A (:success B)) should not compile A for-effect even
if the entire form is in for-effect context.
* lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker):
Don't optimise the condition-case body form for effect (potentially
discarding its value) if there is a success handler and a variable.
* test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--test-cases):
Add test cases.
Eli Zaretskii [Sat, 24 Dec 2022 10:08:43 +0000 (12:08 +0200)]
Fix definition of CNS 11643-15 charset
* lisp/international/mule-conf.el (chinese-cns11643-15): Fix
:code-offset value. (Bug#60275)
* lisp/international/characters.el: Add chinese-cns11643-15 to
charsets whose characters have categories c and C.
Paul Eggert [Sat, 24 Dec 2022 09:08:21 +0000 (01:08 -0800)]
Assume make-directory handler follows new API
Suggested by Michael Albinus (Bug#58919#56).
* lisp/files.el (files--ensure-directory): Omit recently-added arg
MKDIR, since it is now always make-directory again. All uses
changed.
(make-directory): Assume the make-directory handler follows the
new API where it yields non-nil if DIR already exists. This
reverts some of the recent changes in this area, and simplifies
this funciton.
* lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-styles): Use new
matcher and anchor.
(c-ts-mode--looking-at-star): New matcher.
(c-ts-mode--comment-start-after-first-star): New anchor.
Yuan Fu [Sat, 24 Dec 2022 01:17:25 +0000 (17:17 -0800)]
; Add treesit_recursion_limit
* src/treesit.c (treesit_recursion_limit): New constant.
(treesit_cursor_helper)
(Ftreesit_search_subtree)
(Ftreesit_induce_sparse_tree): Use the new constant.
Yuan Fu [Sat, 24 Dec 2022 01:12:32 +0000 (17:12 -0800)]
Fix block comment indent and filling for c-ts-mode (bug#59763)
Now indent and filling works like in c-mode. The only noticeable
missing piece is that the "*/" is not attached to the last sentence
when filling. c-mode does it by replacing whitespaces between the
"*/" and the end of the last sentence with xxx, fill it, then change
the xxx back. I don't know if we should do that in c-ts-mode's filling.
* doc/lispref/modes.texi (Parser-based Indentation): Add new preset.
* lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-styles): Add new
indent rule.
(c-ts-mode--fill-paragraph): New function.
(c-ts-base-mode): Setup paragraph-start, adaptive-fill, etc.
* lisp/treesit.el (treesit-simple-indent-presets): Add new preset.
Yuan Fu [Fri, 23 Dec 2022 23:22:31 +0000 (15:22 -0800)]
Fix treesit_cursor_helper (bug#60267)
The cause of that bug is that in a particular parse tree, the node
treesit_cursor_helper tries to go to is a missing node, not only is it
a missing node, it is the first node of a subtree. So when
treesit_cursor_helper follows the algorithm and goes down the tree, it
goes down the previous subtree (because that subtree's end = end_pos,
because the target node has zero width).
o
|
o--+-o
| |
+-+ +-+-+
| | | | |
o x t o o
(We ended up in x when the target is t, because t has zero width.)
One way to solve it is to go back up the tree if we are at a leaf node
and still haven't matched the target node. That's too ugly and
finicky so I resorted to recursion. Now one more functions will
return give up (treesit_node_parent) if we are in a werid parse tree
that is super deep. But since we already kind of give up on this kind
of parse trees (bug#59426), it doesn't really hurt.
* src/treesit.c (treesit_cursor_helper_1): New function.
(treesit_cursor_helper): Use the new function. Change return type to
bool, and accept a cursor pointer.
(Ftreesit_node_parent)
(Ftreesit_search_subtree)
(Ftreesit_search_forward)
(Ftreesit_induce_sparse_tree): Use the new signature.
glacials [Thu, 22 Dec 2022 20:09:08 +0000 (12:09 -0800)]
Correct wrong info in (info)Go to node
The node (info)Go to node in the Info manual states that 'g'
does not allow the use of abbreviations, however it does.
To test this, type 'gt' from this node and see that it takes
you to (info)Top, then type 'ggo<RET>' and see that it takes
you back to (info)Go to node. Tested on emacs 28.2.
* doc/misc/info.texi (Go to node): Fix inaccurate information.
(Bug#60263)
Daniel Martín [Thu, 22 Dec 2022 18:10:24 +0000 (19:10 +0100)]
Add some diff-fixup-modifs tests
* test/lisp/vc/diff-mode-tests.el (diff-mode-test-fixups-added-lines):
Test that diff-mode fixes patches with added lines correctly.
* test/lisp/vc/diff-mode-tests.el (diff-mode-test-fixups-empty-hunks):
Ditto for patches with empty hunks. (Bug#60259)
Ulrich Müller [Mon, 19 Dec 2022 15:51:20 +0000 (16:51 +0100)]
Fix quoted argument in emacsclient-mail.desktop Exec key
Apparently the emacsclient-mail.desktop file doesn't conform to the
Desktop Entry Specification at
https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#exec-variables
which says about the Exec key:
| Field codes must not be used inside a quoted argument, the result of
| field code expansion inside a quoted argument is undefined.
However, the %u field code is used inside a quoted argument of the
Exec key in both the [Desktop Entry] and [Desktop Action new-window]
sections.
* etc/emacsclient-mail.desktop (Exec): The Desktop Entry
Specification does not allow field codes like %u inside a quoted
argument. Work around it by passing %u as first parameter ($1)
to the shell wrapper.
* etc/emacsclient.desktop (Exec): Use `sh` rather than `placeholder`
as the command name of the shell wrapper. (Bug#60204)
Richard Hansen [Sat, 17 Dec 2022 23:51:33 +0000 (18:51 -0500)]
ert-x: Move window selection logic to its own macro
* lisp/emacs-lisp/ert-x.el (ert-with-buffer-selected): New macro to
temporarily display a buffer in a selected window and evaluate a body.
(ert-with-test-buffer-selected): Use the new macro.
* test/lisp/whitespace-tests.el
(ert-test-with-buffer-selected/current)
(ert-test-with-buffer-selected/selected)
(ert-test-with-buffer-selected/nil-buffer)
(ert-test-with-buffer-selected/modification-hooks)
(ert-test-with-buffer-selected/read-only)
(ert-test-with-buffer-selected/return-value): Add tests.
(Bug#60189)
Richard Hansen [Sat, 17 Dec 2022 23:26:33 +0000 (18:26 -0500)]
; ert-x: Add test for buffer read-only state
This test should have been included with commit 29b7d740006fe2190a729bd1c30ccab9356cee36.
* test/lisp/emacs-lisp/ert-x-tests.el
(ert-test-with-test-buffer-selected/read-only): New test.
(Bug#60189)
Sean Whitton [Fri, 23 Dec 2022 03:54:08 +0000 (20:54 -0700)]
vc-git-checkin: Stash other staged changes
* lisp/vc/vc-git.el (vc-git--stash-staged-changes): New function.
(vc-git-checkin): Use new function to avoid needing to unstage changes
unrelated to the patch we want to commit (bug#60126).
Eli Zaretskii [Fri, 23 Dec 2022 14:41:08 +0000 (16:41 +0200)]
Fix "C-h k" in recursive minibuffers
* lisp/subr.el (event--posn-at-point): Leave POSN alone if it
doesn't have at least 6 members. This follows more faithfully
what 'event-start' and 'event-end' did before they started using
this function, see commit c1cead89f5f. Call posn-at-point with
the minibuffer-window when in the minibuffer. (Bug#60252)
Stefan Kangas [Fri, 23 Dec 2022 05:30:12 +0000 (06:30 +0100)]
Merge from origin/emacs-29
0754173c923 ; Fix docstring 014232d3840 Eglot: eglot--servers-by-xrefed-file doesn't need to be v... bbe35c280c2 Prevent stale servers when using eglot-extend-to-xref 9bf13a3fb9e ; * src/alloc.c (Fmemory_info): Doc fix. baa33a5c054 * etc/tutorials/TUTORIAL.cn: Fix typos. (Bug#60221) 98d7f76b451 Merge branch 'emacs-29' of git.savannah.gnu.org:/srv/git/... a488a6870ac Add alias for removed font-lock function 02e046566e2 Set beginning/end-of-defun-function in treesit-major-mode... 7dea58b88db Add treesit-defun-at-point and fix c-ts-mode-indent-defun 69123d4aa4e ; Fix treesit--defuns-around 05d8310fb5d Use the new keyword ':repeat' in repeatable keymaps.
Jim Porter [Tue, 20 Dec 2022 21:47:20 +0000 (13:47 -0800)]
Simplify handling of /dev/null redirection in Eshell
This also fixes an issue where "echo hi > foo > /dev/null" didn't
write to the file "foo". (Note that users can still use their
system's null device name when redirecting; Eshell doesn't need to do
anything special to support that.)
* test/lisp/eshell/em-extpipe-tests.el (em-extpipe-tests--deftest):
Skip over the newly-added 'eshell-with-copied-handles' form when
checking the parse results.
Jim Porter [Tue, 20 Dec 2022 06:21:10 +0000 (22:21 -0800)]
Add 'eshell-duplicate-handles' to return a copy of file handles
* lisp/eshell/esh-io.el (eshell-create-handles): Support creating with
multiple targets for stdout and/or stderr. Make the targets for a
handle always be a list, and store whether the targets are the default
in a separate 'default' field.
(eshell-protect-handles, eshell-close-handles)
(eshell-copy-output-handle, eshell-interactive-output-p)
(eshell-output-object): Update for changes in 'eshell-create-handles'.
(eshell-duplicate-handles, eshell-get-targets): New functions.
* lisp/eshell/esh-cmd.el (eshell-copy-handles): Rename and alias to...
(eshell-with-copied-handles): ... this function, and use
'eshell-duplicate-handles'.
(eshell-execute-pipeline): Use 'eshell-duplicate-handles'.
Michael Albinus [Thu, 22 Dec 2022 15:46:00 +0000 (16:46 +0100)]
Update Tramp version (don't merge with master)
* doc/misc/trampver.texi:
* lisp/net/trampver.el: Change version to "2.6.0.29.1".
(customize-package-emacs-version-alist):
Adapt Tramp version integrated in Emacs 29.1.
João Távora [Thu, 22 Dec 2022 11:29:49 +0000 (11:29 +0000)]
Prevent stale servers when using eglot-extend-to-xref
A weak-valued hash-table is not enough to guarantee that a reference
to a zombie server in eglot--servers-by-xrefed-file variable won't
survive long enough to confuse the next call to eglot--current-server
in some buffers.
So, before this fix it was common to get "Process EGLOT ... not
running" errors if some xref-extended buffers (like system libraries)
were open and M-x eglot-reconnect was issued. This should be
prevented now.
Note however, that even after this the eglot-extend-to-xref logic is
still flawed. For example, if a buffer for the xref-extended buffer
happens to be already visited by the time M-. is issued to navigate to
it, Eglot won't be activated. A half-decent workaround is to kill the
buffer and re-visit it.
* lisp/progmodes/eglot.el (eglot--servers-by-xrefed-file): Move
up.
(eglot--on-shutdown): Make sure to cleanup
eglot--servers-by-xrefed-file.