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).
This commit is contained in:
parent
aa0d83a727
commit
0f332848cd
1 changed files with 35 additions and 34 deletions
69
lisp/rect.el
69
lisp/rect.el
|
@ -408,40 +408,41 @@ With a prefix (or a FILL) argument, also fill too short lines."
|
|||
:type 'boolean)
|
||||
|
||||
(defun rectangle--string-preview ()
|
||||
(let ((str (minibuffer-contents)))
|
||||
(when (equal str "")
|
||||
(setq str (or (car-safe minibuffer-default)
|
||||
(if (stringp minibuffer-default) minibuffer-default))))
|
||||
(when str (setq str (propertize str 'face 'rectangle-preview)))
|
||||
(with-selected-window rectangle--string-preview-window
|
||||
(unless (or (null rectangle--string-preview-state)
|
||||
(equal str (car rectangle--string-preview-state)))
|
||||
(rectangle--string-flush-preview)
|
||||
(apply-on-rectangle
|
||||
(lambda (startcol endcol)
|
||||
(let* ((sc (move-to-column startcol))
|
||||
(start (if (<= sc startcol) (point)
|
||||
(forward-char -1)
|
||||
(setq sc (current-column))
|
||||
(point)))
|
||||
(ec (move-to-column endcol))
|
||||
(end (point))
|
||||
(ol (make-overlay start end)))
|
||||
(push ol (nthcdr 3 rectangle--string-preview-state))
|
||||
;; FIXME: The extra spacing doesn't interact correctly with
|
||||
;; the extra spacing added by the rectangular-region-highlight.
|
||||
(when (< sc startcol)
|
||||
(overlay-put ol 'before-string (rectangle--space-to startcol)))
|
||||
(let ((as (when (< endcol ec)
|
||||
;; (rectangle--space-to ec)
|
||||
(spaces-string (- ec endcol))
|
||||
)))
|
||||
(if (= start end)
|
||||
(overlay-put ol 'after-string (if as (concat str as) str))
|
||||
(overlay-put ol 'display str)
|
||||
(if as (overlay-put ol 'after-string as))))))
|
||||
(nth 1 rectangle--string-preview-state)
|
||||
(nth 2 rectangle--string-preview-state))))))
|
||||
(when rectangle-preview
|
||||
(let ((str (minibuffer-contents)))
|
||||
(when (equal str "")
|
||||
(setq str (or (car-safe minibuffer-default)
|
||||
(if (stringp minibuffer-default) minibuffer-default))))
|
||||
(when str (setq str (propertize str 'face 'rectangle-preview)))
|
||||
(with-selected-window rectangle--string-preview-window
|
||||
(unless (or (null rectangle--string-preview-state)
|
||||
(equal str (car rectangle--string-preview-state)))
|
||||
(rectangle--string-flush-preview)
|
||||
(apply-on-rectangle
|
||||
(lambda (startcol endcol)
|
||||
(let* ((sc (move-to-column startcol))
|
||||
(start (if (<= sc startcol) (point)
|
||||
(forward-char -1)
|
||||
(setq sc (current-column))
|
||||
(point)))
|
||||
(ec (move-to-column endcol))
|
||||
(end (point))
|
||||
(ol (make-overlay start end)))
|
||||
(push ol (nthcdr 3 rectangle--string-preview-state))
|
||||
;; FIXME: The extra spacing doesn't interact correctly with
|
||||
;; the extra spacing added by the rectangular-region-highlight.
|
||||
(when (< sc startcol)
|
||||
(overlay-put ol 'before-string (rectangle--space-to startcol)))
|
||||
(let ((as (when (< endcol ec)
|
||||
;; (rectangle--space-to ec)
|
||||
(spaces-string (- ec endcol))
|
||||
)))
|
||||
(if (= start end)
|
||||
(overlay-put ol 'after-string (if as (concat str as) str))
|
||||
(overlay-put ol 'display str)
|
||||
(if as (overlay-put ol 'after-string as))))))
|
||||
(nth 1 rectangle--string-preview-state)
|
||||
(nth 2 rectangle--string-preview-state)))))))
|
||||
|
||||
;; FIXME: Should this be turned into inhibit-region-highlight and made to apply
|
||||
;; to non-rectangular regions as well?
|
||||
|
|
Loading…
Add table
Reference in a new issue