Function: table-recognize-region

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

Signature

(table-recognize-region BEG END &optional ARG)

Documentation

Recognize all tables within region.

BEG and END specify the region to work on. If the optional numeric prefix argument ARG is negative the tables in the region become inactive, meaning the tables become plain text and lose all the table specific features.

View in manual

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/table.el.gz
;;;###autoload
(defun table-recognize-region (beg end &optional arg)
  "Recognize all tables within region.
BEG and END specify the region to work on.  If the optional numeric
prefix argument ARG is negative the tables in the region become
inactive, meaning the tables become plain text and lose all the table
specific features."
  (interactive "r\nP")
  (setq arg (prefix-numeric-value arg))
  (let ((inhibit-read-only t)
	(modified-flag (buffer-modified-p)))
    (if (< arg 0)
	(table--remove-cell-properties beg end)
      (save-excursion
	(goto-char beg)
	(let* ((border (format "[%s%c%c]"
			       table-cell-horizontal-chars
			       table-cell-vertical-char
			       table-cell-intersection-char))
	       (non-border (format "[^%s%c%c]"
				   table-cell-horizontal-chars
				   table-cell-vertical-char
				   table-cell-intersection-char))
	       (inhibit-read-only t))
	  (unwind-protect
	      (progn
		(remove-text-properties beg end '(table-cell nil))
		(while (and (< (point) end)
			    (not (and (input-pending-p)
				      table-abort-recognition-when-input-pending)))
		  (cond
		   ((looking-at "\n")
		    (forward-char 1))
		   ((looking-at border)
		    (if (re-search-forward non-border end t)
			(goto-char (match-beginning 0))
		      (goto-char end)))
		   ((table--at-cell-p (point))
		    (goto-char (next-single-property-change (point) 'table-cell nil end)))
		   (t
		    (let ((cell (table-recognize-cell 'force 'no-copy)))
		      (if (and cell table-detect-cell-alignment)
			  (table--detect-cell-alignment cell)))
		    (unless (re-search-forward border end t)
		      (goto-char end))))))
            (restore-buffer-modified-p modified-flag)))))))