Function: 2C-split
2C-split is an autoloaded, interactive and byte-compiled function
defined in two-column.el.gz.
Signature
(2C-split ARG)
Documentation
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. You write the first line of each column and then split that line. E.g.:
First column's text sSs Second column's text
\___/\
/ \
5 character Separator You type M-5 C-x 6 s (2C-split) with the point here.
(See C-h m (describe-mode) .)
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/two-column.el.gz
(require 'fringe)) ; fringe-columns defsubst
;;;###autoload
(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. You
write the first line of each column and then split that line. E.g.:
First column's text sSs Second column's text
\\___/\\
/ \\
5 character Separator You type M-5 \\[2C-split] with the point here.
\(See \\[describe-mode] .)"
(interactive "*p")
(and (2C-other)
(if (y-or-n-p (format-message "Overwrite associated buffer `%s'? "
(buffer-name (2C-other))))
(with-current-buffer (2C-other)
(erase-buffer))
(signal 'quit nil)))
(let ((point (point))
;; 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
(backward-char arg)
(setq chars (buffer-substring (point) point))
(skip-chars-forward " \t" point)
(setq-local 2C-separator (buffer-substring (point) point))
(setq 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
(save-excursion
(while (not (eobp))
(if (not (and (= (current-column) column)
(string= chars
(buffer-substring (point)
(save-excursion
(backward-char arg)
(point))))))
(setq n (1+ n))
(setq point (point))
(backward-char arg)
(skip-chars-backward " \t")
(delete-region point (point))
(setq point (point))
(insert-char ?\n n)
(append-to-buffer other point (progn (end-of-line)
(if (eobp)
(point)
(1+ (point)))))
(delete-region point (point))
(setq n 0))
(forward-line 1)
(move-to-column column)))))