unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: A Soare <as1789@gmail.com>
To: emacs-devel@gnu.org
Subject: Re: line-move-down-up
Date: Mon, 18 Apr 2011 15:37:30 +0000 (UTC)	[thread overview]
Message-ID: <loom.20110418T173327-222@post.gmane.org> (raw)
In-Reply-To: BANLkTi=CmiHoMW8JyvMZLqo_CC=NLRhP7A@mail.gmail.com

Deniz Dogan <deniz.a.m.dogan <at> gmail.com> writes:

> 
> 2011/4/18 A Soare <as1789 <at> gmail.com>:
> >> Also, (next-line n) (beginning-of-line) could be replaced
> >> with (beginning-of-line (1+ n)).
> >>
> >
> > This is wrong in general.
> >
> 
> Care to elaborate?
> 
> 


(progn
  (goto-char (point-max))
  (insert ? )
  (beginning-of-line 4))

The definitive version I keep in .emacs is so:


;; move line

(defun line-move-down (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-down (if (numberp n) (- n) -1) ) ) )

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





  reply	other threads:[~2011-04-18 15:37 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         ` A Soare [this message]
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           ` line-move-down-up Alin Soare
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=loom.20110418T173327-222@post.gmane.org \
    --to=as1789@gmail.com \
    --cc=emacs-devel@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 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).