From 0128495afded0f1bd153925f99c19290760c7d65 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Sat, 18 Nov 2023 18:35:18 +0200 Subject: [PATCH 1/7] Fix string-pixel-width with global setting of display-line-numbers * lisp/emacs-lisp/subr-x.el (string-pixel-width): Instead of checking for display-line-numbers-mode, set the display-line-numbers variable to nil (bug#67248). --- lisp/emacs-lisp/subr-x.el | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el index b164071763b..88ac59fd168 100644 --- a/lisp/emacs-lisp/subr-x.el +++ b/lisp/emacs-lisp/subr-x.el @@ -322,10 +322,9 @@ as the new values of the bound variables in the recursive invocation." ;; Keeping a work buffer around is more efficient than creating a ;; new temporary buffer. (with-current-buffer (get-buffer-create " *string-pixel-width*") - ;; If `display-line-numbers-mode' is enabled in internal - ;; buffers, it breaks width calculation, so disable it (bug#59311) - (when (bound-and-true-p display-line-numbers-mode) - (display-line-numbers-mode -1)) + ;; If `display-line-numbers' is enabled in internal buffers + ;; (e.g. globally), it breaks width calculation (bug#59311) + (setq-local display-line-numbers nil) (delete-region (point-min) (point-max)) ;; Disable line-prefix and wrap-prefix, for the same reason. (setq line-prefix nil From da946ca6924b5ba1a1c785284406cf894aef12b5 Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Sat, 18 Nov 2023 11:01:08 -0800 Subject: [PATCH 2/7] Add missing python-ts-mode keyword (bug#67015) * lisp/progmodes/python.el (python--treesit-keywords): Add "not in". --- lisp/progmodes/python.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index d9ca37145e1..e17651d9275 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -969,7 +969,7 @@ It makes underscores and dots word constituent chars.") "raise" "return" "try" "while" "with" "yield" ;; These are technically operators, but we fontify them as ;; keywords. - "and" "in" "is" "not" "or")) + "and" "in" "is" "not" "or" "not in")) (defvar python--treesit-builtins '("abs" "all" "any" "ascii" "bin" "bool" "breakpoint" "bytearray" From e521669fb3f5fea6f7b9ee88cbcbcf2750c00f9d Mon Sep 17 00:00:00 2001 From: Richard Stallman Date: Sun, 19 Nov 2023 12:14:36 +0200 Subject: [PATCH 3/7] Fix wording in ELisp Intro manual * doc/lispintro/emacs-lisp-intro.texi (Lisp macro): Improve wording in description of 'unless'. (Bug#67185) --- doc/lispintro/emacs-lisp-intro.texi | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/doc/lispintro/emacs-lisp-intro.texi b/doc/lispintro/emacs-lisp-intro.texi index c5b33ac5eaa..e4a0f585f69 100644 --- a/doc/lispintro/emacs-lisp-intro.texi +++ b/doc/lispintro/emacs-lisp-intro.texi @@ -8165,9 +8165,9 @@ the expectation that all goes well has a @code{when}. The code uses text that exists. A @code{when} expression is simply a programmers' convenience. It is -an @code{if} without the possibility of an else clause. In your mind, -you can replace @code{when} with @code{if} and understand what goes -on. That is what the Lisp interpreter does. +like an @code{if} without the possibility of an else clause. In your +mind, you can replace @code{when} with @code{if} and understand what +goes on. That is what the Lisp interpreter does. Technically speaking, @code{when} is a Lisp macro. A Lisp macro enables you to define new control constructs and other language @@ -8176,8 +8176,9 @@ expression which will in turn compute the value. In this case, the other expression is an @code{if} expression. The @code{kill-region} function definition also has an @code{unless} -macro; it is the converse of @code{when}. The @code{unless} macro is -an @code{if} without a then clause +macro; it is the opposite of @code{when}. The @code{unless} macro is +like an @code{if} except that it has no then-clause, and it supplies +an implicit @code{nil} for that. For more about Lisp macros, see @ref{Macros, , Macros, elisp, The GNU Emacs Lisp Reference Manual}. The C programming language also From e0469ddb9d4eb928cb23eb436cd670903f92e20a Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Mon, 20 Nov 2023 21:38:55 +0200 Subject: [PATCH 4/7] ; * doc/emacs/search.texi (Special Isearch): More accurate text. --- doc/emacs/search.texi | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/emacs/search.texi b/doc/emacs/search.texi index 66a55f09220..9d186edbe70 100644 --- a/doc/emacs/search.texi +++ b/doc/emacs/search.texi @@ -407,8 +407,11 @@ characters, that disables character folding during that search. @cindex invisible text, searching for @kindex M-s i @r{(Incremental search)} @findex isearch-toggle-invisible - To toggle whether or not invisible text is searched, type -@kbd{M-s i} (@code{isearch-toggle-invisible}). @xref{Outline Search}. + To toggle whether or not the search will find text made invisible by +overlays, type @kbd{M-s i} (@code{isearch-toggle-invisible}). +@xref{Outline Search}. To make all incremental searches find matches +inside invisible text, whether due to text properties or overlay +properties, customize @code{search-invisible} to the value @code{t}. @kindex M-r @r{(Incremental Search)} @kindex M-s r @r{(Incremental Search)} From fd76a80864d79bcf719e3e9efa7899d4217371d8 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Tue, 21 Nov 2023 14:23:38 +0200 Subject: [PATCH 5/7] ; Mention that -x and --script ignore file-locals * doc/emacs/cmdargs.texi (Initial Options): Document that --script and -x ignore file-local variables. (Bug#67321) --- doc/emacs/cmdargs.texi | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/emacs/cmdargs.texi b/doc/emacs/cmdargs.texi index 9514e3414e1..49ae1288f73 100644 --- a/doc/emacs/cmdargs.texi +++ b/doc/emacs/cmdargs.texi @@ -280,7 +280,10 @@ an Emacs Lisp backtrace being printed. To disable this behavior, set @opindex --script @cindex script mode Run Emacs in batch mode, like @samp{--batch}, and then read and -execute the Lisp code in @var{file}. +execute the Lisp code in @var{file}. Note that when Emacs reads the +Lisp code in this case, it ignores any file-local variables +(@pxref{Specifying File Variables}), both in the first line and in a +local-variables section near the end of the file. The normal use of this option is in executable script files that run Emacs. They can start with this text on the first line @@ -309,6 +312,8 @@ This is like @samp{--script}, but suppresses loading the init files 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. +Note that, like with @samp{--script}, Emacs ignores file-local +variables in the script. @item --no-build-details @opindex --no-build-details From a7b3c92373373f956234349fe6b792e1396e293e Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Tue, 21 Nov 2023 14:40:27 +0200 Subject: [PATCH 6/7] ; * doc/emacs/cmdargs.texi (Initial Options): Fix last change. --- doc/emacs/cmdargs.texi | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/doc/emacs/cmdargs.texi b/doc/emacs/cmdargs.texi index 49ae1288f73..38e683bd7f5 100644 --- a/doc/emacs/cmdargs.texi +++ b/doc/emacs/cmdargs.texi @@ -280,10 +280,7 @@ an Emacs Lisp backtrace being printed. To disable this behavior, set @opindex --script @cindex script mode Run Emacs in batch mode, like @samp{--batch}, and then read and -execute the Lisp code in @var{file}. Note that when Emacs reads the -Lisp code in this case, it ignores any file-local variables -(@pxref{Specifying File Variables}), both in the first line and in a -local-variables section near the end of the file. +execute the Lisp code in @var{file}. The normal use of this option is in executable script files that run Emacs. They can start with this text on the first line @@ -312,8 +309,9 @@ This is like @samp{--script}, but suppresses loading the init files 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. -Note that, like with @samp{--script}, Emacs ignores file-local -variables in the script. +Note that when Emacs reads the Lisp code in this case, it ignores any +file-local variables (@pxref{Specifying File Variables}), both in the +first line and in a local-variables section near the end of the file. @item --no-build-details @opindex --no-build-details From d72a4ed65ce23581ff8b3bf4340caecf31c18f43 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Tue, 21 Nov 2023 15:36:22 +0200 Subject: [PATCH 7/7] Fix 'with-sqlite-transaction' when BODY fails * lisp/sqlite.el (with-sqlite-transaction): Don't commit changes if BODY errors out. Roll back the transaction if committing fails. (Bug#67142) * etc/NEWS: * doc/lispref/text.texi (Database): Document the error handling in 'with-sqlite-transaction'. --- doc/lispref/text.texi | 6 +++++- etc/NEWS | 5 +++++ lisp/sqlite.el | 21 +++++++++++++++------ 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi index 4f11caaf64e..8fa2100ba11 100644 --- a/doc/lispref/text.texi +++ b/doc/lispref/text.texi @@ -5486,7 +5486,11 @@ made by the transaction. @defmac with-sqlite-transaction db body@dots{} Like @code{progn} (@pxref{Sequencing}), but executes @var{body} with a -transaction held, and commits the transaction at the end. +transaction held, and commits the transaction at the end if @var{body} +completes normally. If @var{body} signals an error, or committing the +transaction fails, the changes in @var{db} performed by @var{body} are +rolled back. The macro returns the value of @var{body} if it +completes normally and commit succeeds. @end defmac @defun sqlite-pragma db pragma diff --git a/etc/NEWS b/etc/NEWS index 1b3532b5657..333699f1015 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -62,6 +62,11 @@ of showing the shortcuts. * Incompatible Lisp Changes in Emacs 29.2 ++++ +** 'with-sqlite-transaction' rolls back changes if its BODY fails. +If the BODY of the macro signals an error, or committing the results +of the transaction fails, the changes will now be rolled back. + * Lisp Changes in Emacs 29.2 diff --git a/lisp/sqlite.el b/lisp/sqlite.el index aad0aa40fa4..8a525739c9a 100644 --- a/lisp/sqlite.el +++ b/lisp/sqlite.el @@ -24,19 +24,28 @@ ;;; Code: (defmacro with-sqlite-transaction (db &rest body) - "Execute BODY while holding a transaction for DB." + "Execute BODY while holding a transaction for DB. +If BODY completes normally, commit the changes and return +the value of BODY. +If BODY signals an error, or transaction commit fails, roll +back the transaction changes." (declare (indent 1) (debug (form body))) (let ((db-var (gensym)) - (func-var (gensym))) + (func-var (gensym)) + (res-var (gensym)) + (commit-var (gensym))) `(let ((,db-var ,db) - (,func-var (lambda () ,@body))) + (,func-var (lambda () ,@body)) + ,res-var ,commit-var) (if (sqlite-available-p) (unwind-protect (progn (sqlite-transaction ,db-var) - (funcall ,func-var)) - (sqlite-commit ,db-var)) - (funcall ,func-var))))) + (setq ,res-var (funcall ,func-var)) + (setq ,commit-var (sqlite-commit ,db-var)) + ,res-var) + (or ,commit-var (sqlite-rollback ,db-var)))) + (funcall ,func-var)))) (provide 'sqlite)