aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/emulation
diff options
context:
space:
mode:
authorKim F. Storm2004-09-02 22:56:22 +0000
committerKim F. Storm2004-09-02 22:56:22 +0000
commite2ea72e9dd38da3faac53ec969d2228624ddf024 (patch)
treed7384c8ec6d609bae4e56f827bc6957be795d997 /lisp/emulation
parent46540080eac5c7efa800b5646a4e0a2eea450c4f (diff)
downloademacs-e2ea72e9dd38da3faac53ec969d2228624ddf024.tar.gz
emacs-e2ea72e9dd38da3faac53ec969d2228624ddf024.zip
(cua--rectangle-set-corners): Ensure that
point is set (and displayed) inside rectangle. (cua--rectangle-operation): Fix for highlight of empty lines. (cua--highlight-rectangle): Fix highlight for tabs. Position cursor at left/right edge of rectangle using new `cursor' property on overlay strings. (cua--indent-rectangle): Don't tabify. (cua-rotate-rectangle): Ignore that point has moved.
Diffstat (limited to 'lisp/emulation')
-rw-r--r--lisp/emulation/cua-rect.el44
1 files changed, 30 insertions, 14 deletions
diff --git a/lisp/emulation/cua-rect.el b/lisp/emulation/cua-rect.el
index 626ef22cf2d..03bf28494c3 100644
--- a/lisp/emulation/cua-rect.el
+++ b/lisp/emulation/cua-rect.el
@@ -274,7 +274,11 @@ Knows about CUA rectangle highlighting in addition to standard undo."
274 (move-to-column mc) 274 (move-to-column mc)
275 (set-mark (point)) 275 (set-mark (point))
276 (goto-char pp) 276 (goto-char pp)
277 (move-to-column pc) 277 (if (and (if (cua--rectangle-right-side)
278 (= (move-to-column pc) (- pc tab-width))
279 (> (move-to-column pc) pc))
280 (not (bolp)))
281 (backward-char 1))
278 )) 282 ))
279 283
280;;; Rectangle resizing 284;;; Rectangle resizing
@@ -569,6 +573,8 @@ If command is repeated at same position, delete the rectangle."
569 (setq end (min (window-end) end))) 573 (setq end (min (window-end) end)))
570 (goto-char end) 574 (goto-char end)
571 (setq end (line-end-position)) 575 (setq end (line-end-position))
576 (if (and visible (bolp) (not (eobp)))
577 (setq end (1+ end)))
572 (goto-char start) 578 (goto-char start)
573 (setq start (line-beginning-position)) 579 (setq start (line-beginning-position))
574 (narrow-to-region start end) 580 (narrow-to-region start end)
@@ -761,7 +767,7 @@ If command is repeated at same position, delete the rectangle."
761 (cua--rectangle-operation nil t nil nil nil ; do not tabify 767 (cua--rectangle-operation nil t nil nil nil ; do not tabify
762 '(lambda (s e l r v) 768 '(lambda (s e l r v)
763 (let ((rface (if v 'cua-rectangle-face 'cua-rectangle-noselect-face)) 769 (let ((rface (if v 'cua-rectangle-face 'cua-rectangle-noselect-face))
764 overlay bs as) 770 overlay bs ms as)
765 (if (= s e) (setq e (1+ e))) 771 (if (= s e) (setq e (1+ e)))
766 (when (cua--rectangle-virtual-edges) 772 (when (cua--rectangle-virtual-edges)
767 (let ((lb (line-beginning-position)) 773 (let ((lb (line-beginning-position))
@@ -791,23 +797,31 @@ If command is repeated at same position, delete the rectangle."
791 (setq s (1- s)))) 797 (setq s (1- s))))
792 (cond 798 (cond
793 ((= cr r) 799 ((= cr r)
794 (if (and (/= cr0 (1- cr)) 800 (if (and (/= pr le)
795 (= (mod cr tab-width) 0)) 801 (/= cr0 (1- cr))
802 (or bs (/= cr0 (- cr tab-width)))
803 (/= (mod cr tab-width) 0))
796 (setq e (1- e)))) 804 (setq e (1- e))))
797 ((= cr cl) 805 ((= cr cl)
798 (setq bs (concat bs 806 (setq ms (propertize
799 (propertize 807 (make-string
800 (make-string 808 (- r l)
801 (- r l) 809 (if cua--virtual-edges-debug ?, ?\s))
802 (if cua--virtual-edges-debug ?, ?\s)) 810 'face rface))
803 'face rface))) 811 (if (cua--rectangle-right-side)
812 (put-text-property (1- (length ms)) (length ms) 'cursor t ms)
813 (put-text-property 0 1 'cursor t ms))
814 (setq bs (concat bs ms))
804 (setq rface nil)) 815 (setq rface nil))
805 (t 816 (t
806 (setq as (propertize 817 (setq as (propertize
807 (make-string 818 (make-string
808 (- r cr0 (if (= le pr) 1 0)) 819 (- r cr0 (if (= le pr) 1 0))
809 (if cua--virtual-edges-debug ?~ ?\s)) 820 (if cua--virtual-edges-debug ?~ ?\s))
810 'face rface)) 821 'face rface))
822 (if (cua--rectangle-right-side)
823 (put-text-property (1- (length as)) (length as) 'cursor t as)
824 (put-text-property 0 1 'cursor t as))
811 (if (/= pr le) 825 (if (/= pr le)
812 (setq e (1- e)))))))) 826 (setq e (1- e))))))))
813 ;; Trim old leading overlays. 827 ;; Trim old leading overlays.
@@ -826,7 +840,7 @@ If command is repeated at same position, delete the rectangle."
826 (move-overlay overlay s e) 840 (move-overlay overlay s e)
827 (setq old (cdr old))) 841 (setq old (cdr old)))
828 (setq overlay (make-overlay s e))) 842 (setq overlay (make-overlay s e)))
829 (overlay-put overlay 'before-string bs) 843 (overlay-put overlay 'before-string bs)
830 (overlay-put overlay 'after-string as) 844 (overlay-put overlay 'after-string as)
831 (overlay-put overlay 'face rface) 845 (overlay-put overlay 'face rface)
832 (setq new (cons overlay new)))))) 846 (setq new (cons overlay new))))))
@@ -839,7 +853,7 @@ If command is repeated at same position, delete the rectangle."
839 (let ((col (cua--rectangle-insert-col)) 853 (let ((col (cua--rectangle-insert-col))
840 (pad (cua--rectangle-virtual-edges)) 854 (pad (cua--rectangle-virtual-edges))
841 indent) 855 indent)
842 (cua--rectangle-operation (if clear 'clear 'corners) nil t pad t 856 (cua--rectangle-operation (if clear 'clear 'corners) nil t pad nil
843 '(lambda (s e l r) 857 '(lambda (s e l r)
844 (move-to-column col pad) 858 (move-to-column col pad)
845 (if (and (eolp) 859 (if (and (eolp)
@@ -975,7 +989,9 @@ With prefix argument, the toggle restriction."
975(defun cua-rotate-rectangle () 989(defun cua-rotate-rectangle ()
976 (interactive) 990 (interactive)
977 (cua--rectangle-corner (if (= (cua--rectangle-left) (cua--rectangle-right)) 0 1)) 991 (cua--rectangle-corner (if (= (cua--rectangle-left) (cua--rectangle-right)) 0 1))
978 (cua--rectangle-set-corners)) 992 (cua--rectangle-set-corners)
993 (if (cua--rectangle-virtual-edges)
994 (setq cua--buffer-and-point-before-command nil)))
979 995
980(defun cua-toggle-rectangle-virtual-edges () 996(defun cua-toggle-rectangle-virtual-edges ()
981 (interactive) 997 (interactive)