GNU bug report logs - #57686
28.1.91; Python-mode C-M-a and C-M-e not always symmetrical

Previous Next

Package: emacs;

Reported by: Fabrice Bauzac-Stehly <noon <at> mykolab.com>

Date: Thu, 8 Sep 2022 20:11:02 UTC

Severity: normal

Found in version 28.1.91

To reply to this bug, email your comments to 57686 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#57686; Package emacs. (Thu, 08 Sep 2022 20:11:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Fabrice Bauzac-Stehly <noon <at> mykolab.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 08 Sep 2022 20:11:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Fabrice Bauzac-Stehly <noon <at> mykolab.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.1.91; Python-mode C-M-a and C-M-e not always symmetrical
Date: Thu, 08 Sep 2022 22:10:16 +0200
Hello,

In python-mode, with a class that has methods, if I do end-of-defun
then beginning-of-defun, I do not necessarily come back to the
original location.

================

Example:

In a python-mode buffer, put:
----
def fun1():
    pass

class MyClass:
    def meth1(self):
        pass

    def meth2(self):
        pass

    def meth3(self):
        pass

def fun2():
    pass

def fun3():
    pass
----

Place the point at the beginning of the "class MyClass" line.

Hit C-M-e to go to the end of the MyClass defun.

Hit C-M-a.  Point goes to the first line of meth3, but I would expect
to go back to the beginning of the MyClass defun.

This is especially annoying when I have a class with dozens of methods,
in which case I have to hit C-M-a a number of times to go back to the
first line of the class, even though I have left it with only one
keystroke C-M-e.

================

By doing various C-M-e and C-M-a, it feels like python-mode defun
motion sometimes considers that a method inside a class is a defun,
however if I understood correctly[1], a defun is a top-level
statement, so methods should never be considered as defuns.  Is it the
root cause of my problem?

[1] https://lists.gnu.org/archive/html/emacs-devel/2022-08/msg00200.html

================

Note: I have put this workaround in my configuration, which seems to
work reasonably well for the moment:

