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.
* 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)
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)
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.
Jim Porter [Wed, 21 Dec 2022 00:20:50 +0000 (16:20 -0800)]
When redirecting in Eshell, check for "/dev/null" specifically
This is so that users can type "cmd ... > /dev/null" in Eshell no
matter what their system's null device is called. (Users can still
use their system's null device name when redirecting, too. Eshell
doesn't need to do anything special to support that.) This partially
reverts 67a8bdb90c9b5865b7f17290c7135b1a5458c36d. See bug#59545.
Do not merge to master.
* lisp/eshell/esh-io.el (eshell-set-output-handle): Use "/dev/null"
literally.
Eli Zaretskii [Wed, 21 Dec 2022 19:23:51 +0000 (21:23 +0200)]
Fix write-region to null device on MS-Windows
* src/fileio.c (write_region) [WINDOWSNT]: Ignore EBADF errors
from fsync -- this means fsync is not supported for this file.
Happens, for example, with the null device. (Bug#59545)
Richard Hansen [Tue, 13 Dec 2022 06:33:43 +0000 (01:33 -0500)]
whitespace: Avoid mutating original buffer's markers in clones
* lisp/whitespace.el (whitespace--clone): New hook function that is
run after cloning a buffer that copies `whitespace-bob-marker' and
`whitespace-eob-marker' and changes the copies to point to the new
buffer (Bug#59618).
(whitespace-color-on): Register the hook function.
(whitespace-color-off): Unregister the hook function.
* test/lisp/whitespace-tests.el
(whitespace-tests--with-test-buffer): New macro.
(whitespace-tests--check-markers): New function.
(whitespace-tests--indirect-clone-breaks-base-markers)
(whitespace-tests--indirect-clone-markers)
(whitespace-tests--regular-clone-markers): New tests.
Charl P. Botha [Sat, 10 Dec 2022 17:09:38 +0000 (19:09 +0200)]
Fix empty pairs in js tree-sitter imenu alist (bug#59945)
The current js--treesit-imenu, used by the JavaScript, TypeScript and
TSX tree-sitter modes, would return empty pairs in the imenu alist if
there were none of that type of symbol.
This would break both the built in imenu and also packages like
consult-imenu.
See https://github.com/minad/consult/issues/697 for the discussion
there.
Juri Linkov [Tue, 20 Dec 2022 17:22:15 +0000 (19:22 +0200)]
* lisp/repeat.el: Fix repeat-keep-prefix to allow customizing it to non-nil.
* lisp/repeat.el (repeat-keep-prefix): Add or remove
'repeat-pre-hook' depending on the customized value.
(repeat-mode): Add or remove 'repeat-pre-hook' to/from
'pre-command-hook' when 'repeat-keep-prefix' is non-nil.
(repeat-pre-hook): New function.
(repeat-get-map, repeat-check-map): New function refactored from
'repeat-post-hook'.
(repeat-post-hook): Move some code to smaller functions.
(describe-repeat-maps): Set outline-regexp without ^L.
* test/lisp/repeat-tests.el (repeat-tests-keep-prefix):
Uncomment test case that is fixed now in bug#51281 and bug#55986.
Dmitry Gutov [Mon, 19 Dec 2022 19:01:27 +0000 (21:01 +0200)]
ruby-method-params-indent: New user option
* lisp/progmodes/ruby-mode.el (ruby-method-params-indent):
New option (bug#60110).
(ruby-smie-rules): Use it.
* etc/NEWS: Mention it.
* test/lisp/progmodes/ruby-mode-resources/ruby.rb:
Ensure the var's value is default.
* test/lisp/progmodes/ruby-mode-resources/ruby-method-params-indent.rb:
New file.
* test/lisp/progmodes/ruby-mode-tests.el (ruby-deftest-indent):
New macro, use it to run the indentation test using the new file.
Disable the :expensive-test tag, because neither runs for "longer
than some few seconds", both take significantly below 1s.
Eli Zaretskii [Mon, 19 Dec 2022 17:01:04 +0000 (19:01 +0200)]
Fix storing email into nnmail by Gnus
* lisp/gnus/nnml.el (nnml--encode-headers): Wrap
'rfc2047-encode-string' calls with 'ignore-errors', to avoid
disrupting email workflows due to possibly-invalid headers.
Reported by Florian Weimer <fweimer@redhat.com>.
F. Jason Park [Mon, 12 Dec 2022 03:16:07 +0000 (19:16 -0800)]
; Really respect browse-url var in erc-compat
* lisp/erc/erc-compat.el: Do what was supposed to be done by 75f26646d4a569cfb485de4baddcda66ff44b2c3 "; Be nicer when updating
browse-url var in erc-compat". This is the less harmful version of
that patch (from bug#59976#8) but without the cl-lib requirement since
users may not want to load the main ERC library right away.
* lisp/erc/erc.el: Clarify some comments regarding the core API.
Richard Hansen [Mon, 19 Dec 2022 04:04:00 +0000 (23:04 -0500)]
whitespace: Fix unintended change in buffer modification status
* lisp/whitespace.el (whitespace--empty-at-bob-matcher)
whitespace--empty-at-eob-matcher, whitespace--update-bob-eob):
Silently add the `font-lock-multiline' text property when
highlighting beginning-of-buffer and end-of-buffer empty lines
to prevent Emacs from running modification hooks or considering
the buffer to be modified (Bug#60066).
* test/lisp/whitespace-tests.el
(whitespace-tests--empty-bob-eob-modified): Add a regression test.
Repair setopt test after error demotion to warning
* test/lisp/cus-edit-tests.el (test-setopt):
Check for a warrning instead of an error in attempt to call `setopt`
with a value that does not match the declared type (bug#60162).
Dmitry Gutov [Sun, 18 Dec 2022 12:01:47 +0000 (14:01 +0200)]
ruby-mode: Support endless methods (bug#54702)
* lisp/progmodes/ruby-mode.el (ruby-endless-method-head-re):
New constant.
(ruby-smie-grammar): New token.
(ruby-smie--forward-token, ruby-smie--backward-token):
Recognize it.
(ruby-smie-rules): Indentation support.
(ruby-add-log-current-method): Support here too.
* test/lisp/progmodes/ruby-mode-tests.el
(ruby-add-log-current-method-after-endless-method): New test.
* test/lisp/progmodes/ruby-mode-resources/ruby.rb: New examples.
Gregory Heytings [Sun, 18 Dec 2022 10:46:48 +0000 (10:46 +0000)]
Improve and extend admin/git-bisect-start
* admin/git-bisect-start: Use 'git bisect skip' instead of 'git
bisect good' for merges of external trees, which is equivalent but
faster in some cases. Improve the explanation on external tree
merges. Add list of commits in the last six years on which
building Emacs fails, and call 'git bisect skip' on them. Also
document how the script can be called automatically when 'git
bisect start' is called in the Emacs repository.
* admin/notes/repo (Bisecting): Adapt the explanation of the
script accordingly.
Andrea Monaco [Fri, 9 Dec 2022 20:22:22 +0000 (21:22 +0100)]
Make 'rmail-summary-by-thread' faster
* lisp/mail/rmailsum.el (rmail-summary-message-parents-vector)
(rmail-summary-message-descendants-vector): Doc fixes.
(rmail-summary-message-descendants-vector): New variable.
(rmail-summary-fill-message-parents-and-descs-vectors): Renamed
from 'rmail-summary-fill-message-parents-vector' and rewritten.
(rmail-summary-direct-descendants): Function deleted.
Eli Zaretskii [Sun, 18 Dec 2022 08:29:34 +0000 (10:29 +0200)]
Avoid crashes in PGTK build due to signal in 'note_mouse_highlight'
* src/xdisp.c (string_buffer_position): Make sure the TO argument
of 'string_buffer_position_lim' is always inside [BEGV..ZV].
Otherwise 'string_buffer_position_lim' might call
'get-char-property' and friends with invalid position, which will
just signal an error and do nothing useful. (Bug#60144)
Eli Zaretskii [Sun, 18 Dec 2022 05:57:34 +0000 (07:57 +0200)]
Fix MS-Windows build broken by recent treesit.c changes
* src/treesit.c (init_treesit_functions, ts_tree_cursor_copy)
(ts_tree_cursor_delete): Add boilerplate for using new tree-sitter
functions.
(ts_node_parent): Delete boilerplate of unused function.
Fix wrong capture in typescript-ts-mode (bug#60167)
An example of the issue could be:
<Menu.Item>
{({ active }) => (
link
? <Link to={link}> {text}</Link>
: <a href="#" onClick={onClick}>{text}</a>
)}
</Menu.Item>
Here 'link' as well as a lot of the other constructs inside of the
parenthesized expression will be font-locked with
'font-lock-variable-name-face'. We only want to capture the
identifier.
* lisp/progmodes/typescript-ts-mode.el
(typescript-ts-mode--font-lock-settings): Make the variable capture
only capture the identifier, and not the whole expression.
Randy Taylor [Fri, 16 Dec 2022 21:05:29 +0000 (16:05 -0500)]
Add rust-ts-mode (Bug#60136)
* etc/NEWS: Mention it.
* lisp/progmodes/eglot.el (eglot-server-programs): Add it.
* lisp/progmodes/rust-ts-mode.el: New major mode with
tree-sitter support.
Yuan Fu [Sat, 17 Dec 2022 23:01:57 +0000 (15:01 -0800)]
Switch to use cursor API in treesit.c
ts_node_parent has bugs (bug#60054), using cursor API avoids that.
Tree-sitter's author might remove ts_node_parent in the future, so
might as well switch to use cursors now. We are basically
reimplementing some of the logic of ts_node_prev_sibling and
ts_node_parent in the sibling helper and cursor helper functions.
See also https://github.com/tree-sitter/tree-sitter/issues/1992
* src/treesit.c (treesit_traverse_sibling_helper)
(treesit_traverse_child_helper)
(treesit_traverse_match_predicate): Reimplemented to use the cursor API.
(treesit_search_dfs)
(treesit_search_forward): Use the new cursor helper functions.
(Ftreesit_search_subtree)
(Ftreesit_search_forward)
(Ftreesit_induce_sparse_tree): Use cursors.
* test/src/treesit-tests.el (treesit-search-subtree): New test.
(treesit--ert-search-setup): New macro.
(treesit-search-forward)
(treesit-search-forward-named-only)
(treesit-search-backward)
(treesit-search-backward-named-only)
(treesit-cursor-helper-with-missing-node): New tests.
Yuan Fu [Sat, 17 Dec 2022 22:59:01 +0000 (14:59 -0800)]
Add treesit_assume_true and treesit_cursor_helper
This is part 1 of the change to change node API to cursor API. See
the second part for more detail. (I splitted the change to make the
diff more sane.)
* src/treesit.c (treesit_assume_true)
(treesit_cursor_helper): New functions.
Paul Eggert [Sat, 17 Dec 2022 22:41:48 +0000 (14:41 -0800)]
Remove file-exists-in-trash-p
* lisp/files.el (file-exists-in-trash-p): Remove, as this name is
not suitable for users. All uses replaced by file-attributes,
which is good enough here.
Paul Eggert [Sat, 17 Dec 2022 20:15:30 +0000 (12:15 -0800)]
Fix copy-directory bug when dest dir exists
* lisp/files.el (copy-directory): Set ‘follow’ depending on
whether we made the directory, not based on a guess that is
sometimes wrong. When NEWNAME is a directory name and
COPY-CONTENTS is nil, do not object merely because the adjusted
NEWNAME is already a directory. (Bug#58919).
* test/lisp/files-tests.el (files-tests-copy-directory):
Test for the bug.
Paul Eggert [Sat, 17 Dec 2022 20:15:30 +0000 (12:15 -0800)]
make-directory now returns t if dir already exists
This new feature will help fix a copy-directory bug (Bug#58919).
Its implementation does not rely on make-directory handlers
supporting the new feature, as it no longer uses a make-directory
handler H in any way other than (funcall H DIR), thus using
only the intersection of the old and new behavior for handlers.
This will give us time to fix handlers at our leisure.
* lisp/files.el (files--ensure-directory): New arg MKDIR.
All uses changed.
(files--ensure-directory, make-directory):
Return non-nil if DIR is already a directory. All uses changed.
* test/lisp/files-tests.el (files-tests-make-directory):
Test new return-value convention.
Paul Eggert [Sat, 17 Dec 2022 20:15:30 +0000 (12:15 -0800)]
Use make-directory handlers uniformly
Formerly, the code supported both make-directory and
make-directory-internal handlers. This led to confusion and meant than
in a few cases (nnmaildir, ido) remote directories could not be used in
some cases. Fix this by using only make-directory handlers.
Perhaps there used to be a reason for why there were both
make-directory and make-directory-internal handlers, but whatever that
reason was, it seems to have vanished even before now.
There is no longer any need for make-directory-internal handlers, as
the few remaining callers that use make-directory-internal do so only
when there are no handlers. However, this change keeps the existing
make-directory-internal handlers for now, in case this code is ever
used in older Emacs versions that still call those handlers.
* lisp/gnus/nnmaildir.el (nnmaildir--mkdir):
* lisp/ido.el (ido-file-internal):
* lisp/net/tramp-smb.el (tramp-smb-handle-make-directory):
Use make-directory, not make-directory-internal.
* lisp/net/tramp-smb.el (tramp-smb-handle-make-directory-internal):
Now obsolete.
* src/fileio.c (Fmake_directory_internal): Do not look for or
use a make-directory-internal handler.
* test/lisp/files-tests.el:
(files-tests-file-name-non-special-make-directory-internal):
Remove, as this test incorrectly assumes that make-directory-internal
must support handlers.
Eli Zaretskii [Sat, 17 Dec 2022 18:35:11 +0000 (20:35 +0200)]
Prevent Abort dialogs from async-compiling jobs on Windows
* lisp/emacs-lisp/comp.el (comp-run-async-workers): Disable Abort
dialog popping in the sub-processes that perform async
compilation, by passing w32-disable-abort-dialog=t on their
command line.