aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/org
diff options
context:
space:
mode:
authorStefan Monnier2010-12-12 23:11:49 -0500
committerStefan Monnier2010-12-12 23:11:49 -0500
commit7a600d54c026061eee6db4e499802f524e7ebe00 (patch)
tree684aa988f06de977a52027ee5e1262c37f7678eb /lisp/org
parentf07a954eeb0930029104402e706165bf89853576 (diff)
parentfdbb4d85ffa2ac30cb7ac0ceea6f12d0c8054d6c (diff)
downloademacs-7a600d54c026061eee6db4e499802f524e7ebe00.tar.gz
emacs-7a600d54c026061eee6db4e499802f524e7ebe00.zip
Merge from trunk
Diffstat (limited to 'lisp/org')
-rw-r--r--lisp/org/ChangeLog681
-rw-r--r--lisp/org/ob-C.el2
-rw-r--r--lisp/org/ob-R.el27
-rw-r--r--lisp/org/ob-asymptote.el2
-rw-r--r--lisp/org/ob-calc.el70
-rw-r--r--lisp/org/ob-clojure.el302
-rw-r--r--lisp/org/ob-comint.el2
-rw-r--r--lisp/org/ob-css.el2
-rw-r--r--lisp/org/ob-ditaa.el2
-rw-r--r--lisp/org/ob-dot.el2
-rw-r--r--lisp/org/ob-emacs-lisp.el4
-rw-r--r--lisp/org/ob-eval.el22
-rw-r--r--lisp/org/ob-exp.el6
-rw-r--r--lisp/org/ob-gnuplot.el2
-rw-r--r--lisp/org/ob-haskell.el13
-rw-r--r--lisp/org/ob-js.el24
-rw-r--r--lisp/org/ob-keys.el2
-rw-r--r--lisp/org/ob-latex.el2
-rw-r--r--lisp/org/ob-ledger.el2
-rw-r--r--lisp/org/ob-lisp.el37
-rw-r--r--lisp/org/ob-lob.el23
-rw-r--r--lisp/org/ob-matlab.el2
-rw-r--r--lisp/org/ob-mscgen.el2
-rw-r--r--lisp/org/ob-ocaml.el2
-rw-r--r--lisp/org/ob-octave.el2
-rw-r--r--lisp/org/ob-org.el2
-rw-r--r--lisp/org/ob-perl.el7
-rw-r--r--lisp/org/ob-plantuml.el2
-rw-r--r--lisp/org/ob-python.el65
-rw-r--r--lisp/org/ob-ref.el56
-rw-r--r--lisp/org/ob-ruby.el19
-rw-r--r--lisp/org/ob-sass.el2
-rw-r--r--lisp/org/ob-scheme.el24
-rw-r--r--lisp/org/ob-screen.el4
-rw-r--r--lisp/org/ob-sh.el15
-rw-r--r--lisp/org/ob-sql.el38
-rw-r--r--lisp/org/ob-sqlite.el19
-rw-r--r--lisp/org/ob-table.el8
-rw-r--r--lisp/org/ob-tangle.el3
-rw-r--r--lisp/org/ob.el356
-rw-r--r--lisp/org/org-agenda.el561
-rw-r--r--lisp/org/org-archive.el2
-rw-r--r--lisp/org/org-ascii.el2
-rw-r--r--lisp/org/org-attach.el2
-rw-r--r--lisp/org/org-bbdb.el2
-rw-r--r--lisp/org/org-beamer.el8
-rw-r--r--lisp/org/org-bibtex.el2
-rw-r--r--lisp/org/org-capture.el61
-rw-r--r--lisp/org/org-clock.el845
-rw-r--r--lisp/org/org-colview.el2
-rw-r--r--lisp/org/org-compat.el22
-rw-r--r--lisp/org/org-complete.el279
-rw-r--r--lisp/org/org-crypt.el2
-rw-r--r--lisp/org/org-ctags.el4
-rw-r--r--lisp/org/org-datetree.el2
-rw-r--r--lisp/org/org-docbook.el2
-rw-r--r--lisp/org/org-docview.el2
-rw-r--r--lisp/org/org-entities.el2
-rw-r--r--lisp/org/org-exp-blocks.el5
-rw-r--r--lisp/org/org-exp.el52
-rw-r--r--lisp/org/org-faces.el11
-rw-r--r--lisp/org/org-feed.el2
-rw-r--r--lisp/org/org-footnote.el4
-rw-r--r--lisp/org/org-freemind.el2
-rw-r--r--lisp/org/org-gnus.el2
-rw-r--r--lisp/org/org-habit.el7
-rw-r--r--lisp/org/org-html.el16
-rw-r--r--lisp/org/org-icalendar.el2
-rw-r--r--lisp/org/org-id.el23
-rw-r--r--lisp/org/org-indent.el88
-rw-r--r--lisp/org/org-info.el2
-rw-r--r--lisp/org/org-inlinetask.el182
-rw-r--r--lisp/org/org-irc.el2
-rw-r--r--lisp/org/org-jsinfo.el2
-rw-r--r--lisp/org/org-latex.el61
-rw-r--r--lisp/org/org-list.el85
-rw-r--r--lisp/org/org-mac-message.el2
-rw-r--r--lisp/org/org-macs.el11
-rw-r--r--lisp/org/org-mew.el2
-rw-r--r--lisp/org/org-mhe.el2
-rw-r--r--lisp/org/org-mks.el2
-rw-r--r--lisp/org/org-mobile.el2
-rw-r--r--lisp/org/org-mouse.el9
-rw-r--r--lisp/org/org-plot.el2
-rw-r--r--lisp/org/org-protocol.el4
-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-src.el6
-rw-r--r--lisp/org/org-table.el16
-rw-r--r--lisp/org/org-taskjuggler.el2
-rw-r--r--lisp/org/org-timer.el2
-rw-r--r--lisp/org/org-vm.el2
-rw-r--r--lisp/org/org-w3m.el2
-rw-r--r--lisp/org/org-wl.el2
-rw-r--r--lisp/org/org-xoxo.el2
-rw-r--r--lisp/org/org.el412
97 files changed, 3133 insertions, 1562 deletions
diff --git a/lisp/org/ChangeLog b/lisp/org/ChangeLog
index 29295d67d17..2973ff4b579 100644
--- a/lisp/org/ChangeLog
+++ b/lisp/org/ChangeLog
@@ -1,3 +1,684 @@
12010-12-11 Tassilo Horn <tassilo@member.fsf.org>
2
3 * org-footnote.el (org-footnote-create-definition): Place
4 Footnotes section before message-signature-separator also in modes
5 derived from message-mode.
6
72010-12-11 Julien Danjou <julien@danjou.info>
8
9 * org.el (org-make-tags-matcher): Remove useless cat-p value.
10
112010-12-11 Julien Danjou <julien@danjou.info>
12
13 * org.el (org-entry-properties): Enhance docstring.
14
152010-12-11 Nicolas Goaziou <n.goaziou@gmail.com>
16
17 * org-list.el (org-list-top-point-with-indent)
18 (org-list-bottom-point-with-indent): Pay also attention to
19 'original-indentation property of text, as blocks are put to
20 column 0 upon exporting.
21
222010-12-11 Dan Davison <dandavison7@gmail.com>
23
24 * ob.el (org-babel-remove-temporary-directory): Handle exception
25 with message informing of failure to remove directory.
26
272010-12-11 Eric Schulte <schulte.eric@gmail.com>
28
29 * ob-clojure.el (org-babel-header-arg-names:clojure): Add
30 `package' to the list of Clojure header arguments which will be read
31 from heading properties.
32
332010-12-11 Nicolas Goaziou <n.goaziou@gmail.com>
34
35 * org-inlinetask.el (org-inlinetask-export-templates): Add
36 Sébastien Vauban's suggestion for LaTeX export in docstring. This is
37 not default as it requires an additional LaTeX package: "todonotes".
38
392010-12-11 Nicolas Goaziou <n.goaziou@gmail.com>
40
41 * org-inlinetask.el (org-inlinetask-export-templates): New variable.
42
43 * org-inlinetask.el (org-inlinetask-export-handler): Make use of
44 templates to export inline tasks.
45
462010-12-11 Nicolas Goaziou <n.goaziou@gmail.com>
47
48 * org.el (org-current-level): Ignore inline tasks when getting current
49 level of entry.
50
512010-12-11 Nicolas Goaziou <n.goaziou@gmail.com>
52
53 * org.el (org-indent-line-function): Ignore drawers inside inline
54 tasks if the line to indent isn't inside an inline task itself.
55
562010-12-11 Nicolas Goaziou <n.goaziou@gmail.com>
57
58 * org-inlinetask.el (org-inlinetask-get-task-level): New function.
59
60 * org-indent.el (org-indent-add-properties): Find true level of
61 indentation wrt inline tasks.
62
632010-12-11 Nicolas Goaziou <n.goaziou@gmail.com>
64
65 * org-inlinetask.el (org-inlinetask-outline-regexp): New function.
66
67 * org-inlinetask.el (org-inlinetask-goto-beginning): New function.
68
69 * org-inlinetask.el (org-inlinetask-goto-end): New function.
70
71 * org.el (org-mark-subtree): New command.
72
73 * org.el (org-speed-commands-default, org-mode-map): Make use of
74 new command.
75
762010-12-11 Nicolas Goaziou <n.goaziou@gmail.com>
77
78 * org-inlinetask.el (org-inlinetask-export-handler): Remove protection
79 from @<span class...> so it can be removed during LaTeX export.
80
812010-12-11 Eric Schulte <schulte.eric@gmail.com>
82
83 * ob.el (org-babel-insert-result): More informative code block
84 evaluation messages.
85
862010-12-11 Matt Lundin <mdl@imapmail.org>
87
88 * org.el (org-make-heading-search-string): Optionally limit number
89 of lines stored in file link search strings.
90 (org-context-in-file-links) Add option to set to integer specifying
91 number of lines.
92
932010-12-11 Carsten Dominik <carsten.dominik@gmail.com>
94
95 * org-capture.el (org-capture-finalize): New prefix argument
96 STAY-WITH-CAPTURE.
97 (org-capture-refile): Improve docstring.
98
992010-12-11 Eric Schulte <schulte.eric@gmail.com>
100
101 * ob-sql.el (org-babel-execute:sql): Add msosql as optional sql
102 interaction engine.
103
1042010-12-11 Carsten Dominik <carsten.dominik@gmail.com>
105
106 * org-agenda.el (org-agenda-list):
107 (org-agenda-goto-today): Use `org-today'.
108
1092010-12-11 Carsten Dominik <carsten.dominik@gmail.com>
110
111 * org-latex.el (org-export-latex-make-header): Swap \begin{document}
112 and the title/author definitions.
113
1142010-12-11 Carsten Dominik <carsten.dominik@gmail.com>
115
116 * org-macs.el: Better backup definition for
117 `with-silent-modifications'.
118
1192010-12-11 Eric Schulte <schulte.eric@gmail.com>
120
121 * ob-python.el (org-babel-execute:python): Rename "prefix" to
122 "preamble".
123 (org-babel-python-evaluate): Rename "prefix" to "preamble".
124 (org-babel-python-evaluate-external-process): Rename "prefix" to
125 "preamble".
126
1272010-12-11 Eric Schulte <schulte.eric@gmail.com>
128
129 * ob.el (org-babel-examplize-region): Check if `end' is a marker
130 or a point and handle appropriately.
131
1322010-12-11 Eric Schulte <schulte.eric@gmail.com>
133
134 * ob-sql.el (org-babel-execute:sql): Explicitly set field
135 separator to \t when importing tabular data.
136
1372010-12-11 Julien Danjou <julien@danjou.info>
138
139 * org-agenda.el (org-agenda-custom-commands-local-options):
140 Allow org-agenda-span to be a symbol.
141 (org-agenda-ndays): Make obsolete.
142 (org-agenda-span): New variable superseding org-agenda-ndays.
143 (org-agenda-menu): Use org-agenda-current-span.
144 (org-agenda-current-span): New local variable storing current
145 span.
146 (org-agenda-list): Take a span instead of ndays as argument.
147 This function is now responsible for computing the ndays based
148 on span.
149 (org-agenda-ndays-to-span): Return span only if number of days
150 really matches.
151 (org-agenda-span-to-ndays): New function.
152 (org-agenda-manipulate-query): Use org-agenda-compute-starting-span.
153 (org-agenda-goto-today): Use org-agenda-compute-starting-span.
154 (org-agenda-later): Do not give compute a new span, use the
155 current one.
156 (org-agenda-day-view, org-agenda-week-view)
157 (org-agenda-month-view, org-agenda-year-view): Stop touching
158 org-agenda-ndays.
159 (org-agenda-change-time-span): Only compute starting-span.
160 (org-agenda-compute-starting-span): New function derived from
161 the old org-agenda-compute-time-span.
162 (org-agenda-set-mode-name): Compute mode based on
163 org-agenda-current-span.
164 (org-agenda-span-name): New function.
165
1662010-12-11 Robert Pluim <rpluim@gmail.com> (tiny change)
167
168 * org-agenda.el (org-agenda-toggle-deadlines): Fix docstring.
169
1702010-12-11 Carsten Dominik <carsten.dominik@gmail.com>
171
172 * org-clock.el (org-quarter-to-date): Define variables.
173 (org-clock-special-range): Defin variables. Use org-floor*.
174 (org-clocktable-write-default): Define tcol.
175
176 * org-compat.el (org-floor*): New function.
177
178 * org-complete.el: New file.
179
1802010-12-11 Carsten Dominik <carsten.dominik@gmail.com>
181
182 * org-clock.el (org-clocktable-write-default): Fix the % formula.
183
1842010-12-11 Matt Lundin <mdl@imapmail.org>
185
186 * org-agenda.el: (org-format-agenda-item) The value of
187 org-category is not converted to a string unless it is defined.
188
1892010-12-11 Eric Schulte <schulte.eric@gmail.com>
190
191 * ob-python.el (org-babel-execute:python): Pass the new "prefix"
192 header argument through to external evaluation.
193 (org-babel-python-evaluate): Pass the new "prefix" header argument
194 through to external evaluation.
195 (org-babel-python-evaluate-external-process): When specified prepend
196 "prefix" to the file used in external evaluation.
197
1982010-12-11 Dan Davison <dandavison7@gmail.com>
199
200 * ob-python.el (org-babel-python-evaluate-session): Change python
201 module name from 'pp' to 'pprint'.
202
2032010-12-11 Eric Schulte <schulte.eric@gmail.com>
204
205 * ob-R.el (org-babel-R-evaluate-session): Removing empty lines
206 from R session output, these are often the result of variable
207 assignments.
208
2092010-12-11 Eric Schulte <schulte.eric@gmail.com>
210
211 * ob-sql.el (orgtbl-to-csv): Declaring an external function to
212 fix a compiler warning.
213
2142010-12-11 Eric Schulte <schulte.eric@gmail.com>
215
216 * ob-eval.el (require): No longer require ob.el to allow
217 requiring by ob.el.
218
219 * ob.el (ob-eval): Require ob-eval.
220
2212010-12-11 Eric Schulte <schulte.eric@gmail.com>
222
223 * ob.el (org-babel-confirm-evaluate): Show code block's name when
224 it is available during evaluation query.
225
2262010-12-11 Eric Schulte <schulte.eric@gmail.com>
227
228 * ob-sql.el (org-babel-expand-body:sql): Expand the body of a sql
229 code block.
230 (org-babel-execute:sql): Use sql specific body expansion function.
231 (org-babel-sql-expand-vars): Insert variables into a sql code block.
232
2332010-12-11 Eric Schulte <schulte.eric@gmail.com>
234
235 * ob.el (org-babel-insert-result): Using markers instead of
236 points for more robust buffer anchors.
237
2382010-12-11 Julien Danjou <julien@danjou.info>
239
240 * org-capture.el: Use org-today.
241
2422010-12-11 Julien Danjou <julien@danjou.info>
243
244 * org-habit.el: Use org-today.
245
2462010-12-11 Julien Danjou <julien@danjou.info>
247
248 * org.el (org-auto-repeat-maybe): Use org-today.
249
2502010-12-11 David Maus <dmaus@ictsoc.de>
251
252 * test-org.el (test-org/org-link-escape-url-with-escaped-char): Add
253 test for escaping and unescaping url with already escaped char.
254
2552010-12-11 Carsten Dominik <carsten.dominik@gmail.com>
256
257 * org-clock.el (org-day-of-week): New function.
258 (org-quarter-to-date): New function.
259 (org-clock-special-range): Implement quarters.
260
2612010-12-11 Sébastien Vauban <wxhgmqzgwmuf@spammotel.com>
262
263 * org.el (org-complete-tags-always-offer-all-agenda-tags): Fix
264 docstring.
265
2662010-12-11 Julien Danjou <julien@danjou.info>
267
268 * org-agenda.el (org-format-agenda-item): Convert category to a string
269 if it is a symbol. This fixes the following call to
270 org-agenda-get-category-icon which fails if category is not a string.
271
2722010-12-11 Eric Schulte <schulte.eric@gmail.com>
273
274 * ob-clojure.el: Updated requirements documentation to mention
275 the minimum version of Clojure.
276 (org-babel-expand-body:clojure): Fully qualified function name.
277
2782010-12-11 Nicolas Goaziou <n.goaziou@gmail.com>
279
280 * org-latex.el (org-export-latex-lists): do not add an
281 unnecessary newline character after a list.
282
283 * org-list.el (org-list-bottom-point-with-indent): ensure bottom
284 point is just after a non blank line.
285
2862010-12-11 Eric Schulte <schulte.eric@gmail.com>
287
288 * ob.el (org-babel-examplize-region): Remove old assertion which
289 no longer applies to the result insertion code.
290
2912010-12-11 Eric Schulte <schulte.eric@gmail.com>
292
293 * ob-python.el (org-babel-execute:python): Use a :return header
294 argument for external evaluation in which the code block body need
295 be wrapped in a function
296
2972010-12-11 Eric Schulte <schulte.eric@gmail.com>
298
299 * ob-clojure.el (org-babel-expand-body:clojure): Trapped free
300 variable.
301
3022010-12-11 Carsten Dominik <carsten.dominik@gmail.com>
303
304 * org.el (org-edit-special): Edit formulas when in TBLMF line
305
3062010-12-11 Allen S. Rout <asr@ufl.edu> (tiny change)
307
308 * org-capture.el (org-capture-after-finalize-hook): New hook.
309 (org-capture-finalize): Run the new hook.
310
3112010-12-11 Eric Schulte <schulte.eric@gmail.com>
312
313 * ob-clojure.el (org-babel-expand-body:clojure): Support for
314 pretty printing of Clojure code and data.
315
3162010-12-11 Eric Schulte <schulte.eric@gmail.com>
317
318 * ob.el (org-babel-insert-result): No longer escape results which
319 will be wrapped in a block.
320
3212010-12-11 Eric Schulte <schulte.eric@gmail.com>
322
323 * ob-eval.el (org-babel-eval-wipe-error-buffer): Fixed compiler
324 warning and added documentation string.
325
3262010-12-11 Eric Schulte <schulte.eric@gmail.com>
327
328 * ob-clojure.el (org-babel-execute:clojure): Remade using slime
329 for all code evaluation.
330
3312010-12-11 Carsten Dominik <carsten.dominik@gmail.com>
332
333 * org-beamer.el (org-beamer-sectioning): Allow overlay arguments for
334 the column as well.
335
3362010-12-11 Eric Schulte <schulte.eric@gmail.com>
337
338 * ob.el (org-babel-confirm-evaluate): More descriptive message
339 when evaluation is aborted or disabled.
340
3412010-12-11 Eric Schulte <schulte.eric@gmail.com>
342
343 * ob.el (org-babel-insert-result): Responds to new "wrap" header
344 argument.
345 (org-babel-merge-params): Includes new "wrap" header argument in
346 one of the results header argument exclusive groups.
347
3482010-12-11 David Maus <dmaus@ictsoc.de>
349
350 * org-macs.el (with-silent-modifications): Fix condition for
351 with-silent-modification.
352
3532010-12-11 Eric Schulte <schulte.eric@gmail.com>
354
355 * ob.el (org-babel-parse-header-arguments): Stripping trailing
356 spaces off of header arguments (even the first one).
357
3582010-12-11 Eric Schulte <schulte.eric@gmail.com>
359
360 * ob-sh.el (org-babel-sh-var-to-sh): Wrap end token of heredoc in
361 single quotes which is the best practice.
362 (org-babel-sh-table-or-results): Use `org-babel-script-escape' for
363 more robust parsing of shell output.
364
3652010-12-11 Dan Davison <dandavison7@gmail.com>
366
367 * org.el (org-additional-option-like-keywords): Add more keywords,
368 and colons to some old ones.
369
3702010-12-11 Dan Davison <dandavison7@gmail.com>
371
372 * ob-eval.el (org-babel-error-buffer-name): Define new variable.
373
3742010-12-11 Eric Schulte <schulte.eric@gmail.com>
375
376 * ob-python.el (org-babel-python-table-or-string): Using
377 `org-babel-script-escape' for reading string input from scripting
378 languages.
379
3802010-12-11 Achim Gratz <Stromeko@nexgo.de> (tiny change)
381
382 * org-macs.el (org-called-interactively-p): Wrap function call in
383 with-no-warnings.
384 (with-silent-modifications) Declare macro for Emacs < 23.2.
385
3862010-12-11 David Maus <dmaus@ictsoc.de>
387
388 * org-test.el (org-test-current-file): New function. Run all tests
389 for current file.
390
3912010-12-11 Eric Schulte <schulte.eric@gmail.com>
392
393 * ob.el (org-babel-parse-header-arguments): Removed addition of
394 ":" to singleton first header arguments as it was leading to errors.
395
3962010-12-11 David Maus <dmaus@ictsoc.de>
397
398 * test-org.el (test-org/org-link-escape-ascii-character)
399 (test-org/org-link-escape-ascii-ctrl-character)
400 (test-org/org-link-escape-multibyte-character)
401 (test-org/org-link-escape-custom-table)
402 (test-org/org-link-escape-custom-table-merge)
403 (test-org/org-link-unescape-ascii-character)
404 (test-org/org-link-unescape-ascii-ctrl-character)
405 (test-org/org-link-unescape-multibyte-character)
406 (test-org/org-link-unescape-ascii-extended-char): New tests for
407 unicode aware percent escaping.
408
4092010-12-11 Carsten Dominik <carsten.dominik@gmail.com>
410
411 * org-latex.el (org-export-latex-make-header): Run the title through
412 `org-export-latex-fontify-headline'.
413 (org-export-latex-fontify-headline): Do the protection of math
414 snippets also here.
415
4162010-12-11 Richard Lawrence <richard.lawrence@berkeley.edu>
417
418 * org-latex.el (org-export-as-latex): Sent the section title
419 through the preprocessor.
420
4212010-12-11 Carsten Dominik <carsten.dominik@gmail.com>
422
423 * org-html.el (org-html-level-start): Mark listified headings
424 with a custom id.
425
4262010-12-11 Carsten Dominik <carsten.dominik@gmail.com>
427
428 * org.el (org-open-at-point): Don't do footnote action if cursor is
429 on a bracket link.
430
4312010-12-11 Carsten Dominik <carsten.dominik@gmail.com>
432
433 * org.el (org-edit-special): Check also for TBLFM line.
434
4352010-12-11 Achim Gratz <Stromeko@Stromeko.DE> (tiny change)
436
437 * org-clock.el (org-get-clocktable): previous patch incorrectly
438 required whitespace in front of #+BEGIN: and #+END:
439
4402010-12-11 Dan Davison <dandavison7@gmail.com>
441
442 * org-src.el (org-edit-src-code): Allow region to be inherited by
443 edit buffer when mark is one character beyond end of src block.
444
4452010-12-11 Nicolas Goaziou <n.goaziou@gmail.com>
446
447 * org-list.el (org-cycle-list-bullet): ensure point is at bol before
448 checking item indentation.
449
4502010-12-11 Eric Schulte <schulte.eric@gmail.com>
451
452 * ob.el (org-babel-map-src-blocks): Moved to earlier in the file
453 and now autoloading.
454
4552010-12-11 Eric Schulte <schulte.eric@gmail.com>
456
457 * ob-ref.el (org-babel-ref-at-ref-p): Use higher level function
458 for testing list membership.
459
460 * ob.el (org-babel-read-result): Use higher level function for
461 testing list membership.
462 (org-babel-result-end): Use higher level function for testing list
463 membership.
464
4652010-12-11 Eric Schulte <schulte.eric@gmail.com>
466
467 * ob-sqlite.el (ob-eval): Require ob-eval for external command
468 execution.
469 (org-babel-execute:sqlite): No longer uses the init option for
470 passing commands to sqlite.
471
4722010-12-11 Nicolas Goaziou <n.goaziou@gmail.com>
473
474 * org.el (org-indent-line-function): Drawers and blocks have no
475 influence on indentation of text below. Also fix indentation
476 problem with a block at column 0 and add a special case for
477 literal examples.
478
4792010-12-11 Eric Schulte <schulte.eric@gmail.com>
480
481 * ob.el (org-babel-map-src-blocks): Ensure that the file argument
482 is only evaluated once.
483
4842010-12-11 Eric Schulte <schulte.eric@gmail.com>
485
486 * ob-ref.el (org-babel-ref-resolve): Recognize `list' as a unique
487 type of data
488 (org-babel-ref-at-ref-p): Recognize `list' as a unique type of data
489
4902010-12-11 Eric Schulte <schulte.eric@gmail.com>
491
492 * ob-tangle.el (org-babel-load-file): Can be called interactively.
493
4942010-12-11 Carsten Dominik <carsten.dominik@gmail.com> (tiny change)
495
496 * org-table.el (orgtbl-after-send-table-hook): New hook.
497 (orgtbl-ctrl-c-ctrl-c): Run `orgtbl-after-send-table-hook' when a
498 table was sent.
499 (orgtbl-send-table): Return the number of sent tables, or nil if no
500 sending has happened.
501
5022010-12-11 Carsten Dominik <carsten.dominik@gmail.com>
503
504 * org.el (org-get-priority-function): New option.
505 (org-get-priority): Call `org-get-priority-function' if that
506 has been set.
507
5082010-12-11 Dan Davison <dandavison7@gmail.com>
509
510 * ob-table.el (org-babel-table-truncate-at-newline): Only add
511 "..." if there is something after the newline.
512
5132010-12-11 Achim Gratz <Stromeko@nexgo.de> (tiny change)
514
515 * org-clock.el (org-get-clocktable):
516 (org-in-clocktable-p):
517 (org-clocktable-shift):
518 (org-clocktable-steps): Fix regexp to allow for indented clock tables
519
5202010-12-11 Puneeth Chaganti <punchagan@gmail.com>
521
522 * org-exp.el (org-export-handle-include-files): Support :minlevel
523 property.
524 (org-get-file-contents): New argument minlevel to demote included
525 content.
526
5272010-12-11 Noorul Islam <noorul@noorul.com>
528
529 * org-latex.el (org-export-latex-hyperref-format): New option.
530 (org-export-latex-href-format): Renamed the existing variable
531 `org-export-latex-hyperref-format' as `org-export-latex-href-format'
532 (org-export-latex-links): Use `org-export-latex-hyperref-format' and
533 `org-export-latex-href-format'
534
5352010-12-11 Eric Schulte <schulte.eric@gmail.com>
536
537 * ob-calc.el (org-babel-execute:calc): Ensure the *Calculator*
538 buffer exists before it is used.
539
5402010-12-11 Nicolas Goaziou <n.goaziou@gmail.com>
541
542 * org-exp.el (org-export-preprocess-string): delaying code block
543 processing a bit to allow correct list parsing in the export string
544
5452010-12-11 Christopher Allan Webber <cwebber@dustycloud.org>
546
547 * org-agenda.el (org-agenda-timegrid-use-ampm): New option.
548 (org-agenda-time-of-day-to-ampm): New function.
549 (org-agenda-time-of-day-to-ampm-maybe): New function.
550 (org-format-agenda-item): Call org-agenda-time-of-day-to-ampm-maybe.
551
5522010-12-11 Carsten Dominik <carsten.dominik@gmail.com>
553
554 * org-faces.el (org-cycle-level-faces): New option.
555
556 * org.el (org-get-level-face): Honor org-cycle-level-faces.
557
5582010-12-11 Julien Danjou <julien@danjou.info>
559
560 * org-agenda.el (org-agenda-today): New function.
561 (org-agenda-get-day-face): New function.
562 (org-timeline): Use org-agenda-today and org-agenda-get-day-face.
563 (org-agenda-list): Use org-agenda-today and org-agenda-get-day-face.
564 (org-todo-list): Use org-agenda-today.
565 (org-get-all-dates): Use org-agenda-today.
566 (org-agenda-day-face-function): New variable.
567 (org-agenda-get-day-face): Use org-agenda-day-face-function.
568
5692010-12-11 Carsten Dominik <carsten.dominik@gmail.com>
570
571 * org.el (org-ctrl-c-ctrl-c): Consider sending a radio table also
572 in Org.
573
5742010-12-11 Carsten Dominik <carsten.dominik@gmail.com>
575
576 * org-html.el (org-export-as-html): Do not treat partially
577 protected lines as if they were fully protected.
578
5792010-12-11 Dan Davison <dandavison7@gmail.com>
580
581 * org-exp.el: (org-export-format-source-code-or-example):
582 Remove hard-wired configuration of minted export
583 (org-export-latex-minted-with-line-numbers): Remove variable
584
5852010-12-11 Bastien Guerry <bzg@altern.org>
586
587 * org-clock.el (org-dblock-write:clocktable): Fix double
588 reference to `link' in let construct.
589 (org-clock-clocktable-formatter): Fix typo in docstring.
590 (org-clocktable-write-default): Fix typo in docstring.
591
5922010-12-11 David Maus <dmaus@ictsoc.de>
593
594 * org-protocol.el (org-protocol-unhex-string): Normalize percent
595 escape sequence to upper case letters.
596
5972010-12-11 Eric Schulte <schulte.eric@gmail.com>
598
599 * ob-lob.el (org-babel-lob-get-info): including pass-through
600 header arguments in results variable header argument string
601
6022010-12-11 David Maus <dmaus@ictsoc.de>
603
604 * org-exp.el (org-export-visible): Limit search for in-buffer options
605 beginning of first headline.
606
6072010-12-11 David Maus <dmaus@ictsoc.de>
608
609 * org.el (org-open-at-point): Remove stale link handler for news:
610 links.
611
6122010-12-11 Carsten Dominik <carsten.dominik@gmail.com>
613
614 * org-clock.el (org-clocktable-write-default): Better handling of
615 narrowing.
616
6172010-12-11 Julien Danjou <julien@danjou.info>
618
619 * list/org-agenda.el (org-agenda-category-icon-alist): Fix defcustom
620 type.
621
6222010-12-11 Nicolas Goaziou <n.goaziou@gmail.com>
623
624 * org.el (org-indent-line-function): simplify code and remove bug that
625 would insert a tab at the beginning of the line when trying to
626 indent the item.
627
6282010-12-11 Julien Danjou <julien@danjou.info>
629
630 * org.el (org-diary-sexp-entry): Split sexp result strings at semicolon.
631
6322010-12-11 Julien Danjou <julien@danjou.info>
633
634 * org-agenda.el (org-agenda-prefix-format): Insert place holder
635 for icon.
636 (org-agenda-category-icon-alist): New option.
637 (org-agenda-get-category-icon): New function.
638 (org-format-agenda-item): Support for icons.
639 (org-compile-prefix-format): Support for icons.
640
6412010-12-11 Julien Danjou <julien@danjou.info>
642
643 * org-compat.el: Create defalias for `string-match-p' and
644 looking-at-p.
645
6462010-12-11 Eric Schulte <schulte.eric@gmail.com>
647
648 * ob-calc.el (org-babel-execute:calc): support for variables --
649 converts :var variables in calc variables
650
6512010-12-11 Carsten Dominik <carsten.dominik@gmail.com>
652
653 * org.el (org-sparse-tree): Mention [r] in dispatch menu
654
6552010-12-11 Carsten Dominik <carsten.dominik@gmail.com>
656
657 * org-list.el (org-list-parse-list): Use `org-looking-at-p'.
658
6592010-12-11 Carsten Dominik <carsten.dominik@gmail.com>
660
661 * org-id.el (org-id-store-link): Test for org-mode before checking
662 for IDs.
663
6642010-12-11 David Maus <dmaus@ictsoc.de>
665
666 * org-test.el (org-test-current-defun): `which-function' does not
667 return a list, but the name of the function.
668
6692010-12-11 Carsten Dominik <carsten.dominik@gmail.com>
670
671 * org.el (org-shorten-string): New function.
672
673 * org-exp.el (org-export-convert-protected-spaces): New function.
674 (org-export-preprocess-string): Call
675 `org-export-convert-protected-spaces' to handle new hard spaces.
676
6772010-12-11 David Maus <dmaus@ictsoc.de>
678
679 * org.el (org-narrow-to-subtree): Check for heading that ends at end
680 of buffer.
681
12010-11-12 Carsten Dominik <carsten.dominik@gmail.com> 6822010-11-12 Carsten Dominik <carsten.dominik@gmail.com>
2 683
3 * org-capture.el (org-capture-templates): Remove autoload from 684 * org-capture.el (org-capture-templates): Remove autoload from
diff --git a/lisp/org/ob-C.el b/lisp/org/ob-C.el
index 1c8eac65ace..da0e76894f1 100644
--- a/lisp/org/ob-C.el
+++ b/lisp/org/ob-C.el
@@ -5,7 +5,7 @@
5;; Author: Eric Schulte 5;; Author: Eric Schulte
6;; Keywords: literate programming, reproducible research 6;; Keywords: literate programming, reproducible research
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 7.3 8;; Version: 7.4
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/ob-R.el b/lisp/org/ob-R.el
index 81d628e4206..1f4fd87b0a3 100644
--- a/lisp/org/ob-R.el
+++ b/lisp/org/ob-R.el
@@ -2,11 +2,10 @@
2 2
3;; Copyright (C) 2009, 2010 Free Software Foundation, Inc. 3;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
4 4
5;; Author: Eric Schulte 5;; Author: Eric Schulte, Dan Davison
6;; Dan Davison
7;; Keywords: literate programming, reproducible research, R, statistics 6;; Keywords: literate programming, reproducible research, R, statistics
8;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
9;; Version: 7.3 8;; Version: 7.4
10 9
11;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
12 11
@@ -277,16 +276,18 @@ last statement in BODY, as elisp."
277 (butlast 276 (butlast
278 (delq nil 277 (delq nil
279 (mapcar 278 (mapcar
280 (lambda (line) ;; cleanup extra prompts left in output 279 (lambda (line) (when (> (length line) 0) line))
281 (if (string-match 280 (mapcar
282 "^\\([ ]*[>+][ ]?\\)+\\([[0-9]+\\|[ ]\\)" line) 281 (lambda (line) ;; cleanup extra prompts left in output
283 (substring line (match-end 1)) 282 (if (string-match
284 line)) 283 "^\\([ ]*[>+][ ]?\\)+\\([[0-9]+\\|[ ]\\)" line)
285 (org-babel-comint-with-output (session org-babel-R-eoe-output) 284 (substring line (match-end 1))
286 (insert (mapconcat #'org-babel-chomp 285 line))
287 (list body org-babel-R-eoe-indicator) 286 (org-babel-comint-with-output (session org-babel-R-eoe-output)
288 "\n")) 287 (insert (mapconcat #'org-babel-chomp
289 (inferior-ess-send-input)))) 2) "\n")))) 288 (list body org-babel-R-eoe-indicator)
289 "\n"))
290 (inferior-ess-send-input)))))) "\n"))))
290 291
291(defun org-babel-R-process-value-result (result column-names-p) 292(defun org-babel-R-process-value-result (result column-names-p)
292 "R-specific processing of return value. 293 "R-specific processing of return value.
diff --git a/lisp/org/ob-asymptote.el b/lisp/org/ob-asymptote.el
index 43d65462612..ab2abda28d8 100644
--- a/lisp/org/ob-asymptote.el
+++ b/lisp/org/ob-asymptote.el
@@ -5,7 +5,7 @@
5;; Author: Eric Schulte 5;; Author: Eric Schulte
6;; Keywords: literate programming, reproducible research 6;; Keywords: literate programming, reproducible research
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 7.3 8;; Version: 7.4
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/ob-calc.el b/lisp/org/ob-calc.el
index 426aafd154f..287bad31a29 100644
--- a/lisp/org/ob-calc.el
+++ b/lisp/org/ob-calc.el
@@ -1,11 +1,11 @@
1;;; ob-calc.el --- org-babel functions for calc code evaluation 1;;; ob-calc.el --- org-babel functions for calc code evaluation
2 2
3;; Copyright (C) 2010 Free Software Foundation, Inc. 3;; Copyright (C) 2010 Free Software Foundation, Inc
4 4
5;; Author: Eric Schulte 5;; Author: Eric Schulte
6;; Keywords: literate programming, reproducible research 6;; Keywords: literate programming, reproducible research
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 7.3 8;; Version: 7.4
9 9
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11 11
@@ -40,25 +40,55 @@
40 40
41(defun org-babel-execute:calc (body params) 41(defun org-babel-execute:calc (body params)
42 "Execute a block of calc code with Babel." 42 "Execute a block of calc code with Babel."
43 (mapcar 43 (unless (get-buffer "*Calculator*")
44 (lambda (line) 44 (save-window-excursion (calc) (calc-quit)))
45 (when (> (length line) 0) 45 (let* ((vars (mapcar #'cdr (org-babel-get-header params :var)))
46 (if (string= "'" (substring line 0 1)) 46 (var-syms (mapcar #'car vars))
47 (funcall (lookup-key calc-mode-map (substring line 1)) nil) 47 (var-names (mapcar #'symbol-name var-syms)))
48 (calc-push-list 48 (mapc
49 (list ((lambda (res) 49 (lambda (pair)
50 (cond 50 (calc-push-list (list (cdr pair)))
51 ((numberp res) res) 51 (calc-store-into (car pair)))
52 ((listp res) (error "calc error \"%s\" on input \"%s\"" 52 vars)
53 (cadr res) line)) 53 (mapc
54 (t res)) 54 (lambda (line)
55 (if (numberp res) res (math-read-number res))) 55 (when (> (length line) 0)
56 (calc-eval line))))))) 56 (cond
57 (mapcar #'org-babel-trim 57 ;; simple variable name
58 (split-string (org-babel-expand-body:calc body params) "[\n\r]"))) 58 ((member line var-names) (calc-recall (intern line)))
59 ;; stack operation
60 ((string= "'" (substring line 0 1))
61 (funcall (lookup-key calc-mode-map (substring line 1)) nil))
62 ;; complex expression
63 (t
64 (calc-push-list
65 (list ((lambda (res)
66 (cond
67 ((numberp res) res)
68 ((math-read-number res) (math-read-number res))
69 ((listp res) (error "calc error \"%s\" on input \"%s\""
70 (cadr res) line))
71 (t (calc-eval
72 (math-evaluate-expr
73 ;; resolve user variables, calc built in
74 ;; variables are handled automatically
75 ;; upstream by calc
76 (mapcar (lambda (el)
77 (if (and (consp el) (equal 'var (car el))
78 (member (cadr el) var-syms))
79 (progn
80 (calc-recall (cadr el))
81 (prog1 (calc-top 1)
82 (calc-pop 1)))
83 el))
84 ;; parse line into calc objects
85 (car (math-read-exprs line))))))))
86 (calc-eval line))))))))
87 (mapcar #'org-babel-trim
88 (split-string (org-babel-expand-body:calc body params) "[\n\r]"))))
59 (save-excursion 89 (save-excursion
60 (set-buffer (get-buffer "*Calculator*")) 90 (with-current-buffer (get-buffer "*Calculator*")
61 (calc-eval (calc-top 1)))) 91 (calc-eval (calc-top 1)))))
62 92
63(provide 'ob-calc) 93(provide 'ob-calc)
64 94
diff --git a/lisp/org/ob-clojure.el b/lisp/org/ob-clojure.el
index 0a76e827125..d88c54b6dbe 100644
--- a/lisp/org/ob-clojure.el
+++ b/lisp/org/ob-clojure.el
@@ -2,10 +2,10 @@
2 2
3;; Copyright (C) 2009, 2010 Free Software Foundation, Inc. 3;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
4 4
5;; Author: Joel Boehland 5;; Author: Joel Boehland, Eric Schulte
6;; Keywords: literate programming, reproducible research 6;; Keywords: literate programming, reproducible research
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 7.3 8;; Version: 7.4
9 9
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11 11
@@ -24,14 +24,14 @@
24 24
25;;; Commentary: 25;;; Commentary:
26 26
27;;; ob support for evaluating clojure code 27;;; support for evaluating clojure code, relies on slime for all eval
28 28
29;;; Requirements: 29;;; Requirements:
30 30
31;;; A working clojure install. This also implies a working java executable 31;;; - clojure (at least 1.2.0)
32;;; clojure-mode 32;;; - clojure-mode
33;;; slime 33;;; - slime
34;;; swank-clojure 34;;; - swank-clojure
35 35
36;;; By far, the best way to install these components is by following 36;;; By far, the best way to install these components is by following
37;;; the directions as set out by Phil Hagelberg (Technomancy) on the 37;;; the directions as set out by Phil Hagelberg (Technomancy) on the
@@ -39,277 +39,47 @@
39 39
40;;; Code: 40;;; Code:
41(require 'ob) 41(require 'ob)
42(require 'ob-eval)
43(eval-when-compile (require 'cl))
44 42
45(declare-function slime-eval-async "ext:slime" (sexp &optional cont package))
46(declare-function slime-eval "ext:slime" (sexp &optional package)) 43(declare-function slime-eval "ext:slime" (sexp &optional package))
47(declare-function swank-clojure-concat-paths "ext:slime" (paths))
48(declare-function slime "ext:slime" (&optional command coding-system))
49(declare-function slime-output-buffer "ext:slime" (&optional noprompt))
50(declare-function slime-filter-buffers "ext:slime" (predicate))
51 44
52(add-to-list 'org-babel-tangle-lang-exts '("clojure" . "clj")) 45(add-to-list 'org-babel-tangle-lang-exts '("clojure" . "clj"))
53 46
54(defvar org-babel-default-header-args:clojure '()) 47(defvar org-babel-default-header-args:clojure '())
55 48(defvar org-babel-header-arg-names:clojure '(package))
56(defvar org-babel-clojure-wrapper-method
57 "
58(defn spit
59 [f content]
60 (with-open [#^java.io.PrintWriter w
61 (java.io.PrintWriter.
62 (java.io.BufferedWriter.
63 (java.io.OutputStreamWriter.
64 (java.io.FileOutputStream.
65 (java.io.File. f)))))]
66 (.print w content)))
67
68(defn main
69 []
70 %s)
71
72(spit \"%s\" (str (main)))")
73;;";; <-- syntax highlighting is messed without this double quote
74
75;;taken mostly from clojure-test-mode.el
76(defun org-babel-clojure-clojure-slime-eval (string &optional handler)
77 "Evaluate a STRING of clojure code using `slime-eval-async'."
78 (slime-eval-async `(swank:eval-and-grab-output ,string)
79 (or handler #'identity)))
80
81(defun org-babel-clojure-slime-eval-sync (string)
82 "Evaluate a STRING of clojure code using `slime-eval'."
83 (slime-eval `(swank:eval-and-grab-output ,string)))
84
85;;taken from swank-clojure.el
86(defvar swank-clojure-binary)
87(defvar swank-clojure-classpath)
88(defvar swank-clojure-java-path)
89(defvar swank-clojure-extra-vm-args)
90(defvar swank-clojure-library-paths)
91(defvar swank-clojure-extra-classpaths)
92(defun org-babel-clojure-babel-clojure-cmd ()
93 "Create the command to start clojure according to current settings."
94 (or (when swank-clojure-binary
95 (if (listp swank-clojure-binary)
96 swank-clojure-binary
97 (list swank-clojure-binary)))
98 (when swank-clojure-classpath
99 (delq
100 nil
101 (append
102 (list swank-clojure-java-path)
103 swank-clojure-extra-vm-args
104 (list
105 (when swank-clojure-library-paths
106 (concat "-Djava.library.path="
107 (swank-clojure-concat-paths swank-clojure-library-paths)))
108 "-classpath"
109 (swank-clojure-concat-paths
110 (append
111 swank-clojure-classpath
112 swank-clojure-extra-classpaths))
113 "clojure.main"))))
114 (error "%s" (concat "You must specifiy either a `swank-clojure-binary' "
115 "or a `swank-clojure-classpath'"))))
116
117(defun org-babel-clojure-table-or-string (results)
118 "Convert RESULTS to an elisp value.
119If RESULTS looks like a table, then convert to an Emacs-lisp
120table, otherwise return the results as a string."
121 (org-babel-read
122 (if (string-match "^\\[.+\\]$" results)
123 (org-babel-read
124 (concat "'"
125 (replace-regexp-in-string
126 "\\[" "(" (replace-regexp-in-string
127 "\\]" ")" (replace-regexp-in-string
128 ", " " " (replace-regexp-in-string
129 "'" "\"" results))))))
130 results)))
131
132(defun org-babel-clojure-var-to-clojure (var)
133 "Convert an elisp value into a clojure variable.
134The elisp value VAR is converted into a string of clojure source
135code specifying a variable of the same value."
136 (if (listp var)
137 (format "'%s" var)
138 (format "%S" var)))
139
140(defun org-babel-clojure-build-full-form (body vars)
141 "Construct a clojure let form with VARS as the let variables."
142 (let ((vars-forms
143 (mapconcat ;; define any variables
144 (lambda (pair)
145 (format "%s %s"
146 (car pair) (org-babel-clojure-var-to-clojure (cdr pair))))
147 vars "\n "))
148 (body (org-babel-trim body)))
149 (if (> (length vars-forms) 0)
150 (format "(let [%s]\n %s)" vars-forms body)
151 body)))
152
153(defun org-babel-prep-session:clojure (session params)
154 "Prepare SESSION according to the header arguments specified in PARAMS."
155 (require 'slime) (require 'swank-clojure)
156 (let* ((session-buf (org-babel-clojure-initiate-session session))
157 (vars (mapcar #'cdr (org-babel-get-header params :var)))
158 (var-lines (mapcar ;; define any top level session variables
159 (lambda (pair)
160 (format "(def %s %s)\n" (car pair)
161 (org-babel-clojure-var-to-clojure (cdr pair))))
162 vars)))
163 session-buf))
164
165(defun org-babel-load-session:clojure (session body params)
166 "Load BODY into SESSION."
167 (require 'slime) (require 'swank-clojure)
168 (save-window-excursion
169 (let ((buffer (org-babel-prep-session:clojure session params)))
170 (with-current-buffer buffer
171 (goto-char (point-max))
172 (insert (org-babel-chomp body)))
173 buffer)))
174
175(defvar org-babel-clojure-buffers '())
176(defvar org-babel-clojure-pending-sessions '())
177
178(defun org-babel-clojure-session-buffer (session)
179 "Return the buffer associated with SESSION."
180 (cdr (assoc session org-babel-clojure-buffers)))
181
182(defun org-babel-clojure-initiate-session-by-key (&optional session)
183 "Initiate a clojure session in an inferior-process-buffer.
184If there is not a current inferior-process-buffer in SESSION
185then create one. Return the initialized session."
186 (save-window-excursion
187 (let* ((session (if session
188 (if (stringp session) (intern session)
189 session)
190 :default))
191 (clojure-buffer (org-babel-clojure-session-buffer session)))
192 (unless (and clojure-buffer (buffer-live-p clojure-buffer))
193 (setq org-babel-clojure-buffers
194 (assq-delete-all session org-babel-clojure-buffers))
195 (push session org-babel-clojure-pending-sessions)
196 (slime)
197 ;; we are waiting to finish setting up which will be done in
198 ;; org-babel-clojure-session-connected-hook below.
199 (let ((timeout 9))
200 (while (and (not (org-babel-clojure-session-buffer session))
201 (< 0 timeout))
202 (message "Waiting for clojure repl for session: %s ... %i"
203 session timeout)
204 (sit-for 1)
205 (decf timeout)))
206 (setq org-babel-clojure-pending-sessions
207 (remove session org-babel-clojure-pending-sessions))
208 (unless (org-babel-clojure-session-buffer session)
209 (error "Couldn't create slime clojure process"))
210 (setq clojure-buffer (org-babel-clojure-session-buffer session)))
211 session)))
212
213(defun org-babel-clojure-initiate-session (&optional session params)
214 "Return the slime-clojure repl buffer bound to SESSION.
215Returns nil if \"none\" is specified."
216 (require 'slime) (require 'swank-clojure)
217 (unless (and (stringp session) (string= session "none"))
218 (org-babel-clojure-session-buffer
219 (org-babel-clojure-initiate-session-by-key session))))
220
221(defun org-babel-clojure-session-connected-hook ()
222 "Finish binding an org-babel session to a slime-clojure repl."
223 (let ((pending-session (pop org-babel-clojure-pending-sessions)))
224 (when pending-session
225 (save-excursion
226 (switch-to-buffer (slime-output-buffer))
227 (rename-buffer
228 (if (stringp pending-session)
229 pending-session (symbol-name pending-session)))
230 (org-babel-clojure-bind-session-to-repl-buffer
231 pending-session (slime-output-buffer))))))
232
233(add-hook 'slime-connected-hook 'org-babel-clojure-session-connected-hook)
234
235(defun org-babel-clojure-bind-session-to-repl-buffer (session repl-buffer)
236 "Associate SESSION with REPL-BUFFER."
237 (when (stringp session) (setq session (intern session)))
238 (setq org-babel-clojure-buffers
239 (cons (cons session repl-buffer)
240 (assq-delete-all session org-babel-clojure-buffers))))
241
242(defun org-babel-clojure-repl-buffer-pred ()
243 "Test whether the current buffer is an active slime-clojure
244repl buffer."
245 (and (buffer-live-p (current-buffer)) (eq major-mode 'slime-repl-mode)))
246
247(defun org-babel-clojure-bind-session-to-repl (session)
248 "Bind SESSION to a clojure repl."
249 (interactive "sEnter session name: ")
250 (let ((repl-bufs (slime-filter-buffers 'org-babel-clojure-repl-buffer-pred)))
251 (unless repl-bufs (error "No existing slime-clojure repl buffers exist"))
252 (let ((repl-buf (read-buffer "Choose slime-clojure repl: " repl-bufs t)))
253 (org-babel-clojure-bind-session-to-repl-buffer session repl-buf))))
254
255(defun org-babel-clojure-evaluate-external-process
256 (buffer body &optional result-type)
257 "Evaluate the body in an external process."
258 (let ((cmd (format "%s -" (mapconcat #'identity
259 (org-babel-clojure-babel-clojure-cmd)
260 " "))))
261 (case result-type
262 (output (org-babel-eval cmd body))
263 (value (let* ((tmp-file (org-babel-temp-file "clojure-")))
264 (org-babel-eval
265 cmd
266 (format
267 org-babel-clojure-wrapper-method
268 body
269 (org-babel-process-file-name tmp-file 'noquote)))
270 (org-babel-clojure-table-or-string
271 (org-babel-eval-read-file tmp-file)))))))
272
273(defun org-babel-clojure-evaluate-session (buffer body &optional result-type)
274 "Evaluate the body in the context of a clojure session."
275 (require 'slime) (require 'swank-clojure)
276 (let ((raw nil)
277 (results nil))
278 (with-current-buffer buffer
279 (setq raw (org-babel-clojure-slime-eval-sync body))
280 (setq results (reverse (mapcar #'org-babel-trim raw)))
281 (cond
282 ((equal result-type 'output)
283 (mapconcat #'identity (reverse (cdr results)) "\n"))
284 ((equal result-type 'value)
285 (org-babel-clojure-table-or-string (car results)))))))
286
287(defun org-babel-clojure-evaluate (buffer body &optional result-type)
288 "Pass BODY to the Clojure process in BUFFER.
289If RESULT-TYPE equals 'output then return a list of the outputs
290of the statements in BODY, if RESULT-TYPE equals 'value then
291return the value of the last statement in BODY as elisp."
292 (if buffer
293 (org-babel-clojure-evaluate-session buffer body result-type)
294 (org-babel-clojure-evaluate-external-process buffer body result-type)))
295 49
296(defun org-babel-expand-body:clojure (body params) 50(defun org-babel-expand-body:clojure (body params)
297 "Expand BODY according to PARAMS, return the expanded body." 51 "Expand BODY according to PARAMS, return the expanded body."
298 (org-babel-clojure-build-full-form 52 (let* ((vars (mapcar #'cdr (org-babel-get-header params :var)))
299 body (mapcar #'cdr (org-babel-get-header params :var)))) 53 (result-params (cdr (assoc :result-params params)))
54 (print-level nil) (print-length nil)
55 (body (org-babel-trim
56 (if (> (length vars) 0)
57 (concat "(let ["
58 (mapconcat
59 (lambda (var)
60 (format "%S (quote %S)" (car var) (cdr var)))
61 vars "\n ")
62 "]\n" body ")")
63 body))))
64 (if (or (member "code" result-params)
65 (member "pp" result-params))
66 (format (concat "(let [org-mode-print-catcher (java.io.StringWriter.)]"
67 "(clojure.pprint/with-pprint-dispatch %s-dispatch"
68 "(clojure.pprint/pprint %s org-mode-print-catcher)"
69 "(str org-mode-print-catcher)))")
70 (if (member "code" result-params) "code" "simple") body)
71 body)))
300 72
301(defun org-babel-execute:clojure (body params) 73(defun org-babel-execute:clojure (body params)
302 "Execute a block of Clojure code." 74 "Execute a block of Clojure code with Babel."
303 (require 'slime) (require 'swank-clojure) 75 (require 'slime) (require 'swank-clojure)
304 (let* ((body (org-babel-expand-body:clojure body params)) 76 (with-temp-buffer
305 (session (org-babel-clojure-initiate-session 77 (insert (org-babel-expand-body:clojure body params))
306 (cdr (assoc :session params))))) 78 (read
307 (org-babel-reassemble-table 79 (slime-eval
308 (org-babel-clojure-evaluate session body (cdr (assoc :result-type params))) 80 `(swank:interactive-eval-region
309 (org-babel-pick-name 81 ,(buffer-substring-no-properties (point-min) (point-max)))
310 (cdr (assoc :colname-names params)) (cdr (assoc :colnames params))) 82 (cdr (assoc :package params))))))
311 (org-babel-pick-name
312 (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params))))))
313 83
314(provide 'ob-clojure) 84(provide 'ob-clojure)
315 85
diff --git a/lisp/org/ob-comint.el b/lisp/org/ob-comint.el
index d05b7fbfa40..064aad539c2 100644
--- a/lisp/org/ob-comint.el
+++ b/lisp/org/ob-comint.el
@@ -5,7 +5,7 @@
5;; Author: Eric Schulte 5;; Author: Eric Schulte
6;; Keywords: literate programming, reproducible research, comint 6;; Keywords: literate programming, reproducible research, comint
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 7.3 8;; Version: 7.4
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/ob-css.el b/lisp/org/ob-css.el
index d93f28dcebc..48ea9e3f937 100644
--- a/lisp/org/ob-css.el
+++ b/lisp/org/ob-css.el
@@ -5,7 +5,7 @@
5;; Author: Eric Schulte 5;; Author: Eric Schulte
6;; Keywords: literate programming, reproducible research 6;; Keywords: literate programming, reproducible research
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 7.3 8;; Version: 7.4
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/ob-ditaa.el b/lisp/org/ob-ditaa.el
index a9b6b3ceaf1..097f938e92d 100644
--- a/lisp/org/ob-ditaa.el
+++ b/lisp/org/ob-ditaa.el
@@ -5,7 +5,7 @@
5;; Author: Eric Schulte 5;; Author: Eric Schulte
6;; Keywords: literate programming, reproducible research 6;; Keywords: literate programming, reproducible research
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 7.3 8;; Version: 7.4
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/ob-dot.el b/lisp/org/ob-dot.el
index c78f3dbee0d..36baddb1cd3 100644
--- a/lisp/org/ob-dot.el
+++ b/lisp/org/ob-dot.el
@@ -5,7 +5,7 @@
5;; Author: Eric Schulte 5;; Author: Eric Schulte
6;; Keywords: literate programming, reproducible research 6;; Keywords: literate programming, reproducible research
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 7.3 8;; Version: 7.4
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/ob-emacs-lisp.el b/lisp/org/ob-emacs-lisp.el
index f1d41b3db0d..df6f505ffea 100644
--- a/lisp/org/ob-emacs-lisp.el
+++ b/lisp/org/ob-emacs-lisp.el
@@ -1,11 +1,11 @@
1;;; ob-emacs-lisp.el --- org-babel functions for emacs-lisp code evaluation 1;;; ob-emacs-lisp.el --- org-babel functions for emacs-lisp code evaluation
2 2
3;; Copyright (C) 2009, 2010 Free Software Foundation, Inc. 3;; Copyright (C) 2009, 2010 Free Software Foundation, Inc
4 4
5;; Author: Eric Schulte 5;; Author: Eric Schulte
6;; Keywords: literate programming, reproducible research 6;; Keywords: literate programming, reproducible research
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 7.3 8;; Version: 7.4
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/ob-eval.el b/lisp/org/ob-eval.el
index 57f4dc509aa..a71cb0dd691 100644
--- a/lisp/org/ob-eval.el
+++ b/lisp/org/ob-eval.el
@@ -5,7 +5,7 @@
5;; Author: Eric Schulte 5;; Author: Eric Schulte
6;; Keywords: literate programming, reproducible research, comint 6;; Keywords: literate programming, reproducible research, comint
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 7.3 8;; Version: 7.4
9 9
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11 11
@@ -28,12 +28,13 @@
28;; shell commands. 28;; shell commands.
29 29
30;;; Code: 30;;; Code:
31(require 'ob)
32(eval-when-compile (require 'cl)) 31(eval-when-compile (require 'cl))
33 32
33(defvar org-babel-error-buffer-name "*Org-Babel Error Output*")
34
34(defun org-babel-eval-error-notify (exit-code stderr) 35(defun org-babel-eval-error-notify (exit-code stderr)
35 "Open a buffer to display STDERR and a message with the value of EXIT-CODE." 36 "Open a buffer to display STDERR and a message with the value of EXIT-CODE."
36 (let ((buf (get-buffer-create "*Org-Babel Error Output*"))) 37 (let ((buf (get-buffer-create org-babel-error-buffer-name)))
37 (with-current-buffer buf 38 (with-current-buffer buf
38 (goto-char (point-max)) 39 (goto-char (point-max))
39 (save-excursion (insert stderr))) 40 (save-excursion (insert stderr)))
@@ -44,7 +45,7 @@
44 "Run CMD on BODY. 45 "Run CMD on BODY.
45If CMD succeeds then return its results, otherwise display 46If CMD succeeds then return its results, otherwise display
46STDERR with `org-babel-eval-error-notify'." 47STDERR with `org-babel-eval-error-notify'."
47 (let ((err-buff (get-buffer-create "*Org-Babel Error*")) exit-code) 48 (let ((err-buff (get-buffer-create " *Org-Babel Error*")) exit-code)
48 (with-current-buffer err-buff (erase-buffer)) 49 (with-current-buffer err-buff (erase-buffer))
49 (with-temp-buffer 50 (with-temp-buffer
50 (insert body) 51 (insert body)
@@ -138,9 +139,9 @@ specifies the value of ERROR-BUFFER."
138 (if error-buffer 139 (if error-buffer
139 (make-temp-file 140 (make-temp-file
140 (expand-file-name "scor" 141 (expand-file-name "scor"
141 (or (unless (featurep 'xemacs) 142 (if (featurep 'xemacs)
142 small-temporary-file-directory) 143 (temp-directory)
143 temporary-file-directory))) 144 temporary-file-directory)))
144 nil)) 145 nil))
145 exit-status) 146 exit-status)
146 (if (or replace 147 (if (or replace
@@ -247,6 +248,13 @@ specifies the value of ERROR-BUFFER."
247 (delete-file error-file)) 248 (delete-file error-file))
248 exit-status)) 249 exit-status))
249 250
251(defun org-babel-eval-wipe-error-buffer ()
252 "Delete the contents of the Org code block error buffer.
253This buffer is named by `org-babel-error-buffer-name'."
254 (when (get-buffer org-babel-error-buffer-name)
255 (with-current-buffer org-babel-error-buffer-name
256 (delete-region (point-min) (point-max)))))
257
250(provide 'ob-eval) 258(provide 'ob-eval)
251 259
252;; arch-tag: 5328b17f-957d-42d9-94da-a2952682d04d 260;; arch-tag: 5328b17f-957d-42d9-94da-a2952682d04d
diff --git a/lisp/org/ob-exp.el b/lisp/org/ob-exp.el
index 52da00103f6..8b6914c903c 100644
--- a/lisp/org/ob-exp.el
+++ b/lisp/org/ob-exp.el
@@ -5,7 +5,7 @@
5;; Author: Eric Schulte, Dan Davison 5;; Author: Eric Schulte, Dan Davison
6;; Keywords: literate programming, reproducible research 6;; Keywords: literate programming, reproducible research
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 7.3 8;; Version: 7.4
9 9
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11 11
@@ -39,8 +39,7 @@
39(defvar org-babel-lob-one-liner-regexp) 39(defvar org-babel-lob-one-liner-regexp)
40(defvar org-babel-ref-split-regexp) 40(defvar org-babel-ref-split-regexp)
41(declare-function org-babel-lob-get-info "ob-lob" ()) 41(declare-function org-babel-lob-get-info "ob-lob" ())
42(declare-function org-babel-ref-literal "ob-ref" (ref)) 42(declare-function org-babel-eval-wipe-error-buffer "ob-eval" ())
43
44(add-to-list 'org-export-interblocks '(src org-babel-exp-inline-src-blocks)) 43(add-to-list 'org-export-interblocks '(src org-babel-exp-inline-src-blocks))
45(add-to-list 'org-export-interblocks '(lob org-babel-exp-lob-one-liners)) 44(add-to-list 'org-export-interblocks '(lob org-babel-exp-lob-one-liners))
46(add-hook 'org-export-blocks-postblock-hook 'org-exp-res/src-name-cleanup) 45(add-hook 'org-export-blocks-postblock-hook 'org-exp-res/src-name-cleanup)
@@ -289,6 +288,7 @@ inhibit insertion of results into the buffer."
289 (org-babel-process-params (nth 2 info)))) 288 (org-babel-process-params (nth 2 info))))
290 ;; skip code blocks which we can't evaluate 289 ;; skip code blocks which we can't evaluate
291 (when (fboundp (intern (concat "org-babel-execute:" lang))) 290 (when (fboundp (intern (concat "org-babel-execute:" lang)))
291 (org-babel-eval-wipe-error-buffer)
292 (if (equal type 'inline) 292 (if (equal type 'inline)
293 (let ((raw (org-babel-execute-src-block 293 (let ((raw (org-babel-execute-src-block
294 nil info '((:results . "silent")))) 294 nil info '((:results . "silent"))))
diff --git a/lisp/org/ob-gnuplot.el b/lisp/org/ob-gnuplot.el
index 053d154610b..423e47e8669 100644
--- a/lisp/org/ob-gnuplot.el
+++ b/lisp/org/ob-gnuplot.el
@@ -5,7 +5,7 @@
5;; Author: Eric Schulte 5;; Author: Eric Schulte
6;; Keywords: literate programming, reproducible research 6;; Keywords: literate programming, reproducible research
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 7.3 8;; Version: 7.4
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/ob-haskell.el b/lisp/org/ob-haskell.el
index 1ae8fba66b6..734e1f6c891 100644
--- a/lisp/org/ob-haskell.el
+++ b/lisp/org/ob-haskell.el
@@ -5,7 +5,7 @@
5;; Author: Eric Schulte 5;; Author: Eric Schulte
6;; Keywords: literate programming, reproducible research 6;; Keywords: literate programming, reproducible research
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 7.3 8;; Version: 7.4
9 9
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11 11
@@ -136,16 +136,7 @@ then create one. Return the initialized session."
136 "Convert RESULTS to an Emacs-lisp table or string. 136 "Convert RESULTS to an Emacs-lisp table or string.
137If RESULTS look like a table, then convert them into an 137If RESULTS look like a table, then convert them into an
138Emacs-lisp table, otherwise return the results as a string." 138Emacs-lisp table, otherwise return the results as a string."
139 (org-babel-read 139 (org-babel-script-escape results))
140 (if (and (stringp results) (string-match "^\\[.+\\]$" results))
141 (org-babel-read
142 (concat "'"
143 (replace-regexp-in-string
144 "\\[" "(" (replace-regexp-in-string
145 "\\]" ")" (replace-regexp-in-string
146 "," " " (replace-regexp-in-string
147 "'" "\"" results))))))
148 results)))
149 140
150(defun org-babel-haskell-var-to-haskell (var) 141(defun org-babel-haskell-var-to-haskell (var)
151 "Convert an elisp value VAR into a haskell variable. 142 "Convert an elisp value VAR into a haskell variable.
diff --git a/lisp/org/ob-js.el b/lisp/org/ob-js.el
index dc652a95c96..05f8ea41754 100644
--- a/lisp/org/ob-js.el
+++ b/lisp/org/ob-js.el
@@ -1,26 +1,28 @@
1;;; ob-js.el --- org-babel functions for Javascript 1;;; ob-js.el --- org-babel functions for Javascript
2 2
3;; Copyright (C) 2010 Free Software Foundation, Inc. 3;; Copyright (C) 2010 Free Software Foundation
4 4
5;; Author: Eric Schulte 5;; Author: Eric Schulte
6;; Keywords: literate programming, reproducible research, js 6;; Keywords: literate programming, reproducible research, js
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 7.3 8;; Version: 7.4
9 9
10;; This file is part of GNU Emacs. 10;;; License:
11 11
12;; GNU Emacs is free software: you can redistribute it and/or modify 12;; This program is free software; you can redistribute it and/or modify
13;; it under the terms of the GNU General Public License as published by 13;; it under the terms of the GNU General Public License as published by
14;; the Free Software Foundation, either version 3 of the License, or 14;; the Free Software Foundation; either version 3, or (at your option)
15;; (at your option) any later version. 15;; any later version.
16 16;;
17;; GNU Emacs is distributed in the hope that it will be useful, 17;; This program is distributed in the hope that it will be useful,
18;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20;; GNU General Public License for more details. 20;; GNU General Public License for more details.
21 21;;
22;; You should have received a copy of the GNU General Public License 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/>. 23;; along with GNU Emacs; see the file COPYING. If not, write to the
24;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25;; Boston, MA 02110-1301, USA.
24 26
25;;; Commentary: 27;;; Commentary:
26 28
@@ -33,7 +35,7 @@
33 35
34;; - a non-browser javascript engine such as node.js http://nodejs.org/ 36;; - a non-browser javascript engine such as node.js http://nodejs.org/
35;; or mozrepl http://wiki.github.com/bard/mozrepl/ 37;; or mozrepl http://wiki.github.com/bard/mozrepl/
36;; 38;;
37;; - for session based evaluation mozrepl and moz.el are required see 39;; - for session based evaluation mozrepl and moz.el are required see
38;; http://wiki.github.com/bard/mozrepl/emacs-integration for 40;; http://wiki.github.com/bard/mozrepl/emacs-integration for
39;; configuration instructions 41;; configuration instructions
diff --git a/lisp/org/ob-keys.el b/lisp/org/ob-keys.el
index e04d9ade6bc..af8190692cd 100644
--- a/lisp/org/ob-keys.el
+++ b/lisp/org/ob-keys.el
@@ -5,7 +5,7 @@
5;; Author: Eric Schulte 5;; Author: Eric Schulte
6;; Keywords: literate programming, reproducible research 6;; Keywords: literate programming, reproducible research
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 7.3 8;; Version: 7.4
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/ob-latex.el b/lisp/org/ob-latex.el
index f4cf0802de6..96afbcd92a6 100644
--- a/lisp/org/ob-latex.el
+++ b/lisp/org/ob-latex.el
@@ -5,7 +5,7 @@
5;; Author: Eric Schulte 5;; Author: Eric Schulte
6;; Keywords: literate programming, reproducible research 6;; Keywords: literate programming, reproducible research
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 7.3 8;; Version: 7.4
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/ob-ledger.el b/lisp/org/ob-ledger.el
index 33ec9d3a898..a02eb6fec86 100644
--- a/lisp/org/ob-ledger.el
+++ b/lisp/org/ob-ledger.el
@@ -5,7 +5,7 @@
5;; Author: Eric S Fraga 5;; Author: Eric S Fraga
6;; Keywords: literate programming, reproducible research, accounting 6;; Keywords: literate programming, reproducible research, accounting
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 7.3 8;; Version: 7.4
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/ob-lisp.el b/lisp/org/ob-lisp.el
index 3f9ac673279..600b79ee7af 100644
--- a/lisp/org/ob-lisp.el
+++ b/lisp/org/ob-lisp.el
@@ -1,27 +1,28 @@
1;;; ob-lisp.el --- org-babel functions for Common Lisp 1;;; ob-lisp.el --- org-babel functions for Common Lisp
2 2
3;; Copyright (C) 2010 Free Software Foundation, Inc. 3;; Copyright (C) 2010 Free Software Foundation
4 4
5;; Author: David T. O'Toole <dto@gnu.org> 5;; Author: David T. O'Toole <dto@gnu.org>, Eric Schulte
6;; Eric Schulte
7;; Keywords: literate programming, reproducible research, lisp 6;; Keywords: literate programming, reproducible research, lisp
8;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
9;; Version: 7.3 8;; Version: 7.4
10 9
11;; This file is part of GNU Emacs. 10;;; License:
12 11
13;; GNU Emacs is free software: you can redistribute it and/or modify 12;; This program is free software; you can redistribute it and/or modify
14;; it under the terms of the GNU General Public License as published by 13;; it under the terms of the GNU General Public License as published by
15;; the Free Software Foundation, either version 3 of the License, or 14;; the Free Software Foundation; either version 3, or (at your option)
16;; (at your option) any later version. 15;; any later version.
17 16;;
18;; GNU Emacs is distributed in the hope that it will be useful, 17;; This program is distributed in the hope that it will be useful,
19;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21;; GNU General Public License for more details. 20;; GNU General Public License for more details.
22 21;;
23;; You should have received a copy of the GNU General Public License 22;; You should have received a copy of the GNU General Public License
24;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. 23;; along with GNU Emacs; see the file COPYING. If not, write to the
24;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25;; Boston, MA 02110-1301, USA.
25 26
26;;; Commentary: 27;;; Commentary:
27 28
@@ -40,16 +41,18 @@
40(require 'ob-ref) 41(require 'ob-ref)
41(require 'ob-comint) 42(require 'ob-comint)
42(require 'ob-eval) 43(require 'ob-eval)
43(declare-function slime-eval "ext:slime" (form)) 44
45(declare-function slime-eval "ext:slime" (sexp &optional package))
46(declare-function slime-process "ext:slime" (&optional connection))
44(declare-function slime-connected-p "ext:slime" ()) 47(declare-function slime-connected-p "ext:slime" ())
45(declare-function slime-process "ext:slime" ())
46(require 'slime nil 'noerror)
47 48
48(defvar org-babel-default-header-args:lisp '() 49(defvar org-babel-default-header-args:lisp '()
49 "Default header arguments for lisp code blocks.") 50 "Default header arguments for lisp code blocks.")
50 51
51(defcustom org-babel-lisp-cmd "sbcl --script" 52(defcustom org-babel-lisp-cmd "sbcl --script"
52 "Name of command used to evaluate lisp blocks.") 53 "Name of command used to evaluate lisp blocks."
54 :group 'org-babel
55 :type 'string)
53 56
54(defun org-babel-expand-body:lisp (body params) 57(defun org-babel-expand-body:lisp (body params)
55 "Expand BODY according to PARAMS, return the expanded body." 58 "Expand BODY according to PARAMS, return the expanded body."
@@ -65,6 +68,7 @@
65(defun org-babel-execute:lisp (body params) 68(defun org-babel-execute:lisp (body params)
66 "Execute a block of Lisp code with org-babel. 69 "Execute a block of Lisp code with org-babel.
67This function is called by `org-babel-execute-src-block'" 70This function is called by `org-babel-execute-src-block'"
71 (require 'slime)
68 (message "executing Lisp source code block") 72 (message "executing Lisp source code block")
69 (let* ((session (org-babel-lisp-initiate-session 73 (let* ((session (org-babel-lisp-initiate-session
70 (cdr (assoc :session params)))) 74 (cdr (assoc :session params))))
@@ -96,6 +100,7 @@ This function is called by `org-babel-execute-src-block'"
96(defun org-babel-lisp-initiate-session (&optional session) 100(defun org-babel-lisp-initiate-session (&optional session)
97 "If there is not a current inferior-process-buffer in SESSION 101 "If there is not a current inferior-process-buffer in SESSION
98then create. Return the initialized session." 102then create. Return the initialized session."
103 (require 'slime)
99 (unless (string= session "none") 104 (unless (string= session "none")
100 (save-window-excursion 105 (save-window-excursion
101 (or (slime-connected-p) 106 (or (slime-connected-p)
diff --git a/lisp/org/ob-lob.el b/lisp/org/ob-lob.el
index 243666c0a1b..137a6bce9a3 100644
--- a/lisp/org/ob-lob.el
+++ b/lisp/org/ob-lob.el
@@ -2,11 +2,10 @@
2 2
3;; Copyright (C) 2009, 2010 Free Software Foundation, Inc. 3;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
4 4
5;; Author: Eric Schulte 5;; Author: Eric Schulte, Dan Davison
6;; Dan Davison
7;; Keywords: literate programming, reproducible research 6;; Keywords: literate programming, reproducible research
8;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
9;; Version: 7.3 8;; Version: 7.4
10 9
11;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
12 11
@@ -26,7 +25,7 @@
26;;; Commentary: 25;;; Commentary:
27 26
28;; See the online documentation for more information 27;; See the online documentation for more information
29;; 28;;
30;; http://orgmode.org/worg/org-contrib/babel/ 29;; http://orgmode.org/worg/org-contrib/babel/
31 30
32;;; Code: 31;;; Code:
@@ -72,7 +71,8 @@ If you change the value of this variable then your files may
72 (concat 71 (concat
73 "^\\([ \t]*\\)#\\+\\(?:" 72 "^\\([ \t]*\\)#\\+\\(?:"
74 (mapconcat #'regexp-quote org-babel-lob-call-aliases "\\|") 73 (mapconcat #'regexp-quote org-babel-lob-call-aliases "\\|")
75 "\\):[ \t]+\\([^\(\)\n]+\\)\(\\([^\n]*\\)\)\\(\\[.+\\]\\|\\)[ \t]*\\([^\n]*\\)") 74 "\\):[ \t]+\\([^\(\)\n]+?\\)\\(\\[\\(.*\\)\\]\\|\\(\\)\\)"
75 "\(\\([^\n]*\\)\)\\(\\[.+\\]\\|\\)[ \t]*\\([^\n]*\\)")
76 "Regexp to match calls to predefined source block functions.") 76 "Regexp to match calls to predefined source block functions.")
77 77
78;; functions for executing lob one-liners 78;; functions for executing lob one-liners
@@ -93,13 +93,16 @@ if so then run the appropriate source block from the Library."
93 (beginning-of-line 1) 93 (beginning-of-line 1)
94 (if (looking-at org-babel-lob-one-liner-regexp) 94 (if (looking-at org-babel-lob-one-liner-regexp)
95 (append 95 (append
96 (mapcar #'org-babel-clean-text-properties 96 (mapcar #'org-babel-clean-text-properties
97 (list 97 (list
98 (format "%s(%s)%s" 98 (format "%s%s(%s)%s"
99 (match-string 2) (match-string 3) (match-string 4)) 99 (match-string 2)
100 (match-string 5))) 100 (if (match-string 4)
101 (concat "[" (match-string 4) "]") "")
102 (or (match-string 6) "") (match-string 7))
103 (match-string 8)))
101 (list (length (match-string 1)))))))) 104 (list (length (match-string 1))))))))
102 105
103(defun org-babel-lob-execute (info) 106(defun org-babel-lob-execute (info)
104 "Execute the lob call specified by INFO." 107 "Execute the lob call specified by INFO."
105 (let ((params (org-babel-process-params 108 (let ((params (org-babel-process-params
diff --git a/lisp/org/ob-matlab.el b/lisp/org/ob-matlab.el
index c75d806cc62..192c73d9081 100644
--- a/lisp/org/ob-matlab.el
+++ b/lisp/org/ob-matlab.el
@@ -5,7 +5,7 @@
5;; Author: Dan Davison 5;; Author: Dan Davison
6;; Keywords: literate programming, reproducible research 6;; Keywords: literate programming, reproducible research
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 7.3 8;; Version: 7.4
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/ob-mscgen.el b/lisp/org/ob-mscgen.el
index 119d28cfba0..98230da56a3 100644
--- a/lisp/org/ob-mscgen.el
+++ b/lisp/org/ob-mscgen.el
@@ -5,7 +5,7 @@
5;; Author: Juan Pechiar 5;; Author: Juan Pechiar
6;; Keywords: literate programming, reproducible research 6;; Keywords: literate programming, reproducible research
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 7.3 8;; Version: 7.4
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/ob-ocaml.el b/lisp/org/ob-ocaml.el
index 2217118e537..459dcf336f7 100644
--- a/lisp/org/ob-ocaml.el
+++ b/lisp/org/ob-ocaml.el
@@ -5,7 +5,7 @@
5;; Author: Eric Schulte 5;; Author: Eric Schulte
6;; Keywords: literate programming, reproducible research 6;; Keywords: literate programming, reproducible research
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 7.3 8;; Version: 7.4
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/ob-octave.el b/lisp/org/ob-octave.el
index d6affecd74d..9fcd825f91e 100644
--- a/lisp/org/ob-octave.el
+++ b/lisp/org/ob-octave.el
@@ -5,7 +5,7 @@
5;; Author: Dan Davison 5;; Author: Dan Davison
6;; Keywords: literate programming, reproducible research 6;; Keywords: literate programming, reproducible research
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 7.3 8;; Version: 7.4
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/ob-org.el b/lisp/org/ob-org.el
index 86abbabfb13..c03fa07602a 100644
--- a/lisp/org/ob-org.el
+++ b/lisp/org/ob-org.el
@@ -5,7 +5,7 @@
5;; Author: Eric Schulte 5;; Author: Eric Schulte
6;; Keywords: literate programming, reproducible research 6;; Keywords: literate programming, reproducible research
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 7.3 8;; Version: 7.4
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/ob-perl.el b/lisp/org/ob-perl.el
index 23c0353fcb0..1e0cecb1af0 100644
--- a/lisp/org/ob-perl.el
+++ b/lisp/org/ob-perl.el
@@ -1,12 +1,11 @@
1;;; ob-perl.el --- org-babel functions for perl evaluation 1;;; ob-perl.el --- org-babel functions for perl evaluation
2 2
3;; Copyright (C) 2009, 2010 Free Software Foundation, Inc. 3;; Copyright (C) 2009, 2010 Free Software Foundation
4 4
5;; Author: Dan Davison 5;; Author: Dan Davison, Eric Schulte
6;; Eric Schulte
7;; Keywords: literate programming, reproducible research 6;; Keywords: literate programming, reproducible research
8;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
9;; Version: 7.3 8;; Version: 7.4
10 9
11;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
12 11
diff --git a/lisp/org/ob-plantuml.el b/lisp/org/ob-plantuml.el
index 37561020cb0..fb81dc8e60d 100644
--- a/lisp/org/ob-plantuml.el
+++ b/lisp/org/ob-plantuml.el
@@ -5,7 +5,7 @@
5;; Author: Zhang Weize 5;; Author: Zhang Weize
6;; Keywords: literate programming, reproducible research 6;; Keywords: literate programming, reproducible research
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 7.3 8;; Version: 7.4
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/ob-python.el b/lisp/org/ob-python.el
index 22cb5337d7a..27b69bff5ab 100644
--- a/lisp/org/ob-python.el
+++ b/lisp/org/ob-python.el
@@ -1,12 +1,11 @@
1;;; ob-python.el --- org-babel functions for python evaluation 1;;; ob-python.el --- org-babel functions for python evaluation
2 2
3;; Copyright (C) 2009, 2010 Free Software Foundation, Inc. 3;; Copyright (C) 2009, 2010 Free Software Foundation
4 4
5;; Author: Eric Schulte 5;; Author: Eric Schulte, Dan Davison
6;; Dan Davison
7;; Keywords: literate programming, reproducible research 6;; Keywords: literate programming, reproducible research
8;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
9;; Version: 7.3 8;; Version: 7.4
10 9
11;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
12 11
@@ -57,11 +56,15 @@ This function is called by `org-babel-execute-src-block'."
57 (cdr (assoc :session params)))) 56 (cdr (assoc :session params))))
58 (result-params (cdr (assoc :result-params params))) 57 (result-params (cdr (assoc :result-params params)))
59 (result-type (cdr (assoc :result-type params))) 58 (result-type (cdr (assoc :result-type params)))
59 (return-val (when (and (eq result-type 'value) (not session))
60 (cdr (assoc :return params))))
61 (preamble (cdr (assoc :preamble params)))
60 (full-body 62 (full-body
61 (org-babel-expand-body:generic 63 (org-babel-expand-body:generic
62 body params (org-babel-variable-assignments:python params))) 64 (concat body (if return-val (format "return %s" return-val) ""))
65 params (org-babel-variable-assignments:python params)))
63 (result (org-babel-python-evaluate 66 (result (org-babel-python-evaluate
64 session full-body result-type result-params))) 67 session full-body result-type result-params preamble)))
65 (or (cdr (assoc :file params)) 68 (or (cdr (assoc :file params))
66 (org-babel-reassemble-table 69 (org-babel-reassemble-table
67 result 70 result
@@ -118,20 +121,7 @@ specifying a variable of the same value."
118 "Convert RESULTS into an appropriate elisp value. 121 "Convert RESULTS into an appropriate elisp value.
119If the results look like a list or tuple, then convert them into an 122If the results look like a list or tuple, then convert them into an
120Emacs-lisp table, otherwise return the results as a string." 123Emacs-lisp table, otherwise return the results as a string."
121 ((lambda (res) 124 (org-babel-script-escape results))
122 (if (listp res)
123 (mapcar (lambda (el) (if (equal el 'None) 'hline el)) res)
124 res))
125 (org-babel-read
126 (if (and (stringp results) (string-match "^[([].+[])]$" results))
127 (org-babel-read
128 (concat "'"
129 (replace-regexp-in-string
130 "\\[" "(" (replace-regexp-in-string
131 "\\]" ")" (replace-regexp-in-string
132 ", " " " (replace-regexp-in-string
133 "'" "\"" results t))))))
134 results))))
135 125
136(defvar org-babel-python-buffers '((:default . nil))) 126(defvar org-babel-python-buffers '((:default . nil)))
137 127
@@ -192,35 +182,38 @@ def main():
192open('%s', 'w').write( pprint.pformat(main()) )") 182open('%s', 'w').write( pprint.pformat(main()) )")
193 183
194(defun org-babel-python-evaluate 184(defun org-babel-python-evaluate
195 (session body &optional result-type result-params) 185 (session body &optional result-type result-params preamble)
196 "Evaluate BODY as python code." 186 "Evaluate BODY as python code."
197 (if session 187 (if session
198 (org-babel-python-evaluate-session 188 (org-babel-python-evaluate-session
199 session body result-type result-params) 189 session body result-type result-params)
200 (org-babel-python-evaluate-external-process 190 (org-babel-python-evaluate-external-process
201 body result-type result-params))) 191 body result-type result-params preamble)))
202 192
203(defun org-babel-python-evaluate-external-process 193(defun org-babel-python-evaluate-external-process
204 (body &optional result-type result-params) 194 (body &optional result-type result-params preamble)
205 "Evaluate BODY in external python process. 195 "Evaluate BODY in external python process.
206If RESULT-TYPE equals 'output then return standard output as a 196If RESULT-TYPE equals 'output then return standard output as a
207string. If RESULT-TYPE equals 'value then return the value of the 197string. If RESULT-TYPE equals 'value then return the value of the
208last statement in BODY, as elisp." 198last statement in BODY, as elisp."
209 (case result-type 199 (case result-type
210 (output (org-babel-eval org-babel-python-command body)) 200 (output (org-babel-eval org-babel-python-command
201 (concat (if preamble (concat preamble "\n") "") body)))
211 (value (let ((tmp-file (org-babel-temp-file "python-"))) 202 (value (let ((tmp-file (org-babel-temp-file "python-")))
212 (org-babel-eval org-babel-python-command 203 (org-babel-eval org-babel-python-command
213 (format 204 (concat
214 (if (member "pp" result-params) 205 (if preamble (concat preamble "\n") "")
215 org-babel-python-pp-wrapper-method 206 (format
216 org-babel-python-wrapper-method) 207 (if (member "pp" result-params)
217 (mapconcat 208 org-babel-python-pp-wrapper-method
218 (lambda (line) (format "\t%s" line)) 209 org-babel-python-wrapper-method)
219 (split-string 210 (mapconcat
220 (org-remove-indentation 211 (lambda (line) (format "\t%s" line))
221 (org-babel-trim body)) 212 (split-string
222 "[\r\n]") "\n") 213 (org-remove-indentation
223 (org-babel-process-file-name tmp-file 'noquote))) 214 (org-babel-trim body))
215 "[\r\n]") "\n")
216 (org-babel-process-file-name tmp-file 'noquote))))
224 ((lambda (raw) 217 ((lambda (raw)
225 (if (or (member "code" result-params) 218 (if (or (member "code" result-params)
226 (member "pp" result-params)) 219 (member "pp" result-params))
@@ -240,7 +233,7 @@ last statement in BODY, as elisp."
240 (lambda (statement) (insert statement) (comint-send-input)) 233 (lambda (statement) (insert statement) (comint-send-input))
241 (if pp 234 (if pp
242 (list 235 (list
243 "import pp" 236 "import pprint"
244 (format "open('%s', 'w').write(pprint.pformat(_))" 237 (format "open('%s', 'w').write(pprint.pformat(_))"
245 (org-babel-process-file-name tmp-file 'noquote))) 238 (org-babel-process-file-name tmp-file 'noquote)))
246 (list (format "open('%s', 'w').write(str(_))" 239 (list (format "open('%s', 'w').write(str(_))"
diff --git a/lisp/org/ob-ref.el b/lisp/org/ob-ref.el
index e104d6bd693..2ca99ca651c 100644
--- a/lisp/org/ob-ref.el
+++ b/lisp/org/ob-ref.el
@@ -2,11 +2,10 @@
2 2
3;; Copyright (C) 2009, 2010 Free Software Foundation, Inc. 3;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
4 4
5;; Author: Eric Schulte 5;; Author: Eric Schulte, Dan Davison
6;; Dan Davison
7;; Keywords: literate programming, reproducible research 6;; Keywords: literate programming, reproducible research
8;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
9;; Version: 7.3 8;; Version: 7.4
10 9
11;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
12 11
@@ -52,11 +51,13 @@
52;;; Code: 51;;; Code:
53(require 'ob) 52(require 'ob)
54(eval-when-compile 53(eval-when-compile
54 (require 'org-list)
55 (require 'cl)) 55 (require 'cl))
56 56
57(declare-function org-remove-if-not "org" (predicate seq)) 57(declare-function org-remove-if-not "org" (predicate seq))
58(declare-function org-at-table-p "org" (&optional table-type)) 58(declare-function org-at-table-p "org" (&optional table-type))
59(declare-function org-count "org" (CL-ITEM CL-SEQ)) 59(declare-function org-count "org" (CL-ITEM CL-SEQ))
60(declare-function org-in-item-p "org-list" ())
60 61
61(defvar org-babel-ref-split-regexp 62(defvar org-babel-ref-split-regexp
62 "[ \f\t\n\r\v]*\\(.+?\\)[ \f\t\n\r\v]*=[ \f\t\n\r\v]*\\(.+\\)[ \f\t\n\r\v]*") 63 "[ \f\t\n\r\v]*\\(.+?\\)[ \f\t\n\r\v]*=[ \f\t\n\r\v]*\\(.+\\)[ \f\t\n\r\v]*")
@@ -74,46 +75,39 @@ the variable."
74 (let ((var (match-string 1 assignment)) 75 (let ((var (match-string 1 assignment))
75 (ref (match-string 2 assignment))) 76 (ref (match-string 2 assignment)))
76 (cons (intern var) 77 (cons (intern var)
77 ((lambda (val) 78 (let ((out (org-babel-read ref)))
78 (if (equal :ob-must-be-reference val) 79 (if (equal out ref)
79 (org-babel-ref-resolve ref) val)) 80 (if (string-match "^\".+\"$" ref)
80 (org-babel-ref-literal ref)))))) 81 (read ref)
81 82 (org-babel-ref-resolve ref))
82(defun org-babel-ref-literal (ref) 83 out))))))
83 "Return the value of REF if it is a literal value.
84Determine if the right side of a header argument variable
85assignment is a literal value or is a reference to some external
86resource. REF should be a string of the right hand side of the
87assignment. If REF is literal then return it's value, otherwise
88return nil."
89 (let ((out (org-babel-read ref)))
90 (if (equal out ref)
91 (if (string-match "^\".+\"$" ref)
92 (read ref)
93 :ob-must-be-reference)
94 out)))
95 84
96(defvar org-babel-library-of-babel) 85(defvar org-babel-library-of-babel)
97(defun org-babel-ref-resolve (ref) 86(defun org-babel-ref-resolve (ref)
98 "Resolve the reference REF and return its value." 87 "Resolve the reference REF and return its value."
99 (save-excursion 88 (save-excursion
100 (let ((case-fold-search t) 89 (let ((case-fold-search t)
101 type args new-refere new-referent result lob-info split-file split-ref 90 type args new-refere new-header-args new-referent result
102 index index-row index-col) 91 lob-info split-file split-ref index index-row index-col)
103 ;; if ref is indexed grab the indices -- beware nested indices 92 ;; if ref is indexed grab the indices -- beware nested indices
104 (when (and (string-match "\\[\\(.+\\)\\]" ref) 93 (when (and (string-match "\\[\\([^\\[]+\\)\\]$" ref)
105 (let ((str (substring ref 0 (match-beginning 0)))) 94 (let ((str (substring ref 0 (match-beginning 0))))
106 (= (org-count ?( str) (org-count ?) str)))) 95 (= (org-count ?( str) (org-count ?) str))))
107 (setq index (match-string 1 ref)) 96 (setq index (match-string 1 ref))
108 (setq ref (substring ref 0 (match-beginning 0)))) 97 (setq ref (substring ref 0 (match-beginning 0))))
109 ;; assign any arguments to pass to source block 98 ;; assign any arguments to pass to source block
110 (when (string-match "^\\(.+?\\)\(\\(.*\\)\)$" ref) 99 (when (string-match
111 (setq new-refere (match-string 1 ref)) 100 "^\\(.+?\\)\\(\\[\\(.*\\)\\]\\|\\(\\)\\)\(\\(.*\\)\)$" ref)
112 (setq new-referent (match-string 2 ref)) 101 (setq new-refere (match-string 1 ref))
102 (setq new-header-args (match-string 3 ref))
103 (setq new-referent (match-string 5 ref))
113 (when (> (length new-refere) 0) 104 (when (> (length new-refere) 0)
114 (if (> (length new-referent) 0) 105 (when (> (length new-referent) 0)
115 (setq args (mapcar (lambda (ref) (cons :var ref)) 106 (setq args (mapcar (lambda (ref) (cons :var ref))
116 (org-babel-ref-split-args new-referent)))) 107 (org-babel-ref-split-args new-referent))))
108 (when (> (length new-header-args) 0)
109 (setq args (append (org-babel-parse-header-arguments new-header-args)
110 args)))
117 (setq ref new-refere))) 111 (setq ref new-refere)))
118 (when (string-match "^\\(.+\\):\\(.+\\)$" ref) 112 (when (string-match "^\\(.+\\):\\(.+\\)$" ref)
119 (setq split-file (match-string 1 ref)) 113 (setq split-file (match-string 1 ref))
@@ -155,6 +149,7 @@ return nil."
155 (case type 149 (case type
156 ('results-line (org-babel-read-result)) 150 ('results-line (org-babel-read-result))
157 ('table (org-babel-read-table)) 151 ('table (org-babel-read-table))
152 ('list (org-babel-read-list))
158 ('file (org-babel-read-link)) 153 ('file (org-babel-read-link))
159 ('source-block (org-babel-execute-src-block nil nil params)) 154 ('source-block (org-babel-execute-src-block nil nil params))
160 ('lob (org-babel-execute-src-block nil lob-info params))))) 155 ('lob (org-babel-execute-src-block nil lob-info params)))))
@@ -222,6 +217,7 @@ to \"0:-1\"."
222Return nil if none of the supported reference types are found. 217Return nil if none of the supported reference types are found.
223Supported reference types are tables and source blocks." 218Supported reference types are tables and source blocks."
224 (cond ((org-at-table-p) 'table) 219 (cond ((org-at-table-p) 'table)
220 ((org-in-item-p) 'list)
225 ((looking-at "^[ \t]*#\\+BEGIN_SRC") 'source-block) 221 ((looking-at "^[ \t]*#\\+BEGIN_SRC") 'source-block)
226 ((looking-at org-bracket-link-regexp) 'file) 222 ((looking-at org-bracket-link-regexp) 'file)
227 ((looking-at org-babel-result-regexp) 'results-line))) 223 ((looking-at org-babel-result-regexp) 'results-line)))
diff --git a/lisp/org/ob-ruby.el b/lisp/org/ob-ruby.el
index 70b46411086..3f2af394603 100644
--- a/lisp/org/ob-ruby.el
+++ b/lisp/org/ob-ruby.el
@@ -1,11 +1,11 @@
1;;; ob-ruby.el --- org-babel functions for ruby evaluation 1;;; ob-ruby.el --- org-babel functions for ruby evaluation
2 2
3;; Copyright (C) 2009, 2010 Free Software Foundation, Inc. 3;; Copyright (C) 2009, 2010 Free Software Foundation
4 4
5;; Author: Eric Schulte 5;; Author: Eric Schulte
6;; Keywords: literate programming, reproducible research 6;; Keywords: literate programming, reproducible research
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 7.3 8;; Version: 7.4
9 9
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11 11
@@ -29,10 +29,10 @@
29;;; Requirements: 29;;; Requirements:
30 30
31;; - ruby and irb executables :: http://www.ruby-lang.org/ 31;; - ruby and irb executables :: http://www.ruby-lang.org/
32;; 32;;
33;; - ruby-mode :: Can be installed through ELPA, or from 33;; - ruby-mode :: Can be installed through ELPA, or from
34;; http://github.com/eschulte/rinari/raw/master/util/ruby-mode.el 34;; http://github.com/eschulte/rinari/raw/master/util/ruby-mode.el
35;; 35;;
36;; - inf-ruby mode :: Can be installed through ELPA, or from 36;; - inf-ruby mode :: Can be installed through ELPA, or from
37;; http://github.com/eschulte/rinari/raw/master/util/inf-ruby.el 37;; http://github.com/eschulte/rinari/raw/master/util/inf-ruby.el
38 38
@@ -116,16 +116,7 @@ specifying a variable of the same value."
116 "Convert RESULTS into an appropriate elisp value. 116 "Convert RESULTS into an appropriate elisp value.
117If RESULTS look like a table, then convert them into an 117If RESULTS look like a table, then convert them into an
118Emacs-lisp table, otherwise return the results as a string." 118Emacs-lisp table, otherwise return the results as a string."
119 (org-babel-read 119 (org-babel-script-escape results))
120 (if (and (stringp results) (string-match "^\\[.+\\]$" results))
121 (org-babel-read
122 (concat "'"
123 (replace-regexp-in-string
124 "\\[" "(" (replace-regexp-in-string
125 "\\]" ")" (replace-regexp-in-string
126 ", " " " (replace-regexp-in-string
127 "'" "\"" results))))))
128 results)))
129 120
130(defun org-babel-ruby-initiate-session (&optional session params) 121(defun org-babel-ruby-initiate-session (&optional session params)
131 "Initiate a ruby session. 122 "Initiate a ruby session.
diff --git a/lisp/org/ob-sass.el b/lisp/org/ob-sass.el
index 7f241e0320d..b3acc8b8d2c 100644
--- a/lisp/org/ob-sass.el
+++ b/lisp/org/ob-sass.el
@@ -5,7 +5,7 @@
5;; Author: Eric Schulte 5;; Author: Eric Schulte
6;; Keywords: literate programming, reproducible research 6;; Keywords: literate programming, reproducible research
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 7.3 8;; Version: 7.4
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/ob-scheme.el b/lisp/org/ob-scheme.el
index c0e0a3fb6f9..b2b9fa6a01d 100644
--- a/lisp/org/ob-scheme.el
+++ b/lisp/org/ob-scheme.el
@@ -1,26 +1,28 @@
1;;; ob-scheme.el --- org-babel functions for Scheme 1;;; ob-scheme.el --- org-babel functions for Scheme
2 2
3;; Copyright (C) 2010 Free Software Foundation, Inc. 3;; Copyright (C) 2010 Free Software Foundation
4 4
5;; Author: Eric Schulte 5;; Author: Eric Schulte
6;; Keywords: literate programming, reproducible research, scheme 6;; Keywords: literate programming, reproducible research, scheme
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 7.3 8;; Version: 7.4
9 9
10;; This file is part of GNU Emacs. 10;;; License:
11 11
12;; GNU Emacs is free software: you can redistribute it and/or modify 12;; This program is free software; you can redistribute it and/or modify
13;; it under the terms of the GNU General Public License as published by 13;; it under the terms of the GNU General Public License as published by
14;; the Free Software Foundation, either version 3 of the License, or 14;; the Free Software Foundation; either version 3, or (at your option)
15;; (at your option) any later version. 15;; any later version.
16 16;;
17;; GNU Emacs is distributed in the hope that it will be useful, 17;; This program is distributed in the hope that it will be useful,
18;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20;; GNU General Public License for more details. 20;; GNU General Public License for more details.
21 21;;
22;; You should have received a copy of the GNU General Public License 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/>. 23;; along with GNU Emacs; see the file COPYING. If not, write to the
24;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25;; Boston, MA 02110-1301, USA.
24 26
25;;; Commentary: 27;;; Commentary:
26 28
@@ -33,7 +35,7 @@
33 35
34;; - a working scheme implementation 36;; - a working scheme implementation
35;; (e.g. guile http://www.gnu.org/software/guile/guile.html) 37;; (e.g. guile http://www.gnu.org/software/guile/guile.html)
36;; 38;;
37;; - for session based evaluation cmuscheme.el is required which is 39;; - for session based evaluation cmuscheme.el is required which is
38;; included in Emacs 40;; included in Emacs
39 41
diff --git a/lisp/org/ob-screen.el b/lisp/org/ob-screen.el
index 206e51b19fe..7f4af795499 100644
--- a/lisp/org/ob-screen.el
+++ b/lisp/org/ob-screen.el
@@ -1,11 +1,11 @@
1;;; ob-screen.el --- org-babel support for interactive terminal 1;;; ob-screen.el --- org-babel support for interactive terminal
2 2
3;; Copyright (C) 2009, 2010 Free Software Foundation, Inc. 3;; Copyright (C) 2009, 2010 Free Software Foundation
4 4
5;; Author: Benjamin Andresen 5;; Author: Benjamin Andresen
6;; Keywords: literate programming, interactive shell 6;; Keywords: literate programming, interactive shell
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 7.3 8;; Version: 7.4
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/ob-sh.el b/lisp/org/ob-sh.el
index e86386426cd..e153d68b575 100644
--- a/lisp/org/ob-sh.el
+++ b/lisp/org/ob-sh.el
@@ -5,7 +5,7 @@
5;; Author: Eric Schulte 5;; Author: Eric Schulte
6;; Keywords: literate programming, reproducible research 6;; Keywords: literate programming, reproducible research
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 7.3 8;; Version: 7.4
9 9
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11 11
@@ -100,7 +100,7 @@ var of the same value."
100 (if (listp el) 100 (if (listp el)
101 (mapcar #'deep-string el) 101 (mapcar #'deep-string el)
102 (org-babel-sh-var-to-sh el sep)))) 102 (org-babel-sh-var-to-sh el sep))))
103 (format "$(cat <<BABEL_TABLE\n%s\nBABEL_TABLE\n)" 103 (format "$(cat <<'BABEL_TABLE'\n%s\nBABEL_TABLE\n)"
104 (orgtbl-to-generic 104 (orgtbl-to-generic
105 (deep-string (if (listp (car var)) var (list var))) 105 (deep-string (if (listp (car var)) var (list var)))
106 (list :sep (or sep "\t"))))) 106 (list :sep (or sep "\t")))))
@@ -114,16 +114,7 @@ var of the same value."
114 "Convert RESULTS to an appropriate elisp value. 114 "Convert RESULTS to an appropriate elisp value.
115If the results look like a table, then convert them into an 115If the results look like a table, then convert them into an
116Emacs-lisp table, otherwise return the results as a string." 116Emacs-lisp table, otherwise return the results as a string."
117 (org-babel-read 117 (org-babel-script-escape results))
118 (if (string-match "^\\[.+\\]$" results)
119 (org-babel-read
120 (concat "'"
121 (replace-regexp-in-string
122 "\\[" "(" (replace-regexp-in-string
123 "\\]" ")" (replace-regexp-in-string
124 ", " " " (replace-regexp-in-string
125 "'" "\"" results))))))
126 results)))
127 118
128(defun org-babel-sh-initiate-session (&optional session params) 119(defun org-babel-sh-initiate-session (&optional session params)
129 "Initiate a session named SESSION according to PARAMS." 120 "Initiate a session named SESSION according to PARAMS."
diff --git a/lisp/org/ob-sql.el b/lisp/org/ob-sql.el
index 78e8a3b4377..5bb123d631b 100644
--- a/lisp/org/ob-sql.el
+++ b/lisp/org/ob-sql.el
@@ -5,7 +5,7 @@
5;; Author: Eric Schulte 5;; Author: Eric Schulte
6;; Keywords: literate programming, reproducible research 6;; Keywords: literate programming, reproducible research
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 7.3 8;; Version: 7.4
9 9
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11 11
@@ -47,9 +47,15 @@
47(eval-when-compile (require 'cl)) 47(eval-when-compile (require 'cl))
48 48
49(declare-function org-table-import "org-table" (file arg)) 49(declare-function org-table-import "org-table" (file arg))
50(declare-function orgtbl-to-csv "org-table" (TABLE PARAMS))
50 51
51(defvar org-babel-default-header-args:sql '()) 52(defvar org-babel-default-header-args:sql '())
52 53
54(defun org-babel-expand-body:sql (body params)
55 "Expand BODY according to the values of PARAMS."
56 (org-babel-sql-expand-vars
57 body (mapcar #'cdr (org-babel-get-header params :var))))
58
53(defun org-babel-execute:sql (body params) 59(defun org-babel-execute:sql (body params)
54 "Execute a block of Sql code with Babel. 60 "Execute a block of Sql code with Babel.
55This function is called by `org-babel-execute-src-block'." 61This function is called by `org-babel-execute-src-block'."
@@ -60,6 +66,10 @@ This function is called by `org-babel-execute-src-block'."
60 (out-file (or (cdr (assoc :out-file params)) 66 (out-file (or (cdr (assoc :out-file params))
61 (org-babel-temp-file "sql-out-"))) 67 (org-babel-temp-file "sql-out-")))
62 (command (case (intern engine) 68 (command (case (intern engine)
69 ('msosql (format "osql %s -s \"\t\" -i %s -o %s"
70 (or cmdline "")
71 (org-babel-process-file-name in-file)
72 (org-babel-process-file-name out-file)))
63 ('mysql (format "mysql %s -e \"source %s\" > %s" 73 ('mysql (format "mysql %s -e \"source %s\" > %s"
64 (or cmdline "") 74 (or cmdline "")
65 (org-babel-process-file-name in-file) 75 (org-babel-process-file-name in-file)
@@ -70,11 +80,11 @@ This function is called by `org-babel-execute-src-block'."
70 (or cmdline ""))) 80 (or cmdline "")))
71 (t (error "no support for the %s sql engine" engine))))) 81 (t (error "no support for the %s sql engine" engine)))))
72 (with-temp-file in-file 82 (with-temp-file in-file
73 (insert (org-babel-expand-body:generic body params))) 83 (insert (org-babel-expand-body:sql body params)))
74 (message command) 84 (message command)
75 (shell-command command) 85 (shell-command command)
76 (with-temp-buffer 86 (with-temp-buffer
77 (org-table-import out-file nil) 87 (org-table-import out-file '(16))
78 (org-babel-reassemble-table 88 (org-babel-reassemble-table
79 (org-table-to-lisp) 89 (org-table-to-lisp)
80 (org-babel-pick-name (cdr (assoc :colname-names params)) 90 (org-babel-pick-name (cdr (assoc :colname-names params))
@@ -82,6 +92,28 @@ This function is called by `org-babel-execute-src-block'."
82 (org-babel-pick-name (cdr (assoc :rowname-names params)) 92 (org-babel-pick-name (cdr (assoc :rowname-names params))
83 (cdr (assoc :rownames params))))))) 93 (cdr (assoc :rownames params)))))))
84 94
95(defun org-babel-sql-expand-vars (body vars)
96 "Expand the variables held in VARS in BODY."
97 (mapc
98 (lambda (pair)
99 (setq body
100 (replace-regexp-in-string
101 (format "\$%s" (car pair))
102 ((lambda (val)
103 (if (listp val)
104 ((lambda (data-file)
105 (with-temp-file data-file
106 (insert (orgtbl-to-csv
107 val '(:fmt (lambda (el) (if (stringp el)
108 el
109 (format "%S" el)))))))
110 data-file)
111 (org-babel-temp-file "sql-data-"))
112 (if (stringp val) val (format "%S" val))))
113 (cdr pair))
114 body)))
115 vars)
116 body)
85 117
86(defun org-babel-prep-session:sql (session params) 118(defun org-babel-prep-session:sql (session params)
87 "Raise an error because Sql sessions aren't implemented." 119 "Raise an error because Sql sessions aren't implemented."
diff --git a/lisp/org/ob-sqlite.el b/lisp/org/ob-sqlite.el
index d1fa9ac4c5f..65e8091741f 100644
--- a/lisp/org/ob-sqlite.el
+++ b/lisp/org/ob-sqlite.el
@@ -1,11 +1,11 @@
1;;; ob-sqlite.el --- org-babel functions for sqlite database interaction 1;;; ob-sqlite.el --- org-babel functions for sqlite database interaction
2 2
3;; Copyright (C) 2010 Free Software Foundation, Inc. 3;; Copyright (C) 2010 Free Software Foundation
4 4
5;; Author: Eric Schulte 5;; Author: Eric Schulte
6;; Keywords: literate programming, reproducible research 6;; Keywords: literate programming, reproducible research
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 7.3 8;; Version: 7.4
9 9
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11 11
@@ -28,6 +28,7 @@
28 28
29;;; Code: 29;;; Code:
30(require 'ob) 30(require 'ob)
31(require 'ob-eval)
31(require 'ob-ref) 32(require 'ob-ref)
32 33
33(declare-function org-fill-template "org" (template alist)) 34(declare-function org-fill-template "org" (template alist))
@@ -52,7 +53,6 @@
52 "Execute a block of Sqlite code with Babel. 53 "Execute a block of Sqlite code with Babel.
53This function is called by `org-babel-execute-src-block'." 54This function is called by `org-babel-execute-src-block'."
54 (let ((result-params (split-string (or (cdr (assoc :results params)) ""))) 55 (let ((result-params (split-string (or (cdr (assoc :results params)) "")))
55 (vars (org-babel-get-header params :var))
56 (db (cdr (assoc :db params))) 56 (db (cdr (assoc :db params)))
57 (separator (cdr (assoc :separator params))) 57 (separator (cdr (assoc :separator params)))
58 (nullvalue (cdr (assoc :nullvalue params))) 58 (nullvalue (cdr (assoc :nullvalue params)))
@@ -65,15 +65,10 @@ This function is called by `org-babel-execute-src-block'."
65 (unless db (error "ob-sqlite: can't evaluate without a database.")) 65 (unless db (error "ob-sqlite: can't evaluate without a database."))
66 (with-temp-buffer 66 (with-temp-buffer
67 (insert 67 (insert
68 (shell-command-to-string 68 (org-babel-eval
69 (org-fill-template 69 (org-fill-template
70 "%cmd -init %body %header %separator %nullvalue %others %csv %db " 70 "%cmd %header %separator %nullvalue %others %csv %db "
71 (list 71 (list
72 (cons "body" ((lambda (sql-file)
73 (with-temp-file sql-file
74 (insert (org-babel-expand-body:sqlite body params)))
75 sql-file)
76 (org-babel-temp-file "sqlite-sql-")))
77 (cons "cmd" org-babel-sqlite3-command) 72 (cons "cmd" org-babel-sqlite3-command)
78 (cons "header" (if headers-p "-header" "-noheader")) 73 (cons "header" (if headers-p "-header" "-noheader"))
79 (cons "separator" 74 (cons "separator"
@@ -90,7 +85,9 @@ This function is called by `org-babel-execute-src-block'."
90 (member :html others) separator) 85 (member :html others) separator)
91 "" 86 ""
92 "-csv")) 87 "-csv"))
93 (cons "db " db))))) 88 (cons "db " db)))
89 ;; body of the code block
90 (org-babel-expand-body:sqlite body params)))
94 (if (or (member "scalar" result-params) 91 (if (or (member "scalar" result-params)
95 (member "html" result-params) 92 (member "html" result-params)
96 (member "code" result-params) 93 (member "code" result-params)
diff --git a/lisp/org/ob-table.el b/lisp/org/ob-table.el
index cdc7a6250fe..b7f9673c676 100644
--- a/lisp/org/ob-table.el
+++ b/lisp/org/ob-table.el
@@ -5,7 +5,7 @@
5;; Author: Eric Schulte 5;; Author: Eric Schulte
6;; Keywords: literate programming, reproducible research 6;; Keywords: literate programming, reproducible research
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 7.3 8;; Version: 7.4
9 9
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11 11
@@ -57,9 +57,9 @@
57 "Replace newline character with ellipses. 57 "Replace newline character with ellipses.
58If STRING ends in a newline character, then remove the newline 58If STRING ends in a newline character, then remove the newline
59character and replace it with ellipses." 59character and replace it with ellipses."
60 (if (and (stringp string) (string-match "[\n\r]" string)) 60 (if (and (stringp string) (string-match "[\n\r]\\(.\\)?" string))
61 (concat (substring string 0 (match-beginning 0)) "...") 61 (concat (substring string 0 (match-beginning 0))
62 string)) 62 (if (match-string 1 string) "...")) string))
63 63
64(defmacro sbe (source-block &rest variables) 64(defmacro sbe (source-block &rest variables)
65 "Return the results of calling SOURCE-BLOCK with VARIABLES. 65 "Return the results of calling SOURCE-BLOCK with VARIABLES.
diff --git a/lisp/org/ob-tangle.el b/lisp/org/ob-tangle.el
index e197ff37d36..c5ef2a1fcea 100644
--- a/lisp/org/ob-tangle.el
+++ b/lisp/org/ob-tangle.el
@@ -5,7 +5,7 @@
5;; Author: Eric Schulte 5;; Author: Eric Schulte
6;; Keywords: literate programming, reproducible research 6;; Keywords: literate programming, reproducible research
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 7.3 8;; Version: 7.4
9 9
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11 11
@@ -125,6 +125,7 @@ evaluating BODY."
125This function exports the source code using 125This function exports the source code using
126`org-babel-tangle' and then loads the resulting file using 126`org-babel-tangle' and then loads the resulting file using
127`load-file'." 127`load-file'."
128 (interactive "fFile to load: ")
128 (flet ((age (file) 129 (flet ((age (file)
129 (float-time 130 (float-time
130 (time-subtract (current-time) 131 (time-subtract (current-time)
diff --git a/lisp/org/ob.el b/lisp/org/ob.el
index fe068de549f..1c9f9fdbc12 100644
--- a/lisp/org/ob.el
+++ b/lisp/org/ob.el
@@ -2,11 +2,10 @@
2 2
3;; Copyright (C) 2009, 2010 Free Software Foundation, Inc. 3;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
4 4
5;; Author: Eric Schulte 5;; Author: Eric Schulte, Dan Davison
6;; Dan Davison
7;; Keywords: literate programming, reproducible research 6;; Keywords: literate programming, reproducible research
8;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
9;; Version: 7.3 8;; Version: 7.4
10 9
11;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
12 11
@@ -31,7 +30,9 @@
31 30
32;;; Code: 31;;; Code:
33(eval-when-compile 32(eval-when-compile
33 (require 'org-list)
34 (require 'cl)) 34 (require 'cl))
35(require 'ob-eval)
35(require 'org-macs) 36(require 'org-macs)
36 37
37(defvar org-babel-call-process-region-original) 38(defvar org-babel-call-process-region-original)
@@ -43,7 +44,7 @@
43(declare-function tramp-file-name-host "tramp" (vec)) 44(declare-function tramp-file-name-host "tramp" (vec))
44(declare-function with-parsed-tramp-file-name "tramp" (filename var &rest body)) 45(declare-function with-parsed-tramp-file-name "tramp" (filename var &rest body))
45(declare-function org-icompleting-read "org" (&rest args)) 46(declare-function org-icompleting-read "org" (&rest args))
46(declare-function org-edit-src-code "org-src" 47(declare-function org-edit-src-code "org-src"
47 (&optional context code edit-buffer-name quietp)) 48 (&optional context code edit-buffer-name quietp))
48(declare-function org-edit-src-exit "org-src" (&optional context)) 49(declare-function org-edit-src-exit "org-src" (&optional context))
49(declare-function org-open-at-point "org" (&optional in-emacs reference-buffer)) 50(declare-function org-open-at-point "org" (&optional in-emacs reference-buffer))
@@ -73,6 +74,10 @@
73(declare-function org-babel-ref-resolve "ob-ref" (ref)) 74(declare-function org-babel-ref-resolve "ob-ref" (ref))
74(declare-function org-babel-lob-execute-maybe "ob-lob" ()) 75(declare-function org-babel-lob-execute-maybe "ob-lob" ())
75(declare-function org-number-sequence "org-compat" (from &optional to inc)) 76(declare-function org-number-sequence "org-compat" (from &optional to inc))
77(declare-function org-in-item-p "org-list" ())
78(declare-function org-list-parse-list "org-list" (&optional delete))
79(declare-function org-list-to-generic "org-list" (LIST PARAMS))
80(declare-function org-list-bottom-point "org-list" ())
76 81
77(defgroup org-babel nil 82(defgroup org-babel nil
78 "Code block evaluation and management in `org-mode' documents." 83 "Code block evaluation and management in `org-mode' documents."
@@ -213,9 +218,13 @@ of potentially harmful code."
213 (if (or (equal eval "never") (equal eval "no") 218 (if (or (equal eval "never") (equal eval "no")
214 (and query 219 (and query
215 (not (yes-or-no-p 220 (not (yes-or-no-p
216 (format "Evaluate this%scode on your system? " 221 (format "Evaluate this%scode block%son your system? "
217 (if info (format " %s " (nth 0 info)) " ")))))) 222 (if info (format " %s " (nth 0 info)) " ")
218 (prog1 nil (message "evaluation aborted")) 223 (if (nth 4 info)
224 (format " (%s) " (nth 4 info)) " "))))))
225 (prog1 nil (message "Evaluation %s"
226 (if (or (equal eval "never") (equal eval "no"))
227 "Disabled" "Aborted")))
219 t))) 228 t)))
220 229
221;;;###autoload 230;;;###autoload
@@ -238,7 +247,8 @@ then run `org-babel-execute-src-block'."
238 (interactive) 247 (interactive)
239 (let ((info (org-babel-get-src-block-info))) 248 (let ((info (org-babel-get-src-block-info)))
240 (if info 249 (if info
241 (progn (org-babel-execute-src-block current-prefix-arg info) t) nil))) 250 (progn (org-babel-eval-wipe-error-buffer)
251 (org-babel-execute-src-block current-prefix-arg info) t) nil)))
242 252
243;;;###autoload 253;;;###autoload
244(defun org-babel-expand-src-block-maybe () 254(defun org-babel-expand-src-block-maybe ()
@@ -363,10 +373,12 @@ block."
363 (new-hash (when cache? (org-babel-sha1-hash info))) 373 (new-hash (when cache? (org-babel-sha1-hash info)))
364 (old-hash (when cache? (org-babel-result-hash info))) 374 (old-hash (when cache? (org-babel-result-hash info)))
365 (body (setf (nth 1 info) 375 (body (setf (nth 1 info)
366 (if (and (cdr (assoc :noweb params)) 376 (let ((noweb (cdr (assoc :noweb params))))
367 (string= "yes" (cdr (assoc :noweb params)))) 377 (if (and noweb
368 (org-babel-expand-noweb-references info) 378 (or (string= "yes" noweb)
369 (nth 1 info)))) 379 (string= "tangle" noweb)))
380 (org-babel-expand-noweb-references info)
381 (nth 1 info)))))
370 (cmd (intern (concat "org-babel-execute:" lang))) 382 (cmd (intern (concat "org-babel-execute:" lang)))
371 (dir (cdr (assoc :dir params))) 383 (dir (cdr (assoc :dir params)))
372 (default-directory 384 (default-directory
@@ -379,7 +391,7 @@ block."
379 result) 391 result)
380 (unwind-protect 392 (unwind-protect
381 (flet ((call-process-region (&rest args) 393 (flet ((call-process-region (&rest args)
382 (apply 'org-babel-tramp-handle-call-process-region args))) 394 (apply 'org-babel-tramp-handle-call-process-region args)))
383 (unless (fboundp cmd) 395 (unless (fboundp cmd)
384 (error "No org-babel-execute function for %s!" lang)) 396 (error "No org-babel-execute function for %s!" lang))
385 (if (and (not arg) new-hash (equal new-hash old-hash)) 397 (if (and (not arg) new-hash (equal new-hash old-hash))
@@ -584,6 +596,60 @@ results already exist."
584 t))) 596 t)))
585 597
586;;;###autoload 598;;;###autoload
599(defmacro org-babel-map-src-blocks (file &rest body)
600 "Evaluate BODY forms on each source-block in FILE.
601If FILE is nil evaluate BODY forms on source blocks in current
602buffer. During evaluation of BODY the following local variables
603are set relative to the currently matched code block.
604
605full-block ------- string holding the entirety of the code block
606beg-block -------- point at the beginning of the code block
607end-block -------- point at the end of the matched code block
608lang ------------- string holding the language of the code block
609beg-lang --------- point at the beginning of the lang
610end-lang --------- point at the end of the lang
611switches --------- string holding the switches
612beg-switches ----- point at the beginning of the switches
613end-switches ----- point at the end of the switches
614header-args ------ string holding the header-args
615beg-header-args -- point at the beginning of the header-args
616end-header-args -- point at the end of the header-args
617body ------------- string holding the body of the code block
618beg-body --------- point at the beginning of the body
619end-body --------- point at the end of the body"
620 (declare (indent 1))
621 (let ((tempvar (make-symbol "file")))
622 `(let* ((,tempvar ,file)
623 (visited-p (or (null ,tempvar)
624 (get-file-buffer (expand-file-name ,tempvar))))
625 (point (point)) to-be-removed)
626 (save-window-excursion
627 (when ,tempvar (find-file ,tempvar))
628 (setq to-be-removed (current-buffer))
629 (goto-char (point-min))
630 (while (re-search-forward org-babel-src-block-regexp nil t)
631 (goto-char (match-beginning 0))
632 (let ((full-block (match-string 0))
633 (beg-block (match-beginning 0))
634 (end-block (match-end 0))
635 (lang (match-string 2))
636 (beg-lang (match-beginning 2))
637 (end-lang (match-end 2))
638 (switches (match-string 3))
639 (beg-switches (match-beginning 3))
640 (end-switches (match-end 3))
641 (header-args (match-string 4))
642 (beg-header-args (match-beginning 4))
643 (end-header-args (match-end 4))
644 (body (match-string 5))
645 (beg-body (match-beginning 5))
646 (end-body (match-end 5)))
647 ,@body
648 (goto-char end-block))))
649 (unless visited-p (kill-buffer to-be-removed))
650 (goto-char point))))
651
652;;;###autoload
587(defun org-babel-execute-buffer (&optional arg) 653(defun org-babel-execute-buffer (&optional arg)
588 "Execute source code blocks in a buffer. 654 "Execute source code blocks in a buffer.
589Call `org-babel-execute-src-block' on every source block in 655Call `org-babel-execute-src-block' on every source block in
@@ -757,57 +823,6 @@ portions of results lines."
757 (lambda () (org-add-hook 'change-major-mode-hook 823 (lambda () (org-add-hook 'change-major-mode-hook
758 'org-babel-show-result-all 'append 'local))) 824 'org-babel-show-result-all 'append 'local)))
759 825
760(defmacro org-babel-map-src-blocks (file &rest body)
761 "Evaluate BODY forms on each source-block in FILE.
762If FILE is nil evaluate BODY forms on source blocks in current
763buffer. During evaluation of BODY the following local variables
764are set relative to the currently matched code block.
765
766full-block ------- string holding the entirety of the code block
767beg-block -------- point at the beginning of the code block
768end-block -------- point at the end of the matched code block
769lang ------------- string holding the language of the code block
770beg-lang --------- point at the beginning of the lang
771end-lang --------- point at the end of the lang
772switches --------- string holding the switches
773beg-switches ----- point at the beginning of the switches
774end-switches ----- point at the end of the switches
775header-args ------ string holding the header-args
776beg-header-args -- point at the beginning of the header-args
777end-header-args -- point at the end of the header-args
778body ------------- string holding the body of the code block
779beg-body --------- point at the beginning of the body
780end-body --------- point at the end of the body"
781 (declare (indent 1))
782 `(let ((visited-p (or (null ,file)
783 (get-file-buffer (expand-file-name ,file))))
784 (point (point)) to-be-removed)
785 (save-window-excursion
786 (when ,file (find-file ,file))
787 (setq to-be-removed (current-buffer))
788 (goto-char (point-min))
789 (while (re-search-forward org-babel-src-block-regexp nil t)
790 (goto-char (match-beginning 0))
791 (let ((full-block (match-string 0))
792 (beg-block (match-beginning 0))
793 (end-block (match-end 0))
794 (lang (match-string 2))
795 (beg-lang (match-beginning 2))
796 (end-lang (match-end 2))
797 (switches (match-string 3))
798 (beg-switches (match-beginning 3))
799 (end-switches (match-end 3))
800 (header-args (match-string 4))
801 (beg-header-args (match-beginning 4))
802 (end-header-args (match-end 4))
803 (body (match-string 5))
804 (beg-body (match-beginning 5))
805 (end-body (match-end 5)))
806 ,@body
807 (goto-char end-block))))
808 (unless visited-p (kill-buffer to-be-removed))
809 (goto-char point)))
810
811(defvar org-file-properties) 826(defvar org-file-properties)
812(defun org-babel-params-from-properties (&optional lang) 827(defun org-babel-params-from-properties (&optional lang)
813 "Retrieve parameters specified as properties. 828 "Retrieve parameters specified as properties.
@@ -893,17 +908,31 @@ may be specified at the top of the current buffer."
893 908
894(defun org-babel-parse-header-arguments (arg-string) 909(defun org-babel-parse-header-arguments (arg-string)
895 "Parse a string of header arguments returning an alist." 910 "Parse a string of header arguments returning an alist."
896 (if (> (length arg-string) 0) 911 (when (> (length arg-string) 0)
897 (delq nil 912 (delq nil
898 (mapcar 913 (mapcar
899 (lambda (arg) 914 (lambda (arg)
900 (if (string-match 915 (if (string-match
901 "\\([^ \f\t\n\r\v]+\\)[ \f\t\n\r\v]+\\([^ \f\t\n\r\v]+.*\\)" 916 "\\([^ \f\t\n\r\v]+\\)[ \f\t\n\r\v]+\\([^ \f\t\n\r\v]+.*\\)"
902 arg) 917 arg)
903 (cons (intern (concat ":" (match-string 1 arg))) 918 (cons (intern (match-string 1 arg))
904 (org-babel-read (org-babel-chomp (match-string 2 arg)))) 919 (org-babel-read (org-babel-chomp (match-string 2 arg))))
905 (cons (intern (concat ":" arg)) nil))) 920 (cons (intern (org-babel-chomp arg)) nil)))
906 (split-string (concat " " arg-string) "[ \f\t\n\r\v]+:" t))))) 921 (let ((balance 0) (partial nil) (lst nil) (last 0))
922 (mapc (lambda (ch) ; split on [] balanced instances of [ \t]:
923 (setq balance (+ balance
924 (cond ((equal 91 ch) 1)
925 ((equal 93 ch) -1)
926 (t 0))))
927 (setq partial (cons ch partial))
928 (when (and (= ch 58) (= balance 0)
929 (or (= last 32) (= last 9)))
930 (setq lst (cons (apply #'string (nreverse (cddr partial)))
931 lst))
932 (setq partial (list ch)))
933 (setq last ch))
934 (string-to-list arg-string))
935 (nreverse (cons (apply #'string (nreverse partial)) lst)))))))
907 936
908(defun org-babel-process-params (params) 937(defun org-babel-process-params (params)
909 "Expand variables in PARAMS and add summary parameters." 938 "Expand variables in PARAMS and add summary parameters."
@@ -1291,6 +1320,7 @@ following the source block."
1291 (let ((case-fold-search t) result-string) 1320 (let ((case-fold-search t) result-string)
1292 (cond 1321 (cond
1293 ((org-at-table-p) (org-babel-read-table)) 1322 ((org-at-table-p) (org-babel-read-table))
1323 ((org-in-item-p) (org-babel-read-list))
1294 ((looking-at org-bracket-link-regexp) (org-babel-read-link)) 1324 ((looking-at org-bracket-link-regexp) (org-babel-read-link))
1295 ((looking-at org-block-regexp) (org-babel-trim (match-string 4))) 1325 ((looking-at org-block-regexp) (org-babel-trim (match-string 4)))
1296 ((looking-at "^[ \t]*: ") 1326 ((looking-at "^[ \t]*: ")
@@ -1316,6 +1346,10 @@ following the source block."
1316 (mapcar #'org-babel-read row))) 1346 (mapcar #'org-babel-read row)))
1317 (org-table-to-lisp))) 1347 (org-table-to-lisp)))
1318 1348
1349(defun org-babel-read-list ()
1350 "Read the list at `point' into emacs-lisp."
1351 (mapcar #'org-babel-read (cdr (org-list-parse-list))))
1352
1319(defvar org-link-types-re) 1353(defvar org-link-types-re)
1320(defun org-babel-read-link () 1354(defun org-babel-read-link ()
1321 "Read the link at `point' into emacs-lisp. 1355 "Read the link at `point' into emacs-lisp.
@@ -1349,7 +1383,9 @@ silent -- no results are inserted
1349file ---- the results are interpreted as a file path, and are 1383file ---- the results are interpreted as a file path, and are
1350 inserted into the buffer using the Org-mode file syntax 1384 inserted into the buffer using the Org-mode file syntax
1351 1385
1352raw ----- results are added directly to the org-mode file. This 1386list ---- the results are interpreted as an Org-mode list.
1387
1388raw ----- results are added directly to the Org-mode file. This
1353 is a good option if you code block will output org-mode 1389 is a good option if you code block will output org-mode
1354 formatted text. 1390 formatted text.
1355 1391
@@ -1406,16 +1442,24 @@ code ---- the results are extracted in the syntax of the source
1406 ((member "replace" result-params) 1442 ((member "replace" result-params)
1407 (delete-region (point) (org-babel-result-end))) 1443 (delete-region (point) (org-babel-result-end)))
1408 ((member "append" result-params) 1444 ((member "append" result-params)
1409 (goto-char (org-babel-result-end)) (setq beg (point))) 1445 (goto-char (org-babel-result-end)) (setq beg (point-marker)))
1410 ((member "prepend" result-params) ;; already there 1446 ((member "prepend" result-params)))) ; already there
1411 )))
1412 (setq results-switches 1447 (setq results-switches
1413 (if results-switches (concat " " results-switches) "")) 1448 (if results-switches (concat " " results-switches) ""))
1449 ;; insert results based on type
1414 (cond 1450 (cond
1415 ;; do nothing for an empty result 1451 ;; do nothing for an empty result
1416 ((= (length result) 0)) 1452 ((= (length result) 0))
1453 ;; insert a list if preferred
1454 ((member "list" result-params)
1455 (insert
1456 (org-babel-trim
1457 (org-list-to-generic (cons 'unordered
1458 (if (listp result) result (list result)))
1459 '(:splicep nil :istart "- " :iend "\n")))))
1417 ;; assume the result is a table if it's not a string 1460 ;; assume the result is a table if it's not a string
1418 ((not (stringp result)) 1461 ((not (stringp result))
1462 (goto-char beg)
1419 (insert (concat (orgtbl-to-orgtbl 1463 (insert (concat (orgtbl-to-orgtbl
1420 (if (or (eq 'hline (car result)) 1464 (if (or (eq 'hline (car result))
1421 (and (listp (car result)) 1465 (and (listp (car result))
@@ -1425,24 +1469,34 @@ code ---- the results are extracted in the syntax of the source
1425 (goto-char beg) (when (org-at-table-p) (org-table-align))) 1469 (goto-char beg) (when (org-at-table-p) (org-table-align)))
1426 ((member "file" result-params) 1470 ((member "file" result-params)
1427 (insert result)) 1471 (insert result))
1428 ((member "html" result-params) 1472 (t (goto-char beg) (insert result)))
1429 (insert (format "#+BEGIN_HTML%s\n%s#+END_HTML\n" 1473 (when (listp result) (goto-char (org-table-end)))
1430 results-switches result))) 1474 (setq end (point-marker))
1431 ((member "latex" result-params) 1475 ;; possibly wrap result
1432 (insert (format "#+BEGIN_LaTeX%s\n%s#+END_LaTeX\n" 1476 (flet ((wrap (start finish)
1433 results-switches result))) 1477 (goto-char beg) (insert start)
1434 ((member "code" result-params) 1478 (goto-char end) (insert finish)
1435 (insert (format "#+BEGIN_SRC %s%s\n%s#+END_SRC\n" 1479 (setq end (point-marker))))
1436 (or lang "none") results-switches result))) 1480 (cond
1437 ((member "org" result-params) 1481 ((member "html" result-params)
1438 (insert (format "#+BEGIN_SRC org\n%s#+END_SRC\n" result))) 1482 (wrap "#+BEGIN_HTML\n" "#+END_HTML"))
1439 ((member "raw" result-params) 1483 ((member "latex" result-params)
1440 (save-excursion (insert result)) (if (org-at-table-p) (org-cycle))) 1484 (wrap "#+BEGIN_LaTeX\n" "#+END_LaTeX"))
1441 (t 1485 ((member "code" result-params)
1442 (org-babel-examplize-region 1486 (wrap (format "#+BEGIN_SRC %s%s\n" (or lang "none") results-switches)
1443 (point) (progn (insert result) (point)) results-switches))) 1487 "#+END_SRC"))
1488 ((member "org" result-params)
1489 (wrap "#+BEGIN_ORG\n" "#+END_ORG"))
1490 ((member "raw" result-params)
1491 (goto-char beg) (if (org-at-table-p) (org-cycle)))
1492 ((member "wrap" result-params)
1493 (when (and (stringp result) (not (member "file" result-params)))
1494 (org-babel-examplize-region beg end results-switches))
1495 (wrap "#+BEGIN_RESULT\n" "#+END_RESULT"))
1496 ((and (stringp result) (not (member "file" result-params)))
1497 (org-babel-examplize-region beg end results-switches)
1498 (setq end (point)))))
1444 ;; possibly indent the results to match the #+results line 1499 ;; possibly indent the results to match the #+results line
1445 (setq end (if (listp result) (org-table-end) (point)))
1446 (when (and indent (> indent 0) 1500 (when (and indent (> indent 0)
1447 ;; in this case `table-align' does the work for us 1501 ;; in this case `table-align' does the work for us
1448 (not (and (listp result) 1502 (not (and (listp result)
@@ -1450,9 +1504,9 @@ code ---- the results are extracted in the syntax of the source
1450 (indent-rigidly beg end indent)))) 1504 (indent-rigidly beg end indent))))
1451 (if (= (length result) 0) 1505 (if (= (length result) 0)
1452 (if (member "value" result-params) 1506 (if (member "value" result-params)
1453 (message "No result returned by source block") 1507 (message "Code block returned no value.")
1454 (message "Source block produced no output")) 1508 (message "Code block produced no output."))
1455 (message "finished")))) 1509 (message "Code block evaluation complete."))))
1456 1510
1457(defun org-babel-remove-result (&optional info) 1511(defun org-babel-remove-result (&optional info)
1458 "Remove the result of the current source block." 1512 "Remove the result of the current source block."
@@ -1466,25 +1520,18 @@ code ---- the results are extracted in the syntax of the source
1466(defun org-babel-result-end () 1520(defun org-babel-result-end ()
1467 "Return the point at the end of the current set of results" 1521 "Return the point at the end of the current set of results"
1468 (save-excursion 1522 (save-excursion
1469 (if (org-at-table-p) 1523 (cond
1470 (progn (goto-char (org-table-end)) (point)) 1524 ((org-at-table-p) (progn (goto-char (org-table-end)) (point)))
1471 (let ((case-fold-search t)) 1525 ((org-in-item-p) (- (org-list-bottom-point) 1))
1472 (cond 1526 (t
1473 ((looking-at "[ \t]*#\\+begin_latex") 1527 (let ((case-fold-search t)
1474 (re-search-forward "[ \t]*#\\+end_latex" nil t) 1528 (blocks-re (regexp-opt
1475 (forward-line 1)) 1529 (list "latex" "html" "example" "src" "result"))))
1476 ((looking-at "[ \t]*#\\+begin_html") 1530 (if (looking-at (concat "[ \t]*#\\+begin_" blocks-re))
1477 (re-search-forward "[ \t]*#\\+end_html" nil t) 1531 (re-search-forward (concat "[ \t]*#\\+end_" blocks-re) nil t)
1478 (forward-line 1)) 1532 (while (looking-at "[ \t]*\\(: \\|\\[\\[\\)")
1479 ((looking-at "[ \t]*#\\+begin_example") 1533 (forward-line 1))))
1480 (re-search-forward "[ \t]*#\\+end_example" nil t) 1534 (point)))))
1481 (forward-line 1))
1482 ((looking-at "[ \t]*#\\+begin_src")
1483 (re-search-forward "[ \t]*#\\+end_src" nil t)
1484 (forward-line 1))
1485 (t (progn (while (looking-at "[ \t]*\\(: \\|\\[\\[\\)")
1486 (forward-line 1))))))
1487 (point))))
1488 1535
1489(defun org-babel-result-to-file (result) 1536(defun org-babel-result-to-file (result)
1490 "Convert RESULT into an `org-mode' link. 1537 "Convert RESULT into an `org-mode' link.
@@ -1505,9 +1552,7 @@ file's directory then expand relative links."
1505 (interactive "*r") 1552 (interactive "*r")
1506 (let ((size (count-lines beg end))) 1553 (let ((size (count-lines beg end)))
1507 (save-excursion 1554 (save-excursion
1508 (cond ((= size 0) 1555 (cond ((= size 0)) ; do nothing for an empty result
1509 (error (concat "This should not be impossible:"
1510 "a newline was appended to result if missing")))
1511 ((< size org-babel-min-lines-for-block-output) 1556 ((< size org-babel-min-lines-for-block-output)
1512 (goto-char beg) 1557 (goto-char beg)
1513 (dotimes (n size) 1558 (dotimes (n size)
@@ -1517,7 +1562,7 @@ file's directory then expand relative links."
1517 (insert (if results-switches 1562 (insert (if results-switches
1518 (format "#+begin_example%s\n" results-switches) 1563 (format "#+begin_example%s\n" results-switches)
1519 "#+begin_example\n")) 1564 "#+begin_example\n"))
1520 (forward-char (- end beg)) 1565 (if (markerp end) (goto-char end) (forward-char (- end beg)))
1521 (insert "#+end_example\n")))))) 1566 (insert "#+end_example\n"))))))
1522 1567
1523(defun org-babel-update-block-body (new-body) 1568(defun org-babel-update-block-body (new-body)
@@ -1534,8 +1579,8 @@ Later elements of PLISTS override the values of previous element.
1534This takes into account some special considerations for certain 1579This takes into account some special considerations for certain
1535parameters when merging lists." 1580parameters when merging lists."
1536 (let ((results-exclusive-groups 1581 (let ((results-exclusive-groups
1537 '(("file" "vector" "table" "scalar" "raw" "org" 1582 '(("file" "list" "vector" "table" "scalar" "raw" "org"
1538 "html" "latex" "code" "pp") 1583 "html" "latex" "code" "pp" "wrap")
1539 ("replace" "silent" "append" "prepend") 1584 ("replace" "silent" "append" "prepend")
1540 ("output" "value"))) 1585 ("output" "value")))
1541 (exports-exclusive-groups 1586 (exports-exclusive-groups
@@ -1599,7 +1644,7 @@ parameters when merging lists."
1599 (:tangle ;; take the latest -- always overwrite 1644 (:tangle ;; take the latest -- always overwrite
1600 (setq tangle (or (list (cdr pair)) tangle))) 1645 (setq tangle (or (list (cdr pair)) tangle)))
1601 (:noweb 1646 (:noweb
1602 (setq noweb (e-merge '(("yes" "no")) noweb 1647 (setq noweb (e-merge '(("yes" "no" "tangle")) noweb
1603 (split-string (or (cdr pair) ""))))) 1648 (split-string (or (cdr pair) "")))))
1604 (:cache 1649 (:cache
1605 (setq cache (e-merge '(("yes" "no")) cache 1650 (setq cache (e-merge '(("yes" "no")) cache
@@ -1718,6 +1763,38 @@ block but are passed literally to the \"example-block\"."
1718 "Strip protective commas from bodies of source blocks." 1763 "Strip protective commas from bodies of source blocks."
1719 (replace-regexp-in-string "^,#" "#" body)) 1764 (replace-regexp-in-string "^,#" "#" body))
1720 1765
1766(defun org-babel-script-escape (str)
1767 "Safely convert tables into elisp lists."
1768 (let (in-single in-double out)
1769 (org-babel-read
1770 (if (and (stringp str) (string-match "^\\[.+\\]$" str))
1771 (org-babel-read
1772 (concat
1773 "'"
1774 (progn
1775 (mapc
1776 (lambda (ch)
1777 (setq
1778 out
1779 (case ch
1780 (91 (if (or in-double in-single) ; [
1781 (cons 91 out)
1782 (cons 40 out)))
1783 (93 (if (or in-double in-single) ; ]
1784 (cons 93 out)
1785 (cons 41 out)))
1786 (44 (if (or in-double in-single) (cons 44 out) out)) ; ,
1787 (39 (if in-double ; '
1788 (cons 39 out)
1789 (setq in-single (not in-single)) (cons 34 out)))
1790 (34 (if in-single ; "
1791 (append (list 34 32) out)
1792 (setq in-double (not in-double)) (cons 34 out)))
1793 (t (cons ch out)))))
1794 (string-to-list str))
1795 (apply #'string (reverse out)))))
1796 str))))
1797
1721(defun org-babel-read (cell) 1798(defun org-babel-read (cell)
1722 "Convert the string value of CELL to a number if appropriate. 1799 "Convert the string value of CELL to a number if appropriate.
1723Otherwise if cell looks like lisp (meaning it starts with a 1800Otherwise if cell looks like lisp (meaning it starts with a
@@ -1851,7 +1928,7 @@ of `org-babel-temporary-directory'."
1851 (if (file-remote-p default-directory) 1928 (if (file-remote-p default-directory)
1852 (make-temp-file 1929 (make-temp-file
1853 (concat (file-remote-p default-directory) 1930 (concat (file-remote-p default-directory)
1854 (expand-file-name 1931 (expand-file-name
1855 prefix temporary-file-directory) 1932 prefix temporary-file-directory)
1856 nil suffix)) 1933 nil suffix))
1857 (let ((temporary-file-directory 1934 (let ((temporary-file-directory
@@ -1865,17 +1942,22 @@ of `org-babel-temporary-directory'."
1865 (when (and (boundp 'org-babel-temporary-directory) 1942 (when (and (boundp 'org-babel-temporary-directory)
1866 (file-exists-p org-babel-temporary-directory)) 1943 (file-exists-p org-babel-temporary-directory))
1867 ;; taken from `delete-directory' in files.el 1944 ;; taken from `delete-directory' in files.el
1868 (mapc (lambda (file) 1945 (condition-case nil
1869 ;; This test is equivalent to 1946 (progn
1870 ;; (and (file-directory-p fn) (not (file-symlink-p fn))) 1947 (mapc (lambda (file)
1871 ;; but more efficient 1948 ;; This test is equivalent to
1872 (if (eq t (car (file-attributes file))) 1949 ;; (and (file-directory-p fn) (not (file-symlink-p fn)))
1873 (delete-directory file) 1950 ;; but more efficient
1874 (delete-file file))) 1951 (if (eq t (car (file-attributes file)))
1875 ;; We do not want to delete "." and "..". 1952 (delete-directory file)
1876 (directory-files org-babel-temporary-directory 'full 1953 (delete-file file)))
1877 "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*")) 1954 ;; We do not want to delete "." and "..".
1878 (delete-directory org-babel-temporary-directory))) 1955 (directory-files org-babel-temporary-directory 'full
1956 "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*"))
1957 (delete-directory org-babel-temporary-directory))
1958 (error
1959 (message "Failed to remove temporary Org-babel directory %s"
1960 org-babel-temporary-directory)))))
1879 1961
1880(add-hook 'kill-emacs-hook 'org-babel-remove-temporary-directory) 1962(add-hook 'kill-emacs-hook 'org-babel-remove-temporary-directory)
1881 1963
diff --git a/lisp/org/org-agenda.el b/lisp/org/org-agenda.el
index 1c9d6d4a3de..6bcbf62da02 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: 7.3 9;; Version: 7.4
10;; 10;;
11;; This file is part of GNU Emacs. 11;; This file is part of GNU Emacs.
12;; 12;;
@@ -242,8 +242,12 @@ you can \"misuse\" it to also add other text to the header. However,
242 (const org-agenda-prefix-format :value " %-12:c%?-12t% s") 242 (const org-agenda-prefix-format :value " %-12:c%?-12t% s")
243 (string)) 243 (string))
244 (list :tag "Number of days in agenda" 244 (list :tag "Number of days in agenda"
245 (const org-agenda-ndays) 245 (const org-agenda-span)
246 (integer :value 1)) 246 (choice (const :tag "Day" 'day)
247 (const :tag "Week" 'week)
248 (const :tag "Month" 'month)
249 (const :tag "Year" 'year)
250 (integer :tag "Custom")))
247 (list :tag "Fixed starting date" 251 (list :tag "Fixed starting date"
248 (const org-agenda-start-day) 252 (const org-agenda-start-day)
249 (string :value "2007-11-01")) 253 (string :value "2007-11-01"))
@@ -562,6 +566,33 @@ See also the variable `org-agenda-tags-todo-honor-ignore-options'."
562 :group 'org-agenda-todo-list 566 :group 'org-agenda-todo-list
563 :type 'boolean) 567 :type 'boolean)
564 568
569(defcustom org-agenda-todo-ignore-timestamp nil
570 "Non-nil means don't show entries with a timestamp.
571This applies when creating the global todo list.
572Valid values are:
573
574past Don't show entries for today or in the past.
575
576future Don't show entries with a timestamp in the future.
577 The idea behind this is that if it has a future
578 timestamp, you don't want to think about it until the
579 date.
580
581all Don't show any entries with a timestamp in the global todo list.
582 The idea behind this is that by setting a timestamp, you
583 have already \"taken care\" of this item.
584
585See also `org-agenda-todo-ignore-with-date'.
586See also the variable `org-agenda-tags-todo-honor-ignore-options' if you want
587to make his option also apply to the tags-todo list."
588 :group 'org-agenda-skip
589 :group 'org-agenda-todo-list
590 :type '(choice
591 (const :tag "Ignore future timestamp todos" future)
592 (const :tag "Ignore past or present timestamp todos" past)
593 (const :tag "Ignore all timestamp todos" all)
594 (const :tag "Show timestamp todos" nil)))
595
565(defcustom org-agenda-todo-ignore-scheduled nil 596(defcustom org-agenda-todo-ignore-scheduled nil
566 "Non-nil means, ignore some scheduled TODO items when making TODO list. 597 "Non-nil means, ignore some scheduled TODO items when making TODO list.
567This applies when creating the global todo list. 598This applies when creating the global todo list.
@@ -632,7 +663,8 @@ to make his option also apply to the tags-todo list."
632 "Non-nil means honor todo-list ...ignore options also in tags-todo search. 663 "Non-nil means honor todo-list ...ignore options also in tags-todo search.
633The variables 664The variables
634 `org-agenda-todo-ignore-with-date', 665 `org-agenda-todo-ignore-with-date',
635 `org-agenda-todo-ignore-scheduled' 666 `org-agenda-todo-ignore-timestamp',
667 `org-agenda-todo-ignore-scheduled',
636 `org-agenda-todo-ignore-deadlines' 668 `org-agenda-todo-ignore-deadlines'
637make the global TODO list skip entries that have time stamps of certain 669make the global TODO list skip entries that have time stamps of certain
638kinds. If this option is set, the same options will also apply for the 670kinds. If this option is set, the same options will also apply for the
@@ -860,12 +892,25 @@ option will be ignored."
860 :group 'org-agenda-windows 892 :group 'org-agenda-windows
861 :type 'boolean) 893 :type 'boolean)
862 894
863(defcustom org-agenda-ndays 7 895(defcustom org-agenda-ndays nil
864 "Number of days to include in overview display. 896 "Number of days to include in overview display.
865Should be 1 or 7. 897Should be 1 or 7.
898Obsolete, see `org-agenda-span'."
899 :group 'org-agenda-daily/weekly
900 :type 'integer)
901
902(make-obsolete-variable 'org-agenda-ndays 'org-agenda-span "24.1")
903
904(defcustom org-agenda-span 'week
905 "Number of days to include in overview display.
906Can be day, week, month, year, or any number of days.
866Custom commands can set this variable in the options section." 907Custom commands can set this variable in the options section."
867 :group 'org-agenda-daily/weekly 908 :group 'org-agenda-daily/weekly
868 :type 'integer) 909 :type '(choice (const :tag "Day" day)
910 (const :tag "Week" week)
911 (const :tag "Month" month)
912 (const :tag "Year" year)
913 (integer :tag "Custom")))
869 914
870(defcustom org-agenda-start-on-weekday 1 915(defcustom org-agenda-start-on-weekday 1
871 "Non-nil means start the overview always on the specified weekday. 916 "Non-nil means start the overview always on the specified weekday.
@@ -922,6 +967,35 @@ For example, 9:30am would become 09:30 rather than 9:30."
922 :group 'org-agenda-daily/weekly 967 :group 'org-agenda-daily/weekly
923 :type 'boolean) 968 :type 'boolean)
924 969
970(defcustom org-agenda-timegrid-use-ampm nil
971 "When set, show AM/PM style timestamps on the timegrid."
972 :group 'org-agenda
973 :type 'boolean)
974
975(defun org-agenda-time-of-day-to-ampm (time)
976 "Convert TIME of a string like '13:45' to an AM/PM style time string."
977 (let* ((hour-number (string-to-number (substring time 0 -3)))
978 (minute (substring time -2))
979 (ampm "am"))
980 (cond
981 ((equal hour-number 12)
982 (setq ampm "pm"))
983 ((> hour-number 12)
984 (setq ampm "pm")
985 (setq hour-number (- hour-number 12))))
986 (concat
987 (if org-agenda-time-leading-zero
988 (format "%02d" hour-number)
989 (format "%02s" (number-to-string hour-number)))
990 ":" minute ampm)))
991
992(defun org-agenda-time-of-day-to-ampm-maybe (time)
993 "Conditionally convert TIME to AM/PM format
994based on `org-agenda-timegrid-use-ampm'"
995 (if org-agenda-timegrid-use-ampm
996 (org-agenda-time-of-day-to-ampm time)
997 time))
998
925(defcustom org-agenda-weekend-days '(6 0) 999(defcustom org-agenda-weekend-days '(6 0)
926 "Which days are weekend? 1000 "Which days are weekend?
927These days get the special face `org-agenda-date-weekend' in the agenda 1001These days get the special face `org-agenda-date-weekend' in the agenda
@@ -1211,11 +1285,11 @@ When nil, such items are sorted as 0 minutes effort."
1211 :group 'org-agenda) 1285 :group 'org-agenda)
1212 1286
1213(defcustom org-agenda-prefix-format 1287(defcustom org-agenda-prefix-format
1214 '((agenda . " %-12:c%?-12t% s") 1288 '((agenda . " %i %-12:c%?-12t% s")
1215 (timeline . " % s") 1289 (timeline . " % s")
1216 (todo . " %-12:c") 1290 (todo . " %i %-12:c")
1217 (tags . " %-12:c") 1291 (tags . " %i %-12:c")
1218 (search . " %-12:c")) 1292 (search . " %i %-12:c"))
1219 "Format specifications for the prefix of items in the agenda views. 1293 "Format specifications for the prefix of items in the agenda views.
1220An alist with four entries, for the different agenda types. The keys to the 1294An alist with four entries, for the different agenda types. The keys to the
1221sublists are `agenda', `timeline', `todo', and `tags'. The values 1295sublists are `agenda', `timeline', `todo', and `tags'. The values
@@ -1224,6 +1298,8 @@ This format works similar to a printf format, with the following meaning:
1224 1298
1225 %c the category of the item, \"Diary\" for entries from the diary, or 1299 %c the category of the item, \"Diary\" for entries from the diary, or
1226 as given by the CATEGORY keyword or derived from the file name. 1300 as given by the CATEGORY keyword or derived from the file name.
1301 %i the icon category of the item, as give in
1302 `org-agenda-category-icon-alist'.
1227 %T the *last* tag of the item. Last because inherited tags come 1303 %T the *last* tag of the item. Last because inherited tags come
1228 first in the list. 1304 first in the list.
1229 %t the time-of-day specification if one applies to the entry, in the 1305 %t the time-of-day specification if one applies to the entry, in the
@@ -1431,6 +1507,52 @@ determines if it is a foreground or a background color."
1431 (string :tag "Color") 1507 (string :tag "Color")
1432 (sexp :tag "Face")))))) 1508 (sexp :tag "Face"))))))
1433 1509
1510(defcustom org-agenda-day-face-function nil
1511 "Function called to determine what face should be used to display a day.
1512The only argument passed to that function is the day. It should
1513returns a face, or nil if does not want to specify a face and let
1514the normal rules apply."
1515 :group 'org-agenda-line-format
1516 :type 'function)
1517
1518(defcustom org-agenda-category-icon-alist nil
1519 "Alist of category icon to be displayed in agenda views.
1520
1521Each entry should have the following format:
1522
1523 (CATEGORY-REGEXP FILE-OR-DATA TYPE DATA-P PROPS)
1524
1525Where CATEGORY-REGEXP is a regexp matching the categories where
1526the icon should be displayed.
1527FILE-OR-DATA either a file path or a string containing image data.
1528
1529The other fields can be ommited safely if not needed:
1530TYPE indicates the image type.
1531DATA-P is a boolean indicating whether the FILE-OR-DATA string is
1532image data.
1533PROPS are additional image attributes to assign to the image,
1534like, e.g. `:ascent center'.
1535
1536 (\"Org\" \"/path/to/icon.png\" nil nil :ascent center)
1537
1538If you want to set the display properties yourself, just put a
1539list as second element:
1540
1541 (CATEGORY-REGEXP (MY PROPERTY LIST))
1542
1543For example, to display a 16px horizontal space for Emacs
1544category, you can use:
1545
1546 (\"Emacs\" '(space . (:width (16))))"
1547 :group 'org-agenda-line-format
1548 :type '(alist :key-type (string :tag "Regexp matching category")
1549 :value-type (choice (list :tag "Icon"
1550 (string :tag "File or data")
1551 (symbol :tag "Type")
1552 (boolean :tag "Data?")
1553 (repeat :tag "Extra image properties" :inline t symbol))
1554 (list :tag "Display properties" sexp))))
1555
1434(defgroup org-agenda-column-view nil 1556(defgroup org-agenda-column-view nil
1435 "Options concerning column view in the agenda." 1557 "Options concerning column view in the agenda."
1436 :tag "Org Agenda Column View" 1558 :tag "Org Agenda Column View"
@@ -1720,19 +1842,19 @@ The following commands are available:
1720 ("View" 1842 ("View"
1721 ["Day View" org-agenda-day-view 1843 ["Day View" org-agenda-day-view
1722 :active (org-agenda-check-type nil 'agenda) 1844 :active (org-agenda-check-type nil 'agenda)
1723 :style radio :selected (equal org-agenda-ndays 1) 1845 :style radio :selected (eq org-agenda-current-span 'day)
1724 :keys "v d (or just d)"] 1846 :keys "v d (or just d)"]
1725 ["Week View" org-agenda-week-view 1847 ["Week View" org-agenda-week-view
1726 :active (org-agenda-check-type nil 'agenda) 1848 :active (org-agenda-check-type nil 'agenda)
1727 :style radio :selected (equal org-agenda-ndays 7) 1849 :style radio :selected (eq org-agenda-current-span 'week)
1728 :keys "v w (or just w)"] 1850 :keys "v w (or just w)"]
1729 ["Month View" org-agenda-month-view 1851 ["Month View" org-agenda-month-view
1730 :active (org-agenda-check-type nil 'agenda) 1852 :active (org-agenda-check-type nil 'agenda)
1731 :style radio :selected (member org-agenda-ndays '(28 29 30 31)) 1853 :style radio :selected (eq org-agenda-current-span 'month)
1732 :keys "v m"] 1854 :keys "v m"]
1733 ["Year View" org-agenda-year-view 1855 ["Year View" org-agenda-year-view
1734 :active (org-agenda-check-type nil 'agenda) 1856 :active (org-agenda-check-type nil 'agenda)
1735 :style radio :selected (member org-agenda-ndays '(365 366)) 1857 :style radio :selected (eq org-agenda-current-span 'year)
1736 :keys "v y"] 1858 :keys "v y"]
1737 "--" 1859 "--"
1738 ["Include Diary" org-agenda-toggle-diary 1860 ["Include Diary" org-agenda-toggle-diary
@@ -2778,6 +2900,7 @@ removed from the entry content. Currently only `planning' is allowed here."
2778(defvar org-agenda-columns-active nil) 2900(defvar org-agenda-columns-active nil)
2779(defvar org-agenda-name nil) 2901(defvar org-agenda-name nil)
2780(defvar org-agenda-filter nil) 2902(defvar org-agenda-filter nil)
2903(defvar org-agenda-filter-while-redo nil)
2781(defvar org-agenda-filter-preset nil 2904(defvar org-agenda-filter-preset nil
2782 "A preset of the tags filter used for secondary agenda filtering. 2905 "A preset of the tags filter used for secondary agenda filtering.
2783This must be a list of strings, each string must be a single tag preceded 2906This must be a list of strings, each string must be a single tag preceded
@@ -3065,6 +3188,16 @@ no longer in use."
3065 (progn (delete-overlay o) t))) 3188 (progn (delete-overlay o) t)))
3066 (overlays-in (point-min) (point-max))))) 3189 (overlays-in (point-min) (point-max)))))
3067 3190
3191(defun org-agenda-get-day-face (date)
3192 "Return the face DATE should be displayed with."
3193 (or (and (functionp org-agenda-day-face-function)
3194 (funcall org-agenda-day-face-function date))
3195 (cond ((org-agenda-todayp date)
3196 'org-agenda-date-today)
3197 ((member (calendar-day-of-week date) org-agenda-weekend-days)
3198 'org-agenda-date-weekend)
3199 (t 'org-agenda-date))))
3200
3068;;; Agenda timeline 3201;;; Agenda timeline
3069 3202
3070(defvar org-agenda-only-exact-dates nil) ; dynamically scoped 3203(defvar org-agenda-only-exact-dates nil) ; dynamically scoped
@@ -3092,10 +3225,10 @@ dates."
3092 org-timeline-show-empty-dates)) 3225 org-timeline-show-empty-dates))
3093 (org-deadline-warning-days 0) 3226 (org-deadline-warning-days 0)
3094 (org-agenda-only-exact-dates t) 3227 (org-agenda-only-exact-dates t)
3095 (today (time-to-days (current-time))) 3228 (today (org-today))
3096 (past t) 3229 (past t)
3097 args 3230 args
3098 s e rtn d emptyp wd) 3231 s e rtn d emptyp)
3099 (setq org-agenda-redo-command 3232 (setq org-agenda-redo-command
3100 (list 'progn 3233 (list 'progn
3101 (list 'org-switch-to-buffer-other-window (current-buffer)) 3234 (list 'org-switch-to-buffer-other-window (current-buffer))
@@ -3129,8 +3262,7 @@ dates."
3129 (progn 3262 (progn
3130 (setq past nil) 3263 (setq past nil)
3131 (insert (make-string 79 ?-) "\n"))) 3264 (insert (make-string 79 ?-) "\n")))
3132 (setq date (calendar-gregorian-from-absolute d) 3265 (setq date (calendar-gregorian-from-absolute d))
3133 wd (calendar-day-of-week date))
3134 (setq s (point)) 3266 (setq s (point))
3135 (setq rtn (and (not emptyp) 3267 (setq rtn (and (not emptyp)
3136 (apply 'org-agenda-get-day-entries entry 3268 (apply 'org-agenda-get-day-entries entry
@@ -3144,9 +3276,7 @@ dates."
3144 (funcall org-agenda-format-date date)) 3276 (funcall org-agenda-format-date date))
3145 "\n") 3277 "\n")
3146 (put-text-property s (1- (point)) 'face 3278 (put-text-property s (1- (point)) 'face
3147 (if (member wd org-agenda-weekend-days) 3279 (org-agenda-get-day-face date))
3148 'org-agenda-date-weekend
3149 'org-agenda-date))
3150 (put-text-property s (1- (point)) 'org-date-line t) 3280 (put-text-property s (1- (point)) 'org-date-line t)
3151 (put-text-property s (1- (point)) 'org-agenda-date-header t) 3281 (put-text-property s (1- (point)) 'org-agenda-date-header t)
3152 (if (equal d today) 3282 (if (equal d today)
@@ -3172,7 +3302,7 @@ When EMPTY is non-nil, also include days without any entries."
3172 (if inactive org-ts-regexp-both org-ts-regexp))) 3302 (if inactive org-ts-regexp-both org-ts-regexp)))
3173 dates dates1 date day day1 day2 ts1 ts2) 3303 dates dates1 date day day1 day2 ts1 ts2)
3174 (if force-today 3304 (if force-today
3175 (setq dates (list (time-to-days (current-time))))) 3305 (setq dates (list (org-today))))
3176 (save-excursion 3306 (save-excursion
3177 (goto-char beg) 3307 (goto-char beg)
3178 (while (re-search-forward re end t) 3308 (while (re-search-forward re end t)
@@ -3210,7 +3340,8 @@ When EMPTY is non-nil, also include days without any entries."
3210(defvar org-agenda-last-arguments nil 3340(defvar org-agenda-last-arguments nil
3211 "The arguments of the previous call to `org-agenda'.") 3341 "The arguments of the previous call to `org-agenda'.")
3212(defvar org-starting-day nil) ; local variable in the agenda buffer 3342(defvar org-starting-day nil) ; local variable in the agenda buffer
3213(defvar org-agenda-span nil) ; local variable in the agenda buffer 3343(defvar org-agenda-current-span nil
3344 "The current span used in the agenda view.") ; local variable in the agenda buffer
3214(defvar org-include-all-loc nil) ; local variable 3345(defvar org-include-all-loc nil) ; local variable
3215 3346
3216(defvar org-agenda-entry-types '(:deadline :scheduled :timestamp :sexp) 3347(defvar org-agenda-entry-types '(:deadline :scheduled :timestamp :sexp)
@@ -3247,7 +3378,7 @@ somewhat less efficient) way of determining what is included in
3247the daily/weekly agenda, see `org-agenda-skip-function'.") 3378the daily/weekly agenda, see `org-agenda-skip-function'.")
3248 3379
3249;;;###autoload 3380;;;###autoload
3250(defun org-agenda-list (&optional include-all start-day ndays) 3381(defun org-agenda-list (&optional include-all start-day span)
3251 "Produce a daily/weekly view from all files in variable `org-agenda-files'. 3382 "Produce a daily/weekly view from all files in variable `org-agenda-files'.
3252The view will be for the current day or week, but from the overview buffer 3383The view will be for the current day or week, but from the overview buffer
3253you will be able to go to other days/weeks. 3384you will be able to go to other days/weeks.
@@ -3258,37 +3389,36 @@ This feature is considered obsolete, please use the TODO list or a block
3258agenda instead. 3389agenda instead.
3259 3390
3260With a numeric prefix argument in an interactive call, the agenda will 3391With a numeric prefix argument in an interactive call, the agenda will
3261span INCLUDE-ALL days. Lisp programs should instead specify NDAYS to change 3392span INCLUDE-ALL days. Lisp programs should instead specify SPAN to change
3262the number of days. NDAYS defaults to `org-agenda-ndays'. 3393the number of days. SPAN defaults to `org-agenda-span'.
3263 3394
3264START-DAY defaults to TODAY, or to the most recent match for the weekday 3395START-DAY defaults to TODAY, or to the most recent match for the weekday
3265given in `org-agenda-start-on-weekday'." 3396given in `org-agenda-start-on-weekday'."
3266 (interactive "P") 3397 (interactive "P")
3267 (if (and (integerp include-all) (> include-all 0)) 3398 (if (and (integerp include-all) (> include-all 0))
3268 (setq ndays include-all include-all nil)) 3399 (setq span include-all include-all nil))
3269 (setq ndays (or ndays org-agenda-ndays) 3400 (setq start-day (or start-day org-agenda-start-day))
3270 start-day (or start-day org-agenda-start-day))
3271 (if org-agenda-overriding-arguments 3401 (if org-agenda-overriding-arguments
3272 (setq include-all (car org-agenda-overriding-arguments) 3402 (setq include-all (car org-agenda-overriding-arguments)
3273 start-day (nth 1 org-agenda-overriding-arguments) 3403 start-day (nth 1 org-agenda-overriding-arguments)
3274 ndays (nth 2 org-agenda-overriding-arguments))) 3404 span (nth 2 org-agenda-overriding-arguments)))
3275 (if (stringp start-day) 3405 (if (stringp start-day)
3276 ;; Convert to an absolute day number 3406 ;; Convert to an absolute day number
3277 (setq start-day (time-to-days (org-read-date nil t start-day)))) 3407 (setq start-day (time-to-days (org-read-date nil t start-day))))
3278 (setq org-agenda-last-arguments (list include-all start-day ndays)) 3408 (setq org-agenda-last-arguments (list include-all start-day span))
3279 (org-compile-prefix-format 'agenda) 3409 (org-compile-prefix-format 'agenda)
3280 (org-set-sorting-strategy 'agenda) 3410 (org-set-sorting-strategy 'agenda)
3281 (let* ((org-agenda-start-on-weekday 3411 (let* ((span (org-agenda-ndays-to-span (or span org-agenda-ndays org-agenda-span)))
3282 (if (or (equal ndays 7) (and (null ndays) (equal 7 org-agenda-ndays))) 3412 (today (org-today))
3283 org-agenda-start-on-weekday nil)) 3413 (sd (or start-day today))
3414 (ndays (org-agenda-span-to-ndays span sd))
3415 (org-agenda-start-on-weekday
3416 (if (eq ndays 7)
3417 org-agenda-start-on-weekday))
3284 (thefiles (org-agenda-files nil 'ifmode)) 3418 (thefiles (org-agenda-files nil 'ifmode))
3285 (files thefiles) 3419 (files thefiles)
3286 (today (time-to-days
3287 (time-subtract (current-time)
3288 (list 0 (* 3600 org-extend-today-until) 0))))
3289 (sd (or start-day today))
3290 (start (if (or (null org-agenda-start-on-weekday) 3420 (start (if (or (null org-agenda-start-on-weekday)
3291 (< org-agenda-ndays 7)) 3421 (< ndays 7))
3292 sd 3422 sd
3293 (let* ((nt (calendar-day-of-week 3423 (let* ((nt (calendar-day-of-week
3294 (calendar-gregorian-from-absolute sd))) 3424 (calendar-gregorian-from-absolute sd)))
@@ -3298,24 +3428,19 @@ given in `org-agenda-start-on-weekday'."
3298 (day-numbers (list start)) 3428 (day-numbers (list start))
3299 (day-cnt 0) 3429 (day-cnt 0)
3300 (inhibit-redisplay (not debug-on-error)) 3430 (inhibit-redisplay (not debug-on-error))
3301 s e rtn rtnall file date d start-pos end-pos todayp nd wd 3431 s e rtn rtnall file date d start-pos end-pos todayp
3302 clocktable-start clocktable-end) 3432 clocktable-start clocktable-end filter)
3303 (setq org-agenda-redo-command 3433 (setq org-agenda-redo-command
3304 (list 'org-agenda-list (list 'quote include-all) start-day ndays)) 3434 (list 'org-agenda-list (list 'quote include-all) start-day (list 'quote span)))
3305 ;; Make the list of days 3435 (dotimes (n (1- ndays))
3306 (setq ndays (or ndays org-agenda-ndays) 3436 (push (1+ (car day-numbers)) day-numbers))
3307 nd ndays)
3308 (while (> ndays 1)
3309 (push (1+ (car day-numbers)) day-numbers)
3310 (setq ndays (1- ndays)))
3311 (setq day-numbers (nreverse day-numbers)) 3437 (setq day-numbers (nreverse day-numbers))
3312 (setq clocktable-start (car day-numbers) 3438 (setq clocktable-start (car day-numbers)
3313 clocktable-end (1+ (or (org-last day-numbers) 0))) 3439 clocktable-end (1+ (or (org-last day-numbers) 0)))
3314 (org-prepare-agenda "Day/Week") 3440 (org-prepare-agenda "Day/Week")
3315 (org-set-local 'org-starting-day (car day-numbers)) 3441 (org-set-local 'org-starting-day (car day-numbers))
3316 (org-set-local 'org-include-all-loc include-all) 3442 (org-set-local 'org-include-all-loc include-all)
3317 (org-set-local 'org-agenda-span 3443 (org-set-local 'org-agenda-current-span (org-agenda-ndays-to-span span))
3318 (org-agenda-ndays-to-span nd))
3319 (when (and (or include-all org-agenda-include-all-todo) 3444 (when (and (or include-all org-agenda-include-all-todo)
3320 (member today day-numbers)) 3445 (member today day-numbers))
3321 (setq files thefiles 3446 (setq files thefiles
@@ -3343,7 +3468,7 @@ given in `org-agenda-start-on-weekday'."
3343 (if org-agenda-overriding-header 3468 (if org-agenda-overriding-header
3344 (insert (org-add-props (copy-sequence org-agenda-overriding-header) 3469 (insert (org-add-props (copy-sequence org-agenda-overriding-header)
3345 nil 'face 'org-agenda-structure) "\n") 3470 nil 'face 'org-agenda-structure) "\n")
3346 (insert (capitalize (symbol-name (org-agenda-ndays-to-span nd))) 3471 (insert (org-agenda-span-name span)
3347 "-agenda" 3472 "-agenda"
3348 (if (< (- d2 d1) 350) 3473 (if (< (- d2 d1) 350)
3349 (if (= w1 w2) 3474 (if (= w1 w2)
@@ -3356,7 +3481,6 @@ given in `org-agenda-start-on-weekday'."
3356 (org-agenda-mark-header-line s)) 3481 (org-agenda-mark-header-line s))
3357 (while (setq d (pop day-numbers)) 3482 (while (setq d (pop day-numbers))
3358 (setq date (calendar-gregorian-from-absolute d) 3483 (setq date (calendar-gregorian-from-absolute d)
3359 wd (calendar-day-of-week date)
3360 s (point)) 3484 s (point))
3361 (if (or (setq todayp (= d today)) 3485 (if (or (setq todayp (= d today))
3362 (and (not start-pos) (= d sd))) 3486 (and (not start-pos) (= d sd)))
@@ -3400,19 +3524,16 @@ given in `org-agenda-start-on-weekday'."
3400 (funcall org-agenda-format-date date)) 3524 (funcall org-agenda-format-date date))
3401 "\n") 3525 "\n")
3402 (put-text-property s (1- (point)) 'face 3526 (put-text-property s (1- (point)) 'face
3403 (if (member wd org-agenda-weekend-days) 3527 (org-agenda-get-day-face date))
3404 'org-agenda-date-weekend
3405 'org-agenda-date))
3406 (put-text-property s (1- (point)) 'org-date-line t) 3528 (put-text-property s (1- (point)) 'org-date-line t)
3407 (put-text-property s (1- (point)) 'org-agenda-date-header t) 3529 (put-text-property s (1- (point)) 'org-agenda-date-header t)
3408 (put-text-property s (1- (point)) 'org-day-cnt day-cnt) 3530 (put-text-property s (1- (point)) 'org-day-cnt day-cnt)
3409 (when todayp 3531 (when todayp
3410 (put-text-property s (1- (point)) 'org-today t) 3532 (put-text-property s (1- (point)) 'org-today t))
3411 (put-text-property s (1- (point)) 'face 'org-agenda-date-today))
3412 (if rtnall (insert 3533 (if rtnall (insert
3413 (org-finalize-agenda-entries 3534 (org-finalize-agenda-entries
3414 (org-agenda-add-time-grid-maybe 3535 (org-agenda-add-time-grid-maybe
3415 rtnall nd todayp)) 3536 rtnall ndays todayp))
3416 "\n")) 3537 "\n"))
3417 (put-text-property s (1- (point)) 'day d) 3538 (put-text-property s (1- (point)) 'day d)
3418 (put-text-property s (1- (point)) 'org-day-cnt day-cnt)))) 3539 (put-text-property s (1- (point)) 'org-day-cnt day-cnt))))
@@ -3425,6 +3546,15 @@ given in `org-agenda-start-on-weekday'."
3425 (setq p (plist-put p :tstart clocktable-start)) 3546 (setq p (plist-put p :tstart clocktable-start))
3426 (setq p (plist-put p :tend clocktable-end)) 3547 (setq p (plist-put p :tend clocktable-end))
3427 (setq p (plist-put p :scope 'agenda)) 3548 (setq p (plist-put p :scope 'agenda))
3549 (when (and (eq org-agenda-clockreport-mode 'with-filter)
3550 (setq filter (or org-agenda-filter-while-redo
3551 (get 'org-agenda-filter :preset-filter))))
3552 (setq p (plist-put p :tags (mapconcat (lambda (x)
3553 (if (string-match "[<>=]" x)
3554 ""
3555 x))
3556 filter ""))))
3557 (message "%s" (plist-get p :tags)) (sit-for 2)
3428 (setq tbl (apply 'org-get-clocktable p)) 3558 (setq tbl (apply 'org-get-clocktable p))
3429 (insert tbl))) 3559 (insert tbl)))
3430 (goto-char (point-min)) 3560 (goto-char (point-min))
@@ -3444,7 +3574,31 @@ given in `org-agenda-start-on-weekday'."
3444 (message ""))) 3574 (message "")))
3445 3575
3446(defun org-agenda-ndays-to-span (n) 3576(defun org-agenda-ndays-to-span (n)
3447 (cond ((< n 7) 'day) ((= n 7) 'week) ((< n 32) 'month) (t 'year))) 3577 "Return a span symbol for a span of N days, or N if none matches."
3578 (cond ((symbolp n) n)
3579 ((= n 1) 'day)
3580 ((= n 7) 'week)
3581 (t n)))
3582
3583(defun org-agenda-span-to-ndays (span start-day)
3584 "Return ndays from SPAN starting at START-DAY."
3585 (cond ((numberp span) span)
3586 ((eq span 'day) 1)
3587 ((eq span 'week) 7)
3588 ((eq span 'month)
3589 (let ((date (calendar-gregorian-from-absolute start-day)))
3590 (calendar-last-day-of-month (car date) (caddr date))))
3591 ((eq span 'year)
3592 (let ((date (calendar-gregorian-from-absolute start-day)))
3593 (if (calendar-leap-year-p (caddr date)) 366 365)))))
3594
3595(defun org-agenda-span-name (span)
3596 "Return a SPAN name."
3597 (if (null span)
3598 ""
3599 (if (symbolp span)
3600 (capitalize (symbol-name span))
3601 (format "%d days" span))))
3448 3602
3449;;; Agenda word search 3603;;; Agenda word search
3450 3604
@@ -3723,7 +3877,7 @@ for a keyword. A numeric prefix directly selects the Nth keyword in
3723 (org-set-sorting-strategy 'todo) 3877 (org-set-sorting-strategy 'todo)
3724 (org-prepare-agenda "TODO") 3878 (org-prepare-agenda "TODO")
3725 (if (and (stringp arg) (not (string-match "\\S-" arg))) (setq arg nil)) 3879 (if (and (stringp arg) (not (string-match "\\S-" arg))) (setq arg nil))
3726 (let* ((today (time-to-days (current-time))) 3880 (let* ((today (org-today))
3727 (date (calendar-gregorian-from-absolute today)) 3881 (date (calendar-gregorian-from-absolute today))
3728 (kwds org-todo-keywords-for-agenda) 3882 (kwds org-todo-keywords-for-agenda)
3729 (completion-ignore-case t) 3883 (completion-ignore-case t)
@@ -4347,7 +4501,8 @@ the documentation of `org-diary'."
4347 "Do we have a reason to ignore this TODO entry because it has a time stamp?" 4501 "Do we have a reason to ignore this TODO entry because it has a time stamp?"
4348 (when (or org-agenda-todo-ignore-with-date 4502 (when (or org-agenda-todo-ignore-with-date
4349 org-agenda-todo-ignore-scheduled 4503 org-agenda-todo-ignore-scheduled
4350 org-agenda-todo-ignore-deadlines) 4504 org-agenda-todo-ignore-deadlines
4505 org-agenda-todo-ignore-timestamp)
4351 (setq end (or end (save-excursion (outline-next-heading) (point)))) 4506 (setq end (or end (save-excursion (outline-next-heading) (point))))
4352 (save-excursion 4507 (save-excursion
4353 (or (and org-agenda-todo-ignore-with-date 4508 (or (and org-agenda-todo-ignore-with-date
@@ -4370,7 +4525,29 @@ the documentation of `org-diary'."
4370 (> (org-days-to-time (match-string 1)) 0)) 4525 (> (org-days-to-time (match-string 1)) 0))
4371 ((eq org-agenda-todo-ignore-deadlines 'past) 4526 ((eq org-agenda-todo-ignore-deadlines 'past)
4372 (<= (org-days-to-time (match-string 1)) 0)) 4527 (<= (org-days-to-time (match-string 1)) 0))
4373 (t (org-deadline-close (match-string 1))))))))) 4528 (t (org-deadline-close (match-string 1)))))
4529 (and org-agenda-todo-ignore-timestamp
4530 (let ((buffer (current-buffer))
4531 (regexp
4532 (concat
4533 org-scheduled-time-regexp "\\|" org-deadline-time-regexp))
4534 (start (point)))
4535 ;; Copy current buffer into a temporary one
4536 (with-temp-buffer
4537 (insert-buffer-substring buffer start end)
4538 (goto-char (point-min))
4539 ;; Delete SCHEDULED and DEADLINE items
4540 (while (re-search-forward regexp end t)
4541 (delete-region (match-beginning 0) (match-end 0)))
4542 (goto-char (point-min))
4543 ;; No search for timestamp left
4544 (when (re-search-forward org-ts-regexp nil t)
4545 (cond
4546 ((eq org-agenda-todo-ignore-timestamp 'future)
4547 (> (org-days-to-time (match-string 1)) 0))
4548 ((eq org-agenda-todo-ignore-timestamp 'past)
4549 (<= (org-days-to-time (match-string 1)) 0))
4550 (t))))))))))
4374 4551
4375(defconst org-agenda-no-heading-message 4552(defconst org-agenda-no-heading-message
4376 "No heading for this item in buffer or region.") 4553 "No heading for this item in buffer or region.")
@@ -4924,6 +5101,14 @@ The flag is set if the currently compiled format contains a `%e'.")
4924(defvar org-prefix-category-max-length nil 5101(defvar org-prefix-category-max-length nil
4925 "Used by `org-compile-prefix-format' to remember the category field width.") 5102 "Used by `org-compile-prefix-format' to remember the category field width.")
4926 5103
5104(defun org-agenda-get-category-icon (category)
5105 "Return an image for CATEGORY according to `org-agenda-category-icon-alist'."
5106 (dolist (entry org-agenda-category-icon-alist)
5107 (when (org-string-match-p (car entry) category)
5108 (if (listp (cadr entry))
5109 (return (cadr entry))
5110 (return (apply 'create-image (cdr entry)))))))
5111
4927(defun org-format-agenda-item (extra txt &optional category tags dotime 5112(defun org-format-agenda-item (extra txt &optional category tags dotime
4928 noprefix remove-re habitp) 5113 noprefix remove-re habitp)
4929 "Format TXT to be inserted into the agenda buffer. 5114 "Format TXT to be inserted into the agenda buffer.
@@ -4948,11 +5133,17 @@ Any match of REMOVE-RE will be removed from TXT."
4948 org-agenda-show-inherited-tags 5133 org-agenda-show-inherited-tags
4949 org-agenda-hide-tags-regexp)) 5134 org-agenda-hide-tags-regexp))
4950 (let* ((category (or category 5135 (let* ((category (or category
4951 org-category 5136 (if (stringp org-category)
5137 org-category
5138 (and org-category (symbol-name org-category)))
4952 (if buffer-file-name 5139 (if buffer-file-name
4953 (file-name-sans-extension 5140 (file-name-sans-extension
4954 (file-name-nondirectory buffer-file-name)) 5141 (file-name-nondirectory buffer-file-name))
4955 ""))) 5142 "")))
5143 (category-icon (org-agenda-get-category-icon category))
5144 (category-icon (if category-icon
5145 (propertize " " 'display category-icon)
5146 ""))
4956 ;; time, tag, effort are needed for the eval of the prefix format 5147 ;; time, tag, effort are needed for the eval of the prefix format
4957 (tag (if tags (nth (1- (length tags)) tags) "")) 5148 (tag (if tags (nth (1- (length tags)) tags) ""))
4958 time effort neffort 5149 time effort neffort
@@ -5038,8 +5229,15 @@ Any match of REMOVE-RE will be removed from TXT."
5038 (if noprefix 5229 (if noprefix
5039 (setq rtn txt) 5230 (setq rtn txt)
5040 ;; Prepare the variables needed in the eval of the compiled format 5231 ;; Prepare the variables needed in the eval of the compiled format
5041 (setq time (cond (s2 (concat s1 "-" s2)) 5232 (setq time (cond (s2 (concat
5042 (s1 (concat s1 "......")) 5233 (org-agenda-time-of-day-to-ampm-maybe s1)
5234 "-" (org-agenda-time-of-day-to-ampm-maybe s2)
5235 (if org-agenda-timegrid-use-ampm " ")))
5236 (s1 (concat
5237 (org-agenda-time-of-day-to-ampm-maybe s1)
5238 (if org-agenda-timegrid-use-ampm
5239 "........ "
5240 "......")))
5043 (t "")) 5241 (t ""))
5044 extra (or (and (not habitp) extra) "") 5242 extra (or (and (not habitp) extra) "")
5045 category (if (symbolp category) (symbol-name category) category) 5243 category (if (symbolp category) (symbol-name category) category)
@@ -5163,11 +5361,11 @@ The resulting form is returned and stored in the variable
5163 (t " %-12:c%?-12t% s"))) 5361 (t " %-12:c%?-12t% s")))
5164 (start 0) 5362 (start 0)
5165 varform vars var e c f opt) 5363 varform vars var e c f opt)
5166 (while (string-match "%\\(\\?\\)?\\([-+]?[0-9.]*\\)\\([ .;,:!?=|/<>]?\\)\\([ctse]\\)" 5364 (while (string-match "%\\(\\?\\)?\\([-+]?[0-9.]*\\)\\([ .;,:!?=|/<>]?\\)\\([ctsei]\\)"
5167 s start) 5365 s start)
5168 (setq var (cdr (assoc (match-string 4 s) 5366 (setq var (cdr (assoc (match-string 4 s)
5169 '(("c" . category) ("t" . time) ("s" . extra) 5367 '(("c" . category) ("t" . time) ("s" . extra)
5170 ("T" . tag) ("e" . effort)))) 5368 ("i" . category-icon) ("T" . tag) ("e" . effort))))
5171 c (or (match-string 3 s) "") 5369 c (or (match-string 3 s) "")
5172 opt (match-beginning 1) 5370 opt (match-beginning 1)
5173 start (1+ (match-beginning 0))) 5371 start (1+ (match-beginning 0)))
@@ -5567,6 +5765,7 @@ When this is the global TODO list, a prefix argument will be interpreted."
5567 (let* ((org-agenda-keep-modes t) 5765 (let* ((org-agenda-keep-modes t)
5568 (filter org-agenda-filter) 5766 (filter org-agenda-filter)
5569 (preset (get 'org-agenda-filter :preset-filter)) 5767 (preset (get 'org-agenda-filter :preset-filter))
5768 (org-agenda-filter-while-redo (or filter preset))
5570 (cols org-agenda-columns-active) 5769 (cols org-agenda-columns-active)
5571 (line (org-current-line)) 5770 (line (org-current-line))
5572 (window-line (- line (org-current-line (window-start)))) 5771 (window-line (- line (org-current-line (window-start))))
@@ -5839,13 +6038,10 @@ Negative selection means regexp must not match for selection of an entry."
5839 (cond 6038 (cond
5840 (tdpos (goto-char tdpos)) 6039 (tdpos (goto-char tdpos))
5841 ((eq org-agenda-type 'agenda) 6040 ((eq org-agenda-type 'agenda)
5842 (let* ((sd (time-to-days 6041 (let* ((sd (org-agenda-compute-starting-span
5843 (time-subtract (current-time) 6042 (org-today) (or org-agenda-ndays org-agenda-span)))
5844 (list 0 (* 3600 org-extend-today-until) 0))))
5845 (comp (org-agenda-compute-time-span sd org-agenda-span))
5846 (org-agenda-overriding-arguments org-agenda-last-arguments)) 6043 (org-agenda-overriding-arguments org-agenda-last-arguments))
5847 (setf (nth 1 org-agenda-overriding-arguments) (car comp)) 6044 (setf (nth 1 org-agenda-overriding-arguments) sd)
5848 (setf (nth 2 org-agenda-overriding-arguments) (cdr comp))
5849 (org-agenda-redo) 6045 (org-agenda-redo)
5850 (org-agenda-find-same-or-today-or-agenda))) 6046 (org-agenda-find-same-or-today-or-agenda)))
5851 (t (error "Cannot find today"))))) 6047 (t (error "Cannot find today")))))
@@ -5862,28 +6058,28 @@ Negative selection means regexp must not match for selection of an entry."
5862With prefix ARG, go forward that many times the current span." 6058With prefix ARG, go forward that many times the current span."
5863 (interactive "p") 6059 (interactive "p")
5864 (org-agenda-check-type t 'agenda) 6060 (org-agenda-check-type t 'agenda)
5865 (let* ((span org-agenda-span) 6061 (let* ((span org-agenda-current-span)
5866 (sd org-starting-day) 6062 (sd org-starting-day)
5867 (greg (calendar-gregorian-from-absolute sd)) 6063 (greg (calendar-gregorian-from-absolute sd))
5868 (cnt (org-get-at-bol 'org-day-cnt)) 6064 (cnt (org-get-at-bol 'org-day-cnt))
5869 greg2 nd) 6065 greg2)
5870 (cond 6066 (cond
5871 ((eq span 'day) 6067 ((eq span 'day)
5872 (setq sd (+ arg sd) nd 1)) 6068 (setq sd (+ arg sd)))
5873 ((eq span 'week) 6069 ((eq span 'week)
5874 (setq sd (+ (* 7 arg) sd) nd 7)) 6070 (setq sd (+ (* 7 arg) sd)))
5875 ((eq span 'month) 6071 ((eq span 'month)
5876 (setq greg2 (list (+ (car greg) arg) (nth 1 greg) (nth 2 greg)) 6072 (setq greg2 (list (+ (car greg) arg) (nth 1 greg) (nth 2 greg))
5877 sd (calendar-absolute-from-gregorian greg2)) 6073 sd (calendar-absolute-from-gregorian greg2))
5878 (setcar greg2 (1+ (car greg2))) 6074 (setcar greg2 (1+ (car greg2))))
5879 (setq nd (- (calendar-absolute-from-gregorian greg2) sd)))
5880 ((eq span 'year) 6075 ((eq span 'year)
5881 (setq greg2 (list (car greg) (nth 1 greg) (+ arg (nth 2 greg))) 6076 (setq greg2 (list (car greg) (nth 1 greg) (+ arg (nth 2 greg)))
5882 sd (calendar-absolute-from-gregorian greg2)) 6077 sd (calendar-absolute-from-gregorian greg2))
5883 (setcar (nthcdr 2 greg2) (1+ (nth 2 greg2))) 6078 (setcar (nthcdr 2 greg2) (1+ (nth 2 greg2))))
5884 (setq nd (- (calendar-absolute-from-gregorian greg2) sd)))) 6079 (t
6080 (setq sd (+ (* span arg) sd))))
5885 (let ((org-agenda-overriding-arguments 6081 (let ((org-agenda-overriding-arguments
5886 (list (car org-agenda-last-arguments) sd nd t))) 6082 (list (car org-agenda-last-arguments) sd span t)))
5887 (org-agenda-redo) 6083 (org-agenda-redo)
5888 (org-agenda-find-same-or-today-or-agenda cnt)))) 6084 (org-agenda-find-same-or-today-or-agenda cnt))))
5889 6085
@@ -5926,7 +6122,6 @@ With prefix ARG, go backward that many times the current span."
5926 "Switch to daily view for agenda. 6122 "Switch to daily view for agenda.
5927With argument DAY-OF-YEAR, switch to that day of the year." 6123With argument DAY-OF-YEAR, switch to that day of the year."
5928 (interactive "P") 6124 (interactive "P")
5929 (setq org-agenda-ndays 1)
5930 (org-agenda-change-time-span 'day day-of-year)) 6125 (org-agenda-change-time-span 'day day-of-year))
5931(defun org-agenda-week-view (&optional iso-week) 6126(defun org-agenda-week-view (&optional iso-week)
5932 "Switch to daily view for agenda. 6127 "Switch to daily view for agenda.
@@ -5936,7 +6131,6 @@ week. Any digits before this encode a year. So 200712 means
5936week 12 of year 2007. Years in the range 1938-2037 can also be 6131week 12 of year 2007. Years in the range 1938-2037 can also be
5937written as 2-digit years." 6132written as 2-digit years."
5938 (interactive "P") 6133 (interactive "P")
5939 (setq org-agenda-ndays 7)
5940 (org-agenda-change-time-span 'week iso-week)) 6134 (org-agenda-change-time-span 'week iso-week))
5941(defun org-agenda-month-view (&optional month) 6135(defun org-agenda-month-view (&optional month)
5942 "Switch to monthly view for agenda. 6136 "Switch to monthly view for agenda.
@@ -5961,70 +6155,61 @@ written as 2-digit years."
5961 "Change the agenda view to SPAN. 6155 "Change the agenda view to SPAN.
5962SPAN may be `day', `week', `month', `year'." 6156SPAN may be `day', `week', `month', `year'."
5963 (org-agenda-check-type t 'agenda) 6157 (org-agenda-check-type t 'agenda)
5964 (if (and (not n) (equal org-agenda-span span)) 6158 (if (and (not n) (equal org-agenda-current-span span))
5965 (error "Viewing span is already \"%s\"" span)) 6159 (error "Viewing span is already \"%s\"" span))
5966 (let* ((sd (or (org-get-at-bol 'day) 6160 (let* ((sd (or (org-get-at-bol 'day)
5967 org-starting-day)) 6161 org-starting-day))
5968 (computed (org-agenda-compute-time-span sd span n)) 6162 (sd (org-agenda-compute-starting-span sd span n))
5969 (org-agenda-overriding-arguments 6163 (org-agenda-overriding-arguments
5970 (list (car org-agenda-last-arguments) 6164 (list (car org-agenda-last-arguments) sd span t)))
5971 (car computed) (cdr computed) t)))
5972 (org-agenda-redo) 6165 (org-agenda-redo)
5973 (org-agenda-find-same-or-today-or-agenda)) 6166 (org-agenda-find-same-or-today-or-agenda))
5974 (org-agenda-set-mode-name) 6167 (org-agenda-set-mode-name)
5975 (message "Switched to %s view" span)) 6168 (message "Switched to %s view" span))
5976 6169
5977(defun org-agenda-compute-time-span (sd span &optional n) 6170(defun org-agenda-compute-starting-span (sd span &optional n)
5978 "Compute starting date and number of days for agenda. 6171 "Compute starting date for agenda.
5979SPAN may be `day', `week', `month', `year'. The return value 6172SPAN may be `day', `week', `month', `year'. The return value
5980is a cons cell with the starting date and the number of days, 6173is a cons cell with the starting date and the number of days,
5981so that the date SD will be in that range." 6174so that the date SD will be in that range."
5982 (let* ((greg (calendar-gregorian-from-absolute sd)) 6175 (let* ((greg (calendar-gregorian-from-absolute sd))
5983 (dg (nth 1 greg)) 6176 (dg (nth 1 greg))
5984 (mg (car greg)) 6177 (mg (car greg))
5985 (yg (nth 2 greg)) 6178 (yg (nth 2 greg)))
5986 nd w1 y1 m1 thisweek)
5987 (cond 6179 (cond
5988 ((eq span 'day) 6180 ((eq span 'day)
5989 (when n 6181 (when n
5990 (setq sd (+ (calendar-absolute-from-gregorian 6182 (setq sd (+ (calendar-absolute-from-gregorian
5991 (list mg 1 yg)) 6183 (list mg 1 yg))
5992 n -1))) 6184 n -1))))
5993 (setq nd 1))
5994 ((eq span 'week) 6185 ((eq span 'week)
5995 (let* ((nt (calendar-day-of-week 6186 (let* ((nt (calendar-day-of-week
5996 (calendar-gregorian-from-absolute sd))) 6187 (calendar-gregorian-from-absolute sd)))
5997 (d (if org-agenda-start-on-weekday 6188 (d (if org-agenda-start-on-weekday
5998 (- nt org-agenda-start-on-weekday) 6189 (- nt org-agenda-start-on-weekday)
5999 0))) 6190 0))
6191 y1)
6000 (setq sd (- sd (+ (if (< d 0) 7 0) d))) 6192 (setq sd (- sd (+ (if (< d 0) 7 0) d)))
6001 (when n 6193 (when n
6002 (require 'cal-iso) 6194 (require 'cal-iso)
6003 (setq thisweek (car (calendar-iso-from-absolute sd)))
6004 (when (> n 99) 6195 (when (> n 99)
6005 (setq y1 (org-small-year-to-year (/ n 100)) 6196 (setq y1 (org-small-year-to-year (/ n 100))
6006 n (mod n 100))) 6197 n (mod n 100)))
6007 (setq sd 6198 (setq sd
6008 (calendar-absolute-from-iso 6199 (calendar-absolute-from-iso
6009 (list n 1 6200 (list n 1
6010 (or y1 (nth 2 (calendar-iso-from-absolute sd))))))) 6201 (or y1 (nth 2 (calendar-iso-from-absolute sd)))))))))
6011 (setq nd 7)))
6012 ((eq span 'month) 6202 ((eq span 'month)
6013 (when (and n (> n 99)) 6203 (let (y1)
6014 (setq y1 (org-small-year-to-year (/ n 100)) 6204 (when (and n (> n 99))
6015 n (mod n 100))) 6205 (setq y1 (org-small-year-to-year (/ n 100))
6016 (setq sd (calendar-absolute-from-gregorian 6206 n (mod n 100)))
6017 (list (or n mg) 1 (or y1 yg))) 6207 (setq sd (calendar-absolute-from-gregorian
6018 nd (- (calendar-absolute-from-gregorian 6208 (list (or n mg) 1 (or y1 yg))))))
6019 (list (1+ (or n mg)) 1 (or y1 yg)))
6020 sd)))
6021 ((eq span 'year) 6209 ((eq span 'year)
6022 (setq sd (calendar-absolute-from-gregorian 6210 (setq sd (calendar-absolute-from-gregorian
6023 (list 1 1 (or n yg))) 6211 (list 1 1 (or n yg))))))
6024 nd (- (calendar-absolute-from-gregorian 6212 sd))
6025 (list 1 1 (1+ (or n yg))))
6026 sd))))
6027 (cons sd nd)))
6028 6213
6029(defun org-agenda-next-date-line (&optional arg) 6214(defun org-agenda-next-date-line (&optional arg)
6030 "Jump to the next line indicating a date in agenda buffer." 6215 "Jump to the next line indicating a date in agenda buffer."
@@ -6094,11 +6279,15 @@ so that the date SD will be in that range."
6094 (if org-agenda-entry-text-mode "on" "off") 6279 (if org-agenda-entry-text-mode "on" "off")
6095 (if (integerp arg) arg org-agenda-entry-text-maxlines))) 6280 (if (integerp arg) arg org-agenda-entry-text-maxlines)))
6096 6281
6097(defun org-agenda-clockreport-mode () 6282(defun org-agenda-clockreport-mode (&optional with-filter)
6098 "Toggle clocktable mode in an agenda buffer." 6283 "Toggle clocktable mode in an agenda buffer.
6099 (interactive) 6284With prefix arg WITH-FILTER, make the clocktable respect the current
6285agenda filter."
6286 (interactive "P")
6100 (org-agenda-check-type t 'agenda) 6287 (org-agenda-check-type t 'agenda)
6101 (setq org-agenda-clockreport-mode (not org-agenda-clockreport-mode)) 6288 (if with-filter
6289 (setq org-agenda-clockreport-mode 'with-filter)
6290 (setq org-agenda-clockreport-mode (not org-agenda-clockreport-mode)))
6102 (org-agenda-set-mode-name) 6291 (org-agenda-set-mode-name)
6103 (org-agenda-redo) 6292 (org-agenda-redo)
6104 (message "Clocktable mode is %s" 6293 (message "Clocktable mode is %s"
@@ -6151,7 +6340,7 @@ When called with a prefix argument, include all archive files as well."
6151 (if org-agenda-include-diary "on" "off"))) 6340 (if org-agenda-include-diary "on" "off")))
6152 6341
6153(defun org-agenda-toggle-deadlines () 6342(defun org-agenda-toggle-deadlines ()
6154 "Toggle diary inclusion in an agenda buffer." 6343 "Toggle inclusion of entries with a deadline in an agenda buffer."
6155 (interactive) 6344 (interactive)
6156 (org-agenda-check-type t 'agenda) 6345 (org-agenda-check-type t 'agenda)
6157 (setq org-agenda-include-deadlines (not org-agenda-include-deadlines)) 6346 (setq org-agenda-include-deadlines (not org-agenda-include-deadlines))
@@ -6173,33 +6362,36 @@ When called with a prefix argument, include all archive files as well."
6173(defun org-agenda-set-mode-name () 6362(defun org-agenda-set-mode-name ()
6174 "Set the mode name to indicate all the small mode settings." 6363 "Set the mode name to indicate all the small mode settings."
6175 (setq mode-name 6364 (setq mode-name
6176 (concat "Org-Agenda" 6365 (list "Org-Agenda"
6177 (if (get 'org-agenda-files 'org-restrict) " []" "") 6366 (if (get 'org-agenda-files 'org-restrict) " []" "")
6178 (if (equal org-agenda-ndays 1) " Day" "") 6367 " "
6179 (if (equal org-agenda-ndays 7) " Week" "") 6368 '(:eval (org-agenda-span-name org-agenda-current-span))
6180 (if org-agenda-follow-mode " Follow" "") 6369 (if org-agenda-follow-mode " Follow" "")
6181 (if org-agenda-entry-text-mode " ETxt" "") 6370 (if org-agenda-entry-text-mode " ETxt" "")
6182 (if org-agenda-include-diary " Diary" "") 6371 (if org-agenda-include-diary " Diary" "")
6183 (if org-agenda-include-deadlines " Ddl" "") 6372 (if org-agenda-include-deadlines " Ddl" "")
6184 (if org-agenda-use-time-grid " Grid" "") 6373 (if org-agenda-use-time-grid " Grid" "")
6185 (if (and (boundp 'org-habit-show-habits) 6374 (if (and (boundp 'org-habit-show-habits)
6186 org-habit-show-habits) " Habit" "") 6375 org-habit-show-habits) " Habit" "")
6187 (if (consp org-agenda-show-log) " LogAll" 6376 (if (consp org-agenda-show-log) " LogAll"
6188 (if org-agenda-show-log " Log" "")) 6377 (if org-agenda-show-log " Log" ""))
6189 (if (or org-agenda-filter (get 'org-agenda-filter 6378 (if (or org-agenda-filter (get 'org-agenda-filter
6190 :preset-filter)) 6379 :preset-filter))
6191 (concat " {" (mapconcat 6380 (concat " {" (mapconcat
6192 'identity 6381 'identity
6193 (append (get 'org-agenda-filter 6382 (append (get 'org-agenda-filter
6194 :preset-filter) 6383 :preset-filter)
6195 org-agenda-filter) "") "}") 6384 org-agenda-filter) "") "}")
6196 "") 6385 "")
6197 (if org-agenda-archives-mode 6386 (if org-agenda-archives-mode
6198 (if (eq org-agenda-archives-mode t) 6387 (if (eq org-agenda-archives-mode t)
6199 " Archives" 6388 " Archives"
6200 (format " :%s:" org-archive-tag)) 6389 (format " :%s:" org-archive-tag))
6201 "") 6390 "")
6202 (if org-agenda-clockreport-mode " Clock" ""))) 6391 (if org-agenda-clockreport-mode
6392 (if (eq org-agenda-clockreport-mode 'with-filter)
6393 " Clock{}" " Clock")
6394 "")))
6203 (force-mode-line-update)) 6395 (force-mode-line-update))
6204 6396
6205(defun org-agenda-post-command-hook () 6397(defun org-agenda-post-command-hook ()
@@ -6216,7 +6408,6 @@ When called with a prefix argument, include all archive files as well."
6216 6408
6217(defun org-agenda-previous-line () 6409(defun org-agenda-previous-line ()
6218 "Move cursor to the previous line, and show if follow-mode is active." 6410 "Move cursor to the previous line, and show if follow-mode is active."
6219
6220 (interactive) 6411 (interactive)
6221 (call-interactively 'previous-line) 6412 (call-interactively 'previous-line)
6222 (org-agenda-do-context-action)) 6413 (org-agenda-do-context-action))
@@ -6642,8 +6833,7 @@ the same tree node, and the headline of the tree node in the Org-mode file."
6642 (buffer (marker-buffer marker)) 6833 (buffer (marker-buffer marker))
6643 (pos (marker-position marker)) 6834 (pos (marker-position marker))
6644 (hdmarker (org-get-at-bol 'org-hd-marker)) 6835 (hdmarker (org-get-at-bol 'org-hd-marker))
6645 (todayp (equal (org-get-at-bol 'day) 6836 (todayp (org-agenda-todayp (org-get-at-bol 'day)))
6646 (time-to-days (current-time))))
6647 (inhibit-read-only t) 6837 (inhibit-read-only t)
6648 org-agenda-headline-snapshot-before-repeat newhead just-one) 6838 org-agenda-headline-snapshot-before-repeat newhead just-one)
6649 (org-with-remote-undo buffer 6839 (org-with-remote-undo buffer
@@ -7551,25 +7741,26 @@ This is a command that has to be installed in `calendar-mode-map'."
7551 (eq (get-char-property (point-at-bol) 'type) 7741 (eq (get-char-property (point-at-bol) 'type)
7552 'org-marked-entry-overlay)) 7742 'org-marked-entry-overlay))
7553 7743
7554(defun org-agenda-bulk-mark () 7744(defun org-agenda-bulk-mark (&optional arg)
7555 "Mark the entry at point for future bulk action." 7745 "Mark the entry at point for future bulk action."
7556 (interactive) 7746 (interactive "p")
7557 (org-agenda-check-no-diary) 7747 (dotimes (i (max arg 1))
7558 (let* ((m (org-get-at-bol 'org-hd-marker)) 7748 (unless (org-get-at-bol 'org-agenda-diary-link)
7559 ov) 7749 (let* ((m (org-get-at-bol 'org-hd-marker))
7560 (unless (org-agenda-bulk-marked-p) 7750 ov)
7561 (unless m (error "Nothing to mark at point")) 7751 (unless (org-agenda-bulk-marked-p)
7562 (push m org-agenda-bulk-marked-entries) 7752 (unless m (error "Nothing to mark at point"))
7563 (setq ov (make-overlay (point-at-bol) (+ 2 (point-at-bol)))) 7753 (push m org-agenda-bulk-marked-entries)
7564 (org-overlay-display ov "> " 7754 (setq ov (make-overlay (point-at-bol) (+ 2 (point-at-bol))))
7565 (org-get-todo-face "TODO") 7755 (org-overlay-display ov "> "
7566 'evaporate) 7756 (org-get-todo-face "TODO")
7567 (overlay-put ov 'type 'org-marked-entry-overlay)) 7757 'evaporate)
7568 (beginning-of-line 2) 7758 (overlay-put ov 'type 'org-marked-entry-overlay))
7569 (while (and (get-char-property (point) 'invisible) (not (eobp))) 7759 (beginning-of-line 2)
7570 (beginning-of-line 2)) 7760 (while (and (get-char-property (point) 'invisible) (not (eobp)))
7571 (message "%d entries marked for bulk action" 7761 (beginning-of-line 2))
7572 (length org-agenda-bulk-marked-entries)))) 7762 (message "%d entries marked for bulk action"
7763 (length org-agenda-bulk-marked-entries))))))
7573 7764
7574(defun org-agenda-bulk-unmark () 7765(defun org-agenda-bulk-unmark ()
7575 "Unmark the entry at point for future bulk action." 7766 "Unmark the entry at point for future bulk action."
@@ -7619,7 +7810,7 @@ The prefix arg is passed through to the command if possible."
7619 (interactive "P") 7810 (interactive "P")
7620 (unless org-agenda-bulk-marked-entries 7811 (unless org-agenda-bulk-marked-entries
7621 (error "No entries are marked")) 7812 (error "No entries are marked"))
7622 (message "Bulk: [r]efile [$]archive [A]rch->sib [t]odo [+/-]tag [s]chedule [d]eadline") 7813 (message "Bulk: [r]efile [$]arch [A]rch->sib [t]odo [+/-]tag [s]chd [S]catter [d]eadline")
7623 (let* ((action (read-char-exclusive)) 7814 (let* ((action (read-char-exclusive))
7624 (org-log-refile (if org-log-refile 'time nil)) 7815 (org-log-refile (if org-log-refile 'time nil))
7625 (entries (reverse org-agenda-bulk-marked-entries)) 7816 (entries (reverse org-agenda-bulk-marked-entries))
@@ -7681,6 +7872,29 @@ The prefix arg is passed through to the command if possible."
7681 (if bound 7872 (if bound
7682 (fset 'read-string old) 7873 (fset 'read-string old)
7683 (fmakunbound 'read-string))))))) 7874 (fmakunbound 'read-string)))))))
7875
7876 ((eq action '?S)
7877 (let ((days (read-number
7878 (format "Scatter tasks across how many %sdays: "
7879 (if arg "week" "")) 7)))
7880 (setq cmd
7881 `(let ((distance (random ,(1+ days))))
7882 (if arg
7883 (let ((dist distance)
7884 (day-of-week
7885 (calendar-day-of-week
7886 (calendar-gregorian-from-absolute (org-today)))))
7887 (dotimes (i (1+ dist))
7888 (while (member day-of-week org-agenda-weekend-days)
7889 (incf distance)
7890 (incf day-of-week)
7891 (if (= day-of-week 7)
7892 (setq day-of-week 0)))
7893 (incf day-of-week)
7894 (if (= day-of-week 7)
7895 (setq day-of-week 0)))))
7896 (org-agenda-date-later distance)))))
7897
7684 (t (error "Invalid bulk action"))) 7898 (t (error "Invalid bulk action")))
7685 7899
7686 ;; Sort the markers, to make sure that parents are handled before children 7900 ;; Sort the markers, to make sure that parents are handled before children
@@ -7792,6 +8006,9 @@ belonging to the \"Work\" category."
7792 (let* ((cnt 0) ; count added events 8006 (let* ((cnt 0) ; count added events
7793 (org-agenda-new-buffers nil) 8007 (org-agenda-new-buffers nil)
7794 (org-deadline-warning-days 0) 8008 (org-deadline-warning-days 0)
8009 ;; Do not use `org-today' here because appt only takes
8010 ;; time and without date as argument, so it may pass wrong
8011 ;; information otherwise
7795 (today (org-date-to-gregorian 8012 (today (org-date-to-gregorian
7796 (time-to-days (current-time)))) 8013 (time-to-days (current-time))))
7797 (org-agenda-restrict nil) 8014 (org-agenda-restrict nil)
@@ -7834,14 +8051,10 @@ belonging to the \"Work\" category."
7834 8051
7835(defun org-agenda-todayp (date) 8052(defun org-agenda-todayp (date)
7836 "Does DATE mean today, when considering `org-extend-today-until'?" 8053 "Does DATE mean today, when considering `org-extend-today-until'?"
7837 (let (today h) 8054 (let ((today (org-today))
7838 (if (listp date) (setq date (calendar-absolute-from-gregorian date))) 8055 (date (if (and date (listp date)) (calendar-absolute-from-gregorian date)
7839 (setq today (calendar-absolute-from-gregorian (calendar-current-date))) 8056 date)))
7840 (setq h (nth 2 (decode-time (current-time)))) 8057 (eq date today)))
7841 (or (and (>= h org-extend-today-until)
7842 (= date today))
7843 (and (< h org-extend-today-until)
7844 (= date (1- today))))))
7845 8058
7846(provide 'org-agenda) 8059(provide 'org-agenda)
7847 8060
diff --git a/lisp/org/org-archive.el b/lisp/org/org-archive.el
index 8c1f9a13a12..e56b01f952a 100644
--- a/lisp/org/org-archive.el
+++ b/lisp/org/org-archive.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: 7.3 9;; Version: 7.4
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-ascii.el b/lisp/org/org-ascii.el
index b48f8efa1cd..99facb1e431 100644
--- a/lisp/org/org-ascii.el
+++ b/lisp/org/org-ascii.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: 7.3 9;; Version: 7.4
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-attach.el b/lisp/org/org-attach.el
index d98254cb659..a894064ed84 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: 7.3 7;; Version: 7.4
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-bbdb.el b/lisp/org/org-bbdb.el
index d5a09cab63b..4155f58b5f6 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: 7.3 10;; Version: 7.4
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-beamer.el b/lisp/org/org-beamer.el
index d3f0f47e45c..c88df859f79 100644
--- a/lisp/org/org-beamer.el
+++ b/lisp/org/org-beamer.el
@@ -2,7 +2,7 @@
2;; 2;;
3;; Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 3;; Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
4;; 4;;
5;; Version: 7.3 5;; Version: 7.4
6;; Author: Carsten Dominik <carsten.dominik AT gmail DOT com> 6;; Author: Carsten Dominik <carsten.dominik AT gmail DOT com>
7;; Maintainer: Carsten Dominik <carsten.dominik AT gmail DOT com> 7;; Maintainer: Carsten Dominik <carsten.dominik AT gmail DOT com>
8;; Keywords: org, wp, tex 8;; Keywords: org, wp, tex
@@ -246,14 +246,14 @@ in org-export-latex-classes."
246 (if (and (string-match "\\`[0-9.]+\\'" tmp) 246 (if (and (string-match "\\`[0-9.]+\\'" tmp)
247 (or (= (string-to-number tmp) 1.0) 247 (or (= (string-to-number tmp) 1.0)
248 (= (string-to-number tmp) 0.0))) 248 (= (string-to-number tmp) 0.0)))
249 ;; column width 1 means cloase columns, go back to full width 249 ;; column width 1 means close columns, go back to full width
250 (org-beamer-close-columns-maybe) 250 (org-beamer-close-columns-maybe)
251 (when (setq ass (assoc "BEAMER_envargs" props)) 251 (when (setq ass (assoc "BEAMER_envargs" props))
252 (let (case-fold-search) 252 (let (case-fold-search)
253 (when (string-match "C\\(\\[[^][]*\\]\\)" (cdr ass)) 253 (while (string-match "C\\(\\[[^][]*\\]\\|<[^<>]*>\\)" (cdr ass))
254 (setq columns-option (match-string 1 (cdr ass))) 254 (setq columns-option (match-string 1 (cdr ass)))
255 (setcdr ass (replace-match "" t t (cdr ass)))) 255 (setcdr ass (replace-match "" t t (cdr ass))))
256 (when (string-match "c\\(\\[[^][]*\\]\\)" (cdr ass)) 256 (while (string-match "c\\(\\[[^][]*\\]\\|<[^<>]*>\\)" (cdr ass))
257 (setq column-option (match-string 1 (cdr ass))) 257 (setq column-option (match-string 1 (cdr ass)))
258 (setcdr ass (replace-match "" t t (cdr ass)))))) 258 (setcdr ass (replace-match "" t t (cdr ass))))))
259 (org-beamer-open-columns-maybe columns-option) 259 (org-beamer-open-columns-maybe columns-option)
diff --git a/lisp/org/org-bibtex.el b/lisp/org/org-bibtex.el
index b9018b023ba..e34e1572cd3 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: 7.3 8;; Version: 7.4
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-capture.el b/lisp/org/org-capture.el
index 2abe5c72bf6..5c7b0386e04 100644
--- a/lisp/org/org-capture.el
+++ b/lisp/org/org-capture.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: 7.3 8;; Version: 7.4
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
@@ -133,7 +133,10 @@ target Specification of where the captured item should be placed.
133 File to the entry matching regexp 133 File to the entry matching regexp
134 134
135 (file+datetree \"path/to/file\") 135 (file+datetree \"path/to/file\")
136 Will create a heading in a date tree 136 Will create a heading in a date tree for today's date
137
138 (file+datetree+prompt \"path/to/file\")
139 Will create a heading in a date tree, promts for date
137 140
138 (file+function \"path/to/file\" function-finding-location) 141 (file+function \"path/to/file\" function-finding-location)
139 A function to find the right location in the file 142 A function to find the right location in the file
@@ -280,6 +283,9 @@ calendar | %:type %:date"
280 (list :tag "File & Date tree" 283 (list :tag "File & Date tree"
281 (const :format "" file+datetree) 284 (const :format "" file+datetree)
282 (file :tag " File")) 285 (file :tag " File"))
286 (list :tag "File & Date tree, prompt for date"
287 (const :format "" file+datetree+prompt)
288 (file :tag " File"))
283 (list :tag "File & function" 289 (list :tag "File & function"
284 (const :format "" file+function) 290 (const :format "" file+function)
285 (file :tag " File ") 291 (file :tag " File ")
@@ -313,6 +319,12 @@ The remember buffer is still current when this hook runs."
313 :group 'org-capture 319 :group 'org-capture
314 :type 'hook) 320 :type 'hook)
315 321
322(defcustom org-capture-after-finalize-hook nil
323 "Hook that is run right after a capture process is finalized.
324 Suitable for window cleanup"
325 :group 'org-capture
326 :type 'hook)
327
316;;; The property list for keeping information about the capture process 328;;; The property list for keeping information about the capture process
317 329
318(defvar org-capture-plist nil 330(defvar org-capture-plist nil
@@ -461,9 +473,11 @@ bypassed."
461 (t (setq txt "* Invalid capture template"))) 473 (t (setq txt "* Invalid capture template")))
462 (org-capture-put :template txt))) 474 (org-capture-put :template txt)))
463 475
464(defun org-capture-finalize () 476(defun org-capture-finalize (&optional stay-with-capture)
465 "Finalize the capture process." 477 "Finalize the capture process.
466 (interactive) 478With prefix argument STAY-WITH-CAPTURE, jump to the location of the
479captured item after finalizing."
480 (interactive "P")
467 (unless (and org-capture-mode 481 (unless (and org-capture-mode
468 (buffer-base-buffer (current-buffer))) 482 (buffer-base-buffer (current-buffer)))
469 (error "This does not seem to be a capture buffer for Org-mode")) 483 (error "This does not seem to be a capture buffer for Org-mode"))
@@ -548,17 +562,25 @@ bypassed."
548 562
549 ;; Restore the window configuration before capture 563 ;; Restore the window configuration before capture
550 (set-window-configuration return-wconf)) 564 (set-window-configuration return-wconf))
551 (when abort-note 565
566 (run-hooks 'org-capture-after-finalize-hook)
567 ;; Special cases
568 (cond
569 (abort-note
552 (cond 570 (cond
553 ((equal abort-note 'clean) 571 ((equal abort-note 'clean)
554 (message "Capture process aborted and target buffer cleaned up")) 572 (message "Capture process aborted and target buffer cleaned up"))
555 ((equal abort-note 'dirty) 573 ((equal abort-note 'dirty)
556 (error "Capture process aborted, but target buffer could not be cleaned up correctly")))))) 574 (error "Capture process aborted, but target buffer could not be cleaned up correctly"))))
575 (stay-with-capture
576 (org-capture-goto-last-stored)))
577 ;; Return if we did store something
578 (not abort-note)))
557 579
558(defun org-capture-refile () 580(defun org-capture-refile ()
559 "Finalize the current capture and then refile the entry. 581 "Finalize the current capture and then refile the entry.
560Refiling is done from the base buffer, because the indirect buffer is then 582Refiling is done from the base buffer, because the indirect buffer is then
561already gone." 583already gone. Any prefix argument will be passed to the refile comand."
562 (interactive) 584 (interactive)
563 (unless (eq (org-capture-get :type 'local) 'entry) 585 (unless (eq (org-capture-get :type 'local) 'entry)
564 (error 586 (error
@@ -640,19 +662,28 @@ already gone."
640 (setq target-entry-p (and (org-mode-p) (org-at-heading-p)))) 662 (setq target-entry-p (and (org-mode-p) (org-at-heading-p))))
641 (error "No match for target regexp in file %s" (nth 1 target)))) 663 (error "No match for target regexp in file %s" (nth 1 target))))
642 664
643 ((eq (car target) 'file+datetree) 665 ((memq (car target) '(file+datetree file+datetree+prompt))
644 (require 'org-datetree) 666 (require 'org-datetree)
645 (set-buffer (org-capture-target-buffer (nth 1 target))) 667 (set-buffer (org-capture-target-buffer (nth 1 target)))
646 ;; Make a date tree entry, with the current date (or yesterday, 668 ;; Make a date tree entry, with the current date (or yesterday,
647 ;; if we are extending dates for a couple of hours) 669 ;; if we are extending dates for a couple of hours)
648 (org-datetree-find-date-create 670 (org-datetree-find-date-create
649 (calendar-gregorian-from-absolute 671 (calendar-gregorian-from-absolute
650 (if org-overriding-default-time 672 (cond
651 (time-to-days org-overriding-default-time) 673
652 (time-to-days 674 (org-overriding-default-time
653 (time-subtract (current-time) 675 ;; use the overriding default time
654 (list 0 (* 3600 org-extend-today-until) 0))))))) 676 (time-to-days org-overriding-default-time))
655 677
678 ((eq (car target) 'file+datetree+prompt)
679 ;; prompt for date
680 (time-to-days (org-read-date
681 nil t nil "Date for tree entry:"
682 (days-to-time (org-today)))))
683 (t
684 ;; current date, possible corrected for late night workers
685 (org-today))))))
686
656 ((eq (car target) 'file+function) 687 ((eq (car target) 'file+function)
657 (set-buffer (org-capture-target-buffer (nth 1 target))) 688 (set-buffer (org-capture-target-buffer (nth 1 target)))
658 (funcall (nth 2 target)) 689 (funcall (nth 2 target))
@@ -1358,5 +1389,3 @@ The template may still contain \"%?\" for cursor positioning."
1358;; arch-tag: 986bf41b-8ada-4e28-bf20-e8388a7205a0 1389;; arch-tag: 986bf41b-8ada-4e28-bf20-e8388a7205a0
1359 1390
1360;;; org-capture.el ends here 1391;;; org-capture.el ends here
1361
1362
diff --git a/lisp/org/org-clock.el b/lisp/org/org-clock.el
index 457a4dcb2f0..93b0b524c80 100644
--- a/lisp/org/org-clock.el
+++ b/lisp/org/org-clock.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: 7.3 9;; Version: 7.4
10;; 10;;
11;; This file is part of GNU Emacs. 11;; This file is part of GNU Emacs.
12;; 12;;
@@ -34,7 +34,7 @@
34(eval-when-compile 34(eval-when-compile
35 (require 'cl)) 35 (require 'cl))
36 36
37(declare-function calendar-absolute-from-iso "cal-iso" (&optional date)) 37(declare-function calendar-absolute-from-iso "cal-iso" (&optional date))
38(declare-function notifications-notify "notifications" (&rest params)) 38(declare-function notifications-notify "notifications" (&rest params))
39(defvar org-time-stamp-formats) 39(defvar org-time-stamp-formats)
40 40
@@ -222,11 +222,48 @@ string as argument."
222 (string :tag "Program") 222 (string :tag "Program")
223 (function :tag "Function"))) 223 (function :tag "Function")))
224 224
225(defcustom org-clock-clocktable-default-properties '(:maxlevel 2 :scope file) 225(defgroup org-clocktable nil
226 "Default properties for new clocktables." 226 "Options concerning the clock table in Org-mode."
227 :tag "Org Clock Table"
228 :group 'org-clock)
229
230(defcustom org-clocktable-defaults
231 (list
232 :maxlevel 2
233 :scope 'file
234 :block nil
235 :tstart nil
236 :tend nil
237 :step nil
238 :stepskip0 nil
239 :fileskip0 nil
240 :tags nil
241 :emphasize nil
242 :link nil
243 :narrow '40!
244 :indent t
245 :formula nil
246 :timestamp nil
247 :level nil
248 :tcolumns nil
249 :formatter nil)
250 "Default properties for clock tables."
227 :group 'org-clock 251 :group 'org-clock
228 :type 'plist) 252 :type 'plist)
229 253
254(defcustom org-clock-clocktable-formatter 'org-clocktable-write-default
255 "Function to turn clocking data into a table.
256For more information, see `org-clocktable-write-default'."
257 :group 'org-clocktable
258 :type 'function)
259
260(defcustom org-clock-clocktable-default-properties '(:maxlevel 2 :scope file)
261 "Default properties for new clocktables.
262These will be inserted into the BEGIN line, to make it easy for users to
263play with them."
264 :group 'org-clocktable
265 :type 'plist)
266
230(defcustom org-clock-idle-time nil 267(defcustom org-clock-idle-time nil
231 "When non-nil, resolve open clocks if the user is idle more than X minutes." 268 "When non-nil, resolve open clocks if the user is idle more than X minutes."
232 :group 'org-clock 269 :group 'org-clock
@@ -1586,7 +1623,7 @@ fontified, and then returned."
1586 (font-lock-fontify-buffer) 1623 (font-lock-fontify-buffer)
1587 (forward-line 2) 1624 (forward-line 2)
1588 (buffer-substring (point) (progn 1625 (buffer-substring (point) (progn
1589 (re-search-forward "^#\\+END" nil t) 1626 (re-search-forward "^[ \t]*#\\+END" nil t)
1590 (point-at-bol))))) 1627 (point-at-bol)))))
1591 1628
1592(defun org-clock-report (&optional arg) 1629(defun org-clock-report (&optional arg)
@@ -1611,12 +1648,68 @@ buffer and update it."
1611 (let ((pos (point)) start) 1648 (let ((pos (point)) start)
1612 (save-excursion 1649 (save-excursion
1613 (end-of-line 1) 1650 (end-of-line 1)
1614 (and (re-search-backward "^#\\+BEGIN:[ \t]+clocktable" nil t) 1651 (and (re-search-backward "^[ \t]*#\\+BEGIN:[ \t]+clocktable" nil t)
1615 (setq start (match-beginning 0)) 1652 (setq start (match-beginning 0))
1616 (re-search-forward "^#\\+END:.*" nil t) 1653 (re-search-forward "^[ \t]*#\\+END:.*" nil t)
1617 (>= (match-end 0) pos) 1654 (>= (match-end 0) pos)
1618 start)))) 1655 start))))
1619 1656
1657(defun org-day-of-week (day month year)
1658 "Returns the day of the week as an integer."
1659 (nth 6
1660 (decode-time
1661 (date-to-time
1662 (format "%d-%02d-%02dT00:00:00" year month day)))))
1663
1664(defun org-quarter-to-date (quarter year)
1665 "Get the date (week day year) of the first day of a given quarter."
1666 (let (startday)
1667 (cond
1668 ((= quarter 1)
1669 (setq startday (org-day-of-week 1 1 year))
1670 (cond
1671 ((= startday 0)
1672 (list 52 7 (- year 1)))
1673 ((= startday 6)
1674 (list 52 6 (- year 1)))
1675 ((<= startday 4)
1676 (list 1 startday year))
1677 ((> startday 4)
1678 (list 53 startday (- year 1)))
1679 )
1680 )
1681 ((= quarter 2)
1682 (setq startday (org-day-of-week 1 4 year))
1683 (cond
1684 ((= startday 0)
1685 (list 13 startday year))
1686 ((< startday 4)
1687 (list 14 startday year))
1688 ((>= startday 4)
1689 (list 13 startday year))
1690 )
1691 )
1692 ((= quarter 3)
1693 (setq startday (org-day-of-week 1 7 year))
1694 (cond
1695 ((= startday 0)
1696 (list 26 startday year))
1697 ((< startday 4)
1698 (list 27 startday year))
1699 ((>= startday 4)
1700 (list 26 startday year))
1701 )
1702 )
1703 ((= quarter 4)
1704 (setq startday (org-day-of-week 1 10 year))
1705 (cond
1706 ((= startday 0)
1707 (list 39 startday year))
1708 ((<= startday 4)
1709 (list 40 startday year))
1710 ((> startday 4)
1711 (list 39 startday year)))))))
1712
1620(defun org-clock-special-range (key &optional time as-strings) 1713(defun org-clock-special-range (key &optional time as-strings)
1621 "Return two times bordering a special time range. 1714 "Return two times bordering a special time range.
1622Key is a symbol specifying the range and can be one of `today', `yesterday', 1715Key is a symbol specifying the range and can be one of `today', `yesterday',
@@ -1633,7 +1726,12 @@ the returned times will be formatted strings."
1633 (dow (nth 6 tm)) 1726 (dow (nth 6 tm))
1634 (skey (symbol-name key)) 1727 (skey (symbol-name key))
1635 (shift 0) 1728 (shift 0)
1636 s1 m1 h1 d1 month1 y1 diff ts te fm txt w date) 1729 (q (cond ((>= (nth 4 tm) 10) 4)
1730 ((>= (nth 4 tm) 7) 3)
1731 ((>= (nth 4 tm) 4) 2)
1732 ((>= (nth 4 tm) 1) 1)))
1733 s1 m1 h1 d1 month1 y1 diff ts te fm txt w date
1734 interval tmp shiftedy shiftedm shiftedq)
1637 (cond 1735 (cond
1638 ((string-match "^[0-9]+$" skey) 1736 ((string-match "^[0-9]+$" skey)
1639 (setq y (string-to-number skey) m 1 d 1 key 'year)) 1737 (setq y (string-to-number skey) m 1 d 1 key 'year))
@@ -1650,6 +1748,15 @@ the returned times will be formatted strings."
1650 (setq d (nth 1 date) month (car date) y (nth 2 date) 1748 (setq d (nth 1 date) month (car date) y (nth 2 date)
1651 dow 1 1749 dow 1
1652 key 'week)) 1750 key 'week))
1751 ((string-match "^\\([0-9]+\\)-[qQ]\\([1-4]\\)$" skey)
1752 (require 'cal-iso)
1753 (setq y (string-to-number (match-string 1 skey)))
1754 (setq q (string-to-number (match-string 2 skey)))
1755 (setq date (calendar-gregorian-from-absolute
1756 (calendar-absolute-from-iso (org-quarter-to-date q y))))
1757 (setq d (nth 1 date) month (car date) y (nth 2 date)
1758 dow 1
1759 key 'quarter))
1653 ((string-match "^\\([0-9]+\\)-\\([0-9]\\{1,2\\}\\)-\\([0-9]\\{1,2\\}\\)$" skey) 1760 ((string-match "^\\([0-9]+\\)-\\([0-9]\\{1,2\\}\\)-\\([0-9]\\{1,2\\}\\)$" skey)
1654 (setq y (string-to-number (match-string 1 skey)) 1761 (setq y (string-to-number (match-string 1 skey))
1655 month (string-to-number (match-string 2 skey)) 1762 month (string-to-number (match-string 2 skey))
@@ -1657,12 +1764,17 @@ the returned times will be formatted strings."
1657 key 'day)) 1764 key 'day))
1658 ((string-match "\\([-+][0-9]+\\)$" skey) 1765 ((string-match "\\([-+][0-9]+\\)$" skey)
1659 (setq shift (string-to-number (match-string 1 skey)) 1766 (setq shift (string-to-number (match-string 1 skey))
1660 key (intern (substring skey 0 (match-beginning 1)))))) 1767 key (intern (substring skey 0 (match-beginning 1))))
1768 (if(and (memq key '(quarter thisq)) (> shift 0))
1769 (error "Looking forward with quarters isn't implemented.")
1770 ())))
1771
1661 (when (= shift 0) 1772 (when (= shift 0)
1662 (cond ((eq key 'yesterday) (setq key 'today shift -1)) 1773 (cond ((eq key 'yesterday) (setq key 'today shift -1))
1663 ((eq key 'lastweek) (setq key 'week shift -1)) 1774 ((eq key 'lastweek) (setq key 'week shift -1))
1664 ((eq key 'lastmonth) (setq key 'month shift -1)) 1775 ((eq key 'lastmonth) (setq key 'month shift -1))
1665 ((eq key 'lastyear) (setq key 'year shift -1)))) 1776 ((eq key 'lastyear) (setq key 'year shift -1))
1777 ((eq key 'lastq) (setq key 'quarter shift -1))))
1666 (cond 1778 (cond
1667 ((memq key '(day today)) 1779 ((memq key '(day today))
1668 (setq d (+ d shift) h 0 m 0 h1 24 m1 0)) 1780 (setq d (+ d shift) h 0 m 0 h1 24 m1 0))
@@ -1671,6 +1783,28 @@ the returned times will be formatted strings."
1671 m 0 h 0 d (- d diff) d1 (+ 7 d))) 1783 m 0 h 0 d (- d diff) d1 (+ 7 d)))
1672 ((memq key '(month thismonth)) 1784 ((memq key '(month thismonth))
1673 (setq d 1 h 0 m 0 d1 1 month (+ month shift) month1 (1+ month) h1 0 m1 0)) 1785 (setq d 1 h 0 m 0 d1 1 month (+ month shift) month1 (1+ month) h1 0 m1 0))
1786 ((memq key '(quarter thisq))
1787 ; compute if this shift remains in this year
1788 ; if not, compute how many years and quarters we have to shift (via floor*)
1789 ; and compute the shifted years, months and quarters
1790 (cond
1791 ((< (+ (- q 1) shift) 0) ; shift not in this year
1792 (setq interval (* -1 (+ (- q 1) shift)))
1793 ; set tmp to ((years to shift) (quarters to shift))
1794 (setq tmp (org-floor* interval 4))
1795 ; due to the use of floor, 0 quarters actually means 4
1796 (if (= 0 (nth 1 tmp))
1797 (setq shiftedy (- y (nth 0 tmp))
1798 shiftedm 1
1799 shiftedq 1)
1800 (setq shiftedy (- y (+ 1 (nth 0 tmp)))
1801 shiftedm (- 13 (* 3 (nth 1 tmp)))
1802 shiftedq (- 5 (nth 1 tmp))))
1803 (setq d 1 h 0 m 0 d1 1 month shiftedm month1 (+ 3 shiftedm) h1 0 m1 0 y shiftedy))
1804 ((> (+ q shift) 0) ; shift is whitin this year
1805 (setq shiftedq (+ q shift))
1806 (setq shiftedy y)
1807 (setq d 1 h 0 m 0 d1 1 month (+ 1 (* 3 (- (+ q shift) 1))) month1 (+ 4 (* 3 (- (+ q shift) 1))) h1 0 m1 0))))
1674 ((memq key '(year thisyear)) 1808 ((memq key '(year thisyear))
1675 (setq m 0 h 0 d 1 month 1 y (+ y shift) y1 (1+ y))) 1809 (setq m 0 h 0 d 1 month 1 y (+ y shift) y1 (1+ y)))
1676 (t (error "No such time block %s" key))) 1810 (t (error "No such time block %s" key)))
@@ -1686,11 +1820,21 @@ the returned times will be formatted strings."
1686 ((memq key '(month thismonth)) 1820 ((memq key '(month thismonth))
1687 (setq txt (format-time-string "%B %Y" ts))) 1821 (setq txt (format-time-string "%B %Y" ts)))
1688 ((memq key '(year thisyear)) 1822 ((memq key '(year thisyear))
1689 (setq txt (format-time-string "the year %Y" ts)))) 1823 (setq txt (format-time-string "the year %Y" ts)))
1824 ((memq key '(quarter thisq))
1825 (setq txt (concatenate 'string (org-count-quarter shiftedq) " quarter of " (number-to-string shiftedy))))
1826 )
1690 (if as-strings 1827 (if as-strings
1691 (list (format-time-string fm ts) (format-time-string fm te) txt) 1828 (list (format-time-string fm ts) (format-time-string fm te) txt)
1692 (list ts te txt)))) 1829 (list ts te txt))))
1693 1830
1831(defun org-count-quarter (n)
1832 (cond
1833 ((= n 1) "1st")
1834 ((= n 2) "2nd")
1835 ((= n 3) "3rd")
1836 ((= n 4) "4th")))
1837
1694(defun org-clocktable-shift (dir n) 1838(defun org-clocktable-shift (dir n)
1695 "Try to shift the :block date of the clocktable at point. 1839 "Try to shift the :block date of the clocktable at point.
1696Point must be in the #+BEGIN: line of a clocktable, or this function 1840Point must be in the #+BEGIN: line of a clocktable, or this function
@@ -1704,7 +1848,7 @@ the currently selected interval size."
1704 (and (memq dir '(left down)) (setq n (- n))) 1848 (and (memq dir '(left down)) (setq n (- n)))
1705 (save-excursion 1849 (save-excursion
1706 (goto-char (point-at-bol)) 1850 (goto-char (point-at-bol))
1707 (if (not (looking-at "#\\+BEGIN: clocktable\\>.*?:block[ \t]+\\(\\S-+\\)")) 1851 (if (not (looking-at "^[ \t]*#\\+BEGIN:[ \t]+clocktable\\>.*?:block[ \t]+\\(\\S-+\\)"))
1708 (error "Line needs a :block definition before this command works") 1852 (error "Line needs a :block definition before this command works")
1709 (let* ((b (match-beginning 1)) (e (match-end 1)) 1853 (let* ((b (match-beginning 1)) (e (match-end 1))
1710 (s (match-string 1)) 1854 (s (match-string 1))
@@ -1713,90 +1857,95 @@ the currently selected interval size."
1713 ((equal s "yesterday") (setq s "today-1")) 1857 ((equal s "yesterday") (setq s "today-1"))
1714 ((equal s "lastweek") (setq s "thisweek-1")) 1858 ((equal s "lastweek") (setq s "thisweek-1"))
1715 ((equal s "lastmonth") (setq s "thismonth-1")) 1859 ((equal s "lastmonth") (setq s "thismonth-1"))
1716 ((equal s "lastyear") (setq s "thisyear-1"))) 1860 ((equal s "lastyear") (setq s "thisyear-1"))
1717 (cond 1861 ((equal s "lastq") (setq s "thisq-1")))
1718 ((string-match "^\\(today\\|thisweek\\|thismonth\\|thisyear\\)\\([-+][0-9]+\\)?$" s) 1862
1719 (setq block (match-string 1 s) 1863 (cond
1720 shift (if (match-end 2) 1864 ((string-match "^\\(today\\|thisweek\\|thismonth\\|thisyear\\|thisq\\)\\([-+][0-9]+\\)?$" s)
1721 (string-to-number (match-string 2 s)) 1865 (setq block (match-string 1 s)
1722 0)) 1866 shift (if (match-end 2)
1723 (setq shift (+ shift n)) 1867 (string-to-number (match-string 2 s))
1724 (setq ins (if (= shift 0) block (format "%s%+d" block shift)))) 1868 0))
1725 ((string-match "\\([0-9]+\\)\\(-\\([wW]?\\)\\([0-9]\\{1,2\\}\\)\\(-\\([0-9]\\{1,2\\}\\)\\)?\\)?" s) 1869 (setq shift (+ shift n))
1726 ;; 1 1 2 3 3 4 4 5 6 6 5 2 1870 (setq ins (if (= shift 0) block (format "%s%+d" block shift))))
1727 (setq y (string-to-number (match-string 1 s)) 1871 ((string-match "\\([0-9]+\\)\\(-\\([wWqQ]?\\)\\([0-9]\\{1,2\\}\\)\\(-\\([0-9]\\{1,2\\}\\)\\)?\\)?" s)
1728 wp (and (match-end 3) (match-string 3 s)) 1872 ;; 1 1 2 3 3 4 4 5 6 6 5 2
1729 mw (and (match-end 4) (string-to-number (match-string 4 s))) 1873 (setq y (string-to-number (match-string 1 s))
1730 d (and (match-end 6) (string-to-number (match-string 6 s)))) 1874 wp (and (match-end 3) (match-string 3 s))
1731 (cond 1875 mw (and (match-end 4) (string-to-number (match-string 4 s)))
1732 (d (setq ins (format-time-string 1876 d (and (match-end 6) (string-to-number (match-string 6 s))))
1733 "%Y-%m-%d" 1877 (cond
1734 (encode-time 0 0 0 (+ d n) m y)))) 1878 (d (setq ins (format-time-string
1735 ((and wp mw (> (length wp) 0)) 1879 "%Y-%m-%d"
1736 (require 'cal-iso) 1880 (encode-time 0 0 0 (+ d n) m y))))
1737 (setq date (calendar-gregorian-from-absolute (calendar-absolute-from-iso (list (+ mw n) 1 y)))) 1881 ((and wp (string-match "w\\|W" wp) mw (> (length wp) 0))
1738 (setq ins (format-time-string 1882 (require 'cal-iso)
1739 "%G-W%V" 1883 (setq date (calendar-gregorian-from-absolute (calendar-absolute-from-iso (list (+ mw n) 1 y))))
1740 (encode-time 0 0 0 (nth 1 date) (car date) (nth 2 date))))) 1884 (setq ins (format-time-string
1741 (mw 1885 "%G-W%V"
1742 (setq ins (format-time-string 1886 (encode-time 0 0 0 (nth 1 date) (car date) (nth 2 date)))))
1743 "%Y-%m" 1887 ((and wp (string-match "q\\|Q" wp) mw (> (length wp) 0))
1744 (encode-time 0 0 0 1 (+ mw n) y)))) 1888 (require 'cal-iso)
1745 (y 1889 ; if the 4th + 1 quarter is requested we flip to the 1st quarter of the next year
1746 (setq ins (number-to-string (+ y n)))))) 1890 (if (> (+ mw n) 4)
1747 (t (error "Cannot shift clocktable block"))) 1891 (setq mw 0
1748 (when ins 1892 y (+ 1 y))
1749 (goto-char b) 1893 ())
1750 (insert ins) 1894 ; if the 1st - 1 quarter is requested we flip to the 4th quarter of the previous year
1751 (delete-region (point) (+ (point) (- e b))) 1895 (if (= (+ mw n) 0)
1752 (beginning-of-line 1) 1896 (setq mw 5
1753 (org-update-dblock) 1897 y (- y 1))
1754 t))))) 1898 ())
1899 (setq date (calendar-gregorian-from-absolute (calendar-absolute-from-iso (org-quarter-to-date (+ mw n) y))))
1900 (setq ins (format-time-string
1901 (concatenate 'string (number-to-string y) "-Q" (number-to-string (+ mw n)))
1902 (encode-time 0 0 0 (nth 1 date) (car date) (nth 2 date)))))
1903 (mw
1904 (setq ins (format-time-string
1905 "%Y-%m"
1906 (encode-time 0 0 0 1 (+ mw n) y))))
1907 (y
1908 (setq ins (number-to-string (+ y n))))))
1909 (t (error "Cannot shift clocktable block")))
1910 (when ins
1911 (goto-char b)
1912 (insert ins)
1913 (delete-region (point) (+ (point) (- e b)))
1914 (beginning-of-line 1)
1915 (org-update-dblock)
1916 t)))))
1755 1917
1756(defun org-dblock-write:clocktable (params) 1918(defun org-dblock-write:clocktable (params)
1757 "Write the standard clocktable." 1919 "Write the standard clocktable."
1920 (setq params (org-combine-plists org-clocktable-defaults params))
1758 (catch 'exit 1921 (catch 'exit
1759 (let* ((hlchars '((1 . "*") (2 . "/"))) 1922 (let* ((scope (plist-get params :scope))
1760 (ins (make-marker)) 1923 (block (plist-get params :block))
1761 (total-time nil)
1762 (scope (plist-get params :scope))
1763 (tostring (plist-get params :tostring))
1764 (multifile (plist-get params :multifile))
1765 (header (plist-get params :header))
1766 (maxlevel (or (plist-get params :maxlevel) 3))
1767 (step (plist-get params :step))
1768 (emph (plist-get params :emphasize))
1769 (timestamp (plist-get params :timestamp))
1770 (ts (plist-get params :tstart)) 1924 (ts (plist-get params :tstart))
1771 (te (plist-get params :tend)) 1925 (te (plist-get params :tend))
1772 (block (plist-get params :block))
1773 (link (plist-get params :link)) 1926 (link (plist-get params :link))
1774 (tags (plist-get params :tags)) 1927 (maxlevel (or (plist-get params :maxlevel) 3))
1775 (matcher (if tags (cdr (org-make-tags-matcher tags)))) 1928 (step (plist-get params :step))
1776 ipos time p level hlc hdl tsp props content recalc formula pcol 1929 (timestamp (plist-get params :timestamp))
1777 cc beg end pos tbl tbl1 range-text rm-file-column scope-is-list st) 1930 (formatter (or (plist-get params :formatter)
1778 (setq org-clock-file-total-minutes nil) 1931 org-clock-clocktable-formatter
1932 'org-clocktable-write-default))
1933 cc range-text ipos pos one-file-with-archives
1934 scope-is-list tbls level)
1935
1936 ;; Check if we need to do steps
1937 (when block
1938 ;; Get the range text for the header
1939 (setq cc (org-clock-special-range block nil t)
1940 ts (car cc) te (nth 1 cc) range-text (nth 2 cc)))
1779 (when step 1941 (when step
1942 ;; Write many tables, in steps
1780 (unless (or block (and ts te)) 1943 (unless (or block (and ts te))
1781 (error "Clocktable `:step' can only be used with `:block' or `:tstart,:end'")) 1944 (error "Clocktable `:step' can only be used with `:block' or `:tstart,:end'"))
1782 (org-clocktable-steps params) 1945 (org-clocktable-steps params)
1783 (throw 'exit nil)) 1946 (throw 'exit nil))
1784 (when block 1947
1785 (setq cc (org-clock-special-range block nil t) 1948 (setq ipos (point)) ; remember the insertion position
1786 ts (car cc) te (nth 1 cc) range-text (nth 2 cc)))
1787 (when (integerp ts) (setq ts (calendar-gregorian-from-absolute ts)))
1788 (when (integerp te) (setq te (calendar-gregorian-from-absolute te)))
1789 (when (and ts (listp ts))
1790 (setq ts (format "%4d-%02d-%02d" (nth 2 ts) (car ts) (nth 1 ts))))
1791 (when (and te (listp te))
1792 (setq te (format "%4d-%02d-%02d" (nth 2 te) (car te) (nth 1 te))))
1793 ;; Now the times are strings we can parse.
1794 (if ts (setq ts (org-float-time
1795 (apply 'encode-time (org-parse-time-string ts)))))
1796 (if te (setq te (org-float-time
1797 (apply 'encode-time (org-parse-time-string te)))))
1798 (move-marker ins (point))
1799 (setq ipos (point))
1800 1949
1801 ;; Get the right scope 1950 ;; Get the right scope
1802 (setq pos (point)) 1951 (setq pos (point))
@@ -1810,166 +1959,271 @@ the currently selected interval size."
1810 (setq scope (org-add-archive-files scope))) 1959 (setq scope (org-add-archive-files scope)))
1811 ((eq scope 'file-with-archives) 1960 ((eq scope 'file-with-archives)
1812 (setq scope (org-add-archive-files (list (buffer-file-name))) 1961 (setq scope (org-add-archive-files (list (buffer-file-name)))
1813 rm-file-column t))) 1962 one-file-with-archives t)))
1814 (setq scope-is-list (and scope (listp scope))) 1963 (setq scope-is-list (and scope (listp scope)))
1815 (save-restriction 1964 (if scope-is-list
1816 (cond 1965 ;; we collect from several files
1817 ((not scope))
1818 ((eq scope 'file) (widen))
1819 ((eq scope 'subtree) (org-narrow-to-subtree))
1820 ((eq scope 'tree)
1821 (while (org-up-heading-safe))
1822 (org-narrow-to-subtree))
1823 ((and (symbolp scope) (string-match "^tree\\([0-9]+\\)$"
1824 (symbol-name scope)))
1825 (setq level (string-to-number (match-string 1 (symbol-name scope))))
1826 (catch 'exit
1827 (while (org-up-heading-safe)
1828 (looking-at outline-regexp)
1829 (if (<= (org-reduced-level (funcall outline-level)) level)
1830 (throw 'exit nil))))
1831 (org-narrow-to-subtree))
1832 (scope-is-list
1833 (let* ((files scope) 1966 (let* ((files scope)
1834 (scope 'agenda)
1835 (p1 (copy-sequence params))
1836 file) 1967 file)
1837 (setq p1 (plist-put p1 :tostring t))
1838 (setq p1 (plist-put p1 :multifile t))
1839 (setq p1 (plist-put p1 :scope 'file))
1840 (org-prepare-agenda-buffers files) 1968 (org-prepare-agenda-buffers files)
1841 (while (setq file (pop files)) 1969 (while (setq file (pop files))
1842 (with-current-buffer (find-buffer-visiting file) 1970 (with-current-buffer (find-buffer-visiting file)
1843 (setq org-clock-file-total-minutes 0) 1971 (save-excursion
1844 (setq tbl1 (org-dblock-write:clocktable p1)) 1972 (save-restriction
1845 (when tbl1 1973 (push (org-clock-get-table-data file params) tbls))))))
1846 (push (org-clocktable-add-file 1974 ;; Just from the current file
1847 file 1975 (save-restriction
1848 (concat "| |*File time*|*" 1976 ;; get the right range into the restriction
1849 (org-minutes-to-hh:mm-string 1977 (org-prepare-agenda-buffers (list (buffer-file-name)))
1850 org-clock-file-total-minutes) 1978 (cond
1851 "*|\n" 1979 ((not scope)) ; use the restriction as it is now
1852 tbl1)) tbl) 1980 ((eq scope 'file) (widen))
1853 (setq total-time (+ (or total-time 0) 1981 ((eq scope 'subtree) (org-narrow-to-subtree))
1854 org-clock-file-total-minutes)))))))) 1982 ((eq scope 'tree)
1855 (goto-char pos) 1983 (while (org-up-heading-safe))
1856 1984 (org-narrow-to-subtree))
1857 (unless scope-is-list 1985 ((and (symbolp scope) (string-match "^tree\\([0-9]+\\)$"
1858 (org-clock-sum ts te 1986 (symbol-name scope)))
1859 (unless (null matcher) 1987 (setq level (string-to-number (match-string 1 (symbol-name scope))))
1860 (lambda () 1988 (catch 'exit
1861 (let ((tags-list 1989 (while (org-up-heading-safe)
1862 (org-split-string 1990 (looking-at outline-regexp)
1863 (or (org-entry-get (point) "ALLTAGS") "") 1991 (if (<= (org-reduced-level (funcall outline-level)) level)
1864 ":"))) 1992 (throw 'exit nil))))
1865 (eval matcher))))) 1993 (org-narrow-to-subtree)))
1866 (goto-char (point-min)) 1994 ;; do the table, with no file name.
1867 (setq st t) 1995 (push (org-clock-get-table-data nil params) tbls)))
1868 (while (or (and (bobp) (prog1 st (setq st nil)) 1996
1869 (get-text-property (point) :org-clock-minutes) 1997 ;; OK, at this point we tbls as a list of tables, one per file
1870 (setq p (point-min))) 1998 (setq tbls (nreverse tbls))
1871 (setq p (next-single-property-change (point) :org-clock-minutes))) 1999
1872 (goto-char p) 2000 (setq params (plist-put params :multifile scope-is-list))
1873 (when (setq time (get-text-property p :org-clock-minutes)) 2001 (setq params (plist-put params :one-file-with-archives
1874 (save-excursion 2002 one-file-with-archives))
1875 (beginning-of-line 1) 2003
1876 (when (and (looking-at (org-re "\\(\\*+\\)[ \t]+\\(.*?\\)\\([ \t]+:[[:alnum:]_@#%:]+:\\)?[ \t]*$")) 2004 (funcall formatter ipos tbls params))))
1877 (setq level (org-reduced-level 2005
1878 (- (match-end 1) (match-beginning 1)))) 2006(defun org-clocktable-write-default (ipos tables params)
1879 (<= level maxlevel)) 2007 "Write out a clock table at position IPOS in the current buffer.
1880 (setq hlc (if emph (or (cdr (assoc level hlchars)) "") "") 2008TABLES is a list of tables with clocking data as produced by
1881 hdl (if (not link) 2009`org-clock-get-table-data'. PARAMS is the parameter property list obtained
1882 (match-string 2) 2010from the dynamic block defintion."
1883 (org-make-link-string 2011 ;; This function looks quite complicated, mainly because there are a lot
1884 (format "file:%s::%s" 2012 ;; of options which can add or remove columns. I have massively commented
1885 (buffer-file-name) 2013 ;; function, to I hope it is understandable. If someone want to write
1886 (save-match-data 2014 ;; there own special formatter, this maybe much easier because there can
1887 (org-make-org-heading-search-string 2015 ;; be a fixed format with a well-defined number of columns...
1888 (match-string 2)))) 2016 (let* ((hlchars '((1 . "*") (2 . "/")))
1889 (match-string 2))) 2017 (multifile (plist-get params :multifile))
1890 tsp (when timestamp 2018 (block (plist-get params :block))
1891 (setq props (org-entry-properties (point))) 2019 (ts (plist-get params :tstart))
1892 (or (cdr (assoc "SCHEDULED" props)) 2020 (te (plist-get params :tend))
1893 (cdr (assoc "TIMESTAMP" props)) 2021 (header (plist-get params :header))
1894 (cdr (assoc "DEADLINE" props)) 2022 (narrow (plist-get params :narrow))
1895 (cdr (assoc "TIMESTAMP_IA" props))))) 2023 (link (plist-get params :link))
1896 (if (and (not multifile) (= level 1)) (push "|-" tbl)) 2024 (maxlevel (or (plist-get params :maxlevel) 3))
1897 (push (concat 2025 (emph (plist-get params :emphasize))
1898 "| " (int-to-string level) "|" 2026 (level-p (plist-get params :level))
1899 (if timestamp (concat tsp "|") "") 2027 (timestamp (plist-get params :timestamp))
1900 hlc hdl hlc " |" 2028 (ntcol (max 1 (or (plist-get params :tcolumns) 100)))
1901 (make-string (1- level) ?|) 2029 (rm-file-column (plist-get params :one-file-with-archives))
1902 hlc (org-minutes-to-hh:mm-string time) hlc 2030 (indent (plist-get params :indent))
1903 " |") tbl)))))) 2031 range-text total-time tbl level hlc formula pcol
1904 (setq tbl (nreverse tbl)) 2032 file-time entries entry headline
1905 (if tostring 2033 recalc content narrow-cut-p tcol)
1906 (if tbl (mapconcat 'identity tbl "\n") nil) 2034
1907 (goto-char ins) 2035 ;; Implement abbreviations
1908 (insert-before-markers 2036 (when (plist-get params :compact)
1909 (or header 2037 (setq level nil indent t narrow (or narrow '40!) ntcol 1))
1910 (concat 2038
1911 "Clock summary at [" 2039 ;; Some consistency test for parameters
1912 (substring 2040 (unless (integerp ntcol)
1913 (format-time-string (cdr org-time-stamp-formats)) 2041 (setq params (plist-put params :tcolumns (setq ntcol 100))))
1914 1 -1) 2042
1915 "]" 2043 (when (and narrow (integerp narrow) link)
1916 (if block (concat ", for " range-text ".") "") 2044 ;; We cannot have both integer narrow and link
1917 "\n\n")) 2045 (message
1918 (if scope-is-list "|File" "") 2046 "Using hard narrowing in clocktable to allow for links")
1919 "|L|" (if timestamp "Timestamp|" "") "Headline|Time|\n") 2047 (setq narrow (intern (format "%d!" narrow))))
1920 (setq total-time (or total-time org-clock-file-total-minutes)) 2048
1921 (insert-before-markers 2049 (when narrow
1922 "|-\n|" 2050 (cond
1923 (if scope-is-list "|" "") 2051 ((integerp narrow))
1924 (if timestamp "|Timestamp|" "|") 2052 ((and (symbolp narrow)
1925 "*Total time*| *" 2053 (string-match "\\`[0-9]+!\\'" (symbol-name narrow)))
1926 (org-minutes-to-hh:mm-string (or total-time 0)) 2054 (setq narrow-cut-p t
1927 "*|\n|-\n") 2055 narrow (string-to-number (substring (symbol-name narrow)
1928 (setq tbl (delq nil tbl)) 2056 0 -1))))
1929 (if (and (stringp (car tbl)) (> (length (car tbl)) 1) 2057 (t
1930 (equal (substring (car tbl) 0 2) "|-")) 2058 (error "Invalid value %s of :narrow property in clock table"
1931 (pop tbl)) 2059 narrow))))
1932 (insert-before-markers (mapconcat 2060
1933 'identity (delq nil tbl) 2061 (when block
1934 (if scope-is-list "\n|-\n" "\n"))) 2062 ;; Get the range text for the header
1935 (backward-delete-char 1) 2063 (setq range-text (nth 2 (org-clock-special-range block nil t))))
1936 (if (setq formula (plist-get params :formula)) 2064
1937 (cond 2065 ;; Compute the total time
1938 ((eq formula '%) 2066 (setq total-time (apply '+ (mapcar 'cadr tables)))
1939 (setq pcol (+ (if scope-is-list 1 0) maxlevel 3)) 2067
1940 (insert 2068 ;; Now we need to output this tsuff
1941 (format 2069 (goto-char ipos)
1942 "\n#+TBLFM: $%d='(org-clock-time%% @%d$%d $%d..$%d);%%.1f" 2070
1943 pcol 2071 ;; Insert the text *before* the actual table
1944 2 2072 (insert-before-markers
1945 (+ 3 (if scope-is-list 1 0)) 2073 (or header
1946 (+ (if scope-is-list 1 0) 3) 2074 ;; Format the standard header
1947 (1- pcol))) 2075 (concat
1948 (setq recalc t)) 2076 "Clock summary at ["
1949 ((stringp formula) 2077 (substring
1950 (insert "\n#+TBLFM: " formula) 2078 (format-time-string (cdr org-time-stamp-formats))
1951 (setq recalc t)) 2079 1 -1)
1952 (t (error "invalid formula in clocktable"))) 2080 "]"
1953 ;; Should we rescue an old formula? 2081 (if block (concat ", for " range-text ".") "")
1954 (when (stringp (setq content (plist-get params :content))) 2082 "\n\n")))
1955 (when (string-match "^\\([ \t]*#\\+TBLFM:.*\\)" content) 2083
1956 (setq recalc t) 2084 ;; Insert the narrowing line
1957 (insert "\n" (match-string 1 (plist-get params :content))) 2085 (when (and narrow (integerp narrow) (not narrow-cut-p))
1958 (beginning-of-line 0)))) 2086 (insert-before-markers
1959 (goto-char ipos) 2087 "|" ; table line starter
1960 (skip-chars-forward "^|") 2088 (if multifile "|" "") ; file column, maybe
1961 (org-table-align) 2089 (if level-p "|" "") ; level column, maybe
1962 (when recalc 2090 (if timestamp "|" "") ; timestamp column, maybe
1963 (if (eq formula '%) 2091 (format "<%d>| |\n" narrow))) ; headline and time columns
1964 (save-excursion (org-table-goto-column pcol nil 'force) 2092
1965 (insert "%"))) 2093 ;; Insert the table header line
1966 (org-table-recalculate 'all)) 2094 (insert-before-markers
1967 (when rm-file-column 2095 "|" ; table line starter
1968 (forward-char 1) 2096 (if multifile "File|" "") ; file column, maybe
1969 (org-table-delete-column)) 2097 (if level-p "L|" "") ; level column, maybe
1970 total-time))))) 2098 (if timestamp "Timestamp|" "") ; timestamp column, maybe
2099 "Headline|Time|\n") ; headline and time columns
2100
2101 ;; Insert the total time in the table
2102 (insert-before-markers
2103 "|-\n" ; a hline
2104 "|" ; table line starter
2105 (if multifile "| ALL " "") ; file column, maybe
2106 (if level-p "|" "") ; level column, maybe
2107 (if timestamp "|" "") ; timestamp column, maybe
2108 "*Total time*| " ; instead of a headline
2109 "*"
2110 (org-minutes-to-hh:mm-string (or total-time 0)) ; the time
2111 "*|\n") ; close line
2112
2113 ;; Now iterate over the tables and insert the data
2114 ;; but only if any time has been collected
2115 (when (and total-time (> total-time 0))
2116
2117 (while (setq tbl (pop tables))
2118 ;; now tbl is the table resulting from one file.
2119 (setq file-time (nth 1 tbl))
2120 (when (or (and file-time (> file-time 0))
2121 (not (plist-get params :fileskip0)))
2122 (insert-before-markers "|-\n") ; a hline because a new file starts
2123 ;; First the file time, if we have multiple files
2124 (when multifile
2125 ;; Summarize the time colleted from this file
2126 (insert-before-markers
2127 (format "| %s %s | %s*File time* | *%s*|\n"
2128 (file-name-nondirectory (car tbl))
2129 (if level-p "| " "") ; level column, maybe
2130 (if timestamp "| " "") ; timestamp column, maybe
2131 (org-minutes-to-hh:mm-string (nth 1 tbl))))) ; the time
2132
2133 ;; Get the list of node entries and iterate over it
2134 (setq entries (nth 2 tbl))
2135 (while (setq entry (pop entries))
2136 (setq level (car entry)
2137 headline (nth 1 entry)
2138 hlc (if emph (or (cdr (assoc level hlchars)) "") ""))
2139 (when narrow-cut-p
2140 (if (and (string-match (concat "\\`" org-bracket-link-regexp
2141 "\\'")
2142 headline)
2143 (match-end 3))
2144 (setq headline
2145 (format "[[%s][%s]]"
2146 (match-string 1 headline)
2147 (org-shorten-string (match-string 3 headline)
2148 narrow)))
2149 (setq headline (org-shorten-string headline narrow))))
2150 (insert-before-markers
2151 "|" ; start the table line
2152 (if multifile "|" "") ; free space for file name column?
2153 (if level-p (format "%d|" (car entry)) "") ; level, maybe
2154 (if timestamp (concat (nth 2 entry) "|") "") ; timestamp, maybe
2155 (if indent (org-clocktable-indent-string level) "") ; indentation
2156 hlc headline hlc "|" ; headline
2157 (make-string (min (1- ntcol) (or (- level 1))) ?|)
2158 ; empty fields for higher levels
2159 hlc (org-minutes-to-hh:mm-string (nth 3 entry)) hlc ; time
2160 "|\n" ; close line
2161 )))))
2162 (backward-delete-char 1)
2163 (if (setq formula (plist-get params :formula))
2164 (cond
2165 ((eq formula '%)
2166 ;; compute the column where the % numbers need to go
2167 (setq pcol (+ 2
2168 (if multifile 1 0)
2169 (if level-p 1 0)
2170 (if timestamp 1 0)
2171 (min maxlevel (or ntcol 100))))
2172 ;; compute the column where the total time is
2173 (setq tcol (+ 2
2174 (if multifile 1 0)
2175 (if level-p 1 0)
2176 (if timestamp 1 0)))
2177 (insert
2178 (format
2179 "\n#+TBLFM: $%d='(org-clock-time%% @%d$%d $%d..$%d);%%.1f"
2180 pcol ; the column where the % numbers should go
2181 (if (and narrow (not narrow-cut-p)) 3 2) ; row of the total time
2182 tcol ; column of the total time
2183 tcol (1- pcol) ; range of columns where times can be found
2184 ))
2185 (setq recalc t))
2186 ((stringp formula)
2187 (insert "\n#+TBLFM: " formula)
2188 (setq recalc t))
2189 (t (error "invalid formula in clocktable")))
2190 ;; Should we rescue an old formula?
2191 (when (stringp (setq content (plist-get params :content)))
2192 (when (string-match "^\\([ \t]*#\\+TBLFM:.*\\)" content)
2193 (setq recalc t)
2194 (insert "\n" (match-string 1 (plist-get params :content)))
2195 (beginning-of-line 0))))
2196 ;; Back to beginning, align the table, recalculate if necessary
2197 (goto-char ipos)
2198 (skip-chars-forward "^|")
2199 (org-table-align)
2200 (when org-hide-emphasis-markers
2201 ;; we need to align a second time
2202 (org-table-align))
2203 (when recalc
2204 (if (eq formula '%)
2205 (save-excursion
2206 (if (and narrow (not narrow-cut-p)) (beginning-of-line 2))
2207 (org-table-goto-column pcol nil 'force)
2208 (insert "%")))
2209 (org-table-recalculate 'all))
2210 (when rm-file-column
2211 ;; The file column is actually not wanted
2212 (forward-char 1)
2213 (org-table-delete-column))
2214 total-time))
2215
2216(defun org-clocktable-indent-string (level)
2217 (if (= level 1)
2218 ""
2219 (let ((str "\\__"))
2220 (while (> level 2)
2221 (setq level (1- level)
2222 str (concat str "___")))
2223 (concat str " "))))
1971 2224
1972(defun org-clocktable-steps (params) 2225(defun org-clocktable-steps (params)
2226 "Step through the range to make a number of clock tables."
1973 (let* ((p1 (copy-sequence params)) 2227 (let* ((p1 (copy-sequence params))
1974 (ts (plist-get p1 :tstart)) 2228 (ts (plist-get p1 :tstart))
1975 (te (plist-get p1 :tend)) 2229 (te (plist-get p1 :tend))
@@ -2008,29 +2262,107 @@ the currently selected interval size."
2008 (setq p1 (plist-put p1 :tend (format-time-string 2262 (setq p1 (plist-put p1 :tend (format-time-string
2009 (org-time-stamp-format nil t) 2263 (org-time-stamp-format nil t)
2010 (seconds-to-time (setq ts (+ ts step)))))) 2264 (seconds-to-time (setq ts (+ ts step))))))
2011 (insert "\n" (if (eq step0 'day) "Daily report: " "Weekly report starting on: ") 2265 (insert "\n" (if (eq step0 'day) "Daily report: "
2266 "Weekly report starting on: ")
2012 (plist-get p1 :tstart) "\n") 2267 (plist-get p1 :tstart) "\n")
2013 (setq step-time (org-dblock-write:clocktable p1)) 2268 (setq step-time (org-dblock-write:clocktable p1))
2014 (re-search-forward "#\\+END:") 2269 (re-search-forward "^[ \t]*#\\+END:")
2015 (when (and (equal step-time 0) stepskip0) 2270 (when (and (equal step-time 0) stepskip0)
2016 ;; Remove the empty table 2271 ;; Remove the empty table
2017 (delete-region (point-at-bol) 2272 (delete-region (point-at-bol)
2018 (save-excursion 2273 (save-excursion
2019 (re-search-backward "^\\(Daily\\|Weekly\\) report" nil t) 2274 (re-search-backward "^\\(Daily\\|Weekly\\) report"
2275 nil t)
2020 (point)))) 2276 (point))))
2021 (end-of-line 0)))) 2277 (end-of-line 0))))
2022 2278
2023(defun org-clocktable-add-file (file table) 2279(defun org-clock-get-table-data (file params)
2024 (if table 2280 "Get the clocktable data for file FILE, with parameters PARAMS.
2025 (let ((lines (org-split-string table "\n")) 2281FILE is only for identification - this function assumes that
2026 (ff (file-name-nondirectory file))) 2282the correct buffer is current, and that the wanted restriction is
2027 (mapconcat 'identity 2283in place.
2028 (mapcar (lambda (x) 2284The return value will be a list with the file name and the total
2029 (if (string-match org-table-dataline-regexp x) 2285file time (in minutes) as 1st and 2nd elements. The third element
2030 (concat "|" ff x) 2286of this list will be a list of headline entries. Each entry has the
2031 x)) 2287following structure:
2032 lines) 2288
2033 "\n")))) 2289 (LEVEL HEADLINE TIMESTAMP TIME)
2290
2291LEVEL: The level of the headline, as an integer. This will be
2292 the reduced leve, so 1,2,3,... even if only odd levels
2293 are being used.
2294HEADLINE: The text of the headline. Depending on PARAMS, this may
2295 already be formatted like a link.
2296TIMESTAMP: If PARAMS require it, this will be a time stamp found in the
2297 entry, any of SCHEDULED, DEADLINE, NORMAL, or first inactive,
2298 in this sequence.
2299TIME: The sum of all time spend in this tree, in minutes. This time
2300 will of cause be restricted to the time block and tags match
2301 specified in PARAMS."
2302 (let* ((maxlevel (or (plist-get params :maxlevel) 3))
2303 (timestamp (plist-get params :timestamp))
2304 (ts (plist-get params :tstart))
2305 (te (plist-get params :tend))
2306 (block (plist-get params :block))
2307 (link (plist-get params :link))
2308 (tags (plist-get params :tags))
2309 (matcher (if tags (cdr (org-make-tags-matcher tags))))
2310 cc range-text st p time level hdl props tsp tbl)
2311
2312 (setq org-clock-file-total-minutes nil)
2313 (when block
2314 (setq cc (org-clock-special-range block nil t)
2315 ts (car cc) te (nth 1 cc) range-text (nth 2 cc)))
2316 (when (integerp ts) (setq ts (calendar-gregorian-from-absolute ts)))
2317 (when (integerp te) (setq te (calendar-gregorian-from-absolute te)))
2318 (when (and ts (listp ts))
2319 (setq ts (format "%4d-%02d-%02d" (nth 2 ts) (car ts) (nth 1 ts))))
2320 (when (and te (listp te))
2321 (setq te (format "%4d-%02d-%02d" (nth 2 te) (car te) (nth 1 te))))
2322 ;; Now the times are strings we can parse.
2323 (if ts (setq ts (org-float-time
2324 (apply 'encode-time (org-parse-time-string ts)))))
2325 (if te (setq te (org-float-time
2326 (apply 'encode-time (org-parse-time-string te)))))
2327 (save-excursion
2328 (org-clock-sum ts te
2329 (unless (null matcher)
2330 (lambda ()
2331 (let ((tags-list (org-get-tags-at)))
2332 (eval matcher)))))
2333 (goto-char (point-min))
2334 (setq st t)
2335 (while (or (and (bobp) (prog1 st (setq st nil))
2336 (get-text-property (point) :org-clock-minutes)
2337 (setq p (point-min)))
2338 (setq p (next-single-property-change
2339 (point) :org-clock-minutes)))
2340 (goto-char p)
2341 (when (setq time (get-text-property p :org-clock-minutes))
2342 (save-excursion
2343 (beginning-of-line 1)
2344 (when (and (looking-at (org-re "\\(\\*+\\)[ \t]+\\(.*?\\)\\([ \t]+:[[:alnum:]_@#%:]+:\\)?[ \t]*$"))
2345 (setq level (org-reduced-level
2346 (- (match-end 1) (match-beginning 1))))
2347 (<= level maxlevel))
2348 (setq hdl (if (not link)
2349 (match-string 2)
2350 (org-make-link-string
2351 (format "file:%s::%s"
2352 (buffer-file-name)
2353 (save-match-data
2354 (org-make-org-heading-search-string
2355 (match-string 2))))
2356 (match-string 2)))
2357 tsp (when timestamp
2358 (setq props (org-entry-properties (point)))
2359 (or (cdr (assoc "SCHEDULED" props))
2360 (cdr (assoc "DEADLINE" props))
2361 (cdr (assoc "TIMESTAMP" props))
2362 (cdr (assoc "TIMESTAMP_IA" props)))))
2363 (when (> time 0) (push (list level hdl tsp time) tbl))))))
2364 (setq tbl (nreverse tbl))
2365 (list file org-clock-file-total-minutes tbl))))
2034 2366
2035(defun org-clock-time% (total &rest strings) 2367(defun org-clock-time% (total &rest strings)
2036 "Compute a time fraction in percent. 2368 "Compute a time fraction in percent.
@@ -2051,7 +2383,8 @@ This function is made for clock tables."
2051 (if (string-match "\\([0-9]+\\):\\([0-9]+\\)" s) 2383 (if (string-match "\\([0-9]+\\):\\([0-9]+\\)" s)
2052 (throw 'exit 2384 (throw 'exit
2053 (/ (* 100.0 (+ (string-to-number (match-string 2 s)) 2385 (/ (* 100.0 (+ (string-to-number (match-string 2 s))
2054 (* 60 (string-to-number (match-string 1 s))))) 2386 (* 60 (string-to-number
2387 (match-string 1 s)))))
2055 tot)))) 2388 tot))))
2056 0)))) 2389 0))))
2057 2390
@@ -2081,7 +2414,8 @@ The details of what will be saved are regulated by the variable
2081 (buffer-file-name b) 2414 (buffer-file-name b)
2082 (or (not org-clock-persist-query-save) 2415 (or (not org-clock-persist-query-save)
2083 (y-or-n-p (concat "Save current clock (" 2416 (y-or-n-p (concat "Save current clock ("
2084 (substring-no-properties org-clock-heading) 2417 (substring-no-properties
2418 org-clock-heading)
2085 ") ")))) 2419 ") "))))
2086 (insert "(setq resume-clock '(\"" 2420 (insert "(setq resume-clock '(\""
2087 (buffer-file-name (org-clocking-buffer)) 2421 (buffer-file-name (org-clocking-buffer))
@@ -2162,3 +2496,4 @@ The details of what will be saved are regulated by the variable
2162;; arch-tag: 7b42c5d4-9b36-48be-97c0-66a869daed4c 2496;; arch-tag: 7b42c5d4-9b36-48be-97c0-66a869daed4c
2163 2497
2164;;; org-clock.el ends here 2498;;; org-clock.el ends here
2499
diff --git a/lisp/org/org-colview.el b/lisp/org/org-colview.el
index 15dc7b37a62..c4f18c7c640 100644
--- a/lisp/org/org-colview.el
+++ b/lisp/org/org-colview.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: 7.3 9;; Version: 7.4
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-compat.el b/lisp/org/org-compat.el
index 324464803f2..452a261fd1b 100644
--- a/lisp/org/org-compat.el
+++ b/lisp/org/org-compat.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: 7.3 9;; Version: 7.4
10;; 10;;
11;; This file is part of GNU Emacs. 11;; This file is part of GNU Emacs.
12;; 12;;
@@ -372,15 +372,15 @@ TIME defaults to the current time."
372 (time-to-seconds (or time (current-time))) 372 (time-to-seconds (or time (current-time)))
373 (float-time time))) 373 (float-time time)))
374 374
375(defun org-string-match-p (&rest args) 375(if (fboundp 'string-match-p)
376 (if (fboundp 'string-match-p) 376 (defalias 'org-string-match-p 'string-match-p)
377 (apply 'string-match-p args) 377 (defun org-string-match-p (regexp string &optional start)
378 (save-match-data 378 (save-match-data
379 (apply 'string-match args)))) 379 (funcall 'string-match regexp string start))))
380 380
381(defun org-looking-at-p (&rest args) 381(if (fboundp 'looking-at-p)
382 (if (fboundp 'looking-at-p) 382 (defalias 'org-looking-at-p 'looking-at-p)
383 (apply 'looking-at-p args) 383 (defun org-looking-at-p (&rest args)
384 (save-match-data 384 (save-match-data
385 (apply 'looking-at args)))) 385 (apply 'looking-at args))))
386 386
@@ -418,6 +418,12 @@ LIMIT."
418 (looking-at (concat "\\(?:" regexp "\\)\\'"))))) 418 (looking-at (concat "\\(?:" regexp "\\)\\'")))))
419 (not (null pos))))) 419 (not (null pos)))))
420 420
421(defun org-floor* (x &optional y)
422 "Return a list of the floor of X and the fractional part of X.
423With two arguments, return floor and remainder of their quotient."
424 (let ((q (floor x y)))
425 (list q (- x (if y (* y q) q)))))
426
421(provide 'org-compat) 427(provide 'org-compat)
422 428
423;; arch-tag: a0a0579f-e68c-4bdf-9e55-93768b846bbe 429;; arch-tag: a0a0579f-e68c-4bdf-9e55-93768b846bbe
diff --git a/lisp/org/org-complete.el b/lisp/org/org-complete.el
new file mode 100644
index 00000000000..2eb1f4c3ff5
--- /dev/null
+++ b/lisp/org/org-complete.el
@@ -0,0 +1,279 @@
1;;; org-complete.el --- In-buffer completion code
2
3;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
4;; Free Software Foundation, Inc.
5;;
6;; Author: Carsten Dominik <carsten at orgmode dot org>
7;; John Wiegley <johnw at gnu dot org>
8;; Keywords: outlines, hypermedia, calendar, wp
9;; Homepage: http://orgmode.org
10;; Version: 7.4
11;;
12;; This file is part of GNU Emacs.
13;;
14;; GNU Emacs is free software: you can redistribute it and/or modify
15;; it under the terms of the GNU General Public License as published by
16;; the Free Software Foundation, either version 3 of the License, or
17;; (at your option) any later version.
18
19;; GNU Emacs is distributed in the hope that it will be useful,
20;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22;; GNU General Public License for more details.
23
24;; You should have received a copy of the GNU General Public License
25;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
26;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
27;;
28;;; Code:
29
30;;;; Require other packages
31
32(eval-when-compile
33 (require 'cl))
34
35(require 'org-macs)
36(require 'pcomplete)
37
38(declare-function org-split-string "org" (string &optional separators))
39(declare-function org-get-current-options "org-exp" ())
40(declare-function org-make-org-heading-search-string "org"
41 (&optional string heading))
42(declare-function org-get-buffer-tags "org" ())
43(declare-function org-get-tags "org" ())
44(declare-function org-buffer-property-keys "org"
45 (&optional include-specials include-defaults include-columns))
46(declare-function org-entry-properties "org" (&optional pom which specific))
47
48;;;; Customization variables
49
50(defgroup org-complete nil
51 "Outline-based notes management and organizer."
52 :tag "Org"
53 :group 'org)
54
55(defun org-thing-at-point ()
56 "Examine the thing at point and let the caller know what it is.
57The return value is a string naming the thing at point."
58 (let ((beg1 (save-excursion
59 (skip-chars-backward (org-re "[:alnum:]_@"))
60 (point)))
61 (beg (save-excursion
62 (skip-chars-backward "a-zA-Z0-9_:$")
63 (point)))
64 (line-to-here (buffer-substring (point-at-bol) (point))))
65 (cond
66 ((string-match "\\`[ \t]*#\\+begin: clocktable[ \t]+" line-to-here)
67 (cons "block-option" "clocktable"))
68 ((string-match "\\`[ \t]*#\\+begin_src[ \t]+" line-to-here)
69 (cons "block-option" "src"))
70 ((save-excursion
71 (re-search-backward "^[ \t]*#\\+\\([A-Z_]+\\):.*"
72 (line-beginning-position) t))
73 (cons "file-option" (match-string-no-properties 1)))
74 ((string-match "\\`[ \t]*#\\+[a-zA-Z]*\\'" line-to-here)
75 (cons "file-option" nil))
76 ((equal (char-before beg) ?\[)
77 (cons "link" nil))
78 ((equal (char-before beg) ?\\)
79 (cons "tex" nil))
80 ((string-match "\\`\\*+[ \t]+\\'"
81 (buffer-substring (point-at-bol) beg))
82 (cons "todo" nil))
83 ((equal (char-before beg) ?*)
84 (cons "searchhead" nil))
85 ((and (equal (char-before beg1) ?:)
86 (equal (char-after (point-at-bol)) ?*))
87 (cons "tag" nil))
88 ((and (equal (char-before beg1) ?:)
89 (not (equal (char-after (point-at-bol)) ?*)))
90 (cons "prop" nil))
91 (t nil))))
92
93(defun org-command-at-point ()
94 "Return the qualified name of the Org completion entity at point.
95When completing for #+STARTUP, for example, this function returns
96\"file-option/startup\"."
97 (let ((thing (org-thing-at-point)))
98 (cond
99 ((string= "file-option" (car thing))
100 (concat (car thing) "/" (downcase (cdr thing))))
101 ((string= "block-option" (car thing))
102 (concat (car thing) "/" (downcase (cdr thing))))
103 (t
104 (car thing)))))
105
106(defun org-parse-arguments ()
107 "Parse whitespace separated arguments in the current region."
108 (let ((begin (line-beginning-position))
109 (end (line-end-position))
110 begins args)
111 (save-restriction
112 (narrow-to-region begin end)
113 (save-excursion
114 (goto-char (point-min))
115 (while (not (eobp))
116 (skip-chars-forward " \t\n[")
117 (setq begins (cons (point) begins))
118 (skip-chars-forward "^ \t\n[")
119 (setq args (cons (buffer-substring-no-properties
120 (car begins) (point))
121 args)))
122 (cons (reverse args) (reverse begins))))))
123
124
125(defun org-complete-initial ()
126 "Calls the right completion function for first argument completions."
127 (ignore
128 (funcall (or (pcomplete-find-completion-function
129 (car (org-thing-at-point)))
130 pcomplete-default-completion-function))))
131
132(defvar org-additional-option-like-keywords)
133(defun pcomplete/org-mode/file-option ()
134 "Complete against all valid file options."
135 (require 'org-exp)
136 (pcomplete-here
137 (org-complete-case-double
138 (mapcar (lambda (x)
139 (if (= ?: (aref x (1- (length x))))
140 (concat x " ")
141 x))
142 (delq nil
143 (pcomplete-uniqify-list
144 (append
145 (mapcar (lambda (x)
146 (if (string-match "^#\\+\\([A-Z_]+:?\\)" x)
147 (match-string 1 x)))
148 (org-split-string (org-get-current-options) "\n"))
149 org-additional-option-like-keywords)))))
150 (substring pcomplete-stub 2)))
151
152(defvar org-startup-options)
153(defun pcomplete/org-mode/file-option/startup ()
154 "Complete arguments for the #+STARTUP file option."
155 (while (pcomplete-here
156 (let ((opts (pcomplete-uniqify-list
157 (mapcar 'car org-startup-options))))
158 ;; Some options are mutually exclusive, and shouldn't be completed
159 ;; against if certain other options have already been seen.
160 (dolist (arg pcomplete-args)
161 (cond
162 ((string= arg "hidestars")
163 (setq opts (delete "showstars" opts)))))
164 opts))))
165
166(defun pcomplete/org-mode/file-option/bind ()
167 "Complete arguments for the #+BIND file option, which are variable names"
168 (let (vars)
169 (mapatoms
170 (lambda (a) (if (boundp a) (setq vars (cons (symbol-name a) vars)))))
171 (pcomplete-here vars)))
172
173(defvar org-link-abbrev-alist-local)
174(defvar org-link-abbrev-alist)
175(defun pcomplete/org-mode/link ()
176 "Complete against defined #+LINK patterns."
177 (pcomplete-here
178 (pcomplete-uniqify-list (append (mapcar 'car org-link-abbrev-alist-local)
179 (mapcar 'car org-link-abbrev-alist)))))
180
181(defvar org-entities)
182(defun pcomplete/org-mode/tex ()
183 "Complete against TeX-style HTML entity names."
184 (require 'org-entities)
185 (while (pcomplete-here
186 (pcomplete-uniqify-list (remove nil (mapcar 'car-safe org-entities)))
187 (substring pcomplete-stub 1))))
188
189(defvar org-todo-keywords-1)
190(defun pcomplete/org-mode/todo ()
191 "Complete against known TODO keywords."
192 (pcomplete-here (pcomplete-uniqify-list org-todo-keywords-1)))
193
194(defvar org-todo-line-regexp)
195(defun pcomplete/org-mode/searchhead ()
196 "Complete against all headings.
197This needs more work, to handle headings with lots of spaces in them."
198 (while
199 (pcomplete-here
200 (save-excursion
201 (goto-char (point-min))
202 (let (tbl)
203 (while (re-search-forward org-todo-line-regexp nil t)
204 (push (org-make-org-heading-search-string
205 (match-string-no-properties 3) t)
206 tbl))
207 (pcomplete-uniqify-list tbl)))
208 (substring pcomplete-stub 1))))
209
210(defvar org-tag-alist)
211(defun pcomplete/org-mode/tag ()
212 "Complete a tag name. Omit tags already set."
213 (while (pcomplete-here
214 (mapcar (lambda (x)
215 (concat x ":"))
216 (let ((lst (pcomplete-uniqify-list
217 (or (remove
218 nil
219 (mapcar (lambda (x)
220 (and (stringp (car x)) (car x)))
221 org-tag-alist))
222 (mapcar 'car (org-get-buffer-tags))))))
223 (dolist (tag (org-get-tags))
224 (setq lst (delete tag lst)))
225 lst))
226 (and (string-match ".*:" pcomplete-stub)
227 (substring pcomplete-stub (match-end 0))))))
228
229(defun pcomplete/org-mode/prop ()
230 "Complete a property name. Omit properties already set."
231 (pcomplete-here
232 (mapcar (lambda (x)
233 (concat x ": "))
234 (let ((lst (pcomplete-uniqify-list
235 (org-buffer-property-keys nil t t))))
236 (dolist (prop (org-entry-properties))
237 (setq lst (delete (car prop) lst)))
238 lst))
239 (substring pcomplete-stub 1)))
240
241(defun pcomplete/org-mode/block-option/src ()
242 "Complete the arguments of a begin_src block.
243Complete a language in the first field, the header arguments and switches."
244 (pcomplete-here
245 (mapcar
246 (lambda(x) (symbol-name (nth 3 x)))
247 (cdr (car (cdr (memq :key-type (plist-get
248 (symbol-plist
249 'org-babel-load-languages)
250 'custom-type)))))))
251 (while (pcomplete-here
252 '("-n" "-r" "-l"
253 ":cache" ":colnames" ":comments" ":dir" ":eval" ":exports"
254 ":file" ":hlines" ":no-expand" ":noweb" ":results" ":rownames"
255 ":session" ":shebang" ":tangle" ":var"))))
256
257(defun pcomplete/org-mode/block-option/clocktable ()
258 "Complete keywords in a clocktable line"
259 (while (pcomplete-here '(":maxlevel" ":scope"
260 ":tstart" ":tend" ":block" ":step"
261 ":stepskip0" ":fileskip0"
262 ":emphasize" ":link" ":narrow" ":indent"
263 ":tcolumns" ":level" ":compact" ":timestamp"
264 ":formula" ":formatter"))))
265
266(defun org-complete-case-double (list)
267 "Return list with both upcase and downcase version of all strings in LIST."
268 (let (e res)
269 (while (setq e (pop list))
270 (setq res (cons (downcase e) (cons (upcase e) res))))
271 (nreverse res)))
272
273;;;; Finish up
274
275(provide 'org-complete)
276
277;; arch-tag:
278
279;;; org-complete.el ends here
diff --git a/lisp/org/org-crypt.el b/lisp/org/org-crypt.el
index 693f3ac6a87..1d761049bbb 100644
--- a/lisp/org/org-crypt.el
+++ b/lisp/org/org-crypt.el
@@ -4,7 +4,7 @@
4 4
5;; Emacs Lisp Archive Entry 5;; Emacs Lisp Archive Entry
6;; Filename: org-crypt.el 6;; Filename: org-crypt.el
7;; Version: 7.3 7;; Version: 7.4
8;; Keywords: org-mode 8;; Keywords: org-mode
9;; Author: John Wiegley <johnw@gnu.org> 9;; Author: John Wiegley <johnw@gnu.org>
10;; Maintainer: Peter Jones <pjones@pmade.com> 10;; Maintainer: Peter Jones <pjones@pmade.com>
diff --git a/lisp/org/org-ctags.el b/lisp/org/org-ctags.el
index 71e1b1b6a7e..f2c631afe24 100644
--- a/lisp/org/org-ctags.el
+++ b/lisp/org/org-ctags.el
@@ -3,10 +3,10 @@
3;; Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 3;; Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
4 4
5;; Author: Paul Sexton <eeeickythump@gmail.com> 5;; Author: Paul Sexton <eeeickythump@gmail.com>
6;; Version: 7.3 6;; Version: 7.4
7 7
8;; Keywords: org, wp 8;; Keywords: org, wp
9;; Version: 7.3 9;; Version: 7.4
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-datetree.el b/lisp/org/org-datetree.el
index 286cdc9a1ae..8014f8f1f93 100644
--- a/lisp/org/org-datetree.el
+++ b/lisp/org/org-datetree.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: 7.3 8;; Version: 7.4
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-docbook.el b/lisp/org/org-docbook.el
index 7d90ec32fbe..91ebb971967 100644
--- a/lisp/org/org-docbook.el
+++ b/lisp/org/org-docbook.el
@@ -4,7 +4,7 @@
4;; 4;;
5;; Emacs Lisp Archive Entry 5;; Emacs Lisp Archive Entry
6;; Filename: org-docbook.el 6;; Filename: org-docbook.el
7;; Version: 7.3 7;; Version: 7.4
8;; Author: Baoqiu Cui <cbaoqiu AT yahoo DOT com> 8;; Author: Baoqiu Cui <cbaoqiu AT yahoo DOT com>
9;; Maintainer: Baoqiu Cui <cbaoqiu AT yahoo DOT com> 9;; Maintainer: Baoqiu Cui <cbaoqiu AT yahoo DOT com>
10;; Keywords: org, wp, docbook 10;; Keywords: org, wp, docbook
diff --git a/lisp/org/org-docview.el b/lisp/org/org-docview.el
index 0c77b690765..cb0f24139a2 100644
--- a/lisp/org/org-docview.el
+++ b/lisp/org/org-docview.el
@@ -5,7 +5,7 @@
5;; Author: Jan Böcker <jan.boecker at jboecker dot de> 5;; Author: Jan Böcker <jan.boecker at jboecker 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: 7.3 8;; Version: 7.4
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-entities.el b/lisp/org/org-entities.el
index 5ce5fd7531c..1c99b9eb5a5 100644
--- a/lisp/org/org-entities.el
+++ b/lisp/org/org-entities.el
@@ -6,7 +6,7 @@
6;; Ulf Stegemann <ulf at zeitform dot de> 6;; Ulf Stegemann <ulf at zeitform dot de>
7;; Keywords: outlines, calendar, wp 7;; Keywords: outlines, calendar, wp
8;; Homepage: http://orgmode.org 8;; Homepage: http://orgmode.org
9;; Version: 7.3 9;; Version: 7.4
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-exp-blocks.el b/lisp/org/org-exp-blocks.el
index 3751e68e057..57087e1dfc7 100644
--- a/lisp/org/org-exp-blocks.el
+++ b/lisp/org/org-exp-blocks.el
@@ -4,7 +4,7 @@
4;; Free Software Foundation, Inc. 4;; Free Software Foundation, Inc.
5 5
6;; Author: Eric Schulte 6;; Author: Eric Schulte
7;; Version: 7.3 7;; Version: 7.4
8 8
9;; This file is part of GNU Emacs. 9;; This file is part of GNU Emacs.
10;; 10;;
@@ -201,9 +201,6 @@ which defaults to the value of `org-export-blocks-witheld'."
201 (interblock start (point-max)) 201 (interblock start (point-max))
202 (run-hooks 'org-export-blocks-postblock-hook))))) 202 (run-hooks 'org-export-blocks-postblock-hook)))))
203 203
204(add-hook 'org-export-preprocess-after-include-files-hook
205 'org-export-blocks-preprocess)
206
207;;================================================================================ 204;;================================================================================
208;; type specific functions 205;; type specific functions
209 206
diff --git a/lisp/org/org-exp.el b/lisp/org/org-exp.el
index 73e0951334d..d45ef9cdd74 100644
--- a/lisp/org/org-exp.el
+++ b/lisp/org/org-exp.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: 7.3 9;; Version: 7.4
10;; 10;;
11;; This file is part of GNU Emacs. 11;; This file is part of GNU Emacs.
12;; 12;;
@@ -984,7 +984,7 @@ value of `org-export-run-in-background'."
984 (set-process-sentinel p 'org-export-process-sentinel) 984 (set-process-sentinel p 'org-export-process-sentinel)
985 (message "Background process \"%s\": started" p)) 985 (message "Background process \"%s\": started" p))
986 ;; background processing not requested, or not possible 986 ;; background processing not requested, or not possible
987 (if subtree-p (progn (outline-mark-subtree) (activate-mark))) 987 (if subtree-p (progn (org-mark-subtree) (activate-mark)))
988 (call-interactively (nth 1 ass)) 988 (call-interactively (nth 1 ass))
989 (when (and bpos (get-buffer-window cbuf)) 989 (when (and bpos (get-buffer-window cbuf))
990 (let ((cw (selected-window))) 990 (let ((cw (selected-window)))
@@ -1080,12 +1080,18 @@ on this string to produce the exported version."
1080 ;; Mark end of lists 1080 ;; Mark end of lists
1081 (org-export-mark-list-ending backend) 1081 (org-export-mark-list-ending backend)
1082 1082
1083 ;; Export code blocks
1084 (org-export-blocks-preprocess)
1085
1083 ;; Handle source code snippets 1086 ;; Handle source code snippets
1084 (org-export-replace-src-segments-and-examples backend) 1087 (org-export-replace-src-segments-and-examples backend)
1085 1088
1086 ;; Protect short examples marked by a leading colon 1089 ;; Protect short examples marked by a leading colon
1087 (org-export-protect-colon-examples) 1090 (org-export-protect-colon-examples)
1088 1091
1092 ;; Protected spaces
1093 (org-export-convert-protected-spaces backend)
1094
1089 ;; Normalize footnotes 1095 ;; Normalize footnotes
1090 (when (plist-get parameters :footnotes) 1096 (when (plist-get parameters :footnotes)
1091 (org-footnote-normalize nil t)) 1097 (org-footnote-normalize nil t))
@@ -1536,6 +1542,26 @@ from the buffer."
1536 (add-text-properties (point) (org-end-of-subtree t) 1542 (add-text-properties (point) (org-end-of-subtree t)
1537 '(org-protected t))))) 1543 '(org-protected t)))))
1538 1544
1545(defun org-export-convert-protected-spaces (backend)
1546 "Convert strings like \\____ to protected spaces in all backends."
1547 (goto-char (point-min))
1548 (while (re-search-forward "\\\\__+" nil t)
1549 (org-if-unprotected-1
1550 (replace-match
1551 (org-add-props
1552 (cond
1553 ((eq backend 'latex)
1554 (format "\\hspace{%dex}" (- (match-end 0) (match-beginning 0))))
1555 ((eq backend 'html)
1556 (org-add-props (match-string 0) nil
1557 'org-whitespace (- (match-end 0) (match-beginning 0))))
1558 ;; ((eq backend 'docbook))
1559 ((eq backend 'ascii)
1560 (org-add-props (match-string 0) '(org-whitespace t)))
1561 (t (make-string (- (match-end 0) (match-beginning 0)) ?\ )))
1562 '(org-protected t))
1563 t t))))
1564
1539(defun org-export-protect-verbatim () 1565(defun org-export-protect-verbatim ()
1540 "Mark verbatim snippets with the protection property." 1566 "Mark verbatim snippets with the protection property."
1541 (goto-char (point-min)) 1567 (goto-char (point-min))
@@ -2100,12 +2126,13 @@ TYPE must be a string, any of:
2100(defun org-export-handle-include-files () 2126(defun org-export-handle-include-files ()
2101 "Include the contents of include files, with proper formatting." 2127 "Include the contents of include files, with proper formatting."
2102 (let ((case-fold-search t) 2128 (let ((case-fold-search t)
2103 params file markup lang start end prefix prefix1 switches all) 2129 params file markup lang start end prefix prefix1 switches all minlevel)
2104 (goto-char (point-min)) 2130 (goto-char (point-min))
2105 (while (re-search-forward "^#\\+INCLUDE:?[ \t]+\\(.*\\)" nil t) 2131 (while (re-search-forward "^#\\+INCLUDE:?[ \t]+\\(.*\\)" nil t)
2106 (setq params (read (concat "(" (match-string 1) ")")) 2132 (setq params (read (concat "(" (match-string 1) ")"))
2107 prefix (org-get-and-remove-property 'params :prefix) 2133 prefix (org-get-and-remove-property 'params :prefix)
2108 prefix1 (org-get-and-remove-property 'params :prefix1) 2134 prefix1 (org-get-and-remove-property 'params :prefix1)
2135 minlevel (org-get-and-remove-property 'params :minlevel)
2109 file (org-symname-or-string (pop params)) 2136 file (org-symname-or-string (pop params))
2110 markup (org-symname-or-string (pop params)) 2137 markup (org-symname-or-string (pop params))
2111 lang (and (member markup '("src" "SRC")) 2138 lang (and (member markup '("src" "SRC"))
@@ -2128,7 +2155,7 @@ TYPE must be a string, any of:
2128 end (format "#+end_%s" markup)))) 2155 end (format "#+end_%s" markup))))
2129 (insert (or start "")) 2156 (insert (or start ""))
2130 (insert (org-get-file-contents (expand-file-name file) 2157 (insert (org-get-file-contents (expand-file-name file)
2131 prefix prefix1 markup)) 2158 prefix prefix1 markup minlevel))
2132 (or (bolp) (newline)) 2159 (or (bolp) (newline))
2133 (insert (or end "")))) 2160 (insert (or end ""))))
2134 all)) 2161 all))
@@ -2145,7 +2172,7 @@ TYPE must be a string, any of:
2145 (when intersection 2172 (when intersection
2146 (error "Recursive #+INCLUDE: %S" intersection)))))) 2173 (error "Recursive #+INCLUDE: %S" intersection))))))
2147 2174
2148(defun org-get-file-contents (file &optional prefix prefix1 markup) 2175(defun org-get-file-contents (file &optional prefix prefix1 markup minlevel)
2149 "Get the contents of FILE and return them as a string. 2176 "Get the contents of FILE and return them as a string.
2150If PREFIX is a string, prepend it to each line. If PREFIX1 2177If PREFIX is a string, prepend it to each line. If PREFIX1
2151is a string, prepend it to the first line instead of PREFIX. 2178is a string, prepend it to the first line instead of PREFIX.
@@ -2167,6 +2194,9 @@ take care of the block they are in."
2167 (goto-char (match-beginning 0)) 2194 (goto-char (match-beginning 0))
2168 (insert ",") 2195 (insert ",")
2169 (end-of-line 1))) 2196 (end-of-line 1)))
2197 (when minlevel
2198 (dotimes (lvl minlevel)
2199 (org-map-region 'org-demote (point-min) (point-max))))
2170 (buffer-string))) 2200 (buffer-string)))
2171 2201
2172(defun org-get-and-remove-property (listvar prop) 2202(defun org-get-and-remove-property (listvar prop)
@@ -2235,8 +2265,6 @@ in the list) and remove property and value from the list in LISTVAR."
2235(defvar org-export-latex-listings-langs) ;; defined in org-latex.el 2265(defvar org-export-latex-listings-langs) ;; defined in org-latex.el
2236(defvar org-export-latex-listings-w-names) ;; defined in org-latex.el 2266(defvar org-export-latex-listings-w-names) ;; defined in org-latex.el
2237(defvar org-export-latex-minted-langs) ;; defined in org-latex.el 2267(defvar org-export-latex-minted-langs) ;; defined in org-latex.el
2238(defvar org-export-latex-minted-with-line-numbers) ;; defined in org-latex.el
2239
2240(defun org-export-format-source-code-or-example 2268(defun org-export-format-source-code-or-example
2241 (backend lang code &optional opts indent caption) 2269 (backend lang code &optional opts indent caption)
2242 "Format CODE from language LANG and return it formatted for export. 2270 "Format CODE from language LANG and return it formatted for export.
@@ -2403,8 +2431,7 @@ INDENT was the original indentation of the block."
2403 (format "\n%s $\\equiv$ \n" 2431 (format "\n%s $\\equiv$ \n"
2404 (replace-regexp-in-string 2432 (replace-regexp-in-string
2405 "_" "\\\\_" caption))) 2433 "_" "\\\\_" caption)))
2406 (format 2434 (format "\\begin{minted}{%s}\n" minted-lang)
2407 "\\begin{minted}[mathescape,%s\nnumbersep=5pt,\nframe=lines,\nframesep=2mm]{%s}\n" (if org-export-latex-minted-with-line-numbers "\nlinenos," "") minted-lang)
2408 rtn "\\end{minted}\n")))) 2435 rtn "\\end{minted}\n"))))
2409 (t (concat (car org-export-latex-verbatim-wrap) 2436 (t (concat (car org-export-latex-verbatim-wrap)
2410 rtn (cdr org-export-latex-verbatim-wrap)))) 2437 rtn (cdr org-export-latex-verbatim-wrap))))
@@ -2585,9 +2612,10 @@ command."
2585 ;; does do the trick. 2612 ;; does do the trick.
2586 (if (looking-at "#[^\r\n]*") 2613 (if (looking-at "#[^\r\n]*")
2587 (append-to-buffer buffer (match-beginning 0) (1+ (match-end 0)))) 2614 (append-to-buffer buffer (match-beginning 0) (1+ (match-end 0))))
2588 (while (re-search-forward "[\n\r]#[^\n\r]*" nil t) 2615 (when (re-search-forward "^\\*+[ \t]+" nil t)
2589 (append-to-buffer buffer (1+ (match-beginning 0)) 2616 (while (re-search-backward "[\n\r]#[^\n\r]*" nil t)
2590 (min (point-max) (1+ (match-end 0)))))) 2617 (append-to-buffer buffer (1+ (match-beginning 0))
2618 (min (point-max) (1+ (match-end 0)))))))
2591 (set-buffer buffer) 2619 (set-buffer buffer)
2592 (let ((buffer-file-name file) 2620 (let ((buffer-file-name file)
2593 (org-inhibit-startup t)) 2621 (org-inhibit-startup t))
diff --git a/lisp/org/org-faces.el b/lisp/org/org-faces.el
index e4e17f15c5d..3f8245758f7 100644
--- a/lisp/org/org-faces.el
+++ b/lisp/org/org-faces.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: 7.3 9;; Version: 7.4
10;; 10;;
11;; This file is part of GNU Emacs. 11;; This file is part of GNU Emacs.
12;; 12;;
@@ -685,6 +685,15 @@ If it is less than 8, the level-1 face gets re-used for level N+1 etc."
685 :type 'integer 685 :type 'integer
686 :group 'org-faces) 686 :group 'org-faces)
687 687
688(defcustom org-cycle-level-faces t
689 "Non-nil means level styles cycle after level `org-n-level-faces'.
690Then so level org-n-level-faces+1 is styled like level 1.
691If nil, then all levels >=org-n-level-faces are styled like
692level org-n-level-faces"
693 :group 'org-appearance
694 :group 'org-faces
695 :type 'boolean)
696
688(defface org-latex-and-export-specials 697(defface org-latex-and-export-specials
689 (let ((font (cond ((assq :inherit custom-face-attributes) 698 (let ((font (cond ((assq :inherit custom-face-attributes)
690 '(:inherit underline)) 699 '(:inherit underline))
diff --git a/lisp/org/org-feed.el b/lisp/org/org-feed.el
index 8bda3098e0a..32da49b1cb8 100644
--- a/lisp/org/org-feed.el
+++ b/lisp/org/org-feed.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: 7.3 8;; Version: 7.4
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-footnote.el b/lisp/org/org-footnote.el
index 2a97b54db6f..88ffd6e4842 100644
--- a/lisp/org/org-footnote.el
+++ b/lisp/org/org-footnote.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: 7.3 8;; Version: 7.4
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
@@ -303,7 +303,7 @@ or new, let the user edit the definition of the footnote."
303 (t 303 (t
304 (setq re (concat "^" org-footnote-tag-for-non-org-mode-files "[ \t]*$")) 304 (setq re (concat "^" org-footnote-tag-for-non-org-mode-files "[ \t]*$"))
305 (unless (re-search-forward re nil t) 305 (unless (re-search-forward re nil t)
306 (let ((max (if (and (eq major-mode 'message-mode) 306 (let ((max (if (and (derived-mode-p 'message-mode)
307 (re-search-forward message-signature-separator nil t)) 307 (re-search-forward message-signature-separator nil t))
308 (progn (beginning-of-line) (point)) 308 (progn (beginning-of-line) (point))
309 (goto-char (point-max))))) 309 (goto-char (point-max)))))
diff --git a/lisp/org/org-freemind.el b/lisp/org/org-freemind.el
index 736cc577ce7..d9486afa0b5 100644
--- a/lisp/org/org-freemind.el
+++ b/lisp/org/org-freemind.el
@@ -5,7 +5,7 @@
5;; Author: Lennart Borgman (lennart O borgman A gmail O com) 5;; Author: Lennart Borgman (lennart O borgman A gmail O 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: 7.3 8;; Version: 7.4
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-gnus.el b/lisp/org/org-gnus.el
index 6d782759a75..fccd3e9ee01 100644
--- a/lisp/org/org-gnus.el
+++ b/lisp/org/org-gnus.el
@@ -7,7 +7,7 @@
7;; Tassilo Horn <tassilo at member dot fsf dot org> 7;; Tassilo Horn <tassilo at member dot fsf dot org>
8;; Keywords: outlines, hypermedia, calendar, wp 8;; Keywords: outlines, hypermedia, calendar, wp
9;; Homepage: http://orgmode.org 9;; Homepage: http://orgmode.org
10;; Version: 7.3 10;; Version: 7.4
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-habit.el b/lisp/org/org-habit.el
index 394b4fb05db..b174a1f0879 100644
--- a/lisp/org/org-habit.el
+++ b/lisp/org/org-habit.el
@@ -5,7 +5,7 @@
5;; Author: John Wiegley <johnw at gnu dot org> 5;; Author: John Wiegley <johnw at gnu 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: 7.3 8;; Version: 7.4
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
@@ -197,10 +197,7 @@ This list represents a \"habit\" for the rest of this module."
197 "Determine the relative priority of a habit. 197 "Determine the relative priority of a habit.
198This must take into account not just urgency, but consistency as well." 198This must take into account not just urgency, but consistency as well."
199 (let ((pri 1000) 199 (let ((pri 1000)
200 (now (time-to-days 200 (now (if moment (time-to-days moment) (org-today)))
201 (or moment
202 (time-subtract (current-time)
203 (list 0 (* 3600 org-extend-today-until) 0)))))
204 (scheduled (org-habit-scheduled habit)) 201 (scheduled (org-habit-scheduled habit))
205 (deadline (org-habit-deadline habit))) 202 (deadline (org-habit-deadline habit)))
206 ;; add 10 for every day past the scheduled date, and subtract for every 203 ;; add 10 for every day past the scheduled date, and subtract for every
diff --git a/lisp/org/org-html.el b/lisp/org/org-html.el
index 68fee5b8df5..47e82319873 100644
--- a/lisp/org/org-html.el
+++ b/lisp/org/org-html.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: 7.3 9;; Version: 7.4
10;; 10;;
11;; This file is part of GNU Emacs. 11;; This file is part of GNU Emacs.
12;; 12;;
@@ -1213,7 +1213,11 @@ lang=\"%s\" xml:lang=\"%s\">
1213 (throw 'nextline nil)) 1213 (throw 'nextline nil))
1214 1214
1215 ;; Protected HTML 1215 ;; Protected HTML
1216 (when (get-text-property 0 'org-protected line) 1216 (when (and (get-text-property 0 'org-protected line)
1217 ;; Make sure it is the entire line that is protected
1218 (not (< (or (next-single-property-change
1219 0 'org-protected line) 10000)
1220 (length line))))
1217 (let (par (ind (get-text-property 0 'original-indentation line))) 1221 (let (par (ind (get-text-property 0 'original-indentation line)))
1218 (when (re-search-backward 1222 (when (re-search-backward
1219 "\\(<p>\\)\\([ \t\r\n]*\\)\\=" (- (point) 100) t) 1223 "\\(<p>\\)\\([ \t\r\n]*\\)\\=" (- (point) 100) t)
@@ -2316,10 +2320,9 @@ When TITLE is nil, just close all open levels."
2316 (extra-class (and title (org-get-text-property-any 0 'html-container-class title))) 2320 (extra-class (and title (org-get-text-property-any 0 'html-container-class title)))
2317 (preferred (and target 2321 (preferred (and target
2318 (cdr (assoc target org-export-preferred-target-alist)))) 2322 (cdr (assoc target org-export-preferred-target-alist))))
2319 (remove (or preferred target))
2320 (l org-level-max) 2323 (l org-level-max)
2321 snumber snu href suffix) 2324 snumber snu href suffix)
2322 (setq extra-targets (remove remove extra-targets)) 2325 (setq extra-targets (remove (or preferred target) extra-targets))
2323 (setq extra-targets 2326 (setq extra-targets
2324 (mapconcat (lambda (x) 2327 (mapconcat (lambda (x)
2325 (if (org-uuidgen-p x) (setq x (concat "ID-" x))) 2328 (if (org-uuidgen-p x) (setq x (concat "ID-" x)))
@@ -2358,12 +2361,13 @@ When TITLE is nil, just close all open levels."
2358 (progn 2361 (progn
2359 (org-close-li) 2362 (org-close-li)
2360 (if target 2363 (if target
2361 (insert (format "<li id=\"%s\">" target) extra-targets title "<br/>\n") 2364 (insert (format "<li id=\"%s\">" (or preferred target))
2365 extra-targets title "<br/>\n")
2362 (insert "<li>" title "<br/>\n"))) 2366 (insert "<li>" title "<br/>\n")))
2363 (aset org-levels-open (1- level) t) 2367 (aset org-levels-open (1- level) t)
2364 (org-close-par-maybe) 2368 (org-close-par-maybe)
2365 (if target 2369 (if target
2366 (insert (format "<ul>\n<li id=\"%s\">" target) 2370 (insert (format "<ul>\n<li id=\"%s\">" (or preferred target))
2367 extra-targets title "<br/>\n") 2371 extra-targets title "<br/>\n")
2368 (insert "<ul>\n<li>" title "<br/>\n")))) 2372 (insert "<ul>\n<li>" title "<br/>\n"))))
2369 (aset org-levels-open (1- level) t) 2373 (aset org-levels-open (1- level) t)
diff --git a/lisp/org/org-icalendar.el b/lisp/org/org-icalendar.el
index fe6e97c72dd..d4034fe6d36 100644
--- a/lisp/org/org-icalendar.el
+++ b/lisp/org/org-icalendar.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: 7.3 9;; Version: 7.4
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-id.el b/lisp/org/org-id.el
index fcca58831d1..a8004afec8a 100644
--- a/lisp/org/org-id.el
+++ b/lisp/org/org-id.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: 7.3 8;; Version: 7.4
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
@@ -600,15 +600,18 @@ optional argument MARKERP, return the position as a new marker."
600(defun org-id-store-link () 600(defun org-id-store-link ()
601 "Store a link to the current entry, using its ID." 601 "Store a link to the current entry, using its ID."
602 (interactive) 602 (interactive)
603 (let* ((link (org-make-link "id:" (org-id-get-create))) 603 (when (and (buffer-file-name (buffer-base-buffer)) (org-mode-p))
604 (case-fold-search nil) 604 (let* ((link (org-make-link "id:" (org-id-get-create)))
605 (desc (save-excursion 605 (case-fold-search nil)
606 (org-back-to-heading t) 606 (desc (save-excursion
607 (or (and (looking-at org-complex-heading-regexp) 607 (org-back-to-heading t)
608 (if (match-end 4) (match-string 4) (match-string 0))) 608 (or (and (looking-at org-complex-heading-regexp)
609 link)))) 609 (if (match-end 4)
610 (org-store-link-props :link link :description desc :type "id") 610 (match-string 4)
611 link)) 611 (match-string 0)))
612 link))))
613 (org-store-link-props :link link :description desc :type "id")
614 link)))
612 615
613(defun org-id-open (id) 616(defun org-id-open (id)
614 "Go to the entry with id ID." 617 "Go to the entry with id ID."
diff --git a/lisp/org/org-indent.el b/lisp/org/org-indent.el
index 39ba445eb93..a177a6f2a04 100644
--- a/lisp/org/org-indent.el
+++ b/lisp/org/org-indent.el
@@ -4,7 +4,7 @@
4;; Author: Carsten Dominik <carsten at orgmode dot org> 4;; Author: Carsten Dominik <carsten at orgmode dot org>
5;; Keywords: outlines, hypermedia, calendar, wp 5;; Keywords: outlines, hypermedia, calendar, wp
6;; Homepage: http://orgmode.org 6;; Homepage: http://orgmode.org
7;; Version: 7.3 7;; Version: 7.4
8;; 8;;
9;; This file is part of GNU Emacs. 9;; This file is part of GNU Emacs.
10;; 10;;
@@ -38,6 +38,10 @@
38(eval-when-compile 38(eval-when-compile
39 (require 'cl)) 39 (require 'cl))
40 40
41(defvar org-inlinetask-min-level)
42(declare-function org-inlinetask-get-task-level "org-inlinetask" ())
43(declare-function org-inlinetask-in-task-p "org-inlinetask" ())
44
41(defgroup org-indent nil 45(defgroup org-indent nil
42 "Options concerning dynamic virtual outline indentation." 46 "Options concerning dynamic virtual outline indentation."
43 :tag "Org Indent" 47 :tag "Org Indent"
@@ -219,35 +223,49 @@ useful to make it ever so slightly different."
219(defun org-indent-add-properties (beg end) 223(defun org-indent-add-properties (beg end)
220 "Add indentation properties between BEG and END. 224 "Add indentation properties between BEG and END.
221Assumes that BEG is at the beginning of a line." 225Assumes that BEG is at the beginning of a line."
222 (when (or t org-indent-mode) 226 (let* ((inhibit-modification-hooks t)
223 (let ((inhibit-modification-hooks t) 227 (inlinetaskp (featurep 'org-inlinetask))
224 ov b e n level exit nstars) 228 (get-real-level (lambda (pos lvl)
225 (with-silent-modifications 229 (save-excursion
226 (save-excursion 230 (goto-char pos)
227 (goto-char beg) 231 (if (and inlinetaskp (org-inlinetask-in-task-p))
228 (while (not exit) 232 (org-inlinetask-get-task-level)
229 (setq e end) 233 lvl))))
230 (if (not (re-search-forward org-indent-outline-re nil t)) 234 (b beg)
231 (setq e (point-max) exit t) 235 (e end)
232 (setq e (match-beginning 0)) 236 (level 0)
233 (if (>= e end) (setq exit t)) 237 (n 0)
234 (setq level (- (match-end 0) (match-beginning 0) 1)) 238 exit nstars)
235 (setq nstars (- (* (1- level) org-indent-indentation-per-level) 239 (with-silent-modifications
236 (1- level))) 240 (save-excursion
237 (add-text-properties 241 (goto-char beg)
238 (point-at-bol) (point-at-eol) 242 (while (not exit)
239 (list 'line-prefix 243 (setq e end)
240 (aref org-indent-stars nstars) 244 (if (not (re-search-forward org-indent-outline-re nil t))
241 'wrap-prefix 245 (setq e (point-max) exit t)
242 (aref org-indent-strings 246 (setq e (match-beginning 0))
243 (* level org-indent-indentation-per-level))))) 247 (if (>= e end) (setq exit t))
244 (when (and b (> e b)) 248 (unless (and inlinetaskp (org-inlinetask-in-task-p))
245 (add-text-properties 249 (setq level (- (match-end 0) (match-beginning 0) 1)))
246 b e (list 'line-prefix (aref org-indent-strings n) 250 (setq nstars (* (1- (funcall get-real-level e level))
247 'wrap-prefix (aref org-indent-strings n)))) 251 (1- org-indent-indentation-per-level)))
248 (setq b (1+ (point-at-eol)) 252 (add-text-properties
249 n (* (or level 0) org-indent-indentation-per-level)))))))) 253 (point-at-bol) (point-at-eol)
254 (list 'line-prefix
255 (aref org-indent-stars nstars)
256 'wrap-prefix
257 (aref org-indent-strings
258 (* (funcall get-real-level e level)
259 org-indent-indentation-per-level)))))
260 (when (> e b)
261 (add-text-properties
262 b e (list 'line-prefix (aref org-indent-strings n)
263 'wrap-prefix (aref org-indent-strings n))))
264 (setq b (1+ (point-at-eol))
265 n (* (funcall get-real-level b level)
266 org-indent-indentation-per-level)))))))
250 267
268(defvar org-inlinetask-min-level)
251(defun org-indent-refresh-section () 269(defun org-indent-refresh-section ()
252 "Refresh indentation properties in the current outline section. 270 "Refresh indentation properties in the current outline section.
253Point is assumed to be at the beginning of a headline." 271Point is assumed to be at the beginning of a headline."
@@ -255,7 +273,11 @@ Point is assumed to be at the beginning of a headline."
255 (when org-indent-mode 273 (when org-indent-mode
256 (let (beg end) 274 (let (beg end)
257 (save-excursion 275 (save-excursion
258 (when (ignore-errors (org-back-to-heading)) 276 (when (ignore-errors (let ((outline-regexp (format "\\*\\{1,%s\\}[ \t]+"
277 (if (featurep 'org-inlinetask)
278 (1- org-inlinetask-min-level)
279 ""))))
280 (org-back-to-heading)))
259 (setq beg (point)) 281 (setq beg (point))
260 (setq end (or (save-excursion (or (outline-next-heading) (point))))) 282 (setq end (or (save-excursion (or (outline-next-heading) (point)))))
261 (org-indent-remove-properties beg end) 283 (org-indent-remove-properties beg end)
@@ -268,7 +290,11 @@ Point is assumed to be at the beginning of a headline."
268 (when org-indent-mode 290 (when org-indent-mode
269 (let ((beg (point)) (end limit)) 291 (let ((beg (point)) (end limit))
270 (save-excursion 292 (save-excursion
271 (and (ignore-errors (org-back-to-heading t)) 293 (and (ignore-errors (let ((outline-regexp (format "\\*\\{1,%s\\}[ \t]+"
294 (if (featurep 'org-inlinetask)
295 (1- org-inlinetask-min-level)
296 ""))))
297 (org-back-to-heading)))
272 (setq beg (point)))) 298 (setq beg (point))))
273 (org-indent-remove-properties beg end) 299 (org-indent-remove-properties beg end)
274 (org-indent-add-properties beg end))) 300 (org-indent-add-properties beg end)))
diff --git a/lisp/org/org-info.el b/lisp/org/org-info.el
index 6ea192b1765..250f438ab96 100644
--- a/lisp/org/org-info.el
+++ b/lisp/org/org-info.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: 7.3 9;; Version: 7.4
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-inlinetask.el b/lisp/org/org-inlinetask.el
index 29d8c40eed2..3f2d6fbbf06 100644
--- a/lisp/org/org-inlinetask.el
+++ b/lisp/org/org-inlinetask.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: 7.3 8;; Version: 7.4
9 9
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11 11
@@ -100,6 +100,60 @@ When nil, they will not be exported."
100 :group 'org-inlinetask 100 :group 'org-inlinetask
101 :type 'boolean) 101 :type 'boolean)
102 102
103(defvar org-inlinetask-export-templates
104 '((html "<pre class=\"inlinetask\"><b>%s%s</b><br>%s</pre>"
105 '((unless (eq todo "")
106 (format "<span class=\"%s %s\">%s%s</span> "
107 class todo todo priority))
108 heading content))
109 (latex "\\begin\{description\}\\item[%s%s]%s\\end\{description\}"
110 '((unless (eq todo "") (format "\\textsc\{%s%s\} " todo priority))
111 heading content))
112 (ascii " -- %s%s%s"
113 '((unless (eq todo "") (format "%s%s " todo priority))
114 heading
115 (unless (eq content "")
116 (format "\n ¦ %s"
117 (mapconcat 'identity (org-split-string content "\n")
118 "\n ¦ ")))))
119 (docbook "<variablelist>
120<varlistentry>
121<term>%s%s</term>
122<listitem><para>%s</para></listitem>
123</varlistentry>
124</variablelist>"
125 '((unless (eq todo "") (format "%s%s " todo priority))
126 heading content)))
127 "Templates for inline tasks in various exporters.
128
129This variable is an alist in the shape of (BACKEND STRING OBJECTS).
130
131BACKEND is the name of the backend for the template (ascii, html...).
132
133STRING is a format control string.
134
135OBJECTS is a list of elements to be substituted into the format
136string. They can be of any type, from a string to a form
137returning a value (thus allowing conditional insertion). A nil
138object will be substituted as the empty string. Obviously, there
139must be at least as many objects as %-sequences in the format
140string.
141
142Moreover, the following special keywords are provided: `todo',
143`priority', `heading', `content', `tags'. If some of them are not
144defined in an inline task, their value is the empty string.
145
146As an example, valid associations are:
147
148(html \"<ul><li>%s <p>%s</p></li></ul>\" (heading content))
149
150or, with the additional package \"todonotes\" for LaTeX,
151
152(latex \"\\todo[inline]{\\textbf{\\textsf{%s %s}}\\linebreak{} %s}\"
153 '((unless (eq todo \"\")
154 (format \"\\textsc{%s%s}\" todo priority))
155 heading content)))")
156
103(defvar org-odd-levels-only) 157(defvar org-odd-levels-only)
104(defvar org-keyword-time-regexp) 158(defvar org-keyword-time-regexp)
105(defvar org-drawer-regexp) 159(defvar org-drawer-regexp)
@@ -131,24 +185,56 @@ If prefix arg NO-STATE is set, ignore `org-inlinetask-default-state'."
131 (end-of-line -1)) 185 (end-of-line -1))
132(define-key org-mode-map "\C-c\C-xt" 'org-inlinetask-insert-task) 186(define-key org-mode-map "\C-c\C-xt" 'org-inlinetask-insert-task)
133 187
188(defun org-inlinetask-outline-regexp ()
189 "Return string matching an inline task heading.
190The number of levels is controlled by `org-inlinetask-min-level'."
191 (let ((nstars (if org-odd-levels-only
192 (1- (* org-inlinetask-min-level 2))
193 org-inlinetask-min-level)))
194 (format "^\\(\\*\\{%d,\\}\\)[ \t]+" nstars)))
195
134(defun org-inlinetask-in-task-p () 196(defun org-inlinetask-in-task-p ()
135 "Return true if point is inside an inline task." 197 "Return true if point is inside an inline task."
136 (save-excursion 198 (save-excursion
137 (let* ((nstars (if org-odd-levels-only 199 (let* ((stars-re (org-inlinetask-outline-regexp))
138 (1- (* 2 (or org-inlinetask-min-level 200)))
139 (or org-inlinetask-min-level 200)))
140 (stars-re (concat "^\\(?:\\*\\{"
141 (format "%d" (- nstars 1))
142 ",\\}\\)[ \t]+"))
143 (task-beg-re (concat stars-re "\\(?:.*\\)")) 200 (task-beg-re (concat stars-re "\\(?:.*\\)"))
144 (task-end-re (concat stars-re "\\(?:END\\|end\\)"))) 201 (task-end-re (concat stars-re "\\(?:END\\|end\\)[ \t]*$")))
145 (beginning-of-line) 202 (beginning-of-line)
146 (or (looking-at task-beg-re) 203 (or (looking-at task-beg-re)
147 (and (re-search-forward "^\\*+[ \t]+" nil t) 204 (and (re-search-forward "^\\*+[ \t]+" nil t)
148 (progn (beginning-of-line) (looking-at task-end-re))))))) 205 (progn (beginning-of-line) (looking-at task-end-re)))))))
149 206
150(defvar htmlp) ; dynamically scoped into the next function 207(defun org-inlinetask-goto-beginning ()
151(defvar latexp) ; dynamically scoped into the next function 208 "Go to the beginning of the inline task at point."
209 (end-of-line)
210 (re-search-backward (org-inlinetask-outline-regexp) nil t)
211 (when (org-looking-at-p (concat (org-inlinetask-outline-regexp) "END[ \t]*$"))
212 (re-search-backward (org-inlinetask-outline-regexp) nil t)))
213
214(defun org-inlinetask-goto-end ()
215 "Go to the end of the inline task at point."
216 (beginning-of-line)
217 (cond
218 ((org-looking-at-p (concat (org-inlinetask-outline-regexp) "END[ \t]*$"))
219 (forward-line 1))
220 ((org-looking-at-p (org-inlinetask-outline-regexp))
221 (forward-line 1)
222 (when (org-inlinetask-in-task-p)
223 (re-search-forward (org-inlinetask-outline-regexp) nil t)
224 (forward-line 1)))
225 (t
226 (re-search-forward (org-inlinetask-outline-regexp) nil t)
227 (forward-line 1))))
228
229(defun org-inlinetask-get-task-level ()
230 "Get the level of the inline task around.
231This assumes the point is inside an inline task."
232 (save-excursion
233 (end-of-line)
234 (re-search-backward (org-inlinetask-outline-regexp) nil t)
235 (- (match-end 1) (match-beginning 1))))
236
237(defvar backend) ; dynamically scoped into the next function
152(defun org-inlinetask-export-handler () 238(defun org-inlinetask-export-handler ()
153 "Handle headlines with level larger or equal to `org-inlinetask-min-level'. 239 "Handle headlines with level larger or equal to `org-inlinetask-min-level'.
154Either remove headline and meta data, or do special formatting." 240Either remove headline and meta data, or do special formatting."
@@ -158,7 +244,7 @@ Either remove headline and meta data, or do special formatting."
158 (or org-inlinetask-min-level 200))) 244 (or org-inlinetask-min-level 200)))
159 (re1 (format "^\\(\\*\\{%d,\\}\\) .*\n" nstars)) 245 (re1 (format "^\\(\\*\\{%d,\\}\\) .*\n" nstars))
160 (re2 (concat "^[ \t]*" org-keyword-time-regexp)) 246 (re2 (concat "^[ \t]*" org-keyword-time-regexp))
161 headline beg end stars content indent) 247 headline beg end stars content)
162 (while (re-search-forward re1 nil t) 248 (while (re-search-forward re1 nil t)
163 (setq headline (match-string 0) 249 (setq headline (match-string 0)
164 stars (match-string 1) 250 stars (match-string 1)
@@ -179,40 +265,34 @@ Either remove headline and meta data, or do special formatting."
179 (delete-region beg (1+ (match-end 0)))) 265 (delete-region beg (1+ (match-end 0))))
180 (goto-char beg) 266 (goto-char beg)
181 (when org-inlinetask-export 267 (when org-inlinetask-export
182 (when (string-match org-complex-heading-regexp headline) 268 ;; content formatting
183 (setq headline (concat 269 (when content
184 (if (match-end 2)
185 (concat
186 (org-add-props
187 (format
188 "@<span class=\"%s %s\"> %s@</span>"
189 (if (member (match-string 2 headline)
190 org-done-keywords)
191 "done" "todo")
192 (match-string 2 headline)
193 (match-string 2 headline))
194 nil 'org-protected t)
195 " ") "")
196 (match-string 4 headline)))
197 (when content
198 (if (not (string-match "\\S-" content)) 270 (if (not (string-match "\\S-" content))
199 (setq content nil) 271 (setq content nil)
200 (if (string-match "[ \t\n]+\\'" content) 272 (if (string-match "[ \t\n]+\\'" content)
201 (setq content (substring content 0 (match-beginning 0)))) 273 (setq content (substring content 0 (match-beginning 0))))
202 (setq content (org-remove-indentation content)) 274 (setq content (org-remove-indentation content))))
203 (if latexp (setq content (concat "\\quad \\\\\n" content))))) 275 (setq content (or content ""))
204 (insert (make-string (org-inlinetask-get-current-indentation) ?\ ) 276 ;; grab elements to export
205 "- ") 277 (when (string-match org-complex-heading-regexp headline)
206 (setq indent (make-string (current-column) ?\ )) 278 (let* ((todo (or (match-string 2 headline) ""))
207 (insert headline " ::") 279 (class (or (and (eq "" todo) "")
208 (if content 280 (if (member todo org-done-keywords) "done" "todo")))
209 (insert (if htmlp " " (concat "\n" indent)) 281 (priority (or (match-string 3 headline) ""))
210 (mapconcat 'identity (org-split-string content "\n") 282 (heading (or (match-string 4 headline) ""))
211 (concat "\n" indent)) "\n") 283 (tags (or (match-string 5 headline) ""))
212 (insert "\n")) 284 (backend-spec (assq backend org-inlinetask-export-templates))
213 (insert indent) 285 (format-str (nth 1 backend-spec))
214 (backward-delete-char 2) 286 (tokens (cadr (nth 2 backend-spec)))
215 (insert "THISISTHEINLINELISTTEMINATOR\n")))))) 287 ;; change nil arguments into empty strings
288 (nil-to-str (lambda (el) (or (eval el) "")))
289 ;; build and protect export string
290 (export-str (org-add-props
291 (eval (append '(format format-str)
292 (mapcar nil-to-str tokens)))
293 nil 'org-protected t)))
294 ;; eventually insert it
295 (insert export-str "\n")))))))
216 296
217(defun org-inlinetask-get-current-indentation () 297(defun org-inlinetask-get-current-indentation ()
218 "Get the indentation of the last non-while line above this one." 298 "Get the indentation of the last non-while line above this one."
@@ -247,31 +327,11 @@ Either remove headline and meta data, or do special formatting."
247 org-inlinetask-min-level)) 327 org-inlinetask-min-level))
248 (replace-match ""))) 328 (replace-match "")))
249 329
250(defun org-inlinetask-remove-terminator ()
251 (let (beg end)
252 (save-excursion
253 (goto-char (point-min))
254 (while (re-search-forward "THISISTHEINLINELISTTEMINATOR\n" nil t)
255 (setq beg (match-beginning 0) end (match-end 0))
256 (save-excursion
257 (beginning-of-line 1)
258 (and (looking-at "<p\\(ara\\)?>THISISTHEINLINELISTTEMINATOR[ \t\n]*</p\\(ara\\)?>")
259 (setq beg (point) end (match-end 0))))
260 (delete-region beg end)))))
261
262(eval-after-load "org-exp" 330(eval-after-load "org-exp"
263 '(add-hook 'org-export-preprocess-after-tree-selection-hook 331 '(add-hook 'org-export-preprocess-after-tree-selection-hook
264 'org-inlinetask-export-handler)) 332 'org-inlinetask-export-handler))
265(eval-after-load "org" 333(eval-after-load "org"
266 '(add-hook 'org-font-lock-hook 'org-inlinetask-fontify)) 334 '(add-hook 'org-font-lock-hook 'org-inlinetask-fontify))
267(eval-after-load "org-html"
268 '(add-hook 'org-export-html-final-hook 'org-inlinetask-remove-terminator))
269(eval-after-load "org-latex"
270 '(add-hook 'org-export-latex-final-hook 'org-inlinetask-remove-terminator))
271(eval-after-load "org-ascii"
272 '(add-hook 'org-export-ascii-final-hook 'org-inlinetask-remove-terminator))
273(eval-after-load "org-docbook"
274 '(add-hook 'org-export-docbook-final-hook 'org-inlinetask-remove-terminator))
275 335
276(provide 'org-inlinetask) 336(provide 'org-inlinetask)
277 337
diff --git a/lisp/org/org-irc.el b/lisp/org/org-irc.el
index 3dd9680c8ff..fba274156db 100644
--- a/lisp/org/org-irc.el
+++ b/lisp/org/org-irc.el
@@ -4,7 +4,7 @@
4;; 4;;
5;; Author: Philip Jackson <emacs@shellarchive.co.uk> 5;; Author: Philip Jackson <emacs@shellarchive.co.uk>
6;; Keywords: erc, irc, link, org 6;; Keywords: erc, irc, link, org
7;; Version: 7.3 7;; Version: 7.4
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 d435d814679..e5c65b0fb0f 100644
--- a/lisp/org/org-jsinfo.el
+++ b/lisp/org/org-jsinfo.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: 7.3 9;; Version: 7.4
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-latex.el b/lisp/org/org-latex.el
index 2cf947312d8..a29c9f37401 100644
--- a/lisp/org/org-latex.el
+++ b/lisp/org/org-latex.el
@@ -4,7 +4,7 @@
4;; 4;;
5;; Emacs Lisp Archive Entry 5;; Emacs Lisp Archive Entry
6;; Filename: org-latex.el 6;; Filename: org-latex.el
7;; Version: 7.3 7;; Version: 7.4
8;; Author: Bastien Guerry <bzg AT altern DOT org> 8;; Author: Bastien Guerry <bzg AT altern DOT org>
9;; Maintainer: Carsten Dominik <carsten.dominik AT gmail DOT com> 9;; Maintainer: Carsten Dominik <carsten.dominik AT gmail DOT com>
10;; Keywords: org, wp, tex 10;; Keywords: org, wp, tex
@@ -295,7 +295,14 @@ markup defined, the first one in the association list will be used."
295 :group 'org-export-latex 295 :group 'org-export-latex
296 :type 'string) 296 :type 'string)
297 297
298(defcustom org-export-latex-hyperref-format "\\href{%s}{%s}" 298(defcustom org-export-latex-href-format "\\href{%s}{%s}"
299 "A printf format string to be applied to href links.
300The format must contain two %s instances. The first will be filled with
301the link, the second with the link description."
302 :group 'org-export-latex
303 :type 'string)
304
305(defcustom org-export-latex-hyperref-format "\\hyperref[%s]{%s}"
299 "A printf format string to be applied to hyperref links. 306 "A printf format string to be applied to hyperref links.
300The format must contain two %s instances. The first will be filled with 307The format must contain two %s instances. The first will be filled with
301the link, the second with the link description." 308the link, the second with the link description."
@@ -453,12 +460,6 @@ pygmentize -L lexers
453 (symbol :tag "Major mode ") 460 (symbol :tag "Major mode ")
454 (string :tag "Listings language")))) 461 (string :tag "Listings language"))))
455 462
456(defcustom org-export-latex-minted-with-line-numbers nil
457 "Should source code line numbers be included when exporting
458with the latex minted package?"
459 :group 'org-export-latex
460 :type 'boolean)
461
462(defcustom org-export-latex-remove-from-headlines 463(defcustom org-export-latex-remove-from-headlines
463 '(:todo nil :priority nil :tags nil) 464 '(:todo nil :priority nil :tags nil)
464 "A plist of keywords to remove from headlines. OBSOLETE. 465 "A plist of keywords to remove from headlines. OBSOLETE.
@@ -1280,12 +1281,13 @@ OPT-PLIST is the options plist for current buffer."
1280 (org-export-apply-macros-in-string org-export-latex-append-header) 1281 (org-export-apply-macros-in-string org-export-latex-append-header)
1281 ;; define alert if not yet defined 1282 ;; define alert if not yet defined
1282 "\n\\providecommand{\\alert}[1]{\\textbf{#1}}" 1283 "\n\\providecommand{\\alert}[1]{\\textbf{#1}}"
1284 ;; beginning of the document
1285 "\n\\begin{document}\n\n"
1283 ;; insert the title 1286 ;; insert the title
1284 (format 1287 (format
1285 "\n\n\\title{%s}\n" 1288 "\n\n\\title{%s}\n"
1286 ;; convert the title 1289 ;; convert the title
1287 (org-export-latex-content 1290 (org-export-latex-fontify-headline title))
1288 title '(lists tables fixed-width keywords)))
1289 ;; insert author info 1291 ;; insert author info
1290 (if (plist-get opt-plist :author-info) 1292 (if (plist-get opt-plist :author-info)
1291 (format "\\author{%s}\n" 1293 (format "\\author{%s}\n"
@@ -1297,8 +1299,6 @@ OPT-PLIST is the options plist for current buffer."
1297 (format-time-string 1299 (format-time-string
1298 (or (plist-get opt-plist :date) 1300 (or (plist-get opt-plist :date)
1299 org-export-latex-date-format))) 1301 org-export-latex-date-format)))
1300 ;; beginning of the document
1301 "\n\\begin{document}\n\n"
1302 ;; insert the title command 1302 ;; insert the title command
1303 (when (string-match "\\S-" title) 1303 (when (string-match "\\S-" title)
1304 (if (string-match "%s" org-export-latex-title-command) 1304 (if (string-match "%s" org-export-latex-title-command)
@@ -1325,7 +1325,7 @@ If END is non-nil, it is the end of the region."
1325 (save-excursion 1325 (save-excursion
1326 (goto-char (or beg (point-min))) 1326 (goto-char (or beg (point-min)))
1327 (let* ((pt (point)) 1327 (let* ((pt (point))
1328 (end (if (re-search-forward "^\\*+ " end t) 1328 (end (if (re-search-forward (org-get-limited-outline-regexp) end t)
1329 (goto-char (match-beginning 0)) 1329 (goto-char (match-beginning 0))
1330 (goto-char (or end (point-max)))))) 1330 (goto-char (or end (point-max))))))
1331 (prog1 1331 (prog1
@@ -1452,6 +1452,33 @@ links, keywords, lists, tables, fixed-width"
1452 ;; FIXME: org-inside-LaTeX-fragment-p doesn't work when the $...$ is at 1452 ;; FIXME: org-inside-LaTeX-fragment-p doesn't work when the $...$ is at
1453 ;; the beginning of the buffer - inserting "\n" is safe here though. 1453 ;; the beginning of the buffer - inserting "\n" is safe here though.
1454 (insert "\n" string) 1454 (insert "\n" string)
1455
1456 ;; Preserve math snippets
1457
1458 (let* ((matchers (plist-get org-format-latex-options :matchers))
1459 (re-list org-latex-regexps)
1460 beg end re e m n block off)
1461 ;; Check the different regular expressions
1462 (while (setq e (pop re-list))
1463 (setq m (car e) re (nth 1 e) n (nth 2 e)
1464 block (if (nth 3 e) "\n\n" ""))
1465 (setq off (if (member m '("$" "$1")) 1 0))
1466 (when (and (member m matchers) (not (equal m "begin")))
1467 (goto-char (point-min))
1468 (while (re-search-forward re nil t)
1469 (setq beg (+ (match-beginning 0) off) end (- (match-end 0) 0))
1470 (add-text-properties beg end
1471 '(org-protected t org-latex-math t))))))
1472
1473 ;; Convert LaTeX to \LaTeX{} and TeX to \TeX{}
1474 (goto-char (point-min))
1475 (let ((case-fold-search nil))
1476 (while (re-search-forward "\\<\\(\\(La\\)?TeX\\)\\>" nil t)
1477 (unless (eq (char-before (match-beginning 1)) ?\\)
1478 (org-if-unprotected-1
1479 (replace-match (org-export-latex-protect-string
1480 (concat "\\" (match-string 1)
1481 "{}")) t t)))))
1455 (goto-char (point-min)) 1482 (goto-char (point-min))
1456 (let ((re (concat "\\\\\\([a-zA-Z]+\\)" 1483 (let ((re (concat "\\\\\\([a-zA-Z]+\\)"
1457 "\\(?:<[^<>\n]*>\\)*" 1484 "\\(?:<[^<>\n]*>\\)*"
@@ -2016,10 +2043,10 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
2016 (insert (format 2043 (insert (format
2017 (org-export-get-coderef-format path desc) 2044 (org-export-get-coderef-format path desc)
2018 (cdr (assoc path org-export-code-refs))))) 2045 (cdr (assoc path org-export-code-refs)))))
2019 (radiop (insert (format "\\hyperref[%s]{%s}" 2046 (radiop (insert (format org-export-latex-hyperref-format
2020 (org-solidify-link-text raw-path) desc))) 2047 (org-solidify-link-text raw-path) desc)))
2021 ((not type) 2048 ((not type)
2022 (insert (format "\\hyperref[%s]{%s}" 2049 (insert (format org-export-latex-hyperref-format
2023 (org-remove-initial-hash 2050 (org-remove-initial-hash
2024 (org-solidify-link-text raw-path)) 2051 (org-solidify-link-text raw-path))
2025 desc))) 2052 desc)))
@@ -2030,7 +2057,7 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
2030 ;; a LaTeX issue, but we here implement a work-around anyway. 2057 ;; a LaTeX issue, but we here implement a work-around anyway.
2031 (setq path (org-export-latex-protect-amp path) 2058 (setq path (org-export-latex-protect-amp path)
2032 desc (org-export-latex-protect-amp desc))) 2059 desc (org-export-latex-protect-amp desc)))
2033 (insert (format org-export-latex-hyperref-format path desc))) 2060 (insert (format org-export-latex-href-format path desc)))
2034 2061
2035 ((functionp (setq fnc (nth 2 (assoc type org-link-protocols)))) 2062 ((functionp (setq fnc (nth 2 (assoc type org-link-protocols))))
2036 ;; The link protocol has a function for formatting the link 2063 ;; The link protocol has a function for formatting the link
@@ -2356,7 +2383,7 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
2356 "\n" 2383 "\n"
2357 (match-string 1 res)) 2384 (match-string 1 res))
2358 t t res))) 2385 t t res)))
2359 (insert res "\n")))) 2386 (insert res))))
2360 2387
2361(defconst org-latex-entities 2388(defconst org-latex-entities
2362 '("\\!" 2389 '("\\!"
diff --git a/lisp/org/org-list.el b/lisp/org/org-list.el
index 4ea466f379d..bc8e7bddb5b 100644
--- a/lisp/org/org-list.el
+++ b/lisp/org/org-list.el
@@ -7,7 +7,7 @@
7;; Bastien Guerry <bzg AT altern DOT org> 7;; Bastien Guerry <bzg AT altern DOT org>
8;; Keywords: outlines, hypermedia, calendar, wp 8;; Keywords: outlines, hypermedia, calendar, wp
9;; Homepage: http://orgmode.org 9;; Homepage: http://orgmode.org
10;; Version: 7.3 10;; Version: 7.4
11;; 11;;
12;; This file is part of GNU Emacs. 12;; This file is part of GNU Emacs.
13;; 13;;
@@ -462,7 +462,8 @@ List ending is determined by indentation of text. See
462 (forward-line -1) 462 (forward-line -1)
463 (catch 'exit 463 (catch 'exit
464 (while t 464 (while t
465 (let ((ind (org-get-indentation))) 465 (let ((ind (+ (or (get-text-property (point) 'original-indentation) 0)
466 (org-get-indentation))))
466 (cond 467 (cond
467 ((looking-at "^[ \t]*:END:") 468 ((looking-at "^[ \t]*:END:")
468 (throw 'exit item-ref)) 469 (throw 'exit item-ref))
@@ -502,7 +503,8 @@ List ending is determined by the indentation of text. See
502 (catch 'exit 503 (catch 'exit
503 (while t 504 (while t
504 (skip-chars-forward " \t") 505 (skip-chars-forward " \t")
505 (let ((ind (org-get-indentation))) 506 (let ((ind (+ (or (get-text-property (point) 'original-indentation) 0)
507 (org-get-indentation))))
506 (cond 508 (cond
507 ((or (>= (point) limit) 509 ((or (>= (point) limit)
508 (looking-at ":END:")) 510 (looking-at ":END:"))
@@ -518,7 +520,11 @@ List ending is determined by the indentation of text. See
518 (setq ind-ref ind) 520 (setq ind-ref ind)
519 (forward-line 1)) 521 (forward-line 1))
520 ((<= ind ind-ref) 522 ((<= ind ind-ref)
521 (throw 'exit (point-at-bol))) 523 (throw 'exit (progn
524 ;; Again, ensure bottom is just after a
525 ;; non-blank line.
526 (skip-chars-backward " \r\t\n")
527 (min (point-max) (1+ (point-at-eol))))))
522 ((looking-at "#\\+begin_") 528 ((looking-at "#\\+begin_")
523 (re-search-forward "[ \t]*#\\+end_") 529 (re-search-forward "[ \t]*#\\+end_")
524 (forward-line 1)) 530 (forward-line 1))
@@ -636,7 +642,7 @@ function ends."
636 ;; insert bullet above item in order to avoid bothering 642 ;; insert bullet above item in order to avoid bothering
637 ;; with possible blank lines ending last item. 643 ;; with possible blank lines ending last item.
638 (goto-char (org-get-item-beginning)) 644 (goto-char (org-get-item-beginning))
639 (indent-to-column ind) 645 (org-indent-to-column ind)
640 (insert (concat bullet (when checkbox "[ ] ") after-bullet)) 646 (insert (concat bullet (when checkbox "[ ] ") after-bullet))
641 ;; Stay between after-bullet and before text. 647 ;; Stay between after-bullet and before text.
642 (save-excursion 648 (save-excursion
@@ -1060,7 +1066,7 @@ so this really moves item trees."
1060 (org-list-exchange-items actual-item next-item bottom) 1066 (org-list-exchange-items actual-item next-item bottom)
1061 (org-list-repair nil nil bottom) 1067 (org-list-repair nil nil bottom)
1062 (goto-char (org-get-next-item (point) bottom)) 1068 (goto-char (org-get-next-item (point) bottom))
1063 (move-to-column col))))) 1069 (org-move-to-column col)))))
1064 1070
1065(defun org-move-item-up () 1071(defun org-move-item-up ()
1066 "Move the plain list item at point up, i.e. swap with previous item. 1072 "Move the plain list item at point up, i.e. swap with previous item.
@@ -1081,7 +1087,7 @@ so this really moves item trees."
1081 (error "Cannot move this item further up")) 1087 (error "Cannot move this item further up"))
1082 (org-list-exchange-items prev-item actual-item bottom) 1088 (org-list-exchange-items prev-item actual-item bottom)
1083 (org-list-repair nil top bottom) 1089 (org-list-repair nil top bottom)
1084 (move-to-column col))))) 1090 (org-move-to-column col)))))
1085 1091
1086(defun org-insert-item (&optional checkbox) 1092(defun org-insert-item (&optional checkbox)
1087 "Insert a new item at the current level. 1093 "Insert a new item at the current level.
@@ -1481,7 +1487,7 @@ BOTTOM is position at list ending."
1481 ;; this is not an empty line 1487 ;; this is not an empty line
1482 (let ((i (org-get-indentation))) 1488 (let ((i (org-get-indentation)))
1483 (when (and (> i 0) (> (+ i delta) 0)) 1489 (when (and (> i 0) (> (+ i delta) 0))
1484 (indent-line-to (+ i delta))))) 1490 (org-indent-line-to (+ i delta)))))
1485 (beginning-of-line 0))))) 1491 (beginning-of-line 0)))))
1486 1492
1487(defun org-outdent-item () 1493(defun org-outdent-item ()
@@ -1543,7 +1549,7 @@ Return t at each successful move."
1543 (ignore-errors 1549 (ignore-errors
1544 (org-list-indent-item-generic 1 t top bottom)))) 1550 (org-list-indent-item-generic 1 t top bottom))))
1545 (t (back-to-indentation) 1551 (t (back-to-indentation)
1546 (indent-to-column (car org-tab-ind-state)) 1552 (org-indent-to-column (car org-tab-ind-state))
1547 (end-of-line) 1553 (end-of-line)
1548 (org-list-repair (cdr org-tab-ind-state)) 1554 (org-list-repair (cdr org-tab-ind-state))
1549 ;; Break cycle 1555 ;; Break cycle
@@ -1629,35 +1635,36 @@ If WHICH is a valid string, use that as the new bullet. If WHICH
1629is an integer, 0 means `-', 1 means `+' etc. If WHICH is 1635is an integer, 0 means `-', 1 means `+' etc. If WHICH is
1630'previous, cycle backwards." 1636'previous, cycle backwards."
1631 (interactive "P") 1637 (interactive "P")
1632 (let* ((top (org-list-top-point)) 1638 (save-excursion
1633 (bullet (save-excursion 1639 (let* ((top (org-list-top-point))
1634 (goto-char (org-get-beginning-of-list top)) 1640 (bullet (progn
1635 (org-get-bullet))) 1641 (goto-char (org-get-beginning-of-list top))
1636 (current (cond 1642 (org-get-bullet)))
1637 ((string-match "\\." bullet) "1.") 1643 (current (cond
1638 ((string-match ")" bullet) "1)") 1644 ((string-match "\\." bullet) "1.")
1639 (t bullet))) 1645 ((string-match ")" bullet) "1)")
1640 (bullet-rule-p (cdr (assq 'bullet org-list-automatic-rules))) 1646 (t bullet)))
1641 (bullet-list (append '("-" "+" ) 1647 (bullet-rule-p (cdr (assq 'bullet org-list-automatic-rules)))
1642 ;; *-bullets are not allowed at column 0 1648 (bullet-list (append '("-" "+" )
1643 (unless (and bullet-rule-p 1649 ;; *-bullets are not allowed at column 0
1644 (looking-at "\\S-")) '("*")) 1650 (unless (and bullet-rule-p
1645 ;; Description items cannot be numbered 1651 (looking-at "\\S-")) '("*"))
1646 (unless (and bullet-rule-p 1652 ;; Description items cannot be numbered
1647 (or (eq org-plain-list-ordered-item-terminator ?\)) 1653 (unless (and bullet-rule-p
1648 (org-at-item-description-p))) '("1.")) 1654 (or (eq org-plain-list-ordered-item-terminator ?\))
1649 (unless (and bullet-rule-p 1655 (org-at-item-description-p))) '("1."))
1650 (or (eq org-plain-list-ordered-item-terminator ?.) 1656 (unless (and bullet-rule-p
1651 (org-at-item-description-p))) '("1)")))) 1657 (or (eq org-plain-list-ordered-item-terminator ?.)
1652 (len (length bullet-list)) 1658 (org-at-item-description-p))) '("1)"))))
1653 (item-index (- len (length (member current bullet-list)))) 1659 (len (length bullet-list))
1654 (get-value (lambda (index) (nth (mod index len) bullet-list))) 1660 (item-index (- len (length (member current bullet-list))))
1655 (new (cond 1661 (get-value (lambda (index) (nth (mod index len) bullet-list)))
1656 ((member which bullet-list) which) 1662 (new (cond
1657 ((numberp which) (funcall get-value which)) 1663 ((member which bullet-list) which)
1658 ((eq 'previous which) (funcall get-value (1- item-index))) 1664 ((numberp which) (funcall get-value which))
1659 (t (funcall get-value (1+ item-index)))))) 1665 ((eq 'previous which) (funcall get-value (1- item-index)))
1660 (org-list-repair new top))) 1666 (t (funcall get-value (1+ item-index))))))
1667 (org-list-repair new top))))
1661 1668
1662;;; Checkboxes 1669;;; Checkboxes
1663 1670
@@ -2029,7 +2036,7 @@ sublevels as a list of strings."
2029 (while (org-search-forward-unenclosed org-item-beginning-re end t) 2036 (while (org-search-forward-unenclosed org-item-beginning-re end t)
2030 (save-excursion 2037 (save-excursion
2031 (beginning-of-line) 2038 (beginning-of-line)
2032 (setq ltype (cond ((looking-at-p "^[ \t]*[0-9]") 'ordered) 2039 (setq ltype (cond ((org-looking-at-p "^[ \t]*[0-9]") 'ordered)
2033 ((org-at-item-description-p) 'descriptive) 2040 ((org-at-item-description-p) 'descriptive)
2034 (t 'unordered)))) 2041 (t 'unordered))))
2035 (let* ((indent1 (org-get-indentation)) 2042 (let* ((indent1 (org-get-indentation))
diff --git a/lisp/org/org-mac-message.el b/lisp/org/org-mac-message.el
index afac5ca71b1..a146cc86e2b 100644
--- a/lisp/org/org-mac-message.el
+++ b/lisp/org/org-mac-message.el
@@ -5,7 +5,7 @@
5;; Author: John Wiegley <johnw@gnu.org> 5;; Author: John Wiegley <johnw@gnu.org>
6;; Christopher Suckling <suckling at gmail dot com> 6;; Christopher Suckling <suckling at gmail dot com>
7 7
8;; Version: 7.3 8;; Version: 7.4
9;; Keywords: outlines, hypermedia, calendar, wp 9;; Keywords: outlines, hypermedia, calendar, wp
10 10
11;; This file is part of GNU Emacs. 11;; This file is part of GNU Emacs.
diff --git a/lisp/org/org-macs.el b/lisp/org/org-macs.el
index 5a5612387fd..97a8fdc06e4 100644
--- a/lisp/org/org-macs.el
+++ b/lisp/org/org-macs.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: 7.3 9;; Version: 7.4
10;; 10;;
11;; This file is part of GNU Emacs. 11;; This file is part of GNU Emacs.
12;; 12;;
@@ -46,9 +46,16 @@
46 (if (or (> emacs-major-version 23) 46 (if (or (> emacs-major-version 23)
47 (and (>= emacs-major-version 23) 47 (and (>= emacs-major-version 23)
48 (>= emacs-minor-version 2))) 48 (>= emacs-minor-version 2)))
49 (called-interactively-p ,kind) 49 (with-no-warnings (called-interactively-p ,kind)) ;; defined with no argument in <=23.1
50 (interactive-p)))) 50 (interactive-p))))
51 51
52(if (and (not (fboundp 'with-silent-modifications))
53 (or (< emacs-major-version 23)
54 (and (= emacs-major-version 23)
55 (< emacs-minor-version 2))))
56 (defmacro with-silent-modifications (&rest body)
57 `(org-unmodified ,@body)))
58
52(defmacro org-bound-and-true-p (var) 59(defmacro org-bound-and-true-p (var)
53 "Return the value of symbol VAR if it is bound, else nil." 60 "Return the value of symbol VAR if it is bound, else nil."
54 `(and (boundp (quote ,var)) ,var)) 61 `(and (boundp (quote ,var)) ,var))
diff --git a/lisp/org/org-mew.el b/lisp/org/org-mew.el
index efedef8ec5c..9636a1aa428 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: 7.3 8;; Version: 7.4
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 b1024a000e2..c384062a3fa 100644
--- a/lisp/org/org-mhe.el
+++ b/lisp/org/org-mhe.el
@@ -6,7 +6,7 @@
6;; Author: Thomas Baumann <thomas dot baumann at ch dot tum dot de> 6;; Author: Thomas Baumann <thomas dot baumann at ch dot tum dot de>
7;; Keywords: outlines, hypermedia, calendar, wp 7;; Keywords: outlines, hypermedia, calendar, wp
8;; Homepage: http://orgmode.org 8;; Homepage: http://orgmode.org
9;; Version: 7.3 9;; Version: 7.4
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-mks.el b/lisp/org/org-mks.el
index 2d429a79152..df4ab3e2e75 100644
--- a/lisp/org/org-mks.el
+++ b/lisp/org/org-mks.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: 7.3 8;; Version: 7.4
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-mobile.el b/lisp/org/org-mobile.el
index a278fb16d0a..4b16e2b8fcf 100644
--- a/lisp/org/org-mobile.el
+++ b/lisp/org/org-mobile.el
@@ -4,7 +4,7 @@
4;; Author: Carsten Dominik <carsten at orgmode dot org> 4;; Author: Carsten Dominik <carsten at orgmode dot org>
5;; Keywords: outlines, hypermedia, calendar, wp 5;; Keywords: outlines, hypermedia, calendar, wp
6;; Homepage: http://orgmode.org 6;; Homepage: http://orgmode.org
7;; Version: 7.3 7;; Version: 7.4
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-mouse.el b/lisp/org/org-mouse.el
index 4a341d4272d..d1540c3f3f9 100644
--- a/lisp/org/org-mouse.el
+++ b/lisp/org/org-mouse.el
@@ -1,11 +1,10 @@
1;;; org-mouse.el --- Better mouse support for org-mode 1;;; org-mouse.el --- Better mouse support for org-mode
2 2
3;; Copyright (C) 2006, 2007, 2008, 2009, 2010 3;; Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation
4;; Free Software Foundation, Inc.
5;; 4;;
6;; Author: Piotr Zielinski <piotr dot zielinski at gmail dot com> 5;; Author: Piotr Zielinski <piotr dot zielinski at gmail dot com>
7;; Maintainer: Carsten Dominik <carsten at orgmode dot org> 6;; Maintainer: Carsten Dominik <carsten at orgmode dot org>
8;; Version: 7.3 7;; Version: 7.4
9;; 8;;
10;; This file is part of GNU Emacs. 9;; This file is part of GNU Emacs.
11;; 10;;
@@ -1101,10 +1100,10 @@ This means, between the beginning of line and the point."
1101 "--" 1100 "--"
1102 ["Day View" org-agenda-day-view 1101 ["Day View" org-agenda-day-view
1103 :active (org-agenda-check-type nil 'agenda) 1102 :active (org-agenda-check-type nil 'agenda)
1104 :style radio :selected (equal org-agenda-ndays 1)] 1103 :style radio :selected (eq org-agenda-current-span 'day)]
1105 ["Week View" org-agenda-week-view 1104 ["Week View" org-agenda-week-view
1106 :active (org-agenda-check-type nil 'agenda) 1105 :active (org-agenda-check-type nil 'agenda)
1107 :style radio :selected (equal org-agenda-ndays 7)] 1106 :style radio :selected (eq org-agenda-current-span 'week)]
1108 "--" 1107 "--"
1109 ["Show Logbook entries" org-agenda-log-mode 1108 ["Show Logbook entries" org-agenda-log-mode
1110 :style toggle :selected org-agenda-show-log 1109 :style toggle :selected org-agenda-show-log
diff --git a/lisp/org/org-plot.el b/lisp/org/org-plot.el
index 274d3f94c8a..374e2d43b5e 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: 7.3 8;; Version: 7.4
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-protocol.el b/lisp/org/org-protocol.el
index 3a20c5f729c..5d5059fbf0e 100644
--- a/lisp/org/org-protocol.el
+++ b/lisp/org/org-protocol.el
@@ -9,7 +9,7 @@
9;; Author: Ross Patterson <me AT rpatterson DOT net> 9;; Author: Ross Patterson <me AT rpatterson DOT net>
10;; Maintainer: Sebastian Rose <sebastian_rose AT gmx DOT de> 10;; Maintainer: Sebastian Rose <sebastian_rose AT gmx DOT de>
11;; Keywords: org, emacsclient, wp 11;; Keywords: org, emacsclient, wp
12;; Version: 7.3 12;; Version: 7.4
13 13
14;; This file is part of GNU Emacs. 14;; This file is part of GNU Emacs.
15;; 15;;
@@ -313,7 +313,7 @@ encodeURIComponent. E.g. `%C3%B6' is the german Umlaut `ü'."
313 (let* ((start (match-beginning 0)) 313 (let* ((start (match-beginning 0))
314 (end (match-end 0)) 314 (end (match-end 0))
315 (hex (match-string 0 str)) 315 (hex (match-string 0 str))
316 (replacement (org-protocol-unhex-compound hex))) 316 (replacement (org-protocol-unhex-compound (upcase hex))))
317 (setq tmp (concat tmp (substring str 0 start) replacement)) 317 (setq tmp (concat tmp (substring str 0 start) replacement))
318 (setq str (substring str end)))) 318 (setq str (substring str end))))
319 (setq tmp (concat tmp str)) 319 (setq tmp (concat tmp str))
diff --git a/lisp/org/org-publish.el b/lisp/org/org-publish.el
index 51db9f652d1..bb20cc60dff 100644
--- a/lisp/org/org-publish.el
+++ b/lisp/org/org-publish.el
@@ -5,7 +5,7 @@
5;; Author: David O'Toole <dto@gnu.org> 5;; Author: David O'Toole <dto@gnu.org>
6;; Maintainer: Carsten Dominik <carsten DOT dominik AT gmail DOT com> 6;; Maintainer: Carsten Dominik <carsten DOT dominik AT gmail DOT com>
7;; Keywords: hypermedia, outlines, wp 7;; Keywords: hypermedia, outlines, wp
8;; Version: 7.3 8;; Version: 7.4
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-remember.el b/lisp/org/org-remember.el
index a15825a51ec..c6e21ae057b 100644
--- a/lisp/org/org-remember.el
+++ b/lisp/org/org-remember.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: 7.3 9;; Version: 7.4
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-rmail.el b/lisp/org/org-rmail.el
index 5574bf77ac4..73258685232 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: 7.3 9;; Version: 7.4
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-src.el b/lisp/org/org-src.el
index c4f0065ec34..c932b4a70b2 100644
--- a/lisp/org/org-src.el
+++ b/lisp/org/org-src.el
@@ -8,7 +8,7 @@
8;; Dan Davison <davison at stats dot ox dot ac dot uk> 8;; Dan Davison <davison at stats dot ox dot ac dot uk>
9;; Keywords: outlines, hypermedia, calendar, wp 9;; Keywords: outlines, hypermedia, calendar, wp
10;; Homepage: http://orgmode.org 10;; Homepage: http://orgmode.org
11;; Version: 7.3 11;; Version: 7.4
12;; 12;;
13;; This file is part of GNU Emacs. 13;; This file is part of GNU Emacs.
14;; 14;;
@@ -240,8 +240,8 @@ buffer."
240 block-nindent (nth 5 info) 240 block-nindent (nth 5 info)
241 lang-f (intern (concat lang "-mode")) 241 lang-f (intern (concat lang "-mode"))
242 begline (save-excursion (goto-char beg) (org-current-line))) 242 begline (save-excursion (goto-char beg) (org-current-line)))
243 (if (and mark (>= mark beg) (<= mark end)) 243 (if (and mark (>= mark beg) (<= mark (1+ end)))
244 (save-excursion (goto-char mark) 244 (save-excursion (goto-char (min mark end))
245 (setq markline (org-current-line) 245 (setq markline (org-current-line)
246 markcol (current-column)))) 246 markcol (current-column))))
247 (if (equal lang-f 'table.el-mode) 247 (if (equal lang-f 'table.el-mode)
diff --git a/lisp/org/org-table.el b/lisp/org/org-table.el
index 0d61a782270..116c3fc2312 100644
--- a/lisp/org/org-table.el
+++ b/lisp/org/org-table.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: 7.3 9;; Version: 7.4
10;; 10;;
11;; This file is part of GNU Emacs. 11;; This file is part of GNU Emacs.
12;; 12;;
@@ -48,6 +48,12 @@
48(defvar org-export-html-table-tag) ; defined in org-exp.el 48(defvar org-export-html-table-tag) ; defined in org-exp.el
49(defvar constants-unit-system) 49(defvar constants-unit-system)
50 50
51(defvar orgtbl-after-send-table-hook nil
52 "Hook for functions attaching to `C-c C-c', if the table is sent.
53This can be used to add additional functionality after the table is sent
54to the receiver position, othewise, if table is not sent, the functions
55are not run.")
56
51(defcustom orgtbl-optimized (eq org-enable-table-editor 'optimized) 57(defcustom orgtbl-optimized (eq org-enable-table-editor 'optimized)
52 "Non-nil means use the optimized table editor version for `orgtbl-mode'. 58 "Non-nil means use the optimized table editor version for `orgtbl-mode'.
53In the optimized version, the table editor takes over all simple keys that 59In the optimized version, the table editor takes over all simple keys that
@@ -3729,7 +3735,8 @@ With prefix arg, also recompute table."
3729 (call-interactively 'org-table-recalculate) 3735 (call-interactively 'org-table-recalculate)
3730 (org-table-maybe-recalculate-line)) 3736 (org-table-maybe-recalculate-line))
3731 (call-interactively 'org-table-align) 3737 (call-interactively 'org-table-align)
3732 (orgtbl-send-table 'maybe)) 3738 (when (orgtbl-send-table 'maybe)
3739 (run-hooks 'orgtbl-after-send-table-hook)))
3733 ((eq action 'recalc) 3740 ((eq action 'recalc)
3734 (save-excursion 3741 (save-excursion
3735 (beginning-of-line 1) 3742 (beginning-of-line 1)
@@ -3943,7 +3950,10 @@ this table."
3943 (orgtbl-send-replace-tbl name txt)) 3950 (orgtbl-send-replace-tbl name txt))
3944 (setq ntbl (1+ ntbl))) 3951 (setq ntbl (1+ ntbl)))
3945 (message "Table converted and installed at %d receiver location%s" 3952 (message "Table converted and installed at %d receiver location%s"
3946 ntbl (if (> ntbl 1) "s" ""))))) 3953 ntbl (if (> ntbl 1) "s" ""))
3954 (if (> ntbl 0)
3955 ntbl
3956 nil))))
3947 3957
3948(defun org-remove-by-index (list indices &optional i0) 3958(defun org-remove-by-index (list indices &optional i0)
3949 "Remove the elements in LIST with indices in INDICES. 3959 "Remove the elements in LIST with indices in INDICES.
diff --git a/lisp/org/org-taskjuggler.el b/lisp/org/org-taskjuggler.el
index d03cd591b81..d78e10d56a8 100644
--- a/lisp/org/org-taskjuggler.el
+++ b/lisp/org/org-taskjuggler.el
@@ -4,7 +4,7 @@
4;; 4;;
5;; Emacs Lisp Archive Entry 5;; Emacs Lisp Archive Entry
6;; Filename: org-taskjuggler.el 6;; Filename: org-taskjuggler.el
7;; Version: 7.3 7;; Version: 7.4
8;; Author: Christian Egli 8;; Author: Christian Egli
9;; Maintainer: Christian Egli 9;; Maintainer: Christian Egli
10;; Keywords: org, taskjuggler, project planning 10;; Keywords: org, taskjuggler, project planning
diff --git a/lisp/org/org-timer.el b/lisp/org/org-timer.el
index 6c1f4984cf1..bac11870431 100644
--- a/lisp/org/org-timer.el
+++ b/lisp/org/org-timer.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: 7.3 8;; Version: 7.4
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-vm.el b/lisp/org/org-vm.el
index 629258dec94..daef6713f41 100644
--- a/lisp/org/org-vm.el
+++ b/lisp/org/org-vm.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: 7.3 9;; Version: 7.4
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-w3m.el b/lisp/org/org-w3m.el
index 072020a65e7..6965ac6b337 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: 7.3 8;; Version: 7.4
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-wl.el b/lisp/org/org-wl.el
index 54d35c98f2f..137bad9de89 100644
--- a/lisp/org/org-wl.el
+++ b/lisp/org/org-wl.el
@@ -7,7 +7,7 @@
7;; David Maus <dmaus at ictsoc dot de> 7;; David Maus <dmaus at ictsoc 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: 7.3 10;; Version: 7.4
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-xoxo.el b/lisp/org/org-xoxo.el
index b5656d9406f..2ce277ed6ce 100644
--- a/lisp/org/org-xoxo.el
+++ b/lisp/org/org-xoxo.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: 7.3 9;; Version: 7.4
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.el b/lisp/org/org.el
index f7e7c9fd2f4..eb919687325 100644
--- a/lisp/org/org.el
+++ b/lisp/org/org.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: 7.3 9;; Version: 7.4
10;; 10;;
11;; This file is part of GNU Emacs. 11;; This file is part of GNU Emacs.
12;; 12;;
@@ -75,6 +75,7 @@
75 (require 'gnus-sum)) 75 (require 'gnus-sum))
76 76
77(require 'calendar) 77(require 'calendar)
78
78;; Emacs 22 calendar compatibility: Make sure the new variables are available 79;; Emacs 22 calendar compatibility: Make sure the new variables are available
79(when (fboundp 'defvaralias) 80(when (fboundp 'defvaralias)
80 (unless (boundp 'calendar-view-holidays-initially-flag) 81 (unless (boundp 'calendar-view-holidays-initially-flag)
@@ -98,6 +99,7 @@
98(require 'org-compat) 99(require 'org-compat)
99(require 'org-faces) 100(require 'org-faces)
100(require 'org-list) 101(require 'org-list)
102(require 'org-complete)
101(require 'org-src) 103(require 'org-src)
102(require 'org-footnote) 104(require 'org-footnote)
103 105
@@ -186,7 +188,7 @@ identifier."
186 188
187;;; Version 189;;; Version
188 190
189(defconst org-version "7.3" 191(defconst org-version "7.4"
190 "The version number of the file org.el.") 192 "The version number of the file org.el.")
191 193
192(defun org-version (&optional here) 194(defun org-version (&optional here)
@@ -1383,12 +1385,15 @@ nil Never use an ID to make a link, instead link using a text search for
1383(defcustom org-context-in-file-links t 1385(defcustom org-context-in-file-links t
1384 "Non-nil means file links from `org-store-link' contain context. 1386 "Non-nil means file links from `org-store-link' contain context.
1385A search string will be added to the file name with :: as separator and 1387A search string will be added to the file name with :: as separator and
1386used to find the context when the link is activated by the command 1388used to find the context when the link is activated by the command
1387`org-open-at-point'. 1389`org-open-at-point'. When this option is t, the entire active region
1390will be placed in the search string of the file link. If set to a
1391positive integer, only the first n lines of context will be stored.
1392
1388Using a prefix arg to the command \\[org-store-link] (`org-store-link') 1393Using a prefix arg to the command \\[org-store-link] (`org-store-link')
1389negates this setting for the duration of the command." 1394negates this setting for the duration of the command."
1390 :group 'org-link-store 1395 :group 'org-link-store
1391 :type 'boolean) 1396 :type '(choice boolean integer))
1392 1397
1393(defcustom org-keep-stored-link-after-insertion nil 1398(defcustom org-keep-stored-link-after-insertion nil
1394 "Non-nil means keep link in list for entire session. 1399 "Non-nil means keep link in list for entire session.
@@ -1958,7 +1963,7 @@ indicating if the keywords should be interpreted as a sequence of
1958action steps, or as different types of TODO items. The first 1963action steps, or as different types of TODO items. The first
1959keywords are states requiring action - these states will select a headline 1964keywords are states requiring action - these states will select a headline
1960for inclusion into the global TODO list Org-mode produces. If one of 1965for inclusion into the global TODO list Org-mode produces. If one of
1961the \"keywords\" is the vertical bat \"|\" the remaining keywords 1966the \"keywords\" is the vertical bar, \"|\", the remaining keywords
1962signify that no further action is necessary. If \"|\" is not found, 1967signify that no further action is necessary. If \"|\" is not found,
1963the last keyword is treated as the only DONE state of the sequence. 1968the last keyword is treated as the only DONE state of the sequence.
1964 1969
@@ -2473,6 +2478,16 @@ command used) one higher or lower that the default priority."
2473 :group 'org-priorities 2478 :group 'org-priorities
2474 :type 'boolean) 2479 :type 'boolean)
2475 2480
2481(defcustom org-get-priority-function nil
2482 "Function to extract the priority from a string.
2483The string is normally the headline. If this is nil Org computes the
2484priority from the priority cookie like [#A] in the headline. It returns
2485an integer, increasing by 1000 for each priority level.
2486The user can set a different function here, which should take a string
2487as an argument and return the numeric priority."
2488 :group 'org-priorities
2489 :type 'function)
2490
2476(defgroup org-time nil 2491(defgroup org-time nil
2477 "Options concerning time stamps and deadlines in Org-mode." 2492 "Options concerning time stamps and deadlines in Org-mode."
2478 :tag "Org Time" 2493 :tag "Org Time"
@@ -2613,7 +2628,7 @@ This may t or nil, or the symbol `org-read-date-prefer-future'."
2613 :group 'org-agenda 2628 :group 'org-agenda
2614 :group 'org-time 2629 :group 'org-time
2615 :type '(choice 2630 :type '(choice
2616 (const :tag "Use org-aread-date-prefer-future" 2631 (const :tag "Use org-read-date-prefer-future"
2617 org-read-date-prefer-future) 2632 org-read-date-prefer-future)
2618 (const :tag "Never" nil) 2633 (const :tag "Never" nil)
2619 (const :tag "Always" t))) 2634 (const :tag "Always" t)))
@@ -2719,10 +2734,10 @@ To disable these tags on a per-file basis, insert anywhere in the file:
2719(defcustom org-complete-tags-always-offer-all-agenda-tags nil 2734(defcustom org-complete-tags-always-offer-all-agenda-tags nil
2720 "If non-nil, always offer completion for all tags of all agenda files. 2735 "If non-nil, always offer completion for all tags of all agenda files.
2721Instead of customizing this variable directly, you might want to 2736Instead of customizing this variable directly, you might want to
2722set it locally for remember buffers, because there no list of 2737set it locally for capture buffers, because there no list of
2723tags in that file can be created dynamically (there are none). 2738tags in that file can be created dynamically (there are none).
2724 2739
2725 (add-hook 'org-remember-mode-hook 2740 (add-hook 'org-capture-mode-hook
2726 (lambda () 2741 (lambda ()
2727 (set (make-local-variable 2742 (set (make-local-variable
2728 'org-complete-tags-always-offer-all-agenda-tags) 2743 'org-complete-tags-always-offer-all-agenda-tags)
@@ -3422,7 +3437,7 @@ After a match, the match groups contain these elements:
3422(defcustom org-emphasis-regexp-components 3437(defcustom org-emphasis-regexp-components
3423 '(" \t('\"{" "- \t.,:!?;'\")}\\" " \t\r\n,\"'" "." 1) 3438 '(" \t('\"{" "- \t.,:!?;'\")}\\" " \t\r\n,\"'" "." 1)
3424 "Components used to build the regular expression for emphasis. 3439 "Components used to build the regular expression for emphasis.
3425This is a list with 6 entries. Terminology: In an emphasis string 3440This is a list with five entries. Terminology: In an emphasis string
3426like \" *strong word* \", we call the initial space PREMATCH, the final 3441like \" *strong word* \", we call the initial space PREMATCH, the final
3427space POSTMATCH, the stars MARKERS, \"s\" and \"d\" are BORDER characters 3442space POSTMATCH, the stars MARKERS, \"s\" and \"d\" are BORDER characters
3428and \"trong wor\" is the body. The different components in this variable 3443and \"trong wor\" is the body. The different components in this variable
@@ -3506,8 +3521,8 @@ Note that this variable has only an effect if `org-completion-use-ido' is nil."
3506 :type 'boolean) 3521 :type 'boolean)
3507 3522
3508(defcustom org-completion-fallback-command 'hippie-expand 3523(defcustom org-completion-fallback-command 'hippie-expand
3509 "The expansion command called by \\[org-complete] in normal context. 3524 "The expansion command called by \\[pcomplete] in normal context.
3510Normal means no org-mode-specific context." 3525Normal means, no org-mode-specific context."
3511 :group 'org-completion 3526 :group 'org-completion
3512 :type 'function) 3527 :type 'function)
3513 3528
@@ -3555,10 +3570,13 @@ Normal means no org-mode-specific context."
3555 "org-agenda" (&optional end)) 3570 "org-agenda" (&optional end))
3556(declare-function org-inlinetask-remove-END-maybe "org-inlinetask" ()) 3571(declare-function org-inlinetask-remove-END-maybe "org-inlinetask" ())
3557(declare-function org-inlinetask-in-task-p "org-inlinetask" ()) 3572(declare-function org-inlinetask-in-task-p "org-inlinetask" ())
3573(declare-function org-inlinetask-goto-beginning "org-inlinetask" ())
3574(declare-function org-inlinetask-goto-end "org-inlinetask" ())
3558(declare-function org-indent-mode "org-indent" (&optional arg)) 3575(declare-function org-indent-mode "org-indent" (&optional arg))
3559(declare-function parse-time-string "parse-time" (string)) 3576(declare-function parse-time-string "parse-time" (string))
3560(declare-function org-attach-reveal "org-attach" (&optional if-exists)) 3577(declare-function org-attach-reveal "org-attach" (&optional if-exists))
3561(declare-function org-export-latex-fix-inputenc "org-latex" ()) 3578(declare-function org-export-latex-fix-inputenc "org-latex" ())
3579(declare-function orgtbl-send-table "org-table" (&optional maybe))
3562(defvar remember-data-file) 3580(defvar remember-data-file)
3563(defvar texmathp-why) 3581(defvar texmathp-why)
3564(declare-function speedbar-line-directory "speedbar" (&optional depth)) 3582(declare-function speedbar-line-directory "speedbar" (&optional depth))
@@ -4739,6 +4757,17 @@ The following commands are available:
4739 ;; Turn on org-beamer-mode? 4757 ;; Turn on org-beamer-mode?
4740 (and org-startup-with-beamer-mode (org-beamer-mode 1)) 4758 (and org-startup-with-beamer-mode (org-beamer-mode 1))
4741 4759
4760 ;; Setup the pcomplete hooks
4761 (set (make-local-variable 'pcomplete-command-completion-function)
4762 'org-complete-initial)
4763 (set (make-local-variable 'pcomplete-command-name-function)
4764 'org-command-at-point)
4765 (set (make-local-variable 'pcomplete-default-completion-function)
4766 'ignore)
4767 (set (make-local-variable 'pcomplete-parse-arguments-function)
4768 'org-parse-arguments)
4769 (set (make-local-variable 'pcomplete-termination-string) "")
4770
4742 ;; If empty file that did not turn on org-mode automatically, make it to. 4771 ;; If empty file that did not turn on org-mode automatically, make it to.
4743 (if (and org-insert-mode-line-in-empty-file 4772 (if (and org-insert-mode-line-in-empty-file
4744 (interactive-p) 4773 (interactive-p)
@@ -4773,6 +4802,12 @@ The following commands are available:
4773 (nthcdr 2 time)))) 4802 (nthcdr 2 time))))
4774 (current-time))) 4803 (current-time)))
4775 4804
4805(defun org-today ()
4806 "Return today date, considering `org-extend-today-until'."
4807 (time-to-days
4808 (time-subtract (current-time)
4809 (list 0 (* 3600 org-extend-today-until) 0))))
4810
4776;;;; Font-Lock stuff, including the activators 4811;;;; Font-Lock stuff, including the activators
4777 4812
4778(defvar org-mouse-map (make-sparse-keymap)) 4813(defvar org-mouse-map (make-sparse-keymap))
@@ -5581,14 +5616,17 @@ needs to be inserted at a specific position in the font-lock sequence.")
5581(defvar org-l nil) 5616(defvar org-l nil)
5582(defvar org-f nil) 5617(defvar org-f nil)
5583(defun org-get-level-face (n) 5618(defun org-get-level-face (n)
5584 "Get the right face for match N in font-lock matching of headlines." 5619 "Get the right face for match N in font-lock matching of headlines."
5585 (setq org-l (- (match-end 2) (match-beginning 1) 1)) 5620 (setq org-l (- (match-end 2) (match-beginning 1) 1))
5586 (if org-odd-levels-only (setq org-l (1+ (/ org-l 2)))) 5621 (if org-odd-levels-only (setq org-l (1+ (/ org-l 2))))
5587 (setq org-f (nth (% (1- org-l) org-n-level-faces) org-level-faces)) 5622 (if org-cycle-level-faces
5588 (cond 5623 (setq org-f (nth (% (1- org-l) org-n-level-faces) org-level-faces))
5589 ((eq n 1) (if org-hide-leading-stars 'org-hide org-f)) 5624 (setq org-f (nth (1- (min org-l org-n-level-faces)) org-level-faces)))
5590 ((eq n 2) org-f) 5625 (cond
5591 (t (if org-level-color-stars-only nil org-f)))) 5626 ((eq n 1) (if org-hide-leading-stars 'org-hide org-f))
5627 ((eq n 2) org-f)
5628 (t (if org-level-color-stars-only nil org-f))))
5629
5592 5630
5593(defun org-get-todo-face (kwd) 5631(defun org-get-todo-face (kwd)
5594 "Get the right face for a TODO keyword KWD. 5632 "Get the right face for a TODO keyword KWD.
@@ -6040,8 +6078,8 @@ With a numeric prefix, show all headlines up to that level."
6040 (interactive) 6078 (interactive)
6041 (let (org-show-entry-below state) 6079 (let (org-show-entry-below state)
6042 (save-excursion 6080 (save-excursion
6043 (goto-char (point-max)) 6081 (goto-char (point-min))
6044 (while (re-search-backward 6082 (while (re-search-forward
6045 "^[ \t]*:VISIBILITY:[ \t]+\\([a-z]+\\)" 6083 "^[ \t]*:VISIBILITY:[ \t]+\\([a-z]+\\)"
6046 nil t) 6084 nil t)
6047 (setq state (match-string 1)) 6085 (setq state (match-string 1))
@@ -6982,11 +7020,12 @@ in the region."
6982 "Return the level of the current entry, or nil if before the first headline. 7020 "Return the level of the current entry, or nil if before the first headline.
6983The level is the number of stars at the beginning of the headline." 7021The level is the number of stars at the beginning of the headline."
6984 (save-excursion 7022 (save-excursion
6985 (condition-case nil 7023 (let ((outline-regexp (org-get-limited-outline-regexp)))
6986 (progn 7024 (condition-case nil
6987 (org-back-to-heading t) 7025 (progn
6988 (funcall outline-level)) 7026 (org-back-to-heading t)
6989 (error nil)))) 7027 (funcall outline-level))
7028 (error nil)))))
6990 7029
6991(defun org-get-previous-line-level () 7030(defun org-get-previous-line-level ()
6992 "Return the outline depth of the last headline before the current line. 7031 "Return the outline depth of the last headline before the current line.
@@ -7501,12 +7540,13 @@ If yes, remember the marker and the distance to BEG."
7501 (narrow-to-region 7540 (narrow-to-region
7502 (progn (org-back-to-heading t) (point)) 7541 (progn (org-back-to-heading t) (point))
7503 (progn (org-end-of-subtree t t) 7542 (progn (org-end-of-subtree t t)
7504 (if (org-on-heading-p) (backward-char 1)) 7543 (if (and (org-on-heading-p) (not (eobp))) (backward-char 1))
7505 (point)))))) 7544 (point))))))
7506 7545
7507(eval-when-compile 7546(eval-when-compile
7508 (defvar org-property-drawer-re)) 7547 (defvar org-property-drawer-re))
7509 7548
7549(defvar org-property-start-re) ;; defined below
7510(defun org-clone-subtree-with-time-shift (n &optional shift) 7550(defun org-clone-subtree-with-time-shift (n &optional shift)
7511 "Clone the task (subtree) at point N times. 7551 "Clone the task (subtree) at point N times.
7512The clones will be inserted as siblings. 7552The clones will be inserted as siblings.
@@ -7570,7 +7610,7 @@ and still retain the repeater to cover future instances of the task."
7570 (and idprop (if org-clone-delete-id 7610 (and idprop (if org-clone-delete-id
7571 (org-entry-delete nil "ID") 7611 (org-entry-delete nil "ID")
7572 (org-id-get-create t))) 7612 (org-id-get-create t)))
7573 (while (re-search-forward org-property-drawer-re nil t) 7613 (while (re-search-forward org-property-start-re nil t)
7574 (org-remove-empty-drawer-at "PROPERTIES" (point))) 7614 (org-remove-empty-drawer-at "PROPERTIES" (point)))
7575 (goto-char (point-min)) 7615 (goto-char (point-min))
7576 (when doshift 7616 (when doshift
@@ -8468,7 +8508,8 @@ according to FMT (default from `org-email-link-description-format')."
8468(defun org-make-org-heading-search-string (&optional string heading) 8508(defun org-make-org-heading-search-string (&optional string heading)
8469 "Make search string for STRING or current headline." 8509 "Make search string for STRING or current headline."
8470 (interactive) 8510 (interactive)
8471 (let ((s (or string (org-get-heading)))) 8511 (let ((s (or string (org-get-heading)))
8512 (lines org-context-in-file-links))
8472 (unless (and string (not heading)) 8513 (unless (and string (not heading))
8473 ;; We are using a headline, clean up garbage in there. 8514 ;; We are using a headline, clean up garbage in there.
8474 (if (string-match org-todo-regexp s) 8515 (if (string-match org-todo-regexp s)
@@ -8482,6 +8523,13 @@ according to FMT (default from `org-email-link-description-format')."
8482 (while (string-match org-ts-regexp s) 8523 (while (string-match org-ts-regexp s)
8483 (setq s (replace-match "" t t s)))) 8524 (setq s (replace-match "" t t s))))
8484 (or string (setq s (concat "*" s))) ; Add * for headlines 8525 (or string (setq s (concat "*" s))) ; Add * for headlines
8526 (when (and string (integerp lines) (> lines 0))
8527 (let ((slines (org-split-string s "\n")))
8528 (when (< lines (length slines))
8529 (setq s (mapconcat
8530 'identity
8531 (reverse (nthcdr (- (length slines) lines)
8532 (reverse slines))) "\n")))))
8485 (mapconcat 'identity (org-split-string s "[ \t]+") " "))) 8533 (mapconcat 'identity (org-split-string s "[ \t]+") " ")))
8486 8534
8487(defun org-make-link (&rest strings) 8535(defun org-make-link (&rest strings)
@@ -9054,7 +9102,8 @@ application the system uses for this file type."
9054 (progn (require 'org-attach) (org-attach-reveal 'if-exists)))) 9102 (progn (require 'org-attach) (org-attach-reveal 'if-exists))))
9055 ((run-hook-with-args-until-success 'org-open-at-point-functions)) 9103 ((run-hook-with-args-until-success 'org-open-at-point-functions))
9056 ((org-at-timestamp-p t) (org-follow-timestamp-link)) 9104 ((org-at-timestamp-p t) (org-follow-timestamp-link))
9057 ((or (org-footnote-at-reference-p) (org-footnote-at-definition-p)) 9105 ((and (or (org-footnote-at-reference-p) (org-footnote-at-definition-p))
9106 (not (org-in-regexp org-bracket-link-regexp)))
9058 (org-footnote-action)) 9107 (org-footnote-action))
9059 (t 9108 (t
9060 (let (type path link line search (pos (point))) 9109 (let (type path link line search (pos (point)))
@@ -9170,10 +9219,6 @@ application the system uses for this file type."
9170 (dired path) 9219 (dired path)
9171 (org-open-file path in-emacs line search))) 9220 (org-open-file path in-emacs line search)))
9172 9221
9173 ((string= type "news")
9174 (require 'org-gnus)
9175 (org-gnus-follow-link path))
9176
9177 ((string= type "shell") 9222 ((string= type "shell")
9178 (let ((cmd path)) 9223 (let ((cmd path))
9179 (if (or (not org-confirm-shell-link-function) 9224 (if (or (not org-confirm-shell-link-function)
@@ -10464,6 +10509,7 @@ blocks in the buffer."
10464 "Update the dynamic block at point. 10509 "Update the dynamic block at point.
10465This means to empty the block, parse for parameters and then call 10510This means to empty the block, parse for parameters and then call
10466the correct writing function." 10511the correct writing function."
10512 (interactive)
10467 (save-window-excursion 10513 (save-window-excursion
10468 (let* ((pos (point)) 10514 (let* ((pos (point))
10469 (line (org-current-line)) 10515 (line (org-current-line))
@@ -10505,6 +10551,7 @@ Error if there is no such block at point."
10505(defun org-update-all-dblocks () 10551(defun org-update-all-dblocks ()
10506 "Update all dynamic blocks in the buffer. 10552 "Update all dynamic blocks in the buffer.
10507This function can be used in a hook." 10553This function can be used in a hook."
10554 (interactive)
10508 (when (org-mode-p) 10555 (when (org-mode-p)
10509 (org-map-dblocks 'org-update-dblock))) 10556 (org-map-dblocks 'org-update-dblock)))
10510 10557
@@ -10512,10 +10559,10 @@ This function can be used in a hook."
10512;;;; Completion 10559;;;; Completion
10513 10560
10514(defconst org-additional-option-like-keywords 10561(defconst org-additional-option-like-keywords
10515 '("BEGIN_HTML" "END_HTML" "HTML:" "ATTR_HTML" 10562 '("BEGIN_HTML" "END_HTML" "HTML:" "ATTR_HTML:"
10516 "BEGIN_DocBook" "END_DocBook" "DocBook:" "ATTR_DocBook" 10563 "BEGIN_DocBook" "END_DocBook" "DocBook:" "ATTR_DocBook:"
10517 "BEGIN_LaTeX" "END_LaTeX" "LaTeX:" "LATEX_HEADER:" 10564 "BEGIN_LaTeX" "END_LaTeX" "LaTeX:" "LATEX_HEADER:"
10518 "LATEX_CLASS:" "LATEX_CLASS_OPTIONS:" "ATTR_LaTeX" 10565 "LATEX_CLASS:" "LATEX_CLASS_OPTIONS:" "ATTR_LaTeX:"
10519 "BEGIN:" "END:" 10566 "BEGIN:" "END:"
10520 "ORGTBL" "TBLFM:" "TBLNAME:" 10567 "ORGTBL" "TBLFM:" "TBLNAME:"
10521 "BEGIN_EXAMPLE" "END_EXAMPLE" 10568 "BEGIN_EXAMPLE" "END_EXAMPLE"
@@ -10523,11 +10570,17 @@ This function can be used in a hook."
10523 "BEGIN_VERSE" "END_VERSE" 10570 "BEGIN_VERSE" "END_VERSE"
10524 "BEGIN_CENTER" "END_CENTER" 10571 "BEGIN_CENTER" "END_CENTER"
10525 "BEGIN_SRC" "END_SRC" 10572 "BEGIN_SRC" "END_SRC"
10526 "CATEGORY" "COLUMNS" "PROPERTY" 10573 "BEGIN_RESULT" "END_RESULT"
10527 "CAPTION" "LABEL" 10574 "SOURCE:" "SRCNAME:" "FUNCTION:"
10528 "SETUPFILE" 10575 "RESULTS:"
10529 "BIND" 10576 "HEADER:" "HEADERS:"
10530 "MACRO")) 10577 "BABEL:"
10578 "CATEGORY:" "COLUMNS:" "PROPERTY:"
10579 "CAPTION:" "LABEL:"
10580 "SETUPFILE:"
10581 "INCLUDE:"
10582 "BIND:"
10583 "MACRO:"))
10531 10584
10532(defcustom org-structure-template-alist 10585(defcustom org-structure-template-alist
10533 '( 10586 '(
@@ -10609,137 +10662,6 @@ expands them."
10609 (insert rpl) 10662 (insert rpl)
10610 (if (re-search-backward "\\?" start t) (delete-char 1)))) 10663 (if (re-search-backward "\\?" start t) (delete-char 1))))
10611 10664
10612
10613(defun org-complete (&optional arg)
10614 "Perform completion on word at point.
10615At the beginning of a headline, this completes TODO keywords as given in
10616`org-todo-keywords'.
10617If the current word is preceded by a backslash, completes the TeX symbols
10618that are supported for HTML support.
10619If the current word is preceded by \"#+\", completes special words for
10620setting file options.
10621In the line after \"#+STARTUP:, complete valid keywords.\"
10622At all other locations, this simply calls the value of
10623`org-completion-fallback-command'."
10624 (interactive "P")
10625 (org-without-partial-completion
10626 (catch 'exit
10627 (let* ((a nil)
10628 (end (point))
10629 (beg1 (save-excursion
10630 (skip-chars-backward (org-re "[:alnum:]_@#%"))
10631 (point)))
10632 (beg (save-excursion
10633 (skip-chars-backward "a-zA-Z0-9_:$")
10634 (point)))
10635 (confirm (lambda (x) (stringp (car x))))
10636 (searchhead (equal (char-before beg) ?*))
10637 (struct
10638 (when (and (member (char-before beg1) '(?. ?<))
10639 (setq a (assoc (buffer-substring beg1 (point))
10640 org-structure-template-alist)))
10641 (org-complete-expand-structure-template (1- beg1) a)
10642 (throw 'exit t)))
10643 (tag (and (equal (char-before beg1) ?:)
10644 (equal (char-after (point-at-bol)) ?*)))
10645 (prop (or (and (equal (char-before beg1) ?:)
10646 (not (equal (char-after (point-at-bol)) ?*)))
10647 (string-match "^#\\+PROPERTY:.*"
10648 (buffer-substring (point-at-bol) (point)))))
10649 (texp (equal (char-before beg) ?\\))
10650 (link (equal (char-before beg) ?\[))
10651 (opt (equal (buffer-substring (max (point-at-bol) (- beg 2))
10652 beg)
10653 "#+"))
10654 (startup (string-match "^#\\+STARTUP:.*"
10655 (buffer-substring (point-at-bol) (point))))
10656 (completion-ignore-case opt)
10657 (type nil)
10658 (tbl nil)
10659 (table (cond
10660 (opt
10661 (setq type :opt)
10662 (require 'org-exp)
10663 (append
10664 (delq nil
10665 (mapcar
10666 (lambda (x)
10667 (if (string-match
10668 "^#\\+\\(\\([A-Z_]+:?\\).*\\)" x)
10669 (cons (match-string 2 x)
10670 (match-string 1 x))))
10671 (org-split-string (org-get-current-options) "\n")))
10672 (mapcar 'list org-additional-option-like-keywords)))
10673 (startup
10674 (setq type :startup)
10675 org-startup-options)
10676 (link (append org-link-abbrev-alist-local
10677 org-link-abbrev-alist))
10678 (texp
10679 (setq type :tex)
10680 (append org-entities-user org-entities))
10681 ((string-match "\\`\\*+[ \t]+\\'"
10682 (buffer-substring (point-at-bol) beg))
10683 (setq type :todo)
10684 (mapcar 'list org-todo-keywords-1))
10685 (searchhead
10686 (setq type :searchhead)
10687 (save-excursion
10688 (goto-char (point-min))
10689 (while (re-search-forward org-todo-line-regexp nil t)
10690 (push (list
10691 (org-make-org-heading-search-string
10692 (match-string 3) t))
10693 tbl)))
10694 tbl)
10695 (tag (setq type :tag beg beg1)
10696 (or org-tag-alist (org-get-buffer-tags)))
10697 (prop (setq type :prop beg beg1)
10698 (mapcar 'list (org-buffer-property-keys nil t t)))
10699 (t (progn
10700 (call-interactively org-completion-fallback-command)
10701 (throw 'exit nil)))))
10702 (pattern (buffer-substring-no-properties beg end))
10703 (completion (try-completion pattern table confirm)))
10704 (cond ((eq completion t)
10705 (if (not (assoc (upcase pattern) table))
10706 (message "Already complete")
10707 (if (and (equal type :opt)
10708 (not (member (car (assoc (upcase pattern) table))
10709 org-additional-option-like-keywords)))
10710 (insert (substring (cdr (assoc (upcase pattern) table))
10711 (length pattern)))
10712 (if (memq type '(:tag :prop)) (insert ":")))))
10713 ((null completion)
10714 (message "Can't find completion for \"%s\"" pattern)
10715 (ding))
10716 ((not (string= pattern completion))
10717 (delete-region beg end)
10718 (if (string-match " +$" completion)
10719 (setq completion (replace-match "" t t completion)))
10720 (insert completion)
10721 (if (get-buffer-window "*Completions*")
10722 (delete-window (get-buffer-window "*Completions*")))
10723 (if (assoc completion table)
10724 (if (eq type :todo) (insert " ")
10725 (if (and (memq type '(:tag :prop))
10726 (not (string-match "^#[ \t]*\\+property:"
10727 (org-current-line-string t))))
10728 (insert ":"))))
10729 (if (and (equal type :opt) (assoc completion table))
10730 (message "%s" (substitute-command-keys
10731 "Press \\[org-complete] again to insert example settings"))))
10732 (t
10733 (message "Making completion list...")
10734 (let ((list (sort (all-completions pattern table confirm)
10735 'string<)))
10736 (with-output-to-temp-buffer "*Completions*"
10737 (condition-case nil
10738 ;; Protection needed for XEmacs and emacs 21
10739 (display-completion-list list pattern)
10740 (error (display-completion-list list)))))
10741 (message "Making completion list...%s" "done")))))))
10742
10743;;;; TODO, DEADLINE, Comments 10665;;;; TODO, DEADLINE, Comments
10744 10666
10745(defun org-toggle-comment () 10667(defun org-toggle-comment ()
@@ -11962,13 +11884,13 @@ T Show entries with a specific TODO keyword.
11962m Show entries selected by a tags/property match. 11884m Show entries selected by a tags/property match.
11963p Enter a property name and its value (both with completion on existing 11885p Enter a property name and its value (both with completion on existing
11964 names/values) and show entries with that property. 11886 names/values) and show entries with that property.
11965/ Show entries matching a regular expression (`r' can be used as well) 11887r Show entries matching a regular expression (`/' can be used as well)
11966d Show deadlines due within `org-deadline-warning-days'. 11888d Show deadlines due within `org-deadline-warning-days'.
11967b Show deadlines and scheduled items before a date. 11889b Show deadlines and scheduled items before a date.
11968a Show deadlines and scheduled items after a date." 11890a Show deadlines and scheduled items after a date."
11969 (interactive "P") 11891 (interactive "P")
11970 (let (ans kwd value) 11892 (let (ans kwd value)
11971 (message "Sparse tree: [/]regexp [t]odo [T]odo-kwd [m]atch [p]roperty [d]eadlines\n [b]efore-date [a]fter-date") 11893 (message "Sparse tree: [r]egexp [/]regexp [t]odo [T]odo-kwd [m]atch [p]roperty\n [d]eadlines [b]efore-date [a]fter-date")
11972 (setq ans (read-char-exclusive)) 11894 (setq ans (read-char-exclusive))
11973 (cond 11895 (cond
11974 ((equal ans ?d) 11896 ((equal ans ?d)
@@ -12213,11 +12135,13 @@ ACTION can be `set', `up', `down', or a character."
12213 12135
12214(defun org-get-priority (s) 12136(defun org-get-priority (s)
12215 "Find priority cookie and return priority." 12137 "Find priority cookie and return priority."
12216 (save-match-data 12138 (if (functionp org-get-priority-function)
12217 (if (not (string-match org-priority-regexp s)) 12139 (funcall org-get-priority-function)
12218 (* 1000 (- org-lowest-priority org-default-priority)) 12140 (save-match-data
12219 (* 1000 (- org-lowest-priority 12141 (if (not (string-match org-priority-regexp s))
12220 (string-to-char (match-string 2 s))))))) 12142 (* 1000 (- org-lowest-priority org-default-priority))
12143 (* 1000 (- org-lowest-priority
12144 (string-to-char (match-string 2 s))))))))
12221 12145
12222;;;; Tags 12146;;;; Tags
12223 12147
@@ -12458,7 +12382,7 @@ also TODO lines."
12458 minus tag mm 12382 minus tag mm
12459 tagsmatch todomatch tagsmatcher todomatcher kwd matcher 12383 tagsmatch todomatch tagsmatcher todomatcher kwd matcher
12460 orterms term orlist re-p str-p level-p level-op time-p 12384 orterms term orlist re-p str-p level-p level-op time-p
12461 prop-p pn pv po cat-p gv rest) 12385 prop-p pn pv po gv rest)
12462 (if (string-match "/+" match) 12386 (if (string-match "/+" match)
12463 ;; match contains also a todo-matching request 12387 ;; match contains also a todo-matching request
12464 (progn 12388 (progn
@@ -12498,7 +12422,6 @@ also TODO lines."
12498 (setq pn (match-string 5 term) 12422 (setq pn (match-string 5 term)
12499 po (match-string 6 term) 12423 po (match-string 6 term)
12500 pv (match-string 7 term) 12424 pv (match-string 7 term)
12501 cat-p (equal pn "CATEGORY")
12502 re-p (equal (string-to-char pv) ?{) 12425 re-p (equal (string-to-char pv) ?{)
12503 str-p (equal (string-to-char pv) ?\") 12426 str-p (equal (string-to-char pv) ?\")
12504 time-p (save-match-data 12427 time-p (save-match-data
@@ -13459,7 +13382,7 @@ if the property key was used several times.
13459POM may also be nil, in which case the current entry is used. 13382POM may also be nil, in which case the current entry is used.
13460If WHICH is nil or `all', get all properties. If WHICH is 13383If WHICH is nil or `all', get all properties. If WHICH is
13461`special' or `standard', only get that subclass. If WHICH 13384`special' or `standard', only get that subclass. If WHICH
13462is a string only get exactly this property. Specific can be a string, the 13385is a string only get exactly this property. SPECIFIC can be a string, the
13463specific property we are interested in. Specifying it can speed 13386specific property we are interested in. Specifying it can speed
13464things up because then unnecessary parsing is avoided." 13387things up because then unnecessary parsing is avoided."
13465 (setq which (or which 'all)) 13388 (setq which (or which 'all))
@@ -15025,7 +14948,7 @@ D may be an absolute day number, or a calendar-type list (month day year)."
15025 (org-current-line) 14948 (org-current-line)
15026 (buffer-file-name) sexp) 14949 (buffer-file-name) sexp)
15027 (sleep-for 2)))))) 14950 (sleep-for 2))))))
15028 (cond ((stringp result) result) 14951 (cond ((stringp result) (split-string result "; "))
15029 ((and (consp result) 14952 ((and (consp result)
15030 (not (consp (cdr result))) 14953 (not (consp (cdr result)))
15031 (stringp (cdr result))) (cdr result)) 14954 (stringp (cdr result))) (cdr result))
@@ -16285,9 +16208,9 @@ BEG and END default to the buffer boundaries."
16285(org-defkey org-mode-map "\C-i" 'org-cycle) 16208(org-defkey org-mode-map "\C-i" 'org-cycle)
16286(org-defkey org-mode-map [(tab)] 'org-cycle) 16209(org-defkey org-mode-map [(tab)] 'org-cycle)
16287(org-defkey org-mode-map [(control tab)] 'org-force-cycle-archived) 16210(org-defkey org-mode-map [(control tab)] 'org-force-cycle-archived)
16288(org-defkey org-mode-map [(meta tab)] 'org-complete) 16211(org-defkey org-mode-map [(meta tab)] 'pcomplete)
16289(org-defkey org-mode-map "\M-\t" 'org-complete) 16212(org-defkey org-mode-map "\M-\t" 'pcomplete)
16290(org-defkey org-mode-map "\M-\C-i" 'org-complete) 16213(org-defkey org-mode-map "\M-\C-i" 'pcomplete)
16291;; The following line is necessary under Suse GNU/Linux 16214;; The following line is necessary under Suse GNU/Linux
16292(unless (featurep 'xemacs) 16215(unless (featurep 'xemacs)
16293 (org-defkey org-mode-map [S-iso-lefttab] 'org-shifttab)) 16216 (org-defkey org-mode-map [S-iso-lefttab] 'org-shifttab))
@@ -16352,7 +16275,7 @@ BEG and END default to the buffer boundaries."
16352 (org-defkey org-mode-map [?\C-c (right)] 'org-shiftright) 16275 (org-defkey org-mode-map [?\C-c (right)] 'org-shiftright)
16353 (org-defkey org-mode-map [?\C-c ?\C-x (right)] 'org-shiftcontrolright) 16276 (org-defkey org-mode-map [?\C-c ?\C-x (right)] 'org-shiftcontrolright)
16354 (org-defkey org-mode-map [?\C-c ?\C-x (left)] 'org-shiftcontrolleft) 16277 (org-defkey org-mode-map [?\C-c ?\C-x (left)] 'org-shiftcontrolleft)
16355 (org-defkey org-mode-map [?\e (tab)] 'org-complete) 16278 (org-defkey org-mode-map [?\e (tab)] 'pcomplete)
16356 (org-defkey org-mode-map [?\e (shift return)] 'org-insert-todo-heading) 16279 (org-defkey org-mode-map [?\e (shift return)] 'org-insert-todo-heading)
16357 (org-defkey org-mode-map [?\e (shift left)] 'org-shiftmetaleft) 16280 (org-defkey org-mode-map [?\e (shift left)] 'org-shiftmetaleft)
16358 (org-defkey org-mode-map [?\e (shift right)] 'org-shiftmetaright) 16281 (org-defkey org-mode-map [?\e (shift right)] 'org-shiftmetaright)
@@ -16433,6 +16356,7 @@ BEG and END default to the buffer boundaries."
16433(org-defkey org-mode-map "\C-c\C-xf" 'org-footnote-action) 16356(org-defkey org-mode-map "\C-c\C-xf" 'org-footnote-action)
16434(org-defkey org-mode-map "\C-c\C-x\C-mg" 'org-mobile-pull) 16357(org-defkey org-mode-map "\C-c\C-x\C-mg" 'org-mobile-pull)
16435(org-defkey org-mode-map "\C-c\C-x\C-mp" 'org-mobile-push) 16358(org-defkey org-mode-map "\C-c\C-x\C-mp" 'org-mobile-push)
16359(org-defkey org-mode-map "\C-c@" 'org-mark-subtree)
16436(org-defkey org-mode-map [?\C-c (control ?*)] 'org-list-make-subtree) 16360(org-defkey org-mode-map [?\C-c (control ?*)] 'org-list-make-subtree)
16437;;(org-defkey org-mode-map [?\C-c (control ?-)] 'org-list-make-list-from-subtree) 16361;;(org-defkey org-mode-map [?\C-c (control ?-)] 'org-list-make-list-from-subtree)
16438 16362
@@ -16506,7 +16430,7 @@ BEG and END default to the buffer boundaries."
16506 ("^" . org-sort) 16430 ("^" . org-sort)
16507 ("w" . org-refile) 16431 ("w" . org-refile)
16508 ("a" . org-archive-subtree-default-with-confirmation) 16432 ("a" . org-archive-subtree-default-with-confirmation)
16509 ("." . outline-mark-subtree) 16433 ("." . org-mark-subtree)
16510 ("Clock Commands") 16434 ("Clock Commands")
16511 ("I" . org-clock-in) 16435 ("I" . org-clock-in)
16512 ("O" . org-clock-out) 16436 ("O" . org-clock-out)
@@ -17246,11 +17170,13 @@ When in an #+include line, visit the include file. Otherwise call
17246 ((org-edit-fixed-width-region)) 17170 ((org-edit-fixed-width-region))
17247 ((org-at-table.el-p) 17171 ((org-at-table.el-p)
17248 (org-edit-src-code)) 17172 (org-edit-src-code))
17249 ((org-at-table-p) 17173 ((or (org-at-table-p)
17174 (save-excursion
17175 (beginning-of-line 1)
17176 (looking-at "[ \t]*#\\+TBLFM:")))
17250 (call-interactively 'org-table-edit-formulas)) 17177 (call-interactively 'org-table-edit-formulas))
17251 (t (call-interactively 'ffap)))) 17178 (t (call-interactively 'ffap))))
17252 17179
17253
17254(defun org-ctrl-c-ctrl-c (&optional arg) 17180(defun org-ctrl-c-ctrl-c (&optional arg)
17255 "Set tags in headline, or update according to changed information at point. 17181 "Set tags in headline, or update according to changed information at point.
17256 17182
@@ -17324,7 +17250,8 @@ This command does many different things, depending on context:
17324 (if arg 17250 (if arg
17325 (call-interactively 'org-table-recalculate) 17251 (call-interactively 'org-table-recalculate)
17326 (org-table-maybe-recalculate-line)) 17252 (org-table-maybe-recalculate-line))
17327 (call-interactively 'org-table-align)) 17253 (call-interactively 'org-table-align)
17254 (orgtbl-send-table 'maybe))
17328 ((or (org-footnote-at-reference-p) 17255 ((or (org-footnote-at-reference-p)
17329 (org-footnote-at-definition-p)) 17256 (org-footnote-at-definition-p))
17330 (call-interactively 'org-footnote-action)) 17257 (call-interactively 'org-footnote-action))
@@ -17681,7 +17608,7 @@ See the individual commands for more information."
17681 ("Select keyword" 17608 ("Select keyword"
17682 ["Next keyword" org-shiftright (org-on-heading-p)] 17609 ["Next keyword" org-shiftright (org-on-heading-p)]
17683 ["Previous keyword" org-shiftleft (org-on-heading-p)] 17610 ["Previous keyword" org-shiftleft (org-on-heading-p)]
17684 ["Complete Keyword" org-complete (assq :todo-keyword (org-context))] 17611 ["Complete Keyword" pcomplete (assq :todo-keyword (org-context))]
17685 ["Next keyword set" org-shiftcontrolright (and (> (length org-todo-sets) 1) (org-on-heading-p))] 17612 ["Next keyword set" org-shiftcontrolright (and (> (length org-todo-sets) 1) (org-on-heading-p))]
17686 ["Previous keyword set" org-shiftcontrolright (and (> (length org-todo-sets) 1) (org-on-heading-p))]) 17613 ["Previous keyword set" org-shiftcontrolright (and (> (length org-todo-sets) 1) (org-on-heading-p))])
17687 ["Show TODO Tree" org-show-todo-tree :active t :keys "C-c / t"] 17614 ["Show TODO Tree" org-show-todo-tree :active t :keys "C-c / t"]
@@ -18066,6 +17993,23 @@ upon the next fontification round."
18066 (setq l (- l (get-text-property b 'org-dwidth-n s)))) 17993 (setq l (- l (get-text-property b 'org-dwidth-n s))))
18067 l)) 17994 l))
18068 17995
17996(defun org-shorten-string (s maxlength)
17997 "Shorten string S so tht it is no longer than MAXLENGTH characters.
17998If the string is shorter or has length MAXLENGTH, just return the
17999original string. If it is longer, the functions finds a space in the
18000string, breaks this string off at that locations and adds three dots
18001as ellipsis. Including the ellipsis, the string will not be longer
18002than MAXLENGTH. If finding a good breaking point in the string does
18003not work, the string is just chopped off in the middle of a word
18004if necessary."
18005 (if (<= (length s) maxlength)
18006 s
18007 (let* ((n (max (- maxlength 4) 1))
18008 (re (concat "\\`\\(.\\{1," (int-to-string n) "\\}[^ ]\\)\\([ ]\\|\\'\\)")))
18009 (if (string-match re s)
18010 (concat (match-string 1 s) "...")
18011 (concat (substring s 0 (max (- maxlength 3) 0)) "...")))))
18012
18069(defun org-get-indentation (&optional line) 18013(defun org-get-indentation (&optional line)
18070 "Get the indentation of the current line, interpreting tabs. 18014 "Get the indentation of the current line, interpreting tabs.
18071When LINE is given, assume it represents a line and compute its indentation." 18015When LINE is given, assume it represents a line and compute its indentation."
@@ -18636,11 +18580,36 @@ which make use of the date at the cursor."
18636 (message 18580 (message
18637 "Entry marked for action; press `k' at desired date in agenda or calendar")) 18581 "Entry marked for action; press `k' at desired date in agenda or calendar"))
18638 18582
18583(defun org-mark-subtree ()
18584 "Mark the current subtree.
18585This puts point at the start of the current subtree, and mark at the end.
18586
18587If point is in an inline task, mark that task instead."
18588 (interactive)
18589 (let ((inline-task-p
18590 (and (featurep 'org-inlinetask)
18591 (org-inlinetask-in-task-p)))
18592 (beg))
18593 ;; Get beginning of subtree
18594 (cond
18595 (inline-task-p (org-inlinetask-goto-beginning))
18596 ((org-at-heading-p) (beginning-of-line))
18597 (t (let ((outline-regexp (org-get-limited-outline-regexp)))
18598 (outline-previous-visible-heading 1))))
18599 (setq beg (point))
18600 ;; Get end of it
18601 (if inline-task-p
18602 (org-inlinetask-goto-end)
18603 (org-end-of-subtree))
18604 ;; Mark zone
18605 (push-mark (point) nil t)
18606 (goto-char beg)))
18607
18639;;; Paragraph filling stuff. 18608;;; Paragraph filling stuff.
18640;; We want this to be just right, so use the full arsenal. 18609;; We want this to be just right, so use the full arsenal.
18641 18610
18642(defun org-indent-line-function () 18611(defun org-indent-line-function ()
18643 "Indent line like previous, but further if previous was headline or item." 18612 "Indent line depending on context."
18644 (interactive) 18613 (interactive)
18645 (let* ((pos (point)) 18614 (let* ((pos (point))
18646 (itemp (org-at-item-p)) 18615 (itemp (org-at-item-p))
@@ -18648,14 +18617,16 @@ which make use of the date at the cursor."
18648 (org-drawer-regexp (or org-drawer-regexp "\000")) 18617 (org-drawer-regexp (or org-drawer-regexp "\000"))
18649 (inline-task-p (and (featurep 'org-inlinetask) 18618 (inline-task-p (and (featurep 'org-inlinetask)
18650 (org-inlinetask-in-task-p))) 18619 (org-inlinetask-in-task-p)))
18651 column bpos bcol tpos tcol bullet btype bullet-type) 18620 column bpos bcol tpos tcol)
18652 ;; Find the previous relevant line
18653 (beginning-of-line 1) 18621 (beginning-of-line 1)
18654 (cond 18622 (cond
18655 ;; Comments 18623 ;; Comments
18656 ((looking-at "#") (setq column 0)) 18624 ((looking-at "# ") (setq column 0))
18657 ;; Headings 18625 ;; Headings
18658 ((looking-at "\\*+ ") (setq column 0)) 18626 ((looking-at "\\*+ ") (setq column 0))
18627 ;; Literal examples
18628 ((looking-at "[ \t]*:[ \t]")
18629 (setq column (org-get-indentation))) ; do nothing
18659 ;; Drawers 18630 ;; Drawers
18660 ((and (looking-at "[ \t]*:END:") 18631 ((and (looking-at "[ \t]*:END:")
18661 (save-excursion (re-search-backward org-drawer-regexp nil t))) 18632 (save-excursion (re-search-backward org-drawer-regexp nil t)))
@@ -18683,36 +18654,29 @@ which make use of the date at the cursor."
18683 (looking-at "[ \t]*\\(\\S-+\\)[ \t]*\\(\\(:?\\[@\\(:?start:\\)?[0-9]+\\][ \t]*\\)?\\[[- X]\\][ \t]*\\|.*? :: \\)?") 18654 (looking-at "[ \t]*\\(\\S-+\\)[ \t]*\\(\\(:?\\[@\\(:?start:\\)?[0-9]+\\][ \t]*\\)?\\[[- X]\\][ \t]*\\|.*? :: \\)?")
18684 (setq bpos (match-beginning 1) tpos (match-end 0) 18655 (setq bpos (match-beginning 1) tpos (match-end 0)
18685 bcol (progn (goto-char bpos) (current-column)) 18656 bcol (progn (goto-char bpos) (current-column))
18686 tcol (progn (goto-char tpos) (current-column)) 18657 tcol (progn (goto-char tpos) (current-column)))
18687 bullet (match-string 1)
18688 bullet-type (if (string-match "[0-9]" bullet) "n" bullet))
18689 (if (> tcol (+ bcol org-description-max-indent)) 18658 (if (> tcol (+ bcol org-description-max-indent))
18690 (setq tcol (+ bcol 5))) 18659 (setq tcol (+ bcol 5)))
18691 (if (not itemp) 18660 (goto-char pos)
18692 (setq column tcol) 18661 (setq column (if itemp (org-get-indentation) tcol)))
18693 (beginning-of-line 1) 18662 ;; This line has nothing special, look at the previous relevant
18694 (goto-char pos) 18663 ;; line to compute indentation
18695 (if (looking-at "\\S-")
18696 (progn
18697 (looking-at "[ \t]*\\(\\S-+\\)[ \t]*")
18698 (setq bullet (match-string 1)
18699 btype (if (string-match "[0-9]" bullet) "n" bullet))
18700 (setq column (if (equal btype bullet-type) bcol tcol)))
18701 (setq column (org-get-indentation)))))
18702 ;; This line has nothing special, look upside to get a clue about
18703 ;; what to do.
18704 (t 18664 (t
18705 (beginning-of-line 0) 18665 (beginning-of-line 0)
18706 (while (and (not (bobp)) 18666 (while (and (not (bobp))
18667 (not (looking-at org-drawer-regexp))
18707 ;; skip comments, verbatim, empty lines, tables, 18668 ;; skip comments, verbatim, empty lines, tables,
18708 ;; inline tasks 18669 ;; inline tasks, lists, drawers and blocks
18709 (or (looking-at "[ \t]*[\n:#|]") 18670 (or (and (looking-at "[ \t]*:END:")
18671 (re-search-backward org-drawer-regexp nil t))
18672 (and (looking-at "[ \t]*#\\+end_")
18673 (re-search-backward "[ \t]*#\\+begin_"nil t))
18674 (looking-at "[ \t]*[\n:#|]")
18710 (and (org-in-item-p) (goto-char (org-list-top-point))) 18675 (and (org-in-item-p) (goto-char (org-list-top-point)))
18711 (and (not inline-task-p) 18676 (and (not inline-task-p)
18712 (featurep 'org-inlinetask) 18677 (featurep 'org-inlinetask)
18713 (org-inlinetask-in-task-p))) 18678 (org-inlinetask-in-task-p)
18714 (not (looking-at "[ \t]*:END:")) 18679 (or (org-inlinetask-goto-beginning) t))))
18715 (not (looking-at org-drawer-regexp)))
18716 (beginning-of-line 0)) 18680 (beginning-of-line 0))
18717 (cond 18681 (cond
18718 ;; There was an heading above. 18682 ;; There was an heading above.
@@ -18721,20 +18685,18 @@ which make use of the date at the cursor."
18721 (setq column 0) 18685 (setq column 0)
18722 (goto-char (match-end 0)) 18686 (goto-char (match-end 0))
18723 (setq column (current-column)))) 18687 (setq column (current-column))))
18724 ;; A drawer had started and is unfinished: indent consequently. 18688 ;; A drawer had started and is unfinished
18725 ((looking-at org-drawer-regexp) 18689 ((looking-at org-drawer-regexp)
18726 (goto-char (1- (match-beginning 1))) 18690 (goto-char (1- (match-beginning 1)))
18727 (setq column (current-column))) 18691 (setq column (current-column)))
18728 ;; The drawer had ended: indent like its :END: line.
18729 ((looking-at "\\([ \t]*\\):END:")
18730 (goto-char (match-end 1))
18731 (setq column (current-column)))
18732 ;; Else, nothing noticeable found: get indentation and go on. 18692 ;; Else, nothing noticeable found: get indentation and go on.
18733 (t (setq column (org-get-indentation)))))) 18693 (t (setq column (org-get-indentation))))))
18694 ;; Now apply indentation and move cursor accordingly
18734 (goto-char pos) 18695 (goto-char pos)
18735 (if (<= (current-column) (current-indentation)) 18696 (if (<= (current-column) (current-indentation))
18736 (org-indent-line-to column) 18697 (org-indent-line-to column)
18737 (save-excursion (org-indent-line-to column))) 18698 (save-excursion (org-indent-line-to column)))
18699 ;; Special polishing for properties, see `org-property-format'
18738 (setq column (current-column)) 18700 (setq column (current-column))
18739 (beginning-of-line 1) 18701 (beginning-of-line 1)
18740 (if (looking-at 18702 (if (looking-at
@@ -19005,8 +18967,6 @@ beyond the end of the headline."
19005 18967
19006(define-key org-mode-map "\C-a" 'org-beginning-of-line) 18968(define-key org-mode-map "\C-a" 'org-beginning-of-line)
19007(define-key org-mode-map "\C-e" 'org-end-of-line) 18969(define-key org-mode-map "\C-e" 'org-end-of-line)
19008(define-key org-mode-map [home] 'org-beginning-of-line)
19009(define-key org-mode-map [end] 'org-end-of-line)
19010 18970
19011(defun org-backward-sentence (&optional arg) 18971(defun org-backward-sentence (&optional arg)
19012 "Go to beginning of sentence, or beginning of table field. 18972 "Go to beginning of sentence, or beginning of table field.