diff options
| author | Stefan Monnier | 2005-03-18 23:17:34 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2005-03-18 23:17:34 +0000 |
| commit | 951f97e67d904729032b476caf5f7c2e7e303d73 (patch) | |
| tree | 331bc0a56362f7e34790bdf72ccb3a45154fe58f /lisp/textmodes | |
| parent | 9188be47894513f5bb58b58ed619d9f5de14ec38 (diff) | |
| download | emacs-951f97e67d904729032b476caf5f7c2e7e303d73.tar.gz emacs-951f97e67d904729032b476caf5f7c2e7e303d73.zip | |
(table--line-column-position): New idiom.
(table--row-column-insertion-point-p): New function to test
validity of row and column insertion operation at a location.
(table-global-menu, table-cell-menu): Use above functions for
deterministic test operation.
(table--editable-cell-p): Behave in deterministic fashion.
Diffstat (limited to 'lisp/textmodes')
| -rw-r--r-- | lisp/textmodes/table.el | 53 |
1 files changed, 33 insertions, 20 deletions
diff --git a/lisp/textmodes/table.el b/lisp/textmodes/table.el index 2c685753f1f..52a0c8a1deb 100644 --- a/lisp/textmodes/table.el +++ b/lisp/textmodes/table.el | |||
| @@ -1,11 +1,12 @@ | |||
| 1 | ;;; table.el --- create and edit WYSIWYG text based embedded tables | 1 | ;;; table.el --- create and edit WYSIWYG text based embedded tables |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 2000, 01, 02, 03, 04 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 |
| 4 | ;; Free Software Foundation, Inc. | ||
| 4 | 5 | ||
| 5 | ;; Keywords: wp, convenience | 6 | ;; Keywords: wp, convenience |
| 6 | ;; Author: Takaaki Ota <Takaaki.Ota@am.sony.com> | 7 | ;; Author: Takaaki Ota <Takaaki.Ota@am.sony.com> |
| 7 | ;; Created: Sat Jul 08 2000 13:28:45 (PST) | 8 | ;; Created: Sat Jul 08 2000 13:28:45 (PST) |
| 8 | ;; Revised: Tue Jun 01 2004 11:36:39 (PDT) | 9 | ;; Revised: Fri Mar 18 2005 13:50:13 (PST) |
| 9 | 10 | ||
| 10 | ;; This file is part of GNU Emacs. | 11 | ;; This file is part of GNU Emacs. |
| 11 | 12 | ||
| @@ -1024,16 +1025,10 @@ This is always set to nil at the entry to `table-with-cache-buffer' before execu | |||
| 1024 | :active (and (not buffer-read-only) (not (table--probe-cell))) | 1025 | :active (and (not buffer-read-only) (not (table--probe-cell))) |
| 1025 | :help "Insert a text based table at point"] | 1026 | :help "Insert a text based table at point"] |
| 1026 | ["Row" table-insert-row | 1027 | ["Row" table-insert-row |
| 1027 | :active (and (not buffer-read-only) | 1028 | :active (table--row-column-insertion-point-p) |
| 1028 | (or (table--probe-cell) | ||
| 1029 | (save-excursion | ||
| 1030 | (table--find-row-column nil t)))) | ||
| 1031 | :help "Insert row(s) of cells in table"] | 1029 | :help "Insert row(s) of cells in table"] |
| 1032 | ["Column" table-insert-column | 1030 | ["Column" table-insert-column |
| 1033 | :active (and (not buffer-read-only) | 1031 | :active (table--row-column-insertion-point-p 'column) |
| 1034 | (or (table--probe-cell) | ||
| 1035 | (save-excursion | ||
| 1036 | (table--find-row-column 'column t)))) | ||
| 1037 | :help "Insert column(s) of cells in table"]) | 1032 | :help "Insert column(s) of cells in table"]) |
| 1038 | "----" | 1033 | "----" |
| 1039 | ("Recognize" | 1034 | ("Recognize" |
| @@ -1076,16 +1071,10 @@ This is always set to nil at the entry to `table-with-cache-buffer' before execu | |||
| 1076 | '("Table" | 1071 | '("Table" |
| 1077 | ("Insert" | 1072 | ("Insert" |
| 1078 | ["Row" table-insert-row | 1073 | ["Row" table-insert-row |
| 1079 | :active (and (not buffer-read-only) | 1074 | :active (table--row-column-insertion-point-p) |
| 1080 | (or (table--probe-cell) | ||
| 1081 | (save-excursion | ||
| 1082 | (table--find-row-column nil t)))) | ||
| 1083 | :help "Insert row(s) of cells in table"] | 1075 | :help "Insert row(s) of cells in table"] |
| 1084 | ["Column" table-insert-column | 1076 | ["Column" table-insert-column |
| 1085 | :active (and (not buffer-read-only) | 1077 | :active (table--row-column-insertion-point-p 'column) |
| 1086 | (or (table--probe-cell) | ||
| 1087 | (save-excursion | ||
| 1088 | (table--find-row-column 'column t)))) | ||
| 1089 | :help "Insert column(s) of cells in table"]) | 1078 | :help "Insert column(s) of cells in table"]) |
| 1090 | ("Delete" | 1079 | ("Delete" |
| 1091 | ["Row" table-delete-row | 1080 | ["Row" table-delete-row |
| @@ -4698,6 +4687,30 @@ of line." | |||
| 4698 | (setq multiplier (1- multiplier))) | 4687 | (setq multiplier (1- multiplier))) |
| 4699 | ret-str)) | 4688 | ret-str)) |
| 4700 | 4689 | ||
| 4690 | (defun table--line-column-position (line column) | ||
| 4691 | "Return the location of LINE forward at COLUMN." | ||
| 4692 | (save-excursion | ||
| 4693 | (forward-line line) | ||
| 4694 | (move-to-column column) | ||
| 4695 | (point))) | ||
| 4696 | |||
| 4697 | (defun table--row-column-insertion-point-p (&optional columnp) | ||
| 4698 | "Return non nil if it makes sense to insert a row or a column at point." | ||
| 4699 | (and (not buffer-read-only) | ||
| 4700 | (or (get-text-property (point) 'table-cell) | ||
| 4701 | (let ((column (current-column))) | ||
| 4702 | (if columnp | ||
| 4703 | (or (text-property-any (line-beginning-position 0) | ||
| 4704 | (table--line-column-position -1 column) | ||
| 4705 | 'table-cell t) | ||
| 4706 | (text-property-any (line-beginning-position) (point) 'table-cell t) | ||
| 4707 | (text-property-any (line-beginning-position 2) | ||
| 4708 | (table--line-column-position 1 column) | ||
| 4709 | 'table-cell t)) | ||
| 4710 | (text-property-any (table--line-column-position -2 column) | ||
| 4711 | (table--line-column-position -2 (+ 2 column)) | ||
| 4712 | 'table-cell t)))))) | ||
| 4713 | |||
| 4701 | (defun table--find-row-column (&optional columnp no-error) | 4714 | (defun table--find-row-column (&optional columnp no-error) |
| 4702 | "Search table and return a cell coordinate list of row or column." | 4715 | "Search table and return a cell coordinate list of row or column." |
| 4703 | (let ((current-coordinate (table--get-coordinate))) | 4716 | (let ((current-coordinate (table--get-coordinate))) |
| @@ -5136,7 +5149,7 @@ Focus only on the corner pattern. Further cell validity check is required." | |||
| 5136 | 5149 | ||
| 5137 | (defun table--editable-cell-p (&optional abort-on-error) | 5150 | (defun table--editable-cell-p (&optional abort-on-error) |
| 5138 | (and (not buffer-read-only) | 5151 | (and (not buffer-read-only) |
| 5139 | (table--probe-cell abort-on-error))) | 5152 | (get-text-property (point) 'table-cell))) |
| 5140 | 5153 | ||
| 5141 | (defun table--probe-cell (&optional abort-on-error) | 5154 | (defun table--probe-cell (&optional abort-on-error) |
| 5142 | "Probes a table cell around the point. | 5155 | "Probes a table cell around the point. |
| @@ -5603,5 +5616,5 @@ It returns COLUMN unless STR contains some wide characters." | |||
| 5603 | ;; End: *** | 5616 | ;; End: *** |
| 5604 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 5617 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 5605 | 5618 | ||
| 5606 | ;;; arch-tag: 0d69b03e-aa5f-4e72-8806-5727217617e0 | 5619 | ;; arch-tag: 0d69b03e-aa5f-4e72-8806-5727217617e0 |
| 5607 | ;;; table.el ends here | 5620 | ;;; table.el ends here |