Commit Graph

476 Commits

Author SHA1 Message Date
Michael Brand 0f5f58037d Fix table formula debugger error display
* lisp/org-table.el (org-table-eval-formula): Align the arrow pointing
to the error in a Calc formula to the other fomula debugger logs.
2013-09-07 16:21:38 +02:00
Carsten Dominik 4242b12d1b Fix typo. 2013-09-03 07:07:57 +02:00
Carsten Dominik 3f10db731c Improve docstring of `orgtbl-radio-table-templates'
* lisp/org-table.el (orgtbl-radio-table-templates): Improve docstring.
2013-09-02 11:33:54 +02:00
Carsten Dominik daf36fc918 Fix some issue with orgtbl-mode
* lisp/org-table.el (orgtbl-send-replace-tbl): Allow multiple spaces between
keywords in RECEIVE ORGTBL lines.
* doc/org.texi (A @LaTeX{} example): Fix typo in variable name.
2013-08-30 17:53:28 +02:00
Bastien Guerry 7be5f737f8 Merge branch 'maint' 2013-07-03 10:18:35 +02:00
Bastien Guerry 244aaa3d72 org-table.el (org-table-sum): Fix rounding error when summing times
* org-table.el (org-table-sum): Fix rounding error when
summing times.

Thanks to Paul Stansell for reporting this and to Nick Dokos for
providing the fix.

See http://mid.gmane.org/87ppv2atvf.fsf%40gmail.com for the
discussion of this bug.
2013-07-03 10:18:22 +02:00
Bastien Guerry 5a36318511 Merge branch 'maint' 2013-06-28 09:13:41 +02:00
Achim Gratz 30581835bd do not use mapcar* for transposing tables
* lisp/ob-core.el (org-babel-get-rownames),
  lisp/org-table.el (org-table-transpose-table-at-point): Replace the
  inadvertent use of mapcar* (from cl) by plain mapcar and direct cons
  manipulation.

The error was not caught at compilation time since both source files
require cl during compilation for using cl macros.  These were the
only uses of mapcar* in Org, but I didn't check for other cl
_functions_ (as opposed to macros, which would need to be checked if
their implementation uses cl functions).
2013-06-27 20:17:22 +02:00
Carsten Dominik 29797e921d Fix `interactive' statement in `org-table-convert-region'
* lisp/org-table.el (org-table-convert-region): Fix interactive statement.
2013-06-01 07:46:08 +02:00
Bastien Guerry 8b15ff9d07 Merge branch 'maint' 2013-05-15 16:31:54 +02:00
Bastien Guerry 0c31a4fcb6 org-table.el: Rename a variable and a function
* org-table.el (org-table-TBLFM-begin-regexp): Rename from
`org-TBLFM-begin-regexp'.
(org-table-calc-current-TBLFM): Rename from
`org-calc-current-TBLFM'.

* org.el (org-ctrl-c-ctrl-c): Require org-table if needed.
2013-05-15 16:18:37 +02:00
Achim Gratz 646f1ac426 org-table: several cleanups
* lisp/org.el (org-table-clean-did-remove-column),
  lisp/org-table.el (org-table-clean-did-remove-column): Move defvar,
  this dynamic variable is only used in org-table.
