Gregory Heytings [Fri, 25 Nov 2022 21:43:48 +0000 (21:43 +0000)]
Generic 'with-narrowing' macro.
* lisp/subr.el (with-narrowing): New generic macro, replacing the
'with-locked-narrowing' one. Suggested by Stefan Monnier.
(with-narrowing-1, with-narrowing-2): Helper functions.
Gregory Heytings [Fri, 25 Nov 2022 17:51:01 +0000 (17:51 +0000)]
Reworked locked narrowing.
* src/editfns.c: (narrowing_locks): New alist to hold the narrowing
locks and their buffers.
(narrowing_lock_get_bound, narrowing_lock_peek_tag)
(narrowing_lock_push, narrowing_lock_pop): New functions to access
and update 'narrowing_locks'.
(reset_outermost_narrowings, unwind_reset_outermost_narrowing):
Functions moved from src/xdisp.c, and rewritten with the above
functions.
(Fwiden): Use the above functions. Update docstring.
(Fnarrow_to_region, Fnarrowing_lock, Fnarrowing_unlock): Use the above
functions.
(syms_of_editfns): Remove the 'narrowing-locks' variable.
* src/lisp.h: Make 'reset_outermost_narrowings' externally visible.
* src/xdisp.c (reset_outermost_narrowings)
unwind_reset_outermost_narrowing): Functions moved to src/editfns.c.
* lisp/subr.el (with-locked-narrowing): Improved macro, with a helper
function.
Stefan Kangas [Mon, 21 Nov 2022 10:20:01 +0000 (11:20 +0100)]
Make instructions for updating ancient filesets obsolete
* lisp/filesets.el (filesets-update-pre010505): Make update
information for filesets older than 2001 obsolete. Note that this
dates back to before filesets.el was even added to Emacs.
Juri Linkov [Mon, 21 Nov 2022 07:56:06 +0000 (09:56 +0200)]
* lisp/outline.el (outline-search-function): New variable (bug#53981).
(outline-font-lock-keywords, outline-font-lock-face)
(outline-minor-mode-highlight-buffer, outline-next-preface)
(outline-next-heading, outline-previous-heading)
(outline-back-to-heading, outline-on-heading-p, outline-demote)
(outline-map-region, outline-next-visible-heading)
(outline-hide-sublevels, outline-up-heading): Use outline-search-function
when it's non-nil as an alternative to searching outline-regexp.
(outline-search-level, outline-search-text-property): New functions.
* lisp/apropos.el (apropos-mode): Set outline-search-function
instead of unreliable outline-regexp.
(apropos-print): Add text property outline-level.
* lisp/emacs-lisp/shortdoc.el (shortdoc-display-group):
Add text property outline-level on text separate from final newlines.
(shortdoc-display-group): Add a narrow newline to not show
text properties of the final line when the outline is hidden.
(shortdoc--display-function): Add text property outline-level.
(shortdoc-mode): Set buffer-local outline-search-function and outline-level.
Avoid native compiler setting user-init-file to warnings.el (bug#59358)
* src/lread.c (maybe_swap_for_eln): Use a delayed warning
instead of `display-warning' to avoid a recursive call to
Fload while loading the init file that sets `user-init-file'
to a bogus value.
Juri Linkov [Sun, 20 Nov 2022 18:10:45 +0000 (20:10 +0200)]
Rename 'elisp-eval-buffer' to 'elisp-eval-region-or-buffer' (bug#59350)
* lisp/progmodes/elisp-mode.el (elisp-eval-region-or-buffer):
Rename recently added command 'elisp-eval-buffer' to support active region.
(emacs-lisp-mode-map, lisp-interaction-mode-map): Rebind 'C-c C-e'
from elisp-eval-buffer to elisp-eval-region-or-buffer.
Po Lu [Sun, 20 Nov 2022 13:01:10 +0000 (21:01 +0800)]
Coalesce duplicate scroll valuator handling code
Also, write more commentary.
* src/xterm.c (xi_populate_scroll_valuator): New function.
Describe the meaning of each field in xi_scroll_valuator_t.
(xi_populate_device_from_info, xi_handle_new_classes): Factor
out duplicate code to that function.
Eli Zaretskii [Sun, 20 Nov 2022 11:10:08 +0000 (13:10 +0200)]
Advise against using too-high GC thresholds
* doc/lispref/internals.texi (Garbage Collection):
* src/alloc.c (syms_of_alloc) <gc-cons-threshold>
<gc-cons-percentage>: Advise against enlarging the GC thresholds
more than needed and for prolonged periods of time.
Eli Zaretskii [Sat, 19 Nov 2022 19:34:07 +0000 (21:34 +0200)]
Fix encoding and display of messages sent by server to emacsclient
* lisp/server.el (server-start): Use 'locale-coding-system' to
encode messages sent back to the client.
* lib-src/emacsclient.c (main): Print '-error' messages via
'message', not directly via 'fprintf'. This shows the error on
MS-Windows when the client is invoked as 'emacsclientw', since
stderr goes to the bit bucket in that case.
Gregory Heytings [Sat, 19 Nov 2022 15:46:46 +0000 (15:46 +0000)]
Fix global face scaling bug due to rounding.
* lisp/face-remap.el (global-text-scale-adjust): Try again if the face
height should have changed but did not actually change. Update the
docstring to clarify the difference with 'text-scale-adjust'.
(global-text-scale-adjust--increment-factor): New internal variable.
Fixes bug#59122.
(text-scale-adjust): Update the docstring to clarify the difference
with 'global-text-scale-adjust'.
Po Lu [Sat, 19 Nov 2022 10:46:07 +0000 (18:46 +0800)]
Fix error trapping in x_set_mouse_color
* src/xfns.c (x_set_mouse_color): Use
x_uncatch_errors_after_check right after x_had_errors_p. Then,
trap errors around FreeCursor requests, since some of the IDs
may not name valid cursors.
Po Lu [Sat, 19 Nov 2022 07:24:25 +0000 (15:24 +0800)]
Fixes to fast mouse position reporting
* src/xterm.c (x_fast_mouse_position): New function. Factor out
most of the fast mouse position code here. Correctly port some
Haiku code to take into account multiple displays. Report
scroll bar coordinates correctly.
(XTmouse_position): Call it.
Po Lu [Sat, 19 Nov 2022 05:59:53 +0000 (13:59 +0800)]
Fix automatic DPI adjustment and add workarounds for some systems
* lisp/faces.el (x-create-frame-with-faces): New field
`delayed-font'. Set the `font-parameter' property to `font' in
the given parameter list after face-set-after-frame-default is
called.
* src/fontset.c (Fset_fontset_font): Avoid changing
`font-parameter' with the call to Fmodify_frame_parameters.
* src/frame.c (gui_set_frame_parameters_1): New function.
Factor out gui_set_frame_parameters here, and add an argument
DEFAULT_PARAMETER. If the `font' parameter is set, and
`default_parameter' is not, then set the `font-parameter' frame
parameter to the `font' parameter as well, to keep track of
which user-specified `font' frame parameter set the default
face's font on the frame.
(gui_set_frame_parameters): Call gui_set_frame_parameters_1 with
new arg set to false.
(gui_set_font): Remove broken implementation of
`font-parameter'.
(gui_default_parameter): If the default value was used, then
call gui_set_frame_parameters_1 with the new argument set to
false. This is because no font was specified as a frame
parameter by the user, so Freconsider_frame_fonts is free to do
anything it wants.
(Freconsider_frame_fonts): If `font-parameter' is set, then use
it.
(syms_of_frame): New defsym Qfont_parameter.
* src/frame.h: Update prototypes.
* src/haikuterm.c (haiku_default_font_parameter):
* src/pgtkfns.c (pgtk_default_font_parameter):
* src/w32fns.c (w32_default_font_parameter): Stop setting
`font-parameter' here. This code resulted in decades of
automatic font rescaling not working correctly.
* src/xfaces.c (set_font_frame_param): Clear the
`font-parameter' frame parameter.
(Finternal_merge_in_global_face):
* src/xfns.c (x_default_font_parameter): Avoid changing
`font-parameter' in response to changes to face attributes.
* src/xsettings.c (apply_xft_settings): Add workaround for
Cairo. (bug#59371, bug#59347, bug#59283, bug#59271, bug#59285,
bug#59306.)
Po Lu [Sat, 19 Nov 2022 03:19:41 +0000 (11:19 +0800)]
Fix bug#59371
* src/frame.c (Freconsider_frame_fonts): If a font parameter was
set, create a params alist with it. Then, pass it to both
default_font_parameter and face-set-after-frame-default.
(bug#59371)
Po Lu [Sat, 19 Nov 2022 03:13:15 +0000 (11:13 +0800)]
Fix earlier changes to keyboard.c
* src/keyboard.c (coords_in_menu_bar_window): New function.
(make_lispy_event): Do not process menu bar events on window
system frames if there is no menu bar window or the click lies
outside.
Manuel Giraud [Fri, 18 Nov 2022 08:24:55 +0000 (09:24 +0100)]
Fix click position to menu bar entry with no-toolkit
* src/keyboard.c (make_lispy_event): Use x_y_to_hpos_vpos to
compute correct menu bar position should the menu face change.
* src/xdisp.c (x_y_to_hpos_vpos): Not static anymore.
* src/dispextern.h: Export x_y_to_hpos_vpos.
Robert Pluim [Thu, 17 Nov 2022 15:45:36 +0000 (16:45 +0100)]
Use boolean values directly in rmailsum
* lisp/mail/rmailsum.el (rmail-summary-invert):
(rmail-summary-direct-descendants):
(rmail-summary--walk-thread-message-recursively):
(rmail-summary-by-thread):
(rmail-summary-by-labels):
(rmail-summary-by-recipients):
(rmail-summary-by-regexp):
(rmail-summary-by-topic):
(rmail-summary-by-senders): Use the boolean values in
'rmail-summary-currently-displayed-msgs' and similar directly instead
of comparing them to t and nil.
* test/lisp/simple-tests.el
(simple-execute-extended-command--describe-binding-msg):
Bind text-quoting-style explicitly to ensure consistent behaviour
whether or not the test is run interactively.
Po Lu [Fri, 18 Nov 2022 01:08:59 +0000 (09:08 +0800)]
Add knob to make `mouse-position' faster on X
* etc/PROBLEMS (Improving performance with slow X connections):
Add new advice.
* src/xterm.c (XTmouse_position): Add alternative
implementations for slow connections.
(syms_of_xterm): Add new variable to enable them.
* src/xterm.h (struct x_display_info): Update commentary.
Stefan Monnier [Thu, 17 Nov 2022 23:09:37 +0000 (18:09 -0500)]
itree.c: Get rid of the old iterator code
Only use the new iterator which relies on a fixed size (and small)
state in the iterator.
This makes non-local exits safe within ITREE_FOREACH loops.
* src/itree.c (make_nav, nav_nodeptr, nav_flag, itree_stack_clear)
(itree_stack_push_flagged): Delete functions.
(nodeptr_and_flag): Delete type.
(struct itree_stack): Make the array hold plain pointers instead.
(itree_stack_push): Inline the former code of `itree_stack_push_flagged`.
(itree_stack_pop): Change return type.
(itree_contains): Don't call `ITREE_FOREACH_ABORT` any more.
(itree_insert_gap): Simplify access to the stack of nodes.
(itree_delete_gap, itree_insert_gap): Adjust code to new return type of
`itree_stack_pop`.
(itree_iterator_finish): Delete function.
(itree_iterator_start): Don't setup the `stack` field any more.
(itree_iterator_next): Delete function.
(itree_iter_next): Rename to `itree_iterator_next` and make it non-static.
(itree_iterator_narrow): Don't check the `running` flag any more.
* src/itree.h (itree_iterator_finish): Remove declaration.
(struct itree_iterator): Remove the `stack` and `running` fields.
(ITREE_FOREACH_ABORT): Delete macro.
(ITREE_FOREACH): Don't call `itree_iterator_finish` any more.
* src/xdisp.c (strings_with_newlines):
* src/buffer.c (overlays_in, next_overlay_change, overlay_touches_p):
Don't call `ITREE_FOREACH_ABORT` any more.
Stefan Monnier [Thu, 17 Nov 2022 22:00:22 +0000 (17:00 -0500)]
itree.c: Make the iterator reentrant (bug#59183)
Get rid of the global iterator object and instead allocate
a separate iterator for every loop. This still uses the "duplicate
iterator" code, including the old iterator which needs a stack,
make ITREE_FOREACH a bit more expensive than we'd like.
* src/itree.h (init_itree, forget_itree, itree_iterator_busy_p):
Delete declarations.
(itree_iterator_start): Add iterator arg and remove `line` and `file` args.
(struct itree_iterator): Move from `itree.c`. Remove `line` and
`file` fields.
(ITREE_FOREACH): Stack allocate an iterator object and pass it to
`itree_iterator_start`.
* src/itree.c (struct itree_iterator): Move to itree.h.
(iter): Delete global variable.
(itree_iterator_create, init_itree, forget_itree, itree_iterator_busy_p):
Delete functions.
(itree_contains): Adjust assertion.
(itree_iterator_finish): Deallocate the iterator's stack.
(itree_iterator_start): Take the (uninitialized) iterator as argument.
Allocate a fresh new stack. Remove `file` and `line` arguments.
Don't check `running` any more since the iterator is not expected to be
initialized at all.
* src/eval.c (signal_or_quit):
* src/alloc.c (garbage_collect): Don't check `itree_iterator_busy_p`
any more.
* src/emacs.c (main): No need to `init_itree` any more.
(Fdump_emacs): No need to `forget_itree` any more.
Fix issues related to 'package-vc-install-from-checkout'
* lisp/emacs-lisp/package-vc.el (package-vc--main-file): Ensure the
package name is a string.
(package-vc--unpack-1): Use pkg-dir instead of the empty return value
of 'package-lisp-dir'.
(package-vc-install-from-checkout): Fix file name handling.
* lisp/emacs-lisp/package-vc.el (package-vc-update): Ensure that the
command is only invoked with installed packages. that the hook is
always removed and that 'vc-pull' is always called in the right
directory.
* lisp/emacs-lisp/package-vc.el (package-vc-prepare-patch): Use
'vc-prepare-patch-prompt-revisions'.
* lisp/vc/vc.el (vc-prepare-patch-prompt-revisions): Extract common
function and handle prefix arguments.
(vc-prepare-patch): Pull logic out to
'vc-prepare-patch-prompt-revisions'.
Have 'package-vc-selected-packages' consider all installed packages
* lisp/emacs-lisp/package-vc.el
(package-vc-install-selected-packages): Consider more than just one
value in `package-alist', in case there are multiple installations.
* lisp/emacs-lisp/package.el (package--download-one-archive): Only add
the archive that is actually being downloaded to
'package--downloads-in-progress'.
Track 'default-directory' while updating source packages
* lisp/emacs-lisp/package-vc.el (package-vc-update): Add the source
directory to the identifier list, in case the remaining
'vc-do-command' arguments are all read-time constants.
Respect :lisp-dir in package specs by loading a sub-directory
* lisp/emacs-lisp/package-vc.el (package-vc-repository-store): Remove
obsolete variable.
(package-vc--unpack-1): Respect :lisp-dir.
(package-vc--unpack): Add :lisp-dir to the package description if
necessary.
* lisp/emacs-lisp/package.el (package--delete-directory): Check if a
directory is a symbolic link.
* lisp/emacs-lisp/package-vc.el (package-vc-selected-packages): Remove
reference to non-existent function and add an explanation that the
value won't override an existing source package installation.
* lisp/emacs-lisp/package-vc.el (package-vc--sourced-packages-list):
Remove function in favour of 'package-vc--read-package-name'.
(package-vc--read-package-name):
Extract out common functionality.
(package-vc--read-package-desc): Add auxiliary function based on
'package-vc--read-package-name'.
(package-vc-update): Add interactive spec using
'package-vc--read-package-desc'.
(package-vc-install): Use 'package-vc--read-package-desc'.
(package-vc-checkout): Use 'package-vc--read-package-desc'.
(package-vc--read-pkg): Remove in favour of 'package-vc--read-package-desc'.
(package-vc-refresh): Use 'package-vc--read-package-desc'.
(package-vc-prepare-patch): Use 'package-vc--read-package-desc'.
* lisp/emacs-lisp/package-vc.el (package-vc-ensure-packages): Add an
autoload cookie.
(package-vc-selected-packages): Set
:initialize to 'custom-initialize-default'.