Function: table--generate-source-cells-in-a-row

table--generate-source-cells-in-a-row is a byte-compiled function defined in table.el.gz.

Signature

(table--generate-source-cells-in-a-row DEST-BUFFER LANGUAGE COL-LIST ROW-LIST)

Documentation

Generate and insert source cells into DEST-BUFFER.

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/table.el.gz
(defun table--generate-source-cells-in-a-row (dest-buffer language col-list row-list)
  "Generate and insert source cells into DEST-BUFFER."
  (table-put-source-info 'current-column 1)
  (while col-list
    (let* ((cell (table--probe-cell))
	   (lu (table--get-coordinate (car cell)))
	   (rb (table--get-coordinate (cdr cell)))
	   (alignment (table--get-cell-justify-property cell))
	   (valign (table--get-cell-valign-property cell))
	   (row-list row-list)
	   (colspan 1)
	   (rowspan 1))
	(if (< (car lu) (car col-list))
	    (setq col-list nil)
	  (while (and col-list
		      (> (car lu) (car col-list)))
	    (setq col-list (cdr col-list))
	    (table-put-source-info 'current-column (1+ (table-get-source-info 'current-column))))
	  (setq col-list (cdr col-list))
	  (table-put-source-info 'next-column (1+ (table-get-source-info 'current-column)))
	  (while (and col-list
		      (> (1+ (car rb)) (car col-list)))
	    (setq colspan (1+ colspan))
	    (setq col-list (cdr col-list))
	    (table-put-source-info 'next-column (1+ (table-get-source-info 'next-column))))
	  (setq row-list (cdr row-list))
	  (while (and row-list
		      (> (+ (cdr rb) 2) (car row-list)))
	    (setq rowspan (1+ rowspan))
	    (setq row-list (cdr row-list)))
	  (with-current-buffer dest-buffer
	    (cond
	     ((eq language 'html)
	      (insert (format "    <%s"
			      (table-put-source-info
			       'cell-type
			       (if (or (<= (table-get-source-info 'current-row) table-html-th-rows)
				       (<= (table-get-source-info 'current-column) table-html-th-columns))
				   "th" "td"))))
	      (if (and table-html-cell-attribute (not (string= table-html-cell-attribute "")))
		  (insert " " table-html-cell-attribute))
	      (if (> colspan 1) (insert (format " colspan=\"%d\"" colspan)))
	      (if (> rowspan 1) (insert (format " rowspan=\"%d\"" rowspan)))
	      (insert (format " align=\"%s\"" (if alignment (symbol-name alignment) "left")))
	      (insert (format " valign=\"%s\"" (if valign (symbol-name valign) "top")))
	      (insert ">\n"))
	     ((eq language 'cals)
	      (insert "        <entry")
	      (if (> colspan 1)
		  (let ((scol (table-get-source-info 'current-column))
			(ecol (+ (table-get-source-info 'current-column) colspan -1)))
		    (mapc (lambda (col)
			    (unless (memq col (table-get-source-info 'colnum-list))
			      (table-put-source-info 'colnum-list
						     (cons col (table-get-source-info 'colnum-list)))))
			  (list scol ecol))
		    (insert (format " namest=\"c%d\" nameend=\"c%d\"" scol ecol))))
	      (if (> rowspan 1) (insert (format " morerows=\"%d\"" (1- rowspan))))
	      (if (and alignment
		       (not (memq alignment '(left none))))
		  (insert " align=\"" (symbol-name alignment) "\""))
	      (if (and valign
		       (not (memq valign '(top none))))
		  (insert " valign=\"" (symbol-name valign) "\""))
	      (insert ">\n"))
	     ((memq language '(wiki mediawiki))
	      (insert "|"))))
	  (table--generate-source-cell-contents dest-buffer language cell)
	  (with-current-buffer dest-buffer
	    (cond
	     ((eq language 'html)
	      (insert (format"    </%s>\n" (table-get-source-info 'cell-type))))
	     ((eq language 'cals)
	      (insert "        </entry>\n"))
	     ((eq language 'wiki)
	      (insert "|"))
	     ((eq language 'mediawiki)
	      (insert ?\n))))
	  (table-forward-cell 1 t)
	  (table-put-source-info 'current-column (table-get-source-info 'next-column))
	  ))))