* bug#57223: 29.0.50; python-nav-forward-block moves backward under certain conditions.
@ 2022-08-15 14:03 kobarity
2022-08-15 14:31 ` Lars Ingebrigtsen
0 siblings, 1 reply; 2+ messages in thread
From: kobarity @ 2022-08-15 14:03 UTC (permalink / raw)
To: 57223
[-- Attachment #1: Type: text/plain, Size: 2973 bytes --]
Hi,
The following steps move the point backward to the beginning of the line.
1. emacs -Q
2. Load the following Python file using M-x find-file
#+begin_src python
if True:
pass
#+end_src
3. M-x forward-char
4. M-x python-nav-forward-block
This happens when:
- point is on the block-start line of the last block,
- point is at least one character after the beginning of block-start, and
- searching forward (positive ARG for python-nav-forward-block).
Attached is a patch to fix this issue.
Best Regards,
--
In GNU Emacs 29.0.50 (build 10, x86_64-pc-linux-gnu)
of 2022-08-15 built on ubuntu
System Description: Ubuntu 22.04.1 LTS
Configured using:
'configure --without-x --with-gnutls=ifavailable'
Configured features:
ACL LIBXML2 MODULES NOTIFY INOTIFY PDUMPER SECCOMP SOUND SQLITE3 THREADS
XIM ZLIB
Important settings:
value of $LANG: en_US.UTF-8
locale-coding-system: utf-8-unix
Major mode: Python
Minor modes in effect:
tooltip-mode: t
global-eldoc-mode: t
eldoc-mode: t
show-paren-mode: t
electric-indent-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
line-number-mode: t
transient-mark-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
Load-path shadows:
None found.
Features:
(shadow sort mail-extr emacsbug message mailcap yank-media puny dired
dnd dired-loaddefs rfc822 mml mml-sec password-cache epa epg rfc6068
epg-config gnus-util text-property-search time-date mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail
rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils python skeleton
derived json map rx cl-macs pcase subr-x comint regexp-opt ring
cl-loaddefs cl-lib ansi-color term/screen term/xterm xterm byte-opt gv
bytecomp byte-compile cconv rmc iso-transl tooltip eldoc paren electric
uniquify ediff-hook vc-hooks lisp-float-type elisp-mode tabulated-list
replace newcomment text-mode lisp-mode prog-mode register page tab-bar
menu-bar rfn-eshadow isearch easymenu timer select mouse jit-lock
font-lock syntax font-core term/tty-colors frame minibuffer nadvice seq
simple cl-generic indonesian philippine cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite emoji-zwj charscript charprop case-table
epa-hook jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button
loaddefs faces cus-face macroexp files window text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads inotify multi-tty
make-network-process emacs)
Memory information:
((conses 16 70922 6831)
(symbols 48 7269 0)
(strings 32 19447 1974)
(string-bytes 1 607324)
(vectors 16 10328)
(vector-slots 8 124429 7979)
(floats 8 29 517)
(intervals 56 210 0)
(buffers 992 13))
[-- Attachment #2: fix-python-nav-forward-block.patch --]
[-- Type: application/octet-stream, Size: 2210 bytes --]
commit 48b77389ef9107a5b9eee9c23d2dab39ee3c1143
Author: kobarity <kobarity@gmail.com>
Date: Mon Aug 15 22:46:58 2022 +0900
Fix `python-nav-forward-block' moving backward under certain conditions
* lisp/progmodes/python.el (python-nav-forward-block): Add check
for not moving backward.
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 96f9d14832..44df3186b2 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -1822,7 +1822,8 @@ python-nav-forward-block
(or arg (setq arg 1))
(let ((block-start-regexp
(python-rx line-start (* whitespace) block-start))
- (starting-pos (point)))
+ (starting-pos (point))
+ (orig-arg arg))
(while (> arg 0)
(python-nav-end-of-statement)
(while (and
@@ -1836,7 +1837,8 @@ python-nav-forward-block
(python-syntax-context-type)))
(setq arg (1+ arg)))
(python-nav-beginning-of-statement)
- (if (not (looking-at (python-rx block-start)))
+ (if (or (and (> orig-arg 0) (< (point) starting-pos))
+ (not (looking-at (python-rx block-start))))
(and (goto-char starting-pos) nil)
(and (not (= (point) starting-pos)) (point-marker)))))
diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el
index d303050fad..9e8fa7f552 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -2942,6 +2942,22 @@ python-nav-forward-block-1
(python-tests-look-at
"if request.user.is_authenticated():" -1)))))
+(ert-deftest python-nav-forward-block-2 ()
+ (python-tests-with-temp-buffer
+ "
+if True:
+ pass
+"
+ (python-tests-look-at "if True:")
+ (should (not (save-excursion (python-nav-forward-block))))
+ (should (not (save-excursion (python-nav-forward-block -1))))
+ (forward-char)
+ (should (not (save-excursion (python-nav-forward-block))))
+ (should (= (save-excursion (python-nav-forward-block -1))
+ (progn
+ (end-of-line)
+ (python-tests-look-at "if True:" -1))))))
+
(ert-deftest python-nav-forward-sexp-1 ()
(python-tests-with-temp-buffer
"
^ permalink raw reply related [flat|nested] 2+ messages in thread
* bug#57223: 29.0.50; python-nav-forward-block moves backward under certain conditions.
2022-08-15 14:03 bug#57223: 29.0.50; python-nav-forward-block moves backward under certain conditions kobarity
@ 2022-08-15 14:31 ` Lars Ingebrigtsen
0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2022-08-15 14:31 UTC (permalink / raw)
To: kobarity; +Cc: 57223
kobarity <kobarity@gmail.com> writes:
> Attached is a patch to fix this issue.
Thanks; pushed to Emacs 29.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-08-15 14:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-15 14:03 bug#57223: 29.0.50; python-nav-forward-block moves backward under certain conditions kobarity
2022-08-15 14:31 ` Lars Ingebrigtsen
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.