Sync to HEAD
[bpt/emacs.git] / man / picture.texi
CommitLineData
6bf7aab6
DL
1@c This is part of the Emacs manual.
2@c Copyright (C) 1985, 86, 87, 93, 94, 95, 1997 Free Software Foundation, Inc.
3@c See file emacs.texi for copying conditions.
4@node Picture, Sending Mail, Abbrevs, Top
5@chapter Editing Pictures
6@cindex pictures
7@cindex making pictures out of text characters
8@findex edit-picture
9
10 To edit a picture made out of text characters (for example, a picture
11of the division of a register into fields, as a comment in a program),
12use the command @kbd{M-x edit-picture} to enter Picture mode.
13
14 In Picture mode, editing is based on the @dfn{quarter-plane} model of
15text, according to which the text characters lie studded on an area that
16stretches infinitely far to the right and downward. The concept of the end
17of a line does not exist in this model; the most you can say is where the
18last nonblank character on the line is found.
19
20 Of course, Emacs really always considers text as a sequence of
21characters, and lines really do have ends. But Picture mode replaces
22the most frequently-used commands with variants that simulate the
23quarter-plane model of text. They do this by inserting spaces or by
24converting tabs to spaces.
25
26 Most of the basic editing commands of Emacs are redefined by Picture mode
27to do essentially the same thing but in a quarter-plane way. In addition,
28Picture mode defines various keys starting with the @kbd{C-c} prefix to
29run special picture editing commands.
30
31 One of these keys, @kbd{C-c C-c}, is pretty important. Often a
32picture is part of a larger file that is usually edited in some other
33major mode. @kbd{M-x edit-picture} records the name of the previous
34major mode so you can use the @kbd{C-c C-c} command
35(@code{picture-mode-exit}) later to go back to that mode. @kbd{C-c C-c}
36also deletes spaces from the ends of lines, unless given a numeric
37argument.
38
39 The special commands of Picture mode all work in other modes (provided
40the @file{picture} library is loaded), but are not bound to keys except
41in Picture mode. The descriptions below talk of moving ``one column''
42and so on, but all the picture mode commands handle numeric arguments as
43their normal equivalents do.
44
45@vindex picture-mode-hook
46 Turning on Picture mode runs the hook @code{picture-mode-hook}
47(@pxref{Hooks}).
48
49@menu
50* Basic Picture:: Basic concepts and simple commands of Picture Mode.
51* Insert in Picture:: Controlling direction of cursor motion
52 after "self-inserting" characters.
53* Tabs in Picture:: Various features for tab stops and indentation.
54* Rectangles in Picture:: Clearing and superimposing rectangles.
55@end menu
56
57@node Basic Picture, Insert in Picture, Picture, Picture
58@section Basic Editing in Picture Mode
59
60@findex picture-forward-column
61@findex picture-backward-column
62@findex picture-move-down
63@findex picture-move-up
64@cindex editing in Picture mode
65
66 Most keys do the same thing in Picture mode that they usually do, but
67do it in a quarter-plane style. For example, @kbd{C-f} is rebound to
68run @code{picture-forward-column}, a command which moves point one
69column to the right, inserting a space if necessary so that the actual
70end of the line makes no difference. @kbd{C-b} is rebound to run
71@code{picture-backward-column}, which always moves point left one
72column, converting a tab to multiple spaces if necessary. @kbd{C-n} and
73@kbd{C-p} are rebound to run @code{picture-move-down} and
74@code{picture-move-up}, which can either insert spaces or convert tabs
75as necessary to make sure that point stays in exactly the same column.
76@kbd{C-e} runs @code{picture-end-of-line}, which moves to after the last
77nonblank character on the line. There is no need to change @kbd{C-a},
78as the choice of screen model does not affect beginnings of
79lines.
80
81@findex picture-newline
82 Insertion of text is adapted to the quarter-plane screen model through
83the use of Overwrite mode (@pxref{Minor Modes}). Self-inserting characters
84replace existing text, column by column, rather than pushing existing text
85to the right. @key{RET} runs @code{picture-newline}, which just moves to
86the beginning of the following line so that new text will replace that
87line.
88
89@findex picture-backward-clear-column
90@findex picture-clear-column
91@findex picture-clear-line
92 Picture mode provides erasure instead of deletion and killing of
93text. @key{DEL} (@code{picture-backward-clear-column}) replaces the
94preceding character with a space rather than removing it; this moves
95point backwards. @kbd{C-d} (@code{picture-clear-column}) replaces the
96next character or characters with spaces, but does not move point. (If
97you want to clear characters to spaces and move forward over them, use
98@key{SPC}.) @kbd{C-k} (@code{picture-clear-line}) really kills the
99contents of lines, but does not delete the newlines from the
100buffer.
101
102@findex picture-open-line
103 To do actual insertion, you must use special commands. @kbd{C-o}
104(@code{picture-open-line}) creates a blank line after the current line;
105it never splits a line. @kbd{C-M-o} (@code{split-line}) makes sense in
106Picture mode, so it is not changed. @kbd{C-j}
107(@code{picture-duplicate-line}) inserts below the current line another
108line with the same contents.@refill
109
110@kindex C-c C-d @r{(Picture mode)}
111 To do actual deletion in Picture mode, use @kbd{C-w}, @kbd{C-c C-d}
112(which is defined as @code{delete-char}, as @kbd{C-d} is in other
113modes), or one of the picture rectangle commands (@pxref{Rectangles in
114Picture}).
115
116@node Insert in Picture, Tabs in Picture, Basic Picture, Picture
117@section Controlling Motion after Insert
118
119@findex picture-movement-up
120@findex picture-movement-down
121@findex picture-movement-left
122@findex picture-movement-right
123@findex picture-movement-nw
124@findex picture-movement-ne
125@findex picture-movement-sw
126@findex picture-movement-se
127@kindex C-c < @r{(Picture mode)}
128@kindex C-c > @r{(Picture mode)}
129@kindex C-c ^ @r{(Picture mode)}
130@kindex C-c . @r{(Picture mode)}
131@kindex C-c ` @r{(Picture mode)}
132@kindex C-c ' @r{(Picture mode)}
133@kindex C-c / @r{(Picture mode)}
134@kindex C-c \ @r{(Picture mode)}
135 Since ``self-inserting'' characters in Picture mode overwrite and move
136point, there is no essential restriction on how point should be moved.
137Normally point moves right, but you can specify any of the eight
138orthogonal or diagonal directions for motion after a ``self-inserting''
139character. This is useful for drawing lines in the buffer.
140
141@table @kbd
142@item C-c <
143Move left after insertion (@code{picture-movement-left}).
144@item C-c >
145Move right after insertion (@code{picture-movement-right}).
146@item C-c ^
147Move up after insertion (@code{picture-movement-up}).
148@item C-c .
149Move down after insertion (@code{picture-movement-down}).
150@item C-c `
151Move up and left (``northwest'') after insertion (@code{picture-movement-nw}).
152@item C-c '
153Move up and right (``northeast'') after insertion
154(@code{picture-movement-ne}).
155@item C-c /
156Move down and left (``southwest'') after insertion
157@*(@code{picture-movement-sw}).
158@item C-c \
159Move down and right (``southeast'') after insertion
160@*(@code{picture-movement-se}).
161@end table
162
163@kindex C-c C-f @r{(Picture mode)}
164@kindex C-c C-b @r{(Picture mode)}
165@findex picture-motion
166@findex picture-motion-reverse
167 Two motion commands move based on the current Picture insertion
168direction. The command @kbd{C-c C-f} (@code{picture-motion}) moves in the
169same direction as motion after ``insertion'' currently does, while @kbd{C-c
170C-b} (@code{picture-motion-reverse}) moves in the opposite direction.
171
172@node Tabs in Picture, Rectangles in Picture, Insert in Picture, Picture
173@section Picture Mode Tabs
174
175@kindex M-TAB @r{(Picture mode)}
176@findex picture-tab-search
177@vindex picture-tab-chars
178 Two kinds of tab-like action are provided in Picture mode. Use
179@kbd{M-@key{TAB}} (@code{picture-tab-search}) for context-based tabbing.
180With no argument, it moves to a point underneath the next
181``interesting'' character that follows whitespace in the previous
182nonblank line. ``Next'' here means ``appearing at a horizontal position
183greater than the one point starts out at.'' With an argument, as in
184@kbd{C-u M-@key{TAB}}, this command moves to the next such interesting
185character in the current line. @kbd{M-@key{TAB}} does not change the
186text; it only moves point. ``Interesting'' characters are defined by
187the variable @code{picture-tab-chars}, which should define a set of
188characters. The syntax for this variable is like the syntax used inside
189of @samp{[@dots{}]} in a regular expression---but without the @samp{[}
190and the @samp{]}. Its default value is @code{"!-~"}.
191
192@findex picture-tab
193 @key{TAB} itself runs @code{picture-tab}, which operates based on the
194current tab stop settings; it is the Picture mode equivalent of
195@code{tab-to-tab-stop}. Normally it just moves point, but with a numeric
196argument it clears the text that it moves over.
197
198@kindex C-c TAB @r{(Picture mode)}
199@findex picture-set-tab-stops
200 The context-based and tab-stop-based forms of tabbing are brought
201together by the command @kbd{C-c @key{TAB}} (@code{picture-set-tab-stops}).
202This command sets the tab stops to the positions which @kbd{M-@key{TAB}}
203would consider significant in the current line. The use of this command,
204together with @key{TAB}, can get the effect of context-based tabbing. But
205@kbd{M-@key{TAB}} is more convenient in the cases where it is sufficient.
206
207 It may be convenient to prevent use of actual tab characters in
208pictures. For example, this prevents @kbd{C-x @key{TAB}} from messing
209up the picture. You can do this by setting the variable
210@code{indent-tabs-mode} to @code{nil}. @xref{Just Spaces}.
211
212@node Rectangles in Picture,, Tabs in Picture, Picture
213@section Picture Mode Rectangle Commands
214@cindex rectangles and Picture mode
215@cindex Picture mode and rectangles
216
217 Picture mode defines commands for working on rectangular pieces of the
218text in ways that fit with the quarter-plane model. The standard rectangle
219commands may also be useful (@pxref{Rectangles}).
220
221@table @kbd
222@item C-c C-k
223Clear out the region-rectangle with spaces
224(@code{picture-clear-rectangle}). With argument, delete the text.
225@item C-c C-w @var{r}
58fa012d 226Similar, but save rectangle contents in register @var{r} first
6bf7aab6
DL
227(@code{picture-clear-rectangle-to-register}).
228@item C-c C-y
229Copy last killed rectangle into the buffer by overwriting, with upper
230left corner at point (@code{picture-yank-rectangle}). With argument,
231insert instead.
232@item C-c C-x @var{r}
233Similar, but use the rectangle in register @var{r}
234(@code{picture-yank-rectangle-from-register}).
235@end table
236
237@kindex C-c C-k @r{(Picture mode)}
238@kindex C-c C-w @r{(Picture mode)}
239@findex picture-clear-rectangle
240@findex picture-clear-rectangle-to-register
241 The picture rectangle commands @kbd{C-c C-k}
242(@code{picture-clear-rectangle}) and @kbd{C-c C-w}
243(@code{picture-clear-rectangle-to-register}) differ from the standard
244rectangle commands in that they normally clear the rectangle instead of
245deleting it; this is analogous with the way @kbd{C-d} is changed in Picture
246mode.
247
248 However, deletion of rectangles can be useful in Picture mode, so
249these commands delete the rectangle if given a numeric argument.
250@kbd{C-c C-k} either with or without a numeric argument saves the
251rectangle for @kbd{C-c C-y}.
252
253@kindex C-c C-y @r{(Picture mode)}
254@kindex C-c C-x @r{(Picture mode)}
255@findex picture-yank-rectangle
256@findex picture-yank-rectangle-from-register
257 The Picture mode commands for yanking rectangles differ from the
58fa012d
EZ
258standard ones in that they overwrite instead of inserting. This is
259the same way that Picture mode insertion of other text differs from
260other modes. @kbd{C-c C-y} (@code{picture-yank-rectangle}) inserts
261(by overwriting) the rectangle that was most recently killed, while
262@kbd{C-c C-x} (@code{picture-yank-rectangle-from-register}) does
263likewise for the rectangle found in a specified register.
6b61353c
KH
264
265@ignore
266 arch-tag: b7589747-683c-4f40-aed8-1b10403cb666
267@end ignore