annotate lisp/picture.el @ 5067:7d7ae8db0341

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