(interactive "*p")
(transpose-subr (function
(lambda (arg)
- (if (= arg 1)
+ (if (> arg 0)
(progn
- ;; Move forward over a line,
- ;; but create a newline if none exists yet.
- (end-of-line)
- (if (eobp)
- (newline)
- (forward-char 1)))
+ ;; Move forward over ARG lines,
+ ;; but create newlines if necessary.
+ (setq arg (forward-line arg))
+ (if (/= (preceding-char) ?\n)
+ (setq arg (1+ arg)))
+ (if (> arg 0)
+ (newline arg)))
(forward-line arg))))
arg))
(funcall mover -1)
(setq start1 (point))
(transpose-subr-1))
- (exchange-point-and-mark)))
- (while (> arg 0)
- (funcall mover -1)
- (setq start1 (point))
- (funcall mover 1)
- (setq end1 (point))
- (funcall mover 1)
- (setq end2 (point))
- (funcall mover -1)
- (setq start2 (point))
- (transpose-subr-1)
- (goto-char end2)
- (setq arg (1- arg)))
- (while (< arg 0)
- (funcall mover -1)
- (setq start2 (point))
- (funcall mover -1)
- (setq start1 (point))
- (funcall mover 1)
- (setq end1 (point))
- (funcall mover 1)
- (setq end2 (point))
- (transpose-subr-1)
- (setq arg (1+ arg)))))
+ (exchange-point-and-mark))
+ (if (> arg 0)
+ (progn
+ (funcall mover -1)
+ (setq start1 (point))
+ (funcall mover 1)
+ (setq end1 (point))
+ (funcall mover arg)
+ (setq end2 (point))
+ (funcall mover (- arg))
+ (setq start2 (point))
+ (transpose-subr-1)
+ (goto-char end2))
+ (funcall mover -1)
+ (setq start2 (point))
+ (funcall mover 1)
+ (setq end2 (point))
+ (funcall mover (1- arg))
+ (setq start1 (point))
+ (funcall mover (- arg))
+ (setq end1 (point))
+ (transpose-subr-1)))))
(defun transpose-subr-1 ()
(if (> (min end1 end2) (max start1 start2))