* lisp/emacs-lisp/cconv.el (cconv-convert): When form is an
interactive lambda form, don't destructively modify it, as it might be
a constant literal. Instead, create a new list with the relevant
place(s) changed.
* test/lisp/emacs-lisp/cconv-tests.el
(cconv-tests-interactive-form-modify-bug60974): New test.
Stefan Kangas [Wed, 1 Mar 2023 05:30:20 +0000 (06:30 +0100)]
Merge from origin/emacs-29
97a83ff31fa Eglot: fix M-x eglot-show-workspace-configuration (bug#61... 48a0804d10d ruby-mode: Fix method call indentation in rhs of multiple... 16d012cf3bd * lisp/net/tramp.el (tramp-remote-path): Improve docstring. b371697cdca Minor change in 'dired--find-possibly-alternative-file' c2b5c6acc58 Implement prefix arg for 'c-ts-mode-toggle-comment-style' eb2ab52fb01 Defaults to zero for image-dired--number-of-thumbnails 5dc163f592a ; Add a doc string for 'ediff-window-display-p' obsolescence
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)
Stefan Kangas [Tue, 28 Feb 2023 05:30:13 +0000 (06:30 +0100)]
Merge from origin/emacs-29
613de662811 Rename the newly added -ref- faces to -use- f601e9666d8 Eglot: support multiple labels in same inlay hint 4a5eda7ed2a Eglot: don't paint hints outside requested region (bug#61... 11c1aa1eb12 ; * doc/misc/gnus.texi: Fix last change. 44949c292f9 ; Add `nnimap-user' to Gnus manual 6c7078c66f4 ; * lisp/progmodes/c-ts-mode.el (treesit-node-prev-siblin... 3d0a6c9baa6 Eglot: protect against unintended field text motion (bug#... 647e40f4a0c ; And yet another fix to eglot-current-linepos-function's... 9d0f856a167 Fix description of 'desktop-save-mode' aee10ca1cbe Adjust tree-sitter defun navigation (bug#61617) edf5b976869 Simplify c-ts-mode--top-level-label-matcher 0f15286c539 New tree-sitter indent anchor standalone-parent used by c...
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).
Augusto Stoffel [Wed, 7 Dec 2022 17:44:07 +0000 (18:44 +0100)]
New user option 'grep-use-headings'
* lisp/progmodes/grep.el (grep-heading-regexp): New user option.
(grep-heading): New face (bug#59888).
(grep--heading-format, grep--heading-state, grep--heading-filter):
Filter function for grep processes and supporting variables.
(grep-use-headings): New user option.
(grep-mode): Use the above, if applicable.
Augusto Stoffel [Thu, 8 Dec 2022 20:05:10 +0000 (21:05 +0100)]
Introduce 'compilation-annotation' text property
It is meant to mark parts of compilation buffers which do not
correspond to process output (bug#59888).
* lisp/progmodes/compile.el (compilation-insert-annotation): New
function.
(compilation-start, compilation-handle-exit): Use it.
(compilation--ensure-parse) Rely on 'compilation-annotation' property
instead of 'compilation-header-end'.
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).
Adjust some `pure` and `side-effect-free` function declarations
* lisp/emacs-lisp/byte-opt.el (side-effect-free-fns):
Add `format-message` and `substring-no-properties`.
* lisp/subr.el (number-sequence, copy-tree, looking-at-p)
(string-match-p, string-trim-right, string-lines):
Declare side-effect-free.
(syntax-class, version-list-<, version-list-=, version-list-<=)
(version-list-not-zero): Declare pure and side-effect-free.
(ensure-list): Declare side-effect-free and error-free.
(string-equal-ignore-case): Remove `pure` declaration.
We may want it to be pure but right now it's not.
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.
Improve delete-consecutive-dups doc precision and add test
* lisp/subr.el (delete-consecutive-dups): Document which element of
each run is retained (the earliest in the list). This matters because
it makes it safe to ignore the return value.
* test/lisp/subr-tests.el (subr--delete-dups)
(subr--delete-consecutive-dups): Add tests.
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.
Jim Porter [Sat, 25 Feb 2023 05:49:54 +0000 (21:49 -0800)]
Be more cautious in completing Eshell variable assignments
Previously, Eshell treated cases like the second argument in "tar
--directory=dir" as a variable assignment, but that prevented
'pcomplete/tar' from implementing its own completion for that
argument (bug#61778).
* lisp/eshell/esh-var.el (eshell-complete-variable-assignment): Only
handle completion when all initial arguments are variable assignments.
* test/lisp/eshell/em-cmpl-tests.el
(em-cmpl-test/variable-assign-completion/non-assignment): New test.
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>.
Stefan Kangas [Sat, 25 Feb 2023 05:30:14 +0000 (06:30 +0100)]
Merge from origin/emacs-29
5cf50d60041 Check the anchor along with the offset in treesit-indent-... 497018dd5c3 ; Fix typos in docstrings in c-ts-common.el 03072bbdd38 ; Set indent-tabs-mode to nil in c-ts-mode indent preproc... 4a25fa4586c Align to prev sibling for c-ts-mode indentation d25f24fe57b Fix c-ts-common-statement-offset and c-ts-common--node-is c92360c7a3b typescript-ts-mode: Highlight non-shorthand destructuring... a795c51f605 Add more/finer faces for tree-sitter 146bce49321 Avoid crashes in batch mode due to lack of frame face cache 244a73cd729 Add Tramp version integrated in Emacs 28.3
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.
Stefan Monnier [Fri, 24 Feb 2023 19:18:24 +0000 (14:18 -0500)]
kmacro: Simplify register code and recent change
While reviewing uses of `last-kbd-macro` for more problems like
those of bug#61700 I noticed that we don't need the `kmacro-register`
type any more (we can directly use the new `kmacro` type instead).
Also `macros.el` requires `kmacro` so rather than autoload
`macro--string-to-vector` it's simpler to move the function to
`kmacro.el`. And while at it fold into it the `stringp` test that's used
before every call to that function.
* lisp/kmacro.el (kmacro--to-vector): Rename from
`macro--string-to-vector`, move from `mcros.el`, and make it work for
vectors.
(kmacro-ring-head, kmacro-lambda-form): Simplify accordingly.
(cl-print-object): Remove unused declaration.
(kmacro-register): Delete type. Use `kmacro` objects instead.
(register-val-jump-to, register-val-describe, register-val-insert):
Rewrite accordingly.
(kmacro-to-register): Put the `kmacro` object.
* lisp/macros.el (macro--string-to-vector): Move to `kmacro.el`.
(insert-kbd-macro): Use `kmacro--to-vector`.
* src/macros.c (end_kbd_macro): Always generate a vector.
More accurate suppression of ignored return value warning
* lisp/emacs-lisp/bytecomp.el (byte-compile-file-form-defalias):
Be careful to propagate the for-effect mode through a
`with-suppressed-warnings` form when compiling, so that a form
inside isn't erroneously considered to have its value 'used'
by the surrounding warning suppression form itself.
Follow function aliases for `side-effect-free` and `pure` properties
This way we don't need to set these properties on aliases at all;
it was always easy to forget doing so.
* lisp/emacs-lisp/byte-opt.el (byte-opt--fget): New function.
(byte-optimize-form-code-walker, byte-optimize-form): Use it.
(side-effect-free-fns, side-effect-and-error-free-fns, pure-fns):
Remove aliases from lists, leaving only built-in functions.
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.
Stefan Kangas [Fri, 24 Feb 2023 05:30:11 +0000 (06:30 +0100)]
Merge from origin/emacs-29
b0cbd5590b2 Eglot: simplify inlay hints implementation with jit-lock 91e24c5b5a6 Eglot: update inlay hints on window configuration changes 79fead1709f ; Fix a typo in a doc string in c-ts-common.el (bug#61736). a0b273ef300 ; Clarify documentation of 'file-modes-number-to-symbolic' 5c2be6a2632 ; Fix recently-added doc strings in eglot.el e3be0dbf85c Eglot: display completion label when safe 5286111ea1f Improve documentation of VC commands, including in Dired 990f4027131 * doc/emacs/maintaining.texi: More mentions of marked fil...
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.
Jim Porter [Thu, 2 Feb 2023 01:48:43 +0000 (17:48 -0800)]
Add support for completing quoted variables in Eshell like $'FOO'
This also adds the ability for Pcomplete handlers to set their own
exit functions that will get called as appropriate.
* lisp/pcomplete.el (pcomplete-default-exit-function): New function.
(pcomplete-exit-function): New variable...
(pcomplete-completions-at-point): ... let-bind and use it.
* lisp/eshell/em-cmpl.el (eshell-complete-parse-arguments): Handle
quoted variables. We also build the 'posns' list from right-to-left
now.
* lisp/eshell/esh-var.el (eshell-envvar-names): Ensure that variable
aliases are included in this list.
(eshell-complete-variable-reference): Handle quoted variables and set
the exit function on the completions.
(eshell-variables-list): Simplify. We now add the trailing slash for
directories in the exit function inside
'eshell-complete-variable-reference'.
* test/lisp/eshell/em-cmpl-tests.el
(em-cmpl-test/quoted-variable-ref-completion)
(em-cmpl-test/variable-ref-completion/directory): New tests.
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.