Yuan Fu [Wed, 7 Aug 2024 04:54:20 +0000 (21:54 -0700)]
; Minor change in c-ts-common--fill-block-comment
* lisp/progmodes/c-ts-common.el:
(c-ts-common--fill-block-comment): Add check for end-mask-done. This
doesn't affect correctness, but makes the code easier to read.
Eli Zaretskii [Tue, 6 Aug 2024 18:19:49 +0000 (21:19 +0300)]
Avoid crashes in very large buffers with long lines
* src/xdisp.c (get_large_narrowing_begv, get_large_narrowing_zv)
(get_medium_narrowing_begv, get_medium_narrowing_zv): Use
'ptrdiff_t' instead of 'int', to prevent integer overflow in
large buffers. (Bug#72497)
Ulrich Müller [Tue, 6 Aug 2024 16:04:46 +0000 (18:04 +0200)]
Update description of string comparison functions
* doc/lispref/strings.texi (Text Comparison): Swap descriptions of
'string-equal' (the function) and 'string=' (its alias). Same for
'string-lessp' and 'string<'. Document 'string>'. (Bug#72486)
* doc/lispref/sequences.texi (Sequence Functions): Update cross
reference to 'string-lessp'.
This fixes bugs that crashed Emacs when the Lisp interpreter was fed
bad code.
* src/eval.c (FletX, Flet, internal_lisp_condition_case)
(funcall_lambda): Hoist symbol-with-pos elimination and type checks to a
dominating position for efficiency. This also plugs at least two typing
holes. (Mea culpa.)
* test/src/eval-tests.el (eval-bad-specbind): New regression test.
Eshel Yaron [Thu, 8 Aug 2024 11:55:34 +0000 (13:55 +0200)]
Xref: support lexical variables in Emacs Lisp
* lisp/emacs-lisp/scope.el
* test/lisp/emacs-lisp/scope-tests.el: New files.
* lisp/progmodes/elisp-mode.el (xref-backend-definitions)
Use new 'scope' function to find bindings of lexical vars.
(xref-backend-references): Implement method.
* lisp/progmodes/xref.el (xref-location-line): Implement for
'xref-buffer-location' locations.
Yuan Fu [Mon, 5 Aug 2024 03:46:45 +0000 (20:46 -0700)]
Fix c-ts-common filling
* lisp/progmodes/c-ts-common.el:
(c-ts-common--fill-block-comment): Exclude the last line from filling if
it only has non-word characters like *=-.
* test/lisp/progmodes/c-ts-mode-resources/filling.erts: Fir the
multi-line test and add a single line test.
Jim Porter [Sun, 28 Jul 2024 03:48:38 +0000 (20:48 -0700)]
Add support for variable-pitch fonts in 'visual-wrap-prefix-mode'
* lisp/emacs-lisp/subr-x.el (string-pixel-width): Allow passing BUFFER
to use the face remappings from that buffer when calculating the width.
* lisp/visual-wrap.el (visual-wrap--prefix): Rename to...
(visual-wrap--adjust-prefix): ... this, and support PREFIX as a number.
(visual-wrap-fill-context-prefix): Make obsolete in favor of...
(visual-wrap--content-prefix): ... this.
(visual-wrap-prefix-function): Extract inside of loop into...
(visual-wrap--apply-to-line): ... this.
* doc/lispref/display.texi (Size of Displayed Text): Update
documentation for 'string-pixel-width'.
* lisp/emacs-lisp/pcase.el (pcase-lambda): Copy notice from
'pcase-let', indicating that pcase-lambda won't pattern match
like 'pcase', but just try to destruct with uncertain side
effects if this fails. (Bug#71503)
* lisp/net/tramp-smb.el (tramp-smb-handle-copy-directory):
Use `copy-directory-create-symlink'.
* lisp/net/tramp.el (tramp-skeleton-write-region): Use `lock-file' and
`unlock-file'..
(tramp-handle-make-lock-file-name): Use `remote-file-name-inhibit-locks'.
(tramp-handle-unlock-file): Use `remote-file-name-inhibit-locks'
and `userlock--handle-unlock-error'.
(tramp-handle-shell-command): Use `shell-command-buffer-name-async'
and `shell-command-buffer-name'.
(tramp-read-passwd): Remove workaround.
Eli Zaretskii [Sat, 3 Aug 2024 15:11:57 +0000 (18:11 +0300)]
Improve font search and handling on MS-Windows
* src/w32font.c: Add commentary about font search on MS-Windows.
(w32font_coverage_ok, add_font_entity_to_list)
(font_supported_scripts): Consider the coverage OK if a font has
only the SIP bit set, but also sets relevant codepage bits in the
CSB bits.
(font_supported_scripts): Fix script for USB bit 99.
* src/font.c (font_parse_fcname, font_parse_family_registry)
[HAVE_NTGUI]: Don't consider hyphenated suffixes of some Windows
fonts as not belonging to the family name.
* src/w32uniscribe.c (uniscribe_check_otf_1): Increase tags[]
array size, to avoid the E_OUTOFMEMORY error for some fonts.
* src/sfnt.c (sfnt_read_OS_2_table): Restore realignment after
s_family_class, as it occupies byte 32, not 34. Reported by Pip
Cet <pipcet@protonmail.com>.
Eli Zaretskii [Fri, 2 Aug 2024 06:48:55 +0000 (09:48 +0300)]
Fix display of empty margins when default face is remapped
* src/xdisp.c (display_line): Append space glyphs to margin areas
if the default face is remapped and nothing is written to the
margin area of this screen line.
(produce_special_glyphs): If the truncation/continuation glyphs do
not specify a face, use the remapped default face, not the
original frame-global default face. Reported by Nicolas
P. Rougier <nicolas.rougier@inria.fr> in
https://lists.gnu.org/archive/html/emacs-devel/2024-07/msg01217.html.
Eli Zaretskii [Fri, 2 Aug 2024 06:24:55 +0000 (09:24 +0300)]
Fix finding anchor references after 'Info-on-current-buffer'
* lisp/info.el (Info--record-tag-table): New function, extracted
from 'Info-find-node-2'.
(Info-find-node-2, Info-on-current-buffer): Use
'Info--record-tag-table'. (Bug#72391)
Martin Rudalics [Thu, 1 Aug 2024 16:04:20 +0000 (18:04 +0200)]
Fix regression in 'todo-test-todo-quit02'
* lisp/window.el (switch-to-prev-buffer): If BURY-OR-KILL is
non-nil, remove any 'quit-restore' or 'quit-restore-prev'
parameter referencing the old buffer too. This fixes a
regression when running 'todo-test-todo-quit02' from 'ert'
(reported by Andrea Corallo <acorallo@gnu.org>).
Michael Albinus [Thu, 1 Aug 2024 14:57:53 +0000 (16:57 +0200)]
Fix edge cases in tramp-crypt.el
* lisp/net/tramp-crypt.el (tramp-crypt-handle-set-visited-file-modtime)
(tramp-crypt-handle-verify-visited-file-modtime): New defuns.
(tramp-crypt-file-name-handler-alist): Use them.
(tramp-crypt-handle-lock-file): Care about `buffer-file-name'.
(tramp-crypt-handle-unlock-file): Remove compat code.
Martin Rudalics [Thu, 1 Aug 2024 07:37:50 +0000 (09:37 +0200)]
Improve window/buffer handling code
The purpose of these changes is to improve the code handling the
display of buffers in windows, switching to previous and next
buffers in windows and restoring a previous state after quitting
or killing buffers. In particular it does:
- Add a new window parameter 'quit-restore-prev' so a window can
keep its initial 'quit-restore' parameter and undoing a sequence
of quit window operations becomes more reliable (Bug#59862).
- Optionally have 'kill-buffer' call 'quit-restore-window' for
all windows showing the argument buffer (Bug#59862).
- Add a new hook so it's possible to avoid that a window gets
deleted implicitly by functions like 'kill-buffer' (Bug#71386).
- Add a new option to make 'quit-restore-window' delete windows
more aggressively (Bug#59862).
- Immediately remove killed buffers from all windows' previous
and next buffers. For windows that are already dead, use a weak
hash table to be used by 'kill-buffer'. This avoids any special
handling of such windows by the garbage collector.
- Immediately remove 'quit-restore' and 'quit-restore-prev'
window parameters that reference killed buffers. These
parameters have no more use once their buffers got killed.
- Make sure that internal windows do not have any previous and
next buffers. This fixes a silly memory leak.
- Make sure that after set_window_buffer and some wset_buffer
calls the buffer now shown in the window does not appear in the
lists of that window's previous and next buffers. The old
behavior could make functions investigating these lists
erroneously believe that there still existed some other buffer
to switch to.
* src/alloc.c (mark_discard_killed_buffers): Remove function.
(mark_window): No more filter previous and next buffer lists.
* src/window.h (struct window): Move up prev_buffers and
next-buffers in structure; they are now treated by the collector
as usual.
* src/window.c (window_discard_buffer_from_alist)
(window_discard_buffer_from_list)
(window_discard_buffer_from_window)
(window_discard_buffer_from_dead_windows)
(Fwindow_discard_buffer): New functions.
(set_window_buffer): Discard BUFFER from WINDOW's previous and
next buffers.
(make_parent_window): Make sure internal windows have no previous
and next buffers.
(make_window): Don't initialize window's previous and next
buffers, they are handled by allocate_window now.
(Fdelete_window_internal): Add WINDOW to window_dead_windows_table.
(Fset_window_configuration): Remove resurrected window from
window_dead_windows_table. Make sure buffers set by wset_buffer
calls are not recorded in window's previous and next buffers.
(delete_all_child_windows): Add deleted windows to
window_dead_windows_table.
(window_dead_windows_table): New weak hash table to record dead
windows that are stored in saved window configurations.
* src/buffer.c (Fkill_buffer): Call new function
'window_discard_buffer_from_dead_windows'.
* lisp/window.el (window-deletable-functions): New hook.
(window-deletable-p): Update doc-string. Run
'window-deletable-functions' (Bug#71386).
(unrecord-window-buffer): New argument ALL. Move body to
'window-discard-buffer-from-window' so that if ALL is non-nil,
WINDOW's 'quit-restore' and 'quit-restore-prev' parameters get
removed too.
(switch-to-prev-buffer): Don't care about killed buffers here;
'replace-buffer-in-windows' should have done that already. Use
'unrecord-window-buffer'.
(switch-to-next-buffer): Don't care about killed buffers here;
'replace-buffer-in-windows' should do that now.
(kill-buffer-quit-windows): New option.
(delete-windows-on): Update doc-string. Handle new option
'kill-buffer-quit-windows'. Update 'unrecord-window-buffer'
calls.
(replace-buffer-in-windows): Update doc-string. Handle new
option 'kill-buffer-quit-windows' (Bug#59862). Update call to
'unrecord-window-buffer'.
(quit-restore-window-no-switch): New option.
(quit-restore-window): Update doc-string. Handle additional
values of BURY-OR-KILL so to not kill a buffer about to be
killed by the caller. Handle 'quit-restore-prev' parameter
(Bug#59862). Handle new option 'quit-restore-window-no-switch'
(Bug#59862).
(quit-windows-on): Update doc-string. Call 'quit-window-hook'
and call 'quit-restore-window' directly so that the buffer does
not get buried or killed by the latter. Update
'unrecord-window-buffer' call.
(display-buffer-record-window): Update doc-string. Handle new
`quit-restore-prev' parameter (Bug#59862).
(switch-to-buffer): Call 'display-buffer-record-window' so a
latter 'quit-restore-window' can use its parameters.
* doc/lispref/windows.texi (Deleting Windows): Describe implicit
deletion of windows and new hook 'window-deletable-functions'.
(Buffers and Windows): Update description of
'replace-buffer-in-windows'. Describe new option
'kill-buffer-quit-windows'.
(Quitting Windows): Describe 'quit-restore-prev' parameter and
new option 'quit-restore-window-no-switch'. Update description
of 'quit-restore-window'.
(Window Parameters): Mention 'quit-restore-prev' parameter.
* etc/NEWS: Add entries for 'window-deletable-functions',
'kill-buffer-quit-windows', 'quit-restore-window-no-switch'.
mention new parameter 'quit-restore-prev' and new argument
values for 'quit-restore-window'.
Po Lu [Thu, 1 Aug 2024 00:23:36 +0000 (08:23 +0800)]
Better resolve bug#72188
* lisp/international/fontset.el (setup-default-fontset) <han>:
Don't search for fonts matching the `han' script elsewhere than
on Android, which restores the status quo existing in Emacs 29.
(bug#72188)
Eli Zaretskii [Wed, 31 Jul 2024 15:36:41 +0000 (18:36 +0300)]
Revert "Re-enable displaying `han' characters on Android"
This reverts commit bf0aeaa0d7a1581a095aa423e75d0d71cceb28cd.
The characters removed by this commit cause Emacs to select
sub-optimal fonts that lack many Chinese characters, because
Emacs generally stops looking for fonts when it finds the
first one that seems to match.
Stefan Monnier [Wed, 31 Jul 2024 08:52:08 +0000 (04:52 -0400)]
(vhdl-run-when-idle): Don't use `timer--triggered`
* lisp/progmodes/vhdl-mode.el (vhdl-run-when-idle): Avoid relying
needlessly on internal accessor and fix last change to make sure
we always create a timer.
Po Lu [Wed, 31 Jul 2024 00:32:24 +0000 (08:32 +0800)]
Re-enable displaying `han' characters on Android
* lisp/international/fontset.el (script-representative-chars)
<han>: Remove several characters that were just recently
introduced into unicode and are consequently absent from many
fonts, so that they may match font specs specifying scripts
rather than QClang in the default fontset.
Yuan Fu [Sat, 27 Jul 2024 23:18:13 +0000 (16:18 -0700)]
New variable treesit-language-remap-alist (bug#72388)
* doc/lispref/parsing.texi (Using Parser): Manual entry for the new
variable.
* src/treesit.c (resolve_language_symbol): New function.
(Ftreesit_parser_create, Ftreesit_parser_list): Resolve language before
using it.
(Vtreesit_language_remap_alist): New variable.
Yuan Fu [Sat, 27 Jul 2024 21:50:19 +0000 (14:50 -0700)]
Fix filling in c-ts-mode (bug#72116)
The previous fix introduced a regression in the case when there's only a
single line in the block comment. In that case we don't want to add a
start at the second line:
/* foo foo foo */ should => /* foo foo
foo */
rather than /* foo foo
* foo */
This commit fixes that.
* lisp/progmodes/c-ts-common.el:
(c-ts-common--fill-block-comment): Don't mask the /*.
(c-ts-common--adaptive-fill-prefix): New function.
(c-ts-common-comment-setup): Don't set adaptive-regexp, change
adaptive-fill-first-line-regexp to work with the new
adaptive-fill-function.
* test/lisp/progmodes/c-ts-mode-resources/filling.erts: New tests
Yuan Fu [Sat, 27 Jul 2024 05:33:17 +0000 (22:33 -0700)]
"Separate" tree-sitter parser list for indirect buffers
When create a parser for the indirect buffer, set the buffer field of
the parser to the indirect buffer, but add the parser to the base
buffer's parser list. This way, all the parsers still get buffer
updates, but indirect buffer's parsers can have different narrowing than
the parsers of the base buffer.
When returning the parser list of a buffer, do filtering and only return
the parser for that buffer.
From user's POV, indirect buffers appear to have their own parser list.
* doc/lispref/parsing.texi (Using Parser): Remove the text describing
indirect buffer's special case.
* src/treesit.c (Ftreesit_parser_create): When create a parser for the
indirect buffer, set the buffer field of the parser to the indirect
buffer, but add the parser to the base buffer's parser list.
(Ftreesit_parser_list): Filter parser list, only return parsers for this
buffer.
* lisp/progmodes/vhdl-mode.el (vhdl-run-when-idle):
No need to activate a newly created idle timer; keep it as
compatibility (or voodoo) code for XEmacs which probably doesn't have
the timer accessors anyway.
Harald Jörg [Mon, 29 Jul 2024 19:24:14 +0000 (21:24 +0200)]
; cperl-mode.el: Make it checkdoc clean
This commit does only docstrings, no functional changes at all.
* lisp/progmodes/cperl-mode.el: Docstrings are added where missing.
All parameters are documented. The first line is a complete sentence.
All docstring lines are 80 characters or less.
Po Lu [Mon, 29 Jul 2024 01:19:48 +0000 (09:19 +0800)]
Correct display of Doc View documents after tab switching
* lisp/doc-view.el (doc-view-new-window-function): Prevent
creation of duplicate overlays for the same window after a
window configuration change occasions a call to i-m-r-winprops.
Add new optional argument NO-HIGHLIGHT to query-replace-read-args
* lisp/replace.el (query-replace-read-args): Add new optional
argument to disable regexp highlighting.
* lisp/dired-aux.el (dired-do-query-replace-regexp)
(dired-do-replace-regexp-as-diff)
(dired-do-find-regexp-and-replace): Revert last change, and use
the new argument instead. (bug#72147)
Jim Porter [Sat, 20 Jul 2024 01:02:16 +0000 (18:02 -0700)]
Use 'unwind-protect' to ensure that Eshell always closes I/O handles
See bug#72220.
* lisp/eshell/esh-cmd.el (eshell-with-handles): New macro...
(eshell-commands): ... use it.
(eshell-with-copied-handles): Remove STEAL-P and allow multiple body
forms (this is an incompatible change, but the macro is currently
internal despite the name).
(eshell-parse-command, eshell-do-pipelines)
(eshell-do-pipelines-synchronously, eshell--invoke-command-directly-p):
Remove handle stealing.
(eshell-structure-basic-command, eshell-do-command)
(eshell-lisp-command): Remove 'eshell-close-handles'.
(eshell-protect): Make obsolete.
(eshell-rewrite-for-command, eshell-rewrite-while-command)
(eshell-rewrite-if-command, (eshell-parse-pipeline): Remove
'eshell-protect'.
* lisp/eshell/esh-io.el (eshell-duplicate-handles): Make STEAL-P
obsolete.
* lisp/eshell/esh-proc.el (eshell-gather-process-output): Call
'eshell-protect-handles' one more time. Remove 'eshell-close-handles'.
* lisp/eshell/esh-var.el (eshell-parse-variable-ref): Reimplement
$<COMMAND> form using 'eshell-with-handles'.
* test/lisp/eshell/esh-cmd-tests.el
(esh-cmd-test/command-not-found/pipeline): New test.
* test/lisp/eshell/em-tramp-tests.el
(em-tramp-test/should-replace-command): Adjust check for
'eshell-with-copied-handles'.
Jim Porter [Sat, 20 Jul 2024 01:07:36 +0000 (18:07 -0700)]
; Improve correctness of 'eshell-do-eval' in some edge cases
* lisp/eshell/esh-cmd.el (eshell-do-eval): Make sure that replacing 'if'
forms returns the correct result, and evaluate to 'nil' for 'progn'
forms with no body.