* lisp/org-table.el (org-table-colgroup-info): Remove unused defvar
  for `org-table-colgroup-info'.
  (org-table-clean-before-export): Let-bind regular expression strings
  and remove unused matching group.  Use
  `org-table-clean-did-remove-column' in cond statement rather than
  branching via if to avoid code duplication.  Remove the code
  associated with the removed `org-table-colgroup-info'.
  (orgtbl-export): Remove unused internal function.
2013-05-12 21:10:19 +02:00
Michael Brand 92f3729857 Allow also "#+NAME: table" for remote references
* lisp/org-table.el (org-table-get-remote-range): Extend regexp to
match "#+NAME: table" additionally to "#+TBLNAME: table".
* testing/lisp/test-org-table.el: Add test.
* testing/org-test.el (org-test-table-target-expect): Allow several
tables to support testing remote references in the last table.
2013-04-26 23:17:48 +02:00
Bastien Guerry 2c46ecee4f org-table.el (org-table-get-remote-range): Fix typo
* org-table.el (org-table-get-remote-range): Fix typo.
2013-04-18 15:42:31 +02:00
Bastien Guerry 9ac7fabb46 org-table.el (org-table-copy-down): Don't move cursor when getting the field
* org-table.el (org-table-copy-down): Don't move cursor when
getting the field.

This prevents the point from moving when inadvertently calling
S-RET outside of a table.
2013-04-11 00:32:33 +02:00
Bastien Guerry 01d6b355d8 Use #+NAME instead of #+TBLNAME
* org-table.el (org-table-get-remote-range): Fix docstring:
use #+NAME instead of #+TBLNAME.

* ob-ref.el: Use #+NAME instead of #+TBLNAME in comment.
2013-04-09 22:09:00 +02:00
Michael Brand 5625a6ed79 org-table.el: Fix range len bugs for empty ranges
(org-table-make-reference): A range with only empty fields should lead
to length 0.
* testing/lisp/test-org-table.el: Adapt expected for several
ert-deftest.

The range len bugs may lead to wrong calculations for range references
with empty fields when the range len is relevant.  Affects typically
Calc vmean on simple range and without format specifier EN.  Also
Lisp with e. g. `length' on simple range or with L.

It is worth a small compatibility change: For a range with only empty
fields it is now possible and necessary to choose different behaviors
of vmean by adding the format specifiers E and/or N.

This is a follow-up of commit
764315b3fc.
2013-04-09 19:05:20 +02:00
Rémi Vanicat 1f8822101b Correctly format orgtbl line when there is a :lfmt argument.
* org-table.el (orgtbl-format-line): Fix bug when formatting
line.

TINYCHANGE
2013-04-07 09:41:00 +02:00
Bastien Guerry 0625b53a07 org-table.el (orgtbl-apply-fmt): Enhance docstring
* org-table.el (orgtbl-apply-fmt): Enhance docstring.
2013-04-07 09:36:52 +02:00
Ippei FURUHASHI 67a55acb39 org-table.el: Fix a bug of leaving the inserted TBLFM line
* org-table.el (org-calc-current-TBLFM): Ensure to remove the
currently inserted TBLFM line, when calling `org-table-recalculate'
returns an error and the processing stops.

* testing/lisp/test-org-table.el: Add test.

When you hit =C-c C-c= at the line of "#+TBLFM: $2=$1*2::$2=$1**2" in

    | 1 |   |
    | 2 |   |
    #+TBLFM: $2=$1*1
    #+TBLFM: $2=$1*2::$2=$1**2

you got:

    | 1 |   |
    | 2 |   |
    #+TBLFM: $2=$1*2::$2=$1**2
    #+TBLFM: $2=$1*1
    #+TBLFM: $2=$1*2::$2=$1**2

with the error message of:

    user-error: Double definition `$2=' in TBLFM line, please fix by hand

In this case, you expected:

    | 1 |   |
    | 2 |   |
    #+TBLFM: $2=$1*1
    #+TBLFM: $2=$1*2::$2=$1**2
2013-04-06 15:15:44 +02:00
Ippei FURUHASHI 6693456dd7 org-table.el (org-calc-current-TBLFM): Add function
* org-table.el (org-calc-current-TBLFM): New function to
re-calculate the table by applying the #+TBLFM in the line
where the point is.

