changeset 12506:5dc02bbeb4be

Symbols renamed to be like mode-line indicator. Supposed to now also work for Lucid. (2C-mode-map): New name for `tc-mode-map'. Additionally bound to [f2]. (2C-minor-mode-map) New variable. (2C-mode): New name for `tc-other'. (2C-mode-line-format): New name for `tc-mode-line-format'. (2C-other-buffer-hook): New variable. (2C-separator): New name for `tc-separator'. (2C-window-width): New name for `tc-window-width'. (2C-beyond-fill-column): New name for `tc-beyond-fill-column'. (2C-autoscroll, 2C-autoscroll-start): New variables. (2C-other): New name for `tc-other'. (2C-mode): New name for `tc-mode', `tc-two-columns'. (2C-two-columns): New function. (2C-associate-buffer): New name for `tc-associate-buffer'. (2C-split): New name for `tc-split'. (2C-dissociate): New name for `tc-dissociate'. (2C-merge): New name for `tc-merge'. (2C-associated-buffer): New name for `tc-associated-buffer'. (2C-toggle-autoscroll, 2C-autoscroll): New functions. (tc-scroll-line, tc-scroll-up, tc-scroll-down, tc-recenter): Deleted functions.
author Karl Heuer <kwzh@gnu.org>
date Fri, 07 Jul 1995 20:01:01 +0000
parents 0f970ed476cb
children da322c027bf0
files lisp/textmodes/two-column.el
diffstat 1 files changed, 401 insertions(+), 396 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/textmodes/two-column.el	Fri Jul 07 19:48:24 1995 +0000
+++ b/lisp/textmodes/two-column.el	Fri Jul 07 20:01:01 1995 +0000
@@ -1,407 +1,401 @@
 ;;; two-column.el --- minor mode for editing of two-column text
 
-;; Copyright (C) 1992, 1994 Free Software Foundation, Inc.
-
-;; Author: Daniel Pfeiffer <pfeiffer@cix.cict.fr>
-;; Adapted-By: ESR
-
-;; This file is part of GNU Emacs.
+;; Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
+;; Author: Daniel.Pfeiffer@Informatik.START.dbp.de, fax (+49 69) 7588-2389
+;; Adapted-By: ESR, Daniel Pfeiffer
 
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to
-;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-;;; Commentary:
+;; Esperanto:				 English:
 
-;; This package gives you the ability to edit text in a two-column format.
-
-;; --8<---- two-column.el ----8<--------8<--------8<--------8<--------8<-------
-;; Esperanto:				English:
-
-;; Minora modalo por samtempa dukolumna	Minor mode for simultaneous
-;; tajpado				two-column editing
+;; ^Ci dosiero estas ero de GNU Emacs.	 This file is part of GNU Emacs.
 
-;; Tiu minora  modalo  ebligas  al   vi	This     minor mode  allows  you  to
-;; tajpi   sendepende  en   du   apudaj	independently    edit two   adjacent
-;; bufroj.  Vi  havas tri eblecojn  por	buffers.    You have three  ways  to
-;; eki    ^gin.   ^Ciu  donas  al    vi	start it  up.   Each  gives   you  a
-;; horizontale   disigatan   fenestron,	horizontally split window similar to
-;; simila  al  fina   apareco  de   via	the final outcome of your text:
-;; teksto:
-
-;; C-x 6 2  asocias  novan  bufron  nomatan  associates a new  buffer called
-;;	   same, sed kun 2C/ anta^u.	    the   same,    but   with   2C/
-;;					    prepended.
-
-;; C-x 6 b  asocias alian bufron.  Vi povas  associates    another   buffer.
-;;	   anka^u asocii  dataron,   se vi  This can be used to associate a
-;;	   ^jus anta^ue faris C-x C-f.	    file if you just did C-x C-f.
+;; GNU  Emacs estas libera  programaro;	 GNU Emacs is free software; you can
+;; vi povas disdoni ^gin kaj/a^u modifi	 redistribute it and/or modify it
+;; ^gin sub  la  kondi^coj  de  la  GNU	 under the terms of the GNU General
+;; ^Generala  Publika Licenco kiel pub-	 Public License as published by the
+;; likigita far la Liberprogramara Fon-	 Free Software Foundation; either
+;; da^jo; a^u eldono 2a,  a^u (la^u via	 version 2, or (at your option) any
+;; elekto) ajna posta eldono.		 later version.
 
-;; C-x 6 u  disigas  jam dukolumnan tekston  unmerges a two-column text into
-;;	   en  du   bufroj  ekde  la  nuna  two  buffers from  the  current
-;;	   linio,  kaj je la nuna kolumno.  line and at the current column.
-;;	   La    anta^uaj   signoj   (ofte  The preceding characters (often
-;;	   tabeligilo  a^u  |)  estas   la  tab   or  |)  are   the  column
-;;	   kolumna disiganto.  Linioj kiuj  separator.   Lines  that  don't
-;;	   ne   enhavas   ilin   ne  estas  have them  won't  be separated.
-;;	   disigitaj.   Kiel  la kvara kaj  Like the  fourth and fifth line
-;;	   la   kvina  linio se vi disigas  if  you unmerge this  file from
-;;	   ^ci dataron ekde la unua  angla  the first english word.
-;;	   vorto.
+;; GNU  Emacs  estas  disdonata  en  la	 GNU Emacs is distributed in the hope
+;; espero ke  ^gi estos utila,  sed SEN	 that it will be useful, but WITHOUT
+;; IA  GARANTIO;  sen e^c  la implicita	 ANY WARRANTY; without even the
+;; garantio  de VENDEBLECO  a^u PRETECO	 implied warranty of MERCHANTABILITY
+;; POR  DETERMINITA CELO.  Vidu la  GNU	 or FITNESS FOR A PARTICULAR PURPOSE.
+;; ^Generala Publika Licenco por plenaj	 See the GNU General Public License
+;; detaloj.				 for more details.
+
+;; Vi devus ricevinti kopion de la  GNU	 You should have received a copy of
+;; ^Generala  Publika  Licenco kune kun	 the GNU General Public License along
+;; GNU Emacs; vidu la dosieron COPYING.	 with GNU Emacs; see the file
+;; Alikaze skribu al la			 COPYING.  If not, write to the
 
