annotate lisp/modes/picture.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children 0293115a14e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; picture.el --- "Picture mode" -- editing using quarter-plane screen model.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1985, 1994 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Author: K. Shane Hartman
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Maintainer: FSF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; Synched up with: FSF 19.30.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;; XEmacs changes:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;; -- set zmacs-region-stays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; -- set mouse-track-rectangle-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; -- deleted useless hscroll-point-visible junk.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;; This code provides the picture-mode commands documented in the Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;; manual. The screen is treated as a semi-infinite quarter-plane with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; support for rectangle operations and `etch-a-sketch' character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; insertion in any of eight directions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (defun move-to-column-force (column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 "Move to column COLUMN in current line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 Differs from `move-to-column' in that it creates or modifies whitespace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 if necessary to attain exactly the specified column."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (or (natnump column) (setq column 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (move-to-column column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (let ((col (current-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (if (< col column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (indent-to column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (if (and (/= col column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (= (preceding-char) ?\t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (let (indent-tabs-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (delete-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (indent-to col)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (move-to-column column))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;; XEmacs addition:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (setq zmacs-region-stays t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;; Picture Movement Commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (defun picture-beginning-of-line (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 "Position point at the beginning of the line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 With ARG not nil, move forward ARG - 1 lines first.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 If scan reaches end of buffer, stop there without error."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (if arg (forward-line (1- (prefix-numeric-value arg))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (defun picture-end-of-line (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 "Position point after last non-blank character on current line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 With ARG not nil, move forward ARG - 1 lines first.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 If scan reaches end of buffer, stop there without error."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (if arg (forward-line (1- (prefix-numeric-value arg))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (skip-chars-backward " \t" (prog1 (point) (end-of-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (defun picture-forward-column (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 "Move cursor right, making whitespace if necessary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 With argument, move that many columns."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (let ((target-column (+ (current-column) arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (move-to-column-force target-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;; Picture mode isn't really suited to multi-column characters,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;; but we might as well let the user move across them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (and (< arg 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (> (current-column) target-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (forward-char -1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (defun picture-backward-column (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 "Move cursor left, making whitespace if necessary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 With argument, move that many columns."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (picture-forward-column (- arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (defun picture-move-down (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 "Move vertically down, making whitespace if necessary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 With argument, move that many lines."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (let ((col (current-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (picture-newline arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (move-to-column-force col)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (defconst picture-vertical-step 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 "Amount to move vertically after text character in Picture mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (defconst picture-horizontal-step 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 "Amount to move horizontally after text character in Picture mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (defun picture-move-up (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 "Move vertically up, making whitespace if necessary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 With argument, move that many lines."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (picture-move-down (- arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (defun picture-movement-right ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 "Move right after self-inserting character in Picture mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (picture-set-motion 0 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (defun picture-movement-left ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 "Move left after self-inserting character in Picture mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (picture-set-motion 0 -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (defun picture-movement-up ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 "Move up after self-inserting character in Picture mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (picture-set-motion -1 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (defun picture-movement-down ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 "Move down after self-inserting character in Picture mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (picture-set-motion 1 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (defun picture-movement-nw ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 "Move up and left after self-inserting character in Picture mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (picture-set-motion -1 -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (defun picture-movement-ne ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 "Move up and right after self-inserting character in Picture mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (picture-set-motion -1 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (defun picture-movement-sw ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 "Move down and left after self-inserting character in Picture mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (picture-set-motion 1 -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (defun picture-movement-se ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 "Move down and right after self-inserting character in Picture mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (picture-set-motion 1 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (defun picture-set-motion (vert horiz)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 "Set VERTICAL and HORIZONTAL increments for movement in Picture mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 The modeline is updated to reflect the current direction."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (setq picture-vertical-step vert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 picture-horizontal-step horiz)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (setq mode-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (format "Picture:%s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (car (nthcdr (+ 1 (% horiz 2) (* 3 (1+ (% vert 2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 '(nw up ne left none right sw down se)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (redraw-modeline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (message nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (defun picture-move ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 "Move in direction of `picture-vertical-step' and `picture-horizontal-step'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (picture-move-down picture-vertical-step)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (picture-forward-column picture-horizontal-step))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (defun picture-motion (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 "Move point in direction of current picture motion in Picture mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 With ARG do it that many times. Useful for delineating rectangles in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 conjunction with diagonal picture motion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 Do \\[command-apropos] picture-movement to see commands which control motion."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (picture-move-down (* arg picture-vertical-step))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (picture-forward-column (* arg picture-horizontal-step)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (defun picture-motion-reverse (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 "Move point in direction opposite of current picture motion in Picture mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 With ARG do it that many times. Useful for delineating rectangles in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 conjunction with diagonal picture motion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 Do \\[command-apropos] `picture-movement' to see commands which control motion."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (picture-motion (- arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 ;; Picture insertion and deletion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (defun picture-self-insert (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 "Insert this character in place of character previously at the cursor.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 The cursor then moves in the direction you previously specified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 with the commands `picture-movement-right', `picture-movement-up', etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 Do \\[command-apropos] `picture-movement' to see those commands."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (while (> arg 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (setq arg (1- arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (move-to-column-force (1+ (current-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (delete-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 ;; FSF changes the following to last-command-event.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (insert last-command-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (forward-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (picture-move)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 ;; XEmacs addition:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (setq zmacs-region-stays nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (defun picture-clear-column (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 "Clear out ARG columns after point without moving."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (let* ((opoint (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (original-col (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (target-col (+ original-col arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (move-to-column-force target-col)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (delete-region opoint (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (indent-to (max target-col original-col)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (defun picture-backward-clear-column (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 "Clear out ARG columns before point, moving back over them."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (picture-clear-column (- arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (defun picture-clear-line (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 "Clear out rest of line; if at end of line, advance to next line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 Cleared-out line text goes into the kill ring, as do newlines that are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 advanced over. With argument, clear out (and save in kill ring) that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 many lines."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (if arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (setq arg (prefix-numeric-value arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (kill-line arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (newline (if (> arg 0) arg (- arg))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (if (looking-at "[ \t]*$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (kill-ring-save (point) (progn (forward-line 1) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (kill-region (point) (progn (end-of-line) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 ;; XEmacs addition:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (setq zmacs-region-stays nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (defun picture-newline (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 "Move to the beginning of the following line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 With argument, moves that many lines (up, if negative argument);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 always moves to the beginning of a line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (if (< arg 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (forward-line arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (while (> arg 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (if (eobp) (newline) (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (setq arg (1- arg))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (defun picture-open-line (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 "Insert an empty line after the current line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 With positive argument insert that many lines."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (open-line arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (defun picture-duplicate-line ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 "Insert a duplicate of the current line, below it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (let ((contents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (progn (beginning-of-line) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (progn (picture-newline 1) (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (insert contents))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 ;; Like replace-match, but overwrites.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (defun picture-replace-match (newtext fixedcase literal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (let (ocolumn change pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (goto-char (setq pos (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (setq ocolumn (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 ;; Make the replacement and undo it, to see how it changes the length.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (let ((buffer-undo-list nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 list1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (replace-match newtext fixedcase literal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (setq change (- (current-column) ocolumn))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (setq list1 buffer-undo-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (while list1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (setq list1 (primitive-undo 1 list1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (goto-char pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (if (> change 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (delete-region (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (move-to-column-force (+ change (current-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (replace-match newtext fixedcase literal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (if (< change 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (insert-char ?\ (- change)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 ;; Picture Tabs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (defvar picture-tab-chars "!-~"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 "*A character set which controls behavior of commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 \\[picture-set-tab-stops] and \\[picture-tab-search]. It is NOT a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 regular expression, any regexp special characters will be quoted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 It defines a set of \"interesting characters\" to look for when setting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 \(or searching for) tab stops, initially \"!-~\" (all printing characters).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 For example, suppose that you are editing a table which is formatted thus:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 | foo | bar + baz | 23 *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 | bubbles | and + etc | 97 *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 and that `picture-tab-chars' is \"|+*\". Then invoking
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 \\[picture-set-tab-stops] on either of the previous lines would result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 in the following tab stops
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 : : : :
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 Another example - \"A-Za-z0-9\" would produce the tab stops
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 : : : :
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 Note that if you want the character `-' to be in the set, it must be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 included in a range or else appear in a context where it cannot be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 taken for indicating a range (e.g. \"-A-Z\" declares the set to be the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 letters `A' through `Z' and the character `-'). If you want the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 character `\\' in the set it must be preceded by itself: \"\\\\\".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 The command \\[picture-tab-search] is defined to move beneath (or to) a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 character belonging to this set independent of the tab stops list.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (defun picture-set-tab-stops (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 "Set value of `tab-stop-list' according to context of this line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 This controls the behavior of \\[picture-tab]. A tab stop is set at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 every column occupied by an \"interesting character\" that is preceded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 by whitespace. Interesting characters are defined by the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 `picture-tab-chars', see its documentation for an example of usage.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 With ARG, just (re)set `tab-stop-list' to its default value. The tab
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 stops computed are displayed in the minibuffer with `:' at each stop."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (let (tabs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (if arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (setq tabs (default-value 'tab-stop-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (let ((regexp (concat "[ \t]+[" (regexp-quote picture-tab-chars) "]")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (let ((bol (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (while (re-search-backward regexp bol t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (setq tabs (cons (current-column) tabs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (if (null tabs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (error "No characters in set %s on this line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (regexp-quote picture-tab-chars))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (setq tab-stop-list tabs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (let ((blurb (make-string (1+ (nth (1- (length tabs)) tabs)) ?\ )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (while tabs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (aset blurb (car tabs) ?:)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (setq tabs (cdr tabs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (message blurb)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (defun picture-tab-search (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 "Move to column beneath next interesting char in previous line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 With ARG move to column occupied by next interesting character in this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 line. The character must be preceded by whitespace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 \"interesting characters\" are defined by variable `picture-tab-chars'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 If no such character is found, move to beginning of line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (let ((target (current-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (if (and (not arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (skip-chars-backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (concat "^" (regexp-quote picture-tab-chars))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (not (bobp))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (move-to-column target))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (if (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (concat "[ \t]+[" (regexp-quote picture-tab-chars) "]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (save-excursion (end-of-line) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 'move)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (setq target (1- (current-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (setq target nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (if target
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (move-to-column-force target)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (beginning-of-line))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (defun picture-tab (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 "Tab transparently (just move point) to next tab stop.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 With prefix arg, overwrite the traversed text with spaces. The tab stop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 list can be changed by \\[picture-set-tab-stops] and \\[edit-tab-stops].
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 See also documentation for variable `picture-tab-chars'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (let* ((opoint (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (move-to-tab-stop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (if arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (let (indent-tabs-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (column (current-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (delete-region opoint (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (indent-to column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 ;; XEmacs addition:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (setq zmacs-region-stays t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 ;; Picture Rectangles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (defconst picture-killed-rectangle nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 "Rectangle killed or copied by \\[picture-clear-rectangle] in Picture mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 The contents can be retrieved by \\[picture-yank-rectangle]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (defun picture-clear-rectangle (start end &optional killp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 "Clear and save rectangle delineated by point and mark.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 The rectangle is saved for yanking by \\[picture-yank-rectangle] and replaced
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 with whitespace. The previously saved rectangle, if any, is lost. With
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 prefix argument, the rectangle is actually killed, shifting remaining text."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (interactive "r\nP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (setq picture-killed-rectangle (picture-snarf-rectangle start end killp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (defun picture-clear-rectangle-to-register (start end register &optional killp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 "Clear rectangle delineated by point and mark into REGISTER.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 The rectangle is saved in REGISTER and replaced with whitespace. With
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 prefix argument, the rectangle is actually killed, shifting remaining text."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (interactive "r\ncRectangle to register: \nP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (set-register register (picture-snarf-rectangle start end killp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (defun picture-snarf-rectangle (start end &optional killp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (let ((column (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (indent-tabs-mode nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (prog1 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (if killp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (delete-extract-rectangle start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (prog1 (extract-rectangle start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (clear-rectangle start end))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (move-to-column-force column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 ;; XEmacs addition:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (setq zmacs-region-stays nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (defun picture-yank-rectangle (&optional insertp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 "Overlay rectangle saved by \\[picture-clear-rectangle]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 The rectangle is positioned with upper left corner at point, overwriting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 existing text. With prefix argument, the rectangle is inserted instead,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 shifting existing text. Leaves mark at one corner of rectangle and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 point at the other (diagonally opposed) corner."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (if (not (consp picture-killed-rectangle))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (error "No rectangle saved.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (picture-insert-rectangle picture-killed-rectangle insertp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (defun picture-yank-at-click (click arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 "Insert the last killed rectangle at the position clicked on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 Also move point to one end of the text thus inserted (normally the end).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 Prefix arguments are interpreted as with \\[yank].
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 If `mouse-yank-at-point' is non-nil, insert at point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 regardless of where you click."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (interactive "e\nP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (or mouse-yank-at-point (mouse-set-point click))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (picture-yank-rectangle arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (defun picture-yank-rectangle-from-register (register &optional insertp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 "Overlay rectangle saved in REGISTER.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 The rectangle is positioned with upper left corner at point, overwriting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 existing text. With prefix argument, the rectangle is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 inserted instead, shifting existing text. Leaves mark at one corner
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 of rectangle and point at the other (diagonally opposed) corner."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (interactive "cRectangle from register: \nP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (let ((rectangle (get-register register)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (if (not (consp rectangle))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (error "Register %c does not contain a rectangle." register)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (picture-insert-rectangle rectangle insertp))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (defun picture-insert-rectangle (rectangle &optional insertp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 "Overlay RECTANGLE with upper left corner at point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 Optional argument INSERTP, if non-nil causes RECTANGLE to be inserted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 Leaves the region surrounding the rectangle."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (let ((indent-tabs-mode nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (if (not insertp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (delete-rectangle (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (picture-forward-column (length (car rectangle)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (picture-move-down (1- (length rectangle)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (push-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (insert-rectangle rectangle)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 ;; Picture Keymap, entry and exit points.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (defconst picture-mode-map nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (defun picture-substitute (oldfun newfun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (substitute-key-definition oldfun newfun picture-mode-map global-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (if (not picture-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (setq picture-mode-map (make-keymap 'picture-mode-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 (picture-substitute 'self-insert-command 'picture-self-insert)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (picture-substitute 'forward-char 'picture-forward-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (picture-substitute 'backward-char 'picture-backward-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (picture-substitute 'delete-char 'picture-clear-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 ;; There are two possibilities for what is normally on DEL.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (picture-substitute 'backward-delete-char-untabify 'picture-backward-clear-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (picture-substitute 'delete-backward-char 'picture-backward-clear-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (picture-substitute 'kill-line 'picture-clear-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (picture-substitute 'open-line 'picture-open-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (picture-substitute 'newline 'picture-newline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (picture-substitute 'newline-and-indent 'picture-duplicate-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (picture-substitute 'next-line 'picture-move-down)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (picture-substitute 'previous-line 'picture-move-up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (picture-substitute 'beginning-of-line 'picture-beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (picture-substitute 'end-of-line 'picture-end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (define-key picture-mode-map "\C-c\C-d" 'delete-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (define-key picture-mode-map "\e\t" 'picture-toggle-tab-state)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (define-key picture-mode-map "\t" 'picture-tab)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (define-key picture-mode-map "\e\t" 'picture-tab-search)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (define-key picture-mode-map "\C-c\t" 'picture-set-tab-stops)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (define-key picture-mode-map "\C-c\C-k" 'picture-clear-rectangle)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (define-key picture-mode-map "\C-c\C-w" 'picture-clear-rectangle-to-register)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (define-key picture-mode-map "\C-c\C-y" 'picture-yank-rectangle)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (define-key picture-mode-map "\C-c\C-x" 'picture-yank-rectangle-from-register)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (define-key picture-mode-map "\C-c\C-c" 'picture-mode-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (define-key picture-mode-map "\C-c\C-f" 'picture-motion)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (define-key picture-mode-map "\C-c\C-b" 'picture-motion-reverse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (define-key picture-mode-map "\C-c<" 'picture-movement-left)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (define-key picture-mode-map "\C-c>" 'picture-movement-right)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (define-key picture-mode-map "\C-c^" 'picture-movement-up)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (define-key picture-mode-map "\C-c." 'picture-movement-down)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (define-key picture-mode-map "\C-c`" 'picture-movement-nw)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (define-key picture-mode-map "\C-c'" 'picture-movement-ne)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (define-key picture-mode-map "\C-c/" 'picture-movement-sw)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (define-key picture-mode-map "\C-c\\" 'picture-movement-se)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (defvar picture-mode-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 "If non-nil, its value is called on entry to Picture mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 Picture mode is invoked by the command \\[picture-mode].")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (defvar picture-mode-old-local-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (defvar picture-mode-old-mode-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (defvar picture-mode-old-major-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (defvar picture-mode-old-truncate-lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (defun picture-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 "Switch to Picture mode, in which a quarter-plane screen model is used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 Printing characters replace instead of inserting themselves with motion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 afterwards settable by these commands:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 C-c < Move left after insertion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 C-c > Move right after insertion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 C-c ^ Move up after insertion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 C-c . Move down after insertion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 C-c ` Move northwest (nw) after insertion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 C-c ' Move northeast (ne) after insertion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 C-c / Move southwest (sw) after insertion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 C-c \\ Move southeast (se) after insertion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 The current direction is displayed in the modeline. The initial
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 direction is right. Whitespace is inserted and tabs are changed to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 spaces when required by movement. You can move around in the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 with these commands:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 \\[picture-move-down] Move vertically to SAME column in previous line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 \\[picture-move-up] Move vertically to SAME column in next line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 \\[picture-end-of-line] Move to column following last non-whitespace character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 \\[picture-forward-column] Move right inserting spaces if required.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 \\[picture-backward-column] Move left changing tabs to spaces if required.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 C-c C-f Move in direction of current picture motion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 C-c C-b Move in opposite direction of current picture motion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 Return Move to beginning of next line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 You can edit tabular text with these commands:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 M-Tab Move to column beneath (or at) next interesting character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 `Indents' relative to a previous line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 Tab Move to next stop in tab stop list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 C-c Tab Set tab stops according to context of this line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 With ARG resets tab stops to default (global) value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 See also documentation of variable picture-tab-chars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 which defines \"interesting character\". You can manually
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 change the tab stop list with command \\[edit-tab-stops].
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 You can manipulate text with these commands:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 C-d Clear (replace) ARG columns after point without moving.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 C-c C-d Delete char at point - the command normally assigned to C-d.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 \\[picture-backward-clear-column] Clear (replace) ARG columns before point, moving back over them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 \\[picture-clear-line] Clear ARG lines, advancing over them. The cleared
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 text is saved in the kill ring.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 \\[picture-open-line] Open blank line(s) beneath current line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 You can manipulate rectangles with these commands:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 C-c C-k Clear (or kill) a rectangle and save it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 C-c C-w Like C-c C-k except rectangle is saved in named register.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 C-c C-y Overlay (or insert) currently saved rectangle at point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 C-c C-x Like C-c C-y except rectangle is taken from named register.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 \\[copy-rectangle-to-register] Copies a rectangle to a register.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 \\[advertised-undo] Can undo effects of rectangle overlay commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 commands if invoked soon enough.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 You can return to the previous mode with:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 C-c C-c Which also strips trailing whitespace from every line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 Stripping is suppressed by supplying an argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 Entry to this mode calls the value of picture-mode-hook if non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 Note that Picture mode commands will work outside of Picture mode, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 they are not defaultly assigned to keys."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (if (eq major-mode 'picture-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (error "You are already editing a picture.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (make-local-variable 'picture-mode-old-local-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (setq picture-mode-old-local-map (current-local-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (use-local-map picture-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 (make-local-variable 'picture-mode-old-mode-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (setq picture-mode-old-mode-name mode-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (make-local-variable 'picture-mode-old-major-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (setq picture-mode-old-major-mode major-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (setq major-mode 'picture-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (make-local-variable 'picture-killed-rectangle)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (setq picture-killed-rectangle nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (make-local-variable 'tab-stop-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (setq tab-stop-list (default-value 'tab-stop-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (make-local-variable 'picture-tab-chars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (setq picture-tab-chars (default-value 'picture-tab-chars))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (make-local-variable 'picture-vertical-step)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (make-local-variable 'picture-horizontal-step)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (make-local-variable 'picture-mode-old-truncate-lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (setq picture-mode-old-truncate-lines truncate-lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (setq truncate-lines t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 ;; XEmacs addition:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (make-local-variable 'mouse-track-rectangle-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (setq mouse-track-rectangle-p t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (picture-set-motion 0 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 ;; edit-picture-hook is what we used to run, picture-mode-hook is in doc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (run-hooks 'edit-picture-hook 'picture-mode-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 (substitute-command-keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 "Type \\[picture-mode-exit] in this buffer to return it to %s mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 picture-mode-old-mode-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (defalias 'edit-picture 'picture-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (defun picture-mode-exit (&optional nostrip)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 "Undo picture-mode and return to previous major mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 With no argument strips whitespace from end of every line in Picture buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 otherwise just return to previous mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (if (not (eq major-mode 'picture-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (error "You aren't editing a Picture.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (if (not nostrip) (picture-clean))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (setq mode-name picture-mode-old-mode-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (use-local-map picture-mode-old-local-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (setq major-mode picture-mode-old-major-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (kill-local-variable 'tab-stop-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (setq truncate-lines picture-mode-old-truncate-lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 ;; XEmacs change/addition:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (kill-local-variable 'mouse-track-rectangle-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 (redraw-modeline)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 (defun picture-clean ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 "Eliminate whitespace at ends of lines."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 (while (re-search-forward "[ \t][ \t]*$" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 (delete-region (match-beginning 0) (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 (provide 'picture)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 ;;; picture.el ends here