* org.el (org-ctrl-c-ctrl-c): Call `org-calc-current-TBLFM' when
point is in the #+TBLFM line.

* testing/lisp/test-org-table.el: Add test.
2013-04-05 08:37:51 +02:00
Ippei FURUHASHI c8c17460f1 org-table.el (org-TBLFM-begin): Add function
* org-table.el (org-TBLFM-begin): New defun.
(org-TBLFM-begin-regexp): New variable.

* testing/lisp/test-org-table.el: Add test.
2013-04-05 08:37:51 +02:00
Bastien Guerry de4d520610 org-table.el (orgtbl-to-generic): Fix bug when exporting the cells of radio tables with 'hline
* org-table.el (orgtbl-to-generic): Fix bug when exporting the
cells of radio tables with 'hline.

Thanks to David Kincaid for reporting this.
2013-04-04 00:21:31 +02:00
Carsten Dominik 21fead7888 Revert "Work around calc-eval regression"
This reverts commit 10e239f434.
2013-03-25 15:48:56 +01:00
Carsten Dominik 10e239f434 Work around calc-eval regression
* lisp/org-table.el (org-table-eval-formula): Work-around for
  calc-eval regression.

Calc-eval can no longer be called without initializing the
*Calculator* buffer first.
2013-03-25 11:48:21 +01:00
Bastien Guerry 70417caa90 org-table.el (orgtbl-to-latex, orgtbl-to-texinfo): Export cells to LaTeX and Texinfo before sending the table
* org-table.el (orgtbl-to-generic): New parameter `backend' to
export cells content using a specific backend.
(orgtbl-to-latex, orgtbl-to-texinfo): Export cells to LaTeX
and Texinfo before sending the table.

Thanks to Luca Sabbatini for reporting a problem that led to this change.
2013-03-19 19:39:35 +01:00
Bastien Guerry d8969931a9 org-table.el: Fix setting of constants.
* org.el (org-set-regexps-and-options): Use
`org-table-set-constants'.

* org-table.el (org-table-set-constants): New function.
(orgtbl-ctrl-c-ctrl-c): Use it.

Thanks to Oliver Večerník for reporting problems here.
2013-03-19 19:39:34 +01:00
Achim Gratz e541a1dd19 fix a stray "user-error" introduced in bd89d6a02f
* lisp/org-table.el (org-table-eval-formula): The condition-case to
  check for must be "error", not "user-error".

This fixes these test failures:

4 unexpected results:
   FAILED  test-org-table/references/format-specifier-E
   FAILED  test-org-table/references/format-specifier-EL
   FAILED  test-org-table/references/format-specifier-L
   FAILED  test-org-table/references/format-specifier-none

Reported in:
http://permalink.gmane.org/gmane.emacs.orgmode/67450
http://permalink.gmane.org/gmane.emacs.orgmode/67503
2013-03-03 20:29:58 +01:00
Bastien Guerry bd89d6a02f org-table.el: Use `user-error' instead of `error' for user errors
* org-table.el (org-table-convert-region, org-table-export)
(org-table-align, org-table-beginning-of-field)
(org-table-copy-down, org-table-check-inside-data-field)
(org-table-insert-column, org-table-find-dataline)
(org-table-delete-column, org-table-move-column)
(org-table-insert-row, org-table-insert-hline)
(org-table-kill-row, org-table-paste-rectangle)
(org-table-wrap-region, org-table-sum, org-table-get-formula)
(org-table-get-formula, org-table-get-stored-formulas)
(org-table-fix-formulas, org-table-maybe-eval-formula)
(org-table-rotate-recalc-marks, org-table-eval-formula)
(org-table-get-range, org-table-get-descriptor-line)
(org-table-find-row-type, org-table-recalculate)
(org-table-iterate, org-table-iterate-buffer-tables)
(org-table-formula-handle-first/last-rc)
(org-table-edit-formulas, org-table-fedit-shift-reference)
(org-rematch-and-replace, org-table-shift-refpart)
(org-table-fedit-finish, org-table-fedit-lisp-indent)
(org-table-show-reference, org-table-show-reference)
(org-table-show-reference, org-table-show-reference)
(org-table-force-dataline, orgtbl-error, orgtbl-export)
(orgtbl-send-replace-tbl, org-table-to-lisp)
(orgtbl-send-table, orgtbl-send-table, orgtbl-send-table)
(orgtbl-toggle-comment, orgtbl-insert-radio-table)
(orgtbl-to-unicode, org-table-get-remote-range)
(org-table-get-remote-range, org-table-copy-dow)
(org-table-check-inside-data-field, org-table-insert-colum)
(org-table-find-dataline, org-table-delete-colum)
(org-table-move-column, org-table-insert-ro)
(org-table-insert-hline, org-table-kill-ro)
(org-table-paste-rectangle, org-table-wrap-regio)
(org-table-sum, org-table-get-formul)
(org-table-get-stored-formulas, org-table-fix-formula)
(org-table-maybe-eval-formul, org-table-rotate-recalc-marks)
(org-table-eval-formul, org-table-get-range)
(org-table-get-descriptor-lin, org-table-find-row-type)
(org-table-recalculat, org-table-iterate)
(org-table-iterate-buffer-table)
(org-table-formula-handle-first/last-r)
(org-table-edit-formulas, org-table-fedit-shift-referenc)
(org-rematch-and-replace, org-table-shift-refpar)
(org-table-fedit-finish, org-table-fedit-lisp-inden)
(org-table-show-reference, org-table-force-datalin)
(orgtbl-error, orgtbl-export, orgtbl-send-replace-tb)
(org-table-to-lisp, orgtbl-send-tabl, orgtbl-toggle-comment)
(orgtbl-insert-radio-tabl, orgtbl-to-unicode)
(org-table-get-remote-range): Use `user-error' instead of
`error' for user errors.
2013-03-02 15:40:09 +01:00
Bastien Guerry 71c3c12b39 Use `user-error' when moving or modifying the element at point is not possible
* org.el (org-move-subtree-down, org-forward-element)
(org-backward-element):
* org-table.el (org-table-previous-field)
(org-table-move-column, org-table-move-row):
* org-list.el (org-move-item-down, org-move-item-up)
(org-cycle-item-indentation): Use `user-error' when moving or
modifying the element at point is not possible.
2013-02-22 10:31:35 +01:00
Bastien Guerry 3891c97a72 Remove useless code (leftover from the new exporter merge). 2013-02-19 19:07:02 +01:00
Bastien Guerry adcc0d414b org-table.el (org-table-align): Only set the window start when table alignment is performed in the selected window
* org-table.el (org-table-align): Only set the window start
when table alignment is performed in the selected window.