-;; Je ^cia  flanko  estas  bufro,   kiu	On each side is a buffer  that knows
-;; konas la  alian.  Kun la ordonoj C-x	about the other.  With the  commands
-;; 6 SPC, C-x 6 DEL  kaj  C-x 6 RET oni	C-x 6 SPC,  C-x 6 DEL  and C-x 6 RET
-;; povas   suben-   a^u  supreniri  unu	you can  simultaneously scroll up or
-;; ekranon,    kaj   subeniri   linion,	down by  a screenfull  and by a line
-;; samtempe en la du bufroj. Al la alia	in both buffers.   Empty lines   are
-;; bufro  estas   aldonataj  linioj  se	added to  the  other    buffer    if
-;; necesas,  por  ke  vi vidu la  saman	necessary, so that  you see the same
-;; parton.  Per  C-x  6  C-l vi   povas	part.   With   C-x 6  C-l    you can
-;; recentrigi la linion.    Kiam vi nur	recenter the line.   When  you  only
-;; plu  havas    unu el   la du  bufroj	have one of the two buffers onscreen
-;; surekrane vi  revidos la alian   per	you can get the other back  with C-x
-;; denove C-x 6 2.			6 2 once more.
+;; Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+
+
+;;; Komentario:				 Commentary:
 
-;; Se  vi  volas  meti  longajn liniojn	If you include long lines, i.e which
-;; (ekz. programerojn) en la  kunigotan	will span both columns  (eg.  source
-;; tekston,   ili  devas  esti  en   la	code), they should  be  in what will
-;; estonte unua kolumno.  La alia devas	be the    first column,    with  the
-;; havi malplenajn linion apud ili.	associated buffer having empty lines
-;;					next to them.
+;; Tiu  programaro ebligas  vin redakti	 This package gives you the ability
+;; dukolumnan tekston.			 to edit text in a two-column format.
+
 
-;; Averto: en Emacs kiam vi ^san^gas la	Attention:  in Emacs when you change
-;; ma^joran modalon, la minoraj modaloj	the major mode,  the minor modes are
-;; estas  anka^u  elmemorigitaj.   Tiu-	also  purged  from  memory.  In that
-;; okaze  vi devas religi la du bufrojn	case you   must  reassociate the two
-;; per iu  C-x 6-ordono,  ekz. C-x 6 b.	buffers with any C-x 6-command, e.g.
-;;					C-x 6 b.
-
-;; Kiam   vi   estos  kontenta   de  la	When you have edited both buffers to
-;; rezulto, vi kunmetos la du kolumnojn	your  content,  you merge them  with
-;; per  C-x 6 1.   Se  vi  poste  vidas	C-x 6 1.  If you then see a problem,
-;; problemon, vi  neniigu   la kunmeton	you undo the  merge with  C-x u  and
-;; per C-x u  kaj  plue  modifu  la  du	continue   to  edit the two buffers.
-;; bufrojn.  Kiam vi ne plu volas tajpi	When you  no longer  want to edit in
-;; dukolumne,  vi  eliru el  la  minora	two  columns, you turn off the minor
-;; modalo per C-x 6 k.			mode with C-x 6 k.
+;; Vi  havas  tri eblecojn por eki tiun	 You have three ways to start up this
+;; mal^cefan modalon.  ^Ciu donas al vi	 minor mode.  Each gives you a
+;; horizontale disigatan fenestron, si-	 horizontally split window similar to
+;; milan al fina apareco de via teksto:	 the final outcome of your text:
 
 
-;; An^stata^u tri `autoload' kaj tri  |  Instead  of  three  `autoload' and
-;; `global-set-key'  vi povas uzi la  |  three `global-set-key' you can use
-;; jenon en via dataro ~/.emacs, por  |  the    following   in  your   file
-;; memstare ^sar^gi la modalon:	      |  ~/.emacs,  to  automatically  load
-;;				      |  the mode:
+;; f2 2	    asocias  novan  bufron  nomatan  associates a new  buffer called
+;; C-x 6 2  same, sed kun 2C/ anta^u.	     the   same,    but   with   2C/
+;;					     prepended.
 
-;;	(global-set-key "\C-x6"
-;;			'(lambda () (interactive)
-;;			   (load-library "two-column")
-;;			   (call-interactively
-;;			    (cdr (assq (read-char) tc-mode-map)))))
+;; f2 b	    asocias alian bufron.  Vi povas  associates    another   buffer.
+;; C-x 6 b  anka^u asocii  dataron,   se vi  This can be used to associate a
+;;	    ^jus anta^ue faris C-x C-f.	     file if you just did C-x C-f.
 
-;; Se vi ^satus  havi la dukolumnajn  |  If     you'd like   to  have   the
-;; ordonojn je funkciklavo <f2>,  vi  |  two-column  commands   on function
-;; povas  uzi la jenon en via dataro  |  key   <f2>,  you  can     use  the
-;; ~/.emacs:			      |  following in your file ~/.emacs:
+;; f2 s	    disigas  jam dukolumnan tekston  splits a  two-column  text into
+;; C-x 6 s  en  du   bufroj  ekde  la  nuna  two  buffers from  the  current
+;;	    linio,  kaj je la nuna kolumno.  line and at the current column.
+;;	    La    anta^uaj   signoj   (ofte  The preceding characters (often
+;;	    tabeligilo  a^u  |)  estas   la  tab   or  |)  are   the  column
+;;	    kolumna disiganto.  Linioj kiuj  separator.   Lines  that  don't
+;;	    ne   enhavas   ilin   ne  estas  have them  won't  be separated.
+;;	    disigitaj.   Kiel  la kvara kaj  Like the  fourth and fifth line
+;;	    la   kvina  linio se vi disigas  if  you split this  file from
+;;	    ^ci dataron ekde la unua  angla  the first english word.
+;;	    vorto.
 
