From: Bastian Ballmann <balle@chaostal.de>
To: python-list@python.org
Cc: help-gnu-emacs@gnu.org
Subject: Emacs Python indention
Date: Sat, 11 Jun 2011 22:43:11 +0200 [thread overview]
Message-ID: <20110611224311.62a6e5b1@chaostal.de> (raw)
[-- Attachment #1: Type: text/plain, Size: 1782 bytes --]
Hi Emacs / Python coders,
moving a region of python code for more than one indention in Emacs is
quite annoying, cause the python-shift-left and -right functions always
loose the mark and one has to reactivate it with \C-x \C-x or
guess how many indentions one want to make and do a \C-u <nr> \C-c >
That were the only solutions I found on the net and well both are
not very comfortable so here's a fix for that. With the following code
you can use \C-c left and right to move your Python code to the left
and to the right :)
HF
Basti
(defun balle-python-shift-left ()
(interactive)
(let (start end bds)
(if (and transient-mark-mode
mark-active)
(setq start (region-beginning) end (region-end))
(progn
(setq bds (bounds-of-thing-at-point 'line))
(setq start (car bds) end (cdr bds))))
(python-shift-left start end))
(setq deactivate-mark nil)
)
(defun balle-python-shift-right ()
(interactive)
(let (start end bds)
(if (and transient-mark-mode
mark-active)
(setq start (region-beginning) end (region-end))
(progn
(setq bds (bounds-of-thing-at-point 'line))
(setq start (car bds) end (cdr bds))))
(python-shift-right start end))
(setq deactivate-mark nil)
)
(add-hook 'python-mode-hook
(lambda ()
(define-key python-mode-map (kbd "C-c <right>")
'balle-python-shift-right)
(define-key python-mode-map (kbd "C-c <left>")
'balle-python-shift-left)
)
)
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
next reply other threads:[~2011-06-11 20:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-11 20:43 Bastian Ballmann [this message]
2011-06-12 10:59 ` Emacs Python indention Andrea Crotti
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=20110611224311.62a6e5b1@chaostal.de \
--to=balle@chaostal.de \
--cc=help-gnu-emacs@gnu.org \
--cc=python-list@python.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.