annotate lisp/modes/two-column.el @ 4:b82b59fe008d r19-15b3

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