GNU bug report logs - #23731
25.1.50; Command to break parenthesized python expression over multiple lines

Previous Next

Package: emacs;

Reported by: John Lee <john.lee <at> made.com>

Date: Wed, 8 Jun 2016 15:27:01 UTC

Severity: wishlist

Found in version 25.1.50

To reply to this bug, email your comments to 23731 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#23731; Package emacs. (Wed, 08 Jun 2016 15:27:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to John Lee <john.lee <at> made.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 08 Jun 2016 15:27:01 GMT) Full text and rfc822 format available.

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

From: John Lee <john.lee <at> made.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.1.50; Command to break parenthesized python expression over
 multiple lines
Date: Wed, 8 Jun 2016 13:53:03 +0100
Wishlist

I have emacs set up to indent Python code like so (I don't actually
recall what I did to configure the position of the closing parenthesis,
but I have python-indent and tab-width set to 4):

foo(
    bar, baz
)

That works fine. However, that style in a particular program I'm working
on very often means I find myself with text like this:

some_very_long_python_function_call(an_extremely_long_name_here,
and_another_one_right_here)

At which point I'd like to be able to ask emacs to reformat that line,
or sexp if you like (the one at point, let's say), like this:

some_very_long_python_function_call(
    an_extremely_long_name_here, and_another_one_right_here
)

or sometimes like this:

some_very_long_python_function_call(
    an_extremely_long_name_here,
    and_another_one_right_here
)

Just using regular editing keys I find this a bit of a chore.

It would be really great if there were a command to do this (I guess in
python.el).


I will note that it is also fairly often the case that the reason I want
to split a function call across multiple lines is not that the line
would be too long, but that there are many arguments, so this is better:

do_something(
    foo,
    bar,
    baz,
    ham=spam
    potatoes=vegetables
)

than this:

do_something(foo, bar, baz, ham=spam potatoes=vegetables)

just because I find the former is easier to read.

Finally, in some cases the parenthesized expression to be broken over
lines is something other than a function call (e.g. an import list or
tuple -- or even a list, not strictly a parenthesized expression, but
similar).




In GNU Emacs 25.1.50.2 (x86_64-pc-linux-gnu, GTK+ Version 3.16.7)
 of 2016-04-25 built on lgw01-58
Windowing system distributor 'The X.Org Foundation', version 11.0.11702000
System Description:    Ubuntu 15.10

Configured using:
 'configure --build=x86_64-linux-gnu --prefix=/usr
 '--includedir=${prefix}/include' '--mandir=${prefix}/share/man'
 '--infodir=${prefix}/share/info' --sysconfdir=/etc --localstatedir=/var
 --disable-silent-rules '--libdir=${prefix}/lib/x86_64-linux-gnu'
 '--libexecdir=${prefix}/lib/x86_64-linux-gnu' --disable-maintainer-mode
 --disable-dependency-tracking --prefix=/usr --sharedstatedir=/var/lib
 --program-suffix=-snapshot --with-x=yes --with-x-toolkit=gtk3
 'CFLAGS=-g -O2 -fstack-protector-strong -Wformat
 -Werror=format-security' CPPFLAGS=-D_FORTIFY_SOURCE=2
 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro''

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS
NOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11

Important settings:
  value of $LANG: en_GB.UTF-8
  value of $XMODIFIERS:
  locale-coding-system: utf-8-unix

Major mode: Emacs-Lisp

Minor modes in effect:
  csv-field-index-mode: t
  tdd-mode: t
  which-function-mode: t
  recentf-mode: t
  rainbow-delimiters-mode: t
  global-flycheck-mode: t
  flycheck-mode: t
  evil-leader-mode: t
  diff-auto-refine-mode: t
  magit-auto-revert-mode: t
  auto-revert-mode: t
  global-git-commit-mode: t
  async-bytecomp-package-mode: t
  evil-mode: t
  evil-local-mode: t
  auto-image-file-mode: t
  global-whitespace-mode: t
  global-undo-tree-mode: t
  undo-tree-mode: t
  shell-dirtrack-mode: t
  savehist-mode: t
  show-paren-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
[2016-06-08 13:28:20] ‘ *autoload*’ [nil 1209600]
[2016-06-08 13:28:20] ‘*Packages*’ [4890 1209600]
[2016-06-08 13:28:20] ‘*magit-diff: erp_core’ [4185 1209600]
[2016-06-08 13:28:20] ‘*magit: erp_core’ [4170 1209600]
Desktop saved in ~/.emacs.d/desktop/
Quit [4 times]
All variables and subroutines might as well have a documentation string
Mark saved where search started
Quit [2 times]
Mark saved where search started [2 times]

Load-path shadows:
/home/john.lee/.emacs.d/elpa/helm-20160121.2157/helm-multi-match hides
/home/john.lee/.emacs.d/elpa/helm-core-20160121.2157/helm-multi-match
/home/john.lee/.emacs.d/elpa/magit-20160119.1409/magit-popup hides
/home/john.lee/.emacs.d/elpa/magit-popup-20160119.1409/magit-popup
/usr/share/emacs/site-lisp/dictionaries-common/ispell hides
/usr/share/emacs/25.1.50/lisp/textmodes/ispell
/usr/share/emacs/site-lisp/dictionaries-common/flyspell hides
/usr/share/emacs/25.1.50/lisp/textmodes/flyspell
/home/john.lee/.emacs.d/elpa/seq-20151121.1017/seq hides
/usr/share/emacs/25.1.50/lisp/emacs-lisp/seq

Features:
(shadow mail-extr emacsbug sendmail css-mode-expansions css-mode
smart-mode-line-powerline-theme cus-theme smart-mode-line-dark-theme
smart-mode-line powerline powerline-separators powerline-themes color
rich-minority tar-mode csv-mode org-table edebug debug ibuf-ext ibuffer
ibuffer-loaddefs eieio-opt speedbar sb-image ezimage dframe tdd apropos
compare-w cal-move parse-time tramp-cache two-column iso-transl cua-base
gud linum which-func sort browse-url dabbrev log-view vc-annotate
wgrep-ag ag vc-svn find-dired wgrep grep jira xml-rpc timezone xml
autoload lisp-mnt pp cus-edit misearch multi-isearch mm-archive
network-stream starttls url-http tls gnutls url-gw nsm url-cache
url-auth url url-proxy url-privacy url-expand url-methods url-history
url-cookie url-domsuf url-util mailcap recentf tree-widget wid-edit sql
view vc-hg jinja2-mode json-mode json-reformat json-snatcher evil-mc
evil-mc-command-execute evil-mc-command-record evil-mc-cursor-make
evil-mc-region evil-mc-cursor-state evil-mc-undo evil-mc-vars
evil-mc-known-commands evil-mc-common rng-xsd xsd-regexp rng-cmpct
nxml-mode-expansions rng-nxml rng-valid rng-loc rng-uri rng-parse
nxml-parse rng-match rng-dt rng-util rng-pttrn nxml-ns nxml-mode
nxml-outln nxml-rap nxml-util nxml-enc xmltok conf-mode yaml-mode
cursor-sensor js2-mode-expansions js2-mode etags xref project
js-mode-expansions js html-mode-expansions sgml-mode cc-mode-expansions
cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine
cc-vars cc-defs imenu rainbow-delimiters dockerfile-mode markdown-mode
rst compile sh-script smie executable dired-aux org-element org-indent
org-rmail org-mhe org-irc org-info org-gnus org-docview doc-view
jka-compr image-mode org-bibtex bibtex org-bbdb org-w3m vc vc-dispatcher
vc-git smex desktop frameset flycheck rx subr-x dtrt-indent .emacs
emamux-ghci emamux mmm-mode mmm-univ mmm-class mmm-region mmm-auto
mmm-vars mmm-utils mmm-compat evil-org the-org-mode-expansions org
org-macro org-footnote org-pcomplete org-list org-faces org-entities
noutline outline org-version ob-emacs-lisp ob ob-tangle ob-ref ob-lob
ob-table ob-exp org-src ob-keys ob-comint ob-core ob-eval org-compat
org-macs org-loaddefs find-func cal-menu calendar cal-loaddefs
evil-leader evil-ediff ediff-merg ediff-wind ediff-diff ediff-mult
ediff-help ediff-init ediff-util ediff expand-region
text-mode-expansions python-el-fgallina-expansions er-basic-expansions
expand-region-core expand-region-custom evil-magit magit-blame
magit-stash magit-bisect magit-remote magit-commit magit-sequence magit
magit-apply magit-wip magit-log magit-diff smerge-mode diff-mode
magit-core magit-autorevert autorevert filenotify magit-process
magit-popup magit-mode magit-git crm magit-section magit-utils
git-commit help-fns log-edit message puny dired-x dired dired-loaddefs
rfc822 mml mml-sec epa derived epg gnus-util rmail rmail-loaddefs
mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 mm-util
ietf-drums mail-prsvr mailabbrev mail-utils gmm-utils mailheader
pcvs-util add-log with-editor async-bytecomp async evil evil-integration
evil-maps evil-commands evil-command-window evil-types evil-search
evil-ex evil-macros evil-repeat evil-states evil-core evil-common
thingatpt evil-digraphs evil-vars server midnight image-file cus-start
cus-load disp-table whitespace warnings undo-tree diff python tramp-sh
tramp tramp-compat tramp-loaddefs trampver shell pcomplete format-spec
json map comint ring ansi-color ansible easy-mmode f s ucs-normalize
yasnippet rect exec-path-from-shell framemove windmove ace-jump-mode
advice cl dash ibuf-macs savehist edmacro kmacro ido monokai-theme paren
finder-inf info package epg-config url-handlers url-parse auth-source
cl-seq eieio eieio-core cl-macs eieio-loaddefs password-cache url-vars
seq byte-opt gv bytecomp byte-compile cl-extra help-mode easymenu cconv
cl-loaddefs pcase cl-lib time-date mule-util tooltip eldoc electric
uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list newcomment elisp-mode lisp-mode prog-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core term/tty-colors frame 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 charscript case-table epa-hook
jka-cmpr-hook help simple abbrev obarray minibuffer cl-preloaded nadvice
loaddefs button faces cus-face macroexp files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote dbusbind inotify dynamic-setting
system-font-setting font-render-setting move-toolbar gtk x-toolkit x
multi-tty make-network-process emacs)

Memory information:
((conses 16 3551889 430966)
 (symbols 48 74901 47)
 (miscs 40 28192 11704)
 (strings 32 272740 57968)
 (string-bytes 1 9991530)
 (vectors 16 134497)
 (vector-slots 8 3051785 255164)
 (floats 8 1482 6641)
 (intervals 56 533564 7262)
 (buffers 976 703)
 (heap 1024 193955 19486))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#23731; Package emacs. (Wed, 08 Jun 2016 21:54:02 GMT) Full text and rfc822 format available.

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

From: John Lee <john.lee <at> made.com>
To: 23731 <at> debbugs.gnu.org
Date: Wed, 8 Jun 2016 22:53:18 +0100
Clarification: this line in my opening comment was intended to be a
single physical line:

some_very_long_python_function_call(an_extremely_long_name_here,
and_another_one_right_here)




This bug report was last modified 9 years and 7 days ago.

Previous Next


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