unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#14352: 24.3; Python: narrow-to-defun narrows to class, not method
@ 2013-05-05 17:43 Eric Hanchrow
  2013-12-25 20:07 ` bug#14352: Fabián Ezequiel Gallina
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Hanchrow @ 2013-05-05 17:43 UTC (permalink / raw)
  To: 14352

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

This bug report will be sent to the Bug-GNU-Emacs mailing list
and the GNU bug tracker at debbugs.gnu.org.  Please check that
the From: line contains a valid email address.  After a delay of up
to one day, you should receive an acknowledgment at that address.

Please write in English if possible, as the Emacs maintainers
usually do not have translators for other languages.

Please describe exactly what actions triggered the bug, and
the precise symptoms of the bug.  If you can, give a recipe
starting from `emacs -Q':

Put the following python program into a file named /tmp/repro.py.  It
should have 9 lines and 120 characters.

==>8====>8====>8====>8====>8====>8====>8====>8====>8====>8====>8====>8==
# Hello world

class Frotz(object):

    def meth(self):
        foo = 'bar'

    def seth(self):
        znort='frotz'
==8<====8<====8<====8<====8<====8<====8<====8<====8<====8<====8<====8<==

Start emacs with "emacs -Q".

C-x C-f /tmp/repro.py RET

M-x goto-line RET 5 RET

C-x n d

I see almost the entire file -- only the first two lines have been
hidden by narrowing.  I'd have expected to see only the two lines
starting with "def meth".

In GNU Emacs 24.3.1 (x86_64-apple-darwin, NS apple-appkit-1038.36)
 of 2013-03-12 on bob.porkrind.org
Windowing system distributor `Apple', version 10.3.1187
Configured using:
 `configure '--host=x86_64-apple-darwin' '--build=i686-apple-darwin'
 '--with-ns' 'build_alias=i686-apple-darwin'
 'host_alias=x86_64-apple-darwin' 'CC=gcc -mmacosx-version-min=10.7
 -isystem
 /Users/david/Xcode-10.7_4.5.2/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include/
 -F/Users/david/Xcode-10.7_4.5.2/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks''

Important settings:
  locale-coding-system: nil
  default enable-multibyte-characters: t

Major mode: Python

Minor modes in effect:
  tooltip-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-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
  transient-mark-mode: t

Recent input:
C-x C-f / t m p / r e p <tab> <return> C-u C-n C-u
C-n C-n C-n C-n C-x n d M-x r e p o r t - e m <tab>
<return>

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
mml-sec 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 rx easymenu comint ring ansi-color
time-date tooltip ediff-hook vc-hooks lisp-float-type mwheel ns-win
tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment
lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev
minibuffer loaddefs button faces cus-face macroexp files text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process ns multi-tty
emacs)

[-- Attachment #2: Type: text/html, Size: 4930 bytes --]

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

* bug#14352:
  2013-05-05 17:43 bug#14352: 24.3; Python: narrow-to-defun narrows to class, not method Eric Hanchrow
@ 2013-12-25 20:07 ` Fabián Ezequiel Gallina
  0 siblings, 0 replies; 2+ messages in thread
From: Fabián Ezequiel Gallina @ 2013-12-25 20:07 UTC (permalink / raw)
  To: 14352-done


Unfortunately, this seems like intended behavior (and I do agree that I
don't like it either). I suggest you raise this to emacs-devel if you
really want to change default behavior.

Check the `mark-defun' definition at
emacs/trunk/lisp/emacs-lisp/lisp.el:427 and you'll see that it does have
an explicit call to `beginning-of-defun' for "languages with nested
functions... e.g. Python."

A similar approach seems to takes place in `narrow-to-defun' at
emacs/trunk/lisp/emacs-lisp/lisp.el:470 which causes this.

From my side I've been narrowing defuns by calling `end-of-line' first
if I'm looking at it. You could rebind the `narrow-to-defun' command in
the `python-mode-map' to the following command:

    (defun python-narrow-to-defun (&optional _arg)
      "Make text outside current defun invisible.
    The defun visible is the one that contains point or follows
    point.  Optional ARG is ignored."
      (interactive)
      (save-excursion
        (end-of-line 1)
        (narrow-to-defun)))


Regards,
Fabián.





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

end of thread, other threads:[~2013-12-25 20:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-05 17:43 bug#14352: 24.3; Python: narrow-to-defun narrows to class, not method Eric Hanchrow
2013-12-25 20:07 ` bug#14352: Fabián Ezequiel Gallina

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).