unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alin Soare <as1789@gmail.com>
To: herring@lanl.gov
Cc: "Stephen J. Turnbull" <turnbull@sk.tsukuba.ac.jp>,
	Emacs Dev <emacs-devel@gnu.org>
Subject: Re: line-move-down-up
Date: Wed, 20 Apr 2011 20:22:53 +0300	[thread overview]
Message-ID: <BANLkTin=Mx-R2-MoV4xk-o2+CkS9jPCnPg@mail.gmail.com> (raw)
In-Reply-To: <61133.130.55.132.20.1303154665.squirrel@webmail.lanl.gov>

[-- Attachment #1: Type: text/plain, Size: 1352 bytes --]

>
> > If I use C-x C-t, the cursor goes down, while the line goes up. I cannot
> > move the line the second time.
>
> Which line?  Obviously one line is moving down if another is moving up.
> If you want point to move along with the upward-moving line rather than
> the downward-moving one, use C-- C-x C-t (and then C-x z z ... as needed).
>
> > And this only transposes the line, not move the line.
>
> What's the difference?
>
>
This is a good question. Please, can you write 2 lambda functions that
behaves exactly like the code below, and attach them to M-up , M-down ?

You should use only transpose-line, and none other function that deletes
text, like delete-and-extract-region, kill-line, etc.


(defun line-move-- (n)
  (if (> (point-max) (point-at-eol))
      (let ((column (current-column) )
            (line (delete-and-extract-region (point-at-bol) (1+
(point-at-eol)))))
        (forward-line n)
        (insert-string line)
        (backward-char)
        (move-to-column column) ) ) )

(define-key global-map [(meta up)]
  (lambda (&optional n)
    (interactive "P")
    (line-move-- (- (if (numberp n) n 1) ) ) ) )

(define-key global-map [(meta down)]
  (lambda (&optional n)
    (interactive "P")
    (line-move-- (if (numberp n) n 1) )  ) )

;;;;;

Using transpose-line , it is much direct to simulate line-move--down than I
did.

[-- Attachment #2: Type: text/html, Size: 1821 bytes --]

  reply	other threads:[~2011-04-20 17:22 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-18 13:26 line-move-down-up A Soare
2011-04-18 13:36 ` line-move-down-up Deniz Dogan
2011-04-18 13:40   ` line-move-down-up A Soare
2011-04-18 14:51     ` line-move-down-up A Soare
2011-04-18 15:31       ` line-move-down-up Deniz Dogan
2011-04-18 15:37         ` line-move-down-up A Soare
2011-04-18 14:30 ` line-move-down-up Stephen J. Turnbull
2011-04-18 14:53   ` line-move-down-up A Soare
     [not found]   ` <BANLkTimKts-mZSMmbeo=rOCeP8+Un2aZjA@mail.gmail.com>
     [not found]     ` <87d3kjpnef.fsf@uwakimon.sk.tsukuba.ac.jp>
2011-04-18 15:56       ` line-move-down-up Alin Soare
2011-04-18 19:24         ` line-move-down-up Davis Herring
2011-04-20 17:22           ` Alin Soare [this message]
2011-04-19  8:20         ` line-move-down-up Ivan Andrus
2011-04-19  9:34           ` line-move-down-up Deniz Dogan
2011-04-21  9:28             ` line-move-down-up Ivan Andrus

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='BANLkTin=Mx-R2-MoV4xk-o2+CkS9jPCnPg@mail.gmail.com' \
    --to=as1789@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=herring@lanl.gov \
    --cc=turnbull@sk.tsukuba.ac.jp \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).