commit 7f2ef27f49e2ea22cf38b84efc8e927c0240f16d (HEAD, refs/remotes/origin/master) Merge: d78e446072 1b77362771 Author: Stefan Kangas Date: Tue Apr 19 06:51:47 2022 +0200 ; Merge from origin/emacs-28 The following commits were skipped: 1b77362771 Avoid hangs in python-mode with debug-on-error set 4684b8e62f Fix major-mode setting regression when there's a mode: cookie commit d78e4460727c348fb5a5a62b774797c4374a1190 Author: Po Lu Date: Tue Apr 19 04:39:37 2022 +0000 Minor cleanups to Haiku menu code * src/haiku_draw_support.cc (BView_SetHighColorForVisibleBell): Delete function. * src/haiku_font_support.cc (BFont_dat): Rename to `BFont_metrics'. * src/haiku_support.cc (DrawContent): Use correct UI color for control text. * src/haiku_support.h (HAIKU_MODIFIER_ALT): Turn into enum. (enum haiku_modifier_specification): New enum. * src/haikufont.c (haikufont_open, haikufont_close): Fix coding style. diff --git a/src/haiku_draw_support.cc b/src/haiku_draw_support.cc index f8df298958..a8d46d000a 100644 --- a/src/haiku_draw_support.cc +++ b/src/haiku_draw_support.cc @@ -468,16 +468,6 @@ BView_FillTriangle (void *view, int x1, int y1, BPoint (x3, y3)); } -void -BView_SetHighColorForVisibleBell (void *view, uint32_t color) -{ - BView *vw = (BView *) view; - rgb_color col; - rgb32_to_rgb_color (color, &col); - - vw->SetHighColor (col); -} - void BView_InvertRect (void *view, int x, int y, int width, int height) { diff --git a/src/haiku_font_support.cc b/src/haiku_font_support.cc index d3e1128e09..6bb934af5f 100644 --- a/src/haiku_font_support.cc +++ b/src/haiku_font_support.cc @@ -85,9 +85,9 @@ BFont_close (void *font) } void -BFont_dat (void *font, int *px_size, int *min_width, int *max_width, - int *avg_width, int *height, int *space_width, int *ascent, - int *descent, int *underline_position, int *underline_thickness) +BFont_metrics (void *font, int *px_size, int *min_width, int *max_width, + int *avg_width, int *height, int *space_width, int *ascent, + int *descent, int *underline_position, int *underline_thickness) { BFont *ft = (BFont *) font; struct font_height fheight; diff --git a/src/haiku_support.cc b/src/haiku_support.cc index 1feea6c450..290b2541f4 100644 --- a/src/haiku_support.cc +++ b/src/haiku_support.cc @@ -2263,7 +2263,7 @@ class EmacsTitleMenuItem : public BMenuItem menu->PushState (); menu->SetFont (be_bold_font); - BView_SetHighColorForVisibleBell (menu, 0); + menu->SetHighColor (ui_color (B_CONTROL_TEXT_COLOR)); BMenuItem::DrawContent (); menu->PopState (); } diff --git a/src/haiku_support.h b/src/haiku_support.h index 4718be4f84..7f6f6e9b0d 100644 --- a/src/haiku_support.h +++ b/src/haiku_support.h @@ -131,10 +131,13 @@ struct haiku_dummy_event char dummy; }; -#define HAIKU_MODIFIER_ALT (1) -#define HAIKU_MODIFIER_CTRL (1 << 1) -#define HAIKU_MODIFIER_SHIFT (1 << 2) -#define HAIKU_MODIFIER_SUPER (1 << 3) +enum haiku_modifier_specification + { + HAIKU_MODIFIER_ALT = 1, + HAIKU_MODIFIER_CTRL = (1 << 1), + HAIKU_MODIFIER_SHIFT = (1 << 2), + HAIKU_MODIFIER_SUPER = (1 << 3), + }; struct haiku_key_event { @@ -459,8 +462,8 @@ extern void BWindow_dimensions (void *, int *, int *); extern void BWindow_Flush (void *); extern void BFont_close (void *); -extern void BFont_dat (void *, int *, int *, int *, int *, - int *, int *, int *, int *, int *, int *); +extern void BFont_metrics (void *, int *, int *, int *, int *, + int *, int *, int *, int *, int *, int *); extern int BFont_have_char_p (void *, int32_t); extern int BFont_have_char_block (void *, int32_t, int32_t); extern void BFont_char_bounds (void *, const char *, int *, int *, int *); @@ -468,11 +471,9 @@ extern void BFont_nchar_bounds (void *, const char *, int *, int *, int *, int32_t); extern struct haiku_font_pattern *BFont_find (struct haiku_font_pattern *); - extern void BView_StartClip (void *); extern void BView_EndClip (void *); extern void BView_SetHighColor (void *, uint32_t); -extern void BView_SetHighColorForVisibleBell (void *, uint32_t); extern void BView_SetLowColor (void *, uint32_t); extern void BView_SetPenSize (void *, int); extern void BView_SetFont (void *, void *); @@ -639,10 +640,10 @@ extern bool be_drag_and_drop_in_progress (void); extern bool be_replay_menu_bar_event (void *, struct haiku_menu_bar_click_event *); #ifdef __cplusplus -extern void *find_appropriate_view_for_draw (void *); } extern _Noreturn void gui_abort (const char *); +extern void *find_appropriate_view_for_draw (void *); #endif /* _cplusplus */ #endif /* _HAIKU_SUPPORT_H_ */ diff --git a/src/haikufont.c b/src/haikufont.c index 4e81e57703..960ca466bc 100644 --- a/src/haikufont.c +++ b/src/haikufont.c @@ -727,10 +727,10 @@ haikufont_open (struct frame *f, Lisp_Object font_entity, int x) avg_width, height, space_width, ascent, descent, underline_pos, underline_thickness; - BFont_dat (be_font, &px_size, &min_width, - &max_width, &avg_width, &height, - &space_width, &ascent, &descent, - &underline_pos, &underline_thickness); + BFont_metrics (be_font, &px_size, &min_width, + &max_width, &avg_width, &height, + &space_width, &ascent, &descent, + &underline_pos, &underline_thickness); font->pixel_size = px_size; font->min_width = min_width; @@ -757,22 +757,31 @@ haikufont_open (struct frame *f, Lisp_Object font_entity, int x) static void haikufont_close (struct font *font) { + struct haikufont_info *info = (struct haikufont_info *) font; + int i; + if (font_data_structures_may_be_ill_formed ()) return; - struct haikufont_info *info = (struct haikufont_info *) font; block_input (); if (info && info->be_font) BFont_close (info->be_font); - for (int i = 0; i < info->metrics_nrows; i++) - if (info->metrics[i]) - xfree (info->metrics[i]); + for (i = 0; i < info->metrics_nrows; i++) + { + if (info->metrics[i]) + xfree (info->metrics[i]); + } + if (info->metrics) xfree (info->metrics); - for (int i = 0; i < 0x100; ++i) - if (info->glyphs[i]) - xfree (info->glyphs[i]); + + for (i = 0; i < 0x100; ++i) + { + if (info->glyphs[i]) + xfree (info->glyphs[i]); + } + xfree (info->glyphs); unblock_input (); } commit 92667cc2fb17af947c202d2de765d8736679e858 Author: Po Lu Date: Tue Apr 19 11:18:25 2022 +0800 Fix last change for GTK 2 * src/xfns.c (x_set_alpha_background): * src/xterm.c (x_update_opaque_region): Move some ifdefs around. diff --git a/src/xfns.c b/src/xfns.c index 9ceba98f67..c7e2984ce1 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -732,7 +732,7 @@ x_set_alpha_background (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { unsigned long opaque_region[] = {0, 0, FRAME_PIXEL_WIDTH (f), FRAME_PIXEL_HEIGHT (f)}; -#ifdef USE_GTK +#ifdef HAVE_GTK3 GObjectClass *object_class; GtkWidgetClass *class; #endif diff --git a/src/xterm.c b/src/xterm.c index b5b2fe3294..c4652c19c6 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -3790,6 +3790,10 @@ x_update_opaque_region (struct frame *f, XEvent *configure) (configure ? configure->xconfigure.height : FRAME_PIXEL_HEIGHT (f))}; +#ifdef HAVE_GTK3 + GObjectClass *object_class; + GtkWidgetClass *class; +#endif if (!FRAME_DISPLAY_INFO (f)->alpha_bits) return; @@ -3815,6 +3819,14 @@ x_update_opaque_region (struct frame *f, XEvent *configure) FRAME_DISPLAY_INFO (f)->Xatom_net_wm_opaque_region, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &opaque_region, 4); + else + { + object_class = G_OBJECT_GET_CLASS (FRAME_GTK_OUTER_WIDGET (f)); + class = GTK_WIDGET_CLASS (object_class); + + if (class->style_updated) + class->style_updated (FRAME_GTK_OUTER_WIDGET (f)); + } #endif unblock_input (); } commit 4dd47196f67a223abf482caf430c3e5dd5c05977 Author: Po Lu Date: Tue Apr 19 11:13:11 2022 +0800 Fix opaque region treatment on GTK 3 * src/xfns.c (x_set_alpha_background): * src/xterm.c (x_update_opaque_region): Update opaque region for tooltip frames the correct way on GTK. diff --git a/src/xfns.c b/src/xfns.c index 195af1381b..9ceba98f67 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -730,9 +730,11 @@ x_set_wait_for_wm (struct frame *f, Lisp_Object new_value, Lisp_Object old_value static void x_set_alpha_background (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { -#ifndef HAVE_GTK3 unsigned long opaque_region[] = {0, 0, FRAME_PIXEL_WIDTH (f), FRAME_PIXEL_HEIGHT (f)}; +#ifdef USE_GTK + GObjectClass *object_class; + GtkWidgetClass *class; #endif gui_set_alpha_background (f, arg, oldval); @@ -776,6 +778,24 @@ x_set_alpha_background (struct frame *f, Lisp_Object arg, Lisp_Object oldval) FRAME_DISPLAY_INFO (f)->Xatom_net_wm_opaque_region, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &opaque_region, 4); +#else + else + { + if (FRAME_TOOLTIP_P (f)) + XChangeProperty (FRAME_X_DISPLAY (f), + FRAME_X_WINDOW (f), + FRAME_DISPLAY_INFO (f)->Xatom_net_wm_opaque_region, + XA_CARDINAL, 32, PropModeReplace, + (unsigned char *) &opaque_region, 4); + else + { + object_class = G_OBJECT_GET_CLASS (FRAME_GTK_OUTER_WIDGET (f)); + class = GTK_WIDGET_CLASS (object_class); + + if (class->style_updated) + class->style_updated (FRAME_GTK_OUTER_WIDGET (f)); + } + } #endif } diff --git a/src/xterm.c b/src/xterm.c index 99269e3e92..b5b2fe3294 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -3783,7 +3783,6 @@ x_toolkit_position (struct frame *f, int x, int y, static void x_update_opaque_region (struct frame *f, XEvent *configure) { -#ifndef HAVE_GTK3 unsigned long opaque_region[] = {0, 0, (configure ? configure->xconfigure.width @@ -3791,7 +3790,6 @@ x_update_opaque_region (struct frame *f, XEvent *configure) (configure ? configure->xconfigure.height : FRAME_PIXEL_HEIGHT (f))}; -#endif if (!FRAME_DISPLAY_INFO (f)->alpha_bits) return; @@ -3810,6 +3808,13 @@ x_update_opaque_region (struct frame *f, XEvent *configure) FRAME_DISPLAY_INFO (f)->Xatom_net_wm_opaque_region, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &opaque_region, 4); +#else + else if (FRAME_TOOLTIP_P (f)) + XChangeProperty (FRAME_X_DISPLAY (f), + FRAME_X_WINDOW (f), + FRAME_DISPLAY_INFO (f)->Xatom_net_wm_opaque_region, + XA_CARDINAL, 32, PropModeReplace, + (unsigned char *) &opaque_region, 4); #endif unblock_input (); } commit 9751250adb1333da55fcadb363266214d0782bb9 Author: Paul Eggert Date: Mon Apr 18 19:44:03 2022 -0700 Port struct Lisp_Subr to C99 * src/lisp.h (struct Lisp_Subr): Don’t use an anonymous union, a feature missing from C99 and not supported by older OS X. All uses changed. diff --git a/src/alloc.c b/src/alloc.c index 8fd981a51f..4fc4044587 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -6894,7 +6894,7 @@ process_mark_stack (ptrdiff_t base_sp) { set_vector_marked (ptr); struct Lisp_Subr *subr = XSUBR (obj); - mark_stack_push_value (subr->native_intspec); + mark_stack_push_value (subr->intspec.native); mark_stack_push_value (subr->command_modes); mark_stack_push_value (subr->native_comp_u); mark_stack_push_value (subr->lambda_list); diff --git a/src/comp.c b/src/comp.c index 398f35ddb0..66a7ab789a 100644 --- a/src/comp.c +++ b/src/comp.c @@ -5439,7 +5439,7 @@ make_subr (Lisp_Object symbol_name, Lisp_Object minarg, Lisp_Object maxarg, x->s.min_args = XFIXNUM (minarg); x->s.max_args = FIXNUMP (maxarg) ? XFIXNUM (maxarg) : MANY; x->s.symbol_name = xstrdup (SSDATA (symbol_name)); - x->s.native_intspec = intspec; + x->s.intspec.native = intspec; x->s.command_modes = command_modes; x->s.doc = XFIXNUM (doc_idx); #ifdef HAVE_NATIVE_COMP diff --git a/src/data.c b/src/data.c index f06b561dcc..72af8a6648 100644 --- a/src/data.c +++ b/src/data.c @@ -1090,10 +1090,10 @@ Value, if non-nil, is a list (interactive SPEC). */) if (SUBRP (fun)) { - if (SUBR_NATIVE_COMPILEDP (fun) && !NILP (XSUBR (fun)->native_intspec)) - return XSUBR (fun)->native_intspec; + if (SUBR_NATIVE_COMPILEDP (fun) && !NILP (XSUBR (fun)->intspec.native)) + return XSUBR (fun)->intspec.native; - const char *spec = XSUBR (fun)->intspec; + const char *spec = XSUBR (fun)->intspec.string; if (spec) return list2 (Qinteractive, (*spec != '(') ? build_string (spec) : diff --git a/src/eval.c b/src/eval.c index 6b1e12b823..37bc03465c 100644 --- a/src/eval.c +++ b/src/eval.c @@ -2055,7 +2055,7 @@ then strings and vectors are not accepted. */) /* Emacs primitives are interactive if their DEFUN specifies an interactive spec. */ if (SUBRP (fun)) - return XSUBR (fun)->intspec ? Qt : if_prop; + return XSUBR (fun)->intspec.string ? Qt : if_prop; /* Bytecode objects are interactive if they are long enough to have an element whose index is COMPILED_INTERACTIVE, which is diff --git a/src/lisp.h b/src/lisp.h index f723876634..fb43bfa791 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -2151,9 +2151,9 @@ struct Lisp_Subr short min_args, max_args; const char *symbol_name; union { - const char *intspec; - Lisp_Object native_intspec; - }; + const char *string; + Lisp_Object native; + } intspec; Lisp_Object command_modes; EMACS_INT doc; #ifdef HAVE_NATIVE_COMP diff --git a/src/pdumper.c b/src/pdumper.c index 24393e0366..0b74e6431f 100644 --- a/src/pdumper.c +++ b/src/pdumper.c @@ -2876,13 +2876,13 @@ dump_subr (struct dump_context *ctx, const struct Lisp_Subr *subr) dump_remember_cold_op (ctx, COLD_OP_NATIVE_SUBR, make_lisp_ptr ((void *) subr, Lisp_Vectorlike)); - dump_field_lv (ctx, &out, subr, &subr->native_intspec, WEIGHT_NORMAL); + dump_field_lv (ctx, &out, subr, &subr->intspec.native, WEIGHT_NORMAL); dump_field_lv (ctx, &out, subr, &subr->command_modes, WEIGHT_NORMAL); } else { dump_field_emacs_ptr (ctx, &out, subr, &subr->symbol_name); - dump_field_emacs_ptr (ctx, &out, subr, &subr->intspec); + dump_field_emacs_ptr (ctx, &out, subr, &subr->intspec.string); dump_field_emacs_ptr (ctx, &out, subr, &subr->command_modes); } DUMP_FIELD_COPY (&out, subr, doc); commit 75dfc1e8706d994bd7b18a24360847fd12bd5af0 Author: Paul Eggert Date: Tue Apr 19 04:29:49 2022 +0200 Port module_bignum_count_max to strict C * src/emacs-module.c (module_bignum_count_max): Make this a macro, not an enum, since it might not fit into int as C99 requires. diff --git a/src/emacs-module.c b/src/emacs-module.c index 0974a199e5..0d3cce0276 100644 --- a/src/emacs-module.c +++ b/src/emacs-module.c @@ -955,11 +955,9 @@ single memcpy to convert the magnitude. This way we largely avoid the import/export overhead on most platforms. */ -enum -{ - /* Documented maximum count of magnitude elements. */ - module_bignum_count_max = min (SIZE_MAX, PTRDIFF_MAX) / sizeof (emacs_limb_t) -}; +/* Documented maximum count of magnitude elements. */ +#define module_bignum_count_max \ + ((ptrdiff_t) min (SIZE_MAX, PTRDIFF_MAX) / sizeof (emacs_limb_t)) /* Verify that emacs_limb_t indeed has unique object representations. */ commit 5fae0325872710dcbf42541b985103b66f613f61 Author: Sean Whitton Date: Mon Apr 18 19:43:32 2022 -0700 Tell those using exclusively X not to use the PGTK port * INSTALL (Alternative window systems): Tell those using exclusively X not to use the PGTK port. diff --git a/INSTALL b/INSTALL index b1e3c72c4b..f2687225da 100644 --- a/INSTALL +++ b/INSTALL @@ -243,6 +243,11 @@ This build is only supported with GTK+ version 3, and it is an error to specify any other X-specific configuration option when PGTK is enabled. +If you use exclusively X, do not use the PGTK port. There are a +number of respects in which the regular --with-x-toolkit=gtk build +works better. The PGTK port should not be considered a simple upgrade +from --with-x-toolkit=gtk. + With the PGTK build, you will be able to switch between running Emacs on X, Wayland and Broadway using the 'GDK_BACKEND' environment variable. GTK+ should automatically detect and use the correct value commit ace1f32ac1185cad0c43e4b793fe53b54be95161 Author: Po Lu Date: Tue Apr 19 01:15:33 2022 +0000 Fix display of glyphless characters on Haiku * src/haikuterm.c (haiku_draw_glyph_string_foreground): Fix pen size when drawing composite string w/o font. (haiku_draw_glyphless_glyph_string_foreground): Correctly display glyphless character rectangle. diff --git a/src/haikuterm.c b/src/haikuterm.c index 203bfa3f81..9cd1d0f015 100644 --- a/src/haikuterm.c +++ b/src/haikuterm.c @@ -1059,6 +1059,8 @@ haiku_draw_glyph_string_foreground (struct glyph_string *s) for (i = 0; i < s->nchars; ++i) { struct glyph *g = s->first_glyph + i; + + BView_SetPenSize (view, 1); BView_StrokeRectangle (view, x, s->y, g->pixel_width, s->height); x += g->pixel_width; @@ -1090,6 +1092,7 @@ haiku_draw_glyphless_glyph_string_foreground (struct glyph_string *s) unsigned char2b[8]; int x, i, j; struct face *face = s->face; + unsigned long color; /* If first glyph of S has a left box line, start drawing the text of S to the right of that box line. */ @@ -1153,11 +1156,21 @@ haiku_draw_glyphless_glyph_string_foreground (struct glyph_string *s) s->ybase + glyph->slice.glyphless.lower_yoff, false); } + if (glyph->u.glyphless.method != GLYPHLESS_DISPLAY_THIN_SPACE) - BView_FillRectangle (FRAME_HAIKU_VIEW (s->f), - x, s->ybase - glyph->ascent, - glyph->pixel_width - 1, - glyph->ascent + glyph->descent - 1); + { + if (s->hl == DRAW_CURSOR) + haiku_merge_cursor_foreground (s, NULL, &color); + else + color = s->face->foreground; + + BView_SetHighColor (FRAME_HAIKU_VIEW (s->f), color); + BView_SetPenSize (FRAME_HAIKU_VIEW (s->f), 1); + BView_StrokeRectangle (FRAME_HAIKU_VIEW (s->f), + x, s->ybase - glyph->ascent, + glyph->pixel_width - 1, + glyph->ascent + glyph->descent - 1); + } x += glyph->pixel_width; } } commit 734f0f68a492f999a307e1cfa6f1cd7df408333f Author: Paul Eggert Date: Mon Apr 18 13:08:26 2022 -0700 Use "@code{nil}" in documentation diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index cbd8ac9b9a..2bd0a81fad 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi @@ -2142,7 +2142,7 @@ the buffer might contain long lines that will be truncated anyway. The optional argument @var{y-limit}, if non-@code{nil}, specifies the maximum Y coordinate beyond which text is to be ignored; it is therefore also the maximum pixel-height that the function can return. -If @var{y-limit} is nil or omitted, it means to considers all the +If @var{y-limit} is @code{nil} or omitted, it means to consider all the lines of text till the buffer position specified by @var{to}. Since calculating the pixel-height of a large buffer can take some time, it makes sense to specify this argument; in particular, if the caller @@ -7517,7 +7517,7 @@ end of the buffer continues from the other end. If @var{display-message} is non-@code{nil}, the button's help-echo string is displayed. Any button with a non-@code{nil} @code{skip} property is skipped over. Returns the button found, and signals an error if no -buttons can be found. If @var{no-error} is non-@code{nil}, return nil +buttons can be found. If @var{no-error} is non-@code{nil}, return @code{nil} instead of signaling the error. @end deffn @@ -7529,7 +7529,7 @@ end of the buffer continues from the other end. If @var{display-message} is non-@code{nil}, the button's help-echo string is displayed. Any button with a non-@code{nil} @code{skip} property is skipped over. Returns the button found, and signals an error if no -buttons can be found. If @var{no-error} is non-@code{nil}, return nil +buttons can be found. If @var{no-error} is non-@code{nil}, return @code{nil} instead of signaling the error. @end deffn diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi index 70337d4c4a..2f386eaa47 100644 --- a/doc/lispref/functions.texi +++ b/doc/lispref/functions.texi @@ -1616,7 +1616,7 @@ were a local variable that had been captured by static scoping. @defun oclosure-type object This function returns the OClosure type (a symbol) of @var{object} if it is an -OClosure, and nil otherwise. +OClosure, and @code{nil} otherwise. @end defun diff --git a/doc/lispref/keymaps.texi b/doc/lispref/keymaps.texi index 9d3dc8fe42..a037c228f1 100644 --- a/doc/lispref/keymaps.texi +++ b/doc/lispref/keymaps.texi @@ -1643,7 +1643,7 @@ non-@code{nil}, the definition will be removed. This is almost the same as setting the definition to @code{nil}, but makes a difference if the @var{keymap} has a parent, and @var{key} is shadowing the same binding in the parent. With @var{remove}, subsequent lookups will -return the binding in the parent, and with a nil @var{def}, the +return the binding in the parent, whereas with a @code{nil} definition the lookups will return @code{nil}. @end defun diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi index 2f9cdac232..cabae08970 100644 --- a/doc/lispref/os.texi +++ b/doc/lispref/os.texi @@ -1528,7 +1528,7 @@ integer, it specifies a clock frequency and this function returns an integer-pair timestamp @code{(@var{ticks} . @var{form})}. If @var{form} is @code{t}, this function treats it as a positive integer suitable for representing the timestamp; for example, it is treated as 1000000000 -if @var{time} is nil and the platform timestamp has nanosecond +if @var{time} is @code{nil} and the platform timestamp has nanosecond resolution. If @var{form} is @code{list}, this function returns an integer list @code{(@var{high} @var{low} @var{micro} @var{pico})}. Although an omitted or @code{nil} @var{form} currently acts like diff --git a/doc/lispref/symbols.texi b/doc/lispref/symbols.texi index 9e44348b67..336fa9c918 100644 --- a/doc/lispref/symbols.texi +++ b/doc/lispref/symbols.texi @@ -775,7 +775,7 @@ For most purposes, when the flag variable @code{symbols-with-pos-enabled} is non-@code{nil}, symbols with positions behave just as bare symbols do. For example, @samp{(eq # foo)} has a value @code{t} when that variable -is set (but nil when it isn't set). Most of the time in Emacs this +is set (but @code{nil} when it isn't set). Most of the time in Emacs this variable is @code{nil}, but the byte compiler binds it to @code{t} when it runs. commit 7b1881682bfbd1ff83d47b88fa8cca22c0290c17 Author: Paul Eggert Date: Mon Apr 18 12:57:40 2022 -0700 Remove obsolete footnote Emacs no longer warns about timestamps like (1 . 1000). diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi index eea0ab8f6b..2f9cdac232 100644 --- a/doc/lispref/os.texi +++ b/doc/lispref/os.texi @@ -1345,11 +1345,7 @@ A pair of integers @code{(@var{ticks} . @var{hz})}, where @var{hz} is positive. This represents @var{ticks}/@var{hz} seconds, which is the same time as plain @var{ticks} if @var{hz} is 1. A common value for @var{hz} is 1000000000, for a nanosecond-resolution -clock.@footnote{Currently @var{hz} should be at least 65536 to avoid -compatibility warnings when the timestamp is passed to standard -functions, as previous versions of Emacs would interpret such a -timestamps differently due to backward-compatibility concerns. These -warnings are intended to be removed in a future Emacs version.} +clock. @item A list of four integers @code{(@var{high} @var{low} @var{micro} commit fa91925e13a717c7f3cf8cd30fe4f9e867c091f4 Author: Alan Third Date: Sun Apr 17 21:15:05 2022 +0100 Fix glyphless glyph display on NS (bug#54970) * src/nsterm.m (ns_draw_glyphless_glyph_string_foreground): New function. (ns_draw_glyph_string): Use the new function. * src/nsfont.m (nsfont_draw): Fix the location the glyphs are drawn, and also which glyphs are drawn. (ns_glyph_metrics): Reverse ascent and descent. diff --git a/src/nsfont.m b/src/nsfont.m index f3c8a82930..e913a50cb6 100644 --- a/src/nsfont.m +++ b/src/nsfont.m @@ -1176,15 +1176,15 @@ is false when (FROM > 0 || TO < S->nchars). */ face = s->face; - r.origin.x = s->x; + r.origin.x = x; if (s->face->box != FACE_NO_BOX && s->first_glyph->left_box_line_p) r.origin.x += max (s->face->box_vertical_line_width, 0); - r.origin.y = s->y; + r.origin.y = y; r.size.height = FONT_HEIGHT (font); - for (int i = from; i < to; ++i) - c[i] = s->char2b[i]; + for (int i = 0; i < len; ++i) + c[i] = s->char2b[i + from]; /* Fill background if requested. */ if (with_background && !isComposite) @@ -1210,8 +1210,6 @@ is false when (FROM > 0 || TO < S->nchars). */ } /* set up for character rendering */ - r.origin.y = y; - if (s->hl == DRAW_CURSOR) col = FRAME_BACKGROUND_COLOR (s->f); else @@ -1721,8 +1719,8 @@ is false when (FROM > 0 || TO < S->nchars). */ metrics->rbearing = lrint (rb); metrics->lbearing = lrint (lb); - metrics->descent = NSMinY (r); - metrics->ascent = NSMaxY (r); + metrics->descent = - NSMaxY (r); + metrics->ascent = - NSMinY (r); } unblock_input (); } diff --git a/src/nsterm.m b/src/nsterm.m index 550f29212e..5a6a4d663b 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -3945,6 +3945,81 @@ Function modeled after x_draw_glyph_string_box (). } } +/* Draw the foreground of glyph string S for glyphless characters. */ +static void +ns_draw_glyphless_glyph_string_foreground (struct glyph_string *s) +{ + struct glyph *glyph = s->first_glyph; + NSGlyph char2b[8]; + int x, i, j; + + /* If first glyph of S has a left box line, start drawing the text + of S to the right of that box line. */ + if (s->face && s->face->box != FACE_NO_BOX + && s->first_glyph->left_box_line_p) + x = s->x + max (s->face->box_vertical_line_width, 0); + else + x = s->x; + + s->char2b = char2b; + + for (i = 0; i < s->nchars; i++, glyph++) + { + char buf[7]; + char *str = NULL; + int len = glyph->u.glyphless.len; + + if (glyph->u.glyphless.method == GLYPHLESS_DISPLAY_ACRONYM) + { + if (len > 0 + && CHAR_TABLE_P (Vglyphless_char_display) + && (CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (Vglyphless_char_display)) + >= 1)) + { + Lisp_Object acronym + = (! glyph->u.glyphless.for_no_font + ? CHAR_TABLE_REF (Vglyphless_char_display, + glyph->u.glyphless.ch) + : XCHAR_TABLE (Vglyphless_char_display)->extras[0]); + if (STRINGP (acronym)) + str = SSDATA (acronym); + } + } + else if (glyph->u.glyphless.method == GLYPHLESS_DISPLAY_HEX_CODE) + { + unsigned int ch = glyph->u.glyphless.ch; + eassume (ch <= MAX_CHAR); + sprintf (buf, "%0*X", ch < 0x10000 ? 4 : 6, ch); + str = buf; + } + + if (str) + { + int upper_len = (len + 1) / 2; + + /* It is assured that all LEN characters in STR is ASCII. */ + for (j = 0; j < len; j++) + char2b[j] = s->font->driver->encode_char (s->font, str[j]) & 0xFFFF; + s->font->driver->draw (s, 0, upper_len, + x + glyph->slice.glyphless.upper_xoff, + s->ybase + glyph->slice.glyphless.upper_yoff, + false); + s->font->driver->draw (s, upper_len, len, + x + glyph->slice.glyphless.lower_xoff, + s->ybase + glyph->slice.glyphless.lower_yoff, + false); + } + if (glyph->u.glyphless.method != GLYPHLESS_DISPLAY_THIN_SPACE) + ns_draw_box (NSMakeRect (x, s->ybase - glyph->ascent, + glyph->pixel_width - 1, + glyph->ascent + glyph->descent - 1), + 1, 1, + [NSColor colorWithUnsignedLong:NS_FACE_FOREGROUND (s->face)], + YES, YES); + x += glyph->pixel_width; + } +} + static void ns_draw_glyph_string (struct glyph_string *s) /* -------------------------------------------------------------------------- @@ -4058,9 +4133,7 @@ Function modeled after x_draw_glyph_string_box (). else ns_maybe_dumpglyphs_background (s, s->first_glyph->type == COMPOSITE_GLYPH); - /* ... */ - /* Not yet implemented. */ - /* ... */ + ns_draw_glyphless_glyph_string_foreground (s); break; default: commit 5c7b5c65ada6c07509a46ec459bf3a3aea3a6386 Author: Juri Linkov Date: Mon Apr 18 22:16:17 2022 +0300 ; * doc/emacs/mini.texi (Completion Commands): Remove duplicate @findex. diff --git a/doc/emacs/mini.texi b/doc/emacs/mini.texi index 20282d5378..a899fea7e3 100644 --- a/doc/emacs/mini.texi +++ b/doc/emacs/mini.texi @@ -381,8 +381,6 @@ used with the completion list: @vindex minibuffer-completion-auto-choose @item M-@key{DOWN} @itemx M-@key{UP} -@findex previous-completion -@findex next-completion These keys will navigate through the completions displayed in the completions buffer. When @code{minibuffer-completion-auto-choose} is non-@code{nil} (which is the default), using these commands will commit a45c1c45a29cbf9416bb03f77c99b383db43e7a0 Author: Eli Zaretskii Date: Mon Apr 18 21:04:57 2022 +0300 Minor improvements in 'restart-emacs' on MS-Windows * src/w32.c (w32_reexec_emacs): Explicitly request a new console for the restarted Emacs -nw, and specify its dimensions. Specify NULL instead of security attributes, per examples on the Internet. * src/w32console.c (initialize_w32_display): Check errors in call to GetConsoleCursorInfo. diff --git a/src/w32.c b/src/w32.c index e4237579d8..74923ffece 100644 --- a/src/w32.c +++ b/src/w32.c @@ -10628,41 +10628,46 @@ int w32_reexec_emacs (char *cmd_line, const char *wdir) { STARTUPINFO si; - SECURITY_ATTRIBUTES sec_attrs; BOOL status; PROCESS_INFORMATION proc_info; + DWORD dwCreationFlags = NORMAL_PRIORITY_CLASS; GetStartupInfo (&si); /* Use the same startup info as the caller. */ - sec_attrs.nLength = sizeof (sec_attrs); - sec_attrs.lpSecurityDescriptor = NULL; - sec_attrs.bInheritHandle = FALSE; - - /* Make sure we are in the original directory, in case the command - line specifies the program as a relative file name. */ - chdir (wdir); - - /* This is a kludge: it causes the restarted "emacs -nw" to have a - new console window created for it, and that new window might have - different (default) properties, not the ones of the parent - process's console window. But without this, restarting Emacs in - the -nw mode simply doesn't work. FIXME! */ if (inhibit_window_system) { - if (!FreeConsole ()) + HANDLE screen_handle; + CONSOLE_SCREEN_BUFFER_INFO screen_info; + + screen_handle = GetStdHandle (STD_OUTPUT_HANDLE); + if (screen_handle != INVALID_HANDLE_VALUE + && GetConsoleScreenBufferInfo (screen_handle, &screen_info)) { - errno = ENOEXEC; - return -1; + /* Make the restarted Emacs's console window the same + dimensions as ours. FIXME: for some reason this doesn't + seem to work! */ + si.dwFlags |= STARTF_USECOUNTCHARS; + si.dwXCountChars = screen_info.dwSize.X; + si.dwYCountChars = screen_info.dwSize.Y; } + /* This is a kludge: it causes the restarted "emacs -nw" to have + a new console window created for it, and that new window + might have different (default) properties, not the ones of + the parent process's console window. But without this, + restarting Emacs in the -nw mode simply doesn't work. + FIXME! */ + dwCreationFlags = CREATE_NEW_CONSOLE; } - status = CreateProcess (NULL, /* program */ + /* Make sure we are in the original directory, in case the command + line specifies the program as a relative file name. */ + chdir (wdir); + + status = CreateProcess (NULL, /* no program, take from command line */ cmd_line, /* command line */ - &sec_attrs, /* process attributes */ + NULL, NULL, /* thread attributes */ - TRUE, /* inherit handles? */ - inhibit_window_system - ? 0 /* inherit parent's console */ - : NORMAL_PRIORITY_CLASS, + FALSE, /* unherit handles? */ + dwCreationFlags, NULL, /* environment */ wdir, /* initial directory */ &si, /* startup info */ diff --git a/src/w32console.c b/src/w32console.c index 12e1f39789..09749126e0 100644 --- a/src/w32console.c +++ b/src/w32console.c @@ -716,10 +716,10 @@ initialize_w32_display (struct terminal *term, int *width, int *height) if (cur_screen == INVALID_HANDLE_VALUE) { - printf ("CreateConsoleScreenBuffer failed in ResetTerm\n"); + printf ("CreateConsoleScreenBuffer failed in initialize_w32_display\n"); printf ("LastError = 0x%lx\n", GetLastError ()); fflush (stdout); - exit (0); + exit (1); } #else cur_screen = prev_screen; @@ -760,7 +760,13 @@ initialize_w32_display (struct terminal *term, int *width, int *height) } } - GetConsoleScreenBufferInfo (cur_screen, &info); + if (!GetConsoleScreenBufferInfo (cur_screen, &info)) + { + printf ("GetConsoleScreenBufferInfo failed in initialize_w32_display\n"); + printf ("LastError = 0x%lx\n", GetLastError ()); + fflush (stdout); + exit (1); + } char_attr_normal = info.wAttributes; commit 850074636e73509b09c28e965c1af054a84f4069 Author: Alan Mackenzie Date: Mon Apr 18 15:16:54 2022 +0000 Byte compiler: correct output warning message positions Correct the algorithm for determining the warning position to get the first symbol-with-position in byte-compile--form-stack. * lisp/emacs-lisp/bytecomp.el (byte-compile--first-symbol-with-pos): Function renamed and amended from byte-compile--first-symbol. (byte-compile--warning-source-offset): Call the new function above rather than the old one. diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 43648fa657..8128410916 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -1173,16 +1173,16 @@ message buffer `default-directory'." (f2 (file-relative-name file dir))) (if (< (length f2) (length f1)) f2 f1))) -(defun byte-compile--first-symbol (form) - "Return the \"first\" symbol found in form, or 0 if there is none. +(defun byte-compile--first-symbol-with-pos (form) + "Return the \"first\" symbol with position found in form, or 0 if none. Here, \"first\" is by a depth first search." (let (sym) (cond - ((symbolp form) form) + ((symbol-with-pos-p form) form) ((consp form) - (or (and (symbolp (setq sym (byte-compile--first-symbol (car form)))) + (or (and (symbol-with-pos-p (setq sym (byte-compile--first-symbol-with-pos (car form)))) sym) - (and (symbolp (setq sym (byte-compile--first-symbol (cdr form)))) + (and (symbolp (setq sym (byte-compile--first-symbol-with-pos (cdr form)))) sym) 0)) ((and (vectorp form) @@ -1193,7 +1193,7 @@ Here, \"first\" is by a depth first search." (catch 'sym (while (< i len) (when (symbolp - (setq elt (byte-compile--first-symbol (aref form i)))) + (setq elt (byte-compile--first-symbol-with-pos (aref form i)))) (throw 'sym elt)) (setq i (1+ i))) 0))) @@ -1204,7 +1204,7 @@ Here, \"first\" is by a depth first search." Return nil if such is not found." (catch 'offset (dolist (form byte-compile-form-stack) - (let ((s (byte-compile--first-symbol form))) + (let ((s (byte-compile--first-symbol-with-pos form))) (if (symbol-with-pos-p s) (throw 'offset (symbol-with-pos-pos s))))))) commit 352fc739a1df259b1d2de6bc442465f344e44fec Author: Lars Ingebrigtsen Date: Mon Apr 18 13:36:05 2022 +0200 Make isearch-lax-whitespace a user option * lisp/isearch.el (isearch-lax-whitespace): Make into a defcustom (bug#20351). diff --git a/lisp/isearch.el b/lisp/isearch.el index 168d71ada3..be0227b6e7 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -868,14 +868,16 @@ This variable is set and changed during isearch. To change the default behavior used for searches, see `search-default-mode' instead.") -(defvar isearch-lax-whitespace t +(defcustom isearch-lax-whitespace t "If non-nil, a space will match a sequence of whitespace chars. When you enter a space or spaces in ordinary incremental search, it will match any sequence matched by the regexp defined by the variable `search-whitespace-regexp'. If the value is nil, each space you type matches literally, against one space. You can toggle the value of this variable by the command `isearch-toggle-lax-whitespace', usually bound to -`M-s SPC' during isearch.") +`M-s SPC' during isearch." + :type 'boolean + :version "25.1") (defvar isearch-regexp-lax-whitespace nil "If non-nil, a space will match a sequence of whitespace chars. commit 1b7736277114bf91012b817a4e2557625b7340a5 (refs/remotes/origin/emacs-28) Author: Lars Ingebrigtsen Date: Mon Apr 18 13:17:32 2022 +0200 Avoid hangs in python-mode with debug-on-error set * lisp/progmodes/python.el (python-nav-end-of-statement): Avoid using cl-assert here, because this is called from the font-lock machinery, and if debug-on-error is set here, we'll hang Emacs (bug#54996). Do not merge to master. diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index e6e8a37ad5..70828cb223 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -1620,23 +1620,20 @@ of the statement." ;; are somehow out of whack. This has been ;; observed when using `syntax-ppss' during ;; narrowing. - (cl-assert (>= string-start last-string-end) - :show-args - "\ -Overlapping strings detected (start=%d, last-end=%d)") - (goto-char string-start) - (if (python-syntax-context 'paren) - ;; Ended up inside a paren, roll again. - (python-nav-end-of-statement t) - ;; This is not inside a paren, move to the - ;; end of this string. - (goto-char (+ (point) - (python-syntax-count-quotes - (char-after (point)) (point)))) - (setq last-string-end - (or (re-search-forward - (rx (syntax string-delimiter)) nil t) - (goto-char (point-max)))))) + (when (>= string-start last-string-end) + (goto-char string-start) + (if (python-syntax-context 'paren) + ;; Ended up inside a paren, roll again. + (python-nav-end-of-statement t) + ;; This is not inside a paren, move to the + ;; end of this string. + (goto-char (+ (point) + (python-syntax-count-quotes + (char-after (point)) (point)))) + (setq last-string-end + (or (re-search-forward + (rx (syntax string-delimiter)) nil t) + (goto-char (point-max))))))) ((python-syntax-context 'paren) ;; The statement won't end before we've escaped ;; at least one level of parenthesis. commit 85db21b94b23b4701930892d1eecc9a1167ed968 Author: Lars Ingebrigtsen Date: Mon Apr 18 13:17:32 2022 +0200 Avoid hangs in python-mode with debug-on-error set * lisp/progmodes/python.el (python-nav-end-of-statement): Avoid using cl-assert here, because this is called from the font-lock machinery, and if debug-on-error is set here, we'll hang Emacs (bug#54996). diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index f355055806..b7914655aa 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -1629,23 +1629,20 @@ of the statement." ;; are somehow out of whack. This has been ;; observed when using `syntax-ppss' during ;; narrowing. - (cl-assert (>= string-start last-string-end) - :show-args - "\ -Overlapping strings detected (start=%d, last-end=%d)") - (goto-char string-start) - (if (python-syntax-context 'paren) - ;; Ended up inside a paren, roll again. - (python-nav-end-of-statement t) - ;; This is not inside a paren, move to the - ;; end of this string. - (goto-char (+ (point) - (python-syntax-count-quotes - (char-after (point)) (point)))) - (setq last-string-end - (or (re-search-forward - (rx (syntax string-delimiter)) nil t) - (goto-char (point-max)))))) + (when (>= string-start last-string-end) + (goto-char string-start) + (if (python-syntax-context 'paren) + ;; Ended up inside a paren, roll again. + (python-nav-end-of-statement t) + ;; This is not inside a paren, move to the + ;; end of this string. + (goto-char (+ (point) + (python-syntax-count-quotes + (char-after (point)) (point)))) + (setq last-string-end + (or (re-search-forward + (rx (syntax string-delimiter)) nil t) + (goto-char (point-max))))))) ((python-syntax-context 'paren) ;; The statement won't end before we've escaped ;; at least one level of parenthesis. commit fac640ee8608748f0c4b867080d554c1b94121bd Author: Lars Ingebrigtsen Date: Mon Apr 18 12:58:54 2022 +0200 Make it easier to use Emacs as a script interpreter * doc/emacs/cmdargs.texi (Initial Options): Document -x. * lisp/startup.el (command-line-1): Add new -scripteval. (command-line--eval-script): New function. * src/emacs.c (main): Transform -x to -scripteval. (standard_args): Add -x (bug#20682). diff --git a/doc/emacs/cmdargs.texi b/doc/emacs/cmdargs.texi index de1d5e0b2c..946afb6fc1 100644 --- a/doc/emacs/cmdargs.texi +++ b/doc/emacs/cmdargs.texi @@ -294,6 +294,22 @@ which will invoke Emacs with @samp{--script} and supply the name of the script file as @var{file}. Emacs Lisp then treats the @samp{#!} on this first line as a comment delimiter. +@item -x +@opindex -x +This option can only be used in executable script files, and should be +invoked like this: + +@example +#!/usr/bin/emacs -x +@end example + +This is like @samp{--script}, but suppresses loading the init files +(like @code{--quick}), and can't be used on a normal command line +(since it doesn't specify the script to load). In addition, when it +reaches the end of the script, it exits Emacs and uses the value of +the final form as the exit value from the script (if the final value +is numerical). Otherwise, it will always exit with a zero value. + @item --no-build-details @opindex --no-build-details @cindex build details diff --git a/etc/NEWS b/etc/NEWS index ec56839c06..3e7788277d 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -100,6 +100,17 @@ Saving Emacs Sessions" node in the Emacs manual for more details. * Startup Changes in Emacs 29.1 ++++ +** Emacs can now be used more easily in an executable script. +If you start an executable script with + + #!/usr/bin/emacs -x + +Emac will start without reading any init files (like with --quick), +and then execute the rest of the script file as Emacs Lisp. When it +reaches the end of the script, Emacs will exit with an exit code from +the value of the final form. + +++ ** Emacs now supports setting 'user-emacs-directory' via '--init-directory'. diff --git a/lisp/startup.el b/lisp/startup.el index ab7b81a707..353b5c78f1 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -2664,7 +2664,7 @@ nil default-directory" name) ;; This is used to handle -script. It's not clear ;; we need to document it (it is totally internal). - ((member argi '("-scriptload")) + ((member argi '("-scriptload" "-scripteval")) (let* ((file (command-line-normalize-file-name (or argval (pop command-line-args-left)))) ;; Take file from default dir. @@ -2677,7 +2677,10 @@ nil default-directory" name) ;; actually exist on some systems. (when (file-exists-p truename) (setq file-ex truename)) - (command-line--load-script file-ex))) + (if (equal argi "-scripteval") + ;; This will kill Emacs. + (command-line--eval-script file-ex) + (command-line--load-script file-ex)))) ((equal argi "-insert") (setq inhibit-startup-screen t) @@ -2879,6 +2882,22 @@ nil default-directory" name) (delete-line)) (eval-buffer buffer nil file nil t))))) +(defun command-line--eval-script (file) + (load-with-code-conversion + file file nil t + (lambda (buffer _) + (with-current-buffer buffer + (goto-char (point-min)) + (when (looking-at "#!") + (forward-line)) + (let (value form) + (while (ignore-error 'end-of-file + (setq form (read (current-buffer)))) + (setq value (eval form t))) + (kill-emacs (if (numberp value) + value + 0))))))) + (defun command-line-normalize-file-name (file) "Collapse multiple slashes to one, to handle non-Emacs file names." (save-match-data diff --git a/src/emacs.c b/src/emacs.c index 2fb62cb69a..3100852b2c 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -296,7 +296,10 @@ Initialization options:\n\ -q --no-site-file --no-site-lisp --no-splash\n\ --no-x-resources\n\ --script FILE run FILE as an Emacs Lisp script\n\ ---terminal, -t DEVICE use DEVICE for terminal I/O\n\ +-x to be used in #!/usr/bin/emacs -x\n\ + and has approximately the same meaning\n\ + as -Q --script\n\ +--terminal, -t DEVICE use DEVICE for terminal I/O\n \ --user, -u USER load ~USER/.emacs instead of your own\n\ \n\ ", @@ -2063,6 +2066,16 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem no_site_lisp = 1; } + if (argmatch (argv, argc, "-x", 0, 1, &junk, &skip_args)) + { + noninteractive = 1; + no_site_lisp = 1; + /* This is picked up in startup.el. */ + argv[skip_args - 1] = (char *) "-scripteval"; + skip_args -= 1; + sort_args (argc, argv); + } + /* Don't actually discard this arg. */ skip_args = count_before; } @@ -2504,6 +2517,7 @@ static const struct standard_args standard_args[] = /* (Note that to imply -nsl, -Q is partially handled here.) */ { "-Q", "--quick", 55, 0 }, { "-quick", 0, 55, 0 }, + { "-x", 0, 55, 0 }, { "-q", "--no-init-file", 50, 0 }, { "-no-init-file", 0, 50, 0 }, { "-init-directory", "--init-directory", 30, 1 }, commit 89a5aa4ca791b3ffefb0a5d464fa433f310a8398 Author: Po Lu Date: Mon Apr 18 18:38:35 2022 +0800 Add missing Motif atoms * src/xselect.c (symbol_to_x_atom): (x_atom_to_symbol): (syms_of_xselect): Optimize for XmTRANSFER_SUCCESS and XmTRANSFER_FAILURE as well. diff --git a/src/xselect.c b/src/xselect.c index f855980a30..6d167c0b6f 100644 --- a/src/xselect.c +++ b/src/xselect.c @@ -208,24 +208,49 @@ static Atom symbol_to_x_atom (struct x_display_info *dpyinfo, Lisp_Object sym) { Atom val; - if (NILP (sym)) return 0; - if (EQ (sym, QPRIMARY)) return XA_PRIMARY; - if (EQ (sym, QSECONDARY)) return XA_SECONDARY; - if (EQ (sym, QSTRING)) return XA_STRING; - if (EQ (sym, QINTEGER)) return XA_INTEGER; - if (EQ (sym, QATOM)) return XA_ATOM; - if (EQ (sym, QCLIPBOARD)) return dpyinfo->Xatom_CLIPBOARD; - if (EQ (sym, QTIMESTAMP)) return dpyinfo->Xatom_TIMESTAMP; - if (EQ (sym, QTEXT)) return dpyinfo->Xatom_TEXT; - if (EQ (sym, QCOMPOUND_TEXT)) return dpyinfo->Xatom_COMPOUND_TEXT; - if (EQ (sym, QUTF8_STRING)) return dpyinfo->Xatom_UTF8_STRING; - if (EQ (sym, QDELETE)) return dpyinfo->Xatom_DELETE; - if (EQ (sym, QMULTIPLE)) return dpyinfo->Xatom_MULTIPLE; - if (EQ (sym, QINCR)) return dpyinfo->Xatom_INCR; - if (EQ (sym, Q_EMACS_TMP_)) return dpyinfo->Xatom_EMACS_TMP; - if (EQ (sym, QTARGETS)) return dpyinfo->Xatom_TARGETS; - if (EQ (sym, QNULL)) return dpyinfo->Xatom_NULL; - if (!SYMBOLP (sym)) emacs_abort (); + if (NILP (sym)) + return 0; + if (EQ (sym, QPRIMARY)) + return XA_PRIMARY; + if (EQ (sym, QSECONDARY)) + return XA_SECONDARY; + if (EQ (sym, QSTRING)) + return XA_STRING; + if (EQ (sym, QINTEGER)) + return XA_INTEGER; + if (EQ (sym, QATOM)) + return XA_ATOM; + if (EQ (sym, QCLIPBOARD)) + return dpyinfo->Xatom_CLIPBOARD; + if (EQ (sym, QTIMESTAMP)) + return dpyinfo->Xatom_TIMESTAMP; + if (EQ (sym, QTEXT)) + return dpyinfo->Xatom_TEXT; + if (EQ (sym, QCOMPOUND_TEXT)) + return dpyinfo->Xatom_COMPOUND_TEXT; + if (EQ (sym, QUTF8_STRING)) + return dpyinfo->Xatom_UTF8_STRING; + if (EQ (sym, QDELETE)) + return dpyinfo->Xatom_DELETE; + if (EQ (sym, QMULTIPLE)) + return dpyinfo->Xatom_MULTIPLE; + if (EQ (sym, QINCR)) + return dpyinfo->Xatom_INCR; + if (EQ (sym, Q_EMACS_TMP_)) + return dpyinfo->Xatom_EMACS_TMP; + if (EQ (sym, QTARGETS)) + return dpyinfo->Xatom_TARGETS; + if (EQ (sym, QNULL)) + return dpyinfo->Xatom_NULL; + if (EQ (sym, QXdndSelection)) + return dpyinfo->Xatom_XdndSelection; + if (EQ (sym, QXmTRANSFER_SUCCESS)) + return dpyinfo->Xatom_XmTRANSFER_SUCCESS; + if (EQ (sym, QXmTRANSFER_FAILURE)) + return dpyinfo->Xatom_XmTRANSFER_FAILURE; + + if (!SYMBOLP (sym)) + emacs_abort (); TRACE1 (" XInternAtom %s", SSDATA (SYMBOL_NAME (sym))); block_input (); @@ -287,6 +312,10 @@ x_atom_to_symbol (struct x_display_info *dpyinfo, Atom atom) return QNULL; if (atom == dpyinfo->Xatom_XdndSelection) return QXdndSelection; + if (atom == dpyinfo->Xatom_XmTRANSFER_SUCCESS) + return QXmTRANSFER_SUCCESS; + if (atom == dpyinfo->Xatom_XmTRANSFER_FAILURE) + return QXmTRANSFER_FAILURE; block_input (); x_catch_errors (dpyinfo->display); @@ -2793,6 +2822,9 @@ A value of 0 means wait as long as necessary. This is initialized from the DEFSYM (Qx_lost_selection_functions, "x-lost-selection-functions"); DEFSYM (Qx_sent_selection_functions, "x-sent-selection-functions"); + DEFSYM (QXmTRANSFER_SUCCESS, "XmTRANSFER_SUCCESS"); + DEFSYM (QXmTRANSFER_FAILURE, "XmTRANSFER_FAILURE"); + pdumper_do_now_and_after_load (syms_of_xselect_for_pdumper); } commit 2b6a1c98dfba09d6922f1074047853366d26e31e Author: Alan Mackenzie Date: Mon Apr 18 10:19:54 2022 +0000 Byte compiler: remove symbol positions from byte-switch tables This fixes bug #54990. * lisp/emacs-lisp/bytecomp.el (byte-compile-lapcode): Remove positions from symbols with positions in byte-switch tables, by temporarily removing the entries from the table, and reinserting them amended. diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index c39d931517..43648fa657 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -1009,13 +1009,22 @@ CONST2 may be evaluated multiple times." ;; Similarly, replace TAGs in all jump tables with the correct PC index. (dolist (hash-table byte-compile-jump-tables) - (maphash #'(lambda (value tag) - (setq pc (cadr tag)) - ;; We don't need to split PC here, as it is stored as a lisp - ;; object in the hash table (whereas other goto-* ops store - ;; it within 2 bytes in the byte string). - (puthash value pc hash-table)) - hash-table)) + (let (alist) + (maphash #'(lambda (value tag) + (setq pc (cadr tag)) + ;; We don't need to split PC here, as it is stored as a + ;; lisp object in the hash table (whereas other goto-* + ;; ops store it within 2 bytes in the byte string). + ;; De-position any symbols with position in `value'. + ;; Since this may change the hash table key, we remove + ;; the entry from the table and reinsert it outside the + ;; scope of the `maphash'. + (setq value (byte-run-strip-symbol-positions value)) + (push (cons value pc) alist) + (remhash value hash-table)) + hash-table) + (dolist (elt alist) + (puthash (car elt) (cdr elt) hash-table)))) (let ((bytecode (apply 'unibyte-string (nreverse bytes)))) (when byte-native-compiling ;; Spill LAP for the native compiler here. commit d5f2305187fa96c5eb427e685f68b90da394e09b Author: Lars Ingebrigtsen Date: Mon Apr 18 11:53:59 2022 +0200 Clean up view-emacs-news code * lisp/help.el (view-emacs-news): Remove workaround after fixing mode: cookie error. diff --git a/lisp/help.el b/lisp/help.el index 0d516cf9f6..c5de59d6bc 100644 --- a/lisp/help.el +++ b/lisp/help.el @@ -453,9 +453,8 @@ With argument, display info only for the selected version." ((< vn 18) "NEWS.1-17") (t (format "NEWS.%d" vn)))) res) - (let ((inhibit-local-variables-regexps '(".*"))) - (find-file (expand-file-name file data-directory)) - (emacs-news-view-mode)) + (find-file (expand-file-name file data-directory)) + (emacs-news-view-mode) (goto-char (point-min)) (when (stringp version) (when (re-search-forward commit 26faa2b943675107e1664b2fea7174137c473475 Author: Nacho Barrientos Date: Mon Apr 18 11:36:52 2022 +0200 Unify local variable initialisation in url-http * lisp/url/url-http.el (url-http-chunked-last-crlf-missing): Treat url-http-chunked-last-crlf-missing as any other buffer variable by declaring and initialising it the same way as the other related ones (bug#54989). Copyright-paperwork-exempt: yes diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el index 7f55866eec..b950a8994f 100644 --- a/lisp/url/url-http.el +++ b/lisp/url/url-http.el @@ -36,7 +36,7 @@ (defvar url-current-object) (defvar url-http-after-change-function) (defvar url-http-chunked-counter) -(defvar url-http-chunked-last-crlf-missing nil) +(defvar url-http-chunked-last-crlf-missing) (defvar url-http-chunked-length) (defvar url-http-chunked-start) (defvar url-http-connection-opened) @@ -1163,7 +1163,7 @@ the end of the document." (progn (url-http-debug "Spinning for the terminator of last chunk...") - (setq-local url-http-chunked-last-crlf-missing + (setq url-http-chunked-last-crlf-missing (point))) (url-http-debug "Removing terminator of last chunk") (delete-region (match-beginning 0) (match-end 0)) @@ -1354,6 +1354,7 @@ The return value of this function is the retrieval buffer." url-http-after-change-function url-http-response-version url-http-response-status + url-http-chunked-last-crlf-missing url-http-chunked-length url-http-chunked-counter url-http-chunked-start @@ -1378,6 +1379,7 @@ The return value of this function is the retrieval buffer." url-http-noninteractive url-request-noninteractive url-http-data url-request-data url-http-process connection + url-http-chunked-last-crlf-missing nil url-http-chunked-length nil url-http-chunked-start nil url-http-chunked-counter 0 commit 088cb6115f9e3c4637b1eafbffa022873a70d7e9 Author: Lars Ingebrigtsen Date: Mon Apr 18 11:31:28 2022 +0200 Make `restart-emacs' work when Emacs is started with --chdir * src/emacs.c (find_emacs_executable): Rename from load_pdump_find_executable and always define. (load_pdump): Return the executable. (main): Store the executable. (Fkill_emacs): Use the stored executable so that --chdir works with relative executable names, and so that we attempt to restart the same executable and not some other Emacs from PATH. diff --git a/src/emacs.c b/src/emacs.c index e65ed125b9..2fb62cb69a 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -233,6 +233,7 @@ HANDLE w32_daemon_event; /* Save argv and argc. */ char **initial_argv; int initial_argc; +static char *initial_emacs_executable = NULL; /* The name of the working directory, or NULL if this info is unavailable. */ char const *emacs_wd; @@ -714,34 +715,6 @@ argmatch (char **argv, int argc, const char *sstr, const char *lstr, } } -#ifdef HAVE_PDUMPER - -static const char * -dump_error_to_string (int result) -{ - switch (result) - { - case PDUMPER_LOAD_SUCCESS: - return "success"; - case PDUMPER_LOAD_OOM: - return "out of memory"; - case PDUMPER_NOT_LOADED: - return "not loaded"; - case PDUMPER_LOAD_FILE_NOT_FOUND: - return "could not open file"; - case PDUMPER_LOAD_BAD_FILE_TYPE: - return "not a dump file"; - case PDUMPER_LOAD_FAILED_DUMP: - return "dump file is result of failed dump attempt"; - case PDUMPER_LOAD_VERSION_MISMATCH: - return "not built for this Emacs executable"; - default: - return (result <= PDUMPER_LOAD_ERROR - ? "generic error" - : strerror (result - PDUMPER_LOAD_ERROR)); - } -} - /* Find a name (absolute or relative) of the Emacs executable whose name (as passed into this program) is ARGV0. Called early in initialization by portable dumper loading code, so avoid Lisp and @@ -750,7 +723,7 @@ dump_error_to_string (int result) if not found. Store into *CANDIDATE_SIZE a lower bound on the size of any heap allocation. */ static char * -load_pdump_find_executable (char const *argv0, ptrdiff_t *candidate_size) +find_emacs_executable (char const *argv0, ptrdiff_t *candidate_size) { *candidate_size = 0; @@ -841,7 +814,36 @@ load_pdump_find_executable (char const *argv0, ptrdiff_t *candidate_size) #endif /* !WINDOWSNT */ } -static void +#ifdef HAVE_PDUMPER + +static const char * +dump_error_to_string (int result) +{ + switch (result) + { + case PDUMPER_LOAD_SUCCESS: + return "success"; + case PDUMPER_LOAD_OOM: + return "out of memory"; + case PDUMPER_NOT_LOADED: + return "not loaded"; + case PDUMPER_LOAD_FILE_NOT_FOUND: + return "could not open file"; + case PDUMPER_LOAD_BAD_FILE_TYPE: + return "not a dump file"; + case PDUMPER_LOAD_FAILED_DUMP: + return "dump file is result of failed dump attempt"; + case PDUMPER_LOAD_VERSION_MISMATCH: + return "not built for this Emacs executable"; + default: + return (result <= PDUMPER_LOAD_ERROR + ? "generic error" + : strerror (result - PDUMPER_LOAD_ERROR)); + } +} + +/* This function returns the Emacs executable. */ +static char * load_pdump (int argc, char **argv) { const char *const suffix = ".pdmp"; @@ -890,7 +892,7 @@ load_pdump (int argc, char **argv) #ifndef NS_SELF_CONTAINED ptrdiff_t exec_bufsize; #endif - emacs_executable = load_pdump_find_executable (argv[0], &bufsize); + emacs_executable = find_emacs_executable (argv[0], &bufsize); #ifndef NS_SELF_CONTAINED exec_bufsize = bufsize; #endif @@ -907,7 +909,7 @@ load_pdump (int argc, char **argv) if (result != PDUMPER_LOAD_SUCCESS) fatal ("could not load dump file \"%s\": %s", dump_file, dump_error_to_string (result)); - return; + return emacs_executable; } /* Look for a dump file in the same directory as the executable; it @@ -1032,7 +1034,8 @@ load_pdump (int argc, char **argv) out: xfree (dump_file); - xfree (emacs_executable); + + return emacs_executable; } #endif /* HAVE_PDUMPER */ @@ -1346,7 +1349,10 @@ main (int argc, char **argv) #ifdef HAVE_PDUMPER if (attempt_load_pdump) - load_pdump (argc, argv); + initial_emacs_executable = load_pdump (argc, argv); +#else + ptrdiff_t bufsize; + initial_emacs_executable = find_emacs_executable (argv[0], &bufsize); #endif argc = maybe_disable_address_randomization (argc, argv); @@ -2781,7 +2787,10 @@ killed. */ error ("No command line arguments known; unable to re-execute Emacs"); /* Check that the binary hasn't gone away. */ - if (!file_access_p (initial_argv[0], F_OK)) + if (!initial_emacs_executable) + error ("Unknown Emacs executable"); + + if (!file_access_p (initial_emacs_executable, F_OK)) error ("Emacs executable \"%s\" can't be found", initial_argv[0]); } #endif @@ -2834,6 +2843,7 @@ killed. */ #ifdef WINDOWSNT if (w32_reexec_emacs (initial_cmdline, initial_wd) < 0) #else + initial_argv[0] = initial_emacs_executable; if (execvp (*initial_argv, initial_argv) < 1) #endif emacs_perror ("Unable to re-execute Emacs"); commit 9fc3b003730b90d88af11a31ea55c38fd733503b Author: Lars Ingebrigtsen Date: Mon Apr 18 11:02:55 2022 +0200 Improve `restart-emacs' error reporting * src/emacs.c (Fkill_emacs): Do better error reporting on restarting. diff --git a/src/emacs.c b/src/emacs.c index 6ef19561e0..e65ed125b9 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -2770,6 +2770,22 @@ killed. */ { int exit_code; +#ifndef WINDOWSNT + /* Do some checking before shutting down Emacs, because errors + can't be meaningfully reported afterwards. */ + if (!NILP (restart)) + { + /* This is very unlikely, but it's possible to execute a binary + (on some systems) with no argv. */ + if (initial_argc < 1) + error ("No command line arguments known; unable to re-execute Emacs"); + + /* Check that the binary hasn't gone away. */ + if (!file_access_p (initial_argv[0], F_OK)) + error ("Emacs executable \"%s\" can't be found", initial_argv[0]); + } +#endif + #ifdef HAVE_LIBSYSTEMD /* Notify systemd we are shutting down, but only if we have notified it about startup. */ @@ -2815,10 +2831,6 @@ killed. */ if (!NILP (restart)) { - /* This is very unlikely, but it's possible to execute a binary - (on some systems) with no argv. */ - if (initial_argc < 1) - emacs_perror ("No command line arguments known; unable to re-execute Emacs"); #ifdef WINDOWSNT if (w32_reexec_emacs (initial_cmdline, initial_wd) < 0) #else commit e0009409b8cb0ce3810abf879e9e00c915724e47 Author: Lars Ingebrigtsen Date: Mon Apr 18 10:50:45 2022 +0200 Make "restart" erroring slightly more reliable * src/emacs.c (Fkill_emacs): Use emacs_perror for the "restart" errors -- we've already shut down Emacs at this point, so the normal erroring machinery isn't reliable. diff --git a/src/emacs.c b/src/emacs.c index fd79963ed9..6ef19561e0 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -2818,13 +2818,13 @@ killed. */ /* This is very unlikely, but it's possible to execute a binary (on some systems) with no argv. */ if (initial_argc < 1) - error ("No command line arguments known; unable to re-execute Emacs"); + emacs_perror ("No command line arguments known; unable to re-execute Emacs"); #ifdef WINDOWSNT if (w32_reexec_emacs (initial_cmdline, initial_wd) < 0) #else if (execvp (*initial_argv, initial_argv) < 1) #endif - error ("Unable to re-execute Emacs"); + emacs_perror ("Unable to re-execute Emacs"); } if (FIXNUMP (arg)) commit 4684b8e62f882b2a0f29d89a49bd5da8fad1218f Author: Lars Ingebrigtsen Date: Mon Apr 18 10:37:14 2022 +0200 Fix major-mode setting regression when there's a mode: cookie * lisp/files.el (hack-local-variables): Fix regression in setting the major mode when there are mode: cookies in the file (bug#54993). Do not merge to master. diff --git a/lisp/files.el b/lisp/files.el index d8e7989672..30e8da4da3 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -3887,7 +3887,7 @@ inhibited." (with-demoted-errors "Directory-local variables error: %s" ;; Note this is a no-op if enable-local-variables is nil. (hack-dir-local-variables)) - (let ((result (append (hack-local-variables--find-variables) + (let ((result (append (hack-local-variables--find-variables handle-mode) (hack-local-variables-prop-line)))) (if (and enable-local-variables (not (inhibit-local-variables-p))) commit 713a1997059fb823f9fa26f92cee032fb6bfdc25 Author: Lars Ingebrigtsen Date: Mon Apr 18 10:36:32 2022 +0200 Fix major-mode setting regression when there's a mode: cookie * lisp/files.el (hack-local-variables): Fix regression in setting the major mode when there are mode: cookies in the file (bug#54993). diff --git a/lisp/files.el b/lisp/files.el index 80180276a9..135a6177e9 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -3899,7 +3899,7 @@ inhibited." (with-demoted-errors "Directory-local variables error: %s" ;; Note this is a no-op if enable-local-variables is nil. (hack-dir-local-variables)) - (let ((result (append (hack-local-variables--find-variables) + (let ((result (append (hack-local-variables--find-variables handle-mode) (hack-local-variables-prop-line)))) (if (and enable-local-variables (not (inhibit-local-variables-p))) diff --git a/test/lisp/files-resources/file-mode b/test/lisp/files-resources/file-mode new file mode 100644 index 0000000000..92ac4c30ef --- /dev/null +++ b/test/lisp/files-resources/file-mode @@ -0,0 +1,3 @@ +Local variables: +mode: text +end: diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el index e4424f3cbe..f76d047f30 100644 --- a/test/lisp/files-tests.el +++ b/test/lisp/files-tests.el @@ -1814,5 +1814,12 @@ Prompt users for any modified buffer with `buffer-offer-save' non-nil." (should (equal (file-name-split "/foo/bar/") '("" "foo" "bar" ""))) (should (equal (file-name-split "foo/bar/") '("foo" "bar" "")))) +(ert-deftest files-test-set-mode () + (find-file (ert-resource-file "file-mode")) + (should (eq major-mode 'text-mode)) + (emacs-lisp-mode) + ;; Check that the mode cookie doesn't override the explicit setting. + (should (eq major-mode 'emacs-lisp-mode))) + (provide 'files-tests) ;;; files-tests.el ends here commit 736fd8b258e5bbddf3e5260db1692d3e9ca4c81c Author: Po Lu Date: Mon Apr 18 16:08:19 2022 +0800 Stop skipping ShapeNotify events during DND on GTK+ * src/xterm.c (handle_one_xevent): Don't skip ShapeNotify events because we can't send these events back to GDK manually. diff --git a/src/xterm.c b/src/xterm.c index ef00e027f8..99269e3e92 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -18661,7 +18661,9 @@ handle_one_xevent (struct x_display_info *dpyinfo, && x_dnd_in_progress && x_dnd_use_toplevels && dpyinfo == FRAME_DISPLAY_INFO (x_dnd_frame)) { +#ifndef USE_GTK XEvent xevent; +#endif XShapeEvent *xse = (XShapeEvent *) event; #if defined HAVE_XCB_SHAPE && defined HAVE_XCB_SHAPE_INPUT_RECTS xcb_shape_get_rectangles_cookie_t bounding_rect_cookie; @@ -18678,6 +18680,10 @@ handle_one_xevent (struct x_display_info *dpyinfo, int rc, ordering; #endif + /* Somehow this really interferes with GTK's own processing + of ShapeNotify events. Not sure what GTK uses them for, + but we cannot skip any of them here. */ +#ifndef USE_GTK while (XPending (dpyinfo->display)) { XNextEvent (dpyinfo->display, &xevent); @@ -18691,6 +18697,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, break; } } +#endif for (struct x_client_list_window *tem = x_dnd_toplevels; tem; tem = tem->next) commit 96b21b8da10e4e31981e8a6874411ab184259fa4 Author: Po Lu Date: Mon Apr 18 15:55:40 2022 +0800 Clarify computation of header line vpos * src/dispnew.c (update_text_area): Test vpos is more than 1 only if is both a tab and header line. Reported by Eli Zaretskii . diff --git a/src/dispnew.c b/src/dispnew.c index 3cfe1b86f6..2aba0edfe8 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -3933,7 +3933,8 @@ update_text_area (struct window *w, struct glyph_row *updated_row, int vpos) Apr 2022) */ || (current_row->mouse_face_p && !(current_row->mode_line_p - && (vpos > w->current_matrix->tab_line_p))) + && (vpos > (w->current_matrix->tab_line_p + && w->current_matrix->header_line_p)))) || current_row->x != desired_row->x) { output_cursor_to (w, vpos, 0, desired_row->y, desired_row->x);