Function: table--valign

table--valign is a byte-compiled function defined in table.el.gz.

Signature

(table--valign)

Documentation

Vertically align the cache cell contents.

Current buffer must be the cache buffer at the entry to this function. Returns the coordinate of the final point location.

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/table.el.gz
(defun table--valign ()
  "Vertically align the cache cell contents.
Current buffer must be the cache buffer at the entry to this function.
Returns the coordinate of the final point location."
  (if (or (null table-cell-info-valign)
	  (eq table-cell-info-valign 'none))
      (table--get-coordinate)
    (let ((saved-point (point-marker)))
      ;;(set-marker-insertion-type saved-point t)
      (goto-char (point-min))
      (let* ((from (and (re-search-forward "^.*\\S " nil t)
			(table--current-line)))
	     (to (let ((tmp from))
		   (while (re-search-forward "^.*\\S " nil t)
		     (setq tmp (table--current-line)))
		   tmp))
	     (content-height (and from to (1+ (- to from)))))
	(unless (null content-height)
	  (goto-char (point-min))
	  (if (looking-at "\\s *\n")
	      (replace-match ""))
	  (cond ((eq table-cell-info-valign 'middle)
		 (insert (make-string (/ (- table-cell-info-height content-height) 2) ?\n)))
		((eq table-cell-info-valign 'bottom)
		 (insert (make-string (- table-cell-info-height content-height) ?\n))))
	  (table--goto-coordinate (cons table-cell-info-width (1- table-cell-info-height)))
	  (if (re-search-forward "\\s +\\'" nil t)
	      (replace-match ""))))
      (goto-char saved-point)
      (set-marker saved-point nil)
      (let ((coord (table--get-coordinate)))
	(unless (< (cdr coord) table-cell-info-height)
	  (setcdr coord (1- table-cell-info-height))
	  (table--goto-coordinate coord))
	coord))))