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.
Randy Taylor [Tue, 13 Dec 2022 14:41:01 +0000 (09:41 -0500)]
Add yaml-ts-mode (Bug#60105)
* admin/notes/tree-sitter/build-module/batch.sh:
* admin/notes/tree-sitter/build-module/build.sh: Add yaml support.
* etc/NEWS: Mention it.
* lisp/textmodes/yaml-ts-mode.el: New major mode with
tree-sitter support.
* lisp/progmodes/eglot.el (eglot-server-programs): Add it.
* lisp/cedet/semantic/complete.el (semantic-displayer-show-request):
* lisp/descr-text.el (describe-char-categories):
* lisp/mh-e/mh-identity.el (mh-select-identity):
* lisp/transient.el (transient--delay-post-command)
(transient--post-command):
* lisp/vc/vc-git.el (vc-git-create-tag):
* test/lisp/emacs-lisp/cl-lib-tests.el
(cl-lib-nth-value-test-multiple-values):
* lisp/emulation/viper-cmd.el (viper-preserve-cursor-color):
Use `equal` instead of `eq` and `member` instead of `memq` where
the comparison is with literals without guaranteed identity.
In some cases this change corrects evident bugs, in others it is
mostly cosmetic.
* lisp/emacs-lisp/byte-opt.el (byte-optimize-if):
Remove explicit clauses purposing to simplify
(if X nil t) -> (not X)
(if X t nil) -> (not (not X))
but never did so because of a coding mistake (eq instead of equal),
found by a recently added warning. They weren't actually needed
thanks to the optimiser's fixpoint iteration: we eventually get the
same results through
(if X nil t) -> (if (not X) t nil) -> (if (not X) t) -> (not X)
(if X t nil) -> (if X t) -> (not (not X))
* lisp/emacs-lisp/gv.el (alist-get):
Evaluate TESTFN exactly once (previously up to 3 times).
Reduce the macro-expansion to include a call to either assoc or assq,
not both; this reduces the generated code size in some cases.
Eli Zaretskii [Fri, 16 Dec 2022 15:54:35 +0000 (17:54 +0200)]
Fix moving to trash files that overwrite dangling symlinks there
* lisp/files.el (file-exists-in-trash-p): New function.
(move-file-to-trash): Use it instead of 'file-exists-p' when
testing whether the file exist in the trash. (Bug#59986)
Eli Zaretskii [Fri, 16 Dec 2022 15:43:46 +0000 (17:43 +0200)]
; Add useful hint to which-func documentation
* lisp/progmodes/which-func.el (which-func-non-auto-modes)
(which-func-maxout): Mention the slow startup with Eglot and
how to work around that. (Bug#60107)
F. Jason Park [Mon, 12 Dec 2022 15:38:44 +0000 (07:38 -0800)]
Fix some naming issues involving query buffers in ERC
* lisp/erc/erc-networks.el
(erc-networks-rename-surviving-target-buffer): Don't kill a surviving
target buffer when another, non-target buffer, possibly not even
belonging to ERC, already exists and sports the target's name.
(erc-networks--reconcile-buffer-names): Always append a network-ID
suffix to a target buffer's name if another buffer of that name
already exists. (Bug#59976.)
* lisp/erc/erc.el (erc, erc-tls): Revise `:id' portion of doc strings.
Thanks to Mike Kazantsev for the suggestion and for filing this bug
and helping solve it.
* test/lisp/erc/erc-networks-tests.el:
(erc-networks-rename-surviving-target-buffer--query-non-target): Add
new test.
* test/lisp/erc/erc-scenarios-base-association-query.el: New file.
* test/lisp/erc/resources/base/assoc/queries/netnick.eld: New file.
* test/lisp/erc/resources/base/assoc/queries/non-erc.eld: New file.
F. Jason Park [Fri, 16 Dec 2022 07:25:10 +0000 (23:25 -0800)]
; Fix doc string in ERC's module-activation commands
* lisp/erc/erc-common.el (erc--assemble-toggle): Previously, the doc
string implied that a prefix argument was necessary to achieve
connection-wide effects, which might lead a person to think the
interactive code should be an uppercase "P".
* test/lisp/erc/erc-tests.el (define-erc-module--local): Update
expected result of code-gen.
Eli Zaretskii [Fri, 16 Dec 2022 14:29:51 +0000 (16:29 +0200)]
A better fix for bug#60096
* lisp/startup.el (initial-scratch-message):
* lisp/simple.el (get-scratch-buffer-create): Revert last changes.
* src/window.c (Fset_window_configuration): Force recalculation of
Vwindow_list after restoring the windows.
* src/buffer.c (other_buffer_safely): Make sure we always return a
valid buffer, even if 'get-scratch-buffer-create' signals an
error.
Due to a typo, the defvar eglot--command-history wasn't actually used
in eglot-guess-contact as intended. That function used a
single-dash-name version of the variable instead.
This worked fine, except that two variables were created instead of
one, and the one actually being used didn't have any docstring.
Rename the variable to eglot-command-history to fix this. It's better
than renaming the reference in eglot-guess-contact which would lose
user's history for M-x eglot.
* lisp/progmodes/eglot.el (eglot-command-history): Rename from
eglot--command-history.
João Távora [Thu, 15 Dec 2022 15:26:13 +0000 (15:26 +0000)]
Avoid recursive process filters in lisp/jsonrpc.el (bug#60088)
jsonrpc.el may lose JSON-RPC messages because of recursive process
filters. The problem happens in jsonrpc.el's jsonrpc--process-filter.
The code of the process filter didn't expect to be called recursively
and fails in that case.
But that can happen if the three conditions are verified.
1. the client code invoked by its jsonrpc--connection-receive inside
the process filter callee immediately sends follow-up input to
process within the same Lisp stack. This is a common scenario,
especially during LSP initialiation sequence used by Eglot, a
jsonrpc.el client.
2. that follow-up message is large enough for process-send-string to
send the input in bunches (output from processes can arrive in
between bunches).
3. the process happens to have already some more output ready
The fix in this commit detects recursive invocations and immediately
re-schedules them as non-recursive calls to the
jsonrpc--process-filter (but started from timers).
* lisp/jsonrpc.el (jsonrpc--process-filter): Rework.
(Version): Bump to 1.0.16.
Yuan Fu [Fri, 16 Dec 2022 01:44:07 +0000 (17:44 -0800)]
Use the new tree-sitter commands
* lisp/progmodes/c-ts-mode.el (c-ts-mode--defun-valid-p)
(c-ts-mode--defun-skipper): New functions.
(c-ts-base-mode): Setup defun navigation.
* lisp/progmodes/sh-script.el (bash-ts-mode): Setup defun navigation.
* lisp/treesit.el (treesit-beginning-of-defun)
(treesit-end-of-defun): Change to new implementation, which is
intended to be used as commands.
(treesit-major-mode-setup): Setup remap for beginning/end-of-defun
commands.
Yuan Fu [Fri, 16 Dec 2022 01:25:06 +0000 (17:25 -0800)]
Add "function" feature to python-ts-mode (bug#59977)
* lisp/progmodes/python.el (python--treesit-settings): Add feature.
(python-ts-mode): Add feature. And fix indentation for the
python-indent-guess-indent-offset code.
Eli Zaretskii [Thu, 15 Dec 2022 21:39:58 +0000 (23:39 +0200)]
Avoid segfaults due to invalid selected-window's buffer
* lisp/startup.el (initial-scratch-message): Don't use \\[...]
commands for substitute-command-keys.
* lisp/simple.el (get-scratch-buffer-create): Don't call
substitute-command-keys on initial-scratch-message, to avoid
signaling an error in rare cases. (Bug#60096)
Make tab-bar-tab-group-format-function also handle current group
* lisp/tab-bar.el (tab-bar--format-tab-group): Call
'tab-bar-tab-group-format-default' to format current group tab.
(tab-bar-tab-group-format-default): Update function to also handle
current group tab (bug#60073).
Ensure package directories for source packages from checkouts
* lisp/emacs-lisp/package-vc.el (package-vc-install-from-checkout):
Set the :dir entry, since `package-vc--unpack-1' assumes the field is
set, as is the case when invoking `package-vc--unpack'.
Eli Zaretskii [Thu, 15 Dec 2022 08:47:11 +0000 (10:47 +0200)]
Mention 'tree-sitter' in user manual and NEWS
* doc/emacs/programs.texi (Program Modes): Mention tree-sitter and
the modes supported by it.
* etc/NEWS: Mention tree-sitter in the Installation Changes
section.
Dmitry Gutov [Thu, 15 Dec 2022 01:21:14 +0000 (03:21 +0200)]
Fix ruby-add-log-current-method after nested class definition
* lisp/progmodes/ruby-mode.el (ruby--add-log-current-indent):
New function.
(ruby-add-log-current-method): Use it.
Check for "class" and "module" indentation to filter out the
definitions which don't include the given position. Also try to
match "def" only once (for performance), because if the closest
one doesn't include the given position, none will.
* test/lisp/progmodes/ruby-mode-tests.el
(ruby-add-log-current-method-after-inner-class-outside-methods)
(ruby-add-log-current-method-after-inner-class-outside-methods-with-text):
New tests.