all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Oleksandr Gavenko <gavenkoa@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Move selection up, down
Date: Thu, 11 Sep 2008 20:04:32 +0300	[thread overview]
Message-ID: <gabj2t$enu$1@aioe.org> (raw)
In-Reply-To: 1219193209.777664@arno.fh-trier.de

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



  reply	other threads:[~2008-09-11 17:04 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-19 14:21 Move selection up, down jiri.pejchal
2008-08-19 21:27 ` harven
2008-08-19 22:43   ` Chat
2008-08-19 21:47 ` Lennart Borgman (gmail)
2008-08-19 22:31   ` Drew Adams
2008-08-19 22:58     ` Lennart Borgman (gmail)
2008-08-19 23:21       ` Drew Adams
2008-08-19 23:30         ` Lennart Borgman (gmail)
2008-08-19 23:40           ` Drew Adams
2008-08-19 23:48             ` Lennart Borgman (gmail)
2008-08-20  7:45           ` Jiri Pejchal
2008-08-20  8:15             ` martin rudalics
2008-08-20 23:11   ` Richard M. Stallman
2008-08-20  0:45 ` Andreas Politz
2008-09-11 17:04   ` Oleksandr Gavenko [this message]
2013-07-04 12:15   ` teemu.leisti
2014-12-12 19:14 ` jsglazer

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='gabj2t$enu$1@aioe.org' \
    --to=gavenkoa@gmail.com \
    --cc=help-gnu-emacs@gnu.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.