aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Dominik2009-01-25 15:54:03 +0000
committerCarsten Dominik2009-01-25 15:54:03 +0000
commit0bd48b37bb27e64f7502ad8603f7ace81ca617e6 (patch)
tree9679b3150009b23435356905691d32c6a9923b6e
parentf052351afe2cc9b9460590aef6c0e5b65e485c87 (diff)
downloademacs-0bd48b37bb27e64f7502ad8603f7ace81ca617e6.tar.gz
emacs-0bd48b37bb27e64f7502ad8603f7ace81ca617e6.zip
2009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
* org-exp.el (org-export-as-html): Turn \par into a paragraph. * org.el (org-agenda-tags-todo-honor-ignore-options): Declare variable. * org-table.el (org-table-insert-hline): Fix typo in fuction call to `backward-char'. * org-exp.el (org-export-as-html): Remove the initial space from colon examples. * org.el (org-scan-tags): Call `org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item'. * org-agenda.el (org-agenda-todo-list, org-agenda-match-view): New customization groups. (org-agenda-tags-todo-honor-ignore-options): New option. (org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item): New function. (org-agenda-get-todos): Use `org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item'. 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-format-source-code-or-example): Escape HTML characters also in examples that anre not treated with htmlize. Also, just switch to EXAMPLE processing if we do not have a good version of htmlize. * org-rmail.el: Fix copyright notice. * org.el (org-activate-footnote-links): Improve footnote link highlighting. * org-footnote.el (org-footnote-normalize): Fix finding the end of a footnote definition at the end of the file. * org-table.el (org-table-get-specials): Add an imagined hline at the end of the table. This can be useful for references that want to go to the end of the table. Also fix bug when computing last row constants, in tables that do not start right at the right margin. (org-table-eval-formula): Match and replace remove references. (org-table-formula-substitute-names): Make sure that names inside a "remote" call are left alone, the will be replaced later when the remote call is handled. (org-table-convert-refs-to-rc): Do not convert things that might look like a reference, but are really part of an ID or namei n a remote reference. (org-table-get-remote-range): New function. 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com> * org-faces.el (org-clock-overlay): Fix bug in face definition. * org-clock.el (org-clock-put-overlay): Use new face instead of `secondary-selection'. * org-faces.el (org-clock-overlay): New face. 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-get-current-options): Include the option for publishing time stamps. * org.el (org-toggle-heading): Renamed from `org-toggel-region-headings'. No longer needs a region defined, but will use it if there is one. (org-ctrl-c-star): Simplified, relying more on the internal workings of `org-toggle-heading'. (org-toggle-item): Renamed from `org-toggle-region-items'. No longer needs a region defined, but will use it if there is one. (org-ctrl-c-minus): Simplified, relying more on the inernal workings of `org-toggle-item'. * org-export-latex.el (org-export-latex-preprocess): Fix bug in environment detection. Also, do real changes only in unprotected places. 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com> * org-export-latex.el (org-export-latex-quotation-marks): Use `org-if-unprotected-1'. (org-export-latex-set-initial-vars): Check for class definition in property. * org-macs.el (org-if-unprotected-1): New macro. 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com> * org-compat.el (org-count-lines): New function. * org-exp.el (org-export-format-source-code-or-example): Handle switches related to text areas. * org.el (org-activate-footnote-links): Don't allow match inside a link. * org-footnote.el (org-footnote-re): Don't allow match inside a link. * org-export-latex.el (org-export-latex-links): Keep a relative path relative also after export. * org-exp.el (org-export-html-scripts): Fix HTML snippet. * org.el (org-make-tags-matcher): Never use IDO for completing the tags matcher match string. (org-completing-read): Also remove the special biding for "?". * org-attach.el (org-attach-allow-inheritance): New option. (org-attach-inherited): New variable. (org-attach-dir): Handle properties related to the attachment directory. (org-attach-check-absolute-path): New function. (org-attach-set-directory, org-attach-set-inherit): New commands. (org-attach): Accommodate the new commands in the dispatcher. 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com> * org-compat.el (org-fit-window-to-buffer): Fix bug with using `window-full-width-p'. * org-exp.el (org-export-as-html): Only check for images files that really can be inlined * org.el (org-image-file-name-regexp, org-file-image-p): Allow the list of extensions to be a parameter. * org-exp.el (org-export-html-inline-image-extensions): New variable. * org-agenda.el (org-prepare-agenda): Use `org-agenda-block-separator'. (org-agenda-block-separator): New option. 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com> * org-export-latex.el (org-export-latex-tables): Call `org-table-clean-before-export' with the new optional argument. * org-exp.el (org-table-clean-before-export): New optional parameter MAYBE-QUOTED, allows for quoted characters like \# in first column. 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com> * org-plot.el (org-plot/gnuplot): Fix text-ind parameter for histograms. * org-colview.el (org-colview-construct-allowed-dates): Better error catching when a date/time property does not have allowed values defined. * org-colview-xemacs.el (org-colview-construct-allowed-dates): Better error catching when a date/time property does not have allowed values defined. 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-map-entries): Restore point and restriction after `org-map-entries'. 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-time=, org-time<, org-time<=, org-time>) (org-time>=, org-time<>): Make sure both values are dates. 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com> * org-archive.el (org-extract-archive-heading): Allow %s for file name also in achive location heading. 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com> * org-archive.el (org-add-archive-files): Uniquify the list before returning it. 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com> * org-compat.el (org-fit-window-to-buffer): Use `window-full-width-p'. * org-export-latex.el (org-export-latex-fixed-width): Enforce the space after the colon in short examples. * org-exp.el (org-export-protect-colon-examples): Rewritten, to enforce a space after the colon. However, we also allow lines that are *only* a colon. (org-export-as-html): Enforce the space after the colon in short examples. (org-export-preprocess-string): Do the colon example protection earlier. (org-export-remove-timestamps): Do not check for protection at the end of the line. 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-format-latex-options): Add new matcher for single letters between dollars. (org-get-header): Function removed. (org-heading-components): New function. * org-exp.el (org-export-define-heading-targets): Record ID's also as alternative targets. (org-export-as-html): Interpret "id:" links to other files by preserving the relative path. * org-jsinfo.el (org-infojs-handle-options): Catch the case if v is nil. * org-exp.el (org-export-normalize-links): Protect the main link, to avoid special character processing. * org-export-latex.el (org-export-latex-special-keyword-regexp): New variable. (org-export-latex-special-string-regexps): Variable removed. (org-export-latex-keywords): Use the new regexp. * org-exp.el (org-export-handle-include-files): Fetch switches and put them into the BEGIN statement. * org-timer.el (org-timer-mode-line-string): New variable. * org-clock.el (org-clock-mode-line-map): Renamed from `org-clock-mode-map'. (org-clock-mode-line-timer): Renamed from `org-mode-line-timer'. (org-clock-update-mode-line): Renamed from `org-update-mode-line'. (org-clock-put-overlay): Renamed from `org-put-clock-overlay'. (org-clock-remove-overlays): Renamed from `org-remove-clock-overlays'. * org-timer.el (org-timer-pause-or-continue): Implement stopping and mode line display. (org-timer-stop): New command. (org-timer-seconds): Return correct time when timer is paused. (org-timer-mode-line-timer): New variable. (org-timer-set-mode-line, org-timer-update-mode-line): New functions. * org.el (org-insert-heading): Handle new value `auto' for `org-blank-before-new-entry'. (org-org-menu): Add new items for timer functions. * org-list.el (org-insert-item): Handle new value `auto' for `org-blank-before-new-entry'. * org.el (org-blank-before-new-entry): New value `auto', made default. 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-normalize-links): If the link is also used as the description, protect the description. 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-closest-date): Fix bug with yearly repeats, in combination with preference of the past as it is used for deadline and scheduling search. * org-exp.el (org-html-handle-time-stamps): No longer check for the `org-export-with-timestamps' option, because the preprocesser has taken care of this already. * org.el (org-entry-properties): Catch the case when this is called in a non-org-mode file. * org-export-latex.el (org-export-latex-remove-from-headlines): Variable made obsolete, also LaTeX export now uses the standard variables. (org-export-as-latex): Add the timestamps parameter to the preprocessor parameter list. (org-export-latex-content): Export the remaining keywords without considering to remove them. (org-export-latex-keywords-maybe): Make the REMOVE-LIST optional. Use bold font instead of tt font for the keywords. (org-export-latex-fontify-headline): Format headlines, assuming that all keywords still present should be published. (org-export-latex-keywords): Remove argument TIMESTAMPS and just publish what ever remains of the time stamps. (org-export-latex-list-parameters): New option. (org-export-latex-lists): Pass additional parameters to the list converter. * org-exp.el (org-export-preprocess-string): Remove clock lines and timestamps already in the preprocesor. (org-export-remove-timestamps, org-export-remove-clock-lines): New functions. (org-export-as-ascii, org-export-as-html): Add the timestamps parameter to the preprocessor parameter list. * org-list.el (org-list-parse-list): Parse for checkboxes. (org-list-to-generic): Introduce and handle new parameters :cbon and :cboff. (org-list-to-latex, org-list-to-html, org-list-to-texinfo): Add optional parameter PARAMS. * org-export-latex.el (org-export-latex-special-chars): Fix problems with interpreting dollar signs. (org-inside-latex-math-p): New function. (org-export-latex-preprocess): Protect all the math fragments. * org.el (org-latex-regexps): Allow a dash after a dollar. * org-w3m.el (org-w3m-copy-for-org-mode): Always deactivate the mark after copying. * org-agenda.el (org-run-agenda-series): Have series options set when finalizing the agenda. * org-exp.el (org-export-format-source-code-or-example): Protect the converted examples. * org.el (org-set-regexps-and-options): Fix the regexp `org-complex-heading-regexp'. 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-edit-src-get-label-format): New function. (org-coderef-label-format): New option. (org-edit-src-code, org-edit-src-find-region-and-lang): Parse for a label format specification and make sure it is used in the edit buffer. (org-edit-src-get-label-format): New function. (org-store-link): Handle new coderef formats. (org-link-search): Handle new coderef formats. * org-footnote.el (org-footnote-create-definition) (org-footnote-goto-local-insertion-point): Make footnote insertion work correctly when the "Footnotes" headline is the last line in the buffer. * org.el (org-goto-marker-or-bmk): Expose context after jumping to the location. 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com> * org-w3m.el (org-w3m): New customization group. (org-w3m-deactivate-mark): New option. (org-w3m-copy-for-org-mode): Deactivate region, unless the user option say not to. 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-set-font-lock-defaults): Trigger footnote fontification. (org-activate-footnote-links): New function. (org-activate-links): New entry `footnote'. * org-faces.el (org-footnote): New face. 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com> * org-macs.el (org-re): Handle the [:word:] class. * org-exp.el (org-export-preprocess-string): Call `org-export-protect-colon-examples'. (org-export-protect-colon-examples): Renamed from `org-export-protect-examples', and scope limited to lines starting with a colon. 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-preprocess-string): Move the preprocess hook to after turning on Org-mode. (org-export-preprocess-after-include-files-hook) (org-export-preprocess-after-tree-selection-hook) (org-export-preprocess-before-backend-specifics-hook) (org-export-preprocess-final-hook): New hooks. (org-export-preprocess-string): Run the new hooks. * org.el (org-ctrl-c-minus): Fix indentation for new items. * org-footnote.el: New file. * org.el (org-footnote): Require footnote code. (org-startup-options): Add new footnote options. (org-mode-map): New keybindig for footnotes. (org-ctrl-c-ctrl-c): Add function at footnotes. (org-org-menu): New menu entries for footnotes. * org-export-latex.el (org-export-as-latex): Pass footnote variable to preprocessor. (org-export-latex-preprocess): Treat multiple references to a footnote. * org-exp.el (org-export-preprocess-string): Call `org-footnote-normalize'. (org-export-as-ascii, org-export-as-html): Pass footnote variable to preprocessor. (org-export-as-html): Treat multiple references to a footnote. 2009-01-25 Carsten Dominik <carsten.dominik@gmail.com> * org-export-latex.el (org-export-latex-links): Handle coderef links. * org.el (org-bracket-link-analytic-regexp++): New variable. (org-make-link-regexps): Initialize `org-bracket-link-analytic-regexp++'. (org-store-link): Implement special case in edit-src buffer. (org-insert-link): No use of ide to insert stored links. (org-link-search): Implement special case for coderefs. * org-exp.el (org-export-html-scripts): New constant. (org-export-html-style-default): Add a new style for highlighted code. (org-export-code-refs): New variable. (org-export-preprocess-string): Initialize `org-export-code-refs'. Call `org-export-replace-src-segments-and-examples' No longer call `org-export-protect-examples'. (org-export-target-internal-links): Take care of coderef targets. (org-export-last-code-line-counter-value): New variable. (org-export-replace-src-segments-and-examples): Renamed from `org-export-replace-src-segments', and modified. (org-export-format-source-code-or-example): Renamed from `org-export-format-source-code'. (org-export-number-lines): New function. (org-export-as-ascii, org-export-as-html): Handle coderef links.
-rw-r--r--doc/misc/ChangeLog27
-rw-r--r--lisp/org/ChangeLog422
-rw-r--r--lisp/org/org-agenda.el93
-rw-r--r--lisp/org/org-archive.el32
-rw-r--r--lisp/org/org-attach.el116
-rw-r--r--lisp/org/org-bbdb.el2
-rw-r--r--lisp/org/org-bibtex.el2
-rw-r--r--lisp/org/org-clock.el40
-rw-r--r--lisp/org/org-colview.el60
-rw-r--r--lisp/org/org-compat.el15
-rw-r--r--lisp/org/org-exp.el581
-rw-r--r--lisp/org/org-export-latex.el274
-rw-r--r--lisp/org/org-faces.el25
-rw-r--r--lisp/org/org-footnote.el504
-rw-r--r--lisp/org/org-gnus.el14
-rw-r--r--lisp/org/org-id.el7
-rw-r--r--lisp/org/org-info.el2
-rw-r--r--lisp/org/org-irc.el4
-rw-r--r--lisp/org/org-jsinfo.el4
-rw-r--r--lisp/org/org-list.el110
-rw-r--r--lisp/org/org-mac-message.el2
-rw-r--r--lisp/org/org-macs.el12
-rw-r--r--lisp/org/org-mew.el2
-rw-r--r--lisp/org/org-mhe.el2
-rw-r--r--lisp/org/org-mouse.el7
-rw-r--r--lisp/org/org-plot.el16
-rw-r--r--lisp/org/org-publish.el2
-rw-r--r--lisp/org/org-remember.el2
-rw-r--r--lisp/org/org-rmail.el2
-rw-r--r--lisp/org/org-table.el90
-rw-r--r--lisp/org/org-timer.el93
-rw-r--r--lisp/org/org-vm.el2
-rw-r--r--lisp/org/org-w3m.el106
-rw-r--r--lisp/org/org-wl.el2
-rw-r--r--lisp/org/org.el547
35 files changed, 2563 insertions, 658 deletions
diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog
index 0a9b4d0fd1d..5390d3c2a94 100644
--- a/doc/misc/ChangeLog
+++ b/doc/misc/ChangeLog
@@ -1,3 +1,30 @@
12009-01-25 Carsten Dominik <dominik@science.uva.nl>
2
3 * org.texi (References): Add information about remote references.
4 (Built-in table editor): Document `C-c RET' in tables.
5 (Math symbols, Quoting LaTeX code): Mention that simple
6 LaTeX macros survive LaTeX export.
7 (Images in LaTeX export): Show how to create a reference to a
8 figure.
9 (Sectioning structure): Document that the LaTeX class can be
10 specified in a property.
11 (Text areas in HTML export): New section.
12 (External links): Add examples for text search and ID links.
13 (Built-in table editor): Remove the descriptio of `C-c
14 C-q', it not longer works.
15 (Literal examples): Document that a space must follow
16 the colon in short examples.
17 (Relative timer): Document `org-timer-stop'.
18 (Footnotes): New section.
19 (Footnote markup): Shorten section and refer to new Footnote
20 section.
21 (Literal examples): Add documentation for line
22 numbering in and references to code examples.
23 (CSS support): Fix the description of default CSS styles.
24 (Capturing column view): Document
25 "file:path/to/file.org" as an allowed value for the ID property of
26 a dynamic block copying column view.
27
12009-01-23 Stephen Eglen <stephen@gnu.org> 282009-01-23 Stephen Eglen <stephen@gnu.org>
2 29
3 * mh-e.texi (Getting Started): Describe $MH. 30 * mh-e.texi (Getting Started): Describe $MH.
diff --git a/lisp/org/ChangeLog b/lisp/org/ChangeLog
index 6d714a502c8..a569d6a1144 100644
--- a/lisp/org/ChangeLog
+++ b/lisp/org/ChangeLog
@@ -1,3 +1,425 @@
12009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
2
3 * org-exp.el (org-export-as-html): Turn \par into a paragraph.
4
5 * org.el (org-agenda-tags-todo-honor-ignore-options): Declare
6 variable.
7
8 * org-table.el (org-table-insert-hline): Fix typo in fuction call
9 to `backward-char'.
10
11 * org-exp.el (org-export-as-html): Remove the initial space from
12 colon examples.
13
14 * org.el (org-scan-tags): Call
15 `org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item'.
16
17 * org-agenda.el (org-agenda-todo-list, org-agenda-match-view): New
18 customization groups.
19 (org-agenda-tags-todo-honor-ignore-options): New option.
20 (org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item):
21 New function.
22 (org-agenda-get-todos): Use
23 `org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item'.
24
252009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
26
27 * org-exp.el (org-export-format-source-code-or-example): Escape
28 HTML characters also in examples that anre not treated with
29 htmlize. Also, just switch to EXAMPLE processing if we do not
30 have a good version of htmlize.
31
32 * org-rmail.el: Fix copyright notice.
33
34 * org.el (org-activate-footnote-links): Improve footnote link
35 highlighting.
36
37 * org-footnote.el (org-footnote-normalize): Fix finding the end of
38 a footnote definition at the end of the file.
39
40 * org-table.el (org-table-get-specials): Add an imagined hline at
41 the end of the table. This can be useful for references that want
42 to go to the end of the table. Also fix bug when computing last
43 row constants, in tables that do not start right at the right
44 margin.
45 (org-table-eval-formula): Match and replace remove references.
46 (org-table-formula-substitute-names): Make sure that names inside
47 a "remote" call are left alone, the will be replaced later when
48 the remote call is handled.
49 (org-table-convert-refs-to-rc): Do not convert things that might
50 look like a reference, but are really part of an ID or namei n a
51 remote reference.
52 (org-table-get-remote-range): New function.
53
542009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
55
56 * org-faces.el (org-clock-overlay): Fix bug in face definition.
57
58 * org-clock.el (org-clock-put-overlay): Use new face instead of
59 `secondary-selection'.
60
61 * org-faces.el (org-clock-overlay): New face.
62
632009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
64
65 * org-exp.el (org-get-current-options): Include the option for
66 publishing time stamps.
67
68 * org.el (org-toggle-heading): Renamed from
69 `org-toggel-region-headings'.
70 No longer needs a region defined, but will use it if there is one.
71 (org-ctrl-c-star): Simplified, relying more on the internal
72 workings of `org-toggle-heading'.
73 (org-toggle-item): Renamed from `org-toggle-region-items'.
74 No longer needs a region defined, but will use it if there is one.
75 (org-ctrl-c-minus): Simplified, relying more on the inernal
76 workings of `org-toggle-item'.
77
78 * org-export-latex.el (org-export-latex-preprocess): Fix bug in
79 environment detection. Also, do real changes only in unprotected
80 places.
81
822009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
83
84 * org-export-latex.el (org-export-latex-quotation-marks): Use
85 `org-if-unprotected-1'.
86 (org-export-latex-set-initial-vars): Check for class definition in
87 property.
88
89 * org-macs.el (org-if-unprotected-1): New macro.
90
912009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
92
93 * org-compat.el (org-count-lines): New function.
94
95 * org-exp.el (org-export-format-source-code-or-example): Handle
96 switches related to text areas.
97
98 * org.el (org-activate-footnote-links): Don't allow match inside a
99 link.
100
101 * org-footnote.el (org-footnote-re): Don't allow match inside a link.
102
103 * org-export-latex.el (org-export-latex-links): Keep a relative
104 path relative also after export.
105
106 * org-exp.el (org-export-html-scripts): Fix HTML snippet.
107
108 * org.el (org-make-tags-matcher): Never use IDO for completing the
109 tags matcher match string.
110 (org-completing-read): Also remove the special biding for "?".
111
112 * org-attach.el (org-attach-allow-inheritance): New option.
113 (org-attach-inherited): New variable.
114 (org-attach-dir): Handle properties related to the attachment
115 directory.
116 (org-attach-check-absolute-path): New function.
117 (org-attach-set-directory, org-attach-set-inherit): New commands.
118 (org-attach): Accommodate the new commands in the dispatcher.
119
1202009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
121
122 * org-compat.el (org-fit-window-to-buffer): Fix bug with using
123 `window-full-width-p'.
124
125 * org-exp.el (org-export-as-html): Only check for images files
126 that really can be inlined
127
128 * org.el (org-image-file-name-regexp, org-file-image-p): Allow the
129 list of extensions to be a parameter.
130
131 * org-exp.el (org-export-html-inline-image-extensions): New
132 variable.
133
134 * org-agenda.el (org-prepare-agenda): Use
135 `org-agenda-block-separator'.
136 (org-agenda-block-separator): New option.
137
1382009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
139
140 * org-export-latex.el (org-export-latex-tables): Call
141 `org-table-clean-before-export' with the new optional argument.
142
143 * org-exp.el (org-table-clean-before-export): New optional
144 parameter MAYBE-QUOTED, allows for quoted characters like \# in
145 first column.
146
1472009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
148
149 * org-plot.el (org-plot/gnuplot): Fix text-ind parameter for
150 histograms.
151
152 * org-colview.el (org-colview-construct-allowed-dates): Better
153 error catching when a date/time property does not have allowed
154 values defined.
155
156 * org-colview-xemacs.el (org-colview-construct-allowed-dates):
157 Better error catching when a date/time property does not have
158 allowed values defined.
159
1602009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
161
162 * org.el (org-map-entries): Restore point and restriction after
163 `org-map-entries'.
164
1652009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
166
167 * org.el (org-time=, org-time<, org-time<=, org-time>)
168 (org-time>=, org-time<>): Make sure both values are dates.
169
1702009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
171
172 * org-archive.el (org-extract-archive-heading): Allow %s for file
173 name also in achive location heading.
174
1752009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
176
177 * org-archive.el (org-add-archive-files): Uniquify the list before
178 returning it.
179
1802009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
181
182 * org-compat.el (org-fit-window-to-buffer): Use
183 `window-full-width-p'.
184
185 * org-export-latex.el (org-export-latex-fixed-width): Enforce the
186 space after the colon in short examples.
187
188 * org-exp.el (org-export-protect-colon-examples): Rewritten, to
189 enforce a space after the colon. However, we also allow lines
190 that are *only* a colon.
191 (org-export-as-html): Enforce the space after the colon in short
192 examples.
193 (org-export-preprocess-string): Do the colon example protection
194 earlier.
195 (org-export-remove-timestamps): Do not check for protection at the
196 end of the line.
197
1982009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
199
200 * org.el (org-format-latex-options): Add new matcher for single
201 letters between dollars.
202 (org-get-header): Function removed.
203 (org-heading-components): New function.
204
205 * org-exp.el (org-export-define-heading-targets): Record ID's also
206 as alternative targets.
207 (org-export-as-html): Interpret "id:" links to other files by
208 preserving the relative path.
209
210 * org-jsinfo.el (org-infojs-handle-options): Catch the case if v
211 is nil.
212
213 * org-exp.el (org-export-normalize-links): Protect the main link,
214 to avoid special character processing.
215
216 * org-export-latex.el (org-export-latex-special-keyword-regexp):
217 New variable.
218 (org-export-latex-special-string-regexps): Variable removed.
219 (org-export-latex-keywords): Use the new regexp.
220
221 * org-exp.el (org-export-handle-include-files): Fetch switches and
222 put them into the BEGIN statement.
223
224 * org-timer.el (org-timer-mode-line-string): New variable.
225
226 * org-clock.el (org-clock-mode-line-map): Renamed from
227 `org-clock-mode-map'.
228 (org-clock-mode-line-timer): Renamed from `org-mode-line-timer'.
229 (org-clock-update-mode-line): Renamed from `org-update-mode-line'.
230 (org-clock-put-overlay): Renamed from `org-put-clock-overlay'.
231 (org-clock-remove-overlays): Renamed from
232 `org-remove-clock-overlays'.
233
234 * org-timer.el (org-timer-pause-or-continue): Implement stopping
235 and mode line display.
236 (org-timer-stop): New command.
237 (org-timer-seconds): Return correct time when timer is paused.
238 (org-timer-mode-line-timer): New variable.
239 (org-timer-set-mode-line, org-timer-update-mode-line): New
240 functions.
241
242 * org.el (org-insert-heading): Handle new value `auto' for
243 `org-blank-before-new-entry'.
244 (org-org-menu): Add new items for timer functions.
245
246 * org-list.el (org-insert-item): Handle new value `auto' for
247 `org-blank-before-new-entry'.
248
249 * org.el (org-blank-before-new-entry): New value `auto', made
250 default.
251
2522009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
253
254 * org-exp.el (org-export-normalize-links): If the link is also
255 used as the description, protect the description.
256
2572009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
258
259 * org.el (org-closest-date): Fix bug with yearly repeats, in
260 combination with preference of the past as it is used for deadline
261 and scheduling search.
262
263 * org-exp.el (org-html-handle-time-stamps): No longer check for
264 the `org-export-with-timestamps' option, because the preprocesser
265 has taken care of this already.
266
267 * org.el (org-entry-properties): Catch the case when this is
268 called in a non-org-mode file.
269
270 * org-export-latex.el (org-export-latex-remove-from-headlines):
271 Variable made obsolete, also LaTeX export now uses the standard
272 variables.
273 (org-export-as-latex): Add the timestamps parameter to the
274 preprocessor parameter list.
275 (org-export-latex-content): Export the remaining keywords without
276 considering to remove them.
277 (org-export-latex-keywords-maybe): Make the REMOVE-LIST optional.
278 Use bold font instead of tt font for the keywords.
279 (org-export-latex-fontify-headline): Format headlines, assuming
280 that all keywords still present should be published.
281 (org-export-latex-keywords): Remove argument TIMESTAMPS and just
282 publish what ever remains of the time stamps.
283 (org-export-latex-list-parameters): New option.
284 (org-export-latex-lists): Pass additional parameters to the list
285 converter.
286
287 * org-exp.el (org-export-preprocess-string): Remove clock lines
288 and timestamps already in the preprocesor.
289 (org-export-remove-timestamps, org-export-remove-clock-lines): New
290 functions.
291 (org-export-as-ascii, org-export-as-html): Add the timestamps
292 parameter to the preprocessor parameter list.
293
294 * org-list.el (org-list-parse-list): Parse for checkboxes.
295 (org-list-to-generic): Introduce and handle new parameters :cbon
296 and :cboff.
297 (org-list-to-latex, org-list-to-html, org-list-to-texinfo): Add
298 optional parameter PARAMS.
299
300 * org-export-latex.el (org-export-latex-special-chars): Fix
301 problems with interpreting dollar signs.
302 (org-inside-latex-math-p): New function.
303 (org-export-latex-preprocess): Protect all the math fragments.
304
305 * org.el (org-latex-regexps): Allow a dash after a dollar.
306
307 * org-w3m.el (org-w3m-copy-for-org-mode): Always deactivate the
308 mark after copying.
309
310 * org-agenda.el (org-run-agenda-series): Have series options set
311 when finalizing the agenda.
312
313 * org-exp.el (org-export-format-source-code-or-example): Protect
314 the converted examples.
315
316 * org.el (org-set-regexps-and-options): Fix the regexp
317 `org-complex-heading-regexp'.
318
3192009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
320
321 * org.el (org-edit-src-get-label-format): New function.
322 (org-coderef-label-format): New option.
323 (org-edit-src-code, org-edit-src-find-region-and-lang): Parse for
324 a label format specification and make sure it is used in the edit
325 buffer.
326 (org-edit-src-get-label-format): New function.
327 (org-store-link): Handle new coderef formats.
328 (org-link-search): Handle new coderef formats.
329
330 * org-footnote.el (org-footnote-create-definition)
331 (org-footnote-goto-local-insertion-point): Make footnote insertion
332 work correctly when the "Footnotes" headline is the last line in
333 the buffer.
334
335 * org.el (org-goto-marker-or-bmk): Expose context after jumping to
336 the location.
337
3382009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
339
340 * org-w3m.el (org-w3m): New customization group.
341 (org-w3m-deactivate-mark): New option.
342 (org-w3m-copy-for-org-mode): Deactivate region, unless the user
343 option say not to.
344
3452009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
346
347 * org.el (org-set-font-lock-defaults): Trigger footnote
348 fontification.
349 (org-activate-footnote-links): New function.
350 (org-activate-links): New entry `footnote'.
351
352 * org-faces.el (org-footnote): New face.
353
3542009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
355
356 * org-macs.el (org-re): Handle the [:word:] class.
357
358 * org-exp.el (org-export-preprocess-string): Call
359 `org-export-protect-colon-examples'.
360 (org-export-protect-colon-examples): Renamed from
361 `org-export-protect-examples', and scope limited to lines starting
362 with a colon.
363
3642009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
365
366 * org-exp.el (org-export-preprocess-string): Move the preprocess
367 hook to after turning on Org-mode.
368 (org-export-preprocess-after-include-files-hook)
369 (org-export-preprocess-after-tree-selection-hook)
370 (org-export-preprocess-before-backend-specifics-hook)
371 (org-export-preprocess-final-hook): New hooks.
372 (org-export-preprocess-string): Run the new hooks.
373
374 * org.el (org-ctrl-c-minus): Fix indentation for new items.
375
376 * org-footnote.el: New file.
377
378 * org.el (org-footnote): Require footnote code.
379 (org-startup-options): Add new footnote options.
380 (org-mode-map): New keybindig for footnotes.
381 (org-ctrl-c-ctrl-c): Add function at footnotes.
382 (org-org-menu): New menu entries for footnotes.
383
384 * org-export-latex.el (org-export-as-latex): Pass footnote
385 variable to preprocessor.
386 (org-export-latex-preprocess): Treat multiple references to a
387 footnote.
388
389 * org-exp.el (org-export-preprocess-string): Call
390 `org-footnote-normalize'.
391 (org-export-as-ascii, org-export-as-html): Pass footnote variable
392 to preprocessor.
393 (org-export-as-html): Treat multiple references to a footnote.
394
3952009-01-25 Carsten Dominik <carsten.dominik@gmail.com>
396
397 * org-export-latex.el (org-export-latex-links): Handle coderef
398 links.
399
400 * org.el (org-bracket-link-analytic-regexp++): New variable.
401 (org-make-link-regexps): Initialize
402 `org-bracket-link-analytic-regexp++'.
403 (org-store-link): Implement special case in edit-src buffer.
404 (org-insert-link): No use of ide to insert stored links.
405 (org-link-search): Implement special case for coderefs.
406
407 * org-exp.el (org-export-html-scripts): New constant.
408 (org-export-html-style-default): Add a new style for highlighted
409 code.
410 (org-export-code-refs): New variable.
411 (org-export-preprocess-string): Initialize `org-export-code-refs'.
412 Call `org-export-replace-src-segments-and-examples'
413 No longer call `org-export-protect-examples'.
414 (org-export-target-internal-links): Take care of coderef targets.
415 (org-export-last-code-line-counter-value): New variable.
416 (org-export-replace-src-segments-and-examples): Renamed from
417 `org-export-replace-src-segments', and modified.
418 (org-export-format-source-code-or-example): Renamed from
419 `org-export-format-source-code'.
420 (org-export-number-lines): New function.
421 (org-export-as-ascii, org-export-as-html): Handle coderef links.
422
12009-01-23 Glenn Morris <rgm@gnu.org> 4232009-01-23 Glenn Morris <rgm@gnu.org>
2 424
3 * org-rmail.el (rmail-narrow-to-non-pruned-header): 425 * org-rmail.el (rmail-narrow-to-non-pruned-header):
diff --git a/lisp/org/org-agenda.el b/lisp/org/org-agenda.el
index d7a94d71e2b..698c6244ac4 100644
--- a/lisp/org/org-agenda.el
+++ b/lisp/org/org-agenda.el
@@ -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.16 9;; Version: 6.19a
10;; 10;;
11;; This file is part of GNU Emacs. 11;; This file is part of GNU Emacs.
12;; 12;;
@@ -81,6 +81,15 @@ This is done by leaving out unnecessary lines."
81 :group 'org-agenda 81 :group 'org-agenda
82 :type 'boolean) 82 :type 'boolean)
83 83
84(defcustom org-agenda-block-separator ?=
85 "The separator between blocks in the agenda.
86If this is a string, it will be used as the separator, with a newline added.
87If it is a character, it will be repeated to fill the window width."
88 :group 'org-agenda
89 :type '(choice
90 (character)
91 (string)))
92
84(defgroup org-agenda-export nil 93(defgroup org-agenda-export nil
85 "Options concerning exporting agenda views in Org-mode." 94 "Options concerning exporting agenda views in Org-mode."
86 :tag "Org Agenda Export" 95 :tag "Org Agenda Export"
@@ -400,6 +409,18 @@ this one will be used."
400 "Options concerning skipping parts of agenda files." 409 "Options concerning skipping parts of agenda files."
401 :tag "Org Agenda Skip" 410 :tag "Org Agenda Skip"
402 :group 'org-agenda) 411 :group 'org-agenda)
412(defgroup org-agenda-daily/weekly nil
413 "Options concerning the daily/weekly agenda."
414 :tag "Org Agenda Daily/Weekly"
415 :group 'org-agenda)
416(defgroup org-agenda-todo-list nil
417 "Options concerning the global todo list agenda view."
418 :tag "Org Agenda Todo List"
419 :group 'org-agenda)
420(defgroup org-agenda-match-view nil
421 "Options concerning the general tags/property/todo match agenda view."
422 :tag "Org Agenda Match View"
423 :group 'org-agenda)
403 424
404(defvar org-agenda-archives-mode nil 425(defvar org-agenda-archives-mode nil
405 "Non-nil means, the agenda will include archived items. 426 "Non-nil means, the agenda will include archived items.
@@ -419,7 +440,7 @@ When nil, these trees are also scanned by agenda commands."
419When nil, the sublevels of a TODO entry are not checked, resulting in 440When nil, the sublevels of a TODO entry are not checked, resulting in
420potentially much shorter TODO lists." 441potentially much shorter TODO lists."
421 :group 'org-agenda-skip 442 :group 'org-agenda-skip
422 :group 'org-todo 443 :group 'org-agenda-todo-list
423 :type 'boolean) 444 :type 'boolean)
424 445
425(defcustom org-agenda-todo-ignore-with-date nil 446(defcustom org-agenda-todo-ignore-with-date nil
@@ -430,7 +451,7 @@ When this is set, it also covers deadlines and scheduled items, the settings
430of `org-agenda-todo-ignore-scheduled' and `org-agenda-todo-ignore-deadlines' 451of `org-agenda-todo-ignore-scheduled' and `org-agenda-todo-ignore-deadlines'
431will be ignored." 452will be ignored."
432 :group 'org-agenda-skip 453 :group 'org-agenda-skip
433 :group 'org-todo 454 :group 'org-agenda-todo-list
434 :type 'boolean) 455 :type 'boolean)
435 456
436(defcustom org-agenda-todo-ignore-scheduled nil 457(defcustom org-agenda-todo-ignore-scheduled nil
@@ -439,7 +460,7 @@ The idea behind this is that by scheduling it, you have already taken care
439of this item. 460of this item.
440See also `org-agenda-todo-ignore-with-date'." 461See also `org-agenda-todo-ignore-with-date'."
441 :group 'org-agenda-skip 462 :group 'org-agenda-skip
442 :group 'org-todo 463 :group 'org-agenda-todo-list
443 :type 'boolean) 464 :type 'boolean)
444 465
445(defcustom org-agenda-todo-ignore-deadlines nil 466(defcustom org-agenda-todo-ignore-deadlines nil
@@ -448,7 +469,22 @@ Near means closer than `org-deadline-warning-days' days.
448The idea behind this is that such items will appear in the agenda anyway. 469The idea behind this is that such items will appear in the agenda anyway.
449See also `org-agenda-todo-ignore-with-date'." 470See also `org-agenda-todo-ignore-with-date'."
450 :group 'org-agenda-skip 471 :group 'org-agenda-skip
451 :group 'org-todo 472 :group 'org-agenda-todo-list
473 :type 'boolean)
474
475(defcustom org-agenda-tags-todo-honor-ignore-options nil
476 "Non-nil means, honor todo-list ...ignore options also in tags-todo search.
477The variables
478 `org-agenda-todo-ignore-with-date',
479 `org-agenda-todo-ignore-scheduled'
480 `org-agenda-todo-ignore-deadlines'
481make the global TODO list skip entries that have time stamps of certain
482kinds. If this option is set, the same options will also apply for the
483tags-todo search, which is the general tags/property matcher
484restricted to unfinished TODO entries only."
485 :group 'org-agenda-skip
486 :group 'org-agenda-todo-list
487 :group 'org-agenda-match-view
452 :type 'boolean) 488 :type 'boolean)
453 489
454(defcustom org-agenda-skip-scheduled-if-done nil 490(defcustom org-agenda-skip-scheduled-if-done nil
@@ -458,6 +494,7 @@ it applies only to the actual date of the scheduling. Warnings about
458an item with a past scheduling dates are always turned off when the item 494an item with a past scheduling dates are always turned off when the item
459is DONE." 495is DONE."
460 :group 'org-agenda-skip 496 :group 'org-agenda-skip
497 :group 'org-agenda-daily/weekly
461 :type 'boolean) 498 :type 'boolean)
462 499
463(defcustom org-agenda-skip-deadline-if-done nil 500(defcustom org-agenda-skip-deadline-if-done nil
@@ -467,11 +504,13 @@ This is relevant for the daily/weekly agenda. And it applied only to the
467actually date of the deadline. Warnings about approaching and past-due 504actually date of the deadline. Warnings about approaching and past-due
468deadlines are always turned off when the item is DONE." 505deadlines are always turned off when the item is DONE."
469 :group 'org-agenda-skip 506 :group 'org-agenda-skip
507 :group 'org-agenda-daily/weekly
470 :type 'boolean) 508 :type 'boolean)
471 509
472(defcustom org-agenda-skip-timestamp-if-done nil 510(defcustom org-agenda-skip-timestamp-if-done nil
473 "Non-nil means don't select item by timestamp or -range if it is DONE." 511 "Non-nil means don't select item by timestamp or -range if it is DONE."
474 :group 'org-agenda-skip 512 :group 'org-agenda-skip
513 :group 'org-agenda-daily/weekly
475 :type 'boolean) 514 :type 'boolean)
476 515
477(defcustom org-timeline-show-empty-dates 3 516(defcustom org-timeline-show-empty-dates 3
@@ -550,11 +589,6 @@ option will be ignored.."
550 :group 'org-agenda-windows 589 :group 'org-agenda-windows
551 :type 'boolean) 590 :type 'boolean)
552 591
553(defgroup org-agenda-daily/weekly nil
554 "Options concerning the daily/weekly agenda."
555 :tag "Org Agenda Daily/Weekly"
556 :group 'org-agenda)
557
558(defcustom org-agenda-ndays 7 592(defcustom org-agenda-ndays 7
559 "Number of days to include in overview display. 593 "Number of days to include in overview display.
560Should be 1 or 7." 594Should be 1 or 7."
@@ -631,7 +665,8 @@ and timeline buffers."
631(defcustom org-agenda-include-all-todo nil 665(defcustom org-agenda-include-all-todo nil
632 "Set means weekly/daily agenda will always contain all TODO entries. 666 "Set means weekly/daily agenda will always contain all TODO entries.
633The TODO entries will be listed at the top of the agenda, before 667The TODO entries will be listed at the top of the agenda, before
634the entries for specific days." 668the entries for specific days.
669This option is deprecated, it is better to define a block agenda instead."
635 :group 'org-agenda-daily/weekly 670 :group 'org-agenda-daily/weekly
636 :type 'boolean) 671 :type 'boolean)
637 672
@@ -991,7 +1026,6 @@ or a list like `(:background \"Red\")'."
991 (list (character :tag "Priority" :value ?A) 1026 (list (character :tag "Priority" :value ?A)
992 (sexp :tag "face"))))) 1027 (sexp :tag "face")))))
993 1028
994
995(defgroup org-agenda-column-view nil 1029(defgroup org-agenda-column-view nil
996 "Options concerning column view in the agenda." 1030 "Options concerning column view in the agenda."
997 :tag "Org Agenda Column View" 1031 :tag "Org Agenda Column View"
@@ -1057,7 +1091,8 @@ works you probably want to add it to `org-agenda-custom-commands' for good."
1057(defvar org-agenda-show-log nil) 1091(defvar org-agenda-show-log nil)
1058(defvar org-agenda-redo-command nil) 1092(defvar org-agenda-redo-command nil)
1059(defvar org-agenda-query-string nil) 1093(defvar org-agenda-query-string nil)
1060(defvar org-agenda-mode-hook nil) 1094(defvar org-agenda-mode-hook nil
1095 "Hook for org-agenda-mode, run after the mode is turned on.")
1061(defvar org-agenda-type nil) 1096(defvar org-agenda-type nil)
1062(defvar org-agenda-force-single-file nil) 1097(defvar org-agenda-force-single-file nil)
1063 1098
@@ -1712,7 +1747,7 @@ s Search for keywords C Configure custom agenda commands
1712 (widen) 1747 (widen)
1713 (setq org-agenda-redo-command redo) 1748 (setq org-agenda-redo-command redo)
1714 (goto-char (point-min))) 1749 (goto-char (point-min)))
1715 (org-finalize-agenda)) 1750 (org-let (nth 1 series) '(org-finalize-agenda)))
1716 1751
1717;;;###autoload 1752;;;###autoload
1718(defmacro org-batch-agenda (cmd-key &rest parameters) 1753(defmacro org-batch-agenda (cmd-key &rest parameters)
@@ -2040,7 +2075,11 @@ VALUE defaults to t."
2040 (setq buffer-read-only nil) 2075 (setq buffer-read-only nil)
2041 (goto-char (point-max)) 2076 (goto-char (point-max))
2042 (unless (or (bobp) org-agenda-compact-blocks) 2077 (unless (or (bobp) org-agenda-compact-blocks)
2043 (insert "\n" (make-string (window-width) ?=) "\n")) 2078 (insert "\n"
2079 (if (stringp org-agenda-block-separator)
2080 org-agenda-block-separator
2081 (make-string (window-width) org-agenda-block-separator))
2082 "\n"))
2044 (narrow-to-region (point) (point-max))) 2083 (narrow-to-region (point) (point-max)))
2045 (org-agenda-reset-markers) 2084 (org-agenda-reset-markers)
2046 (setq org-agenda-contributing-files nil) 2085 (setq org-agenda-contributing-files nil)
@@ -3234,13 +3273,7 @@ the documentation of `org-diary'."
3234 (save-match-data 3273 (save-match-data
3235 (beginning-of-line) 3274 (beginning-of-line)
3236 (setq beg (point) end (progn (outline-next-heading) (point))) 3275 (setq beg (point) end (progn (outline-next-heading) (point)))
3237 (when (or (and org-agenda-todo-ignore-with-date (goto-char beg) 3276 (when (org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item end)
3238 (re-search-forward org-ts-regexp end t))
3239 (and org-agenda-todo-ignore-scheduled (goto-char beg)
3240 (re-search-forward org-scheduled-time-regexp end t))
3241 (and org-agenda-todo-ignore-deadlines (goto-char beg)
3242 (re-search-forward org-deadline-time-regexp end t)
3243 (org-deadline-close (match-string 1))))
3244 (goto-char (1+ beg)) 3277 (goto-char (1+ beg))
3245 (or org-agenda-todo-list-sublevels (org-end-of-subtree 'invisible)) 3278 (or org-agenda-todo-list-sublevels (org-end-of-subtree 'invisible))
3246 (throw :skip nil))) 3279 (throw :skip nil)))
@@ -3263,6 +3296,22 @@ the documentation of `org-diary'."
3263 (org-end-of-subtree 'invisible)))) 3296 (org-end-of-subtree 'invisible))))
3264 (nreverse ee))) 3297 (nreverse ee)))
3265 3298
3299;;;###autoload
3300(defun org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item (&optional end)
3301 "Do we have a reason to ignore this todo entry because it has a time stamp?"
3302 (when (or org-agenda-todo-ignore-with-date
3303 org-agenda-todo-ignore-scheduled
3304 org-agenda-todo-ignore-deadlines)
3305 (setq end (or end (save-excursion (outline-next-heading) (point))))
3306 (save-excursion
3307 (or (and org-agenda-todo-ignore-with-date
3308 (re-search-forward org-ts-regexp end t))
3309 (and org-agenda-todo-ignore-scheduled
3310 (re-search-forward org-scheduled-time-regexp end t))
3311 (and org-agenda-todo-ignore-deadlines
3312 (re-search-forward org-deadline-time-regexp end t)
3313 (org-deadline-close (match-string 1)))))))
3314
3266(defconst org-agenda-no-heading-message 3315(defconst org-agenda-no-heading-message
3267 "No heading for this item in buffer or region.") 3316 "No heading for this item in buffer or region.")
3268 3317
diff --git a/lisp/org/org-archive.el b/lisp/org/org-archive.el
index 530a052e21b..baddac4abe7 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.16 8;; Version: 6.19a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
@@ -102,18 +102,19 @@ information."
102 (t org-archive-location (match-string 1))))))) 102 (t org-archive-location (match-string 1)))))))
103 103
104(defun org-add-archive-files (files) 104(defun org-add-archive-files (files)
105 "Splice the archive files into the list f files. 105 "Splice the archive files into the list of files.
106This implies visiting all these files and finding out what the 106This implies visiting all these files and finding out what the
107archive file is." 107archive file is."
108 (apply 108 (org-uniquify
109 'append 109 (apply
110 (mapcar 110 'append
111 (lambda (f) 111 (mapcar
112 (if (not (file-exists-p f)) 112 (lambda (f)
113 nil 113 (if (not (file-exists-p f))
114 (with-current-buffer (org-get-agenda-file-buffer f) 114 nil
115 (cons f (org-all-archive-files))))) 115 (with-current-buffer (org-get-agenda-file-buffer f)
116 files))) 116 (cons f (org-all-archive-files)))))
117 files))))
117 118
118(defun org-all-archive-files () 119(defun org-all-archive-files ()
119 "Get a list of all archive files used in the current buffer." 120 "Get a list of all archive files used in the current buffer."
@@ -150,7 +151,8 @@ if LOCATION is not given, the value of `org-archive-location' is used."
150if LOCATION is not given, the value of `org-archive-location' is used." 151if LOCATION is not given, the value of `org-archive-location' is used."
151 (setq location (or location org-archive-location)) 152 (setq location (or location org-archive-location))
152 (if (string-match "\\(.*\\)::\\(.*\\)" location) 153 (if (string-match "\\(.*\\)::\\(.*\\)" location)
153 (match-string 2 location))) 154 (format (match-string 2 location)
155 (file-name-nondirectory buffer-file-name))))
154 156
155(defun org-archive-subtree (&optional find-done) 157(defun org-archive-subtree (&optional find-done)
156 "Move the current subtree to the archive. 158 "Move the current subtree to the archive.
@@ -304,7 +306,8 @@ this heading."
304 (message "Subtree archived %s" 306 (message "Subtree archived %s"
305 (if (eq this-buffer buffer) 307 (if (eq this-buffer buffer)
306 (concat "under heading: " heading) 308 (concat "under heading: " heading)
307 (concat "in file: " (abbreviate-file-name afile))))))) 309 (concat "in file: " (abbreviate-file-name afile))))))
310 (org-reveal))
308 311
309(defun org-archive-to-archive-sibling () 312(defun org-archive-to-archive-sibling ()
310 "Archive the current heading by moving it under the archive sibling. 313 "Archive the current heading by moving it under the archive sibling.
@@ -355,7 +358,8 @@ sibling does not exist, it will be created at the end of the subtree."
355 (outline-up-heading 1 t) 358 (outline-up-heading 1 t)
356 (hide-subtree) 359 (hide-subtree)
357 (org-cycle-show-empty-lines 'folded) 360 (org-cycle-show-empty-lines 'folded)
358 (goto-char pos)))) 361 (goto-char pos)))
362 (org-reveal))
359 363
360(defun org-archive-all-done (&optional tag) 364(defun org-archive-all-done (&optional tag)
361 "Archive sublevels of the current tree without open TODO items. 365 "Archive sublevels of the current tree without open TODO items.
diff --git a/lisp/org/org-attach.el b/lisp/org/org-attach.el
index d2685b52827..9ee6af64efe 100644
--- a/lisp/org/org-attach.el
+++ b/lisp/org/org-attach.el
@@ -4,7 +4,7 @@
4 4
5;; Author: John Wiegley <johnw@newartisans.com> 5;; Author: John Wiegley <johnw@newartisans.com>
6;; Keywords: org data task 6;; Keywords: org data task
7;; Version: 6.16 7;; Version: 6.19a
8 8
9;; This file is part of GNU Emacs. 9;; This file is part of GNU Emacs.
10;; 10;;
@@ -64,7 +64,9 @@ where the Org file lives."
64 64
65(defcustom org-attach-file-list-property "Attachments" 65(defcustom org-attach-file-list-property "Attachments"
66 "The property used to keep a list of attachment belonging to this entry. 66 "The property used to keep a list of attachment belonging to this entry.
67This is not really needed, so you may set this to nil if you don't want it." 67This is not really needed, so you may set this to nil if you don't want it.
68Also, for entries where children inherit the directory, the list of
69attachments is not kept in this property."
68 :group 'org-attach 70 :group 'org-attach
69 :type '(choice 71 :type '(choice
70 (const :tag "None" nil) 72 (const :tag "None" nil)
@@ -89,6 +91,15 @@ ln create a hard link. Note that this is not supported
89 :group 'org-attach 91 :group 'org-attach
90 :type 'boolean) 92 :type 'boolean)
91 93
94(defcustom org-attach-allow-inheritance t
95 "Non-nil means, allow attachment directories be inherited."
96 :group 'org-attach
97 :type 'boolean)
98
99
100(defvar org-attach-inherited nil
101 "Indicates if the last access to the attachment directory was inherited.")
102
92;;;###autoload 103;;;###autoload
93(defun org-attach () 104(defun org-attach ()
94 "The dispatcher for attachment commands. 105 "The dispatcher for attachment commands.
@@ -124,7 +135,10 @@ F Like \"f\", but force using dired in Emacs.
124 135
125d Delete one attachment, you will be prompted for a file name. 136d Delete one attachment, you will be prompted for a file name.
126D Delete all of a task's attachments. A safer way is 137D Delete all of a task's attachments. A safer way is
127 to open the directory in dired and delete from there."))) 138 to open the directory in dired and delete from there.
139
140s Set a specific attachment directory for this entry.
141i Make children of the current entry inherit its attachment directory.")))
128 (org-fit-window-to-buffer (get-buffer-window "*Org Attach*")) 142 (org-fit-window-to-buffer (get-buffer-window "*Org Attach*"))
129 (message "Select command: [acmlzoOfFdD]") 143 (message "Select command: [acmlzoOfFdD]")
130 (setq c (read-char-exclusive)) 144 (setq c (read-char-exclusive))
@@ -147,29 +161,81 @@ D Delete all of a task's attachments. A safer way is
147 'org-attach-delete-one)) 161 'org-attach-delete-one))
148 ((eq c ?D) (call-interactively 'org-attach-delete-all)) 162 ((eq c ?D) (call-interactively 'org-attach-delete-all))
149 ((eq c ?q) (message "Abort")) 163 ((eq c ?q) (message "Abort"))
164 ((memq c '(?s ?\C-s)) (call-interactively
165 'org-attach-set-directory))
166 ((memq c '(?i ?\C-i)) (call-interactively
167 'org-attach-set-inherit))
150 (t (error "No such attachment command %c" c)))))) 168 (t (error "No such attachment command %c" c))))))
151 169
152(defun org-attach-dir (&optional create-if-not-exists-p) 170(defun org-attach-dir (&optional create-if-not-exists-p)
153 "Return the directory associated with the current entry. 171 "Return the directory associated with the current entry.
172This first checks for a local property ATTACH_DIR, and then for an inherited
173property ATTACH_DIR_INHERIT. If neither exists, the default mechanism
174using the entry ID will be invoked to access the unique directory for the
175current entry.
154If the directory does not exist and CREATE-IF-NOT-EXISTS-P is non-nil, 176If the directory does not exist and CREATE-IF-NOT-EXISTS-P is non-nil,
155the directory and the corresponding ID will be created." 177the directory and (if necessary) the corresponding ID will be created."
156 (when (and (not (buffer-file-name (buffer-base-buffer))) 178 (let (attach-dir uuid inherit)
157 (not (file-name-absolute-p org-attach-directory))) 179 (setq org-attach-inherited (org-entry-get nil "ATTACH_DIR_INHERIT"))
158 (error "Need absolute `org-attach-directory' to attach in buffers without filename.")) 180 (cond
159 (let ((uuid (org-id-get (point) create-if-not-exists-p))) 181 ((setq attach-dir (org-entry-get nil "ATTACH_DIR"))
160 (when (or uuid create-if-not-exists-p) 182 (org-attach-check-absolute-path attach-dir))
161 (unless uuid 183 ((and org-attach-allow-inheritance
162 (error "ID retrieval/creation failed")) 184 (setq inherit (org-entry-get nil "ATTACH_DIR_INHERIT" t)))
163 (let ((attach-dir (expand-file-name 185 (setq attach-dir
164 (format "%s/%s" 186 (save-excursion
165 (substring uuid 0 2) 187 (save-restriction
166 (substring uuid 2)) 188 (widen)
167 (expand-file-name org-attach-directory)))) 189 (goto-char org-entry-property-inherited-from)
168 (if (and create-if-not-exists-p 190 (let (org-attach-allow-inheritance)
169 (not (file-directory-p attach-dir))) 191 (org-attach-dir create-if-not-exists-p)))))
170 (make-directory attach-dir t)) 192 (org-attach-check-absolute-path attach-dir)
171 (and (file-exists-p attach-dir) 193 (setq org-attach-inherited t))
172 attach-dir))))) 194 (t ; use the ID
195 (org-attach-check-absolute-path nil)
196 (setq uuid (org-id-get (point) create-if-not-exists-p))
197 (when (or uuid create-if-not-exists-p)
198 (unless uuid (error "ID retrieval/creation failed"))
199 (setq attach-dir (expand-file-name
200 (format "%s/%s"
201 (substring uuid 0 2)
202 (substring uuid 2))
203 (expand-file-name org-attach-directory))))))
204 (when attach-dir
205 (if (and create-if-not-exists-p
206 (not (file-directory-p attach-dir)))
207 (make-directory attach-dir t))
208 (and (file-exists-p attach-dir)
209 attach-dir))))
210
211(defun org-attach-check-absolute-path (dir)
212 "Check if we have enough information to root the atachment directory.
213When DIR is given, check also if it is already absolute. Otherwise,
214assume that it will be relative, and check if `org-attach-directory' is
215absolute, or if at least the current buffer has a file name.
216Throw an error if we cannot root the directory."
217 (or (and dir (file-name-absolute-p dir))
218 (file-name-absolute-p org-attach-directory)
219 (buffer-file-name (buffer-base-buffer))
220 (error "Need absolute `org-attach-directory' to attach in buffers without filename.")))
221
222(defun org-attach-set-directory ()
223 "Set the ATTACH_DIR property of the current entry.
224The property defines the directory that is used for attachments
225of the entry."
226 (interactive)
227 (let ((dir (org-entry-get nil "ATTACH_DIR")))
228 (setq dir (read-directory-name "Attachment directory: " dir))
229 (org-entry-put nil "ATTACH_DIR" dir)))
230
231(defun org-attach-set-inherit ()
232 "Set the ATTACH_DIR_INHERIT property of the current entry.
233The property defines the directory that is used for attachments
234of the entry and any children that do not explicitly define (by setting
235the ATTACH_DIR property) their own attachment directory."
236 (interactive)
237 (org-entry-put nil "ATTACH_DIR_INHERIT" "t")
238 (message "Children will inherit attachment directory"))
173 239
174(defun org-attach-commit () 240(defun org-attach-commit ()
175 "Commit changes to git if `org-attach-directory' is properly initialized. 241 "Commit changes to git if `org-attach-directory' is properly initialized.
@@ -200,7 +266,7 @@ METHOD may be `cp', `mv', or `ln', default taken from `org-attach-method'."
200 (interactive "fFile to keep as an attachment: \nP") 266 (interactive "fFile to keep as an attachment: \nP")
201 (setq method (or method org-attach-method)) 267 (setq method (or method org-attach-method))
202 (let ((basename (file-name-nondirectory file))) 268 (let ((basename (file-name-nondirectory file)))
203 (when org-attach-file-list-property 269 (when (and org-attach-file-list-property (not org-attach-inherited))
204 (org-entry-add-to-multivalued-property 270 (org-entry-add-to-multivalued-property
205 (point) org-attach-file-list-property basename)) 271 (point) org-attach-file-list-property basename))
206 (let* ((attach-dir (org-attach-dir t)) 272 (let* ((attach-dir (org-attach-dir t))
@@ -234,7 +300,7 @@ On some systems, this apparently does copy the file instead."
234 "Create a new attachment FILE for the current task. 300 "Create a new attachment FILE for the current task.
235The attachment is created as an Emacs buffer." 301The attachment is created as an Emacs buffer."
236 (interactive "sCreate attachment named: ") 302 (interactive "sCreate attachment named: ")
237 (when org-attach-file-list-property 303 (when (and org-attach-file-list-property (not org-attach-inherited))
238 (org-entry-add-to-multivalued-property 304 (org-entry-add-to-multivalued-property
239 (point) org-attach-file-list-property file)) 305 (point) org-attach-file-list-property file))
240 (let ((attach-dir (org-attach-dir t))) 306 (let ((attach-dir (org-attach-dir t)))
@@ -263,7 +329,7 @@ The attachment is created as an Emacs buffer."
263This actually deletes the entire attachment directory. 329This actually deletes the entire attachment directory.
264A safer way is to open the directory in dired and delete from there." 330A safer way is to open the directory in dired and delete from there."
265 (interactive "P") 331 (interactive "P")
266 (when org-attach-file-list-property 332 (when (and org-attach-file-list-property (not org-attach-inherited))
267 (org-entry-delete (point) org-attach-file-list-property)) 333 (org-entry-delete (point) org-attach-file-list-property))
268 (let ((attach-dir (org-attach-dir))) 334 (let ((attach-dir (org-attach-dir)))
269 (when 335 (when
@@ -280,7 +346,7 @@ A safer way is to open the directory in dired and delete from there."
280This can be used after files have been added externally." 346This can be used after files have been added externally."
281 (interactive) 347 (interactive)
282 (org-attach-commit) 348 (org-attach-commit)
283 (when org-attach-file-list-property 349 (when (and org-attach-file-list-property (not org-attach-inherited))
284 (org-entry-delete (point) org-attach-file-list-property)) 350 (org-entry-delete (point) org-attach-file-list-property))
285 (let ((attach-dir (org-attach-dir))) 351 (let ((attach-dir (org-attach-dir)))
286 (when attach-dir 352 (when attach-dir
diff --git a/lisp/org/org-bbdb.el b/lisp/org/org-bbdb.el
index 18ca2b448b9..b925151743f 100644
--- a/lisp/org/org-bbdb.el
+++ b/lisp/org/org-bbdb.el
@@ -7,7 +7,7 @@
7;; Thomas Baumann <thomas dot baumann at ch dot tum dot de> 7;; Thomas Baumann <thomas dot baumann at ch dot tum dot de>
8;; Keywords: outlines, hypermedia, calendar, wp 8;; Keywords: outlines, hypermedia, calendar, wp
9;; Homepage: http://orgmode.org 9;; Homepage: http://orgmode.org
10;; Version: 6.16 10;; Version: 6.19a
11;; 11;;
12;; This file is part of GNU Emacs. 12;; This file is part of GNU Emacs.
13;; 13;;
diff --git a/lisp/org/org-bibtex.el b/lisp/org/org-bibtex.el
index b95b22918ee..0df5d4a05ac 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.16 8;; Version: 6.19a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
diff --git a/lisp/org/org-clock.el b/lisp/org/org-clock.el
index 575a0ea76d0..21f2dab4fee 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.16 8;; Version: 6.19a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
@@ -140,7 +140,7 @@ load."
140(defvar org-mode-line-string "") 140(defvar org-mode-line-string "")
141(put 'org-mode-line-string 'risky-local-variable t) 141(put 'org-mode-line-string 'risky-local-variable t)
142 142
143(defvar org-mode-line-timer nil) 143(defvar org-clock-mode-line-timer nil)
144(defvar org-clock-heading "") 144(defvar org-clock-heading "")
145(defvar org-clock-heading-for-remember "") 145(defvar org-clock-heading-for-remember "")
146(defvar org-clock-start-time "") 146(defvar org-clock-start-time "")
@@ -156,8 +156,8 @@ of a different task.")
156(defvar org-clock-interrupted-task (make-marker) 156(defvar org-clock-interrupted-task (make-marker)
157 "Marker pointing to the task that has been interrupted by the current clock.") 157 "Marker pointing to the task that has been interrupted by the current clock.")
158 158
159(defvar org-clock-mode-map (make-sparse-keymap)) 159(defvar org-clock-mode-line-map (make-sparse-keymap))
160(define-key org-clock-mode-map [mode-line mouse-2] 'org-clock-goto) 160(define-key org-clock-mode-line-map [mode-line mouse-2] 'org-clock-goto)
161 161
162(defun org-clock-history-push (&optional pos buffer) 162(defun org-clock-history-push (&optional pos buffer)
163 "Push a marker to the clock history." 163 "Push a marker to the clock history."
@@ -241,7 +241,7 @@ of a different task.")
241 (insert (format "[%c] %-15s %s\n" i cat task)) 241 (insert (format "[%c] %-15s %s\n" i cat task))
242 (cons i marker))))) 242 (cons i marker)))))
243 243
244(defun org-update-mode-line () 244(defun org-clock-update-mode-line ()
245 (let* ((delta (- (time-to-seconds (current-time)) 245 (let* ((delta (- (time-to-seconds (current-time))
246 (time-to-seconds org-clock-start-time))) 246 (time-to-seconds org-clock-start-time)))
247 (h (floor delta 3600)) 247 (h (floor delta 3600))
@@ -256,7 +256,7 @@ of a different task.")
256 (org-propertize (substring clock-string 0 org-clock-string-limit) 256 (org-propertize (substring clock-string 0 org-clock-string-limit)
257 'help-echo (concat help-text ": " org-clock-heading)) 257 'help-echo (concat help-text ": " org-clock-heading))
258 (org-propertize clock-string 'help-echo help-text))) 258 (org-propertize clock-string 'help-echo help-text)))
259 'local-map org-clock-mode-map 259 'local-map org-clock-mode-line-map
260 'mouse-face (if (featurep 'xemacs) 'highlight 'mode-line-highlight))) 260 'mouse-face (if (featurep 'xemacs) 'highlight 'mode-line-highlight)))
261 (force-mode-line-update))) 261 (force-mode-line-update)))
262 262
@@ -363,9 +363,9 @@ the clocking selection, associated with the letter `d'."
363 (or (memq 'org-mode-line-string global-mode-string) 363 (or (memq 'org-mode-line-string global-mode-string)
364 (setq global-mode-string 364 (setq global-mode-string
365 (append global-mode-string '(org-mode-line-string)))) 365 (append global-mode-string '(org-mode-line-string))))
366 (org-update-mode-line) 366 (org-clock-update-mode-line)
367 (setq org-mode-line-timer 367 (setq org-clock-mode-line-timer
368 (run-with-timer 60 60 'org-update-mode-line)) 368 (run-with-timer 60 60 'org-clock-update-mode-line))
369 (message "Clock started at %s" ts))))))) 369 (message "Clock started at %s" ts)))))))
370 370
371(defun org-clock-find-position () 371(defun org-clock-find-position ()
@@ -463,9 +463,9 @@ If there is no running clock, throw an error, unless FAIL-QUIETLY is set."
463 (when org-log-note-clock-out 463 (when org-log-note-clock-out
464 (org-add-log-setup 'clock-out nil nil nil 464 (org-add-log-setup 'clock-out nil nil nil
465 (concat "# Task: " (org-get-heading t) "\n\n"))) 465 (concat "# Task: " (org-get-heading t) "\n\n")))
466 (when org-mode-line-timer 466 (when org-clock-mode-line-timer
467 (cancel-timer org-mode-line-timer) 467 (cancel-timer org-clock-mode-line-timer)
468 (setq org-mode-line-timer nil)) 468 (setq org-clock-mode-line-timer nil))
469 (setq global-mode-string 469 (setq global-mode-string
470 (delq 'org-mode-line-string global-mode-string)) 470 (delq 'org-mode-line-string global-mode-string))
471 (force-mode-line-update) 471 (force-mode-line-update)
@@ -562,7 +562,7 @@ Puts the resulting times in minutes as a text property on each headline."
562If TOTAL-ONLY is non-nil, only show the total time for the entire file 562If TOTAL-ONLY is non-nil, only show the total time for the entire file
563in the echo area." 563in the echo area."
564 (interactive) 564 (interactive)
565 (org-remove-clock-overlays) 565 (org-clock-remove-overlays)
566 (let (time h m p) 566 (let (time h m p)
567 (org-clock-sum) 567 (org-clock-sum)
568 (unless total-only 568 (unless total-only
@@ -574,19 +574,19 @@ in the echo area."
574 (point) :org-clock-minutes))) 574 (point) :org-clock-minutes)))
575 (goto-char p) 575 (goto-char p)
576 (when (setq time (get-text-property p :org-clock-minutes)) 576 (when (setq time (get-text-property p :org-clock-minutes))
577 (org-put-clock-overlay time (funcall outline-level)))) 577 (org-clock-put-overlay time (funcall outline-level))))
578 (setq h (/ org-clock-file-total-minutes 60) 578 (setq h (/ org-clock-file-total-minutes 60)
579 m (- org-clock-file-total-minutes (* 60 h))) 579 m (- org-clock-file-total-minutes (* 60 h)))
580 ;; Arrange to remove the overlays upon next change. 580 ;; Arrange to remove the overlays upon next change.
581 (when org-remove-highlights-with-change 581 (when org-remove-highlights-with-change
582 (org-add-hook 'before-change-functions 'org-remove-clock-overlays 582 (org-add-hook 'before-change-functions 'org-clock-remove-overlays
583 nil 'local)))) 583 nil 'local))))
584 (message (concat "Total file time: " org-time-clocksum-format " (%d hours and %d minutes)") h m h m))) 584 (message (concat "Total file time: " org-time-clocksum-format " (%d hours and %d minutes)") h m h m)))
585 585
586(defvar org-clock-overlays nil) 586(defvar org-clock-overlays nil)
587(make-variable-buffer-local 'org-clock-overlays) 587(make-variable-buffer-local 'org-clock-overlays)
588 588
589(defun org-put-clock-overlay (time &optional level) 589(defun org-clock-put-overlay (time &optional level)
590 "Put an overlays on the current line, displaying TIME. 590 "Put an overlays on the current line, displaying TIME.
591If LEVEL is given, prefix time with a corresponding number of stars. 591If LEVEL is given, prefix time with a corresponding number of stars.
592This creates a new overlay and stores it in `org-clock-overlays', so that it 592This creates a new overlay and stores it in `org-clock-overlays', so that it
@@ -605,7 +605,7 @@ will be easy to remove."
605 (org-add-props (format fmt 605 (org-add-props (format fmt
606 (make-string l ?*) h m 606 (make-string l ?*) h m
607 (make-string (- 16 l) ?\ )) 607 (make-string (- 16 l) ?\ ))
608 '(face secondary-selection)) 608 (list 'face 'org-clock-overlay))
609 "")) 609 ""))
610 (if (not (featurep 'xemacs)) 610 (if (not (featurep 'xemacs))
611 (org-overlay-put ov 'display tx) 611 (org-overlay-put ov 'display tx)
@@ -613,7 +613,7 @@ will be easy to remove."
613 (org-overlay-put ov 'end-glyph (make-glyph tx))) 613 (org-overlay-put ov 'end-glyph (make-glyph tx)))
614 (push ov org-clock-overlays))) 614 (push ov org-clock-overlays)))
615 615
616(defun org-remove-clock-overlays (&optional beg end noremove) 616(defun org-clock-remove-overlays (&optional beg end noremove)
617 "Remove the occur highlights from the buffer. 617 "Remove the occur highlights from the buffer.
618BEG and END are ignored. If NOREMOVE is nil, remove this function 618BEG and END are ignored. If NOREMOVE is nil, remove this function
619from the `before-change-functions' in the current buffer." 619from the `before-change-functions' in the current buffer."
@@ -623,7 +623,7 @@ from the `before-change-functions' in the current buffer."
623 (setq org-clock-overlays nil) 623 (setq org-clock-overlays nil)
624 (unless noremove 624 (unless noremove
625 (remove-hook 'before-change-functions 625 (remove-hook 'before-change-functions
626 'org-remove-clock-overlays 'local)))) 626 'org-clock-remove-overlays 'local))))
627 627
628(defvar state) ;; dynamically scoped into this function 628(defvar state) ;; dynamically scoped into this function
629(defun org-clock-out-if-current () 629(defun org-clock-out-if-current ()
@@ -671,7 +671,7 @@ will be updated. If not, a new clocktable will be inserted.
671When called with a prefix argument, move to the first clock table in the 671When called with a prefix argument, move to the first clock table in the
672buffer and update it." 672buffer and update it."
673 (interactive "P") 673 (interactive "P")
674 (org-remove-clock-overlays) 674 (org-clock-remove-overlays)
675 (when arg 675 (when arg
676 (org-find-dblock "clocktable") 676 (org-find-dblock "clocktable")
677 (org-show-entry)) 677 (org-show-entry))
diff --git a/lisp/org/org-colview.el b/lisp/org/org-colview.el
index 28caefad800..8f7b56b431b 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.16 8;; Version: 6.19a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
@@ -594,7 +594,7 @@ an integer, select that value."
594This respects the format of the time stamp in S, active or non-active, 594This respects the format of the time stamp in S, active or non-active,
595and also including time or not. S must be just a time stamp, no text 595and also including time or not. S must be just a time stamp, no text
596around it." 596around it."
597 (when (string-match (concat "^" org-ts-regexp3 "$") s) 597 (when (and s (string-match (concat "^" org-ts-regexp3 "$") s))
598 (let* ((time (org-parse-time-string s 'nodefaults)) 598 (let* ((time (org-parse-time-string s 'nodefaults))
599 (active (equal (string-to-char s) ?<)) 599 (active (equal (string-to-char s) ?<))
600 (fmt (funcall (if (nth 1 time) 'cdr 'car) org-time-stamp-formats)) 600 (fmt (funcall (if (nth 1 time) 'cdr 'car) org-time-stamp-formats))
@@ -1067,10 +1067,12 @@ PARAMS is a property list of parameters:
1067 1067
1068:width enforce same column widths with <N> specifiers. 1068:width enforce same column widths with <N> specifiers.
1069:id the :ID: property of the entry where the columns view 1069:id the :ID: property of the entry where the columns view
1070 should be built, as a string. When `local', call locally. 1070 should be built. When the symbol `local', call locally.
1071 When `global' call column view with the cursor at the beginning 1071 When `global' call column view with the cursor at the beginning
1072 of the buffer (usually this means that the whole buffer switches 1072 of the buffer (usually this means that the whole buffer switches
1073 to column view). 1073 to column view). When \"file:path/to/file.org\", invoke column
1074 view at the start of that file. Otherwise, the ID is located
1075 using `org-id-find'.
1074:hlines When t, insert a hline before each item. When a number, insert 1076:hlines When t, insert a hline before each item. When a number, insert
1075 a hline before each level <= that number. 1077 a hline before each level <= that number.
1076:vlines When t, make each column a colgroup to enforce vertical lines. 1078:vlines When t, make each column a colgroup to enforce vertical lines.
@@ -1083,20 +1085,38 @@ PARAMS is a property list of parameters:
1083 (maxlevel (plist-get params :maxlevel)) 1085 (maxlevel (plist-get params :maxlevel))
1084 (content-lines (org-split-string (plist-get params :content) "\n")) 1086 (content-lines (org-split-string (plist-get params :content) "\n"))
1085 (skip-empty-rows (plist-get params :skip-empty-rows)) 1087 (skip-empty-rows (plist-get params :skip-empty-rows))
1086 tbl id idpos nfields tmp recalc line) 1088 tbl id idpos nfields tmp recalc line
1087 (save-excursion 1089 id-as-string view-file view-pos)
1088 (save-restriction 1090 (when (setq id (plist-get params :id))
1089 (when (setq id (plist-get params :id)) 1091 (setq id-as-string (cond ((numberp id) (number-to-string id))
1090 (cond ((not id) nil) 1092 ((symbolp id) (symbol-name id))
1091 ((eq id 'global) (goto-char (point-min))) 1093 ((stringp id) id)
1092 ((eq id 'local) nil) 1094 (t "")))
1093 ((setq idpos (org-find-entry-with-id id)) 1095 (cond ((not id) nil)
1094 (goto-char idpos)) 1096 ((eq id 'global) (setq view-pos (point-min)))
1095 (t (error "Cannot find entry with :ID: %s" id)))) 1097 ((eq id 'local))
1096 (org-columns) 1098 ((string-match "^file:\\(.*\\)" id-as-string)
1097 (setq tbl (org-columns-capture-view maxlevel skip-empty-rows)) 1099 (setq view-file (match-string 1 id-as-string)
1098 (setq nfields (length (car tbl))) 1100 view-pos 1)
1099 (org-columns-quit))) 1101 (unless (file-exists-p view-file)
1102 (error "No such file: \"%s\"" id-as-string)))
1103 ((setq idpos (org-find-entry-with-id id))
1104 (setq view-pos idpos))
1105 ((setq idpos (org-id-find id))
1106 (setq view-file (car idpos))
1107 (setq view-pos (cdr idpos)))
1108 (t (error "Cannot find entry with :ID: %s" id))))
1109 (with-current-buffer (if view-file
1110 (get-file-buffer view-file)
1111 (current-buffer))
1112 (save-excursion
1113 (save-restriction
1114 (widen)
1115 (goto-char (or view-pos (point)))
1116 (org-columns)
1117 (setq tbl (org-columns-capture-view maxlevel skip-empty-rows))
1118 (setq nfields (length (car tbl)))
1119 (org-columns-quit))))
1100 (goto-char pos) 1120 (goto-char pos)
1101 (move-marker pos nil) 1121 (move-marker pos nil)
1102 (when tbl 1122 (when tbl
@@ -1108,7 +1128,9 @@ PARAMS is a property list of parameters:
1108 (if (string-match "\\` *\\(\\*+\\)" (caar tbl)) 1128 (if (string-match "\\` *\\(\\*+\\)" (caar tbl))
1109 (if (and (not (eq (car tmp) 'hline)) 1129 (if (and (not (eq (car tmp) 'hline))
1110 (or (eq hlines t) 1130 (or (eq hlines t)
1111 (and (numberp hlines) (<= (- (match-end 1) (match-beginning 1)) hlines)))) 1131 (and (numberp hlines)
1132 (<= (- (match-end 1) (match-beginning 1))
1133 hlines))))
1112 (push 'hline tmp))) 1134 (push 'hline tmp)))
1113 (push (pop tbl) tmp))) 1135 (push (pop tbl) tmp)))
1114 (setq tbl (nreverse tmp))) 1136 (setq tbl (nreverse tmp)))
diff --git a/lisp/org/org-compat.el b/lisp/org/org-compat.el
index bd9e86bfabb..0703d72301f 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.16 8;; Version: 6.19a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
@@ -157,7 +157,9 @@ WINDOW defaults to the selected window. MAX-HEIGHT and MIN-HEIGHT are
157passed through to `fit-window-to-buffer'. If SHRINK-ONLY is set, call 157passed through to `fit-window-to-buffer'. If SHRINK-ONLY is set, call
158`shrink-window-if-larger-than-buffer' instead, the hight limit are 158`shrink-window-if-larger-than-buffer' instead, the hight limit are
159ignored in this case." 159ignored in this case."
160 (cond ((> (frame-width) (window-width window)) 160 (cond ((if (fboundp 'window-full-width-p)
161 (not (window-full-width-p window))
162 (> (frame-width) (window-width window)))
161 ;; do nothing if another window would suffer 163 ;; do nothing if another window would suffer
162 ) 164 )
163 ((and (fboundp 'fit-window-to-buffer) (not shrink-only)) 165 ((and (fboundp 'fit-window-to-buffer) (not shrink-only))
@@ -287,6 +289,15 @@ that can be added."
287 (org-no-properties (substring string (or from 0) to)) 289 (org-no-properties (substring string (or from 0) to))
288 (substring-no-properties string from to))) 290 (substring-no-properties string from to)))
289 291
292(defun org-count-lines (s)
293 "How many lines in string S?"
294 (let ((start 0) (n 1))
295 (while (string-match "\n" s start)
296 (setq start (match-end 0) n (1+ n)))
297 (if (and (> (length s) 0) (= (aref s (1- (length s))) ?\n))
298 (setq n (1- n)))
299 n))
300
290(provide 'org-compat) 301(provide 'org-compat)
291 302
292;; arch-tag: a0a0579f-e68c-4bdf-9e55-93768b846bbe 303;; arch-tag: a0a0579f-e68c-4bdf-9e55-93768b846bbe
diff --git a/lisp/org/org-exp.el b/lisp/org/org-exp.el
index 8bb77c926c8..0a888746c8c 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.16 8;; Version: 6.19a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
@@ -34,6 +34,7 @@
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)) 36(declare-function htmlize-region "ext:htmlize" (beg end))
37(declare-function org-id-find-id-file "org-id" (id))
37(defvar htmlize-buffer-places) ; from htmlize.el 38(defvar htmlize-buffer-places) ; from htmlize.el
38 39
39(defgroup org-export nil 40(defgroup org-export nil
@@ -298,6 +299,24 @@ drawer names to export."
298 "Hook for preprocessing an export buffer. 299 "Hook for preprocessing an export buffer.
299Pretty much the first thing when exporting is running this hook.") 300Pretty much the first thing when exporting is running this hook.")
300 301
302(defvar org-export-preprocess-after-include-files-hook nil
303 "Hook for preprocessing an export buffer.
304This is run after the contents of included files have been inserted.")
305
306(defvar org-export-preprocess-after-tree-selection-hook nil
307 "Hook for preprocessing an export buffer.
308This is run after selection of trees to be exported has happened.
309This selection includes tags-based selection, as well as removal
310of commented and archived trees.")
311
312(defvar org-export-preprocess-before-backend-specifics-hook nil
313 "Hook run before backend-specific functions are called during preprocessing.")
314
315(defvar org-export-preprocess-final-hook nil
316 "Hook for preprocessing an export buffer.
317This is run as the last thing in the preprocessing buffer, just before
318returning the buffer string to the backend.")
319
301(defgroup org-export-translation nil 320(defgroup org-export-translation nil
302 "Options for translating special ascii sequences for the export backends." 321 "Options for translating special ascii sequences for the export backends."
303 :tag "Org Export Translation" 322 :tag "Org Export Translation"
@@ -381,7 +400,7 @@ This option can also be set with the +OPTIONS line, e.g. \"-:nil\"."
381(defcustom org-export-with-TeX-macros t 400(defcustom org-export-with-TeX-macros t
382 "Non-nil means, interpret simple TeX-like macros when exporting. 401 "Non-nil means, interpret simple TeX-like macros when exporting.
383For example, HTML export converts \\alpha to &alpha; and \\AA to &Aring;. 402For example, HTML export converts \\alpha to &alpha; and \\AA to &Aring;.
384No only real TeX macros will work here, but the standard HTML entities 403Not only real TeX macros will work here, but the standard HTML entities
385for math can be used as macro names as well. For a list of supported 404for math can be used as macro names as well. For a list of supported
386names in HTML export, see the constant `org-html-entities'. 405names in HTML export, see the constant `org-html-entities'.
387Not all export backends support this. 406Not all export backends support this.
@@ -522,6 +541,31 @@ Org-mode file."
522 :group 'org-export-html 541 :group 'org-export-html
523 :type '(string :tag "File or URL")) 542 :type '(string :tag "File or URL"))
524 543
544(defconst org-export-html-scripts
545"<script type=\"text/javascript\">
546<!--/*--><![CDATA[/*><!--*/
547 function CodeHighlightOn(elem, id)
548 {
549 var target = document.getElementById(id);
550 if(null != target) {
551 elem.cacheClassElem = elem.className;
552 elem.cacheClassTarget = target.className;
553 target.className = \"code-highlighted\";
554 elem.className = \"code-highlighted\";
555 }
556 }
557 function CodeHighlightOff(elem, id)
558 {
559 var target = document.getElementById(id);
560 if(elem.cacheClassElem)
561 elem.className = elem.cacheClassElem;
562 if(elem.cacheClassTarget)
563 target.className = elem.cacheClassTarget;
564 }
565/*]]>*/-->
566</script>"
567"Basic javascript that is needed by HTML files produced by Org-mode.")
568
525(defconst org-export-html-style-default 569(defconst org-export-html-style-default
526"<style type=\"text/css\"> 570"<style type=\"text/css\">
527 <!--/*--><![CDATA[/*><!--*/ 571 <!--/*--><![CDATA[/*><!--*/
@@ -547,6 +591,8 @@ Org-mode file."
547 dt { font-weight: bold; } 591 dt { font-weight: bold; }
548 div.figure { padding: 0.5em; } 592 div.figure { padding: 0.5em; }
549 div.figure p { text-align: center; } 593 div.figure p { text-align: center; }
594 .linenr { font-size:smaller }
595 .code-highlighted {background-color:#ffff00;}
550 .org-info-js_info-navigation { border-style:none; } 596 .org-info-js_info-navigation { border-style:none; }
551 #org-info-js_console-label { font-size:10px; font-weight:bold; 597 #org-info-js_console-label { font-size:10px; font-weight:bold;
552 white-space:nowrap; } 598 white-space:nowrap; }
@@ -647,6 +693,12 @@ be linked only."
647 (const :tag "Always" t) 693 (const :tag "Always" t)
648 (const :tag "When there is no description" maybe))) 694 (const :tag "When there is no description" maybe)))
649 695
696(defcustom org-export-html-inline-image-extensions
697 '("png" "jpeg" "jpg" "gif")
698 "Extensions of image files that can be inlined into HTML."
699 :group 'org-export-html
700 :type '(repeat (string :tag "Extension")))
701
650;; FIXME: rename 702;; FIXME: rename
651(defcustom org-export-html-expand t 703(defcustom org-export-html-expand t
652 "Non-nil means, for HTML export, treat @<...> as HTML tag. 704 "Non-nil means, for HTML export, treat @<...> as HTML tag.
@@ -1422,6 +1474,8 @@ translations. There is currently no way for users to extend this.")
1422 1474
1423(defvar org-export-target-aliases nil 1475(defvar org-export-target-aliases nil
1424 "Alist of targets with invisible aliases.") 1476 "Alist of targets with invisible aliases.")
1477(defvar org-export-code-refs nil
1478 "Alist of code references and line numbers")
1425 1479
1426(defun org-export-preprocess-string (string &rest parameters) 1480(defun org-export-preprocess-string (string &rest parameters)
1427 "Cleanup STRING so that that the true exported has a more consistent source. 1481 "Cleanup STRING so that that the true exported has a more consistent source.
@@ -1442,13 +1496,12 @@ on this string to produce the exported version."
1442 target-alist rtn) 1496 target-alist rtn)
1443 1497
1444 (setq org-export-target-aliases nil) 1498 (setq org-export-target-aliases nil)
1499 (setq org-export-code-refs nil)
1445 1500
1446 (with-current-buffer (get-buffer-create " org-mode-tmp") 1501 (with-current-buffer (get-buffer-create " org-mode-tmp")
1447 (erase-buffer) 1502 (erase-buffer)
1448 (insert string) 1503 (insert string)
1449 (setq case-fold-search t) 1504 (setq case-fold-search t)
1450 ;; Call the hook
1451 (run-hooks 'org-export-preprocess-hook)
1452 1505
1453 ;; Remove license-to-kill stuff 1506 ;; Remove license-to-kill stuff
1454 ;; The caller marks some stuff for killing, stuff that has been 1507 ;; The caller marks some stuff for killing, stuff that has been
@@ -1457,17 +1510,36 @@ on this string to produce the exported version."
1457 1510
1458 (let ((org-inhibit-startup t)) (org-mode)) 1511 (let ((org-inhibit-startup t)) (org-mode))
1459 (setq case-fold-search t) 1512 (setq case-fold-search t)
1513
1514 ;; Call the hook
1515 (run-hooks 'org-export-preprocess-hook)
1516
1460 (untabify (point-min) (point-max)) 1517 (untabify (point-min) (point-max))
1461 1518
1462 ;; Handle include files 1519 ;; Handle include files, and call a hook
1463 (org-export-handle-include-files) 1520 (org-export-handle-include-files)
1521 (run-hooks 'org-export-preprocess-after-include-files-hook)
1464 1522
1465 ;; Get rid of excluded trees 1523 ;; Get rid of archived trees
1524 (org-export-remove-archived-trees archived-trees)
1525
1526 ;; Remove comment environment and comment subtrees
1527 (org-export-remove-comment-blocks-and-subtrees)
1528
1529 ;; Get rid of excluded trees, and call a hook
1466 (org-export-handle-export-tags (plist-get parameters :select-tags) 1530 (org-export-handle-export-tags (plist-get parameters :select-tags)
1467 (plist-get parameters :exclude-tags)) 1531 (plist-get parameters :exclude-tags))
1532 (run-hooks 'org-export-preprocess-after-tree-selection-hook)
1468 1533
1469 ;; Handle source code snippets 1534 ;; Handle source code snippets
1470 (org-export-replace-src-segments) 1535 (org-export-replace-src-segments-and-examples backend)
1536
1537 ;; Protect short examples marked by a leading colon
1538 (org-export-protect-colon-examples)
1539
1540 ;; Normalize footnotes
1541 (when (plist-get parameters :footnotes)
1542 (org-footnote-normalize nil t))
1471 1543
1472 ;; Find all headings and compute the targets for them 1544 ;; Find all headings and compute the targets for them
1473 (setq target-alist (org-export-define-heading-targets target-alist)) 1545 (setq target-alist (org-export-define-heading-targets target-alist))
@@ -1487,9 +1559,6 @@ on this string to produce the exported version."
1487 (goto-char (point-min)) 1559 (goto-char (point-min))
1488 (insert (plist-get parameters :add-text) "\n")) 1560 (insert (plist-get parameters :add-text) "\n"))
1489 1561
1490 ;; Get rid of archived trees
1491 (org-export-remove-archived-trees archived-trees)
1492
1493 ;; Remove todo-keywords before exporting, if the user has requested so 1562 ;; Remove todo-keywords before exporting, if the user has requested so
1494 (org-export-remove-headline-metadata parameters) 1563 (org-export-remove-headline-metadata parameters)
1495 1564
@@ -1497,10 +1566,8 @@ on this string to produce the exported version."
1497 ;; but mark them as targets that should be invisible 1566 ;; but mark them as targets that should be invisible
1498 (setq target-alist (org-export-handle-invisible-targets target-alist)) 1567 (setq target-alist (org-export-handle-invisible-targets target-alist))
1499 1568
1500 ;; Protect examples 1569 ;; Select and protect backend specific stuff, throw away stuff
1501 (org-export-protect-examples (if asciip 'indent nil)) 1570 ;; that is specific for other backends
1502
1503 ;; Protect backend specific stuff, throw away the others.
1504 (org-export-select-backend-specific-text backend) 1571 (org-export-select-backend-specific-text backend)
1505 1572
1506 ;; Protect quoted subtrees 1573 ;; Protect quoted subtrees
@@ -1512,13 +1579,15 @@ on this string to produce the exported version."
1512 ;; Blockquotes and verse 1579 ;; Blockquotes and verse
1513 (org-export-mark-blockquote-and-verse) 1580 (org-export-mark-blockquote-and-verse)
1514 1581
1582 ;; Remove timestamps, if the user has requested so
1583 (org-export-remove-clock-lines)
1584 (unless (plist-get parameters :timestamps)
1585 (org-export-remove-timestamps))
1586
1515 ;; Attach captions to the correct object 1587 ;; Attach captions to the correct object
1516 (setq target-alist (org-export-attach-captions-and-attributes 1588 (setq target-alist (org-export-attach-captions-and-attributes
1517 backend target-alist)) 1589 backend target-alist))
1518 1590
1519 ;; Remove comment environment and comment subtrees
1520 (org-export-remove-comment-blocks-and-subtrees)
1521
1522 ;; Find matches for radio targets and turn them into internal links 1591 ;; Find matches for radio targets and turn them into internal links
1523 (org-export-mark-radio-links) 1592 (org-export-mark-radio-links)
1524 1593
@@ -1542,22 +1611,28 @@ on this string to produce the exported version."
1542 (when org-export-table-remove-special-lines 1611 (when org-export-table-remove-special-lines
1543 (org-export-remove-special-table-lines)) 1612 (org-export-remove-special-table-lines))
1544 1613
1545 ;; Specific LaTeX stuff 1614 ;; Another hook
1615 (run-hooks 'org-export-preprocess-before-backend-specifics-hook)
1616
1617 ;; LaTeX-specific preprocessing
1546 (when latexp 1618 (when latexp
1547 (require 'org-export-latex nil) 1619 (require 'org-export-latex nil)
1548 (org-export-latex-preprocess)) 1620 (org-export-latex-preprocess))
1549 1621
1550 ;; Specific ASCII stuff 1622 ;; ASCII-specific preprocessing
1551 (when asciip 1623 (when asciip
1552 (org-export-ascii-preprocess)) 1624 (org-export-ascii-preprocess))
1553 1625
1554 ;; Specific HTML stuff 1626 ;; HTML-specific preprocessing
1555 (when htmlp 1627 (when htmlp
1556 (org-export-html-preprocess parameters)) 1628 (org-export-html-preprocess parameters))
1557 1629
1558 ;; Remove or replace comments 1630 ;; Remove or replace comments
1559 (org-export-handle-comments (plist-get parameters :comments)) 1631 (org-export-handle-comments (plist-get parameters :comments))
1560 1632
1633 ;; Run the final hook
1634 (run-hooks 'org-export-preprocess-final-hook)
1635
1561 (setq rtn (buffer-string))) 1636 (setq rtn (buffer-string)))
1562 (kill-buffer " org-mode-tmp") 1637 (kill-buffer " org-mode-tmp")
1563 rtn)) 1638 rtn))
@@ -1578,16 +1653,24 @@ The new targets are added to TARGET-ALIST, which is also returned."
1578 (org-init-section-numbers) 1653 (org-init-section-numbers)
1579 (let ((re (concat "^" org-outline-regexp 1654 (let ((re (concat "^" org-outline-regexp
1580 "\\| [ \t]*:ID:[ \t]*\\([^ \t\r\n]+\\)")) 1655 "\\| [ \t]*:ID:[ \t]*\\([^ \t\r\n]+\\)"))
1581 level target) 1656 level target last-section-target a)
1582 (while (re-search-forward re nil t) 1657 (while (re-search-forward re nil t)
1583 (if (match-end 1) 1658 (if (match-end 1)
1584 (push (cons (org-match-string-no-properties 1) 1659 (progn
1585 target) target-alist) 1660 (push (cons (org-match-string-no-properties 1)
1661 target) target-alist)
1662 (setq a (or (assoc last-section-target org-export-target-aliases)
1663 (progn
1664 (push (list last-section-target)
1665 org-export-target-aliases)
1666 (car org-export-target-aliases))))
1667 (push (caar target-alist) (cdr a)))
1586 (setq level (org-reduced-level 1668 (setq level (org-reduced-level
1587 (save-excursion (goto-char (point-at-bol)) 1669 (save-excursion (goto-char (point-at-bol))
1588 (org-outline-level)))) 1670 (org-outline-level))))
1589 (setq target (org-solidify-link-text 1671 (setq target (org-solidify-link-text
1590 (format "sec-%s" (org-section-number level)))) 1672 (format "sec-%s" (org-section-number level))))
1673 (setq last-section-target target)
1591 (push (cons target target) target-alist) 1674 (push (cons target target) target-alist)
1592 (add-text-properties 1675 (add-text-properties
1593 (point-at-bol) (point-at-eol) 1676 (point-at-bol) (point-at-eol)
@@ -1632,12 +1715,15 @@ the current file."
1632 (desc (match-end 2)) 1715 (desc (match-end 2))
1633 (link (org-link-unescape (match-string 1))) 1716 (link (org-link-unescape (match-string 1)))
1634 (slink (org-solidify-link-text link)) 1717 (slink (org-solidify-link-text link))
1635 found props pos 1718 found props pos cref
1636 (target 1719 (target
1637 (cond 1720 (cond
1638 ((cdr (assoc slink target-alist))) 1721 ((cdr (assoc slink target-alist)))
1639 ((and (string-match "^id:" link) 1722 ((and (string-match "^id:" link)
1640 (cdr (assoc (substring link 3) target-alist)))) 1723 (cdr (assoc (substring link 3) target-alist))))
1724 ((string-match "^(\\(.*\\))$" link)
1725 (setq cref (match-string 1 link))
1726 (concat "coderef:" cref))
1641 ((string-match org-link-types-re link) nil) 1727 ((string-match org-link-types-re link) nil)
1642 ((or (file-name-absolute-p link) 1728 ((or (file-name-absolute-p link)
1643 (string-match "^\\." link)) 1729 (string-match "^\\." link))
@@ -1767,9 +1853,27 @@ from the buffer."
1767 (when (or (not todo) (not tags) (not pri)) 1853 (when (or (not todo) (not tags) (not pri))
1768 (goto-char (point-min)) 1854 (goto-char (point-min))
1769 (while (re-search-forward re nil t) 1855 (while (re-search-forward re nil t)
1770 (setq rpl (mapconcat (lambda (i) (if (match-end i) (match-string i) "")) 1856 (org-if-unprotected
1771 elts " ")) 1857 (setq rpl (mapconcat (lambda (i) (if (match-end i) (match-string i) ""))
1772 (replace-match rpl t t))))) 1858 elts " "))
1859 (replace-match rpl t t))))))
1860
1861(defun org-export-remove-timestamps ()
1862 "Remove timestamps and keywords for export."
1863 (while (re-search-forward org-maybe-keyword-time-regexp nil t)
1864 (backward-char 1)
1865 (org-if-unprotected
1866 (replace-match "")
1867 (beginning-of-line 1)
1868 (if (looking-at "[- \t]*\\(=>[- \t0-9:]*\\)?[ \t]*\n")
1869 (replace-match "")))))
1870
1871(defun org-export-remove-clock-lines ()
1872 "Remove timestamps and keywords for export."
1873 (let ((re (concat "^[ \t]*" org-clock-string ".*\n?")))
1874 (while (re-search-forward re nil t)
1875 (org-if-unprotected
1876 (replace-match "")))))
1773 1877
1774(defun org-export-protect-quoted-subtrees () 1878(defun org-export-protect-quoted-subtrees ()
1775 "Mark quoted subtrees with the protection property." 1879 "Mark quoted subtrees with the protection property."
@@ -1789,24 +1893,25 @@ from the buffer."
1789 '(org-protected t)) 1893 '(org-protected t))
1790 (goto-char (1+ (match-end 4))))) 1894 (goto-char (1+ (match-end 4)))))
1791 1895
1792(defun org-export-protect-examples (&optional indent) 1896(defun org-export-protect-colon-examples ()
1793 "Protect code that should be exported as monospaced examples." 1897 "Protect lines starting with a colon."
1794 (goto-char (point-min))
1795 (while (re-search-forward "^#\\+BEGIN_EXAMPLE[ \t]*\n" nil t)
1796 (goto-char (match-end 0))
1797 (while (and (not (looking-at "#\\+END_EXAMPLE")) (not (eobp)))
1798 (insert (if indent ": " ":"))
1799 (beginning-of-line 2)))
1800 (goto-char (point-min)) 1898 (goto-char (point-min))
1801 (while (re-search-forward "^[ \t]*:.*\\(\n[ \t]*:.*\\)*" nil t) 1899 (let ((re "^[ \t]*:\\([ \t]\\|$\\)") beg end)
1802 (add-text-properties (match-beginning 0) (match-end 0) 1900 (while (re-search-forward re nil t)
1803 '(org-protected t)))) 1901 (beginning-of-line 1)
1902 (setq beg (point))
1903 (while (looking-at re)
1904 (end-of-line 1)
1905 (or (eobp) (forward-char 1)))
1906 (add-text-properties beg (if (bolp) (1- (point)) (point))
1907 '(org-protected t)))))
1804 1908
1805(defun org-export-select-backend-specific-text (backend) 1909(defun org-export-select-backend-specific-text (backend)
1806 (let ((formatters 1910 (let ((formatters
1807 '((html "HTML" "BEGIN_HTML" "END_HTML") 1911 '((html "HTML" "BEGIN_HTML" "END_HTML")
1808 (ascii "ASCII" "BEGIN_ASCII" "END_ASCII") 1912 (ascii "ASCII" "BEGIN_ASCII" "END_ASCII")
1809 (latex "LaTeX" "BEGIN_LaTeX" "END_LaTeX"))) 1913 (latex "LaTeX" "BEGIN_LaTeX" "END_LaTeX")))
1914 (case-fold-search t)
1810 fmt) 1915 fmt)
1811 1916
1812 (while formatters 1917 (while formatters
@@ -1969,10 +2074,15 @@ When it is nil, all comments will be removed."
1969 (org-translate-link 2074 (org-translate-link
1970 (org-link-expand-abbrev (match-string 1))))) 2075 (org-link-expand-abbrev (match-string 1)))))
1971 (s (concat 2076 (s (concat
1972 "[[" xx "]" 2077 "[[" (org-add-props (copy-sequence xx)
2078 nil 'org-protected t)
2079 "]"
1973 (if (match-end 3) 2080 (if (match-end 3)
1974 (match-string 2) 2081 (match-string 2)
1975 (concat "[" xx "]")) 2082 (concat "[" (org-add-props
2083 (copy-sequence xx)
2084 '(org-protected t))
2085 "]"))
1976 "]"))) 2086 "]")))
1977 (put-text-property 0 (length s) 'face 'org-link s) 2087 (put-text-property 0 (length s) 'face 'org-link s)
1978 (replace-match s t t)))))) 2088 (replace-match s t t))))))
@@ -1993,8 +2103,10 @@ This is to make sure that the line-processing export backends
1993can work correctly." 2103can work correctly."
1994 (goto-char (point-min)) 2104 (goto-char (point-min))
1995 (while (re-search-forward org-emph-re nil t) 2105 (while (re-search-forward org-emph-re nil t)
1996 (if (not (= (char-after (match-beginning 3)) 2106 (if (and (not (= (char-after (match-beginning 3))
1997 (char-after (match-beginning 4)))) 2107 (char-after (match-beginning 4))))
2108 (save-excursion (goto-char (match-beginning 0))
2109 (save-match-data (not (org-at-table-p)))))
1998 (org-if-unprotected 2110 (org-if-unprotected
1999 (subst-char-in-region (match-beginning 0) (match-end 0) 2111 (subst-char-in-region (match-beginning 0) (match-end 0)
2000 ?\n ?\ t) 2112 ?\n ?\ t)
@@ -2149,7 +2261,7 @@ TYPE must be a string, any of:
2149(defun org-export-handle-include-files () 2261(defun org-export-handle-include-files ()
2150 "Include the contents of include files, with proper formatting." 2262 "Include the contents of include files, with proper formatting."
2151 (let ((case-fold-search t) 2263 (let ((case-fold-search t)
2152 params file markup lang start end prefix prefix1) 2264 params file markup lang start end prefix prefix1 switches)
2153 (goto-char (point-min)) 2265 (goto-char (point-min))
2154 (while (re-search-forward "^#\\+INCLUDE:?[ \t]+\\(.*\\)" nil t) 2266 (while (re-search-forward "^#\\+INCLUDE:?[ \t]+\\(.*\\)" nil t)
2155 (setq params (read (concat "(" (match-string 1) ")")) 2267 (setq params (read (concat "(" (match-string 1) ")"))
@@ -2157,7 +2269,9 @@ TYPE must be a string, any of:
2157 prefix1 (org-get-and-remove-property 'params :prefix1) 2269 prefix1 (org-get-and-remove-property 'params :prefix1)
2158 file (org-symname-or-string (pop params)) 2270 file (org-symname-or-string (pop params))
2159 markup (org-symname-or-string (pop params)) 2271 markup (org-symname-or-string (pop params))
2160 lang (org-symname-or-string (pop params))) 2272 lang (and (member markup '("src" "SRC"))
2273 (org-symname-or-string (pop params)))
2274 switches (mapconcat '(lambda (x) (format "%s" x)) params " "))
2161 (delete-region (match-beginning 0) (match-end 0)) 2275 (delete-region (match-beginning 0) (match-end 0))
2162 (if (or (not file) 2276 (if (or (not file)
2163 (not (file-exists-p file)) 2277 (not (file-exists-p file))
@@ -2165,9 +2279,11 @@ TYPE must be a string, any of:
2165 (insert (format "CANNOT INCLUDE FILE %s" file)) 2279 (insert (format "CANNOT INCLUDE FILE %s" file))
2166 (when markup 2280 (when markup
2167 (if (equal (downcase markup) "src") 2281 (if (equal (downcase markup) "src")
2168 (setq start (format "#+begin_src %s\n" (or lang "fundamental")) 2282 (setq start (format "#+begin_src %s %s\n"
2283 (or lang "fundamental")
2284 (or switches ""))
2169 end "#+end_src") 2285 end "#+end_src")
2170 (setq start (format "#+begin_%s\n" markup) 2286 (setq start (format "#+begin_%s %s\n" markup switches)
2171 end (format "#+end_%s" markup)))) 2287 end (format "#+end_%s" markup))))
2172 (insert (or start "")) 2288 (insert (or start ""))
2173 (insert (org-get-file-contents (expand-file-name file) prefix prefix1)) 2289 (insert (org-get-file-contents (expand-file-name file) prefix prefix1))
@@ -2207,70 +2323,207 @@ in the list) and remove property and value from the list in LISTVAR."
2207 (if s (symbol-name s) s) 2323 (if s (symbol-name s) s)
2208 s)) 2324 s))
2209 2325
2210;;; Fontification of code 2326;;; Fontification and line numbers for code examples
2211;; Currently only for the HTML backend, but who knows.... 2327
2212(defun org-export-replace-src-segments () 2328(defvar org-export-last-code-line-counter-value 0)
2329
2330(defun org-export-replace-src-segments-and-examples (backend)
2213 "Replace source code segments with special code for export." 2331 "Replace source code segments with special code for export."
2332 (setq org-export-last-code-line-counter-value 0)
2214 (let ((case-fold-search t) 2333 (let ((case-fold-search t)
2215 lang code trans) 2334 lang code trans opts)
2216 (goto-char (point-min)) 2335 (goto-char (point-min))
2217 (while (re-search-forward 2336 (while (re-search-forward
2218 "^#\\+BEGIN_SRC:?[ \t]+\\([^ \t\n]+\\)[ \t]*\n\\([^\000]+?\n\\)#\\+END_SRC.*" 2337 "\\(^#\\+BEGIN_SRC:?[ \t]+\\([^ \t\n]+\\)\\(.*\\)\n\\([^\000]+?\n\\)#\\+END_SRC.*\\)\\|\\(^#\\+BEGIN_EXAMPLE:?\\(?:[ \t]+\\(.*\\)\\)?\n\\([^\000]+?\n\\)#\\+END_EXAMPLE.*\\)"
2219 nil t) 2338 nil t)
2220 (setq lang (match-string 1) code (match-string 2) 2339 (if (match-end 1)
2221 trans (org-export-format-source-code lang code)) 2340 ;; src segments
2341 (setq lang (match-string 2)
2342 opts (match-string 3)
2343 code (match-string 4))
2344 (setq lang nil
2345 opts (match-string 6)
2346 code (match-string 7)))
2347
2348 (setq trans (org-export-format-source-code-or-example
2349 backend lang code opts))
2222 (replace-match trans t t)))) 2350 (replace-match trans t t))))
2223 2351
2224(defvar htmlp) ;; dynamically scoped from org-exp.el 2352(defvar htmlp) ;; dynamically scoped
2353(defvar latexp) ;; dynamically scoped
2225 2354
2226(defun org-export-format-source-code (lang code) 2355(defun org-export-format-source-code-or-example (backend
2356 lang code &optional opts)
2227 "Format CODE from language LANG and return it formatted for export. 2357 "Format CODE from language LANG and return it formatted for export.
2228Currently, this only does something for HTML export, for all other 2358If LANG is nil, do not add any fontification.
2229backends, it converts the segment into an EXAMPLE segment." 2359OPTS contains formatting optons, like `-n' for triggering numbering lines,
2360and `+n' for continuing previous numering.
2361Code formatting according to language currently only works for HTML.
2362Numbering lines works for all three major backends (html, latex, and ascii)."
2230 (save-match-data 2363 (save-match-data
2231 (cond 2364 (let (num cont rtn named rpllbl keepp textareap cols rows fmt)
2232 (htmlp 2365 (setq opts (or opts "")
2233 ;; We are exporting to HTML 2366 num (string-match "[-+]n\\>" opts)
2234 (require 'htmlize nil t) 2367 cont (string-match "\\+n\\>" opts)
2235 (if (not (fboundp 'htmlize-region-for-paste)) 2368 rpllbl (string-match "-r\\>" opts)
2236 (progn 2369 keepp (string-match "-k\\>" opts)
2370 textareap (string-match "-t\\>" opts)
2371 cols (if (string-match "-w[ \t]+\\([0-9]+\\)" opts)
2372 (string-to-number (match-string 1 opts))
2373 80)
2374 rows (if (string-match "-h[ \t]+\\([0-9]+\\)" opts)
2375 (string-to-number (match-string 1 opts))
2376 (org-count-lines code))
2377 fmt (if (string-match "-l[ \t]+\"\\([^\"\n]+\\)\"" opts)
2378 (match-string 1 opts)))
2379 (when (and textareap (eq backend 'html))
2380 ;; we cannot use numbering or highlighting.
2381 (setq num nil cont nil lang nil))
2382 (if keepp (setq rpllbl 'keep))
2383 (setq rtn code)
2384 (when (equal lang "org")
2385 (setq rtn (with-temp-buffer
2386 (insert rtn)
2387 ;; Free up the protected lines
2388 (goto-char (point-min))
2389 (while (re-search-forward "^," nil t)
2390 (replace-match "")
2391 (end-of-line 1))
2392 (buffer-string))))
2393 ;; Now backend-specific coding
2394 (cond
2395 ((eq backend 'html)
2396 ;; We are exporting to HTML
2397 (when lang
2398 (require 'htmlize nil t)
2399 (when (not (fboundp 'htmlize-region-for-paste))
2237 ;; we do not have htmlize.el, or an old version of it 2400 ;; we do not have htmlize.el, or an old version of it
2401 (setq lang nil)
2238 (message 2402 (message
2239 "htmlize.el 1.34 or later is needed for source code formatting") 2403 "htmlize.el 1.34 or later is needed for source code formatting")))
2240 (concat "#+BEGIN_EXAMPLE\n" code 2404
2241 (if (string-match "\n\\'" code) "" "\n") 2405 (if lang
2242 "#+END_EXAMPLE\n")) 2406 (let* ((mode (and lang (intern (concat lang "-mode"))))
2243 ;; ok, we are good to go 2407 (org-inhibit-startup t)
2244 (let* ((mode (and lang (intern (concat lang "-mode")))) 2408 (org-startup-folded nil))
2245 (org-inhibit-startup t) 2409 (setq rtn
2246 (org-startup-folded nil) 2410 (with-temp-buffer
2247 (htmltext 2411 (insert rtn)
2248 (with-temp-buffer 2412 (if (functionp mode)
2249 (insert code) 2413 (funcall mode)
2250 ;; Free up the protected stuff 2414 (fundamental-mode))
2251 (goto-char (point-min)) 2415 (font-lock-fontify-buffer)
2252 (while (re-search-forward "^," nil t) 2416 (org-export-htmlize-region-for-paste
2253 (replace-match "") 2417 (point-min) (point-max))))
2254 (end-of-line 1)) 2418 (if (string-match "<pre\\([^>]*\\)>\n?" rtn)
2255 (if (functionp mode) 2419 (setq rtn (replace-match
2256 (funcall mode) 2420 (format "<pre class=\"src src-%s\">\n" lang)
2257 (fundamental-mode)) 2421 t t rtn))))
2258 (font-lock-fontify-buffer) 2422 (if textareap
2259 (org-export-htmlize-region-for-paste 2423 (setq rtn (concat
2260 (point-min) (point-max))))) 2424 (format "<p>\n<textarea cols=\"%d\" rows=\"%d\" overflow-x:scroll >\n"
2261 (if (string-match "<pre\\([^>]*\\)>\n?" htmltext) 2425 cols rows)
2262 (setq htmltext (replace-match 2426 rtn "</textarea>\n</p>\n"))
2263 (format "<pre class=\"src src-%s\">\n" lang) 2427 (with-temp-buffer
2264 t t htmltext))) 2428 (insert rtn)
2265 (concat "\n#+BEGIN_HTML\n" htmltext "\n#+END_HTML\n\n")))) 2429 (goto-char (point-min))
2266 (t 2430 (while (re-search-forward "[<>&]" nil t)
2267 ;; This is not HTML, so just make it an example. 2431 (replace-match (cdr (assq (char-before)
2268 (when (equal lang "org") 2432 '((?&."&amp;")(?<."&lt;")(?>."&gt;"))))
2269 (while (string-match "^," code) 2433 t t))
2270 (setq code (replace-match "" t t code)))) 2434 (setq rtn (buffer-string)))
2271 (concat "#+BEGIN_EXAMPLE\n" code 2435 (setq rtn (concat "<pre class=\"example\">\n" rtn "</pre>\n"))))
2272 (if (string-match "\n\\'" code) "" "\n") 2436 (unless textareap
2273 "#+END_EXAMPLE\n"))))) 2437 (setq rtn (org-export-number-lines rtn 'html 1 1 num
2438 cont rpllbl fmt)))
2439 (concat "\n#+BEGIN_HTML\n" (org-add-props rtn '(org-protected t)) "\n#+END_HTML\n\n"))
2440 ((eq backend 'latex)
2441 (setq rtn (org-export-number-lines rtn 'latex 0 0 num cont rpllbl fmt))
2442 (concat "\n#+BEGIN_LaTeX\n"
2443 (org-add-props (concat "\\begin{verbatim}\n" rtn "\n\\end{verbatim}\n")
2444 '(org-protected t))
2445 "#+END_LaTeX\n\n"))
2446 ((eq backend 'ascii)
2447 ;; This is not HTML or LaTeX, so just make it an example.
2448 (setq rtn (org-export-number-lines rtn 'ascii 0 0 num cont rpllbl fmt))
2449 (concat "#+BEGIN_ASCII\n"
2450 (org-add-props
2451 (concat
2452 (mapconcat
2453 (lambda (l) (concat " " l))
2454 (org-split-string rtn "\n")
2455 "\n")
2456 "\n")
2457 '(org-protected t))
2458 "#+END_ASCII\n"))))))
2459
2460(defun org-export-number-lines (text backend
2461 &optional skip1 skip2 number cont
2462 replace-labels label-format)
2463 (if (and (not number) (not (eq replace-labels 'keep)))
2464 (setq replace-labels nil)) ;; must use names if no numbers
2465 (setq skip1 (or skip1 0) skip2 (or skip2 0))
2466 (if (not cont) (setq org-export-last-code-line-counter-value 0))
2467 (with-temp-buffer
2468 (insert text)
2469 (goto-char (point-max))
2470 (skip-chars-backward " \t\n\r")
2471 (delete-region (point) (point-max))
2472 (beginning-of-line (- 1 skip2))
2473 (let* ((last (org-current-line))
2474 (n org-export-last-code-line-counter-value)
2475 (nmax (+ n (- last skip1)))
2476 (fmt (format "%%%dd: " (length (number-to-string nmax))))
2477 (fm
2478 (cond
2479 ((eq backend 'html) (format "<span class=\"linenr\">%s</span>"
2480 fmt))
2481 ((eq backend 'ascii) fmt)
2482 ((eq backend 'latex) fmt)
2483 (t "")))
2484 (label-format (or label-format org-coderef-label-format))
2485 (label-pre (if (string-match "%s" label-format)
2486 (substring label-format 0 (match-beginning 0))
2487 label-format))
2488 (label-post (if (string-match "%s" label-format)
2489 (substring label-format (match-end 0))
2490 ""))
2491 (lbl-re
2492 (concat
2493 ".*?\\S-.*?\\([ \t]*\\("
2494 (regexp-quote label-pre)
2495 "\\([-a-zA-Z0-9_]+\\)"
2496 (regexp-quote label-post)
2497 "\\)\\)"))
2498 ref)
2499
2500 (goto-line (1+ skip1))
2501 (while (and (re-search-forward "^" nil t) (not (eobp)) (< n nmax))
2502 (if number
2503 (insert (format fm (incf n)))
2504 (forward-char 1))
2505 (when (and (not (eq replace-labels 'keep))
2506 (looking-at lbl-re))
2507 (setq ref (match-string 3))
2508 (if replace-labels
2509 (progn
2510 (delete-region (match-beginning 1) (match-end 1))
2511 (push (cons ref n) org-export-code-refs))
2512 (goto-char (match-beginning 2))
2513 (delete-region (match-beginning 2) (match-end 2))
2514 (insert "(" ref ")")
2515 (push (cons ref (concat "(" ref ")")) org-export-code-refs))
2516 (when (eq backend 'html)
2517 (save-excursion
2518 (beginning-of-line 1)
2519 (insert (format "<span id=\"coderef-%s\" class=\"coderef-off\">"
2520 ref))
2521 (end-of-line 1)
2522 (insert "</span>")))))
2523 (setq org-export-last-code-line-counter-value n)
2524 (goto-char (point-max))
2525 (newline)
2526 (buffer-string))))
2274 2527
2275;;; ASCII export 2528;;; ASCII export
2276 2529
@@ -2351,6 +2604,8 @@ underlined headlines. The default is 3."
2351 :drawers (plist-get opt-plist :drawers) 2604 :drawers (plist-get opt-plist :drawers)
2352 :tags (plist-get opt-plist :tags) 2605 :tags (plist-get opt-plist :tags)
2353 :priority (plist-get opt-plist :priority) 2606 :priority (plist-get opt-plist :priority)
2607 :footnotes (plist-get opt-plist :footnotes)
2608 :timestamps (plist-get opt-plist :timestamps)
2354 :todo-keywords (plist-get opt-plist :todo-keywords) 2609 :todo-keywords (plist-get opt-plist :todo-keywords)
2355 :verbatim-multiline t 2610 :verbatim-multiline t
2356 :select-tags (plist-get opt-plist :select-tags) 2611 :select-tags (plist-get opt-plist :select-tags)
@@ -2360,7 +2615,7 @@ underlined headlines. The default is 3."
2360 :add-text (plist-get opt-plist :text)) 2615 :add-text (plist-get opt-plist :text))
2361 "\n")) 2616 "\n"))
2362 thetoc have-headings first-heading-pos 2617 thetoc have-headings first-heading-pos
2363 table-open table-buffer) 2618 table-open table-buffer link desc)
2364 2619
2365 (let ((inhibit-read-only t)) 2620 (let ((inhibit-read-only t))
2366 (org-unmodified 2621 (org-unmodified
@@ -2473,9 +2728,19 @@ underlined headlines. The default is 3."
2473 (setq line (org-html-expand-for-ascii line)) 2728 (setq line (org-html-expand-for-ascii line))
2474 ;; Replace links with the description when possible 2729 ;; Replace links with the description when possible
2475 (while (string-match org-bracket-link-regexp line) 2730 (while (string-match org-bracket-link-regexp line)
2476 (setq line (replace-match 2731 (setq link (match-string 1 line)
2477 (if (match-end 3) "[\\3]" "[\\1]") 2732 desc (match-string (if (match-end 3) 3 1) line))
2478 t nil line))) 2733 (if (and (> (length link) 8)
2734 (equal (substring link 0 8) "coderef:"))
2735 (setq line (replace-match
2736 (format (org-export-get-coderef-format (substring link 8) desc)
2737 (cdr (assoc
2738 (substring link 8)
2739 org-export-code-refs)))
2740 t t line))
2741 (setq line (replace-match
2742 (if (match-end 3) "[\\3]" "[\\1]")
2743 t nil line))))
2479 (when custom-times 2744 (when custom-times
2480 (setq line (org-translate-time line))) 2745 (setq line (org-translate-time line)))
2481 (cond 2746 (cond
@@ -2719,7 +2984,8 @@ Does include HTML export options as well as TODO and CATEGORY stuff."
2719#+EMAIL: %s 2984#+EMAIL: %s
2720#+DATE: %s 2985#+DATE: %s
2721#+LANGUAGE: %s 2986#+LANGUAGE: %s
2722#+OPTIONS: H:%d num:%s toc:%s \\n:%s @:%s ::%s |:%s ^:%s -:%s f:%s *:%s TeX:%s LaTeX:%s skip:%s d:%s todo:%s pri:%s tags:%s 2987#+OPTIONS: H:%d num:%s toc:%s \\n:%s @:%s ::%s |:%s ^:%s -:%s f:%s *:%s <:%s
2988#+OPTIONS: TeX:%s LaTeX:%s skip:%s d:%s todo:%s pri:%s tags:%s
2723%s 2989%s
2724#+EXPORT_SELECT_TAGS: %s 2990#+EXPORT_SELECT_TAGS: %s
2725#+EXPORT_EXCLUDE_TAGS: %s 2991#+EXPORT_EXCLUDE_TAGS: %s
@@ -2750,6 +3016,7 @@ Does include HTML export options as well as TODO and CATEGORY stuff."
2750 org-export-with-special-strings 3016 org-export-with-special-strings
2751 org-export-with-footnotes 3017 org-export-with-footnotes
2752 org-export-with-emphasize 3018 org-export-with-emphasize
3019 org-export-with-timestamps
2753 org-export-with-TeX-macros 3020 org-export-with-TeX-macros
2754 org-export-with-LaTeX-fragments 3021 org-export-with-LaTeX-fragments
2755 org-export-skip-text-before-1st-heading 3022 org-export-skip-text-before-1st-heading
@@ -2933,7 +3200,8 @@ PUB-DIR is set, use this as the publishing directory."
2933 (style (concat (if (plist-get opt-plist :style-include-default) 3200 (style (concat (if (plist-get opt-plist :style-include-default)
2934 org-export-html-style-default) 3201 org-export-html-style-default)
2935 (plist-get opt-plist :style) 3202 (plist-get opt-plist :style)
2936 (plist-get opt-plist :style-extra))) 3203 (plist-get opt-plist :style-extra)
3204 "\n" org-export-html-scripts))
2937 (html-extension (plist-get opt-plist :html-extension)) 3205 (html-extension (plist-get opt-plist :html-extension))
2938 (link-validate (plist-get opt-plist :link-validation-function)) 3206 (link-validate (plist-get opt-plist :link-validation-function))
2939 valid thetoc have-headings first-heading-pos 3207 valid thetoc have-headings first-heading-pos
@@ -3032,6 +3300,8 @@ PUB-DIR is set, use this as the publishing directory."
3032 :todo-keywords (plist-get opt-plist :todo-keywords) 3300 :todo-keywords (plist-get opt-plist :todo-keywords)
3033 :tags (plist-get opt-plist :tags) 3301 :tags (plist-get opt-plist :tags)
3034 :priority (plist-get opt-plist :priority) 3302 :priority (plist-get opt-plist :priority)
3303 :footnotes (plist-get opt-plist :footnotes)
3304 :timestamps (plist-get opt-plist :timestamps)
3035 :archived-trees 3305 :archived-trees
3036 (plist-get opt-plist :archived-trees) 3306 (plist-get opt-plist :archived-trees)
3037 :select-tags (plist-get opt-plist :select-tags) 3307 :select-tags (plist-get opt-plist :select-tags)
@@ -3046,7 +3316,8 @@ PUB-DIR is set, use this as the publishing directory."
3046 ind item-type starter didclose 3316 ind item-type starter didclose
3047 rpl path attr desc descp desc1 desc2 link 3317 rpl path attr desc descp desc1 desc2 link
3048 snumber fnc item-tag 3318 snumber fnc item-tag
3049 footnotes 3319 footnotes footref-seen
3320 id-file
3050 ) 3321 )
3051 3322
3052 (let ((inhibit-read-only t)) 3323 (let ((inhibit-read-only t))
@@ -3214,12 +3485,12 @@ lang=\"%s\" xml:lang=\"%s\">
3214 3485
3215 ;; Fixed-width, verbatim lines (examples) 3486 ;; Fixed-width, verbatim lines (examples)
3216 (when (and org-export-with-fixed-width 3487 (when (and org-export-with-fixed-width
3217 (string-match "^[ \t]*:\\(.*\\)" line)) 3488 (string-match "^[ \t]*:\\(\\([ \t]\\|$\\)\\(.*\\)\\)" line))
3218 (when (not infixed) 3489 (when (not infixed)
3219 (setq infixed t) 3490 (setq infixed t)
3220 (org-close-par-maybe) 3491 (org-close-par-maybe)
3221 (insert "<pre class=\"example\">\n")) 3492 (insert "<pre class=\"example\">\n"))
3222 (insert (org-html-protect (match-string 1 line)) "\n") 3493 (insert (org-html-protect (match-string 3 line)) "\n")
3223 (when (or (not lines) 3494 (when (or (not lines)
3224 (not (string-match "^[ \t]*\\(:.*\\)" 3495 (not (string-match "^[ \t]*\\(:.*\\)"
3225 (car lines)))) 3496 (car lines))))
@@ -3236,7 +3507,6 @@ lang=\"%s\" xml:lang=\"%s\">
3236 (replace-match "\\2\n")) 3507 (replace-match "\\2\n"))
3237 (insert line "\n") 3508 (insert line "\n")
3238 (while (and lines 3509 (while (and lines
3239 (not (string-match "^[ \t]*:" (car lines)))
3240 (or (= (length (car lines)) 0) 3510 (or (= (length (car lines)) 0)
3241 (get-text-property 0 'org-protected (car lines)))) 3511 (get-text-property 0 'org-protected (car lines))))
3242 (insert (pop lines) "\n")) 3512 (insert (pop lines) "\n"))
@@ -3308,7 +3578,7 @@ lang=\"%s\" xml:lang=\"%s\">
3308 3578
3309 ;; Format the links 3579 ;; Format the links
3310 (setq start 0) 3580 (setq start 0)
3311 (while (string-match org-bracket-link-analytic-regexp line start) 3581 (while (string-match org-bracket-link-analytic-regexp++ line start)
3312 (setq start (match-beginning 0)) 3582 (setq start (match-beginning 0))
3313 (setq path (save-match-data (org-link-unescape 3583 (setq path (save-match-data (org-link-unescape
3314 (match-string 3 line)))) 3584 (match-string 3 line))))
@@ -3326,7 +3596,8 @@ lang=\"%s\" xml:lang=\"%s\">
3326 descp (and desc1 (not (equal desc1 desc2))) 3596 descp (and desc1 (not (equal desc1 desc2)))
3327 desc (or desc1 desc2)) 3597 desc (or desc1 desc2))
3328 ;; Make an image out of the description if that is so wanted 3598 ;; Make an image out of the description if that is so wanted
3329 (when (and descp (org-file-image-p desc)) 3599 (when (and descp (org-file-image-p
3600 desc org-export-html-inline-image-extensions))
3330 (save-match-data 3601 (save-match-data
3331 (if (string-match "^file:" desc) 3602 (if (string-match "^file:" desc)
3332 (setq desc (substring desc (match-end 0))))) 3603 (setq desc (substring desc (match-end 0)))))
@@ -3344,11 +3615,24 @@ lang=\"%s\" xml:lang=\"%s\">
3344 "\"" attr ">" 3615 "\"" attr ">"
3345 (org-export-html-format-desc desc) 3616 (org-export-html-format-desc desc)
3346 "</a>"))) 3617 "</a>")))
3618 ((and (equal type "id")
3619 (setq id-file (org-id-find-id-file path)))
3620 ;; This is an id: link to another file (if it was the same file,
3621 ;; it would have become an internal link...)
3622 (setq id-file (file-relative-name
3623 id-file (file-name-directory org-current-export-file)))
3624 (setq id-file (concat (file-name-sans-extension id-file)
3625 "." html-extension))
3626 (setq rpl (concat "<a href=\"" id-file "#" path "\""
3627 attr ">"
3628 (org-export-html-format-desc desc)
3629 "</a>")))
3347 ((member type '("http" "https")) 3630 ((member type '("http" "https"))
3348 ;; standard URL, just check if we need to inline an image 3631 ;; standard URL, just check if we need to inline an image
3349 (if (and (or (eq t org-export-html-inline-images) 3632 (if (and (or (eq t org-export-html-inline-images)
3350 (and org-export-html-inline-images (not descp))) 3633 (and org-export-html-inline-images (not descp)))
3351 (org-file-image-p path)) 3634 (org-file-image-p
3635 path org-export-html-inline-image-extensions))
3352 (setq rpl (org-export-html-format-image 3636 (setq rpl (org-export-html-format-image
3353 (concat type ":" path))) 3637 (concat type ":" path)))
3354 (setq link (concat type ":" path)) 3638 (setq link (concat type ":" path))
@@ -3366,6 +3650,13 @@ lang=\"%s\" xml:lang=\"%s\">
3366 (org-export-html-format-desc desc) 3650 (org-export-html-format-desc desc)
3367 "</a>"))) 3651 "</a>")))
3368 3652
3653 ((string= type "coderef")
3654
3655 (setq rpl (format "<a href=\"#coderef-%s\" class=\"coderef\" onmouseover=\"CodeHighlightOn(this, 'coderef-%s');\" onmouseout=\"CodeHighlightOff(this, 'coderef-%s');\">%s</a>"
3656 path path path
3657 (format (org-export-get-coderef-format path (and descp desc))
3658 (cdr (assoc path org-export-code-refs))))))
3659
3369 ((functionp (setq fnc (nth 2 (assoc type org-link-protocols)))) 3660 ((functionp (setq fnc (nth 2 (assoc type org-link-protocols))))
3370 ;; The link protocol has a function for format the link 3661 ;; The link protocol has a function for format the link
3371 (setq rpl 3662 (setq rpl
@@ -3385,7 +3676,9 @@ lang=\"%s\" xml:lang=\"%s\">
3385 (if (functionp link-validate) 3676 (if (functionp link-validate)
3386 (funcall link-validate filename current-dir) 3677 (funcall link-validate filename current-dir)
3387 t)) 3678 t))
3388 (setq file-is-image-p (org-file-image-p filename)) 3679 (setq file-is-image-p
3680 (org-file-image-p
3681 filename org-export-html-inline-image-extensions))
3389 (setq thefile (if abs-p (expand-file-name filename) filename)) 3682 (setq thefile (if abs-p (expand-file-name filename) filename))
3390 (when (and org-export-html-link-org-files-as-html 3683 (when (and org-export-html-link-org-files-as-html
3391 (string-match "\\.org$" thefile)) 3684 (string-match "\\.org$" thefile))
@@ -3441,12 +3734,18 @@ lang=\"%s\" xml:lang=\"%s\">
3441 (while (string-match "\\([^* \t].*?\\)\\[\\([0-9]+\\)\\]" line start) 3734 (while (string-match "\\([^* \t].*?\\)\\[\\([0-9]+\\)\\]" line start)
3442 (if (get-text-property (match-beginning 2) 'org-protected line) 3735 (if (get-text-property (match-beginning 2) 'org-protected line)
3443 (setq start (match-end 2)) 3736 (setq start (match-end 2))
3444 (let ((n (match-string 2 line))) 3737 (let ((n (match-string 2 line)) extra a)
3738 (if (setq a (assoc n footref-seen))
3739 (progn
3740 (setcdr a (1+ (cdr a)))
3741 (setq extra (format ".%d" (cdr a))))
3742 (setq extra "")
3743 (push (cons n 1) footref-seen))
3445 (setq line 3744 (setq line
3446 (replace-match 3745 (replace-match
3447 (format 3746 (format
3448 "%s<sup><a class=\"footref\" name=\"fnr.%s\" href=\"#fn.%s\">%s</a></sup>" 3747 "%s<sup><a class=\"footref\" name=\"fnr.%s%s\" href=\"#fn.%s\">%s</a></sup>"
3449 (match-string 1 line) n n n) 3748 (match-string 1 line) n extra n n)
3450 t t line)))))) 3749 t t line))))))
3451 3750
3452 (cond 3751 (cond
@@ -3585,6 +3884,17 @@ lang=\"%s\" xml:lang=\"%s\">
3585 (org-export-preserve-breaks 3884 (org-export-preserve-breaks
3586 (setq line (concat line "<br/>")))) 3885 (setq line (concat line "<br/>"))))
3587 3886
3887 ;; Check if a paragraph should be started
3888 (let ((start 0))
3889 (while (and org-par-open
3890 (string-match "\\\\par\\>" line start))
3891 ;; Leave a space in the </p> so that the footnote matcher
3892 ;; does not see this.
3893 (if (not (get-text-property (match-beginning 0)
3894 'org-protected line))
3895 (setq line (replace-match "</p ><p >" t t line)))
3896 (setq start (match-end 0))))
3897
3588 (insert line "\n"))))) 3898 (insert line "\n")))))
3589 3899
3590 ;; Properly close all local lists and other lists 3900 ;; Properly close all local lists and other lists
@@ -3693,6 +4003,15 @@ lang=\"%s\" xml:lang=\"%s\">
3693 (kill-buffer (current-buffer))) 4003 (kill-buffer (current-buffer)))
3694 (current-buffer))))) 4004 (current-buffer)))))
3695 4005
4006(defun org-export-get-coderef-format (path desc)
4007 (save-match-data
4008 (if (and desc (string-match
4009 (regexp-quote (concat "(" path ")"))
4010 desc))
4011 (replace-match "%s" t t desc)
4012 "%s")))
4013
4014
3696(defun org-export-html-format-href (s) 4015(defun org-export-html-format-href (s)
3697 "Make sure the S is valid as a href reference in an XHTML document." 4016 "Make sure the S is valid as a href reference in an XHTML document."
3698 (save-match-data 4017 (save-match-data
@@ -3881,14 +4200,18 @@ lang=\"%s\" xml:lang=\"%s\">
3881 (push html-table-tag html)) 4200 (push html-table-tag html))
3882 (concat (mapconcat 'identity html "\n") "\n"))) 4201 (concat (mapconcat 'identity html "\n") "\n")))
3883 4202
3884(defun org-table-clean-before-export (lines) 4203(defun org-table-clean-before-export (lines &optional maybe-quoted)
3885 "Check if the table has a marking column. 4204 "Check if the table has a marking column.
3886If yes remove the column and the special lines." 4205If yes remove the column and the special lines."
3887 (setq org-table-colgroup-info nil) 4206 (setq org-table-colgroup-info nil)
3888 (if (memq nil 4207 (if (memq nil
3889 (mapcar 4208 (mapcar
3890 (lambda (x) (or (string-match "^[ \t]*|-" x) 4209 (lambda (x) (or (string-match "^[ \t]*|-" x)
3891 (string-match "^[ \t]*| *\\([#!$*_^ /]\\) *|" x))) 4210 (string-match
4211 (if maybe-quoted
4212 "^[ \t]*| *\\\\?\\([\#!$*_^ /]\\) *|"
4213 "^[ \t]*| *\\([\#!$*_^ /]\\) *|")
4214 x)))
3892 lines)) 4215 lines))
3893 (progn 4216 (progn
3894 (setq org-table-clean-did-remove-column nil) 4217 (setq org-table-clean-did-remove-column nil)
@@ -4007,22 +4330,16 @@ But it has the disadvantage, that Org-mode's HTML conversions cannot be used."
4007 (catch 'exit 4330 (catch 'exit
4008 (let (r b) 4331 (let (r b)
4009 (while (string-match org-maybe-keyword-time-regexp s) 4332 (while (string-match org-maybe-keyword-time-regexp s)
4010 (if (and (match-end 1) (equal (match-string 1 s) org-clock-string))
4011 ;; never export CLOCK
4012 (throw 'exit ""))
4013 (or b (setq b (substring s 0 (match-beginning 0)))) 4333 (or b (setq b (substring s 0 (match-beginning 0))))
4014 (if (not org-export-with-timestamps) 4334 (setq r (concat
4015 (setq r (concat r (substring s 0 (match-beginning 0))) 4335 r (substring s 0 (match-beginning 0))
4016 s (substring s (match-end 0))) 4336 (if (match-end 1)
4017 (setq r (concat 4337 (format "@<span class=\"timestamp-kwd\">%s @</span>"
4018 r (substring s 0 (match-beginning 0)) 4338 (match-string 1 s)))
4019 (if (match-end 1) 4339 (format " @<span class=\"timestamp\">%s@</span>"
4020 (format "@<span class=\"timestamp-kwd\">%s @</span>" 4340 (substring
4021 (match-string 1 s))) 4341 (org-translate-time (match-string 3 s)) 1 -1)))
4022 (format " @<span class=\"timestamp\">%s@</span>" 4342 s (substring s (match-end 0))))
4023 (substring
4024 (org-translate-time (match-string 3 s)) 1 -1)))
4025 s (substring s (match-end 0)))))
4026 ;; Line break if line started and ended with time stamp stuff 4343 ;; Line break if line started and ended with time stamp stuff
4027 (if (not r) 4344 (if (not r)
4028 s 4345 s
diff --git a/lisp/org/org-export-latex.el b/lisp/org/org-export-latex.el
index 4a1cc89a27f..2da0648537f 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.16 7;; Version: 6.19a
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
@@ -62,12 +62,11 @@
62(defvar org-export-latex-add-level 0) 62(defvar org-export-latex-add-level 0)
63(defvar org-export-latex-sectioning "") 63(defvar org-export-latex-sectioning "")
64(defvar org-export-latex-sectioning-depth 0) 64(defvar org-export-latex-sectioning-depth 0)
65(defvar org-export-latex-special-string-regexps 65(defvar org-export-latex-special-keyword-regexp
66 '(org-ts-regexp 66 (concat "\\<\\(" org-scheduled-string "\\|"
67 org-scheduled-string 67 org-deadline-string "\\|"
68 org-deadline-string 68 org-closed-string"\\)")
69 org-clock-string) 69 "Regexp matching special time planning keywords plus the time after it.")
70 "A list of regexps to convert as special keywords.")
71 70
72(defvar latexp) ; dynamically scoped from org.el 71(defvar latexp) ; dynamically scoped from org.el
73(defvar re-quote) ; dynamically scoped from org.el 72(defvar re-quote) ; dynamically scoped from org.el
@@ -221,12 +220,25 @@ inserted headline and is mandatory."
221 (symbol :tag "Convert as descriptive list" description) 220 (symbol :tag "Convert as descriptive list" description)
222 (string :tag "Use a section string" :value "\\subparagraph{%s}"))) 221 (string :tag "Use a section string" :value "\\subparagraph{%s}")))
223 222
223(defcustom org-export-latex-list-parameters
224 '(:cbon "\\texttt{[ ]}" :cboff "\\texttt{[ ]}")
225 "Parameters for the LaTeX list exporter.
226These parameters will be passed on to `org-list-to-latex', which in turn
227will pass them (combined with the LaTeX default list parameters) to
228`org-list-to-generic'."
229 :group 'org-export-latex
230 :type 'plist)
231
224(defcustom org-export-latex-remove-from-headlines 232(defcustom org-export-latex-remove-from-headlines
225 '(:todo t :priority t :tags t) 233 '(:todo nil :priority nil :tags nil)
226 "A plist of keywords to remove from headlines. 234 "A plist of keywords to remove from headlines. OBSOLETE.
227Non-nil means remove this keyword type from the headline. 235Non-nil means remove this keyword type from the headline.
228 236
229Don't remove the keys, just change their values." 237Don't remove the keys, just change their values.
238
239Obsolete, this variable is no longer used. Use the separate
240variables `org-export-with-todo-keywords', `org-export-with-priority',
241and `org-export-with-tags' instead."
230 :type 'plist 242 :type 'plist
231 :group 'org-export-latex) 243 :group 'org-export-latex)
232 244
@@ -235,6 +247,16 @@ Don't remove the keys, just change their values."
235 :group 'org-export-latex 247 :group 'org-export-latex
236 :type 'string) 248 :type 'string)
237 249
250(defcustom org-export-latex-inline-image-extensions
251 '("pdf" "jpeg" "jpg" "png")
252 "Extensions of image files that can be inlined into LaTeX.
253Note that this depends on the way the LaTeX file is processed.
254The default setting (pdf and jpg) assumes that pdflatex is doing the
255processing. If you are using latex and dvips or something similar,
256only postscript files can be included."
257 :group 'org-export-html
258 :type '(repeat (string :tag "Extension")))
259
238(defcustom org-export-latex-coding-system nil 260(defcustom org-export-latex-coding-system nil
239 "Coding system for the exported LaTex file." 261 "Coding system for the exported LaTex file."
240 :group 'org-export-latex 262 :group 'org-export-latex
@@ -430,6 +452,8 @@ when PUB-DIR is set, use this as the publishing directory."
430 :comments nil 452 :comments nil
431 :tags (plist-get opt-plist :tags) 453 :tags (plist-get opt-plist :tags)
432 :priority (plist-get opt-plist :priority) 454 :priority (plist-get opt-plist :priority)
455 :footnotes (plist-get opt-plist :footnotes)
456 :timestamps (plist-get opt-plist :timestamps)
433 :todo-keywords (plist-get opt-plist :todo-keywords) 457 :todo-keywords (plist-get opt-plist :todo-keywords)
434 :add-text (if (eq to-buffer 'string) nil text) 458 :add-text (if (eq to-buffer 'string) nil text)
435 :skip-before-1st-heading skip 459 :skip-before-1st-heading skip
@@ -664,12 +688,22 @@ LEVEL indicates the default depth for export."
664 (org-combine-plists (org-default-export-plist) ext-plist 688 (org-combine-plists (org-default-export-plist) ext-plist
665 (org-infile-export-plist)) 689 (org-infile-export-plist))
666 org-export-latex-class 690 org-export-latex-class
667 (save-excursion 691 (or (and (org-region-active-p)
668 (goto-char (point-min)) 692 (save-excursion
669 (if (and (re-search-forward "^#\\+LaTeX_CLASS:[ \t]*\\([a-zA-Z]+\\)" nil t) 693 (goto-char (region-beginning))
670 (assoc (match-string 1) org-export-latex-classes)) 694 (and (looking-at org-complex-heading-regexp)
671 (match-string 1) 695 (org-entry-get nil "LaTeX_CLASS" 'selective))))
672 org-export-latex-default-class)) 696 (save-excursion
697 (save-restriction
698 (widen)
699 (goto-char (point-min))
700 (and (re-search-forward "^#\\+LaTeX_CLASS:[ \t]*\\([a-zA-Z]+\\)" nil t)
701 (match-string 1))))
702 org-export-latex-default-class)
703 org-export-latex-class
704 (or (car (assoc org-export-latex-class org-export-latex-classes))
705 (error "No definition for class `%s' in `org-export-latex-classes'"
706 org-export-latex-class))
673 org-export-latex-header 707 org-export-latex-header
674 (cadr (assoc org-export-latex-class org-export-latex-classes)) 708 (cadr (assoc org-export-latex-class org-export-latex-classes))
675 org-export-latex-sectioning 709 org-export-latex-sectioning
@@ -778,8 +812,7 @@ links, keywords, lists, tables, fixed-width"
778 (unless (memq 'links exclude-list) 812 (unless (memq 'links exclude-list)
779 (org-export-latex-links)) 813 (org-export-latex-links))
780 (unless (memq 'keywords exclude-list) 814 (unless (memq 'keywords exclude-list)
781 (org-export-latex-keywords 815 (org-export-latex-keywords))
782 (plist-get org-export-latex-options-plist :timestamps)))
783 (unless (memq 'lists exclude-list) 816 (unless (memq 'lists exclude-list)
784 (org-export-latex-lists)) 817 (org-export-latex-lists))
785 (unless (memq 'tables exclude-list) 818 (unless (memq 'tables exclude-list)
@@ -806,7 +839,7 @@ links, keywords, lists, tables, fixed-width"
806 (match-end 0) '(org-protected t))) 839 (match-end 0) '(org-protected t)))
807 (buffer-string)))) 840 (buffer-string))))
808 841
809(defun org-export-latex-keywords-maybe (remove-list) 842(defun org-export-latex-keywords-maybe (&optional remove-list)
810 "Maybe remove keywords depending on rules in REMOVE-LIST." 843 "Maybe remove keywords depending on rules in REMOVE-LIST."
811 (goto-char (point-min)) 844 (goto-char (point-min))
812 (let ((re-todo (mapconcat 'identity org-export-latex-todo-keywords-1 "\\|")) 845 (let ((re-todo (mapconcat 'identity org-export-latex-todo-keywords-1 "\\|"))
@@ -815,12 +848,12 @@ links, keywords, lists, tables, fixed-width"
815 (when (re-search-forward (concat "^\\(" re-todo "\\)") nil t) 848 (when (re-search-forward (concat "^\\(" re-todo "\\)") nil t)
816 (if (plist-get remove-list :todo) 849 (if (plist-get remove-list :todo)
817 (replace-match "") 850 (replace-match "")
818 (replace-match (format "\\texttt{%s}" (match-string 1)) t t))) 851 (replace-match (format "\\textbf{%s}" (match-string 1)) t t)))
819 ;; convert priority string 852 ;; convert priority string
820 (when (re-search-forward "\\[\\\\#.\\]" nil t) 853 (when (re-search-forward "\\[\\\\#.\\]" nil t)
821 (if (plist-get remove-list :priority) 854 (if (plist-get remove-list :priority)
822 (replace-match "") 855 (replace-match "")
823 (replace-match (format "\\texttt{%s}" (match-string 0)) t t))) 856 (replace-match (format "\\textbf{%s}" (match-string 0)) t t)))
824 ;; convert tags 857 ;; convert tags
825 (when (re-search-forward "\\(:[a-zA-Z0-9_@]+\\)+:" nil t) 858 (when (re-search-forward "\\(:[a-zA-Z0-9_@]+\\)+:" nil t)
826 (if (or (not org-export-with-tags) 859 (if (or (not org-export-with-tags)
@@ -828,7 +861,7 @@ links, keywords, lists, tables, fixed-width"
828 (replace-match "") 861 (replace-match "")
829 (replace-match 862 (replace-match
830 (org-export-latex-protect-string 863 (org-export-latex-protect-string
831 (format "\\texttt{%s}" 864 (format "\\textbf{%s}"
832 (save-match-data 865 (save-match-data
833 (replace-regexp-in-string 866 (replace-regexp-in-string
834 "_" "\\\\_" (match-string 0))))) 867 "_" "\\\\_" (match-string 0)))))
@@ -843,12 +876,10 @@ links, keywords, lists, tables, fixed-width"
843 (goto-char (point-min)) 876 (goto-char (point-min))
844 (when (plist-get org-export-latex-options-plist :emphasize) 877 (when (plist-get org-export-latex-options-plist :emphasize)
845 (org-export-latex-fontify)) 878 (org-export-latex-fontify))
846 (org-export-latex-keywords-maybe 879 (org-export-latex-keywords-maybe)
847 org-export-latex-remove-from-headlines)
848 (org-export-latex-special-chars 880 (org-export-latex-special-chars
849 (plist-get org-export-latex-options-plist :sub-superscript)) 881 (plist-get org-export-latex-options-plist :sub-superscript))
850 (org-export-latex-links) 882 (org-export-latex-links)
851; (org-trim (buffer-substring-no-properties (point-min) (point-max)))))
852 (org-trim (buffer-string)))) 883 (org-trim (buffer-string))))
853 884
854(defun org-export-latex-quotation-marks () 885(defun org-export-latex-quotation-marks ()
@@ -865,7 +896,7 @@ links, keywords, lists, tables, fixed-width"
865 (while (re-search-forward (car l) nil t) 896 (while (re-search-forward (car l) nil t)
866 (let ((rpl (concat (match-string 1) (cadr l)))) 897 (let ((rpl (concat (match-string 1) (cadr l))))
867 (org-export-latex-protect-string rpl) 898 (org-export-latex-protect-string rpl)
868 (org-if-unprotected 899 (org-if-unprotected-1
869 (replace-match rpl t t))))) quote-rpl))) 900 (replace-match rpl t t))))) quote-rpl)))
870 901
871(defun org-export-latex-special-chars (sub-superscript) 902(defun org-export-latex-special-chars (sub-superscript)
@@ -877,15 +908,11 @@ See the `org-export-latex.el' code for a complete conversion table."
877 (goto-char (point-min)) 908 (goto-char (point-min))
878 (while (re-search-forward c nil t) 909 (while (re-search-forward c nil t)
879 ;; Put the point where to check for org-protected 910 ;; Put the point where to check for org-protected
880; (unless (or (get-text-property (match-beginning 2) 'org-protected);
881; (org-at-table-p))
882 (unless (get-text-property (match-beginning 2) 'org-protected) 911 (unless (get-text-property (match-beginning 2) 'org-protected)
883 (cond ((member (match-string 2) '("\\$" "$")) 912 (cond ((member (match-string 2) '("\\$" "$"))
884 (if (equal (match-string 2) "\\$") 913 (if (equal (match-string 2) "\\$")
885 (replace-match (concat (match-string 1) "$" 914 nil
886 (match-string 3)) t t) 915 (replace-match "\\$" t t)))
887 (replace-match (concat (match-string 1) "\\$"
888 (match-string 3)) t t)))
889 ((member (match-string 2) '("&" "%" "#")) 916 ((member (match-string 2) '("&" "%" "#"))
890 (if (equal (match-string 1) "\\") 917 (if (equal (match-string 1) "\\")
891 (replace-match (match-string 2) t t) 918 (replace-match (match-string 2) t t)
@@ -903,12 +930,12 @@ See the `org-export-latex.el' code for a complete conversion table."
903 (org-export-latex-protect-string 930 (org-export-latex-protect-string
904 (concat (match-string 1) "\\~{}")) t t)))) 931 (concat (match-string 1) "\\~{}")) t t))))
905 ((member (match-string 2) '("{" "}")) 932 ((member (match-string 2) '("{" "}"))
906 (unless (save-match-data (org-inside-LaTeX-fragment-p)) 933 (unless (save-match-data (org-inside-latex-math-p))
907 (if (equal (match-string 1) "\\") 934 (if (equal (match-string 1) "\\")
908 (replace-match (match-string 2) t t) 935 (replace-match (match-string 2) t t)
909 (replace-match (concat (match-string 1) "\\" 936 (replace-match (concat (match-string 1) "\\"
910 (match-string 2)) t t))))) 937 (match-string 2)) t t)))))
911 (unless (save-match-data (org-inside-LaTeX-fragment-p)) 938 (unless (save-match-data (org-inside-latex-math-p))
912 (cond ((equal (match-string 2) "\\") 939 (cond ((equal (match-string 2) "\\")
913 (replace-match (or (save-match-data 940 (replace-match (or (save-match-data
914 (org-export-latex-treat-backslash-char 941 (org-export-latex-treat-backslash-char
@@ -922,7 +949,8 @@ See the `org-export-latex.el' code for a complete conversion table."
922 (match-string 2) 949 (match-string 2)
923 (match-string 1) 950 (match-string 1)
924 (match-string 3))) "") t t))))))) 951 (match-string 3))) "") t t)))))))
925 '("^\\([^\n$]*?\\|^\\)\\(\\\\?\\$\\)\\([^\n$]*\\)$" 952 '(;"^\\([^\n$]*?\\|^\\)\\(\\\\?\\$\\)\\([^\n$]*\\)$"
953 "\\(\\(\\\\?\\$\\)\\)"
926 "\\([a-za-z0-9]+\\|[ \t\n]\\|\\b\\|\\\\\\)\\(_\\|\\^\\)\\([a-za-z0-9]+\\|[ \t\n]\\|[:punct:]\\|{[a-za-z0-9]+}\\|([a-za-z0-9]+)\\)" 954 "\\([a-za-z0-9]+\\|[ \t\n]\\|\\b\\|\\\\\\)\\(_\\|\\^\\)\\([a-za-z0-9]+\\|[ \t\n]\\|[:punct:]\\|{[a-za-z0-9]+}\\|([a-za-z0-9]+)\\)"
927 "\\(.\\|^\\)\\(\\\\\\)\\([ \t\n]\\|[a-zA-Z&#%{}\"]+\\)" 955 "\\(.\\|^\\)\\(\\\\\\)\\([ \t\n]\\|[a-zA-Z&#%{}\"]+\\)"
928 "\\(.\\|^\\)\\(&\\)" 956 "\\(.\\|^\\)\\(&\\)"
@@ -936,6 +964,9 @@ See the `org-export-latex.el' code for a complete conversion table."
936 ;; (?\> . "\\textgreater{}") 964 ;; (?\> . "\\textgreater{}")
937 ))) 965 )))
938 966
967(defun org-inside-latex-math-p ()
968 (get-text-property (point) 'org-latex-math))
969
939(defun org-export-latex-treat-sub-super-char 970(defun org-export-latex-treat-sub-super-char
940 (subsup char string-before string-after) 971 (subsup char string-before string-after)
941 "Convert the \"_\" and \"^\" characters to LaTeX. 972 "Convert the \"_\" and \"^\" characters to LaTeX.
@@ -948,7 +979,7 @@ Convert CHAR depending on STRING-BEFORE and STRING-AFTER."
948 (string-match "\\S-+" string-after)) 979 (string-match "\\S-+" string-after))
949 (cond ((eq 'org-link (get-text-property 0 'face char)) 980 (cond ((eq 'org-link (get-text-property 0 'face char))
950 (concat string-before "\\" char string-after)) 981 (concat string-before "\\" char string-after))
951 ((save-match-data (org-inside-LaTeX-fragment-p)) 982 ((save-match-data (org-inside-latex-math-p))
952 (if subsup 983 (if subsup
953 (cond ((eq 1 (length string-after)) 984 (cond ((eq 1 (length string-after))
954 (concat string-before char string-after)) 985 (concat string-before char string-after))
@@ -996,32 +1027,29 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
996 (t (org-export-latex-protect-string 1027 (t (org-export-latex-protect-string
997 (concat string-before "\\textbackslash{}" string-after))))) 1028 (concat string-before "\\textbackslash{}" string-after)))))
998 1029
999(defun org-export-latex-keywords (timestamps) 1030(defun org-export-latex-keywords ()
1000 "Convert special keywords to LaTeX. 1031 "Convert special keywords to LaTeX."
1001Regexps are those from `org-export-latex-special-string-regexps'. 1032 (goto-char (point-min))
1002If TIMESTAMPS, convert timestamps, otherwise delete them." 1033 (let ((re (concat org-export-latex-special-keyword-regexp
1003 (let ((rg org-export-latex-special-string-regexps) r) 1034 ".*" ; including the time stamp....
1004 (while (setq r (pop rg)) 1035 )))
1005 (goto-char (point-min)) 1036 (while (re-search-forward re nil t)
1006 (while (re-search-forward (eval r) nil t) 1037 (replace-match (format "\\\\texttt{%s}" (match-string 0)) t))))
1007 (if (not timestamps)
1008 (replace-match (format "\\\\texttt{%s}" (match-string 0)) t)
1009 (replace-match ""))))))
1010 1038
1011(defun org-export-latex-fixed-width (opt) 1039(defun org-export-latex-fixed-width (opt)
1012 "When OPT is non-nil convert fixed-width sections to LaTeX." 1040 "When OPT is non-nil convert fixed-width sections to LaTeX."
1013 (goto-char (point-min)) 1041 (goto-char (point-min))
1014 (while (re-search-forward "^[ \t]*:" nil t) 1042 (while (re-search-forward "^[ \t]*:\\([ \t]\\|$\\)" nil t)
1015 (if opt 1043 (if opt
1016 (progn (goto-char (match-beginning 0)) 1044 (progn (goto-char (match-beginning 0))
1017 (insert "\\begin{verbatim}\n") 1045 (insert "\\begin{verbatim}\n")
1018 (while (looking-at "^\\([ \t]*\\):\\(.*\\)$") 1046 (while (looking-at "^\\([ \t]*\\):\\(\\([ \t]\\|$\\).*\\)$")
1019 (replace-match (concat (match-string 1) 1047 (replace-match (concat (match-string 1)
1020 (match-string 2)) t t) 1048 (match-string 2)) t t)
1021 (forward-line)) 1049 (forward-line))
1022 (insert "\\end{verbatim}\n\n")) 1050 (insert "\\end{verbatim}\n\n"))
1023 (progn (goto-char (match-beginning 0)) 1051 (progn (goto-char (match-beginning 0))
1024 (while (looking-at "^\\([ \t]*\\):\\(.*\\)$") 1052 (while (looking-at "^\\([ \t]*\\):\\(\\([ \t]\\|$\\).*\\)$")
1025 (replace-match (concat "%" (match-string 1) 1053 (replace-match (concat "%" (match-string 1)
1026 (match-string 2)) t t) 1054 (match-string 2)) t t)
1027 (forward-line)))))) 1055 (forward-line))))))
@@ -1061,7 +1089,7 @@ If TIMESTAMPS, convert timestamps, otherwise delete them."
1061 (setq lines (split-string raw-table "\n" t)) 1089 (setq lines (split-string raw-table "\n" t))
1062 (apply 'delete-region (list beg end)) 1090 (apply 'delete-region (list beg end))
1063 (when org-export-table-remove-special-lines 1091 (when org-export-table-remove-special-lines
1064 (setq lines (org-table-clean-before-export lines))) 1092 (setq lines (org-table-clean-before-export lines 'maybe-quoted)))
1065 ;; make a formatting string to reflect aligment 1093 ;; make a formatting string to reflect aligment
1066 (setq olines lines) 1094 (setq olines lines)
1067 (while (and (not line-fmt) (setq line (pop olines))) 1095 (while (and (not line-fmt) (setq line (pop olines)))
@@ -1142,8 +1170,16 @@ If TIMESTAMPS, convert timestamps, otherwise delete them."
1142 ;; The match goes one char after the *string* 1170 ;; The match goes one char after the *string*
1143 (let ((emph (assoc (match-string 3) 1171 (let ((emph (assoc (match-string 3)
1144 org-export-latex-emphasis-alist)) 1172 org-export-latex-emphasis-alist))
1173 (beg (match-beginning 0))
1174 (end (match-end 0))
1145 rpl) 1175 rpl)
1146 (unless (get-text-property (1- (point)) 'org-protected) 1176 (unless (or (get-text-property (1- (point)) 'org-protected)
1177 (save-excursion
1178 (goto-char (match-beginning 1))
1179 (save-match-data
1180 (and (org-at-table-p)
1181 (string-match
1182 "[|\n]" (buffer-substring beg end))))))
1147 (setq rpl (concat (match-string 1) 1183 (setq rpl (concat (match-string 1)
1148 (format (org-export-latex-protect-char-in-string 1184 (format (org-export-latex-protect-char-in-string
1149 '("\\" "{" "}") (cadr emph)) 1185 '("\\" "{" "}") (cadr emph))
@@ -1159,7 +1195,7 @@ If TIMESTAMPS, convert timestamps, otherwise delete them."
1159 ;; or send some warnings. 1195 ;; or send some warnings.
1160 "Convert links to LaTeX." 1196 "Convert links to LaTeX."
1161 (goto-char (point-min)) 1197 (goto-char (point-min))
1162 (while (re-search-forward org-bracket-link-analytic-regexp nil t) 1198 (while (re-search-forward org-bracket-link-analytic-regexp++ nil t)
1163 (org-if-unprotected 1199 (org-if-unprotected
1164 (goto-char (match-beginning 0)) 1200 (goto-char (match-beginning 0))
1165 (let* ((re-radio org-export-latex-all-targets-re) 1201 (let* ((re-radio org-export-latex-all-targets-re)
@@ -1171,6 +1207,7 @@ If TIMESTAMPS, convert timestamps, otherwise delete them."
1171 (if (or (file-name-absolute-p raw-path) 1207 (if (or (file-name-absolute-p raw-path)
1172 (string-match "^\\.\\.?/" raw-path)) 1208 (string-match "^\\.\\.?/" raw-path))
1173 "file"))) 1209 "file")))
1210 (coderefp (equal type "coderef"))
1174 (caption (org-find-text-property-in-string 'org-caption raw-path)) 1211 (caption (org-find-text-property-in-string 'org-caption raw-path))
1175 (attr (org-find-text-property-in-string 'org-attributes raw-path)) 1212 (attr (org-find-text-property-in-string 'org-attributes raw-path))
1176 (label (org-find-text-property-in-string 'org-label raw-path)) 1213 (label (org-find-text-property-in-string 'org-label raw-path))
@@ -1178,6 +1215,8 @@ If TIMESTAMPS, convert timestamps, otherwise delete them."
1178 imgp radiop 1215 imgp radiop
1179 ;; define the path of the link 1216 ;; define the path of the link
1180 (path (cond 1217 (path (cond
1218 ((member type '("coderef"))
1219 raw-path)
1181 ((member type '("http" "https" "ftp")) 1220 ((member type '("http" "https" "ftp"))
1182 (concat type ":" raw-path)) 1221 (concat type ":" raw-path))
1183 ((and re-radio (string-match re-radio raw-path)) 1222 ((and re-radio (string-match re-radio raw-path))
@@ -1185,9 +1224,10 @@ If TIMESTAMPS, convert timestamps, otherwise delete them."
1185 ((equal type "mailto") 1224 ((equal type "mailto")
1186 (concat type ":" raw-path)) 1225 (concat type ":" raw-path))
1187 ((equal type "file") 1226 ((equal type "file")
1188 (if (and (or (org-file-image-p (expand-file-name raw-path)) 1227 (if (and (org-file-image-p
1189 (string-match "\\.\\(pdf\\|jpg\\|ps\\|eps\\)$" 1228 (expand-file-name
1190 raw-path)) 1229 raw-path)
1230 org-export-latex-inline-image-extensions)
1191 (equal desc full-raw-path)) 1231 (equal desc full-raw-path))
1192 (setq imgp t) 1232 (setq imgp t)
1193 (progn (when (string-match "\\(.+\\)::.+" raw-path) 1233 (progn (when (string-match "\\(.+\\)::.+" raw-path)
@@ -1205,12 +1245,18 @@ If TIMESTAMPS, convert timestamps, otherwise delete them."
1205 (if floatp "\\begin{figure}[htb]\n") 1245 (if floatp "\\begin{figure}[htb]\n")
1206 (format "\\centerline{\\includegraphics[%s]{%s}}\n" 1246 (format "\\centerline{\\includegraphics[%s]{%s}}\n"
1207 (or attr org-export-latex-image-default-option) 1247 (or attr org-export-latex-image-default-option)
1208 (expand-file-name raw-path)) 1248 (if (file-name-absolute-p raw-path)
1249 (expand-file-name raw-path)
1250 raw-path))
1209 (if floatp 1251 (if floatp
1210 (format "\\caption{%s%s}\n" 1252 (format "\\caption{%s%s}\n"
1211 (if label (concat "\\label{" label "}") "") 1253 (if label (concat "\\label{" label "}") "")
1212 (or caption ""))) 1254 (or caption "")))
1213 (if floatp "\\end{figure}\n")))) 1255 (if floatp "\\end{figure}\n"))))
1256 (coderefp
1257 (insert (format
1258 (org-export-get-coderef-format path desc)
1259 (cdr (assoc path org-export-code-refs)))))
1214 (radiop (insert (format "\\hyperref[%s]{%s}" 1260 (radiop (insert (format "\\hyperref[%s]{%s}"
1215 (org-solidify-link-text raw-path) desc))) 1261 (org-solidify-link-text raw-path) desc)))
1216 ((not type) 1262 ((not type)
@@ -1232,20 +1278,37 @@ If TIMESTAMPS, convert timestamps, otherwise delete them."
1232 1278
1233 ;; Preserve latex environments 1279 ;; Preserve latex environments
1234 (goto-char (point-min)) 1280 (goto-char (point-min))
1235 (while (re-search-forward "^[ \t]*\\begin{\\([a-zA-Z]+\\)}" nil t) 1281 (while (re-search-forward "^[ \t]*\\\\begin{\\([a-zA-Z]+\\)}" nil t)
1236 (let* ((start (progn (beginning-of-line) (point))) 1282 (let* ((start (progn (beginning-of-line) (point)))
1237 (end (or (and (re-search-forward 1283 (end (or (and (re-search-forward
1238 (concat "^[ \t]*\\end{" (match-string 1) "}" nil t) 1284 (concat "^[ \t]*\\\\end{" (match-string 1) "}") nil t)
1239 (point-at-eol))) 1285 (point-at-eol))
1240 (point-max)))) 1286 (point-max))))
1241 (add-text-properties start end '(org-protected t)))) 1287 (add-text-properties start end '(org-protected t))))
1242 1288
1289 ;; Preserve math snippets
1290
1291 (let* ((matchers (plist-get org-format-latex-options :matchers))
1292 (re-list org-latex-regexps)
1293 beg end re e m n block off)
1294 ;; Check the different regular expressions
1295 (while (setq e (pop re-list))
1296 (setq m (car e) re (nth 1 e) n (nth 2 e)
1297 block (if (nth 3 e) "\n\n" ""))
1298 (setq off (if (member m '("$" "$1")) 1 0))
1299 (when (and (member m matchers) (not (equal m "begin")))
1300 (goto-char (point-min))
1301 (while (re-search-forward re nil t)
1302 (setq beg (+ (match-beginning 0) off) end (- (match-end 0) 0))
1303 (add-text-properties beg end '(org-protected t org-latex-math t))))))
1304
1243 ;; Convert LaTeX to \LaTeX{} 1305 ;; Convert LaTeX to \LaTeX{}
1244 (goto-char (point-min)) 1306 (goto-char (point-min))
1245 (let ((case-fold-search nil) rpl) 1307 (let ((case-fold-search nil) rpl)
1246 (while (re-search-forward "\\([^+_]\\)LaTeX" nil t) 1308 (while (re-search-forward "\\([^+_]\\)LaTeX" nil t)
1247 (replace-match (org-export-latex-protect-string 1309 (org-if-unprotected
1248 (concat (match-string 1) "\\LaTeX{}")) t t))) 1310 (replace-match (org-export-latex-protect-string
1311 (concat (match-string 1) "\\LaTeX{}")) t t))))
1249 1312
1250 ;; Convert blockquotes 1313 ;; Convert blockquotes
1251 (goto-char (point-min)) 1314 (goto-char (point-min))
@@ -1266,7 +1329,8 @@ If TIMESTAMPS, convert timestamps, otherwise delete them."
1266 ;; Convert horizontal rules 1329 ;; Convert horizontal rules
1267 (goto-char (point-min)) 1330 (goto-char (point-min))
1268 (while (re-search-forward "^----+.$" nil t) 1331 (while (re-search-forward "^----+.$" nil t)
1269 (replace-match (org-export-latex-protect-string "\\hrule") t t)) 1332 (org-if-unprotected
1333 (replace-match (org-export-latex-protect-string "\\hrule") t t)))
1270 1334
1271 ;; Protect LaTeX commands like \command[...]{...} or \command{...} 1335 ;; Protect LaTeX commands like \command[...]{...} or \command{...}
1272 (goto-char (point-min)) 1336 (goto-char (point-min))
@@ -1285,65 +1349,73 @@ If TIMESTAMPS, convert timestamps, otherwise delete them."
1285 (while (re-search-forward 1349 (while (re-search-forward
1286 (concat "<<<?" org-export-latex-all-targets-re 1350 (concat "<<<?" org-export-latex-all-targets-re
1287 ">>>?\\((INVISIBLE)\\)?") nil t) 1351 ">>>?\\((INVISIBLE)\\)?") nil t)
1288 (replace-match 1352 (org-if-unprotected
1289 (org-export-latex-protect-string 1353 (replace-match
1290 (format "\\label{%s}%s" (save-match-data (org-solidify-link-text 1354 (org-export-latex-protect-string
1291 (match-string 1))) 1355 (format "\\label{%s}%s" (save-match-data (org-solidify-link-text
1292 (if (match-string 2) "" (match-string 1)))) t t)) 1356 (match-string 1)))
1357 (if (match-string 2) "" (match-string 1)))) t t)))
1293 1358
1294 ;; Delete @<...> constructs 1359 ;; Delete @<...> constructs
1295 ;; Thanks to Daniel Clemente for this regexp 1360 ;; Thanks to Daniel Clemente for this regexp
1296 (goto-char (point-min)) 1361 (goto-char (point-min))
1297 (while (re-search-forward "@<\\(?:[^\"\n]\\|\".*\"\\)*?>" nil t) 1362 (while (re-search-forward "@<\\(?:[^\"\n]\\|\".*\"\\)*?>" nil t)
1298 (replace-match "")) 1363 (org-if-unprotected
1364 (replace-match "")))
1299 1365
1300 ;; When converting to LaTeX, replace footnotes 1366 ;; When converting to LaTeX, replace footnotes
1301 ;; FIXME: don't protect footnotes from conversion 1367 ;; FIXME: don't protect footnotes from conversion
1302 (when (plist-get org-export-latex-options-plist :footnotes) 1368 (when (plist-get org-export-latex-options-plist :footnotes)
1303 (goto-char (point-min)) 1369 (goto-char (point-min))
1304 (while (re-search-forward "\\[[0-9]+\\]" nil t) 1370 (while (re-search-forward "\\[\\([0-9]+\\)\\]" nil t)
1305 (when (save-match-data 1371 (org-if-unprotected
1306 (save-excursion (beginning-of-line) 1372 (when (save-match-data
1307 (looking-at "[^:|#]"))) 1373 (save-excursion (beginning-of-line)
1308 (let ((foot-beg (match-beginning 0)) 1374 (looking-at "[^:|#]")))
1309 (foot-end (match-end 0)) 1375 (let ((foot-beg (match-beginning 0))
1310 (foot-prefix (match-string 0)) 1376 (foot-end (match-end 0))
1311 footnote footnote-rpl) 1377 (foot-prefix (match-string 0))
1312 (save-excursion 1378 footnote footnote-rpl)
1313 (when (search-forward foot-prefix nil t) 1379 (save-excursion
1314 (replace-match "") 1380 (if (not (re-search-forward (concat "^" (regexp-quote foot-prefix))
1315 (let ((end (save-excursion 1381 nil t))
1316 (if (re-search-forward "^$\\|^#.*$\\|\\[[0-9]+\\]" nil t) 1382 (replace-match "$^{\\1}$")
1317 (match-beginning 0) (point-max))))) 1383 (replace-match "")
1318 (setq footnote (concat (org-trim (buffer-substring (point) end)) 1384 (let ((end (save-excursion
1319 " ")) ; prevent last } being part of a link 1385 (if (re-search-forward "^$\\|^#.*$\\|\\[[0-9]+\\]" nil t)
1320 (delete-region (point) end)) 1386 (match-beginning 0) (point-max)))))
1321 (goto-char foot-beg) 1387 (setq footnote (concat (org-trim (buffer-substring (point) end))
1322 (delete-region foot-beg foot-end) 1388 " ")) ; prevent last } being part of a link
1323 (unless (null footnote) 1389 (delete-region (point) end))
1324 (setq footnote-rpl (format "\\footnote{%s}" footnote)) 1390 (goto-char foot-beg)
1325 (add-text-properties 0 10 '(org-protected t) footnote-rpl) 1391 (delete-region foot-beg foot-end)
1326 (add-text-properties (1- (length footnote-rpl)) 1392 (unless (null footnote)
1327 (length footnote-rpl) 1393 (setq footnote-rpl (format "\\footnote{%s}" footnote))
1328 '(org-protected t) footnote-rpl) 1394 (add-text-properties 0 10 '(org-protected t) footnote-rpl)
1329 (insert footnote-rpl))))))) 1395 (add-text-properties (1- (length footnote-rpl))
1330 1396 (length footnote-rpl)
1331 ;; Replace footnote section tag for LaTeX 1397 '(org-protected t) footnote-rpl)
1398 (insert footnote-rpl)))
1399 )))))
1400
1401 ;; Remove footnote section tag for LaTeX
1332 (goto-char (point-min)) 1402 (goto-char (point-min))
1333 (while (re-search-forward 1403 (while (re-search-forward
1334 (concat "^" footnote-section-tag-regexp) nil t) 1404 (concat "^" footnote-section-tag-regexp) nil t)
1335 (replace-match "")))) 1405 (org-if-unprotected
1406 (replace-match "")))))
1336 1407
1337;;; List handling: 1408;;; List handling:
1338 1409
1339(defun org-export-latex-lists () 1410(defun org-export-latex-lists ()
1340 "Replace plain text lists in current buffer into LaTeX lists." 1411 "Convert plain text lists in current buffer into LaTeX lists."
1341 "Convert lists to LaTeX."
1342 (goto-char (point-min)) 1412 (goto-char (point-min))
1343 (while (re-search-forward org-list-beginning-re nil t) 1413 (while (re-search-forward org-list-beginning-re nil t)
1344 (org-if-unprotected 1414 (org-if-unprotected
1345 (beginning-of-line) 1415 (beginning-of-line)
1346 (insert (org-list-to-latex (org-list-parse-list t)) "\n")))) 1416 (insert (org-list-to-latex (org-list-parse-list t)
1417 org-export-latex-list-parameters))
1418 "\n")))
1347 1419
1348(defconst org-latex-entities 1420(defconst org-latex-entities
1349 '("\\!" 1421 '("\\!"
diff --git a/lisp/org/org-faces.el b/lisp/org/org-faces.el
index 31200839dcf..e94d1dbf0fa 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.16 8;; Version: 6.19a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
@@ -239,6 +239,13 @@ column view defines special faces for each outline level. See the file
239 "Face for links." 239 "Face for links."
240 :group 'org-faces) 240 :group 'org-faces)
241 241
242(defface org-footnote
243 '((((class color) (background light)) (:foreground "Purple" :underline t))
244 (((class color) (background dark)) (:foreground "Cyan" :underline t))
245 (t (:underline t)))
246 "Face for links."
247 :group 'org-faces)
248
242(defface org-ellipsis 249(defface org-ellipsis
243 '((((class color) (background light)) (:foreground "DarkGoldenrod" :underline t)) 250 '((((class color) (background light)) (:foreground "DarkGoldenrod" :underline t))
244 (((class color) (background dark)) (:foreground "LightGoldenrod" :underline t)) 251 (((class color) (background dark)) (:foreground "LightGoldenrod" :underline t))
@@ -389,6 +396,22 @@ changes."
389 :group 'org-faces 396 :group 'org-faces
390 :version "22.1") 397 :version "22.1")
391 398
399(defface org-clock-overlay ;; copied from secondary-selection
400 (org-compatible-face nil
401 '((((class color) (min-colors 88) (background light))
402 :background "yellow1")
403 (((class color) (min-colors 88) (background dark))
404 :background "SkyBlue4")
405 (((class color) (min-colors 16) (background light))
406 :background "yellow")
407 (((class color) (min-colors 16) (background dark))
408 :background "SkyBlue4")
409 (((class color) (min-colors 8))
410 :background "cyan" :foreground "black")
411 (t :inverse-video t)))
412 "Basic face for displaying the secondary selection."
413 :group 'org-faces)
414
392(defface org-agenda-structure ;; originally copied from font-lock-function-name-face 415(defface org-agenda-structure ;; originally copied from font-lock-function-name-face
393 (org-compatible-face nil 416 (org-compatible-face nil
394 '((((class color) (min-colors 88) (background light)) (:foreground "Blue1")) 417 '((((class color) (min-colors 88) (background light)) (:foreground "Blue1"))
diff --git a/lisp/org/org-footnote.el b/lisp/org/org-footnote.el
new file mode 100644
index 00000000000..05ebce54c0b
--- /dev/null
+++ b/lisp/org/org-footnote.el
@@ -0,0 +1,504 @@
1;;; org-footnote.el --- Footnote support in Org and elsewhere
2;;
3;; Copyright (C) 2009 Free Software Foundation, Inc.
4;;
5;; Author: Carsten Dominik <carsten at orgmode dot org>
6;; Keywords: outlines, hypermedia, calendar, wp
7;; Homepage: http://orgmode.org
8;; Version: 6.19a
9;;
10;; This file is part of GNU Emacs.
11;;
12;; GNU Emacs is free software: you can redistribute it and/or modify
13;; it under the terms of the GNU General Public License as published by
14;; the Free Software Foundation, either version 3 of the License, or
15;; (at your option) any later version.
16
17;; GNU Emacs is distributed in the hope that it will be useful,
18;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20;; GNU General Public License for more details.
21
22;; You should have received a copy of the GNU General Public License
23;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
25;;
26;;; Commentary:
27
28;; This file contains the code dealing with footnotes in Org-mode.
29;; The code can also be used in arbitrary text modes to provide
30;; footnotes. Compared to Steven L Baur's footnote.el it provides
31;; better support for resuming editing. It is less configurable than
32;; Steve's code, though.
33
34;;; Code:
35
36(eval-when-compile
37 (require 'cl))
38(require 'org-macs)
39(require 'org-compat)
40
41(declare-function org-in-regexp "org" (re &optional nlines visually))
42(declare-function org-mark-ring-push "org" (&optional pos buffer))
43(declare-function outline-next-heading "outline")
44(declare-function org-trim "org" (s))
45(declare-function org-show-context "org" (&optional key))
46(declare-function org-back-to-heading "org" (&optional invisible-ok))
47(declare-function org-end-of-subtree "org" (&optional invisible-ok to-heading))
48
49(defconst org-footnote-re
50 (concat "[^][\n]" ; to make sure it is not at the beginning of a line
51 "\\["
52 "\\(?:"
53 "\\([0-9]+\\)"
54 "\\|"
55 (org-re "\\(fn:\\([-_[:word:]]+?\\)?\\)\\(?::\\([^\]]*?\\)\\)?")
56 "\\)"
57 "\\]")
58 "Regular expression for matching footnotes.")
59
60(defconst org-footnote-definition-re
61 (org-re "^\\(\\[\\([0-9]+\\|fn:[-_[:word:]]+\\)\\]\\)")
62 "Regular expression matching the definition of a footnote.")
63
64(defcustom org-footnote-section "Footnotes"
65 "Outline heading containing footnote definitions before export.
66This can be nil, to place footnotes locally at the end of the current
67outline node. If can also be the name of a special outline heading
68under which footnotes should be put.
69This variable defines the place where Org puts the definition
70automatically, i.e. when creating the footnote, and when sorting the notes.
71However, by hand you may place definitions *anywhere*.
72If this is a string, during export, all subtrees starting with this
73heading will be removed after extracting footnote definitions."
74 :group 'org-footnotes
75 :type '(choice
76 (string :tag "Collect fotnotes under heading")
77 (const :tag "Define footnotes locally" nil)))
78
79(defcustom org-footnote-tag-for-non-org-mode-files "Footnotes:"
80 "Tag marking the beginning of footnote section.
81The Org-mode footnote engine can be used in arbitrary text files as well
82as in Org-mode. Outside Org-mode, new footnotes are always placed at
83the end of the file. When you normalize the notes, any line containing
84only this tag will be removed, a new one will be inserted at the end
85of the file, followed by the collected and normalized footnotes."
86 :group 'org-footnotes
87 :type 'string)
88
89(defcustom org-footnote-define-inline nil
90 "Non-nil means, define footnotes inline, at reference location.
91When nil, footnotes will be defined in a special section near
92the end of the document. When t, the [fn:label:definition] notation
93will be used to define the footnote at the reference position."
94 :group 'org-footnote
95 :type 'boolean)
96
97(defcustom org-footnote-auto-label t
98 "Non-nil means, define automatically new labels for footnotes.
99Possible values are:
100
101nil prompt the user for each label
102t create unique labels of the form [fn:1], [fn:2], ...
103confirm like t, but let the user edit the created value. In particular,
104 the label can be removed from the minibuffer, to create
105 an anonymous footnote.
106plain Automatically create plain number labels like [1]"
107 :group 'org-footnote
108 :type '(choice
109 (const :tag "Frompt for label" nil)
110 (const :tag "Create automatic [fn:N]" t)
111 (const :tag "Offer automatic [fn:N] for editing" confirm)
112 (const :tag "Create automatic [N]" plain)))
113
114(defcustom org-footnote-fill-after-inline-note-extraction nil
115 "Non-nil means, fill paragraphs after extracting footnotes.
116When extracting inline footnotes, the lengths of lines can change a lot.
117When this option is set, paragraphs from which an inline footnote has been
118extracted will be filled again."
119 :group 'org-footnote
120 :type 'boolean)
121
122(defun org-footnote-at-reference-p ()
123 "Is the cursor at a footnote reference?
124If yes, return the beginning position, the label, and the definition, if local."
125 (when (org-in-regexp org-footnote-re 15)
126 (list (match-beginning 0)
127 (or (match-string 1)
128 (if (equal (match-string 2) "fn:") nil (match-string 2)))
129 (match-string 4))))
130
131(defun org-footnote-at-definition-p ()
132 "Is the cursor at a footnote definition.
133This matches only pure definitions like [1] or [fn:name] at the beginning
134of a line. It does not a references like [fn:name:definition], where the
135footnote text is included and defined locally.
136The return value will be nil if not at a foornote definition, and a list
137with start and label of the footnote if there is a definition at point."
138 (save-excursion
139 (end-of-line 1)
140 (let ((lim (save-excursion (re-search-backward "^\\*+ \\|^[ \t]*$" nil t))))
141 (when (re-search-backward org-footnote-definition-re lim t)
142 (list (match-beginning 0) (match-string 2))))))
143
144(defun org-footnote-goto-definition (label)
145 "Find the definition of the footnote with label LABEL."
146 (interactive "sLabel: ")
147 (org-mark-ring-push)
148 (setq label (org-footnote-normalize-label label))
149 (let ((re (format "^\\[%s\\]\\|.\\[%s:" label label))
150 pos)
151 (save-excursion
152 (setq pos (or (re-search-forward re nil t)
153 (and (goto-char (point-min))
154 (re-search-forward re nil t))
155 (and (progn (widen) t)
156 (goto-char (point-min))
157 (re-search-forward re nil t)))))
158 (if (not pos)
159 (error "Cannot find definition of footnote %s" label)
160 (goto-char pos)
161 (org-show-context 'link-search)
162 (message "Edit definition and go back with `C-c &' or, if unique, with `C-c C-c'."))))
163
164(defun org-footnote-goto-next-reference (label)
165 "Find the definition of the footnote with label LABEL."
166 (interactive "sLabel: ")
167 (org-mark-ring-push)
168 (setq label (org-footnote-normalize-label label))
169 (let ((re (format ".\\[%s[]:]" label))
170 (p0 (point)) pos)
171 (save-excursion
172 (setq pos (or (re-search-forward re nil t)
173 (and (goto-char (point-min))
174 (re-search-forward re nil t))
175 (and (progn (widen) t)
176 (goto-char p0)
177 (re-search-forward re nil t))
178 (and (goto-char (point-min))
179 (re-search-forward re nil t)))))
180 (if pos
181 (progn
182 (goto-char pos)
183 (org-show-context 'link-search))
184 (error "Cannot find reference of footnote %s" label))))
185
186(defun org-footnote-normalize-label (label)
187 (if (numberp label) (setq label (number-to-string label)))
188 (if (not (string-match "^[0-9]+$\\|^$\\|^fn:" label))
189 (setq label (concat "fn:" label)))
190 label)
191
192(defun org-footnote-all-labels ()
193 "Return list with all defined foot labels used in the buffer."
194 (let (rtn l)
195 (save-excursion
196 (save-restriction
197 (widen)
198 (goto-char (point-min))
199 (while (re-search-forward org-footnote-definition-re nil t)
200 (setq l (org-match-string-no-properties 2))
201 (and l (add-to-list 'rtn l)))
202 (goto-char (point-min))
203 (while (re-search-forward org-footnote-re nil t)
204 (setq l (or (org-match-string-no-properties 1)
205 (org-match-string-no-properties 2)))
206 (and l (not (equal l "fn:")) (add-to-list 'rtn l)))))
207 rtn))
208
209(defun org-footnote-unique-label (&optional current)
210 "Return a new unique footnote label.
211The returns the firsts fn:N labels that is currently not used."
212 (unless current (setq current (org-footnote-all-labels)))
213 (let ((fmt (if (eq org-footnote-auto-label 'plain) "%d" "fn:%d"))
214 (cnt 1))
215 (while (member (format fmt cnt) current)
216 (incf cnt))
217 (format fmt cnt)))
218
219(defvar org-footnote-label-history nil
220 "History of footnote labels entered in current buffer.")
221(make-variable-buffer-local 'org-footnote-label-history)
222
223(defun org-footnote-new ()
224 "Insert a new footnote.
225This command prompts for a label. If this is a label referencing an
226existing label, only insert the label. If the footnote label is empty
227or new, let the user edit the definition of the footnote."
228 (interactive)
229 (let* ((labels (org-footnote-all-labels))
230 (propose (org-footnote-unique-label labels))
231 (label
232 (if (member org-footnote-auto-label '(t plain))
233 propose
234 (completing-read
235 "Label (leave empty for anonymous): "
236 (mapcar 'list labels) nil nil
237 (if (eq org-footnote-auto-label 'confirm) propose nil)
238 'org-footnote-label-history))))
239 (setq label (org-footnote-normalize-label label))
240 (cond
241 ((equal label "")
242 (insert "[fn:: ]")
243 (backward-char 1))
244 ((member label labels)
245 (insert "[" label "]")
246 (message "New reference to existing note"))
247 (org-footnote-define-inline
248 (insert "[" label ": ]")
249 (backward-char 1))
250 (t
251 (insert "[" label "]")
252 (org-footnote-create-definition label)))))
253
254(defun org-footnote-create-definition (label)
255 "Start the definition of a footnote with label LABEL."
256 (interactive "sLabel: ")
257 (setq label (org-footnote-normalize-label label))
258 (let (re p)
259 (cond
260 ((org-mode-p)
261 (if (not org-footnote-section)
262 ;; No section, put footnote into the current outline node
263 nil
264 ;; Try to find or make the special node
265 (setq re (concat "^\\*+[ \t]+" org-footnote-section "[ \t]*$"))
266 (unless (or (re-search-forward re nil t)
267 (and (progn (widen) t)
268 (re-search-forward re nil t)))
269 (goto-char (point-max))
270 (insert "\n\n* " org-footnote-section "\n")))
271 ;; Now go to the end of this entry and insert there.
272 (org-footnote-goto-local-insertion-point))
273 (t
274 (setq re (concat "^" org-footnote-tag-for-non-org-mode-files "[ \t]*$"))
275 (unless (re-search-forward re nil t)
276 (goto-char (point-max))
277 (skip-chars-backward " \t\r\n")
278 (insert "\n\n")
279 (delete-region (point) (point-max))
280 (insert org-footnote-tag-for-non-org-mode-files "\n"))
281 (goto-char (point-max))
282 (skip-chars-backward " \t\r\n")))
283 (insert "\n\n")
284 (insert "[" label "] ")
285 (message "Edit definition and go back with `C-c &' or, if unique, with `C-c C-c'.")))
286
287;;;###autoload
288(defun org-footnote-action (&optional special)
289 "Do the right thing for footnotes.
290When at a foornote reference, jump to the definition. When at a definition,
291jump to the refernces. When neither at definition or reference,
292create a new footnote, interactively.
293With prefix arg SPECIAL, offer additional commands in a menu."
294 (interactive "P")
295 (let (tmp c)
296 (cond
297 (special
298 (message "Footnotes: [s]ort | convert to [n]umeric | [d]elete")
299 (setq c (read-char-exclusive))
300 (cond
301 ((equal c ?s)
302 (org-footnote-normalize 'sort))
303 ((equal c ?n)
304 (org-footnote-normalize))
305 ((equal c ?d)
306 (org-footnote-delete))
307 (t (error "No such footnote command %c" c))))
308 ((setq tmp (org-footnote-at-reference-p))
309 (if (nth 1 tmp)
310 (org-footnote-goto-definition (nth 1 tmp))
311 (goto-char (match-beginning 4))))
312 ((setq tmp (org-footnote-at-definition-p))
313 (org-footnote-goto-next-reference (nth 1 tmp)))
314 (t (org-footnote-new)))))
315
316;;;###autoload
317(defun org-footnote-normalize (&optional sort-only for-preprocessor)
318 "Collect the footnotes in various formats and normalize them.
319This find the different sorts of footnotes allowed in Org, and
320normalizes them to the usual [N] format that is understood by the
321Org-mode exporters.
322When SORT-ONLY is set, only sort the footnote definitions into the
323referenced sequence."
324 ;; This is based on Paul's function, but rewritten.
325 (let ((count 0) ref def idef ref-table liste beg beg1 marker a before
326 ins-point)
327 (save-excursion
328 ;; Now find footnote references, and extract the definitions
329 (goto-char (point-min))
330 (while (re-search-forward org-footnote-re nil t)
331 (org-if-unprotected
332 (setq def (match-string 4)
333 idef def
334 ref (or (match-string 1) (match-string 2))
335 before (char-to-string (char-after (match-beginning 0))))
336 (if (equal ref "fn:") (setq ref nil))
337 (if (and ref (setq a (assoc ref ref-table)))
338 (progn
339 (setq marker (nth 1 a))
340 (unless (nth 2 a) (setf (caddr a) def)))
341 (setq marker (number-to-string (incf count))))
342 (save-match-data
343 (if def
344 (setq def (org-trim def))
345 (save-excursion
346 (goto-char (point-min))
347 (if (not (re-search-forward (concat "^\\[" (regexp-quote ref)
348 "\\]") nil t))
349 (setq def nil)
350 (setq beg (match-beginning 0))
351 (setq beg1 (match-end 0))
352 (re-search-forward
353 (org-re "^[ \t]*$\\|^\\*+ \\|^\\[\\([0-9]+\\|fn:[-_[:word:]]+\\)\\]")
354 nil 'move)
355 (setq def (buffer-substring beg1 (or (match-beginning 0)
356 (point-max))))
357 (goto-char beg)
358 (skip-chars-backward " \t\n\t")
359 (delete-region (1+ (point)) (match-beginning 0))))))
360 (unless sort-only
361 (replace-match (concat before "[" marker "]"))
362 (and idef
363 org-footnote-fill-after-inline-note-extraction
364 (fill-paragraph)))
365 (if (not a) (push (list ref marker def) ref-table))))
366
367 ;; First find and remove the footnote section
368 (goto-char (point-min))
369 (cond
370 ((org-mode-p)
371 (if (and org-footnote-section
372 (re-search-forward
373 (concat "^\\*[ \t]+" (regexp-quote org-footnote-section)
374 "[ \t]*$")
375 nil t))
376 (if (or for-preprocessor (not org-footnote-section))
377 (replace-match "")
378 (org-back-to-heading t)
379 (forward-line 1)
380 (setq ins-point (point))
381 (delete-region (point) (org-end-of-subtree t)))
382 (goto-char (point-max))
383 (unless for-preprocessor
384 (when org-footnote-section
385 (or (bolp) (insert "\n"))
386 (insert "* " org-footnote-section "\n")
387 (setq ins-point (point))))))
388 (t
389 (if (re-search-forward
390 (concat "^"
391 (regexp-quote org-footnote-tag-for-non-org-mode-files)
392 "[ \t]*$")
393 nil t)
394 (replace-match ""))
395 (goto-char (point-max))
396 (skip-chars-backward " \t\n\r")
397 (delete-region (point) (point-max))
398 (insert "\n\n" org-footnote-tag-for-non-org-mode-files "\n")
399 (setq ins-point (point))))
400
401 ;; Insert the footnotes again
402 (goto-char (or ins-point (point-max)))
403 (setq ref-table (reverse ref-table))
404 (when sort-only
405 ;; remove anonymous fotnotes from the list
406 (setq ref-table
407 (delq nil (mapcar
408 (lambda (x) (and (car x)
409 (not (equal (car x) "fn:"))
410 x))
411 ref-table))))
412 ;; Make sure each footnote has a description, or an error message.
413 (setq ref-table
414 (mapcar
415 (lambda (x)
416 (if (not (nth 2 x))
417 (setcar (cddr x)
418 (format "FOOTNOTE DEFINITION NOT FOUND: %s" (car x)))
419 (setcar (cddr x) (org-trim (nth 2 x))))
420 x)
421 ref-table))
422
423 (if (or (not (org-mode-p)) ; not an Org file
424 org-footnote-section ; we do not use a footnote section
425 (not sort-only) ; this is normalization
426 for-preprocessor) ; the is the preprocessor
427 ;; Insert the footnotes together in one place
428 (progn
429 (setq def
430 (mapconcat
431 (lambda (x)
432 (format "[%s] %s" (nth (if sort-only 0 1) x)
433 (org-trim (nth 2 x))))
434 ref-table "\n\n"))
435 (if ref-table (insert "\n" def "\n\n")))
436 ;; Insert each footnote near the first reference
437 ;; Happens only in Org files with no special footnote section,
438 ;; and only when doing sorting
439 (mapc 'org-insert-footnote-reference-near-definition
440 ref-table)))))
441
442(defun org-insert-footnote-reference-near-definition (entry)
443 "Find first reference of footnote ENTRY and insert the definition there.
444ENTRY is (fn-label num-mark definition)."
445 (when (car entry)
446 (let ((pos (point)))
447 (goto-char (point-min))
448 (when (re-search-forward (format ".\\[%s[]:]" (regexp-quote (car entry)))
449 nil t)
450 (org-footnote-goto-local-insertion-point)
451 (insert (format "\n\n[%s] %s" (car entry) (nth 2 entry)))))))
452
453(defun org-footnote-goto-local-insertion-point ()
454 "Find insertion point for footnote, just before next outline heading."
455 (outline-next-heading)
456 (or (bolp) (newline))
457 (beginning-of-line 0)
458 (while (and (not (bobp)) (= (char-after) ?#))
459 (beginning-of-line 0))
460 (if (looking-at "#\\+TBLFM:") (beginning-of-line 2))
461 (end-of-line 1)
462 (skip-chars-backward "\n\r\t "))
463
464(defun org-footnote-delete (&optional label)
465 "Delete the footnote at point.
466This will remove the definition (even multiple definitions if they exist)
467and all references of a footnote label."
468 (catch 'done
469 (let (x label l beg def-re (nref 0) (ndef 0))
470 (unless label
471 (when (setq x (org-footnote-at-reference-p))
472 (setq label (nth 1 x))
473 (when (or (not label) (equal "fn:" label))
474 (delete-region (1+ (match-beginning 0)) (match-end 0))
475 (message "Anonymous footnote removed")
476 (throw 'done t)))
477 (when (and (not label) (setq x (org-footnote-at-definition-p)))
478 (setq label (nth 1 x)))
479 (unless label (error "Don't know which footnote to remove")))
480 (save-excursion
481 (save-restriction
482 (goto-char (point-min))
483 (while (re-search-forward org-footnote-re nil t)
484 (setq l (or (match-string 1) (match-string 2)))
485 (when (equal l label)
486 (delete-region (1+ (match-beginning 0)) (match-end 0))
487 (incf nref)))
488 (goto-char (point-min))
489 (setq def-re (concat "^\\[" (regexp-quote label) "\\]"))
490 (while (re-search-forward def-re nil t)
491 (setq beg (match-beginning 0))
492 (if (re-search-forward "^\\[\\|^[ \t]*$\\|^\\*+ " nil t)
493 (goto-char (match-beginning 0))
494 (goto-char (point-max)))
495 (delete-region beg (point))
496 (incf ndef))))
497 (message "%d definition(s) of and %d reference(s) of footnote %s removed"
498 ndef nref label))))
499
500(provide 'org-footnote)
501
502;; arch-tag: 1b5954df-fb5d-4da5-8709-78d944dbfc37
503
504;;; org-footnote.el ends here
diff --git a/lisp/org/org-gnus.el b/lisp/org/org-gnus.el
index b7b43f9b60b..b77ae9c05a7 100644
--- a/lisp/org/org-gnus.el
+++ b/lisp/org/org-gnus.el
@@ -6,7 +6,7 @@
6;; Tassilo Horn <tassilo at member dot fsf dot org> 6;; Tassilo Horn <tassilo at member dot fsf 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.16 9;; Version: 6.19a
10;; 10;;
11;; This file is part of GNU Emacs. 11;; This file is part of GNU Emacs.
12;; 12;;
@@ -111,12 +111,12 @@ If `org-store-link' was called with a prefix arg the meaning of
111 (gnus-group-name)) 111 (gnus-group-name))
112 (t "???"))) 112 (t "???")))
113 desc link) 113 desc link)
114 (unless group (error "Not on a group")) 114 (when group
115 (org-store-link-props :type "gnus" :group group) 115 (org-store-link-props :type "gnus" :group group)
116 (setq desc (org-gnus-group-link group) 116 (setq desc (org-gnus-group-link group)
117 link desc) 117 link desc)
118 (org-add-link-props :link link :description desc) 118 (org-add-link-props :link link :description desc)
119 link)) 119 link)))
120 120
121 ((memq major-mode '(gnus-summary-mode gnus-article-mode)) 121 ((memq major-mode '(gnus-summary-mode gnus-article-mode))
122 (and (eq major-mode 'gnus-summary-mode) (gnus-summary-show-article)) 122 (and (eq major-mode 'gnus-summary-mode) (gnus-summary-show-article))
diff --git a/lisp/org/org-id.el b/lisp/org/org-id.el
index 40a67dfe2d7..0623c6071a8 100644
--- a/lisp/org/org-id.el
+++ b/lisp/org/org-id.el
@@ -1,10 +1,11 @@
1;;; org-id.el --- Global identifiers for Org-mode entries 1;;; org-id.el --- Global identifiers for Org-mode entries
2;;
2;; Copyright (C) 2008, 2009 Free Software Foundation, Inc. 3;; Copyright (C) 2008, 2009 Free Software Foundation, Inc.
3;; 4;;
4;; Author: Carsten Dominik <carsten at orgmode dot org> 5;; Author: Carsten Dominik <carsten at orgmode dot org>
5;; Keywords: outlines, hypermedia, calendar, wp 6;; Keywords: outlines, hypermedia, calendar, wp
6;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
7;; Version: 6.16 8;; Version: 6.19a
8;; 9;;
9;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
10;; 11;;
@@ -262,6 +263,9 @@ Move the cursor to that entry in that buffer."
262The return value is a cons cell (file-name . position), or nil 263The return value is a cons cell (file-name . position), or nil
263if there is no entry with that ID. 264if there is no entry with that ID.
264With optional argument MARKERP, return the position as a new marker." 265With optional argument MARKERP, return the position as a new marker."
266 (cond
267 ((symbolp id) (setq id (symbol-name id)))
268 ((numberp id) (setq id (number-to-string id))))
265 (let ((file (org-id-find-id-file id)) 269 (let ((file (org-id-find-id-file id))
266 org-agenda-new-buffers where) 270 org-agenda-new-buffers where)
267 (when file 271 (when file
@@ -521,6 +525,7 @@ When CHECK is given, prepare detailed information about duplicate IDs."
521 525
522;; Finding entries with specified id 526;; Finding entries with specified id
523 527
528;;;###autoload
524(defun org-id-find-id-file (id) 529(defun org-id-find-id-file (id)
525 "Query the id database for the file in which this ID is located." 530 "Query the id database for the file in which this ID is located."
526 (unless org-id-locations (org-id-locations-load)) 531 (unless org-id-locations (org-id-locations-load))
diff --git a/lisp/org/org-info.el b/lisp/org/org-info.el
index e211d88d167..110e921ae5e 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.16 8;; Version: 6.19a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
diff --git a/lisp/org/org-irc.el b/lisp/org/org-irc.el
index 170f9346f0f..596f6a9d8e7 100644
--- a/lisp/org/org-irc.el
+++ b/lisp/org/org-irc.el
@@ -1,10 +1,10 @@
1;;; org-irc.el --- Store links to IRC sessions 1;;; org-irc.el --- Store links to IRC sessions
2;; 2;;
3;; Copyright (C) 2008, 2009 Free Software Foundation, Inc. 3;; Copyright (C) 2008, 2009 Free Software Foundation, Inc.
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.16 7;; Version: 6.19a
8;; 8;;
9;; This file is part of GNU Emacs. 9;; This file is part of GNU Emacs.
10;; 10;;
diff --git a/lisp/org/org-jsinfo.el b/lisp/org/org-jsinfo.el
index 15011c71ff7..c13629976dc 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.16 8;; Version: 6.19a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
@@ -140,7 +140,7 @@ Option settings will replace the %MANAGER-OPTIONS cookie."
140 default (cdr (assoc opt org-infojs-options))) 140 default (cdr (assoc opt org-infojs-options)))
141 (and (symbolp default) (not (memq default '(t nil))) 141 (and (symbolp default) (not (memq default '(t nil)))
142 (setq default (plist-get exp-plist default))) 142 (setq default (plist-get exp-plist default)))
143 (if (string-match (format " %s:\\(\\S-+\\)" opt) v) 143 (if (and v (string-match (format " %s:\\(\\S-+\\)" opt) v))
144 (setq val (match-string 1 v)) 144 (setq val (match-string 1 v))
145 (setq val default)) 145 (setq val default))
146 (cond 146 (cond
diff --git a/lisp/org/org-list.el b/lisp/org/org-list.el
index 0cefa5cf89f..41d2e26fd7e 100644
--- a/lisp/org/org-list.el
+++ b/lisp/org/org-list.el
@@ -6,7 +6,7 @@
6;; Bastien Guerry <bzg AT altern DOT org> 6;; Bastien Guerry <bzg AT altern 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.16 9;; Version: 6.19a
10;; 10;;
11;; This file is part of GNU Emacs. 11;; This file is part of GNU Emacs.
12;; 12;;
@@ -46,6 +46,7 @@
46(declare-function org-trim "org" (s)) 46(declare-function org-trim "org" (s))
47(declare-function org-get-indentation "org" (&optional line)) 47(declare-function org-get-indentation "org" (&optional line))
48(declare-function org-timer-item "org-timer" (&optional arg)) 48(declare-function org-timer-item "org-timer" (&optional arg))
49(declare-function org-combine-plists "org" (&rest plists))
49 50
50(defgroup org-plain-lists nil 51(defgroup org-plain-lists nil
51 "Options concerning plain lists in Org-mode." 52 "Options concerning plain lists in Org-mode."
@@ -188,13 +189,20 @@ Return t when things worked, nil when we are not in an item."
188 (save-match-data 189 (save-match-data
189 (and (looking-at "[ \t]*\\(.*?\\) ::") 190 (and (looking-at "[ \t]*\\(.*?\\) ::")
190 (match-string 1))))) 191 (match-string 1)))))
192 (empty-line-p (save-excursion
193 (goto-char (match-beginning 0))
194 (and (not (bobp))
195 (or (beginning-of-line 0) t)
196 (save-match-data
197 (looking-at "[ \t]*$")))))
191 (timerp (and descp 198 (timerp (and descp
192 (save-match-data 199 (save-match-data
193 (string-match "^[-+*][ \t]+[0-9]+:[0-9]+:[0-9]+$" 200 (string-match "^[-+*][ \t]+[0-9]+:[0-9]+:[0-9]+$"
194 descp)))) 201 descp))))
195 (eow (save-excursion (beginning-of-line 1) (looking-at "[ \t]*") 202 (eow (save-excursion (beginning-of-line 1) (looking-at "[ \t]*")
196 (match-end 0))) 203 (match-end 0)))
197 (blank (cdr (assq 'plain-list-item org-blank-before-new-entry))) 204 (blank-a (cdr (assq 'plain-list-item org-blank-before-new-entry)))
205 (blank (if (eq blank-a 'auto) empty-line-p blank-a))
198 pos) 206 pos)
199 (if descp (setq checkbox nil)) 207 (if descp (setq checkbox nil))
200 (if timerp 208 (if timerp
@@ -894,9 +902,12 @@ sublevels as a list of strings."
894 (goto-char end)))) 902 (goto-char end))))
895 (nextindent (match-string 1)) 903 (nextindent (match-string 1))
896 (item (org-trim item)) 904 (item (org-trim item))
897 (item (if (string-match "^\\[.+\\]" item) 905 (item (if (string-match "^\\[\\([xX ]\\)\\]" item)
898 (replace-match "\\\\texttt{\\&}" 906 (replace-match (if (equal (match-string 1 item) " ")
899 t nil item) item))) 907 "[CBOFF]"
908 "[CBON]")
909 t nil item)
910 item)))
900 (push item output) 911 (push item output)
901 (when (> (length nextindent) 912 (when (> (length nextindent)
902 (length indent1)) 913 (length indent1))
@@ -1010,7 +1021,10 @@ Valid parameters PARAMS are
1010:istart String to start a list item 1021:istart String to start a list item
1011:iend String to end a list item 1022:iend String to end a list item
1012:isep String to separate items 1023:isep String to separate items
1013:lsep String to separate sublists" 1024:lsep String to separate sublists
1025
1026:cboff String to insert for an unchecked checkbox
1027:cbon String to insert for a checked checkbox"
1014 (interactive) 1028 (interactive)
1015 (let* ((p params) sublist 1029 (let* ((p params) sublist
1016 (splicep (plist-get p :splice)) 1030 (splicep (plist-get p :splice))
@@ -1027,7 +1041,9 @@ Valid parameters PARAMS are
1027 (istart (plist-get p :istart)) 1041 (istart (plist-get p :istart))
1028 (iend (plist-get p :iend)) 1042 (iend (plist-get p :iend))
1029 (isep (plist-get p :isep)) 1043 (isep (plist-get p :isep))
1030 (lsep (plist-get p :lsep))) 1044 (lsep (plist-get p :lsep))
1045 (cbon (plist-get p :cbon))
1046 (cboff (plist-get p :cboff)))
1031 (let ((wrapper 1047 (let ((wrapper
1032 (cond ((eq (car list) 'ordered) 1048 (cond ((eq (car list) 'ordered)
1033 (concat ostart "\n%s" oend "\n")) 1049 (concat ostart "\n%s" oend "\n"))
@@ -1043,6 +1059,10 @@ Valid parameters PARAMS are
1043 (setq term (org-trim (format (concat dtstart "%s" dtend) 1059 (setq term (org-trim (format (concat dtstart "%s" dtend)
1044 (match-string 1 sublist)))) 1060 (match-string 1 sublist))))
1045 (setq sublist (substring sublist (1+ (length term))))) 1061 (setq sublist (substring sublist (1+ (length term)))))
1062 (if (string-match "\\[CBON\\]" sublist)
1063 (setq sublist (replace-match cbon t t sublist)))
1064 (if (string-match "\\[CBOFF\\]" sublist)
1065 (setq sublist (replace-match cboff t t sublist)))
1046 (setq rtn (concat rtn istart term ddstart 1066 (setq rtn (concat rtn istart term ddstart
1047 sublist ddend iend isep))) 1067 sublist ddend iend isep)))
1048 (t (setq rtn (concat rtn ;; previous list 1068 (t (setq rtn (concat rtn ;; previous list
@@ -1052,38 +1072,56 @@ Valid parameters PARAMS are
1052 ))))) 1072 )))))
1053 (format wrapper rtn)))) 1073 (format wrapper rtn))))
1054 1074
1055(defun org-list-to-latex (list) 1075(defun org-list-to-latex (list &optional params)
1056 "Convert LIST into a LaTeX list." 1076 "Convert LIST into a LaTeX list.
1077LIST is as returnd by `org-list-parse-list'. PARAMS is a property list
1078with overruling parameters for `org-list-to-generic'."
1057 (org-list-to-generic 1079 (org-list-to-generic
1058 list '(:splicep nil :ostart "\\begin{enumerate}" :oend "\\end{enumerate}" 1080 list
1059 :ustart "\\begin{itemize}" :uend "\\end{itemize}" 1081 (org-combine-plists
1060 :dstart "\\begin{description}" :dend "\\end{description}" 1082 '(:splicep nil :ostart "\\begin{enumerate}" :oend "\\end{enumerate}"
1061 :dtstart "[" :dtend "]" 1083 :ustart "\\begin{itemize}" :uend "\\end{itemize}"
1062 :ddstart "" :ddend "" 1084 :dstart "\\begin{description}" :dend "\\end{description}"
1063 :istart "\\item " :iend "" 1085 :dtstart "[" :dtend "]"
1064 :isep "\n" :lsep "\n"))) 1086 :ddstart "" :ddend ""
1065 1087 :istart "\\item " :iend ""
1066(defun org-list-to-html (list) 1088 :isep "\n" :lsep "\n"
1067 "Convert LIST into a HTML list." 1089 :cbon "\\texttt{[X]}" :cboff "\\texttt{[ ]}")
1090 params)))
1091
1092(defun org-list-to-html (list &optional params)
1093 "Convert LIST into a HTML list.
1094LIST is as returnd by `org-list-parse-list'. PARAMS is a property list
1095with overruling parameters for `org-list-to-generic'."
1068 (org-list-to-generic 1096 (org-list-to-generic
1069 list '(:splicep nil :ostart "<ol>" :oend "</ol>" 1097 list
1070 :ustart "<ul>" :uend "</ul>" 1098 (org-combine-plists
1071 :dstart "<dl>" :dend "</dl>" 1099 '(:splicep nil :ostart "<ol>" :oend "</ol>"
1072 :dtstart "<dt>" :dtend "</dt>" 1100 :ustart "<ul>" :uend "</ul>"
1073 :ddstart "<dd>" :ddend "</dd>" 1101 :dstart "<dl>" :dend "</dl>"
1074 :istart "<li>" :iend "</li>" 1102 :dtstart "<dt>" :dtend "</dt>"
1075 :isep "\n" :lsep "\n"))) 1103 :ddstart "<dd>" :ddend "</dd>"
1076 1104 :istart "<li>" :iend "</li>"
1077(defun org-list-to-texinfo (list) 1105 :isep "\n" :lsep "\n"
1078 "Convert LIST into a Texinfo list." 1106 :cbon "<code>[X]</code>" :cboff "<code>[ ]</code>")
1107 params)))
1108
1109(defun org-list-to-texinfo (list &optional params)
1110 "Convert LIST into a Texinfo list.
1111LIST is as returnd by `org-list-parse-list'. PARAMS is a property list
1112with overruling parameters for `org-list-to-generic'."
1079 (org-list-to-generic 1113 (org-list-to-generic
1080 list '(:splicep nil :ostart "@itemize @minus" :oend "@end itemize" 1114 list
1081 :ustart "@enumerate" :uend "@end enumerate" 1115 (org-combine-plists
1082 :dstart "@table" :dend "@end table" 1116 '(:splicep nil :ostart "@itemize @minus" :oend "@end itemize"
1083 :dtstart "@item " :dtend "\n" 1117 :ustart "@enumerate" :uend "@end enumerate"
1084 :ddstart "" :ddend "" 1118 :dstart "@table" :dend "@end table"
1085 :istart "@item\n" :iend "" 1119 :dtstart "@item " :dtend "\n"
1086 :isep "\n" :lsep "\n"))) 1120 :ddstart "" :ddend ""
1121 :istart "@item\n" :iend ""
1122 :isep "\n" :lsep "\n"
1123 :cbon "@code{[X]}" :cboff "@code{[ ]}")
1124 params)))
1087 1125
1088(provide 'org-list) 1126(provide 'org-list)
1089 1127
diff --git a/lisp/org/org-mac-message.el b/lisp/org/org-mac-message.el
index 88aa2bcc5e0..b65bc20eae8 100644
--- a/lisp/org/org-mac-message.el
+++ b/lisp/org/org-mac-message.el
@@ -3,7 +3,7 @@
3;; Copyright (C) 2008, 2009 Free Software Foundation, Inc. 3;; Copyright (C) 2008, 2009 Free Software Foundation, Inc.
4 4
5;; Author: John Wiegley <johnw@gnu.org> 5;; Author: John Wiegley <johnw@gnu.org>
6;; Version: 6.16 6;; Version: 6.19a
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.
diff --git a/lisp/org/org-macs.el b/lisp/org/org-macs.el
index 692b48aa80d..6772e98ecf8 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.16 8;; Version: 6.19a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
@@ -48,6 +48,8 @@
48 (save-match-data 48 (save-match-data
49 (while (string-match "\\[:alnum:\\]" ss) 49 (while (string-match "\\[:alnum:\\]" ss)
50 (setq ss (replace-match "a-zA-Z0-9" t t ss))) 50 (setq ss (replace-match "a-zA-Z0-9" t t ss)))
51 (while (string-match "\\[:word:\\]" ss)
52 (setq ss (replace-match "a-zA-Z0-9" t t ss)))
51 (while (string-match "\\[:alpha:\\]" ss) 53 (while (string-match "\\[:alpha:\\]" ss)
52 (setq ss (replace-match "a-zA-Z" t t ss))) 54 (setq ss (replace-match "a-zA-Z" t t ss)))
53 ss)) 55 ss))
@@ -102,6 +104,11 @@ We use a macro so that the test can happen at compilation time."
102 `(unless (get-text-property (point) 'org-protected) 104 `(unless (get-text-property (point) 'org-protected)
103 ,@body)) 105 ,@body))
104 106
107(defmacro org-if-unprotected-1 (&rest body)
108 "Execute BODY if there is no `org-protected' text property at point-1."
109 `(unless (get-text-property (1- (point)) 'org-protected)
110 ,@body))
111
105(defmacro org-with-remote-undo (_buffer &rest _body) 112(defmacro org-with-remote-undo (_buffer &rest _body)
106 "Execute BODY while recording undo information in two buffers." 113 "Execute BODY while recording undo information in two buffers."
107 `(let ((_cline (org-current-line)) 114 `(let ((_cline (org-current-line))
@@ -188,6 +195,9 @@ we turn off invisibility temporarily. Use this in a `let' form."
188 ;; works also in narrowed buffer, because we start at 1, not point-min 195 ;; works also in narrowed buffer, because we start at 1, not point-min
189 (+ (if (bolp) 1 0) (count-lines 1 (point))))) 196 (+ (if (bolp) 1 0) (count-lines 1 (point)))))
190 197
198(defsubst org-current-line-string (&optional to-here)
199 (buffer-substring (point-at-bol) (if to-here (point) (point-at-eol))))
200
191(defsubst org-pos-in-match-range (pos n) 201(defsubst org-pos-in-match-range (pos n)
192 (and (match-beginning n) 202 (and (match-beginning n)
193 (<= (match-beginning n) pos) 203 (<= (match-beginning n) pos)
diff --git a/lisp/org/org-mew.el b/lisp/org/org-mew.el
index 6daae57a3f0..20a0f08fdcd 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.16 8;; Version: 6.19a
9 9
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11 11
diff --git a/lisp/org/org-mhe.el b/lisp/org/org-mhe.el
index 70040ca2275..21a4b6afcd2 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.16 8;; Version: 6.19a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
diff --git a/lisp/org/org-mouse.el b/lisp/org/org-mouse.el
index 1ae9f041a59..f4dae16dd6b 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.16 7;; Version: 6.19a
8;; 8;;
9;; This file is part of GNU Emacs. 9;; This file is part of GNU Emacs.
10;; 10;;
@@ -219,12 +219,11 @@ this function is called. Otherwise, the current major mode menu is used."
219 (funcall org-mouse-context-menu-function event) 219 (funcall org-mouse-context-menu-function event)
220 (if (fboundp 'mouse-menu-major-mode-map) 220 (if (fboundp 'mouse-menu-major-mode-map)
221 (popup-menu (mouse-menu-major-mode-map) event prefix) 221 (popup-menu (mouse-menu-major-mode-map) event prefix)
222 (with-no-warnings ; don't warn about fallback, obsolete since 23.1 222 (org-no-warnings ; don't warn about fallback, obsolete since 23.1
223 (mouse-major-mode-menu event prefix))))) 223 (mouse-major-mode-menu event prefix)))))
224 (setq this-command 'mouse-save-then-kill) 224 (setq this-command 'mouse-save-then-kill)
225 (mouse-save-then-kill event))) 225 (mouse-save-then-kill event)))
226 226
227
228(defun org-mouse-line-position () 227(defun org-mouse-line-position ()
229 "Returns `:beginning' or `:middle' or `:end', depending on the point position. 228 "Returns `:beginning' or `:middle' or `:end', depending on the point position.
230 229
diff --git a/lisp/org/org-plot.el b/lisp/org/org-plot.el
index 7a7dc14dc55..a0a79a82c39 100644
--- a/lisp/org/org-plot.el
+++ b/lisp/org/org-plot.el
@@ -5,7 +5,7 @@
5;; Author: Eric Schulte <schulte dot eric at gmail dot com> 5;; Author: Eric Schulte <schulte dot eric at gmail dot com>
6;; Keywords: tables, plotting 6;; Keywords: tables, plotting
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 6.16 8;; Version: 6.19a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
@@ -316,12 +316,14 @@ line directly before or after the table."
316 (mapcar (lambda (row) (nth ind row)) table)))) 0) 316 (mapcar (lambda (row) (nth ind row)) table)))) 0)
317 (plist-put params :timeind t) 317 (plist-put params :timeind t)
318 ;; check for text ind column 318 ;; check for text ind column
319 (if (> (length 319
320 (delq 0 (mapcar 320 (if (or (string= (plist-get params :with) "hist")
321 (lambda (el) 321 (> (length
322 (if (string-match org-table-number-regexp el) 322 (delq 0 (mapcar
323 0 1)) 323 (lambda (el)
324 (mapcar (lambda (row) (nth ind row)) table)))) 0) 324 (if (string-match org-table-number-regexp el)
325 0 1))
326 (mapcar (lambda (row) (nth ind row)) table)))) 0))
325 (plist-put params :textind t))))) 327 (plist-put params :textind t)))))
326 ;; write script 328 ;; write script
327 (with-temp-buffer 329 (with-temp-buffer
diff --git a/lisp/org/org-publish.el b/lisp/org/org-publish.el
index ba5fe0a8d99..149975fac22 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.16 7;; Version: 6.19a
8 8
9;; This file is part of GNU Emacs. 9;; This file is part of GNU Emacs.
10;; 10;;
diff --git a/lisp/org/org-remember.el b/lisp/org/org-remember.el
index d6662b46482..047209f1091 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.16 8;; Version: 6.19a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
diff --git a/lisp/org/org-rmail.el b/lisp/org/org-rmail.el
index c1fdf01ad4c..45990f0f4dc 100644
--- a/lisp/org/org-rmail.el
+++ b/lisp/org/org-rmail.el
@@ -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.16 9;; Version: 6.19a
10;; 10;;
11;; This file is part of GNU Emacs. 11;; This file is part of GNU Emacs.
12;; 12;;
diff --git a/lisp/org/org-table.el b/lisp/org/org-table.el
index 7d1c7383f98..13f1879b1a7 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.16 8;; Version: 6.19a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
@@ -1222,6 +1222,9 @@ With prefix ABOVE, insert above the current line."
1222 (interactive "P") 1222 (interactive "P")
1223 (if (not (org-at-table-p)) 1223 (if (not (org-at-table-p))
1224 (error "Not at a table")) 1224 (error "Not at a table"))
1225 (when (eobp) (insert "\n") (backward-char 1))
1226 (if (not (string-match "|[ \t]*$" (org-current-line-string)))
1227 (org-table-align))
1225 (let ((line (org-table-clean-line 1228 (let ((line (org-table-clean-line
1226 (buffer-substring (point-at-bol) (point-at-eol)))) 1229 (buffer-substring (point-at-bol) (point-at-eol))))
1227 (col (current-column))) 1230 (col (current-column)))
@@ -1729,7 +1732,7 @@ When NAMED is non-nil, look for a named equation."
1729 ref) 1732 ref)
1730 (int-to-string (org-table-current-column)))) 1733 (int-to-string (org-table-current-column))))
1731 (dummy (and (or nameass refass) (not named) 1734 (dummy (and (or nameass refass) (not named)
1732 (not (y-or-n-p "Replace field formula with column formula? " )) 1735 (not (y-or-n-p "Replace existing field formula with column formula? " ))
1733 (error "Abort"))) 1736 (error "Abort")))
1734 (name (or name ref)) 1737 (name (or name ref))
1735 (org-table-may-need-update nil) 1738 (org-table-may-need-update nil)
@@ -1906,6 +1909,7 @@ For all numbers larger than LIMIT, shift them by DELTA."
1906 (if (match-end 1) (push l hlines) (push l dlines)) 1909 (if (match-end 1) (push l hlines) (push l dlines))
1907 (beginning-of-line 2) 1910 (beginning-of-line 2)
1908 (setq l (1+ l))) 1911 (setq l (1+ l)))
1912 (push 'hline types) ;; add an imaginary extra hline to the end
1909 (setq org-table-current-line-types (apply 'vector (nreverse types)) 1913 (setq org-table-current-line-types (apply 'vector (nreverse types))
1910 last-dline (car dlines) 1914 last-dline (car dlines)
1911 org-table-dlines (apply 'vector (cons nil (nreverse dlines))) 1915 org-table-dlines (apply 'vector (cons nil (nreverse dlines)))
@@ -1914,7 +1918,7 @@ For all numbers larger than LIMIT, shift them by DELTA."
1914 (let* ((l last-dline) 1918 (let* ((l last-dline)
1915 (fields (org-split-string 1919 (fields (org-split-string
1916 (buffer-substring (point-at-bol) (point-at-eol)) 1920 (buffer-substring (point-at-bol) (point-at-eol))
1917 "|")) 1921 "[ \t]*|[ \t]*"))
1918 (nfields (length fields)) 1922 (nfields (length fields))
1919 al al2) 1923 al al2)
1920 (loop for i from 1 to nfields do 1924 (loop for i from 1 to nfields do
@@ -2149,6 +2153,16 @@ not overwrite the stored one."
2149 (if (and lispp literal) (setq lispp 'literal)) 2153 (if (and lispp literal) (setq lispp 'literal))
2150 ;; Check for old vertical references 2154 ;; Check for old vertical references
2151 (setq form (org-table-rewrite-old-row-references form)) 2155 (setq form (org-table-rewrite-old-row-references form))
2156 ;; Insert remote references
2157 (while (string-match "\\<remote([ \t]*\\([-_a-zA-Z0-9]+\\)[ \t]*,[ \t]*\\([^\n)]+\\))" form)
2158 (setq form
2159 (replace-match
2160 (save-match-data
2161 (org-table-make-reference
2162 (org-table-get-remote-range
2163 (match-string 1 form) (match-string 2 form))
2164 keep-empty numbers lispp))
2165 t t form)))
2152 ;; Insert complex ranges 2166 ;; Insert complex ranges
2153 (while (and (string-match org-table-range-regexp form) 2167 (while (and (string-match org-table-range-regexp form)
2154 (> (length (match-string 0 form)) 1)) 2168 (> (length (match-string 0 form)) 1))
@@ -2525,12 +2539,14 @@ known that the table will be realigned a little later anyway."
2525 (setq f (replace-match (concat "$" (cdr a)) t t f))) 2539 (setq f (replace-match (concat "$" (cdr a)) t t f)))
2526 ;; Parameters and constants 2540 ;; Parameters and constants
2527 (setq start 0) 2541 (setq start 0)
2528 (while (setq start (string-match "\\$\\([a-zA-Z][_a-zA-Z0-9]*\\)" f start)) 2542 (while (setq start (string-match "\\$\\([a-zA-Z][_a-zA-Z0-9]*\\)\\|\\(\\<remote([^)]*)\\)" f start))
2529 (setq start (1+ start)) 2543 (if (match-end 2)
2530 (if (setq a (save-match-data 2544 (setq start (match-end 2))
2531 (org-table-get-constant (match-string 1 f)))) 2545 (setq start (1+ start))
2532 (setq f (replace-match 2546 (if (setq a (save-match-data
2533 (concat (if pp "(") a (if pp ")")) t t f)))) 2547 (org-table-get-constant (match-string 1 f))))
2548 (setq f (replace-match
2549 (concat (if pp "(") a (if pp ")")) t t f)))))
2534 (if org-table-formula-debug 2550 (if org-table-formula-debug
2535 (put-text-property 0 (length f) :orig-formula f1 f)) 2551 (put-text-property 0 (length f) :orig-formula f1 f))
2536 f)) 2552 f))
@@ -2673,7 +2689,7 @@ Parameters get priority."
2673Works for single references, but also for entire formulas and even the 2689Works for single references, but also for entire formulas and even the
2674full TBLFM line." 2690full TBLFM line."
2675 (let ((start 0)) 2691 (let ((start 0))
2676 (while (string-match "\\<\\([a-zA-Z]+\\)\\([0-9]+\\>\\|&\\)\\|\\(;[^\r\n:]+\\)" s start) 2692 (while (string-match "\\<\\([a-zA-Z]+\\)\\([0-9]+\\>\\|&\\)\\|\\(;[^\r\n:]+\\|\\<remote([^)]*)\\)" s start)
2677 (cond 2693 (cond
2678 ((match-end 3) 2694 ((match-end 3)
2679 ;; format match, just advance 2695 ;; format match, just advance
@@ -4065,6 +4081,60 @@ provide ORGTBL directives for the generated table."
4065 (params (org-combine-plists params2 params))) 4081 (params (org-combine-plists params2 params)))
4066 (orgtbl-to-generic table params))) 4082 (orgtbl-to-generic table params)))
4067 4083
4084(defun org-table-get-remote-range (name-or-id form)
4085 "Get a field value or a list of values in a range from table at ID.
4086
4087NAME-OR-ID may be the name of a table in the current file as set by
4088a \"#+TBLNAME:\" directive. The first table following this line
4089will then be used. Alternatively, it may be an ID referring to
4090any entry, also in a different file. In this case, the first table
4091in that netry will be referenced.
4092FORM is a field or range descriptor like \"@2$3\" or or \"B3\" or
4093\"@I$2..@II$2\". All the references must be absolute, not relative.
4094
4095The return value is either a single string for a single field, or a
4096list of the fields in the rectangle ."
4097 (save-match-data
4098 (let ((id-loc nil)
4099 org-table-column-names org-table-column-name-regexp
4100 org-table-local-parameters org-table-named-field-locations
4101 org-table-current-line-types org-table-current-begin-line
4102 org-table-current-begin-pos org-table-dlines
4103 org-table-hlines org-table-last-alignment
4104 org-table-last-column-widths org-table-last-alignment
4105 org-table-last-column-widths tbeg
4106 buffer loc)
4107 (save-excursion
4108 (save-restriction
4109 (widen)
4110 (save-excursion
4111 (goto-char (point-min))
4112 (if (re-search-forward
4113 (concat "^#\\+TBLNAME:[ \t]*" (regexp-quote name-or-id) "[ \t]*$")
4114 nil t)
4115 (setq buffer (current-buffer) loc (match-beginning 0))
4116 (setq id-loc (org-id-find name-or-id 'marker)
4117 buffer (marker-buffer id-loc)
4118 loc (marker-position id-loc))
4119 (move-marker id-loc nil)))
4120 (switch-to-buffer buffer)
4121 (save-excursion
4122 (save-restriction
4123 (widen)
4124 (goto-char loc)
4125 (forward-char 1)
4126 (unless (and (re-search-forward "^\\(\\*+ \\)\\|[ \t]*|" nil t)
4127 (not (match-beginning 1)))
4128 (error "Cannot find a table at NAME or ID %s" name-or-id))
4129 (setq tbeg (point-at-bol))
4130 (org-table-get-specials)
4131 (setq form (org-table-formula-substitute-names form))
4132 (if (and (string-match org-table-range-regexp form)
4133 (> (length (match-string 0 form)) 1))
4134 (save-match-data
4135 (org-table-get-range (match-string 0 form) tbeg 1))
4136 form))))))))
4137
4068(provide 'org-table) 4138(provide 'org-table)
4069 4139
4070;; arch-tag: 4d21cfdd-0268-440a-84b0-09237a0fe0ef 4140;; arch-tag: 4d21cfdd-0268-440a-84b0-09237a0fe0ef
diff --git a/lisp/org/org-timer.el b/lisp/org/org-timer.el
index 2c56ca9b9b3..3320f77d297 100644
--- a/lisp/org/org-timer.el
+++ b/lisp/org/org-timer.el
@@ -1,11 +1,11 @@
1;;; org-clock.el --- The time clocking code for Org-mode 1;;; org-timer.el --- The relative timer code for Org-mode
2 2
3;; Copyright (C) 2008, 2009 Free Software Foundation, Inc. 3;; Copyright (C) 2008, 2009 Free Software Foundation, Inc.
4 4
5;; Author: Carsten Dominik <carsten at orgmode dot org> 5;; Author: Carsten Dominik <carsten at orgmode dot org>
6;; Keywords: outlines, hypermedia, calendar, wp 6;; Keywords: outlines, hypermedia, calendar, wp
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 6.16 8;; Version: 6.19a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
@@ -32,6 +32,9 @@
32(defvar org-timer-start-time nil 32(defvar org-timer-start-time nil
33 "t=0 for the running timer.") 33 "t=0 for the running timer.")
34 34
35(defvar org-timer-pause-time nil
36 "Time when the timer was paused.")
37
35(defconst org-timer-re "\\([-+]?[0-9]+\\):\\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\)" 38(defconst org-timer-re "\\([-+]?[0-9]+\\):\\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\)"
36 "Regular expression used to match timer stamps.") 39 "Regular expression used to match timer stamps.")
37 40
@@ -75,10 +78,41 @@ the region 0:00:00."
75 (- 78 (-
76 (time-to-seconds (current-time)) 79 (time-to-seconds (current-time))
77 (org-timer-hms-to-secs s))))) 80 (org-timer-hms-to-secs s)))))
81 (org-timer-set-mode-line 'on)
78 (message "Timer start time set to %s, current value is %s" 82 (message "Timer start time set to %s, current value is %s"
79 (format-time-string "%T" org-timer-start-time) 83 (format-time-string "%T" org-timer-start-time)
80 (org-timer-secs-to-hms (or delta 0)))))) 84 (org-timer-secs-to-hms (or delta 0))))))
81 85
86(defun org-timer-pause-or-continue (&optional stop)
87 "Pause or continue the relative timer. With prefix arg, stop it entirely."
88 (interactive "P")
89 (cond
90 (stop (org-timer-stop))
91 ((not org-timer-start-time) (error "No timer is running"))
92 (org-timer-pause-time
93 ;; timer is paused, continue
94 (setq org-timer-start-time
95 (seconds-to-time
96 (-
97 (time-to-seconds (current-time))
98 (- (time-to-seconds org-timer-pause-time)
99 (time-to-seconds org-timer-start-time))))
100 org-timer-pause-time nil)
101 (org-timer-set-mode-line 'on)
102 (message "Timer continues at %s" (org-timer-value-string)))
103 (t
104 ;; pause timer
105 (setq org-timer-pause-time (current-time))
106 (org-timer-set-mode-line 'pause)
107 (message "Timer paused at %s" (org-timer-value-string)))))
108
109(defun org-timer-stop ()
110 "Stop the relative timer."
111 (interactive)
112 (setq org-timer-start-time nil
113 org-timer-pause-time nil)
114 (org-timer-set-mode-line 'off))
115
82;;;###autoload 116;;;###autoload
83(defun org-timer (&optional restart) 117(defun org-timer (&optional restart)
84 "Insert a H:MM:SS string from the timer into the buffer. 118 "Insert a H:MM:SS string from the timer into the buffer.
@@ -90,12 +124,14 @@ that was not started at the correct moment."
90 (interactive "P") 124 (interactive "P")
91 (if (equal restart '(4)) (org-timer-start)) 125 (if (equal restart '(4)) (org-timer-start))
92 (or org-timer-start-time (org-timer-start)) 126 (or org-timer-start-time (org-timer-start))
93 (insert (format 127 (insert (org-timer-value-string)))
94 org-timer-format 128
95 (org-timer-secs-to-hms 129(defun org-timer-value-string ()
96 (floor 130 (format org-timer-format (org-timer-secs-to-hms (floor (org-timer-seconds)))))
97 (- (time-to-seconds (current-time)) 131
98 (time-to-seconds org-timer-start-time))))))) 132(defun org-timer-seconds ()
133 (- (time-to-seconds (or org-timer-pause-time (current-time)))
134 (time-to-seconds org-timer-start-time)))
99 135
100;;;###autoload 136;;;###autoload
101(defun org-timer-change-times-in-region (beg end delta) 137(defun org-timer-change-times-in-region (beg end delta)
@@ -176,6 +212,47 @@ If the integer is negative, the string will start with \"-\"."
176 h (/ m 60) m (- m (* 60 h))) 212 h (/ m 60) m (- m (* 60 h)))
177 (format "%s%d:%02d:%02d" sign h m s))) 213 (format "%s%d:%02d:%02d" sign h m s)))
178 214
215(defvar org-timer-mode-line-timer nil)
216(defvar org-timer-mode-line-string nil)
217
218(defun org-timer-set-mode-line (value)
219 "Set the mode-line dispay of the relative timer.
220VALUE can be `on', `off', or `pause'."
221 (or global-mode-string (setq global-mode-string '("")))
222 (or (memq 'org-timer-mode-line-string global-mode-string)
223 (setq global-mode-string
224 (append global-mode-string '(org-timer-mode-line-string))))
225 (cond
226 ((equal value 'off)
227 (when org-timer-mode-line-timer
228 (cancel-timer org-timer-mode-line-timer)
229 (setq org-timer-mode-line-timer nil))
230 (setq global-mode-string
231 (delq 'org-timer-mode-line-string global-mode-string))
232 (force-mode-line-update))
233 ((equal value 'pause)
234 (when org-timer-mode-line-timer
235 (cancel-timer org-timer-mode-line-timer)
236 (setq org-timer-mode-line-timer nil)))
237 ((equal value 'on)
238 (or global-mode-string (setq global-mode-string '("")))
239 (or (memq 'org-timer-mode-line-string global-mode-string)
240 (setq global-mode-string
241 (append global-mode-string '(org-timer-mode-line-string))))
242 (org-timer-update-mode-line)
243 (when org-timer-mode-line-timer
244 (cancel-timer org-timer-mode-line-timer))
245 (setq org-timer-mode-line-timer
246 (run-with-timer 1 1 'org-timer-update-mode-line)))))
247
248(defun org-timer-update-mode-line ()
249 "Update the timer time in the mode line."
250 (if org-timer-pause-time
251 nil
252 (setq org-timer-mode-line-string
253 (concat " <" (substring (org-timer-value-string) 0 -1) ">"))
254 (force-mode-line-update)))
255
179;; arch-tag: 97538f8c-3871-4509-8f23-1e7b3ff3d107 256;; arch-tag: 97538f8c-3871-4509-8f23-1e7b3ff3d107
180 257
181;;; org-timer.el ends here 258;;; org-timer.el ends here
diff --git a/lisp/org/org-vm.el b/lisp/org/org-vm.el
index fb94b0f22b9..24af56b2321 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.16 8;; Version: 6.19a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
diff --git a/lisp/org/org-w3m.el b/lisp/org/org-w3m.el
index 5486ad86ac3..f1d2350b0ba 100644
--- a/lisp/org/org-w3m.el
+++ b/lisp/org/org-w3m.el
@@ -5,7 +5,7 @@
5;; Author: Andy Stewart <lazycat dot manatee at gmail dot com> 5;; Author: Andy Stewart <lazycat dot manatee at gmail dot com>
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.16 8;; Version: 6.19a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
@@ -49,93 +49,97 @@ This will encode `link-title' and `link-location' with
49`org-make-link-string', and insert the transformed test into the kill ring, 49`org-make-link-string', and insert the transformed test into the kill ring,
50so that it can be yanked into an Org-mode buffer with links working correctly." 50so that it can be yanked into an Org-mode buffer with links working correctly."
51 (interactive) 51 (interactive)
52 (let ((regionp (org-region-active-p)) 52 (let* ((regionp (org-region-active-p))
53 transform-start transform-end 53 (transform-start (point-min))
54 return-content 54 (transform-end (point-max))
55 link-location link-title 55 return-content
56 temp-position out-bound) 56 link-location link-title
57 (setq transform-start (if regionp (region-beginning) (point-min)) 57 temp-position out-bound)
58 transform-end (if regionp (region-end) (point-max))) 58 (when regionp
59 (setq transform-start (region-beginning))
60 (setq transform-end (region-end))
61 ;; Deactivate mark if current mark is activate.
62 (if (fboundp 'deactivate-mark) (deactivate-mark)))
59 (message "Transforming links...") 63 (message "Transforming links...")
60 (save-excursion 64 (save-excursion
61 (goto-char transform-start) 65 (goto-char transform-start)
62 (while (and (not out-bound) ; still inside region to copy 66 (while (and (not out-bound) ; still inside region to copy
63 (not (org-w3m-no-next-link-p))) ; no next link current buffer 67 (not (org-w3m-no-next-link-p))) ; no next link current buffer
64 ;; store current point before jump next anchor 68 ;; store current point before jump next anchor
65 (setq temp-position (point)) 69 (setq temp-position (point))
66 ;; move to next anchor when current point is not at anchor 70 ;; move to next anchor when current point is not at anchor
67 (or (w3m-anchor (point)) (org-w3m-get-next-link-start)) 71 (or (w3m-anchor (point)) (org-w3m-get-next-link-start))
68 (if (<= (point) transform-end) ; if point is inside transform bound 72 (if (<= (point) transform-end) ; if point is inside transform bound
69 (progn 73 (progn
70 ;; get content between two links. 74 ;; get content between two links.
71 (if (> (point) temp-position) 75 (if (> (point) temp-position)
72 (setq return-content (concat return-content 76 (setq return-content (concat return-content
73 (buffer-substring 77 (buffer-substring
74 temp-position (point))))) 78 temp-position (point)))))
75 ;; get link location at current point. 79 ;; get link location at current point.
76 (setq link-location (w3m-anchor (point))) 80 (setq link-location (w3m-anchor (point)))
77 ;; get link title at current point. 81 ;; get link title at current point.
78 (setq link-title (buffer-substring (point) 82 (setq link-title (buffer-substring (point)
79 (org-w3m-get-anchor-end))) 83 (org-w3m-get-anchor-end)))
80 ;; concat `org-mode' style url to `return-content'. 84 ;; concat `org-mode' style url to `return-content'.
81 (setq return-content (concat return-content 85 (setq return-content (concat return-content
82 (org-make-link-string 86 (org-make-link-string
83 link-location link-title)))) 87 link-location link-title))))
84 (goto-char temp-position) ; reset point before jump next anchor 88 (goto-char temp-position) ; reset point before jump next anchor
85 (setq out-bound t) ; for break out `while' loop 89 (setq out-bound t) ; for break out `while' loop
86 )) 90 ))
87 ;; add the rest until end of the region to be copied 91 ;; add the rest until end of the region to be copied
88 (if (< (point) transform-end) 92 (if (< (point) transform-end)
89 (setq return-content 93 (setq return-content
90 (concat return-content 94 (concat return-content
91 (buffer-substring (point) transform-end)))) 95 (buffer-substring (point) transform-end))))
92 (kill-new return-content) 96 (kill-new return-content)
93 (message "Transforming links...done, use C-y to insert text into Org-mode file") 97 (message "Transforming links...done, use C-y to insert text into Org-mode file")
94 (message "Copy with link transformation complete.")))) 98 (message "Copy with link transformation complete."))))
95 99
96(defun org-w3m-get-anchor-start () 100(defun org-w3m-get-anchor-start ()
97 "Move to and return `point' for the start of the current anchor." 101 "Move cursor to the start of current anchor. Return point."
98 ;; get start position of anchor or current point 102 ;; get start position of anchor or current point
99 (goto-char (or (previous-single-property-change (point) 'w3m-anchor-sequence) 103 (goto-char (or (previous-single-property-change (point) 'w3m-anchor-sequence)
100 (point)))) 104 (point))))
101 105
102(defun org-w3m-get-anchor-end () 106(defun org-w3m-get-anchor-end ()
103 "Move and return `point' after the end of current anchor." 107 "Move cursor to the end of current anchor. Return point."
104 ;; get end position of anchor or point 108 ;; get end position of anchor or point
105 (goto-char (or (next-single-property-change (point) 'w3m-anchor-sequence) 109 (goto-char (or (next-single-property-change (point) 'w3m-anchor-sequence)
106 (point)))) 110 (point))))
107 111
108(defun org-w3m-get-next-link-start () 112(defun org-w3m-get-next-link-start ()
109 "Move and return `point' for that start of the current link." 113 "Move cursor to the start of next link. Return point."
110 (catch 'reach 114 (catch 'reach
111 (while (next-single-property-change (point) 'w3m-anchor-sequence) 115 (while (next-single-property-change (point) 'w3m-anchor-sequence)
112 ;; jump to next anchor 116 ;; jump to next anchor
113 (goto-char (next-single-property-change (point) 'w3m-anchor-sequence)) 117 (goto-char (next-single-property-change (point) 'w3m-anchor-sequence))
114 (when (w3m-anchor (point)) 118 (when (w3m-anchor (point))
115 ;; return point when current is valid link 119 ;; return point when current is valid link
116 (throw 'reach nil)))) 120 (throw 'reach nil))))
117 (point)) 121 (point))
118 122
119(defun org-w3m-get-prev-link-start () 123(defun org-w3m-get-prev-link-start ()
120 "Move and return `point' for that end of the current link." 124 "Move cursor to the start of prevoius link. Return point."
121 (catch 'reach 125 (catch 'reach
122 (while (previous-single-property-change (point) 'w3m-anchor-sequence) 126 (while (previous-single-property-change (point) 'w3m-anchor-sequence)
123 ;; jump to previous anchor 127 ;; jump to previous anchor
124 (goto-char (previous-single-property-change (point) 'w3m-anchor-sequence)) 128 (goto-char (previous-single-property-change (point) 'w3m-anchor-sequence))
125 (when (w3m-anchor (point)) 129 (when (w3m-anchor (point))
126 ;; return point when current is valid link 130 ;; return point when current is valid link
127 (throw 'reach nil)))) 131 (throw 'reach nil))))
128 (point)) 132 (point))
129 133
130(defun org-w3m-no-next-link-p () 134(defun org-w3m-no-next-link-p ()
131 "Return t if no next link after cursor. 135 "Whether there is no next link after the cursor.
132Otherwise, return nil." 136Return t if there is no next link; otherwise, return nil."
133 (save-excursion 137 (save-excursion
134 (equal (point) (org-w3m-get-next-link-start)))) 138 (equal (point) (org-w3m-get-next-link-start))))
135 139
136(defun org-w3m-no-prev-link-p () 140(defun org-w3m-no-prev-link-p ()
137 "Return t if no previous link after cursor. 141 "Whether there is no previous link after the cursor.
138Otherwise, return nil." 142Return t if there is no previous link; otherwise, return nil."
139 (save-excursion 143 (save-excursion
140 (equal (point) (org-w3m-get-prev-link-start)))) 144 (equal (point) (org-w3m-get-prev-link-start))))
141 145
@@ -143,11 +147,11 @@ Otherwise, return nil."
143(defvar w3m-mode-map) 147(defvar w3m-mode-map)
144(defvar w3m-minor-mode-map) 148(defvar w3m-minor-mode-map)
145(when (and (boundp 'w3m-mode-map) 149(when (and (boundp 'w3m-mode-map)
146 (keymapp w3m-mode-map)) 150 (keymapp w3m-mode-map))
147 (define-key w3m-mode-map "\C-c\C-x\M-w" 'org-w3m-copy-for-org-mode) 151 (define-key w3m-mode-map "\C-c\C-x\M-w" 'org-w3m-copy-for-org-mode)
148 (define-key w3m-mode-map "\C-c\C-x\C-w" 'org-w3m-copy-for-org-mode)) 152 (define-key w3m-mode-map "\C-c\C-x\C-w" 'org-w3m-copy-for-org-mode))
149(when (and (boundp 'w3m-minor-mode-map) 153(when (and (boundp 'w3m-minor-mode-map)
150 (keymapp w3m-minor-mode-map)) 154 (keymapp w3m-minor-mode-map))
151 (define-key w3m-minor-mode-map "\C-c\C-x\M-w" 'org-w3m-copy-for-org-mode) 155 (define-key w3m-minor-mode-map "\C-c\C-x\M-w" 'org-w3m-copy-for-org-mode)
152 (define-key w3m-minor-mode-map "\C-c\C-x\C-w" 'org-w3m-copy-for-org-mode)) 156 (define-key w3m-minor-mode-map "\C-c\C-x\C-w" 'org-w3m-copy-for-org-mode))
153(add-hook 157(add-hook
diff --git a/lisp/org/org-wl.el b/lisp/org/org-wl.el
index 11992dea16f..6e82fadced2 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.16 8;; Version: 6.19a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
diff --git a/lisp/org/org.el b/lisp/org/org.el
index b397a0604e8..97ba3924bd5 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.16 8;; Version: 6.19a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
@@ -87,12 +87,13 @@
87(require 'org-compat) 87(require 'org-compat)
88(require 'org-faces) 88(require 'org-faces)
89(require 'org-list) 89(require 'org-list)
90(require 'org-footnote)
90 91
91;;;; Customization variables 92;;;; Customization variables
92 93
93;;; Version 94;;; Version
94 95
95(defconst org-version "6.16" 96(defconst org-version "6.19a"
96 "The version number of the file org.el.") 97 "The version number of the file org.el.")
97 98
98(defun org-version (&optional here) 99(defun org-version (&optional here)
@@ -688,15 +689,21 @@ for the duration of the command."
688 :group 'org-structure 689 :group 'org-structure
689 :type 'boolean) 690 :type 'boolean)
690 691
691(defcustom org-blank-before-new-entry '((heading . nil) 692(defcustom org-blank-before-new-entry '((heading . auto)
692 (plain-list-item . nil)) 693 (plain-list-item . auto))
693 "Should `org-insert-heading' leave a blank line before new heading/item? 694 "Should `org-insert-heading' leave a blank line before new heading/item?
694The value is an alist, with `heading' and `plain-list-item' as car, 695The value is an alist, with `heading' and `plain-list-item' as car,
695and a boolean flag as cdr." 696and a boolean flag as cdr."
696 :group 'org-edit-structure 697 :group 'org-edit-structure
697 :type '(list 698 :type '(list
698 (cons (const heading) (boolean)) 699 (cons (const heading)
699 (cons (const plain-list-item) (boolean)))) 700 (choice (const :tag "Never" nil)
701 (const :tag "Always" t)
702 (const :tag "Auto" auto)))
703 (cons (const plain-list-item)
704 (choice (const :tag "Never" nil)
705 (const :tag "Always" t)
706 (const :tag "Auto" auto)))))
700 707
701(defcustom org-insert-heading-hook nil 708(defcustom org-insert-heading-hook nil
702 "Hook being run after inserting a new heading." 709 "Hook being run after inserting a new heading."
@@ -728,6 +735,23 @@ there are kept outside the narrowed region."
728 (const :tag "from `lang' element") 735 (const :tag "from `lang' element")
729 (const :tag "from `style' element"))))) 736 (const :tag "from `style' element")))))
730 737
738(defcustom org-coderef-label-format "(ref:%s)"
739 "The default coderef format.
740This format string will be used to search for coderef labels in literal
741examples (EXAMPLE and SRC blocks). The format can be overwritten
742an individual literal example with the -f option, like
743
744#+BEGIN_SRC pascal +n -r -l \"((%s))\"
745...
746#+END_SRC
747
748If you want to use this for HTML export, make sure that the format does
749not introduce special font-locking, and avoid the HTML special
750characters `<', `>', and `&'. The reason for this restriction is that
751the labels are searched for only after htmlize has done its job."
752 :group 'org-edit-structure ; FIXME this is not in the right group
753 :type 'string)
754
731(defcustom org-edit-fixed-width-region-mode 'artist-mode 755(defcustom org-edit-fixed-width-region-mode 'artist-mode
732 "The mode that should be used to edit fixed-width regions. 756 "The mode that should be used to edit fixed-width regions.
733These are the regions where each line starts with a colon." 757These are the regions where each line starts with a colon."
@@ -887,7 +911,7 @@ adaptive Use relative path for files in the current directory and sub-
887 (const noabbrev) 911 (const noabbrev)
888 (const adaptive))) 912 (const adaptive)))
889 913
890(defcustom org-activate-links '(bracket angle plain radio tag date) 914(defcustom org-activate-links '(bracket angle plain radio tag date footnote)
891 "Types of links that should be activated in Org-mode files. 915 "Types of links that should be activated in Org-mode files.
892This is a list of symbols, each leading to the activation of a certain link 916This is a list of symbols, each leading to the activation of a certain link
893type. In principle, it does not hurt to turn on most link types - there may 917type. In principle, it does not hurt to turn on most link types - there may
@@ -900,15 +924,18 @@ plain Plain links in normal text, no whitespace, like http://google.com.
900radio Text that is matched by a radio target, see manual for details. 924radio Text that is matched by a radio target, see manual for details.
901tag Tag settings in a headline (link to tag search). 925tag Tag settings in a headline (link to tag search).
902date Time stamps (link to calendar). 926date Time stamps (link to calendar).
927footnote Footnote labels.
903 928
904Changing this variable requires a restart of Emacs to become effective." 929Changing this variable requires a restart of Emacs to become effective."
905 :group 'org-link 930 :group 'org-link
906 :type '(set (const :tag "Double bracket links (new style)" bracket) 931 :type '(set :greedy t
932 (const :tag "Double bracket links (new style)" bracket)
907 (const :tag "Angular bracket links (old style)" angular) 933 (const :tag "Angular bracket links (old style)" angular)
908 (const :tag "Plain text links" plain) 934 (const :tag "Plain text links" plain)
909 (const :tag "Radio target matches" radio) 935 (const :tag "Radio target matches" radio)
910 (const :tag "Tags" tag) 936 (const :tag "Tags" tag)
911 (const :tag "Timestamps" date))) 937 (const :tag "Timestamps" date)
938 (const :tag "Footnotes" footnote)))
912 939
913(defcustom org-make-link-description-function nil 940(defcustom org-make-link-description-function nil
914 "Function to use to generate link descriptions from links. If 941 "Function to use to generate link descriptions from links. If
@@ -2208,7 +2235,7 @@ default is the character `k' because we use the same key in the agenda."
2208(defcustom org-format-latex-options 2235(defcustom org-format-latex-options
2209 '(:foreground default :background default :scale 1.0 2236 '(:foreground default :background default :scale 1.0
2210 :html-foreground "Black" :html-background "Transparent" :html-scale 1.0 2237 :html-foreground "Black" :html-background "Transparent" :html-scale 1.0
2211 :matchers ("begin" "$" "$$" "\\(" "\\[")) 2238 :matchers ("begin" "$1" "$" "$$" "\\(" "\\["))
2212 "Options for creating images from LaTeX fragments. 2239 "Options for creating images from LaTeX fragments.
2213This is a property list with the following properties: 2240This is a property list with the following properties:
2214:foreground the foreground color for images embedded in Emacs, e.g. \"Black\". 2241:foreground the foreground color for images embedded in Emacs, e.g. \"Black\".
@@ -2221,6 +2248,7 @@ This is a property list with the following properties:
2221:matchers a list indicating which matchers should be used to 2248:matchers a list indicating which matchers should be used to
2222 find LaTeX fragments. Valid members of this list are: 2249 find LaTeX fragments. Valid members of this list are:
2223 \"begin\" find environments 2250 \"begin\" find environments
2251 \"$1\" find single characters surrounded by $.$
2224 \"$\" find math expressions surrounded by $...$ 2252 \"$\" find math expressions surrounded by $...$
2225 \"$$\" find math expressions surrounded by $$....$$ 2253 \"$$\" find math expressions surrounded by $$....$$
2226 \"\\(\" find math expressions surrounded by \\(...\\) 2254 \"\\(\" find math expressions surrounded by \\(...\\)
@@ -2418,7 +2446,10 @@ Use customize to modify this, or restart Emacs after changing it."
2418 :group 'org) 2446 :group 'org)
2419 2447
2420(defcustom org-completion-use-ido nil 2448(defcustom org-completion-use-ido nil
2421 "Non-nil means, use ido completion wherever possible." 2449 "Non-nil means, use ido completion wherever possible.
2450Note that `ido-mode' must be active for this variable to be relevant.
2451If you decide to turn this variable on, you might well want to turn off
2452`org-outline-path-complete-in-steps'."
2422 :group 'org-completion 2453 :group 'org-completion
2423 :type 'boolean) 2454 :type 'boolean)
2424 2455
@@ -2455,6 +2486,7 @@ Normal means, no org-mode-specific context."
2455(declare-function iswitchb-read-buffer (prompt &optional default require-match start matches-set)) 2486(declare-function iswitchb-read-buffer (prompt &optional default require-match start matches-set))
2456(defvar iswitchb-temp-buflist) 2487(defvar iswitchb-temp-buflist)
2457(declare-function org-gnus-follow-link "org-gnus" (&optional group article)) 2488(declare-function org-gnus-follow-link "org-gnus" (&optional group article))
2489(defvar org-agenda-tags-todo-honor-ignore-options)
2458(declare-function org-agenda-skip "org-agenda" ()) 2490(declare-function org-agenda-skip "org-agenda" ())
2459(declare-function org-format-agenda-item "org-agenda" 2491(declare-function org-format-agenda-item "org-agenda"
2460 (extra txt &optional category tags dotime noprefix remove-re)) 2492 (extra txt &optional category tags dotime noprefix remove-re))
@@ -2466,6 +2498,9 @@ Normal means, no org-mode-specific context."
2466(declare-function org-agenda-save-markers-for-cut-and-paste "org-agenda" 2498(declare-function org-agenda-save-markers-for-cut-and-paste "org-agenda"
2467 (beg end)) 2499 (beg end))
2468(declare-function org-agenda-copy-local-variable "org-agenda" (var)) 2500(declare-function org-agenda-copy-local-variable "org-agenda" (var))
2501(declare-function org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item
2502 "org-agenda" (&optional end))
2503
2469(declare-function parse-time-string "parse-time" (string)) 2504(declare-function parse-time-string "parse-time" (string))
2470(declare-function remember "remember" (&optional initial)) 2505(declare-function remember "remember" (&optional initial))
2471(declare-function remember-buffer-desc "remember" ()) 2506(declare-function remember-buffer-desc "remember" ())
@@ -2620,7 +2655,8 @@ If TABLE-TYPE is non-nil, also check for table.el-type tables."
2620 (org-autoload "org-agenda" 2655 (org-autoload "org-agenda"
2621 '(org-agenda org-agenda-list org-search-view 2656 '(org-agenda org-agenda-list org-search-view
2622 org-todo-list org-tags-view org-agenda-list-stuck-projects 2657 org-todo-list org-tags-view org-agenda-list-stuck-projects
2623 org-diary org-agenda-to-appt))) 2658 org-diary org-agenda-to-appt
2659 org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item)))
2624 2660
2625;; Autoload org-remember 2661;; Autoload org-remember
2626 2662
@@ -2634,7 +2670,7 @@ If TABLE-TYPE is non-nil, also check for table.el-type tables."
2634 2670
2635(declare-function org-clock-save-markers-for-cut-and-paste "org-clock" 2671(declare-function org-clock-save-markers-for-cut-and-paste "org-clock"
2636 (beg end)) 2672 (beg end))
2637(declare-function org-update-mode-line "org-clock" ()) 2673(declare-function org-clock-update-mode-line "org-clock" ())
2638(defvar org-clock-start-time) 2674(defvar org-clock-start-time)
2639(defvar org-clock-marker (make-marker) 2675(defvar org-clock-marker (make-marker)
2640 "Marker recording the last clock-in.") 2676 "Marker recording the last clock-in.")
@@ -2644,7 +2680,7 @@ If TABLE-TYPE is non-nil, also check for table.el-type tables."
2644 "org-clock" 2680 "org-clock"
2645 '(org-clock-in org-clock-out org-clock-cancel 2681 '(org-clock-in org-clock-out org-clock-cancel
2646 org-clock-goto org-clock-sum org-clock-display 2682 org-clock-goto org-clock-sum org-clock-display
2647 org-remove-clock-overlays org-clock-report 2683 org-clock-remove-overlays org-clock-report
2648 org-clocktable-shift org-dblock-write:clocktable 2684 org-clocktable-shift org-dblock-write:clocktable
2649 org-get-clocktable))) 2685 org-get-clocktable)))
2650 2686
@@ -2671,7 +2707,7 @@ Otherwise, return nil."
2671 (setq org-clock-start-time 2707 (setq org-clock-start-time
2672 (apply 'encode-time 2708 (apply 'encode-time
2673 (org-parse-time-string (match-string 1)))) 2709 (org-parse-time-string (match-string 1))))
2674 (org-update-mode-line))) 2710 (org-clock-update-mode-line)))
2675 (t 2711 (t
2676 (and (match-end 4) (delete-region (match-beginning 4) (match-end 4))) 2712 (and (match-end 4) (delete-region (match-beginning 4) (match-end 4)))
2677 (end-of-line 1) 2713 (end-of-line 1)
@@ -2739,7 +2775,9 @@ Org-mode Agenda.
2739 2775
2740The archived entries will be filed as subtrees of the specified 2776The archived entries will be filed as subtrees of the specified
2741headline. When the headline is omitted, the subtrees are simply 2777headline. When the headline is omitted, the subtrees are simply
2742filed away at the end of the file, as top-level entries. 2778filed away at the end of the file, as top-level entries. Also in
2779the heading you can use %s to represent the file name, this can be
2780useful when using the same archive for a number of different files.
2743 2781
2744Here are a few examples: 2782Here are a few examples:
2745\"%s_archive::\" 2783\"%s_archive::\"
@@ -2753,6 +2791,10 @@ Here are a few examples:
2753\"~/org/archive.org::\" 2791\"~/org/archive.org::\"
2754 Archive in file ~/org/archive.org (absolute path), as top-level trees. 2792 Archive in file ~/org/archive.org (absolute path), as top-level trees.
2755 2793
2794\"~/org/archive.org::From %s\"
2795 Archive in file ~/org/archive.org (absolute path), und headlines
2796 \"From FILENAME\" where file name is the current file name.
2797
2756\"basement::** Finished Tasks\" 2798\"basement::** Finished Tasks\"
2757 Archive in file ./basement (relative path), as level 3 trees 2799 Archive in file ./basement (relative path), as level 3 trees
2758 below the level 2 heading \"** Finished Tasks\". 2800 below the level 2 heading \"** Finished Tasks\".
@@ -2989,6 +3031,13 @@ After a match, the following groups carry important information:
2989 ("logrepeat" org-log-repeat state) 3031 ("logrepeat" org-log-repeat state)
2990 ("lognoterepeat" org-log-repeat note) 3032 ("lognoterepeat" org-log-repeat note)
2991 ("nologrepeat" org-log-repeat nil) 3033 ("nologrepeat" org-log-repeat nil)
3034 ("fninline" org-footnote-define-inline t)
3035 ("nofninline" org-footnote-define-inline nil)
3036 ("fnlocal" org-footnote-section nil)
3037 ("fnauto" org-footnote-auto-label t)
3038 ("fnprompt" org-footnote-auto-label nil)
3039 ("fnconfirm" org-footnote-auto-label confirm)
3040 ("fnplain" org-footnote-auto-label plain)
2992 ("constcgs" constants-unit-system cgs) 3041 ("constcgs" constants-unit-system cgs)
2993 ("constSI" constants-unit-system SI)) 3042 ("constSI" constants-unit-system SI))
2994 "Variable associated with STARTUP options for org-mode. 3043 "Variable associated with STARTUP options for org-mode.
@@ -3202,7 +3251,7 @@ means to push this value onto the list in the variable.")
3202 (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") 3251 (mapconcat 'regexp-quote org-todo-keywords-1 "\\|")
3203 "\\)\\>\\)?[ \t]*\\(.*\\)") 3252 "\\)\\>\\)?[ \t]*\\(.*\\)")
3204 org-complex-heading-regexp 3253 org-complex-heading-regexp
3205 (concat "^\\(\\*+\\)\\(?:[ \t]+\\(" 3254 (concat "^\\(\\*+\\)[ \t]+\\(?:\\("
3206 (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") 3255 (mapconcat 'regexp-quote org-todo-keywords-1 "\\|")
3207 "\\)\\>\\)?\\(?:[ \t]*\\(\\[#.\\]\\)\\)?[ \t]*\\(.*?\\)" 3256 "\\)\\>\\)?\\(?:[ \t]*\\(\\[#.\\]\\)\\)?[ \t]*\\(.*?\\)"
3208 "\\(?:[ \t]+\\(:[[:alnum:]_@:]+:\\)\\)?[ \t]*$") 3257 "\\(?:[ \t]+\\(:[[:alnum:]_@:]+:\\)\\)?[ \t]*$")
@@ -3358,7 +3407,8 @@ This variable is set by `org-before-change-function'.
3358 "Every change indicates that a table might need an update." 3407 "Every change indicates that a table might need an update."
3359 (setq org-table-may-need-update t)) 3408 (setq org-table-may-need-update t))
3360(defvar org-mode-map) 3409(defvar org-mode-map)
3361(defvar org-mode-hook nil) 3410(defvar org-mode-hook nil
3411 "Mode hook for Org-mode, run after the mode was turned on.")
3362(defvar org-inhibit-startup nil) ; Dynamically-scoped param. 3412(defvar org-inhibit-startup nil) ; Dynamically-scoped param.
3363(defvar org-agenda-keep-modes nil) ; Dynamically-scoped param. 3413(defvar org-agenda-keep-modes nil) ; Dynamically-scoped param.
3364(defvar org-table-buffer-is-an nil) 3414(defvar org-table-buffer-is-an nil)
@@ -3534,6 +3584,8 @@ Here is what the match groups contain after a match:
35343: path 35843: path
35354: [desc] 35854: [desc]
35365: desc") 35865: desc")
3587(defvar org-bracket-link-analytic-regexp++ nil
3588 "Like org-bracket-link-analytic-regexp, but include coderef internal type.")
3537(defvar org-any-link-re nil 3589(defvar org-any-link-re nil
3538 "Regular expression matching any link.") 3590 "Regular expression matching any link.")
3539 3591
@@ -3580,6 +3632,14 @@ This should be called after the variable `org-link-types' has changed."
3580 "\\]" 3632 "\\]"
3581 "\\(\\[" "\\([^]]+\\)" "\\]\\)?" 3633 "\\(\\[" "\\([^]]+\\)" "\\]\\)?"
3582 "\\]") 3634 "\\]")
3635 org-bracket-link-analytic-regexp++
3636 (concat
3637 "\\[\\["
3638 "\\(\\(" (mapconcat 'identity (cons "coderef" org-link-types) "\\|") "\\):\\)?"
3639 "\\([^]]+\\)"
3640 "\\]"
3641 "\\(\\[" "\\([^]]+\\)" "\\]\\)?"
3642 "\\]")
3583 org-any-link-re 3643 org-any-link-re
3584 (concat "\\(" org-bracket-link-regexp "\\)\\|\\(" 3644 (concat "\\(" org-bracket-link-regexp "\\)\\|\\("
3585 org-angle-link-re "\\)\\|\\(" 3645 org-angle-link-re "\\)\\|\\("
@@ -3728,6 +3788,22 @@ will be prompted for."
3728 )) 3788 ))
3729 t))) 3789 t)))
3730 3790
3791(defun org-activate-footnote-links (limit)
3792 "Run through the buffer and add overlays to links."
3793 (if (re-search-forward "\\(^\\|[^][]\\)\\(\\[\\([0-9]+\\]\\|fn:[^ \t\r\n:]+?[]:]\\)\\)"
3794 limit t)
3795 (progn
3796 (add-text-properties (match-beginning 2) (match-end 2)
3797 (list 'mouse-face 'highlight
3798 'rear-nonsticky org-nonsticky-props
3799 'keymap org-mouse-map
3800 'help-echo
3801 (if (= (point-at-bol) (match-beginning 2))
3802 "Footnote definition"
3803 "Footnote reference")
3804 ))
3805 t)))
3806
3731(defun org-activate-bracket-links (limit) 3807(defun org-activate-bracket-links (limit)
3732 "Run through the buffer and add overlays to bracketed links." 3808 "Run through the buffer and add overlays to bracketed links."
3733 (if (re-search-forward org-bracket-link-regexp limit t) 3809 (if (re-search-forward org-bracket-link-regexp limit t)
@@ -3982,6 +4058,8 @@ between words."
3982 (if (memq 'bracket lk) '(org-activate-bracket-links (0 'org-link t))) 4058 (if (memq 'bracket lk) '(org-activate-bracket-links (0 'org-link t)))
3983 (if (memq 'radio lk) '(org-activate-target-links (0 'org-link t))) 4059 (if (memq 'radio lk) '(org-activate-target-links (0 'org-link t)))
3984 (if (memq 'date lk) '(org-activate-dates (0 'org-date t))) 4060 (if (memq 'date lk) '(org-activate-dates (0 'org-date t)))
4061 (if (memq 'footnote lk) '(org-activate-footnote-links
4062 (2 'org-footnote t)))
3985 '("^&?%%(.*\\|<%%([^>\n]*?>" (0 'org-sexp-date t)) 4063 '("^&?%%(.*\\|<%%([^>\n]*?>" (0 'org-sexp-date t))
3986 '(org-hide-wide-columns (0 nil append)) 4064 '(org-hide-wide-columns (0 nil append))
3987 ;; TODO lines 4065 ;; TODO lines
@@ -4771,6 +4849,13 @@ frame is not changed."
4771 4849
4772;;; Inserting headlines 4850;;; Inserting headlines
4773 4851
4852(defun org-previous-line-empty-p ()
4853 (save-excursion
4854 (and (not (bobp))
4855 (or (beginning-of-line 0) t)
4856 (save-match-data
4857 (looking-at "[ \t]*$")))))
4858
4774(defun org-insert-heading (&optional force-heading) 4859(defun org-insert-heading (&optional force-heading)
4775 "Insert a new heading or item with same depth at point. 4860 "Insert a new heading or item with same depth at point.
4776If point is in a plain list and FORCE-HEADING is nil, create a new list item. 4861If point is in a plain list and FORCE-HEADING is nil, create a new list item.
@@ -4781,13 +4866,16 @@ but create the new headline after the current line."
4781 (if (= (buffer-size) 0) 4866 (if (= (buffer-size) 0)
4782 (insert "\n* ") 4867 (insert "\n* ")
4783 (when (or force-heading (not (org-insert-item))) 4868 (when (or force-heading (not (org-insert-item)))
4784 (let* ((head (save-excursion 4869 (let* ((empty-line-p nil)
4870 (head (save-excursion
4785 (condition-case nil 4871 (condition-case nil
4786 (progn 4872 (progn
4787 (org-back-to-heading) 4873 (org-back-to-heading)
4874 (setq empty-line-p (org-previous-line-empty-p))
4788 (match-string 0)) 4875 (match-string 0))
4789 (error "*")))) 4876 (error "*"))))
4790 (blank (cdr (assq 'heading org-blank-before-new-entry))) 4877 (blank-a (cdr (assq 'heading org-blank-before-new-entry)))
4878 (blank (if (eq blank-a 'auto) empty-line-p blank-a))
4791 pos hide-previous previous-pos) 4879 pos hide-previous previous-pos)
4792 (cond 4880 (cond
4793 ((and (org-on-heading-p) (bolp) 4881 ((and (org-on-heading-p) (bolp)
@@ -4820,6 +4908,8 @@ but create the new headline after the current line."
4820 (org-insert-heading-respect-content 4908 (org-insert-heading-respect-content
4821 (org-end-of-subtree nil t) 4909 (org-end-of-subtree nil t)
4822 (or (bolp) (newline)) 4910 (or (bolp) (newline))
4911 (or (org-previous-line-empty-p)
4912 (and blank (newline)))
4823 (open-line 1)) 4913 (open-line 1))
4824 ((org-on-heading-p) 4914 ((org-on-heading-p)
4825 (when hide-previous 4915 (when hide-previous
@@ -4862,6 +4952,25 @@ but create the new headline after the current line."
4862 "\\*+[ \t]+\\([^\r\n]*\\)")) 4952 "\\*+[ \t]+\\([^\r\n]*\\)"))
4863 (match-string 1) ""))) 4953 (match-string 1) "")))
4864 4954
4955(defun org-heading-components ()
4956 "Return the components of the current heading.
4957This is a list with the following elements:
4958- the level as an integer
4959- the reduced level, different if `org-odd-levels-only' is set.
4960- the TODO keyword, or nil
4961- the priority character, like ?A, or nil if no priority is given
4962- the headline text itself, or the tags string if no headline text
4963- the tags string, or nil."
4964 (save-excursion
4965 (org-back-to-heading t)
4966 (if (looking-at org-complex-heading-regexp)
4967 (list (length (match-string 1))
4968 (org-reduced-level (length (match-string 1)))
4969 (org-match-string-no-properties 2)
4970 (and (match-end 3) (aref (match-string 3) 2))
4971 (org-match-string-no-properties 4)
4972 (org-match-string-no-properties 5)))))
4973
4865(defun org-insert-heading-after-current () 4974(defun org-insert-heading-after-current ()
4866 "Insert a new heading with same level as current, after current subtree." 4975 "Insert a new heading with same level as current, after current subtree."
4867 (interactive) 4976 (interactive)
@@ -4970,6 +5079,8 @@ in the region."
4970 ((equal (char-after) ?\ ) (forward-char 1)))))) 5079 ((equal (char-after) ?\ ) (forward-char 1))))))
4971 5080
4972(defun org-reduced-level (l) 5081(defun org-reduced-level (l)
5082 "Compute the effective level of a heading.
5083This takes into account the setting of `org-odd-levels-only'."
4973 (if org-odd-levels-only (1+ (floor (/ l 2))) l)) 5084 (if org-odd-levels-only (1+ (floor (/ l 2))) l))
4974 5085
4975(defun org-get-valid-level (level &optional change) 5086(defun org-get-valid-level (level &optional change)
@@ -5686,13 +5797,14 @@ exit by killing the buffer with \\[org-edit-src-exit]."
5686 "Edit, then exit with C-c ' (C-c and single quote)")) 5797 "Edit, then exit with C-c ' (C-c and single quote)"))
5687 (info (org-edit-src-find-region-and-lang)) 5798 (info (org-edit-src-find-region-and-lang))
5688 (org-mode-p (eq major-mode 'org-mode)) 5799 (org-mode-p (eq major-mode 'org-mode))
5689 beg end lang lang-f single) 5800 beg end lang lang-f single lfmt)
5690 (if (not info) 5801 (if (not info)
5691 nil 5802 nil
5692 (setq beg (nth 0 info) 5803 (setq beg (nth 0 info)
5693 end (nth 1 info) 5804 end (nth 1 info)
5694 lang (nth 2 info) 5805 lang (nth 2 info)
5695 single (nth 3 info) 5806 single (nth 3 info)
5807 lfmt (nth 4 info)
5696 lang-f (intern (concat lang "-mode"))) 5808 lang-f (intern (concat lang "-mode")))
5697 (unless (functionp lang-f) 5809 (unless (functionp lang-f)
5698 (error "No such language mode: %s" lang-f)) 5810 (error "No such language mode: %s" lang-f))
@@ -5708,6 +5820,8 @@ exit by killing the buffer with \\[org-edit-src-exit]."
5708 (funcall lang-f)) 5820 (funcall lang-f))
5709 (set (make-local-variable 'org-edit-src-force-single-line) single) 5821 (set (make-local-variable 'org-edit-src-force-single-line) single)
5710 (set (make-local-variable 'org-edit-src-from-org-mode) org-mode-p) 5822 (set (make-local-variable 'org-edit-src-from-org-mode) org-mode-p)
5823 (when lfmt
5824 (set (make-local-variable 'org-coderef-label-format) lfmt))
5711 (when org-mode-p 5825 (when org-mode-p
5712 (goto-char (point-min)) 5826 (goto-char (point-min))
5713 (while (re-search-forward "^," nil t) 5827 (while (re-search-forward "^," nil t)
@@ -5798,7 +5912,7 @@ the language, a switch telling of the content should be in a single line."
5798 ("^#\\+ascii:" "\n" "ascii" single-line) 5912 ("^#\\+ascii:" "\n" "ascii" single-line)
5799 ))) 5913 )))
5800 (pos (point)) 5914 (pos (point))
5801 re re1 re2 single beg end lang) 5915 re re1 re2 single beg end lang lfmt match-re1)
5802 (catch 'exit 5916 (catch 'exit
5803 (while (setq entry (pop re-list)) 5917 (while (setq entry (pop re-list))
5804 (setq re1 (car entry) re2 (nth 1 entry) lang (nth 2 entry) 5918 (setq re1 (car entry) re2 (nth 1 entry) lang (nth 2 entry)
@@ -5807,19 +5921,27 @@ the language, a switch telling of the content should be in a single line."
5807 (if (or (looking-at re1) 5921 (if (or (looking-at re1)
5808 (re-search-backward re1 nil t)) 5922 (re-search-backward re1 nil t))
5809 (progn 5923 (progn
5810 (setq beg (match-end 0) lang (org-edit-src-get-lang lang)) 5924 (setq match-re1 (match-string 0))
5925 (setq beg (match-end 0)
5926 lang (org-edit-src-get-lang lang)
5927 lfmt (org-edit-src-get-label-format match-re1))
5811 (if (and (re-search-forward re2 nil t) 5928 (if (and (re-search-forward re2 nil t)
5812 (>= (match-end 0) pos)) 5929 (>= (match-end 0) pos))
5813 (throw 'exit (list beg (match-beginning 0) lang single)))) 5930 (throw 'exit (list beg (match-beginning 0)
5931 lang single lfmt))))
5814 (if (or (looking-at re2) 5932 (if (or (looking-at re2)
5815 (re-search-forward re2 nil t)) 5933 (re-search-forward re2 nil t))
5816 (progn 5934 (progn
5817 (setq end (match-beginning 0)) 5935 (setq end (match-beginning 0))
5818 (if (and (re-search-backward re1 nil t) 5936 (if (and (re-search-backward re1 nil t)
5819 (<= (match-beginning 0) pos)) 5937 (<= (match-beginning 0) pos))
5820 (throw 'exit 5938 (progn
5821 (list (match-end 0) end 5939 (setq lfmt (org-edit-src-get-label-format
5822 (org-edit-src-get-lang lang) single))))))))))) 5940 (match-string 0)))
5941 (throw 'exit
5942 (list (match-end 0) end
5943 (org-edit-src-get-lang lang)
5944 single lfmt))))))))))))
5823 5945
5824(defun org-edit-src-get-lang (lang) 5946(defun org-edit-src-get-lang (lang)
5825 "Extract the src language." 5947 "Extract the src language."
@@ -5835,6 +5957,12 @@ the language, a switch telling of the content should be in a single line."
5835 (match-string 1 m)) 5957 (match-string 1 m))
5836 (t "fundamental")))) 5958 (t "fundamental"))))
5837 5959
5960(defun org-edit-src-get-label-format (s)
5961 "Extract the label format."
5962 (save-match-data
5963 (if (string-match "-l[ \t]+\\\\?\"\\([^\t\r\n\"]+\\)\\\\?\"" s)
5964 (match-string 1 s))))
5965
5838(defun org-edit-src-exit () 5966(defun org-edit-src-exit ()
5839 "Exit special edit and protect problematic lines." 5967 "Exit special edit and protect problematic lines."
5840 (interactive) 5968 (interactive)
@@ -6215,6 +6343,25 @@ For file links, arg negates `org-context-in-file-links'."
6215 (setq link (plist-get org-store-link-plist :link) 6343 (setq link (plist-get org-store-link-plist :link)
6216 desc (or (plist-get org-store-link-plist :description) link))) 6344 desc (or (plist-get org-store-link-plist :description) link)))
6217 6345
6346 ((equal (buffer-name) "*Org Edit Src Example*")
6347 (let (label gc)
6348 (while (or (not label)
6349 (save-excursion
6350 (save-restriction
6351 (widen)
6352 (goto-char (point-min))
6353 (re-search-forward
6354 (regexp-quote (format org-coderef-label-format label))
6355 nil t))))
6356 (when label (message "Label exists already") (sit-for 2))
6357 (setq label (read-string "Code line label: " label)))
6358 (end-of-line 1)
6359 (setq link (format org-coderef-label-format label))
6360 (setq gc (- 79 (length link)))
6361 (if (< (current-column) gc) (org-move-to-column gc t) (insert " "))
6362 (insert link)
6363 (setq link (concat "(" label ")") desc nil)))
6364
6218 ((eq major-mode 'calendar-mode) 6365 ((eq major-mode 'calendar-mode)
6219 (let ((cd (calendar-cursor-to-date))) 6366 (let ((cd (calendar-cursor-to-date)))
6220 (setq link 6367 (setq link
@@ -6494,30 +6641,6 @@ This is the list that is used before handing over to the browser.")
6494 "Exclusive or." 6641 "Exclusive or."
6495 (if a (not b) b)) 6642 (if a (not b) b))
6496 6643
6497(defun org-get-header (header)
6498 "Find a header field in the current buffer."
6499 (save-excursion
6500 (goto-char (point-min))
6501 (let ((case-fold-search t) s)
6502 (cond
6503 ((eq header 'from)
6504 (if (re-search-forward "^From:\\s-+\\(.*\\)" nil t)
6505 (setq s (match-string 1)))
6506 (while (string-match "\"" s)
6507 (setq s (replace-match "" t t s)))
6508 (if (string-match "[<(].*" s)
6509 (setq s (replace-match "" t t s))))
6510 ((eq header 'message-id)
6511 (if (re-search-forward "^message-id:\\s-+\\(.*\\)" nil t)
6512 (setq s (match-string 1))))
6513 ((eq header 'subject)
6514 (if (re-search-forward "^subject:\\s-+\\(.*\\)" nil t)
6515 (setq s (match-string 1)))))
6516 (if (string-match "\\`[ \t\]+" s) (setq s (replace-match "" t t s)))
6517 (if (string-match "[ \t\]+\\'" s) (setq s (replace-match "" t t s)))
6518 s)))
6519
6520
6521(defun org-fixup-message-id-for-http (s) 6644(defun org-fixup-message-id-for-http (s)
6522 "Replace special characters in a message id, so it can be used in an http query." 6645 "Replace special characters in a message id, so it can be used in an http query."
6523 (while (string-match "<" s) 6646 (while (string-match "<" s)
@@ -6627,23 +6750,25 @@ used as the link location instead of reading one interactively."
6627 (reverse org-stored-links) "\n")))) 6750 (reverse org-stored-links) "\n"))))
6628 (let ((cw (selected-window))) 6751 (let ((cw (selected-window)))
6629 (select-window (get-buffer-window "*Org Links*")) 6752 (select-window (get-buffer-window "*Org Links*"))
6630 (org-fit-window-to-buffer)
6631 (setq truncate-lines t) 6753 (setq truncate-lines t)
6754 (org-fit-window-to-buffer)
6632 (select-window cw)) 6755 (select-window cw))
6633 ;; Fake a link history, containing the stored links. 6756 ;; Fake a link history, containing the stored links.
6634 (setq tmphist (append (mapcar 'car org-stored-links) 6757 (setq tmphist (append (mapcar 'car org-stored-links)
6635 org-insert-link-history)) 6758 org-insert-link-history))
6636 (unwind-protect 6759 (unwind-protect
6637 (setq link (org-completing-read 6760 (setq link
6638 "Link: " 6761 (let ((org-completion-use-ido nil))
6639 (append 6762 (org-completing-read
6640 (mapcar (lambda (x) (list (concat (car x) ":"))) 6763 "Link: "
6641 (append org-link-abbrev-alist-local org-link-abbrev-alist)) 6764 (append
6642 (mapcar (lambda (x) (list (concat x ":"))) 6765 (mapcar (lambda (x) (list (concat (car x) ":")))
6643 org-link-types)) 6766 (append org-link-abbrev-alist-local org-link-abbrev-alist))
6644 nil nil nil 6767 (mapcar (lambda (x) (list (concat x ":")))
6645 'tmphist 6768 org-link-types))
6646 (or (car (car org-stored-links))))) 6769 nil nil nil
6770 'tmphist
6771 (or (car (car org-stored-links))))))
6647 (set-window-configuration wcf) 6772 (set-window-configuration wcf)
6648 (kill-buffer "*Org Links*")) 6773 (kill-buffer "*Org Links*"))
6649 (setq entry (assoc link org-stored-links)) 6774 (setq entry (assoc link org-stored-links))
@@ -6710,6 +6835,7 @@ used as the link location instead of reading one interactively."
6710 (let ((minibuffer-local-completion-map 6835 (let ((minibuffer-local-completion-map
6711 (copy-keymap minibuffer-local-completion-map))) 6836 (copy-keymap minibuffer-local-completion-map)))
6712 (org-defkey minibuffer-local-completion-map " " 'self-insert-command) 6837 (org-defkey minibuffer-local-completion-map " " 'self-insert-command)
6838 (org-defkey minibuffer-local-completion-map "?" 'self-insert-command)
6713 (apply 'org-ido-completing-read args))) 6839 (apply 'org-ido-completing-read args)))
6714 6840
6715(defun org-ido-completing-read (&rest args) 6841(defun org-ido-completing-read (&rest args)
@@ -6873,8 +6999,11 @@ application the system uses for this file type."
6873 (move-marker org-open-link-marker (point)) 6999 (move-marker org-open-link-marker (point))
6874 (setq org-window-config-before-follow-link (current-window-configuration)) 7000 (setq org-window-config-before-follow-link (current-window-configuration))
6875 (org-remove-occur-highlights nil nil t) 7001 (org-remove-occur-highlights nil nil t)
6876 (if (org-at-timestamp-p t) 7002 (cond
6877 (org-follow-timestamp-link) 7003 ((org-at-timestamp-p t) (org-follow-timestamp-link))
7004 ((or (org-footnote-at-reference-p) (org-footnote-at-definition-p))
7005 (org-footnote-action))
7006 (t
6878 (let (type path link line search (pos (point))) 7007 (let (type path link line search (pos (point)))
6879 (catch 'match 7008 (catch 'match
6880 (save-excursion 7009 (save-excursion
@@ -7020,7 +7149,7 @@ application the system uses for this file type."
7020 (error "Abort")))) 7149 (error "Abort"))))
7021 7150
7022 (t 7151 (t
7023 (browse-url-at-point))))) 7152 (browse-url-at-point))))))
7024 (move-marker org-open-link-marker nil) 7153 (move-marker org-open-link-marker nil)
7025 (run-hook-with-args 'org-follow-link-hook)) 7154 (run-hook-with-args 'org-follow-link-hook))
7026 7155
@@ -7105,6 +7234,19 @@ in all files. If AVOID-POS is given, ignore matches near that position."
7105 pos (match-beginning 0)))) 7234 pos (match-beginning 0))))
7106 ;; There is an exact target for this 7235 ;; There is an exact target for this
7107 (goto-char pos)) 7236 (goto-char pos))
7237 ((and (string-match "^(\\(.*\\))$" s0)
7238 (save-excursion
7239 (goto-char (point-min))
7240 (and
7241 (re-search-forward
7242 (concat "[^[]" (regexp-quote
7243 (format org-coderef-label-format
7244 (match-string 1 s0))))
7245 nil t)
7246 (setq type 'dedicated
7247 pos (1+ (match-beginning 0))))))
7248 ;; There is a coderef target for this
7249 (goto-char pos))
7108 ((string-match "^/\\(.*\\)/$" s) 7250 ((string-match "^/\\(.*\\)/$" s)
7109 ;; A regular expression 7251 ;; A regular expression
7110 (cond 7252 (cond
@@ -9128,6 +9270,7 @@ this case the return value is a list of all return values from these calls.
9128MATCHER is a Lisp form to be evaluated, testing if a given set of tags 9270MATCHER is a Lisp form to be evaluated, testing if a given set of tags
9129qualifies a headline for inclusion. When TODO-ONLY is non-nil, 9271qualifies a headline for inclusion. When TODO-ONLY is non-nil,
9130only lines with a TODO keyword are included in the output." 9272only lines with a TODO keyword are included in the output."
9273 (require 'org-agenda)
9131 (let* ((re (concat "[\n\r]" outline-regexp " *\\(\\<\\(" 9274 (let* ((re (concat "[\n\r]" outline-regexp " *\\(\\<\\("
9132 (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") 9275 (mapconcat 'regexp-quote org-todo-keywords-1 "\\|")
9133 (org-re 9276 (org-re
@@ -9190,7 +9333,10 @@ only lines with a TODO keyword are included in the output."
9190 ;; selective inheritance, remove uninherited ones 9333 ;; selective inheritance, remove uninherited ones
9191 (setcdr (car tags-alist) 9334 (setcdr (car tags-alist)
9192 (org-remove-uniherited-tags (cdar tags-alist)))) 9335 (org-remove-uniherited-tags (cdar tags-alist))))
9193 (when (and (or (not todo-only) (member todo org-not-done-keywords)) 9336 (when (and (or (not todo-only)
9337 (and (member todo org-not-done-keywords)
9338 (or (not org-agenda-tags-todo-honor-ignore-options)
9339 (not (org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item)))))
9194 (let ((case-fold-search t)) (eval matcher)) 9340 (let ((case-fold-search t)) (eval matcher))
9195 (or 9341 (or
9196 (not (member org-archive-tag tags-list)) 9342 (not (member org-archive-tag tags-list))
@@ -9309,7 +9455,7 @@ also TODO lines."
9309 ;; Get a new match request, with completion 9455 ;; Get a new match request, with completion
9310 (let ((org-last-tags-completion-table 9456 (let ((org-last-tags-completion-table
9311 (org-global-tags-completion-table))) 9457 (org-global-tags-completion-table)))
9312 (setq match (org-ido-completing-read 9458 (setq match (org-completing-read
9313 "Match: " 'org-tags-completion-function nil nil nil 9459 "Match: " 'org-tags-completion-function nil nil nil
9314 'org-tags-history)))) 9460 'org-tags-history))))
9315 9461
@@ -9439,16 +9585,16 @@ also TODO lines."
9439(defun org-string>= (a b) (not (string< a b))) 9585(defun org-string>= (a b) (not (string< a b)))
9440(defun org-string> (a b) (and (not (string= a b)) (not (string< a b)))) 9586(defun org-string> (a b) (and (not (string= a b)) (not (string< a b))))
9441(defun org-string<> (a b) (not (string= a b))) 9587(defun org-string<> (a b) (not (string= a b)))
9442(defun org-time= (a b) (= (org-2ft a) (org-2ft b))) 9588(defun org-time= (a b) (setq a (org-2ft a) b (org-2ft b)) (and (> a 0) (> b 0) (= a b)))
9443(defun org-time< (a b) (< (org-2ft a) (org-2ft b))) 9589(defun org-time< (a b) (setq a (org-2ft a) b (org-2ft b)) (and (> a 0) (> b 0) (< a b)))
9444(defun org-time<= (a b) (<= (org-2ft a) (org-2ft b))) 9590(defun org-time<= (a b) (setq a (org-2ft a) b (org-2ft b)) (and (> a 0) (> b 0) (<= a b)))
9445(defun org-time> (a b) (> (org-2ft a) (org-2ft b))) 9591(defun org-time> (a b) (setq a (org-2ft a) b (org-2ft b)) (and (> a 0) (> b 0) (> a b)))
9446(defun org-time>= (a b) (>= (org-2ft a) (org-2ft b))) 9592(defun org-time>= (a b) (setq a (org-2ft a) b (org-2ft b)) (and (> a 0) (> b 0) (>= a b)))
9447(defun org-time<> (a b) (org<> (org-2ft a) (org-2ft b))) 9593(defun org-time<> (a b) (setq a (org-2ft a) b (org-2ft b)) (and (> a 0) (> b 0) (org<> a b)))
9448(defun org-2ft (s) 9594(defun org-2ft (s)
9449 "Convert S to a floating point time. 9595 "Convert S to a floating point time.
9450If S is already a number, just return it. If it is a string, parse 9596If S is already a number, just return it. If it is a string, parse
9451it as a time string and apply `float-time' to it. f S is nil, just return 0." 9597it as a time string and apply `float-time' to it. If S is nil, just return 0."
9452 (cond 9598 (cond
9453 ((numberp s) s) 9599 ((numberp s) s)
9454 ((stringp s) 9600 ((stringp s)
@@ -10030,39 +10176,41 @@ the scanner. The following items can be given here:
10030 ((eq match nil) (setq matcher t)) 10176 ((eq match nil) (setq matcher t))
10031 (t (setq matcher (if match (cdr (org-make-tags-matcher match)) t)))) 10177 (t (setq matcher (if match (cdr (org-make-tags-matcher match)) t))))
10032 10178
10033 (when (eq scope 'tree) 10179 (save-excursion
10034 (org-back-to-heading t) 10180 (save-restriction
10035 (org-narrow-to-subtree) 10181 (when (eq scope 'tree)
10036 (setq scope nil)) 10182 (org-back-to-heading t)
10183 (org-narrow-to-subtree)
10184 (setq scope nil))
10037 10185
10038 (if (not scope) 10186 (if (not scope)
10039 (progn 10187 (progn
10040 (org-prepare-agenda-buffers 10188 (org-prepare-agenda-buffers
10041 (list (buffer-file-name (current-buffer)))) 10189 (list (buffer-file-name (current-buffer))))
10042 (org-scan-tags func matcher)) 10190 (setq res (org-scan-tags func matcher)))
10043 ;; Get the right scope 10191 ;; Get the right scope
10044 (setq pos (point)) 10192 (setq pos (point))
10045 (cond 10193 (cond
10046 ((and scope (listp scope) (symbolp (car scope))) 10194 ((and scope (listp scope) (symbolp (car scope)))
10047 (setq scope (eval scope))) 10195 (setq scope (eval scope)))
10048 ((eq scope 'agenda) 10196 ((eq scope 'agenda)
10049 (setq scope (org-agenda-files t))) 10197 (setq scope (org-agenda-files t)))
10050 ((eq scope 'agenda-with-archives) 10198 ((eq scope 'agenda-with-archives)
10051 (setq scope (org-agenda-files t)) 10199 (setq scope (org-agenda-files t))
10052 (setq scope (org-add-archive-files scope))) 10200 (setq scope (org-add-archive-files scope)))
10053 ((eq scope 'file) 10201 ((eq scope 'file)
10054 (setq scope (list (buffer-file-name)))) 10202 (setq scope (list (buffer-file-name))))
10055 ((eq scope 'file-with-archives) 10203 ((eq scope 'file-with-archives)
10056 (setq scope (org-add-archive-files (list (buffer-file-name)))))) 10204 (setq scope (org-add-archive-files (list (buffer-file-name))))))
10057 (org-prepare-agenda-buffers scope) 10205 (org-prepare-agenda-buffers scope)
10058 (while (setq file (pop scope)) 10206 (while (setq file (pop scope))
10059 (with-current-buffer (org-find-base-buffer-visiting file) 10207 (with-current-buffer (org-find-base-buffer-visiting file)
10060 (save-excursion 10208 (save-excursion
10061 (save-restriction 10209 (save-restriction
10062 (widen) 10210 (widen)
10063 (goto-char (point-min)) 10211 (goto-char (point-min))
10064 (setq res (append res (org-scan-tags func matcher))))))) 10212 (setq res (append res (org-scan-tags func matcher))))))))))
10065 res))) 10213 res))
10066 10214
10067;;;; Properties 10215;;;; Properties
10068 10216
@@ -10177,7 +10325,9 @@ If WHICH is nil or `all', get all properties. If WHICH is
10177 (excluded '("TODO" "TAGS" "ALLTAGS" "PRIORITY")) 10325 (excluded '("TODO" "TAGS" "ALLTAGS" "PRIORITY"))
10178 beg end range props sum-props key value string clocksum) 10326 beg end range props sum-props key value string clocksum)
10179 (save-excursion 10327 (save-excursion
10180 (when (condition-case nil (org-back-to-heading t) (error nil)) 10328 (when (condition-case nil
10329 (and (org-mode-p) (org-back-to-heading t))
10330 (error nil))
10181 (setq beg (point)) 10331 (setq beg (point))
10182 (setq sum-props (get-text-property (point) 'org-summaries)) 10332 (setq sum-props (get-text-property (point) 'org-summaries))
10183 (setq clocksum (get-text-property (point) :org-clock-minutes)) 10333 (setq clocksum (get-text-property (point) :org-clock-minutes))
@@ -11517,7 +11667,7 @@ When SHOW-ALL is nil, only return the current occurrence of a time stamp."
11517 ;; Make the proper lists from the dates 11667 ;; Make the proper lists from the dates
11518 (catch 'exit 11668 (catch 'exit
11519 (let ((a1 '(("d" . day) ("w" . week) ("m" . month) ("y" . year))) 11669 (let ((a1 '(("d" . day) ("w" . week) ("m" . month) ("y" . year)))
11520 dn dw sday cday n1 n2 11670 dn dw sday cday n1 n2 n0
11521 d m y y1 y2 date1 date2 nmonths nm ny m2) 11671 d m y y1 y2 date1 date2 nmonths nm ny m2)
11522 11672
11523 (setq start (org-date-to-gregorian start) 11673 (setq start (org-date-to-gregorian start)
@@ -11566,6 +11716,8 @@ When SHOW-ALL is nil, only return the current occurrence of a time stamp."
11566 (setq m2 (+ m dn) y2 y) 11716 (setq m2 (+ m dn) y2 y)
11567 (if (> m2 12) (setq y2 (1+ y2) m2 (- m2 12))) 11717 (if (> m2 12) (setq y2 (1+ y2) m2 (- m2 12)))
11568 (setq n2 (calendar-absolute-from-gregorian (list m2 d y2)))))) 11718 (setq n2 (calendar-absolute-from-gregorian (list m2 d y2))))))
11719 ;; Make sure n1 is the earlier date
11720 (setq n0 n1 n1 (min n1 n2) n2 (max n0 n2))
11569 (if show-all 11721 (if show-all
11570 (cond 11722 (cond
11571 ((eq prefer 'past) n1) 11723 ((eq prefer 'past) n1)
@@ -12330,7 +12482,8 @@ The images can be removed again with \\[org-ctrl-c-ctrl-c]."
12330 '(("begin" "^[ \t]*\\(\\\\begin{\\([a-zA-Z0-9\\*]+\\)[^\000]+?\\\\end{\\2}\\)" 1 t) 12482 '(("begin" "^[ \t]*\\(\\\\begin{\\([a-zA-Z0-9\\*]+\\)[^\000]+?\\\\end{\\2}\\)" 1 t)
12331 ;; ("$" "\\([ (]\\|^\\)\\(\\(\\([$]\\)\\([^ \r\n,.$].*?\\(\n.*?\\)\\{0,5\\}[^ \r\n,.$]\\)\\4\\)\\)\\([ .,?;:'\")]\\|$\\)" 2 nil) 12483 ;; ("$" "\\([ (]\\|^\\)\\(\\(\\([$]\\)\\([^ \r\n,.$].*?\\(\n.*?\\)\\{0,5\\}[^ \r\n,.$]\\)\\4\\)\\)\\([ .,?;:'\")]\\|$\\)" 2 nil)
12332 ;; \000 in the following regex is needed for org-inside-LaTeX-fragment-p 12484 ;; \000 in the following regex is needed for org-inside-LaTeX-fragment-p
12333 ("$" "\\([^$]\\)\\(\\(\\$\\([^ \r\n,;.$][^$\n\r]*?\\(\n[^$\n\r]*?\\)\\{0,2\\}[^ \r\n,.$]\\)\\$\\)\\)\\([ .,?;:'\")\000]\\|$\\)" 2 nil) 12485 ("$1" "\\([^$]\\)\\(\\$[^ \r\n,;.$]\\$\\)\\([- .,?;:'\")\000]\\|$\\)" 2 nil)
12486 ("$" "\\([^$]\\)\\(\\(\\$\\([^ \r\n,;.$][^$\n\r]*?\\(\n[^$\n\r]*?\\)\\{0,2\\}[^ \r\n,.$]\\)\\$\\)\\)\\([- .,?;:'\")\000]\\|$\\)" 2 nil)
12334 ("\\(" "\\\\([^\000]*?\\\\)" 0 nil) 12487 ("\\(" "\\\\([^\000]*?\\\\)" 0 nil)
12335 ("\\[" "\\\\\\[[^\000]*?\\\\\\]" 0 t) 12488 ("\\[" "\\\\\\[[^\000]*?\\\\\\]" 0 t)
12336 ("$$" "\\$\\$[^\000]*?\\$\\$" 0 t)) 12489 ("$$" "\\$\\$[^\000]*?\\$\\$" 0 t))
@@ -12451,7 +12604,6 @@ The images can be removed again with \\[org-ctrl-c-ctrl-c]."
12451 "Return string to be used as color value for an RGB component." 12604 "Return string to be used as color value for an RGB component."
12452 (format "%g" (/ value 65535.0))) 12605 (format "%g" (/ value 65535.0)))
12453 12606
12454
12455;;;; Key bindings 12607;;;; Key bindings
12456 12608
12457;; Make `C-c C-x' a prefix key 12609;; Make `C-c C-x' a prefix key
@@ -12592,6 +12744,7 @@ The images can be removed again with \\[org-ctrl-c-ctrl-c]."
12592(org-defkey org-mode-map "\C-c\C-e" 'org-export) 12744(org-defkey org-mode-map "\C-c\C-e" 'org-export)
12593(org-defkey org-mode-map "\C-c:" 'org-toggle-fixed-width-section) 12745(org-defkey org-mode-map "\C-c:" 'org-toggle-fixed-width-section)
12594(org-defkey org-mode-map "\C-c\C-x\C-f" 'org-emphasize) 12746(org-defkey org-mode-map "\C-c\C-x\C-f" 'org-emphasize)
12747(org-defkey org-mode-map "\C-c\C-xf" 'org-footnote-action)
12595 12748
12596(org-defkey org-mode-map "\C-c\C-x\C-k" 'org-mark-entry-for-agenda-action) 12749(org-defkey org-mode-map "\C-c\C-x\C-k" 'org-mark-entry-for-agenda-action)
12597(org-defkey org-mode-map "\C-c\C-x\C-w" 'org-cut-special) 12750(org-defkey org-mode-map "\C-c\C-x\C-w" 'org-cut-special)
@@ -12614,6 +12767,7 @@ The images can be removed again with \\[org-ctrl-c-ctrl-c]."
12614(org-defkey org-mode-map "\C-c\C-x." 'org-timer) 12767(org-defkey org-mode-map "\C-c\C-x." 'org-timer)
12615(org-defkey org-mode-map "\C-c\C-x-" 'org-timer-item) 12768(org-defkey org-mode-map "\C-c\C-x-" 'org-timer-item)
12616(org-defkey org-mode-map "\C-c\C-x0" 'org-timer-start) 12769(org-defkey org-mode-map "\C-c\C-x0" 'org-timer-start)
12770(org-defkey org-mode-map "\C-c\C-x," 'org-timer-pause-or-continue)
12617 12771
12618(define-key org-mode-map "\C-c\C-x\C-c" 'org-columns) 12772(define-key org-mode-map "\C-c\C-x\C-c" 'org-columns)
12619 12773
@@ -13004,6 +13158,9 @@ This command does many different things, depending on context:
13004- If the cursor is on a #+TBLFM line, re-apply the formulas to 13158- If the cursor is on a #+TBLFM line, re-apply the formulas to
13005 the entire table. 13159 the entire table.
13006 13160
13161- If the cursor is at a footnote reference or definition, jump to
13162 the corresponding definition or references, respectively.
13163
13007- If the cursor is a the beginning of a dynamic block, update it. 13164- If the cursor is a the beginning of a dynamic block, update it.
13008 13165
13009- If the cursor is inside a table created by the table.el package, 13166- If the cursor is inside a table created by the table.el package,
@@ -13027,7 +13184,7 @@ This command does many different things, depending on context:
13027 ((or (and (boundp 'org-clock-overlays) org-clock-overlays) 13184 ((or (and (boundp 'org-clock-overlays) org-clock-overlays)
13028 org-occur-highlights 13185 org-occur-highlights
13029 org-latex-fragment-image-overlays) 13186 org-latex-fragment-image-overlays)
13030 (and (boundp 'org-clock-overlays) (org-remove-clock-overlays)) 13187 (and (boundp 'org-clock-overlays) (org-clock-remove-overlays))
13031 (org-remove-occur-highlights) 13188 (org-remove-occur-highlights)
13032 (org-remove-latex-fragment-image-overlays) 13189 (org-remove-latex-fragment-image-overlays)
13033 (message "Temporary highlights/overlays removed from current buffer")) 13190 (message "Temporary highlights/overlays removed from current buffer"))
@@ -13049,6 +13206,9 @@ This command does many different things, depending on context:
13049 (call-interactively 'org-table-recalculate) 13206 (call-interactively 'org-table-recalculate)
13050 (org-table-maybe-recalculate-line)) 13207 (org-table-maybe-recalculate-line))
13051 (call-interactively 'org-table-align)) 13208 (call-interactively 'org-table-align))
13209 ((or (org-footnote-at-reference-p)
13210 (org-footnote-at-definition-p))
13211 (call-interactively 'org-footnote-action))
13052 ((org-at-item-checkbox-p) 13212 ((org-at-item-checkbox-p)
13053 (call-interactively 'org-toggle-checkbox)) 13213 (call-interactively 'org-toggle-checkbox))
13054 ((org-at-item-p) 13214 ((org-at-item-p)
@@ -13115,62 +13275,47 @@ context. See the individual commands for more information."
13115 13275
13116(defun org-ctrl-c-star () 13276(defun org-ctrl-c-star ()
13117 "Compute table, or change heading status of lines. 13277 "Compute table, or change heading status of lines.
13118Calls `org-table-recalculate' or `org-toggle-region-headings', 13278Calls `org-table-recalculate' or `org-toggle-heading',
13119depending on context. This will also turn a plain list item or a normal 13279depending on context."
13120line into a subheading."
13121 (interactive) 13280 (interactive)
13122 (cond 13281 (cond
13123 ((org-at-table-p) 13282 ((org-at-table-p)
13124 (call-interactively 'org-table-recalculate)) 13283 (call-interactively 'org-table-recalculate))
13125 ((org-region-active-p) 13284 (t
13126 ;; Convert all lines in region to list items 13285 ;; Convert all lines in region to list items
13127 (call-interactively 'org-toggle-region-headings)) 13286 (call-interactively 'org-toggle-heading))))
13128 ((org-on-heading-p)
13129 (org-toggle-region-headings (point-at-bol)
13130 (min (1+ (point-at-eol)) (point-max))))
13131 ((org-at-item-p)
13132 ;; Convert to heading
13133 (let ((level (save-match-data
13134 (save-excursion
13135 (condition-case nil
13136 (progn
13137 (org-back-to-heading t)
13138 (funcall outline-level))
13139 (error 0))))))
13140 (replace-match
13141 (concat (make-string (org-get-valid-level level 1) ?*) " ") t t)))
13142 (t (org-toggle-region-headings (point-at-bol)
13143 (min (1+ (point-at-eol)) (point-max))))))
13144 13287
13145(defun org-ctrl-c-minus () 13288(defun org-ctrl-c-minus ()
13146 "Insert separator line in table or modify bullet status of line. 13289 "Insert separator line in table or modify bullet status of line.
13147Also turns a plain line or a region of lines into list items. 13290Also turns a plain line or a region of lines into list items.
13148Calls `org-table-insert-hline', `org-toggle-region-items', or 13291Calls `org-table-insert-hline', `org-toggle-item', or
13149`org-cycle-list-bullet', depending on context." 13292`org-cycle-list-bullet', depending on context."
13150 (interactive) 13293 (interactive)
13151 (cond 13294 (cond
13152 ((org-at-table-p) 13295 ((org-at-table-p)
13153 (call-interactively 'org-table-insert-hline)) 13296 (call-interactively 'org-table-insert-hline))
13154 ((org-on-heading-p)
13155 ;; Convert to item
13156 (save-excursion
13157 (beginning-of-line 1)
13158 (if (looking-at "\\*+ ")
13159 (replace-match (concat (make-string (- (match-end 0) (point) 1) ?\ ) "- ")))))
13160 ((org-region-active-p) 13297 ((org-region-active-p)
13161 ;; Convert all lines in region to list items 13298 (call-interactively 'org-toggle-item))
13162 (call-interactively 'org-toggle-region-items))
13163 ((org-in-item-p) 13299 ((org-in-item-p)
13164 (call-interactively 'org-cycle-list-bullet)) 13300 (call-interactively 'org-cycle-list-bullet))
13165 (t (org-toggle-region-items (point-at-bol) 13301 (t
13166 (min (1+ (point-at-eol)) (point-max)))))) 13302 (call-interactively 'org-toggle-item))))
13167 13303
13168(defun org-toggle-region-items (beg end) 13304(defun org-toggle-item ()
13169 "Convert all lines in region to list items. 13305 "Convert headings or normal lines to items, items to normal lines.
13170If the first line is already an item, convert all list items in the region 13306If there is no active region, only the current line is considered.
13171to normal lines." 13307
13172 (interactive "r") 13308If the first line in the region is a headline, convert all headlines to items.
13173 (let (l2 l) 13309
13310If the first line in the region is an item, convert all items to normal lines.
13311
13312If the first line is normal text, add an item bullet to each line."
13313 (interactive)
13314 (let (l2 l beg end)
13315 (if (org-region-active-p)
13316 (setq beg (region-beginning) end (region-end))
13317 (setq beg (point-at-bol)
13318 end (min (1+ (point-at-eol)) (point-max))))
13174 (save-excursion 13319 (save-excursion
13175 (goto-char end) 13320 (goto-char end)
13176 (setq l2 (org-current-line)) 13321 (setq l2 (org-current-line))
@@ -13185,18 +13330,41 @@ to normal lines."
13185 (delete-region (match-beginning 2) (match-end 2)) 13330 (delete-region (match-beginning 2) (match-end 2))
13186 (and (looking-at "[ \t]+") (replace-match ""))) 13331 (and (looking-at "[ \t]+") (replace-match "")))
13187 (beginning-of-line 2)) 13332 (beginning-of-line 2))
13188 (while (< (setq l (1+ l)) l2) 13333 (if (org-on-heading-p)
13189 (unless (org-at-item-p) 13334 ;; Headings, convert to items
13190 (if (looking-at "\\([ \t]*\\)\\(\\S-\\)") 13335 (while (< (setq l (1+ l)) l2)
13191 (replace-match "\\1- \\2"))) 13336 (if (looking-at org-outline-regexp)
13192 (beginning-of-line 2)))))) 13337 (replace-match "- " t t))
13193 13338 (beginning-of-line 2))
13194(defun org-toggle-region-headings (beg end) 13339 ;; normal lines, turn them into items
13195 "Convert all lines in region to list items. 13340 (while (< (setq l (1+ l)) l2)
13196If the first line is already an item, convert all list items in the region 13341 (unless (org-at-item-p)
13197to normal lines." 13342 (if (looking-at "\\([ \t]*\\)\\(\\S-\\)")
13198 (interactive "r") 13343 (replace-match "\\1- \\2")))
13199 (let (l2 l) 13344 (beginning-of-line 2)))))))
13345
13346(defun org-toggle-heading (&optional nstars)
13347 "Convert headings to normal text, or items or text to headings.
13348If there is no active region, only the current line is considered.
13349
13350If the first line is a heading, remove the stars from all headlines
13351in the region.
13352
13353If the first line is a plain list item, turn all plain list items into
13354headings.
13355
13356If the first line is a normal line, turn each and every line in the region
13357into a heading.
13358
13359When converting a line into a heading, the number of stars is chosen
13360such that the lines become children of the current entry. However, when
13361a prefix argument is given, its value determines the number of stars to add."
13362 (interactive "P")
13363 (let (l2 l itemp beg end)
13364 (if (org-region-active-p)
13365 (setq beg (region-beginning) end (region-end))
13366 (setq beg (point-at-bol)
13367 end (min (1+ (point-at-eol)) (point-max))))
13200 (save-excursion 13368 (save-excursion
13201 (goto-char end) 13369 (goto-char end)
13202 (setq l2 (org-current-line)) 13370 (setq l2 (org-current-line))
@@ -13209,15 +13377,22 @@ to normal lines."
13209 (when (org-on-heading-p t) 13377 (when (org-on-heading-p t)
13210 (and (looking-at outline-regexp) (replace-match ""))) 13378 (and (looking-at outline-regexp) (replace-match "")))
13211 (beginning-of-line 2)) 13379 (beginning-of-line 2))
13212 (let* ((stars (save-excursion 13380 (setq itemp (org-at-item-p))
13213 (re-search-backward org-complex-heading-regexp nil t) 13381 (let* ((stars
13214 (or (match-string 1) "*"))) 13382 (if nstars
13215 (add-stars (if org-odd-levels-only "**" "*")) 13383 (make-string (prefix-numeric-value current-prefix-arg)
13216 (rpl (concat stars add-stars " \\2"))) 13384 ?*)
13385 (save-excursion
13386 (re-search-backward org-complex-heading-regexp nil t)
13387 (or (match-string 1) "*"))))
13388 (add-stars (if nstars "" (if org-odd-levels-only "**" "*")))
13389 (rpl (concat stars add-stars " ")))
13217 (while (< (setq l (1+ l)) l2) 13390 (while (< (setq l (1+ l)) l2)
13218 (unless (org-on-heading-p) 13391 (if itemp
13219 (if (looking-at "\\([ \t]*\\)\\(\\S-\\)") 13392 (and (org-at-item-p) (replace-match rpl t t))
13220 (replace-match rpl))) 13393 (unless (org-on-heading-p)
13394 (if (looking-at "\\([ \t]*\\)\\(\\S-\\)")
13395 (replace-match (concat rpl (match-string 2))))))
13221 (beginning-of-line 2))))))) 13396 (beginning-of-line 2)))))))
13222 13397
13223(defun org-meta-return (&optional arg) 13398(defun org-meta-return (&optional arg)
@@ -13332,7 +13507,10 @@ See the individual commands for more information."
13332 ["Convert to odd/even levels" org-convert-to-oddeven-levels t]) 13507 ["Convert to odd/even levels" org-convert-to-oddeven-levels t])
13333 ("Editing" 13508 ("Editing"
13334 ["Emphasis..." org-emphasize t] 13509 ["Emphasis..." org-emphasize t]
13335 ["Edit Source Example" org-edit-special t]) 13510 ["Edit Source Example" org-edit-special t]
13511 "--"
13512 ["Footnote new/jump" org-footnote-action t]
13513 ["Footnote extra" (org-footnote-action t) :active t :keys "C-u C-c C-x f"])
13336 ("Archive" 13514 ("Archive"
13337 ["Toggle ARCHIVE tag" org-toggle-archive-tag t] 13515 ["Toggle ARCHIVE tag" org-toggle-archive-tag t]
13338; ["Check and Tag Children" (org-toggle-archive-tag (4)) 13516; ["Check and Tag Children" (org-toggle-archive-tag (4))
@@ -13390,9 +13568,11 @@ See the individual commands for more information."
13390 ["Goto Calendar" org-goto-calendar t] 13568 ["Goto Calendar" org-goto-calendar t]
13391 ["Date from Calendar" org-date-from-calendar t] 13569 ["Date from Calendar" org-date-from-calendar t]
13392 "--" 13570 "--"
13393 ["Start/restart timer" org-timer-start t] 13571 ["Start/Restart Timer" org-timer-start t]
13394 ["Insert timer string" org-timer t] 13572 ["Pause/Continue Timer" org-timer-pause-or-continue t]
13395 ["Insert timer item" org-timer-item t]) 13573 ["Stop Timer" org-timer-pause-or-continue :active t :keys "C-u C-c C-x ,"]
13574 ["Insert Timer String" org-timer t]
13575 ["Insert Timer Item" org-timer-item t])
13396 ("Logging work" 13576 ("Logging work"
13397 ["Clock in" org-clock-in t] 13577 ["Clock in" org-clock-in t]
13398 ["Clock out" org-clock-out t] 13578 ["Clock out" org-clock-out t]
@@ -13560,7 +13740,8 @@ With optional NODE, go directly to that node."
13560 (switch-to-buffer (marker-buffer marker)) 13740 (switch-to-buffer (marker-buffer marker))
13561 (if (or (> marker (point-max)) (< marker (point-min))) 13741 (if (or (> marker (point-max)) (< marker (point-min)))
13562 (widen)) 13742 (widen))
13563 (goto-char marker)) 13743 (goto-char marker)
13744 (org-show-context 'org-goto))
13564 (if bookmark 13745 (if bookmark
13565 (bookmark-jump bookmark) 13746 (bookmark-jump bookmark)
13566 (error "Cannot find location")))) 13747 (error "Cannot find location"))))
@@ -14006,13 +14187,15 @@ not an indirect buffer."
14006 (or (buffer-base-buffer buf) buf) 14187 (or (buffer-base-buffer buf) buf)
14007 nil))) 14188 nil)))
14008 14189
14009(defun org-image-file-name-regexp () 14190(defun org-image-file-name-regexp (&optional extensions)
14010 "Return regexp matching the file names of images." 14191 "Return regexp matching the file names of images.
14011 (if (fboundp 'image-file-name-regexp) 14192If EXTENSIONS is given, only match these."
14193 (if (and (not extensions) (fboundp 'image-file-name-regexp))
14012 (image-file-name-regexp) 14194 (image-file-name-regexp)
14013 (let ((image-file-name-extensions 14195 (let ((image-file-name-extensions
14014 '("png" "jpeg" "jpg" "gif" "tiff" "tif" 14196 (or extensions
14015 "xbm" "xpm" "pbm" "pgm" "ppm"))) 14197 '("png" "jpeg" "jpg" "gif" "tiff" "tif"
14198 "xbm" "xpm" "pbm" "pgm" "ppm"))))
14016 (concat "\\." 14199 (concat "\\."
14017 (regexp-opt (nconc (mapcar 'upcase 14200 (regexp-opt (nconc (mapcar 'upcase
14018 image-file-name-extensions) 14201 image-file-name-extensions)
@@ -14020,10 +14203,10 @@ not an indirect buffer."
14020 t) 14203 t)
14021 "\\'")))) 14204 "\\'"))))
14022 14205
14023(defun org-file-image-p (file) 14206(defun org-file-image-p (file &optional extensions)
14024 "Return non-nil if FILE is an image." 14207 "Return non-nil if FILE is an image."
14025 (save-match-data 14208 (save-match-data
14026 (string-match (org-image-file-name-regexp) file))) 14209 (string-match (org-image-file-name-regexp extensions) file)))
14027 14210
14028(defun org-get-cursor-date () 14211(defun org-get-cursor-date ()
14029 "Return the date at cursor in as a time. 14212 "Return the date at cursor in as a time.