Eli Zaretskii [Sat, 31 Aug 2024 09:12:00 +0000 (12:12 +0300)]
Improve 'C-h o' in NEWS files
* lisp/textmodes/emacs-news-mode.el (emacs-news--mode-common):
Modify syntax-table of NEWS modes to consider ' as string-quoting
character. Suggested by Visuwesh <visuweshm@gmail.com>.
(Bug#72757)
David Ponce [Thu, 22 Aug 2024 14:56:11 +0000 (16:56 +0200)]
Use 'with-work-macro' in 'string-pixel-width'
Tweak the implementation of 'string-pixel-width' to run
faster and use less memory. Also cater for the case where
this function is called in parallel (bug#72689).
* lisp/emacs-lisp/subr-x.el (string-pixel-width): Use
`with-work-macro'. Prefer `remove-text-properties' to
`propertize' to avoid creating a new string on each call.
David Ponce [Thu, 22 Aug 2024 14:56:11 +0000 (16:56 +0200)]
New macro `with-work-buffer'.
* lisp/emacs-lisp/subr-x.el (work-buffer--list)
(work-buffer-limit): New variables.
(work-buffer--get, work-buffer--release): New function.
(with-work-buffer): New macro. (Bug#72689)
Jim Porter [Sun, 25 Aug 2024 18:37:44 +0000 (11:37 -0700)]
Add manual tests for the 'min-width' display property
* test/manual/redisplay-testsuite.el (test-redisplay-5): Add some
newlines.
(test-redisplay-6): New function...
(test-redisplay): ... call it (bug#72721).
'xwidget-open' wrongly assumed the the text-property at
min-position is an xwidget, if it exists; the fix is just
returning nil if the text-property isn't an xwidget.
* lisp/xwidget.el (xwidget-at): Use 'ignore-errors'. (Bug#72848)
Eli Zaretskii [Thu, 29 Aug 2024 09:56:27 +0000 (12:56 +0300)]
Fix rare segfaults due to freed fontsets
* src/xfaces.c (recompute_basic_faces): Force complete
recalculation of non-ASCII faces and their fontsets if any
non-ASCII faces are in the frame's face cache. (Bug#72692)
This binding dates back at least to 2004 (where we bound
`after-change-functions` instead). Maybe it had a real impact in the past,
but nowadays I can't see any effect other than maybe a negligible
performance improvement at the cost at breaking some uses of
`before-after-change-functions`.
Yuan Fu [Tue, 27 Aug 2024 02:43:00 +0000 (19:43 -0700)]
More consistent treesit-forward-sexp around comments (bug#72525)
* lisp/treesit.el (treesit-forward-sexp): Check if point is strictly
inside a comment or string, only then use the default forward-sexp
function; otherwise use tree-sitter's forward-sexp routine.
Yuan Fu [Mon, 26 Aug 2024 00:59:51 +0000 (17:59 -0700)]
Fix tree-sitter local parser overlay cleanup routine
Sorry for sneaking in a sizable commit so late. But I just found out
about this bug and it has to be fixed. Before this change, we weren't
properly cleaning up overlays that store local parsers. And in the case
of doxygen local parser in C files, the doxygen local parser overlay
sometimes bleeds out of comments and into other code, and interferes
with font-lock and indentation.
This commit adds a cleanup function that'll cleanup any overlays that
aren't being used. I tested with doxygen in C files and everything
works smoothly now, including tricky tests like removing the ending "*/"
of a doxygen comment and adding it back.
The idea is simple, at the end of each call to (treesit-update-ranges
BEG END), we remove any overlay within BEG and END that wasn't touched
by the range setting code.
* lisp/treesit.el (treesit--cleanup-local-range-overlays): New function.
(treesit--update-ranges-local): Remove code for cleaning up zero-length
overlays since we have the cleanup function now.
(treesit-update-ranges): Wrap the function body inside a let form, which
defines modified-tick; and add a call to
treesit--cleanup-local-range-overlays at the very end.
Stefan Monnier [Mon, 26 Aug 2024 15:26:11 +0000 (11:26 -0400)]
(pp): Indent lines right when starting in col > 0
This refines the fix for bug#72561: commit 0a500193087e fixes
the bug by changing `ert--pp-with-indentation-and-newline`,
but it turns out that `pp` was inconsistent (it sometimes
indented the subsequent lines correctly and sometimes not,
depending on the current-buffer's major mode).
So the fix really should be in `pp`, which is what this patch does.
* lisp/emacs-lisp/pp.el (pp): Appropriately indent subsequent lines
if the first line is not inserted in column 0 (tho only when
printing into a buffer since otherwise it's somewhere between
ill-defined and impossible to implement).
* lisp/emacs-lisp/ert.el (ert--pp-with-indentation-and-newline):
Remove the indentation code after `pp` which was just working
around the bug in `pp`. Also remove the redundant addition of
`\n` since `pp` always does it nowadays.
* test/lisp/help-mode-tests.el (help-mode-tests-xref-on-pp):
Fix thinko.
Eli Zaretskii [Sun, 25 Aug 2024 18:43:59 +0000 (21:43 +0300)]
Revert a recent change that caused redisplay slowdown
* src/xfaces.c (recompute_basic_faces): Revert the change which
caused recalculation of all the faces, as it made cursor motion
too slow. Reported by Juri Linkov <juri@linkov.net> (bug#72692).
Jim Porter [Fri, 23 Aug 2024 22:11:24 +0000 (15:11 -0700)]
Improve computation of indent depth in SHR and 'visual-wrap-prefix-mode'
Now, we get the average-width of the current font using
'string-pixel-width' and a specified space display spec, which doesn't
require the buffer to be displayed in a window (bug#72771).
* lisp/net/shr.el (shr-indent):
* lisp/visual-wrap.el (visual-wrap--content-prefix): Fix getting the
font when the buffer isn't displayed in a window.
(visual-wrap-fill-context-prefix): Fix indentation.
F. Jason Park [Fri, 9 Aug 2024 23:49:28 +0000 (16:49 -0700)]
Indent ERT failure explanations rigidly
This also affects the listing of `should' forms produced by hitting
the L key on a test button in an ERT buffer.
* lisp/emacs-lisp/ert.el (ert--pp-with-indentation-and-newline):
Indent the pretty-printed result to match the caller's current column
as a reference indentation.
* test/lisp/emacs-lisp/ert-tests.el
(ert--pp-with-indentation-and-newline): New test. (Bug#72561)
Dmitry Gutov [Sun, 25 Aug 2024 15:23:51 +0000 (18:23 +0300)]
[Eglot] Stricter "expand common" behavior
* lisp/progmodes/eglot.el (eglot--dumb-tryc): Check that the
expanded string matches every completion strictly (bug#72705).
And in the fallback case, check whether the table matches the
original prefix at all. Return nil otherwise.
Dmitry Gutov [Sun, 25 Aug 2024 15:05:28 +0000 (18:05 +0300)]
eglot-tests.el: New tests for existing completion behavior
* test/lisp/progmodes/eglot-tests.el
(eglot-test-common-prefix-completion)
(eglot-test-try-completion-inside-symbol)
(eglot-test-rust-completion-exit-function): New tests.
(eglot--wait-for-rust-analyzer): New function.
Eli Zaretskii [Sun, 25 Aug 2024 07:24:35 +0000 (10:24 +0300)]
Fix handling of 'min-width' display property
* src/xdisp.c (get_display_property, display_min_width): Rename
BUFPOS to CHARPOS, to avoid confusion (it is not necessarily a
buffer position). Suggested by Jim Porter <jporterbugs@gmail.com>.
(get_display_property): Call 'Fget_char_property' to support
'min-width' properties of overlays as well.
(display_min_width): Handle the buffer and string cases more
accurately, without relying only on the values of positions.
(handle_display_prop, handle_single_display_spec): Pass correct
position to 'display_min_width', when iterating over a string.
(handle_display_prop): When OBJECT is a window, pass it to
display_min_width.
(set_iterator_to_next): Call 'display_min_width' when at end of a
display or overlay string. (Bug#72721)
Yuan Fu [Sat, 24 Aug 2024 22:25:48 +0000 (15:25 -0700)]
Fix Ftreesit_parser_create
* src/treesit.c (Ftreesit_parser_create): We recently changed something
such that base buffer and indirect buffer appears to use separate
parser-lists. Therefore, creating a parser in one of the buffer
shouldn't reuse the parser in another buffer.
Björn Bidar [Thu, 8 Aug 2024 14:36:01 +0000 (17:36 +0300)]
Forward user to auth-source inside url-basic-auth
* lisp/url/url-auth.el (url-basic-auth): Forward the user if
provided by the url or found by 'auth-source' when searching
for secrets. Supplying 'auth-source' with the user when
matching secrets allows for more accurate retrieval and fixes
instances where the user enters an url that already contains
the user such as "user@host.de". (Bug#72526)
Michael Albinus [Sat, 24 Aug 2024 10:49:32 +0000 (12:49 +0200)]
Optimize Tramp's copy-directory
* lisp/net/tramp-sh.el (tramp-sh-handle-copy-directory):
* lisp/net/tramp-smb.el (tramp-smb-handle-copy-directory):
Don't check existence of DIRNAME, this is done in
`tramp-skeleton-copy-directory' already.
* lisp/net/tramp-sh.el (tramp-sh-handle-copy-directory):
Apply `tramp-do-copy-or-rename-file-directly' if possible.
Björn Bidar [Thu, 8 Aug 2024 14:31:20 +0000 (17:31 +0300)]
Fix secret search with basic auth with a port in URL
* lisp/url/url-auth.el (url-basic-auth): Fix retrieving of
secrets when the URL contains a port. Amending the port to
server breaks 'auth-source-search' matching for :host which
is redundant as it already specified in :port. (Bug#72526)
Martin Rudalics [Fri, 23 Aug 2024 08:27:12 +0000 (10:27 +0200)]
Avoid putting a dead buffer in the minibuffer window (Bug#72487)
* src/minibuf.c (minibuffer_unwind): Make sure that the buffer
referenced by the first element of the list of previous buffers
of the minibuffer window is live before assigning it to the
minibuffer window (Bug#72487).
* src/window.c (set_window_buffer): Assert that BUFFER is live.