-;; (global-set-key [f2] (function
-;;                       (lambda ()
-;;                         (interactive)
-;;                         (load-library "two-column")
-;;                         (global-set-key [f2] tc-mode-map)
-;;                         (call-interactively
-;;                          (cdr (assq (read-char) tc-mode-map))))))
+;; Se  vi  volas  meti  longajn liniojn	 If you include long lines, i.e which
+;; (ekz. programerojn) en la  kunigotan	 will span both columns  (eg.  source
+;; tekston,   ili  devas  esti  en   la	 code), they should  be  in what will
+;; estonte unua kolumno.  La alia devas	 be the    first column,    with  the
+;; havi vakajn linion apud ili.		 associated buffer having empty lines
+;;					 next to them.
+
+;; Averto: en Emacs kiam vi ^san^gas la	 Attention:  in Emacs when you change
+;; ^cefan modalon, la mal^cefaj modaloj	 the major mode,  the minor modes are
+;; estas  anka^u  elmemorigitaj.   Tiu-	 also  purged  from  memory.  In that
+;; okaze  vi devas religi la du bufrojn	 case you   must  reassociate the two
+;; per iu  C-x 6-ordono,  ekz. C-x 6 b.	 buffers with any C-x 6-command, e.g.
+;;					 C-x 6 b.
 
-;; In addition to two-column editing of text, for example for writing a
-;; bilingual text side-by-side as shown below in the file's prolog, other
-;; interesting uses have been found for this minor mode:
-;; 
-;; 
-;; You can separate the columns with   {+} C-x 6 u  or  <f2> u  if you prefer
-;; any string that pleases you, by     {+} handles these with a prefix argument
-;; setting tc-separator.  For          {+} that enables you to declare the
-;; example "{+}  " if you like to      {+}  desired length of such a string.
-;; amuse yourself.
-;; 
-;; 
-;; keyword You can write any text corresponding to a
-;; 	  given keyword in a filled paragraph next to
-;; 	  it.  Note that the width of the first column
-;; 	  may be less than window-min-width in the
-;; 	  result, but will be displayed at that width.
-;; 
-;; another This is not a three- or multi-column mode.
-;; 	  The example in the file's prolog required
-;; 	  working on two columns and then treating the
-;; 	  result as one column in order to add the
-;; 	  third.
-;; 
-;; 
-;; Programmers might like the ability to split off the comment column of
-;; a file that looks like the following.  The advantage is that with
-;; (setq fill-prefix "-- ") you can run M-q (fill-paragraph) on the
-;; comment.  The problem is, code quickly gets rather wide, so you need
-;; to use a narrower comment column, which is less interesting, unless
-;; you have a 132-column screen.  Code lines that reach beyond
-;; comment-column are no problem, except that you won't always see their
-;; end during editing.
-;; 
+;; Kiam   vi   estos  kontenta   de  la	 When you have edited both buffers to
+;; rezulto, vi kunmetos la du kolumnojn	 your  content,  you merge them  with
+;; per  C-x 6 1.   Se  vi  poste  vidas	 C-x 6 1.  If you then see a problem,
+;; problemon, vi  neniigu   la kunmeton	 you undo the  merge with  C-x u  and
+;; per C-x u  kaj  plue  modifu  la  du	 continue   to  edit the two buffers.
+;; bufrojn.  Kiam vi ne plu volas tajpi	 When you  no longer  want to edit in
+;; dukolumne,  vi  eliru el la mal^cefa	 two  columns, you turn off the minor
+;; modalo per C-x 6 d.			 mode with C-x 6 d.
+
+
+;; Aldone al dukolumna  redaktado,  ek-	 In addition to two-column editing of
+;; zemple por  skribi dulingvan tekston	 text, for example for writing a
+;; flank-al-flanke kiel ^ci tiu,  aliaj	 bilingual text side-by-side as shown
+;; interesaj uzoj trovitas por tiu mal-	 here, other interesting uses have
+;; ^cefa modalo:			 been found for this minor mode:
+
+;; Vi povas  disigi la  kolumnojn per {+} You can separate the columns with
+;; ajna   pla^ca   ^ceno   starigante {+} any string that pleases you, by
+;; `2C-separator'.   Ekzemple  "{+} " {+} setting `2C-separator'.  For example
+;; por  amuzi^gi.  f2 s  a^u  C-x 6 s {+} "{+} " if you'd like to have fun.
+;; traktas   tiujn    kun    prefiksa {+} f2 s or C-x 6 s handles these with a
+;; argumento  kiu  signifas la longon {+} prefix argument that means the
+;; de tia ^ceno.		      {+} desired length of such a string.
+
+
+;; Programistoj eble ^satus la  eblecon  Programmers might like the ability
+;; forspliti la komentarian kolumnon de  to split off the comment column of a
+;; dosiero  kiel la sekvanta.  Vi povas  file that looks like the following.
+;; rearan^gigi  la paragrafon.  La pro-  You can fill-paragraph the comment.
+;; blemo  estas  ke  koda^jo tuj   lar-  The problem is, code quickly gets
+;; ^gi^gas,  tiel  ke vi  bezonas   pli  rather wide, so you need to use a
+;; mallar^gan   komentarian   kolumnon.  narrower comment column.  Code lines
+;; Koda^jaj linioj tra `comment-column'  that reach beyond `comment-column'
+;; ne problemas,  krom  ke vi ne  vidos  are no problem, except that you
+;; iliajn finojn dum redaktado.		 won't see their end during editing.
+
+
 ;; BEGIN				-- This is just some meaningless
 ;;     FOR i IN 1..10 LOOP		-- code in Ada, that runs foobar
