Function: table-forward-cell

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

Signature

(table-forward-cell &optional ARG NO-RECOGNIZE UNRECOGNIZE)

Documentation

Move point forward to the beginning of the next cell.

With argument ARG, do it ARG times; a negative argument ARG = -N means move backward N cells.

Do not specify NO-RECOGNIZE and UNRECOGNIZE. They are for internal use only.

Sample Cell Traveling Order (In Irregular Table Cases)

You can actually try how it works in this buffer. Press M-x table-recognize (table-recognize) and go to cells in the following tables and press M-x table-forward-cell (table-forward-cell) or TAB key.

+-----+--+ +--+-----+ +--+--+--+ +--+--+--+ +---------+ +--+---+--+
|0 |1 | |0 |1 | |0 |1 |2 | |0 |1 |2 | |0 | |0 |1 |2 |
+--+--+ | | +--+--+ +--+ | | | | +--+ +----+----+ +--+-+-+--+
|2 |3 | | | |2 |3 | |3 +--+ | | +--+3 | |1 |2 | |3 |4 |
| +--+--+ +--+--+ | +--+4 | | | |4 +--+ +--+-+-+--+ +----+----+
| |4 | |4 | | |5 | | | | | |5 | |3 |4 |5 | |5 |
+--+-----+ +-----+--+ +--+--+--+ +--+--+--+ +--+---+--+ +---------+

+--+--+--+ +--+--+--+ +--+--+--+ +--+--+--+
|0 |1 |2 | |0 |1 |2 | |0 |1 |2 | |0 |1 |2 |
| | | | | +--+ | | | | | +--+ +--+
+--+ +--+ +--+3 +--+ | +--+ | |3 +--+4 |
|3 | |4 | |4 +--+5 | | |3 | | +--+5 +--+
| | | | | |6 | | | | | | |6 | |7 |
+--+--+--+ +--+--+--+ +--+--+--+ +--+--+--+

