annotate lisp/textmodes/two-column.el @ 12695:3d339e94aece

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