* bug#20897: 25.0.50; [python] sexp-movement are confusing
@ 2015-06-25 15:53 Rasmus
2015-06-25 16:16 ` Andreas Röhler
2022-02-03 21:11 ` Lars Ingebrigtsen
0 siblings, 2 replies; 11+ messages in thread
From: Rasmus @ 2015-06-25 15:53 UTC (permalink / raw
To: 20897
Hi,
Sexp movement in python.el are very confusing to me. I know that logical
sexp movements outside lisp are subjective, and I know that the behavior
isn't wrong. I understand why it does what it does. The behavior is just
confusing when I use it an practice.
Example, starting from emacs -q:
Open test.py
Insert something like this, ignoring point denoted by "{v,^} {1,...,5}".
4 5 6
v v v
def foo(x):
"""return x as one"""
x = 1;
return(x)
^ ^ ^
2 3 1
Consider points 1,...,5. At point 2 forward-sexp will go to point 1, at
point 3 backward-sexp will go to point 2. At point 1, sexp-backward will
go to 4 rather than point 2 (as I would expect). Likewise, at point 4,
forward sexp goes to point 1 rather than 5. At point five, everything is
as I would expect, and {forward,backward}-sexp goes to 6 and 4.
A switch to prefer a closer opening/closing of the "sexp" at point would
be great.
Thanks,
Rasmus
In GNU Emacs 25.0.50.2 (x86_64-unknown-linux-gnu, GTK+ Version 3.16.4)
of 2015-06-21 on x200s
Repository revision: 821a3633564f36857968c7fe2b8bb6681a895905
Windowing system distributor `The X.Org Foundation', version 11.0.11702000
Configured using:
`configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
--localstatedir=/var --mandir=/usr/share/man
--pdfdir=/usr/share/doc/emacs/pdf --with-sound=alsa --with-x-toolkit=gtk3
--with-xft 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe
-fstack-protector-strong --param=ssp-buffer-size=4'
CPPFLAGS=-D_FORTIFY_SOURCE=2
LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro'
Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS
NOTIFY ACL GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3
Important settings:
value of $LC_MONETARY: en_DK.utf8
value of $LC_NUMERIC: en_DK.utf8
value of $LC_TIME: en_DK.utf8
value of $LANG: en_US.utf8
locale-coding-system: utf-8-unix
Major mode: Group
Minor modes in effect:
magit-auto-revert-mode: t
recentf-mode: t
shell-dirtrack-mode: t
pdf-occur-global-minor-mode: t
gnus-topic-mode: t
hl-line-mode: t
cursor-sensor-mode: t
gnus-undo-mode: t
nyan-mode: t
global-company-mode: t
company-mode: t
diff-auto-refine-mode: t
ido-everywhere: t
global-auto-revert-mode: t
which-function-mode: t
winner-mode: t
delete-selection-mode: t
show-paren-mode: t
electric-pair-mode: t
savehist-mode: t
save-place-mode: t
tooltip-mode: t
global-eldoc-mode: t
electric-layout-mode: t
electric-indent-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
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
buffer-read-only: t
column-number-mode: t
line-number-mode: t
global-visual-line-mode: t
visual-line-mode: t
transient-mark-mode: t
Recent messages:
Reading active file via nnnil...done
Reading active file via nndraft...done
Checking new news...done
nnimap read 0k from mail
Checking new news...
Reading active file via nnnil...done
Reading active file via nndraft...done
Checking new news...done
funcall-interactively: Buffer is read-only: #<buffer *Group*>
Quit
Load-path shadows:
/home/rasmus/.emacs.d/lisp/abbrev hides /usr/share/emacs/25.0.50/lisp/abbrev
/usr/share/emacs/site-lisp/org/ox-texinfo hides /usr/share/emacs/25.0.50/lisp/org/ox-texinfo
/usr/share/emacs/site-lisp/org/ox-publish hides /usr/share/emacs/25.0.50/lisp/org/ox-publish
/usr/share/emacs/site-lisp/org/ox-org hides /usr/share/emacs/25.0.50/lisp/org/ox-org
/usr/share/emacs/site-lisp/org/ox-odt hides /usr/share/emacs/25.0.50/lisp/org/ox-odt
/usr/share/emacs/site-lisp/org/ox-md hides /usr/share/emacs/25.0.50/lisp/org/ox-md
/usr/share/emacs/site-lisp/org/ox-man hides /usr/share/emacs/25.0.50/lisp/org/ox-man
/usr/share/emacs/site-lisp/org/ox-latex hides /usr/share/emacs/25.0.50/lisp/org/ox-latex
/usr/share/emacs/site-lisp/org/ox-icalendar hides /usr/share/emacs/25.0.50/lisp/org/ox-icalendar
/usr/share/emacs/site-lisp/org/ox-html hides /usr/share/emacs/25.0.50/lisp/org/ox-html
/usr/share/emacs/site-lisp/org/ox hides /usr/share/emacs/25.0.50/lisp/org/ox
/usr/share/emacs/site-lisp/org/ox-beamer hides /usr/share/emacs/25.0.50/lisp/org/ox-beamer
/usr/share/emacs/site-lisp/org/ox-ascii hides /usr/share/emacs/25.0.50/lisp/org/ox-ascii
/usr/share/emacs/site-lisp/org/org-w3m hides /usr/share/emacs/25.0.50/lisp/org/org-w3m
/usr/share/emacs/site-lisp/org/org-timer hides /usr/share/emacs/25.0.50/lisp/org/org-timer
/usr/share/emacs/site-lisp/org/org-table hides /usr/share/emacs/25.0.50/lisp/org/org-table
/usr/share/emacs/site-lisp/org/org-src hides /usr/share/emacs/25.0.50/lisp/org/org-src
/usr/share/emacs/site-lisp/org/org-rmail hides /usr/share/emacs/25.0.50/lisp/org/org-rmail
/usr/share/emacs/site-lisp/org/org-protocol hides /usr/share/emacs/25.0.50/lisp/org/org-protocol
/usr/share/emacs/site-lisp/org/org-plot hides /usr/share/emacs/25.0.50/lisp/org/org-plot
/usr/share/emacs/site-lisp/org/org-pcomplete hides /usr/share/emacs/25.0.50/lisp/org/org-pcomplete
/usr/share/emacs/site-lisp/org/org-mouse hides /usr/share/emacs/25.0.50/lisp/org/org-mouse
/usr/share/emacs/site-lisp/org/org-mobile hides /usr/share/emacs/25.0.50/lisp/org/org-mobile
/usr/share/emacs/site-lisp/org/org-mhe hides /usr/share/emacs/25.0.50/lisp/org/org-mhe
/usr/share/emacs/site-lisp/org/org-macs hides /usr/share/emacs/25.0.50/lisp/org/org-macs
/usr/share/emacs/site-lisp/org/org-macro hides /usr/share/emacs/25.0.50/lisp/org/org-macro
/usr/share/emacs/site-lisp/org/org-list hides /usr/share/emacs/25.0.50/lisp/org/org-list
/usr/share/emacs/site-lisp/org/org-irc hides /usr/share/emacs/25.0.50/lisp/org/org-irc
/usr/share/emacs/site-lisp/org/org-inlinetask hides /usr/share/emacs/25.0.50/lisp/org/org-inlinetask
/usr/share/emacs/site-lisp/org/org-info hides /usr/share/emacs/25.0.50/lisp/org/org-info
/usr/share/emacs/site-lisp/org/org-indent hides /usr/share/emacs/25.0.50/lisp/org/org-indent
/usr/share/emacs/site-lisp/org/org-id hides /usr/share/emacs/25.0.50/lisp/org/org-id
/usr/share/emacs/site-lisp/org/org-habit hides /usr/share/emacs/25.0.50/lisp/org/org-habit
/usr/share/emacs/site-lisp/org/org-gnus hides /usr/share/emacs/25.0.50/lisp/org/org-gnus
/usr/share/emacs/site-lisp/org/org-footnote hides /usr/share/emacs/25.0.50/lisp/org/org-footnote
/usr/share/emacs/site-lisp/org/org-feed hides /usr/share/emacs/25.0.50/lisp/org/org-feed
/usr/share/emacs/site-lisp/org/org-faces hides /usr/share/emacs/25.0.50/lisp/org/org-faces
/usr/share/emacs/site-lisp/org/org-eshell hides /usr/share/emacs/25.0.50/lisp/org/org-eshell
/usr/share/emacs/site-lisp/org/org-entities hides /usr/share/emacs/25.0.50/lisp/org/org-entities
/usr/share/emacs/site-lisp/org/org-element hides /usr/share/emacs/25.0.50/lisp/org/org-element
/usr/share/emacs/site-lisp/org/org hides /usr/share/emacs/25.0.50/lisp/org/org
/usr/share/emacs/site-lisp/org/org-docview hides /usr/share/emacs/25.0.50/lisp/org/org-docview
/usr/share/emacs/site-lisp/org/org-datetree hides /usr/share/emacs/25.0.50/lisp/org/org-datetree
/usr/share/emacs/site-lisp/org/org-ctags hides /usr/share/emacs/25.0.50/lisp/org/org-ctags
/usr/share/emacs/site-lisp/org/org-crypt hides /usr/share/emacs/25.0.50/lisp/org/org-crypt
/usr/share/emacs/site-lisp/org/org-compat hides /usr/share/emacs/25.0.50/lisp/org/org-compat
/usr/share/emacs/site-lisp/org/org-colview hides /usr/share/emacs/25.0.50/lisp/org/org-colview
/usr/share/emacs/site-lisp/org/org-clock hides /usr/share/emacs/25.0.50/lisp/org/org-clock
/usr/share/emacs/site-lisp/org/org-capture hides /usr/share/emacs/25.0.50/lisp/org/org-capture
/usr/share/emacs/site-lisp/org/org-bibtex hides /usr/share/emacs/25.0.50/lisp/org/org-bibtex
/usr/share/emacs/site-lisp/org/org-bbdb hides /usr/share/emacs/25.0.50/lisp/org/org-bbdb
/usr/share/emacs/site-lisp/org/org-attach hides /usr/share/emacs/25.0.50/lisp/org/org-attach
/usr/share/emacs/site-lisp/org/org-archive hides /usr/share/emacs/25.0.50/lisp/org/org-archive
/usr/share/emacs/site-lisp/org/org-agenda hides /usr/share/emacs/25.0.50/lisp/org/org-agenda
/usr/share/emacs/site-lisp/org/ob-tangle hides /usr/share/emacs/25.0.50/lisp/org/ob-tangle
/usr/share/emacs/site-lisp/org/ob-table hides /usr/share/emacs/25.0.50/lisp/org/ob-table
/usr/share/emacs/site-lisp/org/ob-sqlite hides /usr/share/emacs/25.0.50/lisp/org/ob-sqlite
/usr/share/emacs/site-lisp/org/ob-sql hides /usr/share/emacs/25.0.50/lisp/org/ob-sql
/usr/share/emacs/site-lisp/org/ob-shen hides /usr/share/emacs/25.0.50/lisp/org/ob-shen
/usr/share/emacs/site-lisp/org/ob-screen hides /usr/share/emacs/25.0.50/lisp/org/ob-screen
/usr/share/emacs/site-lisp/org/ob-scheme hides /usr/share/emacs/25.0.50/lisp/org/ob-scheme
/usr/share/emacs/site-lisp/org/ob-scala hides /usr/share/emacs/25.0.50/lisp/org/ob-scala
/usr/share/emacs/site-lisp/org/ob-sass hides /usr/share/emacs/25.0.50/lisp/org/ob-sass
/usr/share/emacs/site-lisp/org/ob-ruby hides /usr/share/emacs/25.0.50/lisp/org/ob-ruby
/usr/share/emacs/site-lisp/org/ob-R hides /usr/share/emacs/25.0.50/lisp/org/ob-R
/usr/share/emacs/site-lisp/org/ob-ref hides /usr/share/emacs/25.0.50/lisp/org/ob-ref
/usr/share/emacs/site-lisp/org/ob-python hides /usr/share/emacs/25.0.50/lisp/org/ob-python
/usr/share/emacs/site-lisp/org/ob-plantuml hides /usr/share/emacs/25.0.50/lisp/org/ob-plantuml
/usr/share/emacs/site-lisp/org/ob-picolisp hides /usr/share/emacs/25.0.50/lisp/org/ob-picolisp
/usr/share/emacs/site-lisp/org/ob-perl hides /usr/share/emacs/25.0.50/lisp/org/ob-perl
/usr/share/emacs/site-lisp/org/ob-org hides /usr/share/emacs/25.0.50/lisp/org/ob-org
/usr/share/emacs/site-lisp/org/ob-octave hides /usr/share/emacs/25.0.50/lisp/org/ob-octave
/usr/share/emacs/site-lisp/org/ob-ocaml hides /usr/share/emacs/25.0.50/lisp/org/ob-ocaml
/usr/share/emacs/site-lisp/org/ob-mscgen hides /usr/share/emacs/25.0.50/lisp/org/ob-mscgen
/usr/share/emacs/site-lisp/org/ob-maxima hides /usr/share/emacs/25.0.50/lisp/org/ob-maxima
/usr/share/emacs/site-lisp/org/ob-matlab hides /usr/share/emacs/25.0.50/lisp/org/ob-matlab
/usr/share/emacs/site-lisp/org/ob-makefile hides /usr/share/emacs/25.0.50/lisp/org/ob-makefile
/usr/share/emacs/site-lisp/org/ob-lob hides /usr/share/emacs/25.0.50/lisp/org/ob-lob
/usr/share/emacs/site-lisp/org/ob-lisp hides /usr/share/emacs/25.0.50/lisp/org/ob-lisp
/usr/share/emacs/site-lisp/org/ob-lilypond hides /usr/share/emacs/25.0.50/lisp/org/ob-lilypond
/usr/share/emacs/site-lisp/org/ob-ledger hides /usr/share/emacs/25.0.50/lisp/org/ob-ledger
/usr/share/emacs/site-lisp/org/ob-latex hides /usr/share/emacs/25.0.50/lisp/org/ob-latex
/usr/share/emacs/site-lisp/org/ob-keys hides /usr/share/emacs/25.0.50/lisp/org/ob-keys
/usr/share/emacs/site-lisp/org/ob-js hides /usr/share/emacs/25.0.50/lisp/org/ob-js
/usr/share/emacs/site-lisp/org/ob-java hides /usr/share/emacs/25.0.50/lisp/org/ob-java
/usr/share/emacs/site-lisp/org/ob-io hides /usr/share/emacs/25.0.50/lisp/org/ob-io
/usr/share/emacs/site-lisp/org/ob-haskell hides /usr/share/emacs/25.0.50/lisp/org/ob-haskell
/usr/share/emacs/site-lisp/org/ob-gnuplot hides /usr/share/emacs/25.0.50/lisp/org/ob-gnuplot
/usr/share/emacs/site-lisp/org/ob-fortran hides /usr/share/emacs/25.0.50/lisp/org/ob-fortran
/usr/share/emacs/site-lisp/org/ob-exp hides /usr/share/emacs/25.0.50/lisp/org/ob-exp
/usr/share/emacs/site-lisp/org/ob-eval hides /usr/share/emacs/25.0.50/lisp/org/ob-eval
/usr/share/emacs/site-lisp/org/ob-emacs-lisp hides /usr/share/emacs/25.0.50/lisp/org/ob-emacs-lisp
/usr/share/emacs/site-lisp/org/ob hides /usr/share/emacs/25.0.50/lisp/org/ob
/usr/share/emacs/site-lisp/org/ob-dot hides /usr/share/emacs/25.0.50/lisp/org/ob-dot
/usr/share/emacs/site-lisp/org/ob-ditaa hides /usr/share/emacs/25.0.50/lisp/org/ob-ditaa
/usr/share/emacs/site-lisp/org/ob-css hides /usr/share/emacs/25.0.50/lisp/org/ob-css
/usr/share/emacs/site-lisp/org/ob-core hides /usr/share/emacs/25.0.50/lisp/org/ob-core
/usr/share/emacs/site-lisp/org/ob-comint hides /usr/share/emacs/25.0.50/lisp/org/ob-comint
/usr/share/emacs/site-lisp/org/ob-clojure hides /usr/share/emacs/25.0.50/lisp/org/ob-clojure
/usr/share/emacs/site-lisp/org/ob-C hides /usr/share/emacs/25.0.50/lisp/org/ob-C
/usr/share/emacs/site-lisp/org/ob-calc hides /usr/share/emacs/25.0.50/lisp/org/ob-calc
/usr/share/emacs/site-lisp/org/ob-awk hides /usr/share/emacs/25.0.50/lisp/org/ob-awk
/usr/share/emacs/site-lisp/org/ob-asymptote hides /usr/share/emacs/25.0.50/lisp/org/ob-asymptote
/usr/share/emacs/site-lisp/org/org-loaddefs hides /usr/share/emacs/25.0.50/lisp/org/org-loaddefs
/usr/share/emacs/site-lisp/org/org-version hides /usr/share/emacs/25.0.50/lisp/org/org-version
/usr/share/emacs/site-lisp/org/org-install hides /usr/share/emacs/25.0.50/lisp/org/org-install
/home/rasmus/.emacs.d/elpa/emms-20150519.736/tq hides /usr/share/emacs/25.0.50/lisp/emacs-lisp/tq
Features:
(shadow emacsbug json-mode json-reformat json-snatcher canlock eieio-opt
speedbar sb-image ezimage dframe cal-iso cal-china lunar solar cal-dst
cal-bahai cal-islam cal-hebrew holidays hol-loaddefs proced browse-url
sh-script smie executable web-mode autoload lisp-mnt url-handlers
tramp-cache magit-key-mode warnings magit view tramp tramp-compat
tramp-loaddefs trampver git-rebase-mode git-commit-mode log-edit pcvs-util
ediff-merg ediff-wind ediff-diff ediff-mult ediff-help ediff-init
ediff-util ediff js skewer-html skewer-mode cache-table js2-mode
simple-httpd sgml-mode rect recentf tree-widget misearch multi-isearch
add-log python find-dired grep dired-aux gnus-dired ffap face-remap
emms-player-mpv emms-info-libtag emms-librefm-stream
emms-librefm-scrobbler emms-playlist-limit emms-volume emms-volume-amixer
emms-i18n emms-history emms-score emms-stream-info emms-metaplaylist-mode
emms-bookmarks emms-cue emms-mode-line-icon emms-browser
emms-playlist-sort emms-last-played emms-player-xine emms-player-mpd
emms-playing-time emms-lyrics emms-url emms-streams emms-tag-editor
emms-mark emms-mode-line emms-cache emms-info-ogginfo emms-info-mp3info
emms-info later-do emms-playlist-mode emms-player-vlc emms-player-mplayer
emms-player-simple emms-source-playlist emms-source-file locate emms-setup
emms emms-compat quail footnote autocap cookie1 flow-fill
gnus-notifications gnus-fun notifications dbus xml cal-move org-bullets
cdlatex texmathp reftex reftex-vars tabify org-table image-file org-rmail
org-mhe org-irc org-info org-gnus org-docview doc-view org-bibtex bibtex
org-bbdb org-element avl-tree org-w3m org-capture ido-completing-read+
smex pdf-sync pdf-annot bbdb-anniv diary-lib diary-loaddefs org-inlinetask
org-indent org-location-google-maps org-agenda google-maps
google-maps-static google-maps-geocode google-maps-base json org org-macro
org-footnote org-pcomplete org-list org-faces org-entities org-version
ob-shell readline-complete shell pcomplete ob-awk ob-org ob-octave
ob-python ob-C ob-emacs-lisp ob-fortran cc-mode cc-fonts cc-guess cc-menus
cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs ob-latex ob-R 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 pdf-outline noutline outline pdf-links pdf-history pdf-occur
ibuf-ext ibuffer tablist tablist-filter semantic/wisent/comp
semantic/wisent semantic/wisent/wisent semantic/util-modes semantic/util
semantic semantic/tag semantic/lex semantic/fw mode-local cedet
pdf-isearch let-alist pdf-misc pdf-tools compile comint cus-edit cus-start
cus-load pdf-view jka-compr pdf-cache pdf-info tq pdf-util image-mode
url-http url-gw url-auth gnus-gravatar gravatar url-cache url url-proxy
url-privacy url-expand url-methods url-history url-cookie url-domsuf
url-util url-parse url-vars gnus-picon sort smiley ansi-color gnus-cite
mm-archive mail-extr gnus-async gnus-bcklg qp gnus-ml disp-table
gnus-topic hl-line cursor-sensor epa-file epa derived epg gnutls utf-7
network-stream nsm starttls nnnil gnus-demon gnus-harvest bbdb-com crm
bbdb bbdb-site timezone mailalias nnir smtpmail-async smtpmail auth-source
sendmail async gnus-delay gnus-draft gnus-agent gnus-srvr gnus-score
score-mode nnvirtual nntp gnus-cache gnus-msg gnus-art mm-uu mml2015
mm-view mml-smime smime password-cache dig mailcap gnus-sum nndraft nnmh
gnus-group gnus-undo gnus-start gnus-cloud nnimap tls utf7 netrc
parse-time gnus-spec nnmail gnus-int gnus-range mail-source message idna
dired-x dired format-spec rfc822 mml mml-sec mm-decode mm-bodies mm-encode
mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mailabbrev gmm-utils
mailheader gnus-win nnoo gnus gnus-ems nnheader gnus-util mail-utils
mm-util help-fns mail-prsvr wid-edit gnus-switch nyan-mode server paredit
checkdoc help-mode flyspell ispell cap-words superword subword
company-files company-oddmuse company-keywords company-etags etags xref
cl-seq eieio byte-opt bytecomp byte-compile cl-extra seq cconv eieio-core
company-gtags company-dabbrev-code company-dabbrev company-capf
company-cmake company-xcode company-clang company-semantic company-eclim
company-template company-css company-nxml company-bbdb company-c-headers
rx company-jedi thingatpt jedi-core python-environment epc ctable
concurrent deferred cl company vc vc-dispatcher vc-git diff-mode
easy-mmode bookmark pp ido autorevert filenotify which-func imenu winner
ring windmove delsel paren elec-pair savehist saveplace cl-macs time-date
edmacro kmacro cl-loaddefs pcase cl-lib gv finder-inf tex-site advice info
easymenu package epg-config mule-util tooltip eldoc electric uniquify
ediff-hook vc-hooks lisp-float-type mwheel 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 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 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 gfilenotify dynamic-setting
system-font-setting font-render-setting move-toolbar gtk x-toolkit x
multi-tty make-network-process emacs)
Memory information:
((conses 16 3221294 73586)
(symbols 48 71726 114)
(miscs 40 13038 7141)
(strings 32 230866 27519)
(string-bytes 1 12018724)
(vectors 16 90831)
(vector-slots 8 2165399 85080)
(floats 8 4055 3190)
(intervals 56 43823 10399)
(buffers 976 278)
(heap 1024 145052 17505))
--
Dung makes an excellent fertilizer
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#20897: 25.0.50; [python] sexp-movement are confusing
2015-06-25 15:53 bug#20897: 25.0.50; [python] sexp-movement are confusing Rasmus
@ 2015-06-25 16:16 ` Andreas Röhler
2015-06-25 16:46 ` Rasmus
2015-06-26 1:48 ` Stefan Monnier
2022-02-03 21:11 ` Lars Ingebrigtsen
1 sibling, 2 replies; 11+ messages in thread
From: Andreas Röhler @ 2015-06-25 16:16 UTC (permalink / raw
To: 20897
Am 25.06.2015 um 17:53 schrieb Rasmus:
> Hi,
>
> Sexp movement in python.el are very confusing to me. I know that logical
> sexp movements outside lisp are subjective,
Not more as anything else editor-related. Languages are composed by
elements, which a syntax may describe. Even if an editor must not be the
slave of a syntax, it should be aware of.
> and I know that the behavior
> isn't wrong.
It behaves arbitrary WRT Python syntax, that's wrong.
> I understand why it does what it does. The behavior is just
> confusing when I use it an practice.
>
> Example, starting from emacs -q:
>
> Open test.py
>
> Insert something like this, ignoring point denoted by "{v,^} {1,...,5}".
>
> 4 5 6
> v v v
> def foo(x):
> """return x as one"""
>
> x = 1;
>
> return(x)
> ^ ^ ^
> 2 3 1
>
> Consider points 1,...,5. At point 2 forward-sexp will go to point 1, at
> point 3 backward-sexp will go to point 2. At point 1, sexp-backward will
> go to 4 rather than point 2 (as I would expect). Likewise, at point 4,
> forward sexp goes to point 1 rather than 5. At point five, everything is
> as I would expect, and {forward,backward}-sexp goes to 6 and 4.
>
> A switch to prefer a closer opening/closing of the "sexp" at point would
> be great.
>
> Thanks,
> Rasmus
>
[ ... ]
Python is composed by expressions.
If inside an expression C-M-f should to to its end.
From end to next end same level if existing - or level up, or next
top-level-form, or nil at EOB
Backward and forward needs to be consistent.
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#20897: 25.0.50; [python] sexp-movement are confusing
2015-06-25 16:16 ` Andreas Röhler
@ 2015-06-25 16:46 ` Rasmus
2015-06-25 17:23 ` Andreas Röhler
2015-06-26 1:48 ` Stefan Monnier
1 sibling, 1 reply; 11+ messages in thread
From: Rasmus @ 2015-06-25 16:46 UTC (permalink / raw
To: 20897
Hi,
Andreas Röhler <andreas.roehler@easy-emacs.de> writes:
>> Sexp movement in python.el are very confusing to me. I know that logical
>> sexp movements outside lisp are subjective,
>
> Not more as anything else editor-related. Languages are composed by
> elements, which a syntax may describe. Even if an editor must not be
> the slave of a syntax, it should be aware of.
That is probably true. I really just want to be able to bent python.el to
work with my internal "fast" logic which controls how I type on keyboard.
>> and I know that the behavior
>> isn't wrong.
>
> It behaves arbitrary WRT Python syntax, that's wrong.
OK. I'm not sure. I can somehow imagine parentheses that would justify
the movements cf. below. But in lisp it would not go from one "nesting"
to another, which is essentially what bugs me.
> Python is composed by expressions.
> If inside an expression C-M-f should to to its end.
>
> From end to next end same level if existing - or level up, or next
> top-level-form, or nil at EOB
>
> Backward and forward needs to be consistent.
I'm not sure I understand.
The way I think about it is like the following. If I'm at point 2 and
move backward I really want to be a point 1. But in python point 0 and 1
is the same, so it assumes the outer level which has end point 4. But I
at most want to go to point 3, closing the "nearest" "sexp".
01 2 3
vv v V
((defun name (arg))
...)
^
4
Rasmus
--
Don't panic!!!
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#20897: 25.0.50; [python] sexp-movement are confusing
2015-06-25 16:46 ` Rasmus
@ 2015-06-25 17:23 ` Andreas Röhler
0 siblings, 0 replies; 11+ messages in thread
From: Andreas Röhler @ 2015-06-25 17:23 UTC (permalink / raw
To: 20897
Am 25.06.2015 um 18:46 schrieb Rasmus:
> Hi,
>
> Andreas Röhler <andreas.roehler@easy-emacs.de> writes:
>
>>> Sexp movement in python.el are very confusing to me. I know that logical
>>> sexp movements outside lisp are subjective,
>> Not more as anything else editor-related. Languages are composed by
>> elements, which a syntax may describe. Even if an editor must not be
>> the slave of a syntax, it should be aware of.
> That is probably true. I really just want to be able to bent python.el to
> work with my internal "fast" logic which controls how I type on keyboard.
>
>>> and I know that the behavior
>>> isn't wrong.
>> It behaves arbitrary WRT Python syntax, that's wrong.
> OK. I'm not sure. I can somehow imagine parentheses that would justify
> the movements cf. below. But in lisp it would not go from one "nesting"
> to another, which is essentially what bugs me.
>
>
>> Python is composed by expressions.
>> If inside an expression C-M-f should to to its end.
>>
>> From end to next end same level if existing - or level up, or next
>> top-level-form, or nil at EOB
>>
>> Backward and forward needs to be consistent.
> I'm not sure I understand.
>
> The way I think about it is like the following. If I'm at point 2 and
> move backward I really want to be a point 1.
Don't think so WRT picture below. From end of symbol "defun" it move
back to beginning "d".
Because "defun" is an element of the list.
Next C-M-b should go up backward - but fails. A design flaw IMO.
> But in python point 0 and 1
> is the same, so it assumes the outer level which has end point 4. But I
> at most want to go to point 3, closing the "nearest" "sexp".
>
> 01 2 3
> vv v V
> ((defun name (arg))
> ...)
> ^
> 4
>
> Rasmus
>
Not sure if I understand the double paren at picture. Rules are simple
anyway: Either there is an element of same level, reach that. Or go up.
Or go the end.
You could try py-forward-expression, py-backward-expression.
Just to study the behavior.
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#20897: 25.0.50; [python] sexp-movement are confusing
2015-06-25 16:16 ` Andreas Röhler
2015-06-25 16:46 ` Rasmus
@ 2015-06-26 1:48 ` Stefan Monnier
2015-06-26 2:03 ` Daniel Colascione
1 sibling, 1 reply; 11+ messages in thread
From: Stefan Monnier @ 2015-06-26 1:48 UTC (permalink / raw
To: Andreas Röhler; +Cc: 20897
> If inside an expression C-M-f should to to its end.
No, as explained elsewhere, C-M-f's binding is a binding that goes to
the end of the expression that immediately *follows* point. If we're
*inside* a sexp, the way to jump to its end is up-list.
I understand you want/like to jump to the end of the enclosing
expression, and that's fine, but this is not what C-M-f should do
by default.
Stefan
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#20897: 25.0.50; [python] sexp-movement are confusing
2015-06-26 1:48 ` Stefan Monnier
@ 2015-06-26 2:03 ` Daniel Colascione
2015-06-26 4:19 ` Stefan Monnier
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Daniel Colascione @ 2015-06-26 2:03 UTC (permalink / raw
To: Stefan Monnier, Andreas Röhler; +Cc: 20897
[-- Attachment #1: Type: text/plain, Size: 814 bytes --]
On 06/25/2015 09:48 PM, Stefan Monnier wrote:
>> If inside an expression C-M-f should to to its end.
>
> No, as explained elsewhere, C-M-f's binding is a binding that goes to
> the end of the expression that immediately *follows* point. If we're
> *inside* a sexp, the way to jump to its end is up-list.
>
> I understand you want/like to jump to the end of the enclosing
> expression, and that's fine, but this is not what C-M-f should do
> by default.
"Right" or "wrong" aside, Python's current default behavior is just
inconsistent with other modes for infix-expression languages. I tried
for a long time to use the default behavior --- maybe there was some
efficiency advantage that would take time to appear --- but I ended up
just giving up and making python-mode work like other modes.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#20897: 25.0.50; [python] sexp-movement are confusing
2015-06-26 2:03 ` Daniel Colascione
@ 2015-06-26 4:19 ` Stefan Monnier
2015-06-26 6:02 ` Andreas Röhler
2015-06-26 6:17 ` Andreas Röhler
2 siblings, 0 replies; 11+ messages in thread
From: Stefan Monnier @ 2015-06-26 4:19 UTC (permalink / raw
To: Daniel Colascione; +Cc: 20897
> "Right" or "wrong" aside, Python's current default behavior is just
> inconsistent with other modes
My comment was only about the part of Andreas's text which I quoted.
It is actually unrelated to this bug-report. Sorry 'bout that,
Stefan
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#20897: 25.0.50; [python] sexp-movement are confusing
2015-06-26 2:03 ` Daniel Colascione
2015-06-26 4:19 ` Stefan Monnier
@ 2015-06-26 6:02 ` Andreas Röhler
2015-06-26 6:17 ` Andreas Röhler
2 siblings, 0 replies; 11+ messages in thread
From: Andreas Röhler @ 2015-06-26 6:02 UTC (permalink / raw
To: Daniel Colascione, Stefan Monnier; +Cc: 20897
Am 26.06.2015 um 04:03 schrieb Daniel Colascione:
> On 06/25/2015 09:48 PM, Stefan Monnier wrote:
>>> If inside an expression C-M-f should to to its end.
>> No, as explained elsewhere, C-M-f's binding is a binding that goes to
>> the end of the expression that immediately *follows* point. If we're
>> *inside* a sexp, the way to jump to its end is up-list.
>>
>> I understand you want/like to jump to the end of the enclosing
>> expression, and that's fine, but this is not what C-M-f should do
>> by default.
> "Right" or "wrong" aside, Python's current default behavior is just
> inconsistent with other modes for infix-expression languages. I tried
> for a long time to use the default behavior --- maybe there was some
> efficiency advantage that would take time to appear --- but I ended up
> just giving up and making python-mode work like other modes.
>
If you could try python-mode.el's py-forward/backward-expression
commands, that would be much appreciated. Won't be surprised, should
some bug show-up there too - just don't see any at the moment.
Thanks all,
Andreas
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#20897: 25.0.50; [python] sexp-movement are confusing
2015-06-26 2:03 ` Daniel Colascione
2015-06-26 4:19 ` Stefan Monnier
2015-06-26 6:02 ` Andreas Röhler
@ 2015-06-26 6:17 ` Andreas Röhler
2 siblings, 0 replies; 11+ messages in thread
From: Andreas Röhler @ 2015-06-26 6:17 UTC (permalink / raw
To: Daniel Colascione, Stefan Monnier; +Cc: 20897
Am 26.06.2015 um 04:03 schrieb Daniel Colascione:
> On 06/25/2015 09:48 PM, Stefan Monnier wrote:
>>> If inside an expression C-M-f should to to its end.
>> No, as explained elsewhere, C-M-f's binding is a binding that goes to
>> the end of the expression that immediately *follows* point. If we're
>> *inside* a sexp, the way to jump to its end is up-list.
>>
>> I understand you want/like to jump to the end of the enclosing
>> expression, and that's fine, but this is not what C-M-f should do
>> by default.
> "Right" or "wrong" aside, Python's current default behavior is just
> inconsistent with other modes for infix-expression languages. I tried
> for a long time to use the default behavior --- maybe there was some
> efficiency advantage that would take time to appear --- but I ended up
> just giving up and making python-mode work like other modes.
>
Just to give an example syntax-oriented doesn't mean being enslaved by
syntax: operators in Python are expressions, but sexp should jump over,
as symbol-at-point is available. In case some more specific is needed,
py-partial-expression is delivered.
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#20897: 25.0.50; [python] sexp-movement are confusing
2015-06-25 15:53 bug#20897: 25.0.50; [python] sexp-movement are confusing Rasmus
2015-06-25 16:16 ` Andreas Röhler
@ 2022-02-03 21:11 ` Lars Ingebrigtsen
2022-02-03 23:22 ` Kévin Le Gouguec
1 sibling, 1 reply; 11+ messages in thread
From: Lars Ingebrigtsen @ 2022-02-03 21:11 UTC (permalink / raw
To: Rasmus; +Cc: 20897
Rasmus <rasmus@gmx.us> writes:
> Open test.py
>
> Insert something like this, ignoring point denoted by "{v,^} {1,...,5}".
>
> 4 5 6
> v v v
> def foo(x):
> """return x as one"""
>
> x = 1;
>
> return(x)
> ^ ^ ^
> 2 3 1
>
> Consider points 1,...,5. At point 2 forward-sexp will go to point 1, at
> point 3 backward-sexp will go to point 2. At point 1, sexp-backward will
> go to 4 rather than point 2 (as I would expect). Likewise, at point 4,
> forward sexp goes to point 1 rather than 5. At point five, everything is
> as I would expect, and {forward,backward}-sexp goes to 6 and 4.
(I'm going through old bug reports that unfortunately weren't resolved
at the time.)
Point movement at 2 has been fixed -- it now goes to 3 (in Emacs 29),
not 1.
As for the other points here -- that C-M-<right> at 4 shouldn't move to
1 -- I think that would be pretty surprising. That is, these commands
(try to) move by semantic unit, which is ambiguous in languages like
Python, so people have differing opinions. But as far as I can tell,
python-mode here works as designed, so I'm therefore closing this bug
report.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 11+ messages in thread
* bug#20897: 25.0.50; [python] sexp-movement are confusing
2022-02-03 21:11 ` Lars Ingebrigtsen
@ 2022-02-03 23:22 ` Kévin Le Gouguec
0 siblings, 0 replies; 11+ messages in thread
From: Kévin Le Gouguec @ 2022-02-03 23:22 UTC (permalink / raw
To: Lars Ingebrigtsen; +Cc: 20897, Rasmus
Lars Ingebrigtsen <larsi@gnus.org> writes:
> As for the other points here -- that C-M-<right> at 4 shouldn't move to
> 1 -- I think that would be pretty surprising. That is, these commands
> (try to) move by semantic unit, which is ambiguous in languages like
> Python, so people have differing opinions. But as far as I can tell,
> python-mode here works as designed, so I'm therefore closing this bug
> report.
FWIW, 28.1 introduces python-forward-sexp-function, which can be set to
nil to have something that is, quoting the Custom tag, more "CC-mode
like".
For older versions, the commentary of python.el suggests an equivalent
way to tweak sexp movement.
I haven't checked if this option satisfies all of the OP's expectations;
still, I figured it was worth mentioning in this thread FTR.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2022-02-03 23:22 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-25 15:53 bug#20897: 25.0.50; [python] sexp-movement are confusing Rasmus
2015-06-25 16:16 ` Andreas Röhler
2015-06-25 16:46 ` Rasmus
2015-06-25 17:23 ` Andreas Röhler
2015-06-26 1:48 ` Stefan Monnier
2015-06-26 2:03 ` Daniel Colascione
2015-06-26 4:19 ` Stefan Monnier
2015-06-26 6:02 ` Andreas Röhler
2015-06-26 6:17 ` Andreas Röhler
2022-02-03 21:11 ` Lars Ingebrigtsen
2022-02-03 23:22 ` Kévin Le Gouguec
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.