unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#55808: 29.0.50; If a Python class is on the first line, mark-defun does not mark the entire class
@ 2022-06-05 14:19 kobarity
  2022-06-25 14:01 ` kobarity
  0 siblings, 1 reply; 3+ messages in thread
From: kobarity @ 2022-06-05 14:19 UTC (permalink / raw)
  To: 55808; +Cc: marcin borkowski

X-Debbugs-CC: Marcin Borkowski <mbork@mbork.pl>

Hi,

The following steps will mark only the method baz, not the entire
class Foo.

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

#+begin_src python
class Foo:
    def bar():
        pass

    def baz():
        pass
#+end_src

3. M-x mark-defun

This issue happens only if the class is on the first line of the file.

The direct cause of this issue is the following condition in
`mark-defun':

#+begin_src elisp
                       (= beg (point-min))) ; we were before the first defun!
#+end_src

This condition was introduced in Message #98 of Bug #21072. I understand
that this is necessary to avoid marking the comment line like following:

#+begin_src elisp
;; Comment header

(defun func-1 (arg)
  "docstring"
  body)
#+end_src

However, I feel that this condition is too broad to test if "we were
before the first defun". Any ideas?

Best Regards,

--

In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu)
 of 2022-06-05 built on ubuntu
Repository revision: 6011d39b6a4bc659da364255bcae22c4e6ef3a3f
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: 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 rmc 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 vc-mtn python json map comint regexp-opt ring cl-loaddefs
cl-lib ansi-color seq term/screen term/xterm xterm gv subr-x byte-opt
bytecomp byte-compile cconv 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
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 54149 7992)
 (symbols 48 6657 1)
 (strings 32 18794 1945)
 (string-bytes 1 610563)
 (vectors 16 10669)
 (vector-slots 8 126166 8797)
 (floats 8 26 262)
 (intervals 56 218 0)
 (buffers 992 12))





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

* bug#55808: 29.0.50; If a Python class is on the first line, mark-defun does not mark the entire class
  2022-06-05 14:19 bug#55808: 29.0.50; If a Python class is on the first line, mark-defun does not mark the entire class kobarity
@ 2022-06-25 14:01 ` kobarity
  2022-06-25 14:51   ` Lars Ingebrigtsen
  0 siblings, 1 reply; 3+ messages in thread
From: kobarity @ 2022-06-25 14:01 UTC (permalink / raw)
  To: 55808

Hello,

I wrote:
> The following steps will mark only the method baz, not the entire
> class Foo.
>
> 1. emacs -Q
> 2. Load the following Python file using M-x find-file
>
> #+begin_src python
> class Foo:
>     def bar():
>         pass
>
>     def baz():
>         pass
> #+end_src
>
> 3. M-x mark-defun
>
> This issue happens only if the class is on the first line of the file.

It turned out that there was a bug in `python-nav-beginning-of-defun'.
Fixing the bug #56105 also resolved this issue #55808. So #55808 can
now be closed.

Thanks,





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

* bug#55808: 29.0.50; If a Python class is on the first line, mark-defun does not mark the entire class
  2022-06-25 14:01 ` kobarity
@ 2022-06-25 14:51   ` Lars Ingebrigtsen
  0 siblings, 0 replies; 3+ messages in thread
From: Lars Ingebrigtsen @ 2022-06-25 14:51 UTC (permalink / raw)
  To: kobarity; +Cc: 55808

kobarity <kobarity@gmail.com> writes:

> It turned out that there was a bug in `python-nav-beginning-of-defun'.
> Fixing the bug #56105 also resolved this issue #55808. So #55808 can
> now be closed.

Thanks; closing this bug report, then.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

end of thread, other threads:[~2022-06-25 14:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-05 14:19 bug#55808: 29.0.50; If a Python class is on the first line, mark-defun does not mark the entire class kobarity
2022-06-25 14:01 ` kobarity
2022-06-25 14:51   ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).