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