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