Mercurial > emacs
annotate lisp/emulation/cua-rect.el @ 110263:280c5216180d
Make sure original ispell arg list is initialized in (ispell-start-process).
* textmodes/ispell.el (ispell-start-process): Make sure original
arg list is properly initialized (Bug#6993, Bug#6994).
author | Agustin martin <agustin.martin@hispalinux.es> |
---|---|
date | Tue, 07 Sep 2010 20:01:23 +0200 |
parents | 280c8ae2476d |
children | 417b1e4d63cd |
rev | line source |
---|---|
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1 ;;; cua-rect.el --- CUA unified rectangle support |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
2 |
64701
34bd8e434dd7
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
3 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, |
106815 | 4 ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
5 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
6 ;; Author: Kim F. Storm <storm@cua.dk> |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
7 ;; Keywords: keyboard emulations convenience CUA |
110015
280c8ae2476d
Add "Package:" file headers to denote built-in packages.
Chong Yidong <cyd@stupidchicken.com>
parents:
108946
diff
changeset
|
8 ;; Package: cua-base |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
9 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
10 ;; This file is part of GNU Emacs. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
11 |
94658
eb7b2376cae5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
12 ;; GNU Emacs is free software: you can redistribute it and/or modify |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
13 ;; it under the terms of the GNU General Public License as published by |
94658
eb7b2376cae5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
14 ;; the Free Software Foundation, either version 3 of the License, or |
eb7b2376cae5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
15 ;; (at your option) any later version. |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
16 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
17 ;; GNU Emacs is distributed in the hope that it will be useful, |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
20 ;; GNU General Public License for more details. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
21 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
22 ;; You should have received a copy of the GNU General Public License |
94658
eb7b2376cae5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
24 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
25 ;;; Acknowledgements |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
26 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
27 ;; The rectangle handling and display code borrows from the standard |
45318 | 28 ;; GNU emacs rect.el package and the rect-mark.el package by Rick |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
29 ;; Sladkey <jrs@world.std.com>. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
30 |
45078 | 31 ;;; Commentary: |
32 | |
33 ;;; Code: | |
34 | |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
35 (eval-when-compile |
87020
52abd10af81e
(top-level): Move provide to end.
Glenn Morris <rgm@gnu.org>
parents:
84905
diff
changeset
|
36 (require 'cua-base)) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
37 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
38 ;;; Rectangle support |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
39 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
40 (require 'rect) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
41 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
42 ;; If non-nil, restrict current region to this rectangle. |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
43 ;; Value is a vector [top bot left right corner ins virt select]. |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
44 ;; CORNER specifies currently active corner 0=t/l 1=t/r 2=b/l 3=b/r. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
45 ;; INS specifies whether to insert on left(nil) or right(t) side. |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
46 ;; If VIRT is non-nil, virtual straight edges are enabled. |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
47 ;; If SELECT is a regexp, only lines starting with that regexp are affected.") |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
48 (defvar cua--rectangle nil) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
49 (make-variable-buffer-local 'cua--rectangle) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
50 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
51 ;; Most recent rectangle geometry. Note: car is buffer. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
52 (defvar cua--last-rectangle nil) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
53 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
54 ;; Rectangle restored by undo. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
55 (defvar cua--restored-rectangle nil) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
56 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
57 ;; Last rectangle copied/killed; nil if last kill was not a rectangle. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
58 (defvar cua--last-killed-rectangle nil) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
59 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
60 ;; List of overlays used to display current rectangle. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
61 (defvar cua--rectangle-overlays nil) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
62 (make-variable-buffer-local 'cua--rectangle-overlays) |
67214
4fd503f32b2c
(cua--rectangle-overlays): Make permanent-local.
Kim F. Storm <storm@cua.dk>
parents:
67143
diff
changeset
|
63 (put 'cua--rectangle-overlays 'permanent-local t) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
64 |
56902
8d62e1b62c44
* emulation/cua-rect.el (cua--overlay-keymap): New keymap for
Kim F. Storm <storm@cua.dk>
parents:
56896
diff
changeset
|
65 (defvar cua--overlay-keymap |
8d62e1b62c44
* emulation/cua-rect.el (cua--overlay-keymap): New keymap for
Kim F. Storm <storm@cua.dk>
parents:
56896
diff
changeset
|
66 (let ((map (make-sparse-keymap))) |
8d62e1b62c44
* emulation/cua-rect.el (cua--overlay-keymap): New keymap for
Kim F. Storm <storm@cua.dk>
parents:
56896
diff
changeset
|
67 (define-key map "\r" 'cua-rotate-rectangle))) |
8d62e1b62c44
* emulation/cua-rect.el (cua--overlay-keymap): New keymap for
Kim F. Storm <storm@cua.dk>
parents:
56896
diff
changeset
|
68 |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
69 (defvar cua--virtual-edges-debug nil) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
70 |
59973
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
71 ;; Undo rectangle commands. |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
72 |
59973
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
73 (defvar cua--rect-undo-set-point nil) |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
74 |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
75 (defun cua--rectangle-undo-boundary () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
76 (when (listp buffer-undo-list) |
59973
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
77 (let ((s (cua--rect-start-position)) |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
78 (e (cua--rect-end-position))) |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
79 (undo-boundary) |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
80 (push (list 'apply 0 s e |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
81 'cua--rect-undo-handler |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
82 (copy-sequence cua--rectangle) t s e) |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
83 buffer-undo-list)))) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
84 |
59973
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
85 (defun cua--rect-undo-handler (rect on s e) |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
86 (if (setq on (not on)) |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
87 (setq cua--rect-undo-set-point s) |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
88 (setq cua--restored-rectangle (copy-sequence rect)) |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
89 (setq cua--buffer-and-point-before-command nil)) |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
90 (push (list 'apply 0 s (if on e s) |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
91 'cua--rect-undo-handler rect on s e) |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
92 buffer-undo-list)) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
93 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
94 ;;; Rectangle geometry |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
95 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
96 (defun cua--rectangle-top (&optional val) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
97 ;; Top of CUA rectangle (buffer position on first line). |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
98 (if (not val) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
99 (aref cua--rectangle 0) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
100 (setq val (line-beginning-position)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
101 (if (<= val (aref cua--rectangle 1)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
102 (aset cua--rectangle 0 val) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
103 (aset cua--rectangle 1 val) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
104 (cua--rectangle-corner 2)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
105 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
106 (defun cua--rectangle-bot (&optional val) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
107 ;; Bot of CUA rectangle (buffer position on last line). |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
108 (if (not val) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
109 (aref cua--rectangle 1) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
110 (setq val (line-end-position)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
111 (if (>= val (aref cua--rectangle 0)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
112 (aset cua--rectangle 1 val) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
113 (aset cua--rectangle 0 val) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
114 (cua--rectangle-corner 2)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
115 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
116 (defun cua--rectangle-left (&optional val) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
117 ;; Left column of CUA rectangle. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
118 (if (integerp val) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
119 (if (<= val (aref cua--rectangle 3)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
120 (aset cua--rectangle 2 val) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
121 (aset cua--rectangle 3 val) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
122 (cua--rectangle-corner (if (cua--rectangle-right-side) -1 1))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
123 (aref cua--rectangle 2))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
124 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
125 (defun cua--rectangle-right (&optional val) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
126 ;; Right column of CUA rectangle. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
127 (if (integerp val) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
128 (if (>= val (aref cua--rectangle 2)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
129 (aset cua--rectangle 3 val) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
130 (aset cua--rectangle 2 val) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
131 (cua--rectangle-corner (if (cua--rectangle-right-side) -1 1))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
132 (aref cua--rectangle 3))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
133 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
134 (defun cua--rectangle-corner (&optional advance) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
135 ;; Currently active corner of rectangle. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
136 (let ((c (aref cua--rectangle 4))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
137 (if (not (integerp advance)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
138 c |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46180
diff
changeset
|
139 (aset cua--rectangle 4 |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
140 (if (= advance 0) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
141 (- 3 c) ; opposite corner |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
142 (mod (+ c 4 advance) 4))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
143 (aset cua--rectangle 5 0)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
144 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
145 (defun cua--rectangle-right-side (&optional topbot) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
146 ;; t if point is on right side of rectangle. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
147 (if (and topbot (= (cua--rectangle-left) (cua--rectangle-right))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
148 (< (cua--rectangle-corner) 2) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
149 (= (mod (cua--rectangle-corner) 2) 1))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
150 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
151 (defun cua--rectangle-column () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
152 (if (cua--rectangle-right-side) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
153 (cua--rectangle-right) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
154 (cua--rectangle-left))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
155 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
156 (defun cua--rectangle-insert-col (&optional col) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
157 ;; Currently active corner of rectangle. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
158 (if (integerp col) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
159 (aset cua--rectangle 5 col) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
160 (if (cua--rectangle-right-side t) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
161 (if (= (aref cua--rectangle 5) 0) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
162 (1+ (cua--rectangle-right)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
163 (aref cua--rectangle 5)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
164 (cua--rectangle-left)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
165 |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
166 (defun cua--rectangle-virtual-edges (&optional set val) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
167 ;; Current setting of rectangle virtual-edges |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
168 (if set |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
169 (aset cua--rectangle 6 val)) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
170 (and ;(not buffer-read-only) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
171 (aref cua--rectangle 6))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
172 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
173 (defun cua--rectangle-restriction (&optional val bounded negated) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
174 ;; Current rectangle restriction |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
175 (if val |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
176 (aset cua--rectangle 7 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
177 (and (stringp val) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
178 (> (length val) 0) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
179 (list val bounded negated))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
180 (aref cua--rectangle 7))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
181 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
182 (defun cua--rectangle-assert () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
183 (message "%S (%d)" cua--rectangle (point)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
184 (if (< (cua--rectangle-right) (cua--rectangle-left)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
185 (message "rectangle right < left")) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
186 (if (< (cua--rectangle-bot) (cua--rectangle-top)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
187 (message "rectangle bot < top"))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
188 |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
189 (defun cua--rectangle-get-corners () |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
190 ;; Calculate the rectangular region represented by point and mark, |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
191 ;; putting start in the upper left corner and end in the |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
192 ;; bottom right corner. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
193 (let ((top (point)) (bot (mark)) r l corner) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
194 (save-excursion |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
195 (goto-char top) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
196 (setq l (current-column)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
197 (goto-char bot) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
198 (setq r (current-column)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
199 (if (<= top bot) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
200 (setq corner (if (<= l r) 0 1)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
201 (setq top (prog1 bot (setq bot top))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
202 (setq corner (if (<= l r) 2 3))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
203 (if (<= l r) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
204 (if (< l r) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
205 (setq r (1- r))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
206 (setq l (prog1 r (setq r l))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
207 (goto-char top) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
208 (move-to-column l) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
209 (setq top (point)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
210 (goto-char bot) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
211 (move-to-column r) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
212 (setq bot (point)))) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
213 (vector top bot l r corner 0 cua-virtual-rectangle-edges nil))) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
214 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
215 (defun cua--rectangle-set-corners () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
216 ;; Set mark and point in opposite corners of current rectangle. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
217 (let (pp pc mp mc (c (cua--rectangle-corner))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
218 (cond |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
219 ((= c 0) ; top/left -> bot/right |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
220 (setq pp (cua--rectangle-top) pc (cua--rectangle-left) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
221 mp (cua--rectangle-bot) mc (cua--rectangle-right))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
222 ((= c 1) ; top/right -> bot/left |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
223 (setq pp (cua--rectangle-top) pc (cua--rectangle-right) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
224 mp (cua--rectangle-bot) mc (cua--rectangle-left))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
225 ((= c 2) ; bot/left -> top/right |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
226 (setq pp (cua--rectangle-bot) pc (cua--rectangle-left) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
227 mp (cua--rectangle-top) mc (cua--rectangle-right))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
228 ((= c 3) ; bot/right -> top/left |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
229 (setq pp (cua--rectangle-bot) pc (cua--rectangle-right) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
230 mp (cua--rectangle-top) mc (cua--rectangle-left)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
231 (goto-char mp) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
232 (move-to-column mc) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
233 (set-mark (point)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
234 (goto-char pp) |
108933 | 235 ;; Move cursor inside rectangle, except if char at right edge is a tab. |
56896
77bbb90bd021
(cua--rectangle-set-corners): Ensure that
Kim F. Storm <storm@cua.dk>
parents:
56838
diff
changeset
|
236 (if (and (if (cua--rectangle-right-side) |
56902
8d62e1b62c44
* emulation/cua-rect.el (cua--overlay-keymap): New keymap for
Kim F. Storm <storm@cua.dk>
parents:
56896
diff
changeset
|
237 (and (= (move-to-column pc) (- pc tab-width)) |
8d62e1b62c44
* emulation/cua-rect.el (cua--overlay-keymap): New keymap for
Kim F. Storm <storm@cua.dk>
parents:
56896
diff
changeset
|
238 (not (eolp))) |
56896
77bbb90bd021
(cua--rectangle-set-corners): Ensure that
Kim F. Storm <storm@cua.dk>
parents:
56838
diff
changeset
|
239 (> (move-to-column pc) pc)) |
77bbb90bd021
(cua--rectangle-set-corners): Ensure that
Kim F. Storm <storm@cua.dk>
parents:
56838
diff
changeset
|
240 (not (bolp))) |
77bbb90bd021
(cua--rectangle-set-corners): Ensure that
Kim F. Storm <storm@cua.dk>
parents:
56838
diff
changeset
|
241 (backward-char 1)) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
242 )) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
243 |
59973
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
244 (defun cua--rect-start-position () |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
245 ;; Return point of top left corner |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
246 (save-excursion |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
247 (goto-char (cua--rectangle-top)) |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
248 (and (> (move-to-column (cua--rectangle-left)) |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
249 (cua--rectangle-left)) |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
250 (not (bolp)) |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
251 (backward-char 1)) |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
252 (point))) |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
253 |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
254 (defun cua--rect-end-position () |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
255 ;; Return point of bottom right cornet |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
256 (save-excursion |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
257 (goto-char (cua--rectangle-bot)) |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
258 (and (= (move-to-column (cua--rectangle-right)) |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
259 (- (cua--rectangle-right) tab-width)) |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
260 (not (eolp)) |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
261 (not (bolp)) |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
262 (backward-char 1)) |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
263 (point))) |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
264 |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
265 ;;; Rectangle resizing |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
266 |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
267 (defun cua--forward-line (n) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
268 ;; Move forward/backward one line. Returns t if movement. |
56902
8d62e1b62c44
* emulation/cua-rect.el (cua--overlay-keymap): New keymap for
Kim F. Storm <storm@cua.dk>
parents:
56896
diff
changeset
|
269 (let ((pt (point))) |
8d62e1b62c44
* emulation/cua-rect.el (cua--overlay-keymap): New keymap for
Kim F. Storm <storm@cua.dk>
parents:
56896
diff
changeset
|
270 (and (= (forward-line n) 0) |
8d62e1b62c44
* emulation/cua-rect.el (cua--overlay-keymap): New keymap for
Kim F. Storm <storm@cua.dk>
parents:
56896
diff
changeset
|
271 ;; Deal with end of buffer |
8d62e1b62c44
* emulation/cua-rect.el (cua--overlay-keymap): New keymap for
Kim F. Storm <storm@cua.dk>
parents:
56896
diff
changeset
|
272 (or (not (eobp)) |
8d62e1b62c44
* emulation/cua-rect.el (cua--overlay-keymap): New keymap for
Kim F. Storm <storm@cua.dk>
parents:
56896
diff
changeset
|
273 (goto-char pt))))) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
274 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
275 (defun cua--rectangle-resized () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
276 ;; Refresh state after resizing rectangle |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
277 (setq cua--buffer-and-point-before-command nil) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
278 (cua--rectangle-insert-col 0) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
279 (cua--rectangle-set-corners) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
280 (cua--keep-active)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
281 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
282 (defun cua-resize-rectangle-right (n) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
283 "Resize rectangle to the right." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
284 (interactive "p") |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
285 (let ((resized (> n 0))) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
286 (while (> n 0) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
287 (setq n (1- n)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
288 (cond |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
289 ((cua--rectangle-right-side) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
290 (cua--rectangle-right (1+ (cua--rectangle-right))) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
291 (move-to-column (cua--rectangle-right))) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
292 (t |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
293 (cua--rectangle-left (1+ (cua--rectangle-left))) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
294 (move-to-column (cua--rectangle-right))))) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
295 (if resized |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
296 (cua--rectangle-resized)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
297 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
298 (defun cua-resize-rectangle-left (n) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
299 "Resize rectangle to the left." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
300 (interactive "p") |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
301 (let (resized) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
302 (while (> n 0) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
303 (setq n (1- n)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
304 (if (or (= (cua--rectangle-right) 0) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
305 (and (not (cua--rectangle-right-side)) (= (cua--rectangle-left) 0))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
306 (setq n 0) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
307 (cond |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
308 ((cua--rectangle-right-side) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
309 (cua--rectangle-right (1- (cua--rectangle-right))) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
310 (move-to-column (cua--rectangle-right))) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
311 (t |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
312 (cua--rectangle-left (1- (cua--rectangle-left))) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
313 (move-to-column (cua--rectangle-right)))) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
314 (setq resized t))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
315 (if resized |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
316 (cua--rectangle-resized)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
317 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
318 (defun cua-resize-rectangle-down (n) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
319 "Resize rectangle downwards." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
320 (interactive "p") |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
321 (let (resized) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
322 (while (> n 0) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
323 (setq n (1- n)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
324 (cond |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
325 ((>= (cua--rectangle-corner) 2) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
326 (goto-char (cua--rectangle-bot)) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
327 (when (cua--forward-line 1) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
328 (move-to-column (cua--rectangle-column)) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
329 (cua--rectangle-bot t) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
330 (setq resized t))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
331 (t |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
332 (goto-char (cua--rectangle-top)) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
333 (when (cua--forward-line 1) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
334 (move-to-column (cua--rectangle-column)) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
335 (cua--rectangle-top t) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
336 (setq resized t))))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
337 (if resized |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
338 (cua--rectangle-resized)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
339 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
340 (defun cua-resize-rectangle-up (n) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
341 "Resize rectangle upwards." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
342 (interactive "p") |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
343 (let (resized) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
344 (while (> n 0) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
345 (setq n (1- n)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
346 (cond |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
347 ((>= (cua--rectangle-corner) 2) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
348 (goto-char (cua--rectangle-bot)) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
349 (when (cua--forward-line -1) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
350 (move-to-column (cua--rectangle-column)) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
351 (cua--rectangle-bot t) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
352 (setq resized t))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
353 (t |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
354 (goto-char (cua--rectangle-top)) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
355 (when (cua--forward-line -1) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
356 (move-to-column (cua--rectangle-column)) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
357 (cua--rectangle-top t) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
358 (setq resized t))))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
359 (if resized |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
360 (cua--rectangle-resized)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
361 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
362 (defun cua-resize-rectangle-eol () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
363 "Resize rectangle to end of line." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
364 (interactive) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
365 (unless (eolp) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
366 (end-of-line) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
367 (if (> (current-column) (cua--rectangle-right)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
368 (cua--rectangle-right (current-column))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
369 (if (not (cua--rectangle-right-side)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
370 (cua--rectangle-corner 1)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
371 (cua--rectangle-resized))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
372 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
373 (defun cua-resize-rectangle-bol () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
374 "Resize rectangle to beginning of line." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
375 (interactive) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
376 (unless (bolp) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
377 (beginning-of-line) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
378 (cua--rectangle-left (current-column)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
379 (if (cua--rectangle-right-side) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
380 (cua--rectangle-corner -1)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
381 (cua--rectangle-resized))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
382 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
383 (defun cua-resize-rectangle-bot () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
384 "Resize rectangle to bottom of buffer." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
385 (interactive) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
386 (goto-char (point-max)) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
387 (move-to-column (cua--rectangle-column)) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
388 (cua--rectangle-bot t) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
389 (cua--rectangle-resized)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
390 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
391 (defun cua-resize-rectangle-top () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
392 "Resize rectangle to top of buffer." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
393 (interactive) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
394 (goto-char (point-min)) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
395 (move-to-column (cua--rectangle-column)) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
396 (cua--rectangle-top t) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
397 (cua--rectangle-resized)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
398 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
399 (defun cua-resize-rectangle-page-up () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
400 "Resize rectangle upwards by one scroll page." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
401 (interactive) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
402 (scroll-down) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
403 (move-to-column (cua--rectangle-column)) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
404 (if (>= (cua--rectangle-corner) 2) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
405 (cua--rectangle-bot t) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
406 (cua--rectangle-top t)) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
407 (cua--rectangle-resized)) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
408 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
409 (defun cua-resize-rectangle-page-down () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
410 "Resize rectangle downwards by one scroll page." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
411 (interactive) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
412 (scroll-up) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
413 (move-to-column (cua--rectangle-column)) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
414 (if (>= (cua--rectangle-corner) 2) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
415 (cua--rectangle-bot t) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
416 (cua--rectangle-top t)) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
417 (cua--rectangle-resized)) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
418 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
419 ;;; Mouse support |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
420 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
421 ;; This is pretty simplistic, but it does the job... |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
422 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
423 (defun cua-mouse-resize-rectangle (event) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
424 "Set rectangle corner at mouse click position." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
425 (interactive "e") |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
426 (mouse-set-point event) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
427 ;; FIX ME -- need to calculate virtual column. |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
428 (if (cua--rectangle-virtual-edges) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
429 (move-to-column (car (posn-col-row (event-end event))) t)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
430 (if (cua--rectangle-right-side) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
431 (cua--rectangle-right (current-column)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
432 (cua--rectangle-left (current-column))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
433 (if (>= (cua--rectangle-corner) 2) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
434 (cua--rectangle-bot t) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
435 (cua--rectangle-top t)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
436 (cua--rectangle-resized)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
437 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
438 (defvar cua--mouse-last-pos nil) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
439 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
440 (defun cua-mouse-set-rectangle-mark (event) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
441 "Start rectangle at mouse click position." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
442 (interactive "e") |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
443 (when cua--rectangle |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
444 (cua--deactivate-rectangle) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
445 (cua--deactivate t)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
446 (setq cua--last-rectangle nil) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
447 (mouse-set-point event) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
448 ;; FIX ME -- need to calculate virtual column. |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
449 (cua-set-rectangle-mark) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
450 (setq cua--buffer-and-point-before-command nil) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
451 (setq cua--mouse-last-pos nil)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
452 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
453 (defun cua-mouse-save-then-kill-rectangle (event arg) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
454 "Expand rectangle to mouse click position and copy rectangle. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
455 If command is repeated at same position, delete the rectangle." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
456 (interactive "e\nP") |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
457 (if (and (eq this-command last-command) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
458 (eq (point) (car-safe cua--mouse-last-pos)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
459 (eq cua--last-killed-rectangle (cdr-safe cua--mouse-last-pos))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
460 (progn |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
461 (unless buffer-read-only |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
462 (cua--delete-rectangle)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
463 (cua--deactivate)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
464 (cua-mouse-resize-rectangle event) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
465 (let ((cua-keep-region-after-copy t)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
466 (cua-copy-rectangle arg) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
467 (setq cua--mouse-last-pos (cons (point) cua--last-killed-rectangle))))) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
468 |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
469 (defun cua--mouse-ignore (event) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
470 (interactive "e") |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
471 (setq this-command last-command)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
472 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
473 (defun cua--rectangle-move (dir) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
474 (let ((moved t) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
475 (top (cua--rectangle-top)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
476 (bot (cua--rectangle-bot)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
477 (l (cua--rectangle-left)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
478 (r (cua--rectangle-right))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
479 (cond |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
480 ((eq dir 'up) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
481 (goto-char top) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
482 (when (cua--forward-line -1) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
483 (cua--rectangle-top t) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
484 (goto-char bot) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
485 (forward-line -1) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
486 (cua--rectangle-bot t))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
487 ((eq dir 'down) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
488 (goto-char bot) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
489 (when (cua--forward-line 1) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
490 (cua--rectangle-bot t) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
491 (goto-char top) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
492 (cua--forward-line 1) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
493 (cua--rectangle-top t))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
494 ((eq dir 'left) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
495 (when (> l 0) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
496 (cua--rectangle-left (1- l)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
497 (cua--rectangle-right (1- r)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
498 ((eq dir 'right) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
499 (cua--rectangle-right (1+ r)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
500 (cua--rectangle-left (1+ l))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
501 (t |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
502 (setq moved nil))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
503 (when moved |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
504 (setq cua--buffer-and-point-before-command nil) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
505 (cua--rectangle-set-corners) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
506 (cua--keep-active)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
507 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
508 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
509 ;;; Operations on current rectangle |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
510 |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
511 (defun cua--tabify-start (start end) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
512 ;; Return position where auto-tabify should start (or nil if not required). |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
513 (save-excursion |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
514 (save-restriction |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
515 (widen) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
516 (and (not buffer-read-only) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
517 cua-auto-tabify-rectangles |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
518 (if (or (not (integerp cua-auto-tabify-rectangles)) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
519 (= (point-min) (point-max)) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
520 (progn |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
521 (goto-char (max (point-min) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
522 (- start cua-auto-tabify-rectangles))) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
523 (search-forward "\t" (min (point-max) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
524 (+ end cua-auto-tabify-rectangles)) t))) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
525 start))))) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
526 |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
527 (defun cua--rectangle-operation (keep-clear visible undo pad tabify &optional fct post-fct) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
528 ;; Call FCT for each line of region with 4 parameters: |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
529 ;; Region start, end, left-col, right-col |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
530 ;; Point is at start when FCT is called |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
531 ;; Call fct with (s,e) = whole lines if VISIBLE non-nil. |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
532 ;; Only call fct for visible lines if VISIBLE==t. |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
533 ;; Set undo boundary if UNDO is non-nil. |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
534 ;; Rectangle is padded if PAD = t or numeric and (cua--rectangle-virtual-edges) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
535 ;; Perform auto-tabify after operation if TABIFY is non-nil. |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
536 ;; Mark is kept if keep-clear is 'keep and cleared if keep-clear is 'clear. |
57075
57f225a13a09
(cua--rectangle-operation): Let bind
Kim F. Storm <storm@cua.dk>
parents:
57011
diff
changeset
|
537 (let* ((inhibit-field-text-motion t) |
57f225a13a09
(cua--rectangle-operation): Let bind
Kim F. Storm <storm@cua.dk>
parents:
57011
diff
changeset
|
538 (start (cua--rectangle-top)) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
539 (end (cua--rectangle-bot)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
540 (l (cua--rectangle-left)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
541 (r (1+ (cua--rectangle-right))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
542 (m (make-marker)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
543 (tabpad (and (integerp pad) (= pad 2))) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
544 (sel (cua--rectangle-restriction)) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
545 (tabify-start (and tabify (cua--tabify-start start end)))) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
546 (if undo |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
547 (cua--rectangle-undo-boundary)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
548 (if (integerp pad) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
549 (setq pad (cua--rectangle-virtual-edges))) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
550 (save-excursion |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
551 (save-restriction |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
552 (widen) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
553 (when (> (cua--rectangle-corner) 1) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
554 (goto-char end) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
555 (and (bolp) (not (eolp)) (not (eobp)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
556 (setq end (1+ end)))) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
557 (when (eq visible t) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
558 (setq start (max (window-start) start)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
559 (setq end (min (window-end) end))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
560 (goto-char end) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
561 (setq end (line-end-position)) |
56896
77bbb90bd021
(cua--rectangle-set-corners): Ensure that
Kim F. Storm <storm@cua.dk>
parents:
56838
diff
changeset
|
562 (if (and visible (bolp) (not (eobp))) |
77bbb90bd021
(cua--rectangle-set-corners): Ensure that
Kim F. Storm <storm@cua.dk>
parents:
56838
diff
changeset
|
563 (setq end (1+ end))) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
564 (goto-char start) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
565 (setq start (line-beginning-position)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
566 (narrow-to-region start end) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
567 (goto-char (point-min)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
568 (while (< (point) (point-max)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
569 (move-to-column r pad) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
570 (and (not pad) (not visible) (> (current-column) r) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
571 (backward-char 1)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
572 (if (and tabpad (not pad) (looking-at "\t")) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
573 (forward-char 1)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
574 (set-marker m (point)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
575 (move-to-column l pad) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
576 (if (and fct (or visible (and (>= (current-column) l) (<= (current-column) r)))) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
577 (let ((v t) (p (point))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
578 (when sel |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
579 (if (car (cdr sel)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
580 (setq v (looking-at (car sel))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
581 (setq v (re-search-forward (car sel) m t)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
582 (goto-char p)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
583 (if (car (cdr (cdr sel))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
584 (setq v (null v)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
585 (if visible |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
586 (funcall fct p m l r v) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
587 (if v |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
588 (funcall fct p m l r))))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
589 (set-marker m nil) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
590 (forward-line 1)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
591 (if (not visible) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
592 (cua--rectangle-bot t)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
593 (if post-fct |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
594 (funcall post-fct l r)) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
595 (when tabify-start |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
596 (tabify tabify-start (point))))) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
597 (cond |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
598 ((eq keep-clear 'keep) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
599 (cua--keep-active)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
600 ((eq keep-clear 'clear) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
601 (cua--deactivate)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
602 ((eq keep-clear 'corners) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
603 (cua--rectangle-set-corners) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
604 (cua--keep-active))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
605 (setq cua--buffer-and-point-before-command nil))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
606 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
607 (put 'cua--rectangle-operation 'lisp-indent-function 4) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
608 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
609 (defun cua--delete-rectangle () |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
610 (let ((lines 0)) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
611 (if (not (cua--rectangle-virtual-edges)) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
612 (cua--rectangle-operation nil nil t 2 t |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
613 '(lambda (s e l r v) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
614 (setq lines (1+ lines)) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
615 (if (and (> e s) (<= e (point-max))) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
616 (delete-region s e)))) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
617 (cua--rectangle-operation nil 1 t nil t |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
618 '(lambda (s e l r v) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
619 (setq lines (1+ lines)) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
620 (when (and (> e s) (<= e (point-max))) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
621 (delete-region s e))))) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
622 lines)) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
623 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
624 (defun cua--extract-rectangle () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
625 (let (rect) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
626 (if (not (cua--rectangle-virtual-edges)) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
627 (cua--rectangle-operation nil nil nil nil nil ; do not tabify |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
628 '(lambda (s e l r) |
108467
114b70461f96
CUA mode: Fix use of `filter-buffer-substring' (rework previous change).
Juanma Barranquero <lekktu@gmail.com>
parents:
107853
diff
changeset
|
629 (setq rect (cons (cua--filter-buffer-noprops s e) rect)))) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
630 (cua--rectangle-operation nil 1 nil nil nil ; do not tabify |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
631 '(lambda (s e l r v) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
632 (let ((copy t) (bs 0) (as 0) row) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
633 (if (= s e) (setq e (1+ e))) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
634 (goto-char s) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
635 (move-to-column l) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
636 (if (= (point) (line-end-position)) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
637 (setq bs (- r l) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
638 copy nil) |
67419
79aa532aaa44
(cua--extract-rectangle): Undo recent change re. \s in strings.
Kim F. Storm <storm@cua.dk>
parents:
67407
diff
changeset
|
639 (skip-chars-forward "\s\t" e) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
640 (setq bs (- (min r (current-column)) l) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
641 s (point)) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
642 (move-to-column r) |
67419
79aa532aaa44
(cua--extract-rectangle): Undo recent change re. \s in strings.
Kim F. Storm <storm@cua.dk>
parents:
67407
diff
changeset
|
643 (skip-chars-backward "\s\t" s) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
644 (setq as (- r (max (current-column) l)) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
645 e (point))) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
646 (setq row (if (and copy (> e s)) |
108467
114b70461f96
CUA mode: Fix use of `filter-buffer-substring' (rework previous change).
Juanma Barranquero <lekktu@gmail.com>
parents:
107853
diff
changeset
|
647 (cua--filter-buffer-noprops s e) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
648 "")) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
649 (when (> bs 0) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
650 (setq row (concat (make-string bs ?\s) row))) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
651 (when (> as 0) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
652 (setq row (concat row (make-string as ?\s)))) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
653 (setq rect (cons row rect)))))) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
654 (nreverse rect))) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
655 |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
656 (defun cua--insert-rectangle (rect &optional below paste-column line-count) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
657 ;; Insert rectangle as insert-rectangle, but don't set mark and exit with |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
658 ;; point at either next to top right or below bottom left corner |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
659 ;; Notice: In overwrite mode, the rectangle is inserted as separate text lines. |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
660 (if (eq below 'auto) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
661 (setq below (and (bolp) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
662 (or (eolp) (eobp) (= (1+ (point)) (point-max)))))) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
663 (unless paste-column |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
664 (setq paste-column (current-column))) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
665 (let ((lines rect) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
666 (first t) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
667 (tabify-start (cua--tabify-start (point) (point))) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
668 last-column |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
669 p) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
670 (while (or lines below) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
671 (or first |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
672 (if overwrite-mode |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
673 (insert ?\n) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
674 (forward-line 1) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
675 (or (bolp) (insert ?\n)))) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
676 (unless overwrite-mode |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
677 (move-to-column paste-column t)) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
678 (if (not lines) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
679 (setq below nil) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
680 (insert-for-yank (car lines)) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
681 (unless last-column |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
682 (setq last-column (current-column))) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
683 (setq lines (cdr lines)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
684 (and first (not below) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
685 (setq p (point)))) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
686 (setq first nil) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
687 (if (and line-count (= (setq line-count (1- line-count)) 0)) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
688 (setq lines nil))) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
689 (when (and line-count last-column (not overwrite-mode)) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
690 (while (> line-count 0) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
691 (forward-line 1) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
692 (or (bolp) (insert ?\n)) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
693 (move-to-column paste-column t) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
694 (insert-char ?\s (- last-column paste-column -1)) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
695 (setq line-count (1- line-count)))) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
696 (when (and tabify-start |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
697 (not overwrite-mode)) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
698 (tabify tabify-start (point))) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
699 (and p (not overwrite-mode) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
700 (goto-char p)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
701 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
702 (defun cua--copy-rectangle-as-kill (&optional ring) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
703 (if cua--register |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
704 (set-register cua--register (cua--extract-rectangle)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
705 (setq killed-rectangle (cua--extract-rectangle)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
706 (setq cua--last-killed-rectangle (cons (and kill-ring (car kill-ring)) killed-rectangle)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
707 (if ring |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
708 (kill-new (mapconcat |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
709 (function (lambda (row) (concat row "\n"))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
710 killed-rectangle ""))))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
711 |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
712 (defun cua--activate-rectangle () |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
713 ;; Turn on rectangular marking mode by disabling transient mark mode |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
714 ;; and manually handling highlighting from a post command hook. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
715 ;; Be careful if we are already marking a rectangle. |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46180
diff
changeset
|
716 (setq cua--rectangle |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46180
diff
changeset
|
717 (if (and cua--last-rectangle |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
718 (eq (car cua--last-rectangle) (current-buffer)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
719 (eq (car (cdr cua--last-rectangle)) (point))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
720 (cdr (cdr cua--last-rectangle)) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
721 (cua--rectangle-get-corners)) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
722 cua--status-string (if (cua--rectangle-virtual-edges) " [R]" "") |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
723 cua--last-rectangle nil)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
724 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
725 ;; (defvar cua-save-point nil) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
726 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
727 (defun cua--deactivate-rectangle () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
728 ;; This is used to clean up after `cua--activate-rectangle'. |
84905
47928cf63c6c
(cua--deactivate-rectangle, cua--highlight-rectangle,
Juanma Barranquero <lekktu@gmail.com>
parents:
78218
diff
changeset
|
729 (mapc (function delete-overlay) cua--rectangle-overlays) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46180
diff
changeset
|
730 (setq cua--last-rectangle (cons (current-buffer) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
731 (cons (point) ;; cua-save-point |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
732 cua--rectangle)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
733 cua--rectangle nil |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
734 cua--rectangle-overlays nil |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
735 cua--status-string nil |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
736 cua--mouse-last-pos nil)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
737 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
738 (defun cua--highlight-rectangle () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
739 ;; This function is used to highlight the rectangular region. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
740 ;; We do this by putting an overlay on each line within the rectangle. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
741 ;; Each overlay extends across all the columns of the rectangle. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
742 ;; We try to reuse overlays where possible because this is more efficient |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
743 ;; and results in less flicker. |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
744 ;; If cua--rectangle-virtual-edges is nil and the buffer contains tabs or short lines, |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
745 ;; the higlighted region may not be perfectly rectangular. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
746 (let ((deactivate-mark deactivate-mark) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
747 (old cua--rectangle-overlays) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
748 (new nil) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
749 (left (cua--rectangle-left)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
750 (right (1+ (cua--rectangle-right)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
751 (when (/= left right) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
752 (sit-for 0) ; make window top/bottom reliable |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
753 (cua--rectangle-operation nil t nil nil nil ; do not tabify |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
754 '(lambda (s e l r v) |
63073
f1bf3660220e
* emulation/cua-base.el (cua-rectangle, cua-rectangle-noselect)
Kim F. Storm <storm@cua.dk>
parents:
62450
diff
changeset
|
755 (let ((rface (if v 'cua-rectangle 'cua-rectangle-noselect)) |
56896
77bbb90bd021
(cua--rectangle-set-corners): Ensure that
Kim F. Storm <storm@cua.dk>
parents:
56838
diff
changeset
|
756 overlay bs ms as) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
757 (when (cua--rectangle-virtual-edges) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
758 (let ((lb (line-beginning-position)) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
759 (le (line-end-position)) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
760 cl cl0 pl cr cr0 pr) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
761 (goto-char s) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
762 (setq cl (move-to-column l) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
763 pl (point)) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
764 (setq cr (move-to-column r) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
765 pr (point)) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
766 (if (= lb pl) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
767 (setq cl0 0) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
768 (goto-char (1- pl)) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
769 (setq cl0 (current-column))) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
770 (if (= lb le) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
771 (setq cr0 0) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
772 (goto-char (1- pr)) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
773 (setq cr0 (current-column))) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
774 (unless (and (= cl l) (= cr r)) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
775 (when (/= cl l) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
776 (setq bs (propertize |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
777 (make-string |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
778 (- l cl0 (if (and (= le pl) (/= le lb)) 1 0)) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
779 (if cua--virtual-edges-debug ?. ?\s)) |
67143
cbf6461ecbbd
(cua--highlight-rectangle): Preserve
Kim F. Storm <storm@cua.dk>
parents:
64710
diff
changeset
|
780 'face (or (get-text-property (1- s) 'face) 'default))) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
781 (if (/= pl le) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
782 (setq s (1- s)))) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
783 (cond |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
784 ((= cr r) |
56896
77bbb90bd021
(cua--rectangle-set-corners): Ensure that
Kim F. Storm <storm@cua.dk>
parents:
56838
diff
changeset
|
785 (if (and (/= pr le) |
77bbb90bd021
(cua--rectangle-set-corners): Ensure that
Kim F. Storm <storm@cua.dk>
parents:
56838
diff
changeset
|
786 (/= cr0 (1- cr)) |
77bbb90bd021
(cua--rectangle-set-corners): Ensure that
Kim F. Storm <storm@cua.dk>
parents:
56838
diff
changeset
|
787 (or bs (/= cr0 (- cr tab-width))) |
77bbb90bd021
(cua--rectangle-set-corners): Ensure that
Kim F. Storm <storm@cua.dk>
parents:
56838
diff
changeset
|
788 (/= (mod cr tab-width) 0)) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
789 (setq e (1- e)))) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
790 ((= cr cl) |
56896
77bbb90bd021
(cua--rectangle-set-corners): Ensure that
Kim F. Storm <storm@cua.dk>
parents:
56838
diff
changeset
|
791 (setq ms (propertize |
77bbb90bd021
(cua--rectangle-set-corners): Ensure that
Kim F. Storm <storm@cua.dk>
parents:
56838
diff
changeset
|
792 (make-string |
77bbb90bd021
(cua--rectangle-set-corners): Ensure that
Kim F. Storm <storm@cua.dk>
parents:
56838
diff
changeset
|
793 (- r l) |
77bbb90bd021
(cua--rectangle-set-corners): Ensure that
Kim F. Storm <storm@cua.dk>
parents:
56838
diff
changeset
|
794 (if cua--virtual-edges-debug ?, ?\s)) |
77bbb90bd021
(cua--rectangle-set-corners): Ensure that
Kim F. Storm <storm@cua.dk>
parents:
56838
diff
changeset
|
795 'face rface)) |
77bbb90bd021
(cua--rectangle-set-corners): Ensure that
Kim F. Storm <storm@cua.dk>
parents:
56838
diff
changeset
|
796 (if (cua--rectangle-right-side) |
69574
e963763ec80a
(cua--highlight-rectangle): Set overlay
Kim F. Storm <storm@cua.dk>
parents:
68648
diff
changeset
|
797 (put-text-property (1- (length ms)) (length ms) 'cursor 2 ms) |
e963763ec80a
(cua--highlight-rectangle): Set overlay
Kim F. Storm <storm@cua.dk>
parents:
68648
diff
changeset
|
798 (put-text-property 0 1 'cursor 2 ms)) |
56896
77bbb90bd021
(cua--rectangle-set-corners): Ensure that
Kim F. Storm <storm@cua.dk>
parents:
56838
diff
changeset
|
799 (setq bs (concat bs ms)) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
800 (setq rface nil)) |
56896
77bbb90bd021
(cua--rectangle-set-corners): Ensure that
Kim F. Storm <storm@cua.dk>
parents:
56838
diff
changeset
|
801 (t |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
802 (setq as (propertize |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
803 (make-string |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
804 (- r cr0 (if (= le pr) 1 0)) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
805 (if cua--virtual-edges-debug ?~ ?\s)) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
806 'face rface)) |
56896
77bbb90bd021
(cua--rectangle-set-corners): Ensure that
Kim F. Storm <storm@cua.dk>
parents:
56838
diff
changeset
|
807 (if (cua--rectangle-right-side) |
69574
e963763ec80a
(cua--highlight-rectangle): Set overlay
Kim F. Storm <storm@cua.dk>
parents:
68648
diff
changeset
|
808 (put-text-property (1- (length as)) (length as) 'cursor 2 as) |
e963763ec80a
(cua--highlight-rectangle): Set overlay
Kim F. Storm <storm@cua.dk>
parents:
68648
diff
changeset
|
809 (put-text-property 0 1 'cursor 2 as)) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
810 (if (/= pr le) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
811 (setq e (1- e)))))))) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
812 ;; Trim old leading overlays. |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
813 (while (and old |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
814 (setq overlay (car old)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
815 (< (overlay-start overlay) s) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
816 (/= (overlay-end overlay) e)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
817 (delete-overlay overlay) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
818 (setq old (cdr old))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
819 ;; Reuse an overlay if possible, otherwise create one. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
820 (if (and old |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
821 (setq overlay (car old)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
822 (or (= (overlay-start overlay) s) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
823 (= (overlay-end overlay) e))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
824 (progn |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
825 (move-overlay overlay s e) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
826 (setq old (cdr old))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
827 (setq overlay (make-overlay s e))) |
56896
77bbb90bd021
(cua--rectangle-set-corners): Ensure that
Kim F. Storm <storm@cua.dk>
parents:
56838
diff
changeset
|
828 (overlay-put overlay 'before-string bs) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
829 (overlay-put overlay 'after-string as) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
830 (overlay-put overlay 'face rface) |
56902
8d62e1b62c44
* emulation/cua-rect.el (cua--overlay-keymap): New keymap for
Kim F. Storm <storm@cua.dk>
parents:
56896
diff
changeset
|
831 (overlay-put overlay 'keymap cua--overlay-keymap) |
64710
0135928f4763
(cua--highlight-rectangle): Only show
Kim F. Storm <storm@cua.dk>
parents:
64701
diff
changeset
|
832 (overlay-put overlay 'window (selected-window)) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
833 (setq new (cons overlay new)))))) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
834 ;; Trim old trailing overlays. |
84905
47928cf63c6c
(cua--deactivate-rectangle, cua--highlight-rectangle,
Juanma Barranquero <lekktu@gmail.com>
parents:
78218
diff
changeset
|
835 (mapc (function delete-overlay) old) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
836 (setq cua--rectangle-overlays (nreverse new)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
837 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
838 (defun cua--indent-rectangle (&optional ch to-col clear) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
839 ;; Indent current rectangle. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
840 (let ((col (cua--rectangle-insert-col)) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
841 (pad (cua--rectangle-virtual-edges)) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
842 indent) |
56896
77bbb90bd021
(cua--rectangle-set-corners): Ensure that
Kim F. Storm <storm@cua.dk>
parents:
56838
diff
changeset
|
843 (cua--rectangle-operation (if clear 'clear 'corners) nil t pad nil |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
844 '(lambda (s e l r) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
845 (move-to-column col pad) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
846 (if (and (eolp) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
847 (< (current-column) col)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
848 (move-to-column col t)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
849 (cond |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
850 (to-col (indent-to to-col)) |
102915
5200e3730ccd
(cua--indent-rectangle): Insert tabs using
Kim F. Storm <storm@cua.dk>
parents:
100908
diff
changeset
|
851 ((and ch (not (eq ch ?\t))) (insert ch)) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
852 (t (tab-to-tab-stop))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
853 (if (cua--rectangle-right-side t) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
854 (cua--rectangle-insert-col (current-column)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
855 (setq indent (- (current-column) l)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
856 '(lambda (l r) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
857 (when (and indent (> indent 0)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
858 (aset cua--rectangle 2 (+ l indent)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
859 (aset cua--rectangle 3 (+ r indent -1))))))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
860 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
861 ;; |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
862 ;; rectangle functions / actions |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
863 ;; |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
864 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
865 (defvar cua--rectangle-initialized nil) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
866 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
867 (defun cua-set-rectangle-mark (&optional reopen) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
868 "Set mark and start in CUA rectangle mode. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
869 With prefix argument, activate previous rectangle if possible." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
870 (interactive "P") |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
871 (unless cua--rectangle-initialized |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
872 (cua--init-rectangles)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
873 (when (not cua--rectangle) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
874 (if (and reopen |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
875 cua--last-rectangle |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
876 (eq (car cua--last-rectangle) (current-buffer))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
877 (goto-char (car (cdr cua--last-rectangle))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
878 (if (not mark-active) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
879 (push-mark nil nil t))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
880 (cua--activate-rectangle) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
881 (cua--rectangle-set-corners) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
882 (setq mark-active t |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
883 cua--explicit-region-start t) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
884 (if cua-enable-rectangle-auto-help |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
885 (cua-help-for-rectangle t)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
886 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
887 (defun cua-clear-rectangle-mark () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
888 "Cancel current rectangle." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
889 (interactive) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
890 (when cua--rectangle |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
891 (setq mark-active nil |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
892 cua--explicit-region-start nil) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
893 (cua--deactivate-rectangle))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
894 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
895 (defun cua-toggle-rectangle-mark () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
896 (interactive) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
897 (if cua--rectangle |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
898 (cua--deactivate-rectangle) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
899 (unless cua--rectangle-initialized |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
900 (cua--init-rectangles)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
901 (cua--activate-rectangle)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
902 (if cua--rectangle |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
903 (if cua-enable-rectangle-auto-help |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
904 (cua-help-for-rectangle t)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
905 (if cua-enable-region-auto-help |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
906 (cua-help-for-region t)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
907 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
908 (defun cua-restrict-regexp-rectangle (arg) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
909 "Restrict rectangle to lines (not) matching REGEXP. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
910 With prefix argument, the toggle restriction." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
911 (interactive "P") |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
912 (let ((r (cua--rectangle-restriction)) regexp) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
913 (if (and r (null (car (cdr r)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
914 (if arg |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
915 (cua--rectangle-restriction (car r) nil (not (car (cdr (cdr r))))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
916 (cua--rectangle-restriction "" nil nil)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
917 (cua--rectangle-restriction |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
918 (read-from-minibuffer "Restrict rectangle (regexp): " |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
919 nil nil nil nil) nil arg)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
920 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
921 (defun cua-restrict-prefix-rectangle (arg) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
922 "Restrict rectangle to lines (not) starting with CHAR. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
923 With prefix argument, the toggle restriction." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
924 (interactive "P") |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
925 (let ((r (cua--rectangle-restriction)) regexp) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
926 (if (and r (car (cdr r))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
927 (if arg |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
928 (cua--rectangle-restriction (car r) t (not (car (cdr (cdr r))))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
929 (cua--rectangle-restriction "" nil nil)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
930 (cua--rectangle-restriction |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46180
diff
changeset
|
931 (format "[%c]" |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
932 (read-char "Restrictive rectangle (char): ")) t arg)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
933 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
934 (defun cua-move-rectangle-up () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
935 (interactive) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
936 (cua--rectangle-move 'up)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
937 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
938 (defun cua-move-rectangle-down () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
939 (interactive) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
940 (cua--rectangle-move 'down)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
941 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
942 (defun cua-move-rectangle-left () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
943 (interactive) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
944 (cua--rectangle-move 'left)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
945 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
946 (defun cua-move-rectangle-right () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
947 (interactive) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
948 (cua--rectangle-move 'right)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
949 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
950 (defun cua-copy-rectangle (arg) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
951 (interactive "P") |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
952 (setq arg (cua--prefix-arg arg)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
953 (cua--copy-rectangle-as-kill arg) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
954 (if cua-keep-region-after-copy |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
955 (cua--keep-active) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
956 (cua--deactivate))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
957 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
958 (defun cua-cut-rectangle (arg) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
959 (interactive "P") |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
960 (if buffer-read-only |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
961 (cua-copy-rectangle arg) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
962 (setq arg (cua--prefix-arg arg)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
963 (goto-char (min (mark) (point))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
964 (cua--copy-rectangle-as-kill arg) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
965 (cua--delete-rectangle)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
966 (cua--deactivate)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
967 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
968 (defun cua-delete-rectangle () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
969 (interactive) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
970 (goto-char (min (point) (mark))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
971 (if cua-delete-copy-to-register-0 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
972 (set-register ?0 (cua--extract-rectangle))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
973 (cua--delete-rectangle) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
974 (cua--deactivate)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
975 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
976 (defun cua-rotate-rectangle () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
977 (interactive) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
978 (cua--rectangle-corner (if (= (cua--rectangle-left) (cua--rectangle-right)) 0 1)) |
56896
77bbb90bd021
(cua--rectangle-set-corners): Ensure that
Kim F. Storm <storm@cua.dk>
parents:
56838
diff
changeset
|
979 (cua--rectangle-set-corners) |
77bbb90bd021
(cua--rectangle-set-corners): Ensure that
Kim F. Storm <storm@cua.dk>
parents:
56838
diff
changeset
|
980 (if (cua--rectangle-virtual-edges) |
77bbb90bd021
(cua--rectangle-set-corners): Ensure that
Kim F. Storm <storm@cua.dk>
parents:
56838
diff
changeset
|
981 (setq cua--buffer-and-point-before-command nil))) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
982 |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
983 (defun cua-toggle-rectangle-virtual-edges () |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
984 (interactive) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
985 (cua--rectangle-virtual-edges t (not (cua--rectangle-virtual-edges))) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
986 (cua--rectangle-set-corners) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
987 (setq cua--status-string (and (cua--rectangle-virtual-edges) " [R]")) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
988 (cua--keep-active)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
989 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
990 (defun cua-do-rectangle-padding () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
991 (interactive) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
992 (if buffer-read-only |
63871
ffc4b2e19212
(cua-do-rectangle-padding): Remove period from end of messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
63073
diff
changeset
|
993 (message "Cannot do padding in read-only buffer") |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
994 (cua--rectangle-operation nil nil t t t) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
995 (cua--rectangle-set-corners)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
996 (cua--keep-active)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
997 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
998 (defun cua-open-rectangle () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
999 "Blank out CUA rectangle, shifting text right. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1000 The text previously in the region is not overwritten by the blanks, |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1001 but instead winds up to the right of the rectangle." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1002 (interactive) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
1003 (cua--rectangle-operation 'corners nil t 1 nil |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1004 '(lambda (s e l r) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1005 (skip-chars-forward " \t") |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1006 (let ((ws (- (current-column) l)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1007 (p (point))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1008 (skip-chars-backward " \t") |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1009 (delete-region (point) p) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1010 (indent-to (+ r ws)))))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1011 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1012 (defun cua-close-rectangle (arg) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1013 "Delete all whitespace starting at left edge of CUA rectangle. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1014 On each line in the rectangle, all continuous whitespace starting |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1015 at that column is deleted. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1016 With prefix arg, also delete whitespace to the left of that column." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1017 (interactive "P") |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
1018 (cua--rectangle-operation 'clear nil t 1 nil |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1019 '(lambda (s e l r) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1020 (when arg |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1021 (skip-syntax-backward " " (line-beginning-position)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1022 (setq s (point))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1023 (skip-syntax-forward " " (line-end-position)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1024 (delete-region s (point))))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1025 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1026 (defun cua-blank-rectangle () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1027 "Blank out CUA rectangle. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1028 The text previously in the rectangle is overwritten by the blanks." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1029 (interactive) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
1030 (cua--rectangle-operation 'keep nil nil 1 nil |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1031 '(lambda (s e l r) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1032 (goto-char e) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1033 (skip-syntax-forward " " (line-end-position)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1034 (setq e (point)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1035 (let ((column (current-column))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1036 (goto-char s) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1037 (skip-syntax-backward " " (line-beginning-position)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1038 (delete-region (point) e) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1039 (indent-to column))))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1040 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1041 (defun cua-align-rectangle () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1042 "Align rectangle lines to left column." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1043 (interactive) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1044 (let (x) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
1045 (cua--rectangle-operation 'clear nil t t nil |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1046 '(lambda (s e l r) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1047 (let ((b (line-beginning-position))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1048 (skip-syntax-backward "^ " b) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1049 (skip-syntax-backward " " b) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1050 (setq s (point))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1051 (skip-syntax-forward " " (line-end-position)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1052 (delete-region s (point)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1053 (indent-to l)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1054 '(lambda (l r) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1055 (move-to-column l) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1056 ;; (setq cua-save-point (point)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1057 )))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1058 |
87020
52abd10af81e
(top-level): Move provide to end.
Glenn Morris <rgm@gnu.org>
parents:
84905
diff
changeset
|
1059 (declare-function cua--cut-rectangle-to-global-mark "cua-gmrk" (as-text)) |
52abd10af81e
(top-level): Move provide to end.
Glenn Morris <rgm@gnu.org>
parents:
84905
diff
changeset
|
1060 (declare-function cua--copy-rectangle-to-global-mark "cua-gmrk" (as-text)) |
52abd10af81e
(top-level): Move provide to end.
Glenn Morris <rgm@gnu.org>
parents:
84905
diff
changeset
|
1061 |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1062 (defun cua-copy-rectangle-as-text (&optional arg delete) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1063 "Copy rectangle, but store as normal text." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1064 (interactive "P") |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1065 (if cua--global-mark-active |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1066 (if delete |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1067 (cua--cut-rectangle-to-global-mark t) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1068 (cua--copy-rectangle-to-global-mark t)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1069 (let* ((rect (cua--extract-rectangle)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1070 (text (mapconcat |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1071 (function (lambda (row) (concat row "\n"))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1072 rect ""))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1073 (setq arg (cua--prefix-arg arg)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1074 (if cua--register |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1075 (set-register cua--register text) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1076 (kill-new text))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1077 (if delete |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1078 (cua--delete-rectangle)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1079 (cua--deactivate))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1080 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1081 (defun cua-cut-rectangle-as-text (arg) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1082 "Kill rectangle, but store as normal text." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1083 (interactive "P") |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1084 (cua-copy-rectangle-as-text arg (not buffer-read-only))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1085 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1086 (defun cua-string-rectangle (string) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1087 "Replace CUA rectangle contents with STRING on each line. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1088 The length of STRING need not be the same as the rectangle width." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1089 (interactive "sString rectangle: ") |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
1090 (cua--rectangle-operation 'keep nil t t nil |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1091 '(lambda (s e l r) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1092 (delete-region s e) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1093 (skip-chars-forward " \t") |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1094 (let ((ws (- (current-column) l))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1095 (delete-region s (point)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1096 (insert string) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1097 (indent-to (+ (current-column) ws)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1098 (unless (cua--rectangle-restriction) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1099 '(lambda (l r) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1100 (cua--rectangle-right (max l (+ l (length string) -1))))))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1101 |
63871
ffc4b2e19212
(cua-do-rectangle-padding): Remove period from end of messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
63073
diff
changeset
|
1102 (defun cua-fill-char-rectangle (character) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1103 "Replace CUA rectangle contents with CHARACTER." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1104 (interactive "cFill rectangle with character: ") |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
1105 (cua--rectangle-operation 'clear nil t 1 nil |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1106 '(lambda (s e l r) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1107 (delete-region s e) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1108 (move-to-column l t) |
63871
ffc4b2e19212
(cua-do-rectangle-padding): Remove period from end of messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
63073
diff
changeset
|
1109 (insert-char character (- r l))))) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1110 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1111 (defun cua-replace-in-rectangle (regexp newtext) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1112 "Replace REGEXP with NEWTEXT in each line of CUA rectangle." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1113 (interactive "sReplace regexp: \nsNew text: ") |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1114 (if buffer-read-only |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1115 (message "Cannot replace in read-only buffer") |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
1116 (cua--rectangle-operation 'keep nil t 1 nil |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1117 '(lambda (s e l r) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1118 (if (re-search-forward regexp e t) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1119 (replace-match newtext nil nil)))))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1120 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1121 (defun cua-incr-rectangle (increment) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1122 "Increment each line of CUA rectangle by prefix amount." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1123 (interactive "p") |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
1124 (cua--rectangle-operation 'keep nil t 1 nil |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1125 '(lambda (s e l r) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1126 (cond |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1127 ((re-search-forward "0x\\([0-9a-fA-F]+\\)" e t) |
108467
114b70461f96
CUA mode: Fix use of `filter-buffer-substring' (rework previous change).
Juanma Barranquero <lekktu@gmail.com>
parents:
107853
diff
changeset
|
1128 (let* ((txt (cua--filter-buffer-noprops (match-beginning 1) (match-end 1))) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1129 (n (string-to-number txt 16)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1130 (fmt (format "0x%%0%dx" (length txt)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1131 (replace-match (format fmt (+ n increment))))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1132 ((re-search-forward "\\( *-?[0-9]+\\)" e t) |
108467
114b70461f96
CUA mode: Fix use of `filter-buffer-substring' (rework previous change).
Juanma Barranquero <lekktu@gmail.com>
parents:
107853
diff
changeset
|
1133 (let* ((txt (cua--filter-buffer-noprops (match-beginning 1) (match-end 1))) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1134 (prefix (if (= (aref txt 0) ?0) "0" "")) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1135 (n (string-to-number txt 10)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1136 (fmt (format "%%%s%dd" prefix (length txt)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1137 (replace-match (format fmt (+ n increment))))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1138 (t nil))))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1139 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1140 (defvar cua--rectangle-seq-format "%d" |
63871
ffc4b2e19212
(cua-do-rectangle-padding): Remove period from end of messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
63073
diff
changeset
|
1141 "Last format used by `cua-sequence-rectangle'.") |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1142 |
63871
ffc4b2e19212
(cua-do-rectangle-padding): Remove period from end of messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
63073
diff
changeset
|
1143 (defun cua-sequence-rectangle (first incr format) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1144 "Resequence each line of CUA rectangle starting from FIRST. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1145 The numbers are formatted according to the FORMAT string." |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46180
diff
changeset
|
1146 (interactive |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1147 (list (if current-prefix-arg |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1148 (prefix-numeric-value current-prefix-arg) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1149 (string-to-number |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1150 (read-string "Start value: (0) " nil nil "0"))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1151 (string-to-number |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1152 (read-string "Increment: (1) " nil nil "1")) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1153 (read-string (concat "Format: (" cua--rectangle-seq-format ") ")))) |
63871
ffc4b2e19212
(cua-do-rectangle-padding): Remove period from end of messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
63073
diff
changeset
|
1154 (if (= (length format) 0) |
ffc4b2e19212
(cua-do-rectangle-padding): Remove period from end of messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
63073
diff
changeset
|
1155 (setq format cua--rectangle-seq-format) |
ffc4b2e19212
(cua-do-rectangle-padding): Remove period from end of messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
63073
diff
changeset
|
1156 (setq cua--rectangle-seq-format format)) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
1157 (cua--rectangle-operation 'clear nil t 1 nil |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1158 '(lambda (s e l r) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1159 (delete-region s e) |
63871
ffc4b2e19212
(cua-do-rectangle-padding): Remove period from end of messages.
Juanma Barranquero <lekktu@gmail.com>
parents:
63073
diff
changeset
|
1160 (insert (format format first)) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1161 (setq first (+ first incr))))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1162 |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
1163 (defmacro cua--convert-rectangle-as (command tabify) |
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
1164 `(cua--rectangle-operation 'clear nil nil nil ,tabify |
55264
1a506cc5235d
(cua--convert-rectangle-as): New defmacro.
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
1165 '(lambda (s e l r) |
1a506cc5235d
(cua--convert-rectangle-as): New defmacro.
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
1166 (,command s e)))) |
1a506cc5235d
(cua--convert-rectangle-as): New defmacro.
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
1167 |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1168 (defun cua-upcase-rectangle () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1169 "Convert the rectangle to upper case." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1170 (interactive) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
1171 (cua--convert-rectangle-as upcase-region nil)) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1172 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1173 (defun cua-downcase-rectangle () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1174 "Convert the rectangle to lower case." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1175 (interactive) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
1176 (cua--convert-rectangle-as downcase-region nil)) |
55264
1a506cc5235d
(cua--convert-rectangle-as): New defmacro.
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
1177 |
1a506cc5235d
(cua--convert-rectangle-as): New defmacro.
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
1178 (defun cua-upcase-initials-rectangle () |
1a506cc5235d
(cua--convert-rectangle-as): New defmacro.
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
1179 "Convert the rectangle initials to upper case." |
1a506cc5235d
(cua--convert-rectangle-as): New defmacro.
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
1180 (interactive) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
1181 (cua--convert-rectangle-as upcase-initials-region nil)) |
55264
1a506cc5235d
(cua--convert-rectangle-as): New defmacro.
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
1182 |
1a506cc5235d
(cua--convert-rectangle-as): New defmacro.
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
1183 (defun cua-capitalize-rectangle () |
1a506cc5235d
(cua--convert-rectangle-as): New defmacro.
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
1184 "Convert the rectangle to proper case." |
1a506cc5235d
(cua--convert-rectangle-as): New defmacro.
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
1185 (interactive) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
1186 (cua--convert-rectangle-as capitalize-region nil)) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1187 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1188 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1189 ;;; Replace/rearrange text in current rectangle |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1190 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1191 (defun cua--rectangle-aux-replace (width adjust keep replace pad format-fct &optional setup-fct) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1192 ;; Process text inserted by calling SETUP-FCT or current rectangle if nil. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1193 ;; Then call FORMAT-FCT on text (if non-nil); takes two args: start and end. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1194 ;; Fill to WIDTH characters if > 0 or fill to current width if == 0. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1195 ;; Don't fill if WIDTH < 0. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1196 ;; Replace current rectangle by filled text if REPLACE is non-nil |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1197 (let ((auxbuf (get-buffer-create "*CUA temp*")) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1198 (w (if (> width 1) width |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1199 (- (cua--rectangle-right) (cua--rectangle-left) -1))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1200 (r (or setup-fct (cua--extract-rectangle))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1201 y z (tr 0)) |
105829
328150f0cf76
* url-util.el (url-insert-entities-in-string):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
102915
diff
changeset
|
1202 (with-current-buffer auxbuf |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1203 (erase-buffer) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1204 (if setup-fct |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1205 (funcall setup-fct) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1206 (cua--insert-rectangle r)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1207 (if format-fct |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1208 (let ((fill-column w)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1209 (funcall format-fct (point-min) (point-max)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1210 (when replace |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1211 (goto-char (point-min)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1212 (while (not (eobp)) |
69901 | 1213 (setq z (cons (filter-buffer-substring (point) (line-end-position)) z)) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1214 (forward-line 1)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1215 (if (not cua--debug) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1216 (kill-buffer auxbuf)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1217 (when replace |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1218 (setq z (reverse z)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1219 (if cua--debug |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1220 (print z auxbuf)) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
1221 (cua--rectangle-operation nil nil t pad nil |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1222 '(lambda (s e l r) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1223 (let (cc) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1224 (goto-char e) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1225 (skip-chars-forward " \t") |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1226 (setq cc (current-column)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1227 (if cua--debug |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1228 (print (list cc s e) auxbuf)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1229 (delete-region s (point)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1230 (if (not z) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1231 (setq y 0) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1232 (move-to-column l t) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1233 (insert (car z)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1234 (when (> (current-column) (+ l w)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1235 (setq y (point)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1236 (move-to-column (+ l w) t) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1237 (delete-region (point) y) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1238 (setq tr (1+ tr))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1239 (setq z (cdr z))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1240 (if cua--debug |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1241 (print (list (current-column) cc) auxbuf)) |
67407
bb2f67d4e710
(cua--rectangle-aux-replace): Fix
Kim F. Storm <storm@cua.dk>
parents:
67405
diff
changeset
|
1242 (just-one-space 0) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1243 (indent-to cc)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1244 (if (> tr 0) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1245 (message "Warning: Truncated %d row%s" tr (if (> tr 1) "s" ""))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1246 (if adjust |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1247 (cua--rectangle-right (+ (cua--rectangle-left) w -1))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1248 (if keep |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1249 (cua--rectangle-resized))))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1250 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1251 (put 'cua--rectangle-aux-replace 'lisp-indent-function 4) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1252 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1253 (defun cua--left-fill-rectangle (start end) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1254 (beginning-of-line) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1255 (while (< (point) (point-max)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1256 (delete-horizontal-space nil) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1257 (forward-line 1)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1258 (fill-region-as-paragraph (point-min) (point-max) 'left nil) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1259 (untabify (point-min) (point-max))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1260 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1261 (defun cua-text-fill-rectangle (width text) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1262 "Replace rectagle with filled TEXT read from minibuffer. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1263 A numeric prefix argument is used a new width for the filled rectangle." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1264 (interactive (list |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1265 (prefix-numeric-value current-prefix-arg) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1266 (read-from-minibuffer "Enter text: " |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1267 nil nil nil nil))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1268 (cua--rectangle-aux-replace width t t t 1 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1269 'cua--left-fill-rectangle |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1270 '(lambda () (insert text)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1271 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1272 (defun cua-refill-rectangle (width) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1273 "Fill contents of current rectagle. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1274 A numeric prefix argument is used as new width for the filled rectangle." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1275 (interactive "P") |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1276 (cua--rectangle-aux-replace |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1277 (if width (prefix-numeric-value width) 0) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1278 t t t 1 'cua--left-fill-rectangle)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1279 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1280 (defun cua-shell-command-on-rectangle (replace command) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1281 "Run shell command on rectangle like `shell-command-on-region'. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1282 With prefix arg, replace rectangle with output from command." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1283 (interactive (list |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1284 current-prefix-arg |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1285 (read-from-minibuffer "Shell command on rectangle: " |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46180
diff
changeset
|
1286 nil nil nil |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1287 'shell-command-history))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1288 (cua--rectangle-aux-replace -1 t t replace 1 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1289 '(lambda (s e) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1290 (shell-command-on-region s e command |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1291 replace replace nil)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1292 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1293 (defun cua-reverse-rectangle () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1294 "Reverse the lines of the rectangle." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1295 (interactive) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1296 (cua--rectangle-aux-replace 0 t t t t 'reverse-region)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1297 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1298 (defun cua-scroll-rectangle-up () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1299 "Remove the first line of the rectangle and scroll remaining lines up." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1300 (interactive) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1301 (cua--rectangle-aux-replace 0 t t t t |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46180
diff
changeset
|
1302 '(lambda (s e) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1303 (if (= (forward-line 1) 0) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1304 (delete-region s (point)))))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1305 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1306 (defun cua-scroll-rectangle-down () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1307 "Insert a blank line at the first line of the rectangle. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1308 The remaining lines are scrolled down, losing the last line." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1309 (interactive) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1310 (cua--rectangle-aux-replace 0 t t t t |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1311 '(lambda (s e) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1312 (goto-char s) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1313 (insert "\n")))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1314 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1315 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1316 ;;; Insert/delete text to left or right of rectangle |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1317 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1318 (defun cua-insert-char-rectangle (&optional ch) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1319 (interactive) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1320 (if buffer-read-only |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1321 (ding) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1322 (cua--indent-rectangle (or ch (aref (this-single-command-keys) 0))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1323 (cua--keep-active)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1324 t) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1325 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1326 (defun cua-indent-rectangle (column) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1327 "Indent rectangle to next tab stop. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1328 With prefix arg, indent to that column." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1329 (interactive "P") |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1330 (if (null column) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1331 (cua-insert-char-rectangle ?\t) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1332 (cua--indent-rectangle nil (prefix-numeric-value column)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1333 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1334 (defun cua-delete-char-rectangle () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1335 "Delete char to left or right of rectangle." |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1336 (interactive) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1337 (let ((col (cua--rectangle-insert-col)) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
1338 (pad (cua--rectangle-virtual-edges)) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1339 indent) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
1340 (cua--rectangle-operation 'corners nil t pad nil |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1341 '(lambda (s e l r) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46180
diff
changeset
|
1342 (move-to-column |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1343 (if (cua--rectangle-right-side t) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1344 (max (1+ r) col) l) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1345 pad) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1346 (if (bolp) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1347 nil |
108765
d835100c3e8b
Replace Lisp calls to delete-backward-char by delete-char.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108467
diff
changeset
|
1348 (delete-char -1) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1349 (if (cua--rectangle-right-side t) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1350 (cua--rectangle-insert-col (current-column)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1351 (setq indent (- l (current-column)))))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1352 '(lambda (l r) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1353 (when (and indent (> indent 0)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1354 (aset cua--rectangle 2 (- l indent)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1355 (aset cua--rectangle 3 (- r indent 1))))))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1356 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1357 (defun cua-help-for-rectangle (&optional help) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1358 (interactive) |
67405
f8d3bd39d0a1
* emulation/cua-base.el (cua-use-hyper-key): Replaced by ...
Kim F. Storm <storm@cua.dk>
parents:
67399
diff
changeset
|
1359 (let ((M (cond ((eq cua--rectangle-modifier-key 'hyper) " H-") |
f8d3bd39d0a1
* emulation/cua-base.el (cua-use-hyper-key): Replaced by ...
Kim F. Storm <storm@cua.dk>
parents:
67399
diff
changeset
|
1360 ((eq cua--rectangle-modifier-key 'super) " s-") |
71906
4a6411420a60
(cua-help-for-rectangle): Add `alt' modifier.
Kim F. Storm <storm@cua.dk>
parents:
69901
diff
changeset
|
1361 ((eq cua--rectangle-modifier-key 'alt) " A-") |
67405
f8d3bd39d0a1
* emulation/cua-base.el (cua-use-hyper-key): Replaced by ...
Kim F. Storm <storm@cua.dk>
parents:
67399
diff
changeset
|
1362 (t " M-")))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46180
diff
changeset
|
1363 (message |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1364 (concat (if help "C-?:help" "") |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46180
diff
changeset
|
1365 M "p:pad" M "o:open" M "c:close" M "b:blank" |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1366 M "s:string" M "f:fill" M "i:incr" M "n:seq")))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1367 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1368 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1369 ;;; CUA-like cut & paste for rectangles |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1370 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1371 (defun cua--cancel-rectangle () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1372 ;; Cancel rectangle |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1373 (if cua--rectangle |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1374 (cua--deactivate-rectangle)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1375 (setq cua--last-rectangle nil)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1376 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1377 (defun cua--rectangle-post-command () |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1378 (if cua--restored-rectangle |
59973
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
1379 (progn |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
1380 (setq cua--rectangle cua--restored-rectangle |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
1381 cua--restored-rectangle nil |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
1382 mark-active t |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
1383 deactivate-mark nil) |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
1384 (cua--rectangle-set-corners)) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1385 (when (and cua--rectangle cua--buffer-and-point-before-command |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1386 (equal (car cua--buffer-and-point-before-command) (current-buffer)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1387 (not (= (cdr cua--buffer-and-point-before-command) (point)))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1388 (if (cua--rectangle-right-side) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1389 (cua--rectangle-right (current-column)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1390 (cua--rectangle-left (current-column))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1391 (if (>= (cua--rectangle-corner) 2) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1392 (cua--rectangle-bot t) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
1393 (cua--rectangle-top t)))) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1394 (if cua--rectangle |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1395 (if (and mark-active |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1396 (not deactivate-mark)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1397 (cua--highlight-rectangle) |
67214
4fd503f32b2c
(cua--rectangle-overlays): Make permanent-local.
Kim F. Storm <storm@cua.dk>
parents:
67143
diff
changeset
|
1398 (cua--deactivate-rectangle)) |
4fd503f32b2c
(cua--rectangle-overlays): Make permanent-local.
Kim F. Storm <storm@cua.dk>
parents:
67143
diff
changeset
|
1399 (when cua--rectangle-overlays |
4fd503f32b2c
(cua--rectangle-overlays): Make permanent-local.
Kim F. Storm <storm@cua.dk>
parents:
67143
diff
changeset
|
1400 ;; clean-up after revert-buffer |
84905
47928cf63c6c
(cua--deactivate-rectangle, cua--highlight-rectangle,
Juanma Barranquero <lekktu@gmail.com>
parents:
78218
diff
changeset
|
1401 (mapc (function delete-overlay) cua--rectangle-overlays) |
67214
4fd503f32b2c
(cua--rectangle-overlays): Make permanent-local.
Kim F. Storm <storm@cua.dk>
parents:
67143
diff
changeset
|
1402 (setq cua--rectangle-overlays nil) |
4fd503f32b2c
(cua--rectangle-overlays): Make permanent-local.
Kim F. Storm <storm@cua.dk>
parents:
67143
diff
changeset
|
1403 (setq deactivate-mark t))) |
59973
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
1404 (when cua--rect-undo-set-point |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
1405 (goto-char cua--rect-undo-set-point) |
b1a9da0dcd80
(cua--undo-list, cua--tidy-undo-counter)
Kim F. Storm <storm@cua.dk>
parents:
57075
diff
changeset
|
1406 (setq cua--rect-undo-set-point nil))) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1407 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1408 ;;; Initialization |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1409 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1410 (defun cua--rect-M/H-key (key cmd) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1411 (cua--M/H-key cua--rectangle-keymap key cmd)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1412 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1413 (defun cua--init-rectangles () |
69669 | 1414 (define-key cua--rectangle-keymap cua-rectangle-mark-key 'cua-clear-rectangle-mark) |
1415 (define-key cua--region-keymap cua-rectangle-mark-key 'cua-toggle-rectangle-mark) | |
67405
f8d3bd39d0a1
* emulation/cua-base.el (cua-use-hyper-key): Replaced by ...
Kim F. Storm <storm@cua.dk>
parents:
67399
diff
changeset
|
1416 (unless (eq cua--rectangle-modifier-key 'meta) |
f8d3bd39d0a1
* emulation/cua-base.el (cua-use-hyper-key): Replaced by ...
Kim F. Storm <storm@cua.dk>
parents:
67399
diff
changeset
|
1417 (cua--rect-M/H-key ?\s 'cua-clear-rectangle-mark) |
f8d3bd39d0a1
* emulation/cua-base.el (cua-use-hyper-key): Replaced by ...
Kim F. Storm <storm@cua.dk>
parents:
67399
diff
changeset
|
1418 (cua--M/H-key cua--region-keymap ?\s 'cua-toggle-rectangle-mark)) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1419 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1420 (define-key cua--rectangle-keymap [remap copy-region-as-kill] 'cua-copy-rectangle) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1421 (define-key cua--rectangle-keymap [remap kill-ring-save] 'cua-copy-rectangle) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1422 (define-key cua--rectangle-keymap [remap kill-region] 'cua-cut-rectangle) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1423 (define-key cua--rectangle-keymap [remap delete-char] 'cua-delete-rectangle) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1424 (define-key cua--rectangle-keymap [remap set-mark-command] 'cua-toggle-rectangle-mark) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1425 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1426 (define-key cua--rectangle-keymap [remap forward-char] 'cua-resize-rectangle-right) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1427 (define-key cua--rectangle-keymap [remap backward-char] 'cua-resize-rectangle-left) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1428 (define-key cua--rectangle-keymap [remap next-line] 'cua-resize-rectangle-down) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1429 (define-key cua--rectangle-keymap [remap previous-line] 'cua-resize-rectangle-up) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1430 (define-key cua--rectangle-keymap [remap end-of-line] 'cua-resize-rectangle-eol) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1431 (define-key cua--rectangle-keymap [remap beginning-of-line] 'cua-resize-rectangle-bol) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1432 (define-key cua--rectangle-keymap [remap end-of-buffer] 'cua-resize-rectangle-bot) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1433 (define-key cua--rectangle-keymap [remap beginning-of-buffer] 'cua-resize-rectangle-top) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1434 (define-key cua--rectangle-keymap [remap scroll-down] 'cua-resize-rectangle-page-up) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1435 (define-key cua--rectangle-keymap [remap scroll-up] 'cua-resize-rectangle-page-down) |
107853
de5ba6f3514c
Bind `C-v' to `scroll-up-command' and `M-v' to `scroll-down-command'.
Juri Linkov <juri@jurta.org>
parents:
106815
diff
changeset
|
1436 (define-key cua--rectangle-keymap [remap scroll-down-command] 'cua-resize-rectangle-page-up) |
de5ba6f3514c
Bind `C-v' to `scroll-up-command' and `M-v' to `scroll-down-command'.
Juri Linkov <juri@jurta.org>
parents:
106815
diff
changeset
|
1437 (define-key cua--rectangle-keymap [remap scroll-up-command] 'cua-resize-rectangle-page-down) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1438 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1439 (define-key cua--rectangle-keymap [remap delete-backward-char] 'cua-delete-char-rectangle) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1440 (define-key cua--rectangle-keymap [remap backward-delete-char] 'cua-delete-char-rectangle) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1441 (define-key cua--rectangle-keymap [remap backward-delete-char-untabify] 'cua-delete-char-rectangle) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1442 (define-key cua--rectangle-keymap [remap self-insert-command] 'cua-insert-char-rectangle) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1443 (define-key cua--rectangle-keymap [remap self-insert-iso] 'cua-insert-char-rectangle) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46180
diff
changeset
|
1444 |
45504
3ddab99699f4
(cua--init-rectangles): Install default
Kim F. Storm <storm@cua.dk>
parents:
45318
diff
changeset
|
1445 ;; Catch self-inserting characters which are "stolen" by other modes |
3ddab99699f4
(cua--init-rectangles): Install default
Kim F. Storm <storm@cua.dk>
parents:
45318
diff
changeset
|
1446 (define-key cua--rectangle-keymap [t] |
3ddab99699f4
(cua--init-rectangles): Install default
Kim F. Storm <storm@cua.dk>
parents:
45318
diff
changeset
|
1447 '(menu-item "sic" cua-insert-char-rectangle :filter cua--self-insert-char-p)) |
3ddab99699f4
(cua--init-rectangles): Install default
Kim F. Storm <storm@cua.dk>
parents:
45318
diff
changeset
|
1448 |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1449 (define-key cua--rectangle-keymap "\r" 'cua-rotate-rectangle) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1450 (define-key cua--rectangle-keymap "\t" 'cua-indent-rectangle) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1451 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1452 (define-key cua--rectangle-keymap [(control ??)] 'cua-help-for-rectangle) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1453 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1454 (define-key cua--rectangle-keymap [mouse-1] 'cua-mouse-set-rectangle-mark) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1455 (define-key cua--rectangle-keymap [down-mouse-1] 'cua--mouse-ignore) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1456 (define-key cua--rectangle-keymap [drag-mouse-1] 'cua--mouse-ignore) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1457 (define-key cua--rectangle-keymap [mouse-3] 'cua-mouse-save-then-kill-rectangle) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1458 (define-key cua--rectangle-keymap [down-mouse-3] 'cua--mouse-ignore) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1459 (define-key cua--rectangle-keymap [drag-mouse-3] 'cua--mouse-ignore) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1460 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1461 (cua--rect-M/H-key 'up 'cua-move-rectangle-up) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1462 (cua--rect-M/H-key 'down 'cua-move-rectangle-down) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1463 (cua--rect-M/H-key 'left 'cua-move-rectangle-left) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1464 (cua--rect-M/H-key 'right 'cua-move-rectangle-right) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1465 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1466 (cua--rect-M/H-key '(control up) 'cua-scroll-rectangle-up) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1467 (cua--rect-M/H-key '(control down) 'cua-scroll-rectangle-down) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1468 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1469 (cua--rect-M/H-key ?a 'cua-align-rectangle) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1470 (cua--rect-M/H-key ?b 'cua-blank-rectangle) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1471 (cua--rect-M/H-key ?c 'cua-close-rectangle) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1472 (cua--rect-M/H-key ?f 'cua-fill-char-rectangle) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1473 (cua--rect-M/H-key ?i 'cua-incr-rectangle) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1474 (cua--rect-M/H-key ?k 'cua-cut-rectangle-as-text) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1475 (cua--rect-M/H-key ?l 'cua-downcase-rectangle) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1476 (cua--rect-M/H-key ?m 'cua-copy-rectangle-as-text) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1477 (cua--rect-M/H-key ?n 'cua-sequence-rectangle) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1478 (cua--rect-M/H-key ?o 'cua-open-rectangle) |
56838
c1345747d0db
(cua--rectangle-padding): Remove.
Kim F. Storm <storm@cua.dk>
parents:
55264
diff
changeset
|
1479 (cua--rect-M/H-key ?p 'cua-toggle-rectangle-virtual-edges) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1480 (cua--rect-M/H-key ?P 'cua-do-rectangle-padding) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1481 (cua--rect-M/H-key ?q 'cua-refill-rectangle) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1482 (cua--rect-M/H-key ?r 'cua-replace-in-rectangle) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1483 (cua--rect-M/H-key ?R 'cua-reverse-rectangle) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1484 (cua--rect-M/H-key ?s 'cua-string-rectangle) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1485 (cua--rect-M/H-key ?t 'cua-text-fill-rectangle) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1486 (cua--rect-M/H-key ?u 'cua-upcase-rectangle) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1487 (cua--rect-M/H-key ?| 'cua-shell-command-on-rectangle) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1488 (cua--rect-M/H-key ?' 'cua-restrict-prefix-rectangle) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1489 (cua--rect-M/H-key ?/ 'cua-restrict-regexp-rectangle) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1490 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1491 (setq cua--rectangle-initialized t)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1492 |
87020
52abd10af81e
(top-level): Move provide to end.
Glenn Morris <rgm@gnu.org>
parents:
84905
diff
changeset
|
1493 (provide 'cua-rect) |
52abd10af81e
(top-level): Move provide to end.
Glenn Morris <rgm@gnu.org>
parents:
84905
diff
changeset
|
1494 |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
1495 ;; arch-tag: b730df53-17b9-4a89-bd63-4a71ec196731 |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1496 ;;; cua-rect.el ends here |