Function: table--cell-insert-char

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

Signature

(table--cell-insert-char CHAR &optional OVERWRITE)

Documentation

Insert CHAR inside a table cell.

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/table.el.gz
(defun table--cell-insert-char (char &optional overwrite)
  "Insert CHAR inside a table cell."
  (let ((delete-selection-p (and delete-selection-mode
				 transient-mark-mode mark-active
				 (not buffer-read-only)))
	(mark-coordinate (table--transcoord-table-to-cache (table--get-coordinate (mark t)))))
    (table-with-cache-buffer
      (and delete-selection-p
	   (>= (car mark-coordinate) 0)
	   (<= (car mark-coordinate) table-cell-info-width)
	   (>= (cdr mark-coordinate) 0)
	   (<= (cdr mark-coordinate) table-cell-info-height)
	   (save-excursion
	     (delete-region (point) (table--goto-coordinate mark-coordinate))))
      (if overwrite
	  (let ((coordinate (table--get-coordinate)))
	    (setq table-inhibit-auto-fill-paragraph t)
	    (if (>= (car coordinate) table-cell-info-width)
		(if (>= (cdr coordinate) (1- table-cell-info-height))
		    (insert "\n" char)
		  (forward-line 1)
		  (insert char)
		  (unless (eolp)
		    (delete-char 1)))
	      (insert char)
	      (unless (eolp)
		(delete-char 1))))
	(if (not (eq char ?\s))
	    (if char (insert char))
	  (if (not (looking-at "\\s *$"))
	      (if (and table-fixed-width-mode
		       (> (point) 2)
		       (save-excursion
			 (forward-char -2)
			 (looking-at (concat "\\("
					     (regexp-quote (char-to-string table-word-continuation-char))
					     "\\)\n"))))
		  (save-excursion
		    (replace-match " " nil nil nil 1))
		(insert char))
	    (let ((coordinate (table--get-coordinate)))
	      (if (< (car coordinate) table-cell-info-width)
		  (move-to-column (1+ (car coordinate)) t)
		(insert (make-string (forward-line 1) ?\n))
		(unless (bolp) (insert ?\n))))
	    (setq table-inhibit-auto-fill-paragraph t))
	  (save-excursion
	    (let ((o-point (point)))
	      (if (and (bolp)
		       (or (progn
			     (forward-paragraph)
			     (forward-paragraph -1)
			     (= o-point (point)))
			   (progn
			     (goto-char o-point)
			     (forward-line)
			     (setq o-point (point))
			     (forward-paragraph)
			     (forward-paragraph -1)
			     (= o-point (point)))))
		  (insert ?\n)))))))))