comparison lisp/org/org-table.el @ 96044:c1ef445563bb

2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-colview.el (org-columns-next-allowed-value): Bug fix. * org-colview-xemacs.el (org-columns-next-allowed-value): Bug fix. * org-agenda.el (org-agenda-get-closed): Get the end time into the agenda prefix as well. * org-publish.el (org-publish-org-index): Make a properly indented list. * org.el (org-calendar-agenda-action-key): New option. (org-get-cursor-date): New function. (org-mark-entry-for-agenda-action): New command. (org-overriding-default-time): New variable. (org-read-date): Respect `org-overriding-default-time'. * org-remember.el (org-remember-apply-template): Respect the ovverriding default time. * org-agenda.el (org-agenda-action-marker): New variable. (org-agenda-action): New command. (org-agenda-do-action): New function. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-schedule, org-deadline): Protect scheduled and deadline tasks against changes that accidently remove the repeater. Also show a message with the new date when done. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-beginning-of-line): Cater for the case when there are tags but no headline text. (org-align-tags-here): Convert to tabs only when indent-tabs-mode it set. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-mhe.el (org-mhe-get-message-folder-from-index): Make sure the return value is nil instead of "nil" when there is no match. * org-exp.el (org-insert-centered): Use fill-column instead of 80. (org-export-as-ascii): Use string-width to measure the width of the heading. * org.el (org-diary-to-ical-string): No longer kill buffer FROMBUF, this is now done by the caller. * org-exp.el (org-print-icalendar-entries): Move the call to `org-diary-to-ical-string' out of the loop, and kill the buffer afterwords. * org-remember.el (org-remember-visit-immediately): Position cursor after moving to the note. (org-remember-apply-template): Use a text property to record the cursor position. (org-remember-handler): Align tags after pasting the note. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-bbdb.el (org-bbdb-follow-anniversary-link): New function. * org-agenda.el (org-agenda-open-link): If there is an org-bbdb-name property in the current line, jump to that bbdb entry. * org-bbdb.el (org-bbdb-anniversaries): Add the bbdb-name as a text property, so that the agenda knows where this entry comes from. * org-agenda.el (org-agenda-clock-in): Fixed bug in the interaction between clocking-in from the agenda, and automatic task state switching. * org-macs.el (org-with-point-at): Bug fix in macro defintion. * org.el (org-beginning-of-line, org-end-of-line): Make sure the zmacs-region stays after this command in XEmacs. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-scan-tags): Allow new values for ACTION parameter. * org-remember.el (org-remember-templates): Fix bug in customization type definition. * org.el (org-map-entries): New function. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-agenda.el (org-agenda-skip-comment-trees): New option. (org-agenda-skip): Respect `org-agenda-skip-comment-trees'. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-remember.el (org-jump-to-target-location): New variable. (org-remember-apply-template): Set `org-remember-apply-template' if requested by template. (org-remember-handler): Start an idle timer to jump to remember location. * org-exp.el (org-get-current-options): Add the FILETAGS setting. * org.el (org-set-regexps-and-options): Fix bug with parsing of file tags. (org-get-tags-at): Add the content of `org-file-tags'. * org-exp.el (org-export-handle-comments): Fix bug with several comment lines after each other. (org-number-to-roman, org-number-to-counter): New functions. (org-export-section-number-format): New option. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-exp.el (org-export-protect-examples): Catch the case of a missing end_example line. * org.el (org-set-regexps-and-options): Set `org-file-properties' and `org-file-tags' to nil. * org-colview.el (org-columns-next-allowed-value): Handle next argument NTH to directly select a value. * org-colview-xemacs.el (org-columns-next-allowed-value): Handle next argument NTH to directly select a value. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-agenda.el (org-agenda-scheduled-leaders): Fix docstring. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-columns-ellipses): New option. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-colview.el (org-columns-add-ellipses): New function. (org-columns-compact-links): New function. (org-columns-cleanup-item): Call `org-columns-compact-links'. (org-columns-display-here): Call `org-agenda-columns-cleanup-item' when in agenda. (org-columns-edit-value): Fixed bug with editing values from agenda column view. (org-columns-redo): Also redo the agenda itself. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-agenda.el (org-agenda-columns-remove-prefix-from-item): New option. * org-colview.el (org-agenda-columns-cleanup-item): New function. * org-exp.el (org-export-ascii-preprocess): Renamed from `org-export-ascii-clean-string'. (org-export-kill-licensed-text) (org-export-define-heading-targets) (org-export-handle-invisible-targets) (org-export-target-internal-links) (org-export-remove-or-extract-drawers) (org-export-remove-archived-trees) (org-export-protect-quoted-subtrees) (org-export-protect-verbatim, org-export-protect-examples) (org-export-select-backend-specific-text) (org-export-mark-blockquote-and-verse) (org-export-remove-comment-blocks-and-subtrees) (org-export-handle-comments, org-export-mark-radio-links) (org-export-remove-special-table-lines) (org-export-normalize-links) (org-export-concatenate-multiline-links) (org-export-concatenate-multiline-emphasis): New functions, obtained from spliiting the export preprocessor. * org-table.el (org-table-recalculate): Improve error message if the row number is invalid. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-archive.el (org-archive-save-context-info): Fix bugs in customization setup and docstring. * org-exp.el (org-export-html-style): Changed the size of in the <pre> element to 90%. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-find-src-example-start): Function removed. (org-edit-src-find-region-and-lang): New function. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-edit-src-exit): New function. (org-exit-edit-mode): New minor mode. * org-exp.el (org-export-preprocess-string): Fix bug with removing comment-like lines from protected examples. * org.el (org-edit-src-example, org-find-src-example-start) (org-protect-source-example, org-edit-special): New functions. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-publish.el (org-publish-project-alist): Fix typo in docstring. (org-publish-project-alist): Handle :index-title property. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-export-latex.el (org-export-as-latex): Make sure region bounds are correct. Parse subtree properties relating to export. * org-exp.el (org-export-add-options-to-plist): New function. (org-infile-export-plist): Use `org-export-add-options-to-plist'. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-default-properties): Add EXPORT_FILE_NAME and EXPORT_TITLE. * org-exp.el (org-export-get-title-from-subtree) (org-export-as-ascii, org-export-as-html): Make sure the original region-beginning and region-end are used, even after moving point. (org-export-get-title-from-subtree): Also try the EXPORT_TITLE property. * org-remember.el (org-remember-last-stored-marker): New variable. (org-remember-goto-last-stored): Use `org-goto-marker-or-bmk'. (org-remember-handler): Also use marker to remember last-stored position. * org.el (org-goto-marker-or-bmk): New function. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-file-properties): Renamed from `org-local-properties'. (org-scan-tags): Take file tags into account. (org-tags-match-list-sublevels): Default changed to t. * org-exp.el (org-export-as-html): Close paragraph after a footnote. * org.el (org-update-parent-todo-statistics): New function. * org-exp.el (org-icalendar-store-UID): New option. (org-icalendar-force-UID): Option removed. (org-print-icalendar-entries): IMplement UIDs. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-mhe.el (org-mhe-follow-link): Fix bug in mhe searches. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-faces.el (org-column): Document how this face is being used and why sometimes the background faces shine through. * org-mhe.el (org-mhe-follow-link): Improve handling of searches. * org-publish.el (org-publish-attachment): Create publishing directory if it does not yet exist. * org-table.el (org-calc-default-modes): Change default number format to (float 8). * org.el (org-olpath-completing-read): New function. (org-time-clocksum-format): New option. (org-minutes-to-hh:mm-string): Use `org-time-clocksum-format'. * org-clock.el (org-clock-display, org-clock-out) (org-update-mode-line): Use `org-time-clocksum-format'. * org-colview-xemacs.el (org-columns-number-to-string): Use `org-time-clocksum-format'. * org-colview.el (org-columns-number-to-string): Use `org-time-clocksum-format'. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-id.el: New file, move from contrib to core. * org-exp.el (org-icalendar-force-UID): New option. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-exp.el (org-print-icalendar-entries): Make sure DTEND is shifted by one day if theere is a date range without an end time. * org.el (org-try-structure-completion): New function. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-set-font-lock-defaults): Improve fontification of description lists. (org-insert-item): Handle description lists. (org-adaptive-fill-function): Improve auto indentation in description lists. * org-exp.el (org-export-as-html, org-export-preprocess-string): Implement VERSE environment. (org-export-preprocess-string): Implement the COMMENT environment. * org-export-latex.el (org-export-latex-preprocess): Implement VERSE environment. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-jsinfo.el (org-infojs-opts-table): Add entry for FIXED_TOC option. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-table.el (orgtbl-to-tsv, orgtbl-to-csv): New functions. * org.el (org-quote-csv-field): New functions. * org-table.el (org-table-export-default-format): Remove :splice from default format, we get the same effect by not specifying :tstart and :tend. (org-table-export): Improve setup, distinguish better between interactive and non-interactive use, allow specifying the format on the fly, better protection against wrong file names. (orgtbl-to-generic): Fix documentation. Do not require :tstart and :tend when :splice is omitted. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-clock.el (org-clock-select-task): Make sure the selection letters are 1-9 and A-Z, no special characters. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-exp.el (org-export-htmlize): New group. (org-export-htmlize-output-type) (org-export-htmlize-css-font-prefix): New options. (org-export-htmlize-region-for-paste): New function. (org-export-htmlize-generate-css): New command. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-set-visibility-according-to-property): New function. (org-ctrl-c-ctrl-c): Do not restart org-mode, just get the options and compute the regular expressions, and update font-lock. (org-property-re): Allow a dash in property names. * org-archive.el (org-extract-archive-file): Insert the file name without the path into the format, to allow the location format to contain a subdirectory. * org-agenda.el (org-agenda-post-command-hook): If point is at end of buffer, and the `org-agenda-type' property undefined, use the value from the character before. * org.el (org-add-planning-info): Don't let indentation for would-be timestamp become extra whitespace at the end of headline. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-remove-double-quotes, org-file-contents): New functions. * org-exp.el (org-infile-export-plist): Also parse the contents of #+SETUPFILE files, recursively. * org.el (org-set-regexps-and-options): Also parse the contents of #+SETUPFILE files, recursively. * org-exp.el (org-export-handle-include-files): New function. (org-export-preprocess-string): Call `org-export-handle-include-files'. * org.el (org-delete-property-globally) (org-delete-property, org-set-property): Ignore case during completion. (org-set-property): Use `org-completing-read' instead of `completing-read'. * org.el (org-complete-expand-structure-template): New, experimental function. (org-structure-template-alist): New, experimental option. (org-complete): Call `org-complete-expand-structure-template'. 2008-06-17 Bastien Guerry <bzg@altern.org> * org-export-latex.el (org-export-latex-preprocess): Added support for blockquotes. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-read-date-analyze): Catch the case where only a weekday is given. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-set-font-lock-defaults): Make the description tag bold. * org-exp.el (org-export-as-html, org-close-li): Implement description lists. 2008-06-17 Jason Riedy <jason@acm.org> * org-table.el (*orgtbl-default-fmt*): New variable. (orgtbl-format-line): Use the value of *orgtbl-default-fmt* when there is no other fmt available. (orgtbl-to-generic): Allow an explicitly nil :tstart or :tend to suppress the appropriate string. (orgtbl-to-orgtbl): New function for translating to another orgtbl table. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.el (org-read-date-analyze): "." as an alias for "+0" in read date. * org-clock.el (org-clock-save-markers-for-cut-and-paste): New function. * org-agenda.el (org-agenda-save-markers-for-cut-and-paste): New function. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-clock.el (org-clock-find-position): Don't include notes into clock drawer. * org-archive.el (org-archive-subtree): No longer remove an extra line after cutting the subtree. `org-cut-subtree' already takes care of this. * org-remember.el (org-remember-handler): Only kill the target buffer if it does not contain the running clock. * org.el (org-markers-to-move): New variable. (org-save-markers-in-region, org-check-and-save-marker) (org-reinstall-markers-in-region): New function. (org-move-subtree-down, org-copy-subtree): Remember relative marker positions before cutting. (org-move-subtree-down, org-paste-subtree): Restore relative marker positions after pasting. * org-remember.el (org-remember-clock-out-on-exit): New option. (org-remember-finalize): Clock out only if the setting in `org-remember-clock-out-on-exit' requires it. (org-remember-handler): Do the cleanup in the buffer, to make sure that the clock marker remains in tact. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-clock.el (org-clock-goto): Widen buffer if necessary. (org-clock-in): Make sure that also tasks outside the narrowed region will be clocked in correctly. (org-clock-insert-selection-line): Widen the buffer so that we can find the correct task heading. * org.el (org-base-buffer): New function. * org-exp.el (org-icalendar-cleanup-string): Make sure '," and ";" are escaped. (org-print-icalendar-entries): Also apply `org-icalendar-cleanup-string' to the headline, not only to the summary property. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org-exp.el (org-export-preprocess-hook): New hook. (org-export-preprocess-string): Call `org-export-preprocess-hook'. * org.el (org-font-lock-hook): New variable. (org-font-lock-hook): New function. (org-set-font-lock-defaults): Call `org-font-lock-hook'. 2008-06-17 Carsten Dominik <dominik@science.uva.nl> * org.texi: Modify license to no longer include back- and front cover matters. (Using the mapping API): New section. (Agenda column view): New section. (Moving subtrees): Document archiving to the archive sibling. (Agenda commands): Document columns view in the agenda. (Using the property API): Document the API for multi-valued properties.
author Carsten Dominik <dominik@science.uva.nl>
date Tue, 17 Jun 2008 15:22:00 +0000
parents ba3167bc4143
children 25423ee77a10
comparison
equal deleted inserted replaced
96043:a678c02d0c40 96044:c1ef445563bb
3 ;; Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. 3 ;; Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
4 4
5 ;; Author: Carsten Dominik <carsten at orgmode dot org> 5 ;; Author: Carsten Dominik <carsten at orgmode dot org>
6 ;; Keywords: outlines, hypermedia, calendar, wp 6 ;; Keywords: outlines, hypermedia, calendar, wp
7 ;; Homepage: http://orgmode.org 7 ;; Homepage: http://orgmode.org
8 ;; Version: 6.02b 8 ;; Version: 6.05a
9 ;; 9 ;;
10 ;; This file is part of GNU Emacs. 10 ;; This file is part of GNU Emacs.
11 ;; 11 ;;
12 ;; GNU Emacs is free software: you can redistribute it and/or modify 12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by 13 ;; it under the terms of the GNU General Public License as published by
185 :group 'org-table-calculation 185 :group 'org-table-calculation
186 :type 'boolean) 186 :type 'boolean)
187 187
188 (defcustom org-calc-default-modes 188 (defcustom org-calc-default-modes
189 '(calc-internal-prec 12 189 '(calc-internal-prec 12
190 calc-float-format (float 5) 190 calc-float-format (float 8)
191 calc-angle-mode deg 191 calc-angle-mode deg
192 calc-prefer-frac nil 192 calc-prefer-frac nil
193 calc-symbolic-mode nil 193 calc-symbolic-mode nil
194 calc-date-format (YYYY "-" MM "-" DD " " Www (" " HH ":" mm)) 194 calc-date-format (YYYY "-" MM "-" DD " " Www (" " HH ":" mm))
195 calc-display-working-message t 195 calc-display-working-message t
247 (defgroup org-table-import-export nil 247 (defgroup org-table-import-export nil
248 "Options concerning table import and export in Org-mode." 248 "Options concerning table import and export in Org-mode."
249 :tag "Org Table Import Export" 249 :tag "Org Table Import Export"
250 :group 'org-table) 250 :group 'org-table)
251 251
252 (defcustom org-table-export-default-format 252 (defcustom org-table-export-default-format "orgtbl-to-tsv"
253 "orgtbl-to-generic :splice t :sep \"\t\""
254 "Default export parameters for org-table-export. These can be 253 "Default export parameters for org-table-export. These can be
255 overridden on for a specific table by setting the 254 overridden on for a specific table by setting the TABLE_EXPORT_FORMAT
256 TABLE_EXPORT_FORMAT parameter. See orgtbl-export for the 255 property. See the manual section on orgtbl radio tables for the different
257 different export transforms and available parameters." 256 export transformations and available parameters."
258 :group 'org-table-import-export 257 :group 'org-table-import-export
259 :type 'string) 258 :type 'string)
260 259
261 (defconst org-table-auto-recalculate-regexp "^[ \t]*| *# *\\(|\\|$\\)" 260 (defconst org-table-auto-recalculate-regexp "^[ \t]*| *# *\\(|\\|$\\)"
262 "Detects a table line marked for automatic recalculation.") 261 "Detects a table line marked for automatic recalculation.")
426 425
427 426
428 (defvar org-table-last-alignment) 427 (defvar org-table-last-alignment)
429 (defvar org-table-last-column-widths) 428 (defvar org-table-last-column-widths)
430 (defun org-table-export (&optional file format) 429 (defun org-table-export (&optional file format)
431 "Export table as a tab-separated file. 430 "Export table to a file, with configurable format.
432 Such a file can be imported into a spreadsheet program like Excel. 431 Such a file can be imported into a spreadsheet program like Excel.
433 FILE can be the output file name. If not given, it will be taken from 432 FILE can be the output file name. If not given, it will be taken from
434 a TABLE_EXPORT_FILE property in the current entry or higher up in the 433 a TABLE_EXPORT_FILE property in the current entry or higher up in the
435 hierarchy, or the user will be prompted for a file name. 434 hierarchy, or the user will be prompted for a file name.
436 FORMAT can be an export format, of the same kind as it used when 435 FORMAT can be an export format, of the same kind as it used when
437 orgtbl-mode sends a table in a different format. The default format can 436 orgtbl-mode sends a table in a different format. The default format can
438 be found in the variable `org-table-export-default-format', but the function 437 be found in the variable `org-table-export-default-format', but the function
439 first checks if there is an export format specified in a TABLE_EXPORT_FORMAT 438 first checks if there is an export format specified in a TABLE_EXPORT_FORMAT
440 property, locally or anywhere up in the hierarchy." 439 property, locally or anywhere up in the hierarchy."
441 (interactive) 440 (interactive)
441 (unless (org-at-table-p)
442 (error "No table at point"))
443 (require 'org-exp)
442 (org-table-align) ;; make sure we have everything we need 444 (org-table-align) ;; make sure we have everything we need
443 (let* ((beg (org-table-begin)) 445 (let* ((beg (org-table-begin))
444 (end (org-table-end)) 446 (end (org-table-end))
445 (txt (buffer-substring-no-properties beg end)) 447 (txt (buffer-substring-no-properties beg end))
446 (file (or file (org-entry-get beg "TABLE_EXPORT_FILE" t) 448 (file (or file (org-entry-get beg "TABLE_EXPORT_FILE" t)))
447 (read-file-name "Export table to: "))) 449 (format (or format (org-entry-get beg "TABLE_EXPORT_FORMAT" t)))
448 (format (or (org-entry-get beg "TABLE_EXPORT_FORMAT" t) 450 buf deffmt-readable)
449 org-table-export-default-format)) 451 (unless file
450 buf) 452 (setq file (read-file-name "Export table to: "))
451 (unless (or (not (file-exists-p file)) 453 (unless (or (not (file-exists-p file))
452 (y-or-n-p (format "Overwrite file %s? " file))) 454 (y-or-n-p (format "Overwrite file %s? " file)))
453 (error "Abort")) 455 (error "Abort")))
454 (message format) 456 (if (file-directory-p file)
457 (error "This is a directory path, not a file"))
458 (if (equal (file-truename file)
459 (file-truename (buffer-file-name)))
460 (error "Please specify a file name that is different from current"))
461 (unless format
462 (setq deffmt-readable org-table-export-default-format)
463 (while (string-match "\t" deffmt-readable)
464 (setq deffmt-readable (replace-match "\\t" t t deffmt-readable)))
465 (while (string-match "\n" deffmt-readable)
466 (setq deffmt-readable (replace-match "\\n" t t deffmt-readable)))
467 (setq format (read-string "Format: " deffmt-readable)))
455 468
456 (if (string-match "\\([^ \t\r\n]+\\)\\( +.*\\)?" format) 469 (if (string-match "\\([^ \t\r\n]+\\)\\( +.*\\)?" format)
457 (let* ((transform (intern (match-string 1 format))) 470 (let* ((transform (intern (match-string 1 format)))
458 (params (if (match-end 2) 471 (params (if (match-end 2)
459 (read (concat "(" (match-string 2 format) ")")))) 472 (read (concat "(" (match-string 2 format) ")"))))
2361 (setq beg (point-at-bol) 2374 (setq beg (point-at-bol)
2362 end (move-marker (make-marker) (1+ (point-at-eol))))) 2375 end (move-marker (make-marker) (1+ (point-at-eol)))))
2363 (goto-char beg) 2376 (goto-char beg)
2364 (and all (message "Re-applying formulas to full table...")) 2377 (and all (message "Re-applying formulas to full table..."))
2365 2378
2366 ;; First find the named fields, and mark them untouchanble 2379 ;; First find the named fields, and mark them untouchable
2367 (remove-text-properties beg end '(org-untouchable t)) 2380 (remove-text-properties beg end '(org-untouchable t))
2368 (while (setq eq (pop eqlname)) 2381 (while (setq eq (pop eqlname))
2369 (setq name (car eq) 2382 (setq name (car eq)
2370 a (assoc name org-table-named-field-locations)) 2383 a (assoc name org-table-named-field-locations))
2371 (and (not a) 2384 (and (not a)
2372 (string-match "@\\([0-9]+\\)\\$\\([0-9]+\\)" name) 2385 (string-match "@\\([0-9]+\\)\\$\\([0-9]+\\)" name)
2373 (setq a (list name 2386 (setq a (list name
2374 (aref org-table-dlines 2387 (condition-case nil
2375 (string-to-number (match-string 1 name))) 2388 (aref org-table-dlines
2389 (string-to-number (match-string 1 name)))
2390 (error (error "Invalid row number in %s"
2391 name)))
2376 (string-to-number (match-string 2 name))))) 2392 (string-to-number (match-string 2 name)))))
2377 (when (and a (or all (equal (nth 1 a) thisline))) 2393 (when (and a (or all (equal (nth 1 a) thisline)))
2378 (message "Re-applying formula to field: %s" name) 2394 (message "Re-applying formula to field: %s" name)
2379 (goto-line (nth 1 a)) 2395 (goto-line (nth 1 a))
2380 (org-table-goto-column (nth 2 a)) 2396 (org-table-goto-column (nth 2 a))
3495 a radio table." 3511 a radio table."
3496 (save-excursion 3512 (save-excursion
3497 (goto-char (org-table-begin)) 3513 (goto-char (org-table-begin))
3498 (let (rtn) 3514 (let (rtn)
3499 (beginning-of-line 0) 3515 (beginning-of-line 0)
3500 (while (looking-at "#\\+ORGTBL: *SEND +\\([a-zA-Z0-9_]+\\) +\\([^ \t\r\n]+\\)\\( +.*\\)?") 3516 (while (looking-at "#\\+ORGTBL[: \t][ \t]*SEND +\\([a-zA-Z0-9_]+\\) +\\([^ \t\r\n]+\\)\\( +.*\\)?")
3501 (let ((name (org-no-properties (match-string 1))) 3517 (let ((name (org-no-properties (match-string 1)))
3502 (transform (intern (match-string 2))) 3518 (transform (intern (match-string 2)))
3503 (params (if (match-end 3) 3519 (params (if (match-end 3)
3504 (read (concat "(" (match-string 3) ")"))))) 3520 (read (concat "(" (match-string 3) ")")))))
3505 (push (list :name name :transform transform :params params) 3521 (push (list :name name :transform transform :params params)
3627 (defvar *orgtbl-rtn* nil 3643 (defvar *orgtbl-rtn* nil
3628 "Formatting routines push the output lines here.") 3644 "Formatting routines push the output lines here.")
3629 ;; Formatting parameters for the current table section. 3645 ;; Formatting parameters for the current table section.
3630 (defvar *orgtbl-hline* nil "Text used for horizontal lines") 3646 (defvar *orgtbl-hline* nil "Text used for horizontal lines")
3631 (defvar *orgtbl-sep* nil "Text used as a column separator") 3647 (defvar *orgtbl-sep* nil "Text used as a column separator")
3648 (defvar *orgtbl-default-fmt* nil "Default format for each entry")
3632 (defvar *orgtbl-fmt* nil "Format for each entry") 3649 (defvar *orgtbl-fmt* nil "Format for each entry")
3633 (defvar *orgtbl-efmt* nil "Format for numbers") 3650 (defvar *orgtbl-efmt* nil "Format for numbers")
3634 (defvar *orgtbl-lfmt* nil "Format for an entire line, overrides fmt") 3651 (defvar *orgtbl-lfmt* nil "Format for an entire line, overrides fmt")
3635 (defvar *orgtbl-llfmt* nil "Specializes lfmt for the last row") 3652 (defvar *orgtbl-llfmt* nil "Specializes lfmt for the last row")
3636 (defvar *orgtbl-lstart* nil "Text starting a row") 3653 (defvar *orgtbl-lstart* nil "Text starting a row")
3668 (let* ((efmt (orgtbl-get-fmt *orgtbl-efmt* i)) 3685 (let* ((efmt (orgtbl-get-fmt *orgtbl-efmt* i))
3669 (f (if (and efmt (string-match orgtbl-exp-regexp f)) 3686 (f (if (and efmt (string-match orgtbl-exp-regexp f))
3670 (orgtbl-apply-fmt efmt (match-string 1 f) 3687 (orgtbl-apply-fmt efmt (match-string 1 f)
3671 (match-string 2 f)) 3688 (match-string 2 f))
3672 f))) 3689 f)))
3673 (orgtbl-apply-fmt (orgtbl-get-fmt *orgtbl-fmt* i) f))) 3690 (orgtbl-apply-fmt (or (orgtbl-get-fmt *orgtbl-fmt* i)
3691 *orgtbl-default-fmt*)
3692 f)))
3674 line))) 3693 line)))
3675 (push (if *orgtbl-lfmt* 3694 (push (if *orgtbl-lfmt*
3676 (orgtbl-apply-fmt *orgtbl-lfmt* line) 3695 (orgtbl-apply-fmt *orgtbl-lfmt* line)
3677 (concat (orgtbl-eval-str *orgtbl-lstart*) 3696 (concat (orgtbl-eval-str *orgtbl-lstart*)
3678 (mapconcat 'identity line *orgtbl-sep*) 3697 (mapconcat 'identity line *orgtbl-sep*)
3696 This generic routine can be used for many standard cases. 3715 This generic routine can be used for many standard cases.
3697 TABLE is a list, each entry either the symbol `hline' for a horizontal 3716 TABLE is a list, each entry either the symbol `hline' for a horizontal
3698 separator line, or a list of fields for that line. 3717 separator line, or a list of fields for that line.
3699 PARAMS is a property list of parameters that can influence the conversion. 3718 PARAMS is a property list of parameters that can influence the conversion.
3700 For the generic converter, some parameters are obligatory: You need to 3719 For the generic converter, some parameters are obligatory: You need to
3701 specify either :lfmt, or all of (:lstart :lend :sep). If you do not use 3720 specify either :lfmt, or all of (:lstart :lend :sep).
3702 :splice, you must have :tstart and :tend.
3703 3721
3704 Valid parameters are 3722 Valid parameters are
3705 3723
3706 :splice When set to t, return only table body lines, don't wrap 3724 :splice When set to t, return only table body lines, don't wrap
3707 them into :tstart and :tend. Default is nil. 3725 them into :tstart and :tend. Default is nil. When :splice
3726 is non-nil, this also means that the exporter should not look
3727 for and interpret header and footer sections.
3708 3728
3709 :hline String to be inserted on horizontal separation lines. 3729 :hline String to be inserted on horizontal separation lines.
3710 May be nil to ignore hlines. 3730 May be nil to ignore hlines.
3711 3731
3712 :sep Separator between two fields 3732 :sep Separator between two fields
3713 :remove-nil-lines Do not include lines that evaluate to nil. 3733 :remove-nil-lines Do not include lines that evaluate to nil.
3714 3734
3715 3735
3716 Each in the following group may be either a string or a function 3736 Each in the following group may be either a string or a function
3717 of no arguments returning a string: 3737 of no arguments returning a string:
3718 :tstart String to start the table. Ignored when :splice is t. 3738 :tstart String to start the table. Ignored when :splice is t.
3719 :tend String to end the table. Ignored when :splice is t. 3739 :tend String to end the table. Ignored when :splice is t.
3720 :lstart String to start a new table line. 3740 :lstart String to start a new table line.
3721 :llstart String to start the last table line, defaults to :lstart. 3741 :llstart String to start the last table line, defaults to :lstart.
3722 :lend String to end a table line 3742 :lend String to end a table line
3723 :llend String to end the last table line, defaults to :lend. 3743 :llend String to end the last table line, defaults to :lend.
3724 3744
3725 Each in the following group may be a string, a function of one 3745 Each in the following group may be a string, a function of one
3726 argument (the field or line) returning a string, or a plist 3746 argument (the field or line) returning a string, or a plist
3727 mapping columns to either of the above: 3747 mapping columns to either of the above:
3728 :lfmt Format for entire line, with enough %s to capture all fields. 3748 :lfmt Format for entire line, with enough %s to capture all fields.
3729 If this is present, :lstart, :lend, and :sep are ignored. 3749 If this is present, :lstart, :lend, and :sep are ignored.
3730 :llfmt Format for the entire last line, defaults to :lfmt. 3750 :llfmt Format for the entire last line, defaults to :lfmt.
3731 :fmt A format to be used to wrap the field, should contain 3751 :fmt A format to be used to wrap the field, should contain
3732 %s for the original field value. For example, to wrap 3752 %s for the original field value. For example, to wrap
3737 :hlstart :hllstart :hlend :hllend :hlsep :hlfmt :hllfmt :hfmt 3757 :hlstart :hllstart :hlend :hllend :hlsep :hlfmt :hllfmt :hfmt
3738 Same as above, specific for the header lines in the table. 3758 Same as above, specific for the header lines in the table.
3739 All lines before the first hline are treated as header. 3759 All lines before the first hline are treated as header.
3740 If any of these is not present, the data line value is used. 3760 If any of these is not present, the data line value is used.
3741 3761
3742 This may be either a string or a function of two arguments: 3762 This may be either a string or a function of two arguments:
3743 :efmt Use this format to print numbers with exponentials. 3763 :efmt Use this format to print numbers with exponentials.
3744 The format should have %s twice for inserting mantissa 3764 The format should have %s twice for inserting mantissa
3745 and exponent, for example \"%s\\\\times10^{%s}\". This 3765 and exponent, for example \"%s\\\\times10^{%s}\". This
3746 may also be a property list with column numbers and 3766 may also be a property list with column numbers and
3747 formats. :fmt will still be applied after :efmt. 3767 formats. :fmt will still be applied after :efmt.
3766 (*orgtbl-fmt* (plist-get params :fmt)) 3786 (*orgtbl-fmt* (plist-get params :fmt))
3767 *orgtbl-rtn*) 3787 *orgtbl-rtn*)
3768 3788
3769 ;; Put header 3789 ;; Put header
3770 (unless splicep 3790 (unless splicep
3771 (push (or (orgtbl-eval-str (plist-get params :tstart)) 3791 (when (plist-member params :tstart)
3772 "ERROR: no :tstart") *orgtbl-rtn*)) 3792 (let ((tstart (orgtbl-eval-str (plist-get params :tstart))))
3793 (if tstart (push tstart *orgtbl-rtn*)))))
3773 3794
3774 ;; Do we have a heading section? If so, format it and handle the 3795 ;; Do we have a heading section? If so, format it and handle the
3775 ;; trailing hline. 3796 ;; trailing hline.
3776 (if (and (not splicep) (listp (car *orgtbl-table*)) 3797 (if (and (not splicep) (listp (car *orgtbl-table*))
3777 (memq 'hline *orgtbl-table*)) 3798 (memq 'hline *orgtbl-table*))
3794 3815
3795 ;; Now format the main section. 3816 ;; Now format the main section.
3796 (orgtbl-format-section nil) 3817 (orgtbl-format-section nil)
3797 3818
3798 (unless splicep 3819 (unless splicep
3799 (push (or (orgtbl-eval-str (plist-get params :tend)) 3820 (when (plist-member params :tend)
3800 "ERROR: no :tend") *orgtbl-rtn*)) 3821 (let ((tend (orgtbl-eval-str (plist-get params :tend))))
3822 (if tend (push tend *orgtbl-rtn*)))))
3801 3823
3802 (mapconcat 'identity (nreverse (if remove-nil-linesp 3824 (mapconcat 'identity (nreverse (if remove-nil-linesp
3803 (remq nil *orgtbl-rtn*) 3825 (remq nil *orgtbl-rtn*)
3804 *orgtbl-rtn*)) "\n"))) 3826 *orgtbl-rtn*)) "\n")))
3827
3828 (defun orgtbl-to-tsv (table params)
3829 "Convert the orgtbl-mode table to TAB separated material."
3830 (orgtbl-to-generic table (org-combine-plists '(:sep "\t") params)))
3831 (defun orgtbl-to-csv (table params)
3832 "Convert the orgtbl-mode table to CSV material.
3833 This does take care of the proper quoting of fields with comma or quotes."
3834 (orgtbl-to-generic table (org-combine-plists
3835 '(:sep "," :fmt org-quote-csv-field)
3836 params)))
3805 3837
3806 (defun orgtbl-to-latex (table params) 3838 (defun orgtbl-to-latex (table params)
3807 "Convert the orgtbl-mode TABLE to LaTeX. 3839 "Convert the orgtbl-mode TABLE to LaTeX.
3808 TABLE is a list, each entry either the symbol `hline' for a horizontal 3840 TABLE is a list, each entry either the symbol `hline' for a horizontal
3809 separator line, or a list of fields for that line. 3841 separator line, or a list of fields for that line.
3906 :tend "@end multitable" 3938 :tend "@end multitable"
3907 :lstart "@item " :lend "" :sep " @tab " 3939 :lstart "@item " :lend "" :sep " @tab "
3908 :hlstart "@headitem "))) 3940 :hlstart "@headitem ")))
3909 (orgtbl-to-generic table (org-combine-plists params2 params)))) 3941 (orgtbl-to-generic table (org-combine-plists params2 params))))
3910 3942
3943 (defun orgtbl-to-orgtbl (table params)
3944 "Convert the orgtbl-mode TABLE into another orgtbl-mode table.
3945 Useful when slicing one table into many. The :hline, :sep,
3946 :lstart, and :lend provide orgtbl framing. The default nil :tstart
3947 and :tend suppress strings without splicing; they can be set to
3948 provide ORGTBL directives for the generated table."
3949 (let* ((params2
3950 (list
3951 :tstart nil :tend nil
3952 :hline "|---"
3953 :sep " | "
3954 :lstart "| "
3955 :lend " |"))
3956 (params (org-combine-plists params2 params)))
3957 (orgtbl-to-generic table params)))
3958
3911 (provide 'org-table) 3959 (provide 'org-table)
3912 3960
3913 ;; arch-tag: 4d21cfdd-0268-440a-84b0-09237a0fe0ef 3961 ;; arch-tag: 4d21cfdd-0268-440a-84b0-09237a0fe0ef
3962
3914 ;;; org-table.el ends here 3963 ;;; org-table.el ends here