From: kobarity <kobarity@gmail.com>
To: 57038@debbugs.gnu.org
Subject: bug#57038: 29.0.50; python-nav-beginning-of-block doesn't work for blank/comment line right after block start
Date: Sun, 7 Aug 2022 23:00:26 +0900 [thread overview]
Message-ID: <CAMQkrSpup8vDSNnHBcNCJFiw-4Y3hQFp-no2G37vyDxBU=aQWA@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 2817 bytes --]
Hi,
The following steps do not place the point at the beginning of the line
"if True:".
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-line
4. M-x python-nav-beginning-of-block
The same thing happens with a comment line right after block start.
Attached is a patch to fix this issue.
Best Regards,
--
In GNU Emacs 29.0.50 (build 8, x86_64-pc-linux-gnu)
of 2022-08-07 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 derived 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
json subr-x map 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 52781 7681)
(symbols 48 6567 0)
(strings 32 18135 1705)
(string-bytes 1 538658)
(vectors 16 10194)
(vector-slots 8 121776 8588)
(floats 8 28 375)
(intervals 56 185 0)
(buffers 992 11))
[-- Attachment #2: fix-python-nav-beginning-of-block.patch --]
[-- Type: application/octet-stream, Size: 2476 bytes --]
commit 7ceef1b590e1dbd8b7c3436a0bc0d1ce69f6b9cf
Author: kobarity <kobarity@gmail.com>
Date: Sun Aug 7 22:50:50 2022 +0900
Fix blank/comment line handling in python-nav-beginning-of-block
* lisp/progmodes/python.el (python-nav-beginning-of-block): Fix
handling of blank/comment line right after block start.
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 27bdbae311..88b19c88cd 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -1761,16 +1761,16 @@ python-nav-beginning-of-block
"Move to start of current block."
(interactive "^")
(let ((starting-pos (point)))
+ ;; Go to first line beginning a statement
+ (while (and (not (bobp))
+ (or (and (python-nav-beginning-of-statement) nil)
+ (python-info-current-line-comment-p)
+ (python-info-current-line-empty-p)))
+ (forward-line -1))
(if (progn
(python-nav-beginning-of-statement)
(looking-at (python-rx block-start)))
(point-marker)
- ;; Go to first line beginning a statement
- (while (and (not (bobp))
- (or (and (python-nav-beginning-of-statement) nil)
- (python-info-current-line-comment-p)
- (python-info-current-line-empty-p)))
- (forward-line -1))
(let ((block-matching-indent
(- (current-indentation) python-indent-offset)))
(while
diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el
index 07f2c4f09a..eb57122690 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -2734,6 +2734,28 @@ python-nav-beginning-of-block-1
(point))
(python-tests-look-at "def wwrap(f):" -1)))))
+(ert-deftest python-nav-beginning-of-block-2 ()
+ (python-tests-with-temp-buffer
+ "
+if True:
+
+ pass
+if False:
+ # comment
+ pass
+"
+ (python-tests-look-at "if True:")
+ (forward-line)
+ (should (= (save-excursion
+ (python-nav-beginning-of-block)
+ (point))
+ (python-tests-look-at "if True:" -1)))
+ (python-tests-look-at "# comment")
+ (should (= (save-excursion
+ (python-nav-beginning-of-block)
+ (point))
+ (python-tests-look-at "if False:" -1)))))
+
(ert-deftest python-nav-end-of-block-1 ()
(python-tests-with-temp-buffer
"
next reply other threads:[~2022-08-07 14:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-07 14:00 kobarity [this message]
2022-08-07 14:10 ` bug#57038: 29.0.50; python-nav-beginning-of-block doesn't work for blank/comment line right after block start Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAMQkrSpup8vDSNnHBcNCJFiw-4Y3hQFp-no2G37vyDxBU=aQWA@mail.gmail.com' \
--to=kobarity@gmail.com \
--cc=57038@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.