bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#65870: 30.0.50; Error in python-mode when try to delete a character


From: Jakub Ječmínek
Subject: bug#65870: 30.0.50; Error in python-mode when try to delete a character in badly-indented code
Date: Sun, 02 Jun 2024 21:08:30 +0000

kobarity <kobarity@gmail.com> writes:

> Eli Zaretskii wrote:
>> kobarity, any suggestions or comments?
>
> Thank you for the report.  The attached is the proposed fix.
>
>>From 32f0dbe5f942ffa60f0945d2ffb771db82db5832 Mon Sep 17 00:00:00 2001
> From: kobarity <kobarity@gmail.com>
> Date: Sat, 16 Sep 2023 23:14:45 +0900
> Subject: [PATCH] Fix Python mode error caused by incorrect indentation
>
> * lisp/progmodes/python.el (python-indent--calculate-indentation):
> Guard against negative indentation.  (Bug #65870)
>
> * test/lisp/progmodes/python-tests.el
> (python-indent-badly-indented-block-end): New test.
> ---
>  lisp/progmodes/python.el            | 2 +-
>  test/lisp/progmodes/python-tests.el | 9 +++++++++
>  2 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
> index 4b940b3f13b..d7e49e225d8 100644
> --- a/lisp/progmodes/python.el
> +++ b/lisp/progmodes/python.el
> @@ -1660,7 +1660,7 @@ python-indent--calculate-indentation
>          (`(:after-block-end . ,start)
>           ;; Subtract one indentation level.
>           (goto-char start)
> -         (- (current-indentation) python-indent-offset))
> +         (max 0 (- (current-indentation) python-indent-offset)))
>          (`(:at-dedenter-block-start . ,_)
>           ;; List all possible indentation levels from opening blocks.
>           (let ((opening-block-start-points
> diff --git a/test/lisp/progmodes/python-tests.el 
> b/test/lisp/progmodes/python-tests.el
> index a44a11896f0..f3456030975 100644
> --- a/test/lisp/progmodes/python-tests.el
> +++ b/test/lisp/progmodes/python-tests.el
> @@ -2081,6 +2081,15 @@ python-indent-after-bare-match
>     (python-tests-look-at "else:")
>     (should (= (python-indent-calculate-indentation) 4))))
>  
> +(ert-deftest python-indent-badly-indented-block-end ()
> +  "Test BUG 65870 regression."
> +  (python-tests-with-temp-buffer
> +   "
> +return
> +"
> +   (goto-char (point-max))
> +   (should (= (python-indent-calculate-indentation) 0))))
> +
>  
>  ;;; Filling

Eli, can you please install this?  I can still reproduce the original error.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]