Yuan Fu [Sat, 4 Mar 2023 22:39:44 +0000 (14:39 -0800)]
Fix c-ts-mode preproc directive indentation
Mentioned in bug#61893, although not the subject of that report. This
change fixes indentation for nested directives. For example, when the
directive involves elif and the like, the elif is nested in the if
directive, so simply using grand-parent and great-grand-parent for
anchor is insufficient, because the nesting can grow arbitrarily.
The test added also covers the last preproc fix.
* lisp/progmodes/c-ts-mode.el:
(c-ts-mode--standalone-parent-skip-preproc): New function.
(c-ts-mode--indent-styles): New rules.
* test/lisp/progmodes/c-ts-mode-resources/indent-preproc.erts: New test.
João Távora [Sat, 4 Mar 2023 19:14:48 +0000 (19:14 +0000)]
More robustly unspoof HOME in Eglot tests (bug#61637)
A fair number of LSP servers allow user-local installations instead of
system wide installations. Emacs's technique of spoofing the HOME env
var to some non-existent or non-home directory during 'make check'
breaks these tests. That's because the executables are still found by
executable-find, but their invocation will rarely be successful as
HOME isn't what they expect it to be.
Eglot tests already had a technique for dealing with this,
"unspoffing" HOME just for the invocations of LSP server but it
stopped working a while back. So make it more robust.
Eventually, we'll want to decide wether these local servers should be
considered in 'make check' runs at all, or whether there is a way to
use them with a spoofed HOME.
* test/lisp/progmodes/eglot-tests.el (eglot--call-with-fixture):
More robustly unspoof HOME.
* lisp/progmodes/eglot.el (eglot--maybe-activate-editing-mode):
Activate eglot-inlay-hints-mode.
(eglot-inlay-hints-mode): Instead of warning about missing
:inlayHintProvider, turn off eglot-inlay-hints-mode.
João Távora [Sat, 4 Mar 2023 12:49:00 +0000 (12:49 +0000)]
Robustify Eglot for "transient" projects
When Eglot needs to synthesize a "transient" project for
default-directory sometimes the value of that variable is set to an
unexpanded value, sometimes not. This can cause simple invocations
like.
Emacs -Q ~/path/to-some-python-file.py -f eglot
to fail, because eglot--current-server will be looking for a project
in the registry called
(transient . "~/path")
where in reality it is stored there as
(transient . "/home/someuser/path")
The fix is to always expand default-directory in eglot--current-project.
* lisp/progmodes/eglot.el (eglot--current-project): Use
expand-file-name.
João Távora [Sat, 4 Mar 2023 00:09:32 +0000 (00:09 +0000)]
Remove Eglot activation check from find-file-hook
Adding eglot--maybe-activate-editing-mode to find-file-hook isn't
really necessary, since it is already in
'after-change-major-mode-hook', and that also runs every time we find
a file.
This reduces the number of project.el logic that runs every time the
user visits a file.
* lisp/progmodes/eglot.el (find-file-hook): No need to add
eglot--maybe-activate-editing-mode here.
When `total_length` is 0 there should be no subtree at all, but
`delete_interval` only deletes one interval, so make sure we don't end
up with some stale child of `i`.
F. Jason Park [Tue, 14 Feb 2023 07:27:50 +0000 (23:27 -0800)]
Release ERC 5.5
* doc/misc/erc.texi: Update ERCVER to 5.5.
* lisp/erc/erc.el: Increment main version header to 5.5. Update
Compat version in package-requires header to 29.1.3.4. Update
`customize-package-emacs-version-alist' entry by mapping ERC 5.5 to
Emacs 29.1.
(erc-version): Update value to 5.5.
Jim Porter [Tue, 28 Feb 2023 19:35:21 +0000 (11:35 -0800)]
Don't create GUI frames in batch sessions
This resolves an issue with running test/lisp/server-tests.el when
'DISPLAY' is set: the tests would start the Emacs server in a batch
session, and then request a new GUI frame. However, that caused the
tests to terminate with SIGIO, since a batch Emacs doesn't set a SIGIO
handler.
Yuan Fu [Fri, 3 Mar 2023 03:59:11 +0000 (19:59 -0800)]
Fix c-ts-mode indentation for statement after preproc (bug#61893)
Originally our c-ts-mode--anchor-prev-sibling only specially handled
labeled_statements, now we add special case for preproc in the similar
fasion: instead of using the preproc directive as anchor, use the last
statement in that preproc as the anchor. Thus effectively ignore the
preproc.
There should be an accompanying test, but there are some problem in
the elif preproc directive indent so it would pass, we'll add the test
when that is fixed.
* lisp/progmodes/c-ts-mode.el:
(c-ts-mode--anchor-prev-sibling): Add special case for preproc
directives.
Eli Zaretskii [Thu, 2 Mar 2023 12:21:33 +0000 (14:21 +0200)]
Fix wdired-tests on MS-Windows
* test/lisp/wdired-tests.el (wdired-test-bug32173-01)
(wdired-test-bug32173-02, wdired-test-unfinished-edit-01)
(wdired-test-bug39280): Run test-dir through file-truename, to
avoid failures due to MS-Windows "numeric tails" (mis)feature and
similar issues, which make file names fail to compare 'equal'.
(wdired-test-bug34915, wdired-test-bug61510): Skip if symlinks
fail.
* src/nsxwidget.m ()
([XwWebView initWithFrame:configuration:xwidget:])
(nsxwidget_init): Fixed memory leaks: when sending an alloc
message to an object, send an autorelease message to any objects
we won't explictly release.
([XwWebView webView:didFinishNavigation:]): Second string to
store in 'store_xwidget_event_string' is "load finished" rather
than empty string.
([XwWebView webView:didStartProvisionalNavigation:])
([XwWebView webView:didReceiveServerRedirectForProvisionalNavigation:])
([XwWebView webView:didCommitNavigation:]): New functions.
(nsxwidget_webkit_estimated_load_progress): New function.
(nsxwidget_webkit_stop_loading): New function.
* src/xwidget.c (Fxwidget_webkit_estimated_load_progress): Call
'nsxwidget_webkit_estimated_load_progress' if we're on MacOS.
(Fxwidget_webkit_stop_loading): Call 'nsxwidget_webkit_stop_loading'
if we're on MacOS.
(syms_of_xwidget): Define symbol for function.
'xwidget_webkit_estimated_load_progress' if we're on MacOS.
* src/nsxwidget.h: Signature for functions
'nsxwidget_webkit_estimated_load_progress' and
'nsxwidget_webkit_stop_loading'.
* lisp/xwidget.el (xwidget-webkit-current-url): Message URL rather
than return value of 'kill-new' (which is always nil).
Yuan Fu [Wed, 1 Mar 2023 22:34:56 +0000 (14:34 -0800)]
Don’t signal warning when loading go-ts-mode.el without grammar
* lisp/progmodes/go-ts-mode.el: Add a QUIET flag to the call of
treesit-ready-p, so that it doesn't signal a warning if
go-mod (tree-sitter grammar) is not available.
Yuan Fu [Wed, 1 Mar 2023 22:01:47 +0000 (14:01 -0800)]
Fix c-ts-mode empty line indentation (bug#61893)
* lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-styles): Make the
"rest sibling" matchers catch the case where NODE is nil, when
indenting an empty line.
* test/lisp/progmodes/c-ts-mode-resources/indent.erts: New test.
Yuan Fu [Wed, 1 Mar 2023 21:55:53 +0000 (13:55 -0800)]
Improve tree-sitter's prev-sibling indent anchor
Now it handles the case where NODE is nil when indenting an empty
line: it tries to get the previous sibling nonetheless.
* lisp/progmodes/c-ts-mode.el (c-ts-mode--anchor-prev-sibling):
* lisp/treesit.el (treesit-simple-indent-presets): Add an or form to
handle more cases.
Juri Linkov [Mon, 27 Feb 2023 18:32:53 +0000 (20:32 +0200)]
* lisp/icomplete.el: Fix in-buffer completion.
(icomplete-force-complete-and-exit, icomplete-force-complete): Use
'icomplete--field-beg/end' when not in the minibuffer to not erase
the current buffer. Also disable 'completion-in-region-mode' instead
of calling 'exit-minibuffer' (bug#45764, bug#51575, bug#61479).
The `noerror` arg of `require` doesn't do what Stefan naively thought
when he wrote this code, so use `condition-case` instead.
Also check for `cl-defmethod` since `cl-prin1` can't be loaded before
that anyway.
Eli Zaretskii [Wed, 1 Mar 2023 15:35:51 +0000 (17:35 +0200)]
Revert "Don't disable eldoc when doing edebug"
This reverts commit 6fd1fb8a6837acde8e1c9ab26618ec0f36121c72.
It turns out ElDoc does show messages inside Edebug, if you
are (un)lucky enough to have point where ElDoc has something
to show. Bug#56459 needs to be fixed in some more complex
way.
Yuan Fu [Wed, 1 Mar 2023 07:51:06 +0000 (23:51 -0800)]
Fix treesit-indent-region
Fix it for the case where there is no suitable rule for the line.
Right now treesit-indent-region would indent the line to column 0.
After the change the indentation is not altered.
* lisp/treesit.el (treesit-indent-region): Handle the case where
ANCHOR or OFFSET is nil specially.
Now consult .dir-locals.el every time the workspace configuration is
needed:
- workspace/configuration server request
- workspace/didChangeConfiguration signal
- M-x eglot-show-workspace-configuration
The major-mode/hack-dir-local-variables-non-file-buffer trick is used.
When there is more than one, the server connection's "main" major mode
is used to find the relevant .dir-locals.el section.
Eli Zaretskii [Tue, 28 Feb 2023 13:15:27 +0000 (15:15 +0200)]
; Add a doc string for 'ediff-window-display-p' obsolescence
* lisp/vc/ediff-init.el (ediff-window-display-p): Document how to
prevent Ediff from creating additional frames, now that this
function can no longer be used or advised for that. (Bug#61850)
Dmitry Gutov [Tue, 28 Feb 2023 02:07:55 +0000 (04:07 +0200)]
Rename the newly added -ref- faces to -use-
* lisp/font-lock.el (font-lock-variable-use-face)
(font-lock-property-use-face): Rename from font-lock-variable-ref-face
and font-lock-property-ref-face. Update all references (bug#61655).
Arash Esbati [Mon, 27 Feb 2023 09:10:13 +0000 (10:10 +0100)]
; Add `nnimap-user' to Gnus manual
* doc/misc/gnus.texi (Customizing the IMAP Connection): Document
backend variable `nnimap-user' which was introduced with commit 5e68f8614f in 2011.
Add index entries for all backend variables. (bug#61837)
João Távora [Mon, 27 Feb 2023 11:29:32 +0000 (11:29 +0000)]
Eglot: protect against unintended field text motion (bug#61726)
Suggested-by: Augusto Stoffel <arstoffel@gmail.com>
* lisp/progmodes/eglot.el (eglot--bol): New helper.
(eglot-utf-8-linepos, eglot-utf-16-linepos)
(eglot-utf-32-linepos, eglot-move-to-utf-8-linepos)
(eglot-move-to-utf-16-linepos, eglot-move-to-utf-32-linepos)
(eglot-handle-notification, eglot--xref-make-match)
(eglot-completion-at-point): Use it.
Yuan Fu [Mon, 27 Feb 2023 08:14:32 +0000 (00:14 -0800)]
Adjust tree-sitter defun navigation (bug#61617)
Before this change, when you use a tree-sitter navigation function to
move to the next beginning of a thing, it jumps over the immediate
next thing and lands you at the beginning of the next-next thing.
Eg, when point is at the "|", and we evaluate
(treesit--navigate-thing pos 1 'beg), we go from
| (thing) (thing)
to
(thing) |(thing)
But some might expect point to go to
|(thing) (thing)
instead, which makes sense. Also, that's how Emacs expect defun
navigation functions to work. The discrepancy in expectation causes
bug#61617.
In this change I made tree-sitter navigation functions to work as what
Emacs expects. And what I described for moving to the next beginning
of thing is similarly applicable to moving to the end of previous end
of thing.
* lisp/treesit.el (treesit-beginning-of-defun)
(treesit-end-of-defun): Handle the case where defun-skipper moves
point back to where we started, by adding a retry.
(treesit--navigate-thing): Add a single condition checking for
progress to the condition form responsible for checking whether to
skip the next defun. Namely (eq pos (funcall advance next)))).
* test/src/treesit-tests.el:
(treesit--ert-defun-navigation-nested-master)
(treesit--ert-defun-navigation-top-level-master): Change tests to
reflect the new expectation.
Yuan Fu [Mon, 27 Feb 2023 02:05:13 +0000 (18:05 -0800)]
New tree-sitter indent anchor standalone-parent used by c-ts-mode
When writing c-ts-mode Theo used parent-bol which works well except
one case:
1 for (int i=0;
2 i < 5;
3 i++) {
4 func(i);
5 }
In this case, when indenting "func(i)", parent-bol returns the start
of "i++" on line 3, instead of the "correct" anchor, the start of
"for" on line 1. parent-bol would have worked if the "for (...) {"
part is in one line.
To support this case I tried numerous things and added a bunch of
stuff, culminating in c-ts-common-statement-offset. It's complicated,
requires extra setup, and slow.
Not anymore! I think the new anchor standalone-parent really captures
the logic behind how people expect indentation to work. It's simple
and fast, and requires no setup.
Eli Zaretskii [Sun, 26 Feb 2023 17:51:59 +0000 (19:51 +0200)]
; Improve documentation of loading *.eln files
* doc/lispref/loading.texi (How Programs Do Loading):
* doc/emacs/building.texi (Lisp Libraries): Some additional
details about what happens with natively-compiled files.
Augusto Stoffel [Sun, 26 Feb 2023 11:47:32 +0000 (11:47 +0000)]
Eglot: support positionEncoding LSP capability (bug#61726)
* lisp/progmodes/eglot.el(eglot-client-capabilities): Announce the
new capability.
(eglot-bytewise-column, eglot-move-to-bytewise-column): New functions.
(eglot--managed-mode): Set 'eglot-current-column-function' and
'eglot-move-to-bytewise-column' appropriately.
Eli Zaretskii [Sat, 25 Feb 2023 15:19:15 +0000 (17:19 +0200)]
Fix infloop in bidi.c
* src/bidi.c (bidi_set_paragraph_end): Reset the isolate_level to
zero. Whenever stack_idx is reset to zero, the isolate_level must
also be reset, since there cannot be any isolate status outside of
embeddings. Failure to reset isolate_level will cause us infloop
when we see a PDI. Reported by Matt Beshara <m@mfa.pw>.
Yuan Fu [Sat, 25 Feb 2023 02:40:52 +0000 (18:40 -0800)]
Align to prev sibling for c-ts-mode indentation
As requested by a discussion on emacs-devel.
* lisp/progmodes/c-ts-mode.el:
(c-ts-mode--anchor-prev-sibling): New function.
(c-ts-mode--indent-styles): Indent first child as before, indent the
rest to their previous sibling. Remove bracketless statement rules
that I forgot to remove previously.
Yuan Fu [Sat, 25 Feb 2023 03:31:34 +0000 (19:31 -0800)]
Fix c-ts-common-statement-offset and c-ts-common--node-is
* lisp/progmodes/c-ts-common.el:
(c-ts-common--node-is): Guard against case where the node has no field
name.
(c-ts-common-statement-offset): Do indent a level if the "if" in the
"else if" is on an independent line.
* lisp/font-lock.el (font-lock-function-call-face)
(font-lock-variable-ref-face, font-lock-property-ref-face):
New faces.
(font-lock-property-name-face):
Rename from 'font-lock-property-face'.
* lisp/progmodes/c-ts-mode.el (c-ts-mode--font-lock-settings):
Use new faces. More 'enumerator' query to 'definition' feature.
(c-ts-mode--fontify-declarator, c-ts-mode--fontify-variable):
Use new faces.
* lisp/progmodes/cmake-ts-mode.el
(cmake-ts-mode--font-lock-settings): Use new faces.
* lisp/progmodes/csharp-mode.el
(csharp-ts-mode--font-lock-settings): Use new faces.
* lisp/progmodes/go-ts-mode.el (go-ts-mode--font-lock-settings):
Use new faces.
* lisp/progmodes/java-ts-mode.el
(java-ts-mode--font-lock-settings): Use new faces.
* lisp/progmodes/js.el (js--treesit-fontify-assignment-lhs)
(js--treesit-font-lock-settings): Use new faces. Highlight
variable definitions inside array and object destructuring
patterns.
* lisp/progmodes/python.el (python--treesit-variable-p):
Exclude identifiers in parameters.
(python--treesit-settings): Use new faces. Highlight function
parameters. Move 'keyword' up to still highlight 'self' as
keyword.
* lisp/progmodes/ruby-ts-mode.el (ruby-ts--font-lock-settings):
Use new faces.
* lisp/progmodes/rust-ts-mode.el
(rust-ts-mode--font-lock-settings): Use new faces.
* lisp/progmodes/typescript-ts-mode.el
(typescript-ts-mode--font-lock-settings): Use new faces.
* lisp/textmodes/css-mode.el (css--treesit-settings):
Use font-lock-property-ref-face.
* lisp/textmodes/toml-ts-mode.el
(toml-ts-mode--font-lock-settings):
Use font-lock-property-ref-face.
João Távora [Fri, 24 Feb 2023 14:48:01 +0000 (14:48 +0000)]
Eglot: fix jit-lock inlay hint bugs
One of the bugs was straightforward. The timer function of
eglot--update-hints must set the correct buffer.
The other is much more odd. When using Eglot on Emacs's own
src/coding.c, the jit-lock code starts calling its jit-functions over
and over again with the same sequence of arguments, like so:
This continues forever at a very fast rate and saturates the LSP
channel.
At first I thought that it was because eglot--update-hints-1 is
actually causing the buffer to be modified with overlays sometime in
the future, but it is not so! It seems that merely calling
Robert Pluim [Fri, 24 Feb 2023 10:12:24 +0000 (11:12 +0100)]
Fix insertion of keyboard macro containing named keys
* lisp/kmacro.el: Autoload `macro--string-to-vector'.
(kmacro-ring-head): Convert `last-kbd-macro' to a vector if it's a
string, since `kmacro' uses `key-parse' on it.
(kmacro-lambda-form): Remove require for 'macros
* test/lisp/kmacro-tests.el
(kmacro-tests-name-last-macro-key-parse-syntax):
Test that insertion of macros that contain strings that look
like named keys works correctly.
João Távora [Thu, 23 Feb 2023 23:51:09 +0000 (23:51 +0000)]
Eglot: simplify inlay hints implementation with jit-lock
This implementation is much simpler than the one based on
windows-scroll-functions. It's also supposedly safer, as long as
jit-lock guarantees refontification of affected regions.
It's not _trivially_ simple though, as simply adding
'eglot--update-hints-1' to jit-lock-functions, while possible, is
going to request inlay hints from the LSP server for many small
regions of the buffer, depending on what jit-lock thinks is best. So
we keep coalescing these into a larger region until the time is
suitable for a more bandwidth-efficient request.
To do this, we use a jit-lock implementation detail,
jit-lock-context-unfontify-pos, which is a proxy for knowing that the
jit-lock-context-timer has run. Not sure how brittle it is, but it
seems to work reasonably.
We also get rid of the previous "get hints for entire buffer"
implementation.
* doc/misc/eglot.texi (Eglot Variables): Remove mention
to deleted eglot-lazy-inlay-hints.
Eli Zaretskii [Thu, 23 Feb 2023 15:45:52 +0000 (17:45 +0200)]
; Clarify documentation of 'file-modes-number-to-symbolic'
* doc/lispref/files.texi (Changing Files):
* lisp/files.el (file-modes-number-to-symbolic): Clarify the
confusion with "symbolic" forms of file modes. (Bug#61709)
João Távora [Thu, 23 Feb 2023 13:58:38 +0000 (13:58 +0000)]
Eglot: display completion label when safe
Originally reported in
https://github.com/joaotavora/eglot/discussions/1141 by "Mintsoup".
Eglot doesn't always show the LSP :label property of a CompletionItem
in the completion candidates. That is because label is sometimes not
what should be inserted in the buffer in the end, the :insertText
property supercedes it.
But the label is usually more suitable for display nevertheless and if
the LSP CompletionItem contains either a snippet or a textEdit, it's
safe to display the label, since :exit-function will guarantee that a
suitable buffer insertion is performed.
This change reflects that awareness that when a textEdit is available,
it's acceptable to show the label.