Thanks to Michael Brand for reporting this.

When opening an .org file from another .org file, org-mode
is initialized in the second one while the window is not yet
selected.  So, functions run during org-mode's initialization
need to check if the org-mode window is the selected one before
manipulating the "current window".
2013-02-16 14:08:47 +01:00
Nicolas Goaziou 0a01e52aa1 Install new exporter into Org innards
* contrib/lisp/org-mime.el (org-mime-htmlize, org-mime-compose): Use
  new exporter.
* lisp/ob-haskell.el (org-babel-haskell-export-to-lhs): Use new
  exporter.
* lisp/ob-latex.el (org-babel-execute:latex): Use new exporter.
* lisp/ob-org.el (org-babel-execute:org): Use new exporter.
* lisp/org-agenda.el (org-agenda-menu, org-agenda-write): Use new
  iCalendar export back-end.
* lisp/org-table.el (org-table-export, orgtbl-export): Remove
  dependency on `org-exp' library.
(org-table-clean-before-export): New function.
(org-table-colgroup-info): New variable.
(orgtbl-to-html): Use to new HTML export back-end.
* lisp/org.el (org-modules): Remove modules relative to obsolete
  export framework and add those relative to the new one.
(org-create-formula-image-with-dvipng, org-format-latex
org-create-formula-image-with-imagemagick): Use new exporter.
(org-indent-line): INCLUDE keywords are indented like regular
keywords.
(org-mode-map): Bind C-c C-e to new export dispatcher.
(org-menu): Install new exporter in menu.
2013-02-06 23:06:30 +01:00
Bastien Guerry 60b23bdeac Merge branch 'maint'
Conflicts:
	contrib/lisp/htmlize.el
	etc/schema/od-manifest-schema-v1.2-os.rnc
	etc/schema/od-schema-v1.2-os.rnc
	lisp/org-exp-blocks.el
2013-01-01 16:06:17 +01:00
Bastien Guerry 98cd4687a2 Update copyright years.
Happy new year!
2013-01-01 16:04:24 +01:00
Michael Brand a77442b37b Use nan for empty fields in Calc formulas
* doc/org.texi (Formula syntax for Calc): Add explanation and example
for empty field.
* lisp/org-table.el (org-table-eval-formula): Use `keep-empty' in more
places.
(org-table-make-reference): Use nan (not a number) for empty fields in
Calc formulas.
* testing/lisp/test-org-table.el: Adapt expected for several
ert-deftest.
(test-org-table/empty-field): New examples dealing with empty fields.
(test-org-table/copy-field): New ert-deftest with examples dealing with
empty fields.

