;;; two-column.el --- minor mode for editing of two-column text
-;; Copyright (C) 1992, 1993, 1994, 1995, 2001, 2002, 2003, 2004,
-;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 1992-1995, 2001-2011 Free Software Foundation, Inc.
;; Author: Daniel Pfeiffer <occitan@esperanto.org>
;; Adapted-By: ESR, Daniel Pfeiffer
(defcustom 2C-mode-line-format
'("-%*- %15b --" (-3 . "%p") "--%[(" mode-name
minor-mode-alist "%n" mode-line-process ")%]%-")
- "*Value of `mode-line-format' for a buffer in two-column minor mode."
+ "Value of `mode-line-format' for a buffer in two-column minor mode."
:type 'sexp
:group 'two-column)
(defcustom 2C-other-buffer-hook 'text-mode
- "*Hook run in new buffer when it is associated with current one."
+ "Hook run in new buffer when it is associated with current one."
:type 'function
:group 'two-column)
(defcustom 2C-separator ""
- "*A string inserted between the two columns when merging.
+ "A string inserted between the two columns when merging.
This gets set locally by \\[2C-split]."
:type 'string
:group 'two-column)
(defcustom 2C-window-width 40
- "*The width of the first column. (Must be at least `window-min-width')
+ "The width of the first column. (Must be at least `window-min-width')
This value is local for every buffer that sets it."
:type 'integer
:group 'two-column)
(defcustom 2C-beyond-fill-column 4
- "*Base for calculating `fill-column' for a buffer in two-column minor mode.
+ "Base for calculating `fill-column' for a buffer in two-column minor mode.
The value of `fill-column' becomes `2C-window-width' for this buffer
minus this value."
:type 'integer
;; first go to full width, so that we can certainly split into two windows
(unless (window-full-width-p)
(enlarge-window 99999 t))
- (split-window-horizontally
+ (split-window-right
(max window-min-width (min 2C-window-width
(- (frame-width) window-min-width))))
(if (2C-other)
(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))
- (forward-line 1)))))
+ (forward-line 1)
+ (move-to-column column)))))
(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))))
;; 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
;;; two-column.el ends here