----
;; Somehow fix C-M-a (backward-defun) by removing "(* space)" in python.el:
(require 'python)
(defvar python-nav-beginning-of-defun-regexp
  (python-rx line-start defun (+ space) (group symbol-name))
  "Regexp matching class or function definition.
The name of the defun should be grouped so it can be retrieved
via `match-string'.")
----

Thanks!

In GNU Emacs 28.1.91 (build 1, x86_64-pc-linux-gnu, cairo version 1.17.6)
 of 2022-09-02 built on fedora.home
Repository revision: e6af4968f947a3e536fbd80e74fea44ca18e22ac
Repository branch: HEAD
Windowing system distributor 'The X.Org Foundation', version 11.0.12201003
System Description: Fedora Linux 36 (Workstation Edition)

Configured using:
 'configure -C --with-x-toolkit=no'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY
INOTIFY OLDXMENU PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF X11 XDBE
XIM XPM ZLIB

Important settings:
  value of $LC_MONETARY: fr_FR.UTF-8
  value of $LC_NUMERIC: fr_FR.UTF-8
  value of $LC_TIME: fr_FR.UTF-8
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Fundamental

Minor modes in effect:
  global-git-commit-mode: t
  magit-auto-revert-mode: t
  shell-dirtrack-mode: t
  electric-pair-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  global-prettify-symbols-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t

Load-path shadows:
/home/noon/.emacs.d/elpa/transient-0.3.7/transient hides /home/noon/git/emacs/lisp/transient

Features:
(shadow sort mail-extr emacsbug sendmail eieio-opt speedbar ezimage
dframe shortdoc help-fns radix-tree my-present my-timeline ert ewoc
debug backtrace find-func calc-arith my-shell my-host-resolve vc-mtn
vc-hg vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs vc bug-reference
face-remap whitespace copyright pcase mule-util cal-china lunar solar
cal-dst cal-islam holidays hol-loaddefs vc-git vc-dispatcher appt
diary-lib diary-loaddefs cal-menu calendar cal-loaddefs find-lisp
filecache my-magit magit-submodule magit-obsolete magit-blame
magit-stash magit-reflog magit-bisect magit-push magit-pull magit-fetch
magit-clone magit-remote magit-commit magit-sequence magit-notes
magit-worktree magit-tag magit-merge magit-branch magit-reset
magit-files magit-refs magit-status magit magit-repos magit-apply
magit-wip magit-log which-func imenu magit-diff smerge-mode diff
diff-mode git-commit rx log-edit message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa epg rfc6068 epg-config mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader pcvs-util
add-log magit-core magit-autorevert autorevert filenotify magit-margin
magit-transient magit-process with-editor magit-mode transient cl-extra
help-mode magit-git magit-section magit-utils crm dash my-bazel
my-skeletons skeleton sh-script smie executable python tramp-sh tramp
tramp-loaddefs trampver tramp-integration files-x tramp-compat shell
pcomplete parse-time iso8601 ls-lisp format-spec comint ring ansi-color
cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine
cc-vars cc-defs ibuf-macs ibuffer ibuffer-loaddefs calc-prog calc-ext
calc calc-loaddefs rect calc-macs gnus nnheader gnus-util rmail
rmail-loaddefs rfc2047 rfc2045 ietf-drums text-property-search time-date
mail-utils mm-util mail-prsvr elec-pair delsel auth-source-pass server
jira-markup-mode derived thingatpt edmacro kmacro cl noutline outline
easy-mmode cus-edit pp cus-load wid-edit info package browse-url url
url-proxy url-privacy url-expand url-methods url-history url-cookie
url-domsuf url-util mailcap url-handlers url-parse auth-source cl-seq
eieio eieio-core cl-macs eieio-loaddefs password-cache json subr-x map
url-vars seq byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib
iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list replace
newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar
rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock
font-lock syntax font-core term/tty-colors frame minibuffer cl-generic
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 simple abbrev obarray
cl-preloaded nadvice button loaddefs faces cus-face macroexp files
window text-properties overlay sha1 md5 base64 format env code-pages
mule custom widget hashtable-print-readable backquote threads dbusbind
inotify dynamic-setting system-font-setting font-render-setting cairo x
multi-tty make-network-process emacs)

Memory information:
((conses 16 270541 36722)
 (symbols 48 26212 6)
 (strings 32 86110 1992)
 (string-bytes 1 2952037)
 (vectors 16 43611)
 (vector-slots 8 492180 28335)
 (floats 8 636 199)
 (intervals 56 1264 0)
 (buffers 992 23))

Best regards

-- 
Fabrice Bauzac-Stehly
PGP 01EEACF8244E9C14B551C5256ADA5F189BD322B6




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57686; Package emacs. (Fri, 09 Sep 2022 11:28:02 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#57686: 28.1.91; Python-mode C-M-a and C-M-e not always
 symmetrical
Date: Fri, 9 Sep 2022 13:27:38 +0200
[Message part 1 (text/plain, inline)]
Am 08.09.22 um 22:10 schrieb Fabrice Bauzac-Stehly:

> Hello,
>
> In python-mode, with a class that has methods, if I do end-of-defun
> then beginning-of-defun, I do not necessarily come back to the
> original location.
>
> ================
>
> Example:
>
> In a python-mode buffer, put:
> ----
> def fun1():
>      pass
>
> class MyClass:
>      def meth1(self):
>          pass
>
>      def meth2(self):
>          pass
>
>      def meth3(self):

>          pass
>
> def fun2():
>      pass
>
> def fun3():
>      pass
> ----

May confirm the bug with

GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.16.0) of 2022-09-01

BTW if starting from an empty line just line below

  def meth3(self)

and before "pass", it should reach   "def meth3(self)", as it does.

From empty line below "pass" however should reach beginning of class.

[Message part 2 (text/html, inline)]

This bug report was last modified 2 years and 284 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.