From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Bastian Ballmann Newsgroups: gmane.emacs.help,gmane.comp.python.general Subject: Emacs Python indention Date: Sat, 11 Jun 2011 22:43:11 +0200 Message-ID: <20110611224311.62a6e5b1@chaostal.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=PGP-SHA1; boundary="Sig_/by1cgmtcYSLGoIwBpMM0=ff"; protocol="application/pgp-signature" X-Trace: dough.gmane.org 1307825125 13141 80.91.229.12 (11 Jun 2011 20:45:25 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 11 Jun 2011 20:45:25 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: python-list@python.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Jun 11 22:45:21 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QVV3Y-0001u3-B2 for geh-help-gnu-emacs@m.gmane.org; Sat, 11 Jun 2011 22:45:20 +0200 Original-Received: from localhost ([::1]:60666 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QVV3X-0007zF-DA for geh-help-gnu-emacs@m.gmane.org; Sat, 11 Jun 2011 16:45:19 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:39191) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QVV2B-0007z8-8o for help-gnu-emacs@gnu.org; Sat, 11 Jun 2011 16:43:56 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QVV2A-0007tt-06 for help-gnu-emacs@gnu.org; Sat, 11 Jun 2011 16:43:55 -0400 Original-Received: from lucy.chaostal.de ([217.69.77.130]:54759) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QVV29-0007tm-J0 for help-gnu-emacs@gnu.org; Sat, 11 Jun 2011 16:43:53 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by lucy.chaostal.de (Postfix) with ESMTP id C11F2112690; Sat, 11 Jun 2011 22:43:50 +0200 (CEST) Original-Received: from lucy.chaostal.de ([127.0.0.1]) by localhost (lucy.openit.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 26499-04; Sat, 11 Jun 2011 22:43:30 +0200 (CEST) Original-Received: from localhost.localdomain (frbg-5d84fc04.pool.mediaWays.net [93.132.252.4]) by lucy.chaostal.de (Postfix) with ESMTP id 16626112684; Sat, 11 Jun 2011 22:43:27 +0200 (CEST) X-Mailer: Claws Mail 3.7.9 (GTK+ 2.24.4; i686-pc-linux-gnu) X-Virus-Scanned: Debian amavisd-new at lucy.chaostal.de X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 217.69.77.130 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:81332 gmane.comp.python.general:692569 Archived-At: --Sig_/by1cgmtcYSLGoIwBpMM0=ff Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable 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 \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) ) = =20 (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) ) = =20 (add-hook 'python-mode-hook=20 (lambda () (define-key python-mode-map (kbd "C-c ") 'balle-python-shift-right)=20 (define-key python-mode-map (kbd "C-c ") 'balle-python-shift-left) ) ) --Sig_/by1cgmtcYSLGoIwBpMM0=ff Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iEYEARECAAYFAk3z018ACgkQEQHD8bvs9q2ZRACghM3mUvcs+tH2TeBvayl9D33H CukAni70S83RJsIFoin8LY1xH6a0yIlz =vNJo -----END PGP SIGNATURE----- --Sig_/by1cgmtcYSLGoIwBpMM0=ff--