unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Dave Benjamin <ramen@lackingtalent.com>
To: help-gnu-emacs@gnu.org
Subject: Moving regions up and down by lines
Date: Sat, 30 Jun 2007 10:25:35 -0700	[thread overview]
Message-ID: <smwhi.542100$6P2.509197@newsfe16.phx> (raw)

Greetings,

I have these two functions defined, which allow me to move the region up 
and down by one or more lines, displacing the text around it. This works 
pretty well, but after the call to yank, the region is no longer 
selected (I use transient-mark-mode). I've tried calling 
exchange-point-and-mark after the yank, but it has no effect. Does 
anyone know how to accomplish this?

(defun move-region-up (arg)
   (interactive "p")
   (kill-region (region-beginning) (region-end))
   (unwind-protect
       (previous-line arg)
     (yank)))

(defun move-region-down (arg)
   (interactive "p")
   (kill-region (region-beginning) (region-end))
   (unwind-protect
       (next-line arg)
     (yank)))

Thanks,
Dave

             reply	other threads:[~2007-06-30 17:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-30 17:25 Dave Benjamin [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-06-30 21:32 Moving regions up and down by lines martin rudalics
     [not found] <mailman.2886.1183239069.32220.help-gnu-emacs@gnu.org>
2007-07-01  6:48 ` Dave Benjamin
2007-07-01 12:05 martin rudalics

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='smwhi.542100$6P2.509197@newsfe16.phx' \
    --to=ramen@lackingtalent.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).