Mercurial > emacs
comparison lisp/textmodes/table.el @ 64059:77cc3a2cedb3
(table-hooks): Finish `defgroup' description with period.
(table-insert, table-shorten-cell, table--generate-source-scan-lines,
table-delete-row, *table--cell-delete-char, table--spacify-frame,
table--horizontally-shift-above-and-below, table--cell-insert-char,
table--cell-blank-str, table--fill-region-strictly): "?\ " -> "?\s".
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Mon, 04 Jul 2005 03:41:55 +0000 |
parents | 6f4701bb40a7 |
children | a8fa7c632ee4 |
comparison
equal
deleted
inserted
replaced
64058:7e00d33823d3 | 64059:77cc3a2cedb3 |
---|---|
648 :group 'paragraphs | 648 :group 'paragraphs |
649 :group 'fill | 649 :group 'fill |
650 :version "22.1") | 650 :version "22.1") |
651 | 651 |
652 (defgroup table-hooks nil | 652 (defgroup table-hooks nil |
653 "Hooks for table manipulation utilities" | 653 "Hooks for table manipulation utilities." |
654 :group 'table) | 654 :group 'table) |
655 | 655 |
656 (defcustom table-time-before-update 0.2 | 656 (defcustom table-time-before-update 0.2 |
657 "*Time in seconds before updating the cell contents after typing. | 657 "*Time in seconds before updating the cell contents after typing. |
658 Updating the cell contents on the screen takes place only after this | 658 Updating the cell contents on the screen takes place only after this |
1676 (insert table-cell-vertical-char) | 1676 (insert table-cell-vertical-char) |
1677 (setq cw cell-width) | 1677 (setq cw cell-width) |
1678 (setq i 0) | 1678 (setq i 0) |
1679 (while (< i columns) | 1679 (while (< i columns) |
1680 (let ((beg (point))) | 1680 (let ((beg (point))) |
1681 (insert (make-string (car cw) ?\ )) | 1681 (insert (make-string (car cw) ?\s)) |
1682 (insert table-cell-vertical-char) | 1682 (insert table-cell-vertical-char) |
1683 (table--put-cell-line-property beg (1- (point)))) | 1683 (table--put-cell-line-property beg (1- (point)))) |
1684 (if (cdr cw) (setq cw (cdr cw))) | 1684 (if (cdr cw) (setq cw (cdr cw))) |
1685 (setq i (1+ i))) | 1685 (setq i (1+ i))) |
1686 (setq cell-str (buffer-substring (point-min) (point-max)))) | 1686 (setq cell-str (buffer-substring (point-min) (point-max)))) |
2245 (exclude-right (and right (<= (cddr right) (cddr this)))) | 2245 (exclude-right (and right (<= (cddr right) (cddr this)))) |
2246 (beg (table--goto-coordinate (cons (caar this) (cdar this)))) | 2246 (beg (table--goto-coordinate (cons (caar this) (cdar this)))) |
2247 (end (table--goto-coordinate (cons (cadr this) bottom-border-y))) | 2247 (end (table--goto-coordinate (cons (cadr this) bottom-border-y))) |
2248 (rect (extract-rectangle beg end)) | 2248 (rect (extract-rectangle beg end)) |
2249 (height (+ (- (cddr this) (cdar this)) 1)) | 2249 (height (+ (- (cddr this) (cdar this)) 1)) |
2250 (blank-line (make-string (- (cadr this) (caar this)) ?\ ))) | 2250 (blank-line (make-string (- (cadr this) (caar this)) ?\s))) |
2251 ;; delete lines from the bottom of the cell | 2251 ;; delete lines from the bottom of the cell |
2252 (setcdr (nthcdr (- height bottom-budget 1) rect) (nthcdr height rect)) | 2252 (setcdr (nthcdr (- height bottom-budget 1) rect) (nthcdr height rect)) |
2253 ;; delete lines from the top of the cell | 2253 ;; delete lines from the top of the cell |
2254 (if (> n bottom-budget) | 2254 (if (> n bottom-budget) |
2255 (let ((props (text-properties-at 0 (car rect)))) | 2255 (let ((props (text-properties-at 0 (car rect)))) |
3361 (replace-match (concat "$" (match-string 3) "$")) t t))) | 3361 (replace-match (concat "$" (match-string 3) "$")) t t))) |
3362 (setq line (buffer-substring (point-min) (point-max)))) | 3362 (setq line (buffer-substring (point-min) (point-max)))) |
3363 ;; insert a column separator and column/multicolumn contents | 3363 ;; insert a column separator and column/multicolumn contents |
3364 (with-current-buffer dest-buffer | 3364 (with-current-buffer dest-buffer |
3365 (unless first-p | 3365 (unless first-p |
3366 (insert (if (eq (char-before) ?\ ) "" " ") "& ")) | 3366 (insert (if (eq (char-before) ?\s) "" " ") "& ")) |
3367 (if (> span 1) | 3367 (if (> span 1) |
3368 (insert (format "\\multicolumn{%d}{%sl|}{%s}" span (if first-p "|" "") line)) | 3368 (insert (format "\\multicolumn{%d}{%sl|}{%s}" span (if first-p "|" "") line)) |
3369 (insert line))) | 3369 (insert line))) |
3370 (setq first-p nil) | 3370 (setq first-p nil) |
3371 (setq span 1) | 3371 (setq span 1) |
3377 (funcall insert-column start (1- (nth i col-list))) | 3377 (funcall insert-column start (1- (nth i col-list))) |
3378 (setq span (1+ span))) | 3378 (setq span (1+ span))) |
3379 (setq i (1+ i))) | 3379 (setq i (1+ i))) |
3380 (funcall insert-column start x1)) | 3380 (funcall insert-column start x1)) |
3381 (with-current-buffer dest-buffer | 3381 (with-current-buffer dest-buffer |
3382 (insert (if (eq (char-before) ?\ ) "" " ") "\\\\\n")))) | 3382 (insert (if (eq (char-before) ?\s) "" " ") "\\\\\n")))) |
3383 (setq y (1+ y))) | 3383 (setq y (1+ y))) |
3384 (with-current-buffer dest-buffer | 3384 (with-current-buffer dest-buffer |
3385 (insert "\\hline\n")) | 3385 (insert "\\hline\n")) |
3386 )) | 3386 )) |
3387 | 3387 |
3532 (table--goto-coordinate (cons (1+ (car rb-coord)) (1+ (cdr bt-coord))))) | 3532 (table--goto-coordinate (cons (1+ (car rb-coord)) (1+ (cdr bt-coord))))) |
3533 (table--goto-coordinate (cons (1- (car lu-coord)) (1- (cdr lu-coord)))) | 3533 (table--goto-coordinate (cons (1- (car lu-coord)) (1- (cdr lu-coord)))) |
3534 ;; insert the remaining area while appending blank lines below it | 3534 ;; insert the remaining area while appending blank lines below it |
3535 (table--insert-rectangle | 3535 (table--insert-rectangle |
3536 (append rect (make-list (+ 2 (- (cdr rb-coord) (cdr lu-coord))) | 3536 (append rect (make-list (+ 2 (- (cdr rb-coord) (cdr lu-coord))) |
3537 (make-string (+ 2 (- (car rb-coord) (car lu-coord))) ?\ )))) | 3537 (make-string (+ 2 (- (car rb-coord) (car lu-coord))) ?\s)))) |
3538 ;; remove the appended blank lines below the table if they are unnecessary | 3538 ;; remove the appended blank lines below the table if they are unnecessary |
3539 (table--goto-coordinate (cons 0 (- (cdr bt-coord) (- (cdr rb-coord) (cdr lu-coord))))) | 3539 (table--goto-coordinate (cons 0 (- (cdr bt-coord) (- (cdr rb-coord) (cdr lu-coord))))) |
3540 (table--remove-blank-lines (+ 2 (- (cdr rb-coord) (cdr lu-coord)))) | 3540 (table--remove-blank-lines (+ 2 (- (cdr rb-coord) (cdr lu-coord)))) |
3541 ;; fix up intersections | 3541 ;; fix up intersections |
3542 (let ((coord (cons (car lu-coord) (1- (cdr lu-coord)))) | 3542 (let ((coord (cons (car lu-coord) (1- (cdr lu-coord)))) |
4012 (unless (zerop (cdr coordinate)) | 4012 (unless (zerop (cdr coordinate)) |
4013 (table--goto-coordinate (cons (1- table-cell-info-width) (1- (cdr coordinate)))) | 4013 (table--goto-coordinate (cons (1- table-cell-info-width) (1- (cdr coordinate)))) |
4014 (unless (eolp) | 4014 (unless (eolp) |
4015 (delete-char 1))) | 4015 (delete-char 1))) |
4016 (delete-char -1) | 4016 (delete-char -1) |
4017 (insert ?\ ) | 4017 (insert ?\s) |
4018 (forward-char -1))) | 4018 (forward-char -1))) |
4019 (setq n (1+ n))) | 4019 (setq n (1+ n))) |
4020 (setq table-inhibit-auto-fill-paragraph t)) | 4020 (setq table-inhibit-auto-fill-paragraph t)) |
4021 (let ((coordinate (table--get-coordinate)) | 4021 (let ((coordinate (table--get-coordinate)) |
4022 (end-marker (copy-marker (+ (point) n))) | 4022 (end-marker (copy-marker (+ (point) n))) |
4444 (and (zerop (forward-line 1)) | 4444 (and (zerop (forward-line 1)) |
4445 (zerop (current-column)) | 4445 (zerop (current-column)) |
4446 (move-to-column col) | 4446 (move-to-column col) |
4447 (table--spacify-frame)))) | 4447 (table--spacify-frame)))) |
4448 (delete-char 1) | 4448 (delete-char 1) |
4449 (insert-before-markers ?\ )) | 4449 (insert-before-markers ?\s)) |
4450 ((table--cell-horizontal-char-p (char-after)) | 4450 ((table--cell-horizontal-char-p (char-after)) |
4451 (while (progn | 4451 (while (progn |
4452 (delete-char 1) | 4452 (delete-char 1) |
4453 (insert-before-markers ?\ ) | 4453 (insert-before-markers ?\s) |
4454 (table--cell-horizontal-char-p (char-after))))) | 4454 (table--cell-horizontal-char-p (char-after))))) |
4455 ((eq (char-after) table-cell-vertical-char) | 4455 ((eq (char-after) table-cell-vertical-char) |
4456 (while (let ((col (current-column))) | 4456 (while (let ((col (current-column))) |
4457 (delete-char 1) | 4457 (delete-char 1) |
4458 (insert-before-markers ?\ ) | 4458 (insert-before-markers ?\s) |
4459 (and (zerop (forward-line 1)) | 4459 (and (zerop (forward-line 1)) |
4460 (zerop (current-column)) | 4460 (zerop (current-column)) |
4461 (move-to-column col) | 4461 (move-to-column col) |
4462 (eq (char-after) table-cell-vertical-char)))))) | 4462 (eq (char-after) table-cell-vertical-char)))))) |
4463 (memq (char-after) frame-char))))) | 4463 (memq (char-after) frame-char))))) |
4609 (if (< columns-to-extend 0) | 4609 (if (< columns-to-extend 0) |
4610 (progn | 4610 (progn |
4611 (table--untabify-line) | 4611 (table--untabify-line) |
4612 (delete-char columns-to-extend)) | 4612 (delete-char columns-to-extend)) |
4613 (table--untabify-line (point)) | 4613 (table--untabify-line (point)) |
4614 (insert (make-string columns-to-extend ?\ ))) | 4614 (insert (make-string columns-to-extend ?\s))) |
4615 (setcdr coord (1- (cdr coord))))) | 4615 (setcdr coord (1- (cdr coord))))) |
4616 (table--goto-coordinate (caar (last top-to-bottom-coord-list))) | 4616 (table--goto-coordinate (caar (last top-to-bottom-coord-list))) |
4617 (let ((coord (table--get-coordinate (cdr (table--horizontal-cell-list nil 'first-only 'bottom))))) | 4617 (let ((coord (table--get-coordinate (cdr (table--horizontal-cell-list nil 'first-only 'bottom))))) |
4618 (setcar coord (1+ (car coord))) | 4618 (setcar coord (1+ (car coord))) |
4619 (setcdr coord (+ (cdr coord) 2)) | 4619 (setcdr coord (+ (cdr coord) 2)) |
4623 (if (< columns-to-extend 0) | 4623 (if (< columns-to-extend 0) |
4624 (progn | 4624 (progn |
4625 (table--untabify-line) | 4625 (table--untabify-line) |
4626 (delete-char columns-to-extend)) | 4626 (delete-char columns-to-extend)) |
4627 (table--untabify-line (point)) | 4627 (table--untabify-line (point)) |
4628 (insert (make-string columns-to-extend ?\ ))) | 4628 (insert (make-string columns-to-extend ?\s))) |
4629 (setcdr coord (1+ (cdr coord))))) | 4629 (setcdr coord (1+ (cdr coord))))) |
4630 (while (<= (cdr beg-coord) (cdr end-coord)) | 4630 (while (<= (cdr beg-coord) (cdr end-coord)) |
4631 (table--untabify-line (table--goto-coordinate beg-coord 'no-extension)) | 4631 (table--untabify-line (table--goto-coordinate beg-coord 'no-extension)) |
4632 (setcdr beg-coord (1+ (cdr beg-coord))))))) | 4632 (setcdr beg-coord (1+ (cdr beg-coord))))))) |
4633 | 4633 |
4852 (unless (eolp) | 4852 (unless (eolp) |
4853 (delete-char 1))) | 4853 (delete-char 1))) |
4854 (insert char) | 4854 (insert char) |
4855 (unless (eolp) | 4855 (unless (eolp) |
4856 (delete-char 1)))) | 4856 (delete-char 1)))) |
4857 (if (not (eq char ?\ )) | 4857 (if (not (eq char ?\s)) |
4858 (if char (insert char)) | 4858 (if char (insert char)) |
4859 (if (not (looking-at "\\s *$")) | 4859 (if (not (looking-at "\\s *$")) |
4860 (if (and table-fixed-width-mode | 4860 (if (and table-fixed-width-mode |
4861 (> (point) 2) | 4861 (> (point) 2) |
4862 (save-excursion | 4862 (save-excursion |
5396 (save-excursion (forward-line 1) (point)))) | 5396 (save-excursion (forward-line 1) (point)))) |
5397 ))) | 5397 ))) |
5398 | 5398 |
5399 (defun table--cell-blank-str (&optional n) | 5399 (defun table--cell-blank-str (&optional n) |
5400 "Return blank table cell string of length N." | 5400 "Return blank table cell string of length N." |
5401 (let ((str (make-string (or n 1) ?\ ))) | 5401 (let ((str (make-string (or n 1) ?\s))) |
5402 (table--put-cell-content-property 0 (length str) str) | 5402 (table--put-cell-content-property 0 (length str) str) |
5403 str)) | 5403 str)) |
5404 | 5404 |
5405 (defun table--remove-eol-spaces (beg end &optional bol force) | 5405 (defun table--remove-eol-spaces (beg end &optional bol force) |
5406 "Remove spaces at the end of each line in the BEG END region of the current buffer. | 5406 "Remove spaces at the end of each line in the BEG END region of the current buffer. |
5479 (looking-at " *$")) | 5479 (looking-at " *$")) |
5480 (delete-region (match-beginning 0) (match-end 0)) | 5480 (delete-region (match-beginning 0) (match-end 0)) |
5481 (and (zerop (forward-line 1)) | 5481 (and (zerop (forward-line 1)) |
5482 (< (point) end))) | 5482 (< (point) end))) |
5483 (t (forward-char -1) | 5483 (t (forward-char -1) |
5484 (insert-before-markers (if (equal (char-before) ?\ ) ?\ table-word-continuation-char) | 5484 (insert-before-markers (if (equal (char-before) ?\s) ?\s table-word-continuation-char) |
5485 "\n") | 5485 "\n") |
5486 t))))) | 5486 t))))) |
5487 | 5487 |
5488 (defun table--goto-coordinate (coordinate &optional no-extension no-tab-expansion) | 5488 (defun table--goto-coordinate (coordinate &optional no-extension no-tab-expansion) |
5489 "Move point to the given COORDINATE and return the location. | 5489 "Move point to the given COORDINATE and return the location. |