Eli Zaretskii [Wed, 5 Jun 2024 16:18:49 +0000 (19:18 +0300)]
Another attempt to prevent crashes when resizing TTY frames
* src/dispnew.c (frame_size_change_delayed): Accept frame as
argument, and check the 'new_size_p' flag of the frame in
addition to 'delayed_size_change'. Callers changed.
(window_to_frame_vpos, build_frame_matrix_from_leaf_window): Call
'frame_size_change_delayed' instead of looking at
delayed_size_change alone. (Bug#71289)
Eshel Yaron [Wed, 5 Jun 2024 08:23:56 +0000 (10:23 +0200)]
New user option 'completion-preview-idle-delay'
Support displaying the completion preview shortly after you
pause typing (on idle) rather than immediately.
* lisp/completion-preview.el (Commentary): Update.
(completion-preview--try-update):
(completion-preview--update-from-timer): New functions.
(completion-preview--timer): New buffer-local variable.
(completion-preview-idle-delay): New user option.
(completion-preview--show): Use it.
(completion-preview--post-command):
(completion-preview-mode): Disable idle timer if active.
Eshel Yaron [Wed, 5 Jun 2024 08:03:06 +0000 (10:03 +0200)]
Allow 'completion-preview-require-minimum-symbol-length' to be nil
With some completion backends, completion preview is useful not only
after a partial symbol, but also after punctuation and other non-symbol
characters. For example, in C code it's helpful to display the
completion preview for struct members when point is after 'foo->'.
Provide an option to skip the check for minimum symbol length at point
in order to support this use case.
* lisp/completion-preview.el
(completion-preview-minimum-symbol-length): Mention possible nil
value in type and docstring.
(completion-preview-require-minimum-symbol-length): Skip check
if 'completion-preview-minimum-symbol-length' is nil.
Juri Linkov [Wed, 5 Jun 2024 06:38:39 +0000 (09:38 +0300)]
Rehighlight hi-lock patterns after reverting the buffer.
* lisp/hi-lock.el (hi-lock-revert-buffer-rehighlight): New function.
(hi-lock-mode): Add hi-lock-revert-buffer-rehighlight to
revert-buffer-restore-functions, and remove after mode is disabled.
https://lists.gnu.org/archive/html/emacs-devel/2024-06/msg00044.html
Juri Linkov [Tue, 4 Jun 2024 16:53:47 +0000 (19:53 +0300)]
* lisp/outline.el (outline-revert-buffer-rehighlight): New function.
(outline-minor-mode): Add 'outline-revert-buffer-rehighlight' to
'revert-buffer-restore-functions'. When mode is disabled,
remove hooks from 'revert-buffer-restore-functions' and
also from 'after-change-functions'.
Eli Zaretskii [Tue, 4 Jun 2024 16:12:38 +0000 (19:12 +0300)]
Fix the build with mingw.org's MinGW
The change in boot-time.c imported from Gnulib broke the
MinGW build using mingw.org's MinGW. It is wrong to include
sysinfoapi.h, MS documentation says to include <windows.h>.
* lib/boot-time.c: Don't include sysinfoapi.h.
Paul Eggert [Mon, 3 Jun 2024 21:43:10 +0000 (14:43 -0700)]
lwlib: pacify gcc -Wmissing-variable-declarations
* lwlib/lwlib.c (lwlib_toolkit_type): Remove unused var.
* lwlib/xlwmenu.c (submenu_destroyed): Now static.
* src/xmenu.c (widget_id_tick): Declare extern, as a FIXME.
Po Lu [Tue, 4 Jun 2024 02:23:13 +0000 (10:23 +0800)]
Provide additional Android metadata
* java/AndroidManifest.xml.in: Enable preserving user data
beyond uninstallation, restarting activities without persiting
state, increase maximum number of simultaneously open
activities, and provide a sensible category.
Juri Linkov [Mon, 3 Jun 2024 18:13:38 +0000 (21:13 +0300)]
Move revert-buffer-restore-functions use from buff-menu.el to outline.el
* lisp/buff-menu.el (Buffer-menu-mode): Remove
revert-buffer-restore-functions with handling of
outline-minor-mode and move it to outline-minor-mode.
* lisp/outline.el (outline-minor-mode):
Add revert-buffer-restore-functions to call
outline-minor-mode-highlight-buffer after reverting the buffer
with outline-minor-mode and outline-minor-mode-highlight
where font-lock can't be used to update highlighting.
Eli Zaretskii [Mon, 3 Jun 2024 18:13:05 +0000 (21:13 +0300)]
Avoid assertion violations in 'try_window_id'
* src/xdisp.c (try_window_id): Avoid assertions in
'find_first_unchanged_at_end_row' due to 'init_iterator' freeing
all the realized faces. (Bug#71274)
Stefan Monnier [Mon, 3 Jun 2024 17:26:10 +0000 (13:26 -0400)]
pcase.el (\`): Try and handle large patterns better
Large backquote patterns tend to lead to very large and deeply
nested expansions, but they also tend to contain a lot of
"constant" subpatterns that can be compiled to quote patterns.
This patch does just that. See discussion at
https://lists.gnu.org/archive/html/emacs-devel/2024-05/msg01140.html
* lisp/emacs-lisp/pcase.el (pcase--split-pred):
Improve the handling of pred-vs-quote so it also works with
quoted objects like cons cells, vectors, and strings.
Simplify the `pcase--mutually-exclusive-p` branch accordingly.
(pcase--expand-\`): New function, extracted from the \` pcase macro.
Make it recurse internally, and optimize backquote patterns to `quote`
patterns where possible.
(\`): Use it.
* test/lisp/emacs-lisp/pcase-tests.el (pcase-tests-vectors): Add tests
that were broken by a more naïve version of the optimization.
(pcase-tests-quote-optimization): New test.
Eli Zaretskii [Mon, 3 Jun 2024 17:37:31 +0000 (20:37 +0300)]
Avoid crashes and assertions while handling SIGWINCH
* src/dispnew.c (build_frame_matrix_from_leaf_window)
(window_to_frame_vpos): Avoid assertion violations when we have an
unhandled SIGWINCH.
(frame_size_change_delayed): New function.
* src/dispextern.h (frame_size_change_delayed): Add prototype.
* src/cm.c (cmcheckmagic): Don't check magicwrap if we have an
unhandled SIGWINCH. (Bug#71289)
Juri Linkov [Mon, 3 Jun 2024 17:18:46 +0000 (20:18 +0300)]
New commands to show/hide outlines by regexp (bug#49731)
* lisp/outline.el (outline-mode-prefix-map): Bind "/ s" to
'outline-show-by-heading-regexp', and "/ h" to
'outline-hide-by-heading-regexp'.
(outline-show-by-heading-regexp)
(outline-hide-by-heading-regexp): New commands.
(outline-hidden-headings-regexp): New helper function.
Juri Linkov [Mon, 3 Jun 2024 16:55:47 +0000 (19:55 +0300)]
New variable 'revert-buffer-restore-functions' (bug#69511)
* doc/lispref/backups.texi (Reverting):
Add documentation for 'revert-buffer-restore-functions'.
* lisp/files.el (revert-buffer-restore-functions): New variable.
(revert-buffer-restore-read-only): New function.
(revert-buffer): Use 'revert-buffer-restore-functions' with
the default value 'revert-buffer-restore-read-only' (bug#69511).
* lisp/buff-menu.el (Buffer-menu-mode): Add hook
'revert-buffer-restore-functions' to restore
outline-minor-mode highlighting.
Robert Pluim [Mon, 3 Jun 2024 12:52:05 +0000 (14:52 +0200)]
Improve key binding documentation.
* doc/emacs/custom.texi (Init Rebinding): Explain how to bind a key to a
string and how to use non-ASCII characters.
* lisp/keymap.el (keymap-global-set, keymap-local-set): Mention
'key-description'.
Robert Pluim [Mon, 3 Jun 2024 12:00:56 +0000 (14:00 +0200)]
Add common pairs to defcustom for electric-quote-chars
* lisp/electric.el (electric--print-list-of-chars): New function to
display chars as chars instead of integers in a custom widget.
(electric-char-pair): New widget for displaying a pair of characters.
(electric-quote-chars-pairs): New widget. Contains presets for common
combinations of left/right quotation characters
(electric-quote-chars): Update to use 'electric-quote-chars-pairs'.
Po Lu [Mon, 3 Jun 2024 12:37:41 +0000 (20:37 +0800)]
Small followup change
* lisp/image.el (create-image): Remove supererogatory instances
of pcase. Recognize new `lambda' values and refrain from
specifying a default transform-smoothing when it is returned.
(image--default-smoothing): Return lambda if scaling is default.
* lisp/tool-bar.el (tool-bar--image-expression): Revert this
portion of last change.
Robert Pluim [Thu, 16 May 2024 14:25:24 +0000 (16:25 +0200)]
Improve support for entering quotation marks
* lisp/international/iso-transl.el (iso-transl-char-map): Add entries
for "low" single and double quotation marks.
(iso-transl-language-alist): Add convenient support for the official
German quoting style to the German language entry. It uses "low" double
quotes on the left, and *left* double quotes on the right. Add support
for single guillemets to the French language entry.
* lisp/leim/quail/latin-post.el ("latin-postfix"): Add entries for
single, double and "low" Unicode quotation marks. Add entries for
single guillemets.
* lisp/leim/quail/latin-pre.el ("latin-prefix"): And here.
Po Lu [Mon, 3 Jun 2024 08:34:51 +0000 (16:34 +0800)]
Maintain relationship between tool bar image and default font width
* doc/lispref/display.texi (Image Descriptors): Document new
value of QCscale.
* lisp/cus-start.el (standard) <image-scaling-factor>: New
definition.
* lisp/image.el (image-scaling-factor): Move to C.
(create-image): Provide `default' as the default scaling factor.
(image--default-smoothing): Accept non-integer scaling factors.
(image-compute-scaling-factor): Document that this function
is no longer invoked by Emacs.
* lisp/tool-bar.el (tool-bar--image-expression): Disable
transform smoothing for tool-bar icons.
* src/dispextern.h (clear_image_cache): New definition.
* src/frame.c (gui_set_font): Clear such image cache entries as
derive their scales from the default font width.
* src/image.c (clear_image_cache): Export function.
(compute_image_size): Implement `default' by reading
Vimage_scaling_factor and/or computing a scale factor from the
frame's column width, as the case may be.
New argument F. All callers changed.
(syms_of_image) <Vimage_scaling_factor>: Move from image.el.
Yuan Fu [Mon, 3 Jun 2024 04:52:48 +0000 (21:52 -0700)]
Use parser notifier to set parser ranges
This is a continuation from an earlier commit where I added
treesit-parser-changed-ranges and friends. Dmitry raised an concern
about the edge case where the parser re-parses multiple times before
treesit--pre-redisplay has a chance to run and process changed ranges.
Instead of making treesit-parser-changed-ranges DTRT and become more
complicated, it's agreed that using parser notifier is a better
solution (and treesit-parser-changed-ranges can probably be removed).
So, I took out the code that does the work from treesit--pre-redisplay
and put them into treesit--font-lock-mark-ranges-to-fontify. This
function will be called on each parser re-parse. And in
treesit--pre-redisplay, to ensure that treesit--f-l-m-r-to-f gets
called, we force the primary parser to re-parse.
I also added a new variable that major modes need to set,
treesit-primary-parser. I also added code that makes Emacs guess the
primary parser if that variable isn't set.
Documentation fot treesit-primary-parser will come later.
For futher reference, the message id for the message that prompted
this change is <dc94733b-df75-446c-980e-1c8ea65826cf@gutov.dev>
* lisp/treesit.el (treesit-primary-parser): New variable.
(treesit--font-lock-mark-ranges-to-fontify): New function.
(treesit--guess-primary-parser): New function.
(treesit--pre-redisplay): Extract out.
(treesit--pre-syntax-ppss): Add comments.
(treesit-major-mode-setup): Guess and set treesit-primary-parser; add
treesit--font-lock-mark-ranges-to-fontify as a notifier to the primary
parser.
* doc/misc/tramp.texi (Inline methods): Be more specific with containers.
(Remote processes): New subsection "Managing remote shell history".
Explain shell-history-file-name.
(Frequently Asked Questions): Add items to Tramp speedup. Remove
entry about history file.
* etc/NEWS: New user option 'shell-history-file-name'.
* lisp/shell.el (shell-history-file-name): New defcustom.
(shell-mode): Use it. (Bug#71049)
Spencer Baugh [Sun, 26 May 2024 13:26:09 +0000 (09:26 -0400)]
In rgrep, check matching files before excluding files
There are a lot of excluding globs, and checking them all is expensive.
The files glob (i.e. the glob for files we actually want) is usually
just one or two entries, so it's quite fast to check.
If find checks the files glob first and then the excluding glob, it has
to do much less checking (since the files glob will substantially narrow
down the set of files on its own), and find performance is much better.
In my benchmarking, this takes (rgrep "foo" "*.el" "~/src/emacs/trunk/")
from ~410ms to ~130ms.
Further optimizations are possible now that the ignores and matched
files are in the same <F> argument which can be rearranged more easily
without compatibility issues; I'll do those optimizations in later
commits.
* lisp/progmodes/grep.el (rgrep-find-ignores-in-<f>): Add.
* lisp/progmodes/grep.el (rgrep-default-command): Check
rgrep-find-ignores-in-<f> and move the excluded files glob to part of
the "files" argument. (Bug#71179)
Vincenzo Pupillo [Sun, 26 May 2024 19:07:50 +0000 (21:07 +0200)]
Make comment-indent-new-line conform better to CC Mode (bug#71225)
* lisp/progmodes/c-ts-common.el: (c-ts-common-comment-indent-new-line):
Single line comment and block comment now behave more like the
c-indent-new-comment-line.
Michael Albinus [Sat, 1 Jun 2024 17:22:21 +0000 (19:22 +0200)]
Minor Tramp changes
* lisp/net/tramp-adb.el:
* lisp/net/tramp-container.el: Add myself as maintainer.
* lisp/net/tramp-compat.el (connection-local-default-application):
Define if not bound.
(tramp-compat-connection-local-p, tramp-compat-connection-local-value):
Use it.
Dmitry Gutov [Sat, 1 Jun 2024 15:03:42 +0000 (18:03 +0300)]
shell-command-mode: New major mode for async-shell-command
* etc/NEWS: Mention the additions.
* lisp/shell.el (shell-command-mode): New major mode (bug#71049).
* lisp/simple.el (async-shell-command-mode):
New variable, with default value pointing to that mode.
(shell-command): Refer to it here.
(async-shell-command): Update docstring.
* lisp/net/tramp.el (tramp-handle-shell-command):
Use the new variable when available.
Noah Peart [Sun, 26 May 2024 12:34:34 +0000 (05:34 -0700)]
Add font-locking for variables in go-ts-mode range clauses (bug#71209)
* lisp/progmodes/go-ts-mode.el (go-ts-mode--font-lock-settings):
Add font-locking rule for variable names in range clauses.
* test/lisp/progmodes/go-ts-mode-tests.el (go-ts-test-font-lock):
Add font-locking test for go-ts-mode.
* test/lisp/progmodes/go-ts-mode-resources/font-lock.go: New file
for go-ts-mode font-locking tests.
Eli Zaretskii [Sat, 1 Jun 2024 13:43:18 +0000 (16:43 +0300)]
Fix misc problems with thumbnails on MS-Windows
* lisp/image/image-dired-external.el (image-dired-pngcrush-thumb):
Fix deletion of intermediate file.
(image-dired-cmd-pngcrush-options)
(image-dired-cmd-create-standard-thumbnail-options): Use %u for
file:// URI.
(image-dired--file-URI): New function.
(image-dired-create-thumb-1, image-dired-create-thumb-2)
(image-dired-set-exif-data): Use it to generate correct URI on
MS-Windows.
* src/w32image.c (Fw32image_create_thumbnail): Copy the file names
before mirroring their slashes.
Po Lu [Sat, 1 Jun 2024 13:27:51 +0000 (21:27 +0800)]
Improve touch-screen support on PGTK
* lisp/touch-screen.el (touch-screen-translate-touch): Do not
prepend posn if the symbol is such that keyboard.c will do so
immediately after returning.
* src/pgtkterm.c (pgtk_toolkit_position): Remove mistakenly
ported code.
(pgtk_create_terminal): Remove toolkit_position hook.
(motion_notify_event, button_event): Ignore emulated pointer
events, and apply an additional test to circumvent a GDK
oversight.
(touch_event_cb): Correct return type, and provide touch
sequence initialization and removal events as
`last_click_event's.
* src/pgtkterm.c (pgtk_free_frame_resources): Free touch points
linked to this frame.
(pgtk_link_touch_point, pgtk_unlink_touch_point)
(pgtk_unlink_touch_points, pgtk_find_touch_point): New
functions, ported from X.
(touch_event_cb): New event callback.
(pgtk_set_event_handler): Register `touch_event_cb' as handler
for `touch-event'.
(pgtk_delete_display): Free residual touch points on this
display.
* src/pgtkterm.h (struct pgtk_touch_point): New structure.
(struct pgtk_display_info) <touchpoints>: New field.
Po Lu [Sat, 1 Jun 2024 05:53:37 +0000 (13:53 +0800)]
On X, avoid reporting unrepresentable touch IDs to Lisp
* src/xterm.c (xi_link_touch_point): Assign a Lisp-representable
identifier to the new touch point and return the same.
(xi_unlink_touch_point): New arg LOCAL_DETAIL. Return such an
identifier if there is a matching touch point record.
(handle_one_xevent): Adjust as is proper.
* src/xterm.h (struct xi_touch_point_t) <local_detail>:
New field. Reorder fields for alignment.
Michael Albinus [Fri, 31 May 2024 14:27:47 +0000 (16:27 +0200)]
Make Tramp error handling more precise
* lisp/net/tramp-container.el (tramp-actions-copy-out-of-band)
(tramp-container-no-container-regexp): Remove. Do not register them.
(tramp-distrobox-no-container-regexp): New defcustom.
(tramp-enable-distrobox-method): Add it to
`'tramp-actions-before-shell. (Bug#71200)