aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/emulation
diff options
context:
space:
mode:
authorStefan Monnier2013-12-15 21:24:08 -0500
committerStefan Monnier2013-12-15 21:24:08 -0500
commit2013a2f955e4dc6edf9869767e9f5d70fbf9d69c (patch)
treed641c6fe8fc0b763645a5447f1fda75987cc4ac0 /lisp/emulation
parentdb50ad5f11cc5809c27091181a13ee7aa34ec5ed (diff)
downloademacs-2013a2f955e4dc6edf9869767e9f5d70fbf9d69c.tar.gz
emacs-2013a2f955e4dc6edf9869767e9f5d70fbf9d69c.zip
* lisp/emulation/cua-rect.el (cua-rectangle-mark-mode): New minor mode.
(cua--deactivate-rectangle): Don't deactivate the mark. (cua-set-rectangle-mark): Don't set mark-active since cua--activate-rectangle already does it for us. (cua--rectangle-highlight-for-redisplay): Unhighlight a previous non-rectangular region. * lisp/emulation/cua-base.el (cua-repeat-replace-region): Use with-current-buffer. * lisp/net/gnutls.el: Use cl-lib. (gnutls-negotiate): `mapcan' -> cl-mapcan.
Diffstat (limited to 'lisp/emulation')
-rw-r--r--lisp/emulation/cua-base.el3
-rw-r--r--lisp/emulation/cua-rect.el30
2 files changed, 24 insertions, 9 deletions
diff --git a/lisp/emulation/cua-base.el b/lisp/emulation/cua-base.el
index 24149a33c89..4a158087d12 100644
--- a/lisp/emulation/cua-base.el
+++ b/lisp/emulation/cua-base.el
@@ -971,9 +971,8 @@ replaced by typing text over it and replaces it with the same stretch
971of text." 971of text."
972 (interactive "P") 972 (interactive "P")
973 (when cua--last-deleted-region-pos 973 (when cua--last-deleted-region-pos
974 (save-excursion 974 (with-current-buffer (car cua--last-deleted-region-pos)
975 (save-restriction 975 (save-restriction
976 (set-buffer (car cua--last-deleted-region-pos))
977 (widen) 976 (widen)
978 ;; Find the text that replaced the region via the undo list. 977 ;; Find the text that replaced the region via the undo list.
979 (let ((ul buffer-undo-list) 978 (let ((ul buffer-undo-list)
diff --git a/lisp/emulation/cua-rect.el b/lisp/emulation/cua-rect.el
index 71578031cba..4e0782c870b 100644
--- a/lisp/emulation/cua-rect.el
+++ b/lisp/emulation/cua-rect.el
@@ -78,7 +78,7 @@
78 (push (list 'apply 0 s e 78 (push (list 'apply 0 s e
79 'cua--rect-undo-handler 79 'cua--rect-undo-handler
80 (copy-sequence cua--rectangle) t s e) 80 (copy-sequence cua--rectangle) t s e)
81 buffer-undo-list)))) 81 buffer-undo-list))))
82 82
83(defun cua--rect-undo-handler (rect on s e) 83(defun cua--rect-undo-handler (rect on s e)
84 (if (setq on (not on)) 84 (if (setq on (not on))
@@ -89,6 +89,21 @@
89 'cua--rect-undo-handler rect on s e) 89 'cua--rect-undo-handler rect on s e)
90 buffer-undo-list)) 90 buffer-undo-list))
91 91
92;;;###autoload
93(define-minor-mode cua-rectangle-mark-mode
94 "Toggle the region as rectangular.
95Activates the region if needed. Only lasts until the region is deactivated."
96 :keymap cua--rectangle-keymap
97 (cond
98 (cua-rectangle-mark-mode
99 (add-hook 'deactivate-mark-hook
100 (lambda () (cua-rectangle-mark-mode -1)))
101 (add-hook 'post-command-hook #'cua--rectangle-post-command nil t)
102 (cua-set-rectangle-mark))
103 (t
104 (cua--deactivate-rectangle)
105 (remove-hook 'post-command-hook #'cua--rectangle-post-command t))))
106
92;;; Rectangle geometry 107;;; Rectangle geometry
93 108
94(defun cua--rectangle-top (&optional val) 109(defun cua--rectangle-top (&optional val)
@@ -708,8 +723,7 @@ If command is repeated at same position, delete the rectangle."
708 killed-rectangle ""))))) 723 killed-rectangle "")))))
709 724
710(defun cua--activate-rectangle () 725(defun cua--activate-rectangle ()
711 ;; Turn on rectangular marking mode by disabling transient mark mode 726 ;; Set cua--rectangle to indicate we're marking a rectangle.
712 ;; and manually handling highlighting from a post command hook.
713 ;; Be careful if we are already marking a rectangle. 727 ;; Be careful if we are already marking a rectangle.
714 (setq cua--rectangle 728 (setq cua--rectangle
715 (if (and cua--last-rectangle 729 (if (and cua--last-rectangle
@@ -725,7 +739,7 @@ If command is repeated at same position, delete the rectangle."
725 739
726(defun cua--deactivate-rectangle () 740(defun cua--deactivate-rectangle ()
727 ;; This is used to clean up after `cua--activate-rectangle'. 741 ;; This is used to clean up after `cua--activate-rectangle'.
728 (mapc (function delete-overlay) cua--rectangle-overlays) 742 (mapc #'delete-overlay cua--rectangle-overlays)
729 (setq cua--last-rectangle (cons (current-buffer) 743 (setq cua--last-rectangle (cons (current-buffer)
730 (cons (point) ;; cua-save-point 744 (cons (point) ;; cua-save-point
731 cua--rectangle)) 745 cua--rectangle))
@@ -733,7 +747,10 @@ If command is repeated at same position, delete the rectangle."
733 cua--rectangle-overlays nil 747 cua--rectangle-overlays nil
734 cua--status-string nil 748 cua--status-string nil
735 cua--mouse-last-pos nil) 749 cua--mouse-last-pos nil)
736 (deactivate-mark)) 750 ;; FIXME: This call to cua-rectangle-mark-mode is a workaround.
751 ;; Deactivation can happen in various different ways, and we
752 ;; currently don't handle them all in a coherent way.
753 (if cua-rectangle-mark-mode (cua-rectangle-mark-mode -1)))
737 754
738(defun cua--highlight-rectangle () 755(defun cua--highlight-rectangle ()
739 ;; This function is used to highlight the rectangular region. 756 ;; This function is used to highlight the rectangular region.
@@ -879,7 +896,6 @@ With prefix argument, activate previous rectangle if possible."
879 (push-mark nil nil t))) 896 (push-mark nil nil t)))
880 (cua--activate-rectangle) 897 (cua--activate-rectangle)
881 (cua--rectangle-set-corners) 898 (cua--rectangle-set-corners)
882 (setq mark-active t)
883 (if cua-enable-rectangle-auto-help 899 (if cua-enable-rectangle-auto-help
884 (cua-help-for-rectangle t)))) 900 (cua-help-for-rectangle t))))
885 901
@@ -1385,7 +1401,7 @@ With prefix arg, indent to that column."
1385 (if (not cua--rectangle) (apply orig args) 1401 (if (not cua--rectangle) (apply orig args)
1386 ;; When cua--rectangle is active, just don't highlight at all, since we 1402 ;; When cua--rectangle is active, just don't highlight at all, since we
1387 ;; already do it elsewhere. 1403 ;; already do it elsewhere.
1388 )) 1404 (funcall redisplay-unhighlight-region-function (nth 3 args))))
1389 1405
1390(defun cua--rectangle-region-extract (orig &optional delete) 1406(defun cua--rectangle-region-extract (orig &optional delete)
1391 (cond 1407 (cond