;;; two-column.el --- minor mode for editing of two-column text
;; Copyright (C) 1992, 1993, 1994, 1995, 2001, 2002, 2003, 2004,
-;; 2005, 2006 Free Software Foundation, Inc.
+;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
;; Author: Daniel Pfeiffer <occitan@esperanto.org>
;; Adapted-By: ESR, Daniel Pfeiffer
;; This file is part of GNU Emacs.
-;; Esperanto: English:
+;; 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 3 of the License, or
+;; (at your option) any later version.
-;; ^Ci dosiero estas ero de GNU Emacs. This file is part of GNU Emacs.
+;; 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.
-;; 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.
-
-;; 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
-
-;; Free Software Foundation, 51 Franklin Street, Fifth Floor
-;; Boston, MA 02110-1301, USA.
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
first and the associated buffer to its right."
(interactive "P")
;; first go to full width, so that we can certainly split into two windows
- (if (< (window-width) (frame-width))
- (enlarge-window 99999 t))
+ (unless (window-full-width-p)
+ (enlarge-window 99999 t))
(split-window-horizontally
(max window-min-width (min 2C-window-width
(- (frame-width) window-min-width))))
(if (y-or-n-p (concat "Overwrite associated buffer `"
(buffer-name (2C-other))
"'? "))
- (save-excursion
- (set-buffer (2C-other))
+ (with-current-buffer (2C-other)
(erase-buffer))
(signal 'quit nil)))
(let ((point (point))
- ; make next-line always come back to same column
- (goal-column (current-column))
- ; a counter for empty lines in other buffer
+ ;; make next-line always come back to same column
+ (column (current-column))
+ ;; a counter for empty lines in other buffer
(n (1- (count-lines (point-min) (point))))
chars other)
(save-excursion
(skip-chars-forward " \t" point)
(make-local-variable '2C-separator)
(setq 2C-separator (buffer-substring (point) point)
- 2C-window-width (current-column)))
+ 2C-window-width (+ (fringe-columns 'left)
+ (fringe-columns 'right)
+ (scroll-bar-columns 'left)
+ (scroll-bar-columns 'right)
+ (current-column))))
(2C-two-columns)
(setq other (2C-other))
- ; now we're ready to actually split
+ ;; now we're ready to actually split
(save-excursion
(while (not (eobp))
- (if (not (and (= (current-column) goal-column)
+ (if (not (and (= (current-column) column)
(string= chars
(buffer-substring (point)
(save-excursion
(1+ (point)))))
(delete-region point (point))
(setq n 0))
- (next-line 1)))))
+ (forward-line 1)
+ (move-to-column column)))))
(end-of-line)
(indent-to-column 2C-window-width)
(insert 2C-separator string))
- (next-line 1) ; add one if necessary
+ (forward-line 1) ; add one if necessary
(set-buffer b2))))
- (if (< (window-width) (frame-width))
- (enlarge-window 99999 t)))
+ (unless (window-full-width-p)
+ (enlarge-window 99999 t)))
\f
;;;;; utility functions ;;;;;
(if (get-buffer-window (2C-other t))
(select-window (get-buffer-window (2C-other)))
(switch-to-buffer (2C-other)))
- (newline (goto-line line))
+ (goto-char (point-min))
+ (newline (forward-line (1- line)))
(if col
(move-to-column col)
(end-of-line 1))))
(newline arg))
(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."
+ "Toggle autoscrolling.
+With prefix argument ARG, turn on autoscrolling if ARG is
+positive, otherwise turn it off. When autoscrolling is turned
+on, this also realigns the two buffers."
(interactive "P")
;(sit-for 0)
(setq 2C-autoscroll-start (window-start))
;; catch a mouse scroll on non-selected scrollbar
(select-window
(prog1 (selected-window)
- (and (consp last-command-char)
+ (and (consp last-command-event)
(not (eq (selected-window)
- (car (car (cdr last-command-char)))))
- (select-window (car (car (cdr last-command-char)))))
+ (car (car (cdr last-command-event)))))
+ (select-window (car (car (cdr last-command-event)))))
;; In some cases scrolling causes an error, but post-command-hook
;; shouldn't, and should always stay in the original window
(condition-case ()
(provide 'two-column)
-;;; arch-tag: 2021b5ab-d3a4-4a8c-a21c-1936b0f9e6b1
+;; arch-tag: 2021b5ab-d3a4-4a8c-a21c-1936b0f9e6b1
;;; two-column.el ends here