This makes it possible to write spreadsheet Calc formulas that check
for empty fields:  To sum the first two columns unless one or both
empty:
$3 = if("$1" = "nan" || "$2" = "nan", string(""), $1 + $2); E
2012-12-29 14:33:52 +01:00
Michael Brand 764315b3fc org-table.el: Fix range len bugs and inconsistencies
* lisp/org-table.el (org-table-eval-formula): Keep empty fields during
preprocessing.
(org-table-make-reference): A range with only empty fields should not
always return 0 but also empty string, consistent with field reference
of an empty field.  Use future design for nan but replicate current
behavior.
* testing/lisp/test-org-table.el: Adapt expected for several
ert-deftest.

The range len bugs may lead to wrong calculations for range references
with empty fields when the range len is relevant.  Affects typically
Calc vmean on simple range and without format specifier EN.  Also
Lisp with e. g. `length' on simple range or with L.
2012-12-29 14:33:52 +01:00
Michael Brand 0ce406151f Extend org-table-number-regexp
* lisp/org-table.el (org-table-number-regexp): Extend 0x hex to
fixed-point number, add <radix>#<number>, add Calc infinite numbers
uinf, -inf and inf.
* testing/lisp/test-org-table.el (test-org-table/align): Adapt
alignment.
2012-12-29 14:33:52 +01:00
Bastien Guerry 953b920c9b Merge branch 'maint' 2012-12-23 17:31:57 +01:00
Bastien Guerry f0a64ab3b5 org-table.el: Use `org-delete-backward-char' which doesn't modify match data anymore
* org-table.el (org-table-fedit-lisp-indent)
(orgtbl-self-insert-command): Use `org-delete-backward-char'
instead of `backward-delete-char'.

* org.el (org-delete-backward-char, org-delete-char): Save
match data.
2012-12-23 17:31:41 +01:00
Bastien Guerry c2e662cf79 Revert "Save match data in `org-delete-backward-char' and `org-delete-char'"
This reverts commit c800836d7c.
2012-12-23 17:26:45 +01:00
Bastien Guerry 9f1f0535be Merge branch 'maint' 2012-12-23 17:20:51 +01:00
Bastien Guerry c800836d7c Save match data in `org-delete-backward-char' and `org-delete-char'
* org.el (org-delete-backward-char, org-delete-char): Save
match data (`delete-backward-char' and `delete-char' don't.)
(org-enable-table-editor, org-insert-heading)
(org-remove-timestamp-with-keyword, org-self-insert-command):
Use `delete-backward-char' instead of `backward-delete-char'.

* org-table.el (org-table-fedit-lisp-indent)
(orgtbl-self-insert-command): Ditto.

* org-latex.el (org-export-latex-subcontent): Ditto.

* org-clock.el (org-clocktable-write-default): Ditto.

* org-ascii.el (org-export-ascii-preprocess): Ditto.

