all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: akkana@shallowsky.com (Akkana Peck)
To: bug-gnu-emacs@gnu.org
Subject: bug#3238: python mode comments should define indentation level
Date: Thu,  7 May 2009 10:20:01 -0700 (PDT)	[thread overview]
Message-ID: <20090507172001.8AD0A19DD1@clavius.shallowsky.com> (raw)

In python mode (python.el), I'm having a lot of trouble adding comments
because newline-and-indent always re-indents to the level of the last
code line, ignoring comment lines.

For instance, if I have this code:

    for item in items :
        for c in chars :
            do_stuff()
            # hitting return after do_stuff() will indent 12 spaces

    # But I want to start a comment block with a 4-space indent.
    # Here is the start of a comment describing what the next code block does.
    # Each of these lines is indented 12 spaces, not 4.

When I hit return after the do_stuff() line, I'm indented 12 spaces,
which is reasonable given the context. I backspace 8 chars to where I
actually want to be. If I now type a code line, like i = 10, and hit
return, the next line will be indented 4 spaces. But if I type a comment
line like the one shown in my example, the next line will be indented
12 spaces, not 4. So it's difficult to add comments for functions or
blocks of code, because you have to correct the indentation with
every line you type.

newline-and-indent in python mode should do the same thing from comment
lines as it does from code lines: use the indentation of the current line.


In GNU Emacs 22.2.1 (i486-pc-linux-gnu, GTK+ Version 2.14.1)
 of 2008-09-05 on vernadsky, modified by Ubuntu
Windowing system distributor `The X.Org Foundation', version 11.0.10502000
configured using `configure  '--build=i486-linux-gnu' '--host=i486-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs22:/etc/emacs:/usr/local/share/emacs/22.2/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/22.2/site-lisp:/usr/share/emacs/site-lisp:/usr/share/emacs/22.2/leim' '--with-x=yes' '--with-x-toolkit=gtk' 'build_alias=i486-linux-gnu' 'host_alias=i486-linux-gnu' 'CFLAGS=-DDEBIAN -DSITELOAD_PURESIZE_EXTRA=5000 -g -O2' 'LDFLAGS=-g -Wl,--as-needed' 'CPPFLAGS=''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: C
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8
  default-enable-multibyte-characters: t

Major mode: Python

Minor modes in effect:
  tooltip-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  unify-8859-on-encoding-mode: t
  utf-translate-cjk-mode: t
  line-number-mode: t
  transient-mark-mode: identity

Recent input:
C-b C-b C-w C-x C-s <help-echo> C-u C-v C-u C-v C-n 
C-n C-n C-n C-n C-a C-k C-k C-p C-p C-y C-p <tab> C-n 
C-a C-k C-k C-x C-f <tab> <tab> C-g C-x C-f s h a <tab> 
<return> C-s d e l e t e C-n C-x b <return> <return> 
C-h C-h C-h C-h g i m p . d e l e t e ( n e w i m g 
) C-x C-s C-p <return> C-h C-h C-h C-h # SPC I f SPC 
t h e SPC s a v e SPC w a s SPC s u c c e s s f u l 
, SPC w e SPC d o n ' t SPC n e e d SPC t o SPC s h 
o w SPC t h e SPC n e w SPC i m a g e , <return> C-h 
C-h C-h C-h # SPC s o SPC d e l e t e SPC i t : C-x 
C-s C-n C-n C-a <return> C-x C-s C-x b <return> C-x 
k <return> C-x b <return> <next> <next> <down-mouse-1> 
<mouse-1> C-h . <return> C-h C-h C-h C-h # SPC C-x 
C-f C-w C-h / . e m a c s <return> C-x b <return> C-x 
C-s X X X C-x C-s C-h C-h C-h C-x C-s C-x b <return> 
C-s p y t h o n C-s C-s C-s C-s C-a C-x b <return> 
C-h C-h C-h SPC a s d f SPC a s d f SPC a s d f a s 
SPC d f a s d SPC f a s d SPC f a s d SPC f a s d f 
M-q M-x r e p o t C-h r t - e m <tab> <return>

Recent messages:
Making completion list...
Quit
Mark saved where search started
Wrote /home/akkana/.gimp-2.6/plug-ins/wallpaper.py [3 times]
Wrote /home/akkana/bin/pytopo [3 times]
Mark saved where search started
Loading newcomment...done
Loading emacsbug...
Loading regexp-opt...done
Loading emacsbug...done







             reply	other threads:[~2009-05-07 17:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-07 17:20 Akkana Peck [this message]
2012-10-07 16:20 ` bug#3238: python mode comments should define indentation level Fabián Ezequiel Gallina

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=20090507172001.8AD0A19DD1@clavius.shallowsky.com \
    --to=akkana@shallowsky.com \
    --cc=3238@emacsbugs.donarmstrong.com \
    --cc=bug-gnu-emacs@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.