diff options
| author | Mark Oteiza | 2016-04-16 12:02:49 -0400 |
|---|---|---|
| committer | Mark Oteiza | 2016-04-16 12:05:16 -0400 |
| commit | 0f332848cdb2ed6d46771914a911cbca194cd51a (patch) | |
| tree | 578e239bf96c1a6f57a73beb82f04da51fe7a5c7 | |
| parent | aa0d83a727aa8868911d68f03d0b6e6ae37ff017 (diff) | |
| download | emacs-0f332848cdb2ed6d46771914a911cbca194cd51a.tar.gz emacs-0f332848cdb2ed6d46771914a911cbca194cd51a.zip | |
Make use of rectangle-preview custom variable.
lisp/rect.el (rectangle--string-preview): Only create a preview if
rectangle-preview is non-nil (Bug#23248).
| -rw-r--r-- | lisp/rect.el | 69 |
1 files changed, 35 insertions, 34 deletions
diff --git a/lisp/rect.el b/lisp/rect.el index fc087477a56..6056b14734d 100644 --- a/lisp/rect.el +++ b/lisp/rect.el | |||
| @@ -408,40 +408,41 @@ With a prefix (or a FILL) argument, also fill too short lines." | |||
| 408 | :type 'boolean) | 408 | :type 'boolean) |
| 409 | 409 | ||
| 410 | (defun rectangle--string-preview () | 410 | (defun rectangle--string-preview () |
| 411 | (let ((str (minibuffer-contents))) | 411 | (when rectangle-preview |
| 412 | (when (equal str "") | 412 | (let ((str (minibuffer-contents))) |
| 413 | (setq str (or (car-safe minibuffer-default) | 413 | (when (equal str "") |
| 414 | (if (stringp minibuffer-default) minibuffer-default)))) | 414 | (setq str (or (car-safe minibuffer-default) |
| 415 | (when str (setq str (propertize str 'face 'rectangle-preview))) | 415 | (if (stringp minibuffer-default) minibuffer-default)))) |
| 416 | (with-selected-window rectangle--string-preview-window | 416 | (when str (setq str (propertize str 'face 'rectangle-preview))) |
| 417 | (unless (or (null rectangle--string-preview-state) | 417 | (with-selected-window rectangle--string-preview-window |
| 418 | (equal str (car rectangle--string-preview-state))) | 418 | (unless (or (null rectangle--string-preview-state) |
| 419 | (rectangle--string-flush-preview) | 419 | (equal str (car rectangle--string-preview-state))) |
| 420 | (apply-on-rectangle | 420 | (rectangle--string-flush-preview) |
| 421 | (lambda (startcol endcol) | 421 | (apply-on-rectangle |
| 422 | (let* ((sc (move-to-column startcol)) | 422 | (lambda (startcol endcol) |
| 423 | (start (if (<= sc startcol) (point) | 423 | (let* ((sc (move-to-column startcol)) |
| 424 | (forward-char -1) | 424 | (start (if (<= sc startcol) (point) |
| 425 | (setq sc (current-column)) | 425 | (forward-char -1) |
| 426 | (point))) | 426 | (setq sc (current-column)) |
| 427 | (ec (move-to-column endcol)) | 427 | (point))) |
| 428 | (end (point)) | 428 | (ec (move-to-column endcol)) |
| 429 | (ol (make-overlay start end))) | 429 | (end (point)) |
| 430 | (push ol (nthcdr 3 rectangle--string-preview-state)) | 430 | (ol (make-overlay start end))) |
| 431 | ;; FIXME: The extra spacing doesn't interact correctly with | 431 | (push ol (nthcdr 3 rectangle--string-preview-state)) |
| 432 | ;; the extra spacing added by the rectangular-region-highlight. | 432 | ;; FIXME: The extra spacing doesn't interact correctly with |
| 433 | (when (< sc startcol) | 433 | ;; the extra spacing added by the rectangular-region-highlight. |
| 434 | (overlay-put ol 'before-string (rectangle--space-to startcol))) | 434 | (when (< sc startcol) |
| 435 | (let ((as (when (< endcol ec) | 435 | (overlay-put ol 'before-string (rectangle--space-to startcol))) |
| 436 | ;; (rectangle--space-to ec) | 436 | (let ((as (when (< endcol ec) |
| 437 | (spaces-string (- ec endcol)) | 437 | ;; (rectangle--space-to ec) |
| 438 | ))) | 438 | (spaces-string (- ec endcol)) |
| 439 | (if (= start end) | 439 | ))) |
| 440 | (overlay-put ol 'after-string (if as (concat str as) str)) | 440 | (if (= start end) |
| 441 | (overlay-put ol 'display str) | 441 | (overlay-put ol 'after-string (if as (concat str as) str)) |
| 442 | (if as (overlay-put ol 'after-string as)))))) | 442 | (overlay-put ol 'display str) |
| 443 | (nth 1 rectangle--string-preview-state) | 443 | (if as (overlay-put ol 'after-string as)))))) |
| 444 | (nth 2 rectangle--string-preview-state)))))) | 444 | (nth 1 rectangle--string-preview-state) |
| 445 | (nth 2 rectangle--string-preview-state))))))) | ||
| 445 | 446 | ||
| 446 | ;; FIXME: Should this be turned into inhibit-region-highlight and made to apply | 447 | ;; FIXME: Should this be turned into inhibit-region-highlight and made to apply |
| 447 | ;; to non-rectangular regions as well? | 448 | ;; to non-rectangular regions as well? |