annotate lisp/textmodes/table.el @ 107930:470fef5038b3

Close bug#1835. * progmodes/fortran.el (fortran-match-and-skip-declaration): New function. (fortran-font-lock-keywords-3): Use it. (Bug#1835)
author Glenn Morris <rgm@gnu.org>
date Fri, 09 Apr 2010 19:12:03 -0700
parents 1d1d5d9bd884
children 904ccd8f2acb 376148b31b5e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;;; table.el --- create and edit WYSIWYG text based embedded tables
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
104386
2e0765155e47 Use help-print-return-message rather than the now obsolete alias.
Glenn Morris <rgm@gnu.org>
parents: 104029
diff changeset
3 ;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 105424
diff changeset
4 ;; 2009, 2010 Free Software Foundation, Inc.
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; Keywords: wp, convenience
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; Author: Takaaki Ota <Takaaki.Ota@am.sony.com>
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;; Created: Sat Jul 08 2000 13:28:45 (PST)
104386
2e0765155e47 Use help-print-return-message rather than the now obsolete alias.
Glenn Morris <rgm@gnu.org>
parents: 104029
diff changeset
9 ;; Revised: Fri Aug 21 2009 00:16:58 (PDT)
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; This file is part of GNU Emacs.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12
94670
f4a69fedbd46 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94298
diff changeset
13 ;; GNU Emacs is free software: you can redistribute it and/or modify
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; it under the terms of the GNU General Public License as published by
94670
f4a69fedbd46 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94298
diff changeset
15 ;; the Free Software Foundation, either version 3 of the License, or
f4a69fedbd46 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94298
diff changeset
16 ;; (at your option) any later version.
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; GNU General Public License for more details.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
94670
f4a69fedbd46 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94298
diff changeset
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 ;;; Commentary:
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 ;; -------------
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;; Introduction:
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;; -------------
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 ;; This package provides text based table creation and editing
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;; feature. With this package Emacs is capable of editing tables that
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 ;; are embedded inside a text document, the feature similar to the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;; ones seen in modern WYSIWYG word processors. A table is a
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;; rectangular text area consisting from a surrounding frame and
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 ;; content inside the frame. The content is usually subdivided into
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;; multiple rectangular cells, see the actual tables used below in
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 ;; this document. Once a table is recognized, editing operation
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 ;; inside a table cell is confined into that specific cell's
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 ;; rectangular area. This means that typing and deleting characters
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 ;; inside a cell do not affect any outside text but introduces
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 ;; appropriate formatting only to the cell contents. If necessary for
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 ;; accommodating added text in the cell, the cell automatically grows
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 ;; vertically and/or horizontally. The package uses no major mode nor
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 ;; minor mode for its implementation because the subject text is
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 ;; localized within a buffer. Therefore the special behaviors inside
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 ;; a table cells are implemented by using keymap text property
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 ;; instead of buffer wide mode-map.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 ;; -----------
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 ;; Background:
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 ;; -----------
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 ;; Paul Georgief is one of my best friends. He became an Emacs
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 ;; convert after I recommended him trying it several years ago. Now
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 ;; we both are devoted disciples of Emacsism and elisp cult. One day
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 ;; in his Emacs exploration he asked me "Tak, what is a command to
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 ;; edit tables in Emacs?". This question started my journey of this
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 ;; table package development. May the code be with me! In the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 ;; software world Emacs is probably one of the longest lifetime record
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 ;; holders. Amazingly there have been no direct support for WYSIWYG
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 ;; table editing tasks in Emacs. Many people must have experienced
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 ;; manipulating existing overwrite-mode and picture-mode for this task
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 ;; and only dreamed of having such a lisp package which supports this
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 ;; specific task directly. Certainly, I have been one of them. The
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 ;; most difficult part of dealing with table editing in Emacs probably
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 ;; is how to realize localized rectangular editing effect. Emacs has
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 ;; no rectangular narrowing mechanism. Existing rect package provides
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 ;; basically kill, delete and yank operations of a rectangle, which
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 ;; internally is a mere list of strings. A simple approach for
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 ;; realizing the localized virtual rectangular operation is combining
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 ;; rect package capability with a temporary buffer. Insertion and
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 ;; deletion of a character to a table cell can be trapped by a
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 ;; function that copies the cell rectangle to a temporary buffer then
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 ;; apply the insertion/deletion to the temporary contents. Then it
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 ;; formats the contents by filling the paragraphs in order to fit it
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 ;; into the original rectangular area and finally copy it back to the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 ;; original buffer. This simplistic approach has to bear with
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 ;; significant performance hit. As cell grows larger the copying
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 ;; rectangle back and forth between the original buffer and the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 ;; temporary buffer becomes expensive and unbearably slow. It was
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 ;; completely impractical and an obvious failure. An idea has been
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 ;; borrowed from the original Emacs design to overcome this
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 ;; shortcoming. When the terminal screen update was slow and
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 ;; expensive Emacs employed a clever algorithm to reduce actual screen
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 ;; update by removing redundant redrawing operations. Also the actual
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 ;; redrawing was done only when there was enough idling time. This
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 ;; technique significantly improved the previously mentioned
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 ;; undesirable situation. Now the original buffer's rectangle is
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 ;; copied into a cache buffer only once. Any cell editing operation
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 ;; is done only to the cache contents. When there is enough idling
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 ;; time the original buffer's rectangle is updated with the current
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 ;; cache contents. This delayed operation is implemented by using
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 ;; Emacs's timer function. To reduce the visual awkwardness
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 ;; introduced by the delayed effect the cursor location is updated in
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 ;; real-time as a user types while the cell contents remains the same
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 ;; until the next idling time. A key to the success of this approach
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 ;; is how to maintain cache coherency. As a user moves point in and
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 ;; out of a cell the table buffer contents and the cache buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 ;; contents must be synchronized without a mistake. By observing user
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 ;; action carefully this is possible however not easy. Once this
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 ;; mechanism is firmly implemented the rest of table features grew in
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 ;; relatively painless progression. Those users who are familiar with
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 ;; Emacs internals appreciate this table package more. Because it
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 ;; demonstrates how extensible Emacs is by showing something that
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 ;; appears like a magic. It lets you re-discover the potential of
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 ;; Emacs.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 ;; -------------
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 ;; Entry Points:
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 ;; -------------
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 ;; If this is the first time for you to try this package, go ahead and
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 ;; load the package by M-x `load-file' RET. Specify the package file
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 ;; name "table.el". Then switch to a new test buffer and issue the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 ;; command M-x `table-insert' RET. It'll ask you number of columns,
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 ;; number of rows, cell width and cell height. Give some small
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 ;; numbers for each of them. Play with the resulted table for a
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 ;; while. If you have menu system find the item "Table" under "Tools"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 ;; and "Table" in the menu bar when the point is in a table cell.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 ;; Some of them are pretty intuitive and you can easily guess what
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 ;; they do. M-x `describe-function' and get the documentation of
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 ;; `table-insert'. The document includes a short tutorial. When you
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 ;; are tired of guessing how it works come back to this document
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 ;; again.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 ;; To use the package regularly place this file in the site library
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 ;; directory and add the next expression in your .emacs file. Make
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 ;; sure that directory is included in the `load-path'.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 ;; (require 'table)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 ;; Have the next expression also, if you want always be ready to edit
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 ;; tables inside text files. This mechanism is analogous to
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 ;; fontification in a sense that tables are recognized at editing time
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 ;; without having table information saved along with the text itself.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 ;; (add-hook 'text-mode-hook 'table-recognize)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 ;; Following is a table of entry points and brief description of each
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 ;; of them. The tables below are of course generated and edited by
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 ;; using this package. Not all the commands are bound to keys. Many
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 ;; of them must be invoked by "M-x" (`execute-extended-command')
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 ;; command. Refer to the section "Keymap" below for the commands
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 ;; available from keys.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 ;; +------------------------------------------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 ;; | User Visible Entry Points |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 ;; +-------------------------------+----------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 ;; | Function | Description |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 ;; +-------------------------------+----------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 ;; |`table-insert' |Insert a table consisting of grid |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 ;; | |of cells by specifying the number |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 ;; | |of COLUMNS, number of ROWS, cell |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 ;; | |WIDTH and cell HEIGHT. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 ;; +-------------------------------+----------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 ;; |`table-insert-row' |Insert row(s) of cells before the |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 ;; | |current row that matches the |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 ;; | |current row structure. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 ;; +-------------------------------+----------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 ;; |`table-insert-column' |Insert column(s) of cells before |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 ;; | |the current column that matches |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 ;; | |the current column structure. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 ;; +-------------------------------+----------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 ;; |`table-delete-row' |Delete row(s) of cells. The row |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 ;; | |must consist from cells of the |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 ;; | |same height. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 ;; +-------------------------------+----------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 ;; |`table-delete-column' |Delete column(s) of cells. The |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 ;; | |column must consist from cells of |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 ;; | |the same width. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 ;; +-------------------------------+----------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 ;; |`table-recognize' |Recognize all tables in the |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 ;; |`table-unrecognize' |current buffer and |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 ;; | |activate/inactivate them. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 ;; +-------------------------------+----------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 ;; |`table-recognize-region' |Recognize all the cells in a |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 ;; |`table-unrecognize-region' |region and activate/inactivate |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 ;; | |them. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 ;; +-------------------------------+----------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 ;; |`table-recognize-table' |Recognize all the cells in a |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 ;; |`table-unrecognize-table' |single table and |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 ;; | |activate/inactivate them. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 ;; +-------------------------------+----------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 ;; |`table-recognize-cell' |Recognize a cell. Find a cell |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 ;; |`table-unrecognize-cell' |which contains the current point |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 ;; | |and activate/inactivate that cell.|
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 ;; +-------------------------------+----------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 ;; |`table-forward-cell' |Move point to the next Nth cell in|
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 ;; | |a table. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 ;; +-------------------------------+----------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 ;; |`table-backward-cell' |Move point to the previous Nth |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 ;; | |cell in a table. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 ;; +-------------------------------+----------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 ;; |`table-span-cell' |Span the current cell toward the |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 ;; | |specified direction and merge it |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 ;; | |with the adjacent cell. The |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 ;; | |direction is right, left, above or|
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 ;; | |below. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 ;; +-------------------------------+----------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 ;; |`table-split-cell-vertically' |Split the current cell vertically |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 ;; | |and create a cell above and a cell|
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 ;; | |below the point location. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 ;; +-------------------------------+----------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 ;; |`table-split-cell-horizontally'|Split the current cell |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 ;; | |horizontally and create a cell on |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 ;; | |the left and a cell on the right |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 ;; | |of the point location. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 ;; +-------------------------------+----------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 ;; |`table-split-cell' |Split the current cell vertically |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 ;; | |or horizontally. This is a |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 ;; | |wrapper command to the other two |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 ;; | |orientation specific commands. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 ;; +-------------------------------+----------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 ;; |`table-heighten-cell' |Heighten the current cell. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 ;; +-------------------------------+----------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 ;; |`table-shorten-cell' |Shorten the current cell. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 ;; +-------------------------------+----------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 ;; |`table-widen-cell' |Widen the current cell. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 ;; +-------------------------------+----------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 ;; |`table-narrow-cell' |Narrow the current cell. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 ;; +-------------------------------+----------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 ;; |`table-fixed-width-mode' |Toggle fixed width mode. In the |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 ;; | |fixed width mode, typing inside a |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 ;; | |cell never changes the cell width,|
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 ;; | |while in the normal mode the cell |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 ;; | |width expands automatically in |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 ;; | |order to prevent a word being |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 ;; | |folded into multiple lines. Fixed|
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 ;; | |width mode reverses video or |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 ;; | |underline the cell contents for |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235 ;; | |its indication. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 ;; +-------------------------------+----------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 ;; |`table-query-dimension' |Compute and report the current |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 ;; | |cell dimension, current table |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 ;; | |dimension and the number of |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 ;; | |columns and rows in the table. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 ;; +-------------------------------+----------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 ;; |`table-generate-source' |Generate the source of the current|
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 ;; | |table in the specified language |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 ;; | |and insert it into a specified |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 ;; | |buffer. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246 ;; +-------------------------------+----------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247 ;; |`table-insert-sequence' |Travel cells forward while |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248 ;; | |inserting a specified sequence |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 ;; | |string into each cell. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 ;; +-------------------------------+----------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 ;; |`table-capture' |Convert plain text into a table by|
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 ;; | |capturing the text in the region. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 ;; +-------------------------------+----------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 ;; |`table-release' |Convert a table into plain text by|
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 ;; | |removing the frame from a table. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 ;; +-------------------------------+----------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 ;; |`table-justify' |Justify the contents of cell(s). |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 ;; +-------------------------------+----------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 ;; *Note*
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 ;; You may find that some of commonly expected table commands are
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 ;; missing such as copying a row/column and yanking it. Those
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 ;; functions can be obtained through existing Emacs text editing
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 ;; commands. Rows are easily manipulated with region commands and
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 ;; columns can be copied and pasted through rectangle commands. After
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268 ;; all a table is still a part of text in the buffer. Only the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 ;; special behaviors exist inside each cell through text properties.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 ;; `table-generate-html' which appeared in earlier releases is
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 ;; deprecated in favor of `table-generate-source'. Now HTML is
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 ;; treated as one of the languages used for describing the table's
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 ;; logical structure.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277 ;; -------
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 ;; Keymap:
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 ;; -------
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281 ;; Although this package does not use a mode it does use its own
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 ;; keymap inside a table cell by way of keymap text property. Some of
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 ;; the standard basic editing commands bound to certain keys are
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 ;; replaced with the table specific version of corresponding commands.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 ;; This replacement combination is listed in the constant alist
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 ;; `table-command-remap-alist' declared below. This alist is
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 ;; not meant to be user configurable but mentioned here for your
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288 ;; better understanding of using this package. In addition, table
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 ;; cells have some table specific bindings for cell navigation and
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290 ;; cell reformation. You can find these additional bindings in the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 ;; constant `table-cell-bindings'. Those key bound functions are
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 ;; considered as internal functions instead of normal commands,
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 ;; therefore they have special prefix, *table-- instead of table-, for
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 ;; symbols. The purpose of this is to make it easier for a user to
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 ;; use command name completion. There is a "normal hooks" variable
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 ;; `table-cell-map-hook' prepared for users to override the default
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 ;; table cell bindings. Following is the table of predefined default
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 ;; key bound commands inside a table cell. Remember these bindings
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 ;; exist only inside a table cell. When your terminal is a tty, the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 ;; control modifier may not be available or applicable for those
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 ;; special characters. In this case use "C-cC-c", which is
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 ;; customizable via `table-command-prefix', as the prefix key
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 ;; sequence. This should preceding the following special character
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304 ;; without the control modifier. For example, use "C-cC-c|" instead
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 ;; of "C-|".
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307 ;; +------------------------------------------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308 ;; | Default Bindings in a Table Cell |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 ;; +-------+----------------------------------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310 ;; | Key | Function |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311 ;; +-------+----------------------------------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312 ;; | TAB |Move point forward to the beginning of the next cell. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313 ;; +-------+----------------------------------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314 ;; | "C->" |Widen the current cell. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315 ;; +-------+----------------------------------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316 ;; | "C-<" |Narrow the current cell. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 ;; +-------+----------------------------------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 ;; | "C-}" |Heighten the current cell. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 ;; +-------+----------------------------------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320 ;; | "C-{" |Shorten the current cell. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321 ;; +-------+----------------------------------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322 ;; | "C--" |Split current cell vertically. (one above and one below) |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323 ;; +-------+----------------------------------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 ;; | "C-|" |Split current cell horizontally. (one left and one right) |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 ;; +-------+----------------------------------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326 ;; | "C-*" |Span current cell into adjacent one. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 ;; +-------+----------------------------------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 ;; | "C-+" |Insert row(s)/column(s). |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 ;; +-------+----------------------------------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 ;; | "C-!" |Toggle between normal mode and fixed width mode. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 ;; +-------+----------------------------------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 ;; | "C-#" |Report cell and table dimension. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 ;; +-------+----------------------------------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 ;; | "C-^" |Generate the source in a language from the current table. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 ;; +-------+----------------------------------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 ;; | "C-:" |Justify the contents of cell(s). |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 ;; +-------+----------------------------------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 ;; *Note*
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341 ;; When using `table-cell-map-hook' do not use `local-set-key'.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343 ;; (add-hook 'table-cell-map-hook
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344 ;; (function (lambda ()
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
345 ;; (local-set-key [<key sequence>] '<function>))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
346 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
347 ;; Above code is well known ~/.emacs idiom for customizing a mode
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
348 ;; specific keymap however it does not work for this package. This is
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349 ;; because there is no table mode in effect. This package does not
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350 ;; use a local map therefor you must modify `table-cell-map'
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351 ;; explicitly. The correct way of achieving above task is:
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353 ;; (add-hook 'table-cell-map-hook
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354 ;; (function (lambda ()
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
355 ;; (define-key table-cell-map [<key sequence>] '<function>))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
356 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
357 ;; -----
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358 ;; Menu:
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
359 ;; -----
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
360 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
361 ;; If a menu system is available a group of table specific menu items,
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
362 ;; "Table" under "Tools" section of the menu bar, is globally added
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
363 ;; after this package is loaded. The commands in this group are
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
364 ;; limited to the ones that are related to creation and initialization
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365 ;; of tables, such as to insert a table, to insert rows and columns,
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
366 ;; or recognize and unrecognize tables. Once tables are created and
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
367 ;; point is placed inside of a table cell a table specific menu item
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368 ;; "Table" appears directly on the menu bar. The commands in this
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
369 ;; menu give full control on table manipulation that include cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
370 ;; navigation, insertion, splitting, spanning, shrinking, expansion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
371 ;; and unrecognizing. In addition to above two types of menu there is
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
372 ;; a pop-up menu available within a table cell. The content of pop-up
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373 ;; menu is identical to the full table menu. [mouse-3] is the default
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374 ;; button, defined in `table-cell-bindings', to bring up the pop-up
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 ;; menu. It can be reconfigured via `table-cell-map-hook'. The
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 ;; benefit of a pop-up menu is that it combines selection of the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 ;; location (which cell, where in the cell) and selection of the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378 ;; desired operation into a single clicking action.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381 ;; -------------------------------
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382 ;; Definition of tables and cells:
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 ;; -------------------------------
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385 ;; There is no artificial-intelligence magic in this package. The
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386 ;; definition of a table and the cells inside the table is reasonably
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 ;; limited in order to achieve acceptable performance in the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388 ;; interactive operation under Emacs lisp implementation. A valid
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389 ;; table is a rectangular text area completely filled with valid
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390 ;; cells. A valid cell is a rectangle text area, which four borders
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391 ;; consist of valid border characters. Cells can not be nested one to
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
392 ;; another or overlapped to each other except sharing the border
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393 ;; lines. A valid character of a cell's vertical border is either
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394 ;; table-cell-vertical-char `|' or table-cell-intersection-char `+'.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395 ;; A valid character of a cell's horizontal border is either
94298
a1cb952a12ac Replace table-cell-horizontal-char -> table-cell-horizontal-chars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87567
diff changeset
396 ;; one of table-cell-horizontal-chars (`-' or `=')
a1cb952a12ac Replace table-cell-horizontal-char -> table-cell-horizontal-chars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87567
diff changeset
397 ;; or table-cell-intersection-char `+'.
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398 ;; A valid character of the four corners of a cell must be
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
399 ;; table-cell-intersection-char `+'. A cell must contain at least one
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400 ;; character space inside. There is no restriction about the contents
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
401 ;; of a table cell, however it is advised if possible to avoid using
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402 ;; any of the border characters inside a table cell. Normally a few
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 ;; boarder characters inside a table cell are harmless. But it is
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404 ;; possible that they accidentally align up to emulate a bogus cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 ;; corner on which software relies on for cell recognition. When this
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406 ;; happens the software may be fooled by it and fail to determine
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
407 ;; correct cell dimension.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
408 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
409 ;; Following are the examples of valid tables.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411 ;; +--+----+---+ +-+ +--+-----+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412 ;; | | | | | | | | |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413 ;; +--+----+---+ +-+ | +--+--+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414 ;; | | | | | | | |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 ;; +--+----+---+ +--+--+ |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416 ;; | | |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417 ;; +-----+--+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 ;; The next five tables are the examples of invalid tables. (From
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 ;; left to right, 1. nested cells 2. overlapped cells and a
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 ;; non-rectangle cell 3. non-rectangle table 4. zero width/height
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 ;; cells 5. zero sized cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 ;; +-----+ +-----+ +--+ +-++--+ ++
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425 ;; | | | | | | | || | ++
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426 ;; | +-+ | | | | | | || |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 ;; | | | | +--+ | +--+--+ +-++--+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428 ;; | +-+ | | | | | | | +-++--+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429 ;; | | | | | | | | | || |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430 ;; +-----+ +--+--+ +--+--+ +-++--+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
431 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
432 ;; Although the program may recognizes some of these invalid tables,
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433 ;; results from the subsequent editing operations inside those cells
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434 ;; are not predictable and will most likely start destroying the table
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435 ;; structures.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437 ;; It is strongly recommended to have at least one blank line above
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 ;; and below a table. For a table to coexist peacefully with
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
439 ;; surrounding environment table needs to be separated from unrelated
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
440 ;; text. This is necessary for the left table to grow or shrink
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441 ;; horizontally without breaking the right table in the following
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
442 ;; example.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 ;; +-----+-----+-----+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
445 ;; +-----+-----+ | | | |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
446 ;; | | | +-----+-----+-----+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
447 ;; +-----+-----+ | | | |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
448 ;; +-----+-----+-----+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
449 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
450 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
451 ;; -------------------------
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
452 ;; Cell contents formatting:
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
453 ;; -------------------------
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
454 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
455 ;; The cell contents are formatted by filling a paragraph immediately
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
456 ;; after characters are inserted into or deleted from a cell. Because
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
457 ;; of this, cell contents always remain fit inside a cell neatly. One
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
458 ;; drawback of this is that users do not have full control over
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
459 ;; spacing between words and line breaking. Only one space can be
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
460 ;; entered between words and up to two spaces between sentences. For
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
461 ;; a newline to be effective the new line must form a beginning of
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
462 ;; paragraph, otherwise it'll automatically be merged with the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
463 ;; previous line in a same paragraph. To form a new paragraph the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
464 ;; line must start with some space characters or immediately follow a
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
465 ;; blank line. Here is a typical example of how to list items within
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
466 ;; a cell. Without a space at the beginning of each line the items
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
467 ;; can not stand on their own.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
468 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
469 ;; +---------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
470 ;; |Each one of the following three |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
471 ;; |items starts with a space |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
472 ;; |character thus forms a paragraph |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
473 ;; |of its own. Limitations in cell |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
474 ;; |contents formatting are: |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
475 ;; | |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
476 ;; | 1. Only one space between words.|
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
477 ;; | 2. Up to two spaces between |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478 ;; |sentences. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479 ;; | 3. A paragraph must start with |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480 ;; |spaces or follow a blank line. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481 ;; | |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
482 ;; |This paragraph stays away from |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
483 ;; |the item 3 because there is a |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
484 ;; |blank line between them. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
485 ;; +---------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
486 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
487 ;; In the normal operation table cell width grows automatically when
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
488 ;; certain word has to be folded into the next line if the width had
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
489 ;; not been increased. This normal operation is useful and
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
490 ;; appropriate for most of the time, however, it is sometimes useful
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
491 ;; or necessary to fix the width of table and width of table cells.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
492 ;; For this purpose the package provides fixed width mode. You can
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
493 ;; toggle between fixed width mode and normal mode by "C-!".
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
494 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
495 ;; Here is a simple example of the fixed width mode. Suppose we have
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
496 ;; a table like this one.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
497 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
498 ;; +-----+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
499 ;; | |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
500 ;; +-----+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
501 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
502 ;; In normal mode if you type a word "antidisestablishmentarianism" it
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
503 ;; grows the cell horizontally like this.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
504 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
505 ;; +----------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
506 ;; |antidisestablishmentarianism|
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
507 ;; +----------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
508 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
509 ;; In the fixed width mode the same action produces the following
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
510 ;; result. The folded locations are indicated by a continuation
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511 ;; character (`\' is the default). The continuation character is
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512 ;; treated specially so it is recommended to choose a character that
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513 ;; does not appear elsewhere in table cells. This character is
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
514 ;; configurable via customization and is kept in the variable
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515 ;; `table-word-continuation-char'. The continuation character is
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
516 ;; treated specially only in the fixed width mode and has no special
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
517 ;; meaning in the normal mode however.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
518 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
519 ;; +-----+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
520 ;; |anti\|
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
521 ;; |dise\|
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
522 ;; |stab\|
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
523 ;; |lish\|
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
524 ;; |ment\|
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
525 ;; |aria\|
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
526 ;; |nism |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
527 ;; +-----+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
528 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
529 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
530 ;; -------------------
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
531 ;; Cell Justification:
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
532 ;; -------------------
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
533 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
534 ;; By default the cell contents are filled with left justification and
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535 ;; no vertical justification. A paragraph can be justified
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
536 ;; individually but only horizontally. Paragraph justification is for
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
537 ;; appearance only and does not change any structural information
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
538 ;; while cell justification affects table's structural information.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
539 ;; For cell justification a user can select horizontal justification
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
540 ;; and vertical justification independently. Horizontal justification
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
541 ;; must be one of the three 'left, 'center or 'right. Vertical
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
542 ;; justification can be 'top, 'middle, 'bottom or 'none. When a cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
543 ;; is justified, that information is recorded as a part of text
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
544 ;; property therefore the information is persistent as long as the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
545 ;; cell remains within the Emacs world. Even copying tables by region
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
546 ;; and rectangle manipulation commands preserve this information.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
547 ;; However, once the table text is saved as a file and the buffer is
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
548 ;; killed the justification information vanishes permanently. To
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
549 ;; alleviate this shortcoming without forcing users to save and
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
550 ;; maintain a separate attribute file, the table code detects
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
551 ;; justification of each cell when recognizing a table. This
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
552 ;; detection is done by guessing the justification by looking at the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
553 ;; appearance of the cell contents. Since it is a guessing work it
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
554 ;; does not guarantee the perfectness but it is designed to be
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
555 ;; practically good enough. The guessing algorithm is implemented in
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
556 ;; the function `table--detect-cell-alignment'. If you have better
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
557 ;; algorithm or idea any suggestion is welcome.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
558 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
559 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
560 ;; -----
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
561 ;; Todo: (in the order of priority, some are just possibility)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
562 ;; -----
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
563 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
564 ;; Fix compatibilities with other input method than quail
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
565 ;; Resolve conflict with flyspell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
566 ;; Use mouse for resizing cells
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
567 ;; A mechanism to link cells internally
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
568 ;; Consider the use of variable width font under Emacs 21
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
569 ;; Consider the use of `:box' face attribute under Emacs 21
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
570 ;; Consider the use of `modification-hooks' text property instead of
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
571 ;; rebinding the keymap
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
572 ;; Maybe provide complete XEmacs support in the future however the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
573 ;; "extent" is the single largest obstacle lying ahead, read the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
574 ;; document in Emacs info.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
575 ;; (eval '(progn (require 'info) (Info-find-node "elisp" "Not Intervals")))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
576 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
577 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
578 ;; ---------------
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
579 ;; Acknowledgment:
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
580 ;; ---------------
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
581 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
582 ;; Table would not have been possible without the help and
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
583 ;; encouragement of the following spirited contributors.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
584 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
585 ;; Paul Georgief <georgief@igpp.ucsd.edu> has been the best tester
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
586 ;; of the code as well as the constructive criticizer.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
587 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
588 ;; Gerd Moellmann <gerd@gnu.org> gave me useful suggestions from Emacs
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
589 ;; 21 point of view.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
590 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
591 ;; Richard Stallman <rms@gnu.org> showed the initial interest in this
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
592 ;; attempt of implementing the table feature to Emacs. This greatly
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
593 ;; motivated me to follow through to its completion.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
594 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
595 ;; Kenichi Handa <handa@etl.go.jp> kindly guided me through to
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
596 ;; overcome many technical issues while I was struggling with quail
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
597 ;; related internationalization problems.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
598 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
599 ;; Christoph Conrad <christoph.conrad@gmx.de> suggested making symbol
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
600 ;; names consistent as well as fixing several bugs.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
601 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
602 ;; Paul Lew <paullew@cisco.com> suggested implementing fixed width
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
603 ;; mode as well as multi column width (row height) input interface.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
604 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
605 ;; Michael Smith <smith@xml-doc.org> a well-informed DocBook user
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
606 ;; asked for CALS table source generation and helped me following
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
607 ;; through the work by offering valuable suggestions and testing out
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
608 ;; the code. Jorge Godoy <godoy@conectiva.com> has also suggested
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
609 ;; supporting for DocBook tables.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
610 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
611 ;; And many other individuals who reported bugs and suggestions.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
612
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
613 ;;; Code:
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
614
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
615
73382
b0c7aa3aef74 2006-10-15 Martin Rudalics <rudalics@gmx.at>
Kim F. Storm <storm@cua.dk>
parents: 72070
diff changeset
616 (require 'regexp-opt)
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
617
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
618 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
619 ;;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
620 ;;; Compatibility:
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
621 ;;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
622
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
623 ;; hush up the byte-compiler
68246
ecfd9a69b670 Move defvars out of eval-when-compile.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64993
diff changeset
624 (defvar quail-translating)
ecfd9a69b670 Move defvars out of eval-when-compile.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64993
diff changeset
625 (defvar quail-converting)
ecfd9a69b670 Move defvars out of eval-when-compile.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64993
diff changeset
626 (defvar flyspell-mode)
ecfd9a69b670 Move defvars out of eval-when-compile.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64993
diff changeset
627 (defvar real-last-command)
ecfd9a69b670 Move defvars out of eval-when-compile.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64993
diff changeset
628 (defvar delete-selection-mode)
ecfd9a69b670 Move defvars out of eval-when-compile.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64993
diff changeset
629 ;; This is evil!!
ecfd9a69b670 Move defvars out of eval-when-compile.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64993
diff changeset
630 ;; (eval-when-compile
ecfd9a69b670 Move defvars out of eval-when-compile.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64993
diff changeset
631 ;; (unless (fboundp 'set-face-property)
ecfd9a69b670 Move defvars out of eval-when-compile.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64993
diff changeset
632 ;; (defun set-face-property (face prop value)))
ecfd9a69b670 Move defvars out of eval-when-compile.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64993
diff changeset
633 ;; (unless (fboundp 'unibyte-char-to-multibyte)
ecfd9a69b670 Move defvars out of eval-when-compile.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64993
diff changeset
634 ;; (defun unibyte-char-to-multibyte (char)))
ecfd9a69b670 Move defvars out of eval-when-compile.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64993
diff changeset
635 ;; (defun table--point-in-cell-p (&optional location)))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
636
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
637 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
638 ;;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
639 ;;; Customization:
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
640 ;;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
641
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
642 (defgroup table nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
643 "Text based table manipulation utilities.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
644 See `table-insert' for examples about how to use."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
645 :tag "Table"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
646 :prefix "table-"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
647 :group 'editing
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
648 :group 'wp
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
649 :group 'paragraphs
57938
d54496881232 (table group): Add :version.
Richard M. Stallman <rms@gnu.org>
parents: 55906
diff changeset
650 :group 'fill
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 57938
diff changeset
651 :version "22.1")
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
652
48373
4c02bb10da9a (defgroup table-hooks): New group.
Markus Rost <rost@math.uni-bielefeld.de>
parents: 47247
diff changeset
653 (defgroup table-hooks nil
64059
77cc3a2cedb3 (table-hooks): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents: 63227
diff changeset
654 "Hooks for table manipulation utilities."
48373
4c02bb10da9a (defgroup table-hooks): New group.
Markus Rost <rost@math.uni-bielefeld.de>
parents: 47247
diff changeset
655 :group 'table)
4c02bb10da9a (defgroup table-hooks): New group.
Markus Rost <rost@math.uni-bielefeld.de>
parents: 47247
diff changeset
656
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
657 (defcustom table-time-before-update 0.2
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
658 "*Time in seconds before updating the cell contents after typing.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
659 Updating the cell contents on the screen takes place only after this
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
660 specified amount of time has passed after the last modification to the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
661 cell contents. When the contents of a table cell changes repetitively
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
662 and frequently the updating the cell contents on the screen is
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
663 deferred until at least this specified amount of quiet time passes. A
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
664 smaller number wastes more computation resource by unnecessarily
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
665 frequent screen update. A large number presents noticeable and
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
666 annoying delay before the typed result start appearing on the screen."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
667 :tag "Time Before Cell Update"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
668 :type 'number
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
669 :group 'table)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
670
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
671 (defcustom table-time-before-reformat 0.2
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
672 "*Time in seconds before reformatting the table.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
673 This many seconds must pass in addition to `table-time-before-update'
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
674 before the table is updated with newly widened width or heightened
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
675 height."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
676 :tag "Time Before Cell Reformat"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
677 :type 'number
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
678 :group 'table)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
679
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
680 (defcustom table-command-prefix [(control c) (control c)]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
681 "*Key sequence to be used as prefix for table command key bindings."
47247
1278169531f1 (table-command-prefix): Fix type.
Markus Rost <rost@math.uni-bielefeld.de>
parents: 46933
diff changeset
682 :type '(vector (repeat :inline t sexp))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
683 :tag "Table Command Prefix"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
684 :group 'table)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
685
63227
6f4701bb40a7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-391
Miles Bader <miles@gnu.org>
parents: 62578
diff changeset
686 (defface table-cell
61394
31aa9a390538 * mh-customize.el (mh-speedbar-selected-folder-face): Special case
Dan Nicolaescu <dann@ics.uci.edu>
parents: 60724
diff changeset
687 '((((min-colors 88) (class color))
31aa9a390538 * mh-customize.el (mh-speedbar-selected-folder-face): Special case
Dan Nicolaescu <dann@ics.uci.edu>
parents: 60724
diff changeset
688 (:foreground "gray90" :background "blue1"))
31aa9a390538 * mh-customize.el (mh-speedbar-selected-folder-face): Special case
Dan Nicolaescu <dann@ics.uci.edu>
parents: 60724
diff changeset
689 (((class color))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
690 (:foreground "gray90" :background "blue"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
691 (t (:bold t)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
692 "*Face used for table cell contents."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
693 :tag "Cell Face"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
694 :group 'table)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
695
51496
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
696 (defcustom table-cell-horizontal-chars "-="
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
697 "*Characters that may be used for table cell's horizontal border line."
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
698 :tag "Cell Horizontal Boundary Characters"
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
699 :type 'string
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
700 :group 'table)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
701
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
702 (defcustom table-cell-vertical-char ?\|
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
703 "*Character that forms table cell's vertical border line."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
704 :tag "Cell Vertical Boundary Character"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
705 :type 'character
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
706 :group 'table)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
707
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
708 (defcustom table-cell-intersection-char ?\+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
709 "*Character that forms table cell's corner."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
710 :tag "Cell Intersection Character"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
711 :type 'character
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
712 :group 'table)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
713
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
714 (defcustom table-word-continuation-char ?\\
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
715 "*Character that indicates word continuation into the next line.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
716 This character has a special meaning only in the fixed width mode,
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
717 that is when `table-fixed-width-mode' is non-nil . In the fixed width
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
718 mode this character indicates that the location is continuing into the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
719 next line. Be careful about the choice of this character. It is
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
720 treated substantially different manner than ordinary characters. Try
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
721 select a character that is unlikely to appear in your document."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
722 :tag "Cell Word Continuation Character"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
723 :type 'character
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
724 :group 'table)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
725
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
726 (defun table-set-table-fixed-width-mode (variable value)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
727 (if (fboundp variable)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
728 (funcall variable (if value 1 -1))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
729
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
730 (defun table-initialize-table-fixed-width-mode (variable value)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
731 (set variable value))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
732
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
733 (defcustom table-fixed-width-mode nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
734 "*Cell width is fixed when this is non-nil.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
735 Normally it should be nil for allowing automatic cell width expansion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
736 that widens a cell when it is necessary. When non-nil, typing in a
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
737 cell does not automatically expand the cell width. A word that is too
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
738 long to fit in a cell is chopped into multiple lines. The chopped
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
739 location is indicated by `table-word-continuation-char'. This
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
740 variable's value can be toggled by \\[table-fixed-width-mode] at
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
741 run-time."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
742 :tag "Fix Cell Width"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
743 :type 'boolean
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
744 :initialize 'table-initialize-table-fixed-width-mode
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
745 :set 'table-set-table-fixed-width-mode
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
746 :group 'table)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
747
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
748 (defcustom table-detect-cell-alignment t
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
749 "*Detect cell contents alignment automatically.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
750 When non-nil cell alignment is automatically determined by the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
751 appearance of the current cell contents when recognizing tables as a
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
752 whole. This applies to `table-recognize', `table-recognize-region'
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
753 and `table-recognize-table' but not to `table-recognize-cell'."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
754 :tag "Detect Cell Alignment"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
755 :type 'boolean
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
756 :group 'table)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
757
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
758 (defcustom table-dest-buffer-name "table"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
759 "*Default buffer name (without a suffix) for source generation."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
760 :tag "Source Buffer Name"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
761 :type 'string
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
762 :group 'table)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
763
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
764 (defcustom table-html-delegate-spacing-to-user-agent nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
765 "*Non-nil delegates cell contents spacing entirely to user agent.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
766 Otherwise, when nil, it preserves the original spacing and line breaks."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
767 :tag "HTML delegate spacing"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
768 :type 'boolean
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
769 :group 'table)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
770
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
771 (defcustom table-html-th-rows 0
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
772 "*Number of top rows to become header cells automatically in HTML generation."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
773 :tag "HTML Header Rows"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
774 :type 'integer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
775 :group 'table)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
776
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
777 (defcustom table-html-th-columns 0
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
778 "*Number of left columns to become header cells automatically in HTML generation."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
779 :tag "HTML Header Columns"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
780 :type 'integer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
781 :group 'table)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
782
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
783 (defcustom table-html-table-attribute "border=\"1\""
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
784 "*Table attribute that applies to the table in HTML generation."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
785 :tag "HTML table attribute"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
786 :type 'string
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
787 :group 'table)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
788
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
789 (defcustom table-html-cell-attribute ""
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
790 "*Cell attribute that applies to all cells in HTML generation.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
791 Do not specify \"align\" and \"valign\" because they are determined by
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
792 the cell contents dynamically."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
793 :tag "HTML cell attribute"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
794 :type 'string
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
795 :group 'table)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
796
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
797 (defcustom table-cals-thead-rows 1
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
798 "*Number of top rows to become header rows in CALS table."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
799 :tag "CALS Header Rows"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
800 :type 'integer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
801 :group 'table)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
802
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
803 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
804 (defcustom table-cell-map-hook nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
805 "*Normal hooks run when finishing construction of `table-cell-map'.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
806 User can modify `table-cell-map' by adding custom functions here."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
807 :tag "Cell Keymap Hooks"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
808 :type 'hook
48373
4c02bb10da9a (defgroup table-hooks): New group.
Markus Rost <rost@math.uni-bielefeld.de>
parents: 47247
diff changeset
809 :group 'table-hooks)
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
810
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
811 (defcustom table-disable-incompatibility-warning nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
812 "*Disable compatibility warning notice.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
813 When nil user is reminded of known incompatible issues."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
814 :tag "Disable Incompatibility Warning"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
815 :type 'boolean
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
816 :group 'table)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
817
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
818 (defcustom table-abort-recognition-when-input-pending t
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
819 "*Abort current recognition process when input pending.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
820 Abort current recognition process when we are not sure that no input
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
821 is available. When non-nil lengthy recognition process is aborted
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
822 simply by any key input."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
823 :tag "Abort Recognition When Input Pending"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
824 :type 'boolean
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
825 :group 'table)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
826
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
827 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
828 (defcustom table-load-hook nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
829 "*List of functions to be called after the table is first loaded."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
830 :type 'hook
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
831 :group 'table-hooks)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
832
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
833 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
834 (defcustom table-point-entered-cell-hook nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
835 "*List of functions to be called after point entered a table cell."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
836 :type 'hook
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
837 :group 'table-hooks)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
838
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
839 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
840 (defcustom table-point-left-cell-hook nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
841 "*List of functions to be called after point left a table cell."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
842 :type 'hook
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
843 :group 'table-hooks)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
844
64695
82f489b3958d (table-yank-handler): Change defcustom to defvar.
Kim F. Storm <storm@cua.dk>
parents: 64084
diff changeset
845 (defvar table-yank-handler '(nil nil t nil)
82f489b3958d (table-yank-handler): Change defcustom to defvar.
Kim F. Storm <storm@cua.dk>
parents: 64084
diff changeset
846 "Yank handler for tables.")
53367
fbdcff26f02a (table-yank-handler): New defcustom.
Eli Zaretskii <eliz@is.elta.co.il>
parents: 52401
diff changeset
847
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
848 (setplist 'table-disable-incompatibility-warning nil)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
849
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
850 (defvar table-disable-menu (null (and (locate-library "easymenu")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
851 (require 'easymenu)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
852 (fboundp 'easy-menu-add-item)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
853 "*When non-nil, use of menu by table package is disabled.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
854 It must be set before loading this package `table.el' for the first
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
855 time.")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
856
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
857
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
858 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
859 ;;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
860 ;;; Implementation:
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
861 ;;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
862
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
863 ;;; Internal variables and constants
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
864 ;;; No need of user configuration
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
865
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
866 (defconst table-paragraph-start "[ \t\n\f]"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
867 "*Regexp for beginning of a line that starts OR separates paragraphs.")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
868 (defconst table-cache-buffer-name " *table cell cache*"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
869 "Cell cache buffer name.")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
870 (defvar table-cell-info-lu-coordinate nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
871 "Zero based coordinate of the cached cell's left upper corner.")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
872 (defvar table-cell-info-rb-coordinate nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
873 "Zero based coordinate of the cached cell's right bottom corner.")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
874 (defvar table-cell-info-width nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
875 "Number of characters per cached cell width.")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
876 (defvar table-cell-info-height nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
877 "Number of lines per cached cell height.")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
878 (defvar table-cell-info-justify nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
879 "Justification information of the cached cell.")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
880 (defvar table-cell-info-valign nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
881 "Vertical alignment information of the cached cell.")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
882 (defvar table-cell-self-insert-command-count 0
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
883 "Counter for undo control.")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
884 (defvar table-cell-map nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
885 "Keymap for table cell contents.")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
886 (defvar table-cell-global-map-alist nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
887 "Alist of copy of global maps that are substituted in `table-cell-map'.")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
888 (defvar table-global-menu-map nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
889 "Menu map created via `easy-menu-define'.")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
890 (defvar table-cell-menu-map nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
891 "Menu map created via `easy-menu-define'.")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
892 (defvar table-cell-buffer nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
893 "Buffer that contains the table cell.")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
894 (defvar table-cell-cache-point-coordinate nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
895 "Cache point coordinate based from the cell origin.")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
896 (defvar table-cell-cache-mark-coordinate nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
897 "Cache mark coordinate based from the cell origin.")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
898 (defvar table-cell-entered-state nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
899 "Records the state whether currently in a cell or nor.")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
900 (defvar table-update-timer nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
901 "Timer id for deferred cell update.")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
902 (defvar table-widen-timer nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
903 "Timer id for deferred cell update.")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
904 (defvar table-heighten-timer nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
905 "Timer id for deferred cell update.")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
906 (defvar table-inhibit-update nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
907 "Non-nil inhibits implicit cell and cache updates.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
908 It inhibits `table-with-cache-buffer' to update data in both direction, cell to cache and cache to cell.")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
909 (defvar table-inhibit-auto-fill-paragraph nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
910 "Non-nil inhibits auto fill paragraph when `table-with-cache-buffer' exits.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
911 This is always set to nil at the entry to `table-with-cache-buffer' before executing body forms.")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
912 (defvar table-mode-indicator nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
913 "For mode line indicator")
68246
ecfd9a69b670 Move defvars out of eval-when-compile.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64993
diff changeset
914 ;; This is not a real minor-mode but placed in the minor-mode-alist
ecfd9a69b670 Move defvars out of eval-when-compile.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64993
diff changeset
915 ;; so that we can show the indicator on the mode line handy.
68271
fe442ba33e0a (table-mode-indicator): Typo in last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68246
diff changeset
916 (make-variable-buffer-local 'table-mode-indicator)
68246
ecfd9a69b670 Move defvars out of eval-when-compile.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64993
diff changeset
917 (unless (assq table-mode-indicator minor-mode-alist)
ecfd9a69b670 Move defvars out of eval-when-compile.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64993
diff changeset
918 (push '(table-mode-indicator (table-fixed-width-mode " Fixed-Table" " Table"))
ecfd9a69b670 Move defvars out of eval-when-compile.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64993
diff changeset
919 minor-mode-alist))
ecfd9a69b670 Move defvars out of eval-when-compile.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64993
diff changeset
920
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
921 (defconst table-source-languages '(html latex cals)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
922 "Supported source languages.")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
923 (defvar table-source-info-plist nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
924 "General storage for temporary information used while generating source.")
68246
ecfd9a69b670 Move defvars out of eval-when-compile.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64993
diff changeset
925
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
926 ;;; The following history containers not only keep the history of user
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
927 ;;; entries but also serve as the default value providers. When an
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
928 ;;; interactive command is invoked it offers a user the latest entry
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
929 ;;; of the history as a default selection. Therefore the values below
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
930 ;;; are the first default value when a command is invoked for the very
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
931 ;;; first time when there is no real history existing yet.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
932 (defvar table-cell-span-direction-history '("right"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
933 (defvar table-cell-split-orientation-history '("horizontally"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
934 (defvar table-cell-split-contents-to-history '("split"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
935 (defvar table-insert-row-column-history '("row"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
936 (defvar table-justify-history '("center"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
937 (defvar table-columns-history '("3"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
938 (defvar table-rows-history '("3"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
939 (defvar table-cell-width-history '("5"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
940 (defvar table-cell-height-history '("1"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
941 (defvar table-source-caption-history '("Table"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
942 (defvar table-sequence-string-history '("0"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
943 (defvar table-sequence-count-history '("0"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
944 (defvar table-sequence-increment-history '("1"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
945 (defvar table-sequence-interval-history '("1"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
946 (defvar table-sequence-justify-history '("left"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
947 (defvar table-source-language-history '("html"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
948 (defvar table-col-delim-regexp-history '(""))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
949 (defvar table-row-delim-regexp-history '(""))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
950 (defvar table-capture-justify-history '("left"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
951 (defvar table-capture-min-cell-width-history '("5"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
952 (defvar table-capture-columns-history '(""))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
953 (defvar table-target-history '("cell"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
954
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
955 ;;; Some entries in `table-cell-bindings' are duplicated in
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
956 ;;; `table-command-remap-alist'. There is a good reason for
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
957 ;;; this. Common key like return key may be taken by some other
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
958 ;;; function than normal `newline' function. Thus binding return key
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
959 ;;; directly for `*table--cell-newline' ensures that the correct enter
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
960 ;;; operation in a table cell. However
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
961 ;;; `table-command-remap-alist' has an additional role than
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
962 ;;; replacing commands. It is also used to construct a table command
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
963 ;;; list. This list is very important because it is used to check if
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
964 ;;; the previous command was one of them in this list or not. If the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
965 ;;; previous command is found in the list the current command will not
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
966 ;;; refill the table cache. If the command were not listed fast
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
967 ;;; typing can cause unwanted cache refill.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
968 (defconst table-cell-bindings
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
969 '(([(control i)] . table-forward-cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
970 ([(control I)] . table-backward-cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
971 ([tab] . table-forward-cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
972 ([(shift backtab)] . table-backward-cell) ; for HPUX console keyboard
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
973 ([(shift iso-lefttab)] . table-backward-cell) ; shift-tab on a microsoft natural keyboard and redhat linux
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
974 ([(shift tab)] . table-backward-cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
975 ([return] . *table--cell-newline)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
976 ([(control m)] . *table--cell-newline)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
977 ([(control j)] . *table--cell-newline-and-indent)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
978 ([mouse-3] . *table--present-cell-popup-menu)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
979 ([(control ?>)] . table-widen-cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
980 ([(control ?<)] . table-narrow-cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
981 ([(control ?})] . table-heighten-cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
982 ([(control ?{)] . table-shorten-cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
983 ([(control ?-)] . table-split-cell-vertically)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
984 ([(control ?|)] . table-split-cell-horizontally)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
985 ([(control ?*)] . table-span-cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
986 ([(control ?+)] . table-insert-row-column)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
987 ([(control ?!)] . table-fixed-width-mode)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
988 ([(control ?#)] . table-query-dimension)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
989 ([(control ?^)] . table-generate-source)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
990 ([(control ?:)] . table-justify)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
991 )
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
992 "Bindings for table cell commands.")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
993
51496
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
994 (defvar table-command-remap-alist
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
995 '((self-insert-command . *table--cell-self-insert-command)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
996 (completion-separator-self-insert-autofilling . *table--cell-self-insert-command)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
997 (completion-separator-self-insert-command . *table--cell-self-insert-command)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
998 (delete-char . *table--cell-delete-char)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
999 (delete-backward-char . *table--cell-delete-backward-char)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1000 (backward-delete-char . *table--cell-delete-backward-char)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1001 (backward-delete-char-untabify . *table--cell-delete-backward-char)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1002 (newline . *table--cell-newline)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1003 (newline-and-indent . *table--cell-newline-and-indent)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1004 (open-line . *table--cell-open-line)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1005 (quoted-insert . *table--cell-quoted-insert)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1006 (describe-mode . *table--cell-describe-mode)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1007 (describe-bindings . *table--cell-describe-bindings)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1008 (dabbrev-expand . *table--cell-dabbrev-expand)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1009 (dabbrev-completion . *table--cell-dabbrev-completion))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1010 "List of cons cells consisting of (ORIGINAL-COMMAND . TABLE-VERSION-OF-THE-COMMAND).")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1011
51496
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
1012 (defvar table-command-list nil
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1013 "List of commands that override original commands.")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1014 ;; construct the real contents of the `table-command-list'
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1015 (let ((remap-alist table-command-remap-alist))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1016 (setq table-command-list nil)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1017 (while remap-alist
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1018 (setq table-command-list (cons (cdar remap-alist) table-command-list))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1019 (setq remap-alist (cdr remap-alist))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1020
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1021 (defconst table-global-menu
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1022 '("Table"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1023 ("Insert"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1024 ["a Table..." table-insert
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1025 :active (and (not buffer-read-only) (not (table--probe-cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1026 :help "Insert a text based table at point"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1027 ["Row" table-insert-row
60724
3a2908eb7595 (table--line-column-position): New idiom.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59996
diff changeset
1028 :active (table--row-column-insertion-point-p)
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1029 :help "Insert row(s) of cells in table"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1030 ["Column" table-insert-column
60724
3a2908eb7595 (table--line-column-position): New idiom.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59996
diff changeset
1031 :active (table--row-column-insertion-point-p 'column)
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1032 :help "Insert column(s) of cells in table"])
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1033 "----"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1034 ("Recognize"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1035 ["in Buffer" table-recognize
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1036 :active t
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1037 :help "Recognize all tables in the current buffer"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1038 ["in Region" table-recognize-region
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1039 :active (and mark-active (not (eq (mark t) (point))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1040 :help "Recognize all tables in the current region"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1041 ["a Table" table-recognize-table
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1042 :active (table--probe-cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1043 :help "Recognize a table at point"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1044 ["a Cell" table-recognize-cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1045 :active (let ((cell (table--probe-cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1046 (and cell (null (table--at-cell-p (car cell)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1047 :help "Recognize a cell at point"])
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1048 ("Unrecognize"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1049 ["in Buffer" table-unrecognize
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1050 :active t
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1051 :help "Unrecognize all tables in the current buffer"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1052 ["in Region" table-unrecognize-region
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1053 :active (and mark-active (not (eq (mark t) (point))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1054 :help "Unrecognize all tables in the current region"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1055 ["a Table" table-unrecognize-table
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1056 :active (table--probe-cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1057 :help "Unrecognize the current table"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1058 ["a Cell" table-unrecognize-cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1059 :active (let ((cell (table--probe-cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1060 (and cell (table--at-cell-p (car cell))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1061 :help "Unrecognize the current cell"])
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1062 "----"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1063 ["Capture Region" table-capture
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1064 :active (and (not buffer-read-only) mark-active (not (eq (mark t) (point))) (not (table--probe-cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1065 :help "Capture text in the current region as a table"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1066 ["Release" table-release
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1067 :active (table--editable-cell-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1068 :help "Release the current table as plain text"]))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1069
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1070 (defconst table-cell-menu
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1071 '("Table"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1072 ("Insert"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1073 ["Row" table-insert-row
60724
3a2908eb7595 (table--line-column-position): New idiom.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59996
diff changeset
1074 :active (table--row-column-insertion-point-p)
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1075 :help "Insert row(s) of cells in table"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1076 ["Column" table-insert-column
60724
3a2908eb7595 (table--line-column-position): New idiom.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59996
diff changeset
1077 :active (table--row-column-insertion-point-p 'column)
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1078 :help "Insert column(s) of cells in table"])
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1079 ("Delete"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1080 ["Row" table-delete-row
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1081 :active (table--editable-cell-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1082 :help "Delete row(s) of cells in table"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1083 ["Column" table-delete-column
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1084 :active (table--editable-cell-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1085 :help "Delete column(s) of cells in table"])
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1086 "----"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1087 ("Split a Cell"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1088 ["Horizontally" table-split-cell-horizontally
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1089 :active (table--cell-can-split-horizontally-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1090 :help "Split the current cell horizontally at point"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1091 ["Vertically" table-split-cell-vertically
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1092 :active (table--cell-can-split-vertically-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1093 :help "Split the current cell vertical at point"])
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1094 ("Span a Cell to"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1095 ["Right" (table-span-cell 'right)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1096 :active (table--cell-can-span-p 'right)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1097 :help "Span the current cell into the right cell"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1098 ["Left" (table-span-cell 'left)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1099 :active (table--cell-can-span-p 'left)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1100 :help "Span the current cell into the left cell"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1101 ["Above" (table-span-cell 'above)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1102 :active (table--cell-can-span-p 'above)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1103 :help "Span the current cell into the cell above"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1104 ["Below" (table-span-cell 'below)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1105 :active (table--cell-can-span-p 'below)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1106 :help "Span the current cell into the cell below"])
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1107 "----"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1108 ("Shrink Cells"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1109 ["Horizontally" table-narrow-cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1110 :active (table--editable-cell-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1111 :help "Shrink the current cell horizontally"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1112 ["Vertically" table-shorten-cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1113 :active (table--editable-cell-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1114 :help "Shrink the current cell vertically"])
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1115 ("Expand Cells"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1116 ["Horizontally" table-widen-cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1117 :active (table--editable-cell-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1118 :help "Expand the current cell horizontally"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1119 ["Vertically" table-heighten-cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1120 :active (table--editable-cell-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1121 :help "Expand the current cell vertically"])
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1122 "----"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1123 ("Justify"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1124 ("a Cell"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1125 ["Left" (table-justify-cell 'left)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1126 :active (table--editable-cell-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1127 :help "Left justify the contents of the current cell"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1128 ["Center" (table-justify-cell 'center)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1129 :active (table--editable-cell-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1130 :help "Center justify the contents of the current cell"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1131 ["Right" (table-justify-cell 'right)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1132 :active (table--editable-cell-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1133 :help "Right justify the contents of the current cell"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1134 "----"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1135 ["Top" (table-justify-cell 'top)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1136 :active (table--editable-cell-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1137 :help "Top align the contents of the current cell"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1138 ["Middle" (table-justify-cell 'middle)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1139 :active (table--editable-cell-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1140 :help "Middle align the contents of the current cell"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1141 ["Bottom" (table-justify-cell 'bottom)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1142 :active (table--editable-cell-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1143 :help "Bottom align the contents of the current cell"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1144 ["None" (table-justify-cell 'none)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1145 :active (table--editable-cell-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1146 :help "Remove vertical alignment from the current cell"])
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1147 ("a Row"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1148 ["Left" (table-justify-row 'left)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1149 :active (table--editable-cell-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1150 :help "Left justify the contents of all cells in the current row"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1151 ["Center" (table-justify-row 'center)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1152 :active (table--editable-cell-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1153 :help "Center justify the contents of all cells in the current row"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1154 ["Right" (table-justify-row 'right)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1155 :active (table--editable-cell-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1156 :help "Right justify the contents of all cells in the current row"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1157 "----"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1158 ["Top" (table-justify-row 'top)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1159 :active (table--editable-cell-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1160 :help "Top align the contents of all cells in the current row"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1161 ["Middle" (table-justify-row 'middle)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1162 :active (table--editable-cell-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1163 :help "Middle align the contents of all cells in the current row"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1164 ["Bottom" (table-justify-row 'bottom)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1165 :active (table--editable-cell-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1166 :help "Bottom align the contents of all cells in the current row"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1167 ["None" (table-justify-cell 'none)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1168 :active (table--editable-cell-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1169 :help "Remove vertical alignment from all cells in the current row"])
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1170 ("a Column"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1171 ["Left" (table-justify-column 'left)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1172 :active (table--editable-cell-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1173 :help "Left justify the contents of all cells in the current column"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1174 ["Center" (table-justify-column 'center)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1175 :active (table--editable-cell-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1176 :help "Center justify the contents of all cells in the current column"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1177 ["Right" (table-justify-column 'right)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1178 :active (table--editable-cell-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1179 :help "Right justify the contents of all cells in the current column"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1180 "----"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1181 ["Top" (table-justify-column 'top)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1182 :active (table--editable-cell-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1183 :help "Top align the contents of all cells in the current column"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1184 ["Middle" (table-justify-column 'middle)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1185 :active (table--editable-cell-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1186 :help "Middle align the contents of all cells in the current column"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1187 ["Bottom" (table-justify-column 'bottom)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1188 :active (table--editable-cell-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1189 :help "Bottom align the contents of all cells in the current column"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1190 ["None" (table-justify-cell 'none)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1191 :active (table--editable-cell-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1192 :help "Remove vertical alignment from all cells in the current column"])
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1193 ("a Paragraph"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1194 ["Left" (table-justify-cell 'left t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1195 :active (table--editable-cell-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1196 :help "Left justify the current paragraph"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1197 ["Center" (table-justify-cell 'center t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1198 :active (table--editable-cell-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1199 :help "Center justify the current paragraph"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1200 ["Right" (table-justify-cell 'right t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1201 :active (table--editable-cell-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1202 :help "Right justify the current paragraph"]))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1203 "----"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1204 ["Query Dimension" table-query-dimension
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1205 :active (table--probe-cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1206 :help "Get the dimension of the current cell and the current table"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1207 ["Generate Source" table-generate-source
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1208 :active (table--probe-cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1209 :help "Generate source of the current table in the specified language"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1210 ["Insert Sequence" table-insert-sequence
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1211 :active (table--editable-cell-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1212 :help "Travel cells forward while inserting a specified sequence string in each cell"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1213 ("Unrecognize"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1214 ["a Table" table-unrecognize-table
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1215 :active (table--probe-cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1216 :help "Unrecognize the current table"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1217 ["a Cell" table-unrecognize-cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1218 :active (let ((cell (table--probe-cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1219 (and cell (table--at-cell-p (car cell))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1220 :help "Unrecognize the current cell"])
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1221 ["Release" table-release
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1222 :active (table--editable-cell-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1223 :help "Release the current table as plain text"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1224 ("Configure Width to"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1225 ["Auto Expand Mode" (table-fixed-width-mode -1)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1226 :active t
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1227 :style radio
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1228 :selected (not table-fixed-width-mode)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1229 :help "A mode that allows automatic horizontal cell expansion"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1230 ["Fixed Width Mode" (table-fixed-width-mode 1)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1231 :active t
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1232 :style radio
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1233 :selected table-fixed-width-mode
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1234 :help "A mode that does not allow automatic horizontal cell expansion"])
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1235 ("Navigate"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1236 ["Forward Cell" table-forward-cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1237 :active (table--probe-cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1238 :help "Move point forward by cell(s)"]
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1239 ["Backward Cell" table-backward-cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1240 :active (table--probe-cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1241 :help "Move point backward by cell(s)"])
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1242 ))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1243
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1244 ;; XEmacs causes an error when encountering unknown keywords in the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1245 ;; menu definition. Specifically the :help keyword is new in Emacs 21
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1246 ;; and causes error for the XEmacs function `check-menu-syntax'. IMHO
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1247 ;; it is unwise to generate an error for unknown keywords because it
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1248 ;; kills the nice backward compatible extensibility of keyword use.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1249 ;; Unknown keywords should be quietly ignore so that future extension
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1250 ;; does not cause a problem in the old implementation. Sigh...
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1251 (when (featurep 'xemacs)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1252 (mapcar
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1253 (defun table--tweak-menu-for-xemacs (menu)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1254 (cond
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1255 ((listp menu)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1256 (mapcar 'table--tweak-menu-for-xemacs menu))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1257 ((vectorp menu)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1258 (let ((i 0) (len (length menu)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1259 (while (< i len)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1260 ;; replace :help with something harmless.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1261 (if (eq (aref menu i) :help) (aset menu i :included))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1262 (setq i (1+ i)))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1263 (list table-global-menu table-cell-menu))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1264 (defvar mark-active t))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1265
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1266 ;; register table menu under global tools menu
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1267 (unless table-disable-menu
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1268 (easy-menu-define table-global-menu-map nil "Table global menu" table-global-menu)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1269 (if (featurep 'xemacs)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1270 (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1271 (easy-menu-add-item nil '("Tools") table-global-menu-map))
62578
ebbe0a507fe4 (table-disable-menu): Add separator as a string so that tmm doesn't create
Eli Zaretskii <eliz@gnu.org>
parents: 62531
diff changeset
1272 (easy-menu-add-item (current-global-map) '("menu-bar" "tools") "--")
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1273 (easy-menu-add-item (current-global-map) '("menu-bar" "tools") table-global-menu-map)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1274
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1275 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1276 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1277 ;; Macros
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1278 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1279
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1280 (defmacro table-with-cache-buffer (&rest body)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1281 "Execute the forms in BODY with table cache buffer as the current buffer.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1282 This macro simplifies the rest of the work greatly by condensing the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1283 common idiom used in many of the cell manipulation functions. It does
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1284 not return any meaningful value.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1285
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1286 Save the current buffer and set the cache buffer as the current
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1287 buffer. Move the point to the cache buffer coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1288 `table-cell-cache-point-coordinate'. After BODY forms are executed,
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1289 the paragraph is filled as long as `table-inhibit-auto-fill-paragraph'
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1290 remains nil. BODY can set it to t when it does not want to fill the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1291 paragraph. If necessary the cell width and height are extended as the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1292 consequence of cell content modification by the BODY. Then the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1293 current buffer is restored to the original one. The last cache point
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1294 coordinate is stored in `table-cell-cache-point-coordinate'. The
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1295 original buffer's point is moved to the location that corresponds to
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1296 the last cache point coordinate."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1297 (let ((height-expansion (make-symbol "height-expansion-var-symbol"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1298 (width-expansion (make-symbol "width-expansion-var-symbol")))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1299 `(let (,height-expansion ,width-expansion)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1300 ;; make sure cache has valid data unless it is explicitly inhibited.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1301 (unless table-inhibit-update
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1302 (table-recognize-cell))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1303 (with-current-buffer (get-buffer-create table-cache-buffer-name)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1304 ;; goto the cell coordinate based on `table-cell-cache-point-coordinate'.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1305 (set-mark (table--goto-coordinate table-cell-cache-mark-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1306 (table--goto-coordinate table-cell-cache-point-coordinate)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1307 (table--untabify-line)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1308 ;; always reset before executing body forms because auto-fill behavior is the default.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1309 (setq table-inhibit-auto-fill-paragraph nil)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1310 ;; do the body
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1311 ,@body
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1312 ;; fill paragraph unless the body does not want to by setting `table-inhibit-auto-fill-paragraph'.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1313 (unless table-inhibit-auto-fill-paragraph
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1314 (if (and table-cell-info-justify
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1315 (not (eq table-cell-info-justify 'left)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1316 (table--fill-region (point-min) (point-max))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1317 (table--fill-region
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1318 (save-excursion (forward-paragraph -1) (point))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1319 (save-excursion (forward-paragraph 1) (point)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1320 ;; keep the updated cell coordinate.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1321 (setq table-cell-cache-point-coordinate (table--get-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1322 ;; determine the cell width expansion.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1323 (setq ,width-expansion (table--measure-max-width))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1324 (if (<= ,width-expansion table-cell-info-width) nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1325 (table--fill-region (point-min) (point-max) ,width-expansion)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1326 ;; keep the updated cell coordinate.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1327 (setq table-cell-cache-point-coordinate (table--get-coordinate)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1328 (setq ,width-expansion (- ,width-expansion table-cell-info-width))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1329 ;; determine the cell height expansion.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1330 (if (looking-at "\\s *\\'") nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1331 (goto-char (point-min))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1332 (if (re-search-forward "\\(\\s *\\)\\'" nil t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1333 (goto-char (match-beginning 1))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1334 (setq ,height-expansion (- (cdr (table--get-coordinate)) (1- table-cell-info-height))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1335 ;; now back to the table buffer.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1336 ;; expand the cell width in the table buffer if necessary.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1337 (if (> ,width-expansion 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1338 (table-widen-cell ,width-expansion 'no-copy 'no-update))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1339 ;; expand the cell height in the table buffer if necessary.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1340 (if (> ,height-expansion 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1341 (table-heighten-cell ,height-expansion 'no-copy 'no-update))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1342 ;; do valign
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1343 (with-current-buffer (get-buffer-create table-cache-buffer-name)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1344 (table--goto-coordinate table-cell-cache-point-coordinate)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1345 (setq table-cell-cache-point-coordinate (table--valign)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1346 ;; move the point in the table buffer to the location that corresponds to
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1347 ;; the location in the cell cache buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1348 (table--goto-coordinate (table--transcoord-cache-to-table table-cell-cache-point-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1349 ;; set up the update timer unless it is explicitly inhibited.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1350 (unless table-inhibit-update
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1351 (table--update-cell)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1352
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1353 ;; for debugging the body form of the macro
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1354 (put 'table-with-cache-buffer 'edebug-form-spec '(body))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1355 ;; for neat presentation use the same indentation as `progn'
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1356 (put 'table-with-cache-buffer 'lisp-indent-function 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1357 (if (or (featurep 'xemacs)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1358 (null (fboundp 'font-lock-add-keywords))) nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1359 ;; color it as a keyword
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1360 (font-lock-add-keywords
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1361 'emacs-lisp-mode
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1362 '("\\<table-with-cache-buffer\\>")))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1363
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1364 (defmacro table-put-source-info (prop value)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1365 "Register source generation information."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1366 `(put 'table-source-info-plist ,prop ,value))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1367
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1368 (defmacro table-get-source-info (prop)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1369 "Retrieve source generation information."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1370 `(get 'table-source-info-plist ,prop))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1371
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1372 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1373 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1374 ;; Modified commands for cell operation
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1375 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1376
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1377 ;; Point Motion Only Group
84927
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
1378 (mapc
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1379 (lambda (command)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1380 (let ((func-symbol (intern (format "*table--cell-%s" command)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1381 (doc-string (format "Table remapped function for `%s'." command)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1382 (fset func-symbol
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1383 `(lambda
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1384 (&rest args)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1385 ,doc-string
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1386 (interactive)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1387 (let ((table-inhibit-update t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1388 (deactivate-mark nil))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1389 (table--finish-delayed-tasks)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1390 (table-recognize-cell 'force)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1391 (table-with-cache-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1392 (call-interactively ',command)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1393 (setq table-inhibit-auto-fill-paragraph t)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1394 (setq table-command-remap-alist
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1395 (cons (cons command func-symbol)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1396 table-command-remap-alist))))
72070
a85c85db662c Add move-beginning-of-line and move-end-of-line to Point Motion Only Group.
Eli Zaretskii <eliz@gnu.org>
parents: 71107
diff changeset
1397 '(move-beginning-of-line
a85c85db662c Add move-beginning-of-line and move-end-of-line to Point Motion Only Group.
Eli Zaretskii <eliz@gnu.org>
parents: 71107
diff changeset
1398 beginning-of-line
a85c85db662c Add move-beginning-of-line and move-end-of-line to Point Motion Only Group.
Eli Zaretskii <eliz@gnu.org>
parents: 71107
diff changeset
1399 move-end-of-line
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1400 end-of-line
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1401 beginning-of-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1402 end-of-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1403 forward-word
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1404 backward-word
55906
b2c91984d5a2 Sentence commands added to Point Motion group; kill and backward-kill
Juanma Barranquero <lekktu@gmail.com>
parents: 53367
diff changeset
1405 forward-sentence
b2c91984d5a2 Sentence commands added to Point Motion group; kill and backward-kill
Juanma Barranquero <lekktu@gmail.com>
parents: 53367
diff changeset
1406 backward-sentence
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1407 forward-paragraph
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1408 backward-paragraph))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1409
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1410 ;; Extraction Group
84927
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
1411 (mapc
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1412 (lambda (command)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1413 (let ((func-symbol (intern (format "*table--cell-%s" command)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1414 (doc-string (format "Table remapped function for `%s'." command)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1415 (fset func-symbol
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1416 `(lambda
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1417 (&rest args)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1418 ,doc-string
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1419 (interactive)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1420 (table--finish-delayed-tasks)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1421 (table-recognize-cell 'force)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1422 (table-with-cache-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1423 (table--remove-cell-properties (point-min) (point-max))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1424 (table--remove-eol-spaces (point-min) (point-max))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1425 (call-interactively ',command))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1426 (table--finish-delayed-tasks)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1427 (setq table-command-remap-alist
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1428 (cons (cons command func-symbol)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1429 table-command-remap-alist))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1430 '(kill-region
55906
b2c91984d5a2 Sentence commands added to Point Motion group; kill and backward-kill
Juanma Barranquero <lekktu@gmail.com>
parents: 53367
diff changeset
1431 kill-ring-save
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1432 delete-region
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1433 copy-region-as-kill
55906
b2c91984d5a2 Sentence commands added to Point Motion group; kill and backward-kill
Juanma Barranquero <lekktu@gmail.com>
parents: 53367
diff changeset
1434 kill-line
b2c91984d5a2 Sentence commands added to Point Motion group; kill and backward-kill
Juanma Barranquero <lekktu@gmail.com>
parents: 53367
diff changeset
1435 kill-word
b2c91984d5a2 Sentence commands added to Point Motion group; kill and backward-kill
Juanma Barranquero <lekktu@gmail.com>
parents: 53367
diff changeset
1436 backward-kill-word
b2c91984d5a2 Sentence commands added to Point Motion group; kill and backward-kill
Juanma Barranquero <lekktu@gmail.com>
parents: 53367
diff changeset
1437 kill-sentence
b2c91984d5a2 Sentence commands added to Point Motion group; kill and backward-kill
Juanma Barranquero <lekktu@gmail.com>
parents: 53367
diff changeset
1438 backward-kill-sentence
b2c91984d5a2 Sentence commands added to Point Motion group; kill and backward-kill
Juanma Barranquero <lekktu@gmail.com>
parents: 53367
diff changeset
1439 kill-paragraph
b2c91984d5a2 Sentence commands added to Point Motion group; kill and backward-kill
Juanma Barranquero <lekktu@gmail.com>
parents: 53367
diff changeset
1440 backward-kill-paragraph
b2c91984d5a2 Sentence commands added to Point Motion group; kill and backward-kill
Juanma Barranquero <lekktu@gmail.com>
parents: 53367
diff changeset
1441 kill-sexp
b2c91984d5a2 Sentence commands added to Point Motion group; kill and backward-kill
Juanma Barranquero <lekktu@gmail.com>
parents: 53367
diff changeset
1442 backward-kill-sexp))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1443
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1444 ;; Pasting Group
84927
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
1445 (mapc
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1446 (lambda (command)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1447 (let ((func-symbol (intern (format "*table--cell-%s" command)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1448 (doc-string (format "Table remapped function for `%s'." command)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1449 (fset func-symbol
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1450 `(lambda
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1451 (&rest args)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1452 ,doc-string
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1453 (interactive)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1454 (table--finish-delayed-tasks)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1455 (table-recognize-cell 'force)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1456 (table-with-cache-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1457 (call-interactively ',command)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1458 (table--untabify (point-min) (point-max))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1459 (table--fill-region (point-min) (point-max))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1460 (setq table-inhibit-auto-fill-paragraph t))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1461 (table--finish-delayed-tasks)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1462 (setq table-command-remap-alist
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1463 (cons (cons command func-symbol)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1464 table-command-remap-alist))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1465 '(yank
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1466 clipboard-yank
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1467 yank-clipboard-selection
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1468 insert))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1469
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1470 ;; Formatting Group
84927
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
1471 (mapc
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1472 (lambda (command)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1473 (let ((func-symbol (intern (format "*table--cell-%s" command)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1474 (doc-string (format "Table remapped function for `%s'." command)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1475 (fset func-symbol
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1476 `(lambda
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1477 (&rest args)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1478 ,doc-string
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1479 (interactive)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1480 (table--finish-delayed-tasks)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1481 (table-recognize-cell 'force)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1482 (table-with-cache-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1483 (let ((fill-column table-cell-info-width))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1484 (call-interactively ',command))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1485 (setq table-inhibit-auto-fill-paragraph t))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1486 (table--finish-delayed-tasks)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1487 (setq table-command-remap-alist
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1488 (cons (cons command func-symbol)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1489 table-command-remap-alist))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1490 '(center-line
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1491 conter-region
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1492 center-paragraph
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1493 fill-paragraph))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1494
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1495 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1496 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1497 ;; Commands
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1498 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1499
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1500 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1501 (defun table-insert (columns rows &optional cell-width cell-height)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1502 "Insert an editable text table.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1503 Insert a table of specified number of COLUMNS and ROWS. Optional
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1504 parameter CELL-WIDTH and CELL-HEIGHT can specify the size of each
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1505 cell. The cell size is uniform across the table if the specified size
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1506 is a number. They can be a list of numbers to specify different size
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1507 for each cell. When called interactively, the list of number is
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1508 entered by simply listing all the numbers with space characters
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1509 delimiting them.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1510
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1511 Examples:
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1512
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1513 \\[table-insert] inserts a table at the current point location.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1514
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1515 Suppose we have the following situation where `-!-' indicates the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1516 location of point.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1517
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1518 -!-
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1519
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1520 Type \\[table-insert] and hit ENTER key. As it asks table
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1521 specification, provide 3 for number of columns, 1 for number of rows,
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1522 5 for cell width and 1 for cell height. Now you shall see the next
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1523 table and the point is automatically moved to the beginning of the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1524 first cell.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1525
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1526 +-----+-----+-----+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1527 |-!- | | |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1528 +-----+-----+-----+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1529
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1530 Inside a table cell, there are special key bindings. \\<table-cell-map>
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1531
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1532 M-9 \\[table-widen-cell] (or \\[universal-argument] 9 \\[table-widen-cell]) widens the first cell by 9 character
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1533 width, which results as
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1534
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1535 +--------------+-----+-----+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1536 |-!- | | |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1537 +--------------+-----+-----+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1538
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1539 Type TAB \\[table-widen-cell] then type TAB M-2 M-7 \\[table-widen-cell] (or \\[universal-argument] 2 7 \\[table-widen-cell]). Typing
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1540 TAB moves the point forward by a cell. The result now looks like this:
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1541
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1542 +--------------+------+--------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1543 | | |-!- |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1544 +--------------+------+--------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1545
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1546 If you knew each width of the columns prior to the table creation,
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1547 what you could have done better was to have had given the complete
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1548 width information to `table-insert'.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1549
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1550 Cell width(s): 14 6 32
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1551
49599
5ade352e8d1c Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48373
diff changeset
1552 instead of
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1553
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1554 Cell width(s): 5
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1555
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1556 This would have eliminated the previously mentioned width adjustment
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1557 work all together.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1558
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1559 If the point is in the last cell type S-TAB S-TAB to move it to the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1560 first cell. Now type \\[table-heighten-cell] which heighten the row by a line.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1561
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1562 +--------------+------+--------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1563 |-!- | | |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1564 | | | |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1565 +--------------+------+--------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1566
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1567 Type \\[table-insert-row-column] and tell it to insert a row.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1568
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1569 +--------------+------+--------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1570 |-!- | | |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1571 | | | |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1572 +--------------+------+--------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1573 | | | |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1574 | | | |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1575 +--------------+------+--------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1576
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1577 Move the point under the table as shown below.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1578
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1579 +--------------+------+--------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1580 | | | |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1581 | | | |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1582 +--------------+------+--------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1583 | | | |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1584 | | | |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1585 +--------------+------+--------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1586 -!-
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1587
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1588 Type M-x table-insert-row instead of \\[table-insert-row-column]. \\[table-insert-row-column] does not work
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1589 when the point is outside of the table. This insertion at
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1590 outside of the table effectively appends a row at the end.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1591
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1592 +--------------+------+--------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1593 | | | |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1594 | | | |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1595 +--------------+------+--------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1596 | | | |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1597 | | | |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1598 +--------------+------+--------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1599 |-!- | | |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1600 | | | |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1601 +--------------+------+--------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1602
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1603 Text editing inside the table cell produces reasonably expected
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1604 results.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1605
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1606 +--------------+------+--------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1607 | | | |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1608 | | | |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1609 +--------------+------+--------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1610 | | |Text editing inside the table |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1611 | | |cell produces reasonably |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1612 | | |expected results.-!- |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1613 +--------------+------+--------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1614 | | | |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1615 | | | |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1616 +--------------+------+--------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1617
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1618 Inside a table cell has a special keymap.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1619
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1620 \\{table-cell-map}
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1621 "
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1622 (interactive
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1623 (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1624 (barf-if-buffer-read-only)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1625 (if (table--probe-cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1626 (error "Can't insert a table inside a table"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1627 (mapcar (function table--read-from-minibuffer)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1628 '(("Number of columns" . table-columns-history)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1629 ("Number of rows" . table-rows-history)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1630 ("Cell width(s)" . table-cell-width-history)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1631 ("Cell height(s)" . table-cell-height-history)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1632 (table--make-cell-map)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1633 ;; reform the arguments.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1634 (if (null cell-width) (setq cell-width (car table-cell-width-history)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1635 (if (null cell-height) (setq cell-height (car table-cell-height-history)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1636 (if (stringp columns) (setq columns (string-to-number columns)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1637 (if (stringp rows) (setq rows (string-to-number rows)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1638 (if (stringp cell-width) (setq cell-width (table--string-to-number-list cell-width)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1639 (if (stringp cell-height) (setq cell-height (table--string-to-number-list cell-height)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1640 (if (numberp cell-width) (setq cell-width (cons cell-width nil)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1641 (if (numberp cell-height) (setq cell-height (cons cell-height nil)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1642 ;; test validity of the arguments.
84927
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
1643 (mapc (lambda (arg)
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
1644 (let* ((value (symbol-value arg))
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
1645 (error-handler
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
1646 (function (lambda ()
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
1647 (error "%s must be a positive integer%s" arg
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
1648 (if (listp value) " or a list of positive integers" ""))))))
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
1649 (if (null value) (funcall error-handler))
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
1650 (mapcar (function (lambda (arg1)
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
1651 (if (or (not (integerp arg1))
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
1652 (< arg1 1))
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
1653 (funcall error-handler))))
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
1654 (if (listp value) value
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
1655 (cons value nil)))))
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
1656 '(columns rows cell-width cell-height))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1657 (let ((orig-coord (table--get-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1658 (coord (table--get-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1659 r i cw ch cell-str border-str)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1660 ;; prefabricate the building blocks border-str and cell-str.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1661 (with-temp-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1662 ;; construct border-str
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1663 (insert table-cell-intersection-char)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1664 (setq cw cell-width)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1665 (setq i 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1666 (while (< i columns)
51496
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
1667 (insert (make-string (car cw) (string-to-char table-cell-horizontal-chars)) table-cell-intersection-char)
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1668 (if (cdr cw) (setq cw (cdr cw)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1669 (setq i (1+ i)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1670 (setq border-str (buffer-substring (point-min) (point-max)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1671 ;; construct cell-str
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1672 (erase-buffer)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1673 (insert table-cell-vertical-char)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1674 (setq cw cell-width)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1675 (setq i 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1676 (while (< i columns)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1677 (let ((beg (point)))
64059
77cc3a2cedb3 (table-hooks): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents: 63227
diff changeset
1678 (insert (make-string (car cw) ?\s))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1679 (insert table-cell-vertical-char)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1680 (table--put-cell-line-property beg (1- (point))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1681 (if (cdr cw) (setq cw (cdr cw)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1682 (setq i (1+ i)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1683 (setq cell-str (buffer-substring (point-min) (point-max))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1684 ;; if the construction site has an empty border push that border down.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1685 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1686 (beginning-of-line)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1687 (if (looking-at "\\s *$")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1688 (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1689 (setq border-str (concat border-str "\n"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1690 (setq cell-str (concat cell-str "\n")))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1691 ;; now build the table using the prefabricated building blocks
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1692 (setq r 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1693 (setq ch cell-height)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1694 (while (< r rows)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1695 (if (> r 0) nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1696 (table--goto-coordinate coord) (setcdr coord (1+ (cdr coord)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1697 (table--untabify-line (point))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1698 (insert border-str))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1699 (setq i 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1700 (while (< i (car ch))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1701 (table--goto-coordinate coord) (setcdr coord (1+ (cdr coord)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1702 (table--untabify-line (point))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1703 (insert cell-str)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1704 (setq i (1+ i)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1705 (table--goto-coordinate coord) (setcdr coord (1+ (cdr coord)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1706 (table--untabify-line (point))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1707 (insert border-str)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1708 (if (cdr ch) (setq ch (cdr ch)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1709 (setq r (1+ r)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1710 ;; stand by at the first cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1711 (table--goto-coordinate (table--offset-coordinate orig-coord '(1 . 1)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1712 (table-recognize-cell 'force)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1713
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1714 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1715 (defun table-insert-row (n)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1716 "Insert N table row(s).
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1717 When point is in a table the newly inserted row(s) are placed above
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1718 the current row. When point is outside of the table it must be below
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1719 the table within the table width range, then the newly created row(s)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1720 are appended at the bottom of the table."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1721 (interactive "*p")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1722 (if (< n 0) (setq n 1))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1723 (let* ((current-coordinate (table--get-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1724 (coord-list (table--cell-list-to-coord-list (table--horizontal-cell-list t nil 'top)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1725 (append-row (if coord-list nil (setq coord-list (table--find-row-column))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1726 (cell-height (cdr (table--min-coord-list coord-list)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1727 (left-list nil)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1728 (this-list coord-list)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1729 (right-list (cdr coord-list))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1730 (bottom-border-y (1+ (cdr (table--get-coordinate (cdr (table--vertical-cell-list nil t))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1731 (vertical-str (string table-cell-vertical-char))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1732 (vertical-str-with-properties (let ((str (string table-cell-vertical-char)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1733 (table--put-cell-keymap-property 0 (length str) str)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1734 (table--put-cell-rear-nonsticky 0 (length str) str) str))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1735 (first-time t))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1736 ;; create the space below for the table to grow
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1737 (table--create-growing-space-below (* n (+ 1 cell-height)) coord-list bottom-border-y)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1738 ;; vertically expand each cell from left to right
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1739 (while this-list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1740 (let* ((left (prog1 (car left-list) (setq left-list (if left-list (cdr left-list) coord-list))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1741 (this (prog1 (car this-list) (setq this-list (cdr this-list))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1742 (right (prog1 (car right-list) (setq right-list (cdr right-list))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1743 (exclude-left (and left (< (cdar left) (cdar this))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1744 (exclude-right (and right (<= (cdar right) (cdar this))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1745 (beg (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1746 (cons (if exclude-left (caar this) (1- (caar this)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1747 (cdar this))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1748 (end (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1749 (cons (if exclude-right (cadr this) (1+ (cadr this)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1750 bottom-border-y)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1751 (rect (if append-row nil (extract-rectangle beg end))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1752 ;; prepend blank cell lines to the extracted rectangle
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1753 (let ((i n))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1754 (while (> i 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1755 (setq rect (cons
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1756 (concat (if exclude-left "" (char-to-string table-cell-intersection-char))
51496
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
1757 (make-string (- (cadr this) (caar this)) (string-to-char table-cell-horizontal-chars))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1758 (if exclude-right "" (char-to-string table-cell-intersection-char)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1759 rect))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1760 (let ((j cell-height))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1761 (while (> j 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1762 (setq rect (cons
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1763 (concat (if exclude-left ""
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1764 (if first-time vertical-str vertical-str-with-properties))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1765 (table--cell-blank-str (- (cadr this) (caar this)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1766 (if exclude-right "" vertical-str-with-properties))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1767 rect))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1768 (setq j (1- j))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1769 (setq i (1- i))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1770 (setq first-time nil)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1771 (if append-row
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1772 (table--goto-coordinate (cons (if exclude-left (caar this) (1- (caar this)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1773 (1+ bottom-border-y)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1774 (delete-rectangle beg end)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1775 (goto-char beg))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1776 (table--insert-rectangle rect)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1777 ;; fix up the intersections
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1778 (setq this-list (if append-row nil coord-list))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1779 (while this-list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1780 (let ((this (prog1 (car this-list) (setq this-list (cdr this-list))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1781 (i 0))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1782 (while (< i n)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1783 (let ((y (1- (* i (+ 1 cell-height)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1784 (table--goto-coordinate (table--offset-coordinate (car this) (cons -1 y)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1785 (delete-char 1) (insert table-cell-intersection-char)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1786 (table--goto-coordinate (table--offset-coordinate (cons (cadr this) (cdar this)) (cons 0 y)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1787 (delete-char 1) (insert table-cell-intersection-char)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1788 (setq i (1+ i))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1789 ;; move the point to the beginning of the first newly inserted cell.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1790 (if (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1791 (if append-row (cons (car (caar coord-list)) (1+ bottom-border-y))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1792 (caar coord-list))) nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1793 (table--goto-coordinate current-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1794 ;; re-recognize the current cell's new dimension
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1795 (table-recognize-cell 'force)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1796
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1797 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1798 (defun table-insert-column (n)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1799 "Insert N table column(s).
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1800 When point is in a table the newly inserted column(s) are placed left
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1801 of the current column. When point is outside of the table it must be
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1802 right side of the table within the table height range, then the newly
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1803 created column(s) are appended at the right of the table."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1804 (interactive "*p")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1805 (if (< n 0) (setq n 1))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1806 (let* ((current-coordinate (table--get-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1807 (coord-list (table--cell-list-to-coord-list (table--vertical-cell-list t nil 'left)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1808 (append-column (if coord-list nil (setq coord-list (table--find-row-column 'column))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1809 (cell-width (car (table--min-coord-list coord-list)))
51496
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
1810 (border-str (table--multiply-string (concat (make-string cell-width (string-to-char table-cell-horizontal-chars))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1811 (char-to-string table-cell-intersection-char)) n))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1812 (cell-str (table--multiply-string (concat (table--cell-blank-str cell-width)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1813 (let ((str (string table-cell-vertical-char)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1814 (table--put-cell-keymap-property 0 (length str) str)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1815 (table--put-cell-rear-nonsticky 0 (length str) str) str)) n))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1816 (columns-to-extend (* n (+ 1 cell-width)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1817 (above-list nil)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1818 (this-list coord-list)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1819 (below-list (cdr coord-list))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1820 (right-border-x (car (table--get-coordinate (cdr (table--horizontal-cell-list nil t))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1821 ;; push back the affected area above and below this table
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1822 (table--horizontally-shift-above-and-below columns-to-extend coord-list)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1823 ;; process each cell vertically from top to bottom
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1824 (while this-list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1825 (let* ((above (prog1 (car above-list) (setq above-list (if above-list (cdr above-list) coord-list))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1826 (this (prog1 (car this-list) (setq this-list (cdr this-list))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1827 (below (prog1 (car below-list) (setq below-list (cdr below-list))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1828 (exclude-above (and above (<= (caar above) (caar this))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1829 (exclude-below (and below (< (caar below) (caar this))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1830 (beg-coord (cons (if append-column (1+ right-border-x) (caar this))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1831 (if exclude-above (cdar this) (1- (cdar this)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1832 (end-coord (cons (1+ right-border-x)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1833 (if exclude-below (cddr this) (1+ (cddr this)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1834 rect)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1835 ;; untabify the area right of the bar that is about to be inserted
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1836 (let ((coord (table--copy-coordinate beg-coord))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1837 (i 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1838 (len (length rect)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1839 (while (< i len)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1840 (if (table--goto-coordinate coord 'no-extension)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1841 (table--untabify-line (point)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1842 (setcdr coord (1+ (cdr coord)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1843 (setq i (1+ i))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1844 ;; extract and delete the rectangle area including the current
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1845 ;; cell and to the right border of the table.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1846 (setq rect (extract-rectangle (table--goto-coordinate beg-coord)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1847 (table--goto-coordinate end-coord)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1848 (delete-rectangle (table--goto-coordinate beg-coord)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1849 (table--goto-coordinate end-coord))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1850 ;; prepend the empty column string at the beginning of each
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1851 ;; rectangle string extracted before.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1852 (let ((rect-str rect)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1853 (first t))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1854 (while rect-str
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1855 (if (and first (null exclude-above))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1856 (setcar rect-str (concat border-str (car rect-str)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1857 (if (and (null (cdr rect-str)) (null exclude-below))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1858 (setcar rect-str (concat border-str (car rect-str)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1859 (setcar rect-str (concat cell-str (car rect-str)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1860 (setq first nil)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1861 (setq rect-str (cdr rect-str))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1862 ;; insert the extended rectangle
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1863 (table--goto-coordinate beg-coord)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1864 (table--insert-rectangle rect)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1865 ;; fix up the intersections
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1866 (setq this-list (if append-column nil coord-list))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1867 (while this-list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1868 (let ((this (prog1 (car this-list) (setq this-list (cdr this-list))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1869 (i 0))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1870 (while (< i n)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1871 (let ((x (1- (* (1+ i) (+ 1 cell-width)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1872 (table--goto-coordinate (table--offset-coordinate (car this) (cons x -1)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1873 (delete-char 1) (insert table-cell-intersection-char)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1874 (table--goto-coordinate (table--offset-coordinate (cons (caar this) (cddr this)) (cons x 1)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1875 (delete-char 1) (insert table-cell-intersection-char)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1876 (setq i (1+ i))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1877 ;; move the point to the beginning of the first newly inserted cell.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1878 (if (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1879 (if append-column
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1880 (cons (1+ right-border-x)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1881 (cdar (car coord-list)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1882 (caar coord-list))) nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1883 (table--goto-coordinate current-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1884 ;; re-recognize the current cell's new dimension
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1885 (table-recognize-cell 'force)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1886
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1887 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1888 (defun table-insert-row-column (row-column n)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1889 "Insert row(s) or column(s).
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1890 See `table-insert-row' and `table-insert-column'."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1891 (interactive
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1892 (let ((n (prefix-numeric-value current-prefix-arg)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1893 (if (< n 0) (setq n 1))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1894 (list (intern (let ((completion-ignore-case t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1895 (default (car table-insert-row-column-history)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1896 (downcase (completing-read
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1897 (format "Insert %s row%s/column%s (default %s): "
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1898 (if (> n 1) (format "%d" n) "a")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1899 (if (> n 1) "s" "")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1900 (if (> n 1) "s" "")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1901 default)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1902 '(("row") ("column"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1903 nil t nil 'table-insert-row-column-history default))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1904 n)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1905 (cond ((eq row-column 'row)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1906 (table-insert-row n))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1907 ((eq row-column 'column)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1908 (table-insert-column n))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1909
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1910 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1911 (defun table-recognize (&optional arg)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1912 "Recognize all tables within the current buffer and activate them.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1913 Scans the entire buffer and recognizes valid table cells. If the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1914 optional numeric prefix argument ARG is negative the tables in the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1915 buffer become inactive, meaning the tables become plain text and loses
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1916 all the table specific features."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1917 (interactive "P")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1918 (setq arg (prefix-numeric-value arg))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1919 (let* ((inhibit-read-only t))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1920 (table-recognize-region (point-min) (point-max) -1)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1921 (if (>= arg 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1922 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1923 (goto-char (point-min))
51496
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
1924 (let* ((border (format "[%s%c%c]"
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
1925 table-cell-horizontal-chars
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1926 table-cell-vertical-char
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1927 table-cell-intersection-char))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1928 (border3 (concat border border border))
51496
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
1929 (non-border (format "^[^%s%c%c]*$"
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
1930 table-cell-horizontal-chars
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1931 table-cell-vertical-char
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1932 table-cell-intersection-char)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1933 ;; `table-recognize-region' is an expensive function so minimize
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1934 ;; the search area. A minimum table at least consists of three consecutive
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1935 ;; table border characters to begin with such as
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1936 ;; +-+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1937 ;; |A|
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1938 ;; +-+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1939 ;; and any tables end with a line containing no table border characters
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1940 ;; or the end of buffer.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1941 (while (and (re-search-forward border3 (point-max) t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1942 (not (and (input-pending-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1943 table-abort-recognition-when-input-pending)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1944 (message "Recognizing tables...(%d%%)" (/ (* 100 (match-beginning 0)) (- (point-max) (point-min))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1945 (let ((beg (match-beginning 0))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1946 end)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1947 (if (re-search-forward non-border (point-max) t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1948 (setq end (match-beginning 0))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1949 (setq end (goto-char (point-max))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1950 (table-recognize-region beg end arg)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1951 (message "Recognizing tables...done"))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1952
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1953 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1954 (defun table-unrecognize ()
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1955 (interactive)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1956 (table-recognize -1))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1957
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1958 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1959 (defun table-recognize-region (beg end &optional arg)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1960 "Recognize all tables within region.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1961 BEG and END specify the region to work on. If the optional numeric
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1962 prefix argument ARG is negative the tables in the region become
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1963 inactive, meaning the tables become plain text and lose all the table
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1964 specific features."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1965 (interactive "r\nP")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1966 (setq arg (prefix-numeric-value arg))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1967 (let ((inhibit-read-only t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1968 (modified-flag (buffer-modified-p)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1969 (if (< arg 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1970 (table--remove-cell-properties beg end)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1971 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1972 (goto-char beg)
51496
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
1973 (let* ((border (format "[%s%c%c]"
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
1974 table-cell-horizontal-chars
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1975 table-cell-vertical-char
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1976 table-cell-intersection-char))
51496
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
1977 (non-border (format "[^%s%c%c]"
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
1978 table-cell-horizontal-chars
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1979 table-cell-vertical-char
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1980 table-cell-intersection-char))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1981 (inhibit-read-only t))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1982 (unwind-protect
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1983 (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1984 (remove-text-properties beg end '(table-cell nil))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1985 (while (and (< (point) end)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1986 (not (and (input-pending-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1987 table-abort-recognition-when-input-pending)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1988 (cond
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1989 ((looking-at "\n")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1990 (forward-char 1))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1991 ((looking-at border)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1992 (if (re-search-forward non-border end t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1993 (goto-char (match-beginning 0))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1994 (goto-char end)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1995 ((table--at-cell-p (point))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1996 (goto-char (next-single-property-change (point) 'table-cell nil end)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1997 (t
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1998 (let ((cell (table-recognize-cell 'force 'no-copy)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1999 (if (and cell table-detect-cell-alignment)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2000 (table--detect-cell-alignment cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2001 (unless (re-search-forward border end t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2002 (goto-char end))))))))))
68246
ecfd9a69b670 Move defvars out of eval-when-compile.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64993
diff changeset
2003 (restore-buffer-modified-p modified-flag)))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2004
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2005 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2006 (defun table-unrecognize-region (beg end)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2007 (interactive "r")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2008 (table-recognize-region beg end -1))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2009
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2010 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2011 (defun table-recognize-table (&optional arg)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2012 "Recognize a table at point.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2013 If the optional numeric prefix argument ARG is negative the table
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2014 becomes inactive, meaning the table becomes plain text and loses all
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2015 the table specific features."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2016 (interactive "P")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2017 (setq arg (prefix-numeric-value arg))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2018 (let ((unrecognize (< arg 0))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2019 (origin-cell (table--probe-cell))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2020 (inhibit-read-only t))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2021 (if origin-cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2022 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2023 (while
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2024 (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2025 (table-forward-cell 1 nil unrecognize)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2026 (let ((cell (table--probe-cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2027 (if (and cell table-detect-cell-alignment)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2028 (table--detect-cell-alignment cell))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2029 (and cell (not (equal cell origin-cell))))))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2030
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2031 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2032 (defun table-unrecognize-table ()
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2033 (interactive)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2034 (table-recognize-table -1))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2035
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2036 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2037 (defun table-recognize-cell (&optional force no-copy arg)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2038 "Recognize a table cell that contains current point.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2039 Probe the cell dimension and prepare the cell information. The
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2040 optional two arguments FORCE and NO-COPY are for internal use only and
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2041 must not be specified. When the optional numeric prefix argument ARG
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2042 is negative the cell becomes inactive, meaning that the cell becomes
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2043 plain text and loses all the table specific features."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2044 (interactive "i\ni\np")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2045 (table--make-cell-map)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2046 (if (or force (not (memq (table--get-last-command) table-command-list)))
105372
bd2966850aac Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents: 104386
diff changeset
2047 (let* ((cell (table--probe-cell (called-interactively-p 'interactive)))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2048 (cache-buffer (get-buffer-create table-cache-buffer-name))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2049 (modified-flag (buffer-modified-p))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2050 (inhibit-read-only t))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2051 (unwind-protect
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2052 (unless (null cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2053 ;; initialize the cell info variables
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2054 (let ((lu-coordinate (table--get-coordinate (car cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2055 (rb-coordinate (table--get-coordinate (cdr cell))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2056 ;; update the previous cell if this cell is different from the previous one.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2057 ;; care only lu but ignore rb since size change does not matter.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2058 (unless (equal table-cell-info-lu-coordinate lu-coordinate)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2059 (table--finish-delayed-tasks))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2060 (setq table-cell-info-lu-coordinate lu-coordinate)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2061 (setq table-cell-info-rb-coordinate rb-coordinate)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2062 (setq table-cell-info-width (- (car table-cell-info-rb-coordinate)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2063 (car table-cell-info-lu-coordinate)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2064 (setq table-cell-info-height (+ (- (cdr table-cell-info-rb-coordinate)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2065 (cdr table-cell-info-lu-coordinate)) 1))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2066 (setq table-cell-info-justify (table--get-cell-justify-property cell))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2067 (setq table-cell-info-valign (table--get-cell-valign-property cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2068 ;; set/remove table cell properties
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2069 (if (< (prefix-numeric-value arg) 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2070 (let ((coord (table--get-coordinate (car cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2071 (n table-cell-info-height))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2072 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2073 (while (> n 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2074 (table--remove-cell-properties
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2075 (table--goto-coordinate coord)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2076 (table--goto-coordinate (cons (+ (car coord) table-cell-info-width 1) (cdr coord))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2077 (setq n (1- n))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2078 (setcdr coord (1+ (cdr coord))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2079 (table--put-cell-property cell))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2080 ;; copy the cell contents to the cache buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2081 ;; only if no-copy is nil and timers are not set
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2082 (unless no-copy
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2083 (setq table-cell-cache-point-coordinate (table--transcoord-table-to-cache))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2084 (setq table-cell-cache-mark-coordinate (table--transcoord-table-to-cache
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2085 (table--get-coordinate (marker-position (mark-marker)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2086 (setq table-cell-buffer (current-buffer))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2087 (let ((rectangle (extract-rectangle (car cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2088 (cdr cell))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2089 (save-current-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2090 (set-buffer cache-buffer)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2091 (erase-buffer)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2092 (table--insert-rectangle rectangle)))))
68246
ecfd9a69b670 Move defvars out of eval-when-compile.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64993
diff changeset
2093 (restore-buffer-modified-p modified-flag))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2094 (if (featurep 'xemacs)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2095 (table--warn-incompatibility))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2096 cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2097
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2098 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2099 (defun table-unrecognize-cell ()
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2100 (interactive)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2101 (table-recognize-cell nil nil -1))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2102
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2103 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2104 (defun table-heighten-cell (n &optional no-copy no-update)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2105 "Heighten the current cell by N lines by expanding the cell vertically.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2106 Heightening is done by adding blank lines at the bottom of the current
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2107 cell. Other cells aligned horizontally with the current one are also
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2108 heightened in order to keep the rectangular table structure. The
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2109 optional argument NO-COPY is internal use only and must not be
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2110 specified."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2111 (interactive "*p")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2112 (if (< n 0) (setq n 1))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2113 (let* ((coord-list (table--cell-list-to-coord-list (table--horizontal-cell-list t)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2114 (left-list nil)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2115 (this-list coord-list)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2116 (right-list (cdr coord-list))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2117 (bottom-border-y (1+ (cdr (table--get-coordinate (cdr (table--vertical-cell-list nil t))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2118 (vertical-str (string table-cell-vertical-char))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2119 (vertical-str-with-properties (string table-cell-vertical-char))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2120 (first-time t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2121 (current-coordinate (table--get-coordinate)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2122 ;; prepare the right vertical string with appropriate properties put
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2123 (table--put-cell-keymap-property 0 (length vertical-str-with-properties) vertical-str-with-properties)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2124 ;; create the space below for the table to grow
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2125 (table--create-growing-space-below n coord-list bottom-border-y)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2126 ;; vertically expand each cell from left to right
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2127 (while this-list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2128 (let* ((left (prog1 (car left-list) (setq left-list (if left-list (cdr left-list) coord-list))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2129 (this (prog1 (car this-list) (setq this-list (cdr this-list))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2130 (right (prog1 (car right-list) (setq right-list (cdr right-list))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2131 (exclude-left (and left (< (cddr left) (cddr this))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2132 (exclude-right (and right (<= (cddr right) (cddr this))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2133 (beg (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2134 (cons (if exclude-left (caar this) (1- (caar this)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2135 (1+ (cddr this)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2136 (end (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2137 (cons (if exclude-right (cadr this) (1+ (cadr this)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2138 bottom-border-y)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2139 (rect (extract-rectangle beg end)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2140 ;; prepend blank cell lines to the extracted rectangle
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2141 (let ((i n))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2142 (while (> i 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2143 (setq rect (cons
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2144 (concat (if exclude-left ""
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2145 (if first-time vertical-str vertical-str-with-properties))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2146 (table--cell-blank-str (- (cadr this) (caar this)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2147 (if exclude-right "" vertical-str-with-properties))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2148 rect))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2149 (setq i (1- i))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2150 (setq first-time nil)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2151 (delete-rectangle beg end)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2152 (goto-char beg)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2153 (table--insert-rectangle rect)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2154 (table--goto-coordinate current-coordinate)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2155 ;; re-recognize the current cell's new dimension
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2156 (table-recognize-cell 'force no-copy)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2157 (unless no-update
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2158 (table--update-cell-heightened))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2159
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2160 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2161 (defun table-shorten-cell (n)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2162 "Shorten the current cell by N lines by shrinking the cell vertically.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2163 Shortening is done by removing blank lines from the bottom of the cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2164 and possibly from the top of the cell as well. Therefor, the cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2165 must have some bottom/top blank lines to be shorten effectively. This
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2166 is applicable to all the cells aligned horizontally with the current
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2167 one because they are also shortened in order to keep the rectangular
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2168 table structure."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2169 (interactive "*p")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2170 (if (< n 0) (setq n 1))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2171 (table--finish-delayed-tasks)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2172 (let* ((table-inhibit-update t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2173 (coord-list (table--cell-list-to-coord-list (table--horizontal-cell-list t)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2174 (left-list nil)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2175 (this-list coord-list)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2176 (right-list (cdr coord-list))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2177 (bottom-budget-list nil)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2178 (bottom-border-y (1+ (cdr (table--get-coordinate (cdr (table--vertical-cell-list nil t))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2179 (current-coordinate (table--get-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2180 (current-cell-coordinate (table--cell-to-coord (table--probe-cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2181 (blank-line-regexp "\\s *$"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2182 (message "Shortening...");; this operation may be lengthy
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2183 ;; for each cell calculate the maximum number of blank lines we can delete
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2184 ;; and adjust the argument n. n is adjusted so that the total number of
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2185 ;; blank lines from top and bottom of a cell do not exceed n, all cell has
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2186 ;; at least one line height after blank line deletion.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2187 (while this-list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2188 (let ((this (prog1 (car this-list) (setq this-list (cdr this-list)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2189 (table--goto-coordinate (car this))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2190 (table-recognize-cell 'force)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2191 (table-with-cache-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2192 (catch 'end-count
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2193 (let ((blank-line-count 0))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2194 (table--goto-coordinate (cons 0 (1- table-cell-info-height)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2195 ;; count bottom
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2196 (while (and (looking-at blank-line-regexp)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2197 (setq blank-line-count (1+ blank-line-count))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2198 ;; need to leave at least one blank line
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2199 (if (> blank-line-count n) (throw 'end-count nil) t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2200 (if (zerop (forward-line -1)) t
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2201 (setq n (if (zerop blank-line-count) 0
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2202 (1- blank-line-count)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2203 (throw 'end-count nil))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2204 (table--goto-coordinate (cons 0 0))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2205 ;; count top
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2206 (while (and (looking-at blank-line-regexp)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2207 (setq blank-line-count (1+ blank-line-count))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2208 ;; can consume all blank lines
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2209 (if (>= blank-line-count n) (throw 'end-count nil) t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2210 (zerop (forward-line 1))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2211 (setq n blank-line-count))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2212 ;; construct the bottom-budget-list which is a list of numbers where each number
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2213 ;; corresponds to how many lines to be deleted from the bottom of each cell. If
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2214 ;; this number, say bb, is smaller than n (bb < n) that means the difference (n - bb)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2215 ;; number of lines must be deleted from the top of the cell in addition to deleting
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2216 ;; bb lines from the bottom of the cell.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2217 (setq this-list coord-list)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2218 (while this-list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2219 (let ((this (prog1 (car this-list) (setq this-list (cdr this-list)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2220 (table--goto-coordinate (car this))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2221 (table-recognize-cell 'force)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2222 (table-with-cache-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2223 (setq bottom-budget-list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2224 (cons
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2225 (let ((blank-line-count 0))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2226 (table--goto-coordinate (cons 0 (1- table-cell-info-height)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2227 (while (and (looking-at blank-line-regexp)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2228 (< blank-line-count n)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2229 (setq blank-line-count (1+ blank-line-count))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2230 (zerop (forward-line -1))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2231 blank-line-count)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2232 bottom-budget-list)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2233 (setq bottom-budget-list (nreverse bottom-budget-list))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2234 ;; vertically shorten each cell from left to right
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2235 (setq this-list coord-list)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2236 (while this-list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2237 (let* ((left (prog1 (car left-list) (setq left-list (if left-list (cdr left-list) coord-list))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2238 (this (prog1 (car this-list) (setq this-list (cdr this-list))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2239 (right (prog1 (car right-list) (setq right-list (cdr right-list))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2240 (bottom-budget (prog1 (car bottom-budget-list) (setq bottom-budget-list (cdr bottom-budget-list))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2241 (exclude-left (and left (< (cddr left) (cddr this))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2242 (exclude-right (and right (<= (cddr right) (cddr this))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2243 (beg (table--goto-coordinate (cons (caar this) (cdar this))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2244 (end (table--goto-coordinate (cons (cadr this) bottom-border-y)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2245 (rect (extract-rectangle beg end))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2246 (height (+ (- (cddr this) (cdar this)) 1))
64059
77cc3a2cedb3 (table-hooks): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents: 63227
diff changeset
2247 (blank-line (make-string (- (cadr this) (caar this)) ?\s)))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2248 ;; delete lines from the bottom of the cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2249 (setcdr (nthcdr (- height bottom-budget 1) rect) (nthcdr height rect))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2250 ;; delete lines from the top of the cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2251 (if (> n bottom-budget)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2252 (let ((props (text-properties-at 0 (car rect))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2253 (setq rect (nthcdr (- n bottom-budget) rect))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2254 (set-text-properties 0 1 props (car rect))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2255 ;; append blank lines below the table
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2256 (setq rect (append rect (make-list n blank-line)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2257 ;; now swap the area with the prepared rect of the same size
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2258 (delete-rectangle beg end)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2259 (goto-char beg)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2260 (table--insert-rectangle rect)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2261 ;; for the left and right borders always delete lines from the bottom of the cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2262 (unless exclude-left
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2263 (let* ((beg (table--goto-coordinate (cons (1- (caar this)) (cdar this))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2264 (end (table--goto-coordinate (cons (caar this) bottom-border-y)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2265 (rect (extract-rectangle beg end)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2266 (setcdr (nthcdr (- height n 1) rect) (nthcdr height rect))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2267 (setq rect (append rect (make-list n " ")))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2268 (delete-rectangle beg end)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2269 (goto-char beg)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2270 (table--insert-rectangle rect)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2271 (unless exclude-right
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2272 (let* ((beg (table--goto-coordinate (cons (cadr this) (cdar this))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2273 (end (table--goto-coordinate (cons (1+ (cadr this)) bottom-border-y)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2274 (rect (extract-rectangle beg end)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2275 (setcdr (nthcdr (- height n 1) rect) (nthcdr height rect))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2276 (setq rect (append rect (make-list n " ")))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2277 (delete-rectangle beg end)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2278 (goto-char beg)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2279 (table--insert-rectangle rect)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2280 ;; if this is the cell where the original point was in, adjust the point location
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2281 (if (null (equal this current-cell-coordinate)) nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2282 (let ((y (- (cdr current-coordinate) (cdar this))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2283 (if (< y (- n bottom-budget))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2284 (setcdr current-coordinate (cdar this))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2285 (if (< (- y (- n bottom-budget)) (- height n))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2286 (setcdr current-coordinate (+ (cdar this) (- y (- n bottom-budget))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2287 (setcdr current-coordinate (+ (cdar this) (- height n 1)))))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2288 ;; remove the appended blank lines below the table if they are unnecessary
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2289 (table--goto-coordinate (cons 0 (1+ (- bottom-border-y n))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2290 (table--remove-blank-lines n)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2291 ;; re-recognize the current cell's new dimension
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2292 (table--goto-coordinate current-coordinate)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2293 (table-recognize-cell 'force)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2294 (table--update-cell-heightened)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2295 (message "")))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2296
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2297 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2298 (defun table-widen-cell (n &optional no-copy no-update)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2299 "Widen the current cell by N columns and expand the cell horizontally.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2300 Some other cells in the same table are widen as well to keep the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2301 table's rectangle structure."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2302 (interactive "*p")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2303 (if (< n 0) (setq n 1))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2304 (let* ((coord-list (table--cell-list-to-coord-list (table--vertical-cell-list)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2305 (below-list nil)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2306 (this-list coord-list)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2307 (above-list (cdr coord-list)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2308 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2309 ;; push back the affected area above and below this table
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2310 (table--horizontally-shift-above-and-below n (reverse coord-list))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2311 ;; now widen vertically for each cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2312 (while this-list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2313 (let* ((below (prog1 (car below-list) (setq below-list (if below-list (cdr below-list) coord-list))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2314 (this (prog1 (car this-list) (setq this-list (cdr this-list))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2315 (above (prog1 (car above-list) (setq above-list (cdr above-list))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2316 (beg (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2317 (cons (car (cdr this))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2318 (if (or (null above) (<= (car (cdr this)) (car (cdr above))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2319 (1- (cdr (car this)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2320 (cdr (car this))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2321 (end (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2322 (cons (1+ (car (cdr this)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2323 (if (or (null below) (< (car (cdr this)) (car (cdr below))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2324 (1+ (cdr (cdr this)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2325 (cdr (cdr this))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2326 (tmp (extract-rectangle (1- beg) end))
51496
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
2327 (border (format "[%s%c]\\%c"
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
2328 table-cell-horizontal-chars
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2329 table-cell-intersection-char
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2330 table-cell-intersection-char))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2331 (blank (table--cell-blank-str))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2332 rectangle)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2333 ;; create a single wide vertical bar of empty cell fragment
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2334 (while tmp
51496
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
2335 ; (message "tmp is %s" tmp)
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
2336 (setq rectangle (cons
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
2337 (if (string-match border (car tmp))
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
2338 (substring (car tmp) 0 1)
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2339 blank)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2340 rectangle))
51496
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
2341 ; (message "rectangle is %s" rectangle)
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2342 (setq tmp (cdr tmp)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2343 (setq rectangle (nreverse rectangle))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2344 ;; untabify the area right of the bar that is about to be inserted
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2345 (let ((coord (table--get-coordinate beg))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2346 (i 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2347 (len (length rectangle)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2348 (while (< i len)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2349 (if (table--goto-coordinate coord 'no-extension)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2350 (table--untabify-line (point)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2351 (setcdr coord (1+ (cdr coord)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2352 (setq i (1+ i))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2353 ;; insert the bar n times
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2354 (goto-char beg)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2355 (let ((i 0))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2356 (while (< i n)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2357 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2358 (table--insert-rectangle rectangle))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2359 (setq i (1+ i)))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2360 (table-recognize-cell 'force no-copy)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2361 (unless no-update
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2362 (table--update-cell-widened))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2363
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2364 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2365 (defun table-narrow-cell (n)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2366 "Narrow the current cell by N columns and shrink the cell horizontally.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2367 Some other cells in the same table are narrowed as well to keep the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2368 table's rectangle structure."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2369 (interactive "*p")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2370 (if (< n 0) (setq n 1))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2371 (table--finish-delayed-tasks)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2372 (let* ((coord-list (table--cell-list-to-coord-list (table--vertical-cell-list)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2373 (current-cell (table--cell-to-coord (table--probe-cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2374 (current-coordinate (table--get-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2375 tmp-list)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2376 (message "Narrowing...");; this operation may be lengthy
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2377 ;; determine the doable n by try narrowing each cell.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2378 (setq tmp-list coord-list)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2379 (while tmp-list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2380 (let ((cell (prog1 (car tmp-list) (setq tmp-list (cdr tmp-list))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2381 (table-inhibit-update t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2382 cell-n)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2383 (table--goto-coordinate (car cell))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2384 (table-recognize-cell 'force)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2385 (table-with-cache-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2386 (table--fill-region (point-min) (point-max) (- table-cell-info-width n))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2387 (if (< (setq cell-n (- table-cell-info-width (table--measure-max-width))) n)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2388 (setq n cell-n))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2389 (erase-buffer)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2390 (setq table-inhibit-auto-fill-paragraph t))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2391 (if (< n 1) nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2392 ;; narrow only the contents of each cell but leave the cell frame as is because
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2393 ;; we need to have valid frame structure in order for table-with-cache-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2394 ;; to work correctly.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2395 (setq tmp-list coord-list)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2396 (while tmp-list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2397 (let* ((cell (prog1 (car tmp-list) (setq tmp-list (cdr tmp-list))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2398 (table-inhibit-update t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2399 (currentp (equal cell current-cell))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2400 old-height)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2401 (if currentp (table--goto-coordinate current-coordinate)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2402 (table--goto-coordinate (car cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2403 (table-recognize-cell 'force)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2404 (setq old-height table-cell-info-height)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2405 (table-with-cache-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2406 (let ((out-of-bound (>= (- (car current-coordinate) (car table-cell-info-lu-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2407 (- table-cell-info-width n)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2408 (sticky (and currentp
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2409 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2410 (unless (bolp) (forward-char -1))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2411 (looking-at ".*\\S ")))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2412 (table--fill-region (point-min) (point-max) (- table-cell-info-width n))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2413 (if (or sticky (and currentp (looking-at ".*\\S ")))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2414 (setq current-coordinate (table--transcoord-cache-to-table))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2415 (if out-of-bound (setcar current-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2416 (+ (car table-cell-info-lu-coordinate) (- table-cell-info-width n 1))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2417 (setq table-inhibit-auto-fill-paragraph t))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2418 (table--update-cell 'now)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2419 ;; if this cell heightens and pushes the current cell below, move
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2420 ;; the current-coordinate (point location) down accordingly.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2421 (if currentp (setq current-coordinate (table--get-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2422 (if (and (> table-cell-info-height old-height)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2423 (> (cdr current-coordinate) (cdr table-cell-info-lu-coordinate)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2424 (setcdr current-coordinate (+ (cdr current-coordinate)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2425 (- table-cell-info-height old-height)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2426 ))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2427 ;; coord-list is now possibly invalid since some cells may have already
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2428 ;; been heightened so recompute them by table--vertical-cell-list.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2429 (table--goto-coordinate current-coordinate)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2430 (setq coord-list (table--cell-list-to-coord-list (table--vertical-cell-list)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2431 ;; push in the affected area above and below this table so that things
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2432 ;; on the right side of the table are shifted horizontally neatly.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2433 (table--horizontally-shift-above-and-below (- n) (reverse coord-list))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2434 ;; finally narrow the frames for each cell.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2435 (let* ((below-list nil)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2436 (this-list coord-list)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2437 (above-list (cdr coord-list)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2438 (while this-list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2439 (let* ((below (prog1 (car below-list) (setq below-list (if below-list (cdr below-list) coord-list))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2440 (this (prog1 (car this-list) (setq this-list (cdr this-list))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2441 (above (prog1 (car above-list) (setq above-list (cdr above-list)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2442 (delete-rectangle
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2443 (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2444 (cons (- (cadr this) n)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2445 (if (or (null above) (<= (cadr this) (cadr above)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2446 (1- (cdar this))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2447 (cdar this))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2448 (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2449 (cons (cadr this)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2450 (if (or (null below) (< (cadr this) (cadr below)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2451 (1+ (cddr this))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2452 (cddr this)))))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2453 (table--goto-coordinate current-coordinate)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2454 ;; re-recognize the current cell's new dimension
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2455 (table-recognize-cell 'force)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2456 (message "")))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2457
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2458 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2459 (defun table-forward-cell (&optional arg no-recognize unrecognize)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2460 "Move point forward to the beginning of the next cell.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2461 With argument ARG, do it ARG times;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2462 a negative argument ARG = -N means move backward N cells.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2463 Do not specify NO-RECOGNIZE and UNRECOGNIZE. They are for internal use only.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2464
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2465 Sample Cell Traveling Order (In Irregular Table Cases)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2466
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2467 You can actually try how it works in this buffer. Press
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2468 \\[table-recognize] and go to cells in the following tables and press
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2469 \\[table-forward-cell] or TAB key.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2470
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2471 +-----+--+ +--+-----+ +--+--+--+ +--+--+--+ +---------+ +--+---+--+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2472 |0 |1 | |0 |1 | |0 |1 |2 | |0 |1 |2 | |0 | |0 |1 |2 |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2473 +--+--+ | | +--+--+ +--+ | | | | +--+ +----+----+ +--+-+-+--+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2474 |2 |3 | | | |2 |3 | |3 +--+ | | +--+3 | |1 |2 | |3 |4 |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2475 | +--+--+ +--+--+ | +--+4 | | | |4 +--+ +--+-+-+--+ +----+----+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2476 | |4 | |4 | | |5 | | | | | |5 | |3 |4 |5 | |5 |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2477 +--+-----+ +-----+--+ +--+--+--+ +--+--+--+ +--+---+--+ +---------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2478
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2479 +--+--+--+ +--+--+--+ +--+--+--+ +--+--+--+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2480 |0 |1 |2 | |0 |1 |2 | |0 |1 |2 | |0 |1 |2 |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2481 | | | | | +--+ | | | | | +--+ +--+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2482 +--+ +--+ +--+3 +--+ | +--+ | |3 +--+4 |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2483 |3 | |4 | |4 +--+5 | | |3 | | +--+5 +--+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2484 | | | | | |6 | | | | | | |6 | |7 |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2485 +--+--+--+ +--+--+--+ +--+--+--+ +--+--+--+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2486
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2487 +--+--+--+ +--+--+--+ +--+--+--+--+ +--+-----+--+ +--+--+--+--+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2488 |0 |1 |2 | |0 |1 |2 | |0 |1 |2 |3 | |0 |1 |2 | |0 |1 |2 |3 |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2489 | +--+ | | +--+ | | +--+--+ | | | | | | +--+--+ |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2490 | |3 +--+ +--+3 | | +--+4 +--+ +--+ +--+ +--+4 +--+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2491 +--+ |4 | |4 | +--+ |5 +--+--+6 | |3 +--+--+4 | |5 | |6 |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2492 |5 +--+ | | +--+5 | | |7 |8 | | | |5 |6 | | | | | |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2493 | |6 | | | |6 | | +--+--+--+--+ +--+--+--+--+ +--+-----+--+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2494 +--+--+--+ +--+--+--+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2495 "
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2496 ;; After modifying this function, test against the above tables in
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2497 ;; the doc string. It is quite tricky. The tables above do not
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2498 ;; mean to cover every possible cases of cell layout, of course.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2499 ;; They are examples of tricky cases from implementation point of
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2500 ;; view and provided for simple regression test purpose.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2501 (interactive "p")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2502 (or arg (setq arg 1))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2503 (table--finish-delayed-tasks)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2504 (while (null (zerop arg))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2505 (let* ((pivot (table--probe-cell 'abort-on-error))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2506 (cell pivot) edge tip)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2507 ;; go to the beginning of the first right/left cell with same height if exists
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2508 (while (and (setq cell (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2509 (cons (if (> arg 0) (1+ (car (table--get-coordinate (cdr cell))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2510 (1- (car (table--get-coordinate (car cell)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2511 (cdr (table--get-coordinate (car pivot)))) 'no-extension))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2512 (setq cell (table--probe-cell))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2513 (/= (cdr (table--get-coordinate (car cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2514 (cdr (table--get-coordinate (car pivot))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2515 (if cell (goto-char (car cell)) ; done
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2516 ;; if the horizontal move fails search the most left/right edge cell below/above the pivot
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2517 ;; but first find the edge cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2518 (setq edge pivot)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2519 (while (and (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2520 (cons (if (> arg 0) (1- (car (table--get-coordinate (car edge))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2521 (1+ (car (table--get-coordinate (cdr edge)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2522 (cdr (table--get-coordinate (car pivot)))) 'no-extension)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2523 (setq cell (table--probe-cell))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2524 (setq edge cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2525 (setq cell (if (> arg 0) edge
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2526 (or (and (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2527 (cons (car (table--get-coordinate (cdr edge)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2528 (1- (cdr (table--get-coordinate (car edge))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2529 (table--probe-cell))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2530 edge)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2531 ;; now search for the tip which is the highest/lowest below/above cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2532 (while cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2533 (let (below/above)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2534 (and (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2535 (cons (car (table--get-coordinate (if (> arg 0) (car cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2536 (cdr cell))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2537 (if (> arg 0) (+ 2 (cdr (table--get-coordinate (cdr cell))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2538 (1- (cdr (table--get-coordinate (car pivot)))))) 'no-extension)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2539 (setq below/above (table--probe-cell))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2540 (or (null tip)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2541 (if (> arg 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2542 (< (cdr (table--get-coordinate (car below/above)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2543 (cdr (table--get-coordinate (car tip))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2544 (> (cdr (table--get-coordinate (car below/above)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2545 (cdr (table--get-coordinate (car tip))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2546 (setq tip below/above)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2547 (and (setq cell (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2548 (cons (if (> arg 0) (1+ (car (table--get-coordinate (cdr cell))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2549 (1- (car (table--get-coordinate (car cell)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2550 (if (> arg 0) (cdr (table--get-coordinate (car pivot)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2551 (1- (cdr (table--get-coordinate (car pivot)))))) 'no-extension))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2552 (setq cell (table--probe-cell))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2553 (if tip (goto-char (car tip)) ; done
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2554 ;; let's climb up/down to the top/bottom from the edge
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2555 (while (and (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2556 (cons (if (> arg 0) (car (table--get-coordinate (car edge)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2557 (car (table--get-coordinate (cdr edge))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2558 (if (> arg 0) (1- (cdr (table--get-coordinate (car edge))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2559 (+ 2 (cdr (table--get-coordinate (cdr edge)))))) 'no-extension)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2560 (setq cell (table--probe-cell))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2561 (setq edge cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2562 (if (< arg 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2563 (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2564 (setq cell edge)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2565 (while (and (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2566 (cons (1- (car (table--get-coordinate (car cell))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2567 (cdr (table--get-coordinate (cdr cell)))) 'no-extension)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2568 (setq cell (table--probe-cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2569 (if (> (cdr (table--get-coordinate (car cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2570 (cdr (table--get-coordinate (car edge))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2571 (setq edge cell)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2572 (goto-char (car edge))))) ; the top left cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2573 (setq arg (if (> arg 0) (1- arg) (1+ arg))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2574 (unless no-recognize
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2575 (table-recognize-cell 'force nil (if unrecognize -1 nil)))) ; refill the cache with new cell contents
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2576
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2577 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2578 (defun table-backward-cell (&optional arg)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2579 "Move backward to the beginning of the previous cell.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2580 With argument ARG, do it ARG times;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2581 a negative argument ARG = -N means move forward N cells."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2582 (interactive "p")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2583 (or arg (setq arg 1))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2584 (table-forward-cell (- arg)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2585
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2586 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2587 (defun table-span-cell (direction)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2588 "Span current cell into adjacent cell in DIRECTION.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2589 DIRECTION is one of symbols; right, left, above or below."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2590 (interactive
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2591 (list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2592 (let* ((dummy (barf-if-buffer-read-only))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2593 (direction-list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2594 (let* ((tmp (delete nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2595 (mapcar (lambda (d)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2596 (if (table--cell-can-span-p d)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2597 (list (symbol-name d))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2598 '(right left above below)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2599 (if (null tmp)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2600 (error "Can't span this cell"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2601 tmp))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2602 (default-direction (if (member (list (car table-cell-span-direction-history)) direction-list)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2603 (car table-cell-span-direction-history)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2604 (caar direction-list)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2605 (completion-ignore-case t))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2606 (intern (downcase (completing-read
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2607 (format "Span into (default %s): " default-direction)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2608 direction-list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2609 nil t nil 'table-cell-span-direction-history default-direction))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2610 (unless (memq direction '(right left above below))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2611 (error "Invalid direction %s, must be right, left, above or below"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2612 (symbol-name direction)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2613 (table-recognize-cell 'force)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2614 (unless (table--cell-can-span-p direction)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2615 (error "Can't span %s" (symbol-name direction)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2616 ;; prepare beginning and ending positions of the border bar to strike through
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2617 (let ((beg (cond
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2618 ((eq direction 'right)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2619 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2620 (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2621 (cons (car table-cell-info-rb-coordinate)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2622 (1- (cdr table-cell-info-lu-coordinate))) 'no-extension)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2623 ((eq direction 'below)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2624 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2625 (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2626 (cons (1- (car table-cell-info-lu-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2627 (1+ (cdr table-cell-info-rb-coordinate))) 'no-extension)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2628 (t
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2629 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2630 (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2631 (cons (1- (car table-cell-info-lu-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2632 (1- (cdr table-cell-info-lu-coordinate))) 'no-extension)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2633 (end (cond
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2634 ((eq direction 'left)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2635 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2636 (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2637 (cons (car table-cell-info-lu-coordinate)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2638 (1+ (cdr table-cell-info-rb-coordinate))) 'no-extension)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2639 ((eq direction 'above)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2640 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2641 (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2642 (cons (1+ (car table-cell-info-rb-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2643 (1- (cdr table-cell-info-lu-coordinate))) 'no-extension)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2644 (t
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2645 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2646 (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2647 (cons (1+ (car table-cell-info-rb-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2648 (1+ (cdr table-cell-info-rb-coordinate))) 'no-extension))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2649 ;; replace the bar with blank space while taking care of edges to be border or intersection
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2650 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2651 (goto-char beg)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2652 (if (memq direction '(left right))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2653 (let* ((column (current-column))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2654 rectangle
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2655 (n-element (- (length (extract-rectangle beg end)) 2))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2656 (above-contp (and (goto-char beg)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2657 (zerop (forward-line -1))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2658 (= (move-to-column column) column)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2659 (looking-at (regexp-quote (char-to-string table-cell-vertical-char)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2660 (below-contp (and (goto-char end)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2661 (progn (forward-char -1) t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2662 (zerop (forward-line 1))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2663 (= (move-to-column column) column)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2664 (looking-at (regexp-quote (char-to-string table-cell-vertical-char))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2665 (setq rectangle
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2666 (cons (if below-contp
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2667 (char-to-string table-cell-intersection-char)
51496
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
2668 (substring table-cell-horizontal-chars 0 1))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2669 rectangle))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2670 (while (> n-element 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2671 (setq rectangle (cons (table--cell-blank-str 1) rectangle))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2672 (setq n-element (1- n-element)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2673 (setq rectangle
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2674 (cons (if above-contp
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2675 (char-to-string table-cell-intersection-char)
51496
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
2676 (substring table-cell-horizontal-chars 0 1))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2677 rectangle))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2678 (delete-rectangle beg end)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2679 (goto-char beg)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2680 (table--insert-rectangle rectangle))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2681 (delete-region beg end)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2682 (insert (if (and (> (point) (point-min))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2683 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2684 (forward-char -1)
51496
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
2685 (looking-at (regexp-opt-charset
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
2686 (string-to-list table-cell-horizontal-chars)))))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2687 table-cell-intersection-char
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2688 table-cell-vertical-char)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2689 (table--cell-blank-str (- end beg 2))
51496
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
2690 (if (looking-at (regexp-opt-charset
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
2691 (string-to-list table-cell-horizontal-chars)))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2692 table-cell-intersection-char
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2693 table-cell-vertical-char))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2694 ;; recognize the newly created spanned cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2695 (table-recognize-cell 'force)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2696 (if (member direction '(right left))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2697 (table-with-cache-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2698 (table--fill-region (point-min) (point-max))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2699 (setq table-inhibit-auto-fill-paragraph t)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2700
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2701 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2702 (defun table-split-cell-vertically ()
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2703 "Split current cell vertically.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2704 Creates a cell above and a cell below the current point location."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2705 (interactive "*")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2706 (table-recognize-cell 'force)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2707 (let ((point-y (cdr (table--get-coordinate))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2708 (unless (table--cell-can-split-vertically-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2709 (error "Can't split here"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2710 (let* ((old-coordinate (table--get-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2711 (column (current-column))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2712 (beg (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2713 (cons (1- (car table-cell-info-lu-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2714 point-y)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2715 (end (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2716 (cons (1+ (car table-cell-info-rb-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2717 point-y)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2718 (line (buffer-substring (1+ beg) (1- end))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2719 (when (= (cdr old-coordinate) (cdr table-cell-info-rb-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2720 (table--goto-coordinate old-coordinate)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2721 (table-heighten-cell 1 'no-copy 'no-update))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2722 (goto-char beg)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2723 (delete-region beg end)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2724 (insert table-cell-intersection-char
51496
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
2725 (make-string table-cell-info-width (string-to-char table-cell-horizontal-chars))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2726 table-cell-intersection-char)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2727 (table--goto-coordinate old-coordinate)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2728 (forward-line 1)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2729 (move-to-column column)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2730 (setq old-coordinate (table--get-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2731 (table-recognize-cell 'force)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2732 (unless (string-match "^\\s *$" line)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2733 (table-with-cache-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2734 (goto-char (point-min))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2735 (insert line ?\n)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2736 (goto-char (point-min)) ;; don't heighten cell unnecessarily
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2737 (setq table-inhibit-auto-fill-paragraph t)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2738 (table--update-cell 'now) ;; can't defer this operation
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2739 (table--goto-coordinate old-coordinate)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2740 (move-to-column column)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2741 (table-recognize-cell 'force))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2742
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2743 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2744 (defun table-split-cell-horizontally ()
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2745 "Split current cell horizontally.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2746 Creates a cell on the left and a cell on the right of the current point location."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2747 (interactive "*")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2748 (table-recognize-cell 'force)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2749 (let* ((o-coordinate (table--get-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2750 (point-x (car o-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2751 cell-empty cell-contents cell-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2752 contents-to beg end rectangle strip-rect
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2753 (right-edge (= (car o-coordinate) (1- (car table-cell-info-rb-coordinate)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2754 (unless (table--cell-can-split-horizontally-p)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2755 (error "Can't split here"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2756 (let ((table-inhibit-update t))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2757 (table-with-cache-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2758 (setq cell-coordinate (table--get-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2759 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2760 (goto-char (point-min))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2761 (setq cell-empty (null (re-search-forward "\\S " nil t))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2762 (setq cell-contents (buffer-substring (point-min) (point-max)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2763 (setq table-inhibit-auto-fill-paragraph t)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2764 (setq contents-to
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2765 (if cell-empty 'left
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2766 (let* ((completion-ignore-case t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2767 (default (car table-cell-split-contents-to-history)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2768 (intern
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2769 (if (member 'click (event-modifiers last-input-event))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2770 (x-popup-menu last-input-event
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2771 '("Existing cell contents to:"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2772 ("Title"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2773 ("Split" . "split") ("Left" . "left") ("Right" . "right"))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2774 (downcase (completing-read
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2775 (format "Existing cell contents to (default %s): " default)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2776 '(("split") ("left") ("right"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2777 nil t nil 'table-cell-split-contents-to-history default)))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2778 (unless (eq contents-to 'split)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2779 (table-with-cache-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2780 (erase-buffer)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2781 (setq table-inhibit-auto-fill-paragraph t)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2782 (table--update-cell 'now)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2783 (setq beg (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2784 (cons point-x
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2785 (1- (cdr table-cell-info-lu-coordinate)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2786 (setq end (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2787 (cons (1+ point-x)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2788 (1+ (cdr table-cell-info-rb-coordinate)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2789 (setq rectangle (cons (char-to-string table-cell-intersection-char) nil))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2790 (let ((n table-cell-info-height))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2791 (while (prog1 (> n 0) (setq n (1- n)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2792 (setq rectangle (cons (char-to-string table-cell-vertical-char) rectangle))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2793 (setq rectangle (cons (char-to-string table-cell-intersection-char) rectangle))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2794 (if (eq contents-to 'split)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2795 (setq strip-rect (extract-rectangle beg end)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2796 (delete-rectangle beg end)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2797 (goto-char beg)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2798 (table--insert-rectangle rectangle)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2799 (table--goto-coordinate o-coordinate)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2800 (if cell-empty
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2801 (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2802 (forward-char 1)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2803 (if right-edge
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2804 (table-widen-cell 1)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2805 (unless (eq contents-to 'left)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2806 (forward-char 1))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2807 (table-recognize-cell 'force)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2808 (table-with-cache-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2809 (if (eq contents-to 'split)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2810 ;; split inserts strip-rect after removing
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2811 ;; top and bottom borders
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2812 (let ((o-coord (table--get-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2813 (l (setq strip-rect (cdr strip-rect))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2814 (while (cddr l) (setq l (cdr l)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2815 (setcdr l nil)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2816 ;; insert the strip only when it is not a completely blank one
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2817 (unless (let ((cl (mapcar (lambda (s) (string= s " ")) strip-rect)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2818 (and (car cl)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2819 (table--uniform-list-p cl)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2820 (goto-char (point-min))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2821 (table--insert-rectangle strip-rect)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2822 (table--goto-coordinate o-coord)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2823 ;; left or right inserts original contents
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2824 (erase-buffer)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2825 (insert cell-contents)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2826 (table--goto-coordinate cell-coordinate)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2827 (table--fill-region (point-min) (point-max))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2828 ;; avoid unnecessary vertical cell expansion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2829 (and (looking-at "\\s *\\'")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2830 (re-search-backward "\\S \\(\\s *\\)\\=" nil t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2831 (goto-char (match-beginning 1))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2832 ;; in either case do not fill paragraph
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2833 (setq table-inhibit-auto-fill-paragraph t))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2834 (table--update-cell 'now)) ;; can't defer this operation
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2835 (table-recognize-cell 'force)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2836
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2837 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2838 (defun table-split-cell (orientation)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2839 "Split current cell in ORIENTATION.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2840 ORIENTATION is a symbol either horizontally or vertically."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2841 (interactive
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2842 (list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2843 (let* ((dummy (barf-if-buffer-read-only))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2844 (completion-ignore-case t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2845 (default (car table-cell-split-orientation-history)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2846 (intern (downcase (completing-read
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2847 (format "Split orientation (default %s): " default)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2848 '(("horizontally") ("vertically"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2849 nil t nil 'table-cell-split-orientation-history default))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2850 (unless (memq orientation '(horizontally vertically))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2851 (error "Invalid orientation %s, must be horizontally or vertically"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2852 (symbol-name orientation)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2853 (if (eq orientation 'horizontally)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2854 (table-split-cell-horizontally)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2855 (table-split-cell-vertically)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2856
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2857 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2858 (defun table-justify (what justify)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2859 "Justify contents of a cell, a row of cells or a column of cells.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2860 WHAT is a symbol 'cell, 'row or 'column. JUSTIFY is a symbol 'left,
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2861 'center, 'right, 'top, 'middle, 'bottom or 'none."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2862 (interactive
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2863 (list (let* ((dummy (barf-if-buffer-read-only))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2864 (completion-ignore-case t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2865 (default (car table-target-history)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2866 (intern (downcase (completing-read
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2867 (format "Justify what (default %s): " default)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2868 '(("cell") ("row") ("column"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2869 nil t nil 'table-target-history default))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2870 (table--query-justification)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2871 (funcall (intern (concat "table-justify-" (symbol-name what))) justify))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2872
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2873 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2874 (defun table-justify-cell (justify &optional paragraph)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2875 "Justify cell contents.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2876 JUSTIFY is a symbol 'left, 'center or 'right for horizontal, or 'top,
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2877 'middle, 'bottom or 'none for vertical. When optional PARAGRAPH is
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2878 non-nil the justify operation is limited to the current paragraph,
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2879 otherwise the entire cell contents is justified."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2880 (interactive
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2881 (list (table--query-justification)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2882 (table--finish-delayed-tasks)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2883 (table-recognize-cell 'force)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2884 (table--justify-cell-contents justify paragraph))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2885
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2886 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2887 (defun table-justify-row (justify)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2888 "Justify cells of a row.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2889 JUSTIFY is a symbol 'left, 'center or 'right for horizontal, or top,
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2890 'middle, 'bottom or 'none for vertical."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2891 (interactive
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2892 (list (table--query-justification)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2893 (let((cell-list (table--horizontal-cell-list nil nil 'top)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2894 (table--finish-delayed-tasks)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2895 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2896 (while cell-list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2897 (let ((cell (car cell-list)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2898 (setq cell-list (cdr cell-list))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2899 (goto-char (car cell))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2900 (table-recognize-cell 'force)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2901 (table--justify-cell-contents justify))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2902
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2903 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2904 (defun table-justify-column (justify)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2905 "Justify cells of a column.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2906 JUSTIFY is a symbol 'left, 'center or 'right for horizontal, or top,
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2907 'middle, 'bottom or 'none for vertical."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2908 (interactive
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2909 (list (table--query-justification)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2910 (let((cell-list (table--vertical-cell-list nil nil 'left)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2911 (table--finish-delayed-tasks)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2912 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2913 (while cell-list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2914 (let ((cell (car cell-list)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2915 (setq cell-list (cdr cell-list))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2916 (goto-char (car cell))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2917 (table-recognize-cell 'force)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2918 (table--justify-cell-contents justify))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2919
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2920 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2921 (defun table-fixed-width-mode (&optional arg)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2922 "Toggle fixing width mode.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2923 In the fixed width mode, typing inside a cell never changes the cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2924 width where in the normal mode the cell width expands automatically in
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2925 order to prevent a word being folded into multiple lines."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2926 (interactive "P")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2927 (table--finish-delayed-tasks)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2928 (setq table-fixed-width-mode
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2929 (if (null arg)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2930 (not table-fixed-width-mode)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2931 (> (prefix-numeric-value arg) 0)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2932 (table--update-cell-face))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2934 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2935 (defun table-query-dimension (&optional where)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2936 "Return the dimension of the current cell and the current table.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2937 The result is a list (cw ch tw th c r cells) where cw is the cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2938 width, ch is the cell height, tw is the table width, th is the table
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2939 height, c is the number of columns, r is the number of rows and cells
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2940 is the total number of cells. The cell dimension excludes the cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2941 frame while the table dimension includes the table frame. The columns
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2942 and the rows are counted by the number of cell boundaries. Therefore
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2943 the number tends to be larger than it appears for the tables with
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2944 non-uniform cell structure (heavily spanned and split). When optional
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2945 WHERE is provided the cell and table at that location is reported."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2946 (interactive)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2947 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2948 (if where (goto-char where))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2949 (let ((starting-cell (table--probe-cell))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2950 cell table-lu table-rb col-list row-list (cells 0))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2951 (if (null starting-cell) nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2952 (setq table-lu (car starting-cell))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2953 (setq table-rb (cdr starting-cell))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2954 (setq col-list (cons (car (table--get-coordinate (car starting-cell))) nil))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2955 (setq row-list (cons (cdr (table--get-coordinate (car starting-cell))) nil))
105372
bd2966850aac Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents: 104386
diff changeset
2956 (and (called-interactively-p 'interactive)
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2957 (message "Computing cell dimension..."))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2958 (while
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2959 (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2960 (table-forward-cell 1 t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2961 (setq cells (1+ cells))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2962 (and (setq cell (table--probe-cell))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2963 (not (equal cell starting-cell))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2964 (if (< (car cell) table-lu)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2965 (setq table-lu (car cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2966 (if (> (cdr cell) table-rb)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2967 (setq table-rb (cdr cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2968 (let ((lu-coordinate (table--get-coordinate (car cell))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2969 (if (memq (car lu-coordinate) col-list) nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2970 (setq col-list (cons (car lu-coordinate) col-list)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2971 (if (memq (cdr lu-coordinate) row-list) nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2972 (setq row-list (cons (cdr lu-coordinate) row-list)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2973 (let* ((cell-lu-coordinate (table--get-coordinate (car starting-cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2974 (cell-rb-coordinate (table--get-coordinate (cdr starting-cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2975 (table-lu-coordinate (table--get-coordinate table-lu))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2976 (table-rb-coordinate (table--get-coordinate table-rb))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2977 (cw (- (car cell-rb-coordinate) (car cell-lu-coordinate)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2978 (ch (1+ (- (cdr cell-rb-coordinate) (cdr cell-lu-coordinate))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2979 (tw (+ 2 (- (car table-rb-coordinate) (car table-lu-coordinate))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2980 (th (+ 3 (- (cdr table-rb-coordinate) (cdr table-lu-coordinate))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2981 (c (length col-list))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2982 (r (length row-list)))
105372
bd2966850aac Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents: 104386
diff changeset
2983 (and (called-interactively-p 'interactive)
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2984 (message "Cell: (%dw, %dh), Table: (%dw, %dh), Dim: (%dc, %dr), Total Cells: %d" cw ch tw th c r cells))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2985 (list cw ch tw th c r cells))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2986
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2987 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2988 (defun table-generate-source (language &optional dest-buffer caption)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2989 "Generate source of the current table in the specified language.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2990 LANGUAGE is a symbol that specifies the language to describe the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2991 structure of the table. It must be either 'html, 'latex or 'cals.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2992 The resulted source text is inserted into DEST-BUFFER and the buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2993 object is returned. When DEST-BUFFER is omitted or nil the default
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2994 buffer specified in `table-dest-buffer-name' is used. In this case
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2995 the content of the default buffer is erased prior to the generation.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2996 When DEST-BUFFER is non-nil it is expected to be either a destination
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2997 buffer or a name of the destination buffer. In this case the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2998 generated result is inserted at the current point in the destination
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2999 buffer and the previously existing contents in the buffer are
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3000 untouched.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3001
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3002 References used for this implementation:
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3003
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3004 HTML:
104029
55ba5af4bf3a Kevin Ryde <user42 at zip.com.au>
Glenn Morris <rgm@gnu.org>
parents: 103294
diff changeset
3005 URL `http://www.w3.org'
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3006
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3007 LaTeX:
104029
55ba5af4bf3a Kevin Ryde <user42 at zip.com.au>
Glenn Morris <rgm@gnu.org>
parents: 103294
diff changeset
3008 URL `http://www.maths.tcd.ie/~dwilkins/LaTeXPrimer/Tables.html'
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3009
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3010 CALS (DocBook DTD):
104029
55ba5af4bf3a Kevin Ryde <user42 at zip.com.au>
Glenn Morris <rgm@gnu.org>
parents: 103294
diff changeset
3011 URL `http://www.oasis-open.org/html/a502.htm'
55ba5af4bf3a Kevin Ryde <user42 at zip.com.au>
Glenn Morris <rgm@gnu.org>
parents: 103294
diff changeset
3012 URL `http://www.oreilly.com/catalog/docbook/chapter/book/table.html#AEN114751'
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3013 "
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3014 (interactive
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3015 (let* ((dummy (unless (table--probe-cell) (error "Table not found here")))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3016 (completion-ignore-case t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3017 (default (car table-source-language-history))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3018 (language (downcase (completing-read
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3019 (format "Language (default %s): " default)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3020 (mapcar (lambda (s) (list (symbol-name s)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3021 table-source-languages)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3022 nil t nil 'table-source-language-history default))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3023 (list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3024 (intern language)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3025 (read-buffer "Destination buffer: " (concat table-dest-buffer-name "." language))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3026 (table--read-from-minibuffer '("Table Caption" . table-source-caption-history)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3027 (let ((default-buffer-name (concat table-dest-buffer-name "." (symbol-name language))))
105372
bd2966850aac Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents: 104386
diff changeset
3028 (unless (or (called-interactively-p 'interactive) (table--probe-cell))
bd2966850aac Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents: 104386
diff changeset
3029 (error "Table not found here"))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3030 (unless (bufferp dest-buffer)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3031 (setq dest-buffer (get-buffer-create (or dest-buffer default-buffer-name))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3032 (if (string= (buffer-name dest-buffer) default-buffer-name)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3033 (with-current-buffer dest-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3034 (erase-buffer)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3035 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3036 (let ((starting-cell (table--probe-cell))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3037 cell origin-cell tail-cell col-list row-list (n 0) i)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3038 ;; first analyze the table structure and prepare:
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3039 ;; 1. origin cell (left up corner cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3040 ;; 2. tail cell (right bottom corner cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3041 ;; 3. column boundary list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3042 ;; 4. row boundary list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3043 (setq origin-cell starting-cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3044 (setq tail-cell starting-cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3045 (setq col-list (cons (car (table--get-coordinate (car starting-cell))) nil))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3046 (setq row-list (cons (cdr (table--get-coordinate (car starting-cell))) nil))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3047 (setq i 0)
49848
1bbf754d4688 (table-generate-source): Use ?\\ instead of space in "work in progress" message.
Juanma Barranquero <lekktu@gmail.com>
parents: 49599
diff changeset
3048 (let ((wheel [?- ?\\ ?| ?/]))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3049 (while
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3050 (progn
105372
bd2966850aac Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents: 104386
diff changeset
3051 (if (called-interactively-p 'interactive)
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3052 (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3053 (message "Analyzing table...%c" (aref wheel i))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3054 (if (eq (setq i (1+ i)) (length wheel))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3055 (setq i 0))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3056 (setq n (1+ n))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3057 (table-forward-cell 1 t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3058 (and (setq cell (table--probe-cell))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3059 (not (equal cell starting-cell))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3060 (if (< (car cell) (car origin-cell))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3061 (setq origin-cell cell))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3062 (if (> (cdr cell) (cdr tail-cell))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3063 (setq tail-cell cell))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3064 (let ((lu-coordinate (table--get-coordinate (car cell))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3065 (unless (memq (car lu-coordinate) col-list)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3066 (setq col-list (cons (car lu-coordinate) col-list)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3067 (unless (memq (cdr lu-coordinate) row-list)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3068 (setq row-list (cons (cdr lu-coordinate) row-list))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3069 (setq col-list (sort col-list '<))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3070 (setq row-list (sort row-list '<))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3071 (message "Generating source...")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3072 ;; clear the source generation property list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3073 (setplist 'table-source-info-plist nil)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3074 ;; prepare to start from the origin cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3075 (goto-char (car origin-cell))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3076 ;; first put some header information
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3077 (table--generate-source-prologue dest-buffer language caption col-list row-list)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3078 (cond
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3079 ((eq language 'latex)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3080 ;; scan by character lines
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3081 (table--generate-source-scan-lines dest-buffer language origin-cell tail-cell col-list row-list))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3082 (t
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3083 ;; scan by table cells
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3084 (table--generate-source-scan-rows dest-buffer language origin-cell col-list row-list)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3085 ;; insert closing
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3086 (table--generate-source-epilogue dest-buffer language col-list row-list))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3087 ;; lastly do some convenience work
105372
bd2966850aac Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents: 104386
diff changeset
3088 (if (called-interactively-p 'interactive)
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3089 (save-selected-window
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3090 (pop-to-buffer dest-buffer t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3091 (goto-char (point-min))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3092 (and (string= (buffer-name dest-buffer) default-buffer-name)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3093 (buffer-file-name dest-buffer)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3094 (save-buffer))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3095 (message "Generating source...done")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3096 (let ((mode
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3097 (if (memq language '(cals)) 'sgml-mode
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3098 (intern (concat (symbol-name language) "-mode")))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3099 (if (fboundp mode)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3100 (call-interactively mode)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3101 )))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3102 dest-buffer))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3103
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3104 (defun table--generate-source-prologue (dest-buffer language caption col-list row-list)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3105 "Generate and insert source prologue into DEST-BUFFER."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3106 (with-current-buffer dest-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3107 (cond
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3108 ((eq language 'html)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3109 (insert (format "<!-- This HTML table template is generated by emacs %s -->\n" emacs-version)
71107
c2a4cb0acf5e 2006-05-31 Takaaki Ota <Takaaki.Ota@am.sony.com>
Kim F. Storm <storm@cua.dk>
parents: 68571
diff changeset
3110 (format "<table %s>\n" table-html-table-attribute)
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3111 (if (and (stringp caption)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3112 (not (string= caption "")))
71107
c2a4cb0acf5e 2006-05-31 Takaaki Ota <Takaaki.Ota@am.sony.com>
Kim F. Storm <storm@cua.dk>
parents: 68571
diff changeset
3113 (format " <caption>%s</caption>\n" caption)
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3114 "")))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3115 ((eq language 'latex)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3116 (insert (format "%% This LaTeX table template is generated by emacs %s\n" emacs-version)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3117 "\\begin{tabular}{|" (apply 'concat (make-list (length col-list) "l|")) "}\n"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3118 "\\hline\n"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3119 ((eq language 'cals)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3120 (insert (format "<!-- This CALS table template is generated by emacs %s -->\n" emacs-version)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3121 "<table frame=\"all\">\n")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3122 (if (and (stringp caption)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3123 (not (string= caption "")))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3124 (insert " <title>" caption "</title>\n"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3125 (insert (format " <tgroup cols=\"%d\" align=\"left\" colsep=\"1\" rowsep=\"1\">\n" (length col-list)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3126 (table-put-source-info 'colspec-marker (point-marker))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3127 (table-put-source-info 'row-type (if (zerop table-cals-thead-rows) "tbody" "thead"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3128 (set-marker-insertion-type (table-get-source-info 'colspec-marker) nil) ;; insert after
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3129 (insert (format " <%s valign=\"top\">\n" (table-get-source-info 'row-type))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3130 )))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3131
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3132 (defun table--generate-source-epilogue (dest-buffer language col-list row-list)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3133 "Generate and insert source epilogue into DEST-BUFFER."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3134 (with-current-buffer dest-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3135 (cond
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3136 ((eq language 'html)
71107
c2a4cb0acf5e 2006-05-31 Takaaki Ota <Takaaki.Ota@am.sony.com>
Kim F. Storm <storm@cua.dk>
parents: 68571
diff changeset
3137 (insert "</table>\n"))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3138 ((eq language 'latex)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3139 (insert "\\end{tabular}\n"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3140 ((eq language 'cals)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3141 (set-marker-insertion-type (table-get-source-info 'colspec-marker) t) ;; insert before
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3142 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3143 (goto-char (table-get-source-info 'colspec-marker))
84927
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
3144 (mapc
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3145 (lambda (col)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3146 (insert (format " <colspec colnum=\"%d\" colname=\"c%d\"/>\n" col col)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3147 (sort (table-get-source-info 'colnum-list) '<)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3148 (insert (format " </%s>\n </tgroup>\n</table>\n" (table-get-source-info 'row-type))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3149 )))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3150
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3151 (defun table--generate-source-scan-rows (dest-buffer language origin-cell col-list row-list)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3152 "Generate and insert source rows into DEST-BUFFER."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3153 (table-put-source-info 'current-row 1)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3154 (while row-list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3155 (with-current-buffer dest-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3156 (cond
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3157 ((eq language 'html)
71107
c2a4cb0acf5e 2006-05-31 Takaaki Ota <Takaaki.Ota@am.sony.com>
Kim F. Storm <storm@cua.dk>
parents: 68571
diff changeset
3158 (insert " <tr>\n"))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3159 ((eq language 'cals)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3160 (insert " <row>\n"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3161 ))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3162 (table--generate-source-cells-in-a-row dest-buffer language col-list row-list)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3163 (with-current-buffer dest-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3164 (cond
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3165 ((eq language 'html)
71107
c2a4cb0acf5e 2006-05-31 Takaaki Ota <Takaaki.Ota@am.sony.com>
Kim F. Storm <storm@cua.dk>
parents: 68571
diff changeset
3166 (insert " </tr>\n"))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3167 ((eq language 'cals)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3168 (insert " </row>\n")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3169 (unless (/= (table-get-source-info 'current-row) table-cals-thead-rows)
49599
5ade352e8d1c Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48373
diff changeset
3170 (insert (format " </%s>\n" (table-get-source-info 'row-type)))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3171 (insert (format " <%s valign=\"top\">\n" (table-put-source-info 'row-type "tbody")))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3172 (table-put-source-info 'current-row (1+ (table-get-source-info 'current-row)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3173 (setq row-list (cdr row-list))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3174
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3175 (defun table--generate-source-cells-in-a-row (dest-buffer language col-list row-list)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3176 "Generate and insert source cells into DEST-BUFFER."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3177 (table-put-source-info 'current-column 1)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3178 (while col-list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3179 (let* ((cell (table--probe-cell))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3180 (lu (table--get-coordinate (car cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3181 (rb (table--get-coordinate (cdr cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3182 (alignment (table--get-cell-justify-property cell))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3183 (valign (table--get-cell-valign-property cell))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3184 (row-list row-list)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3185 (colspan 1)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3186 (rowspan 1))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3187 (if (< (car lu) (car col-list))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3188 (setq col-list nil)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3189 (while (and col-list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3190 (> (car lu) (car col-list)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3191 (setq col-list (cdr col-list))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3192 (table-put-source-info 'current-column (1+ (table-get-source-info 'current-column))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3193 (setq col-list (cdr col-list))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3194 (table-put-source-info 'next-column (1+ (table-get-source-info 'current-column)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3195 (while (and col-list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3196 (> (1+ (car rb)) (car col-list)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3197 (setq colspan (1+ colspan))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3198 (setq col-list (cdr col-list))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3199 (table-put-source-info 'next-column (1+ (table-get-source-info 'next-column))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3200 (setq row-list (cdr row-list))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3201 (while (and row-list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3202 (> (+ (cdr rb) 2) (car row-list)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3203 (setq rowspan (1+ rowspan))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3204 (setq row-list (cdr row-list)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3205 (with-current-buffer dest-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3206 (cond
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3207 ((eq language 'html)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3208 (insert (format " <%s"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3209 (table-put-source-info
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3210 'cell-type
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3211 (if (or (<= (table-get-source-info 'current-row) table-html-th-rows)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3212 (<= (table-get-source-info 'current-column) table-html-th-columns))
71107
c2a4cb0acf5e 2006-05-31 Takaaki Ota <Takaaki.Ota@am.sony.com>
Kim F. Storm <storm@cua.dk>
parents: 68571
diff changeset
3213 "th" "td"))))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3214 (if (and table-html-cell-attribute (not (string= table-html-cell-attribute "")))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3215 (insert " " table-html-cell-attribute))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3216 (if (> colspan 1) (insert (format " colspan=\"%d\"" colspan)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3217 (if (> rowspan 1) (insert (format " rowspan=\"%d\"" rowspan)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3218 (insert (format " align=\"%s\"" (if alignment (symbol-name alignment) "left")))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3219 (insert (format " valign=\"%s\"" (if valign (symbol-name valign) "top")))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3220 (insert ">\n"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3221 ((eq language 'cals)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3222 (insert " <entry")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3223 (if (> colspan 1)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3224 (let ((scol (table-get-source-info 'current-column))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3225 (ecol (+ (table-get-source-info 'current-column) colspan -1)))
84927
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
3226 (mapc (lambda (col)
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
3227 (unless (memq col (table-get-source-info 'colnum-list))
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
3228 (table-put-source-info 'colnum-list
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
3229 (cons col (table-get-source-info 'colnum-list)))))
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
3230 (list scol ecol))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3231 (insert (format " namest=\"c%d\" nameend=\"c%d\"" scol ecol))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3232 (if (> rowspan 1) (insert (format " morerows=\"%d\"" (1- rowspan))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3233 (if (and alignment
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3234 (not (memq alignment '(left none))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3235 (insert " align=\"" (symbol-name alignment) "\""))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3236 (if (and valign
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3237 (not (memq valign '(top none))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3238 (insert " valign=\"" (symbol-name valign) "\""))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3239 (insert ">\n"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3240 ))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3241 (table--generate-source-cell-contents dest-buffer language cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3242 (with-current-buffer dest-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3243 (cond
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3244 ((eq language 'html)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3245 (insert (format" </%s>\n" (table-get-source-info 'cell-type))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3246 ((eq language 'cals)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3247 (insert " </entry>\n"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3248 ))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3249 (table-forward-cell 1 t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3250 (table-put-source-info 'current-column (table-get-source-info 'next-column))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3251 ))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3252
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3253 (defun table--generate-source-cell-contents (dest-buffer language cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3254 "Generate and insert source cell contents of a CELL into DEST-BUFFER."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3255 (let ((cell-contents (extract-rectangle (car cell) (cdr cell))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3256 (with-temp-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3257 (table--insert-rectangle cell-contents)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3258 (table--remove-cell-properties (point-min) (point-max))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3259 (goto-char (point-min))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3260 (cond
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3261 ((eq language 'html)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3262 (if table-html-delegate-spacing-to-user-agent
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3263 (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3264 (table--remove-eol-spaces (point-min) (point-max))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3265 (if (re-search-forward "\\s +\\'" nil t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3266 (replace-match "")))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3267 (while (search-forward " " nil t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3268 (replace-match "&nbsp;"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3269 (goto-char (point-min))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3270 (while (and (re-search-forward "$" nil t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3271 (not (eobp)))
71107
c2a4cb0acf5e 2006-05-31 Takaaki Ota <Takaaki.Ota@am.sony.com>
Kim F. Storm <storm@cua.dk>
parents: 68571
diff changeset
3272 (insert "<br />")
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3273 (forward-char 1)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3274 (unless (and table-html-delegate-spacing-to-user-agent
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3275 (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3276 (goto-char (point-min))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3277 (looking-at "\\s *\\'")))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3278 ((eq language 'cals)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3279 (table--remove-eol-spaces (point-min) (point-max))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3280 (if (re-search-forward "\\s +\\'" nil t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3281 (replace-match "")))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3282 )
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3283 (setq cell-contents (buffer-substring (point-min) (point-max))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3284 (with-current-buffer dest-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3285 (let ((beg (point)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3286 (insert cell-contents)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3287 (indent-rigidly beg (point)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3288 (cond
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3289 ((eq language 'html) 6)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3290 ((eq language 'cals) 10)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3291 (insert ?\n)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3292
51496
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
3293 (defun table--cell-horizontal-char-p (c)
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
3294 "Test if character C is one of the horizontal characters"
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
3295 (memq c (string-to-list table-cell-horizontal-chars)))
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
3296
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3297 (defun table--generate-source-scan-lines (dest-buffer language origin-cell tail-cell col-list row-list)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3298 "Scan the table line by line.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3299 Currently this method is for LaTeX only."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3300 (let* ((lu-coord (table--get-coordinate (car origin-cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3301 (rb-coord (table--get-coordinate (cdr tail-cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3302 (x0 (car lu-coord))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3303 (x1 (car rb-coord))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3304 (y (cdr lu-coord))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3305 (y1 (cdr rb-coord)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3306 (while (<= y y1)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3307 (let* ((border-p (memq (1+ y) row-list))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3308 (border-char-list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3309 (mapcar (lambda (x)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3310 (if border-p (char-after (table--goto-coordinate (cons x y)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3311 (char-before (table--goto-coordinate (cons x y)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3312 col-list))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3313 start i c)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3314 (if border-p
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3315 ;; horizontal cell border processing
51496
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
3316 (if (and (table--cell-horizontal-char-p (car border-char-list))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3317 (table--uniform-list-p border-char-list))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3318 (with-current-buffer dest-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3319 (insert "\\hline\n"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3320 (setq i 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3321 (while (setq c (nth i border-char-list))
51496
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
3322 (if (and start (not (table--cell-horizontal-char-p c)))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3323 (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3324 (with-current-buffer dest-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3325 (insert (format "\\cline{%d-%d}\n" (1+ start) i)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3326 (setq start nil)))
51496
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
3327 (if (and (not start) (table--cell-horizontal-char-p c))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3328 (setq start i))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3329 (setq i (1+ i)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3330 (if start
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3331 (with-current-buffer dest-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3332 (insert (format "\\cline{%d-%d}\n" (1+ start) i)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3333 ;; horizontal cell contents processing
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3334 (let* ((span 1) ;; spanning length
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3335 (first-p t) ;; first in a row
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3336 (insert-column ;; a function that processes one column/multicolumn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3337 (function
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3338 (lambda (from to)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3339 (let ((line (table--buffer-substring-and-trim
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3340 (table--goto-coordinate (cons from y))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3341 (table--goto-coordinate (cons to y)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3342 ;; escape special characters
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3343 (with-temp-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3344 (insert line)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3345 (goto-char (point-min))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3346 (while (re-search-forward "\\([#$~_^%{}]\\)\\|\\(\\\\\\)\\|\\([<>|]\\)" nil t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3347 (if (match-beginning 1)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3348 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3349 (goto-char (match-beginning 1))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3350 (insert "\\"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3351 (if (match-beginning 2)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3352 (replace-match "$\\backslash$" t t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3353 (replace-match (concat "$" (match-string 3) "$")) t t)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3354 (setq line (buffer-substring (point-min) (point-max))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3355 ;; insert a column separator and column/multicolumn contents
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3356 (with-current-buffer dest-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3357 (unless first-p
64059
77cc3a2cedb3 (table-hooks): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents: 63227
diff changeset
3358 (insert (if (eq (char-before) ?\s) "" " ") "& "))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3359 (if (> span 1)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3360 (insert (format "\\multicolumn{%d}{%sl|}{%s}" span (if first-p "|" "") line))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3361 (insert line)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3362 (setq first-p nil)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3363 (setq span 1)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3364 (setq start (nth i col-list)))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3365 (setq start x0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3366 (setq i 1)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3367 (while (setq c (nth i border-char-list))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3368 (if (eq c table-cell-vertical-char)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3369 (funcall insert-column start (1- (nth i col-list)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3370 (setq span (1+ span)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3371 (setq i (1+ i)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3372 (funcall insert-column start x1))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3373 (with-current-buffer dest-buffer
64059
77cc3a2cedb3 (table-hooks): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents: 63227
diff changeset
3374 (insert (if (eq (char-before) ?\s) "" " ") "\\\\\n"))))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3375 (setq y (1+ y)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3376 (with-current-buffer dest-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3377 (insert "\\hline\n"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3378 ))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3379
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3380 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3381 (defun table-insert-sequence (str n increment interval justify)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3382 "Travel cells forward while inserting a specified sequence string in each cell.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3383 STR is the base string from which the sequence starts. When STR is an
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3384 empty string then each cell content is erased. When STR ends with
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3385 numerical characters (they may optionally be surrounded by a pair of
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3386 parentheses) they are incremented as a decimal number. Otherwise the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3387 last character in STR is incremented in ASCII code order. N is the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3388 number of sequence elements to insert. When N is negative the cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3389 traveling direction is backward. When N is zero it travels forward
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3390 entire table. INCREMENT is the increment between adjacent sequence
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3391 elements and can be a negative number for effectively decrementing.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3392 INTERVAL is the number of cells to travel between sequence element
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3393 insertion which is normally 1. When zero or less is given for
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3394 INTERVAL it is interpreted as number of cells per row so that sequence
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3395 is placed straight down vertically as long as the table's cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3396 structure is uniform. JUSTIFY is one of the symbol 'left, 'center or
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3397 'right, that specifies justification of the inserted string.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3398
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3399 Example:
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3400
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3401 (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3402 (table-insert 16 3 5 1)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3403 (table-forward-cell 15)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3404 (table-insert-sequence \"D0\" -16 1 1 'center)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3405 (table-forward-cell 16)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3406 (table-insert-sequence \"A[0]\" -16 1 1 'center)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3407 (table-forward-cell 1)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3408 (table-insert-sequence \"-\" 16 0 1 'center))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3409
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3410 (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3411 (table-insert 16 8 5 1)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3412 (table-insert-sequence \"@\" 0 1 2 'right)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3413 (table-forward-cell 1)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3414 (table-insert-sequence \"64\" 0 1 2 'left))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3415 "
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3416 (interactive
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3417 (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3418 (barf-if-buffer-read-only)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3419 (unless (table--probe-cell) (error "Table not found here"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3420 (list (read-from-minibuffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3421 "Sequence base string: " (car table-sequence-string-history) nil nil 'table-sequence-string-history)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3422 (string-to-number
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3423 (table--read-from-minibuffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3424 '("How many elements (0: maximum, negative: backward traveling)" . table-sequence-count-history)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3425 (string-to-number
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3426 (table--read-from-minibuffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3427 '("Increment element by" . table-sequence-increment-history)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3428 (string-to-number
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3429 (table--read-from-minibuffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3430 '("Cell interval (0: vertical, 1:horizontal)" . table-sequence-interval-history)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3431 (let* ((completion-ignore-case t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3432 (default (car table-sequence-justify-history)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3433 (intern (downcase (completing-read
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3434 (format "Justify (default %s): " default)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3435 '(("left") ("center") ("right"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3436 nil t nil 'table-sequence-justify-history default)))))))
105372
bd2966850aac Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents: 104386
diff changeset
3437 (unless (or (called-interactively-p 'interactive) (table--probe-cell))
bd2966850aac Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents: 104386
diff changeset
3438 (error "Table not found here"))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3439 (string-match "\\([0-9]*\\)\\([]})>]*\\)\\'" str)
105372
bd2966850aac Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents: 104386
diff changeset
3440 (if (called-interactively-p 'interactive)
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3441 (message "Sequencing..."))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3442 (let* ((prefix (substring str 0 (match-beginning 1)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3443 (index (match-string 1 str))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3444 (fmt (format "%%%s%dd" (if (eq (string-to-char index) ?0) "0" "") (length index)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3445 (postfix (match-string 2 str))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3446 (dim (table-query-dimension))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3447 (cells (nth 6 dim))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3448 (direction (if (< n 0) -1 1))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3449 (interval-count 0))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3450 (if (string= index "")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3451 (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3452 (setq index nil)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3453 (if (string= prefix "")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3454 (setq prefix nil)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3455 (setq index (string-to-number index)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3456 (if (< n 0) (setq n (- n)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3457 (if (or (zerop n) (> n cells)) (setq n cells))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3458 (if (< interval 0) (setq interval (- interval)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3459 (if (zerop interval) (setq interval (nth 4 dim)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3460 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3461 (while (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3462 (if (> interval-count 0) nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3463 (setq interval-count interval)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3464 (table-with-cache-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3465 (goto-char (point-min))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3466 (if (not (or prefix index))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3467 (erase-buffer)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3468 (insert prefix)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3469 (if index (insert (format fmt index)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3470 (insert postfix)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3471 (table--fill-region (point-min) (point) table-cell-info-width justify)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3472 (setq table-cell-info-justify justify))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3473 (setq table-inhibit-auto-fill-paragraph t))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3474 (table--update-cell 'now)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3475 (if index
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3476 (setq index (+ index increment))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3477 (if (and prefix (string= postfix ""))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3478 (let ((len-1 (1- (length prefix))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3479 (setq prefix (concat (substring prefix 0 len-1)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3480 (char-to-string
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3481 (+ (string-to-char (substring prefix len-1)) increment)))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3482 (setq n (1- n)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3483 (table-forward-cell direction t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3484 (setq interval-count (1- interval-count))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3485 (setq cells (1- cells))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3486 (and (> n 0) (> cells 0)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3487 (table-recognize-cell 'force)
105372
bd2966850aac Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents: 104386
diff changeset
3488 (if (called-interactively-p 'interactive)
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3489 (message "Sequencing...done"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3490 ))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3491
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3492 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3493 (defun table-delete-row (n)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3494 "Delete N row(s) of cells.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3495 Delete N rows of cells from current row. The current row is the row
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3496 contains the current cell where point is located. Each row must
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3497 consists from cells of same height."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3498 (interactive "*p")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3499 (let ((orig-coord (table--get-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3500 (bt-coord (table--get-coordinate (cdr (table--vertical-cell-list nil 'first-only))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3501 lu-coord rb-coord rect)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3502 ;; determine the area to delete while testing row height uniformity
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3503 (while (> n 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3504 (setq n (1- n))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3505 (unless (table--probe-cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3506 (error "Table not found"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3507 (let ((cell-list (table--horizontal-cell-list 'left-to-right)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3508 (unless
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3509 (and (table--uniform-list-p
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3510 (mapcar (lambda (cell) (cdr (table--get-coordinate (car cell)))) cell-list))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3511 (table--uniform-list-p
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3512 (mapcar (lambda (cell) (cdr (table--get-coordinate (cdr cell)))) cell-list)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3513 (error "Cells in this row are not in uniform height"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3514 (unless lu-coord
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3515 (setq lu-coord (table--get-coordinate (caar cell-list))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3516 (setq rb-coord (table--get-coordinate (cdar (last cell-list))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3517 (table--goto-coordinate (cons (car orig-coord) (+ 2 (cdr rb-coord))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3518 ;; copy the remaining area (below the deleting area)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3519 (setq rect (extract-rectangle
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3520 (table--goto-coordinate (cons (1- (car lu-coord)) (1+ (cdr rb-coord))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3521 (table--goto-coordinate (cons (1+ (car rb-coord)) (1+ (cdr bt-coord))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3522 ;; delete the deleting area and below together
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3523 (delete-rectangle
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3524 (table--goto-coordinate (cons (1- (car lu-coord)) (1- (cdr lu-coord))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3525 (table--goto-coordinate (cons (1+ (car rb-coord)) (1+ (cdr bt-coord)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3526 (table--goto-coordinate (cons (1- (car lu-coord)) (1- (cdr lu-coord))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3527 ;; insert the remaining area while appending blank lines below it
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3528 (table--insert-rectangle
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3529 (append rect (make-list (+ 2 (- (cdr rb-coord) (cdr lu-coord)))
64059
77cc3a2cedb3 (table-hooks): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents: 63227
diff changeset
3530 (make-string (+ 2 (- (car rb-coord) (car lu-coord))) ?\s))))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3531 ;; remove the appended blank lines below the table if they are unnecessary
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3532 (table--goto-coordinate (cons 0 (- (cdr bt-coord) (- (cdr rb-coord) (cdr lu-coord)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3533 (table--remove-blank-lines (+ 2 (- (cdr rb-coord) (cdr lu-coord))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3534 ;; fix up intersections
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3535 (let ((coord (cons (car lu-coord) (1- (cdr lu-coord))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3536 (n (1+ (- (car rb-coord) (car lu-coord)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3537 (while (> n 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3538 (table--goto-coordinate coord)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3539 (if (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3540 (or (and (table--goto-coordinate (cons (car coord) (1- (cdr coord))) 'no-extension)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3541 (looking-at (regexp-quote (char-to-string table-cell-vertical-char))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3542 (and (table--goto-coordinate (cons (car coord) (1+ (cdr coord))) 'no-extension)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3543 (looking-at (regexp-quote (char-to-string table-cell-vertical-char))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3544 (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3545 (delete-char 1)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3546 (insert table-cell-intersection-char))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3547 (delete-char 1)
51496
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
3548 (insert (string-to-char table-cell-horizontal-chars)))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3549 (setq n (1- n))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3550 (setcar coord (1+ (car coord)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3551 ;; goto appropriate end point
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3552 (table--goto-coordinate (cons (car orig-coord) (cdr lu-coord)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3553
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3554 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3555 (defun table-delete-column (n)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3556 "Delete N column(s) of cells.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3557 Delete N columns of cells from current column. The current column is
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3558 the column contains the current cell where point is located. Each
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3559 column must consists from cells of same width."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3560 (interactive "*p")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3561 (let ((orig-coord (table--get-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3562 lu-coord rb-coord)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3563 ;; determine the area to delete while testing column width uniformity
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3564 (while (> n 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3565 (setq n (1- n))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3566 (unless (table--probe-cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3567 (error "Table not found"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3568 (let ((cell-list (table--vertical-cell-list 'top-to-bottom)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3569 (unless
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3570 (and (table--uniform-list-p
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3571 (mapcar (function (lambda (cell) (car (table--get-coordinate (car cell))))) cell-list))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3572 (table--uniform-list-p
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3573 (mapcar (function (lambda (cell) (car (table--get-coordinate (cdr cell))))) cell-list)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3574 (error "Cells in this column are not in uniform width"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3575 (unless lu-coord
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3576 (setq lu-coord (table--get-coordinate (caar cell-list))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3577 (setq rb-coord (table--get-coordinate (cdar (last cell-list))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3578 (table--goto-coordinate (cons (1+ (car rb-coord)) (cdr orig-coord)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3579 ;; delete the area
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3580 (delete-rectangle
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3581 (table--goto-coordinate (cons (car lu-coord) (1- (cdr lu-coord))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3582 (table--goto-coordinate (cons (1+ (car rb-coord)) (1+ (cdr rb-coord)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3583 ;; fix up the intersections
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3584 (let ((coord (cons (1- (car lu-coord)) (cdr lu-coord)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3585 (n (1+ (- (cdr rb-coord) (cdr lu-coord)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3586 (while (> n 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3587 (table--goto-coordinate coord)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3588 (if (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3589 (or (and (table--goto-coordinate (cons (1- (car coord)) (cdr coord)) 'no-extension)
51496
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
3590 (looking-at (regexp-opt-charset
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
3591 (string-to-list table-cell-horizontal-chars))))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3592 (and (table--goto-coordinate (cons (1+ (car coord)) (cdr coord)) 'no-extension)
51496
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
3593 (looking-at (regexp-opt-charset
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
3594 (string-to-list table-cell-horizontal-chars))))))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3595 (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3596 (delete-char 1)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3597 (insert table-cell-intersection-char))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3598 (delete-char 1)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3599 (insert table-cell-vertical-char))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3600 (setq n (1- n))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3601 (setcdr coord (1+ (cdr coord)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3602 ;; goto appropriate end point
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3603 (table--goto-coordinate (cons (car lu-coord) (cdr orig-coord)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3604
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3605 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3606 (defun table-capture (beg end &optional col-delim-regexp row-delim-regexp justify min-cell-width columns)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3607 "Convert plain text into a table by capturing the text in the region.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3608 Create a table with the text in region as cell contents. BEG and END
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3609 specify the region. The text in the region is replaced with a table.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3610 The removed text is inserted in the table. When optional
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3611 COL-DELIM-REGEXP and ROW-DELIM-REGEXP are provided the region contents
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3612 is parsed and separated into individual cell contents by using the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3613 delimiter regular expressions. This parsing determines the number of
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3614 columns and rows of the table automatically. If COL-DELIM-REGEXP and
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3615 ROW-DELIM-REGEXP are omitted the result table has only one cell and
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3616 the entire region contents is placed in that cell. Optional JUSTIFY
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3617 is one of 'left, 'center or 'right, which specifies the cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3618 justification. Optional MIN-CELL-WIDTH specifies the minimum cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3619 width. Optional COLUMNS specify the number of columns when
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3620 ROW-DELIM-REGEXP is not specified.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3621
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3622
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3623 Example 1:
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3624
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3625 1, 2, 3, 4
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3626 5, 6, 7, 8
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3627 , 9, 10
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3628
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3629 Running `table-capture' on above 3 line region with COL-DELIM-REGEXP
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3630 \",\" and ROW-DELIM-REGEXP \"\\n\" creates the following table. In
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3631 this example the cells are centered and minimum cell width is
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3632 specified as 5.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3633
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3634 +-----+-----+-----+-----+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3635 | 1 | 2 | 3 | 4 |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3636 +-----+-----+-----+-----+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3637 | 5 | 6 | 7 | 8 |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3638 +-----+-----+-----+-----+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3639 | | 9 | 10 | |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3640 +-----+-----+-----+-----+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3641
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3642 Note:
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3643
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3644 In case the function is called interactively user must use \\[quoted-insert] `quoted-insert'
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3645 in order to enter \"\\n\" successfully. COL-DELIM-REGEXP at the end
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3646 of each row is optional.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3647
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3648
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3649 Example 2:
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3650
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3651 This example shows how a table can be used for text layout editing.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3652 Let `table-capture' capture the following region starting from
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3653 -!- and ending at -*-, that contains three paragraphs and two item
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3654 name headers. This time specify empty string for both
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3655 COL-DELIM-REGEXP and ROW-DELIM-REGEXP.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3656
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3657 -!-`table-capture' is a powerful command however mastering its power
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3658 requires some practice. Here is a list of items what it can do.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3659
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3660 Parse Cell Items By using column delimiter regular
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3661 expression and raw delimiter regular
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3662 expression, it parses the specified text
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3663 area and extracts cell items from
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3664 non-table text and then forms a table out
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3665 of them.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3666
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3667 Capture Text Area When no delimiters are specified it
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3668 creates a single cell table. The text in
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3669 the specified region is placed in that
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3670 cell.-*-
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3671
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3672 Now the entire content is captured in a cell which is itself a table
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3673 like this.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3674
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3675 +-----------------------------------------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3676 |`table-capture' is a powerful command however mastering its power|
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3677 |requires some practice. Here is a list of items what it can do. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3678 | |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3679 |Parse Cell Items By using column delimiter regular |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3680 | expression and raw delimiter regular |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3681 | expression, it parses the specified text |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3682 | area and extracts cell items from |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3683 | non-table text and then forms a table out |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3684 | of them. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3685 | |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3686 |Capture Text Area When no delimiters are specified it |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3687 | creates a single cell table. The text in |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3688 | the specified region is placed in that |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3689 | cell. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3690 +-----------------------------------------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3691
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3692 By splitting the cell appropriately we now have a table consisting of
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3693 paragraphs occupying its own cell. Each cell can now be edited
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3694 independently.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3695
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3696 +-----------------------------------------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3697 |`table-capture' is a powerful command however mastering its power|
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3698 |requires some practice. Here is a list of items what it can do. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3699 +---------------------+-------------------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3700 |Parse Cell Items |By using column delimiter regular |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3701 | |expression and raw delimiter regular |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3702 | |expression, it parses the specified text |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3703 | |area and extracts cell items from |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3704 | |non-table text and then forms a table out |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3705 | |of them. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3706 +---------------------+-------------------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3707 |Capture Text Area |When no delimiters are specified it |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3708 | |creates a single cell table. The text in |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3709 | |the specified region is placed in that |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3710 | |cell. |
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3711 +---------------------+-------------------------------------------+
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3712
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3713 By applying `table-release', which does the opposite process, the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3714 contents become once again plain text. `table-release' works as
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3715 companion command to `table-capture' this way.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3716 "
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3717 (interactive
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3718 (let ((col-delim-regexp)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3719 (row-delim-regexp))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3720 (barf-if-buffer-read-only)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3721 (if (table--probe-cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3722 (error "Can't insert a table inside a table"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3723 (list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3724 (mark) (point)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3725 (setq col-delim-regexp
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3726 (read-from-minibuffer "Column delimiter regexp: "
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3727 (car table-col-delim-regexp-history) nil nil 'table-col-delim-regexp-history))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3728 (setq row-delim-regexp
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3729 (read-from-minibuffer "Row delimiter regexp: "
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3730 (car table-row-delim-regexp-history) nil nil 'table-row-delim-regexp-history))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3731 (let* ((completion-ignore-case t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3732 (default (car table-capture-justify-history)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3733 (if (and (string= col-delim-regexp "") (string= row-delim-regexp "")) 'left
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3734 (intern
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3735 (downcase (completing-read
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3736 (format "Justify (default %s): " default)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3737 '(("left") ("center") ("right"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3738 nil t nil 'table-capture-justify-history default)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3739 (if (and (string= col-delim-regexp "") (string= row-delim-regexp "")) "1"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3740 (table--read-from-minibuffer '("Minimum cell width" . table-capture-min-cell-width-history)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3741 (if (and (not (string= col-delim-regexp "")) (string= row-delim-regexp ""))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3742 (string-to-number
100782
357f161c8821 (table-capture): Fix symbol quoting typo.
Chong Yidong <cyd@stupidchicken.com>
parents: 94670
diff changeset
3743 (table--read-from-minibuffer '("Number of columns" . table-capture-columns-history)))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3744 nil)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3745 )))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3746 (if (> beg end) (let ((tmp beg)) (setq beg end) (setq end tmp)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3747 (if (string= col-delim-regexp "") (setq col-delim-regexp nil))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3748 (if (string= row-delim-regexp "") (setq row-delim-regexp nil))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3749 (if (and columns (< columns 1)) (setq columns nil))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3750 (unless min-cell-width (setq min-cell-width "5"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3751 (let ((contents (buffer-substring beg end))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3752 (cols 0) (rows 0) c r cell-list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3753 (delim-pattern
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3754 (if (and col-delim-regexp row-delim-regexp)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3755 (format "\\(\\(%s\\)?\\s *\\(%s\\)\\s *\\)\\|\\(\\(%s\\)\\s *\\)"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3756 col-delim-regexp row-delim-regexp col-delim-regexp)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3757 (if col-delim-regexp
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3758 (format "\\(\\)\\(\\)\\(\\)\\(\\(%s\\)\\s *\\)" col-delim-regexp))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3759 (contents-list))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3760 ;; when delimiters are specified extract cells and determine the cell dimension
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3761 (if delim-pattern
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3762 (with-temp-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3763 (insert contents)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3764 ;; make sure the contents ends with a newline
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3765 (goto-char (point-max))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3766 (unless (zerop (current-column))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3767 (insert ?\n))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3768 ;; skip the preceding white spaces
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3769 (goto-char (point-min))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3770 (if (looking-at "\\s +")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3771 (goto-char (match-end 0)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3772 ;; extract cell contents
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3773 (let ((from (point)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3774 (setq cell-list nil)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3775 (setq c 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3776 (while (and (re-search-forward delim-pattern nil t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3777 (cond
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3778 ;; row delimiter
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3779 ((and (match-string 1) (not (string= (match-string 1) "")))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3780 (setq rows (1+ rows))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3781 (setq cell-list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3782 (append cell-list (list (buffer-substring from (match-beginning 1)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3783 (setq from (match-end 1))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3784 (setq contents-list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3785 (append contents-list (list cell-list)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3786 (setq cell-list nil)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3787 (setq c (1+ c))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3788 (if (> c cols) (setq cols c))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3789 (setq c 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3790 t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3791 ;; column delimiter
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3792 ((and (match-string 4) (not (string= (match-string 4) "")))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3793 (setq cell-list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3794 (append cell-list (list (buffer-substring from (match-beginning 4)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3795 (setq from (match-end 4))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3796 (setq c (1+ c))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3797 (if (> c cols) (setq cols c))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3798 t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3799 (t nil))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3800 ;; take care of the last element without a post delimiter
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3801 (unless (null (looking-at ".+$"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3802 (setq cell-list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3803 (append cell-list (list (match-string 0))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3804 (setq cols (1+ cols)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3805 ;; take care of the last row without a terminating delimiter
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3806 (unless (null cell-list)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3807 (setq rows (1+ rows))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3808 (setq contents-list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3809 (append contents-list (list cell-list)))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3810 ;; finalize the table dimension
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3811 (if (and columns contents-list)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3812 ;; when number of columns are specified and cells are parsed determine the dimension
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3813 (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3814 (setq cols columns)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3815 (setq rows (/ (+ (length (car contents-list)) columns -1) columns)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3816 ;; when dimensions are not specified default to a single cell table
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3817 (if (zerop rows) (setq rows 1))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3818 (if (zerop cols) (setq cols 1)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3819 ;; delete the region and reform line breaks
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3820 (delete-region beg end)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3821 (goto-char beg)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3822 (unless (zerop (current-column))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3823 (insert ?\n))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3824 (unless (looking-at "\\s *$")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3825 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3826 (insert ?\n)))
49599
5ade352e8d1c Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48373
diff changeset
3827 ;; insert the table
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3828 ;; insert the cell contents
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3829 (if (null contents-list)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3830 ;; single cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3831 (let ((width) (height))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3832 (with-temp-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3833 (insert contents)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3834 (table--remove-eol-spaces (point-min) (point-max))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3835 (table--untabify (point-min) (point-max))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3836 (setq width (table--measure-max-width))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3837 (setq height (1+ (table--current-line (point-max))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3838 (setq contents (buffer-substring (point-min) (point-max))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3839 (table-insert cols rows width height)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3840 (table-with-cache-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3841 (insert contents)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3842 (setq table-inhibit-auto-fill-paragraph t)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3843 ;; multi cells
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3844 (table-insert cols rows min-cell-width 1)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3845 (setq r 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3846 (setq cell-list nil)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3847 (while (< r rows)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3848 (setq r (1+ r))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3849 (setq c 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3850 (unless cell-list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3851 (setq cell-list (car contents-list))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3852 (setq contents-list (cdr contents-list)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3853 (while (< c cols)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3854 (setq c (1+ c))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3855 (if (car cell-list)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3856 (table-with-cache-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3857 (insert (car cell-list))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3858 (setq cell-list (cdr cell-list))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3859 (setq table-cell-info-justify justify)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3860 (table-forward-cell 1))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3861
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3862 ;;;###autoload
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3863 (defun table-release ()
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3864 "Convert a table into plain text by removing the frame from a table.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3865 Remove the frame from a table and inactivate the table. This command
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3866 converts a table into plain text without frames. It is a companion to
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3867 `table-capture' which does the opposite process."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3868 (interactive)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3869 (let ((origin-cell (table--probe-cell))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3870 table-lu table-rb)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3871 (if origin-cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3872 (let ((old-point (point-marker)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3873 ;; save-excursion is not sufficient for this
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3874 ;; because untabify operation moves point
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3875 (set-marker-insertion-type old-point t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3876 (unwind-protect
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3877 (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3878 (while
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3879 (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3880 (table-forward-cell 1 nil 'unrecognize)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3881 (let ((cell (table--probe-cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3882 (if (or (null table-lu)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3883 (< (car cell) table-lu))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3884 (setq table-lu (car cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3885 (if (or (null table-rb)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3886 (> (cdr cell) table-rb))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3887 (setq table-rb (cdr cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3888 (and cell (not (equal cell origin-cell))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3889 (let* ((lu-coord (table--get-coordinate table-lu))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3890 (rb-coord (table--get-coordinate table-rb))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3891 (lu (table--goto-coordinate (table--offset-coordinate lu-coord '(-1 . -1)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3892 (table--spacify-frame)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3893 (setcdr rb-coord (1+ (cdr rb-coord)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3894 (delete-rectangle lu (table--goto-coordinate (cons (car lu-coord) (cdr rb-coord))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3895 (table--remove-eol-spaces
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3896 (table--goto-coordinate (cons 0 (1- (cdr lu-coord))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3897 (table--goto-coordinate rb-coord) nil t)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3898 (goto-char old-point))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3899
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3900 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3901 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3902 ;; Worker functions (executed implicitly)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3903 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3904
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3905 (defun table--make-cell-map ()
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3906 "Make the table cell keymap if it does not exist yet."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3907 ;; this is irrelevant to keymap but good place to make sure to be executed
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3908 (table--update-cell-face)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3909 (unless table-cell-map
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3910 (let ((map (make-sparse-keymap))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3911 (remap-alist table-command-remap-alist))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3912 ;; table-command-prefix mode specific bindings
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3913 (if (vectorp table-command-prefix)
84927
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
3914 (mapc (lambda (binding)
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
3915 (let ((seq (copy-sequence (car binding))))
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
3916 (and (vectorp seq)
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
3917 (listp (aref seq 0))
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
3918 (eq (car (aref seq 0)) 'control)
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
3919 (progn
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
3920 (aset seq 0 (cadr (aref seq 0)))
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
3921 (define-key map (vconcat table-command-prefix seq) (cdr binding))))))
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
3922 table-cell-bindings))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3923 ;; shorthand control bindings
84927
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
3924 (mapc (lambda (binding)
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
3925 (define-key map (car binding) (cdr binding)))
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
3926 table-cell-bindings)
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3927 ;; remap normal commands to table specific version
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3928 (while remap-alist
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3929 (define-key map (vector 'remap (caar remap-alist)) (cdar remap-alist))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3930 (setq remap-alist (cdr remap-alist)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3931 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3932 (setq table-cell-map map)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3933 (fset 'table-cell-map map)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3934 ;; add menu for table cells
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3935 (unless table-disable-menu
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3936 (easy-menu-define table-cell-menu-map table-cell-map "Table cell menu" table-cell-menu)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3937 (if (featurep 'xemacs)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3938 (easy-menu-add table-cell-menu)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3939 (run-hooks 'table-cell-map-hook))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3940
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3941 ;; Create the keymap after running the user init file so that the user
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3942 ;; modification to the global-map is accounted.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3943 (add-hook 'after-init-hook 'table--make-cell-map t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3944
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3945 (defun *table--cell-self-insert-command ()
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3946 "Table cell version of `self-insert-command'."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3947 (interactive "*")
103294
299eb8fbcd49 * textmodes/table.el (table--unibyte-char-to-multibyte): Function
Chong Yidong <cyd@stupidchicken.com>
parents: 101003
diff changeset
3948 (let ((char last-command-event))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3949 (if (eq buffer-undo-list t) nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3950 (if (not (eq last-command this-command))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3951 (setq table-cell-self-insert-command-count 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3952 (if (car buffer-undo-list) nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3953 (if (>= table-cell-self-insert-command-count 19)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3954 (setq table-cell-self-insert-command-count 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3955 (setq buffer-undo-list (cdr buffer-undo-list))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3956 (setq table-cell-self-insert-command-count (1+ table-cell-self-insert-command-count))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3957 (table--cell-insert-char char overwrite-mode)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3958
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3959 (defun *table--cell-delete-backward-char (n)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3960 "Table cell version of `delete-backward-char'."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3961 (interactive "*p")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3962 (*table--cell-delete-char (- n)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3963
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3964 (defun *table--cell-newline (&optional indent)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3965 "Table cell version of `newline'."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3966 (interactive "*")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3967 (table-with-cache-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3968 (let ((column (current-column)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3969 (insert ?\n)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3970 (if indent (indent-to-column column))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3971 ;; fill only when at the beginning of paragraph
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3972 (if (= (point)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3973 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3974 (forward-paragraph -1)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3975 (if (looking-at "\\s *$")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3976 (forward-line 1))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3977 (point)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3978 nil ; yes, at the beginning of the paragraph
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3979 (setq table-inhibit-auto-fill-paragraph t)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3980
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3981 (defun *table--cell-open-line (n)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3982 "Table cell version of `open-line'."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3983 (interactive "*p")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3984 (table-with-cache-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3985 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3986 (insert (make-string n ?\n))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3987 (table--fill-region (point) (point))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3988 (setq table-inhibit-auto-fill-paragraph t))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3989
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3990 (defun *table--cell-newline-and-indent ()
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3991 "Table cell version of `newline-and-indent'."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3992 (interactive)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3993 (*table--cell-newline t))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3994
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3995 (defun *table--cell-delete-char (n)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3996 "Table cell version of `delete-char'."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3997 (interactive "*p")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3998 (let ((overwrite overwrite-mode))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3999 (table-with-cache-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4000 (if (and overwrite (< n 0))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4001 (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4002 (while (not (zerop n))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4003 (let ((coordinate (table--get-coordinate)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4004 (if (zerop (car coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4005 (unless (zerop (cdr coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4006 (table--goto-coordinate (cons (1- table-cell-info-width) (1- (cdr coordinate))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4007 (unless (eolp)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4008 (delete-char 1)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4009 (delete-char -1)
64059
77cc3a2cedb3 (table-hooks): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents: 63227
diff changeset
4010 (insert ?\s)
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4011 (forward-char -1)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4012 (setq n (1+ n)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4013 (setq table-inhibit-auto-fill-paragraph t))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4014 (let ((coordinate (table--get-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4015 (end-marker (copy-marker (+ (point) n)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4016 (deleted))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4017 (if (or (< end-marker (point-min))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4018 (> end-marker (point-max))) nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4019 (table--remove-eol-spaces (point-min) (point-max))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4020 (setq deleted (buffer-substring (point) end-marker))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4021 (delete-char n)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4022 ;; in fixed width mode when two lines are concatenated
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4023 ;; remove continuation character if there is one.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4024 (and table-fixed-width-mode
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4025 (string-match "^\n" deleted)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4026 (equal (char-before) table-word-continuation-char)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4027 (delete-char -2))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4028 ;; see if the point is placed at the right tip of the previous
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4029 ;; blank line, if so get rid of the preceding blanks.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4030 (if (and (not (bolp))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4031 (/= (cdr coordinate) (cdr (table--get-coordinate)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4032 (let ((end (point)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4033 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4034 (beginning-of-line)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4035 (re-search-forward "\\s +" end t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4036 (= (point) end))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4037 (replace-match ""))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4038 ;; do not fill the paragraph if the point is already at the end
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4039 ;; of this paragraph and is following a blank character
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4040 ;; (otherwise the filling squeezes the preceding blanks)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4041 (if (and (looking-at "\\s *$")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4042 (or (bobp)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4043 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4044 (backward-char)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4045 (looking-at "\\s "))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4046 (setq table-inhibit-auto-fill-paragraph t))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4047 )
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4048 (set-marker end-marker nil))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4049
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4050 (defun *table--cell-quoted-insert (arg)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4051 "Table cell version of `quoted-insert'."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4052 (interactive "*p")
103294
299eb8fbcd49 * textmodes/table.el (table--unibyte-char-to-multibyte): Function
Chong Yidong <cyd@stupidchicken.com>
parents: 101003
diff changeset
4053 (let ((char (read-quoted-char)))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4054 (while (> arg 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4055 (table--cell-insert-char char nil)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4056 (setq arg (1- arg)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4057
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4058 (defun *table--cell-describe-mode ()
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4059 "Table cell version of `describe-mode'."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4060 (interactive)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4061 (if (not (table--point-in-cell-p))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4062 (call-interactively 'describe-mode)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4063 (with-output-to-temp-buffer "*Help*"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4064 (princ "Table mode: (in ")
87567
4c3c683cdff8 * erc-ibuffer.el (erc-channel-modes):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 84927
diff changeset
4065 (princ (format-mode-line mode-name nil nil (current-buffer)))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4066 (princ " mode)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4067
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4068 Table is not a mode technically. You can regard it as a pseudo mode
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4069 which exists locally within a buffer. It overrides some standard
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4070 editing behaviors. Editing operations in a table produces confined
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4071 effects to the current cell. It may grow the cell horizontally and/or
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4072 vertically depending on the newly entered or deleted contents of the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4073 cell, and also depending on the current mode of cell.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4074
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4075 In the normal mode the table preserves word continuity. Which means
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4076 that a word never gets folded into multiple lines. For this purpose
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4077 table will occasionally grow the cell width. On the other hand, when
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4078 in a fixed width mode all cell width are fixed. When a word can not
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4079 fit in the cell width the word is folded into the next line. The
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4080 folded location is marked by a continuation character which is
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4081 specified in the variable `table-word-continuation-char'.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4082 ")
104386
2e0765155e47 Use help-print-return-message rather than the now obsolete alias.
Glenn Morris <rgm@gnu.org>
parents: 104029
diff changeset
4083 (help-print-return-message))))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4084
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4085 (defun *table--cell-describe-bindings ()
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4086 "Table cell version of `describe-bindings'."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4087 (interactive)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4088 (if (not (table--point-in-cell-p))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4089 (call-interactively 'describe-bindings)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4090 (with-output-to-temp-buffer "*Help*"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4091 (princ "Table Bindings:
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4092 key binding
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4093 --- -------
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4094
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4095 ")
84927
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
4096 (mapc (lambda (binding)
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
4097 (princ (format "%-16s%s\n"
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
4098 (key-description (car binding))
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
4099 (cdr binding))))
40125c532944 (table--generate-source-epilogue, table-insert,
Juanma Barranquero <lekktu@gmail.com>
parents: 78225
diff changeset
4100 table-cell-bindings)
104386
2e0765155e47 Use help-print-return-message rather than the now obsolete alias.
Glenn Morris <rgm@gnu.org>
parents: 104029
diff changeset
4101 (help-print-return-message))))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4102
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4103 (defun *table--cell-dabbrev-expand (arg)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4104 "Table cell version of `dabbrev-expand'."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4105 (interactive "*P")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4106 (let ((dabbrev-abbrev-char-regexp (concat "[^"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4107 (char-to-string table-cell-vertical-char)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4108 (char-to-string table-cell-intersection-char)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4109 " \n]")))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4110 (table-with-cache-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4111 (dabbrev-expand arg))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4112
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4113 (defun *table--cell-dabbrev-completion (&optional arg)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4114 "Table cell version of `dabbrev-completion'."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4115 (interactive "*P")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4116 (error "`dabbrev-completion' is incompatible with table")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4117 (let ((dabbrev-abbrev-char-regexp (concat "[^"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4118 (char-to-string table-cell-vertical-char)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4119 (char-to-string table-cell-intersection-char)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4120 " \n]")))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4121 (table-with-cache-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4122 (dabbrev-completion arg))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4123
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4124 (defun *table--present-cell-popup-menu (event)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4125 "Present and handle cell popup menu."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4126 (interactive "e")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4127 (unless table-disable-menu
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4128 (select-window (posn-window (event-start event)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4129 (goto-char (posn-point (event-start event)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4130 (let ((item-list (x-popup-menu event table-cell-menu-map))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4131 (func table-cell-menu-map))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4132 (while item-list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4133 (setq func (nth 3 (assoc (car item-list) func)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4134 (setq item-list (cdr item-list)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4135 (if (and (symbolp func) (fboundp func))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4136 (call-interactively func)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4137
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4138 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4139 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4140 ;; Cell updating functions
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4141 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4142
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4143 (defun table--update-cell (&optional now)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4144 "Update the table cell contents.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4145 When the optional parameter NOW is nil it only sets up the update
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4146 timer. If it is non-nil the function copies the contents of the cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4147 cache buffer into the designated cell in the table buffer."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4148 (if (null table-update-timer) nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4149 (table--cancel-timer table-update-timer)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4150 (setq table-update-timer nil))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4151 (if (or (not now)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4152 (and (boundp 'quail-converting)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4153 quail-converting) ;; defer operation while current quail work is not finished.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4154 (and (boundp 'quail-translating)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4155 quail-translating))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4156 (setq table-update-timer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4157 (table--set-timer table-time-before-update
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4158 (function table--update-cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4159 'now))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4160 (save-current-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4161 (set-buffer table-cell-buffer)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4162 (let ((cache-buffer (get-buffer-create table-cache-buffer-name))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4163 (org-coord (table--get-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4164 (in-cell (equal (table--cell-to-coord (table--probe-cell))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4165 (cons table-cell-info-lu-coordinate table-cell-info-rb-coordinate)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4166 rectangle)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4167 (set-buffer cache-buffer)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4168 (setq rectangle
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4169 (extract-rectangle
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4170 1
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4171 (table--goto-coordinate (cons table-cell-info-width (1- table-cell-info-height)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4172 (set-buffer table-cell-buffer)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4173 (delete-rectangle (table--goto-coordinate table-cell-info-lu-coordinate)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4174 (table--goto-coordinate table-cell-info-rb-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4175 (table--goto-coordinate table-cell-info-lu-coordinate)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4176 (table--insert-rectangle rectangle)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4177 (let* ((cell (table--probe-cell))) ; must probe again in case of wide characters
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4178 (table--put-cell-property cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4179 (table--put-cell-justify-property cell table-cell-info-justify)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4180 (table--put-cell-valign-property cell table-cell-info-valign))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4181 (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4182 (if in-cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4183 (table--transcoord-cache-to-table table-cell-cache-point-coordinate)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4184 org-coord))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4185 ;; simulate undo behavior under overwrite-mode
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4186 (if (and overwrite-mode (not (eq buffer-undo-list t)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4187 (setq buffer-undo-list (cons nil buffer-undo-list)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4188
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4189 (defun table--update-cell-widened (&optional now)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4190 "Update the contents of the cells that are affected by widening operation."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4191 (if (null table-widen-timer) nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4192 (table--cancel-timer table-widen-timer)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4193 (setq table-widen-timer nil))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4194 (if (not now)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4195 (setq table-widen-timer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4196 (table--set-timer (+ table-time-before-update table-time-before-reformat)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4197 (function table--update-cell-widened)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4198 'now))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4199 (save-current-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4200 (if table-update-timer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4201 (table--update-cell 'now))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4202 (set-buffer table-cell-buffer)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4203 (let* ((current-coordinate (table--get-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4204 (current-cell-coordinate (table--cell-to-coord (table--probe-cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4205 (cell-coord-list (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4206 (table--goto-coordinate table-cell-info-lu-coordinate)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4207 (table--cell-list-to-coord-list (table--vertical-cell-list)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4208 (while cell-coord-list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4209 (let* ((cell-coord (prog1 (car cell-coord-list) (setq cell-coord-list (cdr cell-coord-list))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4210 (currentp (equal cell-coord current-cell-coordinate)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4211 (if currentp (table--goto-coordinate current-coordinate)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4212 (table--goto-coordinate (car cell-coord)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4213 (table-recognize-cell 'froce)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4214 (let ((table-inhibit-update t))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4215 (table-with-cache-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4216 (let ((sticky (and currentp
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4217 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4218 (unless (bolp) (forward-char -1))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4219 (looking-at ".*\\S ")))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4220 (table--fill-region (point-min) (point-max))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4221 (if sticky
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4222 (setq current-coordinate (table--transcoord-cache-to-table))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4223 (table--update-cell 'now)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4224 ))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4225 (table--goto-coordinate current-coordinate)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4226 (table-recognize-cell 'froce)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4227
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4228 (defun table--update-cell-heightened (&optional now)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4229 "Update the contents of the cells that are affected by heightening operation."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4230 (if (null table-heighten-timer) nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4231 (table--cancel-timer table-heighten-timer)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4232 (setq table-heighten-timer nil))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4233 (if (not now)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4234 (setq table-heighten-timer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4235 (table--set-timer (+ table-time-before-update table-time-before-reformat)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4236 (function table--update-cell-heightened)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4237 'now))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4238 (save-current-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4239 (if table-update-timer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4240 (table--update-cell 'now))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4241 (if table-widen-timer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4242 (table--update-cell-widened 'now))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4243 (set-buffer table-cell-buffer)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4244 (let* ((current-coordinate (table--get-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4245 (current-cell-coordinate (table--cell-to-coord (table--probe-cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4246 (cell-coord-list (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4247 (table--goto-coordinate table-cell-info-lu-coordinate)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4248 (table--cell-list-to-coord-list (table--horizontal-cell-list)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4249 (while cell-coord-list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4250 (let* ((cell-coord (prog1 (car cell-coord-list) (setq cell-coord-list (cdr cell-coord-list))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4251 (currentp (equal cell-coord current-cell-coordinate)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4252 (if currentp (table--goto-coordinate current-coordinate)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4253 (table--goto-coordinate (car cell-coord)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4254 (table-recognize-cell 'froce)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4255 (let ((table-inhibit-update t))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4256 (table-with-cache-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4257 (let ((sticky (and currentp
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4258 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4259 (unless (bolp) (forward-char -1))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4260 (looking-at ".*\\S ")))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4261 (table--valign)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4262 (if sticky
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4263 (setq current-coordinate (table--transcoord-cache-to-table))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4264 (table--update-cell 'now)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4265 ))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4266 (table--goto-coordinate current-coordinate)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4267 (table-recognize-cell 'froce)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4268
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4269 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4270 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4271 ;; Service functions (for external packages)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4272 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4273
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4274 (defun table-goto-top-left-corner ()
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4275 "Move point to top left corner of the current table and return the char position."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4276 (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4277 (cons
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4278 (1- (car (table--get-coordinate (car (table--horizontal-cell-list t t)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4279 (1- (cdr (table--get-coordinate (car (table--vertical-cell-list t t))))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4280
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4281 (defun table-goto-top-right-corner ()
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4282 "Move point to top right corner of the current table and return the char position."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4283 (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4284 (cons
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4285 (car (table--get-coordinate (cdr (table--horizontal-cell-list nil t))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4286 (1- (cdr (table--get-coordinate (car (table--vertical-cell-list t t))))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4287
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4288 (defun table-goto-bottom-left-corner ()
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4289 "Move point to bottom left corner of the current table and return the char position."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4290 (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4291 (cons
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4292 (1- (car (table--get-coordinate (car (table--horizontal-cell-list t t)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4293 (1+ (cdr (table--get-coordinate (cdr (table--vertical-cell-list nil t))))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4294
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4295 (defun table-goto-bottom-right-corner ()
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4296 "Move point to bottom right corner of the current table and return the char position."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4297 (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4298 (cons
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4299 (car (table--get-coordinate (cdr (table--horizontal-cell-list nil t))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4300 (1+ (cdr (table--get-coordinate (cdr (table--vertical-cell-list nil t))))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4301
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4302 (defun table-call-interactively (function &optional recoard-flag keys)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4303 "Call FUNCTION, or a table version of it if applicable.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4304 See `call-interactively' for full description of the arguments."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4305 (let ((table-func (intern-soft (format "*table--cell-%s" function))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4306 (call-interactively
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4307 (if (and table-func
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4308 (table--point-in-cell-p))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4309 table-func
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4310 function) recoard-flag keys)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4311
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4312 (defun table-funcall (function &rest arguments)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4313 "Call FUNCTION, or a table version of it if applicable.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4314 See `funcall' for full description of the arguments."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4315 (let ((table-func (intern-soft (format "*table--cell-%s" function))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4316 (apply
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4317 (if (and table-func
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4318 (table--point-in-cell-p))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4319 table-func
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4320 function)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4321 arguments)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4322
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4323 (defmacro table-apply (function &rest arguments)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4324 "Call FUNCTION, or a table version of it if applicable.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4325 See `apply' for full description of the arguments."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4326 (let ((table-func (make-symbol "table-func")))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4327 `(let ((,table-func (intern-soft (format "*table--cell-%s" ,function))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4328 (apply
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4329 (if (and ,table-func
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4330 (table--point-in-cell-p))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4331 ,table-func
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4332 ,function)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4333 ,@arguments))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4334
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4335 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4336 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4337 ;; Utility functions
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4338 ;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4339
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4340 (defun table--read-from-minibuffer (prompt-history)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4341 "A wrapper to `read-from-minibuffer'.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4342 PROMPT-HISTORY is a cons cell which car is the prompt string and the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4343 cdr is the history symbol."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4344 (let ((default (car (symbol-value (cdr prompt-history)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4345 (read-from-minibuffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4346 (format "%s (default %s): " (car prompt-history) default)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4347 "" nil nil (cdr prompt-history) default))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4348 (and (featurep 'xemacs)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4349 (equal (car (symbol-value (cdr prompt-history))) "")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4350 (set (cdr prompt-history)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4351 (cdr (symbol-value (cdr prompt-history)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4352 (car (symbol-value (cdr prompt-history))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4353
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4354 (defun table--buffer-substring-and-trim (beg end)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4355 "Extract buffer substring and remove blanks from front and the rear of it."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4356 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4357 (save-restriction
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4358 (narrow-to-region (goto-char beg) end)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4359 (if (re-search-forward "\\s *")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4360 (setq beg (match-end 0)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4361 (if (re-search-forward "\\s *\\'" end t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4362 (setq end (match-beginning 0)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4363 (table--remove-cell-properties
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4364 0 (- end beg)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4365 (buffer-substring beg end)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4366
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4367 (defun table--valign ()
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4368 "Vertically align the cache cell contents.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4369 Current buffer must be the cache buffer at the entry to this function.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4370 Returns the coordinate of the final point location."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4371 (if (or (null table-cell-info-valign)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4372 (eq table-cell-info-valign 'none))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4373 (table--get-coordinate)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4374 (let ((saved-point (point-marker)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4375 ;;(set-marker-insertion-type saved-point t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4376 (goto-char (point-min))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4377 (let* ((from (and (re-search-forward "^.*\\S " nil t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4378 (table--current-line)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4379 (to (let ((tmp from))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4380 (while (re-search-forward "^.*\\S " nil t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4381 (setq tmp (table--current-line)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4382 tmp))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4383 (content-height (and from to (1+ (- to from)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4384 (unless (null content-height)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4385 (goto-char (point-min))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4386 (if (looking-at "\\s *\n")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4387 (replace-match ""))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4388 (cond ((eq table-cell-info-valign 'middle)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4389 (insert (make-string (/ (- table-cell-info-height content-height) 2) ?\n)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4390 ((eq table-cell-info-valign 'bottom)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4391 (insert (make-string (- table-cell-info-height content-height) ?\n))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4392 (table--goto-coordinate (cons table-cell-info-width (1- table-cell-info-height)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4393 (if (re-search-forward "\\s +\\'" nil t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4394 (replace-match ""))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4395 (goto-char saved-point)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4396 (set-marker saved-point nil)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4397 (let ((coord (table--get-coordinate)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4398 (unless (< (cdr coord) table-cell-info-height)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4399 (setcdr coord (1- table-cell-info-height))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4400 (table--goto-coordinate coord))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4401 coord))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4402
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4403 (defun table--query-justification ()
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4404 (barf-if-buffer-read-only)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4405 (let* ((completion-ignore-case t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4406 (default (car table-justify-history)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4407 (intern (downcase (completing-read
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4408 (format "Justify (default %s): " default)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4409 '(("left") ("center") ("right") ("top") ("middle") ("bottom") ("none"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4410 nil t nil 'table-justify-history default)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4411
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4412 (defun table--spacify-frame ()
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4413 "Spacify table frame.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4414 Replace frame characters with spaces."
51496
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
4415 (let ((frame-char
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
4416 (append (string-to-list table-cell-horizontal-chars)
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
4417 (list table-cell-intersection-char table-cell-vertical-char))))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4418 (while
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4419 (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4420 (cond
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4421 ((eq (char-after) table-cell-intersection-char)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4422 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4423 (let ((col (current-column)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4424 (and (zerop (forward-line 1))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4425 (zerop (current-column))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4426 (move-to-column col)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4427 (table--spacify-frame))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4428 (delete-char 1)
64059
77cc3a2cedb3 (table-hooks): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents: 63227
diff changeset
4429 (insert-before-markers ?\s))
51496
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
4430 ((table--cell-horizontal-char-p (char-after))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4431 (while (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4432 (delete-char 1)
64059
77cc3a2cedb3 (table-hooks): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents: 63227
diff changeset
4433 (insert-before-markers ?\s)
51496
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
4434 (table--cell-horizontal-char-p (char-after)))))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4435 ((eq (char-after) table-cell-vertical-char)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4436 (while (let ((col (current-column)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4437 (delete-char 1)
64059
77cc3a2cedb3 (table-hooks): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents: 63227
diff changeset
4438 (insert-before-markers ?\s)
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4439 (and (zerop (forward-line 1))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4440 (zerop (current-column))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4441 (move-to-column col)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4442 (eq (char-after) table-cell-vertical-char))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4443 (memq (char-after) frame-char)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4444
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4445 (defun table--remove-blank-lines (n)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4446 "Delete N blank lines from the current line.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4447 For adjusting below area of the table when the table is shortened."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4448 (move-to-column 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4449 (let ((first-blank t))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4450 (while (> n 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4451 (setq n (1- n))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4452 (cond ((looking-at "\\s *\\'")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4453 (delete-region (match-beginning 0) (match-end 0))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4454 (setq n 0))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4455 ((and (looking-at "\\([ \t]*\n[ \t]*\\)\n") first-blank)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4456 (delete-region (match-beginning 1) (match-end 1)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4457 ((looking-at "[ \t]*$")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4458 (delete-region (match-beginning 0) (match-end 0))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4459 (forward-line 1))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4460 (t
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4461 (setq first-blank nil)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4462 (forward-line 1))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4463
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4464 (defun table--uniform-list-p (l)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4465 "Return nil when LIST contains non equal elements. Otherwise return t."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4466 (if (null l) t
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4467 (catch 'end
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4468 (while (cdr l)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4469 (if (not (equal (car l) (cadr l))) (throw 'end nil))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4470 (setq l (cdr l)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4471 t)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4472
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4473 (defun table--detect-cell-alignment (cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4474 "Detect CELL contents alignment.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4475 Guess CELL contents alignment both horizontally and vertically by
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4476 looking at the appearance of the CELL contents."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4477 (let ((cell-contents (extract-rectangle (car cell) (cdr cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4478 (left-margin 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4479 (right-margin 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4480 (top-margin 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4481 (bottom-margin 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4482 (margin-diff 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4483 (margin-info-available nil)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4484 justify valign)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4485 (with-temp-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4486 (table--insert-rectangle cell-contents)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4487 ;; determine the horizontal justification
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4488 (goto-char (point-min))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4489 (while (re-search-forward "^\\( *\\).*[^ \n]\\( *\\)$" nil t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4490 (setq margin-info-available t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4491 (let* ((lm (- (match-end 1) (match-beginning 1)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4492 (rm (- (match-end 2) (match-beginning 2)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4493 (md (abs (- lm rm))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4494 (if (> lm left-margin)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4495 (setq left-margin lm))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4496 (if (> rm right-margin)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4497 (setq right-margin rm))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4498 (if (> md margin-diff)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4499 (setq margin-diff md))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4500 (setq justify
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4501 (cond
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4502 ((and margin-info-available
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4503 (<= margin-diff 1)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4504 (> left-margin 0)) 'center)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4505 ((and margin-info-available
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4506 (zerop right-margin)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4507 (> left-margin 0)) 'right)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4508 (t 'left)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4509 ;; determine the vertical justification
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4510 (goto-char (point-min))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4511 (if (and (re-search-forward "\\s *\\S " nil t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4512 (/= (match-beginning 0) (match-end 0)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4513 (setq top-margin (1- (count-lines (match-beginning 0) (match-end 0)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4514 (if (and (re-search-forward "\\s *\\'" nil t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4515 (/= (match-beginning 0) (match-end 0)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4516 (setq bottom-margin (1- (count-lines (match-beginning 0) (match-end 0)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4517 (setq valign
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4518 (cond
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4519 ((and (> top-margin 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4520 (> bottom-margin 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4521 (<= (abs (- top-margin bottom-margin)) 1)) 'middle)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4522 ((and (> top-margin 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4523 (zerop bottom-margin)) 'bottom)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4524 (t nil))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4525 (table--put-cell-justify-property cell justify)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4526 (table--put-cell-valign-property cell valign)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4527
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4528 (defun table--string-to-number-list (str)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4529 "Return a list of numbers in STR."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4530 (let ((idx 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4531 (nl nil))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4532 (while (string-match "[-0-9.]+" str idx)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4533 (setq idx (match-end 0))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4534 (setq nl (cons (string-to-number (match-string 0 str)) nl)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4535 (nreverse nl)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4536
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4537 (defun table--justify-cell-contents (justify &optional paragraph)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4538 "Justify the current cell contents.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4539 JUSTIFY is a symbol 'left, 'center or 'right for horizontal, or 'top,
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4540 'middle, 'bottom or 'none for vertical. When PARAGRAPH is non-nil the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4541 justify operation is limited to the current paragraph."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4542 (table-with-cache-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4543 (let ((beg (point-min))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4544 (end (point-max-marker))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4545 (fill-column table-cell-info-width)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4546 (adaptive-fill-mode nil)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4547 (valign-symbols '(top middle bottom none)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4548 (unless paragraph
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4549 (if (memq justify valign-symbols)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4550 (setq table-cell-info-valign
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4551 (if (eq justify 'none) nil justify))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4552 (setq table-cell-info-justify justify)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4553 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4554 (if paragraph
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4555 (let ((paragraph-start "\n"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4556 (forward-paragraph)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4557 (or (bolp) (newline 1))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4558 (set-marker end (point))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4559 (setq beg (progn (forward-paragraph -1) (point)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4560 (if (memq justify valign-symbols)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4561 (table--valign)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4562 (table--remove-eol-spaces beg end 'bol)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4563 (let ((paragraph-start table-paragraph-start))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4564 (fill-region beg end table-cell-info-justify))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4565 (setq table-inhibit-auto-fill-paragraph t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4566 (set-marker end nil)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4567 (table--update-cell 'now))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4568
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4569 (defun table--horizontally-shift-above-and-below (columns-to-extend top-to-bottom-coord-list)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4570 "Horizontally shift outside contents right above and right below of the table.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4571 This function moves the surrounding text outside of the table so that
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4572 they match the horizontal growth/shrink of the table. It also
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4573 untabify the shift affected area including the right side of the table
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4574 so that tab related uneven shifting is avoided. COLUMNS-TO-EXTEND
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4575 specifies the number of columns the table grows, or shrinks if
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4576 negative. TOP-TO-BOTTOM-COORD-LIST is the vertical cell coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4577 list. This list can be any vertical list within the table."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4578 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4579 (let (beg-coord end-coord)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4580 (table--goto-coordinate (caar top-to-bottom-coord-list))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4581 (let* ((cell (table--horizontal-cell-list nil 'first-only 'top))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4582 (coord (cons (car (table--get-coordinate (cdr cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4583 (cdr (table--get-coordinate (car cell))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4584 (setcar coord (1+ (car coord)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4585 (setcdr coord (- (cdr coord) 2))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4586 (setq beg-coord (cons (car coord) (1+ (cdr coord))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4587 (while (and (table--goto-coordinate coord 'no-extension)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4588 (not (looking-at "\\s *$")))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4589 (if (< columns-to-extend 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4590 (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4591 (table--untabify-line)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4592 (delete-char columns-to-extend))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4593 (table--untabify-line (point))
64059
77cc3a2cedb3 (table-hooks): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents: 63227
diff changeset
4594 (insert (make-string columns-to-extend ?\s)))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4595 (setcdr coord (1- (cdr coord)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4596 (table--goto-coordinate (caar (last top-to-bottom-coord-list)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4597 (let ((coord (table--get-coordinate (cdr (table--horizontal-cell-list nil 'first-only 'bottom)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4598 (setcar coord (1+ (car coord)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4599 (setcdr coord (+ (cdr coord) 2))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4600 (setq end-coord (cons (car coord) (1- (cdr coord))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4601 (while (and (table--goto-coordinate coord 'no-extension)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4602 (not (looking-at "\\s *$")))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4603 (if (< columns-to-extend 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4604 (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4605 (table--untabify-line)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4606 (delete-char columns-to-extend))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4607 (table--untabify-line (point))
64059
77cc3a2cedb3 (table-hooks): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents: 63227
diff changeset
4608 (insert (make-string columns-to-extend ?\s)))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4609 (setcdr coord (1+ (cdr coord)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4610 (while (<= (cdr beg-coord) (cdr end-coord))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4611 (table--untabify-line (table--goto-coordinate beg-coord 'no-extension))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4612 (setcdr beg-coord (1+ (cdr beg-coord)))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4613
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4614 (defun table--create-growing-space-below (lines-to-extend left-to-right-coord-list bottom-border-y)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4615 "Create growing space below the table.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4616 This function creates growing space below the table slightly
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4617 intelligent fashion. Following is the cases it handles for each
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4618 growing line:
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4619 1. When the first line below the table is a complete blank line it
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4620 inserts a blank line.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4621 2. When the line starts with a prefix that matches the prefix of the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4622 bottom line of the table it inserts a line consisting of prefix alone.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4623 3. Otherwise it deletes the rectangular contents where table will
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4624 grow into."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4625 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4626 (let ((i 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4627 (prefix (and (table--goto-coordinate (cons 0 bottom-border-y))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4628 (re-search-forward
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4629 ".*\\S "
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4630 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4631 (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4632 (cons (1- (caar (car left-to-right-coord-list))) bottom-border-y)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4633 t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4634 (buffer-substring (match-beginning 0) (match-end 0)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4635 (while (< i lines-to-extend)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4636 (let ((y (+ i bottom-border-y 1)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4637 (table--goto-coordinate (cons 0 y))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4638 (cond
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4639 ((looking-at "\\s *$")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4640 (insert ?\n))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4641 ((and prefix (looking-at (concat (regexp-quote prefix) "\\s *$")))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4642 (insert prefix ?\n))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4643 (t
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4644 (delete-rectangle
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4645 (table--goto-coordinate (cons (1- (caar (car left-to-right-coord-list))) y))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4646 (table--goto-coordinate (cons (1+ (cadr (car (last left-to-right-coord-list)))) y))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4647 (setq i (1+ i))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4648
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4649 (defun table--untabify-line (&optional from)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4650 "Untabify current line.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4651 Unlike save-excursion this guarantees preserving the cursor location
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4652 even when the point is on a tab character which is to be removed.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4653 Optional FROM narrows the subject operation from this point to the end
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4654 of line."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4655 (let ((current-coordinate (table--get-coordinate)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4656 (table--untabify (or from (progn (beginning-of-line) (point)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4657 (progn (end-of-line) (point)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4658 (table--goto-coordinate current-coordinate)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4659
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4660 (defun table--untabify (beg end)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4661 "Wrapper to raw untabify."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4662 (untabify beg end)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4663 (if (featurep 'xemacs)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4664 ;; Cancel strange behavior of xemacs
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4665 (message "")))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4666
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4667 (defun table--multiply-string (string multiplier)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4668 "Multiply string and return it."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4669 (let ((ret-str ""))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4670 (while (> multiplier 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4671 (setq ret-str (concat ret-str string))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4672 (setq multiplier (1- multiplier)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4673 ret-str))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4674
60724
3a2908eb7595 (table--line-column-position): New idiom.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59996
diff changeset
4675 (defun table--line-column-position (line column)
3a2908eb7595 (table--line-column-position): New idiom.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59996
diff changeset
4676 "Return the location of LINE forward at COLUMN."
3a2908eb7595 (table--line-column-position): New idiom.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59996
diff changeset
4677 (save-excursion
3a2908eb7595 (table--line-column-position): New idiom.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59996
diff changeset
4678 (forward-line line)
3a2908eb7595 (table--line-column-position): New idiom.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59996
diff changeset
4679 (move-to-column column)
3a2908eb7595 (table--line-column-position): New idiom.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59996
diff changeset
4680 (point)))
3a2908eb7595 (table--line-column-position): New idiom.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59996
diff changeset
4681
3a2908eb7595 (table--line-column-position): New idiom.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59996
diff changeset
4682 (defun table--row-column-insertion-point-p (&optional columnp)
73654
3c539f2ffdc3 (table--row-column-insertion-point-p): Use "non-nil" in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents: 73382
diff changeset
4683 "Return non-nil if it makes sense to insert a row or a column at point."
60724
3a2908eb7595 (table--line-column-position): New idiom.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59996
diff changeset
4684 (and (not buffer-read-only)
3a2908eb7595 (table--line-column-position): New idiom.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59996
diff changeset
4685 (or (get-text-property (point) 'table-cell)
3a2908eb7595 (table--line-column-position): New idiom.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59996
diff changeset
4686 (let ((column (current-column)))
3a2908eb7595 (table--line-column-position): New idiom.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59996
diff changeset
4687 (if columnp
3a2908eb7595 (table--line-column-position): New idiom.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59996
diff changeset
4688 (or (text-property-any (line-beginning-position 0)
3a2908eb7595 (table--line-column-position): New idiom.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59996
diff changeset
4689 (table--line-column-position -1 column)
3a2908eb7595 (table--line-column-position): New idiom.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59996
diff changeset
4690 'table-cell t)
3a2908eb7595 (table--line-column-position): New idiom.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59996
diff changeset
4691 (text-property-any (line-beginning-position) (point) 'table-cell t)
3a2908eb7595 (table--line-column-position): New idiom.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59996
diff changeset
4692 (text-property-any (line-beginning-position 2)
3a2908eb7595 (table--line-column-position): New idiom.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59996
diff changeset
4693 (table--line-column-position 1 column)
3a2908eb7595 (table--line-column-position): New idiom.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59996
diff changeset
4694 'table-cell t))
3a2908eb7595 (table--line-column-position): New idiom.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59996
diff changeset
4695 (text-property-any (table--line-column-position -2 column)
3a2908eb7595 (table--line-column-position): New idiom.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59996
diff changeset
4696 (table--line-column-position -2 (+ 2 column))
3a2908eb7595 (table--line-column-position): New idiom.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59996
diff changeset
4697 'table-cell t))))))
3a2908eb7595 (table--line-column-position): New idiom.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59996
diff changeset
4698
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4699 (defun table--find-row-column (&optional columnp no-error)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4700 "Search table and return a cell coordinate list of row or column."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4701 (let ((current-coordinate (table--get-coordinate)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4702 (catch 'end
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4703 (catch 'error
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4704 (let ((coord (table--get-coordinate)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4705 (while
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4706 (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4707 (if columnp (setcar coord (1- (car coord)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4708 (setcdr coord (1- (cdr coord))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4709 (>= (if columnp (car coord) (cdr coord)) 0))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4710 (while (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4711 (table--goto-coordinate coord 'no-extension 'no-tab-expansion)
51496
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
4712 (not (looking-at (format "[%s%c%c]"
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
4713 table-cell-horizontal-chars
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4714 table-cell-vertical-char
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4715 table-cell-intersection-char))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4716 (if columnp (setcar coord (1- (car coord)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4717 (setcdr coord (1- (cdr coord))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4718 (if (< (if columnp (car coord) (cdr coord)) 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4719 (throw 'error nil)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4720 (if (table--probe-cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4721 (throw 'end (table--cell-list-to-coord-list (if columnp
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4722 (table--vertical-cell-list t nil 'left)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4723 (table--horizontal-cell-list t nil 'top))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4724 (table--goto-coordinate (table--offset-coordinate coord (if columnp '(0 . 1) '(1 . 0)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4725 'no-extension 'no-tab-expansion)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4726 (if (table--probe-cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4727 (throw 'end (table--cell-list-to-coord-list (if columnp
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4728 (table--vertical-cell-list t nil 'left)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4729 (table--horizontal-cell-list t nil 'top)))))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4730 (table--goto-coordinate current-coordinate)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4731 (if no-error nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4732 (error "Table not found")))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4733
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4734 (defun table--min-coord-list (coord-list)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4735 "Return minimum cell dimension of COORD-LIST.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4736 COORD-LIST is a list of coordinate pairs (lu-coord . rb-coord), where
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4737 each pair in the list represents a cell. lu-coord is the left upper
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4738 coordinate of a cell and rb-coord is the right bottom coordinate of a
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4739 cell. A coordinate is a pair of x and y axis coordinate values. The
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4740 return value is a cons cell (min-w . min-h), where min-w and min-h are
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4741 respectively the minimum width and the minimum height of all the cells
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4742 in the list."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4743 (if (null coord-list) nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4744 (let ((min-width 134217727)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4745 (min-height 134217727))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4746 (while coord-list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4747 (let* ((coord (prog1 (car coord-list) (setq coord-list (cdr coord-list))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4748 (width (- (cadr coord) (caar coord)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4749 (height (1+ (- (cddr coord) (cdar coord)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4750 (if (< width min-width) (setq min-width width))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4751 (if (< height min-height) (setq min-height height))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4752 (cons min-width min-height))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4753
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4754 (defun table--cell-can-split-horizontally-p ()
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4755 "Test if a cell can split at current location horizontally."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4756 (and (not buffer-read-only)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4757 (let ((point-x (car (table--get-coordinate))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4758 (table-recognize-cell 'force)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4759 (and (> point-x (car table-cell-info-lu-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4760 (<= point-x (1- (car table-cell-info-rb-coordinate)))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4761
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4762 (defun table--cell-can-split-vertically-p ()
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4763 "Test if a cell can split at current location vertically."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4764 (and (not buffer-read-only)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4765 (let ((point-y (cdr (table--get-coordinate))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4766 (table-recognize-cell 'force)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4767 (and (> point-y (cdr table-cell-info-lu-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4768 (<= point-y (cdr table-cell-info-rb-coordinate))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4769
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4770 (defun table--cell-can-span-p (direction)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4771 "Test if the current cell can span to DIRECTION."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4772 (table-recognize-cell 'force)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4773 (and (not buffer-read-only)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4774 (table--probe-cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4775 ;; get two adjacent cells from each corner
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4776 (let ((cell (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4777 (and
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4778 (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4779 (cons (cond ((eq direction 'right) (1+ (car table-cell-info-rb-coordinate)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4780 ((eq direction 'left) (1- (car table-cell-info-lu-coordinate)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4781 (t (car table-cell-info-lu-coordinate)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4782 (cond ((eq direction 'above) (- (cdr table-cell-info-lu-coordinate) 2))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4783 ((eq direction 'below) (+ (cdr table-cell-info-rb-coordinate) 2))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4784 (t (cdr table-cell-info-lu-coordinate)))) 'no-extension)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4785 (table--probe-cell))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4786 (cell2 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4787 (and
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4788 (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4789 (cons (cond ((eq direction 'right) (1+ (car table-cell-info-rb-coordinate)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4790 ((eq direction 'left) (1- (car table-cell-info-lu-coordinate)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4791 (t (car table-cell-info-rb-coordinate)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4792 (cond ((eq direction 'above) (- (cdr table-cell-info-lu-coordinate) 2))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4793 ((eq direction 'below) (+ (cdr table-cell-info-rb-coordinate) 2))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4794 (t (cdr table-cell-info-rb-coordinate)))) 'no-extension)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4795 (table--probe-cell)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4796 ;; make sure the two cells exist, and they are identical, that cell's size matches the current one
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4797 (and cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4798 (equal cell cell2)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4799 (if (or (eq direction 'right) (eq direction 'left))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4800 (and (= (cdr (table--get-coordinate (car cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4801 (cdr table-cell-info-lu-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4802 (= (cdr (table--get-coordinate (cdr cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4803 (cdr table-cell-info-rb-coordinate)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4804 (and (= (car (table--get-coordinate (car cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4805 (car table-cell-info-lu-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4806 (= (car (table--get-coordinate (cdr cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4807 (car table-cell-info-rb-coordinate))))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4808
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4809 (defun table--cell-insert-char (char &optional overwrite)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4810 "Insert CHAR inside a table cell."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4811 (let ((delete-selection-p (and (boundp 'delete-selection-mode)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4812 delete-selection-mode
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4813 transient-mark-mode mark-active
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4814 (not buffer-read-only)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4815 (mark-coordinate (table--transcoord-table-to-cache (table--get-coordinate (mark t)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4816 (table-with-cache-buffer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4817 (and delete-selection-p
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4818 (>= (car mark-coordinate) 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4819 (<= (car mark-coordinate) table-cell-info-width)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4820 (>= (cdr mark-coordinate) 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4821 (<= (cdr mark-coordinate) table-cell-info-height)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4822 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4823 (delete-region (point) (table--goto-coordinate mark-coordinate))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4824 (if overwrite
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4825 (let ((coordinate (table--get-coordinate)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4826 (setq table-inhibit-auto-fill-paragraph t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4827 (if (>= (car coordinate) table-cell-info-width)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4828 (if (>= (cdr coordinate) (1- table-cell-info-height))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4829 (insert "\n" char)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4830 (forward-line 1)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4831 (insert char)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4832 (unless (eolp)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4833 (delete-char 1)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4834 (insert char)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4835 (unless (eolp)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4836 (delete-char 1))))
64059
77cc3a2cedb3 (table-hooks): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents: 63227
diff changeset
4837 (if (not (eq char ?\s))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4838 (if char (insert char))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4839 (if (not (looking-at "\\s *$"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4840 (if (and table-fixed-width-mode
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4841 (> (point) 2)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4842 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4843 (forward-char -2)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4844 (looking-at (concat "\\("
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4845 (regexp-quote (char-to-string table-word-continuation-char))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4846 "\\)\n"))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4847 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4848 (replace-match " " nil nil nil 1))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4849 (insert char))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4850 (let ((coordinate (table--get-coordinate)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4851 (if (< (car coordinate) table-cell-info-width)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4852 (move-to-column (1+ (car coordinate)) t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4853 (insert (make-string (forward-line 1) ?\n))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4854 (unless (bolp) (insert ?\n))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4855 (setq table-inhibit-auto-fill-paragraph t))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4856 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4857 (let ((o-point (point)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4858 (if (and (bolp)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4859 (or (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4860 (forward-paragraph)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4861 (forward-paragraph -1)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4862 (= o-point (point)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4863 (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4864 (goto-char o-point)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4865 (forward-line)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4866 (setq o-point (point))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4867 (forward-paragraph)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4868 (forward-paragraph -1)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4869 (= o-point (point)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4870 (insert ?\n)))))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4871
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4872 (defun table--finish-delayed-tasks ()
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4873 "Finish all outstanding delayed tasks."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4874 (if table-update-timer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4875 (table--update-cell 'now))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4876 (if table-widen-timer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4877 (table--update-cell-widened 'now))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4878 (if table-heighten-timer
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4879 (table--update-cell-heightened 'now)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4880
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4881 (defmacro table--log (&rest body)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4882 "Debug logging macro."
68246
ecfd9a69b670 Move defvars out of eval-when-compile.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64993
diff changeset
4883 `(with-current-buffer (get-buffer-create "log")
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4884 (goto-char (point-min))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4885 (let ((standard-output (current-buffer)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4886 ,@body)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4887
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4888 (defun table--measure-max-width (&optional unlimited)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4889 "Return maximum width of current buffer.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4890 Normally the current buffer is expected to be already the cache
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4891 buffer. The width excludes following spaces at the end of each line.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4892 Unless UNLIMITED is non-nil minimum return value is 1."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4893 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4894 (let ((width 0))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4895 (goto-char (point-min))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4896 (while
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4897 (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4898 ;; do not count the following white spaces
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4899 (re-search-forward "\\s *$")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4900 (goto-char (match-beginning 0))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4901 (if (> (current-column) width)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4902 (setq width (current-column)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4903 (forward-line)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4904 (not (eobp))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4905 (if unlimited width
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4906 (max 1 width)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4907
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4908 (defun table--cell-to-coord (cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4909 "Create a cell coordinate pair from cell location pair."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4910 (if cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4911 (cons (table--get-coordinate (car cell))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4912 (table--get-coordinate (cdr cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4913 nil))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4914
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4915 (defun table--cell-list-to-coord-list (cell-list)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4916 "Create and return a coordinate list that corresponds to CELL-LIST.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4917 CELL-LIST is a list of location pairs (lu . rb), where each pair
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4918 represents a cell in the list. lu is the left upper location and rb
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4919 is the right bottom location of a cell. The return value is a list of
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4920 coordinate pairs (lu-coord . rb-coord), where lu-coord is the left
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4921 upper coordinate and rb-coord is the right bottom coordinate of a
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4922 cell."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4923 (let ((coord-list))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4924 (while cell-list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4925 (let ((cell (prog1 (car cell-list) (setq cell-list (cdr cell-list)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4926 (setq coord-list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4927 (cons (table--cell-to-coord cell) coord-list))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4928 (nreverse coord-list)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4929
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4930 (defun table--test-cell-list (&optional horizontal reverse first-only pivot)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4931 "For testing `table--vertical-cell-list' and `table--horizontal-cell-list'."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4932 (let* ((current-coordinate (table--get-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4933 (cell-list (if horizontal
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4934 (table--horizontal-cell-list reverse first-only pivot)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4935 (table--vertical-cell-list reverse first-only pivot)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4936 (count 0))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4937 (while cell-list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4938 (let* ((cell (if first-only (prog1 cell-list (setq cell-list nil))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4939 (prog1 (car cell-list) (setq cell-list (cdr cell-list)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4940 (dig1-str (format "%1d" (prog1 (% count 10) (setq count (1+ count))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4941 (goto-char (car cell))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4942 (table-with-cache-buffer
68246
ecfd9a69b670 Move defvars out of eval-when-compile.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64993
diff changeset
4943 (while (re-search-forward "." nil t)
ecfd9a69b670 Move defvars out of eval-when-compile.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64993
diff changeset
4944 (replace-match dig1-str nil nil))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4945 (setq table-inhibit-auto-fill-paragraph t))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4946 (table--finish-delayed-tasks)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4947 (table--goto-coordinate current-coordinate)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4948
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4949 (defun table--vertical-cell-list (&optional top-to-bottom first-only pivot internal-dir internal-list internal-px)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4950 "Return a vertical cell list from the table.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4951 The return value represents a list of cells including the current cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4952 that align vertically. Each element of the list is a cons cell (lu
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4953 . rb) where lu is the cell's left upper location and rb is the cell's
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4954 right bottom location. The cell order in the list is from bottom to
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4955 top of the table. If optional argument TOP-TO-BOTTOM is non-nil the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4956 order is reversed as from top to bottom of the table. If optional
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4957 argument FIRST-ONLY is non-nil the return value is not a list of cells
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4958 but a single cons cell that is the first cell of the list, if the list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4959 had been created. If optional argument PIVOT is a symbol `left' the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4960 vertical cell search is aligned with the left edge of the current
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4961 cell, otherwise aligned with the right edge of the current cell. The
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4962 arguments INTERNAL-DIR, INTERNAL-LIST and INTERNAL-PX are internal use
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4963 only and must not be specified."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4964 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4965 (let* ((cell (table--probe-cell))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4966 (lu-coordinate (table--get-coordinate (car cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4967 (rb-coordinate (table--get-coordinate (cdr cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4968 (px (or internal-px (car (if (eq pivot 'left) lu-coordinate rb-coordinate))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4969 (ty (- (cdr lu-coordinate) 2))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4970 (by (+ (cdr rb-coordinate) 2)))
105424
098f8a47a308 Fix typos in comments.
Juanma Barranquero <lekktu@gmail.com>
parents: 105372
diff changeset
4971 ;; in case of finding the first cell, get the last adding item on the list
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4972 (if (and (null internal-dir) first-only) (setq top-to-bottom (null top-to-bottom)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4973 ;; travel up and process as recursion traces back (reverse order)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4974 (and cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4975 (or (eq internal-dir 'up) (null internal-dir))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4976 (table--goto-coordinate (cons px (if top-to-bottom by ty)) 'no-extension 'no-tab-expansion)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4977 (setq internal-list (table--vertical-cell-list top-to-bottom first-only nil 'up nil px)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4978 ;; return the last cell or add this cell to the list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4979 (if first-only (or internal-list cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4980 (setq internal-list (if cell (cons cell internal-list) internal-list))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4981 ;; travel down and process as entering each recursion (forward order)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4982 (and cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4983 (or (eq internal-dir 'down) (null internal-dir))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4984 (table--goto-coordinate (cons px (if top-to-bottom ty by)) 'no-extension 'no-tab-expansion)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4985 (setq internal-list (table--vertical-cell-list top-to-bottom nil nil 'down internal-list px)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4986 ;; return the result
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4987 internal-list))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4988
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4989 (defun table--horizontal-cell-list (&optional left-to-right first-only pivot internal-dir internal-list internal-py)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4990 "Return a horizontal cell list from the table.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4991 The return value represents a list of cells including the current cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4992 that align horizontally. Each element of the list is a cons cells (lu
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4993 . rb) where lu is the cell's left upper location and rb is the cell's
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4994 right bottom location. The cell order in the list is from right to
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4995 left of the table. If optional argument LEFT-TO-RIGHT is non-nil the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4996 order is reversed as from left to right of the table. If optional
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4997 argument FIRST-ONLY is non-nil the return value is not a list of cells
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4998 but a single cons cell that is the first cell of the list, if the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4999 list had been created. If optional argument PIVOT is a symbol `top'
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5000 the horizontal cell search is aligned with the top edge of the current
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5001 cell, otherwise aligned with the bottom edge of the current cell. The
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5002 arguments INTERNAL-DIR, INTERNAL-LIST and INTERNAL-PY are internal use
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5003 only and must not be specified."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5004 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5005 (let* ((cell (table--probe-cell))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5006 (lu-coordinate (table--get-coordinate (car cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5007 (rb-coordinate (table--get-coordinate (cdr cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5008 (py (or internal-py (if (eq pivot 'top) (cdr lu-coordinate) (1+ (cdr rb-coordinate)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5009 (lx (1- (car lu-coordinate)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5010 (rx (1+ (car rb-coordinate))))
105424
098f8a47a308 Fix typos in comments.
Juanma Barranquero <lekktu@gmail.com>
parents: 105372
diff changeset
5011 ;; in case of finding the first cell, get the last adding item on the list
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5012 (if (and (null internal-dir) first-only) (setq left-to-right (null left-to-right)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5013 ;; travel left and process as recursion traces back (reverse order)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5014 (and cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5015 (or (eq internal-dir 'left) (null internal-dir))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5016 (table--goto-coordinate (cons (if left-to-right rx lx) py) 'no-extension 'no-tab-expansion)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5017 (setq internal-list (table--horizontal-cell-list left-to-right first-only nil 'left nil py)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5018 ;; return the last cell or add this cell to the list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5019 (if first-only (or internal-list cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5020 (setq internal-list (if cell (cons cell internal-list) internal-list))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5021 ;; travel right and process as entering each recursion (forward order)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5022 (and cell
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5023 (or (eq internal-dir 'right) (null internal-dir))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5024 (table--goto-coordinate (cons (if left-to-right lx rx) py) 'no-extension 'no-tab-expansion)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5025 (setq internal-list (table--horizontal-cell-list left-to-right nil nil 'right internal-list py)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5026 ;; return the result
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5027 internal-list))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5028
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5029 (defun table--point-in-cell-p (&optional location)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5030 "Return t when point is in a valid table cell in the current buffer.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5031 When optional LOCATION is provided the test is performed at that location."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5032 (and (table--at-cell-p (or location (point)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5033 (if location
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5034 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5035 (goto-char location)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5036 (table--probe-cell))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5037 (table--probe-cell))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5038
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5039 (defun table--region-in-cell-p (beg end)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5040 "Return t when location BEG and END are in a valid table cell in the current buffer."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5041 (and (table--at-cell-p (min beg end))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5042 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5043 (let ((cell-beg (progn (goto-char beg) (table--probe-cell))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5044 (and cell-beg
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5045 (equal cell-beg (progn (goto-char end) (table--probe-cell))))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5046
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5047 (defun table--at-cell-p (position &optional object at-column)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5048 "Returns non-nil if POSITION has table-cell property in OBJECT.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5049 OBJECT is optional and defaults to the current buffer.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5050 If POSITION is at the end of OBJECT, the value is nil."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5051 (if (and at-column (stringp object))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5052 (setq position (table--str-index-at-column object position)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5053 (get-text-property position 'table-cell object))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5054
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5055 (defun table--probe-cell-left-up ()
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5056 "Probe left up corner pattern of a cell.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5057 If it finds a valid corner returns a position otherwise returns nil.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5058 The position is the location before the first cell character.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5059 Focus only on the corner pattern. Further cell validity check is required."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5060 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5061 (let ((vertical-str (regexp-quote (char-to-string table-cell-vertical-char)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5062 (intersection-str (regexp-quote (char-to-string table-cell-intersection-char)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5063 (v-border (format "[%c%c]" table-cell-vertical-char table-cell-intersection-char))
51496
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
5064 (h-border (format "[%s%c]" table-cell-horizontal-chars table-cell-intersection-char))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5065 (limit (save-excursion (beginning-of-line) (point))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5066 (catch 'end
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5067 (while t
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5068 (catch 'retry-horizontal
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5069 (if (not (search-backward-regexp v-border limit t))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5070 (throw 'end nil))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5071 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5072 (let ((column (current-column)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5073 (while t
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5074 (catch 'retry-vertical
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5075 (if (zerop (forward-line -1)) nil (throw 'end nil))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5076 (move-to-column column)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5077 (while (and (looking-at vertical-str)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5078 (= column (current-column)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5079 (if (zerop (forward-line -1)) nil (throw 'end nil))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5080 (move-to-column column))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5081 (cond
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5082 ((/= column (current-column))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5083 (throw 'end nil))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5084 ((looking-at (concat intersection-str h-border))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5085 (forward-line 1)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5086 (move-to-column column)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5087 (forward-char 1)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5088 (throw 'end (point)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5089 ((looking-at intersection-str)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5090 (throw 'retry-vertical nil))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5091 (t (throw 'retry-horizontal nil)))))))))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5092
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5093 (defun table--probe-cell-right-bottom ()
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5094 "Probe right bottom corner pattern of a cell.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5095 If it finds a valid corner returns a position otherwise returns nil.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5096 The position is the location after the last cell character.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5097 Focus only on the corner pattern. Further cell validity check is required."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5098 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5099 (let ((vertical-str (regexp-quote (char-to-string table-cell-vertical-char)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5100 (intersection-str (regexp-quote (char-to-string table-cell-intersection-char)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5101 (v-border (format "[%c%c]" table-cell-vertical-char table-cell-intersection-char))
51496
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
5102 (h-border (format "[%s%c]" table-cell-horizontal-chars table-cell-intersection-char))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5103 (limit (save-excursion (end-of-line) (point))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5104 (catch 'end
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5105 (while t
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5106 (catch 'retry-horizontal
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5107 (if (not (search-forward-regexp v-border limit t))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5108 (throw 'end nil))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5109 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5110 (forward-char -1)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5111 (let ((column (current-column)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5112 (while t
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5113 (catch 'retry-vertical
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5114 (while (and (looking-at vertical-str)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5115 (= column (current-column)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5116 (if (and (zerop (forward-line 1)) (zerop (current-column))) nil (throw 'end nil))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5117 (move-to-column column))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5118 (cond
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5119 ((/= column (current-column))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5120 (throw 'end nil))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5121 ((save-excursion (forward-char -1) (looking-at (concat h-border intersection-str)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5122 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5123 (and (zerop (forward-line -1))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5124 (move-to-column column)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5125 (looking-at v-border)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5126 (throw 'end (point))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5127 (forward-char 1)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5128 (throw 'retry-horizontal nil))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5129 ((looking-at intersection-str)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5130 (if (and (zerop (forward-line 1)) (zerop (current-column))) nil (throw 'end nil))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5131 (move-to-column column)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5132 (throw 'retry-vertical nil))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5133 (t (throw 'retry-horizontal nil)))))))))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5134
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5135 (defun table--editable-cell-p (&optional abort-on-error)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5136 (and (not buffer-read-only)
60724
3a2908eb7595 (table--line-column-position): New idiom.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59996
diff changeset
5137 (get-text-property (point) 'table-cell)))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5138
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5139 (defun table--probe-cell (&optional abort-on-error)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5140 "Probes a table cell around the point.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5141 Searches for the left upper corner and the right bottom corner of a table
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5142 cell which contains the current point location.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5143
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5144 The result is a cons cell (left-upper . right-bottom) where
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5145 the left-upper is the position before the cell's left upper corner character,
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5146 the right-bottom is the position after the cell's right bottom corner character.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5147
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5148 When it fails to find either one of the cell corners it returns nil or
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5149 signals error if the optional ABORT-ON-ERROR is non-nil."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5150 (let (lu rb
51496
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
5151 (border (format "^[%s%c%c]+$"
28f18afa589b (table-cell-horizontal-chars): Renamed from table-cell-horizontal-char. Now a
Juanma Barranquero <lekktu@gmail.com>
parents: 49848
diff changeset
5152 table-cell-horizontal-chars
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5153 table-cell-vertical-char
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5154 table-cell-intersection-char)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5155 (if (and (condition-case nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5156 (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5157 (and (setq lu (table--probe-cell-left-up))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5158 (setq rb (table--probe-cell-right-bottom))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5159 (error nil))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5160 (< lu rb)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5161 (let ((lu-coordinate (table--get-coordinate lu))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5162 (rb-coordinate (table--get-coordinate rb)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5163 ;; test for valid upper and lower borders
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5164 (and (string-match
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5165 border
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5166 (buffer-substring
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5167 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5168 (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5169 (cons (1- (car lu-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5170 (1- (cdr lu-coordinate)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5171 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5172 (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5173 (cons (1+ (car rb-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5174 (1- (cdr lu-coordinate)))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5175 (string-match
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5176 border
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5177 (buffer-substring
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5178 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5179 (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5180 (cons (1- (car lu-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5181 (1+ (cdr rb-coordinate)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5182 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5183 (table--goto-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5184 (cons (1+ (car rb-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5185 (1+ (cdr rb-coordinate))))))))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5186 (cons lu rb)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5187 (if abort-on-error
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5188 (error "Table cell not found")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5189 nil))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5190
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5191 (defun table--insert-rectangle (rectangle)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5192 "Insert text of RECTANGLE with upper left corner at point.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5193 Same as insert-rectangle except that mark operation is eliminated."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5194 (let ((lines rectangle)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5195 (insertcolumn (current-column))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5196 (first t))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5197 (while lines
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5198 (or first
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5199 (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5200 (forward-line 1)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5201 (or (bolp) (insert ?\n))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5202 (move-to-column insertcolumn t)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5203 (setq first nil)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5204 (insert (car lines))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5205 (setq lines (cdr lines)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5206
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5207 (defun table--put-cell-property (cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5208 "Put standard text properties to the CELL.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5209 The CELL is a cons cell (left-upper . right-bottom) where the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5210 left-upper is the position before the cell's left upper corner
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5211 character, the right-bottom is the position after the cell's right
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5212 bottom corner character."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5213 (let ((lu (table--get-coordinate (car cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5214 (rb (table--get-coordinate (cdr cell))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5215 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5216 (while (<= (cdr lu) (cdr rb))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5217 (let ((beg (table--goto-coordinate lu 'no-extension))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5218 (end (table--goto-coordinate (cons (car rb) (cdr lu)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5219 (table--put-cell-line-property beg end))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5220 (setcdr lu (1+ (cdr lu))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5221 (table--put-cell-justify-property cell table-cell-info-justify)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5222 (table--put-cell-valign-property cell table-cell-info-valign))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5223
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5224 (defun table--put-cell-line-property (beg end &optional object)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5225 "Put standard text properties to a line of a cell.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5226 BEG is the beginning of the line that is the location between left
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5227 cell border character and the first content character. END is the end
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5228 of the line that is the location between the last content character
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5229 and the right cell border character."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5230 (table--put-cell-content-property beg end object)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5231 (table--put-cell-keymap-property end (1+ end) object)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5232 (table--put-cell-indicator-property end (1+ end) object)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5233 (table--put-cell-rear-nonsticky end (1+ end) object))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5234
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5235 (defun table--put-cell-content-property (beg end &optional object)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5236 "Put cell content text properties."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5237 (table--put-cell-keymap-property beg end object)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5238 (table--put-cell-indicator-property beg end object)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5239 (table--put-cell-face-property beg end object)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5240 (table--put-cell-point-entered/left-property beg end object))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5241
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5242 (defun table--put-cell-indicator-property (beg end &optional object)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5243 "Put cell property which indicates that the location is within a table cell."
53367
fbdcff26f02a (table-yank-handler): New defcustom.
Eli Zaretskii <eliz@is.elta.co.il>
parents: 52401
diff changeset
5244 (put-text-property beg end 'table-cell t object)
fbdcff26f02a (table-yank-handler): New defcustom.
Eli Zaretskii <eliz@is.elta.co.il>
parents: 52401
diff changeset
5245 (put-text-property beg end 'yank-handler table-yank-handler object))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5246
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5247 (defun table--put-cell-face-property (beg end &optional object)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5248 "Put cell face property."
63227
6f4701bb40a7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-391
Miles Bader <miles@gnu.org>
parents: 62578
diff changeset
5249 (put-text-property beg end 'face 'table-cell object))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5250
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5251 (defun table--put-cell-keymap-property (beg end &optional object)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5252 "Put cell keymap property."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5253 (put-text-property beg end 'keymap 'table-cell-map object))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5254
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5255 (defun table--put-cell-rear-nonsticky (beg end &optional object)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5256 "Put rear-nonsticky property."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5257 (put-text-property beg end 'rear-nonsticky t object))
49599
5ade352e8d1c Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48373
diff changeset
5258
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5259 (defun table--put-cell-point-entered/left-property (beg end &optional object)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5260 "Put point-entered/left property."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5261 (put-text-property beg end 'point-entered 'table--point-entered-cell-function object)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5262 (put-text-property beg end 'point-left 'table--point-left-cell-function object))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5263
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5264 (defun table--remove-cell-properties (beg end &optional object)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5265 "Remove all cell properties.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5266 If OBJECT is non-nil cell properties are removed from the OBJECT
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5267 instead of the current buffer and returns the OBJECT."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5268 (while (< beg end)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5269 (let ((next (next-single-property-change beg 'table-cell object end)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5270 (if (get-text-property beg 'table-cell object)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5271 (remove-text-properties beg next
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5272 (list
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5273 'table-cell nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5274 'table-justify nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5275 'table-valign nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5276 'face nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5277 'rear-nonsticky nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5278 'point-entered nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5279 'point-left nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5280 'keymap nil)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5281 object))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5282 (setq beg next)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5283 object)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5284
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5285 (defun table--update-cell-face ()
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5286 "Update cell face according to the current mode."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5287 (if (featurep 'xemacs)
63227
6f4701bb40a7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-391
Miles Bader <miles@gnu.org>
parents: 62578
diff changeset
5288 (set-face-property 'table-cell 'underline table-fixed-width-mode)
6f4701bb40a7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-391
Miles Bader <miles@gnu.org>
parents: 62578
diff changeset
5289 (set-face-inverse-video-p 'table-cell table-fixed-width-mode)))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5290
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5291 (table--update-cell-face)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5292
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5293 (defun table--get-property (cell property)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5294 "Get CELL's PROPERTY."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5295 (or (get-text-property (car cell) property)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5296 (get-text-property (1- (cdr cell)) property)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5297
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5298 (defun table--get-cell-justify-property (cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5299 "Get cell's justify property."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5300 (table--get-property cell 'table-justify))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5301
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5302 (defun table--get-cell-valign-property (cell)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5303 "Get cell's vertical alignment property."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5304 (table--get-property cell 'table-valign))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5305
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5306 (defun table--put-property (cell property value)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5307 "Put CELL's PROPERTY the VALUE."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5308 (let ((beg (car cell))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5309 (end (cdr cell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5310 (put-text-property beg (1+ beg) property value)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5311 (put-text-property (1- end) end property value)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5312
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5313 (defun table--put-cell-justify-property (cell justify)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5314 "Put cell's justify property."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5315 (table--put-property cell 'table-justify justify))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5316
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5317 (defun table--put-cell-valign-property (cell valign)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5318 "Put cell's vertical alignment property."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5319 (table--put-property cell 'table-valign valign))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5320
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5321 (defun table--point-entered-cell-function (&optional old-point new-point)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5322 "Point has entered a cell.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5323 Refresh the menu bar."
77831
03efa2eaa3b7 (table--point-entered-cell-function)
Martin Rudalics <rudalics@gmx.at>
parents: 75347
diff changeset
5324 ;; Avoid calling point-motion-hooks recursively.
03efa2eaa3b7 (table--point-entered-cell-function)
Martin Rudalics <rudalics@gmx.at>
parents: 75347
diff changeset
5325 (let ((inhibit-point-motion-hooks t))
03efa2eaa3b7 (table--point-entered-cell-function)
Martin Rudalics <rudalics@gmx.at>
parents: 75347
diff changeset
5326 (unless table-cell-entered-state
03efa2eaa3b7 (table--point-entered-cell-function)
Martin Rudalics <rudalics@gmx.at>
parents: 75347
diff changeset
5327 (setq table-cell-entered-state t)
03efa2eaa3b7 (table--point-entered-cell-function)
Martin Rudalics <rudalics@gmx.at>
parents: 75347
diff changeset
5328 (setq table-mode-indicator t)
03efa2eaa3b7 (table--point-entered-cell-function)
Martin Rudalics <rudalics@gmx.at>
parents: 75347
diff changeset
5329 (force-mode-line-update)
03efa2eaa3b7 (table--point-entered-cell-function)
Martin Rudalics <rudalics@gmx.at>
parents: 75347
diff changeset
5330 (table--warn-incompatibility)
03efa2eaa3b7 (table--point-entered-cell-function)
Martin Rudalics <rudalics@gmx.at>
parents: 75347
diff changeset
5331 (run-hooks 'table-point-entered-cell-hook))))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5332
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5333 (defun table--point-left-cell-function (&optional old-point new-point)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5334 "Point has left a cell.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5335 Refresh the menu bar."
77831
03efa2eaa3b7 (table--point-entered-cell-function)
Martin Rudalics <rudalics@gmx.at>
parents: 75347
diff changeset
5336 ;; Avoid calling point-motion-hooks recursively.
03efa2eaa3b7 (table--point-entered-cell-function)
Martin Rudalics <rudalics@gmx.at>
parents: 75347
diff changeset
5337 (let ((inhibit-point-motion-hooks t))
03efa2eaa3b7 (table--point-entered-cell-function)
Martin Rudalics <rudalics@gmx.at>
parents: 75347
diff changeset
5338 (when table-cell-entered-state
03efa2eaa3b7 (table--point-entered-cell-function)
Martin Rudalics <rudalics@gmx.at>
parents: 75347
diff changeset
5339 (setq table-cell-entered-state nil)
03efa2eaa3b7 (table--point-entered-cell-function)
Martin Rudalics <rudalics@gmx.at>
parents: 75347
diff changeset
5340 (setq table-mode-indicator nil)
03efa2eaa3b7 (table--point-entered-cell-function)
Martin Rudalics <rudalics@gmx.at>
parents: 75347
diff changeset
5341 (force-mode-line-update)
03efa2eaa3b7 (table--point-entered-cell-function)
Martin Rudalics <rudalics@gmx.at>
parents: 75347
diff changeset
5342 (run-hooks 'table-point-left-cell-hook))))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5343
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5344 (defun table--warn-incompatibility ()
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5345 "If called from interactive operation warn the know incompatibilities.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5346 This feature is disabled when `table-disable-incompatibility-warning'
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5347 is non-nil. The warning is done only once per session for each item."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5348 (unless (and table-disable-incompatibility-warning
105372
bd2966850aac Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents: 104386
diff changeset
5349 (not (called-interactively-p 'interactive)))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5350 (cond ((and (featurep 'xemacs)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5351 (not (get 'table-disable-incompatibility-warning 'xemacs)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5352 (put 'table-disable-incompatibility-warning 'xemacs t)
75117
a2b7810d4ec7 (table--warn-incompatibility):
Richard M. Stallman <rms@gnu.org>
parents: 73654
diff changeset
5353 (display-warning 'table
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5354 "
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5355 *** Warning ***
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5356
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5357 Table package mostly works fine under XEmacs, however, due to the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5358 peculiar implementation of text property under XEmacs, cell splitting
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5359 and any undo operation of table exhibit some known strange problems,
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5360 such that a border characters dissolve into adjacent cells. Please be
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5361 aware of this.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5362
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5363 "
75117
a2b7810d4ec7 (table--warn-incompatibility):
Richard M. Stallman <rms@gnu.org>
parents: 73654
diff changeset
5364 :warning))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5365 ((and (boundp 'flyspell-mode)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5366 flyspell-mode
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5367 (not (get 'table-disable-incompatibility-warning 'flyspell)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5368 (put 'table-disable-incompatibility-warning 'flyspell t)
75117
a2b7810d4ec7 (table--warn-incompatibility):
Richard M. Stallman <rms@gnu.org>
parents: 73654
diff changeset
5369 (display-warning 'table
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5370 "
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5371 *** Warning ***
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5372
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5373 Flyspell minor mode is known to be incompatible with this table
104029
55ba5af4bf3a Kevin Ryde <user42 at zip.com.au>
Glenn Morris <rgm@gnu.org>
parents: 103294
diff changeset
5374 package. The flyspell version 1.5d at URL `http://kaolin.unice.fr/~serrano'
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5375 works better than the previous versions however not fully compatible.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5376
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5377 "
75117
a2b7810d4ec7 (table--warn-incompatibility):
Richard M. Stallman <rms@gnu.org>
parents: 73654
diff changeset
5378 :warning))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5379 )))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5380
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5381 (defun table--cell-blank-str (&optional n)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5382 "Return blank table cell string of length N."
64059
77cc3a2cedb3 (table-hooks): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents: 63227
diff changeset
5383 (let ((str (make-string (or n 1) ?\s)))
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5384 (table--put-cell-content-property 0 (length str) str)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5385 str))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5386
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5387 (defun table--remove-eol-spaces (beg end &optional bol force)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5388 "Remove spaces at the end of each line in the BEG END region of the current buffer.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5389 When optional BOL is non-nil spaces at the beginning of line are
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5390 removed. When optional FORCE is non-nil removal operation is enforced
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5391 even when point is within the removal area."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5392 (if (> beg end)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5393 (let ((tmp beg))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5394 (setq beg end)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5395 (setq end tmp)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5396 (let ((saved-point (point-marker))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5397 (end-marker (copy-marker end)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5398 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5399 (goto-char beg)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5400 (while (if bol (re-search-forward "^\\( +\\)" end-marker t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5401 (re-search-forward "\\( +\\)$" end-marker t))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5402 ;; avoid removal that causes the saved point to lose its location.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5403 (if (and (null bol)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5404 (<= (match-beginning 1) saved-point)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5405 (<= saved-point (match-end 1))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5406 (not force))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5407 (delete-region saved-point (match-end 1))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5408 (delete-region (match-beginning 1) (match-end 1)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5409 (set-marker saved-point nil)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5410 (set-marker end-marker nil)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5411
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5412 (defun table--fill-region (beg end &optional col justify)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5413 "Fill paragraphs in table cell cache.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5414 Current buffer must already be set to the cache buffer."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5415 (let ((fill-column (or col table-cell-info-width))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5416 (fill-prefix nil)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5417 (enable-kinsoku nil)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5418 (adaptive-fill-mode nil)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5419 (marker-beg (copy-marker beg))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5420 (marker-end (copy-marker end))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5421 (marker-point (point-marker)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5422 (setq justify (or justify table-cell-info-justify))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5423 (and justify
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5424 (not (eq justify 'left))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5425 (not (featurep 'xemacs))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5426 (set-marker-insertion-type marker-point t))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5427 (table--remove-eol-spaces (point-min) (point-max))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5428 (if table-fixed-width-mode
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5429 (table--fill-region-strictly marker-beg marker-end)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5430 (let ((paragraph-start table-paragraph-start))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5431 (fill-region marker-beg marker-end justify nil t)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5432 (goto-char marker-point)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5433 (set-marker marker-beg nil)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5434 (set-marker marker-end nil)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5435 (set-marker marker-point nil)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5436
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5437 (defun table--fill-region-strictly (beg end)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5438 "Fill region strictly so that no line exceeds fill-column.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5439 When a word exceeds fill-column the word is chopped into pieces. The
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5440 chopped location is indicated with table-word-continuation-char."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5441 (or (and (markerp beg) (markerp end))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5442 (error "markerp"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5443 (if (< fill-column 2)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5444 (setq fill-column 2))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5445 ;; first remove all continuation characters.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5446 (goto-char beg)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5447 (while (re-search-forward (concat
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5448 (format "[^%c ]\\(" table-word-continuation-char)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5449 (regexp-quote (char-to-string table-word-continuation-char))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5450 "\\s +\\)")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5451 end t)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5452 (delete-region (match-beginning 1) (match-end 1)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5453 ;; then fill as normal
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5454 (let ((paragraph-start table-paragraph-start))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5455 (fill-region beg end nil nil t))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5456 ;; now fix up
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5457 (goto-char beg)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5458 (while (let ((col (move-to-column fill-column t)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5459 (cond
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5460 ((and (<= col fill-column)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5461 (looking-at " *$"))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5462 (delete-region (match-beginning 0) (match-end 0))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5463 (and (zerop (forward-line 1))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5464 (< (point) end)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5465 (t (forward-char -1)
64059
77cc3a2cedb3 (table-hooks): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents: 63227
diff changeset
5466 (insert-before-markers (if (equal (char-before) ?\s) ?\s table-word-continuation-char)
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5467 "\n")
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5468 t)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5469
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5470 (defun table--goto-coordinate (coordinate &optional no-extension no-tab-expansion)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5471 "Move point to the given COORDINATE and return the location.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5472 When optional NO-EXTENSION is non-nil and the specified coordinate is
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5473 not reachable returns nil otherwise the blanks are added if necessary
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5474 to achieve the goal coordinate and returns the goal point. It
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5475 intentionally does not preserve the original point in case it fails
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5476 achieving the goal. When optional NO-TAB-EXPANSION is non-nil and the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5477 goad happens to be in a tab character the tab is not expanded but the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5478 goal ends at the beginning of tab."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5479 (if (or (null coordinate)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5480 (< (car coordinate) 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5481 (< (cdr coordinate) 0)) nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5482 (goto-char (point-min))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5483 (let ((x (car coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5484 (more-lines (forward-line (cdr coordinate))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5485 (catch 'exit
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5486 (if (zerop (current-column)) nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5487 (if no-extension
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5488 (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5489 (move-to-column x)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5490 (throw 'exit nil))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5491 (setq more-lines (1+ more-lines))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5492 (if (zerop more-lines) nil
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5493 (newline more-lines))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5494 (if no-extension
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5495 (if (/= (move-to-column x) x)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5496 (if (> (move-to-column x) x)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5497 (if no-tab-expansion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5498 (progn
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5499 (while (> (move-to-column x) x)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5500 (setq x (1- x)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5501 (point))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5502 (throw 'exit (move-to-column x t)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5503 (throw 'exit nil)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5504 (move-to-column x t))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5505 (point)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5506
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5507 (defun table--copy-coordinate (coord)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5508 "Copy coordinate in a new cons cell."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5509 (cons (car coord) (cdr coord)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5510
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5511 (defun table--get-coordinate (&optional where)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5512 "Return the coordinate of point in current buffer.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5513 When optional WHERE is given it returns the coordinate of that
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5514 location instead of point in the current buffer. It does not move the
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5515 point"
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5516 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5517 (if where (goto-char where))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5518 (cons (current-column)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5519 (table--current-line))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5520
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5521 (defun table--current-line (&optional location)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5522 "Return zero based line count of current line or if non-nil LOCATION line."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5523 (save-excursion
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5524 (if location (goto-char location))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5525 (beginning-of-line)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5526 (count-lines (point-min) (point))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5527
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5528 (defun table--transcoord-table-to-cache (&optional coordinate)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5529 "Transpose COORDINATE from table coordinate system to cache coordinate system.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5530 When COORDINATE is omitted or nil the point in current buffer is assumed in place."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5531 (table--offset-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5532 (or coordinate (table--get-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5533 table-cell-info-lu-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5534 'negative))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5535
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5536 (defun table--transcoord-cache-to-table (&optional coordinate)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5537 "Transpose COORDINATE from cache coordinate system to table coordinate system.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5538 When COORDINATE is omitted or nil the point in current buffer is assumed in place."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5539 (table--offset-coordinate
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5540 (or coordinate (table--get-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5541 table-cell-info-lu-coordinate))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5542
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5543 (defun table--offset-coordinate (coordinate offset &optional negative)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5544 "Return the offseted COORDINATE by OFFSET.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5545 When optional NEGATIVE is non-nil offsetting direction is negative."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5546 (cons (if negative (- (car coordinate) (car offset))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5547 (+ (car coordinate) (car offset)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5548 (if negative (- (cdr coordinate) (cdr offset))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5549 (+ (cdr coordinate) (cdr offset)))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5550
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5551 (defun table--char-in-str-at-column (str column)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5552 "Return the character in STR at COLUMN location.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5553 When COLUMN is out of range it returns null character."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5554 (let ((idx (table--str-index-at-column str column)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5555 (if idx (aref str idx)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5556 ?\0)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5557
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5558 (defun table--str-index-at-column (str column)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5559 "Return the character index in STR that corresponds to COLUMN location.
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5560 It returns COLUMN unless STR contains some wide characters."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5561 (let ((col 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5562 (idx 0)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5563 (len (length str)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5564 (while (and (< col column) (< idx len))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5565 (setq col (+ col (char-width (aref str idx))))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5566 (setq idx (1+ idx)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5567 (if (< idx len)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5568 idx
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5569 nil)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5570
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5571 (defun table--set-timer (seconds func args)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5572 "Generic wrapper for setting up a timer."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5573 (if (featurep 'xemacs)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5574 ;; the picky xemacs refuses to accept zero
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5575 (add-timeout (if (zerop seconds) 0.01 seconds) func args nil)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5576 ;;(run-at-time seconds nil func args)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5577 ;; somehow run-at-time causes strange problem under Emacs 20.7
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5578 ;; this problem does not show up under Emacs 21.0.90
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5579 (run-with-idle-timer seconds nil func args)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5580
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5581 (defun table--cancel-timer (timer)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5582 "Generic wrapper for canceling a timer."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5583 (if (featurep 'xemacs)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5584 (disable-timeout timer)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5585 (cancel-timer timer)))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5586
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5587 (defun table--get-last-command ()
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5588 "Generic wrapper for getting the real last command."
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5589 (if (boundp 'real-last-command)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5590 real-last-command
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5591 last-command))
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5592
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5593 (run-hooks 'table-load-hook)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5594
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5595 (provide 'table)
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5596
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5597 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5598 ;; Local Variables: ***
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5599 ;; time-stamp-line-limit: 16 ***
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5600 ;; time-stamp-start: ";; Revised:[ \t]+" ***
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5601 ;; time-stamp-end: "$" ***
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5602 ;; time-stamp-format: "%3a %3b %02d %:y %02H:%02M:%02S (%Z)" ***
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5603 ;; End: ***
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5604 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5605
60724
3a2908eb7595 (table--line-column-position): New idiom.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59996
diff changeset
5606 ;; arch-tag: 0d69b03e-aa5f-4e72-8806-5727217617e0
46933
efe136f74b89 New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5607 ;;; table.el ends here