annotate lisp/picture.el @ 5934:e2fae7783046 cygwin

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