+--+--+--+ +--+--+--+ +--+--+--+--+ +--+-----+--+ +--+--+--+--+
|0 |1 |2 | |0 |1 |2 | |0 |1 |2 |3 | |0 |1 |2 | |0 |1 |2 |3 |
| +--+ | | +--+ | | +--+--+ | | | | | | +--+--+ |
| |3 +--+ +--+3 | | +--+4 +--+ +--+ +--+ +--+4 +--+
+--+ |4 | |4 | +--+ |5 +--+--+6 | |3 +--+--+4 | |5 | |6 |
|5 +--+ | | +--+5 | | |7 |8 | | | |5 |6 | | | | | |
| |6 | | | |6 | | +--+--+--+--+ +--+--+--+--+ +--+-----+--+
+--+--+--+ +--+--+--+

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/table.el.gz
;;;###autoload
(defun table-forward-cell (&optional arg no-recognize unrecognize)
  "Move point forward to the beginning of the next cell.
With argument ARG, do it ARG times;
a negative argument ARG = -N means move backward N cells.

Do not specify NO-RECOGNIZE and UNRECOGNIZE.  They are for
internal use only.

Sample Cell Traveling Order (In Irregular Table Cases)

You can actually try how it works in this buffer.  Press
\\[table-recognize] and go to cells in the following tables and press
\\[table-forward-cell] or TAB key.

+-----+--+  +--+-----+  +--+--+--+  +--+--+--+  +---------+  +--+---+--+
|0    |1 |  |0 |1    |  |0 |1 |2 |  |0 |1 |2 |  |0        |  |0 |1  |2 |
+--+--+  |  |  +--+--+  +--+  |  |  |  |  +--+  +----+----+  +--+-+-+--+
|2 |3 |  |  |  |2 |3 |  |3 +--+  |  |  +--+3 |  |1   |2   |  |3   |4   |
|  +--+--+  +--+--+  |  +--+4 |  |  |  |4 +--+  +--+-+-+--+  +----+----+
|  |4    |  |4    |  |  |5 |  |  |  |  |  |5 |  |3 |4  |5 |  |5        |
+--+-----+  +-----+--+  +--+--+--+  +--+--+--+  +--+---+--+  +---------+

+--+--+--+  +--+--+--+  +--+--+--+  +--+--+--+
|0 |1 |2 |  |0 |1 |2 |  |0 |1 |2 |  |0 |1 |2 |
|  |  |  |  |  +--+  |  |  |  |  |  +--+  +--+
+--+  +--+  +--+3 +--+  |  +--+  |  |3 +--+4 |
|3 |  |4 |  |4 +--+5 |  |  |3 |  |  +--+5 +--+
|  |  |  |  |  |6 |  |  |  |  |  |  |6 |  |7 |
+--+--+--+  +--+--+--+  +--+--+--+  +--+--+--+

+--+--+--+  +--+--+--+  +--+--+--+--+  +--+-----+--+  +--+--+--+--+
|0 |1 |2 |  |0 |1 |2 |	|0 |1 |2 |3 |  |0 |1    |2 |  |0 |1 |2 |3 |
|  +--+  |  |  +--+  |	|  +--+--+  |  |  |     |  |  |  +--+--+  |
|  |3 +--+  +--+3 |  |	+--+4    +--+  +--+     +--+  +--+4    +--+
+--+  |4 |  |4 |  +--+	|5 +--+--+6 |  |3 +--+--+4 |  |5 |     |6 |
|5 +--+  |  |  +--+5 |	|  |7 |8 |  |  |  |5 |6 |  |  |  |     |  |
|  |6 |  |  |  |6 |  |	+--+--+--+--+  +--+--+--+--+  +--+-----+--+
+--+--+--+  +--+--+--+"
  ;; After modifying this function, test against the above tables in
  ;; the doc string.  It is quite tricky.  The tables above do not
  ;; mean to cover every possible cases of cell layout, of course.
  ;; They are examples of tricky cases from implementation point of
  ;; view and provided for simple regression test purpose.
  (interactive "p")
  (or arg (setq arg 1))
  (table--finish-delayed-tasks)
  (while (null (zerop arg))
    (let* ((pivot (table--probe-cell 'abort-on-error))
	   (cell pivot) edge tip)
      ;; go to the beginning of the first right/left cell with same height if exists
      (while (and (setq cell (table--goto-coordinate
			      (cons (if (> arg 0) (1+ (car (table--get-coordinate (cdr cell))))
				      (1- (car (table--get-coordinate (car cell)))))
				    (cdr (table--get-coordinate (car pivot)))) 'no-extension))
		  (setq cell (table--probe-cell))
		  (/= (cdr (table--get-coordinate (car cell)))
		      (cdr (table--get-coordinate (car pivot))))))
      (if cell (goto-char (car cell))	; done
	;; if the horizontal move fails search the most left/right edge cell below/above the pivot
	;; but first find the edge cell
	(setq edge pivot)
	(while (and (table--goto-coordinate
		     (cons (if (> arg 0) (1- (car (table--get-coordinate (car edge))))
			     (1+ (car (table--get-coordinate (cdr edge)))))
			   (cdr (table--get-coordinate (car pivot)))) 'no-extension)
		    (setq cell (table--probe-cell))
		    (setq edge cell)))
	(setq cell (if (> arg 0) edge
		     (or (and (table--goto-coordinate
			       (cons (car (table--get-coordinate (cdr edge)))
				     (1- (cdr (table--get-coordinate (car edge))))))
			      (table--probe-cell))
			 edge)))
	;; now search for the tip which is the highest/lowest below/above cell
	(while cell
	  (let (below/above)
	    (and (table--goto-coordinate
		  (cons (car (table--get-coordinate (if (> arg 0) (car cell)
						      (cdr cell))))
			(if (> arg 0) (+ 2 (cdr (table--get-coordinate (cdr cell))))
			  (1- (cdr (table--get-coordinate (car pivot)))))) 'no-extension)
		 (setq below/above (table--probe-cell))
		 (or (null tip)
		     (if (> arg 0)
			 (< (cdr (table--get-coordinate (car below/above)))
			    (cdr (table--get-coordinate (car tip))))
		       (> (cdr (table--get-coordinate (car below/above)))
			  (cdr (table--get-coordinate (car tip))))))
		 (setq tip below/above)))
	  (and (setq cell (table--goto-coordinate
			   (cons (if (> arg 0) (1+ (car (table--get-coordinate (cdr cell))))
				   (1- (car (table--get-coordinate (car cell)))))
				 (if (> arg 0) (cdr (table--get-coordinate (car pivot)))
				   (1- (cdr (table--get-coordinate (car pivot)))))) 'no-extension))
	       (setq cell (table--probe-cell))))
	(if tip (goto-char (car tip))	; done
	  ;; let's climb up/down to the top/bottom from the edge
	  (while (and (table--goto-coordinate
		       (cons (if (> arg 0) (car (table--get-coordinate (car edge)))
			       (car (table--get-coordinate (cdr edge))))
			     (if (> arg 0) (1- (cdr (table--get-coordinate (car edge))))
			       (+ 2 (cdr (table--get-coordinate (cdr edge)))))) 'no-extension)
		      (setq cell (table--probe-cell))
		      (setq edge cell)))
	  (if (< arg 0)
	      (progn
		(setq cell edge)
		(while (and (table--goto-coordinate
			     (cons (1- (car (table--get-coordinate (car cell))))
				   (cdr (table--get-coordinate (cdr cell)))) 'no-extension)
			    (setq cell (table--probe-cell)))
		  (if (> (cdr (table--get-coordinate (car cell)))
			 (cdr (table--get-coordinate (car edge))))
		      (setq edge cell)))))
	  (goto-char (car edge)))))	; the top left cell
    (setq arg (if (> arg 0) (1- arg) (1+ arg))))
  (unless no-recognize
    (table-recognize-cell 'force nil (if unrecognize -1 nil)))) ; refill the cache with new cell contents