diff options
| author | Richard M. Stallman | 1998-11-28 02:42:51 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-11-28 02:42:51 +0000 |
| commit | 8b56e02dd55e22bdf5391cc61503ba80b2edac53 (patch) | |
| tree | 2185c256aa12606aece074bc2932e7347a6c15d6 | |
| parent | dc32c4fafbc0d9b2096baf41406f10216d4f737f (diff) | |
| download | emacs-8b56e02dd55e22bdf5391cc61503ba80b2edac53.tar.gz emacs-8b56e02dd55e22bdf5391cc61503ba80b2edac53.zip | |
(transpose-subr, transpose-subr-1): Rename variables
bound in one function and used in the other.
(transpose-subr-start1, transpose-subr-start2): Add defvars.
(transpose-subr-end1, transpose-subr-end2): Add defvars.
| -rw-r--r-- | lisp/simple.el | 52 |
1 files changed, 31 insertions, 21 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index 9e51d95d9bc..6a4734a8004 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -2524,56 +2524,66 @@ With argument 0, interchanges line point is in with line mark is in." | |||
| 2524 | (forward-line arg)))) | 2524 | (forward-line arg)))) |
| 2525 | arg)) | 2525 | arg)) |
| 2526 | 2526 | ||
| 2527 | (defvar transpose-subr-start1) | ||
| 2528 | (defvar transpose-subr-start2) | ||
| 2529 | (defvar transpose-subr-end1) | ||
| 2530 | (defvar transpose-subr-end2) | ||
| 2531 | |||
| 2527 | (defun transpose-subr (mover arg) | 2532 | (defun transpose-subr (mover arg) |
| 2528 | (let (start1 end1 start2 end2) | 2533 | (let (transpose-subr-start1 |
| 2534 | transpose-subr-end1 | ||
| 2535 | transpose-subr-start2 | ||
| 2536 | transpose-subr-end2) | ||
| 2529 | (if (= arg 0) | 2537 | (if (= arg 0) |
| 2530 | (progn | 2538 | (progn |
| 2531 | (save-excursion | 2539 | (save-excursion |
| 2532 | (funcall mover 1) | 2540 | (funcall mover 1) |
| 2533 | (setq end2 (point)) | 2541 | (setq transpose-subr-end2 (point)) |
| 2534 | (funcall mover -1) | 2542 | (funcall mover -1) |
| 2535 | (setq start2 (point)) | 2543 | (setq transpose-subr-start2 (point)) |
| 2536 | (goto-char (mark)) | 2544 | (goto-char (mark)) |
| 2537 | (funcall mover 1) | 2545 | (funcall mover 1) |
| 2538 | (setq end1 (point)) | 2546 | (setq transpose-subr-end1 (point)) |
| 2539 | (funcall mover -1) | 2547 | (funcall mover -1) |
| 2540 | (setq start1 (point)) | 2548 | (setq transpose-subr-start1 (point)) |
| 2541 | (transpose-subr-1)) | 2549 | (transpose-subr-1)) |
| 2542 | (exchange-point-and-mark)) | 2550 | (exchange-point-and-mark)) |
| 2543 | (if (> arg 0) | 2551 | (if (> arg 0) |
| 2544 | (progn | 2552 | (progn |
| 2545 | (funcall mover -1) | 2553 | (funcall mover -1) |
| 2546 | (setq start1 (point)) | 2554 | (setq transpose-subr-start1 (point)) |
| 2547 | (funcall mover 1) | 2555 | (funcall mover 1) |
| 2548 | (setq end1 (point)) | 2556 | (setq transpose-subr-end1 (point)) |
| 2549 | (funcall mover arg) | 2557 | (funcall mover arg) |
| 2550 | (setq end2 (point)) | 2558 | (setq transpose-subr-end2 (point)) |
| 2551 | (funcall mover (- arg)) | 2559 | (funcall mover (- arg)) |
| 2552 | (setq start2 (point)) | 2560 | (setq transpose-subr-start2 (point)) |
| 2553 | (transpose-subr-1) | 2561 | (transpose-subr-1) |
| 2554 | (goto-char end2)) | 2562 | (goto-char transpose-subr-end2)) |
| 2555 | (funcall mover -1) | 2563 | (funcall mover -1) |
| 2556 | (setq start2 (point)) | 2564 | (setq transpose-subr-start2 (point)) |
| 2557 | (funcall mover 1) | 2565 | (funcall mover 1) |
| 2558 | (setq end2 (point)) | 2566 | (setq transpose-subr-end2 (point)) |
| 2559 | (funcall mover (1- arg)) | 2567 | (funcall mover (1- arg)) |
| 2560 | (setq start1 (point)) | 2568 | (setq transpose-subr-start1 (point)) |
| 2561 | (funcall mover (- arg)) | 2569 | (funcall mover (- arg)) |
| 2562 | (setq end1 (point)) | 2570 | (setq transpose-subr-end1 (point)) |
| 2563 | (transpose-subr-1))))) | 2571 | (transpose-subr-1))))) |
| 2564 | 2572 | ||
| 2565 | (defun transpose-subr-1 () | 2573 | (defun transpose-subr-1 () |
| 2566 | (if (> (min end1 end2) (max start1 start2)) | 2574 | (if (> (min transpose-subr-end1 transpose-subr-end2) |
| 2575 | (max transpose-subr-start1 transpose-subr-start2)) | ||
| 2567 | (error "Don't have two things to transpose")) | 2576 | (error "Don't have two things to transpose")) |
| 2568 | (let* ((word1 (buffer-substring start1 end1)) | 2577 | (let* ((word1 (buffer-substring transpose-subr-start1 transpose-subr-end1)) |
| 2569 | (len1 (length word1)) | 2578 | (len1 (length word1)) |
| 2570 | (word2 (buffer-substring start2 end2)) | 2579 | (word2 (buffer-substring transpose-subr-start2 transpose-subr-end2)) |
| 2571 | (len2 (length word2))) | 2580 | (len2 (length word2))) |
| 2572 | (delete-region start2 end2) | 2581 | (delete-region transpose-subr-start2 transpose-subr-end2) |
| 2573 | (goto-char start2) | 2582 | (goto-char transpose-subr-start2) |
| 2574 | (insert word1) | 2583 | (insert word1) |
| 2575 | (goto-char (if (< start1 start2) start1 | 2584 | (goto-char (if (< transpose-subr-start1 transpose-subr-start2) |
| 2576 | (+ start1 (- len1 len2)))) | 2585 | transpose-subr-start1 |
| 2586 | (+ transpose-subr-start1 (- len1 len2)))) | ||
| 2577 | (delete-region (point) (+ (point) len1)) | 2587 | (delete-region (point) (+ (point) len1)) |
| 2578 | (insert word2))) | 2588 | (insert word2))) |
| 2579 | 2589 | ||