From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Oleksandr Gavenko Newsgroups: gmane.emacs.help Subject: Re: Move selection up, down Date: Thu, 11 Sep 2008 20:04:32 +0300 Organization: Aioe.org NNTP Server Message-ID: References: <1422fa24-05d5-436b-82e2-b436af0a00a3@m3g2000hsc.googlegroups.com> <1219193209.777664@arno.fh-trier.de> Reply-To: gavenkoa@gmail.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1221156233 22364 80.91.229.12 (11 Sep 2008 18:03:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 11 Sep 2008 18:03:53 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Sep 11 20:04:46 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KdqX6-0002dr-Jn for geh-help-gnu-emacs@m.gmane.org; Thu, 11 Sep 2008 20:04:44 +0200 Original-Received: from localhost ([127.0.0.1]:46081 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KdqW6-00083E-GP for geh-help-gnu-emacs@m.gmane.org; Thu, 11 Sep 2008 14:03:42 -0400 Original-Path: news.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!aioe.org!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 63 Original-NNTP-Posting-Host: PFePz+PgNjzaSpuOfpcfqg.user.aioe.org Original-X-Complaints-To: abuse@aioe.org User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) Original-Xref: news.stanford.edu gnu.emacs.help:162085 X-Mailman-Approved-At: Thu, 11 Sep 2008 14:02:08 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:57429 Archived-At: Andreas Politz wrote: > jiri.pejchal@gmail.com wrote: >> Hi, >> >> in Netbeans when you press M-S-up/M-S-down you move the selected text >> up/down. When nothing is selected it moves the current line. >> >> With C-S-up/C-S-down you copy the selection up/down. When nothings is >> selected it copies the current line up/down. >> >> Is such functionality available in emacs? >> >> Jiri Pejchal > > > Heres some elisp. It binds M-S-up/down to commands > which move the active region (with respect to columns) > or the current line prefix arg lines up or down. > Have fun. > -ap > > (defun move-text-internal (arg) > (cond > ((and mark-active transient-mark-mode) > (if (> (point) (mark)) > (exchange-point-and-mark)) > (let ((column (current-column)) > (text (delete-and-extract-region (point) (mark)))) > (forward-line arg) > (move-to-column column t) > (set-mark (point)) > (insert text) > (exchange-point-and-mark) > (setq deactivate-mark nil))) > (t > (beginning-of-line) > (when (or (> arg 0) (not (bobp))) > (forward-line) > (when (or (< arg 0) (not (eobp))) > (transpose-lines arg)) > (forward-line -1))))) > > (defun move-text-down (arg) > "Move region (transient-mark-mode active) or current line > arg lines down." > (interactive "*p") > (move-text-internal arg)) > > (defun move-text-up (arg) > "Move region (transient-mark-mode active) or current line > arg lines up." > (interactive "*p") > (move-text-internal (- arg))) > > (global-set-key [\M-\S-up] 'move-text-up) > (global-set-key [\M-\S-down] 'move-text-down) After that code people decide stay in NetBeans than move to Emacs :). Humor about ability of emacs (butterfly-mode): http://www.digitalsanctuary.com/tech-blog/general/why-use-emacs-instead-of-vi.html