commit 840b9eadd6a06c939980bb8b90d8402128ea8901 (HEAD, refs/remotes/origin/master) Author: Paul Eggert Date: Tue Nov 1 23:03:25 2022 -0700 Remove unused local in simple_search * src/search.c (simple_search): Remove unused local. diff --git a/src/search.c b/src/search.c index a7f958c362..1c5831b6de 100644 --- a/src/search.c +++ b/src/search.c @@ -1558,7 +1558,6 @@ simple_search (EMACS_INT n, unsigned char *pat, while (1) { /* Try matching at position POS. */ - ptrdiff_t this_pos = pos; ptrdiff_t this_pos_byte = pos_byte; ptrdiff_t this_len = len; unsigned char *p = pat; @@ -1580,7 +1579,6 @@ simple_search (EMACS_INT n, unsigned char *pat, p += charlen; this_pos_byte += buf_charlen; - this_pos++; } if (this_len == 0) commit 8a5678906fa1b899c4d111e5ee4334b278f50d48 Author: Stefan Monnier Date: Tue Nov 1 21:38:55 2022 -0400 src/buffer.c: Fix interaction between overlays & indirect buffers (bug#58928) * src/buffer.c (adjust_overlays_for_insert) (adjust_overlays_for_delete): Repeat for all buffers sharing the same text. * src/itree.c (itree_insert_gap, itree_delete_gap): Allow an empty tree. * test/src/buffer-tests.el (buffer-tests--overlays-indirect-bug58928): New test. diff --git a/src/buffer.c b/src/buffer.c index b67b989326..3129aa2890 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -3456,19 +3456,37 @@ overlay_strings (ptrdiff_t pos, struct window *w, unsigned char **pstr) void adjust_overlays_for_insert (ptrdiff_t pos, ptrdiff_t length) { - /* After an insertion, the lists are still sorted properly, - but we may need to update the value of the overlay center. */ - if (! current_buffer->overlays) - return; - itree_insert_gap (current_buffer->overlays, pos, length); + if (!current_buffer->indirections) + itree_insert_gap (current_buffer->overlays, pos, length); + else + { + struct buffer *base = current_buffer->base_buffer + ? current_buffer->base_buffer + : current_buffer; + Lisp_Object tail, other; + itree_insert_gap (base->overlays, pos, length); + FOR_EACH_LIVE_BUFFER (tail, other) + if (XBUFFER (other)->base_buffer == base) + itree_insert_gap (XBUFFER (other)->overlays, pos, length); + } } void adjust_overlays_for_delete (ptrdiff_t pos, ptrdiff_t length) { - if (! current_buffer->overlays) - return; - itree_delete_gap (current_buffer->overlays, pos, length); + if (!current_buffer->indirections) + itree_delete_gap (current_buffer->overlays, pos, length); + else + { + struct buffer *base = current_buffer->base_buffer + ? current_buffer->base_buffer + : current_buffer; + Lisp_Object tail, other; + itree_delete_gap (base->overlays, pos, length); + FOR_EACH_LIVE_BUFFER (tail, other) + if (XBUFFER (other)->base_buffer == base) + itree_delete_gap (XBUFFER (other)->overlays, pos, length); + } } diff --git a/src/itree.c b/src/itree.c index 3b10802ff0..bd4e8cc574 100644 --- a/src/itree.c +++ b/src/itree.c @@ -1196,7 +1196,7 @@ void itree_insert_gap (struct itree_tree *tree, ptrdiff_t pos, ptrdiff_t length) { - if (length <= 0 || tree->root == NULL) + if (!tree || length <= 0 || tree->root == NULL) return; uintmax_t ootick = tree->otick; @@ -1280,7 +1280,7 @@ void itree_delete_gap (struct itree_tree *tree, ptrdiff_t pos, ptrdiff_t length) { - if (length <= 0 || tree->root == NULL) + if (!tree || length <= 0 || tree->root == NULL) return; /* FIXME: Don't allocate stack anew every time. */ diff --git a/test/src/buffer-tests.el b/test/src/buffer-tests.el index e020732524..b96a8dcacd 100644 --- a/test/src/buffer-tests.el +++ b/test/src/buffer-tests.el @@ -275,6 +275,27 @@ with parameters from the *Messages* buffer modification." (with-temp-buffer (should (eq (buffer-base-buffer (current-buffer)) nil)))) +(ert-deftest buffer-tests--overlays-indirect-bug58928 () + (with-temp-buffer + (insert "hello world") + (let* ((base (current-buffer)) + (ol1 (make-overlay (+ 2 (point-min)) (+ 8 (point-min)))) + (ib (make-indirect-buffer + base (generate-new-buffer-name "bug58928"))) + (ol2 (with-current-buffer ib + (make-overlay (+ 2 (point-min)) (+ 8 (point-min)))))) + (should (equal (overlay-start ol1) (overlay-start ol2))) + (should (equal (overlay-end ol1) (overlay-end ol2))) + (goto-char (+ 3 (point-min))) + (insert "a") (delete-char 2) + (should (equal (overlay-start ol1) (overlay-start ol2))) + (should (equal (overlay-end ol1) (overlay-end ol2))) + (with-current-buffer ib + (goto-char (+ 4 (point-min))) + (insert "a") (delete-char 2)) + (should (equal (overlay-start ol1) (overlay-start ol2))) + (should (equal (overlay-end ol1) (overlay-end ol2)))))) + (ert-deftest overlay-evaporation-after-killed-buffer () (let* ((ols (with-temp-buffer (insert "toto") commit 835295381bdee3d517c7ee243a22640c78783a9f Author: Dmitry Gutov Date: Wed Nov 2 01:30:08 2022 +0200 project-switch-project: Avoid altering default-directory in cb * lisp/progmodes/project.el (project-switch-project): Avoid altering default-directory in the current buffer, even temporarily (bug#58784). diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index ac278edd40..0aa7955c65 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -1667,9 +1667,10 @@ to directory DIR." (let ((command (if (symbolp project-switch-commands) project-switch-commands (project--switch-project-command)))) - (let ((default-directory dir) - (project-current-inhibit-prompt t)) - (call-interactively command)))) + (with-temp-buffer + (let ((default-directory dir) + (project-current-inhibit-prompt t)) + (call-interactively command))))) (provide 'project) ;;; project.el ends here commit 0f5bf1dbb961f7ca39e130f30891a566e4dfed09 Author: Dmitry Gutov Date: Wed Nov 2 00:46:02 2022 +0200 vc-svn-ignore-completion-table: Ignore empty lines * lisp/vc/vc-svn.el (vc-svn-ignore-completion-table): Make sure to ignore empty lines (bug#58889). diff --git a/lisp/vc/vc-svn.el b/lisp/vc/vc-svn.el index 9c2bdf6674..b9ea8f1578 100644 --- a/lisp/vc/vc-svn.el +++ b/lisp/vc/vc-svn.el @@ -364,7 +364,7 @@ DIRECTORY or absolute." (with-temp-buffer (when (zerop (vc-svn-command t t nil "propget" "svn:ignore" (expand-file-name directory))) - (split-string (buffer-string) "\n")))) + (split-string (buffer-string) "\n" t)))) (defun vc-svn-find-admin-dir (file) "Return the administrative directory of FILE." commit 208f0578d1e523762c356895c21cde47f909fd7c Author: Gregory Heytings Date: Tue Nov 1 18:20:00 2022 +0000 Add a script to ease bisecting. * admin/git-bisect-start: New script. * admin/notes/repo (Bisecting): Mention the script. * admin/emake: Add a Copyright blurb. diff --git a/admin/emake b/admin/emake index e2f38501e9..09f7410779 100755 --- a/admin/emake +++ b/admin/emake @@ -1,5 +1,22 @@ #!/bin/bash +# Copyright (C) 2022 Free Software Foundation, Inc. + +# This file is part of GNU Emacs. + +# GNU Emacs is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# GNU Emacs is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with GNU Emacs. If not, see . + # This script is meant to be used as ./admin/emake, and will compile # the Emacs tree with virtually all of the informational messages # removed, and with errors/warnings highlighted in red. It'll give a diff --git a/admin/git-bisect-start b/admin/git-bisect-start new file mode 100755 index 0000000000..889c959875 --- /dev/null +++ b/admin/git-bisect-start @@ -0,0 +1,27 @@ +#!/bin/bash + +# Start a git bisection, and prune the branches that are the result of +# merging external trees into the Emacs repository. + +# Copyright (C) 2022 Free Software Foundation, Inc. + +# This file is part of GNU Emacs. + +# GNU Emacs is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# GNU Emacs is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with GNU Emacs. If not, see . + +git bisect start + +# Prune commits 1e5b753bf4..806734c1b1 introduced by 0186faf2a1 (Eglot +# merge on Oct 20 2022) +git bisect good 806734c1b1 diff --git a/admin/notes/repo b/admin/notes/repo index afba3dca8f..97f02ab605 100644 --- a/admin/notes/repo +++ b/admin/notes/repo @@ -128,10 +128,9 @@ again. This is a semi-automated way to find the revision that introduced a bug. Browse 'git help bisect' for technical instructions. -Depending on what you want to do, it can be helpful to start bisecing -with the option '--first-parent', like `git bisect start ---first-parent', which makes bisect ignore commits coming into a -branch from merges. +It is recommended to start a bisection with the admin/git-bisect-start +script. This script prunes the branches that are the result of +merging external trees into the Emacs repository. * Maintaining ChangeLog history commit 22e8a775838ef12bd43102315f13d202e2f215bd Author: Michael Albinus Date: Tue Nov 1 16:35:40 2022 +0100 * lisp/net/dbus.el (dbus-debug): Declare. (Bug#58865) diff --git a/lisp/net/dbus.el b/lisp/net/dbus.el index 6c978c5a5f..9f0ad7b83c 100644 --- a/lisp/net/dbus.el +++ b/lisp/net/dbus.el @@ -37,6 +37,7 @@ (declare-function dbus-message-internal "dbusbind.c") (declare-function dbus--init-bus "dbusbind.c") (declare-function libxml-parse-xml-region "xml.c") +(defvar dbus-debug) (defvar dbus-message-type-invalid) (defvar dbus-message-type-method-call) (defvar dbus-message-type-method-return) commit e39537ea1ec54e4073b2a3da2c94022c8ca912c2 Author: Po Lu Date: Tue Nov 1 19:20:03 2022 +0800 * src/xterm.c (x_term_init): Fix last change. diff --git a/src/xterm.c b/src/xterm.c index d8358269f6..bd60a04c6c 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -29801,7 +29801,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) that also destroys the font, leading to to X protocol errors at XtCloseDisplay. Just free the font info structure. (Bug#18403) */ - XFreeFontInfo (NULL, query_result, 0); + XFreeFontInfo (NULL, query_result, 1); x_uncatch_errors (); } #endif commit eb68c3d5a23e519a4b9ffc7b87fa7db68a18ae0b Author: Po Lu Date: Tue Nov 1 19:11:19 2022 +0800 Fix leak on Lucid build * src/xterm.c (x_term_init): Rectify wrong fix for bug#18403. diff --git a/src/xterm.c b/src/xterm.c index 7dd969b821..d8358269f6 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -29778,21 +29778,30 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) { XrmValue d, fr, to; Font font; + XFontStruct *query_result; dpy = dpyinfo->display; - d.addr = (XPointer)&dpy; + d.addr = (XPointer) &dpy; d.size = sizeof (Display *); fr.addr = (char *) XtDefaultFont; fr.size = sizeof (XtDefaultFont); to.size = sizeof (Font *); - to.addr = (XPointer)&font; + to.addr = (XPointer) &font; x_catch_errors (dpy); if (!XtCallConverter (dpy, XtCvtStringToFont, &d, 1, &fr, &to, NULL)) emacs_abort (); - if (x_had_errors_p (dpy) || !XQueryFont (dpy, font)) + query_result = XQueryFont (dpy, font); + + /* Set the dialog font to some fallback (here, 9x15) if the font + specified is invalid. */ + if (x_had_errors_p (dpy) || !font) XrmPutLineResource (&xrdb, "Emacs.dialog.*.font: 9x15"); - /* Do not free XFontStruct returned by the above call to XQueryFont. - This leads to X protocol errors at XtCloseDisplay (Bug#18403). */ + + /* Do not destroy the font struct returned above with XFreeFont; + that also destroys the font, leading to to X protocol errors at + XtCloseDisplay. Just free the font info structure. + (Bug#18403) */ + XFreeFontInfo (NULL, query_result, 0); x_uncatch_errors (); } #endif commit 123baf3772e71a33eabc1b1169a9b778e2fe3877 Merge: e7c105fd73 1862df834c Author: Stefan Kangas Date: Tue Nov 1 10:30:09 2022 +0100 Merge from origin/emacs-28 1862df834c ; * src/search.c (Fmatch_data): Doc fix. 15fc5225b1 ; * lisp/whitespace.el (whitespace-trailing): Fix a typo. 9f3c896f7c ; * doc/emacs/text.texi (Quotation Marks): Typo fix. (Bug... # Conflicts: # src/search.c commit e7c105fd73dbede4d00c1f26ad2273d49fabd0da Author: Gerd Möllmann Date: Tue Nov 1 10:25:28 2022 +0100 ; Mention git bisect's --first-parent in admin/notes/repo diff --git a/admin/notes/repo b/admin/notes/repo index 2185c5a003..afba3dca8f 100644 --- a/admin/notes/repo +++ b/admin/notes/repo @@ -128,6 +128,11 @@ again. This is a semi-automated way to find the revision that introduced a bug. Browse 'git help bisect' for technical instructions. +Depending on what you want to do, it can be helpful to start bisecing +with the option '--first-parent', like `git bisect start +--first-parent', which makes bisect ignore commits coming into a +branch from merges. + * Maintaining ChangeLog history Older ChangeLog entries are kept in history files named ChangeLog.1, commit d305eaf4ce56177171aa1bcde80bbed5fc486a45 Author: Gerd Möllmann Date: Tue Nov 1 10:14:07 2022 +0100 Preven a buffer-overflow (bug#58850) * src/print.c (print_vectorlike): Don't use sprintf. diff --git a/src/print.c b/src/print.c index 65218084a4..07560518c4 100644 --- a/src/print.c +++ b/src/print.c @@ -2017,8 +2017,8 @@ print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag, i = sprintf (buf, " stmt=%p", XSQLITE (obj)->stmt); strout (buf, i, i, printcharfun); } - i = sprintf (buf, " name=%s", XSQLITE (obj)->name); - strout (buf, i, i, printcharfun); + print_c_string (" name=", printcharfun); + print_c_string (XSQLITE (obj)->name, printcharfun); printchar ('>', printcharfun); } break; commit 1862df834c29197cdd339ee369c0ef21694db851 (refs/remotes/origin/emacs-28) Author: Eli Zaretskii Date: Sun Oct 30 19:57:14 2022 +0200 ; * src/search.c (Fmatch_data): Doc fix. diff --git a/src/search.c b/src/search.c index 88ee584504..88ab1df779 100644 --- a/src/search.c +++ b/src/search.c @@ -2811,22 +2811,37 @@ Return value is undefined if the last search failed. */) } DEFUN ("match-data", Fmatch_data, Smatch_data, 0, 3, 0, - doc: /* Return a list describing what the last search matched. -Element 2N is `(match-beginning N)'; element 2N + 1 is `(match-end N)'. -All the elements are markers or nil (nil if the Nth pair didn't match) -if the last match was on a buffer; integers or nil if a string was matched. -Use `set-match-data' to reinstate the data in this list. - -If INTEGERS (the optional first argument) is non-nil, always use -integers (rather than markers) to represent buffer positions. In -this case, and if the last match was in a buffer, the buffer will get -stored as one additional element at the end of the list. - -If REUSE is a list, reuse it as part of the value. If REUSE is long -enough to hold all the values, and if INTEGERS is non-nil, no consing -is done. - -If optional third arg RESEAT is non-nil, any previous markers on the + doc: /* Return a list of positions that record text matched by the last search. +Element 2N of the returned list is the position of the beginning of the +match of the Nth subexpression; it corresponds to `(match-beginning N)'; +element 2N + 1 is the position of the end of the match of the Nth +subexpression; it corresponds to `(match-end N)'. See `match-beginning' +and `match-end'. +If the last search was on a buffer, all the elements are by default +markers or nil (nil when the Nth pair didn't match); they are integers +or nil if the search was on a string. But if the optional argument +INTEGERS is non-nil, the elements that represent buffer positions are +always integers, not markers, and (if the search was on a buffer) the +buffer itself is appended to the list as one additional element. + +Use `set-match-data' to reinstate the match data from the elements of +this list. + +Note that non-matching optional groups at the end of the regexp are +elided instead of being represented with two `nil's each. For instance: + + (progn + (string-match "^\\(a\\)?\\(b\\)\\(c\\)?$" "b") + (match-data)) + => (0 1 nil nil 0 1) + +If REUSE is a list, store the value in REUSE by destructively modifying it. +If REUSE is long enough to hold all the values, its length remains the +same, and any unused elements are set to nil. If REUSE is not long +enough, it is extended. Note that if REUSE is long enough and INTEGERS +is non-nil, no consing is done to make the return value; this minimizes GC. + +If optional third argument RESEAT is non-nil, any previous markers on the REUSE list will be modified to point to nowhere. Return value is undefined if the last search failed. */) commit 15fc5225b1c84abfd08a312cf5ca34c65f235a27 Author: Eli Zaretskii Date: Sat Oct 29 15:40:31 2022 +0300 ; * lisp/whitespace.el (whitespace-trailing): Fix a typo. diff --git a/lisp/whitespace.el b/lisp/whitespace.el index e518f1e00a..6cdc4ab484 100644 --- a/lisp/whitespace.el +++ b/lisp/whitespace.el @@ -536,7 +536,7 @@ Used when `whitespace-style' includes the value `trailing'.") (t :background "red1" :foreground "yellow")) "Face used to visualize trailing blanks. -See '`whitespace-trailing-regexp'." +See `whitespace-trailing-regexp'." :group 'whitespace) commit 9f3c896f7cb116bddaa072b6b37fe6c2377c3cc2 Author: Matt Armstrong Date: Thu Oct 27 13:46:38 2022 -0700 ; * doc/emacs/text.texi (Quotation Marks): Typo fix. (Bug#58822) diff --git a/doc/emacs/text.texi b/doc/emacs/text.texi index a8aa4a413d..caf853d6e2 100644 --- a/doc/emacs/text.texi +++ b/doc/emacs/text.texi @@ -460,7 +460,7 @@ variables. @vindex electric-quote-replace-double You can also set the option @code{electric-quote-replace-double} to -a non-@code{nil} value. Then, typing @kbd{"} insert an appropriate +a non-@code{nil} value. Then, typing @kbd{"} inserts an appropriate curved double quote depending on context: @t{“} at the beginning of the buffer or after a line break, whitespace, opening parenthesis, or quote character, and @t{”} otherwise.