João Távora [Wed, 16 Apr 2025 23:31:07 +0000 (00:31 +0100)]
Eglot: be aware of LSP version of contextual diagnostics
In certain situations, Eglot has to report to the server parts
of the diagnostics that it itself sent us. The server may use
this as context to compute code actions, for example. Eglot
selects diagnostics by asking Flymake, looking for the ones that
contain Eglot-specific cookies.
But when doing so, it is important to also be aware of the LSP
document version these each of these diagnostics pertain to,
since if a diagonstic in the buffer pertains to an older version
of the LSP document (because Flymake fired or the server hasn't
pushed a new set), that diagnostics 'eglot-lsp-data' cookie is
invalid and possibly harmful.
An example is when a diagnostic extends all the way to the end
of the buffer. If we attempt to fix by shortening the buffer,
an Eldoc-started code actions request may be sent to the server
considering the soon-to-be-deleted Flymake diagnostic as
context. But that diagnostic's 'eglot-lsp-data' cookie is no
longer valid and when processing that context we try to go past
point-max and burp an annoying error.
Best to check the version of the diagnostic (if we have it) and
ignore the ones that don't match the document version.
* lisp/progmodes/eglot.el (eglot--versioned-identifier): Move up.
(eglot--flymake-diagnostics, eglot--diag-to-lsp-diag): New helpers.
(eglot-handle-notification): Record LSP doc version in diagnostics.
(eglot--code-action-bounds)
(eglot--code-action-params): Use eglot--flymake-diagnostics.
Juri Linkov [Wed, 16 Apr 2025 18:45:40 +0000 (21:45 +0300)]
* lisp/textmodes/markdown-ts-mode.el: More ts-modes for code blocks.
(markdown-ts--code-block-language-map): Add more aliases.
(markdown-ts-code-block-source-mode-map): Add more mappings
for existing core ts-modes.
(markdown-ts--convert-code-block-language):
Check 'lang-string' with 'symbolp'. Check 'mode' with 'fboundp'.
Juri Linkov [Wed, 16 Apr 2025 17:32:54 +0000 (20:32 +0300)]
Change the default navigation sexp-type in 'elixir-ts-mode'.
* lisp/progmodes/elixir-ts-mode.el (elixir-ts-mode):
Call 'treesit-cycle-sexp-type' at the end to enable navigation across
nodes defined by the tree-sitter thing 'sexp' by default (bug#76788).
Juri Linkov [Wed, 16 Apr 2025 17:11:34 +0000 (20:11 +0300)]
New hook 'outline-after-change-functions' (bug#77256).
* lisp/outline.el (outline-after-change-functions): New variable.
(outline--fix-buttons-after-change):
Run hook 'outline-after-change-functions'.
* lisp/treesit.el (treesit--after-change): Improve docstring.
(treesit-major-mode-setup): Simplify to just add
'treesit--after-change' to 'outline-after-change-functions' hook.
* lisp/progmodes/rust-ts-mode.el (rust-ts-mode): Add explicit
'treesit-outline-predicate' that is like
'treesit-simple-imenu-settings', but also adds "trait_item".
* lisp/treesit.el (treesit-language-at-point-function):
Change the default value from nil to 'treesit-language-at-point-default'.
(treesit-language-at): Funcall 'treesit-language-at-point-function'
unconditionally.
(treesit-language-at-point-default): New function with body from
'treesit-language-at'.
(treesit-node-at): Simplify by replacing duplicate code
with the call to 'treesit-parsers-at'.
Stefan Monnier [Wed, 16 Apr 2025 14:15:16 +0000 (10:15 -0400)]
(Freplace_region_contents): Treat point as insert-before marker
Experience suggests that it's more often useful to keep point
at the end of the replacement than it is to keep point at the
beginning of the replacement.
This also aligns the behavior of `replace-region-contents` with
that of `insert`.
* src/insdel.c (replace_range): Treat PT like an insert-before marker.
* src/editfns.c (Freplace_region_contents): Adjust docstring accordingly.
Select the created frame because 'quit-window' unexpectedly
selects the original frame (https://debbugs.gnu.org/71386#262).
Add a comment about the `message' call bound to the original frame.
https://lists.gnu.org/archive/html/emacs-devel/2025-04/msg00546.html
Yuan Fu [Wed, 12 Mar 2025 03:37:43 +0000 (20:37 -0700)]
Expand markdown-ts-mode and add code block support for javascript
- Define new faces and use them in place of font-lock faces
- Add more fontification, add a new feature for headings.
- Remove fontification for code blocks, so embedeed parser can
fontify them
- Add experimental code block support for javascript by using
tree-sitter setup from js-ts-mode.
- Correctly setup markdown_inline with range settings.
* lisp/textmodes/markdown-ts-mode.el:
(markdown-ts--code-block-language-map):
(markdown-ts-code-block-source-mode-map): New variables.
(markdown-ts-faces): New group.
(markdown-ts-delimiter):
(markdown-ts-heading-1):
(markdown-ts-setext-heading):
(markdown-ts-heading-2):
(markdown-ts-heading-3):
(markdown-ts-heading-4):
(markdown-ts-heading-5):
(markdown-ts-heading-6):
(markdown-ts-list-marker):
(markdown-ts-block-quote):
(markdown-ts-language-keyword): New faces.
(markdown-ts--treesit-settings):
(markdown-ts--configured-languages): New variables.
(markdown-ts--harvest-treesit-configs):
(markdown-ts--add-config-for-mode):
(markdown-ts--convert-code-block-language): New functions.
(markdown-ts--range-settings): New variable.
(markdown-ts-setup): Setup range configuration.
(markdown-ts-mode): Add heading feature.
Jared Finder [Sat, 22 Feb 2025 22:25:37 +0000 (14:25 -0800)]
Show drag cursor on all window lines (mode, tab, header)
* lisp/ruler-mode.el (ruler-mode-map): Remove down-mouse-1
binding that conflicts with dragging header line.
* src/xdisp.c (note_mode_line_or_margin_highlight): Renamed
to...
(note_line_or_margin_highlight): ...new name since it applies to
any window line (mode, tab, header). Set drag cursor for window
top lines.
(note_mouse_highlight): Update call to new name (bug#76084).
* lisp/man.el (Man-start-calling): Declare as debuggable.
(Man-getpage-in-background): Call `Man-bgproc-sentinel' with a
cons (BUFFER . EXIT-STATUS) as PROCESS argument for synchronous calls.
(Man-bgproc-sentinel): Use that information to handle those more
similarly to asynchronous calls. Do not employ window selection hacks
for synchronous calls. (Bug#77755)
* exec/exec.c (struct exec_jump_command, exec_0): Don't define
or set `fpu_mode' if __LP64__.
* exec/exec.h (struct exec_tracee): New field `callno'.
* exec/trace.c (process_system_call): Always record the current
system call number in TRACEE lest it should be required once it
has been overwritten upon the syscall's completion.
(seccomp_system_call): Likewise.
(after_fork): Clear `tracee->callno'.
Eli Zaretskii [Tue, 15 Apr 2025 06:45:16 +0000 (09:45 +0300)]
; Fix tab-bar-tests on MS-Windows
* test/lisp/tab-bar-tests.el (tab-bar-tests-quit-restore-window):
Skip test on MS-Windows in batch mode, since terminal frames
cannot be created in that case.
Po Lu [Tue, 15 Apr 2025 03:14:14 +0000 (11:14 +0800)]
Address typos in MIPS executable loader
* exec/loader-mipsel.s (rest_of_exec): Delete redundant nop.
(skip_environ): Correct stack space test. Don't jump into
the label for the sp preserving case's delay slot.
The compile-time option XMALLOC_BLOCK_INPUT_CHECK was added in
2012 (commit 4d7e6e51dd4acecff) to allow blocking input during
malloc-family calls, in case any issues arose from related
changes in Emacs 24.3. However, it has not been referenced on
emacs-devel or the bug tracker in over a decade.
It is clear that we do not need it, as our signal handlers do not
allocate memory. Removing it simplifies the allocation function
wrappers and eliminates dead debug code.
Po Lu [Mon, 14 Apr 2025 13:28:15 +0000 (21:28 +0800)]
Port recent changes to mipsel systems
* exec/exec.c (exec_0): Don't disable AT_EXECFN substitution on
MIPS systems.
* exec/loader-aarch64.s (skip_environ): Correct typo in
commentary.
* exec/loader-mips64el.s: Add a disclaimer that this file is
currently inoperable.
* exec/loader-mipsel.s (__start): Move environment and argument
vectors and produce and replace AT_EXECFN. Clear stack before
proceeding to circumvent an oversight in glibc.
* test/lisp/emacs-lisp/find-func-tests.el
(find-func-tests--locate-macro-generated-symbols): bind
'trusted-content' to names of files in which we want to
expand macros during this test.
Po Lu [Sun, 13 Apr 2025 10:50:59 +0000 (18:50 +0800)]
Replace AT_EXECFN in auxiliary vectors of programs executed on Android
* exec/exec.c (insert_args, exec_0): On non-MIPS systems, copy
NAME and its length to the loader area. State that MIPS support
is not yet available (though it will be pending the availability
of a functioning emulator).
* exec/loader-aarch64.s (_start):
* exec/loader-armeabi.s (_start):
* exec/loader-x86.s (_start):
* exec/loader-x86_64.s (_start): Displace auxv, environ, and
argv to create sufficient space for the provided file name, and
copy the file name there. Replace AT_EXECFN to refer to this
space.
Add variable for control docstring length in elisp eldoc functions
* etc/NEWS: Announce new variable.
* lisp/progmodes/elisp-mode.el (elisp-eldoc-docstring-length-limit):
New user option.
(elisp-eldoc-funcall-with-docstring): Add "Undocumented" as
docstring if the function has no docstring.
(elisp-eldoc-var-docstring-with-value): Use
`elisp-eldoc-docstring-length-limit'. (Bug#77628)
* lisp/url/url-parse.el (url-generic-parse-url): Remove prefix /
when a file URI's filename starts with a single letter followed
by a colon and a slash or backslash.
(url-recreate-url): Mirror the change applied when parsing, so
the URL is recreated properly on MS-Windows.
* test/lisp/url/url-parse-tests.el
(url-generic-parse-url/ms-windows-file-uri-hanlding): New test.
(Bug#76982)
argv as left after main has proccessed the command-line can differ
both in order and contents of the original command-line arguments,
which can lead to surprising results when restarting emacs on the
cooked argv through `kill-emacs'.
Starting from that observation, consistenly use variables
'initial_cmdline' on Windows, 'initial_argc', 'initial_argv' on
non-Windows, and 'initial_argv0' in all ports.
* src/lisp.h: Declare 'initial_argv0', limit declaration of
'initial_argv' and 'initial_argc' to non-Windows ports.
* src/emacs.c: Likewise, but for the definitions.
(init_cmdargs): Move initialization of 'initial_argv' and
'initial_argc' ...
(copy_args) [!WINDOWSNT]: ... to this new function ...
(main): ... and call that in 'main', also initializing
'initial_argv0' before the command-line processing.
* src/emacs.c (Fkill_emacs):
* src/pgtkterm.c (pgtk_term_init):
* src/sysdep.c (emacs_perror):
* src/xterm.c (x_term_init): Use 'initial_argv0' where only that
is required. (Bug#77389)
Fix term.el bug with very short multibyte character chunk
Before this change, a chunk containing only a part
of a multibyte character would be discarded and
displayed undecoded on the terminal.
* lisp/term.el (term-emulate-terminal): Fix handling chunks
with part of a multibyte character. (Bug#77410)
* test/lisp/term-tests.el (term-decode-partial)
(term-undecodable-input): Fix and enhance tests.
Sean Whitton [Sun, 13 Apr 2025 06:38:27 +0000 (14:38 +0800)]
; Fix replacements of old vc-annotate-parent-file
* lisp/vc/vc-annotate.el (vc-annotate-working-revision)
(vc-annotate-extract-revision-at-line)
(vc-annotate-revision-at-line, vc-annotate-warp-revision)
(vc-annotate-goto-line): Fix extracting the file name from
vc-buffer-overriding-fileset.
Limit fontification of "customize" in setopt suggestion
* lisp/help-fns.el (help-fns--customize-variable): Limit the
fontification to newly inserted text to avoid spurious
fontification of other instances of the word "customize."
Previously, flymake-indicator-type defaulted to either fringes
or margins. But fringes should be used on graphical frames, and
margins on TTY frames. So default to fringes instead, and
simply fall back to margins automatically on text frames.
* lisp/progmodes/flymake.el (flymake-indicator-type): Set to
fringes. (bug#77313)
(flymake-mode): Fallback to margins if there's no fringes.
* doc/misc/flymake.texi (Customizable variables): Mention
fallback behavior.
* etc/NEWS: Announce fallback behavior.
Eli Zaretskii [Sat, 12 Apr 2025 06:52:04 +0000 (09:52 +0300)]
Improve documentation of 'user-emacs-directory'
* doc/emacs/custom.texi (Find Init): Document the effect of
'user-emacs-directory' on native compilation. Advise against
changing the value of 'user-emacs-directory' in init files.
(Bug#77745)
Sean Whitton [Sat, 12 Apr 2025 02:05:57 +0000 (10:05 +0800)]
vc-do-async-command: Ellipse later lines in multiline arguments
* lisp/emacs-lisp/cl-print.el (cl-print-expand-ellipsis): Bind
inhibit-read-only to t.
* lisp/vc/vc-dispatcher.el (require): Require cl-print at
compile time.
(vc-do-async-command): When printing command arguments that
contain multiple lines, use cl-prin1 with cl-print-string-length
bound in order to ellipse lines other than the first.
Switch the outer quotation marks to single quotation marks.
Sean Whitton [Fri, 4 Apr 2025 02:49:57 +0000 (10:49 +0800)]
New buffer-local vc-buffer-overriding-fileset and vc-buffer-revision
* lisp/vc/vc.el (vc-buffer-overriding-fileset)
(vc-buffer-revision): New variables (bug#77529).
(vc-find-revision-save, vc-find-revision-no-save): Set them.
(vc-deduce-fileset): Respect vc-buffer-overriding-fileset.
(vc-print-log): Use vc-buffer-revision as a default working
revision.
* lisp/vc/vc-annotate.el (vc-annotate-parent-file)
(vc-annotate-parent-rev): Delete.
(vc-annotate): Respect vc-buffer-overriding-fileset and
vc-buffer-revision. This makes 'C-x v g' work from buffers
generated by 'C-x v ~' (bug#5424).
Set the two variables in the newly prepared buffer.
(vc-annotate-working-revision)
(vc-annotate-extract-revision-at-line)
(vc-annotate-revision-at-line, vc-annotate-warp-revision)
(vc-annotate-goto-line):
* lisp/vc/vc-svn.el (vc-svn-annotate-current-time): Use
vc-buffer-overriding-fileset instead of vc-annotate-parent-file,
vc-buffer-revision instead of vc-annotate-parent-rev.
(vc-annotate-parent-rev): Delete declaration.