From 4684b8e62f882b2a0f29d89a49bd5da8fad1218f Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Mon, 18 Apr 2022 10:37:14 +0200 Subject: [PATCH 1/2] 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. --- lisp/files.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/files.el b/lisp/files.el index d8e7989672a..30e8da4da37 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))) From 1b7736277114bf91012b817a4e2557625b7340a5 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Mon, 18 Apr 2022 13:17:32 +0200 Subject: [PATCH 2/2] 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. --- lisp/progmodes/python.el | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index e6e8a37ad57..70828cb223a 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.