Function: org-table-highlight-rectangle

org-table-highlight-rectangle is a byte-compiled function defined in org-table.el.gz.

Signature

(org-table-highlight-rectangle &optional BEG END FACE)

Documentation

Highlight rectangular region in a table.

When buffer positions BEG and END are provided, use them to delimit the region to highlight. Otherwise, refer to point. Use FACE, when non-nil, for the highlight.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-table.el.gz
(defun org-table-highlight-rectangle (&optional beg end face)
  "Highlight rectangular region in a table.
When buffer positions BEG and END are provided, use them to
delimit the region to highlight.  Otherwise, refer to point.  Use
FACE, when non-nil, for the highlight."
  (let* ((beg (or beg (point)))
	 (end (or end (point)))
	 (b (min beg end))
	 (e (max beg end))
	 (start-coordinates
	  (save-excursion
	    (goto-char b)
	    (cons (line-beginning-position) (org-table-current-column))))
	 (end-coordinates
	  (save-excursion
	    (goto-char e)
	    (cons (line-beginning-position) (org-table-current-column)))))
    (when (boundp 'org-show-positions)
      (setq org-show-positions (cons b (cons e org-show-positions))))
    (goto-char (car start-coordinates))
    (let ((column-start (min (cdr start-coordinates) (cdr end-coordinates)))
	  (column-end (max (cdr start-coordinates) (cdr end-coordinates)))
	  (last-row (car end-coordinates)))
      (while (<= (point) last-row)
	(when (looking-at org-table-dataline-regexp)
	  (org-table-goto-column column-start)
	  (skip-chars-backward "^|\n")
	  (let ((p (point)))
	    (org-table-goto-column column-end)
	    (skip-chars-forward "^|\n")
	    (org-table-add-rectangle-overlay p (point) face)))
	(forward-line)))
    (goto-char (car start-coordinates)))
  (add-hook 'before-change-functions #'org-table-remove-rectangle-highlight))