Function: table-split-cell-vertically

table-split-cell-vertically is an autoloaded, interactive and byte-compiled function defined in table.el.gz.

Signature

(table-split-cell-vertically)

Documentation

Split current cell vertically.

Creates a cell above and a cell below the current point location.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/table.el.gz
;;;###autoload
(defun table-split-cell-vertically ()
  "Split current cell vertically.
Creates a cell above and a cell below the current point location."
  (interactive "*")
  (table-recognize-cell 'force)
  (let ((point-y (cdr (table--get-coordinate))))
    (unless (table--cell-can-split-vertically-p)
      (error "Can't split here"))
    (let* ((old-coordinate (table--get-coordinate))
	   (column (current-column))
	   (beg (table--goto-coordinate
		 (cons (1- (car table-cell-info-lu-coordinate))
		       point-y)))
	   (end (table--goto-coordinate
		 (cons (1+ (car table-cell-info-rb-coordinate))
		       point-y)))
	   (line (buffer-substring (1+ beg) (1- end))))
      (when (= (cdr old-coordinate) (cdr table-cell-info-rb-coordinate))
	(table--goto-coordinate old-coordinate)
	(table-heighten-cell 1 'no-copy 'no-update))
      (goto-char beg)
      (delete-region beg end)
      (insert table-cell-intersection-char
	      (make-string table-cell-info-width (string-to-char table-cell-horizontal-chars))
	      table-cell-intersection-char)
      (table--goto-coordinate old-coordinate)
      (forward-line 1)
      (move-to-column column)
      (setq old-coordinate (table--get-coordinate))
      (table-recognize-cell 'force)
      (unless (string-match "^\\s *$" line)
	(table-with-cache-buffer
	  (goto-char (point-min))
	  (insert line ?\n)
	  (goto-char (point-min)) ;; don't heighten cell unnecessarily
	  (setq table-inhibit-auto-fill-paragraph t)))
      (table--update-cell 'now)	;; can't defer this operation
      (table--goto-coordinate old-coordinate)
      (move-to-column column)
      (table-recognize-cell 'force))))