Function: org-table-copy-region

org-table-copy-region is an autoloaded, interactive and byte-compiled function defined in org-table.el.gz.

Signature

(org-table-copy-region BEG END &optional CUT)

Documentation

Copy rectangular region in table to clipboard.

A special clipboard is used which can only be accessed with org-table-paste-rectangle. Return the region copied, as a list of lists of fields.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-table.el.gz
;;;###autoload
(defun org-table-copy-region (beg end &optional cut)
  "Copy rectangular region in table to clipboard.
A special clipboard is used which can only be accessed with
`org-table-paste-rectangle'.  Return the region copied, as a list
of lists of fields."
  (interactive (list
		(if (org-region-active-p) (region-beginning) (point))
		(if (org-region-active-p) (region-end) (point))
		current-prefix-arg))
  (goto-char (min beg end))
  (org-table-check-inside-data-field)
  (let ((beg (line-beginning-position))
	(c01 (org-table-current-column))
	region)
    (goto-char (max beg end))
    (org-table-check-inside-data-field nil t)
    (let* ((end (copy-marker (line-end-position)))
	   (c02 (org-table-current-column))
	   (column-start (min c01 c02))
	   (column-end (max c01 c02))
	   (column-number (1+ (- column-end column-start)))
	   (rpl (and cut "  ")))
      (goto-char beg)
      (while (< (point) end)
	(unless (org-at-table-hline-p)
	  ;; Collect every cell between COLUMN-START and COLUMN-END.
	  (let (cols)
	    (dotimes (c column-number)
	      (push (org-table-get-field (+ c column-start) rpl) cols))
	    (push (nreverse cols) region)))
	(forward-line))
      (set-marker end nil))
    (when cut (org-table-align))
    (when (called-interactively-p 'any)
      (message (substitute-command-keys "Cells in the region copied, use \
\\[org-table-paste-rectangle] to paste them in a table.")))
    (setq org-table-clip (nreverse region))))