comparison lisp/textmodes/two-column.el @ 12506:5dc02bbeb4be

Symbols renamed to be like mode-line indicator. Supposed to now also work for Lucid. (2C-mode-map): New name for `tc-mode-map'. Additionally bound to [f2]. (2C-minor-mode-map) New variable. (2C-mode): New name for `tc-other'. (2C-mode-line-format): New name for `tc-mode-line-format'. (2C-other-buffer-hook): New variable. (2C-separator): New name for `tc-separator'. (2C-window-width): New name for `tc-window-width'. (2C-beyond-fill-column): New name for `tc-beyond-fill-column'. (2C-autoscroll, 2C-autoscroll-start): New variables. (2C-other): New name for `tc-other'. (2C-mode): New name for `tc-mode', `tc-two-columns'. (2C-two-columns): New function. (2C-associate-buffer): New name for `tc-associate-buffer'. (2C-split): New name for `tc-split'. (2C-dissociate): New name for `tc-dissociate'. (2C-merge): New name for `tc-merge'. (2C-associated-buffer): New name for `tc-associated-buffer'. (2C-toggle-autoscroll, 2C-autoscroll): New functions. (tc-scroll-line, tc-scroll-up, tc-scroll-down, tc-recenter): Deleted functions.
author Karl Heuer <kwzh@gnu.org>
date Fri, 07 Jul 1995 20:01:01 +0000
parents cc7cd83ccf3f
children ae2e8daffa31
comparison
equal deleted inserted replaced
12505:0f970ed476cb 12506:5dc02bbeb4be
1 ;;; two-column.el --- minor mode for editing of two-column text 1 ;;; two-column.el --- minor mode for editing of two-column text
2 2
3 ;; Copyright (C) 1992, 1994 Free Software Foundation, Inc. 3 ;; Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
4 4
5 ;; Author: Daniel Pfeiffer <pfeiffer@cix.cict.fr> 5 ;; Author: Daniel.Pfeiffer@Informatik.START.dbp.de, fax (+49 69) 7588-2389
6 ;; Adapted-By: ESR 6 ;; Adapted-By: ESR, Daniel Pfeiffer
7 7
8 ;; This file is part of GNU Emacs. 8 ;; Esperanto: English:
9 9
10 ;; GNU Emacs is free software; you can redistribute it and/or modify 10 ;; ^Ci dosiero estas ero de GNU Emacs. This file is part of GNU Emacs.
11 ;; it under the terms of the GNU General Public License as published by 11
12 ;; the Free Software Foundation; either version 2, or (at your option) 12 ;; GNU Emacs estas libera programaro; GNU Emacs is free software; you can
13 ;; any later version. 13 ;; vi povas disdoni ^gin kaj/a^u modifi redistribute it and/or modify it
14 14 ;; ^gin sub la kondi^coj de la GNU under the terms of the GNU General
15 ;; GNU Emacs is distributed in the hope that it will be useful, 15 ;; ^Generala Publika Licenco kiel pub- Public License as published by the
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 16 ;; likigita far la Liberprogramara Fon- Free Software Foundation; either
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 ;; da^jo; a^u eldono 2a, a^u (la^u via version 2, or (at your option) any
18 ;; GNU General Public License for more details. 18 ;; elekto) ajna posta eldono. later version.
19 19
20 ;; You should have received a copy of the GNU General Public License 20 ;; GNU Emacs estas disdonata en la GNU Emacs is distributed in the hope
21 ;; along with GNU Emacs; see the file COPYING. If not, write to 21 ;; espero ke ^gi estos utila, sed SEN that it will be useful, but WITHOUT
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 22 ;; IA GARANTIO; sen e^c la implicita ANY WARRANTY; without even the
23 23 ;; garantio de VENDEBLECO a^u PRETECO implied warranty of MERCHANTABILITY
24 ;;; Commentary: 24 ;; POR DETERMINITA CELO. Vidu la GNU or FITNESS FOR A PARTICULAR PURPOSE.
25 25 ;; ^Generala Publika Licenco por plenaj See the GNU General Public License
26 ;; This package gives you the ability to edit text in a two-column format. 26 ;; detaloj. for more details.
27 27
28 ;; --8<---- two-column.el ----8<--------8<--------8<--------8<--------8<------- 28 ;; Vi devus ricevinti kopion de la GNU You should have received a copy of
29 ;; Esperanto: English: 29 ;; ^Generala Publika Licenco kune kun the GNU General Public License along
30 30 ;; GNU Emacs; vidu la dosieron COPYING. with GNU Emacs; see the file
31 ;; Minora modalo por samtempa dukolumna Minor mode for simultaneous 31 ;; Alikaze skribu al la COPYING. If not, write to the
32 ;; tajpado two-column editing 32
33 33 ;; Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
34 ;; Tiu minora modalo ebligas al vi This minor mode allows you to 34
35 ;; tajpi sendepende en du apudaj independently edit two adjacent 35
36 ;; bufroj. Vi havas tri eblecojn por buffers. You have three ways to 36 ;;; Komentario: Commentary:
37 ;; eki ^gin. ^Ciu donas al vi start it up. Each gives you a 37
38 ;; horizontale disigatan fenestron, horizontally split window similar to 38 ;; Tiu programaro ebligas vin redakti This package gives you the ability
39 ;; simila al fina apareco de via the final outcome of your text: 39 ;; dukolumnan tekston. to edit text in a two-column format.
40 ;; teksto: 40
41 41
42 ;; C-x 6 2 asocias novan bufron nomatan associates a new buffer called 42 ;; Vi havas tri eblecojn por eki tiun You have three ways to start up this
43 ;; same, sed kun 2C/ anta^u. the same, but with 2C/ 43 ;; mal^cefan modalon. ^Ciu donas al vi minor mode. Each gives you a
44 ;; prepended. 44 ;; horizontale disigatan fenestron, si- horizontally split window similar to
45 45 ;; milan al fina apareco de via teksto: the final outcome of your text:
46 ;; C-x 6 b asocias alian bufron. Vi povas associates another buffer. 46
47 ;; anka^u asocii dataron, se vi This can be used to associate a 47
48 ;; ^jus anta^ue faris C-x C-f. file if you just did C-x C-f. 48 ;; f2 2 asocias novan bufron nomatan associates a new buffer called
49 49 ;; C-x 6 2 same, sed kun 2C/ anta^u. the same, but with 2C/
50 ;; C-x 6 u disigas jam dukolumnan tekston unmerges a two-column text into 50 ;; prepended.
51 ;; en du bufroj ekde la nuna two buffers from the current 51
52 ;; linio, kaj je la nuna kolumno. line and at the current column. 52 ;; f2 b asocias alian bufron. Vi povas associates another buffer.
53 ;; La anta^uaj signoj (ofte The preceding characters (often 53 ;; C-x 6 b anka^u asocii dataron, se vi This can be used to associate a
54 ;; tabeligilo a^u |) estas la tab or |) are the column 54 ;; ^jus anta^ue faris C-x C-f. file if you just did C-x C-f.
55 ;; kolumna disiganto. Linioj kiuj separator. Lines that don't 55
56 ;; ne enhavas ilin ne estas have them won't be separated. 56 ;; f2 s disigas jam dukolumnan tekston splits a two-column text into
57 ;; disigitaj. Kiel la kvara kaj Like the fourth and fifth line 57 ;; C-x 6 s en du bufroj ekde la nuna two buffers from the current
58 ;; la kvina linio se vi disigas if you unmerge this file from 58 ;; linio, kaj je la nuna kolumno. line and at the current column.
59 ;; ^ci dataron ekde la unua angla the first english word. 59 ;; La anta^uaj signoj (ofte The preceding characters (often
60 ;; vorto. 60 ;; tabeligilo a^u |) estas la tab or |) are the column
61 61 ;; kolumna disiganto. Linioj kiuj separator. Lines that don't
62 ;; Je ^cia flanko estas bufro, kiu On each side is a buffer that knows 62 ;; ne enhavas ilin ne estas have them won't be separated.
63 ;; konas la alian. Kun la ordonoj C-x about the other. With the commands 63 ;; disigitaj. Kiel la kvara kaj Like the fourth and fifth line
64 ;; 6 SPC, C-x 6 DEL kaj C-x 6 RET oni C-x 6 SPC, C-x 6 DEL and C-x 6 RET 64 ;; la kvina linio se vi disigas if you split this file from
65 ;; povas suben- a^u supreniri unu you can simultaneously scroll up or 65 ;; ^ci dataron ekde la unua angla the first english word.
66 ;; ekranon, kaj subeniri linion, down by a screenfull and by a line 66 ;; vorto.
67 ;; samtempe en la du bufroj. Al la alia in both buffers. Empty lines are 67
68 ;; bufro estas aldonataj linioj se added to the other buffer if 68 ;; Se vi volas meti longajn liniojn If you include long lines, i.e which
69 ;; necesas, por ke vi vidu la saman necessary, so that you see the same 69 ;; (ekz. programerojn) en la kunigotan will span both columns (eg. source
70 ;; parton. Per C-x 6 C-l vi povas part. With C-x 6 C-l you can 70 ;; tekston, ili devas esti en la code), they should be in what will
71 ;; recentrigi la linion. Kiam vi nur recenter the line. When you only 71 ;; estonte unua kolumno. La alia devas be the first column, with the
72 ;; plu havas unu el la du bufroj have one of the two buffers onscreen 72 ;; havi vakajn linion apud ili. associated buffer having empty lines
73 ;; surekrane vi revidos la alian per you can get the other back with C-x 73 ;; next to them.
74 ;; denove C-x 6 2. 6 2 once more. 74
75 75 ;; Averto: en Emacs kiam vi ^san^gas la Attention: in Emacs when you change
76 ;; Se vi volas meti longajn liniojn If you include long lines, i.e which 76 ;; ^cefan modalon, la mal^cefaj modaloj the major mode, the minor modes are
77 ;; (ekz. programerojn) en la kunigotan will span both columns (eg. source 77 ;; estas anka^u elmemorigitaj. Tiu- also purged from memory. In that
78 ;; tekston, ili devas esti en la code), they should be in what will 78 ;; okaze vi devas religi la du bufrojn case you must reassociate the two
79 ;; estonte unua kolumno. La alia devas be the first column, with the 79 ;; per iu C-x 6-ordono, ekz. C-x 6 b. buffers with any C-x 6-command, e.g.
80 ;; havi malplenajn linion apud ili. associated buffer having empty lines 80 ;; C-x 6 b.
81 ;; next to them. 81
82 82 ;; Kiam vi estos kontenta de la When you have edited both buffers to
83 ;; Averto: en Emacs kiam vi ^san^gas la Attention: in Emacs when you change 83 ;; rezulto, vi kunmetos la du kolumnojn your content, you merge them with
84 ;; ma^joran modalon, la minoraj modaloj the major mode, the minor modes are 84 ;; per C-x 6 1. Se vi poste vidas C-x 6 1. If you then see a problem,
85 ;; estas anka^u elmemorigitaj. Tiu- also purged from memory. In that 85 ;; problemon, vi neniigu la kunmeton you undo the merge with C-x u and
86 ;; okaze vi devas religi la du bufrojn case you must reassociate the two 86 ;; per C-x u kaj plue modifu la du continue to edit the two buffers.
87 ;; per iu C-x 6-ordono, ekz. C-x 6 b. buffers with any C-x 6-command, e.g. 87 ;; bufrojn. Kiam vi ne plu volas tajpi When you no longer want to edit in
88 ;; C-x 6 b. 88 ;; dukolumne, vi eliru el la mal^cefa two columns, you turn off the minor
89 89 ;; modalo per C-x 6 d. mode with C-x 6 d.
90 ;; Kiam vi estos kontenta de la When you have edited both buffers to 90
91 ;; rezulto, vi kunmetos la du kolumnojn your content, you merge them with 91
92 ;; per C-x 6 1. Se vi poste vidas C-x 6 1. If you then see a problem, 92 ;; Aldone al dukolumna redaktado, ek- In addition to two-column editing of
93 ;; problemon, vi neniigu la kunmeton you undo the merge with C-x u and 93 ;; zemple por skribi dulingvan tekston text, for example for writing a
94 ;; per C-x u kaj plue modifu la du continue to edit the two buffers. 94 ;; flank-al-flanke kiel ^ci tiu, aliaj bilingual text side-by-side as shown
95 ;; bufrojn. Kiam vi ne plu volas tajpi When you no longer want to edit in 95 ;; interesaj uzoj trovitas por tiu mal- here, other interesting uses have
96 ;; dukolumne, vi eliru el la minora two columns, you turn off the minor 96 ;; ^cefa modalo: been found for this minor mode:
97 ;; modalo per C-x 6 k. mode with C-x 6 k. 97
98 98 ;; Vi povas disigi la kolumnojn per {+} You can separate the columns with
99 99 ;; ajna pla^ca ^ceno starigante {+} any string that pleases you, by
100 ;; An^stata^u tri `autoload' kaj tri | Instead of three `autoload' and 100 ;; `2C-separator'. Ekzemple "{+} " {+} setting `2C-separator'. For example
101 ;; `global-set-key' vi povas uzi la | three `global-set-key' you can use 101 ;; por amuzi^gi. f2 s a^u C-x 6 s {+} "{+} " if you'd like to have fun.
102 ;; jenon en via dataro ~/.emacs, por | the following in your file 102 ;; traktas tiujn kun prefiksa {+} f2 s or C-x 6 s handles these with a
103 ;; memstare ^sar^gi la modalon: | ~/.emacs, to automatically load 103 ;; argumento kiu signifas la longon {+} prefix argument that means the
104 ;; | the mode: 104 ;; de tia ^ceno. {+} desired length of such a string.
105 105
106 ;; (global-set-key "\C-x6" 106
107 ;; '(lambda () (interactive) 107 ;; Programistoj eble ^satus la eblecon Programmers might like the ability
108 ;; (load-library "two-column") 108 ;; forspliti la komentarian kolumnon de to split off the comment column of a
109 ;; (call-interactively 109 ;; dosiero kiel la sekvanta. Vi povas file that looks like the following.
110 ;; (cdr (assq (read-char) tc-mode-map))))) 110 ;; rearan^gigi la paragrafon. La pro- You can fill-paragraph the comment.
111 111 ;; blemo estas ke koda^jo tuj lar- The problem is, code quickly gets
112 ;; Se vi ^satus havi la dukolumnajn | If you'd like to have the 112 ;; ^gi^gas, tiel ke vi bezonas pli rather wide, so you need to use a
113 ;; ordonojn je funkciklavo <f2>, vi | two-column commands on function 113 ;; mallar^gan komentarian kolumnon. narrower comment column. Code lines
114 ;; povas uzi la jenon en via dataro | key <f2>, you can use the 114 ;; Koda^jaj linioj tra `comment-column' that reach beyond `comment-column'
115 ;; ~/.emacs: | following in your file ~/.emacs: 115 ;; ne problemas, krom ke vi ne vidos are no problem, except that you
116 116 ;; iliajn finojn dum redaktado. won't see their end during editing.
117 ;; (global-set-key [f2] (function 117
118 ;; (lambda () 118
119 ;; (interactive)
120 ;; (load-library "two-column")
121 ;; (global-set-key [f2] tc-mode-map)
122 ;; (call-interactively
123 ;; (cdr (assq (read-char) tc-mode-map))))))
124
125 ;; In addition to two-column editing of text, for example for writing a
126 ;; bilingual text side-by-side as shown below in the file's prolog, other
127 ;; interesting uses have been found for this minor mode:
128 ;;
129 ;;
130 ;; You can separate the columns with {+} C-x 6 u or <f2> u if you prefer
131 ;; any string that pleases you, by {+} handles these with a prefix argument
132 ;; setting tc-separator. For {+} that enables you to declare the
133 ;; example "{+} " if you like to {+} desired length of such a string.
134 ;; amuse yourself.
135 ;;
136 ;;
137 ;; keyword You can write any text corresponding to a
138 ;; given keyword in a filled paragraph next to
139 ;; it. Note that the width of the first column
140 ;; may be less than window-min-width in the
141 ;; result, but will be displayed at that width.
142 ;;
143 ;; another This is not a three- or multi-column mode.
144 ;; The example in the file's prolog required
145 ;; working on two columns and then treating the
146 ;; result as one column in order to add the
147 ;; third.
148 ;;
149 ;;
150 ;; Programmers might like the ability to split off the comment column of
151 ;; a file that looks like the following. The advantage is that with
152 ;; (setq fill-prefix "-- ") you can run M-q (fill-paragraph) on the
153 ;; comment. The problem is, code quickly gets rather wide, so you need
154 ;; to use a narrower comment column, which is less interesting, unless
155 ;; you have a 132-column screen. Code lines that reach beyond
156 ;; comment-column are no problem, except that you won't always see their
157 ;; end during editing.
158 ;;
159 ;; BEGIN -- This is just some meaningless 119 ;; BEGIN -- This is just some meaningless
160 ;; FOR i IN 1..10 LOOP -- code in Ada, that runs foobar 120 ;; FOR i IN 1..10 LOOP -- code in Ada, that runs foobar
161 ;; foobar( i ); -- once for each argument from one 121 ;; foobar( i ); -- once for each argument from one
162 ;; END LOOP; -- to ten, and then we're already 122 ;; END LOOP; -- to ten, and then we're already
163 ;; END; -- through with it. 123 ;; END; -- through with it.
164 ;; 124
165 ;; Better yet, you can put the point before "This", type M-3 C-x 6 u 125 ;; Pli bone ankora^u, vi povas pozici- Better yet, you can put the point
166 ;; which makes "-- " the separator between a no-comments Ada buffer, and 126 ;; i^gi anta^u "This", tajpi M-3 f2 s before "This", type M-3 f2 s
167 ;; a plain text comment buffer. When you put them back together, every 127 ;; kiu igas "-- " la separigilon inter which makes "-- " the separator
168 ;; non-empty line of the 2nd column will again be preceded by "-- ". 128 ;; senkomentaria Ada bufro kaj nur- between a no-comments Ada buffer,
169 ;; 129 ;; teksta komentaria bufro. Kiam vi and a plain text comment buffer.
170 ;; 130 ;; denove kuni^gos ilin, ^ciu nevaka When you put them back together,
171 ;; The <f2> function key hack (which is one of the rare times when 131 ;; linio de l' dua kolumno denove every non-empty line of the 2nd
172 ;; function keys are mnemonic) at the end of the file's prolog requires 132 ;; anta^uhavos "-- ". column will again be preceded by
173 ;; that the lisp/term/*.el for your terminal use the standard 133 ;; "-- ".
174 ;; conventions. Too bad that some don't (at least not in version 18.55). 134
175 ;; The Sun one is hopelessly non-standard, and vt2[024]0 somehow forgot
176 ;; to define <f1> thru <f5>. (It defines <pf1> thru <pf4> instead, but
177 ;; that is not what we need on an X terminal.) If you want to use those,
178 ;; you'll need another hack something like:
179 ;;
180 ;; (if (string= (system-name) "cix")
181 ;; (progn
182 ;; (load-library "term/vt200.el")
183 ;; (define-key CSI-map "12~" (cons function-keymap ?\^b)))
184 ;; (global-unset-key "\e[")
185 ;; (define-key esc-map "[225z" (cons function-keymap ?\^b)))
186 ;;
187 ;; where "cix" is the non-sun machine I use. Actually I use the same X
188 ;; terminal to connect to both machines, and I want to keep my ~/.emacs
189 ;; identical on both. Bother, the two Emacses don't recognize the same
190 ;; keys and assign different sequences to those they do! I sure hope all
191 ;; this nonsense will stop with version 19 (or preferably soon) where I'd
192 ;; like to be able to say (define-key some-map '<f2> some-cmd), and see
193 ;; <f2> rather than some unintelligible ESC-sequence in command key
194 ;; sequences.
195 135
196 ;;; Code: 136 ;;; Code:
197 137
138
139 ;; Lucid patch
140 (or (fboundp 'frame-width)
141 (fset 'frame-width 'screen-width))
142
143
198 ;;;;; Set up keymap ;;;;; 144 ;;;;; Set up keymap ;;;;;
199 145
146 (defvar 2C-mode-map
147 (let ((map (make-sparse-keymap)))
148 (define-key map "2" '2C-two-columns)
149 (define-key map [f2] '2C-two-columns)
150 (define-key map "b" '2C-associate-buffer)
151 (define-key map "s" '2C-split)
152 (define-key map "{" 'shrink-window-horizontally)
153 (define-key map "}" 'enlarge-window-horizontally)
154 map)
155 "Keymap for commands for setting up two-column mode.")
156
157
158
159 ;;;###autoload (autoload '2C-command "two-column" () t 'keymap)
160 (fset '2C-command 2C-mode-map)
161
200 ;;;###autoload 162 ;;;###autoload
201 (defvar tc-mode-map nil 163 ;; This one is for historical reasons and simple keyboards, it is not
202 "Keymap for commands for two-column mode.") 164 ;; at all mnemonic. All usual sequences containing 2 were used, and
165 ;; f2 could not be set up in a standard way under Emacs 18.
166 (global-set-key "\C-x6" '2C-command)
167
203 168
204 ;;;###autoload 169 ;;;###autoload
205 (if tc-mode-map 170 (global-set-key [f2] '2C-command)
206 () 171
207 (setq tc-mode-map (make-sparse-keymap)) 172
208 (define-key tc-mode-map "1" 'tc-merge) 173 (defvar 2C-minor-mode-map
209 (define-key tc-mode-map "2" 'tc-two-columns) 174 (let ((map (make-sparse-keymap)))
210 (define-key tc-mode-map "b" 'tc-associate-buffer) 175 (define-key map "1" '2C-merge)
211 (define-key tc-mode-map "d" 'tc-dissociate) 176 (define-key map "d" '2C-dissociate)
212 (define-key tc-mode-map "\C-l" 'tc-recenter) 177 (define-key map "o" '2C-associated-buffer)
213 (define-key tc-mode-map "o" 'tc-associated-buffer) 178 (define-key map "|" '2C-toggle-autoscroll)
214 (define-key tc-mode-map "s" 'tc-split) 179 map)
215 (define-key tc-mode-map "{" 'shrink-window-horizontally) 180 "Keymap for commands for use in two-column mode.")
216 (define-key tc-mode-map "}" 'enlarge-window-horizontally) 181
217 (define-key tc-mode-map " " 'tc-scroll-up) 182
218 (define-key tc-mode-map "\^?" 'tc-scroll-down) 183 (setq minor-mode-map-alist
219 (define-key tc-mode-map "\C-m" 'tc-scroll-line)) 184 (cons (cons '2C-mode
220 185 (let ((map (make-sparse-keymap)))
221 ;;;###autoload 186 (substitute-key-definition '2C-command 2C-minor-mode-map
222 (global-set-key "\C-x6" tc-mode-map) 187 map (current-global-map))
188 map))
189 minor-mode-map-alist))
223 190
224 ;;;;; variable declarations ;;;;; 191 ;;;;; variable declarations ;;;;;
225 192
226 ;; markers seem to be the only buffer-id not affected by renaming 193 ;; Markers seem to be the only buffer-id not affected by renaming a buffer.
227 ;; a buffer. This nevertheless loses when a buffer is killed. 194 ;; This nevertheless loses when a buffer is killed. The variable-name is
228 (defvar tc-other nil 195 ;; required by `describe-mode'.
196 (defvar 2C-mode nil
229 "Marker to the associated buffer, if non-nil.") 197 "Marker to the associated buffer, if non-nil.")
230 (make-variable-buffer-local 'tc-other) 198 (make-variable-buffer-local '2C-mode)
231 (put 'tc-other 'permanent-local t) 199 (put '2C-mode 'permanent-local t)
232 200
233 (setq minor-mode-alist (cons '(tc-other " 2C") minor-mode-alist)) 201
202
203 (setq minor-mode-alist (cons '(2C-mode " 2C") minor-mode-alist))
204
205
234 206
235 ;; rearranged, so that the pertinent info will show in 40 columns 207 ;; rearranged, so that the pertinent info will show in 40 columns
236 (defvar tc-mode-line-format 208 (defvar 2C-mode-line-format
237 '("-%*- %15b --" (-3 . "%p") "--%[(" mode-name 209 '("-%*- %15b --" (-3 . "%p") "--%[(" mode-name
238 minor-mode-alist mode-line-process "%n" ")%]%-") 210 minor-mode-alist "%n" mode-line-process ")%]%-")
239 "*Value of mode-line-format for a buffer in two-column minor mode.") 211 "*Value of mode-line-format for a buffer in two-column minor mode.")
240 212
241 (defvar tc-separator "" 213
214 (defvar 2C-other-buffer-hook 'text-mode
215 "*Hook run in new buffer when it is associated with current one.")
216
217
218 (defvar 2C-separator ""
242 "*A string inserted between the two columns when merging. 219 "*A string inserted between the two columns when merging.
243 This gets set locally by \\[tc-split].") 220 This gets set locally by \\[2C-split].")
244 (put 'tc-separator 'permanent-local t) 221 (put '2C-separator 'permanent-local t)
245 222
246 (defvar tc-window-width 40 223
224
225 (defvar 2C-window-width 40
247 "*The width of the first column. (Must be at least `window-min-width') 226 "*The width of the first column. (Must be at least `window-min-width')
248 This value is local for every buffer that sets it.") 227 This value is local for every buffer that sets it.")
249 (make-variable-buffer-local 'tc-window-width) 228 (make-variable-buffer-local '2C-window-width)
250 (put 'tc-window-width 'permanent-local t) 229 (put '2C-window-width 'permanent-local t)
251 230
252 (defvar tc-beyond-fill-column 4 231
232
233 (defvar 2C-beyond-fill-column 4
253 "*Base for calculating `fill-column' for a buffer in two-column minor mode. 234 "*Base for calculating `fill-column' for a buffer in two-column minor mode.
254 The value of `fill-column' becomes `tc-window-width' for this buffer 235 The value of `fill-column' becomes `2C-window-width' for this buffer
255 minus this value.") 236 minus this value.")
256 237
257 (defvar tc-mode-hook nil 238
258 "Function called, if non-nil, whenever turning on two-column minor mode. 239
259 It can get called by \\[tc-two-columns] (tc-two-columns), \\[tc-split] (tc-split) 240 (defvar 2C-autoscroll t
260 and \\[tc-associate-buffer] (tc-associate-buffer), on both buffers.") 241 "If this is non-nil, Emacs attempts to keep the two buffers aligned.")
242
243
244
245 (defvar 2C-autoscroll-start nil)
246 (make-variable-buffer-local '2C-autoscroll-start)
261 247
262 ;;;;; base functions ;;;;; 248 ;;;;; base functions ;;;;;
263 249
264 ;; the access method for the other buffer. this tries to remedy against 250 ;; The access method for the other buffer. This tries to remedy against
265 ;; lost local variables and lost buffers. 251 ;; lost local variables and lost buffers.
266 (defun tc-other () 252 (defun 2C-other ()
267 (if tc-other 253 (if 2C-mode
268 (or (prog1 254 (or (prog1
269 (marker-buffer tc-other) 255 (marker-buffer 2C-mode)
270 (setq mode-line-format tc-mode-line-format )) 256 (setq mode-line-format 2C-mode-line-format))
271 ; The associated buffer somehow got killed. 257 ;; The associated buffer somehow got killed.
272 (progn 258 (progn
273 ; The other variables may later be useful if the user 259 ;; The other variables may later be useful if the user
274 ; reestablishes the association. 260 ;; reestablishes the association.
275 (kill-local-variable 'tc-other) 261 (kill-local-variable '2C-mode)
276 (kill-local-variable 'mode-line-format) 262 (kill-local-variable 'mode-line-format)
277 nil)))) 263 nil))))
278 264
279 ;;;###autoload 265
280 (defun tc-two-columns (&optional buffer) 266
281 "Split current window vertically for two-column editing. 267 ;; function for setting up two-column minor mode in a buffer associated
282 268 ;; with the buffer pointed to by the marker other.
283 When called the first time, associates a buffer with the current 269 (defun 2C-mode (other)
284 buffer. Both buffers are put in two-column minor mode and 270 "Minor mode for independently editing two columns.
285 tc-mode-hook gets called on both. These buffers remember 271 This is set up for two associated buffers by the three commands bound
286 about one another, even when renamed. 272 to \\[2C-two-columns] , \\[2C-associate-buffer] and \\[2C-split].
287 273 Turning on two-column mode calls the value of the variable `2C-mode-hook',
288 When called again, restores the screen layout with the current buffer 274 if that value is non-nil.
289 first and the associated buffer to it's right. 275
276 These buffers can be edited separately, for example with `fill-paragraph'.
277 If you want to disable parallel scrolling temporarily, use \\[2C-toggle-autoscroll] .
290 278
291 If you include long lines, i.e which will span both columns (eg. 279 If you include long lines, i.e which will span both columns (eg.
292 source code), they should be in what will be the first column, with 280 source code), they should be in what will be the first column, with
293 the associated buffer having empty lines next to them. 281 the associated buffer having empty lines next to them.
294 282
283 Potential uses are writing bilingual texts, or editing the comments of a
284 source code. See the file lisp/two-column.el for detailed examples.
285
295 You have the following commands at your disposal: 286 You have the following commands at your disposal:
296 287
297 \\[tc-two-columns] Rearrange screen 288 \\[2C-two-columns] Rearrange screen with current buffer first
298 \\[tc-associate-buffer] Reassociate buffer after changing major mode 289 \\[2C-associate-buffer] Reassociate buffer after changing major mode
299 \\[tc-scroll-up] Scroll both buffers up by a screenfull
300 \\[tc-scroll-down] Scroll both buffers down by a screenful
301 \\[tc-scroll-line] Scroll both buffers up by one or more lines
302 \\[tc-recenter] Recenter and realign other buffer
303 \\[shrink-window-horizontally], \\[enlarge-window-horizontally] Shrink, enlarge current column 290 \\[shrink-window-horizontally], \\[enlarge-window-horizontally] Shrink, enlarge current column
304 \\[tc-associated-buffer] Switch to associated buffer 291 \\[2C-associated-buffer] Switch to associated buffer
305 \\[tc-merge] Merge both buffers 292 \\[2C-merge] Merge both buffers
306 293 \\[2C-dissociate] Dissociate the two buffers
307 These keybindings can be customized in your ~/.emacs by `tc-prefix' 294
308 and `tc-mode-map'. 295 These keybindings can be customized in your ~/.emacs by `2C-mode-map',
296 `2C-minor-mode-map' and by binding `2C-command' to some prefix.
309 297
310 The appearance of the screen can be customized by the variables 298 The appearance of the screen can be customized by the variables
311 `tc-window-width', `tc-beyond-fill-column', 299 `2C-window-width', `2C-beyond-fill-column', `2C-mode-line-format' and
312 `tc-mode-line-format' and `truncate-partial-width-windows'." 300 `truncate-partial-width-windows'."
313 301 (make-variable-buffer-local 'post-command-hook)
302 (setq fill-column (- 2C-window-width
303 2C-beyond-fill-column)
304 post-command-hook '2C-autoscroll
305 mode-line-format 2C-mode-line-format
306 2C-mode other)
307 (run-hooks '2C-mode-hook))
308
309
310
311 ;;;###autoload
312 (defun 2C-two-columns (&optional buffer)
313 "Split current window vertically for two-column editing.
314 When called the first time, associates a buffer with the current
315 buffer in two-column minor mode (see \\[describe-mode] ).
316 Runs `2C-other-buffer-hook' in the new buffer.
317 When called again, restores the screen layout with the current buffer
318 first and the associated buffer to it's right."
314 (interactive "P") 319 (interactive "P")
315 ; first go to full width, so that we can certainly split into 320 ;; first go to full width, so that we can certainly split into two windows
316 ; two windows
317 (if (< (window-width) (frame-width)) 321 (if (< (window-width) (frame-width))
318 (enlarge-window 99999 t)) 322 (enlarge-window 99999 t))
319 (split-window-horizontally 323 (split-window-horizontally
320 (max window-min-width (min tc-window-width 324 (max window-min-width (min 2C-window-width
321 (- (frame-width) window-min-width)))) 325 (- (frame-width) window-min-width))))
322 (if (tc-other) 326 (if (2C-other)
323 (progn 327 (progn
324 (other-window 1) 328 (other-window 1)
325 (switch-to-buffer (tc-other)) 329 (switch-to-buffer (2C-other))
326 (other-window -1) 330 (other-window -1)
327 ; align buffers if necessary 331 (if 2C-autoscroll
328 (tc-scroll-line 0)) 332 (2C-toggle-autoscroll t)))
329 333
330 ; set up minor mode linking two buffers 334 (2C-mode (prog1 (point-marker)
331 (setq fill-column (- tc-window-width 335 (other-window 1)
332 tc-beyond-fill-column) 336 (switch-to-buffer
333 mode-line-format tc-mode-line-format) 337 (or buffer
334 (run-hooks tc-mode-hook) 338 (generate-new-buffer
335 (let ((other (point-marker))) 339 (concat "2C/" (buffer-name)))))
336 (other-window 1) 340 (or buffer
337 (switch-to-buffer 341 (run-hooks '2C-other-buffer-hook))))
338 (or buffer 342
339 (generate-new-buffer 343 (2C-mode (prog1 (point-marker)
340 (concat "2C/" (buffer-name))))) 344 (other-window -1)))))
341 (or buffer 345
342 (text-mode)) 346
343 (setq fill-column (- tc-window-width
344 tc-beyond-fill-column)
345 mode-line-format tc-mode-line-format
346 tc-other other
347 other (point-marker))
348 (run-hooks tc-mode-hook)
349 (other-window -1)
350 (setq tc-other other))))
351
352 (defalias 'tc-mode 'tc-two-columns)
353 347
354 ;;;###autoload 348 ;;;###autoload
355 (defun tc-associate-buffer () 349 (defun 2C-associate-buffer ()
356 "Associate another buffer with this one in two-column minor mode. 350 "Associate another buffer with this one in two-column minor mode.
357 Can also be used to associate a just previously visited file, by 351 Can also be used to associate a just previously visited file, by
358 accepting the proposed default buffer. 352 accepting the proposed default buffer.
359 353
360 See \\[tc-two-columns] and `lisp/two-column.el' for further details." 354 \(See \\[describe-mode] .)"
361 (interactive) 355 (interactive)
362 (let ((b1 (current-buffer)) 356 (let ((b1 (current-buffer))
363 (b2 (or (tc-other) 357 (b2 (or (2C-other)
364 (read-buffer "Associate buffer: " (other-buffer))))) 358 (read-buffer "Associate buffer: " (other-buffer)))))
365 (save-excursion 359 (save-excursion
366 (setq tc-other nil) 360 (setq 2C-mode nil)
367 (set-buffer b2) 361 (set-buffer b2)
368 (and (tc-other) 362 (and (2C-other)
369 (not (eq b1 (tc-other))) 363 (not (eq b1 (2C-other)))
370 (error "Buffer already associated with buffer `%s'." 364 (error "Buffer already associated with buffer `%s'."
371 (buffer-name (tc-other)))) 365 (buffer-name (2C-other))))
372 (setq b1 (and (assq 'tc-window-width (buffer-local-variables)) 366 (setq b1 (and (assq '2C-window-width (buffer-local-variables))
373 tc-window-width))) 367 2C-window-width)))
374 ; if other buffer has a local width, adjust here too 368 ; if other buffer has a local width, adjust here too
375 (if b1 (setq tc-window-width (- (frame-width) b1))) 369 (if b1 (setq 2C-window-width (- (frame-width) b1)))
376 (tc-two-columns b2))) 370 (2C-two-columns b2)))
371
372
377 373
378 ;;;###autoload 374 ;;;###autoload
379 (defun tc-split (arg) 375 (defun 2C-split (arg)
380 "Unmerge a two-column text into two buffers in two-column minor mode. 376 "Split a two-column text at point, into two buffers in two-column minor mode.
381 The text is unmerged at the cursor's column which becomes the local 377 Point becomes the local value of `2C-window-width'. Only lines that
382 value of `tc-window-width'. Only lines that have the ARG same 378 have the ARG same preceding characters at that column get split. The
383 preceding characters at that column get split. The ARG preceding 379 ARG preceding characters without any leading whitespace become the local
384 characters without any leading whitespace become the local value for 380 value for `2C-separator'. This way lines that continue across both
385 `tc-separator'. This way lines that continue across both
386 columns remain untouched in the first buffer. 381 columns remain untouched in the first buffer.
387 382
388 This function can be used with a prototype line, to set up things as 383 This function can be used with a prototype line, to set up things. You
389 you like them. You write the first line of each column with the 384 write the first line of each column and then split that line. E.g.:
390 separator you like and then unmerge that line. E.g.: 385
391 386 First column's text sSs Second column's text
392 First column's text sSs Second columns text
393 \\___/\\ 387 \\___/\\
394 / \\ 388 / \\
395 5 character Separator You type M-5 \\[tc-split] with the point here 389 5 character Separator You type M-5 \\[2C-split] with the point here.
396 390
397 See \\[tc-two-columns] and `lisp/two-column.el' for further details." 391 \(See \\[describe-mode] .)"
398 (interactive "p") 392 (interactive "*p")
399 (and (tc-other) 393 (and (2C-other)
400 (if (y-or-n-p (concat "Overwrite associated buffer `" 394 (if (y-or-n-p (concat "Overwrite associated buffer `"
401 (buffer-name (tc-other)) 395 (buffer-name (2C-other))
402 "'? ")) 396 "'? "))
403 (save-excursion 397 (save-excursion
404 (set-buffer (tc-other)) 398 (set-buffer (2C-other))
405 (erase-buffer)) 399 (erase-buffer))
406 (signal 'quit nil))) 400 (signal 'quit nil)))
407 (let ((point (point)) 401 (let ((point (point))
408 ; make next-line always come back to same column 402 ; make next-line always come back to same column
409 (goal-column (current-column)) 403 (goal-column (current-column))
412 chars other) 406 chars other)
413 (save-excursion 407 (save-excursion
414 (backward-char arg) 408 (backward-char arg)
415 (setq chars (buffer-substring (point) point)) 409 (setq chars (buffer-substring (point) point))
416 (skip-chars-forward " \t" point) 410 (skip-chars-forward " \t" point)
417 (make-local-variable 'tc-separator) 411 (make-local-variable '2C-separator)
418 (setq tc-separator (buffer-substring (point) point) 412 (setq 2C-separator (buffer-substring (point) point)
419 tc-window-width (current-column))) 413 2C-window-width (current-column)))
420 (tc-two-columns) 414 (2C-two-columns)
421 (setq other (tc-other)) 415 (setq other (2C-other))
422 ; now we're ready to actually unmerge 416 ; now we're ready to actually split
423 (save-excursion 417 (save-excursion
424 (while (not (eobp)) 418 (while (not (eobp))
425 (if (not (and (= (current-column) goal-column) 419 (if (not (and (= (current-column) goal-column)
426 (string= chars 420 (string= chars
427 (buffer-substring (point) 421 (buffer-substring (point)
441 (1+ (point))))) 435 (1+ (point)))))
442 (delete-region point (point)) 436 (delete-region point (point))
443 (setq n 0)) 437 (setq n 0))
444 (next-line 1))))) 438 (next-line 1)))))
445 439
446 ;;;###autoload 440
447 (defun tc-dissociate () 441
442
443 (defun 2C-dissociate ()
448 "Turn off two-column minor mode in current and associated buffer. 444 "Turn off two-column minor mode in current and associated buffer.
449 If the associated buffer is unmodified and empty, it is killed." 445 If the associated buffer is unmodified and empty, it is killed."
450 (interactive) 446 (interactive)
451 (let ((buffer (current-buffer))) 447 (let ((buffer (current-buffer)))
452 (save-excursion 448 (save-excursion
453 (and (tc-other) 449 (and (2C-other)
454 (set-buffer (tc-other)) 450 (set-buffer (2C-other))
455 (or (not (tc-other)) 451 (or (not (2C-other))
456 (eq buffer (tc-other))) 452 (eq buffer (2C-other)))
457 (if (and (not (buffer-modified-p)) 453 (if (and (not (buffer-modified-p))
458 (eobp) (bobp)) 454 (eobp) (bobp))
459 (kill-buffer nil) 455 (kill-buffer nil)
460 (kill-local-variable 'tc-other) 456 (kill-local-variable '2C-mode)
461 (kill-local-variable 'tc-window-width) 457 (kill-local-variable '2C-window-width)
462 (kill-local-variable 'tc-separator) 458 (kill-local-variable '2C-separator)
463 (kill-local-variable 'mode-line-format) 459 (kill-local-variable 'mode-line-format)
464 (kill-local-variable 'fill-column)))) 460 (kill-local-variable 'fill-column))))
465 (kill-local-variable 'tc-other) 461 (kill-local-variable '2C-mode)
466 (kill-local-variable 'tc-window-width) 462 (kill-local-variable '2C-window-width)
467 (kill-local-variable 'tc-separator) 463 (kill-local-variable '2C-separator)
468 (kill-local-variable 'mode-line-format) 464 (kill-local-variable 'mode-line-format)
469 (kill-local-variable 'fill-column))) 465 (kill-local-variable 'fill-column)))
470 466
471 467
468
472 ;; this doesn't use yank-rectangle, so that the first column can 469 ;; this doesn't use yank-rectangle, so that the first column can
473 ;; contain long lines 470 ;; contain long lines
474 ;;;###autoload 471 (defun 2C-merge ()
475 (defun tc-merge ()
476 "Merges the associated buffer with the current buffer. 472 "Merges the associated buffer with the current buffer.
477 They get merged at the column, which is the value of 473 They get merged at the column, which is the value of `2C-window-width',
478 `tc-window-width', i.e. usually at the vertical window 474 i.e. usually at the vertical window separator. This separator gets
479 separator. This separator gets replaced with white space. Beyond 475 replaced with white space. Beyond that the value of `2C-separator' gets
480 that the value of gets inserted on merged lines. The two columns are 476 inserted on merged lines. The two columns are thus pasted side by side,
481 thus pasted side by side, in a single text. If the other buffer is 477 in a single text. If the other buffer is not displayed to the left of
482 not displayed to the left of this one, then this one becomes the left 478 this one, then this one becomes the left column.
483 column. 479
484 480 If you want `2C-separator' on empty lines in the second column,
485 If you want `tc-separator' on empty lines in the second column,
486 you should put just one space in them. In the final result, you can strip 481 you should put just one space in them. In the final result, you can strip
487 off trailing spaces with \\[beginning-of-buffer] \\[replace-regexp] [ SPC TAB ] + $ RET RET" 482 off trailing spaces with \\[beginning-of-buffer] \\[replace-regexp] [ SPC TAB ] + $ RET RET"
488 483
489 (interactive) 484 (interactive)
490 (or (tc-other) 485 (or (2C-other)
491 (error "You must first set two-column minor mode.")) 486 (error "You must first set two-column minor mode."))
492 (and (> (car (window-edges)) 0) ; not touching left edge of screen 487 (and (> (car (window-edges)) 0) ; not touching left edge of screen
493 (eq (window-buffer (previous-window)) 488 (eq (window-buffer (previous-window))
494 (tc-other)) 489 (2C-other))
495 (other-window -1)) 490 (other-window -1))
496 (save-excursion 491 (save-excursion
497 (let ((b1 (current-buffer)) 492 (let ((b1 (current-buffer))
498 (b2 (tc-other)) 493 (b2 (2C-other))
499 string) 494 string)
500 (goto-char (point-min)) 495 (goto-char (point-min))
501 (set-buffer b2) 496 (set-buffer b2)
502 (goto-char (point-min)) 497 (goto-char (point-min))
503 (while (not (eobp)) 498 (while (not (eobp))
507 (forward-char)) ; next line 502 (forward-char)) ; next line
508 (set-buffer b1) 503 (set-buffer b1)
509 (if (string= string "") 504 (if (string= string "")
510 () 505 ()
511 (end-of-line) 506 (end-of-line)
512 (indent-to-column tc-window-width) 507 (indent-to-column 2C-window-width)
513 (insert tc-separator string)) 508 (insert 2C-separator string))
514 (next-line 1) ; add one if necessary 509 (next-line 1) ; add one if necessary
515 (set-buffer b2)))) 510 (set-buffer b2))))
516 (if (< (window-width) (frame-width)) 511 (if (< (window-width) (frame-width))
517 (enlarge-window 99999 t))) 512 (enlarge-window 99999 t)))
518 513
519 ;;;;; utility functions ;;;;; 514 ;;;;; utility functions ;;;;;
520 515
521 ;;;###autoload 516 (defun 2C-associated-buffer ()
522 (defun tc-associated-buffer ()
523 "Switch to associated buffer." 517 "Switch to associated buffer."
524 (interactive) 518 (interactive)
525 (or (tc-other) 519 (or (2C-other)
526 (error "You must set two-column minor mode.")) 520 (error "You must set two-column minor mode."))
527 (if (get-buffer-window (tc-other)) 521 (if (get-buffer-window (2C-other))
528 (select-window (get-buffer-window (tc-other))) 522 (select-window (get-buffer-window (2C-other)))
529 (switch-to-buffer (tc-other)))) 523 (switch-to-buffer (2C-other))))
530 524
531 ;; It would be desirable to intercept anything that causes the current 525
532 ;; window to scroll. Maybe a `scroll-hook'? 526
533 ;;;###autoload 527 (defun 2C-toggle-autoscroll (arg)
534 (defun tc-scroll-line (arg) 528 "Toggle autoscrolling, or set it iff prefix ARG is non-nil and positive.
535 "Scroll current window upward by ARG lines. 529 When autoscrolling is turned on, this also realigns the two buffers."
536 The associated window gets scrolled to the same line."
537 (interactive "p")
538 (or (tc-other)
539 (error "You must set two-column minor mode."))
540 ; scroll-up has a bug on arg 0 at end of buffer
541 (or (zerop arg)
542 (scroll-up arg))
543 (setq arg (count-lines (point-min) (window-start)))
544 ; too bad that pre 18.57 Emacs makes save-window-excursion restore
545 ; the point. When it becomes extinct, we can simplify this.
546 (if (get-buffer-window (tc-other))
547 (let ((window (selected-window)))
548 (select-window (get-buffer-window (tc-other)))
549 (setq arg (- arg (count-lines (point-min) (window-start))))
550 ; make sure that other buffer has enough lines
551 (save-excursion
552 (goto-char (point-max))
553 (insert-char ?\n
554 (- arg (count-lines (window-start) (point-max)) -1)))
555 (or (zerop arg)
556 (scroll-up arg))
557 (select-window window))))
558
559 ;;;###autoload
560 (defun tc-scroll-up (arg)
561 "Scroll current window upward by ARG screens.
562 The associated window gets scrolled to the same line."
563 (interactive "p")
564 (tc-scroll-line (* arg (- (window-height)
565 next-screen-context-lines 1))))
566
567 ;;;###autoload
568 (defun tc-scroll-down (arg)
569 "Scroll current window downward by ARG screens.
570 The associated window gets scrolled to the same line."
571 (interactive "p")
572 (tc-scroll-line (* arg (- next-screen-context-lines
573 (window-height) -1))))
574
575 ;;;###autoload
576 (defun tc-recenter (arg)
577 "Center point in window. With ARG, put point on line ARG.
578 This counts from bottom if ARG is negative. The associated window
579 gets scrolled to the same line."
580 (interactive "P") 530 (interactive "P")
581 (setq arg (and arg (prefix-numeric-value arg))) 531 (setq 2C-autoscroll-start (window-start))
582 (tc-scroll-line (- (count-lines (window-start) (point)) 532 (if (setq 2C-autoscroll (if arg
583 (cond ((null arg) (/ (window-height) 2)) 533 (>= (prefix-numeric-value arg) 0)
584 ((< arg 0) (+ (window-height) arg)) 534 (not 2C-autoscroll)))
585 ( arg))))) 535 (select-window
536 (prog1 (selected-window)
537 (message "Autoscrolling is on.")
538 (or (2C-other)
539 (error "You must set two-column minor mode."))
540 (setq arg (count-lines (point-min) (window-start)))
541 (if (get-buffer-window (2C-other))
542 (progn
543 (select-window (get-buffer-window (2C-other)))
544 (setq arg (- arg (count-lines (point-min) (window-start))))
545 ;; make sure that other buffer has enough lines
546 (save-excursion
547 (insert-char ?\n
548 (- arg (count-lines (window-start)
549 (goto-char (point-max)))
550 -1)))
551 (scroll-up arg)))))
552 (message "Autoscrolling is off.")))
553
554
555
556 (defun 2C-autoscroll ()
557 (if 2C-autoscroll
558 ;; catch a mouse scroll on non-selected scrollbar
559 (select-window
560 (prog1 (selected-window)
561 (and (consp last-command-char)
562 (not (eq (selected-window)
563 (car (car (cdr last-command-char)))))
564 (select-window (car (car (cdr last-command-char)))))
565 ;; In some cases scrolling causes an error, but post-command-hook
566 ;; shouldn't, and should always stay in the original window
567 (condition-case ()
568 (and (or 2C-autoscroll-start (2C-toggle-autoscroll t) nil)
569 (/= (window-start) 2C-autoscroll-start)
570 (2C-other)
571 (get-buffer-window (2C-other))
572 (let ((lines (count-lines (window-start)
573 2C-autoscroll-start)))
574 (if (< (window-start) 2C-autoscroll-start)
575 (setq lines (- lines)))
576 (setq 2C-autoscroll-start (window-start))
577 (select-window (get-buffer-window (2C-other)))
578 ;; make sure that other buffer has enough lines
579 (save-excursion
580 (insert-char
581 ?\n (- lines (count-lines (window-start)
582 (goto-char (point-max)))
583 -1)))
584 (scroll-up lines)
585 (setq 2C-autoscroll-start (window-start))))
586 (error))))))
587
588
586 589
587 (defun enlarge-window-horizontally (arg) 590 (defun enlarge-window-horizontally (arg)
588 "Make current window ARG columns wider." 591 "Make current window ARG columns wider."
589 (interactive "p") 592 (interactive "p")
590 (enlarge-window arg t) 593 (enlarge-window arg t)
591 (and (tc-other) 594 (and (2C-other)
592 (setq tc-window-width (+ tc-window-width arg)) 595 (setq 2C-window-width (+ 2C-window-width arg))
593 (set-buffer (tc-other)) 596 (set-buffer (2C-other))
594 (setq tc-window-width (- tc-window-width arg)))) 597 (setq 2C-window-width (- 2C-window-width arg))))
595 598
596 (defun shrink-window-horizontally (arg) 599 (defun shrink-window-horizontally (arg)
597 "Make current window ARG columns narrower." 600 "Make current window ARG columns narrower."
598 (interactive "p") 601 (interactive "p")
599 (enlarge-window-horizontally (- arg))) 602 (enlarge-window-horizontally (- arg)))
600 603
604
605
601 (provide 'two-column) 606 (provide 'two-column)
602 607
603 ;;; two-column.el ends here 608 ;;; two-column.el ends here