-;; 	foobar( i );			-- once for each argument from one
+;;	   foobar( i );			-- once for each argument from one
 ;;     END LOOP;			-- to ten, and then we're already
 ;; END;					-- through with it.
-;; 
-;; Better yet, you can put the point before "This", type M-3 C-x 6 u
-;; which makes "-- " the separator between a no-comments Ada buffer, and
-;; a plain text comment buffer.  When you put them back together, every
-;; non-empty line of the 2nd column will again be preceded by "-- ".
-;; 
-;; 
-;; The <f2> function key hack (which is one of the rare times when
-;; function keys are mnemonic) at the end of the file's prolog requires
-;; that the lisp/term/*.el for your terminal use the standard
-;; conventions.  Too bad that some don't (at least not in version 18.55).
-;; The Sun one is hopelessly non-standard, and vt2[024]0 somehow forgot
-;; to define <f1> thru <f5>.  (It defines <pf1> thru <pf4> instead, but
-;; that is not what we need on an X terminal.)  If you want to use those,
-;; you'll need another hack something like:
-;; 
-;;       (if (string= (system-name) "cix")
-;; 	  (progn
-;; 	    (load-library "term/vt200.el")
-;; 	    (define-key CSI-map "12~" (cons function-keymap ?\^b)))
-;; 	(global-unset-key "\e[")
-;; 	(define-key esc-map "[225z" (cons function-keymap ?\^b)))
-;; 
-;; where "cix" is the non-sun machine I use.  Actually I use the same X
-;; terminal to connect to both machines, and I want to keep my ~/.emacs
-;; identical on both.  Bother, the two Emacses don't recognize the same
-;; keys and assign different sequences to those they do!  I sure hope all
-;; this nonsense will stop with version 19 (or preferably soon) where I'd
-;; like to be able to say (define-key some-map '<f2> some-cmd), and see
-;; <f2> rather than some unintelligible ESC-sequence in command key
-;; sequences.
+
+;; Pli bone ankora^u, vi povas  pozici-	 Better yet, you can put the point
+;; i^gi anta^u "This",  tajpi  M-3 f2 s	 before "This", type  M-3 f2 s
+;; kiu  igas "-- " la separigilon inter	 which makes "-- " the separator
+;; senkomentaria  Ada  bufro  kaj  nur-	 between a no-comments Ada buffer,
+;; teksta  komentaria  bufro.   Kiam vi	 and a plain text comment buffer.
+;; denove  kuni^gos ilin,  ^ciu  nevaka	 When you put them back together,
+;; linio  de  l'  dua  kolumno   denove	 every non-empty line of the 2nd
+;; anta^uhavos "-- ".			 column will again be preceded by
+;;					 "-- ".
+
 
 ;;; Code:
 
+
+;; Lucid patch
+(or (fboundp 'frame-width)
+    (fset 'frame-width 'screen-width))
+
+
 ;;;;; Set up keymap ;;;;;
 
-;;;###autoload
-(defvar tc-mode-map nil
-  "Keymap for commands for two-column mode.")
+(defvar 2C-mode-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map "2" '2C-two-columns)
+    (define-key map [f2] '2C-two-columns)
+    (define-key map "b" '2C-associate-buffer)
+    (define-key map "s" '2C-split)
+    (define-key map "{" 'shrink-window-horizontally)
+    (define-key map "}" 'enlarge-window-horizontally)
+    map)
+  "Keymap for commands for setting up two-column mode.")
+
+
+
+;;;###autoload (autoload '2C-command "two-column" () t 'keymap)
+(fset '2C-command 2C-mode-map)
 
 ;;;###autoload
-(if tc-mode-map
-    ()
-  (setq tc-mode-map (make-sparse-keymap))
-  (define-key tc-mode-map "1" 'tc-merge)
-  (define-key tc-mode-map "2" 'tc-two-columns)
-  (define-key tc-mode-map "b" 'tc-associate-buffer)
-  (define-key tc-mode-map "d" 'tc-dissociate)
-  (define-key tc-mode-map "\C-l" 'tc-recenter)
-  (define-key tc-mode-map "o" 'tc-associated-buffer)
-  (define-key tc-mode-map "s" 'tc-split)
-  (define-key tc-mode-map "{" 'shrink-window-horizontally)
-  (define-key tc-mode-map "}" 'enlarge-window-horizontally)
-  (define-key tc-mode-map " " 'tc-scroll-up)
-  (define-key tc-mode-map "\^?" 'tc-scroll-down)
-  (define-key tc-mode-map "\C-m" 'tc-scroll-line))
+;; This one is for historical reasons and simple keyboards, it is not
+;; at all mnemonic.  All usual sequences containing 2 were used, and
+;; f2 could not be set up in a standard way under Emacs 18.
+(global-set-key "\C-x6" '2C-command)
+
 
 ;;;###autoload
-(global-set-key "\C-x6" tc-mode-map)
+(global-set-key [f2] '2C-command)
+
+
+(defvar 2C-minor-mode-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map "1" '2C-merge)
+    (define-key map "d" '2C-dissociate)
+    (define-key map "o" '2C-associated-buffer)
+    (define-key map "|" '2C-toggle-autoscroll)
+    map)
+  "Keymap for commands for use in two-column mode.")
+
+
+(setq minor-mode-map-alist
+      (cons (cons '2C-mode
+		  (let ((map (make-sparse-keymap)))
+		    (substitute-key-definition '2C-command 2C-minor-mode-map
+					       map (current-global-map))
+		    map))
+	    minor-mode-map-alist))
 
 ;;;;; variable declarations ;;;;;
 
-;; markers seem to be the only buffer-id not affected by renaming
-;; a buffer.  This nevertheless loses when a buffer is killed.
-(defvar tc-other nil
+;; Markers seem to be the only buffer-id not affected by renaming a buffer.
+;; This nevertheless loses when a buffer is killed.  The variable-name is
+;; required by `describe-mode'.
+(defvar 2C-mode nil
   "Marker to the associated buffer, if non-nil.")
-(make-variable-buffer-local 'tc-other)
-(put 'tc-other 'permanent-local t)
+(make-variable-buffer-local '2C-mode)
+(put '2C-mode 'permanent-local t)
+
 
-(setq minor-mode-alist (cons '(tc-other " 2C") minor-mode-alist))
+
+(setq minor-mode-alist (cons '(2C-mode " 2C") minor-mode-alist))
+
+
 
 ;; rearranged, so that the pertinent info will show in 40 columns
-(defvar tc-mode-line-format
+(defvar 2C-mode-line-format
 	'("-%*- %15b --"  (-3 . "%p")  "--%[("  mode-name
-	  minor-mode-alist  mode-line-process  "%n"  ")%]%-")
+	  minor-mode-alist  "%n"  mode-line-process  ")%]%-")
   "*Value of mode-line-format for a buffer in two-column minor mode.")
 
-(defvar tc-separator ""
+
+(defvar 2C-other-buffer-hook 'text-mode
+  "*Hook run in new buffer when it is associated with current one.")
+
+
+(defvar 2C-separator ""
   "*A string inserted between the two columns when merging.
-This gets set locally by \\[tc-split].")
-(put 'tc-separator 'permanent-local t)
+This gets set locally by \\[2C-split].")
+(put '2C-separator 'permanent-local t)
 
-(defvar tc-window-width 40
+
+
+(defvar 2C-window-width 40
   "*The width of the first column.  (Must be at least `window-min-width')
 This value is local for every buffer that sets it.")
-(make-variable-buffer-local 'tc-window-width)
-(put 'tc-window-width 'permanent-local t)
+(make-variable-buffer-local '2C-window-width)
+(put '2C-window-width 'permanent-local t)
+
 
-(defvar tc-beyond-fill-column 4
+
+(defvar 2C-beyond-fill-column 4
   "*Base for calculating `fill-column' for a buffer in two-column minor mode.
-The value of `fill-column' becomes `tc-window-width' for this buffer
+The value of `fill-column' becomes `2C-window-width' for this buffer
 minus this value.")
 
-(defvar tc-mode-hook nil
-  "Function called, if non-nil, whenever turning on two-column minor mode.
-It can get called by \\[tc-two-columns] (tc-two-columns), \\[tc-split] (tc-split)
-and \\[tc-associate-buffer] (tc-associate-buffer), on both buffers.")
+
+
+(defvar 2C-autoscroll t
+  "If this is non-nil, Emacs attempts to keep the two buffers aligned.")
+
+
+
+(defvar 2C-autoscroll-start nil)
+(make-variable-buffer-local '2C-autoscroll-start)
 
 ;;;;; base functions ;;;;;
 
-;; the access method for the other buffer.  this tries to remedy against
+;; The access method for the other buffer.  This tries to remedy against
 ;; lost local variables and lost buffers.
-(defun tc-other ()
-  (if tc-other
+(defun 2C-other ()
+  (if 2C-mode
       (or (prog1
-	      (marker-buffer tc-other)
-	    (setq mode-line-format tc-mode-line-format ))
-	  ; The associated buffer somehow got killed.
+	      (marker-buffer 2C-mode)
+	    (setq mode-line-format 2C-mode-line-format))
+	  ;; The associated buffer somehow got killed.
 	  (progn
-	    ; The other variables may later be useful if the user
-	    ; reestablishes the association.
-	    (kill-local-variable 'tc-other)
+	    ;; The other variables may later be useful if the user
+	    ;; reestablishes the association.
+	    (kill-local-variable '2C-mode)
 	    (kill-local-variable 'mode-line-format)
 	    nil))))
 
-;;;###autoload
-(defun tc-two-columns (&optional buffer)
-  "Split current window vertically for two-column editing.
+
 
-When called the first time, associates a buffer with the current
-buffer.  Both buffers are put in two-column minor mode and
-tc-mode-hook gets called on both.  These buffers remember
-about one another, even when renamed.
+;; function for setting up two-column minor mode in a buffer associated
+;; with the buffer pointed to by the marker other.
+(defun 2C-mode (other)
+  "Minor mode for independently editing two columns.
+This is set up for two associated buffers by the three commands bound
+to  \\[2C-two-columns] ,  \\[2C-associate-buffer]  and  \\[2C-split].
+Turning on two-column mode calls the value of the variable `2C-mode-hook',
+if that value is non-nil.
 
-When called again, restores the screen layout with the current buffer
-first and the associated buffer to it's right.
+These buffers can be edited separately, for example with `fill-paragraph'.
+If you want to disable parallel scrolling temporarily, use  \\[2C-toggle-autoscroll] .
 
 If you include long lines, i.e which will span both columns (eg.
 source code), they should be in what will be the first column, with
 the associated buffer having empty lines next to them.
 
+Potential uses are writing bilingual texts, or editing the comments of a
+source code.  See the file lisp/two-column.el for detailed examples.
+
 You have the following commands at your disposal:
 
-\\[tc-two-columns]   Rearrange screen
-\\[tc-associate-buffer]   Reassociate buffer after changing major mode
-\\[tc-scroll-up]   Scroll both buffers up by a screenfull
-\\[tc-scroll-down]   Scroll both buffers down by a screenful
-\\[tc-scroll-line]   Scroll both buffers up by one or more lines
-\\[tc-recenter]   Recenter and realign other buffer
+\\[2C-two-columns]   Rearrange screen with current buffer first
+\\[2C-associate-buffer]   Reassociate buffer after changing major mode
 \\[shrink-window-horizontally], \\[enlarge-window-horizontally]   Shrink, enlarge current column
-\\[tc-associated-buffer]   Switch to associated buffer
-\\[tc-merge]   Merge both buffers
+\\[2C-associated-buffer]   Switch to associated buffer
+\\[2C-merge]   Merge both buffers
+\\[2C-dissociate]   Dissociate the two buffers
 
-These keybindings can be customized in your ~/.emacs by `tc-prefix'
-and `tc-mode-map'.
+These keybindings can be customized in your ~/.emacs by `2C-mode-map',
+`2C-minor-mode-map' and by binding `2C-command' to some prefix.
 
 The appearance of the screen can be customized by the variables
-`tc-window-width', `tc-beyond-fill-column',
-`tc-mode-line-format' and `truncate-partial-width-windows'."
+`2C-window-width', `2C-beyond-fill-column', `2C-mode-line-format' and
+`truncate-partial-width-windows'."
+  (make-variable-buffer-local 'post-command-hook)
+  (setq fill-column (- 2C-window-width
+		       2C-beyond-fill-column)
+	post-command-hook '2C-autoscroll
+	mode-line-format 2C-mode-line-format
+	2C-mode other)
+  (run-hooks '2C-mode-hook))
+
 
+
+;;;###autoload
+(defun 2C-two-columns (&optional buffer)
+  "Split current window vertically for two-column editing.
+When called the first time, associates a buffer with the current
+buffer in two-column minor mode (see  \\[describe-mode] ).
+Runs `2C-other-buffer-hook' in the new buffer.
+When called again, restores the screen layout with the current buffer
+first and the associated buffer to it's right."
   (interactive "P")
-  ; first go to full width, so that we can certainly split into
-  ; two windows
+  ;; first go to full width, so that we can certainly split into two windows
   (if (< (window-width) (frame-width))
       (enlarge-window 99999 t))
   (split-window-horizontally
-   (max window-min-width (min tc-window-width
+   (max window-min-width (min 2C-window-width
 			      (- (frame-width) window-min-width))))
-  (if (tc-other)
+  (if (2C-other)
       (progn
 	(other-window 1)
-	(switch-to-buffer (tc-other))
+	(switch-to-buffer (2C-other))
 	(other-window -1)
-	; align buffers if necessary
-	(tc-scroll-line 0))
+	(if 2C-autoscroll
+	    (2C-toggle-autoscroll t)))
 
-    ; set up minor mode linking two buffers
-    (setq fill-column (- tc-window-width
-			 tc-beyond-fill-column)
-	  mode-line-format tc-mode-line-format)
-    (run-hooks tc-mode-hook)
-    (let ((other (point-marker)))
-      (other-window 1)
-      (switch-to-buffer
-       (or buffer
-	   (generate-new-buffer
-	    (concat "2C/" (buffer-name)))))
-      (or buffer
-	  (text-mode))
-      (setq fill-column (- tc-window-width
-			   tc-beyond-fill-column)
-	    mode-line-format tc-mode-line-format
-	    tc-other other
-	    other (point-marker))
-      (run-hooks tc-mode-hook)
-      (other-window -1)
-      (setq tc-other other))))
+    (2C-mode (prog1 (point-marker)
+	       (other-window 1)
+	       (switch-to-buffer
+		(or buffer
+		    (generate-new-buffer
+		     (concat "2C/" (buffer-name)))))
+	       (or buffer
+		   (run-hooks '2C-other-buffer-hook))))
+    
+    (2C-mode (prog1 (point-marker)
+	       (other-window -1)))))
 
-(defalias 'tc-mode 'tc-two-columns)
+
 
 ;;;###autoload
-(defun tc-associate-buffer ()
+(defun 2C-associate-buffer ()
   "Associate another buffer with this one in two-column minor mode.
 Can also be used to associate a just previously visited file, by
 accepting the proposed default buffer.
 
-See  \\[tc-two-columns]  and  `lisp/two-column.el'  for further details."
+\(See  \\[describe-mode] .)"
   (interactive)
   (let ((b1 (current-buffer))
-	(b2 (or (tc-other)
+	(b2 (or (2C-other)
 		(read-buffer "Associate buffer: " (other-buffer)))))
     (save-excursion
-      (setq tc-other nil)
+      (setq 2C-mode nil)
       (set-buffer b2)
-      (and (tc-other)
-	   (not (eq b1 (tc-other)))
+      (and (2C-other)
+	   (not (eq b1 (2C-other)))
 	   (error "Buffer already associated with buffer `%s'."
-		  (buffer-name (tc-other))))
-      (setq b1 (and (assq 'tc-window-width (buffer-local-variables))
-		    tc-window-width)))
+		  (buffer-name (2C-other))))
+      (setq b1 (and (assq '2C-window-width (buffer-local-variables))
+		    2C-window-width)))
     ; if other buffer has a local width, adjust here too
-    (if b1 (setq tc-window-width (- (frame-width) b1)))
-    (tc-two-columns b2)))
+    (if b1 (setq 2C-window-width (- (frame-width) b1)))
+    (2C-two-columns b2)))
+
+
 
 ;;;###autoload
-(defun tc-split (arg)
-  "Unmerge a two-column text into two buffers in two-column minor mode.
-The text is unmerged at the cursor's column which becomes the local
-value of `tc-window-width'.  Only lines that have the ARG same
-preceding characters at that column get split.  The ARG preceding
-characters without any leading whitespace become the local value for
-`tc-separator'.  This way lines that continue across both
+(defun 2C-split (arg)
+  "Split a two-column text at point, into two buffers in two-column minor mode.
+Point becomes the local value of `2C-window-width'.  Only lines that
+have the ARG same preceding characters at that column get split.  The
+ARG preceding characters without any leading whitespace become the local
+value for `2C-separator'.  This way lines that continue across both
 columns remain untouched in the first buffer.
 
-This function can be used with a prototype line, to set up things as
-you like them.  You write the first line of each column with the
-separator you like and then unmerge that line.  E.g.:
+This function can be used with a prototype line, to set up things.  You
+write the first line of each column and then split that line.  E.g.:
 
-First column's text    sSs  Second columns text
+First column's text    sSs  Second column's text
 		       \\___/\\
 			/    \\
-   5 character Separator      You type  M-5 \\[tc-split]  with the point here
+   5 character Separator      You type  M-5 \\[2C-split]  with the point here.
 
-See  \\[tc-two-columns]  and  `lisp/two-column.el'  for further details."
-  (interactive "p")
-  (and (tc-other)
+\(See  \\[describe-mode] .)"
+  (interactive "*p")
+  (and (2C-other)
        (if (y-or-n-p (concat "Overwrite associated buffer `"
-			     (buffer-name (tc-other))
+			     (buffer-name (2C-other))
 			     "'? "))
 	   (save-excursion
-	     (set-buffer (tc-other))
+	     (set-buffer (2C-other))
 	     (erase-buffer))
 	 (signal 'quit nil)))
   (let ((point (point))
@@ -414,12 +408,12 @@
       (backward-char arg)
       (setq chars (buffer-substring (point) point))
       (skip-chars-forward " \t" point)
-      (make-local-variable 'tc-separator)
-      (setq tc-separator (buffer-substring (point) point)
-	    tc-window-width (current-column)))
-    (tc-two-columns)
-    (setq other (tc-other))
-    ; now we're ready to actually unmerge
+      (make-local-variable '2C-separator)
+      (setq 2C-separator (buffer-substring (point) point)
+	    2C-window-width (current-column)))
+    (2C-two-columns)
+    (setq other (2C-other))
+    ; now we're ready to actually split
     (save-excursion
       (while (not (eobp))
 	(if (not (and (= (current-column) goal-column)
@@ -443,59 +437,60 @@
 	  (setq n 0))
 	(next-line 1)))))
 
-;;;###autoload
-(defun tc-dissociate ()
+
+
+
+(defun 2C-dissociate ()
   "Turn off two-column minor mode in current and associated buffer.
 If the associated buffer is unmodified and empty, it is killed."
   (interactive)
   (let ((buffer (current-buffer)))
     (save-excursion
-      (and (tc-other)
-	   (set-buffer (tc-other))
-	   (or (not (tc-other))
-	       (eq buffer (tc-other)))
+      (and (2C-other)
+	   (set-buffer (2C-other))
+	   (or (not (2C-other))
+	       (eq buffer (2C-other)))
 	   (if (and (not (buffer-modified-p))
 		    (eobp) (bobp))
 	       (kill-buffer nil)
-	     (kill-local-variable 'tc-other)
-	     (kill-local-variable 'tc-window-width)
-	     (kill-local-variable 'tc-separator)
+	     (kill-local-variable '2C-mode)
+	     (kill-local-variable '2C-window-width)
+	     (kill-local-variable '2C-separator)
 	     (kill-local-variable 'mode-line-format)
 	     (kill-local-variable 'fill-column))))
-    (kill-local-variable 'tc-other)
-    (kill-local-variable 'tc-window-width)
-    (kill-local-variable 'tc-separator)
+    (kill-local-variable '2C-mode)
+    (kill-local-variable '2C-window-width)
+    (kill-local-variable '2C-separator)
     (kill-local-variable 'mode-line-format)
     (kill-local-variable 'fill-column)))
 
 
+
 ;; this doesn't use yank-rectangle, so that the first column can
 ;; contain long lines
-;;;###autoload
-(defun tc-merge ()
+(defun 2C-merge ()
   "Merges the associated buffer with the current buffer.
-They get merged at the column, which is the value of
-`tc-window-width', i.e. usually at the vertical window
-separator.  This separator gets replaced with white space.  Beyond
-that the value of gets inserted on merged lines.  The two columns are
-thus pasted side by side, in a single text.  If the other buffer is
-not displayed to the left of this one, then this one becomes the left
-column.
+They get merged at the column, which is the value of `2C-window-width',
+i.e. usually at the vertical window separator.  This separator gets
+replaced with white space.  Beyond that the value of `2C-separator' gets
+inserted on merged lines.  The two columns are thus pasted side by side,
+in a single text.  If the other buffer is not displayed to the left of
+this one, then this one becomes the left column.
 
-If you want `tc-separator' on empty lines in the second column,
+If you want `2C-separator' on empty lines in the second column,
 you should put just one space in them.  In the final result, you can strip
 off trailing spaces with \\[beginning-of-buffer] \\[replace-regexp] [ SPC TAB ] + $ RET RET"
 
   (interactive)
-  (or (tc-other)
+  (or (2C-other)
       (error "You must first set two-column minor mode."))
   (and (> (car (window-edges)) 0)	; not touching left edge of screen
        (eq (window-buffer (previous-window))
-	   (tc-other))
+	   (2C-other))
        (other-window -1))
   (save-excursion
     (let ((b1 (current-buffer))
-	  (b2 (tc-other))
+	  (b2 (2C-other))
 	  string)
       (goto-char (point-min))
       (set-buffer b2)
@@ -509,8 +504,8 @@
 	(if (string= string "")
 	    ()
 	  (end-of-line)
-	  (indent-to-column tc-window-width)
-	  (insert tc-separator string))
+	  (indent-to-column 2C-window-width)
+	  (insert 2C-separator string))
 	(next-line 1)			; add one if necessary
 	(set-buffer b2))))
   (if (< (window-width) (frame-width))
@@ -518,86 +513,96 @@
 
 ;;;;; utility functions ;;;;;
 
-;;;###autoload
-(defun tc-associated-buffer ()
+(defun 2C-associated-buffer ()
   "Switch to associated buffer."
   (interactive)
-  (or (tc-other)
-      (error "You must set two-column minor mode."))
-  (if (get-buffer-window (tc-other))
-      (select-window (get-buffer-window (tc-other)))
-    (switch-to-buffer (tc-other))))
-
-;; It would be desirable to intercept anything that causes the current
-;; window to scroll.  Maybe a `scroll-hook'?
-;;;###autoload
-(defun tc-scroll-line (arg)
-  "Scroll current window upward by ARG lines.
-The associated window gets scrolled to the same line."
-  (interactive "p")
-  (or (tc-other)
+  (or (2C-other)
       (error "You must set two-column minor mode."))
-  ; scroll-up has a bug on arg 0 at end of buffer
-  (or (zerop arg)
-      (scroll-up arg))
-  (setq arg (count-lines (point-min) (window-start)))
-  ; too bad that pre 18.57 Emacs makes save-window-excursion restore
-  ; the point.  When it becomes extinct, we can simplify this.
-  (if (get-buffer-window (tc-other))
-      (let ((window (selected-window)))
-	(select-window (get-buffer-window (tc-other)))
-	(setq arg (- arg (count-lines (point-min) (window-start))))
-	; make sure that other buffer has enough lines
-	(save-excursion
-	  (goto-char (point-max))
-	  (insert-char ?\n
-		       (- arg (count-lines (window-start) (point-max)) -1)))
-	(or (zerop arg)
-	    (scroll-up arg))
-	(select-window window))))
+  (if (get-buffer-window (2C-other))
+      (select-window (get-buffer-window (2C-other)))
+    (switch-to-buffer (2C-other))))
+
+
+
+(defun 2C-toggle-autoscroll (arg)
+  "Toggle autoscrolling, or set it iff prefix ARG is non-nil and positive.
+When autoscrolling is turned on, this also realigns the two buffers."
+  (interactive "P")
+  (setq 2C-autoscroll-start (window-start))
+  (if (setq 2C-autoscroll (if arg
+			      (>= (prefix-numeric-value arg) 0)
+			    (not 2C-autoscroll)))
+      (select-window
+       (prog1 (selected-window)
+	 (message "Autoscrolling is on.")
+	 (or (2C-other)
+	     (error "You must set two-column minor mode."))
+	 (setq arg (count-lines (point-min) (window-start)))
+	 (if (get-buffer-window (2C-other))
+	     (progn
+	       (select-window (get-buffer-window (2C-other)))
+	       (setq arg (- arg (count-lines (point-min) (window-start))))
+	       ;; make sure that other buffer has enough lines
+	       (save-excursion
+		 (insert-char ?\n
+			      (- arg (count-lines (window-start)
+						  (goto-char (point-max)))
+				 -1)))
+	       (scroll-up arg)))))
+    (message "Autoscrolling is off.")))
+
 
-;;;###autoload
-(defun tc-scroll-up (arg)
-  "Scroll current window upward by ARG screens.
-The associated window gets scrolled to the same line."
-  (interactive "p")
-  (tc-scroll-line (* arg (- (window-height)
-				    next-screen-context-lines 1))))
 
-;;;###autoload
-(defun tc-scroll-down (arg)
-  "Scroll current window downward by ARG screens.
-The associated window gets scrolled to the same line."
-  (interactive "p")
-  (tc-scroll-line (* arg (- next-screen-context-lines
-				    (window-height) -1))))
+(defun 2C-autoscroll ()
+  (if 2C-autoscroll
+      ;; catch a mouse scroll on non-selected scrollbar
+      (select-window
+       (prog1 (selected-window)
+	 (and (consp last-command-char)
+	      (not (eq (selected-window)
+		       (car (car (cdr last-command-char)))))
+	      (select-window (car (car (cdr last-command-char)))))
+	 ;; In some cases scrolling causes an error, but post-command-hook
+	 ;; shouldn't, and should always stay in the original window
+	 (condition-case ()
+	     (and (or 2C-autoscroll-start (2C-toggle-autoscroll t) nil)
+		  (/= (window-start) 2C-autoscroll-start)
+		  (2C-other)
+		  (get-buffer-window (2C-other))
+		  (let ((lines (count-lines (window-start)
+					    2C-autoscroll-start)))
+		    (if (< (window-start) 2C-autoscroll-start)
+			(setq lines (- lines)))
+		    (setq 2C-autoscroll-start (window-start))
+		    (select-window (get-buffer-window (2C-other)))
+		    ;; make sure that other buffer has enough lines
+		    (save-excursion
+		      (insert-char
+		       ?\n (- lines (count-lines (window-start)
+						 (goto-char (point-max)))
+			      -1)))
+		    (scroll-up lines)
+		    (setq 2C-autoscroll-start (window-start))))
+	   (error))))))
 
-;;;###autoload
-(defun tc-recenter (arg)
-  "Center point in window.  With ARG, put point on line ARG.
-This counts from bottom if ARG is negative.  The associated window
-gets scrolled to the same line."
-  (interactive "P")
-  (setq arg (and arg (prefix-numeric-value arg)))
-  (tc-scroll-line (- (count-lines (window-start) (point))
-			     (cond ((null arg)  (/ (window-height) 2))
-				   ((< arg 0)  (+ (window-height) arg))
-				   (  arg)))))
+
 
 (defun enlarge-window-horizontally (arg)
   "Make current window ARG columns wider."
   (interactive "p")
   (enlarge-window arg t)
-  (and (tc-other)
-       (setq tc-window-width (+ tc-window-width arg))
-       (set-buffer (tc-other))
-       (setq tc-window-width (- tc-window-width arg))))
+  (and (2C-other)
+       (setq 2C-window-width (+ 2C-window-width arg))
+       (set-buffer (2C-other))
+       (setq 2C-window-width (- 2C-window-width arg))))
 
 (defun shrink-window-horizontally (arg)
   "Make current window ARG columns narrower."
   (interactive "p")
   (enlarge-window-horizontally (- arg)))
 
+
+
 (provide 'two-column)
 
 ;;; two-column.el ends here