commit d679f9e388cde367d8d0c2e438b62a16ec1aca67 (HEAD, refs/remotes/origin/master) Author: Po Lu Date: Mon Jul 3 11:45:04 2023 +0800 Fix leak when quit arrives during incremental selection transfer * src/xselect.c (x_free_selection_data): New function. (x_get_window_property_as_lisp_data): Free `data' reliably if receive_incremental_selection quits. diff --git a/src/xselect.c b/src/xselect.c index 40be6d4c00c..c38a1f8b6a9 100644 --- a/src/xselect.c +++ b/src/xselect.c @@ -1989,9 +1989,22 @@ receive_incremental_selection (struct x_display_info *dpyinfo, } + +/* Free the selection data allocated inside *DATA, which is actually a + pointer to unsigned char *. */ + +static void +x_free_selection_data (void *data) +{ + unsigned char **ptr; + + ptr = data; + xfree (*ptr); +} + /* Fetch a value from property PROPERTY of X window WINDOW on display - DISPLAY. TARGET_TYPE and SELECTION_ATOM are used in error message - if this fails. */ + DISPLAY. TARGET_TYPE and SELECTION_ATOM are used in the error + message signaled if this fails. */ static Lisp_Object x_get_window_property_as_lisp_data (struct x_display_info *dpyinfo, @@ -2007,6 +2020,7 @@ x_get_window_property_as_lisp_data (struct x_display_info *dpyinfo, ptrdiff_t bytes = 0, array_bytes; Lisp_Object val; Display *display = dpyinfo->display; + specpdl_ref count; /* array_bytes is only used as an argument to xpalloc. The actual size of the data inside the buffer is inside bytes. */ @@ -2042,6 +2056,13 @@ x_get_window_property_as_lisp_data (struct x_display_info *dpyinfo, } } + /* Make sure DATA is freed even if `receive_incremental_connection' + quits. Use xfree, not XFree, because x_get_window_property calls + xmalloc itself. */ + + count = SPECPDL_INDEX (); + record_unwind_protect_ptr (x_free_selection_data, &data); + if (!for_multiple && actual_type == dpyinfo->Xatom_INCR) { /* That wasn't really the data, just the beginning. */ @@ -2051,6 +2072,9 @@ x_get_window_property_as_lisp_data (struct x_display_info *dpyinfo, /* Use xfree, not XFree, because x_get_window_property calls xmalloc itself. */ xfree (data); + + /* In case quitting happens below. */ + data = NULL; unblock_input (); /* Clear bytes again. Previously, receive_incremental_selection @@ -2077,10 +2101,8 @@ x_get_window_property_as_lisp_data (struct x_display_info *dpyinfo, val = selection_data_to_lisp_data (dpyinfo, data, bytes, actual_type, actual_format); - /* Use xfree, not XFree, because x_get_window_property - calls xmalloc itself. */ - xfree (data); - return val; + /* This will also free `data'. */ + return unbind_to (count, val); } /* These functions convert from the selection data read from the server into commit 30f83e30932f2b0f523b66e5dcf1b8fec54ec1f7 Author: Po Lu Date: Mon Jul 3 08:56:21 2023 +0800 Provide move-toolbar in a more appropriate place * src/frame.c (syms_of_frame): Provide `move-toolbar' here... * src/keyboard.c (syms_of_keyboard): ..instead of here. diff --git a/src/frame.c b/src/frame.c index 8ac62b284a0..83925d4742a 100644 --- a/src/frame.c +++ b/src/frame.c @@ -6809,4 +6809,17 @@ focus (where a frame immediately loses focus when it's left by the mouse defsubr (&Sx_parse_geometry); defsubr (&Sreconsider_frame_fonts); #endif + +#ifdef HAVE_WINDOW_SYSTEM + DEFSYM (Qmove_toolbar, "move-toolbar"); + + /* The `tool-bar-position' frame parameter is supported on GTK and + builds using the internal tool bar. Providing this feature + causes menu-bar.el to provide `tool-bar-position' as a user + option. */ + +#if !defined HAVE_EXT_TOOL_BAR || defined USE_GTK + Fprovide (Qmove_toolbar, Qnil); +#endif /* !HAVE_EXT_TOOL_BAR || USE_GTK */ +#endif /* HAVE_WINDOW_SYSTEM */ } diff --git a/src/keyboard.c b/src/keyboard.c index e0182057b39..b61b1766856 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -12793,19 +12793,6 @@ syms_of_keyboard (void) DEFSYM (Qcoding, "coding"); -#ifdef HAVE_WINDOW_SYSTEM - DEFSYM (Qmove_toolbar, "move-toolbar"); - - /* The `tool-bar-position' frame parameter is supported on GTK and - builds using the internal tool bar. Providing this feature - causes menu-bar.el to provide `tool-bar-position' as a user - option. */ - -#if !defined HAVE_EXT_TOOL_BAR || defined USE_GTK - Fprovide (Qmove_toolbar, Qnil); -#endif /* !HAVE_EXT_TOOL_BAR || USE_GTK */ -#endif /* HAVE_WINDOW_SYSTEM */ - Fset (Qecho_area_clear_hook, Qnil); #ifdef USE_LUCID commit 3a07511f1bacafca57a825fdab885f0a24577595 Author: Po Lu Date: Mon Jul 3 08:42:39 2023 +0800 ; * src/keyboard.c (syms_of_keyboard): Fix typo. diff --git a/src/keyboard.c b/src/keyboard.c index 74e30d111db..e0182057b39 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -12796,9 +12796,10 @@ syms_of_keyboard (void) #ifdef HAVE_WINDOW_SYSTEM DEFSYM (Qmove_toolbar, "move-toolbar"); - /* The `tool-bar-position' is supported on GTK and builds using the - internal tool bar. Providing this feature causes menu-bar.el to - provide `tool-bar-position' as a user option. */ + /* The `tool-bar-position' frame parameter is supported on GTK and + builds using the internal tool bar. Providing this feature + causes menu-bar.el to provide `tool-bar-position' as a user + option. */ #if !defined HAVE_EXT_TOOL_BAR || defined USE_GTK Fprovide (Qmove_toolbar, Qnil); commit d0c1e97397aed68170b454cb9e2dce0dca3dee2b Author: Po Lu Date: Mon Jul 3 08:42:24 2023 +0800 Always provide `move-toolbar' when its position can be changed * src/keyboard.c (syms_of_keyboard): Make `move-toolbar' a defsym. Provide that feature if Emacs uses its internal tool bars or GTK+. * src/xfns.c (syms_of_xfns): Stop provide `move-toolbar' here. diff --git a/src/keyboard.c b/src/keyboard.c index b61b1766856..74e30d111db 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -12793,6 +12793,18 @@ syms_of_keyboard (void) DEFSYM (Qcoding, "coding"); +#ifdef HAVE_WINDOW_SYSTEM + DEFSYM (Qmove_toolbar, "move-toolbar"); + + /* The `tool-bar-position' is supported on GTK and builds using the + internal tool bar. Providing this feature causes menu-bar.el to + provide `tool-bar-position' as a user option. */ + +#if !defined HAVE_EXT_TOOL_BAR || defined USE_GTK + Fprovide (Qmove_toolbar, Qnil); +#endif /* !HAVE_EXT_TOOL_BAR || USE_GTK */ +#endif /* HAVE_WINDOW_SYSTEM */ + Fset (Qecho_area_clear_hook, Qnil); #ifdef USE_LUCID diff --git a/src/xfns.c b/src/xfns.c index a58e854811b..5c9f58e3a96 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -10456,7 +10456,6 @@ syms_of_xfns (void) accepts --with-x-toolkit=gtk. */ Fprovide (intern_c_string ("x-toolkit"), Qnil); Fprovide (intern_c_string ("gtk"), Qnil); - Fprovide (intern_c_string ("move-toolbar"), Qnil); DEFVAR_LISP ("gtk-version-string", Vgtk_version_string, doc: /* Version info for GTK+. */); commit a5bf0ae66141e7560f70a045c0dea132a4868c87 Author: Andreas Schwab Date: Mon Jun 12 14:40:24 2023 +0200 sh-script: improve fontification of RPM spec files Fontifiy only macros at line beginning as keywords, otherwise as variables. Add more accurate match for macros. * lisp/progmodes/sh-script.el (sh-font-lock-keywords-var): Add more accurate patterns for rpm macros. Also fontify parenthesized word after keyword. diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index a305c35c5f8..cfc10878922 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -864,10 +864,13 @@ sh-font-lock-keywords-var ("\\${?\\([[:alpha:]_][[:alnum:]_]*\\|[0-9]+\\|[$*_]\\)" 1 font-lock-variable-name-face)) (rpm sh-append rpm2 - ("%{?\\(\\sw+\\)" 1 font-lock-keyword-face)) + ("^\\s-*%\\(\\sw+\\)" 1 font-lock-keyword-face) + ("%{?\\([!?]*[[:alpha:]_][[:alnum:]_]*\\|[0-9]+\\|[%*#]\\*?\\|!?-[[:alpha:]]\\*?\\)" + 1 font-lock-variable-name-face)) (rpm2 sh-append shell ("^Summary:\\(.*\\)$" (1 font-lock-doc-face t)) - ("^\\(\\sw+\\):" 1 font-lock-variable-name-face))) + ("^\\(\\sw+\\)\\((\\(\\sw+\\))\\)?:" (1 font-lock-variable-name-face) + (3 font-lock-string-face nil t)))) "Default expressions to highlight in Shell Script modes. See `sh-feature'.") (defvar sh-font-lock-keywords-var-1 commit 667348682b4423f8c90d213e9ef35fff9cfab44d Author: Mark A. Hershberger Date: Sun Jul 2 15:15:17 2023 -0400 Fix a minor typo * lisp/xml.el: Correct a minor typo found by flandrew. diff --git a/lisp/xml.el b/lisp/xml.el index 9095653416e..5a7501dcf41 100644 --- a/lisp/xml.el +++ b/lisp/xml.el @@ -265,7 +265,7 @@ xml-entity-value-re "\\)*\"\\|'\\(?:[^%&']\\|" xml-pe-reference-re "\\|" xml-reference-re "\\)*'\\)")) -) ; End of `eval-when-compile' +) ; End of `eval-and-compile' ;; [75] ExternalID ::= 'SYSTEM' S SystemLiteral commit 777c4dfa30f33c5e1318cb601759ea4ef278c4f7 Author: Harald Jörg Date: Sun Jul 2 13:00:21 2023 +0200 ; cperl-mode: Fix a wide docstring which causes warnings when compiling * lisp/progmodes/cperl-mode.el (defconst): Fix wide docstring for ' cperl--sloppy-signature-rx' (thanks Mattias Engdegård for reviewing) diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el index 1abe57c15ea..0b3cee7d2d0 100644 --- a/lisp/progmodes/cperl-mode.el +++ b/lisp/progmodes/cperl-mode.el @@ -1363,7 +1363,9 @@ cperl-menu ,cperl--ws*-rx (or "," "=" "||=" "//=" ")")) "A rx sequence for the begin of a signature with initializers. -Initializers can contain almost all Perl constructs and thus can not be covered by regular expressions. This sequence captures enough to distinguish a signature from a prototype.") +Initializers can contain almost all Perl constructs and thus can +not be covered by regular expressions. This sequence captures +enough to distinguish a signature from a prototype.") (defconst cperl--package-rx `(sequence (group "package") commit c2e4c68333d72a342bb531449412a424b3507a65 Author: João Távora Date: Sun Jul 2 11:57:15 2023 +0100 Eglot: another tweak to eglot--sig-info Going to the start of the first param and skipping non-word syntax backward would seem to be the right thing to do, for traditional C-style languages and also languages like Ocaml where function signatures don't start the param list with '('. See also https://github.com/joaotavora/eglot/discussions/1251. * lisp/progmodes/eglot.el (eglot--sig-info): Rework again. diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 897cf3bc93e..f09c348143d 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -3212,7 +3212,7 @@ eglot--sig-info parameter (when (zerop i) (goto-char (elt parlabel 0)) - (search-backward "(" nil t) + (skip-syntax-backward "^w") (add-face-text-property (point-min) (point) 'font-lock-function-name-face)) ;; ...perhaps highlight it in the formals list commit 59a350cb911a1c488635d1eb447b07a509939125 Author: Mattias Engdegård Date: Sun Jul 2 11:44:29 2023 +0200 Warn about misplaced :success in condition-case (bug#64404) * lisp/emacs-lisp/bytecomp.el (byte-compile-condition-case): Warn if :success is part of a list of conditions (it must come alone). diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 99202185d8d..262c658e258 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -5060,6 +5060,10 @@ byte-compile-condition-case (byte-compile-warn-x condition "`condition-case' condition should not be quoted: %S" condition)) + (when (and (consp condition) (memq :success condition)) + (byte-compile-warn-x + condition + "`:success' must be the first element of a `condition-case' handler")) (unless (consp condition) (setq condition (list condition))) (dolist (c condition) (unless (and c (symbolp c)) commit a2ccab18ca247c5ba99499aa65470e15e33adcda Author: Stephen Berman Date: Sun Jul 2 11:49:08 2023 +0200 Fix todo-mode commands to move items and categories (bug#64298) * lisp/calendar/todo-mode.el (todo-move-category): Restore display of selected category in source file, so internal file structure is not visible if user is prompted to choose a new category name in target file, and widen again to delete moved category from source file. (todo-move-item): Don't use todo-forward-item when moving done items, to avoid mislocation if done items sections of the the target category was empty before moving. (todo-forward-item): Remove commented out code meant to have the effect of the above change in todo-move-item, but it did not work. diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el index ad18e8f035e..56b0943d303 100644 --- a/lisp/calendar/todo-mode.el +++ b/lisp/calendar/todo-mode.el @@ -1463,6 +1463,10 @@ todo-move-category (point-max))) (content (buffer-substring-no-properties beg end)) (counts (cdr (assoc cat todo-categories)))) + ;; Restore display of selected category, so internal file + ;; structure is not visible if user is prompted to choose a new + ;; category name in target file. + (todo-category-select) ;; Move the category to the new file. Also update or create ;; archive file if necessary. (with-current-buffer @@ -1525,7 +1529,8 @@ todo-move-category ;; last category, delete the file. Also handle archive file ;; if necessary. (let ((buffer-read-only nil)) - (remove-overlays beg end) + (widen) + (remove-overlays beg end) (delete-region beg end) (goto-char (point-min)) ;; Put point after todo-categories sexp. @@ -2856,7 +2861,8 @@ todo-move-item (while done-items (let ((buffer-read-only nil)) (todo-insert-with-overlays (pop done-items))) - (todo-forward-item))) + (todo-item-end) + (forward-line))) ;; If only done items were moved, move point to the top ;; one, otherwise, move point to the top moved todo item. (goto-char here) @@ -5296,21 +5302,7 @@ todo-forward-item ;; legitimate place to insert an item. But skip this space if ;; count > 1, since that should only stop on an item. (when (and not-done (todo-done-item-p) (not count)) - ;; (if (or (not count) (= count 1)) - (re-search-backward "^$" start t))));) - ;; The preceding sexp is insufficient when buffer is not narrowed, - ;; since there could be no done items in this category, so the - ;; search puts us on first todo item of next category. Does this - ;; ever happen? If so: - ;; (let ((opoint) (point)) - ;; (forward-line -1) - ;; (when (or (not count) (= count 1)) - ;; (cond ((looking-at (concat "^" (regexp-quote todo-category-beg))) - ;; (forward-line -2)) - ;; ((looking-at (concat "^" (regexp-quote todo-category-done))) - ;; (forward-line -1)) - ;; (t - ;; (goto-char opoint))))))) + (re-search-backward "^$" start t)))) (defun todo-backward-item (&optional count) "Move point up to start of item with next higher priority. commit f893ace8352d39c95048b143bf01d35973343ea0 Author: Eli Zaretskii Date: Sun Jul 2 11:10:59 2023 +0300 Fix display of wide characters on TTY frame's mode line * src/xdisp.c (pad_mode_line): New function. (display_string): Use it instead of 'produce_special_glyphs' to replace a character that's too wide to fit on the mode/header/tab line, but which occupies some columns that do fit. (Bug#64395) diff --git a/src/xdisp.c b/src/xdisp.c index 85ece901111..a3464c2c375 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -1194,6 +1194,7 @@ #define face_after_it_pos(IT) face_before_or_after_it_pos (IT, false) #endif /* HAVE_WINDOW_SYSTEM */ static void produce_special_glyphs (struct it *, enum display_element_type); +static void pad_mode_line (struct it *, bool); static void show_mouse_face (Mouse_HLInfo *, enum draw_glyphs_face); static bool coords_in_mouse_face_p (struct window *, int, int); static void reset_box_start_end_flags (struct it *); @@ -28770,7 +28771,11 @@ display_string (const char *string, Lisp_Object lisp_string, Lisp_Object face_st { /* Add truncation mark, but don't do it if the line is truncated at a padding space. */ - if (it_charpos < it->string_nchars) + /* Need to do the below for the last string character as + well, since it could be a double-width character, in + which case the previous character ends before + last_visible_x. Thus, comparison with <=, not <. */ + if (it_charpos <= it->string_nchars) { if (!FRAME_WINDOW_P (it->f)) { @@ -28778,6 +28783,18 @@ display_string (const char *string, Lisp_Object lisp_string, Lisp_Object face_st if (it->current_x > it->last_visible_x) { + /* This flag is true if we are displaying mode + line, false for header-line or tab-line. */ + bool mode_line_p = false; + + /* ROW->mode_line_p is true if we display mode + line or header-line or tab-line. */ + if (row->mode_line_p) + { + struct window *w = it->w; + if (row == MATRIX_MODE_LINE_ROW (w->desired_matrix)) + mode_line_p = true; + } if (!row->reversed_p) { for (ii = row->used[TEXT_AREA] - 1; ii > 0; --ii) @@ -28795,7 +28812,10 @@ display_string (const char *string, Lisp_Object lisp_string, Lisp_Object face_st for (n = row->used[TEXT_AREA]; ii < n; ++ii) { row->used[TEXT_AREA] = ii; - produce_special_glyphs (it, IT_TRUNCATION); + if (row->mode_line_p) + pad_mode_line (it, mode_line_p); + else + produce_special_glyphs (it, IT_TRUNCATION); } } produce_special_glyphs (it, IT_TRUNCATION); @@ -31621,6 +31641,38 @@ produce_special_glyphs (struct it *it, enum display_element_type what) it->nglyphs = temp_it.nglyphs; } +/* Produce padding glyphs for mode/header/tab-line whose text needs to + be truncated. This is used when the last visible character leaves + one or more columns till the window edge, but the next character is + wider than that number of columns, and therefore cannot fit on the + line. We then replace these columns with the appropriate padding + character: '-' for the mode line and SPC for the other two. That's + because these lines should not show the usual truncation glyphs + there. This function is only used on TTY frames. */ +static void +pad_mode_line (struct it *it, bool mode_line_p) +{ + struct it temp_it; + GLYPH glyph; + + eassert (!FRAME_WINDOW_P (it->f)); + temp_it = *it; + temp_it.object = Qnil; + memset (&temp_it.current, 0, sizeof temp_it.current); + + SET_GLYPH (glyph, mode_line_p ? '-' : ' ', it->base_face_id); + + temp_it.dp = NULL; + temp_it.what = IT_CHARACTER; + temp_it.c = temp_it.char_to_display = GLYPH_CHAR (glyph); + temp_it.face_id = GLYPH_FACE (glyph); + temp_it.len = CHAR_BYTES (temp_it.c); + + PRODUCE_GLYPHS (&temp_it); + it->pixel_width = temp_it.pixel_width; + it->nglyphs = temp_it.nglyphs; +} + #ifdef HAVE_WINDOW_SYSTEM /* Calculate line-height and line-spacing properties.