all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#56615: 29.0.50; python-nav-beginning-of-defun problem with a line continuation using backslash in nested defun
@ 2022-07-17 14:49 kobarity
  2022-07-17 14:55 ` kobarity
  0 siblings, 1 reply; 3+ messages in thread
From: kobarity @ 2022-07-17 14:49 UTC (permalink / raw)
  To: 56615

Hi,

The following steps will place the point at the beginning of the line
"class C:", not the line "def \".

1. emacs -Q
2. Load the following Python file using M-x find-file

#+begin_src python
class C:

    def \
            m(self):
        pass
#+end_src

3. M-: (forward-line 3)
4. M-: (python-nav-beginning-of-defun)

Best Regards,

--

In GNU Emacs 29.0.50 (build 6, x86_64-pc-linux-gnu)
 of 2022-07-16 built on ubuntu
Repository revision: ea9b442b82f1efd7e41094b455a00d73c16d0fc3
Repository branch: master
System Description: Ubuntu 22.04 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: Lisp Interaction

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
  indent-tabs-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 regexp-opt 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
subr-x mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader cl-loaddefs cl-lib sendmail rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mail-utils 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 44274 5286)
 (symbols 48 5634 1)
 (strings 32 15464 1865)
 (string-bytes 1 494915)
 (vectors 16 8324)
 (vector-slots 8 102199 7439)
 (floats 8 25 355)
 (intervals 56 202 14)
 (buffers 992 11))





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#56615: 29.0.50; python-nav-beginning-of-defun problem with a line continuation using backslash in nested defun
  2022-07-17 14:49 bug#56615: 29.0.50; python-nav-beginning-of-defun problem with a line continuation using backslash in nested defun kobarity
@ 2022-07-17 14:55 ` kobarity
  2022-07-23  8:26   ` Lars Ingebrigtsen
  0 siblings, 1 reply; 3+ messages in thread
From: kobarity @ 2022-07-17 14:55 UTC (permalink / raw)
  To: 56615

[-- Attachment #1: Type: text/plain, Size: 158 bytes --]

Hello,

Support for a line continuation using backslash is needed in
`python-nav--beginning-of-defun'.  Attached is a patch to fix this
issue.

Best Regards,

[-- Attachment #2: fix-56615.patch --]
[-- Type: application/octet-stream, Size: 2351 bytes --]

commit 338bf13a173f46fb3eef60f9c067d875c597950e
Author: kobarity <kobarity@gmail.com>
Date:   Sun Jul 17 23:52:24 2022 +0900

    Fix Python navigation problem with a line continuation using backslash
    
    * lisp/progmodes/python.el (python-nav--beginning-of-defun): Fix
    line continuation using backslash in nested defun (bug#56615).

diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index f31832fec9..ec7d657220 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -1459,8 +1459,11 @@ python-nav--beginning-of-defun
                             (current-indentation)))
          (body-indentation
           (and (> arg 0)
-               (or (and (python-info-looking-at-beginning-of-defun)
-                        (+ (current-indentation) python-indent-offset))
+               (or (and (python-info-looking-at-beginning-of-defun nil t)
+                        (+ (save-excursion
+                             (python-nav-beginning-of-statement)
+                             (current-indentation))
+                           python-indent-offset))
                    (save-excursion
                      (while
                          (and
diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el
index b2cccdd956..3b10bde23b 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -1995,6 +1995,32 @@ python-nav-beginning-of-defun-4
                 (beginning-of-line)
                 (point))))))
 
+(ert-deftest python-nav-beginning-of-defun-5 ()
+  (python-tests-with-temp-buffer
+   "
+class C:
+
+    def \\
+            m(self):
+        pass
+"
+   (python-tests-look-at "m(self):")
+   (should (= (save-excursion
+                (python-nav-beginning-of-defun)
+                (point))
+              (save-excursion
+                (python-tests-look-at "def \\" -1)
+                (beginning-of-line)
+                (point))))
+   (python-tests-look-at "class C:" -1)
+   (should (= (save-excursion
+                (python-nav-beginning-of-defun -1)
+                (point))
+              (save-excursion
+                (python-tests-look-at "def \\")
+                (beginning-of-line)
+                (point))))))
+
 (ert-deftest python-nav-end-of-defun-1 ()
   (python-tests-with-temp-buffer
    "

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#56615: 29.0.50; python-nav-beginning-of-defun problem with a line continuation using backslash in nested defun
  2022-07-17 14:55 ` kobarity
@ 2022-07-23  8:26   ` Lars Ingebrigtsen
  0 siblings, 0 replies; 3+ messages in thread
From: Lars Ingebrigtsen @ 2022-07-23  8:26 UTC (permalink / raw)
  To: kobarity; +Cc: 56615

kobarity <kobarity@gmail.com> writes:

> Support for a line continuation using backslash is needed in
> `python-nav--beginning-of-defun'.  Attached is a patch to fix this
> issue.

Thanks; pushed to Emacs 29.






^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-07-23  8:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-17 14:49 bug#56615: 29.0.50; python-nav-beginning-of-defun problem with a line continuation using backslash in nested defun kobarity
2022-07-17 14:55 ` kobarity
2022-07-23  8:26   ` 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.