Thanks to Vegard Vesterheim for raising this issue and proposing a patch,
and to Carsten for pointing at the root of the problem.
2012-12-23 12:30:40 +01:00
Bastien Guerry 5de94e46e4 Merge branch 'maint' 2012-12-20 13:16:47 +01:00
Dmitry Antipov bfb9f9d10f Use (point-marker) instead of (move-marker (make-marker) (point))
* org-agenda.el (org-agenda-get-restriction-and-command): Use `point-marker'.
* org-capture.el (org-capture-place-template): Likewise.
* org-colview-xemacs.el (org-dblock-write:columnview): Likewise.
* org-colview.el (org-dblock-write:columnview): Likewise.
* org-mobile.el (org-mobile-locate-entry): Likewise.
* org-table.el (org-table-convert-region): Likewise.
* org.el (org-update-statistics-cookies): Likewise.
* contrib/lisp/org-invoice.el (org-dblock-write:invoice): Likewise.
2012-12-20 13:16:41 +01:00
Bastien Guerry beeb9168dd org-table.el: Handle localized time-stamps in formulas evaluation
* org-table.el (org-table-eval-formula): Handle localized
time-stamps by internally converting them to english during
formulas evaluation.

Thanks to Viktor Rosenfeld for suggesting this.
2012-12-20 01:36:05 +01:00
Bastien Guerry 5508053d63 Merge branch 'maint' 2012-12-11 18:14:00 +01:00
Bastien Guerry c3a0dc11a3 org-table.el: Ensure table coordinates are correctly displayed when sorting.
* org-table.el (org-table-sort-lines): Ensure coordinates are
correctly displayed when sorting.

* org.el (org-do-sort): Enhance prompt.
2012-12-11 17:29:38 +01:00
Jarmo Hurri e375cfd834 Table lookup functions
* lisp/org-table.el: added macro org-define-lookup-function and the
calls to this macro that generate the lookup functions
org-lookup-first, org-lookup-last and org-lookup-all
* doc/org.texi: documented lookup functions
2012-10-24 14:59:33 +02:00
Bastien Guerry 30f1a62878 Update autoloads.
* org.el: Don't dynamically autoload already autoloaded
functions.
(org-clock-update-time-maybe): Move to org-clock.el.

* org-exp.el (org-insert-export-options-template): Remove
autoload cookie.

* org-clock.el (org-resolve-clocks, org-clock-in)
(org-clock-out, org-clock-cancel, org-clock-goto)
(org-clock-sum, org-clock-display, org-clock-report)
(org-dblock-write:clocktable): Add autoload cookie.
(org-clock-update-time-maybe): Moved from org.el.

* org-beamer.el (org-beamer-sectioning, org-beamer-mode): Ditto.

* org-ascii.el (org-export-ascii-preprocess): Ditto.

* org-archive.el (org-archive-subtree)
(org-archive-to-archive-sibling, org-toggle-archive-tag): Add
autoload cookie.

* org-colview.el (org-columns, org-dblock-write:columnview)
(org-insert-columns-dblock, org-agenda-columns): Ditto.

* org-table.el (org-table-create-with-table.el)
(org-table-create-or-convert-from-region, org-table-create)
(org-table-convert-region, org-table-import)
(org-table-export, org-table-align)
(org-table-justify-field-maybe, org-table-next-field)
(org-table-previous-field, org-table-next-row)
(org-table-copy-down, org-table-field-info)
(org-table-current-dline, org-table-goto-column)
(org-table-insert-column, org-table-delete-column)
(org-table-move-column-right, org-table-move-column-left)
(org-table-move-column, org-table-move-row-down)
(org-table-move-row-up, org-table-move-row)
(org-table-insert-row, org-table-insert-hline)
(org-table-hline-and-move, org-table-kill-row)
(org-table-sort-lines, org-table-cut-region)
(org-table-copy-region, org-table-paste-rectangle)
(org-table-convert, org-table-wrap-region)
(org-table-edit-field, org-table-sum)
(org-table-get-stored-formulas)
(org-table-maybe-eval-formula)
(org-table-rotate-recalc-marks)
(org-table-maybe-recalculate-line, org-table-eval-formula)
(org-table-recalculate, org-table-iterate)
(org-table-edit-formulas)
(org-table-toggle-coordinate-overlays)
(org-table-toggle-formula-debugger, orgtbl-to-generic)
(orgtbl-to-tsv, orgtbl-to-csv, orgtbl-to-latex)
(orgtbl-to-html, orgtbl-to-texinfo, orgtbl-to-orgtbl): Ditto.
2012-10-02 10:52:17 +02:00