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