Function: table--probe-cell

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

Signature

(table--probe-cell &optional ABORT-ON-ERROR)

Documentation

Probe a table cell around the point.

Searches for the left upper corner and the right bottom corner of a table cell which contains the current point location.

The result is a cons cell (left-upper . right-bottom) where the left-upper is the position before the cell's left upper corner character, the right-bottom is the position after the cell's right bottom corner character.

When it fails to find either one of the cell corners it returns nil or signals error if the optional ABORT-ON-ERROR is non-nil.

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/table.el.gz
(defun table--probe-cell (&optional abort-on-error)
  "Probe a table cell around the point.
Searches for the left upper corner and the right bottom corner of a table
cell which contains the current point location.

The result is a cons cell (left-upper . right-bottom) where
the left-upper is the position before the cell's left upper corner character,
the right-bottom is the position after the cell's right bottom corner character.

When it fails to find either one of the cell corners it returns nil or
signals error if the optional ABORT-ON-ERROR is non-nil."
  (let (lu rb
	(border (format "^[%s%c%c]+$"
			table-cell-horizontal-chars
			table-cell-vertical-char
			table-cell-intersection-char)))
    (if (and (condition-case nil
		 (progn
		   (and (setq lu (table--probe-cell-left-up))
			(setq rb (table--probe-cell-right-bottom))))
	       (error nil))
	     (< lu rb)
	     (let ((lu-coordinate (table--get-coordinate lu))
		   (rb-coordinate (table--get-coordinate rb)))
	       ;; test for valid upper and lower borders
	       (and (string-match
		     border
		     (buffer-substring
		      (save-excursion
			(table--goto-coordinate
			 (cons (1- (car lu-coordinate))
			       (1- (cdr lu-coordinate)))))
		      (save-excursion
			(table--goto-coordinate
			 (cons (1+ (car rb-coordinate))
			       (1- (cdr lu-coordinate)))))))
		    (string-match
		     border
		     (buffer-substring
		      (save-excursion
			(table--goto-coordinate
			 (cons (1- (car lu-coordinate))
			       (1+ (cdr rb-coordinate)))))
		      (save-excursion
			(table--goto-coordinate
			 (cons (1+ (car rb-coordinate))
			       (1+ (cdr rb-coordinate))))))))))
	(cons lu rb)
      (if abort-on-error
	  (error "Table cell not found")
	nil))))