(forward-line arg))))
arg))
+(defvar transpose-subr-start1)
+(defvar transpose-subr-start2)
+(defvar transpose-subr-end1)
+(defvar transpose-subr-end2)
+
(defun transpose-subr (mover arg)
- (let (start1 end1 start2 end2)
+ (let (transpose-subr-start1
+ transpose-subr-end1
+ transpose-subr-start2
+ transpose-subr-end2)
(if (= arg 0)
(progn
(save-excursion
(funcall mover 1)
- (setq end2 (point))
+ (setq transpose-subr-end2 (point))
(funcall mover -1)
- (setq start2 (point))
+ (setq transpose-subr-start2 (point))
(goto-char (mark))
(funcall mover 1)
- (setq end1 (point))
+ (setq transpose-subr-end1 (point))
(funcall mover -1)
- (setq start1 (point))
+ (setq transpose-subr-start1 (point))
(transpose-subr-1))
(exchange-point-and-mark))
(if (> arg 0)
(progn
(funcall mover -1)
- (setq start1 (point))
+ (setq transpose-subr-start1 (point))
(funcall mover 1)
- (setq end1 (point))
+ (setq transpose-subr-end1 (point))
(funcall mover arg)
- (setq end2 (point))
+ (setq transpose-subr-end2 (point))
(funcall mover (- arg))
- (setq start2 (point))
+ (setq transpose-subr-start2 (point))
(transpose-subr-1)
- (goto-char end2))
+ (goto-char transpose-subr-end2))
(funcall mover -1)
- (setq start2 (point))
+ (setq transpose-subr-start2 (point))
(funcall mover 1)
- (setq end2 (point))
+ (setq transpose-subr-end2 (point))
(funcall mover (1- arg))
- (setq start1 (point))
+ (setq transpose-subr-start1 (point))
(funcall mover (- arg))
- (setq end1 (point))
+ (setq transpose-subr-end1 (point))
(transpose-subr-1)))))
(defun transpose-subr-1 ()
- (if (> (min end1 end2) (max start1 start2))
+ (if (> (min transpose-subr-end1 transpose-subr-end2)
+ (max transpose-subr-start1 transpose-subr-start2))
(error "Don't have two things to transpose"))
- (let* ((word1 (buffer-substring start1 end1))
+ (let* ((word1 (buffer-substring transpose-subr-start1 transpose-subr-end1))
(len1 (length word1))
- (word2 (buffer-substring start2 end2))
+ (word2 (buffer-substring transpose-subr-start2 transpose-subr-end2))
(len2 (length word2)))
- (delete-region start2 end2)
- (goto-char start2)
+ (delete-region transpose-subr-start2 transpose-subr-end2)
+ (goto-char transpose-subr-start2)
(insert word1)
- (goto-char (if (< start1 start2) start1
- (+ start1 (- len1 len2))))
+ (goto-char (if (< transpose-subr-start1 transpose-subr-start2)
+ transpose-subr-start1
+ (+ transpose-subr-start1 (- len1 len2))))
(delete-region (point) (+ (point) len1))
(insert word2)))
\f