mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-12-28 10:56:57 +00:00
Re-install the support for table.el tables again.
This support was totally broken. It works now again. Unfortunately it is not possible to edit the table directly in the org-mode buffer anymore - to edit such a table, you have to use C-c '
This commit is contained in:
parent
045676bcaa
commit
6d1e30828b
@ -2,6 +2,7 @@
|
||||
|
||||
* org.texi (The date/time prompt): Document that we accept dates
|
||||
like month/day/year.
|
||||
(Cooperation): Document the changes in table.el support.
|
||||
|
||||
2010-02-25 Carsten Dominik <carsten.dominik@gmail.com>
|
||||
|
||||
|
27
doc/org.texi
27
doc/org.texi
@ -10857,9 +10857,6 @@ works even if the automatic table editor has been turned off.
|
||||
If the cursor is on a @code{#+TBLFM} line, re-apply the formulas to
|
||||
the entire table.
|
||||
@item
|
||||
If the cursor is inside a table created by the @file{table.el} package,
|
||||
activate that table.
|
||||
@item
|
||||
If the current buffer is a Remember buffer, close the note and file it.
|
||||
With a prefix argument, file it, without further interaction, to the
|
||||
default location.
|
||||
@ -11122,20 +11119,18 @@ the command @kbd{<} in the Speedbar frame.
|
||||
@cindex @file{table.el}
|
||||
@cindex Ota, Takaaki
|
||||
|
||||
Complex ASCII tables with automatic line wrapping, column- and
|
||||
row-spanning, and alignment can be created using the Emacs table
|
||||
package by Takaaki Ota (@uref{http://sourceforge.net/projects/table},
|
||||
and also part of Emacs 22).
|
||||
When @key{TAB} or @kbd{C-c C-c} is pressed in such a table, Org mode
|
||||
will call @command{table-recognize-table} and move the cursor into the
|
||||
table. Inside a table, the keymap of Org mode is inactive. In order
|
||||
to execute Org mode-related commands, leave the table.
|
||||
Complex ASCII tables with automatic line wrapping, column- and row-spanning,
|
||||
and alignment can be created using the Emacs table package by Takaaki Ota
|
||||
(@uref{http://sourceforge.net/projects/table}, and also part of Emacs 22).
|
||||
Org-mode will recognize these tables and export them properly. Because of
|
||||
interference with other Org-mode functionality, you unfortunately cannot edit
|
||||
these tables directly in the buffer. Instead, you need to use the command
|
||||
@kbd{C-c '} to edit them, similar to source code snippets.
|
||||
|
||||
@table @kbd
|
||||
@kindex C-c C-c
|
||||
@item C-c C-c
|
||||
Recognize @file{table.el} table. Works when the cursor is in a
|
||||
table.el table.
|
||||
@kindex C-c '
|
||||
@item C-c '
|
||||
Edit a @file{table.el} table. Works when the cursor is in a table.el table.
|
||||
@c
|
||||
@kindex C-c ~
|
||||
@item C-c ~
|
||||
@ -11145,7 +11140,7 @@ format. See the documentation string of the command
|
||||
@code{org-convert-table} for the restrictions under which this is
|
||||
possible.
|
||||
@end table
|
||||
@file{table.el} is part of Emacs 22.
|
||||
@file{table.el} is part of Emacs since Emacs 22.
|
||||
@item @file{footnote.el} by Steven L. Baur
|
||||
@cindex @file{footnote.el}
|
||||
@cindex Baur, Steven L.
|
||||
|
@ -1,5 +1,20 @@
|
||||
2010-02-26 Carsten Dominik <carsten.dominik@gmail.com>
|
||||
|
||||
* org.el (org-cycle): Print a message when in a table.el table.
|
||||
(org-edit-special): Recognize the table.el context.
|
||||
(org-ctrl-c-ctrl-c): Print a message when in a table.el table.
|
||||
|
||||
* org-src.el (org-at-table.el-p): Declare.
|
||||
(org-edit-src-code): Handle a special case for table.el editing.
|
||||
(org-edit-src-find-region-and-lang): Recognize the table.el
|
||||
context.
|
||||
|
||||
* org-latex.el (org-export-latex-tables): Convert table.el
|
||||
tables.
|
||||
(org-export-latex-convert-table.el-table): New function.
|
||||
|
||||
* org-html.el (org-html-expand): Fix table.el export.
|
||||
|
||||
* org-latex.el (org-export-latex-preprocess): Protect footnotes in
|
||||
headings.
|
||||
|
||||
|
@ -1876,15 +1876,17 @@ If there are links in the string, don't modify these."
|
||||
(let* ((re (concat org-bracket-link-regexp "\\|"
|
||||
(org-re "[ \t]+\\(:[[:alnum:]_@:]+:\\)[ \t]*$")))
|
||||
m s l res)
|
||||
(while (setq m (string-match re string))
|
||||
(setq s (substring string 0 m)
|
||||
l (match-string 0 string)
|
||||
string (substring string (match-end 0)))
|
||||
(push (org-html-do-expand s) res)
|
||||
(push l res))
|
||||
(push (org-html-do-expand string) res)
|
||||
(apply 'concat (nreverse res))))
|
||||
|
||||
(if (string-match "^[ \t]*\\+-[-+]*\\+[ \t]*$" string)
|
||||
string
|
||||
(while (setq m (string-match re string))
|
||||
(setq s (substring string 0 m)
|
||||
l (match-string 0 string)
|
||||
string (substring string (match-end 0)))
|
||||
(push (org-html-do-expand s) res)
|
||||
(push l res))
|
||||
(push (org-html-do-expand string) res)
|
||||
(apply 'concat (nreverse res)))))
|
||||
|
||||
(defun org-html-do-expand (s)
|
||||
"Apply all active conversions to translate special ASCII to HTML."
|
||||
(setq s (org-html-protect s))
|
||||
|
@ -1537,6 +1537,13 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
|
||||
(declare-function orgtbl-to-latex "org-table" (table params) t)
|
||||
(defun org-export-latex-tables (insert)
|
||||
"Convert tables to LaTeX and INSERT it."
|
||||
;; First, get the table.el tables
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "^[ \t]*\\(\\+-[-+]*\\+\\)[ \t]*\n[ \t]*|" nil t)
|
||||
(require 'table)
|
||||
(org-export-latex-convert-table.el-table))
|
||||
|
||||
;; And now the Org-mode tables
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "^\\([ \t]*\\)|" nil t)
|
||||
(org-if-unprotected-at (1- (point))
|
||||
@ -1649,6 +1656,56 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
|
||||
(if floatp "\\end{table}"))))
|
||||
"\n\n"))))))))
|
||||
|
||||
(defun org-export-latex-convert-table.el-table ()
|
||||
"Replace table.el table at point with LaTeX code."
|
||||
(let (tbl caption label line floatp attr align rmlines)
|
||||
(setq line (buffer-substring (point-at-bol) (point-at-eol))
|
||||
label (org-get-text-property-any 0 'org-label line)
|
||||
caption (org-get-text-property-any 0 'org-caption line)
|
||||
attr (org-get-text-property-any 0 'org-attributes line)
|
||||
align (and attr (stringp attr)
|
||||
(string-match "\\<align=\\([^ \t\n\r,]+\\)" attr)
|
||||
(match-string 1 attr))
|
||||
rmlines (and attr (stringp attr)
|
||||
(string-match "\\<rmlines\\>" attr))
|
||||
floatp (or label caption))
|
||||
(and (get-buffer "*org-export-table*")
|
||||
(kill-buffer (get-buffer "*org-export-table*")))
|
||||
(table-generate-source 'latex "*org-export-table*" "caption")
|
||||
(setq tbl (with-current-buffer "*org-export-table*"
|
||||
(buffer-string)))
|
||||
(while (string-match "^%.*\n" tbl)
|
||||
(setq tbl (replace-match "" t t tbl)))
|
||||
;; fix the hlines
|
||||
(when rmlines
|
||||
(let ((n 0) lines)
|
||||
(setq lines (mapcar (lambda (x)
|
||||
(if (string-match "^\\\\hline$" x)
|
||||
(progn
|
||||
(setq n (1+ n))
|
||||
(if (= n 2) x nil))
|
||||
x))
|
||||
(org-split-string tbl "\n")))
|
||||
(setq tbl (mapconcat 'identity (delq nil lines) "\n"))))
|
||||
(when (and align (string-match "\\\\begin{tabular}{.*}" tbl))
|
||||
(setq tbl (replace-match (concat "\\begin{tabular}{" align "}")
|
||||
t t tbl)))
|
||||
(and (get-buffer "*org-export-table*")
|
||||
(kill-buffer (get-buffer "*org-export-table*")))
|
||||
(beginning-of-line 0)
|
||||
(while (looking-at "[ \t]*\\(|\\|\\+-\\)")
|
||||
(delete-region (point) (1+ (point-at-eol))))
|
||||
(when org-export-latex-tables-centered
|
||||
(setq tbl (concat "\\begin{center}\n" tbl "\\end{center}")))
|
||||
(when floatp
|
||||
(setq tbl (concat "\\begin{table}\n"
|
||||
(format "\\caption{%s%s}\n"
|
||||
(if label (format "\\label{%s}" label) "")
|
||||
(or caption ""))
|
||||
tbl
|
||||
"\n\\end{table}\n")))
|
||||
(insert (org-export-latex-protect-string tbl))))
|
||||
|
||||
(defun org-export-latex-fontify ()
|
||||
"Convert fontification to LaTeX."
|
||||
(goto-char (point-min))
|
||||
|
@ -38,6 +38,7 @@
|
||||
(require 'cl))
|
||||
|
||||
(declare-function org-do-remove-indentation "org" (&optional n))
|
||||
(declare-function org-at-table.el-p "org" ())
|
||||
(declare-function org-get-indentation "org" (&optional line))
|
||||
(declare-function org-switch-to-buffer-other-window "org" (&rest args))
|
||||
|
||||
@ -113,7 +114,6 @@ When nil, the message will only be shown intermittently in the echo area."
|
||||
:group 'org-edit-structure
|
||||
:type 'boolean)
|
||||
|
||||
|
||||
(defcustom org-src-window-setup 'reorganize-frame
|
||||
"How the source code edit buffer should be displayed.
|
||||
Possible values for this option are:
|
||||
@ -221,6 +221,13 @@ the edited version. Optional argument CONTEXT is used by
|
||||
block-nindent (nth 5 info)
|
||||
lang-f (intern (concat lang "-mode"))
|
||||
begline (save-excursion (goto-char beg) (org-current-line)))
|
||||
(if (equal lang-f 'table.el-mode)
|
||||
(setq lang-f (lambda ()
|
||||
(text-mode)
|
||||
(if (org-bound-and-true-p flyspell-mode)
|
||||
(flyspell-mode -1))
|
||||
(table-recognize)
|
||||
(org-set-local 'org-edit-src-content-indentation 0))))
|
||||
(unless (functionp lang-f)
|
||||
(error "No such language mode: %s" lang-f))
|
||||
(org-goto-line line)
|
||||
@ -452,6 +459,15 @@ the language, a switch telling if the content should be in a single line."
|
||||
(pos (point))
|
||||
re1 re2 single beg end lang lfmt match-re1 ind entry)
|
||||
(catch 'exit
|
||||
(when (org-at-table.el-p)
|
||||
(re-search-backward "^[\t]*[^ \t|\\+]" nil t)
|
||||
(setq beg (1+ (point-at-eol)))
|
||||
(goto-char beg)
|
||||
(or (re-search-forward "^[\t]*[^ \t|\\+]" nil t)
|
||||
(progn (goto-char (point-max)) (newline)))
|
||||
(setq end (point-at-bol))
|
||||
(setq ind (org-edit-src-get-indentation beg))
|
||||
(throw 'exit (list beg end 'table.el nil nil ind)))
|
||||
(while (setq entry (pop re-list))
|
||||
(setq re1 (car entry) re2 (nth 1 entry) lang (nth 2 entry)
|
||||
single (nth 3 entry))
|
||||
|
20
lisp/org.el
20
lisp/org.el
@ -5230,11 +5230,11 @@ in special contexts.
|
||||
|
||||
((org-at-table-p 'any)
|
||||
;; Enter the table or move to the next field in the table
|
||||
(or (org-table-recognize-table.el)
|
||||
(progn
|
||||
(if arg (org-table-edit-field t)
|
||||
(org-table-justify-field-maybe)
|
||||
(call-interactively 'org-table-next-field)))))
|
||||
(if (org-at-table.el-p)
|
||||
(message "Use C-c ' to edit table.el tables")
|
||||
(if arg (org-table-edit-field t)
|
||||
(org-table-justify-field-maybe)
|
||||
(call-interactively 'org-table-next-field))))
|
||||
|
||||
((run-hook-with-args-until-success
|
||||
'org-tab-after-check-for-table-hook))
|
||||
@ -15908,6 +15908,8 @@ When in an #+include line, visit the include file. Otherwise call
|
||||
`ffap' to visit the file at point."
|
||||
(interactive)
|
||||
(cond
|
||||
((org-at-table.el-p)
|
||||
(org-edit-src-code))
|
||||
((org-at-table-p)
|
||||
(call-interactively 'org-table-edit-formulas))
|
||||
((save-excursion
|
||||
@ -15948,9 +15950,6 @@ This command does many different things, depending on context:
|
||||
|
||||
- If the cursor is a the beginning of a dynamic block, update it.
|
||||
|
||||
- If the cursor is inside a table created by the table.el package,
|
||||
activate that table.
|
||||
|
||||
- If the current buffer is a remember buffer, close note and file
|
||||
it. A prefix argument of 1 files to the default location
|
||||
without further interaction. A prefix argument of 2 files to
|
||||
@ -15985,10 +15984,7 @@ This command does many different things, depending on context:
|
||||
(call-interactively 'org-update-statistics-cookies))
|
||||
((org-on-heading-p) (call-interactively 'org-set-tags))
|
||||
((org-at-table.el-p)
|
||||
(require 'table)
|
||||
(beginning-of-line 1)
|
||||
(re-search-forward "|" (save-excursion (end-of-line 2) (point)))
|
||||
(call-interactively 'table-recognize-table))
|
||||
(message "Use C-c ' to edit table.el tables"))
|
||||
((org-at-table-p)
|
||||
(org-table-maybe-eval-formula)
|
||||
(if arg
|
||||
|
Loading…
Reference in New Issue
Block a user