diff options
| author | Stefan Monnier | 2013-12-08 02:32:01 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2013-12-08 02:32:01 -0500 |
| commit | 02033d491fa708e28bb3568ff85dab4d0ceb076b (patch) | |
| tree | f45b338a7b45d6f2a56e4d2ed51a6a8bdf854a7c /lisp/rect.el | |
| parent | 6407822c66a86abe01eea33d7eca662e3e7c2b60 (diff) | |
| download | emacs-02033d491fa708e28bb3568ff85dab4d0ceb076b.tar.gz emacs-02033d491fa708e28bb3568ff85dab4d0ceb076b.zip | |
* lisp/rect.el (rectangle-mark-mode): Activate mark even if
transient-mark-mode is off.
(rectangle--highlight-for-redisplay): Fix boundary condition when point
is > mark and at bolp.
Fixes: debbugs:16066
Diffstat (limited to 'lisp/rect.el')
| -rw-r--r-- | lisp/rect.el | 134 |
1 files changed, 69 insertions, 65 deletions
diff --git a/lisp/rect.el b/lisp/rect.el index ad94663fc96..be29517e087 100644 --- a/lisp/rect.el +++ b/lisp/rect.el | |||
| @@ -443,7 +443,9 @@ with a prefix argument, prompt for START-AT and FORMAT." | |||
| 443 | Activates the region if needed. Only lasts until the region is deactivated." | 443 | Activates the region if needed. Only lasts until the region is deactivated." |
| 444 | nil nil nil | 444 | nil nil nil |
| 445 | (when rectangle-mark-mode | 445 | (when rectangle-mark-mode |
| 446 | (unless (region-active-p) (push-mark-command t)))) | 446 | (unless (region-active-p) |
| 447 | (push-mark) | ||
| 448 | (activate-mark)))) | ||
| 447 | 449 | ||
| 448 | (defun rectangle--extract-region (orig &optional delete) | 450 | (defun rectangle--extract-region (orig &optional delete) |
| 449 | (if (not rectangle-mark-mode) | 451 | (if (not rectangle-mark-mode) |
| @@ -495,70 +497,72 @@ Activates the region if needed. Only lasts until the region is deactivated." | |||
| 495 | (leftcol (min ptcol markcol)) | 497 | (leftcol (min ptcol markcol)) |
| 496 | (rightcol (max ptcol markcol))) | 498 | (rightcol (max ptcol markcol))) |
| 497 | (goto-char start) | 499 | (goto-char start) |
| 498 | (while (< (point) end) | 500 | (while |
| 499 | (let* ((mleft (move-to-column leftcol)) | 501 | (let* ((mleft (move-to-column leftcol)) |
| 500 | (left (point)) | 502 | (left (point)) |
| 501 | (mright (move-to-column rightcol)) | 503 | (mright (move-to-column rightcol)) |
| 502 | (right (point)) | 504 | (right (point)) |
| 503 | (ol | 505 | (ol |
| 504 | (if (not old) | 506 | (if (not old) |
| 505 | (let ((ol (make-overlay left right))) | 507 | (let ((ol (make-overlay left right))) |
| 506 | (overlay-put ol 'window window) | 508 | (overlay-put ol 'window window) |
| 507 | (overlay-put ol 'face 'region) | 509 | (overlay-put ol 'face 'region) |
| 508 | ol) | 510 | ol) |
| 509 | (let ((ol (pop old))) | 511 | (let ((ol (pop old))) |
| 510 | (move-overlay ol left right (current-buffer)) | 512 | (move-overlay ol left right (current-buffer)) |
| 511 | ol)))) | 513 | ol)))) |
| 512 | ;; `move-to-column' may stop before the column (if bumping into | 514 | ;; `move-to-column' may stop before the column (if bumping into |
| 513 | ;; EOL) or overshoot it a little, when column is in the middle | 515 | ;; EOL) or overshoot it a little, when column is in the middle |
| 514 | ;; of a char. | 516 | ;; of a char. |
| 515 | (cond | 517 | (cond |
| 516 | ((< mleft leftcol) ;`leftcol' is past EOL. | 518 | ((< mleft leftcol) ;`leftcol' is past EOL. |
| 517 | (overlay-put ol 'before-string | 519 | (overlay-put ol 'before-string |
| 518 | (spaces-string (- leftcol mleft))) | 520 | (spaces-string (- leftcol mleft))) |
| 519 | (setq mright (max mright leftcol))) | 521 | (setq mright (max mright leftcol))) |
| 520 | ((and (> mleft leftcol) ;`leftcol' is in the middle of a char. | 522 | ((and (> mleft leftcol) ;`leftcol' is in the middle of a char. |
| 521 | (eq (char-before left) ?\t)) | 523 | (eq (char-before left) ?\t)) |
| 522 | (setq left (1- left)) | 524 | (setq left (1- left)) |
| 523 | (move-overlay ol left right) | 525 | (move-overlay ol left right) |
| 524 | (goto-char left) | 526 | (goto-char left) |
| 525 | (overlay-put ol 'before-string | 527 | (overlay-put ol 'before-string |
| 526 | (spaces-string (- leftcol (current-column))))) | 528 | (spaces-string (- leftcol (current-column))))) |
| 527 | ((overlay-get ol 'before-string) | 529 | ((overlay-get ol 'before-string) |
| 528 | (overlay-put ol 'before-string nil))) | 530 | (overlay-put ol 'before-string nil))) |
| 529 | (cond | 531 | (cond |
| 530 | ((< mright rightcol) ;`rightcol' is past EOL. | 532 | ((< mright rightcol) ;`rightcol' is past EOL. |
| 531 | (let ((str (make-string (- rightcol mright) ?\s))) | 533 | (let ((str (make-string (- rightcol mright) ?\s))) |
| 532 | (put-text-property 0 (length str) 'face 'region str) | 534 | (put-text-property 0 (length str) 'face 'region str) |
| 533 | ;; If cursor happens to be here, draw it *before* rather than | 535 | ;; If cursor happens to be here, draw it *before* rather than |
| 534 | ;; after this highlighted pseudo-text. | 536 | ;; after this highlighted pseudo-text. |
| 535 | (put-text-property 0 1 'cursor t str) | 537 | (put-text-property 0 1 'cursor t str) |
| 536 | (overlay-put ol 'after-string str))) | 538 | (overlay-put ol 'after-string str))) |
| 537 | ((and (> mright rightcol) ;`rightcol' is in the middle of a char. | 539 | ((and (> mright rightcol) ;`rightcol's in the middle of a char. |
| 538 | (eq (char-before right) ?\t)) | 540 | (eq (char-before right) ?\t)) |
| 539 | (setq right (1- right)) | 541 | (setq right (1- right)) |
| 540 | (move-overlay ol left right) | 542 | (move-overlay ol left right) |
| 541 | (if (= rightcol leftcol) | 543 | (if (= rightcol leftcol) |
| 542 | (overlay-put ol 'after-string nil) | 544 | (overlay-put ol 'after-string nil) |
| 543 | (goto-char right) | 545 | (goto-char right) |
| 544 | (let ((str (make-string | 546 | (let ((str (make-string |
| 545 | (- rightcol (max leftcol (current-column))) ?\s))) | 547 | (- rightcol (max leftcol (current-column))) |
| 546 | (put-text-property 0 (length str) 'face 'region str) | 548 | ?\s))) |
| 547 | (when (= left right) | 549 | (put-text-property 0 (length str) 'face 'region str) |
| 548 | ;; If cursor happens to be here, draw it *before* rather | 550 | (when (= left right) |
| 549 | ;; than after this highlighted pseudo-text. | 551 | ;; If cursor happens to be here, draw it *before* rather |
| 550 | (put-text-property 0 1 'cursor 1 str)) | 552 | ;; than after this highlighted pseudo-text. |
| 551 | (overlay-put ol 'after-string str)))) | 553 | (put-text-property 0 1 'cursor 1 str)) |
| 552 | ((overlay-get ol 'after-string) | 554 | (overlay-put ol 'after-string str)))) |
| 553 | (overlay-put ol 'after-string nil))) | 555 | ((overlay-get ol 'after-string) |
| 554 | (when (= leftcol rightcol) | 556 | (overlay-put ol 'after-string nil))) |
| 555 | ;; Make zero-width rectangles visible! | 557 | (when (= leftcol rightcol) |
| 556 | (overlay-put ol 'after-string | 558 | ;; Make zero-width rectangles visible! |
| 557 | (concat (propertize " " | 559 | (overlay-put ol 'after-string |
| 558 | 'face '(region (:height 0.2))) | 560 | (concat (propertize " " |
| 559 | (overlay-get ol 'after-string)))) | 561 | 'face '(region (:height 0.2))) |
| 560 | (push ol nrol)) | 562 | (overlay-get ol 'after-string)))) |
| 561 | (forward-line 1)) | 563 | (push ol nrol) |
| 564 | (and (zerop (forward-line 1)) | ||
| 565 | (<= (point) end)))) | ||
| 562 | (mapc #'delete-overlay old) | 566 | (mapc #'delete-overlay old) |
| 563 | `(rectangle ,(buffer-chars-modified-tick) ,start ,end ,@nrol)))))) | 567 | `(rectangle ,(buffer-chars-modified-tick) ,start ,end ,@nrol)))))) |
| 564 | 568 | ||