aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Dominik2008-06-17 15:22:00 +0000
committerCarsten Dominik2008-06-17 15:22:00 +0000
commitb349f79f7434513bd603b063473bfdf59c465817 (patch)
tree787a8d6677b022cd76aebc1fc9706a5c06980d27
parent4271b4248d5e0add806a41ddbd6b0c99574eea8e (diff)
downloademacs-b349f79f7434513bd603b063473bfdf59c465817.tar.gz
emacs-b349f79f7434513bd603b063473bfdf59c465817.zip
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.
-rw-r--r--doc/misc/ChangeLog18
-rw-r--r--doc/misc/org.texi1552
-rw-r--r--etc/refcards/orgcard.tex11
-rw-r--r--lisp/org/ChangeLog480
-rw-r--r--lisp/org/org-agenda.el156
-rw-r--r--lisp/org/org-archive.el37
-rw-r--r--lisp/org/org-bbdb.el125
-rw-r--r--lisp/org/org-bibtex.el3
-rw-r--r--lisp/org/org-clock.el150
-rw-r--r--lisp/org/org-colview.el136
-rw-r--r--lisp/org/org-compat.el4
-rw-r--r--lisp/org/org-exp.el1165
-rw-r--r--lisp/org/org-export-latex.el37
-rw-r--r--lisp/org/org-faces.el39
-rw-r--r--lisp/org/org-gnus.el3
-rw-r--r--lisp/org/org-info.el3
-rw-r--r--lisp/org/org-irc.el3
-rw-r--r--lisp/org/org-jsinfo.el5
-rw-r--r--lisp/org/org-mac-message.el3
-rw-r--r--lisp/org/org-macs.el7
-rw-r--r--lisp/org/org-mew.el3
-rw-r--r--lisp/org/org-mhe.el17
-rw-r--r--lisp/org/org-mouse.el4
-rw-r--r--lisp/org/org-publish.el88
-rw-r--r--lisp/org/org-remember.el253
-rw-r--r--lisp/org/org-rmail.el3
-rw-r--r--lisp/org/org-table.el119
-rw-r--r--lisp/org/org-vm.el3
-rw-r--r--lisp/org/org-wl.el3
-rw-r--r--lisp/org/org.el1241
30 files changed, 4248 insertions, 1423 deletions
diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog
index 7f74be79b39..f13b30bd7dd 100644
--- a/doc/misc/ChangeLog
+++ b/doc/misc/ChangeLog
@@ -1,3 +1,21 @@
12008-06-17 Carsten Dominik <dominik@science.uva.nl>
2
3 * org.texi: Modify license to no longer include back- and front
4 cover matters.
5 (Using the mapping API): New section.
6 (Agenda column view): New section.
7 (Moving subtrees): Document archiving to the archive
8 sibling.
9 (Agenda commands): Document columns view in the agenda.
10 (Using the property API): Document the API for
11 multi-valued properties.
12
132008-06-17 Jason Riedy <jason@acm.org>
14
15 * org.texi (A LaTeX example): Note that fmt may be a one-argument
16 function, and efmt may be a two-argument function.
17 (Radio tables): Document multiple destinations.
18
12008-06-16 Glenn Morris <rgm@gnu.org> 192008-06-16 Glenn Morris <rgm@gnu.org>
2 20
3 * epa.texi, erc.texi, pgg.texi, remember.texi, sasl.texi, url.texi: 21 * epa.texi, erc.texi, pgg.texi, remember.texi, sasl.texi, url.texi:
diff --git a/doc/misc/org.texi b/doc/misc/org.texi
index 7ec70e9caa2..71865b7b2a0 100644
--- a/doc/misc/org.texi
+++ b/doc/misc/org.texi
@@ -3,8 +3,8 @@
3@setfilename ../../info/org 3@setfilename ../../info/org
4@settitle The Org Manual 4@settitle The Org Manual
5 5
6@set VERSION 6.02b 6@set VERSION 6.05a
7@set DATE April 2008 7@set DATE June 2008
8 8
9@dircategory Emacs 9@dircategory Emacs
10@direntry 10@direntry
@@ -42,9 +42,9 @@ Permission is granted to copy, distribute and/or modify this document
42under the terms of the GNU Free Documentation License, Version 1.2 or 42under the terms of the GNU Free Documentation License, Version 1.2 or
43any later version published by the Free Software Foundation; with no 43any later version published by the Free Software Foundation; with no
44Invariant Sections, with the Front-Cover texts being ``A GNU Manual,'' 44Invariant Sections, with the Front-Cover texts being ``A GNU Manual,''
45and with the Back-Cover Texts as in (a) below. A copy of the 45and with the Back-Cover Texts as in (a) below. A copy of the
46license is included in the section entitled ``GNU Free Documentation 46 license is included in the section entitled ``GNU Free Documentation
47License'' in the Emacs manual. 47-License.''
48 48
49(a) The FSF's Back-Cover Text is: ``You have the freedom to copy and 49(a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
50modify this GNU manual. Buying copies from the FSF supports it in 50modify this GNU manual. Buying copies from the FSF supports it in
@@ -94,7 +94,8 @@ license to the document, as described in section 6 of the license.
94* Exporting:: Sharing and publishing of notes 94* Exporting:: Sharing and publishing of notes
95* Publishing:: Create a web site of linked Org files 95* Publishing:: Create a web site of linked Org files
96* Miscellaneous:: All the rest which did not fit elsewhere 96* Miscellaneous:: All the rest which did not fit elsewhere
97* Extensions and Hacking:: It is possible to write add-on code 97* Extensions::
98* Hacking::
98* History and Acknowledgments:: How Org came into being 99* History and Acknowledgments:: How Org came into being
99* Main Index:: An index of Org's concepts and features 100* Main Index:: An index of Org's concepts and features
100* Key Index:: Key bindings and where they are described 101* Key Index:: Key bindings and where they are described
@@ -279,16 +280,35 @@ Embedded LaTeX
279 280
280Exporting 281Exporting
281 282
283* Markup rules:: Which structures are recognized?
284* Export options:: Per-file export settings
285* The export dispatcher:: How to access exporter commands
282* ASCII export:: Exporting to plain ASCII 286* ASCII export:: Exporting to plain ASCII
283* HTML export:: Exporting to HTML 287* HTML export:: Exporting to HTML
284* LaTeX export:: Exporting to LaTeX 288* LaTeX export:: Exporting to LaTeX
285* XOXO export:: Exporting to XOXO 289* XOXO export:: Exporting to XOXO
286* iCalendar export:: Exporting in iCalendar format 290* iCalendar export:: Exporting in iCalendar format
287* Text interpretation:: How the exporter looks at the file 291
292Markup rules
293
294* Document title:: How the document title is determined
295* Headings and sections:: The main structure of the exported document
296* Table of contents:: If, where, how to create a table of contents
297* Initial text:: Text before the first headline
298* Lists:: Plain lists are exported
299* Paragraphs:: What determines beginning and ending
300* Literal examples:: Source code and other examples
301* Include files:: Include the contents of a file during export
302* Tables exported:: Tables are exported richly
303* Footnotes:: Numbers like [1]
304* Emphasis and monospace:: To bold or not to bold
305* TeX macros and LaTeX fragments:: Create special, rich export.
306* Horizontal rules:: A line across the page
307* Comment lines:: Some lines will not be exported
288 308
289HTML export 309HTML export
290 310
291* HTML Export commands:: How to invoke LaTeX export 311* HTML Export commands:: How to invoke HTML export
292* Quoting HTML tags:: Using direct HTML in Org mode 312* Quoting HTML tags:: Using direct HTML in Org mode
293* Links:: Transformation of links for HTML 313* Links:: Transformation of links for HTML
294* Images:: How to include images 314* Images:: How to include images
@@ -301,15 +321,6 @@ LaTeX export
301* Quoting LaTeX code:: Incorporating literal LaTeX code 321* Quoting LaTeX code:: Incorporating literal LaTeX code
302* Sectioning structure:: Changing sectioning in LaTeX output 322* Sectioning structure:: Changing sectioning in LaTeX output
303 323
304Text interpretation by the exporter
305
306* Comment lines:: Some lines will not be exported
307* Initial text:: Text before the first headline
308* Footnotes:: Numbers like [1]
309* Quoted examples:: Inserting quoted chunks of text
310* Enhancing text:: Subscripts, symbols and more
311* Export options:: How to influence the export settings
312
313Publishing 324Publishing
314 325
315* Configuration:: Defining projects 326* Configuration:: Defining projects
@@ -347,14 +358,19 @@ Interaction with other packages
347* Cooperation:: Packages Org cooperates with 358* Cooperation:: Packages Org cooperates with
348* Conflicts:: Packages that lead to conflicts 359* Conflicts:: Packages that lead to conflicts
349 360
350Extensions, Hooks and Hacking 361Extensions
362
363* Extensions in the contrib directory:: These come with the Org distro
364* Other extensions:: These you have to find on the web.
365
366Hacking
351 367
352* Extensions:: Existing 3rd-party extensions
353* Adding hyperlink types:: New custom link types 368* Adding hyperlink types:: New custom link types
354* Tables in arbitrary syntax:: Orgtbl for LaTeX and other programs 369* Tables in arbitrary syntax:: Orgtbl for LaTeX and other programs
355* Dynamic blocks:: Automatically filled blocks 370* Dynamic blocks:: Automatically filled blocks
356* Special agenda views:: Customized views 371* Special agenda views:: Customized views
357* Using the property API:: Writing programs that use entry properties 372* Using the property API:: Writing programs that use entry properties
373* Using the mapping API:: Mapping over all or selected entries
358 374
359Tables and lists in arbitrary syntax 375Tables and lists in arbitrary syntax
360 376
@@ -561,9 +577,10 @@ the file's name is. See also the variable
561@cindex maintainer 577@cindex maintainer
562@cindex author 578@cindex author
563 579
564If you find problems with Org, or if you have questions, remarks, 580If you find problems with Org, or if you have questions, remarks, or ideas
565or ideas about it, please contact the maintainer @value{MAINTAINER} at 581about it, please mail to the Org mailing list @code{emacs-orgmode@@gnu.org}.
566@value{MAINTAINEREMAIL}. 582If you are not a member of the mailing list, your mail will be reviewed by a
583moderator and then passed through to the list.
567 584
568For bug reports, please provide as much information as possible, 585For bug reports, please provide as much information as possible,
569including the version information of Emacs (@kbd{C-h v emacs-version 586including the version information of Emacs (@kbd{C-h v emacs-version
@@ -792,6 +809,19 @@ buffer:
792#+STARTUP: showall 809#+STARTUP: showall
793@end example 810@end example
794 811
812@noindent
813Forthermore, any entries with a @samp{VISIBILITY} property (@pxref{Properties
814and Columns}) will get their visibility adapted accordingly. Allowed values
815for this property are @code{folded}, @code{children}, @code{content}, and
816@code{all}.
817@table @kbd
818@kindex C-u C-u @key{TAB}
819@item C-u C-u @key{TAB}
820Switch back to the startup visibility of the buffer, i.e. whatever is
821requested by startup options and @samp{VISIBILITY} properties in individual
822entries.
823@end table
824
795@node Motion, Structure editing, Visibility cycling, Document Structure 825@node Motion, Structure editing, Visibility cycling, Document Structure
796@section Motion 826@section Motion
797@cindex motion, between headlines 827@cindex motion, between headlines
@@ -915,6 +945,12 @@ been defined in the setup). Reverse sorting is possible as well. You can
915also supply your own function to extract the sorting key. With a @kbd{C-u} 945also supply your own function to extract the sorting key. With a @kbd{C-u}
916prefix, sorting will be case-sensitive. With two @kbd{C-u C-u} prefixes, 946prefix, sorting will be case-sensitive. With two @kbd{C-u C-u} prefixes,
917duplicate entries will also be removed. 947duplicate entries will also be removed.
948@kindex C-x n s
949@item C-x n s
950Narrow buffer to current subtree.
951@kindex C-x n w
952@item C-x n w
953Widen buffer to remove a narrowing.
918@kindex C-c * 954@kindex C-c *
919@item C-c * 955@item C-c *
920Turn a normal line or plain list item into a headline (so that it 956Turn a normal line or plain list item into a headline (so that it
@@ -1064,14 +1100,14 @@ added.
1064@cindex folding, sparse trees 1100@cindex folding, sparse trees
1065@cindex occur, command 1101@cindex occur, command
1066 1102
1067An important feature of Org mode is the ability to construct 1103An important feature of Org mode is the ability to construct @emph{sparse
1068@emph{sparse trees} for selected information in an outline tree, so that 1104trees} for selected information in an outline tree, so that the entire
1069the entire document is folded as much as possible, but the selected 1105document is folded as much as possible, but the selected information is made
1070information is made visible along with the headline structure above 1106visible along with the headline structure above it@footnote{See also the
1071it@footnote{See also the variables @code{org-show-hierarchy-above}, 1107variables @code{org-show-hierarchy-above}, @code{org-show-following-heading},
1072@code{org-show-following-heading}, and @code{org-show-siblings} for 1108@code{org-show-siblings}, and @code{org-show-entry-below} for detailed
1073detailed control on how much context is shown around each match.}. Just 1109control on how much context is shown around each match.}. Just try it out
1074try it out and you will see immediately how it works. 1110and you will see immediately how it works.
1075 1111
1076Org mode contains several commands creating such trees, all these 1112Org mode contains several commands creating such trees, all these
1077commands can be accessed through a dispatcher: 1113commands can be accessed through a dispatcher:
@@ -1082,15 +1118,16 @@ commands can be accessed through a dispatcher:
1082This prompts for an extra key to select a sparse-tree creating command. 1118This prompts for an extra key to select a sparse-tree creating command.
1083@kindex C-c / r 1119@kindex C-c / r
1084@item C-c / r 1120@item C-c / r
1085Occur. Prompts for a regexp and shows a sparse tree with all matches. 1121Occur. Prompts for a regexp and shows a sparse tree with all matches. If
1086If the match is in a headline, the headline is made visible. If the 1122the match is in a headline, the headline is made visible. If the match is in
1087match is in the body of an entry, headline and body are made visible. 1123the body of an entry, headline and body are made visible. In order to
1088In order to provide minimal context, also the full hierarchy of 1124provide minimal context, also the full hierarchy of headlines above the match
1089headlines above the match is shown, as well as the headline following 1125is shown, as well as the headline following the match. Each match is also
1090the match. Each match is also highlighted; the highlights disappear 1126highlighted; the highlights disappear when the buffer is changed by an
1091when the buffer is changed by an editing command, or by pressing 1127editing command@footnote{depending on the option
1092@kbd{C-c C-c}. When called with a @kbd{C-u} prefix argument, previous 1128@code{org-remove-highlights-with-change}}, or by pressing @kbd{C-c C-c}.
1093highlights are kept, so several calls to this command can be stacked. 1129When called with a @kbd{C-u} prefix argument, previous highlights are kept,
1130so several calls to this command can be stacked.
1094@end table 1131@end table
1095 1132
1096@noindent 1133@noindent
@@ -1133,24 +1170,34 @@ additional structure. They also provide a way to create lists of
1133checkboxes (@pxref{Checkboxes}). Org supports editing such lists, 1170checkboxes (@pxref{Checkboxes}). Org supports editing such lists,
1134and the HTML exporter (@pxref{Exporting}) parses and formats them. 1171and the HTML exporter (@pxref{Exporting}) parses and formats them.
1135 1172
1136Org knows ordered and unordered lists. Unordered list items start 1173Org knows ordered lists, unordered lists, and description lists.
1137with @samp{-}, @samp{+}, or @samp{*}@footnote{When using @samp{*} as a 1174@itemize @bullet
1138bullet, lines must be indented or they will be seen as top-level 1175@item
1139headlines. Also, when you are hiding leading stars to get a clean 1176@emph{Unordered} list items start with @samp{-}, @samp{+}, or
1140outline view, plain list items starting with a star are visually 1177@samp{*}@footnote{When using @samp{*} as a bullet, lines must be indented or
1141indistinguishable from true headlines. In short: even though @samp{*} 1178they will be seen as top-level headlines. Also, when you are hiding leading
1142is supported, it may be better to not use it for plain list items.} as 1179stars to get a clean outline view, plain list items starting with a star are
1143bullets. Ordered list items start with a numeral followed by either a 1180visually indistinguishable from true headlines. In short: even though
1144period or a right parenthesis, such as @samp{1.} or @samp{1)}. Items 1181@samp{*} is supported, it may be better to not use it for plain list items.}
1145belonging to the same list must have the same indentation on the first 1182as bullets.
1146line. In particular, if an ordered list reaches number @samp{10.}, then 1183@item
1147the 2--digit numbers must be written left-aligned with the other numbers 1184@emph{Ordered} list items start with a numeral followed by either a period or
1148in the list. Indentation also determines the end of a list item. It 1185a right parenthesis, such as @samp{1.} or @samp{1)}.
1149ends before the next line that is indented like the bullet/number, or 1186@item
1150less. Empty lines are part of the previous item, so you can have 1187@emph{Description} list items are like unordered list items, but contain the
1151several paragraphs in one item. If you would like an empty line to 1188separator @samp{ :: } to separate the description @emph{term} from the
1152terminate all currently open plain lists, configure the variable 1189desciption.
1153@code{org-empty-line-terminates-plain-lists}. Here is an example: 1190@end itemize
1191
1192Items belonging to the same list must have the same indentation on the first
1193line. In particular, if an ordered list reaches number @samp{10.}, then the
11942--digit numbers must be written left-aligned with the other numbers in the
1195list. Indentation also determines the end of a list item. It ends before
1196the next line that is indented like the bullet/number, or less. Empty lines
1197are part of the previous item, so you can have several paragraphs in one
1198item. If you would like an empty line to terminate all currently open plain
1199lists, configure the variable @code{org-empty-line-terminates-plain-lists}.
1200Here is an example:
1154 1201
1155@example 1202@example
1156@group 1203@group
@@ -1164,6 +1211,10 @@ terminate all currently open plain lists, configure the variable
1164 - on DVD only 1211 - on DVD only
1165 He makes a really funny face when it happens. 1212 He makes a really funny face when it happens.
1166 But in the end, not individual scenes matter but the film as a whole. 1213 But in the end, not individual scenes matter but the film as a whole.
1214 Important actors in this film are:
1215 - @b{Elijah Wood} :: He plays the Frodo
1216 - @b{Sean Austin} :: He plays the Sam, Frodos friend. I still remember
1217 him very well from his role as Mikey Walsh a in the Goonies.
1167@end group 1218@end group
1168@end example 1219@end example
1169 1220
@@ -1171,7 +1222,8 @@ Org supports these lists by tuning filling and wrapping commands to
1171deal with them correctly@footnote{Org only changes the filling 1222deal with them correctly@footnote{Org only changes the filling
1172settings for Emacs. For XEmacs, you should use Kyle E. Jones' 1223settings for Emacs. For XEmacs, you should use Kyle E. Jones'
1173@file{filladapt.el}. To turn this on, put into @file{.emacs}: 1224@file{filladapt.el}. To turn this on, put into @file{.emacs}:
1174@code{(require 'filladapt)}}. 1225@code{(require 'filladapt)}}, and by exporting them properly
1226(@pxref{Exporting}).
1175 1227
1176The following commands act on items when the cursor is in the first line 1228The following commands act on items when the cursor is in the first line
1177of an item (the line with the bullet or number). 1229of an item (the line with the bullet or number).
@@ -1265,7 +1317,8 @@ Visibility cycling (@pxref{Visibility cycling}) on the headline will
1265hide and show the entry, but keep the drawer collapsed to a single line. 1317hide and show the entry, but keep the drawer collapsed to a single line.
1266In order to look inside the drawer, you need to move the cursor to the 1318In order to look inside the drawer, you need to move the cursor to the
1267drawer line and press @key{TAB} there. Org mode uses a drawer for 1319drawer line and press @key{TAB} there. Org mode uses a drawer for
1268storing properties (@pxref{Properties and Columns}). 1320storing properties (@pxref{Properties and Columns}), and another one for
1321storing clock times (@pxref{Clocking work time}).
1269 1322
1270@node Orgstruct mode, , Drawers, Document Structure 1323@node Orgstruct mode, , Drawers, Document Structure
1271@section The Orgstruct minor mode 1324@section The Orgstruct minor mode
@@ -1520,7 +1573,10 @@ exchange with, for example, spreadsheet or database programs. The format
1520used to export the file can be configured in the variable 1573used to export the file can be configured in the variable
1521@code{org-table-export-default-format}. You may also use properties 1574@code{org-table-export-default-format}. You may also use properties
1522@code{TABLE_EXPORT_FILE} and @code{TABLE_EXPORT_FORMAT} to specify the file 1575@code{TABLE_EXPORT_FILE} and @code{TABLE_EXPORT_FORMAT} to specify the file
1523name and the format for table export in a subtree. 1576name and the format for table export in a subtree. Org supports quite
1577general formats for exported tables. The exporter format is the same as the
1578format used by Orgtbl radio tables, see @ref{Translator functions} for a
1579detailed description.
1524@end table 1580@end table
1525 1581
1526If you don't like the automatic table editor because it gets in your 1582If you don't like the automatic table editor because it gets in your
@@ -2656,8 +2712,6 @@ for Bib@TeX{} database files, and you can use the corresponding code as
2656an implementation example. Search for @samp{BibTeX links} in the source 2712an implementation example. Search for @samp{BibTeX links} in the source
2657file. 2713file.
2658 2714
2659
2660
2661@node TODO Items, Tags, Hyperlinks, Top 2715@node TODO Items, Tags, Hyperlinks, Top
2662@chapter TODO Items 2716@chapter TODO Items
2663@cindex TODO items 2717@cindex TODO items
@@ -3136,12 +3190,37 @@ priority):
3136@cindex tasks, breaking down 3190@cindex tasks, breaking down
3137 3191
3138It is often advisable to break down large tasks into smaller, manageable 3192It is often advisable to break down large tasks into smaller, manageable
3139subtasks. You can do this by creating an outline tree below a TODO 3193subtasks. You can do this by creating an outline tree below a TODO item,
3140item, with detailed subtasks on the tree@footnote{To keep subtasks out 3194with detailed subtasks on the tree@footnote{To keep subtasks out of the
3141of the global TODO list, see the 3195global TODO list, see the @code{org-agenda-todo-list-sublevels}.}. To keep
3142@code{org-agenda-todo-list-sublevels}.}. Another possibility is the use 3196the overview over the fraction of subtasks that are already completed, insert
3143of checkboxes to identify (a hierarchy of) a large number of subtasks 3197either @samp{[/]} or @samp{[%]} anywhere in the headline. These cookies will
3144(@pxref{Checkboxes}). 3198be updates each time the todo status of a child changes. For example:
3199
3200@example
3201* Organize Party [33%]
3202** TODO Call people [1/2]
3203*** TODO Peter
3204*** DONE Sarah
3205** TODO Buy food
3206** DONE Talk to neighbor
3207@end example
3208
3209If you would like a TODO entry to automatically change to DONE when all
3210chilrden are done, you can use the following setup:
3211
3212@example
3213(defun org-summary-todo (n-done n-not-done)
3214 "Switch entry to DONE when all subentries are done, to TODO otherwise."
3215 (let (org-log-done org-log-states) ; turn off logging
3216 (org-todo (if (= n-not-done 0) "DONE" "TODO"))))
3217
3218(add-hook 'org-after-todo-statistics-hook 'org-summary-todo)
3219@end example
3220
3221
3222Another possibility is the use of checkboxes to identify (a hierarchy of) a
3223large number of subtasks (@pxref{Checkboxes}).
3145 3224
3146 3225
3147@node Checkboxes, , Breaking down tasks, TODO Items 3226@node Checkboxes, , Breaking down tasks, TODO Items
@@ -3268,14 +3347,24 @@ well. For example, in the list
3268@noindent 3347@noindent
3269the final heading will have the tags @samp{:work:}, @samp{:boss:}, 3348the final heading will have the tags @samp{:work:}, @samp{:boss:},
3270@samp{:notes:}, and @samp{:action:} even though the final heading is not 3349@samp{:notes:}, and @samp{:action:} even though the final heading is not
3271explicitly marked with those tags. When executing tag searches and 3350explicitly marked with those tags. You can also set tags that all entries in
3272Org mode finds that a certain headline matches the search criterion, it 3351a file should inherit as if these tags would be defined in a hypothetical
3273will not check any sublevel headline, assuming that these also match and 3352level zero that surounds the entire file.
3274that the list of matches could become very long because of that. If you 3353
3275do want the sublevels be tested and listed as well, you may set the 3354@example
3276variable @code{org-tags-match-list-sublevels}. To limit tag inheritance 3355#+FILETAGS: :Peter:Boss:Secret:
3277to specific tags, or to turn it off entirely, use the variable 3356@end example
3278@code{org-use-tag-inheritance}. 3357
3358@noindent
3359To limit tag inheritance to specific tags, or to turn it off entirely, use
3360the variable @code{org-use-tag-inheritance}.
3361
3362When a headline matches during a tags search while tag inheritance is turned
3363on, all the sublevels in the same tree will match as well@footnote{This is
3364only true if the the search does not involve more complex tests including
3365properties (@pxref{Property searches}).}. The list of matches may then
3366become very long. If you only want to see the first tags match in a subtree,
3367configure the variable @code{org-tags-match-list-sublevels}.
3279 3368
3280@node Setting tags, Tag searches, Tag inheritance, Tags 3369@node Setting tags, Tag searches, Tag inheritance, Tags
3281@section Setting tags 3370@section Setting tags
@@ -3886,6 +3975,8 @@ Move through the column view from field to field.
3886@item S-@key{left}/@key{right} 3975@item S-@key{left}/@key{right}
3887Switch to the next/previous allowed value of the field. For this, you 3976Switch to the next/previous allowed value of the field. For this, you
3888have to have specified allowed values for a property. 3977have to have specified allowed values for a property.
3978@item 1..9,0
3979Directly select the nth allowed value, @kbd{0} selects the 10th value.
3889@kindex n 3980@kindex n
3890@kindex p 3981@kindex p
3891@itemx n / p 3982@itemx n / p
@@ -3930,6 +4021,7 @@ exported or printed directly. If you want to capture a column view, use
3930this @code{columnview} dynamic block (@pxref{Dynamic blocks}). The frame 4021this @code{columnview} dynamic block (@pxref{Dynamic blocks}). The frame
3931of this block looks like this: 4022of this block looks like this:
3932 4023
4024@cindex #+BEGIN: columnview
3933@example 4025@example
3934* The column view 4026* The column view
3935#+BEGIN: columnview :hlines 1 :id "label" 4027#+BEGIN: columnview :hlines 1 :id "label"
@@ -3948,8 +4040,10 @@ capture, you can use 3 values:
3948@example 4040@example
3949local @r{use the tree in which the capture block is located} 4041local @r{use the tree in which the capture block is located}
3950global @r{make a global view, including all headings in the file} 4042global @r{make a global view, including all headings in the file}
3951"label" @r{call column view in the tree that has and @code{:ID:}} 4043"label" @r{call column view in the tree that has an @code{:ID:}}
3952 @r{property with the value @i{label}} 4044 @r{property with the value @i{label}. You can use}
4045 @r{@kbd{M-x org-id-copy} to create a globally unique ID for}
4046 @r{the current entry and copy it to the kill-ring.}
3953@end example 4047@end example
3954@item :hlines 4048@item :hlines
3955When @code{t}, insert a hline after every line. When a number N, insert 4049When @code{t}, insert a hline after every line. When a number N, insert
@@ -4215,6 +4309,8 @@ a single letter, you use the abbreviation of day name, the date will be
4215the nth such day. E.g. 4309the nth such day. E.g.
4216 4310
4217@example 4311@example
4312+0 --> today
4313. --> today
4218+4d --> four days from today 4314+4d --> four days from today
4219+4 --> same as above 4315+4 --> same as above
4220+2w --> two weeks from today 4316+2w --> two weeks from today
@@ -4411,6 +4507,15 @@ Insert @samp{SCHEDULED} keyword along with a stamp. The insertion will
4411happen in the line directly following the headline. Any CLOSED 4507happen in the line directly following the headline. Any CLOSED
4412timestamp will be removed. When called with a prefix argument, remove 4508timestamp will be removed. When called with a prefix argument, remove
4413the scheduling date from the entry. 4509the scheduling date from the entry.
4510@c
4511@kindex C-c C-x C-k
4512@kindex k a
4513@kindex k s
4514@item C-c C-x C-k
4515Mark the current entry for agenda action. After you have marked the entry
4516like this, you can open the agenda or the calendar to find an appropriate
4517date. With the cursor on the selected date, press @kbd{k s} or @kbd{k d} to
4518schedule the marked item.
4414@end table 4519@end table
4415 4520
4416@node Repeated tasks, , Inserting deadline/schedule, Deadlines and scheduling 4521@node Repeated tasks, , Inserting deadline/schedule, Deadlines and scheduling
@@ -4545,6 +4650,7 @@ report as an Org mode table into the current file. When the cursor is
4545at an existing clock table, just update it. When called with a prefix 4650at an existing clock table, just update it. When called with a prefix
4546argument, jump to the first clock report in the current document and 4651argument, jump to the first clock report in the current document and
4547update it. 4652update it.
4653@cindex #+BEGIN: clocktable
4548@example 4654@example
4549#+BEGIN: clocktable :maxlevel 2 :emphasize nil :scope file 4655#+BEGIN: clocktable :maxlevel 2 :emphasize nil :scope file
4550#+END: clocktable 4656#+END: clocktable
@@ -4620,7 +4726,7 @@ The @kbd{l} key may be used in the timeline (@pxref{Timeline}) and in
4620the agenda (@pxref{Weekly/daily agenda}) to show which tasks have been 4726the agenda (@pxref{Weekly/daily agenda}) to show which tasks have been
4621worked on or closed during a day. 4727worked on or closed during a day.
4622 4728
4623@node Effort estimates 4729@node Effort estimates, , Clocking work time, Dates and Times
4624@section Effort estimates 4730@section Effort estimates
4625@cindex Effort estimates 4731@cindex Effort estimates
4626 4732
@@ -4655,7 +4761,7 @@ In the column next to it, any clocked time will be displayed.
4655If you switch to column view in the daily/weekly agenda, the effort column 4761If you switch to column view in the daily/weekly agenda, the effort column
4656will summarize the estimated work effort for each day@footnote{Please note 4762will summarize the estimated work effort for each day@footnote{Please note
4657the pitfalls of summing hierarchical data in a flat list (@pxref{Agenda 4763the pitfalls of summing hierarchical data in a flat list (@pxref{Agenda
4658column view}.}, and you can use this to find space in your schedule. To get 4764column view}).}, and you can use this to find space in your schedule. To get
4659an overview of the entire part of the day that is committed, you can set the 4765an overview of the entire part of the day that is committed, you can set the
4660option @code{org-agenda-columns-add-appointments-to-effort-sum}. The 4766option @code{org-agenda-columns-add-appointments-to-effort-sum}. The
4661appointments on a day that take place over a specified time interval will 4767appointments on a day that take place over a specified time interval will
@@ -4705,6 +4811,11 @@ stored: Just call @code{org-remember} with a prefix argument. If you
4705use two prefix arguments, Org jumps to the location where the last 4811use two prefix arguments, Org jumps to the location where the last
4706remember note was stored. 4812remember note was stored.
4707 4813
4814You can also call @code{org-remember} in a special way from the agenda,
4815using the @kbd{k r} key combination. With this access, any time stamps
4816inserted by the selected remember template (see below) will default to
4817the cursor date in the agenda, rather than to the current date.
4818
4708@node Remember templates, Storing notes, Setting up Remember, Remember 4819@node Remember templates, Storing notes, Setting up Remember, Remember
4709@section Remember templates 4820@section Remember templates
4710@cindex templates, for remember 4821@cindex templates, for remember
@@ -4724,26 +4835,29 @@ use:
4724 4835
4725@noindent In these entries, the first string is just a name, and the 4836@noindent In these entries, the first string is just a name, and the
4726character specifies how to select the template. It is useful if the 4837character specifies how to select the template. It is useful if the
4727character is also the first letter of the name. The next string 4838character is also the first letter of the name. The next string specifies
4728specifies the template. Two more (optional) strings give the file in 4839the template. Two more (optional) strings give the file in which, and the
4729which, and the headline under which the new note should be stored. The 4840headline under which the new note should be stored. The file (if not present
4730file (if not present or @code{nil}) defaults to 4841or @code{nil}) defaults to @code{org-default-notes-file}, the heading to
4731@code{org-default-notes-file}, the heading to 4842@code{org-remember-default-headline}. If the file name is not an absolute
4732@code{org-remember-default-headline}. If the file name is not an 4843path, it will be interpreted relative to @code{org-directory}. The heading
4733absolute path, it will be interpreted relative to @code{org-directory}. 4844can also be the symbols @code{top} or @code{bottom} to send note as level 1
4734 4845entries to the beginning or end of the file, respectively.
4735An optional sixth element specifies the contexts in which the user can 4846
4736select the template. This element can be either a list of major modes 4847An optional sixth element specifies the contexts in which the user can select
4737or a function. @code{org-remember} will first check whether the function 4848the template. This element can be a list of major modes or a function.
4738returns @code{t} or if we are in any of the listed major mode, and select 4849@code{org-remember} will first check whether the function returns @code{t} or
4739the template accordingly. 4850if we are in any of the listed major mode, and exclude templates fo which
4851this condition is not fulfilled. Templates that do not specify this element
4852at all, or that use @code{nil} or @code{t} as a value will always be
4853selectable.
4740 4854
4741So for example: 4855So for example:
4742 4856
4743@example 4857@example
4744(setq org-remember-templates 4858(setq org-remember-templates
4745 '(("Bug" ?b "* BUG %?\n %i\n %a" "~/org/BUGS.org" "Bugs" (emacs-lisp-mode)) 4859 '(("Bug" ?b "* BUG %?\n %i\n %a" "~/org/BUGS.org" "Bugs" (emacs-lisp-mode))
4746 ("Journal" ?j "* %U %?\n\n %i\n %a" "~/org/JOURNAL.org" my-check) 4860 ("Journal" ?j "* %U %?\n\n %i\n %a" "~/org/JOURNAL.org" "X" my-check)
4747 ("Idea" ?i "* %^@{Title@}\n %i\n %a" "~/org/JOURNAL.org" "New Ideas"))) 4861 ("Idea" ?i "* %^@{Title@}\n %i\n %a" "~/org/JOURNAL.org" "New Ideas")))
4748@end example 4862@end example
4749 4863
@@ -4752,8 +4866,8 @@ from an buffer in @code{emacs-lisp-mode}. The second template will only be
4752available when the function @code{my-check} returns @code{t}. The third 4866available when the function @code{my-check} returns @code{t}. The third
4753template will be proposed in any context. 4867template will be proposed in any context.
4754 4868
4755When you call @kbd{M-x remember} (or @kbd{M-x org-remember}) to remember 4869When you call @kbd{M-x org-remember} (or @kbd{M-x remember}) to remember
4756something, org will prompt for a key to select the template (if you have 4870something, Org will prompt for a key to select the template (if you have
4757more than one template) and then prepare the buffer like 4871more than one template) and then prepare the buffer like
4758@example 4872@example
4759* TODO 4873* TODO
@@ -4768,16 +4882,16 @@ insertion of content:
4768 @r{You may specify a default value and a completion table with} 4882 @r{You may specify a default value and a completion table with}
4769 @r{%^@{prompt|default|completion2|completion3...@}} 4883 @r{%^@{prompt|default|completion2|completion3...@}}
4770 @r{The arrow keys access a prompt-specific history.} 4884 @r{The arrow keys access a prompt-specific history.}
4885%a @r{annotation, normally the link created with @code{org-store-link}}
4886%A @r{like @code{%a}, but prompt for the description part}
4887%i @r{initial content, the region when remember is called with C-u.}
4888 @r{The entire text will be indented like @code{%i} itself.}
4771%t @r{time stamp, date only} 4889%t @r{time stamp, date only}
4772%T @r{time stamp with date and time} 4890%T @r{time stamp with date and time}
4773%u, %U @r{like the above, but inactive time stamps} 4891%u, %U @r{like the above, but inactive time stamps}
4774%^t @r{like @code{%t}, but prompt for date. Similarly @code{%^T}, @code{%^u}, @code{%^U}} 4892%^t @r{like @code{%t}, but prompt for date. Similarly @code{%^T}, @code{%^u}, @code{%^U}}
4775 @r{You may define a prompt like @code{%^@{Birthday@}t}} 4893 @r{You may define a prompt like @code{%^@{Birthday@}t}}
4776%n @r{user name (taken from @code{user-full-name})} 4894%n @r{user name (taken from @code{user-full-name})}
4777%a @r{annotation, normally the link created with @code{org-store-link}}
4778%A @r{like @code{%a}, but prompt for the description part}
4779%i @r{initial content, the region when remember is called with C-u.}
4780 @r{The entire text will be indented like @code{%i} itself.}
4781%c @r{Current kill ring head.} 4895%c @r{Current kill ring head.}
4782%x @r{Content of the X clipboard.} 4896%x @r{Content of the X clipboard.}
4783%^C @r{Interactive selection of which kill or clip to use.} 4897%^C @r{Interactive selection of which kill or clip to use.}
@@ -4789,6 +4903,7 @@ insertion of content:
4789%(sexp) @r{evaluate elisp @code{(sexp)} and replace with the result} 4903%(sexp) @r{evaluate elisp @code{(sexp)} and replace with the result}
4790%! @r{immediately store note after completing the template} 4904%! @r{immediately store note after completing the template}
4791 @r{(skipping the @kbd{C-c C-c} that normally triggers storing)} 4905 @r{(skipping the @kbd{C-c C-c} that normally triggers storing)}
4906%& @r{jump to target location immediately after storing note}
4792@end example 4907@end example
4793 4908
4794@noindent 4909@noindent
@@ -4828,14 +4943,20 @@ template that will be filled with the previous context information.
4828@node Storing notes, Refiling notes, Remember templates, Remember 4943@node Storing notes, Refiling notes, Remember templates, Remember
4829@section Storing notes 4944@section Storing notes
4830 4945
4831When you are finished preparing a note with @i{remember}, you have to 4946When you are finished preparing a note with @i{remember}, you have to press
4832press @kbd{C-c C-c} to file the note away. The handler will store the 4947@kbd{C-c C-c} to file the note away. If you have started the clock in the
4833note in the file and under the headline specified in the template, or it 4948remember buffer, you will first be asked if you want to clock out
4834will use the default file and headlines. The window configuration will 4949now@footnote{To avoid this query, configure the variable
4835be restored, sending you back to the working context before the call to 4950@code{org-remember-clock-out-on-exit}.}. If you answer @kbd{n}, the clock
4836@code{remember}. To re-use the location found during the last call to 4951will continue to run after the note is filed away.
4837@code{remember}, exit the remember buffer with @kbd{C-u C-u C-c C-c}, 4952
4838i.e. specify a double prefix argument to @kbd{C-c C-c}. 4953The handler will then store the note in the file and under the headline
4954specified in the template, or it will use the default file and headlines.
4955The window configuration will be restored, sending you back to the working
4956context before the call to @code{remember}. To re-use the location found
4957during the last call to @code{remember}, exit the remember buffer with
4958@kbd{C-u C-u C-c C-c}, i.e. specify a double prefix argument to @kbd{C-c
4959C-c}.
4839 4960
4840If you want to store the note directly to a different place, use 4961If you want to store the note directly to a different place, use
4841@kbd{C-u C-c C-c} instead to exit remember@footnote{Configure the 4962@kbd{C-u C-c C-c} instead to exit remember@footnote{Configure the
@@ -4898,7 +5019,9 @@ filed below the target heading as a subitem. Depending on
4898subitem.@* By default, all level 1 headlines in the current buffer are 5019subitem.@* By default, all level 1 headlines in the current buffer are
4899considered to be targets, but you can have more complex definitions 5020considered to be targets, but you can have more complex definitions
4900across a number of files. See the variable @code{org-refile-targets} 5021across a number of files. See the variable @code{org-refile-targets}
4901for details. 5022for details. If you would like to select a location via a file-pathlike
5023completion along the outline path, see the variable
5024@code{org-refile-use-outline-path}.
4902@kindex C-u C-c C-w 5025@kindex C-u C-c C-w
4903@item C-u C-c C-w 5026@item C-u C-c C-w
4904Use the refile interface to jump to a heading. 5027Use the refile interface to jump to a heading.
@@ -5696,13 +5819,13 @@ Toggle the ARCHIVE tag for the current headline.
5696@c 5819@c
5697@kindex A 5820@kindex A
5698@item A 5821@item A
5699Move the subtree correspoding to the current entry to its @emph{Archive 5822Move the subtree corresponding to the current entry to its @emph{Archive
5700Sibling}. 5823Sibling}.
5701@c 5824@c
5702@kindex $ 5825@kindex $
5703@item $ 5826@item $
5704Archive the subtree corresponding to the current headline. This means the 5827Archive the subtree corresponding to the current headline. This means the
5705entry will be moved to the configured archive locatin, most likely a 5828entry will be moved to the configured archive location, most likely a
5706different file. 5829different file.
5707@c 5830@c
5708@kindex T 5831@kindex T
@@ -5747,6 +5870,21 @@ Schedule this item
5747@item C-c C-d 5870@item C-c C-d
5748Set a deadline for this item. 5871Set a deadline for this item.
5749@c 5872@c
5873@kindex k
5874@item k
5875Agenda actions, to set dates for selected items to the cursor date.
5876This command also works in the calendar! The command prompts for an
5877additonal key:
5878@example
5879m @r{Mark the entry at point for action. You can also make entries}
5880 @r{in Org files with @kbd{C-c C-x C-k}.}
5881d @r{Set the deadline of the marked entry to the date at point.}
5882s @r{Schedule the marked entry at the date at point.}
5883r @r{Call @code{org-remember} with the cursor date as default date.}
5884@end example
5885Press @kbd{r} afterwards to refresh the agenda and see the effect of the
5886command.
5887@c
5750@kindex S-@key{right} 5888@kindex S-@key{right}
5751@item S-@key{right} 5889@item S-@key{right}
5752Change the time stamp associated with the current line by one day into the 5890Change the time stamp associated with the current line by one day into the
@@ -6554,8 +6692,425 @@ deadlines or appointments into a desktop calendar program like iCal,
6554Org mode can also produce extracts in the iCalendar format. Currently 6692Org mode can also produce extracts in the iCalendar format. Currently
6555Org mode only supports export, not import of these different formats. 6693Org mode only supports export, not import of these different formats.
6556 6694
6557When exporting, Org mode uses special conventions to enrich the output 6695@menu
6558produced. @xref{Text interpretation}, for more details. 6696* Markup rules:: Which structures are recognized?
6697* Export options:: Per-file export settings
6698* The export dispatcher:: How to access exporter commands
6699* ASCII export:: Exporting to plain ASCII
6700* HTML export:: Exporting to HTML
6701* LaTeX export:: Exporting to LaTeX
6702* XOXO export:: Exporting to XOXO
6703* iCalendar export:: Exporting in iCalendar format
6704@end menu
6705
6706@node Markup rules, Export options, Exporting, Exporting
6707@section Markup rules
6708
6709When exporting Org mode documents, the exporter tries to reflect the
6710structure of the document as accurately as possible in the back-end. Since
6711export targets like HTML or La@TeX{} allow much richer formatting, Org mode
6712has rules how to prepare text for rich export. This section summarizes the
6713markup rule used in an Org mode buffer.
6714
6715@menu
6716* Document title:: How the document title is determined
6717* Headings and sections:: The main structure of the exported document
6718* Table of contents:: If, where, how to create a table of contents
6719* Initial text:: Text before the first headline
6720* Lists:: Plain lists are exported
6721* Paragraphs:: What determines beginning and ending
6722* Literal examples:: Source code and other examples
6723* Include files:: Include the contents of a file during export
6724* Tables exported:: Tables are exported richly
6725* Footnotes:: Numbers like [1]
6726* Emphasis and monospace:: To bold or not to bold
6727* TeX macros and LaTeX fragments:: Create special, rich export.
6728* Horizontal rules:: A line across the page
6729* Comment lines:: Some lines will not be exported
6730@end menu
6731
6732@node Document title, Headings and sections, Markup rules, Markup rules
6733@subheading Document title
6734@cindex document title, markup rules
6735
6736@noindent
6737The title of the exported document is taken from the special line
6738
6739@example
6740#+TITLE: This is the title of the document
6741@end example
6742
6743@noindent
6744If this line does not exist, the title is derived from the first non-empty,
6745non-comment line in the buffer. If no such line exists, or if you have
6746turned off exporting of the text before the first headline (see below), the
6747title will be the file name without extension.
6748
6749If you are exporting only a subtree by marking is as the region, the heading
6750of the subtree will become the title of the document. If the subtree has a
6751property @code{EXPORT_TITLE}, that will take precedence.
6752
6753@node Headings and sections, Table of contents, Document title, Markup rules
6754@subheading Headings and sections
6755@cindex headings and sections, markup rules
6756
6757The outline structure of the document as described in @ref{Document
6758Structure} forms the basis for defining sections of the exported document.
6759However, since the outline structure is also used for (for example) lists of
6760tasks, only the first three outline levels will be used as headings. Deeper
6761levels will become itemized lists. You can change the location of this
6762switch, globally by setting the variable @code{org-headline-levels}, or on a
6763per file basis with a line
6764
6765@example
6766#+OPTIONS: H:4
6767@end example
6768
6769@node Table of contents, Initial text, Headings and sections, Markup rules
6770@subheading Table of contents
6771@cindex table of contents, markup rules
6772
6773The table of contents is normally inserted directly before the first headline
6774of the file. If you would like to get it to a different location, insert the
6775string @code{[TABLE-OF-CONTENTS]} on a line by itself at the desired
6776location. The depth of the table of contents is by default the same as the
6777number of headline levels, but you can choose a smaller number or turn off
6778the table of contents entirely by configuring the variable
6779@code{org-export-with-toc}, or on a per-file basis with a line like
6780
6781@example
6782#+OPTIONS: toc:2 (only to two levels in TOC)
6783#+OPTIONS: toc:nil (no TOC at all)
6784@end example
6785
6786@node Initial text, Lists, Table of contents, Markup rules
6787@subheading Text before the first headline
6788@cindex text before first headline, markup rules
6789@cindex #+TEXT
6790
6791Org mode normally exports the text before the first headline, and even uses
6792the first line as the document title. The text will be fully marked up. If
6793you need to include literal HTML or La@TeX{} code, use the special constructs
6794described below in the sections for the individual exporters.
6795
6796Some people like to use the space before the first headline for setup and
6797internal links and therefore would like to control the exported text before
6798the first headline in a different way. You can do so by setting the variable
6799@code{org-export-skip-text-before-1st-heading} to @code{t}. On a per-file
6800basis, you can get the same effect with @samp{#+OPTIONS: skip:t}.
6801
6802@noindent
6803If you still want to have some text before the first headline, use the
6804@code{#+TEXT} construct:
6805
6806@example
6807#+OPTIONS: skip:t
6808#+TEXT: This text will go before the *first* headline.
6809#+TEXT: [TABLE-OF-CONTENTS]
6810#+TEXT: This goes between the table of contents and the first headline
6811@end example
6812
6813@node Lists, Paragraphs, Initial text, Markup rules
6814@subheading Lists
6815@cindex lists, markup rules
6816
6817Plain lists as described in @ref{Plain lists} are translated to the back-ends
6818syntax for such lists. Most back-ends support unordered, ordered, and
6819description lists.
6820
6821@node Paragraphs, Literal examples, Lists, Markup rules
6822@subheading Paragraphs, line breaks, and quoting
6823@cindex paragraphs, markup rules
6824
6825Paragraphs are separated by at least one empty line. If you need to enforce
6826a line break within a paragraph, use @samp{\\} at the end of a line.
6827
6828To keep the line breaks in a region, but otherwise use normal formatting, you
6829can use this construct, which can also be used to format poetry.
6830
6831@example
6832#+BEGIN_VERSE
6833Everything should be made as simple as possible,
6834but not any simpler -- Albert Einstein
6835#+END_VERSE
6836@end example
6837
6838When quoting a passage from another document, it is customary to format this
6839as a paragraph that is indented on both the left and the right margin. You
6840can include quotations in Org mode documents like this:
6841
6842@example
6843#+BEGIN_QUOTE
6844Everything should be made as simple as possible,
6845but not any simpler -- Albert Einstein
6846#+END_QUOTE
6847@end example
6848
6849
6850@node Literal examples, Include files, Paragraphs, Markup rules
6851@subheading Literal examples
6852@cindex literal examples, markup rules
6853
6854You can include literal examples that should not be subjected to
6855markup. Such examples will be typeset in monospace, so this is well suited
6856for source code and similar examples.
6857@cindex #+BEGIN_EXAMPLE
6858
6859@example
6860#+BEGIN_EXAMPLE
6861Some example from a text file.
6862#+END_EXAMPLE
6863@end example
6864
6865For simplicity when using small examples, you can also start the example
6866lines with a colon:
6867
6868@example
6869: Some example from a text file.
6870@end example
6871
6872@cindex formatting source code, markup rules
6873If the example is source code from a programming language, or any other text
6874that can be marked up by font-lock in Emacs, you can ask for the example to
6875look like the fontified Emacs buffer@footnote{Currently this works only for
6876the HTML back-end, and requires the @file{htmlize.el} package version 1.34 or
6877later.}. This is done with the @samp{src} block, where you also need to
6878specify the name of the major mode that should be used to fontify the
6879example:
6880@cindex #+BEGIN_SRC
6881
6882@example
6883#+BEGIN_SRC emacs-lisp
6884(defun org-xor (a b)
6885 "Exclusive or."
6886 (if a (not b) b))
6887#+END_SRC
6888@end example
6889
6890@table @kbd
6891@kindex C-c '
6892@item C-c '
6893Edit the source code example at point in its native mode. This works by
6894switching to an indirect buffer, narrowing the buffer and switching to the
6895other mode. You need to exit by pressing @kbd{C-c '} again.
6896@end table
6897
6898
6899@node Include files, Tables exported, Literal examples, Markup rules
6900@subheading Include files
6901@cindex include files, markup rules
6902
6903During export, you can include the content of another file. For example, to
6904include your .emacs file, you could use:
6905@cindex #+INCLUDE
6906
6907@example
6908#+INCLUDE: "~/.emacs" src emacs-lisp
6909@end example
6910
6911The optional second and third parameter are the markup (@samp{quote},
6912@samp{example}, or @samp{src}), and, if the markup is @samp{src}, the
6913language for formatting the contents. The markup is optional, if it is not
6914given, the text will be assumed to be in Org mode format and will be
6915processed normally.
6916
6917@table @kbd
6918@kindex C-c '
6919@item C-c '
6920Visit the include file at point.
6921@end table
6922
6923@node Tables exported, Footnotes, Include files, Markup rules
6924@subheading Tables
6925@cindex tables, markup rules
6926
6927Both the native Org mode tables (@pxref{Tables}) and tables formatted with
6928the @file{table.el} package will be exported properly. For Org mode tables,
6929the lines before the first horizontal separator line will become table header
6930lines.
6931
6932@node Footnotes, Emphasis and monospace, Tables exported, Markup rules
6933@subheading Footnotes
6934@cindex footnotes, markup rules
6935@cindex @file{footnote.el}
6936
6937@kindex C-c !
6938Numbers in square brackets are treated as footnote markers, and lines
6939starting with such a marker are interpreted as the footnote itself. You can
6940use the Emacs package @file{footnote.el} to create footnotes@footnote{The
6941@file{footnote} package uses @kbd{C-c !} to invoke its commands. This
6942binding conflicts with the Org mode command for inserting inactive time
6943stamps. You could use the variable @code{footnote-prefix} to switch
6944footnotes commands to another key. Or, if you are too used to this binding,
6945you could use @code{org-replace-disputed-keys} and @code{org-disputed-keys}
6946to change the settings in Org.}. For example:
6947
6948@example
6949The Org homepage[1] now looks a lot better than it used to.
6950
6951[1] The link is: http://orgmode.org
6952@end example
6953
6954@node Emphasis and monospace, TeX macros and LaTeX fragments, Footnotes, Markup rules
6955@subheading Emphasis and monospace
6956
6957@cindex underlined text, markup rules
6958@cindex bold text, markup rules
6959@cindex italic text, markup rules
6960@cindex verbatim text, markup rules
6961@cindex code text, markup rules
6962@cindex strike-through text, markup rules
6963You can make words @b{*bold*}, @i{/italic/}, _underlined_, @code{=code=}
6964and @code{~verbatim~}, and, if you must, @samp{+strike-through+}. Text
6965in the code and verbatim string is not processed for Org mode specific
6966syntax, it is exported verbatim.
6967
6968@node TeX macros and LaTeX fragments, Horizontal rules, Emphasis and monospace, Markup rules
6969@subheading @TeX{} macros and La@TeX{} fragments
6970@cindex LaTeX fragments, markup rules
6971@cindex TeX macros, markup rules
6972@cindex HTML entities
6973@cindex LaTeX entities
6974
6975A @TeX{}-like syntax is used to specify special characters. Where possible,
6976these will be transformed into the native format of the exporter back-end.
6977Strings like @code{\alpha} will be exported as @code{&alpha;} in the HTML
6978output, and as @code{$\alpha$} in the La@TeX{} output. Similarly,
6979@code{\nbsp} will become @code{&nbsp;} in HTML and @code{~} in La@TeX{}.
6980This applies for a large number of entities, with names taken from both HTML
6981and La@TeX{}, see the variable @code{org-html-entities} for the complete
6982list. If you are unsure about a name, use @kbd{M-@key{TAB}} for completion
6983after having types the backslash and maybe a few characters
6984(@pxref{Completion}).
6985
6986La@TeX{} fragments are converted into images for HTML export, and they are
6987written literally into the La@TeX{} export. See also @ref{Embedded LaTeX}.
6988
6989Finally, @samp{\-} is treated as a shy hyphen, and @samp{--}, @samp{---}, and
6990@samp{...} are all converted into special commands creating hyphens of
6991different lengths or a compact set of dots.
6992
6993@node Horizontal rules, Comment lines, TeX macros and LaTeX fragments, Markup rules
6994@subheading Horizontal rules
6995@cindex horizontal rules, markup rules
6996A line consisting of only dashes, and at least 5 of them, will be
6997exported as a horizontal line (@samp{<hr/>} in HTML).
6998
6999@node Comment lines, , Horizontal rules, Markup rules
7000@subheading Comment lines
7001@cindex comment lines
7002@cindex exporting, not
7003
7004Lines starting with @samp{#} in column zero are treated as comments and will
7005never be exported. Also entire subtrees starting with the word
7006@samp{COMMENT} will never be exported. Finally, regions surrounded by
7007@samp{#+BEGIN_COMMENT} ... @samp{#+END_COMMENT} will not be exported.
7008
7009@table @kbd
7010@kindex C-c ;
7011@item C-c ;
7012Toggle the COMMENT keyword at the beginning of an entry.
7013@end table
7014
7015@node Export options, The export dispatcher, Markup rules, Exporting
7016@section Export options
7017@cindex options, for export
7018
7019@cindex completion, of option keywords
7020The exporter recognizes special lines in the buffer which provide
7021additional information. These lines may be put anywhere in the file.
7022The whole set of lines can be inserted into the buffer with @kbd{C-c
7023C-e t}. For individual lines, a good way to make sure the keyword is
7024correct is to type @samp{#+} and then use @kbd{M-@key{TAB}} completion
7025(@pxref{Completion}).
7026
7027@table @kbd
7028@kindex C-c C-e t
7029@item C-c C-e t
7030Insert template with export options, see example below.
7031@end table
7032
7033@cindex #+TITLE:
7034@cindex #+AUTHOR:
7035@cindex #+DATE:
7036@cindex #+EMAIL:
7037@cindex #+LANGUAGE:
7038@cindex #+TEXT:
7039@cindex #+OPTIONS:
7040@cindex #+LINK_UP:
7041@cindex #+LINK_HOME:
7042@example
7043#+TITLE: the title to be shown (default is the buffer name)
7044#+AUTHOR: the author (default taken from @code{user-full-name})
7045#+DATE: A date, fixed, of a format string for @code{format-time-string}
7046#+EMAIL: his/her email address (default from @code{user-mail-address})
7047#+LANGUAGE: language for HTML, e.g. @samp{en} (@code{org-export-default-language})
7048#+TEXT: Some descriptive text to be inserted at the beginning.
7049#+TEXT: Several lines may be given.
7050#+OPTIONS: H:2 num:t toc:t \n:nil @@:t ::t |:t ^:t f:t TeX:t ...
7051#+LINK_UP: the ``up'' link of an exported page
7052#+LINK_HOME: the ``home'' link of an exported page
7053@end example
7054
7055@noindent
7056The OPTIONS line is a compact@footnote{If you want to configure many options
7057this way, you can use several OPTIONS lines.} form to specify export settings. Here
7058you can:
7059@cindex headline levels
7060@cindex section-numbers
7061@cindex table of contents
7062@cindex line-break preservation
7063@cindex quoted HTML tags
7064@cindex fixed-width sections
7065@cindex tables
7066@cindex @TeX{}-like syntax for sub- and superscripts
7067@cindex footnotes
7068@cindex special strings
7069@cindex emphasized text
7070@cindex @TeX{} macros
7071@cindex La@TeX{} fragments
7072@cindex author info, in export
7073@cindex time info, in export
7074@example
7075H: @r{set the number of headline levels for export}
7076num: @r{turn on/off section-numbers}
7077toc: @r{turn on/off table of contents, or set level limit (integer)}
7078\n: @r{turn on/off line-break-preservation}
7079@@: @r{turn on/off quoted HTML tags}
7080:: @r{turn on/off fixed-width sections}
7081|: @r{turn on/off tables}
7082^: @r{turn on/off @TeX{}-like syntax for sub- and superscripts. If}
7083 @r{you write "^:@{@}", @code{a_@{b@}} will be interpreted, but}
7084 @r{the simple @code{a_b} will be left as it is.}
7085-: @r{turn on/off conversion of special strings.}
7086f: @r{turn on/off footnotes like this[1].}
7087*: @r{turn on/off emphasized text (bold, italic, underlined)}
7088TeX: @r{turn on/off simple @TeX{} macros in plain text}
7089LaTeX: @r{turn on/off La@TeX{} fragments}
7090skip: @r{turn on/off skipping the text before the first heading}
7091author: @r{turn on/off inclusion of author name/email into exported file}
7092timestamp: @r{turn on/off inclusion creation time into exported file}
7093d: @r{turn on/off inclusion of drawers}
7094@end example
7095
7096These options take effect in both the HTML and La@TeX{} export, except
7097for @code{TeX} and @code{LaTeX}, which are respectively @code{t} and
7098@code{nil} for the La@TeX{} export.
7099
7100When exporting only a single subtree by selecting it with @kbd{C-c @@} before
7101calling an export command, the subtree can overrule some of the file's export
7102settings with properties @code{EXPORT_FILE_NAME}, @code{EXPORT_TITLE},
7103@code{EXPORT_TEXT}, and @code{EXPORT_OPTIONS}.
7104
7105@node The export dispatcher, ASCII export, Export options, Exporting
7106@section The export dispatcher
7107@cindex dispatcher, for export commands
7108
7109All export commands can be reached using the export dispatcher, which is a
7110prefix key that prompts for an additional key specifying the command.
7111Normally the entire file is exported, but if there is an active region that
7112contains one outline tree, the first heading is used as document title and
7113the subtrees are exported.
6559 7114
6560@table @kbd 7115@table @kbd
6561@kindex C-c C-e 7116@kindex C-c C-e
@@ -6566,6 +7121,10 @@ command. The prefix arg is passed through to the exporter. If the option
6566@code{org-export-run-in-background} is set, Org will run the command in the 7121@code{org-export-run-in-background} is set, Org will run the command in the
6567background if that seems useful for the specific command (i.e. commands that 7122background if that seems useful for the specific command (i.e. commands that
6568write to a file). 7123write to a file).
7124@kindex C-c C-e v
7125@item C-c C-e v
7126Like @kbd{C-c C-e}, but only export the text that is currently visible
7127(i.e. not hidden by outline visibility).
6569@kindex C-u C-u C-c C-e 7128@kindex C-u C-u C-c C-e
6570@item C-u C-u C-c C-e 7129@item C-u C-u C-c C-e
6571Call an the exporter, but reverse the setting of 7130Call an the exporter, but reverse the setting of
@@ -6573,16 +7132,7 @@ Call an the exporter, but reverse the setting of
6573not set, or force processing in the current Emacs process if st. 7132not set, or force processing in the current Emacs process if st.
6574@end table 7133@end table
6575 7134
6576@menu 7135@node ASCII export, HTML export, The export dispatcher, Exporting
6577* ASCII export:: Exporting to plain ASCII
6578* HTML export:: Exporting to HTML
6579* LaTeX export:: Exporting to LaTeX
6580* XOXO export:: Exporting to XOXO
6581* iCalendar export:: Exporting in iCalendar format
6582* Text interpretation:: How the exporter looks at the file
6583@end menu
6584
6585@node ASCII export, HTML export, Exporting, Exporting
6586@section ASCII export 7136@section ASCII export
6587@cindex ASCII export 7137@cindex ASCII export
6588 7138
@@ -6598,9 +7148,10 @@ file.
6598Export as ASCII file. For an org file @file{myfile.org}, the ASCII file 7148Export as ASCII file. For an org file @file{myfile.org}, the ASCII file
6599will be @file{myfile.txt}. The file will be overwritten without 7149will be @file{myfile.txt}. The file will be overwritten without
6600warning. If there is an active region, only the region will be 7150warning. If there is an active region, only the region will be
6601exported. If the selected region is a single tree, the tree head will 7151exported. If the selected region is a single tree@footnote{To select the
7152current subtree, use @kbd{C-c @@}.}, the tree head will
6602become the document title. If the tree head entry has or inherits an 7153become the document title. If the tree head entry has or inherits an
6603@code{:EXPORT_FILE_NAME:} property, that name will be used for the 7154@code{EXPORT_FILE_NAME} property, that name will be used for the
6604export. 7155export.
6605@kindex C-c C-e v a 7156@kindex C-c C-e v a
6606@item C-c C-e v a 7157@item C-c C-e v a
@@ -6635,7 +7186,7 @@ HTML formatting, in ways similar to John Grubers @emph{markdown}
6635language, but with additional support for tables. 7186language, but with additional support for tables.
6636 7187
6637@menu 7188@menu
6638* HTML Export commands:: How to invoke LaTeX export 7189* HTML Export commands:: How to invoke HTML export
6639* Quoting HTML tags:: Using direct HTML in Org mode 7190* Quoting HTML tags:: Using direct HTML in Org mode
6640* Links:: Transformation of links for HTML 7191* Links:: Transformation of links for HTML
6641* Images:: How to include images 7192* Images:: How to include images
@@ -6652,13 +7203,13 @@ language, but with additional support for tables.
6652@table @kbd 7203@table @kbd
6653@kindex C-c C-e h 7204@kindex C-c C-e h
6654@item C-c C-e h 7205@item C-c C-e h
6655Export as HTML file @file{myfile.html}. For an org file 7206Export as HTML file @file{myfile.html}. For an org file @file{myfile.org},
6656@file{myfile.org}, the ASCII file will be @file{myfile.html}. The file 7207the ASCII file will be @file{myfile.html}. The file will be overwritten
6657will be overwritten without warning. If there is an active region, only 7208without warning. If there is an active region, only the region will be
6658the region will be exported. If the selected region is a single tree, 7209exported. If the selected region is a single tree@footnote{To select the
6659the tree head will become the document title. If the tree head entry 7210current subtree, use @kbd{C-c @@}.}, the tree head will become the document
6660has or inherits an @code{:EXPORT_FILE_NAME:} property, that name will be 7211title. If the tree head entry has or inherits an @code{EXPORT_FILE_NAME}
6661used for the export. 7212property, that name will be used for the export.
6662@kindex C-c C-e b 7213@kindex C-c C-e b
6663@item C-c C-e b 7214@item C-c C-e b
6664Export as HTML file and immediately open it with a browser. 7215Export as HTML file and immediately open it with a browser.
@@ -6716,6 +7267,7 @@ the exported file use either
6716@end example 7267@end example
6717 7268
6718@noindent or 7269@noindent or
7270@cindex #+BEGIN_HTML
6719 7271
6720@example 7272@example
6721#+BEGIN_HTML 7273#+BEGIN_HTML
@@ -6818,19 +7370,20 @@ navigation can be done with the @kbd{n} and @kbd{p} keys (and some other keys
6818as well, press @kbd{?} for an overview of the available keys). The second 7370as well, press @kbd{?} for an overview of the available keys). The second
6819view type is a @emph{folding} view much like Org provides it inside Emacs. 7371view type is a @emph{folding} view much like Org provides it inside Emacs.
6820The script is available at @url{http://orgmode.org/org-info.js} and you can 7372The script is available at @url{http://orgmode.org/org-info.js} and you can
6821find the documentation for it at @url{http://orgmode.org/org-infojs.html}. 7373find the documentation for it at
6822We are serving the script from our site, but if you use it a lot, you might 7374@url{http://orgmode.org/worg/code/org-info-js/org-info.js.html}. We are
6823not want to be dependent on @url{orgmode.org} and prefer to install a local 7375serving the script from our site, but if you use it a lot, you might not want
6824copy on your own web server. 7376to be dependent on @url{orgmode.org} and prefer to install a local copy on
7377your own web server.
6825 7378
6826To use the script, you need to make sure that the @file{org-infojs.el} module 7379To use the script, you need to make sure that the @file{org-jsinfo.el} module
6827gets loaded. It should be loaded by default, try @kbd{M-x customize-variable 7380gets loaded. It should be loaded by default, try @kbd{M-x customize-variable
6828@key{RET} org-modules @key{RET}} to convince yourself that this is indeed the 7381@key{RET} org-modules @key{RET}} to convince yourself that this is indeed the
6829case. All it then takes to make use of the program is adding a single line 7382case. All it then takes to make use of the program is adding a single line
6830to the Org file: 7383to the Org file:
6831 7384
6832@example 7385@example
6833#+INFOSJ_OPT: view:info toc:nil 7386#+INFOJS_OPT: view:info toc:nil
6834@end example 7387@end example
6835 7388
6836@noindent 7389@noindent
@@ -6842,7 +7395,7 @@ viewing options:
6842path: @r{The path to the script. The default is to grab the script from} 7395path: @r{The path to the script. The default is to grab the script from}
6843 @r{@url{http://orgmode.org/org-info.js}, but you might want to have} 7396 @r{@url{http://orgmode.org/org-info.js}, but you might want to have}
6844 @r{a local copy and use a path like @samp{../scripts/org-info.js}.} 7397 @r{a local copy and use a path like @samp{../scripts/org-info.js}.}
6845view: @r{Initial view when website is first shown. Possible values are} 7398view: @r{Initial view when website is first shown. Possible values are:}
6846 info @r{Info-like interface with one section per page.} 7399 info @r{Info-like interface with one section per page.}
6847 overview @r{Folding interface, initially showing only top-level.} 7400 overview @r{Folding interface, initially showing only top-level.}
6848 content @r{Folding interface, starting with all headlines visible.} 7401 content @r{Folding interface, starting with all headlines visible.}
@@ -6856,6 +7409,8 @@ toc: @r{Should the table of content @emph{initially} be visible?}
6856 @r{Even when @code{nil}, you can always get to the toc with @kbd{i}.} 7409 @r{Even when @code{nil}, you can always get to the toc with @kbd{i}.}
6857tdepth: @r{The depth of the table of contents. The defaults are taken from} 7410tdepth: @r{The depth of the table of contents. The defaults are taken from}
6858 @r{the variables @code{org-headline-levels} and @code{org-export-with-toc}.} 7411 @r{the variables @code{org-headline-levels} and @code{org-export-with-toc}.}
7412ftoc: @r{Does the css of the page specify a fixed position for the toc?}
7413 @r{If yes, the toc will never be displayed as a section.}
6859ltoc: @r{Should there be short contents (children) in each section?} 7414ltoc: @r{Should there be short contents (children) in each section?}
6860mouse: @r{Headings are highlighted when the mouse is over them. Should be} 7415mouse: @r{Headings are highlighted when the mouse is over them. Should be}
6861 @r{@samp{underline} (default) or a background color like @samp{#cccccc}.} 7416 @r{@samp{underline} (default) or a background color like @samp{#cccccc}.}
@@ -6885,7 +7440,13 @@ Org mode contains a La@TeX{} exporter written by Bastien Guerry.
6885@table @kbd 7440@table @kbd
6886@kindex C-c C-e l 7441@kindex C-c C-e l
6887@item C-c C-e l 7442@item C-c C-e l
6888Export as La@TeX{} file @file{myfile.tex}. 7443Export as La@TeX{} file @file{myfile.tex}. For an org file
7444@file{myfile.org}, the ASCII file will be @file{myfile.tex}. The file will
7445be overwritten without warning. If there is an active region, only the
7446region will be exported. If the selected region is a single tree@footnote{To
7447select the current subtree, use @kbd{C-c @@}.}, the tree head will become the
7448document title. If the tree head entry has or inherits an
7449@code{EXPORT_FILE_NAME} property, that name will be used for the export.
6889@kindex C-c C-e L 7450@kindex C-c C-e L
6890@item C-c C-e L 7451@item C-c C-e L
6891Export to a temporary buffer, do not create a file. 7452Export to a temporary buffer, do not create a file.
@@ -6933,6 +7494,7 @@ constructs:
6933@end example 7494@end example
6934 7495
6935@noindent or 7496@noindent or
7497@cindex #+BEGIN_LaTeX
6936 7498
6937@example 7499@example
6938#+BEGIN_LaTeX 7500#+BEGIN_LaTeX
@@ -6940,8 +7502,6 @@ All lines between these markers are exported literally
6940#+END_LaTeX 7502#+END_LaTeX
6941@end example 7503@end example
6942 7504
6943
6944
6945@node Sectioning structure, , Quoting LaTeX code, LaTeX export 7505@node Sectioning structure, , Quoting LaTeX code, LaTeX export
6946@subsection Sectioning structure 7506@subsection Sectioning structure
6947@cindex LaTeX class 7507@cindex LaTeX class
@@ -6973,7 +7533,7 @@ Export as XOXO file @file{myfile.html}.
6973Export only the visible part of the document. 7533Export only the visible part of the document.
6974@end table 7534@end table
6975 7535
6976@node iCalendar export, Text interpretation, XOXO export, Exporting 7536@node iCalendar export, , XOXO export, Exporting
6977@section iCalendar export 7537@section iCalendar export
6978@cindex iCalendar export 7538@cindex iCalendar export
6979 7539
@@ -6985,6 +7545,16 @@ application. Org mode can export calendar information in the standard
6985iCalendar format. If you also want to have TODO entries included in the 7545iCalendar format. If you also want to have TODO entries included in the
6986export, configure the variable @code{org-icalendar-include-todo}. 7546export, configure the variable @code{org-icalendar-include-todo}.
6987 7547
7548The iCalendar standard requires each entry to have a globally unique
7549identifier (UID). Org creates these identifiers during export. If you set
7550the variable @code{org-icalendar-store-UID}, the UID will be stored in the
7551@code{:ID:} property of the entry and re-used next time you report this
7552entry. Since a single entry can give rise to multiple iCalendar entries (as
7553a timestamp, a deadline, a scheduled item, and as a TODO item), Org adds
7554prefixes to the UID, depending on what triggered the inclusion of the entry.
7555In this way the UID remains unique, but a synchronization program can still
7556figure out from which entry all the different instances originate.
7557
6988@table @kbd 7558@table @kbd
6989@kindex C-c C-e i 7559@kindex C-c C-e i
6990@item C-c C-e i 7560@item C-c C-e i
@@ -7010,294 +7580,6 @@ from the headline, and the description from the body (limited to
7010How this calendar is best read and updated, depends on the application 7580How this calendar is best read and updated, depends on the application
7011you are using. The FAQ covers this issue. 7581you are using. The FAQ covers this issue.
7012 7582
7013
7014@node Text interpretation, , iCalendar export, Exporting
7015@section Text interpretation by the exporter
7016
7017The exporter backends interpret additional structure in the Org file
7018in order to produce better output.
7019
7020@menu
7021* Comment lines:: Some lines will not be exported
7022* Initial text:: Text before the first headline
7023* Footnotes:: Numbers like [1]
7024* Quoted examples:: Inserting quoted chunks of text
7025* Enhancing text:: Subscripts, symbols and more
7026* Export options:: How to influence the export settings
7027@end menu
7028
7029@node Comment lines, Initial text, Text interpretation, Text interpretation
7030@subsection Comment lines
7031@cindex comment lines
7032@cindex exporting, not
7033
7034Lines starting with @samp{#} in column zero are treated as comments
7035and will never be exported. Also entire subtrees starting with the
7036word @samp{COMMENT} will never be exported.
7037
7038@table @kbd
7039@kindex C-c ;
7040@item C-c ;
7041Toggle the COMMENT keyword at the beginning of an entry.
7042@end table
7043
7044@node Initial text, Footnotes, Comment lines, Text interpretation
7045@subsection Text before the first headline
7046
7047Org mode normally ignores any text before the first headline when
7048exporting, leaving this region for internal links to speed up navigation
7049etc. However, in publishing-oriented files, you might want to have some
7050text before the first headline, like a small introduction, special HTML
7051code with a navigation bar, etc. You can ask to have this part of the
7052file exported as well by setting the variable
7053@code{org-export-skip-text-before-1st-heading} to @code{nil}. On a
7054per-file basis, you can get the same effect with
7055
7056@example
7057#+OPTIONS: skip:nil
7058@end example
7059
7060The text before the first headline will be fully processed
7061(@pxref{Enhancing text}), and the first non-comment line becomes the
7062title of the exported document. If you need to include literal HTML,
7063use the special constructs described in @ref{Quoting HTML tags}. The
7064table of contents is normally inserted directly before the first
7065headline of the file. If you would like to get it to a different
7066location, insert the string @code{[TABLE-OF-CONTENTS]} on a line by
7067itself at the desired location.
7068
7069Finally, if you want to use the space before the first headline for
7070internal purposes, but @emph{still} want to place something before the
7071first headline when exporting the file, you can use the @code{#+TEXT}
7072construct:
7073
7074@example
7075#+OPTIONS: skip:t
7076#+TEXT: This text will go before the *first* headline.
7077#+TEXT: We place the table of contents here:
7078#+TEXT: [TABLE-OF-CONTENTS]
7079#+TEXT: This goes between the table of contents and the first headline
7080@end example
7081
7082@node Footnotes, Quoted examples, Initial text, Text interpretation
7083@subsection Footnotes
7084@cindex footnotes
7085@cindex @file{footnote.el}
7086
7087Numbers in square brackets are treated as footnotes, so that you can use
7088the Emacs package @file{footnote.el} to create footnotes. For example:
7089
7090@example
7091The Org homepage[1] clearly needs help from
7092a good web designer.
7093
7094[1] The link is: http://orgmode.org
7095@end example
7096
7097@noindent
7098@kindex C-c !
7099Note that the @file{footnote} package uses @kbd{C-c !} to invoke its
7100commands. This binding conflicts with the Org mode command for
7101inserting inactive time stamps. You could use the variable
7102@code{footnote-prefix} to switch footnotes commands to another key. Or,
7103if you are too used to this binding, you could use
7104@code{org-replace-disputed-keys} and @code{org-disputed-keys} to change
7105the settings in Org.
7106
7107@node Quoted examples, Enhancing text, Footnotes, Text interpretation
7108@subsection Quoted examples
7109@cindex quoted examples
7110@cindex examples, quoted
7111@cindex text, fixed width
7112@cindex fixed width text
7113
7114When writing technical documents, you often need to insert examples that
7115are not further interpreted by Org mode. For historical reasons, there
7116are several ways to do this:
7117
7118@itemize @bullet
7119@item
7120If a headline starts with the word @samp{QUOTE}, the text below the
7121headline will be typeset as fixed-width, to allow quoting of computer
7122codes etc.
7123@item
7124Lines starting with @samp{:} are also typeset in fixed-width font.
7125@table @kbd
7126@kindex C-c :
7127@item C-c :
7128Toggle fixed-width for entry (QUOTE) or region, see below.
7129@end table
7130@item
7131Finally, text between
7132@example
7133#+BEGIN_EXAMPLE
7134quoted text
7135#+END_EXAMPLE
7136@end example
7137will also be exported in this way.
7138@end itemize
7139
7140
7141@node Enhancing text, Export options, Quoted examples, Text interpretation
7142@subsection Enhancing text for export
7143@cindex enhancing text
7144@cindex richer text
7145
7146Some of the export backends of Org mode allow for sophisticated text
7147formatting, this is true in particular for the HTML and La@TeX{}
7148backends. Org mode has a number of typing conventions that allow to
7149produce a richly formatted output.
7150
7151@itemize @bullet
7152
7153@cindex hand-formatted lists
7154@cindex lists, hand-formatted
7155@item
7156Plain lists @samp{-}, @samp{*} or @samp{+} as bullet, or with @samp{1.}
7157or @samp{2)} as enumerator will be recognized and transformed if the
7158backend supports lists. See @xref{Plain lists}.
7159
7160@cindex underlined text
7161@cindex bold text
7162@cindex italic text
7163@cindex verbatim text
7164@item
7165You can make words @b{*bold*}, @i{/italic/}, _underlined_, @code{=code=}
7166and @code{~verbatim~}, and, if you must, @samp{+strikethrough+}. Text
7167in the code and verbatim string is not processed for Org mode specific
7168syntax, it is exported verbatim.
7169
7170@cindex horizontal rules, in exported files
7171@item
7172A line consisting of only dashes, and at least 5 of them, will be
7173exported as a horizontal line (@samp{<hr/>} in HTML).
7174
7175@cindex LaTeX fragments, export
7176@cindex TeX macros, export
7177@item
7178Many @TeX{} macros and entire La@TeX{} fragments are converted into HTML
7179entities or images (@pxref{Embedded LaTeX}).
7180
7181@cindex tables, export
7182@item
7183Tables are transformed into native tables under the exporter, if the
7184export backend supports this. Data fields before the first horizontal
7185separator line will be formatted as table header fields.
7186
7187@cindex fixed width
7188@item
7189If a headline starts with the word @samp{QUOTE}, the text below the
7190headline will be typeset as fixed-width, to allow quoting of computer
7191codes etc. Lines starting with @samp{:} are also typeset in fixed-width
7192font.
7193@table @kbd
7194@kindex C-c :
7195@item C-c :
7196Toggle fixed-width for entry (QUOTE) or region, see below.
7197@end table
7198Finally, text between
7199@example
7200#+BEGIN_EXAMPLE
7201quoted text
7202#+END_EXAMPLE
7203@end example
7204will also be exported in this way.
7205
7206@cindex linebreak, forced
7207@item
7208A double backslash @emph{at the end of a line} enforces a line break at
7209this position.
7210
7211@cindex HTML entities, LaTeX entities
7212@item
7213Strings like @code{\alpha} will be exported as @code{&alpha;}, in the
7214HTML output. These strings are exported as @code{$\alpha$} in the
7215La@TeX{} output. Similarly, @code{\nbsp} will become @code{&nbsp;} in
7216HTML and in La@TeX{}. This applies for a long list of entities, see
7217the variable @code{org-html-entities} for the complete list.
7218@c FIXME
7219@end itemize
7220
7221If these conversions conflict with your habits of typing ASCII text,
7222they can all be turned off with corresponding variables. See the
7223customization group @code{org-export-general}, and the following section
7224which explains how to set export options with special lines in a
7225buffer.
7226
7227
7228@node Export options, , Enhancing text, Text interpretation
7229@subsection Export options
7230@cindex options, for export
7231
7232@cindex completion, of option keywords
7233The exporter recognizes special lines in the buffer which provide
7234additional information. These lines may be put anywhere in the file.
7235The whole set of lines can be inserted into the buffer with @kbd{C-c
7236C-e t}. For individual lines, a good way to make sure the keyword is
7237correct is to type @samp{#+} and then use @kbd{M-@key{TAB}} completion
7238(@pxref{Completion}).
7239
7240@table @kbd
7241@kindex C-c C-e t
7242@item C-c C-e t
7243Insert template with export options, see example below.
7244@end table
7245
7246@example
7247#+TITLE: the title to be shown (default is the buffer name)
7248#+AUTHOR: the author (default taken from @code{user-full-name})
7249#+DATE: A date, fixed, of a format string for @code{format-time-string}
7250#+EMAIL: his/her email address (default from @code{user-mail-address})
7251#+LANGUAGE: language for HTML, e.g. @samp{en} (@code{org-export-default-language})
7252#+TEXT: Some descriptive text to be inserted at the beginning.
7253#+TEXT: Several lines may be given.
7254#+OPTIONS: H:2 num:t toc:t \n:nil @@:t ::t |:t ^:t f:t TeX:t ...
7255@end example
7256
7257@noindent
7258The OPTIONS line is a compact form to specify export settings. Here
7259you can:
7260@cindex headline levels
7261@cindex section-numbers
7262@cindex table of contents
7263@cindex linebreak preservation
7264@cindex quoted HTML tags
7265@cindex fixed-width sections
7266@cindex tables
7267@cindex @TeX{}-like syntax for sub- and superscripts
7268@cindex footnotes
7269@cindex special strings
7270@cindex emphasized text
7271@cindex @TeX{} macros
7272@cindex La@TeX{} fragments
7273@cindex author info, in export
7274@cindex time info, in export
7275@example
7276H: @r{set the number of headline levels for export}
7277num: @r{turn on/off section-numbers}
7278toc: @r{turn on/off table of contents, or set level limit (integer)}
7279\n: @r{turn on/off linebreak-preservation}
7280@@: @r{turn on/off quoted HTML tags}
7281:: @r{turn on/off fixed-width sections}
7282|: @r{turn on/off tables}
7283^: @r{turn on/off @TeX{}-like syntax for sub- and superscripts. If}
7284 @r{you write "^:@{@}", @code{a_@{b@}} will be interpreted, but}
7285 @r{the simple @code{a_b} will be left as it is.}
7286-: @r{turn on/off conversion of special strings.}
7287f: @r{turn on/off foototes like this[1].}
7288*: @r{turn on/off emphasized text (bold, italic, underlined)}
7289TeX: @r{turn on/off simple @TeX{} macros in plain text}
7290LaTeX: @r{turn on/off La@TeX{} fragments}
7291skip: @r{turn on/off skipping the text before the first heading}
7292author: @r{turn on/off inclusion of author name/email into exported file}
7293timestamp: @r{turn on/off inclusion creation time into exported file}
7294d: @r{turn on/off inclusion of drawers}
7295@end example
7296
7297These options take effect in both the HTML and La@TeX{} export, except
7298for @code{TeX} and @code{LaTeX}, which are respectively @code{t} and
7299@code{nil} for the La@TeX{} export.
7300
7301@node Publishing, Miscellaneous, Exporting, Top 7583@node Publishing, Miscellaneous, Exporting, Top
7302@chapter Publishing 7584@chapter Publishing
7303@cindex publishing 7585@cindex publishing
@@ -7383,8 +7665,11 @@ and where to put published files.
7383@item @code{:publishing-directory} 7665@item @code{:publishing-directory}
7384@tab Directory (possibly remote) where output files will be published. 7666@tab Directory (possibly remote) where output files will be published.
7385@item @code{:preparation-function} 7667@item @code{:preparation-function}
7386@tab Function called before starting publishing process, for example to 7668@tab Function called before starting the publishing process, for example to
7387run @code{make} for updating files to be published. 7669run @code{make} for updating files to be published.
7670@item @code{:completion-function}
7671@tab Function called after finishing the publishing process, for example to
7672change permissions of the resulting files.
7388@end multitable 7673@end multitable
7389@noindent 7674@noindent
7390 7675
@@ -7651,7 +7936,7 @@ Org uses timestamps to track when a file has changed. The above
7651functions normally only publish changed files. You can override this and 7936functions normally only publish changed files. You can override this and
7652force publishing of all files by giving a prefix argument. 7937force publishing of all files by giving a prefix argument.
7653 7938
7654@node Miscellaneous, Extensions and Hacking, Publishing, Top 7939@node Miscellaneous, Extensions, Publishing, Top
7655@chapter Miscellaneous 7940@chapter Miscellaneous
7656 7941
7657@menu 7942@menu
@@ -7769,6 +8054,9 @@ Set file-local values for constants to be used in table formulas. This
7769line set the local variable @code{org-table-formula-constants-local}. 8054line set the local variable @code{org-table-formula-constants-local}.
7770The global version of this variable is 8055The global version of this variable is
7771@code{org-table-formula-constants}. 8056@code{org-table-formula-constants}.
8057@item #+FILETAGS: :tag1:tag2:tag3:
8058Set tags that can be inherited by any entry in the file, including the
8059top-level entries.
7772@item #+DRAWERS: NAME1 ..... 8060@item #+DRAWERS: NAME1 .....
7773Set the file-local set of drawers. The corresponding global variable is 8061Set the file-local set of drawers. The corresponding global variable is
7774@code{org-drawers}. 8062@code{org-drawers}.
@@ -7783,6 +8071,14 @@ have a lower ASCII number that the lowest priority.
7783@item #+PROPERTY: Property_Name Value 8071@item #+PROPERTY: Property_Name Value
7784This line sets a default inheritance value for entries in the current 8072This line sets a default inheritance value for entries in the current
7785buffer, most useful for specifying the allowed values of a property. 8073buffer, most useful for specifying the allowed values of a property.
8074@item #+SETUPFILE: file
8075This line defines a file that holds more in-buffer setup. Normally this is
8076entirely ignored. Only when the buffer is parsed for option-setting lines
8077(i.e. when starting Org mode for a file, when pressing @kbd{C-c C-c} in a
8078settings line, or when exporting), then the contents of this file are parsed
8079as if they had been included in the buffer. In particlar, the file can be
8080any other Org mode file with internal setup. You can visit the file the
8081cursor is in the line with @kbd{C-c '}.
7786@item #+STARTUP: 8082@item #+STARTUP:
7787This line sets options to be used at startup of Org mode, when an 8083This line sets options to be used at startup of Org mode, when an
7788Org file is being visited. The first set of options deals with the 8084Org file is being visited. The first set of options deals with the
@@ -7828,10 +8124,10 @@ nologrepeat @r{do not record when reinstating repeating item}
7828lognoteclock-out @r{record a note when clocking out} 8124lognoteclock-out @r{record a note when clocking out}
7829nolognoteclock-out @r{don't record a note when clocking out} 8125nolognoteclock-out @r{don't record a note when clocking out}
7830@end example 8126@end example
7831Here are the options for hiding leading stars in outline headings. The 8127Here are the options for hiding leading stars in outline headings, and for
7832corresponding variables are @code{org-hide-leading-stars} and 8128indenting outlines. The corresponding variables are
7833@code{org-odd-levels-only}, both with a default setting @code{nil} 8129@code{org-hide-leading-stars} and @code{org-odd-levels-only}, both with a
7834(meaning @code{showstars} and @code{oddeven}). 8130default setting @code{nil} (meaning @code{showstars} and @code{oddeven}).
7835@cindex @code{hidestars}, STARTUP keyword 8131@cindex @code{hidestars}, STARTUP keyword
7836@cindex @code{showstars}, STARTUP keyword 8132@cindex @code{showstars}, STARTUP keyword
7837@cindex @code{odd}, STARTUP keyword 8133@cindex @code{odd}, STARTUP keyword
@@ -7839,6 +8135,8 @@ corresponding variables are @code{org-hide-leading-stars} and
7839@example 8135@example
7840hidestars @r{make all but one of the stars starting a headline invisible.} 8136hidestars @r{make all but one of the stars starting a headline invisible.}
7841showstars @r{show all stars starting a headline} 8137showstars @r{show all stars starting a headline}
8138indent @r{virtual indentation according to outline level}
8139noindent @r{no virtual indentation according to outline level}
7842odd @r{allow only odd outline levels (1,3,...)} 8140odd @r{allow only odd outline levels (1,3,...)}
7843oddeven @r{allow all outline levels} 8141oddeven @r{allow all outline levels}
7844@end example 8142@end example
@@ -7925,56 +8223,73 @@ block is updated.
7925@node Clean view, TTY keys, The very busy C-c C-c key, Miscellaneous 8223@node Clean view, TTY keys, The very busy C-c C-c key, Miscellaneous
7926@section A cleaner outline view 8224@section A cleaner outline view
7927@cindex hiding leading stars 8225@cindex hiding leading stars
8226@cindex dynamic indentation
8227@cindex odd-levels-only outlines
7928@cindex clean outline view 8228@cindex clean outline view
7929 8229
7930Some people find it noisy and distracting that the Org headlines 8230Some people find it noisy and distracting that the Org headlines are starting
7931are starting with a potentially large number of stars. For example 8231with a potentially large number of stars, and that text below the headlines
7932the tree from @ref{Headlines}: 8232is not indented. This is not really a problem when you are writing a book
8233where the outline headings are really section headlines. However, in a more
8234list-oriented outline, it is clear that an indented structure is a lot
8235cleaner, as can be seen by comparing the two columns in the following
8236example:
7933 8237
7934@example 8238@example
7935* Top level headline 8239@group
7936** Second level 8240* Top level headline | * Top level headline
7937*** 3rd level 8241** Second level | * Second level
7938 some text 8242*** 3rd level | * 3rd level
7939*** 3rd level 8243some text | some text
7940 more text 8244*** 3rd level | * 3rd level
7941* Another top level headline 8245more text | more text
8246* Another top level headline | * Another top level headline
8247@end group
7942@end example 8248@end example
7943 8249
7944@noindent 8250@noindent
7945Unfortunately this is deeply ingrained into the code of Org and 8251It is non-trivial to make such a look work in Emacs, but Org contains three
7946cannot be easily changed. You can, however, modify the display in such 8252separate features that, combined, achieve just that.
7947a way that all leading stars become invisible and the outline more easy
7948to read. To do this, customize the variable
7949@code{org-hide-leading-stars} like this:
7950 8253
7951@lisp 8254@enumerate
7952(setq org-hide-leading-stars t) 8255@item
7953@end lisp 8256@emph{Indentation of text below headlines}@*
8257You may indent text below each headline to make the left boundary line up
8258with the headline, like
7954 8259
7955@noindent 8260@example
7956or change this on a per-file basis with one of the lines (anywhere in 8261*** 3rd level
7957the buffer) 8262 more text, now indented
8263@end example
8264
8265A good way to get this indentation is by hand, and Org supports this with
8266paragraph filling, line wrapping, and structure editing@footnote{See also the
8267variable @code{org-adapt-indentation}.} preserving or adapting the
8268indentation appropriate. A different approach would be to have a way to
8269automatically indent lines according to outline structure by adding overlays
8270or text properties. But I have not yet found a robust and efficient way to
8271do this in large files.
8272
8273@item
8274@emph{Hiding leading stars}@* You can modify the display in such a way that
8275all leading stars become invisible. To do this in a global way, configure
8276the variable @code{org-hide-leading-stars} or change this on a per-file basis
8277with
7958 8278
7959@example 8279@example
7960#+STARTUP: showstars 8280#+STARTUP: showstars
7961#+STARTUP: hidestars 8281#+STARTUP: hidestars
7962@end example 8282@end example
7963 8283
7964@noindent 8284With hidden stars, the tree becomes:
7965Press @kbd{C-c C-c} with the cursor in a @samp{STARTUP} line to activate
7966the modifications.
7967
7968With stars hidden, the tree becomes:
7969 8285
7970@example 8286@example
8287@group
7971* Top level headline 8288* Top level headline
7972 * Second level 8289 * Second level
7973 * 3rd level 8290 * 3rd level
7974 some text 8291 ...
7975 * 3rd level 8292@end group
7976 more text
7977* Another top level headline
7978@end example 8293@end example
7979 8294
7980@noindent 8295@noindent
@@ -7986,32 +8301,14 @@ effect. Another possibility is to set this font such that the extra
7986stars are @i{almost} invisible, for example using the color 8301stars are @i{almost} invisible, for example using the color
7987@code{grey90} on a white background. 8302@code{grey90} on a white background.
7988 8303
7989Things become cleaner still if you skip all the even levels and use only 8304@item
7990odd levels 1, 3, 5..., effectively adding two stars to go from one 8305Things become cleaner still if you skip all the even levels and use only odd
7991outline level to the next: 8306levels 1, 3, 5..., effectively adding two stars to go from one outline level
7992 8307to the next. In this way we get the outline view shown at the beginning of
7993@example 8308this section. In order to make the structure editing and export commands
7994* Top level headline 8309handle this convention correctly, configure the variable
7995 * Second level 8310@code{org-odd-levels-only}, or set this on a per-file basis with one of the
7996 * 3rd level 8311following lines:
7997 some text
7998 * 3rd level
7999 more text
8000* Another top level headline
8001@end example
8002
8003@noindent
8004In order to make the structure editing and export commands handle this
8005convention correctly, use
8006
8007@lisp
8008(setq org-odd-levels-only t)
8009@end lisp
8010
8011@noindent
8012or set this on a per-file basis with one of the following lines (don't
8013forget to press @kbd{C-c C-c} with the cursor in the startup line to
8014activate changes immediately).
8015 8312
8016@example 8313@example
8017#+STARTUP: odd 8314#+STARTUP: odd
@@ -8022,6 +8319,7 @@ You can convert an Org file from single-star-per-level to the
8022double-star-per-level convention with @kbd{M-x org-convert-to-odd-levels 8319double-star-per-level convention with @kbd{M-x org-convert-to-odd-levels
8023RET} in that file. The reverse operation is @kbd{M-x 8320RET} in that file. The reverse operation is @kbd{M-x
8024org-convert-to-oddeven-levels}. 8321org-convert-to-oddeven-levels}.
8322@end enumerate
8025 8323
8026@node TTY keys, Interaction, Clean view, Miscellaneous 8324@node TTY keys, Interaction, Clean view, Miscellaneous
8027@section Using Org on a tty 8325@section Using Org on a tty
@@ -8240,39 +8538,108 @@ multiple recalculation may be needed to get all fields consistent. You
8240may use the command @code{org-table-iterate} (@kbd{C-u C-c *}) to 8538may use the command @code{org-table-iterate} (@kbd{C-u C-c *}) to
8241recalculate until convergence. 8539recalculate until convergence.
8242@item 8540@item
8243A single letter cannot be made bold, for example @samp{*a*}.
8244@item
8245The exporters work well, but could be made more efficient. 8541The exporters work well, but could be made more efficient.
8246@end itemize 8542@end itemize
8247 8543
8248 8544
8249@node Extensions and Hacking, History and Acknowledgments, Miscellaneous, Top 8545@node Extensions, Hacking, Miscellaneous, Top
8250@appendix Extensions, Hooks and Hacking 8546@appendix Extensions
8547
8548This appendix lists the extension modules that have been written for Org.
8549Many of these extensions live in the @file{contrib} directory of the Org
8550distribution, others are available somewhere on the web.
8251 8551
8252This appendix lists extensions for Org written by other authors. 8552@menu
8253It also covers some aspects where users can extend the functionality of 8553* Extensions in the contrib directory:: These come with the Org distro
8554* Other extensions:: These you have to find on the web.
8555@end menu
8556
8557@node Extensions in the contrib directory, Other extensions, Extensions, Extensions
8558@section Extensions in the @file{contrib} directory
8559
8560@table @asis
8561@item @file{org-annotate-file.el} by @i{Philip Jackson}
8562 Annotate a file with org syntax, in a separate file, with links back to
8563 the annotated file.
8564@item @file{org-annotation-helper.el} by @i{Bastien Guerry and Daniel E. German}
8565 Call @i{remember} directly from Firefox/Opera, or from Adobe Reader.
8566 When activating a special link or bookmark, Emacs receives a trigger to
8567 create a note with a link back to the website. Requires some setup, a
8568 detailes description is in
8569 @file{contrib/packages/org-annotation-helper}.
8570@item @file{org-bookmark.el} by @i{Tokuya Kameshima}
8571 Support for links to Emacs bookmarks.
8572@item @file{org-depend.el} by @i{Carsten Dominik}
8573 TODO dependencies for Org-mode. Make TODO state changes in one entry
8574 trigger changes in another, or be blocked by the state of another
8575 entry. Also, easily create chains of TODO items with exactly one
8576 active item at any time.
8577@item @file{org-elisp-symbol.el} by @i{Bastien Guerry}
8578 Org links to emacs-lisp symbols. This can create annotated links that
8579 exactly point to the definition location of a variable of function.
8580@item @file{org-eval.el} by @i{Carsten Dominik}
8581 The @code{<lisp>} tag, adapted from Emacs Wiki and Emacs Muse, allows
8582 to include text in a document that is the result of evaluating some
8583 code. Other scripting languages like @code{perl} can be supported with
8584 this package as well.
8585@item @file{org-expiry.el} by @i{Bastien Guerry}
8586 Expiry mechanism for Org entries.
8587@item @file{org-indent.el} by @i{Carsten Dominik}
8588 Dynamic indentation of Org outlines. The plan is to indent an outline
8589 according to level, but so far this is too hard for a proper and stable
8590 implementation. Still, it works somewhat.
8591@item @file{org-interactive-query.el} by @i{Christopher League}
8592 Interactive modification of tags queries. After running a general
8593 query in Org, this package allows to narrow down the results by adding
8594 more tags or keywords.
8595@item @file{org-mairix.el} by @i{Georg C. F. Greve}
8596 Hook mairix search into Org for different MUAs.
8597@item @file{org-man.el} by @i{Carsten Dominik}
8598 Support for links to manpages in Org-mode.
8599@item @file{org-mtags.el} by @i{Carsten Dominik}
8600 Support for some Muse-like tags in Org-mode. This package allows you
8601 to write @code{<example>} and @code{<src>} and other syntax copied from
8602 Emacs Muse, right inside an Org file. The goal here is to make it easy
8603 to publish the same file using either org-publish or Muse.
8604@item @file{org-panel.el} by @i{Lennard Borgman}
8605 Simplified and display-aided access to some Org commands.
8606@item @file{org-registry.el} by @i{Bastien Guerry}
8607 A registry for Org links, to find out from where links point to a given
8608 file or location.
8609@item @file{org2rem.el} by @i{Bastien Guerry}
8610 Convert org appointments into reminders for the @file{remind} program.
8611@item @file{org-screen.el} by @i{Andrew Hyatt}
8612 Visit screen sessions through Org-mode links.
8613@item @file{org-toc.el} by @i{Bastien Guerry}
8614 Table of contents in a separate buffer, with fast access to sections
8615 and easy visibility cycling.
8616@item @file{orgtbl-sqlinsert.el} by @i{Jason Riedy}
8617 Convert Org-mode tables to SQL insertions. Documentation for this can
8618 be found on the Worg pages.
8619@end table
8620
8621
8622@node Other extensions, , Extensions in the contrib directory, Extensions
8623@section Other extensions
8624
8625@i{TO BE DONE}
8626
8627@node Hacking, History and Acknowledgments, Extensions, Top
8628@appendix Hacking
8629
8630This appendix covers some aspects where users can extend the functionality of
8254Org. 8631Org.
8255 8632
8256@menu 8633@menu
8257* Extensions:: Existing 3rd-party extensions
8258* Adding hyperlink types:: New custom link types 8634* Adding hyperlink types:: New custom link types
8259* Tables in arbitrary syntax:: Orgtbl for LaTeX and other programs 8635* Tables in arbitrary syntax:: Orgtbl for LaTeX and other programs
8260* Dynamic blocks:: Automatically filled blocks 8636* Dynamic blocks:: Automatically filled blocks
8261* Special agenda views:: Customized views 8637* Special agenda views:: Customized views
8262* Using the property API:: Writing programs that use entry properties 8638* Using the property API:: Writing programs that use entry properties
8639* Using the mapping API:: Mapping over all or selected entries
8263@end menu 8640@end menu
8264 8641
8265@node Extensions, Adding hyperlink types, Extensions and Hacking, Extensions and Hacking 8642@node Adding hyperlink types, Tables in arbitrary syntax, Hacking, Hacking
8266@section Third-party extensions for Org
8267@cindex extension, third-party
8268
8269There are lots of extensions that have been written by other people. Most of
8270them have either been integrated into Org by now, or they can be found in the
8271Org distribution, in the @file{contrib} directory. The list has gotten too
8272long to cover in any detail here, but there is a seaparate manual for these
8273extensions.
8274
8275@node Adding hyperlink types, Tables in arbitrary syntax, Extensions, Extensions and Hacking
8276@section Adding hyperlink types 8643@section Adding hyperlink types
8277@cindex hyperlinks, adding new types 8644@cindex hyperlinks, adding new types
8278 8645
@@ -8369,7 +8736,7 @@ can also set the @code{:description} property to provide a default for
8369the link description when the link is later inserted into an Org 8736the link description when the link is later inserted into an Org
8370buffer with @kbd{C-c C-l}. 8737buffer with @kbd{C-c C-l}.
8371 8738
8372@node Tables in arbitrary syntax, Dynamic blocks, Adding hyperlink types, Extensions and Hacking 8739@node Tables in arbitrary syntax, Dynamic blocks, Adding hyperlink types, Hacking
8373@section Tables and lists in arbitrary syntax 8740@section Tables and lists in arbitrary syntax
8374@cindex tables, in other modes 8741@cindex tables, in other modes
8375@cindex lists, in other modes 8742@cindex lists, in other modes
@@ -8436,7 +8803,9 @@ acted upon before the translation function is called:
8436 8803
8437@table @code 8804@table @code
8438@item :skip N 8805@item :skip N
8439Skip the first N lines of the table. Hlines do count! 8806Skip the first N lines of the table. Hlines do count as separate lines for
8807this parameter!
8808
8440@item :skipcols (n1 n2 ...) 8809@item :skipcols (n1 n2 ...)
8441List of columns that should be skipped. If the table has a column with 8810List of columns that should be skipped. If the table has a column with
8442calculation marks, that column is automatically discarded as well. 8811calculation marks, that column is automatically discarded as well.
@@ -8482,6 +8851,7 @@ modes.} with the command @kbd{M-x orgtbl-insert-radio-table}. You will
8482be prompted for a table name, lets say we use @samp{salesfigures}. You 8851be prompted for a table name, lets say we use @samp{salesfigures}. You
8483will then get the following template: 8852will then get the following template:
8484 8853
8854@cindex #+ORGTBL: SEND
8485@example 8855@example
8486% BEGIN RECEIVE ORGTBL salesfigures 8856% BEGIN RECEIVE ORGTBL salesfigures
8487% END RECEIVE ORGTBL salesfigures 8857% END RECEIVE ORGTBL salesfigures
@@ -8550,7 +8920,7 @@ Month & \multicolumn@{1@}@{c@}@{Days@} & Nr.\ sold & per day\\
8550The La@TeX{} translator function @code{orgtbl-to-latex} is already part of 8920The La@TeX{} translator function @code{orgtbl-to-latex} is already part of
8551Orgtbl mode. It uses a @code{tabular} environment to typeset the table 8921Orgtbl mode. It uses a @code{tabular} environment to typeset the table
8552and marks horizontal lines with @code{\hline}. Furthermore, it 8922and marks horizontal lines with @code{\hline}. Furthermore, it
8553interprets the following parameters: 8923interprets the following parameters (see also @ref{Translator functions}):
8554 8924
8555@table @code 8925@table @code
8556@item :splice nil/t 8926@item :splice nil/t
@@ -8581,15 +8951,15 @@ supplied instead of strings.
8581@cindex HTML, and Orgtbl mode 8951@cindex HTML, and Orgtbl mode
8582@cindex translator function 8952@cindex translator function
8583 8953
8584Orgtbl mode has several translator functions built-in: 8954Orgtbl mode has several translator functions built-in: @code{orgtbl-to-csv}
8585@code{orgtbl-to-latex}, @code{orgtbl-to-html}, and 8955(comma-separated values), @code{orgtbl-to-tsv} (TAB-separated values)
8586@code{orgtbl-to-texinfo}. Except for @code{orgtbl-to-html}@footnote{The 8956@code{orgtbl-to-latex}, @code{orgtbl-to-html}, and @code{orgtbl-to-texinfo}.
8587HTML translator uses the same code that produces tables during HTML 8957Except for @code{orgtbl-to-html}@footnote{The HTML translator uses the same
8588export.}, these all use a generic translator, @code{orgtbl-to-generic}. 8958code that produces tables during HTML export.}, these all use a generic
8589For example, @code{orgtbl-to-latex} itself is a very short function that 8959translator, @code{orgtbl-to-generic}. For example, @code{orgtbl-to-latex}
8590computes the column definitions for the @code{tabular} environment, 8960itself is a very short function that computes the column definitions for the
8591defines a few field and line separators and then hands over to the 8961@code{tabular} environment, defines a few field and line separators and then
8592generic translator. Here is the entire code: 8962hands over to the generic translator. Here is the entire code:
8593 8963
8594@lisp 8964@lisp
8595@group 8965@group
@@ -8692,7 +9062,7 @@ La@TeX{} file:
8692Pressing `C-c C-c' on @code{a new house} and will insert the converted 9062Pressing `C-c C-c' on @code{a new house} and will insert the converted
8693La@TeX{} list between the two marker lines. 9063La@TeX{} list between the two marker lines.
8694 9064
8695@node Dynamic blocks, Special agenda views, Tables in arbitrary syntax, Extensions and Hacking 9065@node Dynamic blocks, Special agenda views, Tables in arbitrary syntax, Hacking
8696@section Dynamic blocks 9066@section Dynamic blocks
8697@cindex dynamic blocks 9067@cindex dynamic blocks
8698 9068
@@ -8705,6 +9075,7 @@ Dynamic block are enclosed by a BEGIN-END structure that assigns a name
8705to the block and can also specify parameters for the function producing 9075to the block and can also specify parameters for the function producing
8706the content of the block. 9076the content of the block.
8707 9077
9078#+BEGIN:dynamic block
8708@example 9079@example
8709#+BEGIN: myblock :parameter1 value1 :parameter2 value2 ... 9080#+BEGIN: myblock :parameter1 value1 :parameter2 value2 ...
8710 9081
@@ -8756,7 +9127,7 @@ example @code{before-save-hook}. @code{org-update-all-dblocks} is
8756written in a way that is does nothing in buffers that are not in 9127written in a way that is does nothing in buffers that are not in
8757@code{org-mode}. 9128@code{org-mode}.
8758 9129
8759@node Special agenda views, Using the property API, Dynamic blocks, Extensions and Hacking 9130@node Special agenda views, Using the property API, Dynamic blocks, Hacking
8760@section Special agenda views 9131@section Special agenda views
8761@cindex agenda views, user-defined 9132@cindex agenda views, user-defined
8762 9133
@@ -8838,7 +9209,7 @@ like this, even without defining a special function:
8838 (org-agenda-overriding-header "Projects waiting for something: ")))) 9209 (org-agenda-overriding-header "Projects waiting for something: "))))
8839@end lisp 9210@end lisp
8840 9211
8841@node Using the property API, , Special agenda views, Extensions and Hacking 9212@node Using the property API, Using the mapping API, Special agenda views, Hacking
8842@section Using the property API 9213@section Using the property API
8843@cindex API, for properties 9214@cindex API, for properties
8844@cindex properties, API 9215@cindex properties, API
@@ -8896,7 +9267,105 @@ Treat the value of the property PROPERTY as a whitespace-separated list of
8896values and check if VALUE is in this list. 9267values and check if VALUE is in this list.
8897@end defun 9268@end defun
8898 9269
8899@node History and Acknowledgments, Main Index, Extensions and Hacking, Top 9270@node Using the mapping API, , Using the property API, Hacking
9271@section Using the mapping API
9272@cindex API, for mapping
9273@cindex mapping entries, API
9274
9275Org has sophisticated mapping capabilities to find all entries satisfying
9276certain criteria. Internally, this functionality is used to produce agenda
9277views, but there is also an API that can be used to execute arbitrary
9278functions for each or selected entries. The main entry point for this API
9279is:
9280
9281@defun org-map-entries func &optional match scope &rest skip
9282Call FUNC at each headline selected by MATCH in SCOPE.
9283
9284FUNC is a function or a lisp form. The function will be called without
9285arguments, with the cursor positioned at the beginning of the headline.
9286The return values of all calls to the function will be collected and
9287returned as a list.
9288
9289MATCH is a tags/property/todo match as it is used in the agenda tags view.
9290Only headlines that are matched by this query will be considered during
9291the iteration. When MATCH is nil or t, all headlines will be
9292visited by the iteration.
9293
9294SCOPE determines the scope of this command. It can be any of:
9295
9296@example
9297nil @r{the current buffer, respecting the restriction if any}
9298tree @r{the subtree started with the entry at point}
9299file @r{the current buffer, without restriction}
9300file-with-archives
9301 @r{the current buffer, and any archives associated with it}
9302agenda @r{all agenda files}
9303agenda-with-archives
9304 @r{all agenda files with any archive files associated with them}
9305(file1 file2 ...)
9306 @r{if this is a list, all files in the list will be scanned}
9307@end example
9308
9309The remaining args are treated as settings for the skipping facilities of
9310the scanner. The following items can be given here:
9311
9312@example
9313archive @r{skip trees with the archive tag}
9314comment @r{skip trees with the COMMENT keyword}
9315function or Lisp form
9316 @r{will be used as value for @code{org-agenda-skip-function},}
9317 @r{so whenever the the function returns t, FUNC}
9318 @r{will not be called for that entry and search will}
9319 @r{continue from the point where the function leaves it}
9320@end example
9321@end defun
9322
9323The function given to that mapping routine can really do anything you like.
9324It can uce the property API (@pxref{Using the property API}) to gather more
9325information about the entry, or in order to change metadate in the entry.
9326Here are a couple of functions that might be handy:
9327
9328@defun org-todo &optional arg
9329Change the TODO state of the entry, see the docstring of the functions for
9330the many possible values for the argument ARG.
9331@end defun
9332
9333@defun org-priority &optional action
9334Change the priority of the entry, see the docstring of this function for the
9335possible values for ACTION.
9336@end defun
9337
9338@defun org-toggle-tag tag &optional onoff
9339Toggle the tag TAG in the current entry. Setting ONOFF to either @code{on}
9340or @code{off} will not toggle tag, but ensure that it is either on or off.
9341@end defun
9342
9343@defun org-promote
9344Promote the current entry.
9345@end defun
9346
9347@defun org-demote
9348Demote the current entry.
9349@end defun
9350
9351Here is a simple example that will turn all entries in the current file with
9352a tag @code{TOMORROW} into TODO entries with the keyword @code{UPCOMING}.
9353Entries in comment trees and in archive trees will be ignored.
9354
9355@lisp
9356(org-map-entries
9357 '(org-todo "UPCOMING")
9358 "+TOMORROW" 'file 'archive 'comment)
9359@end lisp
9360
9361The following example counts the number of entries with TODO keyword
9362@code{WAITING}, in all agenda files.
9363
9364@lisp
9365(length (org-map-entries t "/+WAITING" nil 'agenda))
9366@end lisp
9367
9368@node History and Acknowledgments, Main Index, Hacking, Top
8900@appendix History and Acknowledgments 9369@appendix History and Acknowledgments
8901@cindex acknowledgments 9370@cindex acknowledgments
8902@cindex history 9371@cindex history
@@ -8940,6 +9409,9 @@ let me know.
8940@item 9409@item
8941@i{Thomas Baumann} wrote @file{org-bbdb.el} and @file{org-mhe.el}. 9410@i{Thomas Baumann} wrote @file{org-bbdb.el} and @file{org-mhe.el}.
8942@item 9411@item
9412@i{Christophe Bataillon} created the great unicorn logo that we use on the
9413Org-mode website.
9414@item
8943@i{Alex Bochannek} provided a patch for rounding time stamps. 9415@i{Alex Bochannek} provided a patch for rounding time stamps.
8944@item 9416@item
8945@i{Charles Cave}'s suggestion sparked the implementation of templates 9417@i{Charles Cave}'s suggestion sparked the implementation of templates
@@ -9039,15 +9511,16 @@ single key navigation.
9039@i{Frank Ruell} solved the mystery of the @code{keymapp nil} bug, a 9511@i{Frank Ruell} solved the mystery of the @code{keymapp nil} bug, a
9040conflict with @file{allout.el}. 9512conflict with @file{allout.el}.
9041@item 9513@item
9042@i{Jason Riedy} sent a patch to fix a bug with export of TODO keywords. 9514@i{Jason Riedy} generalized the send-receive mechanism for orgtbl tables with
9515extensive patches.
9043@item 9516@item
9044@i{Philip Rooke} created the Org reference card and provided lots 9517@i{Philip Rooke} created the Org reference card, provided lots
9045of feedback. 9518of feedback, developed and applied standards to the Org documentation.
9046@item 9519@item
9047@i{Christian Schlauer} proposed angular brackets around links, among 9520@i{Christian Schlauer} proposed angular brackets around links, among
9048other things. 9521other things.
9049@item 9522@item
9050Linking to VM/BBDB/Gnus was inspired by @i{Tom Shannon}'s 9523Linking to VM/BBDB/Gnus was first inspired by @i{Tom Shannon}'s
9051@file{organizer-mode.el}. 9524@file{organizer-mode.el}.
9052@item 9525@item
9053@i{Ilya Shlyakhter} proposed the Archive Sibling. 9526@i{Ilya Shlyakhter} proposed the Archive Sibling.
@@ -9057,8 +9530,8 @@ subtrees.
9057@item 9530@item
9058@i{Dale Smith} proposed link abbreviations. 9531@i{Dale Smith} proposed link abbreviations.
9059@item 9532@item
9060@i{Adam Spiers} asked for global linking commands and inspired the link 9533@i{Adam Spiers} asked for global linking commands, inspired the link
9061extension system. support mairix. 9534extension system, added support for mairix, and proposed the mapping API.
9062@item 9535@item
9063@i{David O'Toole} wrote @file{org-publish.el} and drafted the manual 9536@i{David O'Toole} wrote @file{org-publish.el} and drafted the manual
9064chapter about publishing. 9537chapter about publishing.
@@ -9072,12 +9545,11 @@ keyword.
9072@i{David Wainberg} suggested archiving, and improvements to the linking 9545@i{David Wainberg} suggested archiving, and improvements to the linking
9073system. 9546system.
9074@item 9547@item
9075@i{John Wiegley} wrote @file{emacs-wiki.el} and @file{planner.el}. The 9548@i{John Wiegley} wrote @file{emacs-wiki.el}, @file{planner.el}, and
9076development of Org was fully independent, and both systems are really 9549@file{muse.el}, which have similar goals as Org. Initially the
9077different beasts in their basic ideas and implementation details. I later 9550development of Org was fully independent because I was not aware of the
9078looked at John's code, however, and learned from his implementation of (i) 9551existence of these packages. But with time I have accasionally looked
9079links where the link itself is hidden and only a description is shown, and 9552at John's code and learned a lot from it. John has also contributed a
9080(ii) popping up a calendar to select a date. John has also contributed a
9081number of great ideas and patches directly to Org, including the file 9553number of great ideas and patches directly to Org, including the file
9082@code{org-mac-message.el}' 9554@code{org-mac-message.el}'
9083@item 9555@item
diff --git a/etc/refcards/orgcard.tex b/etc/refcards/orgcard.tex
index 34976c10763..17617430cb6 100644
--- a/etc/refcards/orgcard.tex
+++ b/etc/refcards/orgcard.tex
@@ -1,5 +1,5 @@
1% Reference Card for Org Mode 1% Reference Card for Org Mode
2\def\orgversionnumber{6.02b} 2\def\orgversionnumber{6.05a}
3\def\versionyear{2008} % latest update 3\def\versionyear{2008} % latest update
4\def\year{2008} % latest copyright year 4\def\year{2008} % latest copyright year
5 5
@@ -309,10 +309,8 @@ are preserved on all copies.
309\key{insert new heading after subtree}{C-RET} 309\key{insert new heading after subtree}{C-RET}
310\key{insert new TODO entry/checkbox item}{M-S-RET} 310\key{insert new TODO entry/checkbox item}{M-S-RET}
311 311
312\key{promote current heading up one level}{M-LEFT} 312\key{promote/demote heading}{M-LEFT/RIGHT}
313\key{demote current heading down one level}{M-RIGHT} 313\metax{promote/demote current subtree}{M-S-LEFT/RIGHT}
314\key{promote current subtree up one level}{M-S-LEFT}
315\key{demote current subtree down one level}{M-S-RIGHT}
316 314
317\key{move subtree/list item up/down}{M-S-UP/DOWN} 315\key{move subtree/list item up/down}{M-S-UP/DOWN}
318\key{refile subtree}{C-c C-w} 316\key{refile subtree}{C-c C-w}
@@ -320,6 +318,7 @@ are preserved on all copies.
320\key{copy subtree}{C-c C-x M-w} 318\key{copy subtree}{C-c C-x M-w}
321\key{yank subtree}{C-c C-x C-y} 319\key{yank subtree}{C-c C-x C-y}
322\key{narrow buffer to current subtree}{C-x n s} 320\key{narrow buffer to current subtree}{C-x n s}
321\key{widen restriction to full buffer}{C-x n w}
323 322
324\section{Archiving} 323\section{Archiving}
325 324
@@ -452,7 +451,7 @@ formula, \kbd{:=} a field formula.
452\key{jump back to last followed link(s)}{C-c \&} 451\key{jump back to last followed link(s)}{C-c \&}
453\key{Find next link}{C-c C-x C-n} 452\key{Find next link}{C-c C-x C-n}
454\key{Find previous link}{C-c C-x C-p} 453\key{Find previous link}{C-c C-x C-p}
455 454\key{Edit code snippet of file at point}{C-c '}
456{\bf Internal Links} 455{\bf Internal Links}
457 456
458\key{\kbd{<<My Target>>}}{\rm target} 457\key{\kbd{<<My Target>>}}{\rm target}
diff --git a/lisp/org/ChangeLog b/lisp/org/ChangeLog
new file mode 100644
index 00000000000..a2c5e7044d4
--- /dev/null
+++ b/lisp/org/ChangeLog
@@ -0,0 +1,480 @@
12008-06-17 Carsten Dominik <dominik@science.uva.nl>
2
3 * org-colview.el (org-columns-next-allowed-value): Bug fix.
4
5 * org-colview-xemacs.el (org-columns-next-allowed-value): Bug fix.
6
7 * org-agenda.el (org-agenda-get-closed): Get the end time into the
8 agenda prefix as well.
9
10 * org-publish.el (org-publish-org-index): Make a properly indented
11 list.
12
13 * org.el (org-calendar-agenda-action-key): New option.
14 (org-get-cursor-date): New function.
15 (org-mark-entry-for-agenda-action): New command.
16 (org-overriding-default-time): New variable.
17 (org-read-date): Respect `org-overriding-default-time'.
18
19 * org-remember.el (org-remember-apply-template): Respect the
20 ovverriding default time.
21
22 * org-agenda.el (org-agenda-action-marker): New variable.
23 (org-agenda-action): New command.
24 (org-agenda-do-action): New function.
25
262008-06-17 Carsten Dominik <dominik@science.uva.nl>
27
28 * org.el (org-schedule, org-deadline): Protect scheduled and
29 deadline tasks against changes that accidently remove the
30 repeater. Also show a message with the new date when done.
31
322008-06-17 Carsten Dominik <dominik@science.uva.nl>
33
34 * org.el (org-beginning-of-line): Cater for the case when there
35 are tags but no headline text.
36 (org-align-tags-here): Convert to tabs only when indent-tabs-mode
37 it set.
38
392008-06-17 Carsten Dominik <dominik@science.uva.nl>
40
41 * org-mhe.el (org-mhe-get-message-folder-from-index): Make sure
42 the return value is nil instead of "nil" when there is no match.
43
44 * org-exp.el (org-insert-centered): Use fill-column instead of
45 80.
46 (org-export-as-ascii): Use string-width to measure the width of
47 the heading.
48
49 * org.el (org-diary-to-ical-string): No longer kill buffer
50 FROMBUF, this is now done by the caller.
51
52 * org-exp.el (org-print-icalendar-entries): Move the call to
53 `org-diary-to-ical-string' out of the loop, and kill the buffer
54 afterwords.
55
56 * org-remember.el (org-remember-visit-immediately): Position
57 cursor after moving to the note.
58 (org-remember-apply-template): Use a text property to record the
59 cursor position.
60 (org-remember-handler): Align tags after pasting the note.
61
622008-06-17 Carsten Dominik <dominik@science.uva.nl>
63
64 * org-bbdb.el (org-bbdb-follow-anniversary-link): New function.
65
66 * org-agenda.el (org-agenda-open-link): If there is an
67 org-bbdb-name property in the current line, jump to that bbdb
68 entry.
69
70 * org-bbdb.el (org-bbdb-anniversaries): Add the bbdb-name as a
71 text property, so that the agenda knows where this entry comes
72 from.
73
74 * org-agenda.el (org-agenda-clock-in): Fixed bug in the
75 interaction between clocking-in from the agenda, and automatic
76 task state switching.
77
78 * org-macs.el (org-with-point-at): Bug fix in macro defintion.
79
80 * org.el (org-beginning-of-line, org-end-of-line): Make sure the
81 zmacs-region stays after this command in XEmacs.
82
832008-06-17 Carsten Dominik <dominik@science.uva.nl>
84
85 * org.el (org-scan-tags): Allow new values for ACTION parameter.
86
87 * org-remember.el (org-remember-templates): Fix bug in
88 customization type definition.
89
90 * org.el (org-map-entries): New function.
91
922008-06-17 Carsten Dominik <dominik@science.uva.nl>
93
94 * org-agenda.el (org-agenda-skip-comment-trees): New option.
95 (org-agenda-skip): Respect `org-agenda-skip-comment-trees'.
96
972008-06-17 Carsten Dominik <dominik@science.uva.nl>
98
99 * org-remember.el (org-jump-to-target-location): New variable.
100 (org-remember-apply-template): Set
101 `org-remember-apply-template' if requested by template.
102 (org-remember-handler): Start an idle timer to jump to
103 remember location.
104
105 * org-exp.el (org-get-current-options): Add the FILETAGS setting.
106
107 * org.el (org-set-regexps-and-options): Fix bug with parsing of
108 file tags.
109 (org-get-tags-at): Add the content of `org-file-tags'.
110
111 * org-exp.el (org-export-handle-comments): Fix bug with several
112 comment lines after each other.
113 (org-number-to-roman, org-number-to-counter): New functions.
114 (org-export-section-number-format): New option.
115
1162008-06-17 Carsten Dominik <dominik@science.uva.nl>
117
118 * org-exp.el (org-export-protect-examples): Catch the case of a
119 missing end_example line.
120
121 * org.el (org-set-regexps-and-options): Set `org-file-properties' and
122 `org-file-tags' to nil.
123
124 * org-colview.el (org-columns-next-allowed-value): Handle next
125 argument NTH to directly select a value.
126
127 * org-colview-xemacs.el (org-columns-next-allowed-value): Handle next
128 argument NTH to directly select a value.
129
1302008-06-17 Carsten Dominik <dominik@science.uva.nl>
131
132 * org-agenda.el (org-agenda-scheduled-leaders): Fix docstring.
133
1342008-06-17 Carsten Dominik <dominik@science.uva.nl>
135
136 * org.el (org-columns-ellipses): New option.
137
1382008-06-17 Carsten Dominik <dominik@science.uva.nl>
139
140 * org-colview.el (org-columns-add-ellipses): New function.
141 (org-columns-compact-links): New function.
142 (org-columns-cleanup-item): Call `org-columns-compact-links'.
143 (org-columns-display-here): Call `org-agenda-columns-cleanup-item'
144 when in agenda.
145 (org-columns-edit-value): Fixed bug with editing values from
146 agenda column view.
147 (org-columns-redo): Also redo the agenda itself.
148
1492008-06-17 Carsten Dominik <dominik@science.uva.nl>
150
151 * org-agenda.el (org-agenda-columns-remove-prefix-from-item): New
152 option.
153
154 * org-colview.el (org-agenda-columns-cleanup-item): New function.
155
156 * org-exp.el (org-export-ascii-preprocess): Renamed from
157 `org-export-ascii-clean-string'.
158 (org-export-kill-licensed-text)
159 (org-export-define-heading-targets)
160 (org-export-handle-invisible-targets)
161 (org-export-target-internal-links)
162 (org-export-remove-or-extract-drawers)
163 (org-export-remove-archived-trees)
164 (org-export-protect-quoted-subtrees)
165 (org-export-protect-verbatim, org-export-protect-examples)
166 (org-export-select-backend-specific-text)
167 (org-export-mark-blockquote-and-verse)
168 (org-export-remove-comment-blocks-and-subtrees)
169 (org-export-handle-comments, org-export-mark-radio-links)
170 (org-export-remove-special-table-lines)
171 (org-export-normalize-links)
172 (org-export-concatenate-multiline-links)
173 (org-export-concatenate-multiline-emphasis): New functions,
174 obtained from spliiting the export preprocessor.
175
176 * org-table.el (org-table-recalculate): Improve error message if
177 the row number is invalid.
178
1792008-06-17 Carsten Dominik <dominik@science.uva.nl>
180
181 * org-archive.el (org-archive-save-context-info): Fix bugs in
182 customization setup and docstring.
183
184 * org-exp.el (org-export-html-style): Changed the size of in the
185 <pre> element to 90%.
186
1872008-06-17 Carsten Dominik <dominik@science.uva.nl>
188
189 * org.el (org-find-src-example-start): Function removed.
190 (org-edit-src-find-region-and-lang): New function.
191
1922008-06-17 Carsten Dominik <dominik@science.uva.nl>
193
194 * org.el (org-edit-src-exit): New function.
195 (org-exit-edit-mode): New minor mode.
196
197 * org-exp.el (org-export-preprocess-string): Fix bug with removing
198 comment-like lines from protected examples.
199
200 * org.el (org-edit-src-example, org-find-src-example-start)
201 (org-protect-source-example, org-edit-special): New functions.
202
2032008-06-17 Carsten Dominik <dominik@science.uva.nl>
204
205 * org-publish.el (org-publish-project-alist): Fix typo in
206 docstring.
207 (org-publish-project-alist): Handle :index-title property.
208
2092008-06-17 Carsten Dominik <dominik@science.uva.nl>
210
211 * org-export-latex.el (org-export-as-latex): Make sure region
212 bounds are correct. Parse subtree properties relating to export.
213
214 * org-exp.el (org-export-add-options-to-plist): New function.
215 (org-infile-export-plist): Use `org-export-add-options-to-plist'.
216
2172008-06-17 Carsten Dominik <dominik@science.uva.nl>
218
219 * org.el (org-default-properties): Add EXPORT_FILE_NAME and
220 EXPORT_TITLE.
221
222 * org-exp.el (org-export-get-title-from-subtree)
223 (org-export-as-ascii, org-export-as-html): Make sure the original
224 region-beginning and region-end are used, even after moving
225 point.
226 (org-export-get-title-from-subtree): Also try the EXPORT_TITLE
227 property.
228
229 * org-remember.el (org-remember-last-stored-marker): New variable.
230 (org-remember-goto-last-stored): Use `org-goto-marker-or-bmk'.
231 (org-remember-handler): Also use marker to remember
232 last-stored position.
233
234 * org.el (org-goto-marker-or-bmk): New function.
235
2362008-06-17 Carsten Dominik <dominik@science.uva.nl>
237
238 * org.el (org-file-properties): Renamed from `org-local-properties'.
239 (org-scan-tags): Take file tags into account.
240 (org-tags-match-list-sublevels): Default changed to t.
241
242 * org-exp.el (org-export-as-html): Close paragraph after a
243 footnote.
244
245 * org.el (org-update-parent-todo-statistics): New function.
246
247 * org-exp.el (org-icalendar-store-UID): New option.
248 (org-icalendar-force-UID): Option removed.
249 (org-print-icalendar-entries): IMplement UIDs.
250
2512008-06-17 Carsten Dominik <dominik@science.uva.nl>
252
253 * org-mhe.el (org-mhe-follow-link): Fix bug in mhe searches.
254
2552008-06-17 Carsten Dominik <dominik@science.uva.nl>
256
257 * org-faces.el (org-column): Document how this face is being used
258 and why sometimes the background faces shine through.
259
260 * org-mhe.el (org-mhe-follow-link): Improve handling of searches.
261
262 * org-publish.el (org-publish-attachment): Create publishing
263 directory if it does not yet exist.
264
265 * org-table.el (org-calc-default-modes): Change default number
266 format to (float 8).
267
268 * org.el (org-olpath-completing-read): New function.
269 (org-time-clocksum-format): New option.
270 (org-minutes-to-hh:mm-string): Use `org-time-clocksum-format'.
271
272 * org-clock.el (org-clock-display, org-clock-out)
273 (org-update-mode-line): Use `org-time-clocksum-format'.
274
275 * org-colview-xemacs.el (org-columns-number-to-string): Use
276 `org-time-clocksum-format'.
277
278 * org-colview.el (org-columns-number-to-string): Use
279 `org-time-clocksum-format'.
280
2812008-06-17 Carsten Dominik <dominik@science.uva.nl>
282
283 * org-id.el: New file, move from contrib to core.
284
285 * org-exp.el (org-icalendar-force-UID): New option.
286
2872008-06-17 Carsten Dominik <dominik@science.uva.nl>
288
289 * org-exp.el (org-print-icalendar-entries): Make sure DTEND is
290 shifted by one day if theere is a date range without an end
291 time.
292
293 * org.el (org-try-structure-completion): New function.
294
2952008-06-17 Carsten Dominik <dominik@science.uva.nl>
296
297 * org.el (org-set-font-lock-defaults): Improve fontification of
298 description lists.
299 (org-insert-item): Handle description lists.
300 (org-adaptive-fill-function): Improve auto indentation in
301 description lists.
302
303 * org-exp.el (org-export-as-html, org-export-preprocess-string):
304 Implement VERSE environment.
305 (org-export-preprocess-string): Implement the COMMENT
306 environment.
307
308 * org-export-latex.el (org-export-latex-preprocess): Implement
309 VERSE environment.
310
3112008-06-17 Carsten Dominik <dominik@science.uva.nl>
312
313 * org-jsinfo.el (org-infojs-opts-table): Add entry for FIXED_TOC
314 option.
315
3162008-06-17 Carsten Dominik <dominik@science.uva.nl>
317
318 * org-table.el (orgtbl-to-tsv, orgtbl-to-csv): New functions.
319
320 * org.el (org-quote-csv-field): New functions.
321
322 * org-table.el (org-table-export-default-format): Remove :splice
323 from default format, we get the same effect by not specifying
324 :tstart and :tend.
325 (org-table-export): Improve setup, distinguish better between
326 interactive and non-interactive use, allow specifying the format
327 on the fly, better protection against wrong file names.
328 (orgtbl-to-generic): Fix documentation. Do not require :tstart
329 and :tend when :splice is omitted.
330
3312008-06-17 Carsten Dominik <dominik@science.uva.nl>
332
333 * org-clock.el (org-clock-select-task): Make sure the selection
334 letters are 1-9 and A-Z, no special characters.
335
3362008-06-17 Carsten Dominik <dominik@science.uva.nl>
337
338 * org-exp.el (org-export-htmlize): New group.
339 (org-export-htmlize-output-type)
340 (org-export-htmlize-css-font-prefix): New options.
341 (org-export-htmlize-region-for-paste): New function.
342 (org-export-htmlize-generate-css): New command.
343
3442008-06-17 Carsten Dominik <dominik@science.uva.nl>
345
346 * org.el (org-set-visibility-according-to-property): New function.
347 (org-ctrl-c-ctrl-c): Do not restart org-mode, just get the options
348 and compute the regular expressions, and update font-lock.
349 (org-property-re): Allow a dash in property names.
350
351 * org-archive.el (org-extract-archive-file): Insert the file name
352 without the path into the format, to allow the location format to
353 contain a subdirectory.
354
355 * org-agenda.el (org-agenda-post-command-hook): If point is at end
356 of buffer, and the `org-agenda-type' property undefined, use the
357 value from the character before.
358
359 * org.el (org-add-planning-info): Don't let indentation for
360 would-be timestamp become extra whitespace at the end of headline.
361
3622008-06-17 Carsten Dominik <dominik@science.uva.nl>
363
364 * org.el (org-remove-double-quotes, org-file-contents): New
365 functions.
366
367 * org-exp.el (org-infile-export-plist): Also parse the
368 contents of #+SETUPFILE files, recursively.
369
370 * org.el (org-set-regexps-and-options): Also parse the
371 contents of #+SETUPFILE files, recursively.
372
373 * org-exp.el (org-export-handle-include-files): New function.
374 (org-export-preprocess-string): Call
375 `org-export-handle-include-files'.
376
377 * org.el (org-delete-property-globally)
378 (org-delete-property, org-set-property): Ignore case during
379 completion.
380 (org-set-property): Use `org-completing-read' instead of
381 `completing-read'.
382
383 * org.el (org-complete-expand-structure-template): New,
384 experimental function.
385 (org-structure-template-alist): New, experimental option.
386 (org-complete): Call `org-complete-expand-structure-template'.
387
3882008-06-17 Bastien Guerry <bzg@altern.org>
389
390 * org-export-latex.el (org-export-latex-preprocess): Added
391 support for blockquotes.
392
3932008-06-17 Carsten Dominik <dominik@science.uva.nl>
394
395 * org.el (org-read-date-analyze): Catch the case where only a
396 weekday is given.
397
3982008-06-17 Carsten Dominik <dominik@science.uva.nl>
399
400 * org.el (org-set-font-lock-defaults): Make the description
401 tag bold.
402
403 * org-exp.el (org-export-as-html, org-close-li): Implement
404 description lists.
405
4062008-06-17 Jason Riedy <jason@acm.org>
407
408 * org-table.el (*orgtbl-default-fmt*): New variable.
409 (orgtbl-format-line): Use the value of *orgtbl-default-fmt*
410 when there is no other fmt available.
411
412 (orgtbl-to-generic): Allow an explicitly nil :tstart or
413 :tend to suppress the appropriate string.
414
415 (orgtbl-to-orgtbl): New function for translating to another orgtbl
416 table.
417
4182008-06-17 Carsten Dominik <dominik@science.uva.nl>
419
420 * org.el (org-read-date-analyze): "." as an alias for "+0" in
421 read date.
422
423 * org-clock.el (org-clock-save-markers-for-cut-and-paste):
424 New function.
425
426 * org-agenda.el (org-agenda-save-markers-for-cut-and-paste):
427 New function.
428
4292008-06-17 Carsten Dominik <dominik@science.uva.nl>
430
431 * org-clock.el (org-clock-find-position): Don't include notes
432 into clock drawer.
433
434 * org-archive.el (org-archive-subtree): No longer remove an
435 extra line after cutting the subtree. `org-cut-subtree' already
436 takes care of this.
437
438 * org-remember.el (org-remember-handler): Only kill the target
439 buffer if it does not contain the running clock.
440
441 * org.el (org-markers-to-move): New variable.
442 (org-save-markers-in-region, org-check-and-save-marker)
443 (org-reinstall-markers-in-region): New function.
444 (org-move-subtree-down, org-copy-subtree): Remember relative
445 marker positions before cutting.
446 (org-move-subtree-down, org-paste-subtree): Restore relative
447 marker positions after pasting.
448
449 * org-remember.el (org-remember-clock-out-on-exit): New option.
450 (org-remember-finalize): Clock out only if the setting in
451 `org-remember-clock-out-on-exit' requires it.
452 (org-remember-handler): Do the cleanup in the buffer, to make sure
453 that the clock marker remains in tact.
454
4552008-06-17 Carsten Dominik <dominik@science.uva.nl>
456
457 * org-clock.el (org-clock-goto): Widen buffer if necessary.
458 (org-clock-in): Make sure that also tasks outside the narrowed
459 region will be clocked in correctly.
460 (org-clock-insert-selection-line): Widen the buffer so that we can
461 find the correct task heading.
462
463 * org.el (org-base-buffer): New function.
464
465 * org-exp.el (org-icalendar-cleanup-string): Make sure ',"
466 and ";" are escaped.
467 (org-print-icalendar-entries): Also apply
468 `org-icalendar-cleanup-string' to the headline, not only to the
469 summary property.
470
4712008-06-17 Carsten Dominik <dominik@science.uva.nl>
472
473 * org-exp.el (org-export-preprocess-hook): New hook.
474 (org-export-preprocess-string): Call
475 `org-export-preprocess-hook'.
476
477 * org.el (org-font-lock-hook): New variable.
478 (org-font-lock-hook): New function.
479 (org-set-font-lock-defaults): Call `org-font-lock-hook'.
480
diff --git a/lisp/org/org-agenda.el b/lisp/org/org-agenda.el
index 0f8fcf5a377..32efe5d8413 100644
--- a/lisp/org/org-agenda.el
+++ b/lisp/org/org-agenda.el
@@ -1,4 +1,4 @@
1;;; org-agenda.el --- The table editor for Org-mode 1;;; org-agenda.el --- Dynamic task and appointment lists for Org
2 2
3;; Copyright (C) 2004, 2005, 2006, 2007, 2008 3;; Copyright (C) 2004, 2005, 2006, 2007, 2008
4;; Free Software Foundation, Inc. 4;; Free Software Foundation, Inc.
@@ -6,7 +6,7 @@
6;; Author: Carsten Dominik <carsten at orgmode dot org> 6;; Author: Carsten Dominik <carsten at orgmode dot org>
7;; Keywords: outlines, hypermedia, calendar, wp 7;; Keywords: outlines, hypermedia, calendar, wp
8;; Homepage: http://orgmode.org 8;; Homepage: http://orgmode.org
9;; Version: 6.02b 9;; Version: 6.05a
10;; 10;;
11;; This file is part of GNU Emacs. 11;; This file is part of GNU Emacs.
12;; 12;;
@@ -34,7 +34,7 @@
34(eval-when-compile 34(eval-when-compile
35 (require 'calendar)) 35 (require 'calendar))
36 36
37(declare-function add-to-diary-list "diary-lib" 37(declare-function diary-add-to-list "diary-lib"
38 (date string specifier &optional marker globcolor literal)) 38 (date string specifier &optional marker globcolor literal))
39(declare-function calendar-absolute-from-iso "cal-iso" (date)) 39(declare-function calendar-absolute-from-iso "cal-iso" (date))
40(declare-function calendar-astro-date-string "cal-julian" (&optional date)) 40(declare-function calendar-astro-date-string "cal-julian" (&optional date))
@@ -392,6 +392,12 @@ or `C-c a #' to produce the list."
392 :tag "Org Agenda Skip" 392 :tag "Org Agenda Skip"
393 :group 'org-agenda) 393 :group 'org-agenda)
394 394
395(defcustom org-agenda-skip-comment-trees t
396 "Non-nil means, skip trees that start with teh COMMENT keyword.
397When nil, these trees are also scand by agenda commands."
398 :group 'org-agenda-skip
399 :type 'boolean)
400
395(defcustom org-agenda-todo-list-sublevels t 401(defcustom org-agenda-todo-list-sublevels t
396 "Non-nil means, check also the sublevels of a TODO entry for TODO entries. 402 "Non-nil means, check also the sublevels of a TODO entry for TODO entries.
397When nil, the sublevels of a TODO entry are not checked, resulting in 403When nil, the sublevels of a TODO entry are not checked, resulting in
@@ -464,7 +470,6 @@ N days, just insert a special line indicating the size of the gap."
464 (const :tag "All" t) 470 (const :tag "All" t)
465 (number :tag "at most"))) 471 (number :tag "at most")))
466 472
467
468(defgroup org-agenda-startup nil 473(defgroup org-agenda-startup nil
469 "Options concerning initial settings in the Agenda in Org Mode." 474 "Options concerning initial settings in the Agenda in Org Mode."
470 :tag "Org Agenda Startup" 475 :tag "Org Agenda Startup"
@@ -676,7 +681,7 @@ symbols specifying conditions when the grid should be displayed:
676 today show grid on current date, independent of daily/weekly display 681 today show grid on current date, independent of daily/weekly display
677 require-timed show grid only if at least one item has a time specification 682 require-timed show grid only if at least one item has a time specification
678 683
679The second item is a string which will be places behing the grid time. 684The second item is a string which will be placed behind the grid time.
680 685
681The third item is a list of integers, indicating the times that should have 686The third item is a list of integers, indicating the times that should have
682a grid line." 687a grid line."
@@ -849,8 +854,10 @@ to occupy a fixed space in the agenda display."
849 "Text preceeding scheduled items in the agenda view. 854 "Text preceeding scheduled items in the agenda view.
850This is a list with two strings. The first applies when the item is 855This is a list with two strings. The first applies when the item is
851scheduled on the current day. The second applies when it has been scheduled 856scheduled on the current day. The second applies when it has been scheduled
852previously, it may contain a %d to capture how many days ago the item was 857previously, it may contain a %d indicating that this is the nth time that
853scheduled." 858this item is scheduled, due to automatic rescheduling of unfinished items
859for the following day. So this number is one larger than the number of days
860that passed since this item was scheduled first."
854 :group 'org-agenda-line-format 861 :group 'org-agenda-line-format
855 :type '(list 862 :type '(list
856 (string :tag "Scheduled today ") 863 (string :tag "Scheduled today ")
@@ -946,6 +953,16 @@ a names face, or a list like `(:background \"Red\")'."
946 :group 'org-agenda-column-view 953 :group 'org-agenda-column-view
947 :type 'boolean) 954 :type 'boolean)
948 955
956(defcustom org-agenda-columns-remove-prefix-from-item t
957 "Non-nil means, remove the prefix from a headline for agenda column view.
958The special ITEM field in the columns format contains the current line, with
959all information shown in other columns (like the TODO state or a tag).
960When this variable is non-nil, also the agenda prefix will be removed from
961the content of the ITEM field, to make sure as much as possible of the
962headline can be shown in the limited width of the field."
963 :group 'org-agenda
964 :type 'boolean)
965
949(defcustom org-agenda-columns-compute-summary-properties t 966(defcustom org-agenda-columns-compute-summary-properties t
950 "Non-nil means, recompute all summary properties before column view. 967 "Non-nil means, recompute all summary properties before column view.
951When column view in the agenda is listing properties that have a summary 968When column view in the agenda is listing properties that have a summary
@@ -1071,6 +1088,8 @@ The following commands are available:
1071(org-defkey org-agenda-mode-map "y" 'org-agenda-year-view) 1088(org-defkey org-agenda-mode-map "y" 'org-agenda-year-view)
1072(org-defkey org-agenda-mode-map "\C-c\C-z" 'org-agenda-add-note) 1089(org-defkey org-agenda-mode-map "\C-c\C-z" 'org-agenda-add-note)
1073(org-defkey org-agenda-mode-map "z" 'org-agenda-add-note) 1090(org-defkey org-agenda-mode-map "z" 'org-agenda-add-note)
1091(org-defkey org-agenda-mode-map "k" 'org-agenda-action)
1092(org-defkey org-agenda-mode-map "\C-c\C-x\C-k" 'org-agenda-action)
1074(org-defkey org-agenda-mode-map [(shift right)] 'org-agenda-date-later) 1093(org-defkey org-agenda-mode-map [(shift right)] 'org-agenda-date-later)
1075(org-defkey org-agenda-mode-map [(shift left)] 'org-agenda-date-earlier) 1094(org-defkey org-agenda-mode-map [(shift left)] 'org-agenda-date-earlier)
1076(org-defkey org-agenda-mode-map [?\C-c ?\C-x (right)] 'org-agenda-date-later) 1095(org-defkey org-agenda-mode-map [?\C-c ?\C-x (right)] 'org-agenda-date-later)
@@ -1177,6 +1196,11 @@ The following commands are available:
1177 ["Schedule" org-agenda-schedule t] 1196 ["Schedule" org-agenda-schedule t]
1178 ["Set Deadline" org-agenda-deadline t] 1197 ["Set Deadline" org-agenda-deadline t]
1179 "--" 1198 "--"
1199 ["Mark item" org-agenda-action :active t :keys "k m"]
1200 ["Show mark item" org-agenda-action :active t :keys "k v"]
1201 ["Schedule marked item" org-agenda-action :active t :keys "k s"]
1202 ["Set Deadline for marked item" org-agenda-action :active t :keys "k d"]
1203 "--"
1180 ["Change Date +1 day" org-agenda-date-later (org-agenda-check-type nil 'agenda 'timeline)] 1204 ["Change Date +1 day" org-agenda-date-later (org-agenda-check-type nil 'agenda 'timeline)]
1181 ["Change Date -1 day" org-agenda-date-earlier (org-agenda-check-type nil 'agenda 'timeline)] 1205 ["Change Date -1 day" org-agenda-date-earlier (org-agenda-check-type nil 'agenda 'timeline)]
1182 ["Change Date to ..." org-agenda-date-prompt (org-agenda-check-type nil 'agenda 'timeline)]) 1206 ["Change Date to ..." org-agenda-date-prompt (org-agenda-check-type nil 'agenda 'timeline)])
@@ -2012,7 +2036,8 @@ continue from there."
2012 (get-text-property p :org-archived) 2036 (get-text-property p :org-archived)
2013 (org-end-of-subtree t) 2037 (org-end-of-subtree t)
2014 (throw :skip t)) 2038 (throw :skip t))
2015 (and (get-text-property p :org-comment) 2039 (and org-agenda-skip-comment-trees
2040 (get-text-property p :org-comment)
2016 (org-end-of-subtree t) 2041 (org-end-of-subtree t)
2017 (throw :skip t)) 2042 (throw :skip t))
2018 (if (equal (char-after p) ?#) (throw :skip t)) 2043 (if (equal (char-after p) ?#) (throw :skip t))
@@ -2045,6 +2070,11 @@ no longer in use."
2045 (while org-agenda-markers 2070 (while org-agenda-markers
2046 (move-marker (pop org-agenda-markers) nil))) 2071 (move-marker (pop org-agenda-markers) nil)))
2047 2072
2073(defun org-agenda-save-markers-for-cut-and-paste (beg end)
2074 "Save relative positions of markers in region."
2075 (mapc (lambda (m) (org-check-and-save-marker m beg end))
2076 org-agenda-markers))
2077
2048;;; Agenda timeline 2078;;; Agenda timeline
2049 2079
2050(defvar org-agenda-only-exact-dates nil) ; dynamically scoped 2080(defvar org-agenda-only-exact-dates nil) ; dynamically scoped
@@ -2425,6 +2455,7 @@ in `org-agenda-text-search-extra-files'."
2425 'done-face 'org-done 2455 'done-face 'org-done
2426 'org-not-done-regexp org-not-done-regexp 2456 'org-not-done-regexp org-not-done-regexp
2427 'org-todo-regexp org-todo-regexp 2457 'org-todo-regexp org-todo-regexp
2458 'org-complex-heading-regexp org-complex-heading-regexp
2428 'mouse-face 'highlight 2459 'mouse-face 'highlight
2429 'keymap org-agenda-keymap 2460 'keymap org-agenda-keymap
2430 'help-echo (format "mouse-2 or RET jump to location"))) 2461 'help-echo (format "mouse-2 or RET jump to location")))
@@ -2539,6 +2570,7 @@ in `org-agenda-text-search-extra-files'."
2539 (org-add-props txt props 2570 (org-add-props txt props
2540 'org-marker marker 'org-hd-marker marker 2571 'org-marker marker 'org-hd-marker marker
2541 'org-todo-regexp org-todo-regexp 2572 'org-todo-regexp org-todo-regexp
2573 'org-complex-heading-regexp org-complex-heading-regexp
2542 'priority 1000 'org-category category 2574 'priority 1000 'org-category category
2543 'type "search") 2575 'type "search")
2544 (push txt ee) 2576 (push txt ee)
@@ -3065,6 +3097,7 @@ the documentation of `org-diary'."
3065 'done-face 'org-done 3097 'done-face 'org-done
3066 'org-not-done-regexp org-not-done-regexp 3098 'org-not-done-regexp org-not-done-regexp
3067 'org-todo-regexp org-todo-regexp 3099 'org-todo-regexp org-todo-regexp
3100 'org-complex-heading-regexp org-complex-heading-regexp
3068 'mouse-face 'highlight 3101 'mouse-face 'highlight
3069 'keymap org-agenda-keymap 3102 'keymap org-agenda-keymap
3070 'help-echo 3103 'help-echo
@@ -3123,6 +3156,7 @@ the documentation of `org-diary'."
3123 (let* ((props (list 'face nil 3156 (let* ((props (list 'face nil
3124 'org-not-done-regexp org-not-done-regexp 3157 'org-not-done-regexp org-not-done-regexp
3125 'org-todo-regexp org-todo-regexp 3158 'org-todo-regexp org-todo-regexp
3159 'org-complex-heading-regexp org-complex-heading-regexp
3126 'mouse-face 'highlight 3160 'mouse-face 'highlight
3127 'keymap org-agenda-keymap 3161 'keymap org-agenda-keymap
3128 'help-echo 3162 'help-echo
@@ -3255,6 +3289,7 @@ the documentation of `org-diary'."
3255 (let* ((props (list 'mouse-face 'highlight 3289 (let* ((props (list 'mouse-face 'highlight
3256 'org-not-done-regexp org-not-done-regexp 3290 'org-not-done-regexp org-not-done-regexp
3257 'org-todo-regexp org-todo-regexp 3291 'org-todo-regexp org-todo-regexp
3292 'org-complex-heading-regexp org-complex-heading-regexp
3258 'keymap org-agenda-keymap 3293 'keymap org-agenda-keymap
3259 'help-echo 3294 'help-echo
3260 (format "mouse-2 or RET jump to org file %s" 3295 (format "mouse-2 or RET jump to org file %s"
@@ -3269,7 +3304,7 @@ the documentation of `org-diary'."
3269 (list 0 0 0 (nth 1 date) (car date) (nth 2 date)))) 3304 (list 0 0 0 (nth 1 date) (car date) (nth 2 date))))
3270 1 11)))) 3305 1 11))))
3271 marker hdmarker priority category tags closedp 3306 marker hdmarker priority category tags closedp
3272 ee txt timestr) 3307 ee txt timestr rest)
3273 (goto-char (point-min)) 3308 (goto-char (point-min))
3274 (while (re-search-forward regexp nil t) 3309 (while (re-search-forward regexp nil t)
3275 (catch :skip 3310 (catch :skip
@@ -3280,9 +3315,15 @@ the documentation of `org-diary'."
3280 timestr (buffer-substring (match-beginning 0) (point-at-eol)) 3315 timestr (buffer-substring (match-beginning 0) (point-at-eol))
3281 ;; donep (org-entry-is-done-p) 3316 ;; donep (org-entry-is-done-p)
3282 ) 3317 )
3283 (if (string-match "\\]" timestr) 3318 (when (string-match "\\]" timestr)
3284 ;; substring should only run to end of time stamp 3319 ;; substring should only run to end of time stamp
3285 (setq timestr (substring timestr 0 (match-end 0)))) 3320 (setq rest (substring timestr (match-end 0))
3321 timestr (substring timestr 0 (match-end 0)))
3322 (if (and (not closedp)
3323 (string-match "\\([0-9]\\{1,2\\}:[0-9]\\{2\\}\\)\\]" rest))
3324 (setq timestr (concat (substring timestr 0 -1)
3325 "-" (match-string 1 rest) "]"))))
3326
3286 (save-excursion 3327 (save-excursion
3287 (if (re-search-backward "^\\*+ " nil t) 3328 (if (re-search-backward "^\\*+ " nil t)
3288 (progn 3329 (progn
@@ -3309,6 +3350,7 @@ the documentation of `org-diary'."
3309 (let* ((props (list 'mouse-face 'highlight 3350 (let* ((props (list 'mouse-face 'highlight
3310 'org-not-done-regexp org-not-done-regexp 3351 'org-not-done-regexp org-not-done-regexp
3311 'org-todo-regexp org-todo-regexp 3352 'org-todo-regexp org-todo-regexp
3353 'org-complex-heading-regexp org-complex-heading-regexp
3312 'keymap org-agenda-keymap 3354 'keymap org-agenda-keymap
3313 'help-echo 3355 'help-echo
3314 (format "mouse-2 or RET jump to org file %s" 3356 (format "mouse-2 or RET jump to org file %s"
@@ -3394,6 +3436,7 @@ FRACTION is what fraction of the head-warning time has passed."
3394 "Return the scheduled information for agenda display." 3436 "Return the scheduled information for agenda display."
3395 (let* ((props (list 'org-not-done-regexp org-not-done-regexp 3437 (let* ((props (list 'org-not-done-regexp org-not-done-regexp
3396 'org-todo-regexp org-todo-regexp 3438 'org-todo-regexp org-todo-regexp
3439 'org-complex-heading-regexp org-complex-heading-regexp
3397 'done-face 'org-done 3440 'done-face 'org-done
3398 'mouse-face 'highlight 3441 'mouse-face 'highlight
3399 'keymap org-agenda-keymap 3442 'keymap org-agenda-keymap
@@ -3469,6 +3512,7 @@ FRACTION is what fraction of the head-warning time has passed."
3469 (let* ((props (list 'face nil 3512 (let* ((props (list 'face nil
3470 'org-not-done-regexp org-not-done-regexp 3513 'org-not-done-regexp org-not-done-regexp
3471 'org-todo-regexp org-todo-regexp 3514 'org-todo-regexp org-todo-regexp
3515 'org-complex-heading-regexp org-complex-heading-regexp
3472 'mouse-face 'highlight 3516 'mouse-face 'highlight
3473 'keymap org-agenda-keymap 3517 'keymap org-agenda-keymap
3474 'help-echo 3518 'help-echo
@@ -4137,12 +4181,12 @@ written as 2-digit years."
4137 (setq org-agenda-ndays 7) 4181 (setq org-agenda-ndays 7)
4138 (org-agenda-change-time-span 'week iso-week)) 4182 (org-agenda-change-time-span 'week iso-week))
4139(defun org-agenda-month-view (&optional month) 4183(defun org-agenda-month-view (&optional month)
4140 "Switch to daily view for agenda. 4184 "Switch to monthly view for agenda.
4141With argument MONTH, switch to that month." 4185With argument MONTH, switch to that month."
4142 (interactive "P") 4186 (interactive "P")
4143 (org-agenda-change-time-span 'month month)) 4187 (org-agenda-change-time-span 'month month))
4144(defun org-agenda-year-view (&optional year) 4188(defun org-agenda-year-view (&optional year)
4145 "Switch to daily view for agenda. 4189 "Switch to yearly view for agenda.
4146With argument YEAR, switch to that year. 4190With argument YEAR, switch to that year.
4147If MONTH has more then 2 digits, only the last two encode the 4191If MONTH has more then 2 digits, only the last two encode the
4148month. Any digits before this encode a year. So 200712 means 4192month. Any digits before this encode a year. So 200712 means
@@ -4331,7 +4375,10 @@ so that the date SD will be in that range."
4331 4375
4332(defun org-agenda-post-command-hook () 4376(defun org-agenda-post-command-hook ()
4333 (and (eolp) (not (bolp)) (backward-char 1)) 4377 (and (eolp) (not (bolp)) (backward-char 1))
4334 (setq org-agenda-type (get-text-property (point) 'org-agenda-type)) 4378 (setq org-agenda-type
4379 (or (get-text-property (point) 'org-agenda-type)
4380 (get-text-property (max (point-min) (1- (point)))
4381 'org-agenda-type)))
4335 (if (and org-agenda-follow-mode 4382 (if (and org-agenda-follow-mode
4336 (get-text-property (point) 'org-marker)) 4383 (get-text-property (point) 'org-marker))
4337 (org-agenda-show))) 4384 (org-agenda-show)))
@@ -4890,6 +4937,69 @@ be used to request time specification in the time stamp."
4890 (org-agenda-show-new-time marker ts "S")) 4937 (org-agenda-show-new-time marker ts "S"))
4891 (message "Deadline for this item set to %s" ts))) 4938 (message "Deadline for this item set to %s" ts)))
4892 4939
4940(defun org-agenda-action ()
4941 "Select entry for agenda action, or execute an agenda action.
4942This command prompts for another letter. Valid inputs are:
4943
4944m Mark the entry at point for an agenda action
4945s Schedule the marked entry to the date at the cursor
4946d Set the deadline of the marked entry to the date at the cursor
4947r Call `org-remember' with cursor date as the default date
4948SPC Show marked entry in other window
4949TAB Visit marked entry in other window
4950
4951The cursor may be at a date in the calendar, or in the Org agenda."
4952 (interactive)
4953 (let (pos ans)
4954 (message "Select action: [m]ark | [s]chedule [d]eadline [r]emember [ ]show")
4955 (setq ans (read-char-exclusive))
4956 (cond
4957 ((equal ans ?m)
4958 ;; Mark this entry
4959 (if (eq major-mode 'org-agenda-mode)
4960 (let ((m (or (get-text-property (point) 'org-hd-marker)
4961 (get-text-property (point) 'org-marker))))
4962 (if m
4963 (progn
4964 (move-marker org-agenda-action-marker
4965 (marker-position m) (marker-buffer m))
4966 (message "Entry marked for action; press `k' at desired date in agenda or calendar"))
4967 (error "Don't know which entry to mark")))
4968 (error "This command works only in the agenda")))
4969 ((equal ans ?s)
4970 (org-agenda-do-action '(org-schedule nil org-overriding-default-time)))
4971 ((equal ans ?d)
4972 (org-agenda-do-action '(org-deadline nil org-overriding-default-time)))
4973 ((equal ans ?r)
4974 (org-agenda-do-action '(org-remember) t))
4975 ((equal ans ?\ )
4976 (let ((cw (selected-window)))
4977 (org-switch-to-buffer-other-window
4978 (marker-buffer org-agenda-action-marker))
4979 (goto-char org-agenda-action-marker)
4980 (org-show-context 'agenda)
4981 (select-window cw)))
4982 ((equal ans ?\C-i)
4983 (org-switch-to-buffer-other-window
4984 (marker-buffer org-agenda-action-marker))
4985 (goto-char org-agenda-action-marker)
4986 (org-show-context 'agenda))
4987 (t (error "Invalid agenda action %c" ans)))))
4988
4989(defun org-agenda-do-action (form &optional current-buffer)
4990 "Evaluate FORM at the entry pointed to by `org-agenda-action-marker'."
4991 (let ((org-overriding-default-time (org-get-cursor-date)))
4992 (if current-buffer
4993 (eval form)
4994 (if (not (marker-buffer org-agenda-action-marker))
4995 (error "No entry has bee selected for agenda action")
4996 (with-current-buffer (marker-buffer org-agenda-action-marker)
4997 (save-excursion
4998 (save-restriction
4999 (widen)
5000 (goto-char org-agenda-action-marker)
5001 (eval form))))))))
5002
4893(defun org-agenda-clock-in (&optional arg) 5003(defun org-agenda-clock-in (&optional arg)
4894 "Start the clock on the currently selected item." 5004 "Start the clock on the currently selected item."
4895 (interactive "P") 5005 (interactive "P")
@@ -4898,12 +5008,20 @@ be used to request time specification in the time stamp."
4898 (org-clock-in arg) 5008 (org-clock-in arg)
4899 (let* ((marker (or (get-text-property (point) 'org-marker) 5009 (let* ((marker (or (get-text-property (point) 'org-marker)
4900 (org-agenda-error))) 5010 (org-agenda-error)))
4901 (pos (marker-position marker))) 5011 (hdmarker (or (get-text-property (point) 'org-hd-marker)
5012 marker))
5013 (pos (marker-position marker))
5014 newhead)
4902 (org-with-remote-undo (marker-buffer marker) 5015 (org-with-remote-undo (marker-buffer marker)
4903 (with-current-buffer (marker-buffer marker) 5016 (with-current-buffer (marker-buffer marker)
4904 (widen) 5017 (widen)
4905 (goto-char pos) 5018 (goto-char pos)
4906 (org-clock-in arg)))))) 5019 (org-show-context 'agenda)
5020 (org-show-entry)
5021 (org-cycle-hide-drawers 'children)
5022 (org-clock-in arg)
5023 (setq newhead (org-get-heading)))
5024 (org-agenda-change-all-lines newhead hdmarker t)))))
4907 5025
4908(defun org-agenda-clock-out (&optional arg) 5026(defun org-agenda-clock-out (&optional arg)
4909 "Stop the currently running clock." 5027 "Stop the currently running clock."
@@ -5141,6 +5259,8 @@ belonging to the \"Work\" category."
5141 5259
5142(provide 'org-agenda) 5260(provide 'org-agenda)
5143 5261
5262;; arch-tag: 77f7565d-7c4b-44af-a2df-9f6f7070cff1
5263
5144;;; org-agenda.el ends here 5264;;; org-agenda.el ends here
5145 5265
5146;; arch-tag: 77f7565d-7c4b-44af-a2df-9f6f7070cff1 5266
diff --git a/lisp/org/org-archive.el b/lisp/org/org-archive.el
index 9f8e57d6898..3d7d06f3453 100644
--- a/lisp/org/org-archive.el
+++ b/lisp/org/org-archive.el
@@ -5,7 +5,7 @@
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;;
@@ -64,8 +64,8 @@ This variable can be a list of any of the following symbols:
64 64
65time The time of archiving. 65time The time of archiving.
66file The file where the entry originates. 66file The file where the entry originates.
67itags The local tags, in the headline of the subtree. 67ltags The local tags, in the headline of the subtree.
68ltags The tags the subtree inherits from further up the hierarchy. 68itags The tags the subtree inherits from further up the hierarchy.
69todo The pre-archive TODO state. 69todo The pre-archive TODO state.
70category The category, taken from file name or #+CATEGORY lines. 70category The category, taken from file name or #+CATEGORY lines.
71olpath The outline path to the item. These are all headlines above 71olpath The outline path to the item. These are all headlines above
@@ -80,7 +80,7 @@ information."
80 (const :tag "File" file) 80 (const :tag "File" file)
81 (const :tag "Category" category) 81 (const :tag "Category" category)
82 (const :tag "TODO state" todo) 82 (const :tag "TODO state" todo)
83 (const :tag "TODO state" priority) 83 (const :tag "Priority" priority)
84 (const :tag "Inherited tags" itags) 84 (const :tag "Inherited tags" itags)
85 (const :tag "Outline path" olpath) 85 (const :tag "Outline path" olpath)
86 (const :tag "Local tags" ltags))) 86 (const :tag "Local tags" ltags)))
@@ -135,14 +135,19 @@ archive file is."
135 files)) 135 files))
136 136
137(defun org-extract-archive-file (&optional location) 137(defun org-extract-archive-file (&optional location)
138 "Extract and expand the file name from archive LOCATION.
139if LOCATION is not given, the value of `org-archive-location' is used."
138 (setq location (or location org-archive-location)) 140 (setq location (or location org-archive-location))
139 (if (string-match "\\(.*\\)::\\(.*\\)" location) 141 (if (string-match "\\(.*\\)::\\(.*\\)" location)
140 (if (= (match-beginning 1) (match-end 1)) 142 (if (= (match-beginning 1) (match-end 1))
141 (buffer-file-name) 143 (buffer-file-name)
142 (expand-file-name 144 (expand-file-name
143 (format (match-string 1 location) buffer-file-name))))) 145 (format (match-string 1 location)
146 (file-name-nondirectory buffer-file-name))))))
144 147
145(defun org-extract-archive-heading (&optional location) 148(defun org-extract-archive-heading (&optional location)
149 "Extract the heading from archive LOCATION.
150if LOCATION is not given, the value of `org-archive-location' is used."
146 (setq location (or location org-archive-location)) 151 (setq location (or location org-archive-location))
147 (if (string-match "\\(.*\\)::\\(.*\\)" location) 152 (if (string-match "\\(.*\\)::\\(.*\\)" location)
148 (match-string 2 location))) 153 (match-string 2 location)))
@@ -180,7 +185,7 @@ this heading."
180 (current-time))) 185 (current-time)))
181 category todo priority ltags itags 186 category todo priority ltags itags
182 ;; end of variables that will be used for saving context 187 ;; end of variables that will be used for saving context
183 location afile heading buffer level newfile-p) 188 location afile heading buffer level newfile-p visiting)
184 189
185 ;; Find the local archive location 190 ;; Find the local archive location
186 (setq location (org-get-local-archive-location) 191 (setq location (org-get-local-archive-location)
@@ -191,7 +196,8 @@ this heading."
191 196
192 (if (> (length afile) 0) 197 (if (> (length afile) 0)
193 (setq newfile-p (not (file-exists-p afile)) 198 (setq newfile-p (not (file-exists-p afile))
194 buffer (find-file-noselect afile)) 199 visiting (find-buffer-visiting afile)
200 buffer (or visiting (find-file-noselect afile)))
195 (setq buffer (current-buffer))) 201 (setq buffer (current-buffer)))
196 (unless buffer 202 (unless buffer
197 (error "Cannot access file \"%s\"" afile)) 203 (error "Cannot access file \"%s\"" afile))
@@ -213,9 +219,9 @@ this heading."
213 (setq ltags (mapconcat 'identity ltags " ") 219 (setq ltags (mapconcat 'identity ltags " ")
214 itags (mapconcat 'identity itags " ")) 220 itags (mapconcat 'identity itags " "))
215 ;; We first only copy, in case something goes wrong 221 ;; We first only copy, in case something goes wrong
216 ;; we need to protect this-command, to avoid kill-region sets it, 222 ;; we need to protect `this-command', to avoid kill-region sets it,
217 ;; which would lead to duplication of subtrees 223 ;; which would lead to duplication of subtrees
218 (let (this-command) (org-copy-subtree)) 224 (let (this-command) (org-copy-subtree 1 nil t))
219 (set-buffer buffer) 225 (set-buffer buffer)
220 ;; Enforce org-mode for the archive buffer 226 ;; Enforce org-mode for the archive buffer
221 (if (not (org-mode-p)) 227 (if (not (org-mode-p))
@@ -283,12 +289,18 @@ this heading."
283 (org-entry-put (point) n v))))) 289 (org-entry-put (point) n v)))))
284 290
285 ;; Save and kill the buffer, if it is not the same buffer. 291 ;; Save and kill the buffer, if it is not the same buffer.
286 (if (not (eq this-buffer buffer)) 292 (when (not (eq this-buffer buffer))
287 (progn (save-buffer) (kill-buffer buffer))))) 293 (save-buffer)
294 ;; Check if it is OK to kill the buffer
295 (unless
296 (or visiting
297 (equal (marker-buffer org-clock-marker) (current-buffer)))
298 (kill-buffer buffer)))
299 ))
288 ;; Here we are back in the original buffer. Everything seems to have 300 ;; Here we are back in the original buffer. Everything seems to have
289 ;; worked. So now cut the tree and finish up. 301 ;; worked. So now cut the tree and finish up.
290 (let (this-command) (org-cut-subtree)) 302 (let (this-command) (org-cut-subtree))
291 (if (and (not (eobp)) (looking-at "[ \t]*$")) (kill-line)) 303 (setq org-markers-to-move nil)
292 (message "Subtree archived %s" 304 (message "Subtree archived %s"
293 (if (eq this-buffer buffer) 305 (if (eq this-buffer buffer)
294 (concat "under heading: " heading) 306 (concat "under heading: " heading)
@@ -404,4 +416,5 @@ the children that do not contain any open TODO items."
404(provide 'org-archive) 416(provide 'org-archive)
405 417
406;; arch-tag: 0837f601-9699-43c3-8b90-631572ae6c85 418;; arch-tag: 0837f601-9699-43c3-8b90-631572ae6c85
419
407;;; org-archive.el ends here 420;;; org-archive.el ends here
diff --git a/lisp/org/org-bbdb.el b/lisp/org/org-bbdb.el
index b32899e5727..4dd6b2332c4 100644
--- a/lisp/org/org-bbdb.el
+++ b/lisp/org/org-bbdb.el
@@ -6,7 +6,7 @@
6;; Thomas Baumann <thomas dot baumann at ch dot tum dot de> 6;; Thomas Baumann <thomas dot baumann at ch dot tum dot de>
7;; Keywords: outlines, hypermedia, calendar, wp 7;; Keywords: outlines, hypermedia, calendar, wp
8;; Homepage: http://orgmode.org 8;; Homepage: http://orgmode.org
9;; Version: 6.02b 9;; Version: 6.05a
10;; 10;;
11;; This file is part of GNU Emacs. 11;; This file is part of GNU Emacs.
12;; 12;;
@@ -30,7 +30,6 @@
30;; Org-mode loads this module by default - if this is not what you want, 30;; Org-mode loads this module by default - if this is not what you want,
31;; configure the variable `org-modules'. 31;; configure the variable `org-modules'.
32 32
33
34;; It also implements an interface (based on Ivar Rummelhoff's 33;; It also implements an interface (based on Ivar Rummelhoff's
35;; bbdb-anniv.el) for those org-mode users, who do not use the diary 34;; bbdb-anniv.el) for those org-mode users, who do not use the diary
36;; but who do want to include the anniversaries stored in the BBDB 35;; but who do want to include the anniversaries stored in the BBDB
@@ -77,7 +76,10 @@
77;; 1973-06-22 76;; 1973-06-22
78;; 20??-??-?? wedding 77;; 20??-??-?? wedding
79;; 1998-03-12 %s created bbdb-anniv.el %d years ago 78;; 1998-03-12 %s created bbdb-anniv.el %d years ago
80 79;;
80;; From Org's agenda, you can use `C-c C-o' to jump to the BBDB
81;; link from which the entry at point originates.
82;;
81;;; Code: 83;;; Code:
82 84
83(require 'org) 85(require 'org)
@@ -100,7 +102,7 @@
100(declare-function calendar-leap-year-p "calendar" (year)) 102(declare-function calendar-leap-year-p "calendar" (year))
101(declare-function diary-ordinal-suffix "diary-lib" (n)) 103(declare-function diary-ordinal-suffix "diary-lib" (n))
102 104
103(defvar date) 105(defvar date) ;; dynamically scoped from Org
104 106
105;; Customization 107;; Customization
106 108
@@ -115,8 +117,16 @@
115 :require 'bbdb) 117 :require 'bbdb)
116 118
117(defcustom org-bbdb-anniversary-format-alist 119(defcustom org-bbdb-anniversary-format-alist
118 '( ("birthday" . "Birthday: %s (%d%s)") 120 '(("birthday" lambda
119 ("wedding" . "%s's %d%s wedding anniversary") ) 121 (name years suffix)
122 (concat "Birthday: [[bbdb:" name "][" name " ("
123 (number-to-string years)
124 suffix ")]]"))
125 ("wedding" lambda
126 (name years suffix)
127 (concat "[[bbdb:" name "][" name "'s "
128 (number-to-string years)
129 suffix " wedding anniversary]]")))
120 "How different types of anniversaries should be formatted. 130 "How different types of anniversaries should be formatted.
121An alist of elements (STRING . FORMAT) where STRING is the name of an 131An alist of elements (STRING . FORMAT) where STRING is the name of an
122anniversary class and format is either: 132anniversary class and format is either:
@@ -227,17 +237,19 @@ Argument STR is the anniversary field in BBDB."
227 (bbdb-string-trim (substring str pos))) 237 (bbdb-string-trim (substring str pos)))
228 (list str nil)))) 238 (list str nil))))
229 239
240(defvar org-bbdb-anniv-hash nil
241 "A hash holding anniversaries extracted from BBDB.
242The hash table is created on first use.")
230 243
231;;;###autoload 244(defvar org-bbdb-updated-p t
232(defun org-bbdb-anniversaries () 245 "This is non-nil if BBDB has been updated since we last built the hash.")
233 "Extract anniversaries from BBDB for display in the agenda." 246
234 (require 'diary-lib) 247(defun org-bbdb-make-anniv-hash ()
235 (let ((dates (list (cons (cons (car date) ; month 248 "Create a hash with anniversaries extracted from BBDB, for fast access.
236 (nth 1 date)) ; day 249The anniversaries are assumed to be stored `org-bbdb-anniversary-field'."
237 (nth 2 date)))) ; year 250
238 (text ()) 251 (let (split tmp annivs)
239 annivs date years 252 (clrhash org-bbdb-anniv-hash)
240 split class form)
241 (dolist (rec (bbdb-records)) 253 (dolist (rec (bbdb-records))
242 (when (setq annivs (bbdb-record-getprop 254 (when (setq annivs (bbdb-record-getprop
243 rec org-bbdb-anniversary-field)) 255 rec org-bbdb-anniversary-field))
@@ -246,33 +258,70 @@ Argument STR is the anniversary field in BBDB."
246 (setq split (org-bbdb-anniv-split (pop annivs))) 258 (setq split (org-bbdb-anniv-split (pop annivs)))
247 (multiple-value-bind (m d y) 259 (multiple-value-bind (m d y)
248 (funcall org-bbdb-extract-date-fun (car split)) 260 (funcall org-bbdb-extract-date-fun (car split))
261 (setq tmp (gethash (list m d) org-bbdb-anniv-hash))
262 (puthash (list m d) (cons (list y
263 (bbdb-record-name rec)
264 (cadr split))
265 tmp)
266 org-bbdb-anniv-hash))))))
267 (setq org-bbdb-updated-p nil))
268
269(defun org-bbdb-updated (rec)
270 "Record the fact that BBDB has been updated.
271This is used by Org to re-create the anniversary hash table."
272 (setq org-bbdb-updated-p t))
249 273
250 (when (and (or (setq date (assoc (cons m d) dates)) 274(add-hook 'bbdb-after-change-hook 'org-bbdb-updated)
251 (and (= d 29) 275
252 (= m 2) 276;;;###autoload
253 (setq date (assoc '(3 . 1) dates)) 277(defun org-bbdb-anniversaries()
254 (not (calendar-leap-year-p (cdr date))))) 278 "Extract anniversaries from BBDB for display in the agenda."
255 (< 0 (setq years (- (cdr date) y)))) 279 (require 'diary-lib)
256 (let* ((class (or (cadr split) 280 (unless (hash-table-p org-bbdb-anniv-hash)
257 org-bbdb-default-anniversary-format)) 281 (setq org-bbdb-anniv-hash
258 (form (or (cdr (assoc class 282 (make-hash-table :test 'equal :size 366)))
259 org-bbdb-anniversary-format-alist)) 283
260 class)) ; (as format string) 284 (when (or org-bbdb-updated-p
261 (name (bbdb-record-name rec)) 285 (= 0 (hash-table-count org-bbdb-anniv-hash)))
262 (suffix (diary-ordinal-suffix years)) 286 (org-bbdb-make-anniv-hash))
263 (tmp (cond 287
264 ((functionp form) 288 (let* ((m (car date)) ; month
265 (funcall form name years suffix)) 289 (d (nth 1 date)) ; day
266 ((listp form) (eval form)) 290 (y (nth 2 date)) ; year
267 (t (format form name years suffix))))) 291 (annivs (gethash (list m d) org-bbdb-anniv-hash))
268 (if text 292 (text ())
269 (setq text (append text (list tmp))) 293 split class form rec)
270 (setq text (list tmp)))) 294
271 ))))) 295 ;; we don't want to miss people born on Feb. 29th
296 (when (and (= m 3) (= d 1) (not (calendar-leap-year-p y)))
297 (setq annivs (cons annivs (gethash (list 2 29) org-bbdb-anniv-hash))))
298
299 (when annivs
300 (while (setq rec (pop annivs))
301 (when rec
302 (let* ((class (or (nth 2 rec)
303 org-bbdb-default-anniversary-format))
304 (form (or (cdr (assoc class
305 org-bbdb-anniversary-format-alist))
306 class)) ; (as format string)
307 (name (nth 1 rec))
308 (years (- y (car rec)))
309 (suffix (diary-ordinal-suffix years))
310 (tmp (cond
311 ((functionp form)
312 (funcall form name years suffix))
313 ((listp form) (eval form))
314 (t (format form name years suffix)))))
315 (org-add-props tmp nil 'org-bbdb-name name)
316 (if text
317 (setq text (append text (list tmp)))
318 (setq text (list tmp)))))
319 ))
272 (when text 320 (when text
273 (mapconcat 'identity text "; ")))) 321 (mapconcat 'identity text "; "))))
274 322
275(provide 'org-bbdb) 323(provide 'org-bbdb)
276 324
277;; arch-tag: 9e4f275d-d080-48c1-b040-62247f66b5c2 325;; arch-tag: 9e4f275d-d080-48c1-b040-62247f66b5c2
326
278;;; org-bbdb.el ends here 327;;; org-bbdb.el ends here
diff --git a/lisp/org/org-bibtex.el b/lisp/org/org-bibtex.el
index e0de2579f32..e314f452e9f 100644
--- a/lisp/org/org-bibtex.el
+++ b/lisp/org/org-bibtex.el
@@ -5,7 +5,7 @@
5;; Author: Bastien Guerry <bzg at altern dot org> 5;; Author: Bastien Guerry <bzg at altern dot org>
6;; Carsten Dominik <carsten dot dominik at gmail dot com> 6;; Carsten Dominik <carsten dot dominik at gmail dot com>
7;; Keywords: org, wp, remember 7;; Keywords: org, wp, remember
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;;
@@ -200,4 +200,5 @@
200(provide 'org-bibtex) 200(provide 'org-bibtex)
201 201
202;; arch-tag: 83987d5a-01b8-41c7-85bc-77700f1285f5 202;; arch-tag: 83987d5a-01b8-41c7-85bc-77700f1285f5
203
203;;; org-bibtex.el ends here 204;;; org-bibtex.el ends here
diff --git a/lisp/org/org-clock.el b/lisp/org/org-clock.el
index ca0f50591ff..99be3907cd7 100644
--- a/lisp/org/org-clock.el
+++ b/lisp/org/org-clock.el
@@ -5,7 +5,7 @@
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;;
@@ -97,11 +97,7 @@ The function is called with point at the beginning of the headline."
97(defvar org-clock-start-time "") 97(defvar org-clock-start-time "")
98 98
99(defvar org-clock-history nil 99(defvar org-clock-history nil
100 "Marker pointing to the previous task teking clock time. 100 "List of marker pointing to recent clocked tasks.")
101This is used to find back to the previous task after interrupting work.
102When clocking into a task and the clock is currently running, this marker
103is moved to the position of the currently running task and continues
104to point there even after the task is clocked out.")
105 101
106(defvar org-clock-default-task (make-marker) 102(defvar org-clock-default-task (make-marker)
107 "Marker pointing to the default task that should clock time. 103 "Marker pointing to the default task that should clock time.
@@ -109,12 +105,11 @@ The clock can be made to switch to this task after clocking out
109of a different task.") 105of a different task.")
110 106
111(defvar org-clock-interrupted-task (make-marker) 107(defvar org-clock-interrupted-task (make-marker)
112 "Marker pointing to the default task that should clock time. 108 "Marker pointing to the task that has been interrupted by the current clock.")
113The clock can be made to switch to this task after clocking out
114of a different task.")
115 109
116(defun org-clock-history-push (&optional pos buffer) 110(defun org-clock-history-push (&optional pos buffer)
117 "Push a marker to the clock history." 111 "Push a marker to the clock history."
112 (setq org-clock-history-length (max 1 (min 35 org-clock-history-length)))
118 (let ((m (move-marker (make-marker) (or pos (point)) buffer)) n l) 113 (let ((m (move-marker (make-marker) (or pos (point)) buffer)) n l)
119 (while (setq n (member m org-clock-history)) 114 (while (setq n (member m org-clock-history))
120 (move-marker (car n) nil)) 115 (move-marker (car n) nil))
@@ -129,6 +124,14 @@ of a different task.")
129 (nreverse org-clock-history))))) 124 (nreverse org-clock-history)))))
130 (push m org-clock-history))) 125 (push m org-clock-history)))
131 126
127(defun org-clock-save-markers-for-cut-and-paste (beg end)
128 "Save relative positions of markers in region."
129 (org-check-and-save-marker org-clock-marker beg end)
130 (org-check-and-save-marker org-clock-default-task beg end)
131 (org-check-and-save-marker org-clock-interrupted-task beg end)
132 (mapc (lambda (m) (org-check-and-save-marker m beg end))
133 org-clock-history))
134
132(defun org-clock-select-task (&optional prompt) 135(defun org-clock-select-task (&optional prompt)
133 "Select a task that recently was associated with clocking." 136 "Select a task that recently was associated with clocking."
134 (interactive) 137 (interactive)
@@ -155,10 +158,14 @@ of a different task.")
155 (when (marker-buffer m) 158 (when (marker-buffer m)
156 (setq i (1+ i) 159 (setq i (1+ i)
157 s (org-clock-insert-selection-line 160 s (org-clock-insert-selection-line
158 (string-to-char (number-to-string i)) m)) 161 (if (< i 10)
162 (+ i ?0)
163 (+ i (- ?A 10))) m))
159 (push s sel-list))) 164 (push s sel-list)))
160 org-clock-history) 165 org-clock-history)
161 (shrink-window-if-larger-than-buffer) 166 (if (fboundp 'fit-window-to-buffer)
167 (fit-window-to-buffer)
168 (shrink-window-if-larger-than-buffer))
162 (message (or prompt "Select task for clocking:")) 169 (message (or prompt "Select task for clocking:"))
163 (setq rpl (read-char-exclusive)) 170 (setq rpl (read-char-exclusive))
164 (cond 171 (cond
@@ -170,14 +177,16 @@ of a different task.")
170(defun org-clock-insert-selection-line (i marker) 177(defun org-clock-insert-selection-line (i marker)
171 (when (marker-buffer marker) 178 (when (marker-buffer marker)
172 (let (file cat task) 179 (let (file cat task)
173 (with-current-buffer (marker-buffer marker) 180 (with-current-buffer (org-base-buffer (marker-buffer marker))
174 (save-excursion 181 (save-excursion
175 (goto-char marker) 182 (save-restriction
176 (setq file (buffer-file-name (marker-buffer marker)) 183 (widen)
177 cat (or (org-get-category) 184 (goto-char marker)
178 (progn (org-refresh-category-properties) 185 (setq file (buffer-file-name (marker-buffer marker))
179 (org-get-category))) 186 cat (or (org-get-category)
180 task (org-get-heading 'notags)))) 187 (progn (org-refresh-category-properties)
188 (org-get-category)))
189 task (org-get-heading 'notags)))))
181 (when (and cat task) 190 (when (and cat task)
182 (insert (format "[%c] %-15s %s\n" i cat task)) 191 (insert (format "[%c] %-15s %s\n" i cat task))
183 (cons i marker))))) 192 (cons i marker)))))
@@ -188,7 +197,7 @@ of a different task.")
188 (h (floor delta 3600)) 197 (h (floor delta 3600))
189 (m (floor (- delta (* 3600 h)) 60))) 198 (m (floor (- delta (* 3600 h)) 60)))
190 (setq org-mode-line-string 199 (setq org-mode-line-string
191 (propertize (format "-[%d:%02d (%s)]" h m org-clock-heading) 200 (propertize (format (concat "-[" org-time-clocksum-format " (%s)]") h m org-clock-heading)
192 'help-echo "Org-mode clock is running")) 201 'help-echo "Org-mode clock is running"))
193 (force-mode-line-update))) 202 (force-mode-line-update)))
194 203
@@ -204,60 +213,69 @@ is as the default task, a special task that will always be offered in
204the clocking selection, associated with the letter `d'." 213the clocking selection, associated with the letter `d'."
205 (interactive "P") 214 (interactive "P")
206 (let ((interrupting (marker-buffer org-clock-marker)) 215 (let ((interrupting (marker-buffer org-clock-marker))
207 ts selected-task) 216 ts selected-task target-pos)
208 (when (equal select '(4)) 217 (when (equal select '(4))
209 (setq selected-task (org-clock-select-task "Clock-in on task: ")) 218 (setq selected-task (org-clock-select-task "Clock-in on task: "))
210 (if selected-task 219 (if selected-task
211 (setq selected-task (copy-marker selected-task)) 220 (setq selected-task (copy-marker selected-task))
212 (error "Abort"))) 221 (error "Abort")))
213 ;; Are we interrupting the clocking of a differnt task? 222 (when interrupting
214 (if interrupting 223 ;; We are interrupting the clocking of a differnt task.
215 (progn 224 ;; Save a marker to this task, so that we can go back.
216 (move-marker org-clock-interrupted-task 225 (move-marker org-clock-interrupted-task
217 (marker-position org-clock-marker) 226 (marker-position org-clock-marker)
218 (marker-buffer org-clock-marker)) 227 (marker-buffer org-clock-marker))
219 (org-clock-out t))) 228 (org-clock-out t))
220 229
221 (when (equal select '(16)) 230 (when (equal select '(16))
231 ;; Mark as default clocking task
222 (save-excursion 232 (save-excursion
223 (org-back-to-heading t) 233 (org-back-to-heading t)
224 (move-marker org-clock-default-task (point)))) 234 (move-marker org-clock-default-task (point))))
225 235
236 (setq target-pos (point)) ;; we want to clock in at this location
226 (save-excursion 237 (save-excursion
227 (org-back-to-heading t)
228 (when (and selected-task (marker-buffer selected-task)) 238 (when (and selected-task (marker-buffer selected-task))
229 (set-buffer (marker-buffer selected-task)) 239 ;; There is a selected task, move to the correct buffer
230 (goto-char selected-task) 240 ;; and set the new target position.
241 (set-buffer (org-base-buffer (marker-buffer selected-task)))
242 (setq target-pos (marker-position selected-task))
231 (move-marker selected-task nil)) 243 (move-marker selected-task nil))
232 (or interrupting (move-marker org-clock-interrupted-task nil)) 244 (save-excursion
233 (org-clock-history-push) 245 (save-restriction
234 (when (and org-clock-in-switch-to-state 246 (widen)
235 (not (looking-at (concat outline-regexp "[ \t]*" 247 (goto-char target-pos)
236 org-clock-in-switch-to-state 248 (org-back-to-heading t)
237 "\\>")))) 249 (or interrupting (move-marker org-clock-interrupted-task nil))
238 (org-todo org-clock-in-switch-to-state)) 250 (org-clock-history-push)
239 (if (and org-clock-heading-function 251 (when (and org-clock-in-switch-to-state
240 (functionp org-clock-heading-function)) 252 (not (looking-at (concat outline-regexp "[ \t]*"
241 (setq org-clock-heading (funcall org-clock-heading-function)) 253 org-clock-in-switch-to-state
242 (if (looking-at org-complex-heading-regexp) 254 "\\>"))))
243 (setq org-clock-heading (match-string 4)) 255 (org-todo org-clock-in-switch-to-state))
244 (setq org-clock-heading "???"))) 256 (if (and org-clock-heading-function
245 (setq org-clock-heading (propertize org-clock-heading 'face nil)) 257 (functionp org-clock-heading-function))
246 (org-clock-find-position) 258 (setq org-clock-heading (funcall org-clock-heading-function))
247 259 (if (looking-at org-complex-heading-regexp)
248 (insert "\n") (backward-char 1) 260 (setq org-clock-heading (match-string 4))
249 (indent-relative) 261 (setq org-clock-heading "???")))
250 (insert org-clock-string " ") 262 (setq org-clock-heading (propertize org-clock-heading 'face nil))
251 (setq org-clock-start-time (current-time)) 263 (org-clock-find-position)
252 (setq ts (org-insert-time-stamp (current-time) 'with-hm 'inactive)) 264
253 (move-marker org-clock-marker (point) (buffer-base-buffer)) 265 (insert "\n") (backward-char 1)
254 (or global-mode-string (setq global-mode-string '(""))) 266 (indent-relative)
255 (or (memq 'org-mode-line-string global-mode-string) 267 (insert org-clock-string " ")
256 (setq global-mode-string 268 (setq org-clock-start-time (current-time))
257 (append global-mode-string '(org-mode-line-string)))) 269 (setq ts (org-insert-time-stamp (current-time) 'with-hm 'inactive))
258 (org-update-mode-line) 270 (move-marker org-clock-marker (point) (buffer-base-buffer))
259 (setq org-mode-line-timer (run-with-timer 60 60 'org-update-mode-line)) 271 (or global-mode-string (setq global-mode-string '("")))
260 (message "Clock started at %s" ts)))) 272 (or (memq 'org-mode-line-string global-mode-string)
273 (setq global-mode-string
274 (append global-mode-string '(org-mode-line-string))))
275 (org-update-mode-line)
276 (setq org-mode-line-timer
277 (run-with-timer 60 60 'org-update-mode-line))
278 (message "Clock started at %s" ts))))))
261 279
262(defun org-clock-find-position () 280(defun org-clock-find-position ()
263 "Find the location where the next clock line should be inserted." 281 "Find the location where the next clock line should be inserted."
@@ -288,7 +306,6 @@ the clocking selection, associated with the letter `d'."
288 ;; Wrap current entries into a new drawer 306 ;; Wrap current entries into a new drawer
289 (goto-char last) 307 (goto-char last)
290 (beginning-of-line 2) 308 (beginning-of-line 2)
291 (if (org-at-item-p) (org-end-of-item))
292 (insert ":END:\n") 309 (insert ":END:\n")
293 (beginning-of-line 0) 310 (beginning-of-line 0)
294 (org-indent-line-function) 311 (org-indent-line-function)
@@ -358,7 +375,7 @@ If there is no running clock, throw an error, unless FAIL-QUIETLY is set."
358 (setq global-mode-string 375 (setq global-mode-string
359 (delq 'org-mode-line-string global-mode-string)) 376 (delq 'org-mode-line-string global-mode-string))
360 (force-mode-line-update) 377 (force-mode-line-update)
361 (message "Clock stopped at %s after HH:MM = %d:%02d%s" te h m 378 (message (concat "Clock stopped at %s after HH:MM = " org-time-clocksum-format "%s") te h m
362 (if remove " => LINE REMOVED" ""))))))) 379 (if remove " => LINE REMOVED" "")))))))
363 380
364(defun org-clock-cancel () 381(defun org-clock-cancel ()
@@ -387,6 +404,7 @@ With prefix arg SELECT, offer recently clocked tasks."
387 (error "No task selected") 404 (error "No task selected")
388 (error "No active clock"))) 405 (error "No active clock")))
389 (switch-to-buffer (marker-buffer m)) 406 (switch-to-buffer (marker-buffer m))
407 (if (or (< m (point-min)) (> m (point-max))) (widen))
390 (goto-char m) 408 (goto-char m)
391 (org-show-entry) 409 (org-show-entry)
392 (org-back-to-heading) 410 (org-back-to-heading)
@@ -469,7 +487,7 @@ in the echo area."
469 (when org-remove-highlights-with-change 487 (when org-remove-highlights-with-change
470 (org-add-hook 'before-change-functions 'org-remove-clock-overlays 488 (org-add-hook 'before-change-functions 'org-remove-clock-overlays
471 nil 'local)))) 489 nil 'local))))
472 (message "Total file time: %d:%02d (%d hours and %d minutes)" h m h m))) 490 (message (concat "Total file time: " org-time-clocksum-format " (%d hours and %d minutes)") h m h m)))
473 491
474(defvar org-clock-overlays nil) 492(defvar org-clock-overlays nil)
475(make-variable-buffer-local 'org-clock-overlays) 493(make-variable-buffer-local 'org-clock-overlays)
@@ -481,6 +499,7 @@ This creates a new overlay and stores it in `org-clock-overlays', so that it
481will be easy to remove." 499will be easy to remove."
482 (let* ((c 60) (h (floor (/ time 60))) (m (- time (* 60 h))) 500 (let* ((c 60) (h (floor (/ time 60))) (m (- time (* 60 h)))
483 (l (if level (org-get-valid-level level 0) 0)) 501 (l (if level (org-get-valid-level level 0) 0))
502 (fmt (concat "%s " org-time-clocksum-format "%s"))
484 (off 0) 503 (off 0)
485 ov tx) 504 ov tx)
486 (org-move-to-column c) 505 (org-move-to-column c)
@@ -489,7 +508,7 @@ will be easy to remove."
489 (setq ov (org-make-overlay (1- (point)) (point-at-eol)) 508 (setq ov (org-make-overlay (1- (point)) (point-at-eol))
490 tx (concat (buffer-substring (1- (point)) (point)) 509 tx (concat (buffer-substring (1- (point)) (point))
491 (make-string (+ off (max 0 (- c (current-column)))) ?.) 510 (make-string (+ off (max 0 (- c (current-column)))) ?.)
492 (org-add-props (format "%s %2d:%02d%s" 511 (org-add-props (format fmt
493 (make-string l ?*) h m 512 (make-string l ?*) h m
494 (make-string (- 16 l) ?\ )) 513 (make-string (- 16 l) ?\ ))
495 '(face secondary-selection)) 514 '(face secondary-selection))
@@ -920,7 +939,6 @@ the currently selected interval size."
920 939
921(provide 'org-clock) 940(provide 'org-clock)
922 941
923;;; org-clock.el ends here
924
925
926;; arch-tag: 7b42c5d4-9b36-48be-97c0-66a869daed4c 942;; arch-tag: 7b42c5d4-9b36-48be-97c0-66a869daed4c
943
944;;; org-clock.el ends here
diff --git a/lisp/org/org-colview.el b/lisp/org/org-colview.el
index 9c4cfbad322..95a5aa3fccf 100644
--- a/lisp/org/org-colview.el
+++ b/lisp/org/org-colview.el
@@ -5,7 +5,7 @@
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;;
@@ -32,6 +32,8 @@
32(eval-when-compile (require 'cl)) 32(eval-when-compile (require 'cl))
33(require 'org) 33(require 'org)
34 34
35(declare-function org-agenda-redo "org-agenda" ())
36
35;;; Column View 37;;; Column View
36 38
37(defvar org-columns-overlays nil 39(defvar org-columns-overlays nil
@@ -90,6 +92,10 @@ This is the compiled version of the format.")
90(org-defkey org-columns-map [(meta left)] 'org-columns-move-left) 92(org-defkey org-columns-map [(meta left)] 'org-columns-move-left)
91(org-defkey org-columns-map [(shift meta right)] 'org-columns-new) 93(org-defkey org-columns-map [(shift meta right)] 'org-columns-new)
92(org-defkey org-columns-map [(shift meta left)] 'org-columns-delete) 94(org-defkey org-columns-map [(shift meta left)] 'org-columns-delete)
95(dotimes (i 10)
96 (org-defkey org-columns-map (number-to-string i)
97 `(lambda () (interactive)
98 (org-columns-next-allowed-value nil ,i))))
93 99
94(easy-menu-define org-columns-menu org-columns-map "Org Column Menu" 100(easy-menu-define org-columns-menu org-columns-map "Org Column Menu"
95 '("Column" 101 '("Column"
@@ -137,12 +143,11 @@ This is the compiled version of the format.")
137 (and (eq major-mode 'org-agenda-mode) 143 (and (eq major-mode 'org-agenda-mode)
138 (get-text-property (point-at-bol) 'face)) 144 (get-text-property (point-at-bol) 'face))
139 'default)) 145 'default))
140 (color (list :foreground 146 (color (list :foreground (face-attribute ref-face :foreground)))
141 (face-attribute ref-face :foreground) 147 (face (list color 'org-column ref-face))
142 :weight 'normal :strike-through nil 148 (pl (or (get-text-property (point-at-bol) 'prefix-length) 0))
143 :underline nil)) 149 (cphr (get-text-property (point-at-bol) 'org-complex-heading-regexp))
144 (face (list color 'org-column level-face)) 150 pom property ass width f string ov column val modval s1 s2)
145 pom property ass width f string ov column val modval)
146 ;; Check if the entry is in another buffer. 151 ;; Check if the entry is in another buffer.
147 (unless props 152 (unless props
148 (if (eq major-mode 'org-agenda-mode) 153 (if (eq major-mode 'org-agenda-mode)
@@ -167,8 +172,13 @@ This is the compiled version of the format.")
167 f (format "%%-%d.%ds | " width width) 172 f (format "%%-%d.%ds | " width width)
168 val (or (cdr ass) "") 173 val (or (cdr ass) "")
169 modval (if (equal property "ITEM") 174 modval (if (equal property "ITEM")
170 (org-columns-cleanup-item val org-columns-current-fmt-compiled)) 175 (if (org-mode-p)
171 string (format f (or modval val))) 176 (org-columns-cleanup-item
177 val org-columns-current-fmt-compiled)
178 (org-agenda-columns-cleanup-item
179 val pl cphr org-columns-current-fmt-compiled))))
180 (setq s2 (org-columns-add-ellipses (or modval val) width))
181 (setq string (format f s2))
172 ;; Create the overlay 182 ;; Create the overlay
173 (org-unmodified 183 (org-unmodified
174 (setq ov (org-columns-new-overlay 184 (setq ov (org-columns-new-overlay
@@ -200,6 +210,15 @@ This is the compiled version of the format.")
200 (min (point-max) (1+ (point-at-eol))) 210 (min (point-max) (1+ (point-at-eol)))
201 'read-only "Type `e' to edit property"))))) 211 'read-only "Type `e' to edit property")))))
202 212
213(defun org-columns-add-ellipses (string width)
214 "Truncate STRING with WIDTH characters, with ellipses."
215 (cond
216 ((<= (length string) width) string)
217 ((<= width (length org-columns-ellipses))
218 (substring org-columns-ellipses 0 width))
219 (t (concat (substring string 0 (- width (length org-columns-ellipses)))
220 org-columns-ellipses))))
221
203(defvar org-columns-full-header-line-format nil 222(defvar org-columns-full-header-line-format nil
204 "Fthe full header line format, will be shifted by horizontal scrolling." ) 223 "Fthe full header line format, will be shifted by horizontal scrolling." )
205(defvar org-previous-header-line-format nil 224(defvar org-previous-header-line-format nil
@@ -275,13 +294,40 @@ for the duration of the command.")
275 (if (not org-complex-heading-regexp) 294 (if (not org-complex-heading-regexp)
276 item 295 item
277 (when (string-match org-complex-heading-regexp item) 296 (when (string-match org-complex-heading-regexp item)
278 (concat 297 (setq item
279 (org-add-props (concat (match-string 1 item) " ") nil 298 (concat
280 'org-whitespace (* 2 (1- (org-reduced-level (- (match-end 1) (match-beginning 1)))))) 299 (org-add-props (match-string 1 item) nil
281 (and (match-end 2) (not (assoc "TODO" fmt)) (concat " " (match-string 2 item))) 300 'org-whitespace (* 2 (1- (org-reduced-level (- (match-end 1) (match-beginning 1))))))
282 (and (match-end 3) (not (assoc "PRIORITY" fmt)) (concat " " (match-string 3 item))) 301 (and (match-end 2) (not (assoc "TODO" fmt)) (concat " " (match-string 2 item)))
283 " " (match-string 4 item) 302 (and (match-end 3) (not (assoc "PRIORITY" fmt)) (concat " " (match-string 3 item)))
284 (and (match-end 5) (not (assoc "TAGS" fmt)) (concat " " (match-string 5 item))))))) 303 " " (save-match-data (org-columns-compact-links (match-string 4 item)))
304 (and (match-end 5) (not (assoc "TAGS" fmt)) (concat " " (match-string 5 item)))))
305 (add-text-properties
306 0 (1+ (match-end 1))
307 (list 'org-whitespace (* 2 (1- (org-reduced-level (- (match-end 1) (match-beginning 1))))))
308 item)
309 item)))
310
311(defun org-columns-compact-links (s)
312 "Replace [[link][desc]] with [desc] or [link]."
313 (while (string-match org-bracket-link-regexp s)
314 (setq s (replace-match
315 (concat "[" (match-string (if (match-end 3) 3 1) s) "]")
316 t t s)))
317 s)
318
319(defvar org-agenda-columns-remove-prefix-from-item)
320(defun org-agenda-columns-cleanup-item (item pl cphr fmt)
321 "Cleanup the tiem property for agenda column view.
322See also the variable `org-agenda-columns-remove-prefix-from-item'."
323 (let* ((org-complex-heading-regexp cphr)
324 (prefix (substring item 0 pl))
325 (rest (substring item pl))
326 (fake (concat "* " rest))
327 (cleaned (org-trim (substring (org-columns-cleanup-item fake fmt) 1))))
328 (if org-agenda-columns-remove-prefix-from-item
329 cleaned
330 (concat prefix cleaned))))
285 331
286(defun org-columns-show-value () 332(defun org-columns-show-value ()
287 "Show the full value of the property." 333 "Show the full value of the property."
@@ -381,7 +427,7 @@ Where possible, use the standard interface for changing this line."
381 427
382 (cond 428 (cond
383 ((equal major-mode 'org-agenda-mode) 429 ((equal major-mode 'org-agenda-mode)
384 (org-columns-eval '(org-entry-put pom key nval)) 430 (org-columns-eval eval)
385 ;; The following let preserves the current format, and makes sure 431 ;; The following let preserves the current format, and makes sure
386 ;; that in only a single file things need to be upated. 432 ;; that in only a single file things need to be upated.
387 (let* ((org-agenda-overriding-columns-format org-columns-current-fmt) 433 (let* ((org-agenda-overriding-columns-format org-columns-current-fmt)
@@ -411,7 +457,8 @@ Where possible, use the standard interface for changing this line."
411 "Edit the current headline, the part without TODO keyword, TAGS." 457 "Edit the current headline, the part without TODO keyword, TAGS."
412 (org-back-to-heading) 458 (org-back-to-heading)
413 (when (looking-at org-todo-line-regexp) 459 (when (looking-at org-todo-line-regexp)
414 (let ((pre (buffer-substring (match-beginning 0) (match-beginning 3))) 460 (let ((pos (point))
461 (pre (buffer-substring (match-beginning 0) (match-beginning 3)))
415 (txt (match-string 3)) 462 (txt (match-string 3))
416 (post "") 463 (post "")
417 txt2) 464 txt2)
@@ -420,7 +467,7 @@ Where possible, use the standard interface for changing this line."
420 txt (substring txt 0 (match-beginning 0)))) 467 txt (substring txt 0 (match-beginning 0))))
421 (setq txt2 (read-string "Edit: " txt)) 468 (setq txt2 (read-string "Edit: " txt))
422 (when (not (equal txt txt2)) 469 (when (not (equal txt txt2))
423 (beginning-of-line 1) 470 (goto-char pos)
424 (insert pre txt2 post) 471 (insert pre txt2 post)
425 (delete-region (point) (point-at-eol)) 472 (delete-region (point) (point-at-eol))
426 (org-set-tags nil t))))) 473 (org-set-tags nil t)))))
@@ -461,8 +508,10 @@ Where possible, use the standard interface for changing this line."
461 (interactive) 508 (interactive)
462 (org-columns-next-allowed-value t)) 509 (org-columns-next-allowed-value t))
463 510
464(defun org-columns-next-allowed-value (&optional previous) 511(defun org-columns-next-allowed-value (&optional previous nth)
465 "Switch to the next allowed value for this column." 512 "Switch to the next allowed value for this column.
513When PREVIOUS is set, go to the previous value. When NTH is
514an integer, select that value."
466 (interactive) 515 (interactive)
467 (org-columns-check-computed) 516 (org-columns-check-computed)
468 (let* ((col (current-column)) 517 (let* ((col (current-column))
@@ -484,6 +533,9 @@ Where possible, use the standard interface for changing this line."
484 '(checkbox checkbox-n-of-m checkbox-percent)) 533 '(checkbox checkbox-n-of-m checkbox-percent))
485 '("[ ]" "[X]")))) 534 '("[ ]" "[X]"))))
486 nval) 535 nval)
536 (when (integerp nth)
537 (setq nth (1- nth))
538 (if (= nth -1) (setq nth 9)))
487 (when (equal key "ITEM") 539 (when (equal key "ITEM")
488 (error "Cannot edit item headline from here")) 540 (error "Cannot edit item headline from here"))
489 (unless (or allowed (member key '("SCHEDULED" "DEADLINE"))) 541 (unless (or allowed (member key '("SCHEDULED" "DEADLINE")))
@@ -491,11 +543,18 @@ Where possible, use the standard interface for changing this line."
491 (if (member key '("SCHEDULED" "DEADLINE")) 543 (if (member key '("SCHEDULED" "DEADLINE"))
492 (setq nval (if previous 'earlier 'later)) 544 (setq nval (if previous 'earlier 'later))
493 (if previous (setq allowed (reverse allowed))) 545 (if previous (setq allowed (reverse allowed)))
494 (if (member value allowed) 546 (cond
495 (setq nval (car (cdr (member value allowed))))) 547 (nth
496 (setq nval (or nval (car allowed))) 548 (setq nval (nth nth allowed))
497 (if (equal nval value) 549 (if (not nval)
498 (error "Only one allowed value for this property"))) 550 (error "There are only %d allowed values for property `%s'"
551 (length allowed) key)))
552 ((member value allowed)
553 (setq nval (or (car (cdr (member value allowed)))
554 (car allowed)))
555 (if (equal nval value)
556 (error "Only one allowed value for this property")))
557 (t (setq nval (car allowed)))))
499 (cond 558 (cond
500 ((equal major-mode 'org-agenda-mode) 559 ((equal major-mode 'org-agenda-mode)
501 (org-columns-eval '(org-entry-put pom key nval)) 560 (org-columns-eval '(org-entry-put pom key nval))
@@ -812,13 +871,18 @@ Don't set this, this is meant for dynamic scoping.")
812 "Construct the column display again." 871 "Construct the column display again."
813 (interactive) 872 (interactive)
814 (message "Recomputing columns...") 873 (message "Recomputing columns...")
815 (save-excursion 874 (let ((line (org-current-line))
816 (if (marker-position org-columns-begin-marker) 875 (col (current-column)))
817 (goto-char org-columns-begin-marker)) 876 (save-excursion
818 (org-columns-remove-overlays) 877 (if (marker-position org-columns-begin-marker)
819 (if (org-mode-p) 878 (goto-char org-columns-begin-marker))
820 (call-interactively 'org-columns) 879 (org-columns-remove-overlays)
821 (call-interactively 'org-agenda-columns))) 880 (if (org-mode-p)
881 (call-interactively 'org-columns)
882 (org-agenda-redo)
883 (call-interactively 'org-agenda-columns)))
884 (goto-line line)
885 (move-to-column col))
822 (message "Recomputing columns...done")) 886 (message "Recomputing columns...done"))
823 887
824(defun org-columns-not-in-agenda () 888(defun org-columns-not-in-agenda ()
@@ -840,7 +904,7 @@ Don't set this, this is meant for dynamic scoping.")
840 (cond 904 (cond
841 ((eq fmt 'add_times) 905 ((eq fmt 'add_times)
842 (let* ((h (floor n)) (m (floor (+ 0.5 (* 60 (- n h)))))) 906 (let* ((h (floor n)) (m (floor (+ 0.5 (* 60 (- n h))))))
843 (format "%d:%02d" h m))) 907 (format org-time-clocksum-format h m)))
844 ((eq fmt 'checkbox) 908 ((eq fmt 'checkbox)
845 (cond ((= n (floor n)) "[X]") 909 (cond ((= n (floor n)) "[X]")
846 ((> n 1.) "[-]") 910 ((> n 1.) "[-]")
@@ -1212,6 +1276,6 @@ This will add overlays to the date lines, to show the summary for each day."
1212 1276
1213(provide 'org-colview) 1277(provide 'org-colview)
1214 1278
1215;;; org-colview.el ends here
1216
1217;; arch-tag: 61f5128d-747c-4983-9479-e3871fa3d73c 1279;; arch-tag: 61f5128d-747c-4983-9479-e3871fa3d73c
1280
1281;;; org-colview.el ends here
diff --git a/lisp/org/org-compat.el b/lisp/org/org-compat.el
index e4fe1f2a36d..bc21429cb37 100644
--- a/lisp/org/org-compat.el
+++ b/lisp/org/org-compat.el
@@ -5,7 +5,7 @@
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;;
@@ -246,8 +246,8 @@ that can be added."
246 (cadr ext-inv-spec)))) 246 (cadr ext-inv-spec))))
247 (move-to-column column force))) 247 (move-to-column column force)))
248 248
249
250(provide 'org-compat) 249(provide 'org-compat)
251 250
252;; arch-tag: a0a0579f-e68c-4bdf-9e55-93768b846bbe 251;; arch-tag: a0a0579f-e68c-4bdf-9e55-93768b846bbe
252
253;;; org-compat.el ends here 253;;; org-compat.el ends here
diff --git a/lisp/org/org-exp.el b/lisp/org/org-exp.el
index c401226a83d..0ebcdbbfb89 100644
--- a/lisp/org/org-exp.el
+++ b/lisp/org/org-exp.el
@@ -5,7 +5,7 @@
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;;
@@ -33,6 +33,8 @@
33(declare-function org-export-latex-preprocess "org-export-latex" ()) 33(declare-function org-export-latex-preprocess "org-export-latex" ())
34(declare-function org-agenda-skip "org-agenda" ()) 34(declare-function org-agenda-skip "org-agenda" ())
35(declare-function org-infojs-options-inbuffer-template "org-jsinfo" ()) 35(declare-function org-infojs-options-inbuffer-template "org-jsinfo" ())
36(declare-function htmlize-region "ext:htmlize" (beg end))
37(defvar htmlize-buffer-places) ; from htmlize.el
36 38
37(defgroup org-export nil 39(defgroup org-export nil
38 "Options for exporting org-listings." 40 "Options for exporting org-listings."
@@ -86,7 +88,9 @@ This option can also be set with the +OPTIONS line, e.g. \"-:nil\"."
86 ("fr" "Auteur" "Date" "Table des mati\xe8res") 88 ("fr" "Auteur" "Date" "Table des mati\xe8res")
87 ("it" "Autore" "Data" "Indice") 89 ("it" "Autore" "Data" "Indice")
88 ("nl" "Auteur" "Datum" "Inhoudsopgave") 90 ("nl" "Auteur" "Datum" "Inhoudsopgave")
89 ("nn" "Forfattar" "Dato" "Innhold") ;; nn = Norsk (nynorsk) 91 ("no" "Forfatter" "Dato" "Innhold")
92 ("nb" "Forfatter" "Dato" "Innhold") ;; nb = Norsk (bokm.l)
93 ("nn" "Forfattar" "Dato" "Innhald") ;; nn = Norsk (nynorsk)
90 ("sv" "F\xf6rfattarens" "Datum" "Inneh\xe5ll")) 94 ("sv" "F\xf6rfattarens" "Datum" "Inneh\xe5ll"))
91 "Terms used in export text, translated to different languages. 95 "Terms used in export text, translated to different languages.
92Use the variable `org-export-default-language' to set the language, 96Use the variable `org-export-default-language' to set the language,
@@ -105,7 +109,7 @@ This should have an association in `org-export-language-setup'."
105 :group 'org-export-general 109 :group 'org-export-general
106 :type 'string) 110 :type 'string)
107 111
108(defcustom org-export-skip-text-before-1st-heading t 112(defcustom org-export-skip-text-before-1st-heading nil
109 "Non-nil means, skip all text before the first headline when exporting. 113 "Non-nil means, skip all text before the first headline when exporting.
110When nil, that text is exported as well." 114When nil, that text is exported as well."
111 :group 'org-export-general 115 :group 'org-export-general
@@ -128,6 +132,26 @@ This option can also be set with the +OPTIONS line, e.g. \"num:t\"."
128 :group 'org-export-general 132 :group 'org-export-general
129 :type 'boolean) 133 :type 'boolean)
130 134
135(defcustom org-export-section-number-format '((("1" ".")) . "")
136 "Format of section numbers for export.
137The variable has two components.
1381. A list of lists, each indicating a counter type and a separator.
139 The counter type can be any of \"1\", \"A\", \"a\", \"I\", or \"a\".
140 It causes causes numeric, alphabetic, or roman counters, respectively.
141 The separator is only used if another counter for a subsection is being
142 added.
143 If there are more numbered section levels than entries in this lists,
144 then the last entry will be reused.
1452. A terminator string that will be added after the entire
146 section number."
147 :group 'org-export-general
148 :type '(cons
149 (repeat
150 (list
151 (string :tag "Counter Type")
152 (string :tag "Separator ")))
153 (string :tag "Terminator")))
154
131(defcustom org-export-with-toc t 155(defcustom org-export-with-toc t
132 "Non-nil means, create a table of contents in exported files. 156 "Non-nil means, create a table of contents in exported files.
133The TOC contains headlines with levels up to`org-export-headline-levels'. 157The TOC contains headlines with levels up to`org-export-headline-levels'.
@@ -227,6 +251,10 @@ drawer names to export."
227 (repeat :tag "Selected drawers" 251 (repeat :tag "Selected drawers"
228 (string :tag "Drawer name")))) 252 (string :tag "Drawer name"))))
229 253
254(defvar org-export-preprocess-hook nil
255 "Hook for preprocessing an export buffer.
256Pretty much the first thing when exporting is running this hook.")
257
230(defgroup org-export-translation nil 258(defgroup org-export-translation nil
231 "Options for translating special ascii sequences for the export backends." 259 "Options for translating special ascii sequences for the export backends."
232 :tag "Org Export Translation" 260 :tag "Org Export Translation"
@@ -456,12 +484,14 @@ Org-mode file."
456 background-color: #F3F5F7; 484 background-color: #F3F5F7;
457 padding: 5pt; 485 padding: 5pt;
458 font-family: courier, monospace; 486 font-family: courier, monospace;
487 font-size: 90%;
459 } 488 }
460 table { border-collapse: collapse; } 489 table { border-collapse: collapse; }
461 td, th { 490 td, th {
462 vertical-align: top; 491 vertical-align: top;
463 <!--border: 1pt solid #ADB9CC;--> 492 <!--border: 1pt solid #ADB9CC;-->
464 } 493 }
494 dt { font-weight: bold; }
465</style>" 495</style>"
466 "The default style specification for exported HTML files. 496 "The default style specification for exported HTML files.
467Since there are different ways of setting style information, this variable 497Since there are different ways of setting style information, this variable
@@ -564,6 +594,25 @@ to a file."
564 :group 'org-export-html 594 :group 'org-export-html
565 :type 'string) 595 :type 'string)
566 596
597(defgroup org-export-htmlize nil
598 "Options for processing examples with htmlize.el."
599 :tag "Org Export Htmlize"
600 :group 'org-export-html)
601
602(defcustom org-export-htmlize-output-type 'inline-css
603 "Output type to be used by htmlize when formatting code snippets.
604Normally this is `inline-css', but if you have defined to appropriate
605classes in your css style file, setting this to `css' means that the
606fontification will use the class names.
607See also the function `org-export-htmlize-generate-css'."
608 :group 'org-export-htmlize
609 :type '(choice (const css) (const inline-css)))
610
611(defcustom org-export-htmlize-css-font-prefix "org-"
612 "The prefix for CSS class names for htmlize font specifications."
613 :group 'org-export-htmlize
614 :type 'string)
615
567(defgroup org-export-icalendar nil 616(defgroup org-export-icalendar nil
568 "Options specific for iCalendar export of Org-mode files." 617 "Options specific for iCalendar export of Org-mode files."
569 :tag "Org Export iCalendar" 618 :tag "Org Export iCalendar"
@@ -606,6 +655,20 @@ The text will be inserted into the DESCRIPTION field."
606 :group 'org-export-icalendar 655 :group 'org-export-icalendar
607 :type 'string) 656 :type 'string)
608 657
658(defcustom org-icalendar-store-UID nil
659 "Non-nil means, store any created UIDs in properties.
660The iCalendar standard requires that all entries have a unique identifyer.
661Org will create these identifiers as needed. When this variable is non-nil,
662the created UIDs will be stored in the ID property of the entry. Then the
663next time this entry is exported, it will be exported with the same UID,
664superceeding the previous form of it. This is essential for
665synchronization services.
666This variable is not turned on by default because we want to avoid creating
667a property drawer in every entry if people are only playing with this feature,
668or if they are only using it locally."
669 :group 'org-export-icalendar
670 :type 'boolean)
671
609;;;; Exporting 672;;;; Exporting
610 673
611;;; Variables, constants, and parameter plists 674;;; Variables, constants, and parameter plists
@@ -630,6 +693,7 @@ The text will be inserted into the DESCRIPTION field."
630 (:customtime . org-display-custom-times) 693 (:customtime . org-display-custom-times)
631 (:headline-levels . org-export-headline-levels) 694 (:headline-levels . org-export-headline-levels)
632 (:section-numbers . org-export-with-section-numbers) 695 (:section-numbers . org-export-with-section-numbers)
696 (:section-number-format . org-export-section-number-format)
633 (:table-of-contents . org-export-with-toc) 697 (:table-of-contents . org-export-with-toc)
634 (:preserve-breaks . org-export-preserve-breaks) 698 (:preserve-breaks . org-export-preserve-breaks)
635 (:archived-trees . org-export-with-archived-trees) 699 (:archived-trees . org-export-with-archived-trees)
@@ -694,16 +758,21 @@ modified) list.")
694 (save-excursion 758 (save-excursion
695 (save-restriction 759 (save-restriction
696 (widen) 760 (widen)
697 (goto-char 0) 761 (goto-char (point-min))
698 (let ((re (org-make-options-regexp 762 (let ((re (org-make-options-regexp
699 (append 763 (append
700 '("TITLE" "AUTHOR" "DATE" "EMAIL" "TEXT" "OPTIONS" "LANGUAGE" 764 '("TITLE" "AUTHOR" "DATE" "EMAIL" "TEXT" "OPTIONS" "LANGUAGE"
701 "LINK_UP" "LINK_HOME") 765 "LINK_UP" "LINK_HOME" "SETUPFILE")
702 (mapcar 'car org-export-inbuffer-options-extra)))) 766 (mapcar 'car org-export-inbuffer-options-extra))))
703 p key val text options js-up js-main js-css js-opt a pr) 767 p key val text options js-up js-main js-css js-opt a pr
704 (while (re-search-forward re nil t) 768 ext-setup-or-nil setup-contents (start 0))
705 (setq key (org-match-string-no-properties 1) 769 (while (or (and ext-setup-or-nil
706 val (org-match-string-no-properties 2)) 770 (string-match re ext-setup-or-nil start)
771 (setq start (match-end 0)))
772 (and (setq ext-setup-or-nil nil start 0)
773 (re-search-forward re nil t)))
774 (setq key (upcase (org-match-string-no-properties 1 ext-setup-or-nil))
775 val (org-match-string-no-properties 2 ext-setup-or-nil))
707 (cond 776 (cond
708 ((setq a (assoc key org-export-inbuffer-options-extra)) 777 ((setq a (assoc key org-export-inbuffer-options-extra))
709 (setq pr (nth 1 a)) 778 (setq pr (nth 1 a))
@@ -716,41 +785,75 @@ modified) list.")
716 ((string-equal key "TEXT") 785 ((string-equal key "TEXT")
717 (setq text (if text (concat text "\n" val) val))) 786 (setq text (if text (concat text "\n" val) val)))
718 ((string-equal key "OPTIONS") 787 ((string-equal key "OPTIONS")
719 (setq options (concat options " " val))) 788 (setq options (concat val " " options)))
720 ((string-equal key "LINK_UP") 789 ((string-equal key "LINK_UP")
721 (setq p (plist-put p :link-up val))) 790 (setq p (plist-put p :link-up val)))
722 ((string-equal key "LINK_HOME") 791 ((string-equal key "LINK_HOME")
723 (setq p (plist-put p :link-home val))))) 792 (setq p (plist-put p :link-home val)))
793 ((equal key "SETUPFILE")
794 (setq setup-contents (org-file-contents
795 (expand-file-name
796 (org-remove-double-quotes
797 (org-trim val)))
798 'noerror))
799 (if (not ext-setup-or-nil)
800 (setq ext-setup-or-nil setup-contents start 0)
801 (setq ext-setup-or-nil
802 (concat (substring ext-setup-or-nil 0 start)
803 "\n" setup-contents "\n"
804 (substring ext-setup-or-nil start)))))))
724 (setq p (plist-put p :text text)) 805 (setq p (plist-put p :text text))
725 (when options 806 (when options
726 (let ((op '(("H" . :headline-levels) 807 (setq p (org-export-add-options-to-plist p options)))
727 ("num" . :section-numbers)
728 ("toc" . :table-of-contents)
729 ("\\n" . :preserve-breaks)
730 ("@" . :expand-quoted-html)
731 (":" . :fixed-width)
732 ("|" . :tables)
733 ("^" . :sub-superscript)
734 ("-" . :special-strings)
735 ("f" . :footnotes)
736 ("d" . :drawers)
737 ("tags" . :tags)
738 ("*" . :emphasize)
739 ("TeX" . :TeX-macros)
740 ("LaTeX" . :LaTeX-fragments)
741 ("skip" . :skip-before-1st-heading)
742 ("author" . :author-info)
743 ("timestamp" . :time-stamp-file)))
744 o)
745 (while (setq o (pop op))
746 (if (string-match (concat (regexp-quote (car o))
747 ":\\([^ \t\n\r;,.]*\\)")
748 options)
749 (setq p (plist-put p (cdr o)
750 (car (read-from-string
751 (match-string 1 options)))))))))
752 p)))) 808 p))))
753 809
810(defun org-export-add-options-to-plist (p options)
811 "Parse an OPTONS line and set values in the property list P."
812 (let (o)
813 (when options
814 (let ((op '(("H" . :headline-levels)
815 ("num" . :section-numbers)
816 ("toc" . :table-of-contents)
817 ("\\n" . :preserve-breaks)
818 ("@" . :expand-quoted-html)
819 (":" . :fixed-width)
820 ("|" . :tables)
821 ("^" . :sub-superscript)
822 ("-" . :special-strings)
823 ("f" . :footnotes)
824 ("d" . :drawers)
825 ("tags" . :tags)
826 ("*" . :emphasize)
827 ("TeX" . :TeX-macros)
828 ("LaTeX" . :LaTeX-fragments)
829 ("skip" . :skip-before-1st-heading)
830 ("author" . :author-info)
831 ("timestamp" . :time-stamp-file)))
832 o)
833 (while (setq o (pop op))
834 (if (string-match (concat (regexp-quote (car o))
835 ":\\([^ \t\n\r;,.]*\\)")
836 options)
837 (setq p (plist-put p (cdr o)
838 (car (read-from-string
839 (match-string 1 options))))))))))
840 p)
841
842(defun org-export-add-subtree-options (p pos)
843 "Add options in subtree at position POS to property list P."
844 (save-excursion
845 (goto-char pos)
846 (when (org-at-heading-p)
847 (let (a)
848 ;; This is actually read in `org-export-get-title-from-subtree'
849 ;; (when (setq a (org-entry-get pos "EXPORT_TITLE"))
850 ;; (setq p (plist-put p :title a)))
851 (when (setq a (org-entry-get pos "EXPORT_TEXT"))
852 (setq p (plist-put p :text a)))
853 (when (setq a (org-entry-get pos "EXPORT_OPTIONS"))
854 (setq p (org-export-add-options-to-plist p a)))))
855 p))
856
754(defun org-export-directory (type plist) 857(defun org-export-directory (type plist)
755 (let* ((val (plist-get plist :publishing-directory)) 858 (let* ((val (plist-get plist :publishing-directory))
756 (dir (if (listp val) 859 (dir (if (listp val)
@@ -758,6 +861,12 @@ modified) list.")
758 val))) 861 val)))
759 dir)) 862 dir))
760 863
864(defun org-export-process-option-filters (plist)
865 (let ((functions org-export-options-filters) f)
866 (while (setq f (pop functions))
867 (setq plist (funcall f plist))))
868 plist)
869
761;;;###autoload 870;;;###autoload
762(defun org-export (&optional arg) 871(defun org-export (&optional arg)
763 "Export dispatcher for Org-mode. 872 "Export dispatcher for Org-mode.
@@ -1151,51 +1260,41 @@ to export. It then creates a temporary buffer where it does its job.
1151The result is then again returned as a string, and the exporter works 1260The result is then again returned as a string, and the exporter works
1152on this string to produce the exported version." 1261on this string to produce the exported version."
1153 (interactive) 1262 (interactive)
1154 (let* ((re-radio (and org-target-link-regexp 1263 (let* ((htmlp (plist-get parameters :for-html))
1155 (concat "\\([^<]\\)\\(" org-target-link-regexp "\\)")))
1156 (re-plain-link (concat "\\([^[<]\\)" org-plain-link-re))
1157 (re-angle-link (concat "\\([^[]\\)" org-angle-link-re))
1158 (re-archive (concat ":" org-archive-tag ":"))
1159 (re-quote (concat "^\\*+[ \t]+" org-quote-string "\\>"))
1160 (re-commented (concat "^\\*+[ \t]+" org-comment-string "\\>"))
1161 (htmlp (plist-get parameters :for-html))
1162 (asciip (plist-get parameters :for-ascii)) 1264 (asciip (plist-get parameters :for-ascii))
1163 (latexp (plist-get parameters :for-LaTeX)) 1265 (latexp (plist-get parameters :for-LaTeX))
1164 (commentsp (plist-get parameters :comments))
1165 (archived-trees (plist-get parameters :archived-trees)) 1266 (archived-trees (plist-get parameters :archived-trees))
1166 (inhibit-read-only t) 1267 (inhibit-read-only t)
1167 (drawers org-drawers) 1268 (drawers org-drawers)
1168 (exp-drawers (plist-get parameters :drawers))
1169 (outline-regexp "\\*+ ") 1269 (outline-regexp "\\*+ ")
1170 target-alist tmp target level 1270 target-alist rtn)
1171 a b xx rtn p)
1172 1271
1173 (with-current-buffer (get-buffer-create " org-mode-tmp") 1272 (with-current-buffer (get-buffer-create " org-mode-tmp")
1174 (erase-buffer) 1273 (erase-buffer)
1175 (insert string) 1274 (insert string)
1275 (setq case-fold-search t)
1276 ;; Call the hook
1277 (run-hooks 'org-export-preprocess-hook)
1278
1176 ;; Remove license-to-kill stuff 1279 ;; Remove license-to-kill stuff
1177 ;; The caller markes some stuff fo killing, stuff that has been 1280 ;; The caller markes some stuff fo killing, stuff that has been
1178 ;; used to create the page title, for example. 1281 ;; used to create the page title, for example.
1179 (while (setq p (text-property-any (point-min) (point-max) 1282 (org-export-kill-licensed-text)
1180 :org-license-to-kill t)) 1283
1181 (delete-region p (next-single-property-change p :org-license-to-kill)))
1182
1183 (let ((org-inhibit-startup t)) (org-mode)) 1284 (let ((org-inhibit-startup t)) (org-mode))
1285 (setq case-fold-search t)
1184 (untabify (point-min) (point-max)) 1286 (untabify (point-min) (point-max))
1185 1287
1288 ;; Handle incude files
1289 (org-export-handle-include-files)
1290
1291 ;; Handle source code snippets
1292 (org-export-replace-src-segments)
1293
1186 ;; Get rid of drawers 1294 ;; Get rid of drawers
1187 (unless (eq t exp-drawers) 1295 (org-export-remove-or-extract-drawers drawers
1188 (goto-char (point-min)) 1296 (plist-get parameters :drawers))
1189 (let ((re (concat "^[ \t]*:\\(" 1297
1190 (mapconcat
1191 'identity
1192 (org-delete-all exp-drawers
1193 (copy-sequence drawers))
1194 "\\|")
1195 "\\):[ \t]*\n\\([^@]*?\n\\)?[ \t]*:END:[ \t]*\n")))
1196 (while (re-search-forward re nil t)
1197 (replace-match ""))))
1198
1199 ;; Get the correct stuff before the first headline 1298 ;; Get the correct stuff before the first headline
1200 (when (plist-get parameters :skip-before-1st-heading) 1299 (when (plist-get parameters :skip-before-1st-heading)
1201 (goto-char (point-min)) 1300 (goto-char (point-min))
@@ -1206,247 +1305,390 @@ on this string to produce the exported version."
1206 (when (plist-get parameters :add-text) 1305 (when (plist-get parameters :add-text)
1207 (goto-char (point-min)) 1306 (goto-char (point-min))
1208 (insert (plist-get parameters :add-text) "\n")) 1307 (insert (plist-get parameters :add-text) "\n"))
1209 1308
1210 ;; Get rid of archived trees 1309 ;; Get rid of archived trees
1211 (when (not (eq archived-trees t)) 1310 (org-export-remove-archived-trees archived-trees)
1212 (goto-char (point-min)) 1311
1213 (while (re-search-forward re-archive nil t)
1214 (if (not (org-on-heading-p t))
1215 (org-end-of-subtree t)
1216 (beginning-of-line 1)
1217 (setq a (if archived-trees
1218 (1+ (point-at-eol)) (point))
1219 b (org-end-of-subtree t))
1220 (if (> b a) (delete-region a b)))))
1221
1222 ;; Find all headings and compute the targets for them 1312 ;; Find all headings and compute the targets for them
1223 (goto-char (point-min)) 1313 (setq target-alist (org-export-define-heading-targets target-alist))
1224 (org-init-section-numbers)
1225 (let ((re (concat "^" org-outline-regexp)))
1226 (while (re-search-forward re nil t)
1227 (setq level (org-reduced-level
1228 (save-excursion (goto-char (point-at-bol))
1229 (org-outline-level))))
1230 (setq target (org-solidify-link-text
1231 (format "sec-%s" (org-section-number level))))
1232 (push (cons target target) target-alist)
1233 (add-text-properties
1234 (point-at-bol) (point-at-eol)
1235 (list 'target target))))
1236 1314
1237 ;; Find targets in comments and move them out of comments, 1315 ;; Find targets in comments and move them out of comments,
1238 ;; but mark them as targets that should be invisible 1316 ;; but mark them as targets that should be invisible
1239 (goto-char (point-min)) 1317 (setq target-alist (org-export-handle-invisible-targets target-alist))
1240 (while (re-search-forward "^#.*?\\(<<<?\\([^>\r\n]+\\)>>>?\\).*" nil t) 1318
1241 ;; Check if the line before or after is a headline with a target 1319 ;; Protect examples
1242 (if (setq target (or (get-text-property (point-at-bol 0) 'target) 1320 (org-export-protect-examples)
1243 (get-text-property (point-at-bol 2) 'target)))
1244 (progn
1245 ;; use the existing target in a neighboring line
1246 (setq tmp (match-string 2))
1247 (replace-match "")
1248 (and (looking-at "\n") (delete-char 1))
1249 (push (cons (org-solidify-link-text tmp) target)
1250 target-alist))
1251 ;; Make an invisible target
1252 (replace-match "\\1(INVISIBLE)")))
1253 1321
1254 ;; Protect backend specific stuff, throw away the others. 1322 ;; Protect backend specific stuff, throw away the others.
1255 (let ((formatters 1323 (org-export-select-backend-specific-text
1256 `((,htmlp "HTML" "BEGIN_HTML" "END_HTML") 1324 (cond (htmlp 'html) (latexp 'latex) (asciip 'ascii)))
1257 (,asciip "ASCII" "BEGIN_ASCII" "END_ASCII")
1258 (,latexp "LaTeX" "BEGIN_LaTeX" "END_LaTeX")))
1259 fmt)
1260 (goto-char (point-min))
1261 (while (re-search-forward "^#\\+BEGIN_EXAMPLE[ \t]*\n" nil t)
1262 (goto-char (match-end 0))
1263 (while (not (looking-at "#\\+END_EXAMPLE"))
1264 (insert ": ")
1265 (beginning-of-line 2)))
1266 (goto-char (point-min))
1267 (while (re-search-forward "^[ \t]*:.*\\(\n[ \t]*:.*\\)*" nil t)
1268 (add-text-properties (match-beginning 0) (match-end 0)
1269 '(org-protected t)))
1270 (while formatters
1271 (setq fmt (pop formatters))
1272 (when (car fmt)
1273 (goto-char (point-min))
1274 (while (re-search-forward (concat "^#\\+" (cadr fmt)
1275 ":[ \t]*\\(.*\\)") nil t)
1276 (replace-match "\\1" t)
1277 (add-text-properties
1278 (point-at-bol) (min (1+ (point-at-eol)) (point-max))
1279 '(org-protected t))))
1280 (goto-char (point-min))
1281 (while (re-search-forward
1282 (concat "^#\\+"
1283 (caddr fmt) "\\>.*\\(\\(\n.*\\)*?\n\\)#\\+"
1284 (cadddr fmt) "\\>.*\n?") nil t)
1285 (if (car fmt)
1286 (add-text-properties (match-beginning 1) (1+ (match-end 1))
1287 '(org-protected t))
1288 (delete-region (match-beginning 0) (match-end 0))))))
1289 1325
1290 ;; Protect quoted subtrees 1326 ;; Protect quoted subtrees
1291 (goto-char (point-min)) 1327 (org-export-protect-quoted-subtrees)
1292 (while (re-search-forward re-quote nil t)
1293 (goto-char (match-beginning 0))
1294 (end-of-line 1)
1295 (add-text-properties (point) (org-end-of-subtree t)
1296 '(org-protected t)))
1297 1328
1298 ;; Protect verbatim elements 1329 ;; Protect verbatim elements
1299 (goto-char (point-min)) 1330 (org-export-protect-verbatim)
1300 (while (re-search-forward org-verbatim-re nil t)
1301 (add-text-properties (match-beginning 4) (match-end 4)
1302 '(org-protected t))
1303 (goto-char (1+ (match-end 4))))
1304 1331
1305 ;; Remove subtrees that are commented 1332 ;; Blockquotes and verse
1306 (goto-char (point-min)) 1333 (org-export-mark-blockquote-and-verse)
1307 (while (re-search-forward re-commented nil t) 1334
1308 (goto-char (match-beginning 0)) 1335 ;; Remove comment environment and comment subtrees
1309 (delete-region (point) (org-end-of-subtree t))) 1336 (org-export-remove-comment-blocks-and-subtrees)
1310 1337
1311 ;; Remove special table lines 1338 ;; Remove special table lines
1312 (when org-export-table-remove-special-lines 1339 (when org-export-table-remove-special-lines
1313 (goto-char (point-min)) 1340 (org-export-remove-special-table-lines))
1314 (while (re-search-forward "^[ \t]*|" nil t)
1315 (beginning-of-line 1)
1316 (if (or (looking-at "[ \t]*| *[!_^] *|")
1317 (and (looking-at ".*?| *<[0-9]+> *|")
1318 (not (looking-at ".*?| *[^ <|]"))))
1319 (delete-region (max (point-min) (1- (point-at-bol)))
1320 (point-at-eol))
1321 (end-of-line 1))))
1322 1341
1323 ;; Specific LaTeX stuff 1342 ;; Specific LaTeX stuff
1324 (when latexp 1343 (when latexp
1325 (require 'org-export-latex nil) 1344 (require 'org-export-latex nil)
1326 (org-export-latex-preprocess)) 1345 (org-export-latex-preprocess))
1327 1346
1347 ;; Specific ASCII stuff
1328 (when asciip 1348 (when asciip
1329 (org-export-ascii-clean-string)) 1349 (org-export-ascii-preprocess))
1330 1350
1331 ;; Specific HTML stuff 1351 ;; Specific HTML stuff
1332 (when htmlp 1352 (when htmlp
1333 ;; Convert LaTeX fragments to images 1353 (org-export-html-preprocess parameters))
1334 (when (plist-get parameters :LaTeX-fragments)
1335 (org-format-latex
1336 (concat "ltxpng/" (file-name-sans-extension
1337 (file-name-nondirectory
1338 org-current-export-file)))
1339 org-current-export-dir nil "Creating LaTeX image %s"))
1340 (message "Exporting..."))
1341 1354
1342 ;; Remove or replace comments 1355 ;; Remove or replace comments
1343 (goto-char (point-min)) 1356 (org-export-handle-comments (plist-get parameters :comments))
1344 (while (re-search-forward "^#\\(.*\n?\\)" nil t)
1345 (if commentsp
1346 (progn (add-text-properties
1347 (match-beginning 0) (match-end 0) '(org-protected t))
1348 (replace-match (format commentsp (match-string 1)) t t))
1349 (replace-match "")))
1350 1357
1351 ;; Find matches for radio targets and turn them into internal links 1358 ;; Find matches for radio targets and turn them into internal links
1352 (goto-char (point-min)) 1359 (org-export-mark-radio-links)
1353 (when re-radio
1354 (while (re-search-forward re-radio nil t)
1355 (org-if-unprotected
1356 (replace-match "\\1[[\\2]]"))))
1357 1360
1358 ;; Find all links that contain a newline and put them into a single line 1361 ;; Find all links that contain a newline and put them into a single line
1359 (goto-char (point-min)) 1362 (org-export-concatenate-multiline-links)
1360 (while (re-search-forward "\\(\\(\\[\\|\\]\\)\\[[^]]*?\\)[ \t]*\n[ \t]*\\([^]]*\\]\\(\\[\\|\\]\\)\\)" nil t)
1361 (org-if-unprotected
1362 (replace-match "\\1 \\3")
1363 (goto-char (match-beginning 0))))
1364 1363
1365 ;; Find all internal links. If they have a fuzzy match (i.e. not 1364 ;; Find all internal links. If they have a fuzzy match (i.e. not
1366 ;; a *dedicated* target match, let the link point to the 1365 ;; a *dedicated* target match, let the link point to the
1367 ;; correspinding section. 1366 ;; corresponding section.
1368 1367 (org-export-target-internal-links target-alist)
1369 (goto-char (point-min))
1370 (while (re-search-forward org-bracket-link-regexp nil t)
1371 (org-if-unprotected
1372 (let* ((md (match-data))
1373 (desc (match-end 2))
1374 (link (org-link-unescape (match-string 1)))
1375 (slink (org-solidify-link-text link))
1376 found props pos
1377 (target
1378 (or (cdr (assoc slink target-alist))
1379 (save-excursion
1380 (unless (string-match org-link-types-re link)
1381 (setq found (condition-case nil (org-link-search link)
1382 (error nil)))
1383 (when (and found
1384 (or (org-on-heading-p)
1385 (not (eq found 'dedicated))))
1386 (or (get-text-property (point) 'target)
1387 (get-text-property
1388 (max (point-min)
1389 (1- (previous-single-property-change
1390 (point) 'target)))
1391 'target))))))))
1392 (when target
1393 (set-match-data md)
1394 (goto-char (match-beginning 1))
1395 (setq props (text-properties-at (point)))
1396 (delete-region (match-beginning 1) (match-end 1))
1397 (setq pos (point))
1398 (insert target)
1399 (unless desc (insert "][" link))
1400 (add-text-properties pos (point) props)))))
1401 1368
1402 ;; Normalize links: Convert angle and plain links into bracket links 1369 ;; Normalize links: Convert angle and plain links into bracket links
1403 ;; Expand link abbreviations 1370 ;; and expand link abbreviations
1404 (goto-char (point-min)) 1371 (org-export-normalize-links)
1405 (while (re-search-forward re-plain-link nil t)
1406 (goto-char (1- (match-end 0)))
1407 (org-if-unprotected
1408 (let* ((s (concat (match-string 1) "[[" (match-string 2)
1409 ":" (match-string 3) "]]")))
1410 ;; added 'org-link face to links
1411 (put-text-property 0 (length s) 'face 'org-link s)
1412 (replace-match s t t))))
1413 (goto-char (point-min))
1414 (while (re-search-forward re-angle-link nil t)
1415 (goto-char (1- (match-end 0)))
1416 (org-if-unprotected
1417 (let* ((s (concat (match-string 1) "[[" (match-string 2)
1418 ":" (match-string 3) "]]")))
1419 (put-text-property 0 (length s) 'face 'org-link s)
1420 (replace-match s t t))))
1421 (goto-char (point-min))
1422 (while (re-search-forward org-bracket-link-regexp nil t)
1423 (org-if-unprotected
1424 (let* ((s (concat "[[" (setq xx (save-match-data
1425 (org-link-expand-abbrev (match-string 1))))
1426 "]"
1427 (if (match-end 3)
1428 (match-string 2)
1429 (concat "[" xx "]"))
1430 "]")))
1431 (put-text-property 0 (length s) 'face 'org-link s)
1432 (replace-match s t t))))
1433 1372
1434 ;; Find multiline emphasis and put them into single line 1373 ;; Find multiline emphasis and put them into single line
1435 (when (plist-get parameters :emph-multiline) 1374 (when (plist-get parameters :emph-multiline)
1436 (goto-char (point-min)) 1375 (org-export-concatenate-multiline-emphasis))
1437 (while (re-search-forward org-emph-re nil t)
1438 (if (not (= (char-after (match-beginning 3))
1439 (char-after (match-beginning 4))))
1440 (org-if-unprotected
1441 (subst-char-in-region (match-beginning 0) (match-end 0)
1442 ?\n ?\ t)
1443 (goto-char (1- (match-end 0))))
1444 (goto-char (1+ (match-beginning 0))))))
1445 1376
1446 (setq rtn (buffer-string))) 1377 (setq rtn (buffer-string)))
1447 (kill-buffer " org-mode-tmp") 1378 (kill-buffer " org-mode-tmp")
1448 rtn)) 1379 rtn))
1449 1380
1381(defun org-export-kill-licensed-text ()
1382 "Remove all text that is marked with a :org-license-to-kill property."
1383 (let (p)
1384 (while (setq p (text-property-any (point-min) (point-max)
1385 :org-license-to-kill t))
1386 (delete-region p (next-single-property-change p :org-license-to-kill)))))
1387
1388(defun org-export-define-heading-targets (target-alist)
1389 "Find all headings and define the targets for them.
1390The new targets are added to TARGET-ALIST, which is also returned."
1391 (goto-char (point-min))
1392 (org-init-section-numbers)
1393 (let ((re (concat "^" org-outline-regexp))
1394 level target)
1395 (while (re-search-forward re nil t)
1396 (setq level (org-reduced-level
1397 (save-excursion (goto-char (point-at-bol))
1398 (org-outline-level))))
1399 (setq target (org-solidify-link-text
1400 (format "sec-%s" (org-section-number level))))
1401 (push (cons target target) target-alist)
1402 (add-text-properties
1403 (point-at-bol) (point-at-eol)
1404 (list 'target target))))
1405 target-alist)
1406
1407(defun org-export-handle-invisible-targets (target-alist)
1408 "Find targets in comments and move them out of comments.
1409Mark them as invisible targets."
1410 (let (target tmp)
1411 (goto-char (point-min))
1412 (while (re-search-forward "^#.*?\\(<<<?\\([^>\r\n]+\\)>>>?\\).*" nil t)
1413 ;; Check if the line before or after is a headline with a target
1414 (if (setq target (or (get-text-property (point-at-bol 0) 'target)
1415 (get-text-property (point-at-bol 2) 'target)))
1416 (progn
1417 ;; use the existing target in a neighboring line
1418 (setq tmp (match-string 2))
1419 (replace-match "")
1420 (and (looking-at "\n") (delete-char 1))
1421 (push (cons (org-solidify-link-text tmp) target)
1422 target-alist))
1423 ;; Make an invisible target
1424 (replace-match "\\1(INVISIBLE)"))))
1425 target-alist)
1426
1427(defun org-export-target-internal-links (target-alist)
1428 "Find all internal links and assign target to them.
1429If a link has a fuzzy match (i.e. not a *dedicated* target match),
1430let the link point to the corresponding section."
1431 (goto-char (point-min))
1432 (while (re-search-forward org-bracket-link-regexp nil t)
1433 (org-if-unprotected
1434 (let* ((md (match-data))
1435 (desc (match-end 2))
1436 (link (org-link-unescape (match-string 1)))
1437 (slink (org-solidify-link-text link))
1438 found props pos
1439 (target
1440 (or (cdr (assoc slink target-alist))
1441 (save-excursion
1442 (unless (string-match org-link-types-re link)
1443 (setq found (condition-case nil (org-link-search link)
1444 (error nil)))
1445 (when (and found
1446 (or (org-on-heading-p)
1447 (not (eq found 'dedicated))))
1448 (or (get-text-property (point) 'target)
1449 (get-text-property
1450 (max (point-min)
1451 (1- (previous-single-property-change
1452 (point) 'target)))
1453 'target))))))))
1454 (when target
1455 (set-match-data md)
1456 (goto-char (match-beginning 1))
1457 (setq props (text-properties-at (point)))
1458 (delete-region (match-beginning 1) (match-end 1))
1459 (setq pos (point))
1460 (insert target)
1461 (unless desc (insert "][" link))
1462 (add-text-properties pos (point) props))))))
1463
1464(defun org-export-remove-or-extract-drawers (all-drawers exp-drawers)
1465 "Remove drawers, or extract the content.
1466ALL-DRAWERS is a list of all drawer names valid in the current buffer.
1467EXP-DRAWERS can be t to keep all drawer contents, or a list of drawers
1468whose content to keep."
1469 (unless (eq t exp-drawers)
1470 (goto-char (point-min))
1471 (let ((re (concat "^[ \t]*:\\("
1472 (mapconcat
1473 'identity
1474 (org-delete-all exp-drawers
1475 (copy-sequence all-drawers))
1476 "\\|")
1477 "\\):[ \t]*\n\\([^@]*?\n\\)?[ \t]*:END:[ \t]*\n")))
1478 (while (re-search-forward re nil t)
1479 (replace-match "")))))
1480
1481(defun org-export-remove-archived-trees (export-archived-trees)
1482 "Remove archived trees.
1483When EXPORT-ARCHIVED-TREES is `headline;, only the headline will be exported.
1484When it is t, the entire archived tree will be exported.
1485When it is nil the entire tree including the headline will be removed
1486from the buffer."
1487 (let ((re-archive (concat ":" org-archive-tag ":"))
1488 a b)
1489 (when (not (eq export-archived-trees t))
1490 (goto-char (point-min))
1491 (while (re-search-forward re-archive nil t)
1492 (if (not (org-on-heading-p t))
1493 (org-end-of-subtree t)
1494 (beginning-of-line 1)
1495 (setq a (if export-archived-trees
1496 (1+ (point-at-eol)) (point))
1497 b (org-end-of-subtree t))
1498 (if (> b a) (delete-region a b)))))))
1499
1500(defun org-export-protect-quoted-subtrees ()
1501 "Mark quoted subtrees with the protection property."
1502 (let ((re-quote (concat "^\\*+[ \t]+" org-quote-string "\\>")))
1503 (goto-char (point-min))
1504 (while (re-search-forward re-quote nil t)
1505 (goto-char (match-beginning 0))
1506 (end-of-line 1)
1507 (add-text-properties (point) (org-end-of-subtree t)
1508 '(org-protected t)))))
1509
1510(defun org-export-protect-verbatim ()
1511 "Mark verbatim snippets with the protection property."
1512 (goto-char (point-min))
1513 (while (re-search-forward org-verbatim-re nil t)
1514 (add-text-properties (match-beginning 4) (match-end 4)
1515 '(org-protected t))
1516 (goto-char (1+ (match-end 4)))))
1517
1518(defun org-export-protect-examples ()
1519 "Protect code that should be exported as monospaced examples."
1520 (goto-char (point-min))
1521 (while (re-search-forward "^#\\+BEGIN_EXAMPLE[ \t]*\n" nil t)
1522 (goto-char (match-end 0))
1523 (while (and (not (looking-at "#\\+END_EXAMPLE")) (not (eobp)))
1524 (insert ": ")
1525 (beginning-of-line 2)))
1526 (goto-char (point-min))
1527 (while (re-search-forward "^[ \t]*:.*\\(\n[ \t]*:.*\\)*" nil t)
1528 (add-text-properties (match-beginning 0) (match-end 0)
1529 '(org-protected t))))
1530
1531(defun org-export-select-backend-specific-text (backend)
1532 (let ((formatters
1533 '((html "HTML" "BEGIN_HTML" "END_HTML")
1534 (ascii "ASCII" "BEGIN_ASCII" "END_ASCII")
1535 (latex "LaTeX" "BEGIN_LaTeX" "END_LaTeX")))
1536 fmt)
1537
1538 (while formatters
1539 (setq fmt (pop formatters))
1540 (when (eq (car fmt) backend)
1541 ;; This is selected code, put it into the file for real
1542 (goto-char (point-min))
1543 (while (re-search-forward (concat "^#\\+" (cadr fmt)
1544 ":[ \t]*\\(.*\\)") nil t)
1545 (replace-match "\\1" t)
1546 (add-text-properties
1547 (point-at-bol) (min (1+ (point-at-eol)) (point-max))
1548 '(org-protected t))))
1549 (goto-char (point-min))
1550 (while (re-search-forward
1551 (concat "^#\\+"
1552 (caddr fmt) "\\>.*\\(\\(\n.*\\)*?\n\\)#\\+"
1553 (cadddr fmt) "\\>.*\n?") nil t)
1554 (if (eq (car fmt) backend)
1555 ;; yes, keep this
1556 (add-text-properties (match-beginning 1) (1+ (match-end 1))
1557 '(org-protected t))
1558 ;; No, this is for a different backend, kill it
1559 (delete-region (match-beginning 0) (match-end 0)))))))
1560
1561(defun org-export-mark-blockquote-and-verse ()
1562 "Mark block quote and verse environments with special cookies.
1563These special cookies will later be interpreted by the backend."
1564 ;; Blockquotes
1565 (goto-char (point-min))
1566 (while (re-search-forward "^#\\+\\(begin\\|end\\)_\\(block\\)?quote\\>.*"
1567 nil t)
1568 (replace-match (if (equal (downcase (match-string 1)) "end")
1569 "ORG-BLOCKQUOTE-END" "ORG-BLOCKQUOTE-START")
1570 t t))
1571 ;; Verse
1572 (goto-char (point-min))
1573 (while (re-search-forward "^#\\+\\(begin\\|end\\)_verse\\>.*" nil t)
1574 (replace-match (if (equal (downcase (match-string 1)) "end")
1575 "ORG-VERSE-END" "ORG-VERSE-START")
1576 t t)))
1577
1578(defun org-export-remove-comment-blocks-and-subtrees ()
1579 "Remove the comment environment, and also commented subtrees."
1580 (let ((re-commented (concat "^\\*+[ \t]+" org-comment-string "\\>")))
1581 ;; Remove comment environment
1582 (goto-char (point-min))
1583 (while (re-search-forward
1584 "^#\\+BEGIN_COMMENT[ \t]*\n[^\000]*?^#\\+END_COMMENT\\>.*" nil t)
1585 (replace-match "" t t))
1586 ;; Remove subtrees that are commented
1587 (goto-char (point-min))
1588 (while (re-search-forward re-commented nil t)
1589 (goto-char (match-beginning 0))
1590 (delete-region (point) (org-end-of-subtree t)))))
1591
1592(defun org-export-handle-comments (commentsp)
1593 "Remove comments, or convert to backend-specific format.
1594COMMENTSP can be a format string for publishing comments.
1595When it is nil, all comments will be removed."
1596 (let ((re "^#\\(.*\n?\\)")
1597 pos)
1598 (goto-char (point-min))
1599 (while (or (looking-at re)
1600 (re-search-forward re nil t))
1601 (setq pos (match-beginning 0))
1602 (if commentsp
1603 (progn (add-text-properties
1604 (match-beginning 0) (match-end 0) '(org-protected t))
1605 (replace-match (format commentsp (match-string 1)) t t))
1606 (goto-char (1+ pos))
1607 (org-if-unprotected
1608 (replace-match "")
1609 (goto-char (max (point-min) (1- pos))))))))
1610
1611(defun org-export-mark-radio-links ()
1612 "Find all matches for radio targets and turn them into internal links."
1613 (let ((re-radio (and org-target-link-regexp
1614 (concat "\\([^<]\\)\\(" org-target-link-regexp "\\)"))))
1615 (goto-char (point-min))
1616 (when re-radio
1617 (while (re-search-forward re-radio nil t)
1618 (org-if-unprotected
1619 (replace-match "\\1[[\\2]]"))))))
1620
1621(defun org-export-remove-special-table-lines ()
1622 "Remove tables lines that are used for internal purposes."
1623 (goto-char (point-min))
1624 (while (re-search-forward "^[ \t]*|" nil t)
1625 (beginning-of-line 1)
1626 (if (or (looking-at "[ \t]*| *[!_^] *|")
1627 (and (looking-at ".*?| *<[0-9]+> *|")
1628 (not (looking-at ".*?| *[^ <|]"))))
1629 (delete-region (max (point-min) (1- (point-at-bol)))
1630 (point-at-eol))
1631 (end-of-line 1))))
1632
1633(defun org-export-normalize-links ()
1634 "Convert all links to bracket links, and expand link abbreviations."
1635 (let ((re-plain-link (concat "\\([^[<]\\)" org-plain-link-re))
1636 (re-angle-link (concat "\\([^[]\\)" org-angle-link-re)))
1637 (goto-char (point-min))
1638 (while (re-search-forward re-plain-link nil t)
1639 (goto-char (1- (match-end 0)))
1640 (org-if-unprotected
1641 (let* ((s (concat (match-string 1) "[[" (match-string 2)
1642 ":" (match-string 3) "]]")))
1643 ;; added 'org-link face to links
1644 (put-text-property 0 (length s) 'face 'org-link s)
1645 (replace-match s t t))))
1646 (goto-char (point-min))
1647 (while (re-search-forward re-angle-link nil t)
1648 (goto-char (1- (match-end 0)))
1649 (org-if-unprotected
1650 (let* ((s (concat (match-string 1) "[[" (match-string 2)
1651 ":" (match-string 3) "]]")))
1652 (put-text-property 0 (length s) 'face 'org-link s)
1653 (replace-match s t t))))
1654 (goto-char (point-min))
1655 (while (re-search-forward org-bracket-link-regexp nil t)
1656 (org-if-unprotected
1657 (let* ((xx (save-match-data
1658 (org-link-expand-abbrev (match-string 1))))
1659 (s (concat
1660 "[[" xx "]"
1661 (if (match-end 3)
1662 (match-string 2)
1663 (concat "[" xx "]"))
1664 "]")))
1665 (put-text-property 0 (length s) 'face 'org-link s)
1666 (replace-match s t t))))))
1667
1668(defun org-export-concatenate-multiline-links ()
1669 "Find multi-line links and put it all into a single line.
1670This is to make sure that the line-processing export backends
1671can work correctly."
1672 (goto-char (point-min))
1673 (while (re-search-forward "\\(\\(\\[\\|\\]\\)\\[[^]]*?\\)[ \t]*\n[ \t]*\\([^]]*\\]\\(\\[\\|\\]\\)\\)" nil t)
1674 (org-if-unprotected
1675 (replace-match "\\1 \\3")
1676 (goto-char (match-beginning 0)))))
1677
1678(defun org-export-concatenate-multiline-emphasis ()
1679 "Find multi-line emphasis and put it all into a single line.
1680This is to make sure that the line-processing export backends
1681can work correctly."
1682 (goto-char (point-min))
1683 (while (re-search-forward org-emph-re nil t)
1684 (if (not (= (char-after (match-beginning 3))
1685 (char-after (match-beginning 4))))
1686 (org-if-unprotected
1687 (subst-char-in-region (match-beginning 0) (match-end 0)
1688 ?\n ?\ t)
1689 (goto-char (1- (match-end 0))))
1690 (goto-char (1+ (match-beginning 0))))))
1691
1450(defun org-export-grab-title-from-buffer () 1692(defun org-export-grab-title-from-buffer ()
1451 "Get a title for the current document, from looking at the buffer." 1693 "Get a title for the current document, from looking at the buffer."
1452 (let ((inhibit-read-only t)) 1694 (let ((inhibit-read-only t))
@@ -1463,18 +1705,19 @@ on this string to produce the exported version."
1463 1705
1464(defun org-export-get-title-from-subtree () 1706(defun org-export-get-title-from-subtree ()
1465 "Return subtree title and exclude it from export." 1707 "Return subtree title and exclude it from export."
1466 (let (title (m (mark))) 1708 (let (title (m (mark)) (rbeg (region-beginning)) (rend (region-end)))
1467 (save-excursion 1709 (save-excursion
1468 (goto-char (region-beginning)) 1710 (goto-char rbeg)
1469 (when (and (org-at-heading-p) 1711 (when (and (org-at-heading-p)
1470 (>= (org-end-of-subtree t t) (region-end))) 1712 (>= (org-end-of-subtree t t) rend))
1471 ;; This is a subtree, we take the title from the first heading 1713 ;; This is a subtree, we take the title from the first heading
1472 (goto-char (region-beginning)) 1714 (goto-char rbeg)
1473 (looking-at org-todo-line-regexp) 1715 (looking-at org-todo-line-regexp)
1474 (setq title (match-string 3)) 1716 (setq title (match-string 3))
1475 (org-unmodified 1717 (org-unmodified
1476 (add-text-properties (point) (1+ (point-at-eol)) 1718 (add-text-properties (point) (1+ (point-at-eol))
1477 (list :org-license-to-kill t))))) 1719 (list :org-license-to-kill t)))
1720 (setq title (or (org-entry-get nil "EXPORT_TITLE") title))))
1478 title)) 1721 title))
1479 1722
1480(defun org-solidify-link-text (s &optional alist) 1723(defun org-solidify-link-text (s &optional alist)
@@ -1512,14 +1755,19 @@ on this string to produce the exported version."
1512 (if (string-match "\\`[A-Z]\\'" number-string) 1755 (if (string-match "\\`[A-Z]\\'" number-string)
1513 (aset org-section-numbers i 1756 (aset org-section-numbers i
1514 (- (string-to-char number-string) ?A -1)) 1757 (- (string-to-char number-string) ?A -1))
1515 (aset org-section-numbers i (string-to-number number-string))) 1758 (aset org-section-numbers i (string-to-number number-string)))
1516 (pop numbers)) 1759 (pop numbers))
1517 (setq i (1- i))))) 1760 (setq i (1- i)))))
1518 1761
1519(defun org-section-number (&optional level) 1762(defun org-section-number (&optional level)
1520 "Return a string with the current section number. 1763 "Return a string with the current section number.
1521When LEVEL is non-nil, increase section numbers on that level." 1764When LEVEL is non-nil, increase section numbers on that level."
1522 (let* ((depth (1- (length org-section-numbers))) idx n (string "")) 1765 (let* ((depth (1- (length org-section-numbers)))
1766 (string "")
1767 (fmts (car org-export-section-number-format))
1768 (term (cdr org-export-section-number-format))
1769 (sep "")
1770 ctype fmt idx n)
1523 (when level 1771 (when level
1524 (when (> level -1) 1772 (when (> level -1)
1525 (aset org-section-numbers 1773 (aset org-section-numbers
@@ -1531,16 +1779,153 @@ When LEVEL is non-nil, increase section numbers on that level."
1531 (setq idx (1+ idx)))) 1779 (setq idx (1+ idx))))
1532 (setq idx 0) 1780 (setq idx 0)
1533 (while (<= idx depth) 1781 (while (<= idx depth)
1534 (setq n (aref org-section-numbers idx)) 1782 (when (> (aref org-section-numbers idx) 0)
1535 (setq string (concat string (if (not (string= string "")) "." "") 1783 (setq fmt (or (pop fmts) fmt)
1536 (int-to-string n))) 1784 ctype (car fmt)
1785 n (aref org-section-numbers idx)
1786 string (if (> n 0)
1787 (concat string sep (org-number-to-counter n ctype))
1788 (concat string ".0"))
1789 sep (nth 1 fmt)))
1537 (setq idx (1+ idx))) 1790 (setq idx (1+ idx)))
1538 (save-match-data 1791 (save-match-data
1539 (if (string-match "\\`\\([@0]\\.\\)+" string) 1792 (if (string-match "\\`\\([@0]\\.\\)+" string)
1540 (setq string (replace-match "" t nil string))) 1793 (setq string (replace-match "" t nil string)))
1541 (if (string-match "\\(\\.0\\)+\\'" string) 1794 (if (string-match "\\(\\.0\\)+\\'" string)
1542 (setq string (replace-match "" t nil string)))) 1795 (setq string (replace-match "" t nil string))))
1543 string)) 1796 (concat string term)))
1797
1798(defun org-number-to-counter (n type)
1799 "Concert number N to a string counter, according to TYPE.
1800TYPE must be a string, any of:
1801 1 number
1802 A A,B,....
1803 a a,b,....
1804 I uppper case roman numeral
1805 i lower case roman numeral"
1806 (cond
1807 ((equal type "1") (number-to-string n))
1808 ((equal type "A") (char-to-string (+ ?A n -1)))
1809 ((equal type "a") (char-to-string (+ ?a n -1)))
1810 ((equal type "I") (org-number-to-roman n))
1811 ((equal type "i") (downcase (org-number-to-roman n)))
1812 (t (error "Invalid counter type `%s'" type))))
1813
1814(defun org-number-to-roman (n)
1815 "Convert integer N into a roman numeral."
1816 (let ((roman '((1000 . "M") (900 . "CM") (500 . "D") (400 . "CD")
1817 ( 100 . "C") ( 90 . "XC") ( 50 . "L") ( 40 . "XL")
1818 ( 10 . "X") ( 9 . "IX") ( 5 . "V") ( 4 . "IV")
1819 ( 1 . "I")))
1820 (res ""))
1821 (if (<= n 0)
1822 (number-to-string n)
1823 (while roman
1824 (if (>= n (caar roman))
1825 (setq n (- n (caar roman))
1826 res (concat res (cdar roman)))
1827 (pop roman)))
1828 res)))
1829
1830(org-number-to-roman 1961)
1831
1832
1833;;; Include files
1834
1835(defun org-export-handle-include-files ()
1836 "Include the contents of include files, with proper formatting."
1837 (let ((case-fold-search t)
1838 params file markup lang start end)
1839 (goto-char (point-min))
1840 (while (re-search-forward "^#\\+INCLUDE:?[ \t]+\\(.*\\)" nil t)
1841 (setq params (read (concat "(" (match-string 1) ")"))
1842 file (org-symname-or-string (pop params))
1843 markup (org-symname-or-string (pop params))
1844 lang (org-symname-or-string (pop params)))
1845 (delete-region (match-beginning 0) (match-end 0))
1846 (if (or (not file)
1847 (not (file-exists-p file))
1848 (not (file-readable-p file)))
1849 (insert (format "CANNOT INCLUDE FILE %s" file))
1850 (when markup
1851 (if (equal (downcase markup) "src")
1852 (setq start (format "#+begin_src %s\n" (or lang "fundamental"))
1853 end "#+end_src")
1854 (setq start (format "#+begin_%s\n" markup)
1855 end (format "#+end_%s" markup))))
1856 (insert (or start ""))
1857 (forward-char (nth 1 (insert-file-contents (expand-file-name file))))
1858 (or (bolp) (newline))
1859 (insert (or end ""))))))
1860
1861(defun org-symname-or-string (s)
1862 (if (symbolp s)
1863 (if s (symbol-name s) s)
1864 s))
1865
1866;;; Fontification of code
1867;; Currently only for th HTML backend, but who knows....
1868(defun org-export-replace-src-segments ()
1869 "Replace source code segments with special code for export."
1870 (let ((case-fold-search t)
1871 lang code trans)
1872 (goto-char (point-min))
1873 (while (re-search-forward
1874 "^#\\+BEGIN_SRC:?[ \t]+\\([^ \t\n]+\\)[ \t]*\n\\([^\000]+?\n\\)#\\+END_SRC.*"
1875 nil t)
1876 (setq lang (match-string 1) code (match-string 2)
1877 trans (org-export-format-source-code lang code))
1878 (replace-match trans t t))))
1879
1880(defvar htmlp) ;; dynamically scoped from org-exp.el
1881
1882(defun org-export-format-source-code (lang code)
1883 "Format CODE from language LANG and return it formatted for export.
1884Currently, this only does something for HTML export, for all other
1885backends, it converts the segment into an EXAMPLE segment."
1886 (save-match-data
1887 (cond
1888 (htmlp
1889 ;; We are exporting to HTML
1890 (condition-case nil (require 'htmlize) (nil t))
1891 (if (not (fboundp 'htmlize-region-for-paste))
1892 (progn
1893 ;; we do not have htmlize.el, or an old version of it
1894 (message
1895 "htmlize.el 1.34 or later is needed for source code formatting")
1896 (concat "#+BEGIN_EXAMPLE\n" code
1897 (if (string-match "\n\\'" code) "" "\n")
1898 "#+END_EXAMPLE\n"))
1899 ;; ok, we are good to go
1900 (let* ((mode (and lang (intern (concat lang "-mode"))))
1901 (org-inhibit-startup t)
1902 (org-startup-folded nil)
1903 (htmltext
1904 (with-temp-buffer
1905 (insert code)
1906 ;; Free up the protected stuff
1907 (goto-char (point-min))
1908 (while (re-search-forward "^," nil t)
1909 (replace-match "")
1910 (end-of-line 1))
1911 (if (functionp mode)
1912 (funcall mode)
1913 (fundamental-mode))
1914 (font-lock-fontify-buffer)
1915 (org-export-htmlize-region-for-paste
1916 (point-min) (point-max)))))
1917 (if (string-match "<pre\\([^>]*\\)>\n?" htmltext)
1918 (setq htmltext (replace-match "<pre class=\"src\">"
1919 t t htmltext)))
1920 (concat "#+BEGIN_HTML\n" htmltext "\n#+END_HTML\n"))))
1921 (t
1922 ;; This is not HTML, so just make it an example.
1923 (when (equal lang "org")
1924 (while (string-match "^," code)
1925 (setq code (replace-match "" t t code))))
1926 (concat "#+BEGIN_EXAMPLE\n" code
1927 (if (string-match "\n\\'" code) "" "\n")
1928 "#+END_EXAMPLE\n")))))
1544 1929
1545;;; ASCII export 1930;;; ASCII export
1546 1931
@@ -1560,12 +1945,17 @@ underlined headlines. The default is 3."
1560 (let* ((opt-plist (org-combine-plists (org-default-export-plist) 1945 (let* ((opt-plist (org-combine-plists (org-default-export-plist)
1561 (org-infile-export-plist))) 1946 (org-infile-export-plist)))
1562 (region-p (org-region-active-p)) 1947 (region-p (org-region-active-p))
1948 (rbeg (and region-p (region-beginning)))
1949 (rend (and region-p (region-end)))
1563 (subtree-p 1950 (subtree-p
1564 (when region-p 1951 (when region-p
1565 (save-excursion 1952 (save-excursion
1566 (goto-char (region-beginning)) 1953 (goto-char rbeg)
1567 (and (org-at-heading-p) 1954 (and (org-at-heading-p)
1568 (>= (org-end-of-subtree t t) (region-end)))))) 1955 (>= (org-end-of-subtree t t) rend)))))
1956 (opt-plist (if subtree-p
1957 (org-export-add-subtree-options opt-plist rbeg)
1958 opt-plist))
1569 (custom-times org-display-custom-times) 1959 (custom-times org-display-custom-times)
1570 (org-ascii-current-indentation '(0 . 0)) 1960 (org-ascii-current-indentation '(0 . 0))
1571 (level 0) line txt 1961 (level 0) line txt
@@ -1673,7 +2063,8 @@ underlined headlines. The default is 3."
1673 (if org-export-with-toc 2063 (if org-export-with-toc
1674 (progn 2064 (progn
1675 (push (concat (nth 3 lang-words) "\n") thetoc) 2065 (push (concat (nth 3 lang-words) "\n") thetoc)
1676 (push (concat (make-string (length (nth 3 lang-words)) ?=) "\n") thetoc) 2066 (push (concat (make-string (string-width (nth 3 lang-words)) ?=)
2067 "\n") thetoc)
1677 (mapc '(lambda (line) 2068 (mapc '(lambda (line)
1678 (if (string-match org-todo-line-regexp 2069 (if (string-match org-todo-line-regexp
1679 line) 2070 line)
@@ -1810,7 +2201,7 @@ underlined headlines. The default is 3."
1810 (goto-char beg))) 2201 (goto-char beg)))
1811 (goto-char (point-min)))) 2202 (goto-char (point-min))))
1812 2203
1813(defun org-export-ascii-clean-string () 2204(defun org-export-ascii-preprocess ()
1814 "Do extra work for ASCII export" 2205 "Do extra work for ASCII export"
1815 (goto-char (point-min)) 2206 (goto-char (point-min))
1816 (while (re-search-forward org-verbatim-re nil t) 2207 (while (re-search-forward org-verbatim-re nil t)
@@ -1847,7 +2238,7 @@ underlined headlines. The default is 3."
1847 2238
1848(defun org-insert-centered (s &optional underline) 2239(defun org-insert-centered (s &optional underline)
1849 "Insert the string S centered and underline it with character UNDERLINE." 2240 "Insert the string S centered and underline it with character UNDERLINE."
1850 (let ((ind (max (/ (- 80 (string-width s)) 2) 0))) 2241 (let ((ind (max (/ (- fill-column (string-width s)) 2) 0)))
1851 (insert (make-string ind ?\ ) s "\n") 2242 (insert (make-string ind ?\ ) s "\n")
1852 (if underline 2243 (if underline
1853 (insert (make-string ind ?\ ) 2244 (insert (make-string ind ?\ )
@@ -1984,6 +2375,7 @@ Does include HTML export options as well as TODO and CATEGORY stuff."
1984#+DRAWERS: %s 2375#+DRAWERS: %s
1985#+STARTUP: %s %s %s %s %s 2376#+STARTUP: %s %s %s %s %s
1986#+TAGS: %s 2377#+TAGS: %s
2378#+FILETAGS: %s
1987#+ARCHIVE: %s 2379#+ARCHIVE: %s
1988#+LINK: %s 2380#+LINK: %s
1989" 2381"
@@ -2006,7 +2398,7 @@ Does include HTML export options as well as TODO and CATEGORY stuff."
2006 org-export-skip-text-before-1st-heading 2398 org-export-skip-text-before-1st-heading
2007 org-export-with-drawers 2399 org-export-with-drawers
2008 org-export-with-tags 2400 org-export-with-tags
2009 (if (featurep 'org-infojs) (org-infojs-options-inbuffer-template) "") 2401 (if (featurep 'org-jsinfo) (org-infojs-options-inbuffer-template) "")
2010 org-export-html-link-up 2402 org-export-html-link-up
2011 org-export-html-link-home 2403 org-export-html-link-home
2012 (file-name-nondirectory buffer-file-name) 2404 (file-name-nondirectory buffer-file-name)
@@ -2029,10 +2421,21 @@ Does include HTML export options as well as TODO and CATEGORY stuff."
2029 ((cdr x) (format "%s(%c)" (car x) (cdr x))) 2421 ((cdr x) (format "%s(%c)" (car x) (cdr x)))
2030 (t (car x)))) 2422 (t (car x))))
2031 (or org-tag-alist (org-get-buffer-tags)) " ") "") 2423 (or org-tag-alist (org-get-buffer-tags)) " ") "")
2424 (mapconcat 'identity org-file-tags " ")
2032 org-archive-location 2425 org-archive-location
2033 "org file:~/org/%s.org" 2426 "org file:~/org/%s.org"
2034 )) 2427 ))
2035 2428
2429(defun org-export-html-preprocess (parameters)
2430 ;; Convert LaTeX fragments to images
2431 (when (plist-get parameters :LaTeX-fragments)
2432 (org-format-latex
2433 (concat "ltxpng/" (file-name-sans-extension
2434 (file-name-nondirectory
2435 org-current-export-file)))
2436 org-current-export-dir nil "Creating LaTeX image %s"))
2437 (message "Exporting..."))
2438
2036;;;###autoload 2439;;;###autoload
2037(defun org-insert-export-options-template () 2440(defun org-insert-export-options-template ()
2038 "Insert into the buffer a template with information for exporting." 2441 "Insert into the buffer a template with information for exporting."
@@ -2171,12 +2574,17 @@ PUB-DIR is set, use this as the publishing directory."
2171 valid thetoc have-headings first-heading-pos 2574 valid thetoc have-headings first-heading-pos
2172 (odd org-odd-levels-only) 2575 (odd org-odd-levels-only)
2173 (region-p (org-region-active-p)) 2576 (region-p (org-region-active-p))
2577 (rbeg (and region-p (region-beginning)))
2578 (rend (and region-p (region-end)))
2174 (subtree-p 2579 (subtree-p
2175 (when region-p 2580 (when region-p
2176 (save-excursion 2581 (save-excursion
2177 (goto-char (region-beginning)) 2582 (goto-char rbeg)
2178 (and (org-at-heading-p) 2583 (and (org-at-heading-p)
2179 (>= (org-end-of-subtree t t) (region-end)))))) 2584 (>= (org-end-of-subtree t t) rend)))))
2585 (opt-plist (if subtree-p
2586 (org-export-add-subtree-options opt-plist rbeg)
2587 opt-plist))
2180 ;; The following two are dynamically scoped into other 2588 ;; The following two are dynamically scoped into other
2181 ;; routines below. 2589 ;; routines below.
2182 (org-current-export-dir 2590 (org-current-export-dir
@@ -2222,7 +2630,7 @@ PUB-DIR is set, use this as the publishing directory."
2222 (inquote nil) 2630 (inquote nil)
2223 (infixed nil) 2631 (infixed nil)
2224 (in-local-list nil) 2632 (in-local-list nil)
2225 (local-list-num nil) 2633 (local-list-type nil)
2226 (local-list-indent nil) 2634 (local-list-indent nil)
2227 (llt org-plain-list-ordered-item-terminator) 2635 (llt org-plain-list-ordered-item-terminator)
2228 (email (plist-get opt-plist :email)) 2636 (email (plist-get opt-plist :email))
@@ -2262,9 +2670,9 @@ PUB-DIR is set, use this as the publishing directory."
2262 "[\r\n]")) 2670 "[\r\n]"))
2263 table-open type 2671 table-open type
2264 table-buffer table-orig-buffer 2672 table-buffer table-orig-buffer
2265 ind start-is-num starter didclose 2673 ind item-type starter didclose
2266 rpl path desc descp desc1 desc2 link 2674 rpl path desc descp desc1 desc2 link
2267 snumber fnc 2675 snumber fnc item-tag
2268 ) 2676 )
2269 2677
2270 (let ((inhibit-read-only t)) 2678 (let ((inhibit-read-only t))
@@ -2435,9 +2843,9 @@ lang=\"%s\" xml:lang=\"%s\">
2435 (setq infixed t) 2843 (setq infixed t)
2436 (insert "<pre>\n")) 2844 (insert "<pre>\n"))
2437 (insert (org-html-protect (match-string 1 line)) "\n") 2845 (insert (org-html-protect (match-string 1 line)) "\n")
2438 (when (and lines 2846 (when (or (not lines)
2439 (not (string-match "^[ \t]*\\(:.*\\)" 2847 (not (string-match "^[ \t]*\\(:.*\\)"
2440 (car lines)))) 2848 (car lines))))
2441 (setq infixed nil) 2849 (setq infixed nil)
2442 (insert "</pre>\n")) 2850 (insert "</pre>\n"))
2443 (throw 'nextline nil)) 2851 (throw 'nextline nil))
@@ -2451,6 +2859,7 @@ lang=\"%s\" xml:lang=\"%s\">
2451 (replace-match "\\2\n")) 2859 (replace-match "\\2\n"))
2452 (insert line "\n") 2860 (insert line "\n")
2453 (while (and lines 2861 (while (and lines
2862 (not (string-match "^[ \t]*:" (car lines)))
2454 (or (= (length (car lines)) 0) 2863 (or (= (length (car lines)) 0)
2455 (get-text-property 0 'org-protected (car lines)))) 2864 (get-text-property 0 'org-protected (car lines))))
2456 (insert (pop lines) "\n")) 2865 (insert (pop lines) "\n"))
@@ -2462,6 +2871,20 @@ lang=\"%s\" xml:lang=\"%s\">
2462 (insert "\n<hr/>\n") 2871 (insert "\n<hr/>\n")
2463 (throw 'nextline nil)) 2872 (throw 'nextline nil))
2464 2873
2874 ;; Blockquotes and verse
2875 (when (equal "ORG-BLOCKQUOTE-START" line)
2876 (insert "<blockquote>\n<p>\n")
2877 (throw 'nextline nil))
2878 (when (equal "ORG-BLOCKQUOTE-END" line)
2879 (insert "</p>\n</blockquote>\n")
2880 (throw 'nextline nil))
2881 (when (equal "ORG-VERSE-START" line)
2882 (insert "<verse>\n<p>\n")
2883 (throw 'nextline nil))
2884 (when (equal "ORG-VERSE-END" line)
2885 (insert "</p>\n</verse>\n")
2886 (throw 'nextline nil))
2887
2465 ;; make targets to anchors 2888 ;; make targets to anchors
2466 (while (string-match "<<<?\\([^<>]*\\)>>>?\\((INVISIBLE)\\)?[ \t]*\n?" line) 2889 (while (string-match "<<<?\\([^<>]*\\)>>>?\\((INVISIBLE)\\)?[ \t]*\n?" line)
2467 (cond 2890 (cond
@@ -2620,10 +3043,10 @@ lang=\"%s\" xml:lang=\"%s\">
2620 (setq head-count (+ head-count 1))) 3043 (setq head-count (+ head-count 1)))
2621 (when in-local-list 3044 (when in-local-list
2622 ;; Close any local lists before inserting a new header line 3045 ;; Close any local lists before inserting a new header line
2623 (while local-list-num 3046 (while local-list-type
2624 (org-close-li) 3047 (org-close-li (car local-list-type))
2625 (insert (if (car local-list-num) "</ol>\n" "</ul>")) 3048 (insert (format "</%sl>\n" (car local-list-type)))
2626 (pop local-list-num)) 3049 (pop local-list-type))
2627 (setq local-list-indent nil 3050 (setq local-list-indent nil
2628 in-local-list nil)) 3051 in-local-list nil))
2629 (setq first-heading-pos (or first-heading-pos (point))) 3052 (setq first-heading-pos (or first-heading-pos (point)))
@@ -2661,11 +3084,17 @@ lang=\"%s\" xml:lang=\"%s\">
2661 (t (error "Invalid value of `org-plain-list-ordered-item-terminator'"))) 3084 (t (error "Invalid value of `org-plain-list-ordered-item-terminator'")))
2662 line) 3085 line)
2663 (setq ind (org-get-string-indentation line) 3086 (setq ind (org-get-string-indentation line)
2664 start-is-num (match-beginning 4) 3087 item-type (if (match-beginning 4) "o" "u")
2665 starter (if (match-beginning 2) 3088 starter (if (match-beginning 2)
2666 (substring (match-string 2 line) 0 -1)) 3089 (substring (match-string 2 line) 0 -1))
2667 line (substring line (match-beginning 5))) 3090 line (substring line (match-beginning 5))
2668 (unless (string-match "[^ \t]" line) 3091 item-tag nil)
3092 (if (and starter (string-match "\\(.*?\\) ::[ \t]*" line))
3093 (setq item-type "d"
3094 item-tag (match-string 1 line)
3095 line (substring line (match-end 0))))
3096 (when (and (not (equal item-type "d"))
3097 (not (string-match "[^ \t]" line)))
2669 ;; empty line. Pretend indentation is large. 3098 ;; empty line. Pretend indentation is large.
2670 (setq ind (if org-empty-line-terminates-plain-lists 3099 (setq ind (if org-empty-line-terminates-plain-lists
2671 0 3100 0
@@ -2676,9 +3105,9 @@ lang=\"%s\" xml:lang=\"%s\">
2676 (not starter)) 3105 (not starter))
2677 (< ind (car local-list-indent)))) 3106 (< ind (car local-list-indent))))
2678 (setq didclose t) 3107 (setq didclose t)
2679 (org-close-li) 3108 (org-close-li (car local-list-type))
2680 (insert (if (car local-list-num) "</ol>\n" "</ul>")) 3109 (insert (format "</%sl>\n" (car local-list-type)))
2681 (pop local-list-num) (pop local-list-indent) 3110 (pop local-list-type) (pop local-list-indent)
2682 (setq in-local-list local-list-indent)) 3111 (setq in-local-list local-list-indent))
2683 (cond 3112 (cond
2684 ((and starter 3113 ((and starter
@@ -2686,14 +3115,21 @@ lang=\"%s\" xml:lang=\"%s\">
2686 (> ind (car local-list-indent)))) 3115 (> ind (car local-list-indent))))
2687 ;; Start new (level of) list 3116 ;; Start new (level of) list
2688 (org-close-par-maybe) 3117 (org-close-par-maybe)
2689 (insert (if start-is-num "<ol>\n<li>\n" "<ul>\n<li>\n")) 3118 (insert (cond
2690 (push start-is-num local-list-num) 3119 ((equal item-type "u") "<ul>\n<li>\n")
3120 ((equal item-type "o") "<ol>\n<li>\n")
3121 ((equal item-type "d")
3122 (format "<dl>\n<dt>%s</dt><dd>\n" item-tag))))
3123 (push item-type local-list-type)
2691 (push ind local-list-indent) 3124 (push ind local-list-indent)
2692 (setq in-local-list t)) 3125 (setq in-local-list t))
2693 (starter 3126 (starter
2694 ;; continue current list 3127 ;; continue current list
2695 (org-close-li) 3128 (org-close-li (car local-list-type))
2696 (insert "<li>\n")) 3129 (insert (cond
3130 ((equal (car local-list-type) "d")
3131 (format "<dt>%s</dt><dd>\n" (or item-tag "???")))
3132 (t "<li>\n"))))
2697 (didclose 3133 (didclose
2698 ;; we did close a list, normal text follows: need <p> 3134 ;; we did close a list, normal text follows: need <p>
2699 (org-open-par))) 3135 (org-open-par)))
@@ -2716,7 +3152,8 @@ lang=\"%s\" xml:lang=\"%s\">
2716 (org-close-par-maybe) 3152 (org-close-par-maybe)
2717 (let ((n (match-string 1 line))) 3153 (let ((n (match-string 1 line)))
2718 (setq line (replace-match 3154 (setq line (replace-match
2719 (format "<p class=\"footnote\"><sup><a class=\"footnum\" name=\"fn.%s\" href=\"#fnr.%s\">%s</a></sup>" n n n) t t line))))) 3155 (format "<p class=\"footnote\"><sup><a class=\"footnum\" name=\"fn.%s\" href=\"#fnr.%s\">%s</a></sup>" n n n) t t line))
3156 (setq line (concat line "</p>")))))
2720 3157
2721 ;; Check if the line break needs to be conserved 3158 ;; Check if the line break needs to be conserved
2722 (cond 3159 (cond
@@ -2731,10 +3168,10 @@ lang=\"%s\" xml:lang=\"%s\">
2731 (when inquote (insert "</pre>\n")) 3168 (when inquote (insert "</pre>\n"))
2732 (when in-local-list 3169 (when in-local-list
2733 ;; Close any local lists before inserting a new header line 3170 ;; Close any local lists before inserting a new header line
2734 (while local-list-num 3171 (while local-list-type
2735 (org-close-li) 3172 (org-close-li (car local-list-type))
2736 (insert (if (car local-list-num) "</ol>\n" "</ul>\n")) 3173 (insert (format "</%sl>\n" (car local-list-type)))
2737 (pop local-list-num)) 3174 (pop local-list-type))
2738 (setq local-list-indent nil 3175 (setq local-list-indent nil
2739 in-local-list nil)) 3176 in-local-list nil))
2740 (org-html-level-start 1 nil umax 3177 (org-html-level-start 1 nil umax
@@ -2762,6 +3199,8 @@ lang=\"%s\" xml:lang=\"%s\">
2762 (insert "<p class=\"date\"> " 3199 (insert "<p class=\"date\"> "
2763 (nth 2 lang-words) ": " 3200 (nth 2 lang-words) ": "
2764 date "</p>\n")) 3201 date "</p>\n"))
3202 (insert (format "<p>HTML generated by org-mode %s in emacs %s<\p>\n"
3203 org-version emacs-major-version))
2765 (insert "</div>")) 3204 (insert "</div>"))
2766 3205
2767 (if org-export-html-with-timestamp 3206 (if org-export-html-with-timestamp
@@ -3106,6 +3545,54 @@ But it has the disadvantage, that Org-mode's HTML conversions cannot be used."
3106 (setq r (concat r "@<br/>"))) 3545 (setq r (concat r "@<br/>")))
3107 r)))) 3546 r))))
3108 3547
3548(defun org-export-htmlize-region-for-paste (beg end)
3549 "Convert the region to HTML, using htmlize.el.
3550This is much like `htmlize-region-for-paste', only that it uses
3551the settings define in the org-... variables."
3552 (let* ((htmlize-output-type org-export-htmlize-output-type)
3553 (htmlize-css-name-prefix org-export-htmlize-css-font-prefix)
3554 (htmlbuf (htmlize-region beg end)))
3555 (unwind-protect
3556 (with-current-buffer htmlbuf
3557 (buffer-substring (plist-get htmlize-buffer-places 'content-start)
3558 (plist-get htmlize-buffer-places 'content-end)))
3559 (kill-buffer htmlbuf))))
3560
3561;;;###autoload
3562(defun org-export-htmlize-generate-css ()
3563 "Create the CSS for all font definitions in the current Emacs session.
3564Use this to create face definitions in your CSS style file that can then
3565be used by code snippets transformed by htmlize.
3566This command just produces a buffer that contains class definitions for all
3567faces used in the current Emacs session. You can copy and paste the ones you
3568need into your CSS file.
3569
3570If you then set `org-export-htmlize-output-type' to `css', calls to
3571the function `org-export-htmlize-region-for-paste' will produce code
3572that uses these same face definitions."
3573 (interactive)
3574 (require 'htmlize)
3575 (and (get-buffer "*html*") (kill-buffer "*html*"))
3576 (with-temp-buffer
3577 (let ((fl (face-list))
3578 (htmlize-css-name-prefix "org-")
3579 (htmlize-output-type 'css)
3580 f i)
3581 (while (setq f (pop fl)
3582 i (and f (face-attribute f :inherit)))
3583 (when (and (symbolp f) (or (not i) (not (listp i))))
3584 (insert (org-add-props (copy-sequence "1") nil 'face f))))
3585 (htmlize-region (point-min) (point-max))))
3586 (switch-to-buffer "*html*")
3587 (goto-char (point-min))
3588 (if (re-search-forward "<style" nil t)
3589 (delete-region (point-min) (match-beginning 0)))
3590 (if (re-search-forward "</style>" nil t)
3591 (delete-region (1+ (match-end 0)) (point-max)))
3592 (beginning-of-line 1)
3593 (if (looking-at " +") (replace-match ""))
3594 (goto-char (point-min)))
3595
3109(defun org-html-protect (s) 3596(defun org-html-protect (s)
3110 ;; convert & to &amp;, < to &lt; and > to &gt; 3597 ;; convert & to &amp;, < to &lt; and > to &gt;
3111 (let ((start 0)) 3598 (let ((start 0))
@@ -3280,10 +3767,10 @@ stacked delimiters is N. Escaping delimiters is not possible."
3280 (when org-par-open 3767 (when org-par-open
3281 (insert "</p>") 3768 (insert "</p>")
3282 (setq org-par-open nil))) 3769 (setq org-par-open nil)))
3283(defun org-close-li () 3770(defun org-close-li (&optional type)
3284 "Close <li> if necessary." 3771 "Close <li> if necessary."
3285 (org-close-par-maybe) 3772 (org-close-par-maybe)
3286 (insert "</li>\n")) 3773 (insert (if (equal type "d") "</dd>\n" "</li>\n")))
3287 3774
3288(defvar body-only) ; dynamically scoped into this. 3775(defvar body-only) ; dynamically scoped into this.
3289(defun org-html-level-start (level title umax with-toc head-count) 3776(defun org-html-level-start (level title umax with-toc head-count)
@@ -3417,12 +3904,17 @@ file and store it under the name `org-combined-agenda-icalendar-file'."
3417 (when (or (and combine (not files)) (not combine)) 3904 (when (or (and combine (not files)) (not combine))
3418 (org-finish-icalendar-file) 3905 (org-finish-icalendar-file)
3419 (set-buffer ical-buffer) 3906 (set-buffer ical-buffer)
3907 (run-hooks 'org-before-save-iCalendar-file-hook)
3420 (save-buffer) 3908 (save-buffer)
3421 (run-hooks 'org-after-save-iCalendar-file-hook) 3909 (run-hooks 'org-after-save-iCalendar-file-hook)
3422 (and (boundp 'org-wait) (numberp org-wait) (sit-for org-wait)) 3910 (and (boundp 'org-wait) (numberp org-wait) (sit-for org-wait))
3423 )))) 3911 ))))
3424 (org-release-buffers org-agenda-new-buffers)))) 3912 (org-release-buffers org-agenda-new-buffers))))
3425 3913
3914(defvar org-before-save-iCalendar-file-hook nil
3915 "Hook run before an iCalendar file has been saved.
3916This can be used to modify the result of the export.")
3917
3426(defvar org-after-save-iCalendar-file-hook nil 3918(defvar org-after-save-iCalendar-file-hook nil
3427 "Hook run after an iCalendar file has been saved. 3919 "Hook run after an iCalendar file has been saved.
3428The iCalendar buffer is still current when this hook is run. 3920The iCalendar buffer is still current when this hook is run.
@@ -3440,7 +3932,8 @@ When COMBINE is non nil, add the category to each line."
3440 (format-time-string (cdr org-time-stamp-formats) (current-time)) 3932 (format-time-string (cdr org-time-stamp-formats) (current-time))
3441 "DTSTART")) 3933 "DTSTART"))
3442 hd ts ts2 state status (inc t) pos b sexp rrule 3934 hd ts ts2 state status (inc t) pos b sexp rrule
3443 scheduledp deadlinep tmp pri category entry location summary desc 3935 scheduledp deadlinep prefix
3936 tmp pri category entry location summary desc uid
3444 (sexp-buffer (get-buffer-create "*ical-tmp*"))) 3937 (sexp-buffer (get-buffer-create "*ical-tmp*")))
3445 (org-refresh-category-properties) 3938 (org-refresh-category-properties)
3446 (save-excursion 3939 (save-excursion
@@ -3456,7 +3949,9 @@ When COMBINE is non nil, add the category to each line."
3456 (setq pos (match-beginning 0) 3949 (setq pos (match-beginning 0)
3457 ts (match-string 0) 3950 ts (match-string 0)
3458 inc t 3951 inc t
3459 hd (condition-case nil (org-get-heading) 3952 hd (condition-case nil
3953 (org-icalendar-cleanup-string
3954 (org-get-heading))
3460 (error (throw :skip nil))) 3955 (error (throw :skip nil)))
3461 summary (org-icalendar-cleanup-string 3956 summary (org-icalendar-cleanup-string
3462 (org-entry-get nil "SUMMARY")) 3957 (org-entry-get nil "SUMMARY"))
@@ -3466,11 +3961,16 @@ When COMBINE is non nil, add the category to each line."
3466 t org-icalendar-include-body) 3961 t org-icalendar-include-body)
3467 location (org-icalendar-cleanup-string 3962 location (org-icalendar-cleanup-string
3468 (org-entry-get nil "LOCATION")) 3963 (org-entry-get nil "LOCATION"))
3469 category (org-get-category)) 3964 uid (if org-icalendar-store-UID
3965 (org-id-get-create)
3966 (or (org-id-get) (org-id-new)))
3967 category (org-get-category)
3968 deadlinep nil scheduledp nil)
3470 (if (looking-at re2) 3969 (if (looking-at re2)
3471 (progn 3970 (progn
3472 (goto-char (match-end 0)) 3971 (goto-char (match-end 0))
3473 (setq ts2 (match-string 1) inc nil)) 3972 (setq ts2 (match-string 1)
3973 inc (not (string-match "[0-9]\\{1,2\\}:[0-9][0-9]" ts2))))
3474 (setq tmp (buffer-substring (max (point-min) 3974 (setq tmp (buffer-substring (max (point-min)
3475 (- pos org-ds-keyword-length)) 3975 (- pos org-ds-keyword-length))
3476 pos) 3976 pos)
@@ -3483,6 +3983,7 @@ When COMBINE is non nil, add the category to each line."
3483 scheduledp (string-match org-scheduled-regexp tmp) 3983 scheduledp (string-match org-scheduled-regexp tmp)
3484 ;; donep (org-entry-is-done-p) 3984 ;; donep (org-entry-is-done-p)
3485 )) 3985 ))
3986 (setq prefix (if deadlinep "DL-" (if scheduledp "SC-" "TS-")))
3486 (if (or (string-match org-tr-regexp hd) 3987 (if (or (string-match org-tr-regexp hd)
3487 (string-match org-ts-regexp hd)) 3988 (string-match org-ts-regexp hd))
3488 (setq hd (replace-match "" t t hd))) 3989 (setq hd (replace-match "" t t hd)))
@@ -3500,19 +4001,21 @@ When COMBINE is non nil, add the category to each line."
3500 (setq summary 4001 (setq summary
3501 (replace-match (if (match-end 3) 4002 (replace-match (if (match-end 3)
3502 (match-string 3 summary) 4003 (match-string 3 summary)
3503 (match-string 1 summary)) 4004 (match-string 1 summary))
3504 t t summary))) 4005 t t summary)))
3505 (if deadlinep (setq summary (concat "DL: " summary))) 4006 (if deadlinep (setq summary (concat "DL: " summary)))
3506 (if scheduledp (setq summary (concat "S: " summary))) 4007 (if scheduledp (setq summary (concat "S: " summary)))
3507 (if (string-match "\\`<%%" ts) 4008 (if (string-match "\\`<%%" ts)
3508 (with-current-buffer sexp-buffer 4009 (with-current-buffer sexp-buffer
3509 (insert (substring ts 1 -1) " " summary "\n")) 4010 (insert (substring ts 1 -1) " " summary "\n"))
3510 (princ (format "BEGIN:VEVENT 4011 (princ (format "BEGIN:VEVENT
4012UID: %s
3511%s 4013%s
3512%s%s 4014%s%s
3513SUMMARY:%s%s%s 4015SUMMARY:%s%s%s
3514CATEGORIES:%s 4016CATEGORIES:%s
3515END:VEVENT\n" 4017END:VEVENT\n"
4018 (concat prefix uid)
3516 (org-ical-ts-to-string ts "DTSTART") 4019 (org-ical-ts-to-string ts "DTSTART")
3517 (org-ical-ts-to-string ts2 "DTEND" inc) 4020 (org-ical-ts-to-string ts2 "DTEND" inc)
3518 rrule summary 4021 rrule summary
@@ -3521,7 +4024,6 @@ END:VEVENT\n"
3521 (if (and location (string-match "\\S-" location)) 4024 (if (and location (string-match "\\S-" location))
3522 (concat "\nLOCATION: " location) "") 4025 (concat "\nLOCATION: " location) "")
3523 category))))) 4026 category)))))
3524
3525 (when (and org-icalendar-include-sexps 4027 (when (and org-icalendar-include-sexps
3526 (condition-case nil (require 'icalendar) (error nil)) 4028 (condition-case nil (require 'icalendar) (error nil))
3527 (fboundp 'icalendar-export-region)) 4029 (fboundp 'icalendar-export-region))
@@ -3536,10 +4038,12 @@ END:VEVENT\n"
3536 (end-of-line 1) 4038 (end-of-line 1)
3537 (setq sexp (buffer-substring b (point))) 4039 (setq sexp (buffer-substring b (point)))
3538 (with-current-buffer sexp-buffer 4040 (with-current-buffer sexp-buffer
3539 (insert sexp "\n")) 4041 (insert sexp "\n"))))
3540 (princ (org-diary-to-ical-string sexp-buffer))))) 4042 (princ (org-diary-to-ical-string sexp-buffer))
3541 4043 (kill-buffer sexp-buffer))
4044
3542 (when org-icalendar-include-todo 4045 (when org-icalendar-include-todo
4046 (setq prefix "TODO-")
3543 (goto-char (point-min)) 4047 (goto-char (point-min))
3544 (while (re-search-forward org-todo-line-regexp nil t) 4048 (while (re-search-forward org-todo-line-regexp nil t)
3545 (catch :skip 4049 (catch :skip
@@ -3565,7 +4069,10 @@ END:VEVENT\n"
3565 (and org-icalendar-include-body (org-get-entry))) 4069 (and org-icalendar-include-body (org-get-entry)))
3566 t org-icalendar-include-body) 4070 t org-icalendar-include-body)
3567 location (org-icalendar-cleanup-string 4071 location (org-icalendar-cleanup-string
3568 (org-entry-get nil "LOCATION"))) 4072 (org-entry-get nil "LOCATION"))
4073 uid (if org-icalendar-store-UID
4074 (org-id-get-create)
4075 (or (org-id-get) (org-id-new))))
3569 (if (string-match org-bracket-link-regexp hd) 4076 (if (string-match org-bracket-link-regexp hd)
3570 (setq hd (replace-match (if (match-end 3) (match-string 3 hd) 4077 (setq hd (replace-match (if (match-end 3) (match-string 3 hd)
3571 (match-string 1 hd)) 4078 (match-string 1 hd))
@@ -3579,6 +4086,7 @@ END:VEVENT\n"
3579 (- org-lowest-priority org-highest-priority)))))) 4086 (- org-lowest-priority org-highest-priority))))))
3580 4087
3581 (princ (format "BEGIN:VTODO 4088 (princ (format "BEGIN:VTODO
4089UID: %s
3582%s 4090%s
3583SUMMARY:%s%s%s 4091SUMMARY:%s%s%s
3584CATEGORIES:%s 4092CATEGORIES:%s
@@ -3586,13 +4094,15 @@ SEQUENCE:1
3586PRIORITY:%d 4094PRIORITY:%d
3587STATUS:%s 4095STATUS:%s
3588END:VTODO\n" 4096END:VTODO\n"
4097 (concat prefix uid)
3589 dts 4098 dts
3590 (or summary hd) 4099 (or summary hd)
3591 (if (and location (string-match "\\S-" location)) 4100 (if (and location (string-match "\\S-" location))
3592 (concat "\nLOCATION: " location) "") 4101 (concat "\nLOCATION: " location) "")
3593 (if (and desc (string-match "\\S-" desc)) 4102 (if (and desc (string-match "\\S-" desc))
3594 (concat "\nDESCRIPTION: " desc) "") 4103 (concat "\nDESCRIPTION: " desc) "")
3595 category pri status))))))))) 4104 category
4105 pri status)))))))))
3596 4106
3597(defun org-icalendar-cleanup-string (s &optional is-body maxlength) 4107(defun org-icalendar-cleanup-string (s &optional is-body maxlength)
3598 "Take out stuff and quote what needs to be quoted. 4108 "Take out stuff and quote what needs to be quoted.
@@ -3607,7 +4117,7 @@ characters."
3607 (while (string-match re s) (setq s (replace-match "" t t s))) 4117 (while (string-match re s) (setq s (replace-match "" t t s)))
3608 (while (string-match re2 s) (setq s (replace-match "" t t s))))) 4118 (while (string-match re2 s) (setq s (replace-match "" t t s)))))
3609 (let ((start 0)) 4119 (let ((start 0))
3610 (while (string-match "\\([,;\\]\\)" s start) 4120 (while (string-match "\\([,;]\\)" s start)
3611 (setq start (+ (match-beginning 0) 2) 4121 (setq start (+ (match-beginning 0) 2)
3612 s (replace-match "\\\\\\1" nil nil s)))) 4122 s (replace-match "\\\\\\1" nil nil s))))
3613 (when is-body 4123 (when is-body
@@ -3756,12 +4266,7 @@ The XOXO buffer is named *xoxo-<source buffer name>*"
3756 4266
3757(provide 'org-exp) 4267(provide 'org-exp)
3758 4268
3759;;; org-exp.el ends here 4269;; arch-tag: 65985fe9-095c-49c7-a7b6-cb4ee15c0a95
3760 4270
4271;;; org-exp.el ends here
3761 4272
3762(defun org-export-process-option-filters (plist)
3763 (let ((functions org-export-options-filters) f)
3764 (while (setq f (pop functions))
3765 (setq plist (funcall f plist))))
3766 plist)
3767;; arch-tag: 65985fe9-095c-49c7-a7b6-cb4ee15c0a95
diff --git a/lisp/org/org-export-latex.el b/lisp/org/org-export-latex.el
index 1c05e5fc913..11354fcd501 100644
--- a/lisp/org/org-export-latex.el
+++ b/lisp/org/org-export-latex.el
@@ -4,7 +4,7 @@
4;; 4;;
5;; Emacs Lisp Archive Entry 5;; Emacs Lisp Archive Entry
6;; Filename: org-export-latex.el 6;; Filename: org-export-latex.el
7;; Version: 6.02b 7;; Version: 6.05a
8;; Author: Bastien Guerry <bzg AT altern DOT org> 8;; Author: Bastien Guerry <bzg AT altern DOT org>
9;; Maintainer: Bastien Guerry <bzg AT altern DOT org> 9;; Maintainer: Bastien Guerry <bzg AT altern DOT org>
10;; Keywords: org, wp, tex 10;; Keywords: org, wp, tex
@@ -361,12 +361,19 @@ when PUB-DIR is set, use this as the publishing directory."
361 (let* ((wcf (current-window-configuration)) 361 (let* ((wcf (current-window-configuration))
362 (opt-plist org-export-latex-options-plist) 362 (opt-plist org-export-latex-options-plist)
363 (region-p (org-region-active-p)) 363 (region-p (org-region-active-p))
364 (rbeg (and region-p (region-beginning)))
365 (rend (and region-p (region-end)))
364 (subtree-p 366 (subtree-p
365 (when region-p 367 (when region-p
366 (save-excursion 368 (save-excursion
367 (goto-char (region-beginning)) 369 (goto-char rbeg)
368 (and (org-at-heading-p) 370 (and (org-at-heading-p)
369 (>= (org-end-of-subtree t t) (region-end)))))) 371 (>= (org-end-of-subtree t t) rend)))))
372 (opt-plist (if subtree-p
373 (org-export-add-subtree-options opt-plist rbeg)
374 opt-plist))
375 ;; Make sure the variable contains the updated values.
376 (org-export-latex-options-plist opt-plist)
370 (title (or (and subtree-p (org-export-get-title-from-subtree)) 377 (title (or (and subtree-p (org-export-get-title-from-subtree))
371 (plist-get opt-plist :title) 378 (plist-get opt-plist :title)
372 (and (not 379 (and (not
@@ -378,8 +385,11 @@ when PUB-DIR is set, use this as the publishing directory."
378 (or pub-dir 385 (or pub-dir
379 (org-export-directory :LaTeX ext-plist))) 386 (org-export-directory :LaTeX ext-plist)))
380 (file-name-sans-extension 387 (file-name-sans-extension
381 (file-name-nondirectory ;sans-extension 388 (or (and subtree-p
382 buffer-file-name)) ".tex")) 389 (org-entry-get rbeg "EXPORT_FILE_NAME" t))
390 (file-name-nondirectory ;sans-extension
391 buffer-file-name)))
392 ".tex"))
383 (filename (if (equal (file-truename filename) 393 (filename (if (equal (file-truename filename)
384 (file-truename buffer-file-name)) 394 (file-truename buffer-file-name))
385 (concat filename ".tex") 395 (concat filename ".tex")
@@ -1094,6 +1104,22 @@ Regexps are those from `org-export-latex-special-string-regexps'."
1094 (replace-match (org-export-latex-protect-string 1104 (replace-match (org-export-latex-protect-string
1095 (concat (match-string 1) "\\LaTeX{}")) t t))) 1105 (concat (match-string 1) "\\LaTeX{}")) t t)))
1096 1106
1107 ;; Convert blockquotes
1108 (goto-char (point-min))
1109 (while (re-search-forward "^#\\+BEGIN_QUOTE" nil t)
1110 (replace-match "\\begin{quote}" t t))
1111 (goto-char (point-min))
1112 (while (re-search-forward "^#\\+END_QUOTE" nil t)
1113 (replace-match "\\end{quote}" t t))
1114
1115 ;; Convert verse
1116 (goto-char (point-min))
1117 (while (re-search-forward "^#\\+BEGIN_VERSE" nil t)
1118 (replace-match "\\begin{verse}" t t))
1119 (goto-char (point-min))
1120 (while (re-search-forward "^#\\+END_VERSE" nil t)
1121 (replace-match "\\end{verse}" t t))
1122
1097 ;; Convert horizontal rules 1123 ;; Convert horizontal rules
1098 (goto-char (point-min)) 1124 (goto-char (point-min))
1099 (while (re-search-forward "^----+.$" nil t) 1125 (while (re-search-forward "^----+.$" nil t)
@@ -1538,4 +1564,5 @@ Valid parameters are
1538(provide 'org-export-latex) 1564(provide 'org-export-latex)
1539 1565
1540;; arch-tag: 23c2b87d-da04-4c2d-ad2d-1eb6487bc3ad 1566;; arch-tag: 23c2b87d-da04-4c2d-ad2d-1eb6487bc3ad
1567
1541;;; org-export-latex.el ends here 1568;;; org-export-latex.el ends here
diff --git a/lisp/org/org-faces.el b/lisp/org/org-faces.el
index 8764fa5e319..102bec9db05 100644
--- a/lisp/org/org-faces.el
+++ b/lisp/org/org-faces.el
@@ -5,7 +5,7 @@
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;;
@@ -148,13 +148,41 @@ color of the frame."
148(defface org-column 148(defface org-column
149 (org-compatible-face nil 149 (org-compatible-face nil
150 '((((class color) (min-colors 16) (background light)) 150 '((((class color) (min-colors 16) (background light))
151 (:background "grey90")) 151 (:background "grey90" :weight normal :slant normal :strike-through nil
152 :underline nil))
152 (((class color) (min-colors 16) (background dark)) 153 (((class color) (min-colors 16) (background dark))
153 (:background "grey30")) 154 (:background "grey30" :weight normal :slant normal :strike-through nil
155 :underline nil))
154 (((class color) (min-colors 8)) 156 (((class color) (min-colors 8))
155 (:background "cyan" :foreground "black")) 157 (:background "cyan" :foreground "black"
158 :weight normal :slant normal :strike-through nil
159 :underline nil))
156 (t (:inverse-video t)))) 160 (t (:inverse-video t))))
157 "Face for column display of entry properties." 161 "Face for column display of entry properties.
162This is actually only part of the face definition for the text in column view.
163The following faces apply, with this priority.
164
1651. The color of the reference face. This is normally the level fact that
166 is used in the outline. In agenda-mode, it will be the face of the
167 first character in the line. The color is explicitly retained to
168 make sure that the column line still looks a bit like the structure
169 line it is masking.
170
1712. The `org-column' face.
172
1733. The remaining properties of the reference face.
174
175Since column view works by putting overlays with a display property
176over individual characters in the buffer, the face of the underlining
177character (this might for example be the a TODO keyword) might still
178shine through in some properties. So when your column view looks
179funny, with \"random\" colors, weight, strike-through, try to explicitly
180set the properties in the `org-column' face. For example, set
181:underline to nil, or the :slant to `normal'.
182
183Under XEmacs, the rules are simpler, because the XEmacs version of
184column view defines special faces for each outline level. See the file
185`org-colview-xemacs.el' for details."
158 :group 'org-faces) 186 :group 'org-faces)
159 187
160(defface org-column-title 188(defface org-column-title
@@ -457,4 +485,5 @@ If it is less than 8, the level-1 face gets re-used for level N+1 etc."
457(provide 'org-faces) 485(provide 'org-faces)
458 486
459;; arch-tag: 9dab5f91-c4b9-4d6f-bac3-1f6211ad0a04 487;; arch-tag: 9dab5f91-c4b9-4d6f-bac3-1f6211ad0a04
488
460;;; org-faces.el ends here 489;;; org-faces.el ends here
diff --git a/lisp/org/org-gnus.el b/lisp/org/org-gnus.el
index 280804a8cf0..e006f854e3d 100644
--- a/lisp/org/org-gnus.el
+++ b/lisp/org/org-gnus.el
@@ -5,7 +5,7 @@
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;;
@@ -125,4 +125,5 @@ negates this setting for the duration of the command."
125(provide 'org-gnus) 125(provide 'org-gnus)
126 126
127;; arch-tag: 512e0840-58fa-45b3-b456-71e10fa2376d 127;; arch-tag: 512e0840-58fa-45b3-b456-71e10fa2376d
128
128;;; org-gnus.el ends here 129;;; org-gnus.el ends here
diff --git a/lisp/org/org-info.el b/lisp/org/org-info.el
index cdc0b579864..a81eaa793da 100644
--- a/lisp/org/org-info.el
+++ b/lisp/org/org-info.el
@@ -5,7 +5,7 @@
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;;
@@ -78,4 +78,5 @@
78(provide 'org-info) 78(provide 'org-info)
79 79
80;; arch-tag: 1e289f54-7176-487f-b575-dd4854bab15e 80;; arch-tag: 1e289f54-7176-487f-b575-dd4854bab15e
81
81;;; org-info.el ends here 82;;; org-info.el ends here
diff --git a/lisp/org/org-irc.el b/lisp/org/org-irc.el
index 5704929ffbb..16a677c7ba2 100644
--- a/lisp/org/org-irc.el
+++ b/lisp/org/org-irc.el
@@ -4,7 +4,7 @@
4;; 4;;
5;; Author: Philip Jackson <emacs@shellarchive.co.uk> 5;; Author: Philip Jackson <emacs@shellarchive.co.uk>
6;; Keywords: erc, irc, link, org 6;; Keywords: erc, irc, link, org
7;; Version: 6.02b 7;; Version: 6.05a
8;; 8;;
9;; This file is part of GNU Emacs. 9;; This file is part of GNU Emacs.
10;; 10;;
@@ -252,4 +252,5 @@ default."
252(provide 'org-irc) 252(provide 'org-irc)
253 253
254;; arch-tag: 018d7dda-53b8-4a35-ba92-6670939e525a 254;; arch-tag: 018d7dda-53b8-4a35-ba92-6670939e525a
255
255;;; org-irc.el ends here 256;;; org-irc.el ends here
diff --git a/lisp/org/org-jsinfo.el b/lisp/org/org-jsinfo.el
index 6eebf96d64a..337886c057c 100644
--- a/lisp/org/org-jsinfo.el
+++ b/lisp/org/org-jsinfo.el
@@ -5,7 +5,7 @@
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;;
@@ -66,6 +66,7 @@ line in the buffer. See also the variable `org-infojs-options'."
66 '((path PATH "http://orgmode.org/org-info.js") 66 '((path PATH "http://orgmode.org/org-info.js")
67 (view VIEW "info") 67 (view VIEW "info")
68 (toc TOC :table-of-contents) 68 (toc TOC :table-of-contents)
69 (ftoc FIXED_TOC "0")
69 (tdepth TOC_DEPTH "max") 70 (tdepth TOC_DEPTH "max")
70 (sdepth SECTION_DEPTH "max") 71 (sdepth SECTION_DEPTH "max")
71 (mouse MOUSE_HINT "underline") 72 (mouse MOUSE_HINT "underline")
@@ -200,6 +201,8 @@ Option settings will replace the %MANAGER-OPTIONS cookie."
200 (cdr (assoc 'path org-infojs-options)))) 201 (cdr (assoc 'path org-infojs-options))))
201 202
202(provide 'org-infojs) 203(provide 'org-infojs)
204(provide 'org-jsinfo)
203 205
204;; arch-tag: c71d1d85-3337-4817-a066-725e74ac9eac 206;; arch-tag: c71d1d85-3337-4817-a066-725e74ac9eac
207
205;;; org-jsinfo.el ends here 208;;; org-jsinfo.el ends here
diff --git a/lisp/org/org-mac-message.el b/lisp/org/org-mac-message.el
index 758a345c82d..8f1607ffc47 100644
--- a/lisp/org/org-mac-message.el
+++ b/lisp/org/org-mac-message.el
@@ -3,7 +3,7 @@
3;; Copyright (C) 2008 Free Software Foundation, Inc. 3;; Copyright (C) 2008 Free Software Foundation, Inc.
4 4
5;; Author: John Wiegley <johnw@gnu.org> 5;; Author: John Wiegley <johnw@gnu.org>
6;; Version: 6.02b 6;; Version: 6.05a
7;; Keywords: outlines, hypermedia, calendar, wp 7;; Keywords: outlines, hypermedia, calendar, wp
8 8
9;; This file is part of GNU Emacs. 9;; This file is part of GNU Emacs.
@@ -79,4 +79,5 @@ end tell")))
79(provide 'org-mac-message) 79(provide 'org-mac-message)
80 80
81;; arch-tag: 3806d0c1-abe1-4db6-9c31-f3ed7d4a9b32 81;; arch-tag: 3806d0c1-abe1-4db6-9c31-f3ed7d4a9b32
82
82;;; org-mac-message.el ends here 83;;; org-mac-message.el ends here
diff --git a/lisp/org/org-macs.el b/lisp/org/org-macs.el
index e9d0edb41c8..3434c57ec7b 100644
--- a/lisp/org/org-macs.el
+++ b/lisp/org/org-macs.el
@@ -5,7 +5,7 @@
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;;
@@ -89,9 +89,9 @@ We use a macro so that the test can happen at compilation time."
89(defmacro org-with-point-at (pom &rest body) 89(defmacro org-with-point-at (pom &rest body)
90 "Move to buffer and point of point-or-marker POM for the duration of BODY." 90 "Move to buffer and point of point-or-marker POM for the duration of BODY."
91 `(save-excursion 91 `(save-excursion
92 (if (markerp pom) (set-buffer (marker-buffer pom))) 92 (if (markerp ,pom) (set-buffer (marker-buffer ,pom)))
93 (save-excursion 93 (save-excursion
94 (goto-char (or pom (point))) 94 (goto-char (or ,pom (point)))
95 ,@body))) 95 ,@body)))
96 96
97(defmacro org-no-warnings (&rest body) 97(defmacro org-no-warnings (&rest body)
@@ -220,4 +220,5 @@ This is in contrast to merely setting it to 0."
220(provide 'org-macs) 220(provide 'org-macs)
221 221
222;; arch-tag: 7e6a73ce-aac9-4fc0-9b30-ce6f89dc6668 222;; arch-tag: 7e6a73ce-aac9-4fc0-9b30-ce6f89dc6668
223
223;;; org-macs.el ends here 224;;; org-macs.el ends here
diff --git a/lisp/org/org-mew.el b/lisp/org/org-mew.el
index e3fba77d5e4..655e344e4ff 100644
--- a/lisp/org/org-mew.el
+++ b/lisp/org/org-mew.el
@@ -5,7 +5,7 @@
5;; Author: Tokuya Kameshima <kames at fa2 dot so-net dot ne dot jp> 5;; Author: Tokuya Kameshima <kames at fa2 dot so-net dot ne dot jp>
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
@@ -123,4 +123,5 @@
123(provide 'org-mew) 123(provide 'org-mew)
124 124
125;; arch-tag: 07ccdca7-6020-4941-a593-588a1e51b870 125;; arch-tag: 07ccdca7-6020-4941-a593-588a1e51b870
126
126;;; org-mew.el ends here 127;;; org-mew.el ends here
diff --git a/lisp/org/org-mhe.el b/lisp/org/org-mhe.el
index c29ea9d98c3..66f1bcc31a8 100644
--- a/lisp/org/org-mhe.el
+++ b/lisp/org/org-mhe.el
@@ -5,7 +5,7 @@
5;; Author: Thomas Baumann <thomas dot baumann at ch dot tum dot de> 5;; Author: Thomas Baumann <thomas dot baumann at ch dot tum dot de>
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;;
@@ -71,6 +71,7 @@ supported by MH-E."
71(defvar mh-show-folder-buffer) 71(defvar mh-show-folder-buffer)
72(defvar mh-index-folder) 72(defvar mh-index-folder)
73(defvar mh-searcher) 73(defvar mh-searcher)
74(defvar mh-search-regexp-builder)
74 75
75;; Install the link type 76;; Install the link type
76(org-add-link-type "mhe" 'org-mhe-open) 77(org-add-link-type "mhe" 'org-mhe-open)
@@ -137,11 +138,11 @@ So if you use sequences, it will now work."
137 ))) 138 )))
138 139
139(defun org-mhe-get-message-folder-from-index () 140(defun org-mhe-get-message-folder-from-index ()
140 "Return the name of the message folder in a index folder buffer." 141 "Return the name of the message folder in an index folder buffer."
141 (save-excursion 142 (save-excursion
142 (mh-index-previous-folder) 143 (mh-index-previous-folder)
143 (re-search-forward "^\\(+.*\\)$" nil t) 144 (if (re-search-forward "^\\(+.*\\)$" nil t)
144 (message "%s" (match-string 1)))) 145 (message "%s" (match-string 1)))))
145 146
146(defun org-mhe-get-message-folder () 147(defun org-mhe-get-message-folder ()
147 "Return the name of the current message folder. 148 "Return the name of the current message folder.
@@ -194,16 +195,19 @@ folders."
194 (mh-find-path) 195 (mh-find-path)
195 (if (not article) 196 (if (not article)
196 (mh-visit-folder (mh-normalize-folder-name folder)) 197 (mh-visit-folder (mh-normalize-folder-name folder))
197 (setq article (org-add-angle-brackets article))
198 (mh-search-choose) 198 (mh-search-choose)
199 (if (equal mh-searcher 'pick) 199 (if (equal mh-searcher 'pick)
200 (progn 200 (progn
201 (setq article (org-add-angle-brackets article))
201 (mh-search folder (list "--message-id" article)) 202 (mh-search folder (list "--message-id" article))
202 (when (and org-mhe-search-all-folders 203 (when (and org-mhe-search-all-folders
203 (not (org-mhe-get-message-real-folder))) 204 (not (org-mhe-get-message-real-folder)))
204 (kill-this-buffer) 205 (kill-this-buffer)
205 (mh-search "+" (list "--message-id" article)))) 206 (mh-search "+" (list "--message-id" article))))
206 (mh-search "+" article)) 207 (if mh-search-regexp-builder
208 (mh-search "+" (funcall mh-search-regexp-builder
209 (list (cons 'message-id article))))
210 (mh-search "+" article)))
207 (if (org-mhe-get-message-real-folder) 211 (if (org-mhe-get-message-real-folder)
208 (mh-show-msg 1) 212 (mh-show-msg 1)
209 (kill-this-buffer) 213 (kill-this-buffer)
@@ -212,4 +216,5 @@ folders."
212(provide 'org-mhe) 216(provide 'org-mhe)
213 217
214;; arch-tag: dcb05484-8627-491d-a8c1-01dbd2bde4ae 218;; arch-tag: dcb05484-8627-491d-a8c1-01dbd2bde4ae
219
215;;; org-mhe.el ends here 220;;; org-mhe.el ends here
diff --git a/lisp/org/org-mouse.el b/lisp/org/org-mouse.el
index 3be478b072e..623afac29fc 100644
--- a/lisp/org/org-mouse.el
+++ b/lisp/org/org-mouse.el
@@ -4,7 +4,7 @@
4;; 4;;
5;; Author: Piotr Zielinski <piotr dot zielinski at gmail dot com> 5;; Author: Piotr Zielinski <piotr dot zielinski at gmail dot com>
6;; Maintainer: Carsten Dominik <carsten at orgmode dot org> 6;; Maintainer: Carsten Dominik <carsten at orgmode dot org>
7;; Version: 6.02b 7;; Version: 6.05a
8;; 8;;
9;; This file is part of GNU Emacs. 9;; This file is part of GNU Emacs.
10;; 10;;
@@ -1113,3 +1113,5 @@ SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:"
1113(provide 'org-mouse) 1113(provide 'org-mouse)
1114 1114
1115;; arch-tag: ff1ae557-3529-41a3-95c6-baaebdcc280f 1115;; arch-tag: ff1ae557-3529-41a3-95c6-baaebdcc280f
1116
1117;;; org-mouse.el ends-here
diff --git a/lisp/org/org-publish.el b/lisp/org/org-publish.el
index 351b11e31a6..65c49e7b9c9 100644
--- a/lisp/org/org-publish.el
+++ b/lisp/org/org-publish.el
@@ -4,7 +4,7 @@
4;; Author: David O'Toole <dto@gnu.org> 4;; Author: David O'Toole <dto@gnu.org>
5;; Maintainer: Bastien Guerry <bzg AT altern DOT org> 5;; Maintainer: Bastien Guerry <bzg AT altern DOT org>
6;; Keywords: hypermedia, outlines, wp 6;; Keywords: hypermedia, outlines, wp
7;; Version: 6.02b 7;; Version: 6.05a
8 8
9;; This file is part of GNU Emacs. 9;; This file is part of GNU Emacs.
10;; 10;;
@@ -149,15 +149,17 @@
149 149
150(eval-when-compile 150(eval-when-compile
151 (require 'cl)) 151 (require 'cl))
152(require 'org)
153(require 'org-exp)
152 154
153(eval-and-compile 155(eval-and-compile
154 (unless (fboundp 'declare-function) 156 (unless (fboundp 'declare-function)
155 (defmacro declare-function (fn file &optional arglist fileonly)))) 157 (defmacro declare-function (fn file &optional arglist fileonly))))
156 158
157(defgroup org-publish nil 159(defgroup org-publish nil
158 "Options for publishing a set of Org-mode and related files." 160 "Options for publishing a set of Org-mode and related files."
159 :tag "Org Publishing" 161 :tag "Org Publishing"
160 :group 'org) 162 :group 'org)
161 163
162(defcustom org-publish-project-alist nil 164(defcustom org-publish-project-alist nil
163 "Association list to control publishing behavior. 165 "Association list to control publishing behavior.
@@ -195,8 +197,8 @@ being published. Its value may be a string or regexp matching
195file names you don't want to be published. 197file names you don't want to be published.
196 198
197The :include property may be used to include extra files. Its 199The :include property may be used to include extra files. Its
198value may be a list of filenames to include. The filenames are 200value may be a list of filenames to include. The filenames are
199considered relative to the publishing directory. 201considered relative to the base directory.
200 202
201When both :include and :exclude properties are given values, the 203When both :include and :exclude properties are given values, the
202exclusion step happens first. 204exclusion step happens first.
@@ -219,6 +221,8 @@ certain makefile, to ensure published files are built up to date.
219 221
220 :preparation-function Function to be called before publishing 222 :preparation-function Function to be called before publishing
221 this project. 223 this project.
224 :completion-function Function to be called after publishing
225 this project.
222 226
223Some properties control details of the Org publishing process, 227Some properties control details of the Org publishing process,
224and are equivalent to the corresponding user variables listed in 228and are equivalent to the corresponding user variables listed in
@@ -449,6 +453,11 @@ matching filenames."
449 ;; FIXME distinguish exclude regexp 453 ;; FIXME distinguish exclude regexp
450 ;; for skip-file and skip-dir? 454 ;; for skip-file and skip-dir?
451 exclude-regexp exclude-regexp) 455 exclude-regexp exclude-regexp)
456 (mapc (lambda (f)
457 (pushnew
458 (expand-file-name (concat base-dir f))
459 org-publish-temp-files))
460 include-list)
452 org-publish-temp-files)) 461 org-publish-temp-files))
453 462
454(defun org-publish-get-project-from-filename (filename) 463(defun org-publish-get-project-from-filename (filename)
@@ -512,6 +521,8 @@ See `org-publish-org-to' to the list of arguments."
512 (require 'eshell) 521 (require 'eshell)
513 (require 'esh-maint) 522 (require 'esh-maint)
514 (require 'em-unix)) 523 (require 'em-unix))
524 (unless (file-directory-p pub-dir)
525 (make-directory pub-dir t))
515 (eshell/cp filename pub-dir)) 526 (eshell/cp filename pub-dir))
516 527
517;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 528;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -559,19 +570,22 @@ See `org-publish-org-to' to the list of arguments."
559If :auto-index is set, publish the index too." 570If :auto-index is set, publish the index too."
560 (mapc 571 (mapc
561 (lambda (project) 572 (lambda (project)
562 (let* ((project-plist (cdr project)) 573 (let*
563 (exclude-regexp (plist-get project-plist :exclude)) 574 ((project-plist (cdr project))
564 (index-p (plist-get project-plist :auto-index)) 575 (exclude-regexp (plist-get project-plist :exclude))
565 (index-filename (or (plist-get project-plist :index-filename) 576 (index-p (plist-get project-plist :auto-index))
566 "index.org")) 577 (index-filename (or (plist-get project-plist :index-filename)
567 (index-function (or (plist-get project-plist :index-function) 578 "index.org"))
568 'org-publish-org-index)) 579 (index-function (or (plist-get project-plist :index-function)
569 (preparation-function (plist-get project-plist :preparation-function)) 580 'org-publish-org-index))
570 (files (org-publish-get-base-files project exclude-regexp)) file) 581 (preparation-function (plist-get project-plist :preparation-function))
582 (completion-function (plist-get project-plist :completion-function))
583 (files (org-publish-get-base-files project exclude-regexp)) file)
571 (when preparation-function (funcall preparation-function)) 584 (when preparation-function (funcall preparation-function))
572 (if index-p (funcall index-function project index-filename)) 585 (if index-p (funcall index-function project index-filename))
573 (while (setq file (pop files)) 586 (while (setq file (pop files))
574 (org-publish-file file project)))) 587 (org-publish-file file project))
588 (when completion-function (funcall completion-function))))
575 (org-publish-expand-projects projects))) 589 (org-publish-expand-projects projects)))
576 590
577(defun org-publish-org-index (project &optional index-filename) 591(defun org-publish-org-index (project &optional index-filename)
@@ -581,9 +595,13 @@ Default for INDEX-FILENAME is 'index.org'."
581 (let* ((project-plist (cdr project)) 595 (let* ((project-plist (cdr project))
582 (dir (file-name-as-directory 596 (dir (file-name-as-directory
583 (plist-get project-plist :base-directory))) 597 (plist-get project-plist :base-directory)))
598 (localdir (file-name-directory dir))
599 (indent-str (make-string 2 ?\ ))
584 (exclude-regexp (plist-get project-plist :exclude)) 600 (exclude-regexp (plist-get project-plist :exclude))
585 (files (org-publish-get-base-files project exclude-regexp)) 601 (files (nreverse (org-publish-get-base-files project exclude-regexp)))
586 (index-filename (concat dir (or index-filename "index.org"))) 602 (index-filename (concat dir (or index-filename "index.org")))
603 (index-title (or (plist-get project-plist :index-title)
604 (concat "Index for project " (car project))))
587 (index-buffer (find-buffer-visiting index-filename)) 605 (index-buffer (find-buffer-visiting index-filename))
588 (ifn (file-name-nondirectory index-filename)) 606 (ifn (file-name-nondirectory index-filename))
589 file) 607 file)
@@ -591,16 +609,47 @@ Default for INDEX-FILENAME is 'index.org'."
591 (if index-buffer 609 (if index-buffer
592 (kill-buffer index-buffer)) 610 (kill-buffer index-buffer))
593 (with-temp-buffer 611 (with-temp-buffer
612 (insert (concat index-title "\n\n"))
594 (while (setq file (pop files)) 613 (while (setq file (pop files))
595 (let ((fn (file-name-nondirectory file))) 614 (let ((fn (file-name-nondirectory file))
615 (link (file-relative-name file dir))
616 (oldlocal localdir))
596 ;; index shouldn't index itself 617 ;; index shouldn't index itself
597 (unless (string= fn ifn) 618 (unless (string= fn ifn)
598 (insert (concat " + [[file:" fn "][" 619 (setq localdir (concat (file-name-as-directory dir)
620 (file-name-directory link)))
621 (unless (string= localdir oldlocal)
622 (if (string= localdir dir)
623 (setq indent-str (make-string 2 ?\ ))
624 (let ((subdirs
625 (split-string
626 (directory-file-name
627 (file-name-directory
628 (file-relative-name localdir dir))) "/"))
629 (subdir ""))
630 (setq indent-str (make-string 2 ?\ ))
631 (dolist (d subdirs)
632 (setq subdir (concat subdir d "/"))
633 (insert (concat indent-str " + [[file:" subdir "][" d "/]]\n"))
634 (setq indent-str (make-string (+ (length indent-str) 2) ?\ ))))))
635 (insert (concat indent-str " + [[file:" link "]["
599 (file-name-sans-extension fn) 636 (file-name-sans-extension fn)
600 "]]\n"))))) 637 "]]\n")))))
601 (write-file index-filename) 638 (write-file index-filename)
602 (kill-buffer (current-buffer))))) 639 (kill-buffer (current-buffer)))))
603 640
641(defun org-publish-find-title (file)
642 "Find the title of file in project."
643 (save-excursion
644 (set-buffer (find-file-noselect file))
645 (let* ((opt-plist (org-combine-plists (org-default-export-plist)
646 (org-infile-export-plist))))
647 (or (plist-get opt-plist :title)
648 (and (not
649 (plist-get opt-plist :skip-before-1st-heading))
650 (org-export-grab-title-from-buffer))
651 (file-name-sans-extension file)))))
652
604;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 653;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
605;;; Interactive publishing functions 654;;; Interactive publishing functions
606 655
@@ -663,4 +712,5 @@ the project."
663 712
664 713
665;; arch-tag: 72807f3c-8af0-4a6b-8dca-c3376eb25adb 714;; arch-tag: 72807f3c-8af0-4a6b-8dca-c3376eb25adb
715
666;;; org-publish.el ends here 716;;; org-publish.el ends here
diff --git a/lisp/org/org-remember.el b/lisp/org/org-remember.el
index 8a9bcecef66..a97fd647337 100644
--- a/lisp/org/org-remember.el
+++ b/lisp/org/org-remember.el
@@ -5,7 +5,7 @@
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;;
@@ -50,9 +50,12 @@
50 :group 'org) 50 :group 'org)
51 51
52(defcustom org-remember-store-without-prompt t 52(defcustom org-remember-store-without-prompt t
53 "Non-nil means, `C-c C-c' stores remember note without further promts. 53 "Non-nil means, `C-c C-c' stores remember note without further prompts.
54In this case, you need `C-u C-c C-c' to get the prompts for 54It then uses the file and headline specified by the template or (if the
55note file and headline. 55themplate does not specify them) by the variables `org-default-notes-file'
56and `org-remember-default-headline'. To force prompting anyway, use
57`C-u C-c C-c' to file the note.
58
56When this variable is nil, `C-c C-c' gives you the prompts, and 59When this variable is nil, `C-c C-c' gives you the prompts, and
57`C-u C-c C-c' triggers the fasttrack." 60`C-u C-c C-c' triggers the fasttrack."
58 :group 'org-remember 61 :group 'org-remember
@@ -99,13 +102,16 @@ it will be interpreted relative to `org-directory'.
99 102
100An optional fifth element can specify the headline in that file that should 103An optional fifth element can specify the headline in that file that should
101be offered first when the user is asked to file the entry. The default 104be offered first when the user is asked to file the entry. The default
102headline is given in the variable `org-remember-default-headline'. 105headline is given in the variable `org-remember-default-headline'. When
106this element is `top' or `bottom', the note will be placed as a level-1
107entry at the beginning or end of the file, respectively.
103 108
104An optional sixth element specifies the contexts in which the user can 109An optional sixth element specifies the contexts in which the template
105select the template. This element can be either a list of major modes 110will be offered to the user. This element can be a list of major modes
106or a function. `org-remember' will first check whether the function 111or a function, and the template will only be offered if `org-remember'
107returns `t' or if we are in any of the listed major modes, and select 112is called from a mode in the list, or if the function returns t.
108the template accordingly. 113Templates that specify t or nil for the context will be always be added
114to the list of selectable templates.
109 115
110The template specifies the structure of the remember buffer. It should have 116The template specifies the structure of the remember buffer. It should have
111a first line starting with a star, to act as the org-mode headline. 117a first line starting with a star, to act as the org-mode headline.
@@ -117,19 +123,23 @@ Furthermore, the following %-escapes will be replaced with content:
117 %t time stamp, date only 123 %t time stamp, date only
118 %T time stamp with date and time 124 %T time stamp with date and time
119 %u, %U like the above, but inactive time stamps 125 %u, %U like the above, but inactive time stamps
120 %^t like %t, but prompt for date. Similarly %^T, %^u, %^U 126 %^t like %t, but prompt for date. Similarly %^T, %^u, %^U.
121 You may define a prompt like %^{Please specify birthday}t 127 You may define a prompt like %^{Please specify birthday
122 %n user name (taken from `user-full-name') 128 %n user name (taken from `user-full-name')
123 %a annotation, normally the link created with org-store-link 129 %a annotation, normally the link created with org-store-link
124 %i initial content, the region active. If %i is indented, 130 %i initial content, the region active. If %i is indented,
125 the entire inserted text will be indented as well. 131 the entire inserted text will be indented as well.
126 %c content of the clipboard, or current kill ring head 132 %c current kill ring head
133 %x content of the X clipboard
134 %^C Interactive selection of which kill or clip to use
135 %^L Like %^C, but insert as link
127 %^g prompt for tags, with completion on tags in target file 136 %^g prompt for tags, with completion on tags in target file
128 %^G prompt for tags, with completion all tags in all agenda files 137 %^G prompt for tags, with completion all tags in all agenda files
129 %:keyword specific information for certain link types, see below 138 %:keyword specific information for certain link types, see below
130 %[pathname] insert the contents of the file given by `pathname' 139 %[pathname] insert the contents of the file given by `pathname'
131 %(sexp) evaluate elisp `(sexp)' and replace with the result 140 %(sexp) evaluate elisp `(sexp)' and replace with the result
132 %! Store this note immediately after filling the template 141 %! Store this note immediately after filling the template
142 %& Visit note immediately after storing it
133 143
134 %? After completing the template, position cursor here. 144 %? After completing the template, position cursor here.
135 145
@@ -164,19 +174,34 @@ calendar | %:type %:date"
164 (string :tag "Name") 174 (string :tag "Name")
165 (character :tag "Selection Key") 175 (character :tag "Selection Key")
166 (string :tag "Template") 176 (string :tag "Template")
167 (choice 177 (choice :tag "Destination file"
168 (file :tag "Destination file") 178 (file :tag "Specify")
169 (const :tag "Prompt for file" nil)) 179 (const :tag "Use `org-default-notes-file'" nil))
170 (choice 180 (choice :tag "Destin. headline"
171 (string :tag "Destination headline") 181 (string :tag "Specify")
172 (const :tag "Selection interface for heading")) 182 (const :tag "Use `org-remember-default-headline'" nil)
173 (choice 183 (const :tag "Level 1 at beginning of file" top)
174 (const :tag "Use by default" nil) 184 (const :tag "Level 1 at end of file" bottom))
185 (choice :tag "Context"
186 (const :tag "Use in all contexts" nil)
175 (const :tag "Use in all contexts" t) 187 (const :tag "Use in all contexts" t)
176 (repeat :tag "Use only if in major mode" 188 (repeat :tag "Use only if in major mode"
177 (symbol :tag "Major mode")) 189 (symbol :tag "Major mode"))
178 (function :tag "Perform a check against function"))))) 190 (function :tag "Perform a check against function")))))
179 191
192(defcustom org-remember-clock-out-on-exit 'query
193 "Non-nil means, stop the clock when exiting a clocking remember buffer.
194This only applies if the clock is running in the remember buffer. If the
195clock is not stopped, it continues to run in the storage location.
196Instead of nil or t, this may also be the symbol `query' to prompt the
197user each time a remember buffer with a running clock is filed away. "
198 :group 'org-remember
199 :type '(choice
200 (const :tag "Never" nil)
201 (const :tag "Always" t)
202 (const :tag "Query user" query)))
203
204
180(defvar annotation) ; from remember.el, dynamically scoped in `remember-mode' 205(defvar annotation) ; from remember.el, dynamically scoped in `remember-mode'
181(defvar initial) ; from remember.el, dynamically scoped in `remember-mode' 206(defvar initial) ; from remember.el, dynamically scoped in `remember-mode'
182 207
@@ -203,6 +228,7 @@ RET on headline -> Store as sublevel entry to current headline
203RET at beg-of-buf -> Append to file as level 2 headline 228RET at beg-of-buf -> Append to file as level 2 headline
204<left>/<right> -> before/after current headline, same headings level") 229<left>/<right> -> before/after current headline, same headings level")
205 230
231(defvar org-jump-to-target-location nil)
206(defvar org-remember-previous-location nil) 232(defvar org-remember-previous-location nil)
207(defvar org-force-remember-template-char) ;; dynamically scoped 233(defvar org-force-remember-template-char) ;; dynamically scoped
208 234
@@ -289,6 +315,7 @@ This function should be placed into `remember-mode-hook' and in fact requires
289to be run from that hook to function properly." 315to be run from that hook to function properly."
290 (if org-remember-templates 316 (if org-remember-templates
291 (let* ((entry (org-select-remember-template use-char)) 317 (let* ((entry (org-select-remember-template use-char))
318 (ct (or org-overriding-default-time (org-current-time)))
292 (tpl (car entry)) 319 (tpl (car entry))
293 (plist-p (if org-store-link-plist t nil)) 320 (plist-p (if org-store-link-plist t nil))
294 (file (if (and (nth 1 entry) (stringp (nth 1 entry)) 321 (file (if (and (nth 1 entry) (stringp (nth 1 entry))
@@ -300,8 +327,8 @@ to be run from that hook to function properly."
300 (v-x (or (org-get-x-clipboard 'PRIMARY) 327 (v-x (or (org-get-x-clipboard 'PRIMARY)
301 (org-get-x-clipboard 'CLIPBOARD) 328 (org-get-x-clipboard 'CLIPBOARD)
302 (org-get-x-clipboard 'SECONDARY))) 329 (org-get-x-clipboard 'SECONDARY)))
303 (v-t (format-time-string (car org-time-stamp-formats) (org-current-time))) 330 (v-t (format-time-string (car org-time-stamp-formats) ct))
304 (v-T (format-time-string (cdr org-time-stamp-formats) (org-current-time))) 331 (v-T (format-time-string (cdr org-time-stamp-formats) ct))
305 (v-u (concat "[" (substring v-t 1 -1) "]")) 332 (v-u (concat "[" (substring v-t 1 -1) "]"))
306 (v-U (concat "[" (substring v-T 1 -1) "]")) 333 (v-U (concat "[" (substring v-T 1 -1) "]"))
307 ;; `initial' and `annotation' are bound in `remember' 334 ;; `initial' and `annotation' are bound in `remember'
@@ -394,11 +421,11 @@ to be run from that hook to function properly."
394 (org-set-local 'org-finish-function 'org-remember-finalize) 421 (org-set-local 'org-finish-function 'org-remember-finalize)
395 (if (and file (string-match "\\S-" file) (not (file-directory-p file))) 422 (if (and file (string-match "\\S-" file) (not (file-directory-p file)))
396 (org-set-local 'org-default-notes-file file)) 423 (org-set-local 'org-default-notes-file file))
397 (if (and headline (stringp headline) (string-match "\\S-" headline)) 424 (if headline
398 (org-set-local 'org-remember-default-headline headline)) 425 (org-set-local 'org-remember-default-headline headline))
399 ;; Interactive template entries 426 ;; Interactive template entries
400 (goto-char (point-min)) 427 (goto-char (point-min))
401 (while (re-search-forward "%^\\({\\([^}]*\\)}\\)?\\([gGuUtTCL]\\)?" nil t) 428 (while (re-search-forward "%^\\({\\([^}]*\\)}\\)?\\([gGtTuUCL]\\)?" nil t)
402 (setq char (if (match-end 3) (match-string 3)) 429 (setq char (if (match-end 3) (match-string 3))
403 prompt (if (match-end 2) (match-string 2))) 430 prompt (if (match-end 2) (match-string 2)))
404 (goto-char (match-beginning 0)) 431 (goto-char (match-beginning 0))
@@ -444,6 +471,7 @@ to be run from that hook to function properly."
444 '(clipboards . 1) 471 '(clipboards . 1)
445 (car clipboards)))))) 472 (car clipboards))))))
446 (char 473 (char
474 ;; These are the date/time related ones
447 (setq org-time-was-given (equal (upcase char) char)) 475 (setq org-time-was-given (equal (upcase char) char))
448 (setq time (org-read-date (equal (upcase char) "U") t nil 476 (setq time (org-read-date (equal (upcase char) "U") t nil
449 prompt)) 477 prompt))
@@ -464,6 +492,11 @@ to be run from that hook to function properly."
464 (org-set-local 'org-finish-function 'org-remember-finalize)) 492 (org-set-local 'org-finish-function 'org-remember-finalize))
465 (when (save-excursion 493 (when (save-excursion
466 (goto-char (point-min)) 494 (goto-char (point-min))
495 (re-search-forward "%&" nil t))
496 (replace-match "")
497 (org-set-local 'org-jump-to-target-location t))
498 (when (save-excursion
499 (goto-char (point-min))
467 (re-search-forward "%!" nil t)) 500 (re-search-forward "%!" nil t))
468 (replace-match "") 501 (replace-match "")
469 (add-hook 'post-command-hook 'org-remember-finish-immediately 'append))) 502 (add-hook 'post-command-hook 'org-remember-finish-immediately 'append)))
@@ -476,15 +509,34 @@ from that hook."
476 (when org-finish-function 509 (when org-finish-function
477 (funcall org-finish-function))) 510 (funcall org-finish-function)))
478 511
479(defvar org-clock-marker) ; Defined below 512(defun org-remember-visit-immediately ()
513 "File remember note immediately.
514This should be run in `post-command-hook' and will remove itself
515from that hook."
516 (org-remember '(16))
517 (goto-char (or (text-property-any
518 (point) (save-excursion (org-end-of-subtree t t))
519 'org-position-cursor t)
520 (point)))
521 (message "%s"
522 (format
523 (substitute-command-keys
524 "Restore window configuration with \\[jump-to-register] %c")
525 remember-register)))
526
527(defvar org-clock-marker) ; Defined in org.el
480(defun org-remember-finalize () 528(defun org-remember-finalize ()
481 "Finalize the remember process." 529 "Finalize the remember process."
482 (unless (fboundp 'remember-finalize) 530 (unless (fboundp 'remember-finalize)
483 (defalias 'remember-finalize 'remember-buffer)) 531 (defalias 'remember-finalize 'remember-buffer))
484 (when (and org-clock-marker 532 (when (and org-clock-marker
485 (equal (marker-buffer org-clock-marker) (current-buffer))) 533 (equal (marker-buffer org-clock-marker) (current-buffer)))
486 ;; FIXME: test this, this is w/o notetaking! 534 ;; the clock is running in this buffer.
487 (let (org-log-note-clock-out) (org-clock-out))) 535 (when (and (equal (marker-buffer org-clock-marker) (current-buffer))
536 (or (eq org-remember-clock-out-on-exit t)
537 (and org-remember-clock-out-on-exit
538 (y-or-n-p "The clock is running in this buffer. Clock out now? "))))
539 (let (org-log-note-clock-out) (org-clock-out))))
488 (when buffer-file-name 540 (when buffer-file-name
489 (save-buffer) 541 (save-buffer)
490 (setq buffer-file-name nil)) 542 (setq buffer-file-name nil))
@@ -525,10 +577,14 @@ associated with a template in `org-remember-templates'."
525 (org-do-remember (buffer-substring (point) (mark))) 577 (org-do-remember (buffer-substring (point) (mark)))
526 (org-do-remember)))))) 578 (org-do-remember))))))
527 579
580(defvar org-remember-last-stored-marker (make-marker)
581 "Marker pointing to the entry most recently stored with `org-remember'.")
582
528(defun org-remember-goto-last-stored () 583(defun org-remember-goto-last-stored ()
529 "Go to the location where the last remember note was stored." 584 "Go to the location where the last remember note was stored."
530 (interactive) 585 (interactive)
531 (bookmark-jump "org-remember-last-stored") 586 (org-goto-marker-or-bmk org-remember-last-stored-marker
587 "org-remember-last-stored")
532 (message "This is the last note stored by remember")) 588 (message "This is the last note stored by remember"))
533 589
534(defun org-go-to-remember-target (&optional template-key) 590(defun org-go-to-remember-target (&optional template-key)
@@ -594,6 +650,11 @@ also indented so that it starts in the same column as the headline
594\(i.e. after the stars). 650\(i.e. after the stars).
595 651
596See also the variable `org-reverse-note-order'." 652See also the variable `org-reverse-note-order'."
653 (when (org-bound-and-true-p org-jump-to-target-location)
654 (let* ((end (min (point-max) (1+ (point))))
655 (beg (point)))
656 (if (= end beg) (setq beg (1- beg)))
657 (put-text-property beg end 'org-position-cursor t)))
597 (goto-char (point-min)) 658 (goto-char (point-min))
598 (while (looking-at "^[ \t]*\n\\|^##.*\n") 659 (while (looking-at "^[ \t]*\n\\|^##.*\n")
599 (replace-match "")) 660 (replace-match ""))
@@ -604,7 +665,7 @@ See also the variable `org-reverse-note-order'."
604 (beginning-of-line 1)) 665 (beginning-of-line 1))
605 (catch 'quit 666 (catch 'quit
606 (if org-note-abort (throw 'quit nil)) 667 (if org-note-abort (throw 'quit nil))
607 (let* ((txt (buffer-substring (point-min) (point-max))) 668 (let* ((visitp (org-bound-and-true-p org-jump-to-target-location))
608 (fastp (org-xor (equal current-prefix-arg '(4)) 669 (fastp (org-xor (equal current-prefix-arg '(4))
609 org-remember-store-without-prompt)) 670 org-remember-store-without-prompt))
610 (file (cond 671 (file (cond
@@ -620,46 +681,39 @@ See also the variable `org-reverse-note-order'."
620 (org-startup-folded nil) 681 (org-startup-folded nil)
621 (org-startup-align-all-tables nil) 682 (org-startup-align-all-tables nil)
622 (org-goto-start-pos 1) 683 (org-goto-start-pos 1)
623 spos exitcmd level indent reversed) 684 spos exitcmd level reversed txt)
624 (if (and (equal current-prefix-arg '(16)) org-remember-previous-location) 685 (if (and (equal current-prefix-arg '(16)) org-remember-previous-location)
625 (setq file (car org-remember-previous-location) 686 (setq file (car org-remember-previous-location)
626 heading (cdr org-remember-previous-location) 687 heading (cdr org-remember-previous-location)
627 fastp t)) 688 fastp t))
628 (setq current-prefix-arg nil) 689 (setq current-prefix-arg nil)
629 (if (string-match "[ \t\n]+\\'" txt)
630 (setq txt (replace-match "" t t txt)))
631 ;; Modify text so that it becomes a nice subtree which can be inserted 690 ;; Modify text so that it becomes a nice subtree which can be inserted
632 ;; into an org tree. 691 ;; into an org tree.
633 (let* ((lines (split-string txt "\n"))
634 first)
635 (setq first (car lines) lines (cdr lines))
636 (if (string-match "^\\*+ " first)
637 ;; Is already a headline
638 (setq indent nil)
639 ;; We need to add a headline: Use time and first buffer line
640 (setq lines (cons first lines)
641 first (concat "* " (current-time-string)
642 " (" (remember-buffer-desc) ")")
643 indent " "))
644 (if (and org-adapt-indentation indent)
645 (setq lines (mapcar
646 (lambda (x)
647 (if (string-match "\\S-" x)
648 (concat indent x) x))
649 lines)))
650 (setq txt (concat first "\n"
651 (mapconcat 'identity lines "\n"))))
652 (if (string-match "\n[ \t]*\n[ \t\n]*\\'" txt)
653 (setq txt (replace-match "\n\n" t t txt))
654 (if (string-match "[ \t\n]*\\'" txt)
655 (setq txt (replace-match "\n" t t txt))))
656 ;; Put the modified text back into the remember buffer, for refile.
657 (erase-buffer)
658 (insert txt)
659 (goto-char (point-min)) 692 (goto-char (point-min))
693 (if (re-search-forward "[ \t\n]+\\'" nil t)
694 ;; remove empty lines at end
695 (replace-match ""))
696 (goto-char (point-min))
697 (unless (looking-at org-outline-regexp)
698 ;; add a headline
699 (insert (concat "* " (current-time-string)
700 " (" (remember-buffer-desc) ")\n"))
701 (backward-char 1)
702 (when org-adapt-indentation
703 (while (re-search-forward "^" nil t)
704 (insert " "))))
705 (goto-char (point-min))
706 (if (re-search-forward "\n[ \t]*\n[ \t\n]*\\'" nil t)
707 (replace-match "\n\n")
708 (if (re-search-forward "[ \t\n]*\\'")
709 (replace-match "\n")))
710 (goto-char (point-min))
711 (setq txt (buffer-string))
712 (org-save-markers-in-region (point-min) (point-max))
660 (when (and (eq org-remember-interactive-interface 'refile) 713 (when (and (eq org-remember-interactive-interface 'refile)
661 (not fastp)) 714 (not fastp))
662 (org-refile nil (or visiting (find-file-noselect file))) 715 (org-refile nil (or visiting (find-file-noselect file)))
716 (and visitp (run-with-idle-timer 0.01 nil 'org-remember-visit-immediately))
663 (throw 'quit t)) 717 (throw 'quit t))
664 ;; Find the file 718 ;; Find the file
665 (if (not visiting) (find-file-noselect file)) 719 (if (not visiting) (find-file-noselect file))
@@ -671,25 +725,43 @@ See also the variable `org-reverse-note-order'."
671 (widen) 725 (widen)
672 (and (goto-char (point-min)) 726 (and (goto-char (point-min))
673 (not (re-search-forward "^\\* " nil t)) 727 (not (re-search-forward "^\\* " nil t))
674 (insert "\n* " (or heading "Notes") "\n")) 728 (insert "\n* " (or (and (stringp heading) heading)
729 "Notes") "\n"))
675 (setq reversed (org-notes-order-reversed-p)) 730 (setq reversed (org-notes-order-reversed-p))
676 731
677 ;; Find the default location 732 ;; Find the default location
678 (when (and heading (stringp heading) (string-match "\\S-" heading)) 733 (when heading
679 (goto-char (point-min)) 734 (cond
680 (if (re-search-forward 735 ((eq heading 'top)
681 (concat "^\\*+[ \t]+" (regexp-quote heading) 736 (goto-char (point-min))
682 (org-re "\\([ \t]+:[[:alnum:]@_:]*\\)?[ \t]*$")) 737 (or (looking-at org-outline-regexp)
683 nil t) 738 (re-search-forward org-outline-regexp nil t))
684 (setq org-goto-start-pos (match-beginning 0)) 739 (setq org-goto-start-pos (or (match-beginning 0) (point-min))))
685 (when fastp 740 ((eq heading 'bottom)
686 (goto-char (point-max)) 741 (goto-char (point-max))
687 (unless (bolp) (newline)) 742 (re-search-backward "^\\* " nil t)
688 (insert "* " heading "\n") 743 (or (bolp) (newline))
689 (setq org-goto-start-pos (point-at-bol 0))))) 744 (setq org-goto-start-pos (point)))
745 ((and (stringp heading) (string-match "\\S-" heading))
746 (goto-char (point-min))
747 (if (re-search-forward
748 (concat "^\\*+[ \t]+" (regexp-quote heading)
749 (org-re "\\([ \t]+:[[:alnum:]@_:]*\\)?[ \t]*$"))
750 nil t)
751 (setq org-goto-start-pos (match-beginning 0))
752 (when fastp
753 (goto-char (point-max))
754 (unless (bolp) (newline))
755 (insert "* " heading "\n")
756 (setq org-goto-start-pos (point-at-bol 0)))))
757 (t (goto-char (point-min)) (setq org-goto-start-pos (point)
758 heading 'top))))
690 759
691 ;; Ask the User for a location, using the appropriate interface 760 ;; Ask the User for a location, using the appropriate interface
692 (cond 761 (cond
762 ((and fastp (memq heading '(top bottom)))
763 (setq spos org-goto-start-pos
764 exitcmd (if (eq heading 'top) 'left 'right)))
693 (fastp (setq spos org-goto-start-pos 765 (fastp (setq spos org-goto-start-pos
694 exitcmd 'return)) 766 exitcmd 'return))
695 ((eq org-remember-interactive-interface 'outline) 767 ((eq org-remember-interactive-interface 'outline)
@@ -706,6 +778,7 @@ See also the variable `org-reverse-note-order'."
706 (t (error "This should not happen"))) 778 (t (error "This should not happen")))
707 (if (not spos) (throw 'quit nil)) ; return nil to show we did 779 (if (not spos) (throw 'quit nil)) ; return nil to show we did
708 ; not handle this note 780 ; not handle this note
781 (and visitp (run-with-idle-timer 0.01 nil 'org-remember-visit-immediately))
709 (goto-char spos) 782 (goto-char spos)
710 (cond ((org-on-heading-p t) 783 (cond ((org-on-heading-p t)
711 (org-back-to-heading t) 784 (org-back-to-heading t)
@@ -724,17 +797,23 @@ See also the variable `org-reverse-note-order'."
724 (beginning-of-line 2) 797 (beginning-of-line 2)
725 (end-of-line 1) 798 (end-of-line 1)
726 (insert "\n")))) 799 (insert "\n"))))
800 (org-paste-subtree (org-get-valid-level level 1) txt)
801 (and org-auto-align-tags (org-set-tags nil t))
727 (bookmark-set "org-remember-last-stored") 802 (bookmark-set "org-remember-last-stored")
728 (org-paste-subtree (org-get-valid-level level 1) txt)) 803 (move-marker org-remember-last-stored-marker (point)))
729 ((eq exitcmd 'left) 804 ((eq exitcmd 'left)
730 ;; before current 805 ;; before current
806 (org-paste-subtree level txt)
807 (and org-auto-align-tags (org-set-tags nil t))
731 (bookmark-set "org-remember-last-stored") 808 (bookmark-set "org-remember-last-stored")
732 (org-paste-subtree level txt)) 809 (move-marker org-remember-last-stored-marker (point)))
733 ((eq exitcmd 'right) 810 ((eq exitcmd 'right)
734 ;; after current 811 ;; after current
735 (org-end-of-subtree t) 812 (org-end-of-subtree t)
813 (org-paste-subtree level txt)
814 (and org-auto-align-tags (org-set-tags nil t))
736 (bookmark-set "org-remember-last-stored") 815 (bookmark-set "org-remember-last-stored")
737 (org-paste-subtree level txt)) 816 (move-marker org-remember-last-stored-marker (point)))
738 (t (error "This should not happen")))) 817 (t (error "This should not happen"))))
739 818
740 ((and (bobp) (not reversed)) 819 ((and (bobp) (not reversed))
@@ -743,8 +822,10 @@ See also the variable `org-reverse-note-order'."
743 (widen) 822 (widen)
744 (goto-char (point-max)) 823 (goto-char (point-max))
745 (if (not (bolp)) (newline)) 824 (if (not (bolp)) (newline))
825 (org-paste-subtree (org-get-valid-level 1 1) txt)
826 (and org-auto-align-tags (org-set-tags nil t))
746 (bookmark-set "org-remember-last-stored") 827 (bookmark-set "org-remember-last-stored")
747 (org-paste-subtree (org-get-valid-level 1 1) txt))) 828 (move-marker org-remember-last-stored-marker (point))))
748 829
749 ((and (bobp) reversed) 830 ((and (bobp) reversed)
750 ;; Put it at the start, as level 1 831 ;; Put it at the start, as level 1
@@ -753,18 +834,26 @@ See also the variable `org-reverse-note-order'."
753 (goto-char (point-min)) 834 (goto-char (point-min))
754 (re-search-forward "^\\*+ " nil t) 835 (re-search-forward "^\\*+ " nil t)
755 (beginning-of-line 1) 836 (beginning-of-line 1)
837 (org-paste-subtree 1 txt)
838 (and org-auto-align-tags (org-set-tags nil t))
756 (bookmark-set "org-remember-last-stored") 839 (bookmark-set "org-remember-last-stored")
757 (org-paste-subtree 1 txt))) 840 (move-marker org-remember-last-stored-marker (point))))
758 (t 841 (t
759 ;; Put it right there, with automatic level determined by 842 ;; Put it right there, with automatic level determined by
760 ;; org-paste-subtree or from prefix arg 843 ;; org-paste-subtree or from prefix arg
761 (bookmark-set "org-remember-last-stored")
762 (org-paste-subtree 844 (org-paste-subtree
763 (if (numberp current-prefix-arg) current-prefix-arg) 845 (if (numberp current-prefix-arg) current-prefix-arg)
764 txt))) 846 txt)
847 (and org-auto-align-tags (org-set-tags nil t))
848 (bookmark-set "org-remember-last-stored")
849 (move-marker org-remember-last-stored-marker (point))))
850
765 (when remember-save-after-remembering 851 (when remember-save-after-remembering
766 (save-buffer) 852 (save-buffer)
767 (if (not visiting) (kill-buffer (current-buffer))))))))) 853 (if (and (not visiting)
854 (not (equal (marker-buffer org-clock-marker)
855 (current-buffer))))
856 (kill-buffer (current-buffer)))))))))
768 857
769 t) ;; return t to indicate that we took care of this note. 858 t) ;; return t to indicate that we took care of this note.
770 859
@@ -775,6 +864,6 @@ See also the variable `org-reverse-note-order'."
775 864
776(provide 'org-remember) 865(provide 'org-remember)
777 866
778;;; org-remember.el ends here
779
780;; arch-tag: 497f30d0-4bc3-4097-8622-2d27ac5f2698 867;; arch-tag: 497f30d0-4bc3-4097-8622-2d27ac5f2698
868
869;;; org-remember.el ends here
diff --git a/lisp/org/org-rmail.el b/lisp/org/org-rmail.el
index af0e88780d3..337909f3af7 100644
--- a/lisp/org/org-rmail.el
+++ b/lisp/org/org-rmail.el
@@ -5,7 +5,7 @@
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;;
@@ -105,4 +105,5 @@
105(provide 'org-rmail) 105(provide 'org-rmail)
106 106
107;; arch-tag: c6cf4a8b-6639-4b7f-821f-bdf10746b173 107;; arch-tag: c6cf4a8b-6639-4b7f-821f-bdf10746b173
108
108;;; org-rmail.el ends here 109;;; org-rmail.el ends here
diff --git a/lisp/org/org-table.el b/lisp/org/org-table.el
index 6f9b57f38d0..45981776c43 100644
--- a/lisp/org/org-table.el
+++ b/lisp/org/org-table.el
@@ -5,7 +5,7 @@
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;;
@@ -187,7 +187,7 @@ t: accept as input and present for editing"
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
@@ -249,12 +249,11 @@ Automatically means, when TAB or RET or C-c C-c are pressed in the line."
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 254overridden on for a specific table by setting the TABLE_EXPORT_FORMAT
256 TABLE_EXPORT_FORMAT parameter. See orgtbl-export for the 255property. See the manual section on orgtbl radio tables for the different
257 different export transforms and available parameters." 256export transformations and available parameters."
258 :group 'org-table-import-export 257 :group 'org-table-import-export
259 :type 'string) 258 :type 'string)
260 259
@@ -428,7 +427,7 @@ are found, lines will be split on whitespace into fields."
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.
432Such a file can be imported into a spreadsheet program like Excel. 431Such a file can be imported into a spreadsheet program like Excel.
433FILE can be the output file name. If not given, it will be taken from 432FILE can be the output file name. If not given, it will be taken from
434a TABLE_EXPORT_FILE property in the current entry or higher up in the 433a TABLE_EXPORT_FILE property in the current entry or higher up in the
@@ -439,19 +438,33 @@ be found in the variable `org-table-export-default-format', but the function
439first checks if there is an export format specified in a TABLE_EXPORT_FORMAT 438first checks if there is an export format specified in a TABLE_EXPORT_FORMAT
440property, locally or anywhere up in the hierarchy." 439property, 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)))
@@ -2363,7 +2376,7 @@ With prefix arg ALL, do this for all lines in the table."
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)
@@ -2371,8 +2384,11 @@ With prefix arg ALL, do this for all lines in the table."
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)
@@ -3497,7 +3513,7 @@ a radio table."
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)
@@ -3629,6 +3645,7 @@ First element has index 0, or I0 if given."
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")
@@ -3670,7 +3687,9 @@ First element has index 0, or I0 if given."
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)
@@ -3698,13 +3717,14 @@ TABLE is a list, each entry either the symbol `hline' for a horizontal
3698separator line, or a list of fields for that line. 3717separator line, or a list of fields for that line.
3699PARAMS is a property list of parameters that can influence the conversion. 3718PARAMS is a property list of parameters that can influence the conversion.
3700For the generic converter, some parameters are obligatory: You need to 3719For the generic converter, some parameters are obligatory: You need to
3701specify either :lfmt, or all of (:lstart :lend :sep). If you do not use 3720specify either :lfmt, or all of (:lstart :lend :sep).
3702:splice, you must have :tstart and :tend.
3703 3721
3704Valid parameters are 3722Valid 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.
@@ -3713,8 +3733,8 @@ Valid parameters are
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 3736Each in the following group may be either a string or a function
3717 of no arguments returning a string: 3737of 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.
@@ -3722,9 +3742,9 @@ Valid parameters are
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 3745Each in the following group may be a string, a function of one
3726 argument (the field or line) returning a string, or a plist 3746argument (the field or line) returning a string, or a plist
3727 mapping columns to either of the above: 3747mapping 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.
@@ -3739,7 +3759,7 @@ Valid parameters are
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: 3762This 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
@@ -3768,8 +3788,9 @@ directly by `orgtbl-send-table'. See manual."
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.
@@ -3796,13 +3817,24 @@ directly by `orgtbl-send-table'. See manual."
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")))
3805 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.
3833This 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)))
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.
3808TABLE is a list, each entry either the symbol `hline' for a horizontal 3840TABLE is a list, each entry either the symbol `hline' for a horizontal
@@ -3908,7 +3940,24 @@ this function is called."
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.
3945Useful when slicing one table into many. The :hline, :sep,
3946:lstart, and :lend provide orgtbl framing. The default nil :tstart
3947and :tend suppress strings without splicing; they can be set to
3948provide 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
diff --git a/lisp/org/org-vm.el b/lisp/org/org-vm.el
index 1c93619bd86..032881e3eea 100644
--- a/lisp/org/org-vm.el
+++ b/lisp/org/org-vm.el
@@ -5,7 +5,7 @@
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;;
@@ -126,4 +126,5 @@
126(provide 'org-vm) 126(provide 'org-vm)
127 127
128;; arch-tag: cbc3047b-935e-4d2a-96e7-c5b0117aaa6d 128;; arch-tag: cbc3047b-935e-4d2a-96e7-c5b0117aaa6d
129
129;;; org-vm.el ends here 130;;; org-vm.el ends here
diff --git a/lisp/org/org-wl.el b/lisp/org/org-wl.el
index 9382edd217c..56ad2123972 100644
--- a/lisp/org/org-wl.el
+++ b/lisp/org/org-wl.el
@@ -5,7 +5,7 @@
5;; Author: Tokuya Kameshima <kames at fa2 dot so-net dot ne dot jp> 5;; Author: Tokuya Kameshima <kames at fa2 dot so-net dot ne dot jp>
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;;
@@ -142,4 +142,5 @@
142(provide 'org-wl) 142(provide 'org-wl)
143 143
144;; arch-tag: 29b75a0f-ef2e-430b-8abc-acff75bde54a 144;; arch-tag: 29b75a0f-ef2e-430b-8abc-acff75bde54a
145
145;;; org-wl.el ends here 146;;; org-wl.el ends here
diff --git a/lisp/org/org.el b/lisp/org/org.el
index 281b4ab732f..b47b52c879b 100644
--- a/lisp/org/org.el
+++ b/lisp/org/org.el
@@ -5,7 +5,7 @@
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;;
@@ -91,7 +91,7 @@
91 91
92;;; Version 92;;; Version
93 93
94(defconst org-version "6.02b" 94(defconst org-version "6.05a"
95 "The version number of the file org.el.") 95 "The version number of the file org.el.")
96 96
97(defun org-version (&optional here) 97(defun org-version (&optional here)
@@ -161,6 +161,7 @@ to add the symbol `xyz', and the package must have a call to
161 (const :tag " bbdb: Links to BBDB entries" org-bbdb) 161 (const :tag " bbdb: Links to BBDB entries" org-bbdb)
162 (const :tag " bibtex: Links to BibTeX entries" org-bibtex) 162 (const :tag " bibtex: Links to BibTeX entries" org-bibtex)
163 (const :tag " gnus: Links to GNUS folders/messages" org-gnus) 163 (const :tag " gnus: Links to GNUS folders/messages" org-gnus)
164 (const :tag " id: Global id's for identifying entries" org-id)
164 (const :tag " info: Links to Info nodes" org-info) 165 (const :tag " info: Links to Info nodes" org-info)
165 (const :tag " jsinfo: Set up Sebastian Rose's JavaScript org-info.js" org-jsinfo) 166 (const :tag " jsinfo: Set up Sebastian Rose's JavaScript org-info.js" org-jsinfo)
166 (const :tag " irc: Links to IRC/ERC chat sessions" org-irc) 167 (const :tag " irc: Links to IRC/ERC chat sessions" org-irc)
@@ -173,15 +174,17 @@ to add the symbol `xyz', and the package must have a call to
173 (const :tag " mouse: Additional mouse support" org-mouse) 174 (const :tag " mouse: Additional mouse support" org-mouse)
174 175
175 (const :tag "C annotate-file: Annotate a file with org syntax" org-annotate-file) 176 (const :tag "C annotate-file: Annotate a file with org syntax" org-annotate-file)
177 (const :tag "C annotation-helper: Call Remeber directly from Browser" org-annotation-helper)
176 (const :tag "C bookmark: Org links to bookmarks" org-bookmark) 178 (const :tag "C bookmark: Org links to bookmarks" org-bookmark)
177 (const :tag "C depend: TODO dependencies for Org-mode" org-depend) 179 (const :tag "C depend: TODO dependencies for Org-mode" org-depend)
178 (const :tag "C elisp-symbol: Org links to emacs-lisp symbols" org-elisp-symbol) 180 (const :tag "C elisp-symbol: Org links to emacs-lisp symbols" org-elisp-symbol)
181 (const :tag "C eval: Include command output as text" org-eval)
179 (const :tag "C expiry: Expiry mechanism for Org entries" org-expiry) 182 (const :tag "C expiry: Expiry mechanism for Org entries" org-expiry)
180 (const :tag "C id: Global id's for identifying entries" org-id) 183 (const :tag "C id: Global id's for identifying entries" org-id)
181 (const :tag "C interactive-query: Interactive modification of tags query" org-interactive-query) 184 (const :tag "C interactive-query: Interactive modification of tags query" org-interactive-query)
182 (const :tag "C mairix: Hook mairix search into Org for different MUAs" org-mairix) 185 (const :tag "C mairix: Hook mairix search into Org for different MUAs" org-mairix)
183 (const :tag "C man: Support for links to manpages in Org-mode" org-man) 186 (const :tag "C man: Support for links to manpages in Org-mode" org-man)
184 (const :tag "C mew: Support for links to messages in Mew" org-mew) 187 (const :tag "C mtags: Support for muse-like tags" org-mtags)
185 (const :tag "C panel: Simple routines for us with bad memory" org-panel) 188 (const :tag "C panel: Simple routines for us with bad memory" org-panel)
186 (const :tag "C registry: A registry for Org links" org-registry) 189 (const :tag "C registry: A registry for Org links" org-registry)
187 (const :tag "C org2rem: Convert org appointments into reminders" org2rem) 190 (const :tag "C org2rem: Convert org appointments into reminders" org2rem)
@@ -217,6 +220,20 @@ uninteresting. Also tables look terrible when wrapped."
217 :group 'org-startup 220 :group 'org-startup
218 :type 'boolean) 221 :type 'boolean)
219 222
223(defcustom org-startup-indented nil
224 "Non-nil means, turn on `org-indent-mode' on startup.
225This can also be configured on a per-file basis by adding one of
226the following lines anywhere in the buffer:
227
228 #+STARTUP: localindent
229 #+STARTUP: indent
230 #+STARTUP: noindent"
231 :group 'org-structure
232 :type '(choice
233 (const :tag "Not" nil)
234 (const :tag "Locally" local)
235 (const :tag "Globally (slow on startup in large files)" t)))
236
220(defcustom org-startup-align-all-tables nil 237(defcustom org-startup-align-all-tables nil
221 "Non-nil means, align all tables when visiting a file. 238 "Non-nil means, align all tables when visiting a file.
222This is useful when the column width in tables is forced with <N> cookies 239This is useful when the column width in tables is forced with <N> cookies
@@ -748,6 +765,12 @@ with \\[org-ctrl-c-ctrl-c\\]."
748 :group 'org-plain-lists 765 :group 'org-plain-lists
749 :type 'boolean) 766 :type 'boolean)
750 767
768(defcustom org-description-max-indent 20
769 "Maximum indentation for the second line of a description list.
770When the indentation would be larger than this, it will become
7715 characters instead."
772 :group 'org-plain-lists
773 :type 'integer)
751 774
752(defgroup org-imenu-and-speedbar nil 775(defgroup org-imenu-and-speedbar nil
753 "Options concerning imenu and speedbar in Org-mode." 776 "Options concerning imenu and speedbar in Org-mode."
@@ -1380,6 +1403,13 @@ by a letter in parenthesis, like TODO(t)."
1380 (const :tag "By default" t) 1403 (const :tag "By default" t)
1381 (const :tag "Only with C-u C-c C-t" prefix))) 1404 (const :tag "Only with C-u C-c C-t" prefix)))
1382 1405
1406(defcustom org-provide-todo-statistics t
1407 "Non-nil means, update todo statistics after insert and toggle.
1408When this is set, todo statistics is updated in the parent of the current
1409entry each time a todo state is changed."
1410 :group 'org-todo
1411 :type 'boolean)
1412
1383(defcustom org-after-todo-state-change-hook nil 1413(defcustom org-after-todo-state-change-hook nil
1384 "Hook which is run after the state of a TODO item was changed. 1414 "Hook which is run after the state of a TODO item was changed.
1385The new state (a string with a TODO keyword, or nil) is available in the 1415The new state (a string with a TODO keyword, or nil) is available in the
@@ -1463,8 +1493,8 @@ When nil, the notes will be orderer according to time."
1463 "Non-nil means, record moving through the DONE state when triggering repeat. 1493 "Non-nil means, record moving through the DONE state when triggering repeat.
1464An auto-repeating tasks is immediately switched back to TODO when marked 1494An auto-repeating tasks is immediately switched back to TODO when marked
1465done. If you are not logging state changes (by adding \"@\" or \"!\" to 1495done. If you are not logging state changes (by adding \"@\" or \"!\" to
1466the TODO keyword definition, or recording a cloing note by setting 1496the TODO keyword definition, or recording a closing note by setting
1467`org-log-done', there will be no record of the task moving trhough DONE. 1497`org-log-done', there will be no record of the task moving through DONE.
1468This variable forces taking a note anyway. Possible values are: 1498This variable forces taking a note anyway. Possible values are:
1469 1499
1470nil Don't force a record 1500nil Don't force a record
@@ -1590,6 +1620,12 @@ end of the second format."
1590 (concat "[" (substring f 1 -1) "]") 1620 (concat "[" (substring f 1 -1) "]")
1591 f))) 1621 f)))
1592 1622
1623(defcustom org-time-clocksum-format "%d:%02d"
1624 "The format string used when creating CLOCKSUM lines, or when
1625org-mode generates a time duration."
1626 :group 'org-time
1627 :type 'string)
1628
1593(defcustom org-deadline-warning-days 14 1629(defcustom org-deadline-warning-days 14
1594 "No. of days before expiration during which a deadline becomes active. 1630 "No. of days before expiration during which a deadline becomes active.
1595This variable governs the display in sparse trees and in the agenda. 1631This variable governs the display in sparse trees and in the agenda.
@@ -1682,6 +1718,12 @@ See the manual for details."
1682 (const :tag "Start radio group" (:startgroup)) 1718 (const :tag "Start radio group" (:startgroup))
1683 (const :tag "End radio group" (:endgroup))))) 1719 (const :tag "End radio group" (:endgroup)))))
1684 1720
1721(defvar org-file-tags nil
1722 "List of tags that can be inherited by all entries in the file.
1723The tags will be inherited if the variable `org-use-tag-inheritance'
1724says they should be.
1725This variable is populated from #+TAG lines.")
1726
1685(defcustom org-use-fast-tag-selection 'auto 1727(defcustom org-use-fast-tag-selection 'auto
1686 "Non-nil means, use fast tag selection scheme. 1728 "Non-nil means, use fast tag selection scheme.
1687This is a special interface to select and deselect tags with single keys. 1729This is a special interface to select and deselect tags with single keys.
@@ -1732,8 +1774,10 @@ the tags are again aligned to `org-tags-column'."
1732(defcustom org-use-tag-inheritance t 1774(defcustom org-use-tag-inheritance t
1733 "Non-nil means, tags in levels apply also for sublevels. 1775 "Non-nil means, tags in levels apply also for sublevels.
1734When nil, only the tags directly given in a specific line apply there. 1776When nil, only the tags directly given in a specific line apply there.
1735If you turn off this option, you very likely want to turn on the 1777If this option is t, a match early-on in a tree can lead to a large
1736companion option `org-tags-match-list-sublevels'. 1778number of matches in the subtree. If you only want to see the first
1779match in a tree during a search, check out the variable
1780`org-tags-match-list-sublevels'.
1737 1781
1738This may also be a list of tags that should be inherited, or a regexp that 1782This may also be a list of tags that should be inherited, or a regexp that
1739matches tags that should be inherited." 1783matches tags that should be inherited."
@@ -1755,7 +1799,7 @@ matches tags that should be inherited."
1755 (member tag org-use-tag-inheritance)) 1799 (member tag org-use-tag-inheritance))
1756 (t (error "Invalid setting of `org-use-tag-inheritance'")))) 1800 (t (error "Invalid setting of `org-use-tag-inheritance'"))))
1757 1801
1758(defcustom org-tags-match-list-sublevels nil 1802(defcustom org-tags-match-list-sublevels t
1759 "Non-nil means list also sublevels of headlines matching tag search. 1803 "Non-nil means list also sublevels of headlines matching tag search.
1760Because of tag inheritance (see variable `org-use-tag-inheritance'), 1804Because of tag inheritance (see variable `org-use-tag-inheritance'),
1761the sublevels of a headline matching a tag search often also match 1805the sublevels of a headline matching a tag search often also match
@@ -1839,6 +1883,17 @@ This variable can be set on the per-file basis by inserting a line
1839 :group 'org-properties 1883 :group 'org-properties
1840 :type 'string) 1884 :type 'string)
1841 1885
1886(defcustom org-columns-ellipses ".."
1887 "The ellipses to be used when a field in column view is truncated.
1888When this is the empty string, as many characters as possible are shown,
1889but then there will be no visual indication that the field has been truncated.
1890When this is a string of length N, the last N characters of a truncated
1891field are replaced by this string. If the column is narrower than the
1892ellipses string, only part of the ellipses string will be shown."
1893 :group 'org-properties
1894 :type 'string)
1895
1896
1842(defcustom org-effort-property "Effort" 1897(defcustom org-effort-property "Effort"
1843 "The property that is being used to keep track of effort estimates. 1898 "The property that is being used to keep track of effort estimates.
1844Effort estimates given in this property need to have the format H:MM." 1899Effort estimates given in this property need to have the format H:MM."
@@ -1846,6 +1901,12 @@ Effort estimates given in this property need to have the format H:MM."
1846 :group 'org-progress 1901 :group 'org-progress
1847 :type '(string :tag "Property")) 1902 :type '(string :tag "Property"))
1848 1903
1904(defconst org-global-properties-fixed
1905 '(("VISIBILITY_ALL" . "folded children content all"))
1906 "List of property/value pairs that can be inherited by any entry.
1907These are fixed values, for the preset properties.")
1908
1909
1849(defcustom org-global-properties nil 1910(defcustom org-global-properties nil
1850 "List of property/value pairs that can be inherited by any entry. 1911 "List of property/value pairs that can be inherited by any entry.
1851You can set buffer-local values for this by adding lines like 1912You can set buffer-local values for this by adding lines like
@@ -1856,10 +1917,11 @@ You can set buffer-local values for this by adding lines like
1856 (cons (string :tag "Property") 1917 (cons (string :tag "Property")
1857 (string :tag "Value")))) 1918 (string :tag "Value"))))
1858 1919
1859(defvar org-local-properties nil 1920(defvar org-file-properties nil
1860 "List of property/value pairs that can be inherited by any entry. 1921 "List of property/value pairs that can be inherited by any entry.
1861Valid for the current buffer. 1922Valid for the current buffer.
1862This variable is populated from #+PROPERTY lines.") 1923This variable is populated from #+PROPERTY lines.")
1924(make-variable-buffer-local 'org-file-properties)
1863 1925
1864(defgroup org-agenda nil 1926(defgroup org-agenda nil
1865 "Options concerning agenda views in Org-mode." 1927 "Options concerning agenda views in Org-mode."
@@ -1938,9 +2000,19 @@ forth between agenda and calendar."
1938 :group 'org-agenda 2000 :group 'org-agenda
1939 :type 'sexp) 2001 :type 'sexp)
1940 2002
2003(defcustom org-calendar-agenda-action-key [?k]
2004 "The key to be installed in `calendar-mode-map' for agenda-action.
2005The command `org-agenda-action' will be bound to this key. The
2006default is the character `k' because we use the same key in the agenda."
2007 :group 'org-agenda
2008 :type 'sexp)
2009
1941(eval-after-load "calendar" 2010(eval-after-load "calendar"
1942 '(org-defkey calendar-mode-map org-calendar-to-agenda-key 2011 '(progn
1943 'org-calendar-goto-agenda)) 2012 (org-defkey calendar-mode-map org-calendar-to-agenda-key
2013 'org-calendar-goto-agenda)
2014 (org-defkey calendar-mode-map org-calendar-agenda-action-key
2015 'org-agenda-action)))
1944 2016
1945(defgroup org-latex nil 2017(defgroup org-latex nil
1946 "Options for embedding LaTeX code into Org-mode." 2018 "Options for embedding LaTeX code into Org-mode."
@@ -2123,7 +2195,7 @@ Use customize to modify this, or restart Emacs after changing it."
2123 (sexp :tag "Forbidden chars in border ") 2195 (sexp :tag "Forbidden chars in border ")
2124 (sexp :tag "Regexp for body ") 2196 (sexp :tag "Regexp for body ")
2125 (integer :tag "number of newlines allowed") 2197 (integer :tag "number of newlines allowed")
2126 (option (boolean :tag "Stacking (DISABLED) ")))) 2198 (option (boolean :tag "Please ignore this button"))))
2127 2199
2128(defcustom org-emphasis-alist 2200(defcustom org-emphasis-alist
2129 `(("*" bold "<b>" "</b>") 2201 `(("*" bold "<b>" "</b>")
@@ -2200,6 +2272,8 @@ Normal means, no org-mode-specific context."
2200 (newhead hdmarker &optional fixface)) 2272 (newhead hdmarker &optional fixface))
2201(declare-function org-agenda-set-restriction-lock "org-agenda" (&optional type)) 2273(declare-function org-agenda-set-restriction-lock "org-agenda" (&optional type))
2202(declare-function org-agenda-maybe-redo "org-agenda" ()) 2274(declare-function org-agenda-maybe-redo "org-agenda" ())
2275(declare-function org-agenda-save-markers-for-cut-and-paste "org-agenda"
2276 (beg end))
2203(declare-function parse-time-string "parse-time" (string)) 2277(declare-function parse-time-string "parse-time" (string))
2204(declare-function remember "remember" (&optional initial)) 2278(declare-function remember "remember" (&optional initial))
2205(declare-function remember-buffer-desc "remember" ()) 2279(declare-function remember-buffer-desc "remember" ())
@@ -2345,6 +2419,7 @@ If TABLE-TYPE is non-nil, also check for table.el-type tables."
2345 org-replace-region-by-html org-export-region-as-html 2419 org-replace-region-by-html org-export-region-as-html
2346 org-export-as-html org-export-icalendar-this-file 2420 org-export-as-html org-export-icalendar-this-file
2347 org-export-icalendar-all-agenda-files 2421 org-export-icalendar-all-agenda-files
2422 org-table-clean-before-export
2348 org-export-icalendar-combine-agenda-files org-export-as-xoxo))) 2423 org-export-icalendar-combine-agenda-files org-export-as-xoxo)))
2349 2424
2350;; Declare and autoload functions from org-exp.el 2425;; Declare and autoload functions from org-exp.el
@@ -2364,6 +2439,11 @@ If TABLE-TYPE is non-nil, also check for table.el-type tables."
2364 2439
2365;; Autoload org-clock.el 2440;; Autoload org-clock.el
2366 2441
2442
2443(declare-function org-clock-save-markers-for-cut-and-paste "org-clock"
2444 (beg end))
2445(declare-function org-update-mode-line "org-clock" ())
2446(defvar org-clock-start-time)
2367(defvar org-clock-marker (make-marker) 2447(defvar org-clock-marker (make-marker)
2368 "Marker recording the last clock-in.") 2448 "Marker recording the last clock-in.")
2369 2449
@@ -2385,15 +2465,26 @@ Otherwise, return nil."
2385 (skip-chars-forward " \t") 2465 (skip-chars-forward " \t")
2386 (when (looking-at org-clock-string) 2466 (when (looking-at org-clock-string)
2387 (let ((re (concat "[ \t]*" org-clock-string 2467 (let ((re (concat "[ \t]*" org-clock-string
2388 " *[[<]\\([^]>]+\\)[]>]-+[[<]\\([^]>]+\\)[]>]" 2468 " *[[<]\\([^]>]+\\)[]>]\\(-+[[<]\\([^]>]+\\)[]>]"
2389 "\\([ \t]*=>.*\\)?")) 2469 "\\([ \t]*=>.*\\)?\\)?"))
2390 ts te h m s) 2470 ts te h m s)
2391 (if (not (looking-at re)) 2471 (cond
2392 nil 2472 ((not (looking-at re))
2393 (and (match-end 3) (delete-region (match-beginning 3) (match-end 3))) 2473 nil)
2474 ((not (match-end 2))
2475 (when (and (equal (marker-buffer org-clock-marker) (current-buffer))
2476 (> org-clock-marker (point))
2477 (<= org-clock-marker (point-at-eol)))
2478 ;; The clock is running here
2479 (setq org-clock-start-time
2480 (apply 'encode-time
2481 (org-parse-time-string (match-string 1))))
2482 (org-update-mode-line)))
2483 (t
2484 (and (match-end 4) (delete-region (match-beginning 4) (match-end 4)))
2394 (end-of-line 1) 2485 (end-of-line 1)
2395 (setq ts (match-string 1) 2486 (setq ts (match-string 1)
2396 te (match-string 2)) 2487 te (match-string 3))
2397 (setq s (- (time-to-seconds 2488 (setq s (- (time-to-seconds
2398 (apply 'encode-time (org-parse-time-string te))) 2489 (apply 'encode-time (org-parse-time-string te)))
2399 (time-to-seconds 2490 (time-to-seconds
@@ -2403,7 +2494,7 @@ Otherwise, return nil."
2403 m (floor (/ s 60)) 2494 m (floor (/ s 60))
2404 s (- s (* 60 s))) 2495 s (- s (* 60 s)))
2405 (insert " => " (format "%2d:%02d" h m)) 2496 (insert " => " (format "%2d:%02d" h m))
2406 t))))) 2497 t))))))
2407 2498
2408(defun org-check-running-clock () 2499(defun org-check-running-clock ()
2409 "Check if the current buffer contains the running clock. 2500 "Check if the current buffer contains the running clock.
@@ -2552,6 +2643,14 @@ collapsed state."
2552 org-columns-compute org-agenda-columns org-columns-remove-overlays 2643 org-columns-compute org-agenda-columns org-columns-remove-overlays
2553 org-columns org-insert-columns-dblock)) 2644 org-columns org-insert-columns-dblock))
2554 2645
2646;; Autoload ID code
2647
2648(org-autoload "org-id"
2649 '(org-id-get-create org-id-new org-id-copy org-id-get
2650 org-id-get-with-outline-path-completion
2651 org-id-get-with-outline-drilling
2652 org-id-goto org-id-find))
2653
2555;;; Variables for pre-computed regular expressions, all buffer local 2654;;; Variables for pre-computed regular expressions, all buffer local
2556 2655
2557(defvar org-drawer-regexp nil 2656(defvar org-drawer-regexp nil
@@ -2699,19 +2798,27 @@ means to push this value onto the list in the variable.")
2699 (org-set-local 'org-todo-heads nil) 2798 (org-set-local 'org-todo-heads nil)
2700 (org-set-local 'org-todo-sets nil) 2799 (org-set-local 'org-todo-sets nil)
2701 (org-set-local 'org-todo-log-states nil) 2800 (org-set-local 'org-todo-log-states nil)
2801 (org-set-local 'org-file-properties nil)
2802 (org-set-local 'org-file-tags nil)
2702 (let ((re (org-make-options-regexp 2803 (let ((re (org-make-options-regexp
2703 '("CATEGORY" "SEQ_TODO" "TYP_TODO" "TODO" "COLUMNS" 2804 '("CATEGORY" "SEQ_TODO" "TYP_TODO" "TODO" "COLUMNS"
2704 "STARTUP" "ARCHIVE" "TAGS" "LINK" "PRIORITIES" 2805 "STARTUP" "ARCHIVE" "FILETAGS" "TAGS" "LINK" "PRIORITIES"
2705 "CONSTANTS" "PROPERTY" "DRAWERS"))) 2806 "CONSTANTS" "PROPERTY" "DRAWERS" "SETUPFILE")))
2706 (splitre "[ \t]+") 2807 (splitre "[ \t]+")
2707 kwds kws0 kwsa key log value cat arch tags const links hw dws 2808 kwds kws0 kwsa key log value cat arch tags const links hw dws
2708 tail sep kws1 prio props drawers) 2809 tail sep kws1 prio props ftags drawers
2810 ext-setup-or-nil setup-contents (start 0))
2709 (save-excursion 2811 (save-excursion
2710 (save-restriction 2812 (save-restriction
2711 (widen) 2813 (widen)
2712 (goto-char (point-min)) 2814 (goto-char (point-min))
2713 (while (re-search-forward re nil t) 2815 (while (or (and ext-setup-or-nil
2714 (setq key (match-string 1) value (org-match-string-no-properties 2)) 2816 (string-match re ext-setup-or-nil start)
2817 (setq start (match-end 0)))
2818 (and (setq ext-setup-or-nil nil start 0)
2819 (re-search-forward re nil t)))
2820 (setq key (upcase (match-string 1 ext-setup-or-nil))
2821 value (org-match-string-no-properties 2 ext-setup-or-nil))
2715 (cond 2822 (cond
2716 ((equal key "CATEGORY") 2823 ((equal key "CATEGORY")
2717 (if (string-match "[ \t]+$" value) 2824 (if (string-match "[ \t]+$" value)
@@ -2736,6 +2843,14 @@ means to push this value onto the list in the variable.")
2736 (when (string-match "\\(\\S-+\\)\\s-+\\(.*\\)" value) 2843 (when (string-match "\\(\\S-+\\)\\s-+\\(.*\\)" value)
2737 (push (cons (match-string 1 value) (match-string 2 value)) 2844 (push (cons (match-string 1 value) (match-string 2 value))
2738 props))) 2845 props)))
2846 ((equal key "FILETAGS")
2847 (when (string-match "\\S-" value)
2848 (setq ftags
2849 (append
2850 ftags
2851 (apply 'append
2852 (mapcar (lambda (x) (org-split-string x ":"))
2853 (org-split-string value)))))))
2739 ((equal key "DRAWERS") 2854 ((equal key "DRAWERS")
2740 (setq drawers (org-split-string value splitre))) 2855 (setq drawers (org-split-string value splitre)))
2741 ((equal key "CONSTANTS") 2856 ((equal key "CONSTANTS")
@@ -2756,8 +2871,19 @@ means to push this value onto the list in the variable.")
2756 (string-match " *$" value) 2871 (string-match " *$" value)
2757 (setq arch (replace-match "" t t value)) 2872 (setq arch (replace-match "" t t value))
2758 (remove-text-properties 0 (length arch) 2873 (remove-text-properties 0 (length arch)
2759 '(face t fontified t) arch))) 2874 '(face t fontified t) arch))
2760 ))) 2875 ((equal key "SETUPFILE")
2876 (setq setup-contents (org-file-contents
2877 (expand-file-name
2878 (org-remove-double-quotes value))
2879 'noerror))
2880 (if (not ext-setup-or-nil)
2881 (setq ext-setup-or-nil setup-contents start 0)
2882 (setq ext-setup-or-nil
2883 (concat (substring ext-setup-or-nil 0 start)
2884 "\n" setup-contents "\n"
2885 (substring ext-setup-or-nil start)))))
2886 ))))
2761 (when cat 2887 (when cat
2762 (org-set-local 'org-category (intern cat)) 2888 (org-set-local 'org-category (intern cat))
2763 (push (cons "CATEGORY" cat) props)) 2889 (push (cons "CATEGORY" cat) props))
@@ -2767,7 +2893,8 @@ means to push this value onto the list in the variable.")
2767 (org-set-local 'org-highest-priority (nth 0 prio)) 2893 (org-set-local 'org-highest-priority (nth 0 prio))
2768 (org-set-local 'org-lowest-priority (nth 1 prio)) 2894 (org-set-local 'org-lowest-priority (nth 1 prio))
2769 (org-set-local 'org-default-priority (nth 2 prio))) 2895 (org-set-local 'org-default-priority (nth 2 prio)))
2770 (and props (org-set-local 'org-local-properties (nreverse props))) 2896 (and props (org-set-local 'org-file-properties (nreverse props)))
2897 (and ftags (org-set-local 'org-file-tags ftags))
2771 (and drawers (org-set-local 'org-drawers drawers)) 2898 (and drawers (org-set-local 'org-drawers drawers))
2772 (and arch (org-set-local 'org-archive-location arch)) 2899 (and arch (org-set-local 'org-archive-location arch))
2773 (and links (setq org-link-abbrev-alist-local (nreverse links))) 2900 (and links (setq org-link-abbrev-alist-local (nreverse links)))
@@ -2838,87 +2965,101 @@ means to push this value onto the list in the variable.")
2838 (while (setq e (pop tgs)) 2965 (while (setq e (pop tgs))
2839 (or (and (stringp (car e)) 2966 (or (and (stringp (car e))
2840 (assoc (car e) org-tag-alist)) 2967 (assoc (car e) org-tag-alist))
2841 (push e org-tag-alist)))))) 2968 (push e org-tag-alist)))))
2842 2969
2843 ;; Compute the regular expressions and other local variables 2970 ;; Compute the regular expressions and other local variables
2844 (if (not org-done-keywords) 2971 (if (not org-done-keywords)
2845 (setq org-done-keywords (list (org-last org-todo-keywords-1)))) 2972 (setq org-done-keywords (list (org-last org-todo-keywords-1))))
2846 (setq org-ds-keyword-length (+ 2 (max (length org-deadline-string) 2973 (setq org-ds-keyword-length (+ 2 (max (length org-deadline-string)
2847 (length org-scheduled-string) 2974 (length org-scheduled-string)
2848 (length org-clock-string) 2975 (length org-clock-string)
2849 (length org-closed-string))) 2976 (length org-closed-string)))
2850 org-drawer-regexp 2977 org-drawer-regexp
2851 (concat "^[ \t]*:\\(" 2978 (concat "^[ \t]*:\\("
2852 (mapconcat 'regexp-quote org-drawers "\\|") 2979 (mapconcat 'regexp-quote org-drawers "\\|")
2853 "\\):[ \t]*$") 2980 "\\):[ \t]*$")
2854 org-not-done-keywords 2981 org-not-done-keywords
2855 (org-delete-all org-done-keywords (copy-sequence org-todo-keywords-1)) 2982 (org-delete-all org-done-keywords (copy-sequence org-todo-keywords-1))
2856 org-todo-regexp 2983 org-todo-regexp
2857 (concat "\\<\\(" (mapconcat 'regexp-quote org-todo-keywords-1 2984 (concat "\\<\\(" (mapconcat 'regexp-quote org-todo-keywords-1
2858 "\\|") "\\)\\>") 2985 "\\|") "\\)\\>")
2859 org-not-done-regexp 2986 org-not-done-regexp
2860 (concat "\\<\\(" 2987 (concat "\\<\\("
2861 (mapconcat 'regexp-quote org-not-done-keywords "\\|") 2988 (mapconcat 'regexp-quote org-not-done-keywords "\\|")
2862 "\\)\\>") 2989 "\\)\\>")
2863 org-todo-line-regexp 2990 org-todo-line-regexp
2864 (concat "^\\(\\*+\\)[ \t]+\\(?:\\(" 2991 (concat "^\\(\\*+\\)[ \t]+\\(?:\\("
2865 (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") 2992 (mapconcat 'regexp-quote org-todo-keywords-1 "\\|")
2866 "\\)\\>\\)?[ \t]*\\(.*\\)") 2993 "\\)\\>\\)?[ \t]*\\(.*\\)")
2867 org-complex-heading-regexp 2994 org-complex-heading-regexp
2868 (concat "^\\(\\*+\\)\\(?:[ \t]+\\(" 2995 (concat "^\\(\\*+\\)\\(?:[ \t]+\\("
2869 (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") 2996 (mapconcat 'regexp-quote org-todo-keywords-1 "\\|")
2870 "\\)\\>\\)?\\(?:[ \t]*\\(\\[#.\\]\\)\\)?[ \t]*\\(.*?\\)" 2997 "\\)\\>\\)?\\(?:[ \t]*\\(\\[#.\\]\\)\\)?[ \t]*\\(.*?\\)"
2871 "\\(?:[ \t]+\\(:[[:alnum:]_@:]+:\\)\\)?[ \t]*$") 2998 "\\(?:[ \t]+\\(:[[:alnum:]_@:]+:\\)\\)?[ \t]*$")
2872 org-nl-done-regexp 2999 org-nl-done-regexp
2873 (concat "\n\\*+[ \t]+" 3000 (concat "\n\\*+[ \t]+"
2874 "\\(?:" (mapconcat 'regexp-quote org-done-keywords "\\|") 3001 "\\(?:" (mapconcat 'regexp-quote org-done-keywords "\\|")
2875 "\\)" "\\>") 3002 "\\)" "\\>")
2876 org-todo-line-tags-regexp 3003 org-todo-line-tags-regexp
2877 (concat "^\\(\\*+\\)[ \t]+\\(?:\\(" 3004 (concat "^\\(\\*+\\)[ \t]+\\(?:\\("
2878 (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") 3005 (mapconcat 'regexp-quote org-todo-keywords-1 "\\|")
2879 (org-re 3006 (org-re
2880 "\\)\\>\\)? *\\(.*?\\([ \t]:[[:alnum:]:_@]+:[ \t]*\\)?$\\)")) 3007 "\\)\\>\\)? *\\(.*?\\([ \t]:[[:alnum:]:_@]+:[ \t]*\\)?$\\)"))
2881 org-looking-at-done-regexp 3008 org-looking-at-done-regexp
2882 (concat "^" "\\(?:" 3009 (concat "^" "\\(?:"
2883 (mapconcat 'regexp-quote org-done-keywords "\\|") "\\)" 3010 (mapconcat 'regexp-quote org-done-keywords "\\|") "\\)"
2884 "\\>") 3011 "\\>")
2885 org-deadline-regexp (concat "\\<" org-deadline-string) 3012 org-deadline-regexp (concat "\\<" org-deadline-string)
2886 org-deadline-time-regexp 3013 org-deadline-time-regexp
2887 (concat "\\<" org-deadline-string " *<\\([^>]+\\)>") 3014 (concat "\\<" org-deadline-string " *<\\([^>]+\\)>")
2888 org-deadline-line-regexp 3015 org-deadline-line-regexp
2889 (concat "\\<\\(" org-deadline-string "\\).*") 3016 (concat "\\<\\(" org-deadline-string "\\).*")
2890 org-scheduled-regexp 3017 org-scheduled-regexp
2891 (concat "\\<" org-scheduled-string) 3018 (concat "\\<" org-scheduled-string)
2892 org-scheduled-time-regexp 3019 org-scheduled-time-regexp
2893 (concat "\\<" org-scheduled-string " *<\\([^>]+\\)>") 3020 (concat "\\<" org-scheduled-string " *<\\([^>]+\\)>")
2894 org-closed-time-regexp 3021 org-closed-time-regexp
2895 (concat "\\<" org-closed-string " *\\[\\([^]]+\\)\\]") 3022 (concat "\\<" org-closed-string " *\\[\\([^]]+\\)\\]")
2896 org-keyword-time-regexp 3023 org-keyword-time-regexp
2897 (concat "\\<\\(" org-scheduled-string 3024 (concat "\\<\\(" org-scheduled-string
2898 "\\|" org-deadline-string 3025 "\\|" org-deadline-string
2899 "\\|" org-closed-string 3026 "\\|" org-closed-string
2900 "\\|" org-clock-string "\\)" 3027 "\\|" org-clock-string "\\)"
2901 " *[[<]\\([^]>]+\\)[]>]") 3028 " *[[<]\\([^]>]+\\)[]>]")
2902 org-keyword-time-not-clock-regexp 3029 org-keyword-time-not-clock-regexp
2903 (concat "\\<\\(" org-scheduled-string 3030 (concat "\\<\\(" org-scheduled-string
2904 "\\|" org-deadline-string 3031 "\\|" org-deadline-string
2905 "\\|" org-closed-string 3032 "\\|" org-closed-string
2906 "\\)" 3033 "\\)"
2907 " *[[<]\\([^]>]+\\)[]>]") 3034 " *[[<]\\([^]>]+\\)[]>]")
2908 org-maybe-keyword-time-regexp 3035 org-maybe-keyword-time-regexp
2909 (concat "\\(\\<\\(" org-scheduled-string 3036 (concat "\\(\\<\\(" org-scheduled-string
2910 "\\|" org-deadline-string 3037 "\\|" org-deadline-string
2911 "\\|" org-closed-string 3038 "\\|" org-closed-string
2912 "\\|" org-clock-string "\\)\\)?" 3039 "\\|" org-clock-string "\\)\\)?"
2913 " *\\([[<][0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [^]\r\n>]*?[]>]\\|<%%([^\r\n>]*>\\)") 3040 " *\\([[<][0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [^]\r\n>]*?[]>]\\|<%%([^\r\n>]*>\\)")
2914 org-planning-or-clock-line-re 3041 org-planning-or-clock-line-re
2915 (concat "\\(?:^[ \t]*\\(" org-scheduled-string 3042 (concat "\\(?:^[ \t]*\\(" org-scheduled-string
2916 "\\|" org-deadline-string 3043 "\\|" org-deadline-string
2917 "\\|" org-closed-string "\\|" org-clock-string 3044 "\\|" org-closed-string "\\|" org-clock-string
2918 "\\)\\>\\)") 3045 "\\)\\>\\)")
2919 ) 3046 )
2920 (org-compute-latex-and-specials-regexp) 3047 (org-compute-latex-and-specials-regexp)
2921 (org-set-font-lock-defaults))) 3048 (org-set-font-lock-defaults))))
3049
3050(defun org-file-contents (file &optional noerror)
3051 "Return the contents of FILE, as a string."
3052 (if (or (not file)
3053 (not (file-readable-p file)))
3054 (if noerror
3055 (progn
3056 (message "Cannot read file %s" file)
3057 (ding) (sit-for 2)
3058 "")
3059 (error "Cannot read file %s" file))
3060 (with-temp-buffer
3061 (insert-file-contents file)
3062 (buffer-string))))
2922 3063
2923(defun org-extract-log-state-settings (x) 3064(defun org-extract-log-state-settings (x)
2924 "Extract the log state setting from a TODO keyword string. 3065 "Extract the log state setting from a TODO keyword string.
@@ -3123,13 +3264,7 @@ The following commands are available:
3123 (let ((bmp (buffer-modified-p))) 3264 (let ((bmp (buffer-modified-p)))
3124 (org-table-map-tables 'org-table-align) 3265 (org-table-map-tables 'org-table-align)
3125 (set-buffer-modified-p bmp))) 3266 (set-buffer-modified-p bmp)))
3126 (org-cycle-hide-drawers 'all) 3267 (org-set-startup-visibility)))
3127 (cond
3128 ((eq org-startup-folded t)
3129 (org-cycle '(4)))
3130 ((eq org-startup-folded 'content)
3131 (let ((this-command 'org-cycle) (last-command 'org-cycle))
3132 (org-cycle '(4)) (org-cycle '(4)))))))
3133 3268
3134(put 'org-mode 'flyspell-mode-predicate 'org-mode-flyspell-verify) 3269(put 'org-mode 'flyspell-mode-predicate 'org-mode-flyspell-verify)
3135 3270
@@ -3583,14 +3718,22 @@ between words."
3583 3718
3584(defvar org-font-lock-keywords nil) 3719(defvar org-font-lock-keywords nil)
3585 3720
3586(defconst org-property-re (org-re "^[ \t]*\\(:\\([[:alnum:]_]+\\):\\)[ \t]*\\([^ \t\r\n].*\\)") 3721(defconst org-property-re (org-re "^[ \t]*\\(:\\([-[:alnum:]_]+\\):\\)[ \t]*\\([^ \t\r\n].*\\)")
3587 "Regular expression matching a property line.") 3722 "Regular expression matching a property line.")
3588 3723
3724(defvar org-font-lock-hook nil
3725 "Functions to be called for special font lock stuff.")
3726
3727(defun org-font-lock-hook (limit)
3728 (run-hook-with-args 'org-font-lock-hook limit))
3729
3589(defun org-set-font-lock-defaults () 3730(defun org-set-font-lock-defaults ()
3590 (let* ((em org-fontify-emphasized-text) 3731 (let* ((em org-fontify-emphasized-text)
3591 (lk org-activate-links) 3732 (lk org-activate-links)
3592 (org-font-lock-extra-keywords 3733 (org-font-lock-extra-keywords
3593 (list 3734 (list
3735 ;; Call the hook
3736 '(org-font-lock-hook)
3594 ;; Headlines 3737 ;; Headlines
3595 '("^\\(\\**\\)\\(\\* \\)\\(.*\\)" (1 (org-get-level-face 1)) 3738 '("^\\(\\**\\)\\(\\* \\)\\(.*\\)" (1 (org-get-level-face 1))
3596 (2 (org-get-level-face 2)) (3 (org-get-level-face 3))) 3739 (2 (org-get-level-face 2)) (3 (org-get-level-face 3)))
@@ -3647,6 +3790,9 @@ between words."
3647 (if org-provide-checkbox-statistics 3790 (if org-provide-checkbox-statistics
3648 '("\\[\\([0-9]*%\\)\\]\\|\\[\\([0-9]*\\)/\\([0-9]*\\)\\]" 3791 '("\\[\\([0-9]*%\\)\\]\\|\\[\\([0-9]*\\)/\\([0-9]*\\)\\]"
3649 (0 (org-get-checkbox-statistics-face) t))) 3792 (0 (org-get-checkbox-statistics-face) t)))
3793 ;; Description list items
3794 '("^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +\\(.*? ::\\)"
3795 2 'bold prepend)
3650 (list (concat "^\\*+ \\(.*:" org-archive-tag ":.*\\)") 3796 (list (concat "^\\*+ \\(.*:" org-archive-tag ":.*\\)")
3651 '(1 'org-archived prepend)) 3797 '(1 'org-archived prepend))
3652 ;; Specials 3798 ;; Specials
@@ -3716,6 +3862,9 @@ If KWD is a number, get the corresponding match group."
3716 1. OVERVIEW: Show only top-level headlines. 3862 1. OVERVIEW: Show only top-level headlines.
3717 2. CONTENTS: Show all headlines of all levels, but no body text. 3863 2. CONTENTS: Show all headlines of all levels, but no body text.
3718 3. SHOW ALL: Show everything. 3864 3. SHOW ALL: Show everything.
3865 When called with two C-c C-u prefixes, switch to the startup visibility,
3866 determined by the variable `org-startup-folded', and by any VISIBILITY
3867 properties in the buffer.
3719 3868
3720- When point is at the beginning of a headline, rotate the subtree started 3869- When point is at the beginning of a headline, rotate the subtree started
3721 by this line through 3 different states (local cycling) 3870 by this line through 3 different states (local cycling)
@@ -3729,8 +3878,8 @@ If KWD is a number, get the corresponding match group."
3729 a `show-subtree' and return to the previous cursor position. If ARG 3878 a `show-subtree' and return to the previous cursor position. If ARG
3730 is negative, go up that many levels. 3879 is negative, go up that many levels.
3731 3880
3732- When point is not at the beginning of a headline, execute 3881- When point is not at the beginning of a headline, execute the global
3733 `indent-relative', like TAB normally does. See the option 3882 binding for TAB, which is re-indenting the line. See the option
3734 `org-cycle-emulate-tab' for details. 3883 `org-cycle-emulate-tab' for details.
3735 3884
3736- Special case: if point is at the beginning of the buffer and there is 3885- Special case: if point is at the beginning of the buffer and there is
@@ -3757,6 +3906,10 @@ If KWD is a number, get the corresponding match group."
3757 3906
3758 (cond 3907 (cond
3759 3908
3909 ((equal arg '(16))
3910 (org-set-startup-visibility)
3911 (message "Startup visibility, plus VISIBILITY properties."))
3912
3760 ((org-at-table-p 'any) 3913 ((org-at-table-p 'any)
3761 ;; Enter the table or move to the next field in the table 3914 ;; Enter the table or move to the next field in the table
3762 (or (org-table-recognize-table.el) 3915 (or (org-table-recognize-table.el)
@@ -3865,9 +4018,11 @@ If KWD is a number, get the corresponding match group."
3865 (setq org-cycle-subtree-status 'folded) 4018 (setq org-cycle-subtree-status 'folded)
3866 (run-hook-with-args 'org-cycle-hook 'folded))))) 4019 (run-hook-with-args 'org-cycle-hook 'folded)))))
3867 4020
3868 ;; TAB emulation 4021 ;; TAB emulation and template completion
3869 (buffer-read-only (org-back-to-heading)) 4022 (buffer-read-only (org-back-to-heading))
3870 4023
4024 ((org-try-structure-completion))
4025
3871 ((org-try-cdlatex-tab)) 4026 ((org-try-cdlatex-tab))
3872 4027
3873 ((and (eq org-cycle-emulate-tab 'exc-hl-bol) 4028 ((and (eq org-cycle-emulate-tab 'exc-hl-bol)
@@ -3891,16 +4046,67 @@ If KWD is a number, get the corresponding match group."
3891 4046
3892;;;###autoload 4047;;;###autoload
3893(defun org-global-cycle (&optional arg) 4048(defun org-global-cycle (&optional arg)
3894 "Cycle the global visibility. For details see `org-cycle'." 4049 "Cycle the global visibility. For details see `org-cycle'.
4050With C-u prefix arg, switch to startup visibility.
4051With a numeric prefix, show all headlines up to that level."
3895 (interactive "P") 4052 (interactive "P")
3896 (let ((org-cycle-include-plain-lists 4053 (let ((org-cycle-include-plain-lists
3897 (if (org-mode-p) org-cycle-include-plain-lists nil))) 4054 (if (org-mode-p) org-cycle-include-plain-lists nil)))
3898 (if (integerp arg) 4055 (cond
3899 (progn 4056 ((integerp arg)
3900 (show-all) 4057 (show-all)
3901 (hide-sublevels arg) 4058 (hide-sublevels arg)
3902 (setq org-cycle-global-status 'contents)) 4059 (setq org-cycle-global-status 'contents))
3903 (org-cycle '(4))))) 4060 ((equal arg '(4))
4061 (org-set-startup-visibility)
4062 (message "Startup visibility, plus VISIBILITY properties."))
4063 (t
4064 (org-cycle '(4))))))
4065
4066(defun org-set-startup-visibility ()
4067 "Set the visibility required by startup options and properties."
4068 (cond
4069 ((eq org-startup-folded t)
4070 (org-cycle '(4)))
4071 ((eq org-startup-folded 'content)
4072 (let ((this-command 'org-cycle) (last-command 'org-cycle))
4073 (org-cycle '(4)) (org-cycle '(4)))))
4074 (org-set-visibility-according-to-property 'no-cleanup)
4075 (org-cycle-hide-archived-subtrees 'all)
4076 (org-cycle-hide-drawers 'all)
4077 (org-cycle-show-empty-lines 'all))
4078
4079(defun org-set-visibility-according-to-property (&optional no-cleanup)
4080 "Switch subtree visibilities according to :VISIBILITY: property."
4081 (interactive)
4082 (let (state)
4083 (save-excursion
4084 (goto-char (point-min))
4085 (while (re-search-forward
4086 "^[ \t]*:VISIBILITY:[ \t]+\\([a-z]+\\)"
4087 nil t)
4088 (setq state (match-string 1))
4089 (save-excursion
4090 (org-back-to-heading t)
4091 (hide-subtree)
4092 (org-reveal)
4093 (cond
4094 ((equal state '("fold" "folded"))
4095 (hide-subtree))
4096 ((equal state "children")
4097 (org-show-hidden-entry)
4098 (show-children))
4099 ((equal state "content")
4100 (save-excursion
4101 (save-restriction
4102 (org-narrow-to-subtree)
4103 (org-content))))
4104 ((member state '("all" "showall"))
4105 (show-subtree)))))
4106 (unless no-cleanup
4107 (org-cycle-hide-archived-subtrees 'all)
4108 (org-cycle-hide-drawers 'all)
4109 (org-cycle-show-empty-lines 'all)))))
3904 4110
3905(defun org-overview () 4111(defun org-overview ()
3906 "Switch to overview mode, shoing only top-level headlines. 4112 "Switch to overview mode, shoing only top-level headlines.
@@ -4024,8 +4230,6 @@ are at least `org-cycle-separator-lines' empty lines before the headeline."
4024 (outline-flag-region b (point-at-eol) flag) 4230 (outline-flag-region b (point-at-eol) flag)
4025 (error ":END: line missing")))))) 4231 (error ":END: line missing"))))))
4026 4232
4027
4028
4029(defun org-subtree-end-visible-p () 4233(defun org-subtree-end-visible-p ()
4030 "Is the end of the current subtree visible?" 4234 "Is the end of the current subtree visible?"
4031 (pos-visible-in-window-p 4235 (pos-visible-in-window-p
@@ -4083,6 +4287,7 @@ RET=jump to location [Q]uit and return to previous location
4083 4287
4084(defvar org-goto-start-pos) ; dynamically scoped parameter 4288(defvar org-goto-start-pos) ; dynamically scoped parameter
4085 4289
4290;; FIXME: Docstring doe not mention both interfaces
4086(defun org-goto (&optional alternative-interface) 4291(defun org-goto (&optional alternative-interface)
4087 "Look up a different location in the current file, keeping current visibility. 4292 "Look up a different location in the current file, keeping current visibility.
4088 4293
@@ -4405,7 +4610,9 @@ state (TODO by default). Also with prefix arg, force first state."
4405 (not (match-beginning 2)) 4610 (not (match-beginning 2))
4406 (member (match-string 2) org-done-keywords)) 4611 (member (match-string 2) org-done-keywords))
4407 (insert (car org-todo-keywords-1) " ") 4612 (insert (car org-todo-keywords-1) " ")
4408 (insert (match-string 2) " ")))) 4613 (insert (match-string 2) " "))
4614 (when org-provide-todo-statistics
4615 (org-update-parent-todo-statistics))))
4409 4616
4410(defun org-insert-subheading (arg) 4617(defun org-insert-subheading (arg)
4411 "Insert a new subheading and demote it. 4618 "Insert a new subheading and demote it.
@@ -4665,10 +4872,14 @@ is signaled in this case."
4665 (setq ne-ins (org-back-over-empty-lines)) 4872 (setq ne-ins (org-back-over-empty-lines))
4666 (move-marker ins-point (point)) 4873 (move-marker ins-point (point))
4667 (setq txt (buffer-substring beg end)) 4874 (setq txt (buffer-substring beg end))
4875 (org-save-markers-in-region beg end)
4668 (delete-region beg end) 4876 (delete-region beg end)
4669 (outline-flag-region (1- beg) beg nil) 4877 (outline-flag-region (1- beg) beg nil)
4670 (outline-flag-region (1- (point)) (point) nil) 4878 (outline-flag-region (1- (point)) (point) nil)
4671 (insert txt) 4879 (let ((bbb (point)))
4880 (insert-before-markers txt)
4881 (org-reinstall-markers-in-region bbb)
4882 (move-marker ins-point bbb))
4672 (or (bolp) (insert "\n")) 4883 (or (bolp) (insert "\n"))
4673 (setq ins-end (point)) 4884 (setq ins-end (point))
4674 (goto-char ins-point) 4885 (goto-char ins-point)
@@ -4705,11 +4916,14 @@ This is a short-hand for marking the subtree and then cutting it."
4705 (interactive "p") 4916 (interactive "p")
4706 (org-copy-subtree n 'cut)) 4917 (org-copy-subtree n 'cut))
4707 4918
4708(defun org-copy-subtree (&optional n cut) 4919(defun org-copy-subtree (&optional n cut force-store-markers)
4709 "Cut the current subtree into the clipboard. 4920 "Cut the current subtree into the clipboard.
4710With prefix arg N, cut this many sequential subtrees. 4921With prefix arg N, cut this many sequential subtrees.
4711This is a short-hand for marking the subtree and then copying it. 4922This is a short-hand for marking the subtree and then copying it.
4712If CUT is non-nil, actually cut the subtree." 4923If CUT is non-nil, actually cut the subtree.
4924If FORCE-STORE-MARKERS is non-nil, store the relative locations
4925of some markers in the region, even if CUT is non-nil. This is
4926useful if the caller implements cut-and-paste as copy-then-paste-then-cut."
4713 (interactive "p") 4927 (interactive "p")
4714 (let (beg end folded (beg0 (point))) 4928 (let (beg end folded (beg0 (point)))
4715 (if (interactive-p) 4929 (if (interactive-p)
@@ -4730,6 +4944,8 @@ If CUT is non-nil, actually cut the subtree."
4730 (goto-char beg0) 4944 (goto-char beg0)
4731 (when (> end beg) 4945 (when (> end beg)
4732 (setq org-subtree-clip-folded folded) 4946 (setq org-subtree-clip-folded folded)
4947 (when (or cut force-store-markers)
4948 (org-save-markers-in-region beg end))
4733 (if cut (kill-region beg end) (copy-region-as-kill beg end)) 4949 (if cut (kill-region beg end) (copy-region-as-kill beg end))
4734 (setq org-subtree-clip (current-kill 0)) 4950 (setq org-subtree-clip (current-kill 0))
4735 (message "%s: Subtree(s) with %d characters" 4951 (message "%s: Subtree(s) with %d characters"
@@ -4807,6 +5023,7 @@ If optional TREE is given, use this text instead of the kill ring."
4807 (setq beg (point)) 5023 (setq beg (point))
4808 (insert-before-markers txt) 5024 (insert-before-markers txt)
4809 (unless (string-match "\n\\'" txt) (insert "\n")) 5025 (unless (string-match "\n\\'" txt) (insert "\n"))
5026 (org-reinstall-markers-in-region beg)
4810 (setq end (point)) 5027 (setq end (point))
4811 (goto-char beg) 5028 (goto-char beg)
4812 (skip-chars-forward " \t\n\r") 5029 (skip-chars-forward " \t\n\r")
@@ -4851,6 +5068,40 @@ If optional TXT is given, check this string instead of the current kill."
4851 (throw 'exit nil))) 5068 (throw 'exit nil)))
4852 t)))) 5069 t))))
4853 5070
5071(defvar org-markers-to-move nil
5072 "Markers that should be moved with a cut-and-paste operation.
5073Those markers are stored together with their positions relative to
5074the start of the region.")
5075
5076(defun org-save-markers-in-region (beg end)
5077 "Check markers in region.
5078If these markers are between BEG and END, record their position relative
5079to BEG, so that after moving the block of text, we can put the markers back
5080into place.
5081This function gets called just before an entry or tree gets cut from the
5082buffer. After re-insertion, `org-reinstall-markers-in-region' must be
5083called immediately, to move the markers with the entries."
5084 (setq org-markers-to-move nil)
5085 (when (featurep 'org-clock)
5086 (org-clock-save-markers-for-cut-and-paste beg end))
5087 (when (featurep 'org-agenda)
5088 (org-agenda-save-markers-for-cut-and-paste beg end)))
5089
5090(defun org-check-and-save-marker (marker beg end)
5091 "Check if MARKER is between BEG and END.
5092If yes, remember the marker and the distance to BEG."
5093 (when (and (marker-buffer marker)
5094 (equal (marker-buffer marker) (current-buffer)))
5095 (if (and (>= marker beg) (< marker end))
5096 (push (cons marker (- marker beg)) org-markers-to-move))))
5097
5098(defun org-reinstall-markers-in-region (beg)
5099 "Move all remembered markers to their position relative to BEG."
5100 (mapc (lambda (x)
5101 (move-marker (car x) (+ beg (cdr x))))
5102 org-markers-to-move)
5103 (setq org-markers-to-move nil))
5104
4854(defun org-narrow-to-subtree () 5105(defun org-narrow-to-subtree ()
4855 "Narrow buffer to the current subtree." 5106 "Narrow buffer to the current subtree."
4856 (interactive) 5107 (interactive)
@@ -5104,6 +5355,147 @@ If WITH-CASE is non-nil, the sorting will be case-sensitive."
5104 table) 5355 table)
5105 (lambda (a b) (funcall comparefun (car a) (car b)))))) 5356 (lambda (a b) (funcall comparefun (car a) (car b))))))
5106 5357
5358;;; Editing source examples
5359
5360(defvar org-exit-edit-mode-map (make-sparse-keymap))
5361(define-key org-exit-edit-mode-map "\C-c'" 'org-edit-src-exit)
5362(defvar org-edit-src-force-single-line nil)
5363(defvar org-edit-src-from-org-mode nil)
5364
5365(define-minor-mode org-exit-edit-mode
5366 "Minor mode installing a single key binding, \"C-c '\" to exit special edit.")
5367
5368(defun org-edit-src-code ()
5369 "Edit the source code example at point.
5370An indirect buffer is created, and that buffer is then narrowed to the
5371example at point and switched to the correct language mode. When done,
5372exit by killing the buffer with \\[org-edit-src-exit]."
5373 (interactive)
5374 (let ((line (org-current-line))
5375 (case-fold-search t)
5376 (msg (substitute-command-keys
5377 "Edit, then exit with C-c ' (C-c and single quote)"))
5378 (info (org-edit-src-find-region-and-lang))
5379 (org-mode-p (eq major-mode 'org-mode))
5380 beg end lang lang-f single)
5381 (if (not info)
5382 nil
5383 (setq beg (nth 0 info)
5384 end (nth 1 info)
5385 lang (nth 2 info)
5386 single (nth 3 info)
5387 lang-f (intern (concat lang "-mode")))
5388 (unless (functionp lang-f)
5389 (error "No such language mode: %s" lang-f))
5390 (goto-line line)
5391 (if (get-buffer "*Org Edit Src Example*")
5392 (kill-buffer "*Org Edit Src Example*"))
5393 (switch-to-buffer (make-indirect-buffer (current-buffer)
5394 "*Org Edit Src Example*"))
5395 (narrow-to-region beg end)
5396 (remove-text-properties beg end '(display nil invisible nil
5397 intangible nil))
5398 (let ((org-inhibit-startup t))
5399 (funcall lang-f))
5400 (set (make-local-variable 'org-edit-src-force-single-line) single)
5401 (set (make-local-variable 'org-edit-src-from-org-mode) org-mode-p)
5402 (when org-mode-p
5403 (goto-char (point-min))
5404 (while (re-search-forward "^," nil t)
5405 (replace-match "")))
5406 (goto-line line)
5407 (org-exit-edit-mode)
5408 (org-set-local 'header-line-format msg)
5409 (message "%s" msg)
5410 t)))
5411
5412(defun org-edit-src-find-region-and-lang ()
5413 "Find the region and language for a local edit.
5414Return a list with beginning and end of the region, a string representing
5415the language, a switch telling of the content should be in a single line."
5416 (let ((re-list
5417 '(
5418 ("<src\\>[^<]*>[ \t]*\n?" "\n?[ \t]*</src>" lang)
5419 ("<literal\\>[^<]*>[ \t]*\n?" "\n?[ \t]*</literal>" style)
5420 ("<example>[ \t]*\n?" "\n?[ \t]*</example>" "fundamental")
5421 ("<lisp>[ \t]*\n?" "\n?[ \t]*</lisp>" "emacs-lisp")
5422 ("<perl>[ \t]*\n?" "\n?[ \t]*</perl>" "perl")
5423 ("<python>[ \t]*\n?" "\n?[ \t]*</python>" "python")
5424 ("<ruby>[ \t]*\n?" "\n?[ \t]*</ruby>" "ruby")
5425 ("^#\\+begin_src\\( \\([^ \t\n]+\\)\\)?.*\n" "\n#\\+end_src" 2)
5426 ("^#\\+begin_example.*\n" "^#\\+end_example" "fundamental")
5427 ("^#\\+html:" "\n" "html" single-line)
5428 ("^#\\+begin_html.*\n" "\n#\\+end_html" "html")
5429 ("^#\\+begin_latex.*\n" "\n#\\+end_latex" "latex")
5430 ("^#\\+latex:" "\n" "latex" single-line)
5431 ("^#\\+begin_ascii.*\n" "\n#\\+end_ascii" "fundamental")
5432 ("^#\\+ascii:" "\n" "ascii" single-line)
5433 ))
5434 (pos (point))
5435 re re1 re2 single beg end lang)
5436 (catch 'exit
5437 (while (setq entry (pop re-list))
5438 (setq re1 (car entry) re2 (nth 1 entry) lang (nth 2 entry)
5439 single (nth 3 entry))
5440 (save-excursion
5441 (if (or (looking-at re1)
5442 (re-search-backward re1 nil t))
5443 (progn
5444 (setq beg (match-end 0) lang (org-edit-src-get-lang lang))
5445 (if (and (re-search-forward re2 nil t)
5446 (>= (match-end 0) pos))
5447 (throw 'exit (list beg (match-beginning 0) lang single))))
5448 (if (or (looking-at re2)
5449 (re-search-forward re2 nil t))
5450 (progn
5451 (setq end (match-beginning 0))
5452 (if (and (re-search-backward re1 nil t)
5453 (<= (match-beginning 0) pos))
5454 (throw 'exit
5455 (list (match-end 0) end
5456 (org-edit-src-get-lang lang) single)))))))))))
5457
5458(defun org-edit-src-get-lang (lang)
5459 "Extract the src language."
5460 (let ((m (match-string 0)))
5461 (cond
5462 ((stringp lang) lang)
5463 ((integerp lang) (match-string lang))
5464 ((and (eq lang lang)
5465 (string-match "\\<lang=\"\\([^ \t\n\"]+\\)\"" m))
5466 (match-string 1 m))
5467 ((and (eq lang lang)
5468 (string-match "\\<style=\"\\([^ \t\n\"]+\\)\"" m))
5469 (match-string 1 m))
5470 (t "fundamental"))))
5471
5472(defun org-edit-src-exit ()
5473 "Exit special edit and protect problematic lines."
5474 (interactive)
5475 (unless (buffer-base-buffer (current-buffer))
5476 (error "This is not an indirect buffer, something is wrong..."))
5477 (unless (> (point-min) 1)
5478 (error "This buffer is not narrowed, something is wrong..."))
5479 (goto-char (point-min))
5480 (if (looking-at "[ \t\n]*\n") (replace-match ""))
5481 (if (re-search-forward "\n[ \t\n]*\\'" nil t) (replace-match ""))
5482 (when (org-bound-and-true-p org-edit-src-force-single-line)
5483 (goto-char (point-min))
5484 (while (re-search-forward "\n" nil t)
5485 (replace-match " "))
5486 (goto-char (point-min))
5487 (if (looking-at "\\s-*") (replace-match " "))
5488 (if (re-search-forward "\\s-+\\'" nil t)
5489 (replace-match "")))
5490 (when (org-bound-and-true-p org-edit-src-from-org-mode)
5491 (goto-char (point-min))
5492 (while (re-search-forward (if (org-mode-p) "^\\(.\\)" "^\\([*#]\\)") nil t)
5493 (replace-match ",\\1"))
5494 (when font-lock-mode
5495 (font-lock-unfontify-region (point-min) (point-max)))
5496 (put-text-property (point-min) (point-max) 'font-lock-fontified t))
5497 (kill-buffer (current-buffer)))
5498
5107;;;; Plain list items, including checkboxes 5499;;;; Plain list items, including checkboxes
5108 5500
5109;;; Plain list items 5501;;; Plain list items
@@ -5143,10 +5535,15 @@ Return t when things worked, nil when we are not in an item."
5143 t) 5535 t)
5144 (error nil))) 5536 (error nil)))
5145 (let* ((bul (match-string 0)) 5537 (let* ((bul (match-string 0))
5538 (descp (save-excursion (goto-char (match-beginning 0))
5539 (beginning-of-line 1)
5540 (save-match-data
5541 (looking-at "[ \t]*.*? ::"))))
5146 (eow (save-excursion (beginning-of-line 1) (looking-at "[ \t]*") 5542 (eow (save-excursion (beginning-of-line 1) (looking-at "[ \t]*")
5147 (match-end 0))) 5543 (match-end 0)))
5148 (blank (cdr (assq 'plain-list-item org-blank-before-new-entry))) 5544 (blank (cdr (assq 'plain-list-item org-blank-before-new-entry)))
5149 pos) 5545 pos)
5546 (if descp (setq checkbox nil))
5150 (cond 5547 (cond
5151 ((and (org-at-item-p) (<= (point) eow)) 5548 ((and (org-at-item-p) (<= (point) eow))
5152 ;; before the bullet 5549 ;; before the bullet
@@ -5159,7 +5556,10 @@ Return t when things worked, nil when we are not in an item."
5159 (end-of-line 1) 5556 (end-of-line 1)
5160 (delete-horizontal-space)) 5557 (delete-horizontal-space))
5161 (newline (if blank 2 1)))) 5558 (newline (if blank 2 1))))
5162 (insert bul (if checkbox "[ ]" "")) 5559 (insert bul
5560 (if checkbox "[ ]" "")
5561 (if descp (concat (if checkbox " " "")
5562 (read-string "Term: ") " :: ") ""))
5163 (just-one-space) 5563 (just-one-space)
5164 (setq pos (point)) 5564 (setq pos (point))
5165 (end-of-line 1) 5565 (end-of-line 1)
@@ -6197,7 +6597,10 @@ For file links, arg negates `org-context-in-file-links'."
6197 (t nil))) 6597 (t nil)))
6198 (when (or (null txt) (string-match "\\S-" txt)) 6598 (when (or (null txt) (string-match "\\S-" txt))
6199 (setq cpltxt 6599 (setq cpltxt
6200 (concat cpltxt "::" (org-make-org-heading-search-string txt)) 6600 (concat cpltxt "::"
6601 (condition-case nil
6602 (org-make-org-heading-search-string txt)
6603 (error "")))
6201 desc "NONE")))) 6604 desc "NONE"))))
6202 (if (string-match "::\\'" cpltxt) 6605 (if (string-match "::\\'" cpltxt)
6203 (setq cpltxt (substring cpltxt 0 -2))) 6606 (setq cpltxt (substring cpltxt 0 -2)))
@@ -7084,6 +7487,10 @@ onto the ring."
7084 (if (equal (substring s 0 1) "<") nil (setq s (concat "<" s))) 7487 (if (equal (substring s 0 1) "<") nil (setq s (concat "<" s)))
7085 (if (equal (substring s -1) ">") nil (setq s (concat s ">"))) 7488 (if (equal (substring s -1) ">") nil (setq s (concat s ">")))
7086 s) 7489 s)
7490(defun org-remove-double-quotes (s)
7491 (if (equal (substring s 0 1) "\"") (setq s (substring s 1)))
7492 (if (equal (substring s -1) "\"") (setq s (substring s 0 -1)))
7493 s)
7087 7494
7088;;; Following specific links 7495;;; Following specific links
7089 7496
@@ -7157,7 +7564,9 @@ If the file does not exist, an error is thrown."
7157 (setq cmd (replace-match "%s" t t cmd))) 7564 (setq cmd (replace-match "%s" t t cmd)))
7158 (while (string-match "%s" cmd) 7565 (while (string-match "%s" cmd)
7159 (setq cmd (replace-match 7566 (setq cmd (replace-match
7160 (save-match-data (shell-quote-argument file)) 7567 (save-match-data
7568 (shell-quote-argument
7569 (convert-standard-filename file)))
7161 t t cmd))) 7570 t t cmd)))
7162 (save-window-excursion 7571 (save-window-excursion
7163 (start-process-shell-command cmd nil cmd) 7572 (start-process-shell-command cmd nil cmd)
@@ -7170,7 +7579,8 @@ If the file does not exist, an error is thrown."
7170 (if line (goto-line line) 7579 (if line (goto-line line)
7171 (if search (org-link-search search)))) 7580 (if search (org-link-search search))))
7172 ((consp cmd) 7581 ((consp cmd)
7173 (eval cmd)) 7582 (let ((file (convert-standard-filename file)))
7583 (eval cmd)))
7174 (t (funcall (cdr (assq 'file org-link-frame-setup)) file))) 7584 (t (funcall (cdr (assq 'file org-link-frame-setup)) file)))
7175 (and (org-mode-p) (eq old-mode 'org-mode) 7585 (and (org-mode-p) (eq old-mode 'org-mode)
7176 (or (not (equal old-buffer (current-buffer))) 7586 (or (not (equal old-buffer (current-buffer)))
@@ -7346,7 +7756,7 @@ operation has put the subtree."
7346 (switch-to-buffer nbuf) 7756 (switch-to-buffer nbuf)
7347 (goto-char pos) 7757 (goto-char pos)
7348 (org-show-context 'org-goto)) 7758 (org-show-context 'org-goto))
7349 (org-copy-special) 7759 (org-copy-subtree 1 nil t)
7350 (save-excursion 7760 (save-excursion
7351 (set-buffer (setq nbuf (or (find-buffer-visiting file) 7761 (set-buffer (setq nbuf (or (find-buffer-visiting file)
7352 (find-file-noselect file)))) 7762 (find-file-noselect file))))
@@ -7365,7 +7775,8 @@ operation has put the subtree."
7365 (point-max)))) 7775 (point-max))))
7366 (bookmark-set "org-refile-last-stored") 7776 (bookmark-set "org-refile-last-stored")
7367 (org-paste-subtree level)))) 7777 (org-paste-subtree level))))
7368 (org-cut-special) 7778 (org-cut-subtree)
7779 (setq org-markers-to-move nil)
7369 (message "Entry refiled to \"%s\"" (car it))))))) 7780 (message "Entry refiled to \"%s\"" (car it)))))))
7370 7781
7371(defun org-refile-goto-last-stored () 7782(defun org-refile-goto-last-stored ()
@@ -7382,20 +7793,54 @@ operation has put the subtree."
7382 (unless org-refile-target-table 7793 (unless org-refile-target-table
7383 (error "No refile targets")) 7794 (error "No refile targets"))
7384 (let* ((cbuf (current-buffer)) 7795 (let* ((cbuf (current-buffer))
7796 (cfunc (if org-refile-use-outline-path
7797 'org-olpath-completing-read
7798 'completing-read))
7799 (extra (if org-refile-use-outline-path "/" ""))
7385 (filename (buffer-file-name (buffer-base-buffer cbuf))) 7800 (filename (buffer-file-name (buffer-base-buffer cbuf)))
7386 (fname (and filename (file-truename filename))) 7801 (fname (and filename (file-truename filename)))
7387 (tbl (mapcar 7802 (tbl (mapcar
7388 (lambda (x) 7803 (lambda (x)
7389 (if (not (equal fname (file-truename (nth 1 x)))) 7804 (if (not (equal fname (file-truename (nth 1 x))))
7390 (cons (concat (car x) " (" (file-name-nondirectory 7805 (cons (concat (car x) extra " ("
7391 (nth 1 x)) ")") 7806 (file-name-nondirectory (nth 1 x)) ")")
7392 (cdr x)) 7807 (cdr x))
7393 x)) 7808 (cons (concat (car x) extra) (cdr x))))
7394 org-refile-target-table)) 7809 org-refile-target-table))
7395 (completion-ignore-case t)) 7810 (completion-ignore-case t))
7396 (assoc (completing-read prompt tbl nil t nil 'org-refile-history) 7811 (assoc (funcall cfunc prompt tbl nil t nil 'org-refile-history)
7397 tbl))) 7812 tbl)))
7398 7813
7814(defun org-olpath-completing-read (prompt collection &rest args)
7815 "Read an outline path like a file name."
7816 (let ((thetable collection))
7817 (apply
7818 'completing-read prompt
7819 (lambda (string predicate &optional flag)
7820 (let (rtn r s f (l (length string)))
7821 (cond
7822 ((eq flag nil)
7823 ;; try completion
7824 (try-completion string thetable))
7825 ((eq flag t)
7826 ;; all-completions
7827 (setq rtn (all-completions string thetable predicate))
7828 (mapcar
7829 (lambda (x)
7830 (setq r (substring x l))
7831 (if (string-match " ([^)]*)$" x)
7832 (setq f (match-string 0 x))
7833 (setq f ""))
7834 (if (string-match "/" r)
7835 (concat string (substring r 0 (match-end 0)) f)
7836 x))
7837 rtn))
7838 ((eq flag 'lambda)
7839 ;; exact match?
7840 (assoc string thetable)))
7841 ))
7842 args)))
7843
7399;;;; Dynamic blocks 7844;;;; Dynamic blocks
7400 7845
7401(defun org-find-dblock (name) 7846(defun org-find-dblock (name)
@@ -7521,6 +7966,82 @@ This function can be used in a hook."
7521 "ORGTBL" "HTML:" "LaTeX:" "BEGIN:" "END:" "TBLFM" 7966 "ORGTBL" "HTML:" "LaTeX:" "BEGIN:" "END:" "TBLFM"
7522 "BEGIN_EXAMPLE" "END_EXAMPLE")) 7967 "BEGIN_EXAMPLE" "END_EXAMPLE"))
7523 7968
7969(defcustom org-structure-template-alist
7970 '(
7971 ("s" "#+begin_src ?\n\n#+end_src"
7972 "<src lang=\"?\">\n\n</src>")
7973 ("e" "#+begin_example\n?\n#+end_example"
7974 "<example>\n?\n</example>")
7975 ("q" "#+begin_quote\n?\n#+end_quote"
7976 "<quote>\n?\n</quote>")
7977 ("v" "#+begin_verse\n?\n#+end_verse"
7978 "<verse>\n?\n/verse>")
7979 ("l" "#+begin_latex\n?\n#+end_latex"
7980 "<literal style=\"latex\">\n?\n</literal>")
7981 ("L" "#+latex: "
7982 "<literal style=\"latex\">?</literal>")
7983 ("h" "#+begin_html\n?\n#+end_html"
7984 "<literal style=\"html\">\n?\n</literal>")
7985 ("H" "#+html: "
7986 "<literal style=\"html\">?</literal>")
7987 ("a" "#+begin_ascii\n?\n#+end_ascii")
7988 ("A" "#+ascii: ")
7989 ("i" "#+include %file ?"
7990 "<include file=%file markup=\"?\">")
7991 )
7992 "Structure completion elements.
7993This is a list of abbreviation keys and values. The value gets inserted
7994it you type @samp{.} followed by the key and then the completion key,
7995usually `M-TAB'. %file will be replaced by a file name after prompting
7996for the file uning completion.
7997There are two templates for each key, the first uses the original Org syntax,
7998the second uses Emacs Muse-like syntax tags. These Muse-like tags become
7999the default when the /org-mtags.el/ module has been loaded. See also the
8000variable `org-mtags-prefere-muse-templates'.
8001This is an experimental feature, it is undecided if it is going to stay in."
8002 :group 'org-completion
8003 :type '(repeat
8004 (string :tag "Key")
8005 (string :tag "Template")
8006 (string :tag "Muse Template")))
8007
8008(defun org-try-structure-completion ()
8009 "Try to complete a structure template before point.
8010This looks for strings like \"<e\" on an otherwise empty line and
8011expands them."
8012 (let ((l (buffer-substring (point-at-bol) (point)))
8013 a)
8014 (when (and (looking-at "[ \t]*$")
8015 (string-match "^[ \t]*<\\([a-z]+\\)$"l)
8016 (setq a (assoc (match-string 1 l) org-structure-template-alist)))
8017 (org-complete-expand-structure-template (+ -1 (point-at-bol)
8018 (match-beginning 1)) a)
8019 t)))
8020
8021(defun org-complete-expand-structure-template (start cell)
8022 "Expand a structure template."
8023 (let* ((musep (org-bound-and-true-p org-mtags-prefere-muse-templates))
8024 (rpl (nth (if musep 2 1) cell)))
8025 (delete-region start (point))
8026 (when (string-match "\\`#\\+" rpl)
8027 (cond
8028 ((bolp))
8029 ((not (string-match "\\S-" (buffer-substring (point-at-bol) (point))))
8030 (delete-region (point-at-bol) (point)))
8031 (t (newline))))
8032 (setq start (point))
8033 (if (string-match "%file" rpl)
8034 (setq rpl (replace-match
8035 (concat
8036 "\""
8037 (save-match-data
8038 (abbreviate-file-name (read-file-name "Include file: ")))
8039 "\"")
8040 t t rpl)))
8041 (insert rpl)
8042 (if (re-search-backward "\\?" start t) (delete-char 1))))
8043
8044
7524(defun org-complete (&optional arg) 8045(defun org-complete (&optional arg)
7525 "Perform completion on word at point. 8046 "Perform completion on word at point.
7526At the beginning of a headline, this completes TODO keywords as given in 8047At the beginning of a headline, this completes TODO keywords as given in
@@ -7535,7 +8056,8 @@ At all other locations, this simply calls the value of
7535 (interactive "P") 8056 (interactive "P")
7536 (org-without-partial-completion 8057 (org-without-partial-completion
7537 (catch 'exit 8058 (catch 'exit
7538 (let* ((end (point)) 8059 (let* ((a nil)
8060 (end (point))
7539 (beg1 (save-excursion 8061 (beg1 (save-excursion
7540 (skip-chars-backward (org-re "[:alnum:]_@")) 8062 (skip-chars-backward (org-re "[:alnum:]_@"))
7541 (point))) 8063 (point)))
@@ -7544,6 +8066,12 @@ At all other locations, this simply calls the value of
7544 (point))) 8066 (point)))
7545 (confirm (lambda (x) (stringp (car x)))) 8067 (confirm (lambda (x) (stringp (car x))))
7546 (searchhead (equal (char-before beg) ?*)) 8068 (searchhead (equal (char-before beg) ?*))
8069 (struct
8070 (when (and (member (char-before beg1) '(?. ?<))
8071 (setq a (assoc (buffer-substring beg1 (point))
8072 org-structure-template-alist)))
8073 (org-complete-expand-structure-template (1- beg1) a)
8074 (throw 'exit t)))
7547 (tag (and (equal (char-before beg1) ?:) 8075 (tag (and (equal (char-before beg1) ?:)
7548 (equal (char-after (point-at-bol)) ?*))) 8076 (equal (char-after (point-at-bol)) ?*)))
7549 (prop (and (equal (char-before beg1) ?:) 8077 (prop (and (equal (char-before beg1) ?:)
@@ -7868,6 +8396,8 @@ For calling through lisp, arg is also interpreted in the following way:
7868 (org-add-log-setup 'state state 'findpos dolog))) 8396 (org-add-log-setup 'state state 'findpos dolog)))
7869 ;; Fixup tag positioning 8397 ;; Fixup tag positioning
7870 (and org-auto-align-tags (not org-setting-tags) (org-set-tags nil t)) 8398 (and org-auto-align-tags (not org-setting-tags) (org-set-tags nil t))
8399 (when org-provide-todo-statistics
8400 (org-update-parent-todo-statistics))
7871 (run-hooks 'org-after-todo-state-change-hook) 8401 (run-hooks 'org-after-todo-state-change-hook)
7872 (if (and arg (not (member state org-done-keywords))) 8402 (if (and arg (not (member state org-done-keywords)))
7873 (setq head (org-get-todo-sequence-head state))) 8403 (setq head (org-get-todo-sequence-head state)))
@@ -7887,6 +8417,51 @@ For calling through lisp, arg is also interpreted in the following way:
7887 (save-excursion 8417 (save-excursion
7888 (run-hook-with-args 'org-trigger-hook change-plist))))))) 8418 (run-hook-with-args 'org-trigger-hook change-plist)))))))
7889 8419
8420(defun org-update-parent-todo-statistics ()
8421 "Update any statistics cookie in the parent of the current headline."
8422 (interactive)
8423 (let ((box-re "\\(\\(\\[[0-9]*%\\]\\)\\|\\(\\[[0-9]*/[0-9]*\\]\\)\\)")
8424 level (cnt-all 0) (cnt-done 0) is-percent kwd)
8425 (catch 'exit
8426 (save-excursion
8427 (setq level (org-up-heading-safe))
8428 (unless (and level
8429 (re-search-forward box-re (point-at-eol) t))
8430 (throw 'exit nil))
8431 (setq is-percent (match-end 2))
8432 (save-match-data
8433 (unless (outline-next-heading) (throw 'exit nil))
8434 (while (looking-at org-todo-line-regexp)
8435 (setq kwd (match-string 2))
8436 (and kwd (setq cnt-all (1+ cnt-all)))
8437 (and (member kwd org-done-keywords)
8438 (setq cnt-done (1+ cnt-done)))
8439 (condition-case nil
8440 (outline-forward-same-level 1)
8441 (error (end-of-line 1)))))
8442 (replace-match
8443 (if is-percent
8444 (format "[%d%%]" (/ (* 100 cnt-done) (max 1 cnt-all)))
8445 (format "[%d/%d]" cnt-done cnt-all)))
8446 (run-hook-with-args 'org-after-todo-statistics-hook
8447 cnt-done (- cnt-all cnt-done))))))
8448
8449(defvar org-after-todo-statistics-hook nil
8450 "Hook that is called after a TODO statistics cookie has been updated.
8451Each function is called with two arguments: the number of not-done entries
8452and the number of done entries.
8453
8454For example, the following function, when added to this hook, will switch
8455an entry to DONE when all children are done, and back to TODO when new
8456entries are set to a TODO status. Note that this hook is only called
8457when there is a statistics cookie in the headline!
8458
8459 (defun org-summary-todo (n-done n-not-done)
8460 \"Switch entry to DONE when all subentries are done, to TODO otherwise.\"
8461 (let (org-log-done org-log-states) ; turn off logging
8462 (org-todo (if (= n-not-done 0) \"DONE\" \"TODO\"))))
8463")
8464
7890(defun org-local-logging (value) 8465(defun org-local-logging (value)
7891 "Get logging settings from a property VALUE." 8466 "Get logging settings from a property VALUE."
7892 (let* (words w a) 8467 (let* (words w a)
@@ -8020,6 +8595,7 @@ Returns the new TODO keyword, or nil if no state change should occur."
8020 (match-string 1))))) 8595 (match-string 1)))))
8021 8596
8022(defvar org-last-changed-timestamp) 8597(defvar org-last-changed-timestamp)
8598(defvar org-last-inserted-timestamp)
8023(defvar org-log-post-message) 8599(defvar org-log-post-message)
8024(defvar org-log-note-purpose) 8600(defvar org-log-note-purpose)
8025(defvar org-log-note-how) 8601(defvar org-log-note-how)
@@ -8120,25 +8696,35 @@ of `org-todo-keywords-1'."
8120 (message "%d TODO entries found" 8696 (message "%d TODO entries found"
8121 (org-occur (concat "^" outline-regexp " *" kwd-re ))))) 8697 (org-occur (concat "^" outline-regexp " *" kwd-re )))))
8122 8698
8123(defun org-deadline (&optional remove) 8699(defun org-deadline (&optional remove time)
8124 "Insert the \"DEADLINE:\" string with a timestamp to make a deadline. 8700 "Insert the \"DEADLINE:\" string with a timestamp to make a deadline.
8125With argument REMOVE, remove any deadline from the item." 8701With argument REMOVE, remove any deadline from the item.
8702When TIME is set, it should be an internal time specification, and the
8703scheduling will use the corresponding date."
8126 (interactive "P") 8704 (interactive "P")
8127 (if remove 8705 (if remove
8128 (progn 8706 (progn
8129 (org-remove-timestamp-with-keyword org-deadline-string) 8707 (org-remove-timestamp-with-keyword org-deadline-string)
8130 (message "Item no longer has a deadline.")) 8708 (message "Item no longer has a deadline."))
8131 (org-add-planning-info 'deadline nil 'closed))) 8709 (if (org-get-repeat)
8710 (error "Cannot change deadline on task with repeater, please do that by hand")
8711 (org-add-planning-info 'deadline time 'closed)
8712 (message "Deadline on %s" org-last-inserted-timestamp))))
8132 8713
8133(defun org-schedule (&optional remove) 8714(defun org-schedule (&optional remove time)
8134 "Insert the SCHEDULED: string with a timestamp to schedule a TODO item. 8715 "Insert the SCHEDULED: string with a timestamp to schedule a TODO item.
8135With argument REMOVE, remove any scheduling date from the item." 8716With argument REMOVE, remove any scheduling date from the item.
8717When TIME is set, it should be an internal time specification, and the
8718scheduling will use the corresponding date."
8136 (interactive "P") 8719 (interactive "P")
8137 (if remove 8720 (if remove
8138 (progn 8721 (progn
8139 (org-remove-timestamp-with-keyword org-scheduled-string) 8722 (org-remove-timestamp-with-keyword org-scheduled-string)
8140 (message "Item is no longer scheduled.")) 8723 (message "Item is no longer scheduled."))
8141 (org-add-planning-info 'scheduled nil 'closed))) 8724 (if (org-get-repeat)
8725 (error "Cannot reschedule task with repeater, please do that by hand")
8726 (org-add-planning-info 'scheduled time 'closed)
8727 (message "Scheduled to %s" org-last-inserted-timestamp))))
8142 8728
8143(defun org-remove-timestamp-with-keyword (keyword) 8729(defun org-remove-timestamp-with-keyword (keyword)
8144 "Remove all time stamps with KEYWORD in the current entry." 8730 "Remove all time stamps with KEYWORD in the current entry."
@@ -8150,8 +8736,13 @@ With argument REMOVE, remove any scheduling date from the item."
8150 (org-end-of-subtree t t) 8736 (org-end-of-subtree t t)
8151 (while (re-search-backward re beg t) 8737 (while (re-search-backward re beg t)
8152 (replace-match "") 8738 (replace-match "")
8153 (unless (string-match "\\S-" (buffer-substring (point-at-bol) (point))) 8739 (if (and (string-match "\\S-" (buffer-substring (point-at-bol) (point)))
8154 (delete-region (point-at-bol) (min (1+ (point)) (point-max)))))))) 8740 (equal (char-before) ?\ ))
8741 (backward-delete-char 1)
8742 (if (string-match "^[ \t]*$" (buffer-substring
8743 (point-at-bol) (point-at-eol)))
8744 (delete-region (point-at-bol)
8745 (min (point-max) (1+ (point-at-eol))))))))))
8155 8746
8156(defun org-add-planning-info (what &optional time &rest remove) 8747(defun org-add-planning-info (what &optional time &rest remove)
8157 "Insert new timestamp with keyword in the line directly after the headline. 8748 "Insert new timestamp with keyword in the line directly after the headline.
@@ -8205,7 +8796,7 @@ be removed."
8205 (insert-before-markers "\n") 8796 (insert-before-markers "\n")
8206 (backward-char 1) 8797 (backward-char 1)
8207 (narrow-to-region (point) (point)) 8798 (narrow-to-region (point) (point))
8208 (org-indent-to-column col)) 8799 (and org-adapt-indentation (org-indent-to-column col)))
8209 ;; Check if we have to remove something. 8800 ;; Check if we have to remove something.
8210 (setq list (cons what remove)) 8801 (setq list (cons what remove))
8211 (while list 8802 (while list
@@ -8223,7 +8814,7 @@ be removed."
8223 (goto-char (point-max)) 8814 (goto-char (point-max))
8224 (when what 8815 (when what
8225 (insert 8816 (insert
8226 (if (not (equal (char-before) ?\ )) " " "") 8817 (if (not (or (bolp) (eq (char-before) ?\ ))) " " "")
8227 (cond ((eq what 'scheduled) org-scheduled-string) 8818 (cond ((eq what 'scheduled) org-scheduled-string)
8228 ((eq what 'deadline) org-deadline-string) 8819 ((eq what 'deadline) org-deadline-string)
8229 ((eq what 'closed) org-closed-string)) 8820 ((eq what 'closed) org-closed-string))
@@ -8239,7 +8830,7 @@ be removed."
8239 (widen) 8830 (widen)
8240 (if (and (looking-at "[ \t]+\n") 8831 (if (and (looking-at "[ \t]+\n")
8241 (equal (char-before) ?\n)) 8832 (equal (char-before) ?\n))
8242 (backward-delete-char 1)) 8833 (delete-region (1- (point)) (point-at-eol)))
8243 ts))))) 8834 ts)))))
8244 8835
8245(defvar org-log-note-marker (make-marker)) 8836(defvar org-log-note-marker (make-marker))
@@ -8607,10 +9198,15 @@ ACTION can be `set', `up', `down', or a character."
8607 9198
8608(defun org-scan-tags (action matcher &optional todo-only) 9199(defun org-scan-tags (action matcher &optional todo-only)
8609 "Scan headline tags with inheritance and produce output ACTION. 9200 "Scan headline tags with inheritance and produce output ACTION.
8610ACTION can be `sparse-tree' or `agenda'. MATCHER is a Lisp form to be 9201
8611evaluated, testing if a given set of tags qualifies a headline for 9202ACTION can be `sparse-tree' to produce a sparse tree in the current buffer,
8612inclusion. When TODO-ONLY is non-nil, only lines with a TODO keyword 9203or `agenda' to produce an entry list for an agenda view. It can also be
8613are included in the output." 9204a Lisp form or a function that should be called at each matched headline, in
9205this case the return value is a list of all return values from these calls.
9206
9207MATCHER is a Lisp form to be evaluated, testing if a given set of tags
9208qualifies a headline for inclusion. When TODO-ONLY is non-nil,
9209only lines with a TODO keyword are included in the output."
8614 (let* ((re (concat "[\n\r]" outline-regexp " *\\(\\<\\(" 9210 (let* ((re (concat "[\n\r]" outline-regexp " *\\(\\<\\("
8615 (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") 9211 (mapconcat 'regexp-quote org-todo-keywords-1 "\\|")
8616 (org-re 9212 (org-re
@@ -8628,9 +9224,12 @@ are included in the output."
8628 (or (buffer-file-name (buffer-base-buffer)) 9224 (or (buffer-file-name (buffer-base-buffer))
8629 (buffer-name (buffer-base-buffer))))))) 9225 (buffer-name (buffer-base-buffer)))))))
8630 (case-fold-search nil) 9226 (case-fold-search nil)
8631 lspos 9227 lspos tags tags-list
8632 tags tags-list tags-alist (llast 0) rtn level category i txt 9228 (tags-alist (list (cons 0 (mapcar 'downcase org-file-tags))))
9229 (llast 0) rtn rtn1 level category i txt
8633 todo marker entry priority) 9230 todo marker entry priority)
9231 (when (not (member action '(agenda sparse-tree)))
9232 (setq action (list 'lambda nil action)))
8634 (save-excursion 9233 (save-excursion
8635 (goto-char (point-min)) 9234 (goto-char (point-min))
8636 (when (eq action 'sparse-tree) 9235 (when (eq action 'sparse-tree)
@@ -8668,16 +9267,18 @@ are included in the output."
8668 (eval matcher) 9267 (eval matcher)
8669 (or (not org-agenda-skip-archived-trees) 9268 (or (not org-agenda-skip-archived-trees)
8670 (not (member org-archive-tag tags-list)))) 9269 (not (member org-archive-tag tags-list))))
8671 (and (eq action 'agenda) (org-agenda-skip)) 9270 (unless (eq action 'sparse-tree) (org-agenda-skip))
8672 ;; list this headline
8673 9271
8674 (if (eq action 'sparse-tree) 9272 ;; select this headline
8675 (progn 9273
8676 (and org-highlight-sparse-tree-matches 9274 (cond
8677 (org-get-heading) (match-end 0) 9275 ((eq action 'sparse-tree)
8678 (org-highlight-new-match 9276 (and org-highlight-sparse-tree-matches
8679 (match-beginning 0) (match-beginning 1))) 9277 (org-get-heading) (match-end 0)
8680 (org-show-context 'tags-tree)) 9278 (org-highlight-new-match
9279 (match-beginning 0) (match-beginning 1)))
9280 (org-show-context 'tags-tree))
9281 ((eq action 'agenda)
8681 (setq txt (org-format-agenda-item 9282 (setq txt (org-format-agenda-item
8682 "" 9283 ""
8683 (concat 9284 (concat
@@ -8692,6 +9293,13 @@ are included in the output."
8692 'org-marker marker 'org-hd-marker marker 'org-category category 9293 'org-marker marker 'org-hd-marker marker 'org-category category
8693 'priority priority 'type "tagsmatch") 9294 'priority priority 'type "tagsmatch")
8694 (push txt rtn)) 9295 (push txt rtn))
9296 ((functionp action)
9297 (save-excursion
9298 (setq rtn1 (funcall action))
9299 (push rtn1 rtn))
9300 (goto-char (point-at-eol)))
9301 (t (error "Invalid action")))
9302
8695 ;; if we are to skip sublevels, jump to end of subtree 9303 ;; if we are to skip sublevels, jump to end of subtree
8696 (or org-tags-match-list-sublevels (org-end-of-subtree t)))))) 9304 (or org-tags-match-list-sublevels (org-end-of-subtree t))))))
8697 (when (and (eq action 'sparse-tree) 9305 (when (and (eq action 'sparse-tree)
@@ -8897,7 +9505,7 @@ also TODO lines."
8897 "Get a list of all headline tags applicable at POS. 9505 "Get a list of all headline tags applicable at POS.
8898POS defaults to point. If tags are inherited, the list contains 9506POS defaults to point. If tags are inherited, the list contains
8899the targets in the same sequence as the headlines appear, i.e. 9507the targets in the same sequence as the headlines appear, i.e.
8900sthe tags of the current headline come last." 9508the tags of the current headline come last."
8901 (interactive) 9509 (interactive)
8902 (let (tags ltags lastpos parent) 9510 (let (tags ltags lastpos parent)
8903 (save-excursion 9511 (save-excursion
@@ -8919,7 +9527,7 @@ sthe tags of the current headline come last."
8919 (org-up-heading-all 1) 9527 (org-up-heading-all 1)
8920 (setq parent t))) 9528 (setq parent t)))
8921 (error nil)))) 9529 (error nil))))
8922 tags))) 9530 (append (org-remove-uniherited-tags org-file-tags) tags))))
8923 9531
8924(defun org-toggle-tag (tag &optional onoff) 9532(defun org-toggle-tag (tag &optional onoff)
8925 "Toggle the tag TAG for the current line. 9533 "Toggle the tag TAG for the current line.
@@ -8973,7 +9581,7 @@ If ONOFF is `on' or `off', don't toggle but set to this state."
8973 (setq p (point)) 9581 (setq p (point))
8974 (insert (make-string (- ncol (current-column)) ?\ )) 9582 (insert (make-string (- ncol (current-column)) ?\ ))
8975 (setq ncol (current-column)) 9583 (setq ncol (current-column))
8976 (tabify p (point-at-eol)) 9584 (when indent-tabs-mode (tabify p (point-at-eol)))
8977 (org-move-to-column (min ncol col) t)) 9585 (org-move-to-column (min ncol col) t))
8978 (goto-char pos)))) 9586 (goto-char pos))))
8979 9587
@@ -9351,6 +9959,89 @@ Returns the new tags string, or nil to not change the current settings."
9351 (org-split-string (org-match-string-no-properties 1) ":"))))) 9959 (org-split-string (org-match-string-no-properties 1) ":")))))
9352 (mapcar 'list tags))) 9960 (mapcar 'list tags)))
9353 9961
9962;;;; The mapping API
9963
9964;;;###autoload
9965(defun org-map-entries (func &optional match scope &rest skip)
9966 "Call FUNC at each headline selected by MATCH in SCOPE.
9967
9968FUNC is a function or a lisp form. The function will be called without
9969arguments, with the cursor positioned at the beginning of the headline.
9970The return values of all calls to the function will be collected and
9971returned as a list.
9972
9973MATCH is a tags/property/todo match as it is used in the agenda tags view.
9974Only headlines that are matched by this query will be considered during
9975the iteration. When MATCH is nil or t, all headlines will be
9976visited by the iteration.
9977
9978SCOPE determines the scope of this command. It can be any of:
9979
9980nil The current buffer, respecting the restriction if any
9981tree The subtree started with the entry at point
9982file The current buffer, without restriction
9983file-with-archives
9984 The current buffer, and any archives associated with it
9985agenda All agenda files
9986agenda-with-archives
9987 All agenda files with any archive files associated with them
9988\(file1 file2 ...)
9989 If this is a list, all files in the list will be scanned
9990
9991The remaining args are treated as settings for the skipping facilities of
9992the scanner. The following items can be given here:
9993
9994 archive skip trees with the archive tag.
9995 comment skip trees with the COMMENT keyword
9996 function or Emacs Lisp form:
9997 will be used as value for `org-agenda-skip-function', so whenever
9998 the the function returns t, FUNC will not be called for that
9999 entry and search will continue from the point where the
10000 function leaves it."
10001 (let* ((org-agenda-skip-archived-trees (memq 'archive skip))
10002 (org-agenda-skip-comment-trees (memq 'comment skip))
10003 (org-agenda-skip-function
10004 (car (org-delete-all '(comment archive) skip)))
10005 (org-tags-match-list-sublevels t)
10006 matcher pos)
10007
10008 (cond
10009 ((eq match t) (setq matcher t))
10010 ((eq match nil) (setq matcher t))
10011 (t (setq matcher (if match (org-make-tags-matcher match) t))))
10012
10013 (when (eq scope 'tree)
10014 (org-back-to-heading t)
10015 (org-narrow-to-subtree)
10016 (setq scope nil))
10017
10018 (if (not scope)
10019 (progn
10020 (org-prepare-agenda-buffers
10021 (list (buffer-file-name (current-buffer))))
10022 (org-scan-tags func matcher))
10023 ;; Get the right scope
10024 (setq pos (point))
10025 (cond
10026 ((and scope (listp scope) (symbolp (car scope)))
10027 (setq scope (eval scope)))
10028 ((eq scope 'agenda)
10029 (setq scope (org-agenda-files t)))
10030 ((eq scope 'agenda-with-archives)
10031 (setq scope (org-agenda-files t))
10032 (setq scope (org-add-archive-files scope)))
10033 ((eq scope 'file)
10034 (setq scope (list (buffer-file-name))))
10035 ((eq scope 'file-with-archives)
10036 (setq scope (org-add-archive-files (list (buffer-file-name))))))
10037 (org-prepare-agenda-buffers scope)
10038 (while (setq file (pop scope))
10039 (with-current-buffer (org-find-base-buffer-visiting file)
10040 (save-excursion
10041 (save-restriction
10042 (widen)
10043 (goto-char (point-min))
10044 (org-scan-tags func matcher))))))))
9354 10045
9355;;;; Properties 10046;;;; Properties
9356 10047
@@ -9366,7 +10057,9 @@ but in some other way.")
9366 10057
9367(defconst org-default-properties 10058(defconst org-default-properties
9368 '("ARCHIVE" "CATEGORY" "SUMMARY" "DESCRIPTION" 10059 '("ARCHIVE" "CATEGORY" "SUMMARY" "DESCRIPTION"
9369 "LOCATION" "LOGGING" "COLUMNS") 10060 "LOCATION" "LOGGING" "COLUMNS" "VISIBILITY"
10061 "TABLE_EXPORT_FORMAT" "TABLE_EXPORT_FILE"
10062 "EXPORT_FILE_NAME" "EXPORT_TITLE")
9370 "Some properties that are used by Org-mode for various purposes. 10063 "Some properties that are used by Org-mode for various purposes.
9371Being in this list makes sure that they are offered for completion.") 10064Being in this list makes sure that they are offered for completion.")
9372 10065
@@ -9594,8 +10287,10 @@ If yes, return this value. If not, return the current value of the variable."
9594 (move-marker org-entry-property-inherited-from (point)) 10287 (move-marker org-entry-property-inherited-from (point))
9595 (throw 'ex tmp)) 10288 (throw 'ex tmp))
9596 (or (org-up-heading-safe) (throw 'ex nil))))) 10289 (or (org-up-heading-safe) (throw 'ex nil)))))
9597 (or tmp (cdr (assoc property org-local-properties)) 10290 (or tmp
9598 (cdr (assoc property org-global-properties)))))) 10291 (cdr (assoc property org-file-properties))
10292 (cdr (assoc property org-global-properties))
10293 (cdr (assoc property org-global-properties-fixed))))))
9599 10294
9600(defun org-entry-put (pom property value) 10295(defun org-entry-put (pom property value)
9601 "Set PROPERTY to VALUE for entry at point-or-marker POM." 10296 "Set PROPERTY to VALUE for entry at point-or-marker POM."
@@ -9751,14 +10446,21 @@ for a value, offering competion either on allowed values (via an inherited
9751xxx_ALL property) or on existing values in other instances of this property 10446xxx_ALL property) or on existing values in other instances of this property
9752in the current file." 10447in the current file."
9753 (interactive 10448 (interactive
9754 (let* ((prop (completing-read 10449 (let* ((completion-ignore-case t)
9755 "Property: " (mapcar 'list (org-buffer-property-keys nil t t)))) 10450 (keys (org-buffer-property-keys nil t t))
10451 (prop0 (completing-read "Property: " (mapcar 'list keys)))
10452 (prop (if (member prop0 keys)
10453 prop0
10454 (or (cdr (assoc (downcase prop0)
10455 (mapcar (lambda (x) (cons (downcase x) x))
10456 keys)))
10457 prop0)))
9756 (cur (org-entry-get nil prop)) 10458 (cur (org-entry-get nil prop))
9757 (allowed (org-property-get-allowed-values nil prop 'table)) 10459 (allowed (org-property-get-allowed-values nil prop 'table))
9758 (existing (mapcar 'list (org-property-values prop))) 10460 (existing (mapcar 'list (org-property-values prop)))
9759 (val (if allowed 10461 (val (if allowed
9760 (completing-read "Value: " allowed nil 'req-match) 10462 (org-completing-read "Value: " allowed nil 'req-match)
9761 (completing-read 10463 (org-completing-read
9762 (concat "Value" (if (and cur (string-match "\\S-" cur)) 10464 (concat "Value" (if (and cur (string-match "\\S-" cur))
9763 (concat "[" cur "]") "") 10465 (concat "[" cur "]") "")
9764 ": ") 10466 ": ")
@@ -9770,7 +10472,8 @@ in the current file."
9770(defun org-delete-property (property) 10472(defun org-delete-property (property)
9771 "In the current entry, delete PROPERTY." 10473 "In the current entry, delete PROPERTY."
9772 (interactive 10474 (interactive
9773 (let* ((prop (completing-read 10475 (let* ((completion-ignore-case t)
10476 (prop (completing-read
9774 "Property: " (org-entry-properties nil 'standard)))) 10477 "Property: " (org-entry-properties nil 'standard))))
9775 (list prop))) 10478 (list prop)))
9776 (message "Property %s %s" property 10479 (message "Property %s %s" property
@@ -9781,7 +10484,8 @@ in the current file."
9781(defun org-delete-property-globally (property) 10484(defun org-delete-property-globally (property)
9782 "Remove PROPERTY globally, from all entries." 10485 "Remove PROPERTY globally, from all entries."
9783 (interactive 10486 (interactive
9784 (let* ((prop (completing-read 10487 (let* ((completion-ignore-case t)
10488 (prop (completing-read
9785 "Globally remove property: " 10489 "Globally remove property: "
9786 (mapcar 'list (org-buffer-property-keys))))) 10490 (mapcar 'list (org-buffer-property-keys)))))
9787 (list prop))) 10491 (list prop)))
@@ -9894,6 +10598,8 @@ Return the position where this entry starts, or nil if there is no such entry."
9894;;;; Timestamps 10598;;;; Timestamps
9895 10599
9896(defvar org-last-changed-timestamp nil) 10600(defvar org-last-changed-timestamp nil)
10601(defvar org-last-inserted-timestamp nil
10602 "The last time stamp inserted with `org-insert-time-stamp'.")
9897(defvar org-time-was-given) ; dynamically scoped parameter 10603(defvar org-time-was-given) ; dynamically scoped parameter
9898(defvar org-end-time-was-given) ; dynamically scoped parameter 10604(defvar org-end-time-was-given) ; dynamically scoped parameter
9899(defvar org-ts-what) ; dynamically scoped parameter 10605(defvar org-ts-what) ; dynamically scoped parameter
@@ -9983,6 +10689,7 @@ So these are more for recording a certain time/date."
9983 10689
9984(defvar org-plain-time-of-day-regexp) ; defined below 10690(defvar org-plain-time-of-day-regexp) ; defined below
9985 10691
10692(defvar org-overriding-default-time nil) ; dynamically scoped
9986(defvar org-read-date-overlay nil) 10693(defvar org-read-date-overlay nil)
9987(defvar org-dcst nil) ; dynamically scoped 10694(defvar org-dcst nil) ; dynamically scoped
9988 10695
@@ -10040,7 +10747,7 @@ user."
10040 (if (equal with-time '(16)) '(0 0) org-time-stamp-rounding-minutes)) 10747 (if (equal with-time '(16)) '(0 0) org-time-stamp-rounding-minutes))
10041 (org-dcst org-display-custom-times) 10748 (org-dcst org-display-custom-times)
10042 (ct (org-current-time)) 10749 (ct (org-current-time))
10043 (def (or default-time ct)) 10750 (def (or org-overriding-default-time default-time ct))
10044 (defdecode (decode-time def)) 10751 (defdecode (decode-time def))
10045 (dummy (progn 10752 (dummy (progn
10046 (when (< (nth 2 defdecode) org-extend-today-until) 10753 (when (< (nth 2 defdecode) org-extend-today-until)
@@ -10181,6 +10888,9 @@ user."
10181 hour minute second wday pm h2 m2 tl wday1 10888 hour minute second wday pm h2 m2 tl wday1
10182 iso-year iso-weekday iso-week iso-year iso-date) 10889 iso-year iso-weekday iso-week iso-year iso-date)
10183 10890
10891 (when (string-match "\\`[ \t]*\\.[ \t]*\\'" ans)
10892 (setq ans "+0"))
10893
10184 (when (setq delta (org-read-date-get-relative ans (current-time) def)) 10894 (when (setq delta (org-read-date-get-relative ans (current-time) def))
10185 (setq ans (replace-match "" t t ans) 10895 (setq ans (replace-match "" t t ans)
10186 deltan (car delta) 10896 deltan (car delta)
@@ -10401,7 +11111,7 @@ The command returns the inserted time stamp."
10401 (insert-before-markers extra) 11111 (insert-before-markers extra)
10402 (forward-char 1)) 11112 (forward-char 1))
10403 (insert-before-markers (or post "")) 11113 (insert-before-markers (or post ""))
10404 stamp)) 11114 (setq org-last-inserted-timestamp stamp)))
10405 11115
10406(defun org-toggle-time-stamp-overlays () 11116(defun org-toggle-time-stamp-overlays ()
10407 "Toggle the use of custom time stamp formats." 11117 "Toggle the use of custom time stamp formats."
@@ -10425,7 +11135,7 @@ The command returns the inserted time stamp."
10425 (message "Time stamp overlays removed"))) 11135 (message "Time stamp overlays removed")))
10426 11136
10427(defun org-display-custom-time (beg end) 11137(defun org-display-custom-time (beg end)
10428 "Overlay modified time stamp format over timestamp between BED and END." 11138 "Overlay modified time stamp format over timestamp between BEG and END."
10429 (let* ((ts (buffer-substring beg end)) 11139 (let* ((ts (buffer-substring beg end))
10430 t1 w1 with-hm tf time str w2 (off 0)) 11140 t1 w1 with-hm tf time str w2 (off 0))
10431 (save-match-data 11141 (save-match-data
@@ -10724,7 +11434,6 @@ This uses the icalendar.el library."
10724 (setq e (match-end 0))) 11434 (setq e (match-end 0)))
10725 (setq rtn (if (and b e) (concat (buffer-substring b e) "\n") ""))) 11435 (setq rtn (if (and b e) (concat (buffer-substring b e) "\n") "")))
10726 (kill-buffer buf) 11436 (kill-buffer buf)
10727 (kill-buffer frombuf)
10728 (delete-file tmpfile) 11437 (delete-file tmpfile)
10729 rtn)) 11438 rtn))
10730 11439
@@ -11055,7 +11764,7 @@ If there is already a time stamp at the cursor position, update it."
11055 "Compute H:MM from a number of minutes." 11764 "Compute H:MM from a number of minutes."
11056 (let ((h (/ m 60))) 11765 (let ((h (/ m 60)))
11057 (setq m (- m (* 60 h))) 11766 (setq m (- m (* 60 h)))
11058 (format "%d:%02d" h m))) 11767 (format org-time-clocksum-format h m)))
11059 11768
11060(defun org-hh:mm-string-to-minutes (s) 11769(defun org-hh:mm-string-to-minutes (s)
11061 "Convert a string H:MM to a number of minutes." 11770 "Convert a string H:MM to a number of minutes."
@@ -11768,7 +12477,7 @@ The images can be removed again with \\[org-ctrl-c-ctrl-c]."
11768(org-defkey org-mode-map "\C-c " 'org-table-blank-field) 12477(org-defkey org-mode-map "\C-c " 'org-table-blank-field)
11769(org-defkey org-mode-map "\C-c+" 'org-table-sum) 12478(org-defkey org-mode-map "\C-c+" 'org-table-sum)
11770(org-defkey org-mode-map "\C-c=" 'org-table-eval-formula) 12479(org-defkey org-mode-map "\C-c=" 'org-table-eval-formula)
11771(org-defkey org-mode-map "\C-c'" 'org-table-edit-formulas) 12480(org-defkey org-mode-map "\C-c'" 'org-edit-special)
11772(org-defkey org-mode-map "\C-c`" 'org-table-edit-field) 12481(org-defkey org-mode-map "\C-c`" 'org-table-edit-field)
11773(org-defkey org-mode-map "\C-c|" 'org-table-create-or-convert-from-region) 12482(org-defkey org-mode-map "\C-c|" 'org-table-create-or-convert-from-region)
11774(org-defkey org-mode-map [(control ?#)] 'org-table-rotate-recalc-marks) 12483(org-defkey org-mode-map [(control ?#)] 'org-table-rotate-recalc-marks)
@@ -11780,7 +12489,7 @@ The images can be removed again with \\[org-ctrl-c-ctrl-c]."
11780(org-defkey org-mode-map "\C-c:" 'org-toggle-fixed-width-section) 12489(org-defkey org-mode-map "\C-c:" 'org-toggle-fixed-width-section)
11781(org-defkey org-mode-map "\C-c\C-x\C-f" 'org-emphasize) 12490(org-defkey org-mode-map "\C-c\C-x\C-f" 'org-emphasize)
11782 12491
11783(org-defkey org-mode-map "\C-c\C-x\C-k" 'org-cut-special) 12492(org-defkey org-mode-map "\C-c\C-x\C-k" 'org-mark-entry-for-agenda-action)
11784(org-defkey org-mode-map "\C-c\C-x\C-w" 'org-cut-special) 12493(org-defkey org-mode-map "\C-c\C-x\C-w" 'org-cut-special)
11785(org-defkey org-mode-map "\C-c\C-x\M-w" 'org-copy-special) 12494(org-defkey org-mode-map "\C-c\C-x\M-w" 'org-copy-special)
11786(org-defkey org-mode-map "\C-c\C-x\C-y" 'org-paste-special) 12495(org-defkey org-mode-map "\C-c\C-x\C-y" 'org-paste-special)
@@ -11937,9 +12646,10 @@ See the individual commands for more information."
11937 (interactive "P") 12646 (interactive "P")
11938 (cond 12647 (cond
11939 ((org-at-table-p) (call-interactively 'org-table-previous-field)) 12648 ((org-at-table-p) (call-interactively 'org-table-previous-field))
11940 (arg (message "Content view to level: ") 12649 ((integerp arg)
11941 (org-content (prefix-numeric-value arg)) 12650 (message "Content view to level: %d" arg)
11942 (setq org-cycle-global-status 'overview)) 12651 (org-content (prefix-numeric-value arg))
12652 (setq org-cycle-global-status 'overview))
11943 (t (call-interactively 'org-global-cycle)))) 12653 (t (call-interactively 'org-global-cycle))))
11944 12654
11945(defun org-shiftmetaleft () 12655(defun org-shiftmetaleft ()
@@ -12135,6 +12845,23 @@ See the individual commands for more information."
12135 (org-table-paste-rectangle) 12845 (org-table-paste-rectangle)
12136 (org-paste-subtree arg))) 12846 (org-paste-subtree arg)))
12137 12847
12848(defun org-edit-special ()
12849 "Call a special editor for the stuff at point.
12850When at a table, call the formula editor with `org-table-edit-formulas'.
12851When at the first line of an src example, call `org-edit-src-code'.
12852When in an #+include line, visit the include file. Otherwise call
12853`ffap' to visit the file at point."
12854 (interactive)
12855 (cond
12856 ((org-at-table-p)
12857 (call-interactively 'org-table-edit-formulas))
12858 ((save-excursion
12859 (beginning-of-line 1)
12860 (looking-at "\\(?:#\\+\\(?:setupfile\\|include\\):?[ \t]+\"?\\|[ \t]*<include\\>.*?file=\"\\)\\([^\"\n>]+\\)"))
12861 (find-file (org-trim (match-string 1))))
12862 ((org-edit-src-code))
12863 (t (call-interactively 'ffap))))
12864
12138(defun org-ctrl-c-ctrl-c (&optional arg) 12865(defun org-ctrl-c-ctrl-c (&optional arg)
12139 "Set tags in headline, or update according to changed information at point. 12866 "Set tags in headline, or update according to changed information at point.
12140 12867
@@ -12216,15 +12943,18 @@ This command does many different things, depending on context:
12216 (if (org-at-table-p) 12943 (if (org-at-table-p)
12217 (org-call-with-arg 'org-table-recalculate t)))) 12944 (org-call-with-arg 'org-table-recalculate t))))
12218 (t 12945 (t
12219 (call-interactively 'org-mode-restart)))) 12946; (org-set-regexps-and-options)
12947; (org-restart-font-lock)
12948 (let ((org-inhibit-startup t)) (org-mode-restart))
12949 (message "Local setup has been refreshed"))))
12220 (t (error "C-c C-c can do nothing useful at this location."))))) 12950 (t (error "C-c C-c can do nothing useful at this location.")))))
12221 12951
12222(defun org-mode-restart () 12952(defun org-mode-restart ()
12223 "Restart Org-mode, to scan again for special lines. 12953 "Restart Org-mode, to scan again for special lines.
12224Also updates the keyword regular expressions." 12954Also updates the keyword regular expressions."
12225 (interactive) 12955 (interactive)
12226 (let ((org-inhibit-startup t)) (org-mode)) 12956 (org-mode)
12227 (message "Org-mode restarted to refresh keyword and special line setup")) 12957 (message "Org-mode restarted"))
12228 12958
12229(defun org-kill-note-or-show-branches () 12959(defun org-kill-note-or-show-branches ()
12230 "If this is a Note buffer, abort storing the note. Else call `show-branches'." 12960 "If this is a Note buffer, abort storing the note. Else call `show-branches'."
@@ -12261,7 +12991,7 @@ context. See the individual commands for more information."
12261 12991
12262(defun org-ctrl-c-star () 12992(defun org-ctrl-c-star ()
12263 "Compute table, or change heading status of lines. 12993 "Compute table, or change heading status of lines.
12264Calls `org-table-recalculate' or `org-toggle-region-headlines', 12994Calls `org-table-recalculate' or `org-toggle-region-headings',
12265depending on context. This will also turn a plain list item or a normal 12995depending on context. This will also turn a plain list item or a normal
12266line into a subheading." 12996line into a subheading."
12267 (interactive) 12997 (interactive)
@@ -12412,7 +13142,7 @@ See the individual commands for more information."
12412 ("Calculate" 13142 ("Calculate"
12413 ["Set Column Formula" org-table-eval-formula (org-at-table-p)] 13143 ["Set Column Formula" org-table-eval-formula (org-at-table-p)]
12414 ["Set Field Formula" (org-table-eval-formula '(4)) :active (org-at-table-p) :keys "C-u C-c ="] 13144 ["Set Field Formula" (org-table-eval-formula '(4)) :active (org-at-table-p) :keys "C-u C-c ="]
12415 ["Edit Formulas" org-table-edit-formulas (org-at-table-p)] 13145 ["Edit Formulas" org-edit-special (org-at-table-p)]
12416 "--" 13146 "--"
12417 ["Recalculate line" org-table-recalculate (org-at-table-p)] 13147 ["Recalculate line" org-table-recalculate (org-at-table-p)]
12418 ["Recalculate all" (lambda () (interactive) (org-table-recalculate '(4))) :active (org-at-table-p) :keys "C-u C-c *"] 13148 ["Recalculate all" (lambda () (interactive) (org-table-recalculate '(4))) :active (org-at-table-p) :keys "C-u C-c *"]
@@ -12477,7 +13207,8 @@ See the individual commands for more information."
12477 ["Convert to odd levels" org-convert-to-odd-levels t] 13207 ["Convert to odd levels" org-convert-to-odd-levels t]
12478 ["Convert to odd/even levels" org-convert-to-oddeven-levels t]) 13208 ["Convert to odd/even levels" org-convert-to-oddeven-levels t])
12479 ("Editing" 13209 ("Editing"
12480 ["Emphasis..." org-emphasize t]) 13210 ["Emphasis..." org-emphasize t]
13211 ["Edit Source Example" org-edit-special t])
12481 ("Archive" 13212 ("Archive"
12482 ["Toggle ARCHIVE tag" org-toggle-archive-tag t] 13213 ["Toggle ARCHIVE tag" org-toggle-archive-tag t]
12483; ["Check and Tag Children" (org-toggle-archive-tag (4)) 13214; ["Check and Tag Children" (org-toggle-archive-tag (4))
@@ -12633,13 +13364,15 @@ With optional NODE, go directly to that node."
12633 13364
12634;;;; Documentation 13365;;;; Documentation
12635 13366
13367;;;###autoload
12636(defun org-require-autoloaded-modules () 13368(defun org-require-autoloaded-modules ()
12637 (interactive) 13369 (interactive)
12638 (mapc 'require 13370 (mapc 'require
12639 '(org-agenda org-archive org-clock org-colview 13371 '(org-agenda org-archive org-clock org-colview
12640 org-exp org-export-latex org-publish 13372 org-exp org-id org-export-latex org-publish
12641 org-remember org-table))) 13373 org-remember org-table)))
12642 13374
13375;;;###autoload
12643(defun org-customize () 13376(defun org-customize ()
12644 "Call the customize function with org as argument." 13377 "Call the customize function with org as argument."
12645 (interactive) 13378 (interactive)
@@ -12671,6 +13404,41 @@ With optional NODE, go directly to that node."
12671 13404
12672;;; Generally useful functions 13405;;; Generally useful functions
12673 13406
13407(defun org-display-warning (message) ;; Copied from Emacs-Muse
13408 "Display the given MESSAGE as a warning."
13409 (if (fboundp 'display-warning)
13410 (display-warning 'org message
13411 (if (featurep 'xemacs)
13412 'warning
13413 :warning))
13414 (let ((buf (get-buffer-create "*Org warnings*")))
13415 (with-current-buffer buf
13416 (goto-char (point-max))
13417 (insert "Warning (Org): " message)
13418 (unless (bolp)
13419 (newline)))
13420 (display-buffer buf)
13421 (sit-for 0))))
13422
13423(defun org-goto-marker-or-bmk (marker &optional bookmark)
13424 "Go to MARKER, widen if necesary. When marker is not live, try BOOKMARK."
13425 (if (and marker (marker-buffer marker)
13426 (buffer-live-p (marker-buffer marker)))
13427 (progn
13428 (switch-to-buffer (marker-buffer marker))
13429 (if (or (> marker (point-max)) (< marker (point-min)))
13430 (widen))
13431 (goto-char marker))
13432 (if bookmark
13433 (bookmark-jump bookmark)
13434 (error "Cannot find location"))))
13435
13436(defun org-quote-csv-field (s)
13437 "Quote field for inclusion in CSV material."
13438 (if (string-match "[\",]" s)
13439 (concat "\"" (mapconcat 'identity (split-string s "\"") "\"\"") "\"")
13440 s))
13441
12674(defun org-plist-delete (plist property) 13442(defun org-plist-delete (plist property)
12675 "Delete PROPERTY from PLIST. 13443 "Delete PROPERTY from PLIST.
12676This is in contrast to merely setting it to 0." 13444This is in contrast to merely setting it to 0."
@@ -12708,6 +13476,12 @@ upon the next fontification round."
12708 (setq l (- l (get-text-property b 'org-dwidth-n s)))) 13476 (setq l (- l (get-text-property b 'org-dwidth-n s))))
12709 l)) 13477 l))
12710 13478
13479(defun org-base-buffer (buffer)
13480 "Return the base buffer of BUFFER, if it has one. Else return the buffer."
13481 (if (not buffer)
13482 buffer
13483 (or (buffer-base-buffer buffer)
13484 buffer)))
12711 13485
12712(defun org-trim (s) 13486(defun org-trim (s)
12713 "Remove whitespace at beginning and end of string." 13487 "Remove whitespace at beginning and end of string."
@@ -13083,6 +13857,37 @@ not an indirect buffer."
13083 (save-match-data 13857 (save-match-data
13084 (string-match (org-image-file-name-regexp) file))) 13858 (string-match (org-image-file-name-regexp) file)))
13085 13859
13860(defun org-get-cursor-date ()
13861 "Return the date at cursor in as a time.
13862This works in the calendar and in the agenda, anywhere else it just
13863returns the current time."
13864 (let (date day defd)
13865 (cond
13866 ((eq major-mode 'calendar-mode)
13867 (setq date (calendar-cursor-to-date)
13868 defd (encode-time 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date))))
13869 ((eq major-mode 'org-agenda-mode)
13870 (setq day (get-text-property (point) 'day))
13871 (if day
13872 (setq date (calendar-gregorian-from-absolute day)
13873 defd (encode-time 0 0 0 (nth 1 date) (nth 0 date)
13874 (nth 2 date))))))
13875 (or defd (current-time))))
13876
13877(defvar org-agenda-action-marker (make-marker)
13878 "Marker pointing to the entry for the next agenda action.")
13879
13880(defun org-mark-entry-for-agenda-action ()
13881 "Mark the current entry as target of an agenda action.
13882Agenda actions are actions executed from the agenda with the key `k',
13883which make use of the date at the cursor."
13884 (interactive)
13885 (move-marker org-agenda-action-marker
13886 (save-excursion (org-back-to-heading t) (point))
13887 (current-buffer))
13888 (message
13889 "Entry marked for action; press `k' at desired date in agenda or calendar"))
13890
13086;;; Paragraph filling stuff. 13891;;; Paragraph filling stuff.
13087;; We want this to be just right, so use the full arsenal. 13892;; We want this to be just right, so use the full arsenal.
13088 13893
@@ -13103,17 +13908,21 @@ not an indirect buffer."
13103 (beginning-of-line 0)) 13908 (beginning-of-line 0))
13104 (cond 13909 (cond
13105 ((looking-at "\\*+[ \t]+") 13910 ((looking-at "\\*+[ \t]+")
13106 (goto-char (match-end 0)) 13911 (if (not org-adapt-indentation)
13107 (setq column (current-column))) 13912 (setq column 0)
13913 (goto-char (match-end 0))
13914 (setq column (current-column))))
13108 ((org-in-item-p) 13915 ((org-in-item-p)
13109 (org-beginning-of-item) 13916 (org-beginning-of-item)
13110; (looking-at "[ \t]*\\(\\S-+\\)[ \t]*") 13917; (looking-at "[ \t]*\\(\\S-+\\)[ \t]*")
13111 (looking-at "[ \t]*\\(\\S-+\\)[ \t]*\\(\\[[- X]\\][ \t]*\\)?") 13918 (looking-at "[ \t]*\\(\\S-+\\)[ \t]*\\(\\[[- X]\\][ \t]*\\|.*? :: \\)?")
13112 (setq bpos (match-beginning 1) tpos (match-end 0) 13919 (setq bpos (match-beginning 1) tpos (match-end 0)
13113 bcol (progn (goto-char bpos) (current-column)) 13920 bcol (progn (goto-char bpos) (current-column))
13114 tcol (progn (goto-char tpos) (current-column)) 13921 tcol (progn (goto-char tpos) (current-column))
13115 bullet (match-string 1) 13922 bullet (match-string 1)
13116 bullet-type (if (string-match "[0-9]" bullet) "n" bullet)) 13923 bullet-type (if (string-match "[0-9]" bullet) "n" bullet))
13924 (if (> tcol (+ bcol org-description-max-indent))
13925 (setq tcol (+ bcol 5)))
13117 (if (not itemp) 13926 (if (not itemp)
13118 (setq column tcol) 13927 (setq column tcol)
13119 (goto-char pos) 13928 (goto-char pos)
@@ -13197,6 +14006,13 @@ In particular, this makes sure hanging paragraphs for hand-formatted lists
13197work correctly." 14006work correctly."
13198 (cond ((looking-at "#[ \t]+") 14007 (cond ((looking-at "#[ \t]+")
13199 (match-string 0)) 14008 (match-string 0))
14009 ((looking-at "[ \t]*\\([-*+] .*? :: \\)")
14010 (save-excursion
14011 (if (> (match-end 1) (+ (match-beginning 1)
14012 org-description-max-indent))
14013 (goto-char (+ (match-beginning 1) 5))
14014 (goto-char (match-end 0)))
14015 (make-string (current-column) ?\ )))
13200 ((looking-at "[ \t]*\\([-*+] \\|[0-9]+[.)] \\)?") 14016 ((looking-at "[ \t]*\\([-*+] \\|[0-9]+[.)] \\)?")
13201 (save-excursion 14017 (save-excursion
13202 (goto-char (match-end 0)) 14018 (goto-char (match-end 0))
@@ -13259,7 +14075,7 @@ If this is a headline, and `org-special-ctrl-a/e' is set, ignore tags on the
13259first attempt, and only move to after the tags when the cursor is already 14075first attempt, and only move to after the tags when the cursor is already
13260beyond the end of the headline." 14076beyond the end of the headline."
13261 (interactive "P") 14077 (interactive "P")
13262 (let ((pos (point))) 14078 (let ((pos (point)) refpos)
13263 (beginning-of-line 1) 14079 (beginning-of-line 1)
13264 (if (bobp) 14080 (if (bobp)
13265 nil 14081 nil
@@ -13271,16 +14087,18 @@ beyond the end of the headline."
13271 (forward-char 1))) 14087 (forward-char 1)))
13272 (when org-special-ctrl-a/e 14088 (when org-special-ctrl-a/e
13273 (cond 14089 (cond
13274 ((and (looking-at org-todo-line-regexp) 14090 ((and (looking-at org-complex-heading-regexp)
13275 (= (char-after (match-end 1)) ?\ )) 14091 (= (char-after (match-end 1)) ?\ ))
14092 (setq refpos (min (1+ (or (match-end 3) (match-end 2) (match-end 1)))
14093 (point-at-eol)))
13276 (goto-char 14094 (goto-char
13277 (if (eq org-special-ctrl-a/e t) 14095 (if (eq org-special-ctrl-a/e t)
13278 (cond ((> pos (match-beginning 3)) (match-beginning 3)) 14096 (cond ((> pos refpos) refpos)
13279 ((= pos (point)) (match-beginning 3)) 14097 ((= pos (point)) refpos)
13280 (t (point))) 14098 (t (point)))
13281 (cond ((> pos (point)) (point)) 14099 (cond ((> pos (point)) (point))
13282 ((not (eq last-command this-command)) (point)) 14100 ((not (eq last-command this-command)) (point))
13283 (t (match-beginning 3)))))) 14101 (t refpos)))))
13284 ((org-at-item-p) 14102 ((org-at-item-p)
13285 (goto-char 14103 (goto-char
13286 (if (eq org-special-ctrl-a/e t) 14104 (if (eq org-special-ctrl-a/e t)
@@ -13289,7 +14107,9 @@ beyond the end of the headline."
13289 (t (point))) 14107 (t (point)))
13290 (cond ((> pos (point)) (point)) 14108 (cond ((> pos (point)) (point))
13291 ((not (eq last-command this-command)) (point)) 14109 ((not (eq last-command this-command)) (point))
13292 (t (match-end 4)))))))))) 14110 (t (match-end 4))))))))
14111 (org-no-warnings
14112 (and (featurep 'xemacs) (setq zmacs-region-stays t)))))
13293 14113
13294(defun org-end-of-line (&optional arg) 14114(defun org-end-of-line (&optional arg)
13295 "Go to the end of the line. 14115 "Go to the end of the line.
@@ -13311,7 +14131,10 @@ beyond the end of the headline."
13311 (if (or (< pos (match-end 0)) (not (eq this-command last-command))) 14131 (if (or (< pos (match-end 0)) (not (eq this-command last-command)))
13312 (goto-char (match-end 0)) 14132 (goto-char (match-end 0))
13313 (goto-char (match-beginning 1)))) 14133 (goto-char (match-beginning 1))))
13314 (end-of-line arg))))) 14134 (end-of-line arg))))
14135 (org-no-warnings
14136 (and (featurep 'xemacs) (setq zmacs-region-stays t))))
14137
13315 14138
13316(define-key org-mode-map "\C-a" 'org-beginning-of-line) 14139(define-key org-mode-map "\C-a" 'org-beginning-of-line)
13317(define-key org-mode-map "\C-e" 'org-end-of-line) 14140(define-key org-mode-map "\C-e" 'org-end-of-line)
@@ -13688,6 +14511,6 @@ Still experimental, may disappear in the future."
13688(run-hooks 'org-load-hook) 14511(run-hooks 'org-load-hook)
13689 14512
13690;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd 14513;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd
13691;;; org.el ends here
13692 14514
14515;;; org.el ends here
13693 14516