Function: table--cell-can-span-p

table--cell-can-span-p is a byte-compiled function defined in table.el.gz.

Signature

(table--cell-can-span-p DIRECTION)

Documentation

Test if the current cell can span to DIRECTION.

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/table.el.gz
(defun table--cell-can-span-p (direction)
  "Test if the current cell can span to DIRECTION."
  (table-recognize-cell 'force)
  (and (not buffer-read-only)
       (table--probe-cell)
       ;; get two adjacent cells from each corner
       (let ((cell (save-excursion
		     (and
		      (table--goto-coordinate
		       (cons (cond ((eq direction 'right) (1+ (car table-cell-info-rb-coordinate)))
				   ((eq direction 'left)  (1- (car table-cell-info-lu-coordinate)))
				   (t (car table-cell-info-lu-coordinate)))
			     (cond ((eq direction 'above) (- (cdr table-cell-info-lu-coordinate) 2))
				   ((eq direction 'below) (+ (cdr table-cell-info-rb-coordinate) 2))
				   (t (cdr table-cell-info-lu-coordinate)))) 'no-extension)
		      (table--probe-cell))))
	     (cell2 (save-excursion
		      (and
		       (table--goto-coordinate
			(cons (cond ((eq direction 'right) (1+ (car table-cell-info-rb-coordinate)))
				    ((eq direction 'left)  (1- (car table-cell-info-lu-coordinate)))
				    (t (car table-cell-info-rb-coordinate)))
			      (cond ((eq direction 'above) (- (cdr table-cell-info-lu-coordinate) 2))
				    ((eq direction 'below) (+ (cdr table-cell-info-rb-coordinate) 2))
				    (t (cdr table-cell-info-rb-coordinate)))) 'no-extension)
		       (table--probe-cell)))))
	 ;; make sure the two cells exist, and they are identical, that cell's size matches the current one
	 (and cell
	      (equal cell cell2)
	      (if (or (eq direction 'right) (eq direction 'left))
		  (and (= (cdr (table--get-coordinate (car cell)))
			  (cdr table-cell-info-lu-coordinate))
		       (= (cdr (table--get-coordinate (cdr cell)))
			  (cdr table-cell-info-rb-coordinate)))
		(and (= (car (table--get-coordinate (car cell)))
			(car table-cell-info-lu-coordinate))
		     (= (car (table--get-coordinate (cdr cell)))
			(car table-cell-info-rb-coordinate))))))))