diff options
| author | Carsten Dominik | 2010-11-11 22:10:19 -0600 |
|---|---|---|
| committer | Carsten Dominik | 2010-11-11 22:10:19 -0600 |
| commit | afe98dfa700de5cf0493e8bf95b7d894e2734e47 (patch) | |
| tree | 92a812b353bb09c1286e8a44fb552de9f1af3384 /lisp/org | |
| parent | df26e1f58a7e484b7ed500ea48d0e1c49345ffbf (diff) | |
| download | emacs-afe98dfa700de5cf0493e8bf95b7d894e2734e47.tar.gz emacs-afe98dfa700de5cf0493e8bf95b7d894e2734e47.zip | |
Install org-mode version 7.3
Diffstat (limited to 'lisp/org')
96 files changed, 10560 insertions, 3650 deletions
diff --git a/lisp/org/ChangeLog b/lisp/org/ChangeLog index aaa356f8769..90bf8e56a9b 100644 --- a/lisp/org/ChangeLog +++ b/lisp/org/ChangeLog | |||
| @@ -1,3 +1,3336 @@ | |||
| 1 | 2010-11-11 Dan Davison <dandavison7@gmail.com> | ||
| 2 | |||
| 3 | * ob.el: `copy-sequence' suffices to copy alist; no need for | ||
| 4 | `copy-tree'. | ||
| 5 | |||
| 6 | 2010-11-11 Dan Davison <dandavison7@gmail.com> | ||
| 7 | |||
| 8 | * ob.el (org-babel-execute-src-block): If ":results file" is in | ||
| 9 | effect, then ensure that the value of :file is returned as the | ||
| 10 | result; don't rely on language files for this. | ||
| 11 | |||
| 12 | 2010-11-11 Dan Davison <dandavison7@gmail.com> | ||
| 13 | |||
| 14 | * ob.el (org-babel-sha1-hash): Avoid corrupting `info' data | ||
| 15 | structure by side-effects of `sort'. | ||
| 16 | |||
| 17 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 18 | |||
| 19 | * org-list.el (org-list-bottom-point-with-indent): Do not check | ||
| 20 | indentation of a non-empty blank line. | ||
| 21 | |||
| 22 | * org-list.el (org-sort-list): Sort a list with point anywhere | ||
| 23 | inside it. | ||
| 24 | |||
| 25 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 26 | |||
| 27 | * ob-calc.el (org-babel-execute:calc): Safer evaluation and | ||
| 28 | hopefully better error messages. | ||
| 29 | |||
| 30 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 31 | |||
| 32 | * org.el (org-babel-load-languages): Adding calc. | ||
| 33 | |||
| 34 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 35 | |||
| 36 | * ob.el (org-babel-initiate-session): Don't resolve variable | ||
| 37 | references unless prefix arg is supplied. | ||
| 38 | |||
| 39 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 40 | |||
| 41 | * ob-calc.el (org-babel-execute:calc): Ensure that calc stack | ||
| 42 | refers to the correct stack. | ||
| 43 | |||
| 44 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 45 | |||
| 46 | * ob-calc.el: Adding the beginnings of support for calc code | ||
| 47 | blocks. | ||
| 48 | |||
| 49 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 50 | |||
| 51 | * ob-tangle.el (org-babel-update-block-body): Declaring function | ||
| 52 | for updating code block bodies. | ||
| 53 | (org-babel-spec-to-string): | ||
| 54 | (org-babel-detangle): Detangle all tangled and commented code | ||
| 55 | blocks in the current file back to org. | ||
| 56 | (org-babel-tangle-jump-to-org): Jump from a tangled and commented | ||
| 57 | file back to the originating org-mode code block ob-tangle: | ||
| 58 | detangle changes in code files back to the original org files. | ||
| 59 | |||
| 60 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 61 | |||
| 62 | * ob-tangle.el (org-babel-tangle-comment-format-beg): Fix typo. | ||
| 63 | (org-babel-tangle-comment-format-end): Fix typo. | ||
| 64 | |||
| 65 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 66 | |||
| 67 | * org-exp.el (org-export-format-source-code-or-example): Use | ||
| 68 | minted for latex source code export if `org-export-latex-listings' | ||
| 69 | has the value 'minted | ||
| 70 | |||
| 71 | * org-latex.el (org-export-latex-listings): Document special value | ||
| 72 | 'minted | ||
| 73 | |||
| 74 | * org-latex.el (org-export-latex-minted): Delete variable. | ||
| 75 | |||
| 76 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 77 | |||
| 78 | * ob.el (org-babel-get-src-block-info): Retrieve contents of | ||
| 79 | parentheses, excluding parentheses themselves. | ||
| 80 | |||
| 81 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 82 | |||
| 83 | * ob-gnuplot.el (org-babel-variable-assignments:gnuplot): Fixed | ||
| 84 | bug in gnuplot data file assignment using user variables. | ||
| 85 | |||
| 86 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 87 | |||
| 88 | * ob-latex.el (org-babel-execute:latex): Adding new :headers | ||
| 89 | header argument for latex code blocks. | ||
| 90 | |||
| 91 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 92 | |||
| 93 | * org-capture.el (org-capture-templates): New capture property | ||
| 94 | `:kill-buffer'. (org-capture-finalize): Kill target buffer if that | ||
| 95 | is desired. | ||
| 96 | (org-capture-target-buffer): Remember if we have to make the | ||
| 97 | buffer. | ||
| 98 | |||
| 99 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 100 | |||
| 101 | * org-clock.el (org-dblock-write:clocktable): Fix bug when | ||
| 102 | computing clock tables. | ||
| 103 | |||
| 104 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 105 | |||
| 106 | * org-clock.el (org-dblock-write:clocktable): Pass file minutes up | ||
| 107 | to caller even if no table is generated. | ||
| 108 | |||
| 109 | 2010-11-11 Åukasz Stelmach <lukasz.stelmach@iem.pw.edu.pl> | ||
| 110 | |||
| 111 | * org-agenda.el (org-agenda-get-sexps): Handle lists as return | ||
| 112 | values from diary entries | ||
| 113 | |||
| 114 | * org-bbdb.el (org-bbdb-anniversaries): Handle lists of | ||
| 115 | anniversaries | ||
| 116 | |||
| 117 | * org.el (org-diary-sexp-entry): Handle lists as return values | ||
| 118 | from diary entries. | ||
| 119 | |||
| 120 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 121 | |||
| 122 | * org-capture.el (org-capture-empty-lines-before): | ||
| 123 | (org-capture-empty-lines-after): Make sure the n=0 does not insert | ||
| 124 | any newlines. | ||
| 125 | |||
| 126 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 127 | |||
| 128 | * ob-clojure.el (org-babel-clojure-babel-clojure-cmd): Fixed error | ||
| 129 | message when clojure binary is not found. | ||
| 130 | |||
| 131 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 132 | |||
| 133 | * org-html.el (org-format-table-html): New argument DOCBOOK. | ||
| 134 | (org-format-org-table-html): New argument DOCBOOK. When set, use | ||
| 135 | align instead of class to align table fields. | ||
| 136 | |||
| 137 | * org-docbook.el (org-export-as-docbook): Specify the docbook | ||
| 138 | argument for the table converter. | ||
| 139 | |||
| 140 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 141 | |||
| 142 | * org-macs.el (org-called-interactively-p): New macro. | ||
| 143 | |||
| 144 | * org-freemind.el: No longer require 'rx. | ||
| 145 | (org-freemind): New customization group, use it for all the | ||
| 146 | variables. | ||
| 147 | (org-export-as-freemind): Add docstring. | ||
| 148 | (org-freemind-show): Improve filen naming. | ||
| 149 | (org-freemind-convert-links-helper): New function. | ||
| 150 | (org-freemind-bol-helper-base-indent): New variable. | ||
| 151 | (org-freemind-bol-helper): New function. | ||
| 152 | (org-freemind-node-css-style): New option. | ||
| 153 | (org-freemind-node-pattern): New variable. | ||
| 154 | (org-freemind-from-org-mode): Better docstring. | ||
| 155 | |||
| 156 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 157 | |||
| 158 | * ob-haskell.el (org-babel-variable-assignments:haskell): Don't | ||
| 159 | pass more than two arguments to mapc. | ||
| 160 | |||
| 161 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 162 | |||
| 163 | * ob.el (org-babel-ref-resolve): Declare to silence byte compiler. | ||
| 164 | |||
| 165 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 166 | |||
| 167 | * org-footnote.el (message-signature-separator): Defvar to silence | ||
| 168 | byte compiler. | ||
| 169 | |||
| 170 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 171 | |||
| 172 | * org-exp.el (org-export-string): Fix reference to wrong symbol. | ||
| 173 | |||
| 174 | 2010-11-11 Jambunathan K <kjambunathan@gmail.com> | ||
| 175 | |||
| 176 | * org.el (org-link-search): Return 'dedicated on successful match | ||
| 177 | when org-link-search-must-match-exact-headline is set to t. | ||
| 178 | |||
| 179 | 2010-11-11 Daniel Clemente <n142857@gmail.com> | ||
| 180 | |||
| 181 | * org-html.el (org-html-make-link): Append fragment to file: links | ||
| 182 | if present. | ||
| 183 | |||
| 184 | 2010-11-11 Tassilo Horn <tassilo@member.fsf.org> | ||
| 185 | |||
| 186 | * org-footnote.el (org-footnote-create-definition) | ||
| 187 | (org-footnote-goto-local-insertion-point): Add footnotes before | ||
| 188 | signature when in message-mode. | ||
| 189 | |||
| 190 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 191 | |||
| 192 | * org.el (org-display-inline-images): Improve regexp. | ||
| 193 | |||
| 194 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 195 | |||
| 196 | * org.el (org-cycle): Make sure resetting to startup visibility | ||
| 197 | works after another cycle command. | ||
| 198 | |||
| 199 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 200 | |||
| 201 | * org-exp.el (org-export-string): New function org-export-string | ||
| 202 | can be used to convert a string of test in org-mode markup to a | ||
| 203 | specified format. | ||
| 204 | |||
| 205 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 206 | |||
| 207 | * org.el (org-display-inline-images): Allow non-ASCII characters | ||
| 208 | in image file names. Save match data. | ||
| 209 | |||
| 210 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 211 | |||
| 212 | * org.el (org-auto-repeat-maybe): Fix shifting multiple time | ||
| 213 | stamps. | ||
| 214 | |||
| 215 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 216 | |||
| 217 | * org-exp.el (org-store-forced-table-alignment): | ||
| 218 | (org-export-remove-special-table-lines): Allow the "c" cookie for | ||
| 219 | table alignment. | ||
| 220 | |||
| 221 | * org-html.el (org-export-table-header-tags): | ||
| 222 | (org-export-table-data-tags): Add another %s format for the | ||
| 223 | alignment. | ||
| 224 | (org-export-html-table-align-individual-fields): New option. | ||
| 225 | (org-format-org-table-html): Implement field-by-field alignment | ||
| 226 | and support centering. | ||
| 227 | (org-format-table-table-html): Make sure the new table tag formats | ||
| 228 | don't break this function. | ||
| 229 | |||
| 230 | * org-table.el (org-table-cookie-line-p): | ||
| 231 | (org-table-align): Allow for the <c> cookie. | ||
| 232 | |||
| 233 | * org.el (org-set-font-lock-defaults): Allow for the <c> cookie. | ||
| 234 | |||
| 235 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 236 | |||
| 237 | * org-exp.el (org-export-normalize-links): Skip normalization of | ||
| 238 | plain links that are part of another link. | ||
| 239 | |||
| 240 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 241 | |||
| 242 | * ob-R.el (org-babel-expand-body:R): Fix bug in let binding. | ||
| 243 | |||
| 244 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 245 | |||
| 246 | * org-indent.el: (org-indent-add-properties): Use | ||
| 247 | `with-silent-modificaitons'. | ||
| 248 | (org-indent-remove-properties): Use `with-silent-modificaitons'. | ||
| 249 | |||
| 250 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 251 | |||
| 252 | * org-table.el (org-table-cookie-line-p): Fix indentation. | ||
| 253 | |||
| 254 | * org-exp.el (org-store-forced-table-alignment): New function. | ||
| 255 | (org-export-preprocess-string): Call | ||
| 256 | `org-store-forced-table-alignment'. | ||
| 257 | |||
| 258 | * org-html.el (org-format-org-table-html): Use stored alignment | ||
| 259 | information. | ||
| 260 | |||
| 261 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 262 | |||
| 263 | * ob.el (org-babel-execute-src-block): Respects prefix argument | ||
| 264 | (which forces re-calculation). | ||
| 265 | |||
| 266 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 267 | |||
| 268 | * ob.el (org-babel-execute-src-block): Removed needless param | ||
| 269 | sorting from ob-execute-src-block, the params are sorted already | ||
| 270 | by ob-sha1-hash. | ||
| 271 | |||
| 272 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 273 | |||
| 274 | * ob.el (org-babel-sha1-hash): Ensure that info is sorted at the | ||
| 275 | header argument level. | ||
| 276 | |||
| 277 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 278 | |||
| 279 | * ob.el (org-babel-sha1-hash): Consider words in different order | ||
| 280 | as different input. | ||
| 281 | |||
| 282 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 283 | |||
| 284 | * ob.el (org-babel-sha1-hash): Fix check for zero length sequences. | ||
| 285 | |||
| 286 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 287 | |||
| 288 | * ob-sh.el (org-babel-sh-var-to-sh): Ensure value has the | ||
| 289 | structure of an Org-mode table (list of lists). | ||
| 290 | |||
| 291 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 292 | |||
| 293 | * ob-tangle.el (org-babel-tangle-collect-blocks): Fix bug | ||
| 294 | (reference to unassigned variable `src-lang' and avoid calling | ||
| 295 | org-babel-get-src-block-info twice. | ||
| 296 | |||
| 297 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 298 | |||
| 299 | * ob.el (org-babel-demarcate-block): Updated to reflect the new | ||
| 300 | info list contents. | ||
| 301 | |||
| 302 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 303 | |||
| 304 | * org-src.el (org-edit-src-code): Supply non-nil argument to | ||
| 305 | `org-babel-get-src-block-info' to avoid resolving variable | ||
| 306 | references. | ||
| 307 | |||
| 308 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 309 | |||
| 310 | * ob.el (org-babel-map-src-blocks): Fixed minor bug in and | ||
| 311 | improved efficiency of org-babel-map-src-blocks. | ||
| 312 | |||
| 313 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 314 | |||
| 315 | * ob-tangle.el (org-babel-tangle-collect-blocks): Now explicitly | ||
| 316 | checks that a code block will actually be tangled before | ||
| 317 | collecting it's full information (a process which could involve | ||
| 318 | the execution of other code blocks). | ||
| 319 | |||
| 320 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 321 | |||
| 322 | * ob.el (org-babel-demarcate-block): Use light version of | ||
| 323 | `org-babel-get-src-block-info'. | ||
| 324 | |||
| 325 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 326 | |||
| 327 | * ob.el (org-babel-sha1-hash): Now handles more complex types in | ||
| 328 | params. | ||
| 329 | |||
| 330 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 331 | |||
| 332 | * ob.el (org-babel-execute-src-block): Generally using the new | ||
| 333 | more informative params | ||
| 334 | (org-babel-process-params): Don't forget the :var portion of | ||
| 335 | variable assignments. | ||
| 336 | |||
| 337 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 338 | |||
| 339 | * ob-table.el (sbe): Simplified to reflect to var resolution. | ||
| 340 | |||
| 341 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 342 | |||
| 343 | * ob-ref.el (org-babel-ref-resolve): Bringing the referent | ||
| 344 | arguments back to their params before evaluation. | ||
| 345 | |||
| 346 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 347 | |||
| 348 | * ob-ref.el (org-babel-ref-resolve): Cleanup of variable usage and | ||
| 349 | indentation. | ||
| 350 | |||
| 351 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 352 | |||
| 353 | * ob-table.el (sbe): Use `org-babel-process-params params' instead | ||
| 354 | of `org-babel-expand-variables'. | ||
| 355 | |||
| 356 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 357 | |||
| 358 | * ob-C.el (org-babel-C-execute): Remove call to | ||
| 359 | org-babel-process-params which should no longer be called from | ||
| 360 | within a language file | ||
| 361 | |||
| 362 | * ob-R.el (org-babel-execute:R): Remove call to | ||
| 363 | org-babel-process-params which should no longer be called from | ||
| 364 | within a language file | ||
| 365 | (org-babel-R-variable-assignments): Remove call to | ||
| 366 | org-babel-process-params which should no longer be called from | ||
| 367 | within a language file | ||
| 368 | |||
| 369 | * ob-asymptote.el (org-babel-execute:asymptote): Remove call to | ||
| 370 | org-babel-process-params which should no longer be called from | ||
| 371 | within a language file | ||
| 372 | |||
| 373 | * ob-clojure.el (org-babel-execute:clojure): Remove call to | ||
| 374 | org-babel-process-params which should no longer be called from | ||
| 375 | within a language file | ||
| 376 | |||
| 377 | * ob-dot.el (org-babel-execute:dot): Remove call to | ||
| 378 | org-babel-process-params which should no longer be called from | ||
| 379 | within a language file | ||
| 380 | |||
| 381 | * ob-emacs-lisp.el (org-babel-expand-body:emacs-lisp): Remove | ||
| 382 | call to org-babel-process-params which should no longer be called | ||
| 383 | from within a language file | ||
| 384 | (org-babel-execute:emacs-lisp): Remove call to | ||
| 385 | org-babel-process-params which should no longer be called from | ||
| 386 | within a language file | ||
| 387 | |||
| 388 | * ob-haskell.el (org-babel-execute:haskell): Remove call to | ||
| 389 | org-babel-process-params which should no longer be called from | ||
| 390 | within a language file | ||
| 391 | |||
| 392 | * ob-js.el (org-babel-execute:js): Remove call to | ||
| 393 | org-babel-process-params which should no longer be called from | ||
| 394 | within a language file | ||
| 395 | |||
| 396 | * ob-lisp.el (org-babel-execute:lisp): Remove call to | ||
| 397 | org-babel-process-params which should no longer be called from | ||
| 398 | within a language file | ||
| 399 | |||
| 400 | * ob-ocaml.el (org-babel-execute:ocaml): Remove call to | ||
| 401 | org-babel-process-params which should no longer be called from | ||
| 402 | within a language file | ||
| 403 | |||
| 404 | * ob-octave.el (org-babel-execute:octave): Remove call to | ||
| 405 | org-babel-process-params which should no longer be called from | ||
| 406 | within a language file | ||
| 407 | |||
| 408 | * ob-perl.el (org-babel-execute:perl): Remove call to | ||
| 409 | org-babel-process-params which should no longer be called from | ||
| 410 | within a language file | ||
| 411 | |||
| 412 | * ob-python.el (org-babel-execute:python): Remove call to | ||
| 413 | org-babel-process-params which should no longer be called from | ||
| 414 | within a language file | ||
| 415 | |||
| 416 | * ob-ruby.el (org-babel-execute:ruby): Remove call to | ||
| 417 | org-babel-process-params which should no longer be called from | ||
| 418 | within a language file | ||
| 419 | |||
| 420 | * ob-scheme.el (org-babel-execute:scheme): Remove call to | ||
| 421 | org-babel-process-params which should no longer be called from | ||
| 422 | within a language file | ||
| 423 | |||
| 424 | * ob-screen.el (org-babel-execute:screen): Remove call to | ||
| 425 | org-babel-process-params which should no longer be called from | ||
| 426 | within a language file | ||
| 427 | (org-babel-prep-session:screen): Remove call to | ||
| 428 | org-babel-process-params which should no longer be called from | ||
| 429 | within a language file | ||
| 430 | |||
| 431 | * ob-sh.el (org-babel-execute:sh): Remove call to | ||
| 432 | org-babel-process-params which should no longer be called from | ||
| 433 | within a language file | ||
| 434 | |||
| 435 | * ob-sql.el (org-babel-execute:sql): Remove call to | ||
| 436 | org-babel-process-params which should no longer be called from | ||
| 437 | within a language file | ||
| 438 | |||
| 439 | * ob-haskell.el (org-babel-execute:haskell): Remove reference to | ||
| 440 | processed params | ||
| 441 | |||
| 442 | * ob-clojure.el (org-babel-execute:clojure): Remove reference to | ||
| 443 | processed params | ||
| 444 | |||
| 445 | * ob-R.el (org-babel-execute:R): Remove reference to processed | ||
| 446 | params. | ||
| 447 | |||
| 448 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 449 | |||
| 450 | * ob-sql.el (org-babel-execute:sql): Use generic expansion | ||
| 451 | function | ||
| 452 | (org-babel-expand-body:sql): Delete function. | ||
| 453 | |||
| 454 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 455 | |||
| 456 | * ob-sh.el (org-babel-execute:sh): Use generic expansion function | ||
| 457 | (org-babel-expand-body:sh): Delete function | ||
| 458 | (org-babel-prep-session:sh): Change name of called function | ||
| 459 | (org-babel-variable-assignments:sh): Change function name. | ||
| 460 | |||
| 461 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 462 | |||
| 463 | * ob-screen.el (org-babel-execute:screen): Use generic expansion | ||
| 464 | function | ||
| 465 | (org-babel-expand-body:screen): Delete function | ||
| 466 | (org-babel-prep-session:screen): Remove references to processed | ||
| 467 | params. | ||
| 468 | |||
| 469 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 470 | |||
| 471 | * ob-sass.el (org-babel-execute:sass): Use generic expansion | ||
| 472 | function | ||
| 473 | (org-babel-expand-body:sass): Delete function. | ||
| 474 | |||
| 475 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 476 | |||
| 477 | * ob-ruby.el (org-babel-execute:ruby): Use generic expansion | ||
| 478 | function | ||
| 479 | (org-babel-prep-session:ruby): Use new variable assignment | ||
| 480 | function | ||
| 481 | (org-babel-variable-assignments:ruby): New function | ||
| 482 | (org-babel-expand-body:ruby): Delete function. | ||
| 483 | |||
| 484 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 485 | |||
| 486 | * ob-python.el (org-babel-execute:python): Use generic expansion | ||
| 487 | function | ||
| 488 | (org-babel-prep-session:python): Change name of called function | ||
| 489 | (org-babel-variable-assignments:python): Change function name | ||
| 490 | (org-babel-expand-body:python): Delete function. | ||
| 491 | |||
| 492 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 493 | |||
| 494 | * ob-plantuml.el (org-babel-expand-body:plantuml): Delete function | ||
| 495 | (automatically handled by generic version). | ||
| 496 | |||
| 497 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 498 | |||
| 499 | * ob-perl.el (org-babel-execute:perl): Use generic expansion | ||
| 500 | function | ||
| 501 | (org-babel-expand-body:perl): Delete function | ||
| 502 | (org-babel-variable-assignments:perl): New function. | ||
| 503 | |||
| 504 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 505 | |||
| 506 | * ob-org.el (org-babel-expand-body:org): Delete function | ||
| 507 | (automatically handled by generic version). | ||
| 508 | |||
| 509 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 510 | |||
| 511 | * ob-octave.el (org-babel-execute:octave): Use generic expansion | ||
| 512 | function | ||
| 513 | (org-babel-variable-assignments:octave): Change name of function | ||
| 514 | (org-babel-variable-assignments:matlab): New defalias | ||
| 515 | (org-babel-prep-session:octave): Change name of function | ||
| 516 | (org-babel-expand-body:matlab): Delete function | ||
| 517 | (org-babel-expand-body:octave): Delete function. | ||
| 518 | |||
| 519 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 520 | |||
| 521 | * ob-ocaml.el (org-babel-execute:ocaml): Use generic expansion | ||
| 522 | function | ||
| 523 | (org-babel-variable-assignments:ocaml): New function | ||
| 524 | (org-babel-expand-body:ocaml): Delete function. | ||
| 525 | |||
| 526 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 527 | |||
| 528 | * ob-mscgen.el (org-babel-expand-body:mscgen): Delete function | ||
| 529 | (automatically handled by generic version). | ||
| 530 | |||
| 531 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 532 | |||
| 533 | * ob-js.el (org-babel-execute:js): Use new variable assignment | ||
| 534 | function | ||
| 535 | (org-babel-expand-body:js): Delete function | ||
| 536 | (org-babel-prep-session:js): Use new variable assignment function | ||
| 537 | (org-babel-variable-assignments:js): New function. | ||
| 538 | |||
| 539 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 540 | |||
| 541 | * ob-haskell.el (org-babel-execute:haskell): Use generic expansion | ||
| 542 | function | ||
| 543 | (org-babel-expand-body:haskell): Delete function | ||
| 544 | (org-babel-prep-session:haskell): Use variable assignment function | ||
| 545 | (org-babel-variable-assignments:haskell): New function. | ||
| 546 | |||
| 547 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 548 | |||
| 549 | * ob-gnuplot.el (org-babel-expand-body:gnuplot): Use variable | ||
| 550 | assignment function | ||
| 551 | (org-babel-prep-session:gnuplot): Use variable assignment function | ||
| 552 | (org-babel-variable-assignments:gnuplot): New function. | ||
| 553 | |||
| 554 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 555 | |||
| 556 | * ob-ditaa.el (org-babel-expand-body:ditaa): Delete function | ||
| 557 | (automatically handled by generic version). | ||
| 558 | |||
| 559 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 560 | |||
| 561 | * ob-css.el (org-babel-expand-body:css): Delete function | ||
| 562 | (automatically handled by generic version). | ||
| 563 | |||
| 564 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 565 | |||
| 566 | * ob-asymptote.el (org-babel-execute:asymptote): Use generic | ||
| 567 | expansion function | ||
| 568 | (org-babel-expand-body:asymptote): Delete function | ||
| 569 | (org-babel-variable-assignments:asymptote): New function. | ||
| 570 | |||
| 571 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 572 | |||
| 573 | * ob-R.el (org-babel-expand-body:R): Use new function | ||
| 574 | `org-babel-variable-assignments:R'; don't trim body. | ||
| 575 | (org-babel-execute:R): Respond to changes in | ||
| 576 | `org-babel-expand-body:R' | ||
| 577 | (org-babel-prep-session:R): Called function is now named | ||
| 578 | `org-babel-variable-assignments:R' | ||
| 579 | (org-babel-variable-assignments:R): Receives processed-params as | ||
| 580 | new optional argument. | ||
| 581 | |||
| 582 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 583 | |||
| 584 | * ob-C.el (org-babel-C-expand): Don't trim body. | ||
| 585 | |||
| 586 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 587 | |||
| 588 | * ob-scheme.el (org-babel-expand-body:scheme): Fix bug in | ||
| 589 | obtaining variable references. | ||
| 590 | |||
| 591 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 592 | |||
| 593 | * ob-tangle.el (org-babel-tangle-collect-blocks): Supply variable | ||
| 594 | assignment lines to generic expansion command. | ||
| 595 | |||
| 596 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 597 | |||
| 598 | * ob.el (org-babel-expand-src-block): Supply variable assignment | ||
| 599 | lines to generic expansion function | ||
| 600 | (org-babel-expand-body:generic): Prepend body with optional | ||
| 601 | variable assignment lines. | ||
| 602 | |||
| 603 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 604 | |||
| 605 | * ob-exp.el (org-babel-exp-results): Replaced old function call. | ||
| 606 | |||
| 607 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 608 | |||
| 609 | * ob-lob.el (org-babel-lob-execute): Now expanding variable | ||
| 610 | references before execution. | ||
| 611 | |||
| 612 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 613 | |||
| 614 | * ob.el (org-babel-execute-src-block): Only sort parameters if | ||
| 615 | it's required for caching. | ||
| 616 | |||
| 617 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 618 | |||
| 619 | * ob-table.el (sbe): Reworking for better indentation and to | ||
| 620 | integrate the new variable resolution. | ||
| 621 | |||
| 622 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 623 | |||
| 624 | * ob-ref.el (org-babel-ref-resolve-reference): Now expanding | ||
| 625 | variables when resolving references. | ||
| 626 | |||
| 627 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 628 | |||
| 629 | * ob.el (org-babel-merge-params): Fixed order or precedence for | ||
| 630 | variables. | ||
| 631 | |||
| 632 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 633 | |||
| 634 | * ob-C.el (org-babel-expand-body:c++): Remove obsoleted optional | ||
| 635 | third argument | ||
| 636 | (org-babel-expand-body:c++): Remove obsoleted optional third | ||
| 637 | argument | ||
| 638 | (org-babel-C-expand): Remove obsoleted optional third argument | ||
| 639 | |||
| 640 | * ob-R.el: | ||
| 641 | (org-babel-expand-body:R): Remove obsoleted optional third | ||
| 642 | argument | ||
| 643 | (org-babel-execute:R): Remove obsoleted optional third argument | ||
| 644 | (org-babel-R-variable-assignments): Remove obsoleted optional | ||
| 645 | third argument | ||
| 646 | |||
| 647 | * ob-asymptote.el: | ||
| 648 | (org-babel-expand-body:asymptote): Remove obsoleted optional | ||
| 649 | third argument | ||
| 650 | (org-babel-execute:asymptote): Remove obsoleted optional third | ||
| 651 | argument | ||
| 652 | |||
| 653 | * ob-clojure.el: | ||
| 654 | (org-babel-expand-body:clojure): Remove obsoleted optional third | ||
| 655 | argument | ||
| 656 | (org-babel-execute:clojure): Remove obsoleted optional third | ||
| 657 | argument | ||
| 658 | |||
| 659 | * ob-css.el: | ||
| 660 | (org-babel-expand-body:css): Remove obsoleted optional third | ||
| 661 | argument | ||
| 662 | |||
| 663 | * ob-ditaa.el: | ||
| 664 | (org-babel-expand-body:ditaa): Remove obsoleted optional third | ||
| 665 | argument | ||
| 666 | |||
| 667 | * ob-dot.el: | ||
| 668 | (org-babel-expand-body:dot): Remove obsoleted optional third | ||
| 669 | argument | ||
| 670 | (org-babel-execute:dot): Remove obsoleted optional third | ||
| 671 | argument | ||
| 672 | |||
| 673 | * ob-emacs-lisp.el: | ||
| 674 | (org-babel-expand-body:emacs-lisp): Remove obsoleted optional | ||
| 675 | third argument | ||
| 676 | (org-babel-execute:emacs-lisp): Remove obsoleted optional third | ||
| 677 | argument | ||
| 678 | |||
| 679 | * ob-gnuplot.el: | ||
| 680 | (org-babel-expand-body:gnuplot): Remove obsoleted optional third | ||
| 681 | argument | ||
| 682 | |||
| 683 | * ob-haskell.el: | ||
| 684 | (org-babel-expand-body:haskell): Remove obsoleted optional third | ||
| 685 | argument | ||
| 686 | (org-babel-execute:haskell): Remove obsoleted optional third | ||
| 687 | argument | ||
| 688 | (org-babel-load-session:haskell): Remove obsoleted optional | ||
| 689 | third | ||
| 690 | (org-babel-prep-session:haskell): Remove obsoleted optional | ||
| 691 | third | ||
| 692 | |||
| 693 | * ob-js.el: | ||
| 694 | (org-babel-expand-body:js): Remove obsoleted optional third | ||
| 695 | argument | ||
| 696 | (org-babel-execute:js): Remove obsoleted optional third argument | ||
| 697 | |||
| 698 | * ob-latex.el: | ||
| 699 | (org-babel-expand-body:latex): Remove obsoleted optional third | ||
| 700 | argument | ||
| 701 | |||
| 702 | * ob-lisp.el: | ||
| 703 | (org-babel-expand-body:lisp): Remove obsoleted optional third | ||
| 704 | argument | ||
| 705 | (org-babel-execute:lisp): Remove obsoleted optional third | ||
| 706 | argument | ||
| 707 | |||
| 708 | * ob-mscgen.el: | ||
| 709 | (org-babel-expand-body:mscgen): Remove obsoleted optional third | ||
| 710 | argument | ||
| 711 | |||
| 712 | * ob-ocaml.el: | ||
| 713 | (org-babel-expand-body:ocaml): Remove obsoleted optional third | ||
| 714 | argument | ||
| 715 | (org-babel-execute:ocaml): Remove obsoleted optional third | ||
| 716 | argument | ||
| 717 | |||
| 718 | * ob-octave.el: | ||
| 719 | (org-babel-expand-body:matlab): Remove obsoleted optional third | ||
| 720 | argument | ||
| 721 | (org-babel-expand-body:octave): Remove obsoleted optional third | ||
| 722 | argument | ||
| 723 | (org-babel-execute:octave): Remove obsoleted optional third | ||
| 724 | argument | ||
| 725 | (org-babel-octave-variable-assignments): Remove obsoleted | ||
| 726 | optional third | ||
| 727 | |||
| 728 | * ob-org.el: | ||
| 729 | (org-babel-expand-body:org): Remove obsoleted optional third | ||
| 730 | argument | ||
| 731 | |||
| 732 | * ob-perl.el: | ||
| 733 | (org-babel-expand-body:perl): Remove obsoleted optional third | ||
| 734 | argument | ||
| 735 | (org-babel-execute:perl): Remove obsoleted optional third | ||
| 736 | argument | ||
| 737 | |||
| 738 | * ob-plantuml.el: | ||
| 739 | (org-babel-expand-body:plantuml): Remove obsoleted optional | ||
| 740 | third argument | ||
| 741 | |||
| 742 | * ob-python.el: | ||
| 743 | (org-babel-expand-body:python): Remove obsoleted optional third | ||
| 744 | argument | ||
| 745 | (org-babel-execute:python): Remove obsoleted optional third | ||
| 746 | argument | ||
| 747 | (org-babel-python-variable-assignments): Remove obsoleted | ||
| 748 | optional third | ||
| 749 | |||
| 750 | * ob-ruby.el: | ||
| 751 | (org-babel-expand-body:ruby): Remove obsoleted optional third | ||
| 752 | argument | ||
| 753 | (org-babel-execute:ruby): Remove obsoleted optional third | ||
| 754 | argument | ||
| 755 | |||
| 756 | * ob-sass.el: | ||
| 757 | (org-babel-expand-body:sass): Remove obsoleted optional third | ||
| 758 | argument | ||
| 759 | |||
| 760 | * ob-scheme.el: | ||
| 761 | (org-babel-expand-body:scheme): Remove obsoleted optional third | ||
| 762 | argument | ||
| 763 | (org-babel-execute:scheme): Remove obsoleted optional third | ||
| 764 | argument | ||
| 765 | |||
| 766 | * ob-screen.el: | ||
| 767 | (org-babel-expand-body:screen): Remove obsoleted optional third | ||
| 768 | argument | ||
| 769 | |||
| 770 | * ob-sh.el: | ||
| 771 | (org-babel-expand-body:sh): Remove obsoleted optional third | ||
| 772 | argument | ||
| 773 | (org-babel-execute:sh): Remove obsoleted optional third argument | ||
| 774 | (org-babel-sh-variable-assignments): Remove obsoleted optional | ||
| 775 | third | ||
| 776 | |||
| 777 | * ob-sql.el: | ||
| 778 | (org-babel-expand-body:sql): Remove obsoleted optional third | ||
| 779 | argument | ||
| 780 | |||
| 781 | * ob-sqlite.el: | ||
| 782 | (org-babel-expand-body:sqlite): Remove obsoleted optional third | ||
| 783 | argument | ||
| 784 | (org-babel-execute:sqlite): Remove obsoleted optional third | ||
| 785 | argument | ||
| 786 | |||
| 787 | * ob.el: | ||
| 788 | (org-babel-expand-body:generic): Remove obsoleted optional third | ||
| 789 | argument. | ||
| 790 | |||
| 791 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 792 | |||
| 793 | * ob-clojure.el (org-babel-prep-session:clojure): Purging all | ||
| 794 | calls to removed org-babel-ref-variables. | ||
| 795 | |||
| 796 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 797 | |||
| 798 | * ob-lob.el (org-babel-lob-ingest): Now returns the count of | ||
| 799 | ingested code blocks. | ||
| 800 | |||
| 801 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 802 | |||
| 803 | * ob-exp.el (org-babel-exp-in-export-file): Wrapper for collecting | ||
| 804 | information from within the original export file. | ||
| 805 | |||
| 806 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 807 | |||
| 808 | * ob.el (org-babel-get-src-block-info): Small but crucial fix) | ||
| 809 | (this should return nil if not match found. | ||
| 810 | |||
| 811 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 812 | |||
| 813 | * ob-emacs-lisp.el (org-babel-expand-body:emacs-lisp): Whitespace | ||
| 814 | (org-babel-execute:emacs-lisp): Whitespace. | ||
| 815 | |||
| 816 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 817 | |||
| 818 | * ob-sh.el (org-babel-sh-variable-assignments): Provide missing | ||
| 819 | docstring | ||
| 820 | |||
| 821 | * ob-python.el (org-babel-python-variable-assignments): Provide | ||
| 822 | missing docstring. | ||
| 823 | |||
| 824 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 825 | |||
| 826 | * ob-octave.el (org-babel-expand-body:octave): Refactor: break | ||
| 827 | variable assignment part out into a separate function | ||
| 828 | (org-babel-octave-variable-assignments): New function constructing | ||
| 829 | list of variable assignment statements | ||
| 830 | (org-babel-prep-session:octave): Use new function | ||
| 831 | `org-babel-octave-variable-assignments' instead of previous | ||
| 832 | (incorrect) variable assignment code. | ||
| 833 | |||
| 834 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 835 | |||
| 836 | * ob-sh.el (org-babel-expand-body:sh): Refactor: break variable | ||
| 837 | assignment part out into a separate function | ||
| 838 | (org-babel-sh-variable-assignments): New function constructing | ||
| 839 | list of variable assignment statements | ||
| 840 | (org-babel-prep-session:sh): Use new function | ||
| 841 | `org-babel-sh-variable-assignments' instead of previous | ||
| 842 | (incorrect) variable assignment code. | ||
| 843 | |||
| 844 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 845 | |||
| 846 | * ob-python.el (org-babel-expand-body:python): Refactor: break | ||
| 847 | variable assignment part out into a separate function | ||
| 848 | (org-babel-python-variable-assignments): New function constructing | ||
| 849 | list of variable assignment statements | ||
| 850 | (org-babel-prep-session:python): Use new function | ||
| 851 | `org-babel-python-variable-assignments' instead of previous | ||
| 852 | (incorrect) variable assignment code. | ||
| 853 | |||
| 854 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 855 | |||
| 856 | * ob-R.el (org-babel-expand-body:R): Refactor: break variable | ||
| 857 | assignment part out into a separate function | ||
| 858 | (org-babel-R-variable-assignments): New function constructing list | ||
| 859 | of variable assignment statements | ||
| 860 | (org-babel-prep-session:R): Use new function | ||
| 861 | `org-babel-R-variable-assignments' instead of previous | ||
| 862 | (incorrect) variable assignment code. | ||
| 863 | |||
| 864 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 865 | |||
| 866 | * ob.el (org-babel-initiate-session): Better variable names. | ||
| 867 | |||
| 868 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 869 | |||
| 870 | * ob.el (org-number-sequence): Declared | ||
| 871 | |||
| 872 | * ob-R.el (org-number-sequence): Declared. | ||
| 873 | |||
| 874 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 875 | |||
| 876 | * ob.el (org-babel-map-src-blocks): Store correct value of | ||
| 877 | `end-block'. | ||
| 878 | |||
| 879 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 880 | |||
| 881 | * ob.el (org-babel-mark-block): New function to mark the body of a | ||
| 882 | src block in the style of `mark-defun'. | ||
| 883 | |||
| 884 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 885 | |||
| 886 | * org-compat.el (org-number-sequence): New function. | ||
| 887 | |||
| 888 | * ob-R.el (org-babel-expand-body:R): Use `org-number-sequence'. | ||
| 889 | |||
| 890 | * ob.el (org-babel-where-is-src-block-result): Use | ||
| 891 | `org-number-sequence'. | ||
| 892 | (org-babel-current-buffer-properties): Fix variable definition. | ||
| 893 | |||
| 894 | * ob-ref.el (org-babel-ref-index-list): Use `org-number-sequence'. | ||
| 895 | |||
| 896 | * ob-latex.el (org-babel-latex-tex-to-pdf): Use the 2-argument | ||
| 897 | version of `shell-command'. | ||
| 898 | |||
| 899 | * org-latex.el (org-export-as-pdf): Use the 2-argument version of | ||
| 900 | `shell-command'. | ||
| 901 | |||
| 902 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 903 | |||
| 904 | * org-list.el (org-list-search-unenclosed-generic): Replace call | ||
| 905 | to booleanp. | ||
| 906 | |||
| 907 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 908 | |||
| 909 | * org.el (org-agenda-jump-prefer-future): New option. | ||
| 910 | |||
| 911 | * org-agenda.el (org-agenda-goto-date): Use | ||
| 912 | `org-agenda-jump-prefer-future'. | ||
| 913 | |||
| 914 | 2010-11-11 Noorul Islam <noorul@noorul.com> | ||
| 915 | |||
| 916 | * org-latex.el (org-export-latex-links) : Replaced hard coded | ||
| 917 | hyperref format with custom variable | ||
| 918 | `org-export-latex-hyperref-format'. | ||
| 919 | |||
| 920 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 921 | |||
| 922 | * org.el (org-insert-heading): Fix docstring. | ||
| 923 | |||
| 924 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> (tiny change) | ||
| 925 | |||
| 926 | * org-capture.el (org-capture-place-entry): If the first line is | ||
| 927 | already a headline, just stay there. | ||
| 928 | |||
| 929 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 930 | |||
| 931 | * ob-sh.el (org-babel-sh-evaluate): No longer assumes that results | ||
| 932 | are non-nil. | ||
| 933 | |||
| 934 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 935 | |||
| 936 | * org-ascii.el (org-ascii-replace-entities): Match an optional {} | ||
| 937 | after an entity. | ||
| 938 | |||
| 939 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 940 | |||
| 941 | * org-table.el (orgtbl-to-html): Apply `org-html-expand' to the | ||
| 942 | table fields. | ||
| 943 | |||
| 944 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 945 | |||
| 946 | * org.el (org-insert-heading): When on the headline of an inline | ||
| 947 | task, insert another inline tasks. | ||
| 948 | |||
| 949 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 950 | |||
| 951 | * ob-tangle.el (org-babel-tangle-collect-blocks): Only create | ||
| 952 | links for blocks that will actually tangle. | ||
| 953 | |||
| 954 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 955 | |||
| 956 | * ob-sh.el (org-babel-expand-body:sh): Don't insert extra newlines | ||
| 957 | in expanded shell bodies. | ||
| 958 | |||
| 959 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 960 | |||
| 961 | * ob-sh.el (org-babel-expand-body:sh): Avoid inserting extra | ||
| 962 | newline characters. | ||
| 963 | |||
| 964 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 965 | |||
| 966 | * ob-sh.el (org-babel-expand-body:sh): Align code. | ||
| 967 | |||
| 968 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 969 | |||
| 970 | * ob.el (org-babel-params-from-properties): Max line with at <=80 | ||
| 971 | |||
| 972 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 973 | |||
| 974 | * org-latex.el (org-export-latex-listings-langs): Clojure is now | ||
| 975 | recognized as a lisp. | ||
| 976 | |||
| 977 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 978 | |||
| 979 | * ob.el (org-babel-params-from-properties): Use `org-babel-read' | ||
| 980 | to interpret property as header argument value. | ||
| 981 | |||
| 982 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 983 | |||
| 984 | * ob.el (org-babel-parse-header-arguments): Simplify reading of | ||
| 985 | header arg value. | ||
| 986 | |||
| 987 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 988 | |||
| 989 | * org-publish.el (org-publish-org-to-ascii): | ||
| 990 | (org-publish-org-to-latin1): | ||
| 991 | (org-publish-org-to-utf8): New functions. | ||
| 992 | |||
| 993 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 994 | |||
| 995 | * org.el (org-insert-heading): Skip inline tasks when trying to | ||
| 996 | insert a new heading after the end of the subtree. | ||
| 997 | |||
| 998 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 999 | |||
| 1000 | * org-inlinetask.el (org-inlinetask-min-level): Set customization | ||
| 1001 | type to integer or nil. | ||
| 1002 | |||
| 1003 | * org.el (org-insert-heading): When after an inline task, do not | ||
| 1004 | use level but go back to headline level before the inline task. | ||
| 1005 | |||
| 1006 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 1007 | |||
| 1008 | * org-inlinetask.el (org-inlinetask-in-task-p): New function. | ||
| 1009 | |||
| 1010 | * org.el (org-indent-line-function): Fix indentation of inline | ||
| 1011 | tasks. | ||
| 1012 | |||
| 1013 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 1014 | |||
| 1015 | * org.el (org-activate-links): Fix customize type. | ||
| 1016 | |||
| 1017 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 1018 | |||
| 1019 | * org-latex.el (org-latex-to-pdf-process): Add rubber as another | ||
| 1020 | default option. | ||
| 1021 | |||
| 1022 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 1023 | |||
| 1024 | * org-latex.el (org-export-latex-minted): Document pygments | ||
| 1025 | dependency. | ||
| 1026 | |||
| 1027 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 1028 | |||
| 1029 | * org-mobile.el (org-mobile-create-index-file): Encrypt the index | ||
| 1030 | file if encryption has been turned on. | ||
| 1031 | (org-mobile-copy-agenda-files): Avoid double encryption of | ||
| 1032 | `mobileorg.org'. | ||
| 1033 | |||
| 1034 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 1035 | |||
| 1036 | * org-exp.el (org-export-latex-minted-with-line-numbers): Ensure | ||
| 1037 | that variable is declared. | ||
| 1038 | |||
| 1039 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1040 | |||
| 1041 | * ob-python.el (org-src-preserve-indentation): Fixed compiler | ||
| 1042 | warning. | ||
| 1043 | |||
| 1044 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 1045 | |||
| 1046 | * org-exp.el (org-export-format-source-code-or-example): Latex | ||
| 1047 | formatting of source code blocks using the minted package | ||
| 1048 | (org-export-plist-vars): Add :latex-minted property | ||
| 1049 | (org-export-latex-minted): Ensure variable is defined | ||
| 1050 | (org-export-latex-minted-langs): Ensure variable is defined. | ||
| 1051 | |||
| 1052 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 1053 | |||
| 1054 | * org-src.el (org-edit-src-code): Use `org-region-active-p'. | ||
| 1055 | |||
| 1056 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 1057 | |||
| 1058 | * ob-tangle.el (org-babel-spec-to-string): Whitespace changes. | ||
| 1059 | |||
| 1060 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 1061 | |||
| 1062 | * ob-tangle.el (org-babel-spec-to-string): Don't trim whitespace | ||
| 1063 | when `org-src-preserve-indentation' is non-nil. | ||
| 1064 | |||
| 1065 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 1066 | |||
| 1067 | * ob-lob.el (org-babel-lob-ingest): Provide message stating number | ||
| 1068 | of blocks added to Library of Babel. | ||
| 1069 | |||
| 1070 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 1071 | |||
| 1072 | * ob-lob.el (org-babel-lob-ingest): Check for nil source block | ||
| 1073 | name. | ||
| 1074 | |||
| 1075 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 1076 | |||
| 1077 | * org-beamer.el (org-beamer-place-default-actions-for-lists): Fix | ||
| 1078 | typo in regexp. | ||
| 1079 | |||
| 1080 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 1081 | |||
| 1082 | * org-list.el (org-toggle-checkbox): Avoid some boundary error | ||
| 1083 | when inserting a checkbox in an empty last item of a list. | ||
| 1084 | |||
| 1085 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 1086 | |||
| 1087 | * org-gnus.el (org-gnus-nnimap-query-article-no-from-file): Query | ||
| 1088 | article number from file is nil by default. | ||
| 1089 | |||
| 1090 | 2010-11-11 Stephen Eglen <S.J.Eglen@damtp.cam.ac.uk> | ||
| 1091 | |||
| 1092 | * org-beamer.el (org-beamer-amend-header): Fix typo in docstring. | ||
| 1093 | |||
| 1094 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 1095 | |||
| 1096 | * org-capture.el (org-capture-place-entry): Move to `beg' before | ||
| 1097 | searching for `%?'. | ||
| 1098 | |||
| 1099 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 1100 | |||
| 1101 | * org.el (org-format-latex): Fix mathjax treatment of single | ||
| 1102 | letters in between dollars. | ||
| 1103 | |||
| 1104 | 2010-11-11 Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> | ||
| 1105 | |||
| 1106 | * org-latex.el (org-latex-to-pdf-process): Add a third pdflatex | ||
| 1107 | run. | ||
| 1108 | |||
| 1109 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 1110 | |||
| 1111 | * org.el (org-blank-before-new-entry): Improve docstring. | ||
| 1112 | |||
| 1113 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 1114 | |||
| 1115 | * org-mobile.el (org-mobile-force-id-on-agenda-items): Fix | ||
| 1116 | docstring. | ||
| 1117 | (org-mobile-write-agenda-for-mobile): Use outline path if we do | ||
| 1118 | not have an ID and are not allowed to make one. | ||
| 1119 | (org-mobile-get-outline-path-link): New function. | ||
| 1120 | |||
| 1121 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 1122 | |||
| 1123 | * org-mobile.el (org-mobile-copy-agenda-files): Encrypt the empty | ||
| 1124 | file. | ||
| 1125 | (org-mobile-write-agenda-for-mobile): Use the right name, even if | ||
| 1126 | the file get encrypted. | ||
| 1127 | (org-mobile-move-capture): Only delete tempfile if it does exist. | ||
| 1128 | |||
| 1129 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1130 | |||
| 1131 | * ob.el (org-babel-number-p): Fixed documentation string. | ||
| 1132 | |||
| 1133 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1134 | |||
| 1135 | * ob-tangle.el (org-babel-tangle-collect-blocks): Accepting | ||
| 1136 | "tangle" as a positive argument for the :noweb header argument | ||
| 1137 | during tangling. | ||
| 1138 | |||
| 1139 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1140 | |||
| 1141 | * ob-exp.el (org-babel-exp-src-blocks): Fixed export when headings | ||
| 1142 | have links, with tests. | ||
| 1143 | |||
| 1144 | 2010-11-11 Sebastian Rose, Hannover, Germany <sebastian_rose@gmx.de> | ||
| 1145 | |||
| 1146 | * org-test-which-func: New function. Find name of defun around | ||
| 1147 | point. | ||
| 1148 | |||
| 1149 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 1150 | |||
| 1151 | * org-latex.el (org-latex-to-pdf-process): Use texi2dvi if | ||
| 1152 | available. | ||
| 1153 | (org-export-latex-get-error): New function. | ||
| 1154 | (org-export-as-pdf): Give an indication of the errors that | ||
| 1155 | happened during processing. | ||
| 1156 | |||
| 1157 | 2010-11-11 Åukasz Stelmach <lukasz.stelmach@iem.pw.edu.pl> | ||
| 1158 | |||
| 1159 | * org-exp.el (org-export-language-setup): Fix Polish entries. | ||
| 1160 | |||
| 1161 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 1162 | |||
| 1163 | * org.el (org-set-tags): Allow comma as a separator when | ||
| 1164 | specifying tags at the completion interface. | ||
| 1165 | (org-tags-completion-function): Allow comma as a separator when | ||
| 1166 | specifying tags at the completion interface. | ||
| 1167 | |||
| 1168 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1169 | |||
| 1170 | * ob-exp.el (org-babel-exp-src-blocks): Don't jump back to | ||
| 1171 | export-file if exporting from a buffer which is not visiting a | ||
| 1172 | file. | ||
| 1173 | |||
| 1174 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1175 | |||
| 1176 | * ob-exp.el (org-babel-exp-src-blocks): Only append "::" to a file | ||
| 1177 | name in link construction if there is a heading to follow it. | ||
| 1178 | |||
| 1179 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 1180 | |||
| 1181 | * org-html.el (org-export-html-inline-image-extensions): Add "svg" | ||
| 1182 | as an allowed extension. | ||
| 1183 | |||
| 1184 | 2010-11-11 Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> | ||
| 1185 | |||
| 1186 | * org-agenda.el (org-agenda-add-time-grid-maybe): Pad clock times | ||
| 1187 | with zeros. Start applying face earlier. | ||
| 1188 | |||
| 1189 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1190 | |||
| 1191 | * ob.el (or): Don't create org-babel-temporary-directory in batch | ||
| 1192 | as it won't be removed by emacs-kill-hook | ||
| 1193 | (org-babel-remove-temporary-directory): Only try to remove this | ||
| 1194 | directory if it exists. | ||
| 1195 | |||
| 1196 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1197 | |||
| 1198 | * ob.el (org-babel-temporary-directory): Fixing byte-compilation | ||
| 1199 | warning in ob.el. | ||
| 1200 | |||
| 1201 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1202 | |||
| 1203 | * ob-tangle.el (org-babel-tangle): Now sharing the file name in | ||
| 1204 | the tangling message. | ||
| 1205 | |||
| 1206 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1207 | |||
| 1208 | * ob.el (org-babel-load-languages): Fixes compiler warning. | ||
| 1209 | |||
| 1210 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1211 | |||
| 1212 | * ob-plantuml.el (org-babel-execute:plantuml): Fixes bug with svg | ||
| 1213 | output. | ||
| 1214 | |||
| 1215 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 1216 | |||
| 1217 | * org-ascii.el (org-export-as-ascii): Use the correct match group. | ||
| 1218 | |||
| 1219 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1220 | |||
| 1221 | * ob.el (boundp): Uncommenting defvar form for | ||
| 1222 | org-babel-temporary-directory | ||
| 1223 | (org-babel-temp-file): Now using the org-babel-temporary-directory | ||
| 1224 | for holding new babel temporary files | ||
| 1225 | (org-babel-remove-temporary-directory): Removes the babel temp dir | ||
| 1226 | when Emacs shutsdown | ||
| 1227 | (kill-emacs-hook): Now removing the babel temp dir on Emacs | ||
| 1228 | shutdown. | ||
| 1229 | |||
| 1230 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 1231 | |||
| 1232 | * org-capture.el (org-capture-fill-template): Initialize history | ||
| 1233 | variable. | ||
| 1234 | |||
| 1235 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 1236 | |||
| 1237 | * org-src.el (org-edit-src-code): Don't move point when generating | ||
| 1238 | edit buffer. | ||
| 1239 | |||
| 1240 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 1241 | |||
| 1242 | * org-src.el (org-edit-src-code): Deal with point being in | ||
| 1243 | #+end_src line. | ||
| 1244 | |||
| 1245 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 1246 | |||
| 1247 | * org-table.el (org-table-current-column): Add interactive to turn | ||
| 1248 | this into a command. | ||
| 1249 | |||
| 1250 | 2010-11-11 Bernt Hansen <bernt@norang.ca> | ||
| 1251 | |||
| 1252 | * org.el (org-insert-heading): Run org-insert-heading-hook when | ||
| 1253 | creating the first heading in a file. | ||
| 1254 | |||
| 1255 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 1256 | |||
| 1257 | * org.el (org-startup-with-inline-images): New option. | ||
| 1258 | (org-startup-options): Add new keywords inlineimages and | ||
| 1259 | noinlineimages. | ||
| 1260 | (org-mode): Inline images when this has been configured. | ||
| 1261 | |||
| 1262 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 1263 | |||
| 1264 | * ob.el (org-babel-get-src-block-info): Remove optional | ||
| 1265 | HEADER-VARS-ONLY argument; further simplification. | ||
| 1266 | |||
| 1267 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1268 | |||
| 1269 | * ob.el (org-babel-confirm-evaluate): Fixed bug causing extra | ||
| 1270 | prompt in ob-confirm-evaluate in some cases. | ||
| 1271 | |||
| 1272 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1273 | |||
| 1274 | * ob.el (org-babel-demarcate-block): Visible region and completion | ||
| 1275 | during language selection. | ||
| 1276 | |||
| 1277 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 1278 | |||
| 1279 | * ob.el (org-babel-get-src-block-info): Remove comment. | ||
| 1280 | |||
| 1281 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 1282 | |||
| 1283 | * ob.el (org-babel-get-src-block-info): Simplify function. | ||
| 1284 | |||
| 1285 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 1286 | |||
| 1287 | * ob.el (org-babel-get-src-block-info): Form info list correctly | ||
| 1288 | when parenthesised arguments are missing. | ||
| 1289 | |||
| 1290 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 1291 | |||
| 1292 | * ob-exp.el (org-export-babel-evaluate): Docstring typo | ||
| 1293 | (org-babel-exp-code): Docstring typo. | ||
| 1294 | |||
| 1295 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 1296 | |||
| 1297 | * org-mobile.el (org-mobile-encryption-password): Improve | ||
| 1298 | docstring. | ||
| 1299 | (org-mobile-encryption-password-session): New variable. | ||
| 1300 | (org-mobile-encryption-password): New function. | ||
| 1301 | (org-mobile-check-setup): | ||
| 1302 | (org-mobile-encrypt-file): | ||
| 1303 | (org-mobile-decrypt-file): Use the new function. | ||
| 1304 | |||
| 1305 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 1306 | |||
| 1307 | * org-capture.el (org-capture-place-template): Widen to remove | ||
| 1308 | possible restrictions in target buffer. | ||
| 1309 | |||
| 1310 | 2010-11-11 Jambunathan K <kjambunathan@gmail.com> | ||
| 1311 | |||
| 1312 | * org.el (org-speed-command-hook): Added org-speed-command-hook | ||
| 1313 | (org-babel-speed-command-hook): Hook for Babel's speed commands. | ||
| 1314 | |||
| 1315 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 1316 | |||
| 1317 | * ob.el (org-babel-execute-buffer): Re-implement using | ||
| 1318 | `org-babel-map-src-blocks'. | ||
| 1319 | |||
| 1320 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 1321 | |||
| 1322 | * org-capture.el (org-capture-templates): Update doc string with | ||
| 1323 | new message date related escapes. | ||
| 1324 | |||
| 1325 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 1326 | |||
| 1327 | * org-wl.el (org-wl-store-link-message): Define properties %:date) | ||
| 1328 | (%:date-timestamp, and %:date-timestamp-inactive. | ||
| 1329 | |||
| 1330 | * org-mew.el (org-mew-store-link): Dto. | ||
| 1331 | |||
| 1332 | * org-mhe.el (org-mhe-store-link): Dto. | ||
| 1333 | |||
| 1334 | * org-rmail.el (org-rmail-store-link): Dto. | ||
| 1335 | |||
| 1336 | * org-vm.el (org-vm-store-link): Dto. | ||
| 1337 | |||
| 1338 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 1339 | |||
| 1340 | * org-wl.el (org-wl-message-field): Always get literal content of | ||
| 1341 | header fields. | ||
| 1342 | |||
| 1343 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 1344 | |||
| 1345 | * org-gnus.el (org-gnus-store-link): Define properties | ||
| 1346 | %:date-timestamp and %:date-timestamp-inactive. | ||
| 1347 | |||
| 1348 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 1349 | |||
| 1350 | * org-gnus.el (org-gnus-store-link): Handle empty date header | ||
| 1351 | field. | ||
| 1352 | |||
| 1353 | 2010-11-11 Jambunathan K <kjambunathan@gmail.com> (tiny change) | ||
| 1354 | |||
| 1355 | * org.el (org-speed-command-hook): New. Hook for installing | ||
| 1356 | additional speed commands. Use this for enabling speed commands on | ||
| 1357 | src blocks. | ||
| 1358 | (org-speed-command-default-hook): The default hook for | ||
| 1359 | org-speed-command-hook. Factored out from org-self-insert-command | ||
| 1360 | and mimics existing behaviour. | ||
| 1361 | (org-self-insert-command): Modified to use org-speed-command-hook. | ||
| 1362 | |||
| 1363 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 1364 | |||
| 1365 | * org-agenda.el (org-search-view): Recover spaces in search words | ||
| 1366 | if they were escaped with \ or inside a regexp. | ||
| 1367 | |||
| 1368 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 1369 | |||
| 1370 | * org.el (org-additional-option-like-keywords): Add PROPERTIES to | ||
| 1371 | the list of completable meta line words. | ||
| 1372 | (org-complete): Complete property names after #+PROPERTY. | ||
| 1373 | |||
| 1374 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 1375 | |||
| 1376 | * ob-python.el (org-babel-python-evaluate-session): Make temp file | ||
| 1377 | names consistent. | ||
| 1378 | |||
| 1379 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 1380 | |||
| 1381 | * ob-clojure.el (org-babel-clojure-evaluate-external-process): | ||
| 1382 | Delete extra format argument. | ||
| 1383 | |||
| 1384 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 1385 | |||
| 1386 | * ob-org.el (org-babel-org-export): Typo in docstring. | ||
| 1387 | |||
| 1388 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 1389 | |||
| 1390 | * ob-sh.el (org-babel-sh-evaluate): Remove unused temporary file | ||
| 1391 | variable. | ||
| 1392 | |||
| 1393 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 1394 | |||
| 1395 | * ob-scheme.el (org-babel-execute:scheme): Alter temp file name. | ||
| 1396 | |||
| 1397 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 1398 | |||
| 1399 | * ob.el (org-babel-process-file-name): New function | ||
| 1400 | (org-babel-maybe-remote-file): Delete function. | ||
| 1401 | |||
| 1402 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 1403 | |||
| 1404 | * ob-C.el (org-babel-C-execute): Remove unused variable. | ||
| 1405 | |||
| 1406 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 1407 | |||
| 1408 | * org.el (org-make-link-string): Prevent superfluous colon. | ||
| 1409 | |||
| 1410 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 1411 | |||
| 1412 | * org.el (org-make-org-heading-search-string): Leave headline | ||
| 1413 | intact. | ||
| 1414 | |||
| 1415 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 1416 | |||
| 1417 | * org.el (org-make-link-string): Don't escape characters in link | ||
| 1418 | type. | ||
| 1419 | |||
| 1420 | 2010-11-11 Bastien Guerry <bzg@altern.org> | ||
| 1421 | |||
| 1422 | * org-capture.el (org-capture-templates): Update docstring to | ||
| 1423 | advertize %:org-date. | ||
| 1424 | |||
| 1425 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1426 | |||
| 1427 | * ob-dot.el (org-babel-execute:dot): Automatically specifies | ||
| 1428 | "-T<ext>" based on file name extension. | ||
| 1429 | |||
| 1430 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1431 | |||
| 1432 | * ob-org.el (org-babel-org-export): Raise error on nested export | ||
| 1433 | call. | ||
| 1434 | |||
| 1435 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1436 | |||
| 1437 | * ob-plantuml.el (org-babel-execute:plantuml): Support for svg | ||
| 1438 | output files. | ||
| 1439 | |||
| 1440 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1441 | |||
| 1442 | * ob.el (org-babel-demarcate-block): Better initialization of | ||
| 1443 | stars. | ||
| 1444 | |||
| 1445 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 1446 | |||
| 1447 | * org-src.el (org-src-tab-acts-natively): Add customize interface. | ||
| 1448 | |||
| 1449 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 1450 | |||
| 1451 | * org-src.el (org-src-strip-leading-and-trailing-blank-lines): New | ||
| 1452 | variable allowing prevention of automatic stripping of leading and | ||
| 1453 | trailing blank lines when exiting edit buffer. | ||
| 1454 | (org-edit-src-exit): Respect value of | ||
| 1455 | `org-src-strip-leading-and-trailing-blank-lines' | ||
| 1456 | (org-src-native-tab-command-maybe): Bind | ||
| 1457 | `org-src-strip-leading-and-trailing-blank-lines' to nil during | ||
| 1458 | this function. | ||
| 1459 | |||
| 1460 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 1461 | |||
| 1462 | * org-src.el (org-edit-src-code): If mark was inside code block | ||
| 1463 | then code edit buffer inherits mark with active region. | ||
| 1464 | |||
| 1465 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1466 | |||
| 1467 | * ob.el (org-babel-demarcate-block): Fix compiler warnings. | ||
| 1468 | |||
| 1469 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1470 | |||
| 1471 | * ob.el (org-babel-demarcate-block): Better handling of empty | ||
| 1472 | space around demarcated area. | ||
| 1473 | |||
| 1474 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 1475 | |||
| 1476 | * org-agenda.el (org-agenda-goto-date): Turn off prefer future for | ||
| 1477 | this command. | ||
| 1478 | |||
| 1479 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 1480 | |||
| 1481 | * org-gnus.el (org-gnus-open-nntp): New function. | ||
| 1482 | |||
| 1483 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 1484 | |||
| 1485 | * org-wl.el (org-wl-open-nntp): New function. | ||
| 1486 | |||
| 1487 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 1488 | |||
| 1489 | * org-wl.el (org-wl-open): Open message by numeric reference if | ||
| 1490 | article part is not a message id. | ||
| 1491 | |||
| 1492 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 1493 | |||
| 1494 | * org-agenda.el (org-agenda-filter-apply): Move cursor to a | ||
| 1495 | visible line. | ||
| 1496 | |||
| 1497 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1498 | |||
| 1499 | * ob.el (org-babel-demarcate-block): Interactive demarcation of | ||
| 1500 | code blocks | ||
| 1501 | |||
| 1502 | * ob-keys.el (org-babel-key-bindings): Key bindings for block | ||
| 1503 | demarcation. | ||
| 1504 | |||
| 1505 | 2010-11-11 Bastien Guerry <bzg@altern.org> | ||
| 1506 | |||
| 1507 | * org.el (org-link-types): Add the "message" link type. | ||
| 1508 | |||
| 1509 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 1510 | |||
| 1511 | * org.el (org-link-types): Add 'message:' link type to default | ||
| 1512 | link types. | ||
| 1513 | |||
| 1514 | 2010-11-11 Bastien Guerry <bzg@altern.org> | ||
| 1515 | |||
| 1516 | * org-gnus.el (org-gnus-store-link): Add the :date property to | ||
| 1517 | gnus links, allowing the use of %:date in capture templates. | ||
| 1518 | |||
| 1519 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 1520 | |||
| 1521 | * org-list.el (org-cycle-list-bullet): Follow order of bullets | ||
| 1522 | indicated in doc-string. | ||
| 1523 | |||
| 1524 | * org-list.el (org-list-bottom-point-with-indent): List is ended | ||
| 1525 | when a line is less indented that the last item, not the less | ||
| 1526 | indented item. | ||
| 1527 | |||
| 1528 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1529 | |||
| 1530 | * ob-exp.el (org-babel-exp-src-blocks): Now switching back to the | ||
| 1531 | original file before resolving code block parameters to ensure | ||
| 1532 | headline and buffer wide parameters are taken into consideration | ||
| 1533 | when only a narrowed portion of the file is exported. | ||
| 1534 | |||
| 1535 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 1536 | |||
| 1537 | * org.el (org-forward-same-level): Fix docstring. | ||
| 1538 | |||
| 1539 | 2010-11-11 Sebastian Rose <sebastian_rose@gmx.de> | ||
| 1540 | |||
| 1541 | * org-publish.el (org-publish-attachment): Put the attachment into | ||
| 1542 | the right directory. | ||
| 1543 | |||
| 1544 | 2010-11-11 Jambunathan K <kjambunathan@gmail.com> (tiny change) | ||
| 1545 | |||
| 1546 | * org.el (org-goto-first-child): New command. | ||
| 1547 | |||
| 1548 | 2010-11-11 Matt Lundin <mdl@imapmail.org> | ||
| 1549 | |||
| 1550 | * org-agenda.el (org-prepare-agenda): If the agenda is called from | ||
| 1551 | within the agenda via an elisp link, such as | ||
| 1552 | [[elisp:(org-agenda-list)]], org-prepare-agenda erases the buffer | ||
| 1553 | of the file containing the link, since that buffer is current | ||
| 1554 | during org-prepare agenda (due to a with-current-buffer in | ||
| 1555 | org-agenda-open-link). An additional test now ensures that the | ||
| 1556 | agenda buffer is in fact current when the buffer is erased and | ||
| 1557 | local variables for the agenda are set. | ||
| 1558 | |||
| 1559 | 2010-11-11 David Maus <dmaus@ictsoc.de> (tiny change) | ||
| 1560 | |||
| 1561 | * org-exp.el (org-infile-export-plist): Define property macro. | ||
| 1562 | |||
| 1563 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 1564 | |||
| 1565 | * org-mhe.el (org-mhe-get-header): Remove possible folding white | ||
| 1566 | space in message header field. | ||
| 1567 | |||
| 1568 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 1569 | |||
| 1570 | * org-feed.el (org-feed): Fix typo in customization group :tag | ||
| 1571 | property. | ||
| 1572 | |||
| 1573 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 1574 | |||
| 1575 | * org-latex.el (org-export-latex-tag-markup): New option. | ||
| 1576 | (org-export-latex-keywords-maybe): Use | ||
| 1577 | `org-export-latex-tag-markup'. | ||
| 1578 | |||
| 1579 | 2010-11-11 Rémi Vanicat <vanicat@debian.org> | ||
| 1580 | |||
| 1581 | * org-icalendar.el (org-icalendar-use-UTC-date-time): New option. | ||
| 1582 | (org-ical-ts-to-string): Use UTC time when requested. | ||
| 1583 | |||
| 1584 | 2010-11-11 Noorul Islam <noorul@noorul.com> (tiny change) | ||
| 1585 | |||
| 1586 | * org-html.el (org-html-cvt-org-as-html): Do not convert protocol | ||
| 1587 | from 'file' to 'http'. | ||
| 1588 | |||
| 1589 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 1590 | |||
| 1591 | * org.el (org-store-log-note): Fix wrong usage | ||
| 1592 | of`org-adapt-indentation'. | ||
| 1593 | |||
| 1594 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 1595 | |||
| 1596 | * org.el (org-skip-over-state-notes): Do not compute bottom point | ||
| 1597 | at each item. | ||
| 1598 | |||
| 1599 | * org-mouse.el (org-mouse-for-each-item): Use `org-apply-on-list' | ||
| 1600 | instead of moving to each item. | ||
| 1601 | |||
| 1602 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 1603 | |||
| 1604 | * org-capture.el (org-capture-templates): Small fix in doc string. | ||
| 1605 | |||
| 1606 | 2010-11-11 aaa bbb <dominik@powerbook-g4-12-van-aaa-bbb.local> | ||
| 1607 | |||
| 1608 | * org-archive.el (org-get-local-archive-location): Use | ||
| 1609 | `org-carchive-location' as default. | ||
| 1610 | |||
| 1611 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1612 | |||
| 1613 | * ob-C.el (org): No longer requires org | ||
| 1614 | |||
| 1615 | * ob-ledger.el (org): No longer requires org. | ||
| 1616 | |||
| 1617 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 1618 | |||
| 1619 | * org.el (org-priority): Save match data before call to | ||
| 1620 | `read-char-exclusive'. | ||
| 1621 | |||
| 1622 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 1623 | |||
| 1624 | * org-list.el (org-list-to-generic): Descriptions labels can be | ||
| 1625 | any suit of symbols, and will end at double colons. | ||
| 1626 | |||
| 1627 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 1628 | |||
| 1629 | * org.el (org-indent-line-function): Indent past [@num] and | ||
| 1630 | [@start:num], consistently with what is already done with | ||
| 1631 | checkboxes. | ||
| 1632 | |||
| 1633 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 1634 | |||
| 1635 | * org.el (org-store-log-note): Indent new notes to the right | ||
| 1636 | column. Also take `org-list-two-spaces-after-bullet-regexp' into | ||
| 1637 | consideration when creating the note. | ||
| 1638 | |||
| 1639 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 1640 | |||
| 1641 | * org-gnus.el (nnimap-group-overview-filename): Declare function | ||
| 1642 | to silence byte compiler. | ||
| 1643 | |||
| 1644 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 1645 | |||
| 1646 | * org-gnus.el (org-gnus-nnimap-query-article-no-from-file): New | ||
| 1647 | customization variable. | ||
| 1648 | (org-gnus-nnimap-cached-article-number): New function. | ||
| 1649 | (org-gnus-follow-link): Try to fetch cached article number of | ||
| 1650 | message-id. | ||
| 1651 | |||
| 1652 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1653 | |||
| 1654 | * ob-org.el (org-babel-org-default-header): Used to insert a dummy | ||
| 1655 | first line into code blocks before export so that the first line | ||
| 1656 | is not interpreted as a title | ||
| 1657 | (org-babel-org-export): Use new dummy code block prefix. | ||
| 1658 | |||
| 1659 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1660 | |||
| 1661 | * ob.el (org-babel-insert-result): No longer throws error when | ||
| 1662 | inserting an empty result. | ||
| 1663 | |||
| 1664 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1665 | |||
| 1666 | * ob-tangle.el: autoload org-babel-tangle-lang-exts from ob-tangle. | ||
| 1667 | |||
| 1668 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 1669 | |||
| 1670 | * ob.el (org-babel-do-in-edit-buffer): Use | ||
| 1671 | `org-babel-where-is-src-block-head' to test for source block at | ||
| 1672 | point. | ||
| 1673 | |||
| 1674 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1675 | |||
| 1676 | * ob-keys.el (org-babel-key-bindings): Adding key-binding for | ||
| 1677 | `org-babel-goto-src-block-head' | ||
| 1678 | |||
| 1679 | * ob.el (org-babel-goto-src-block-head): Jump to the head of the | ||
| 1680 | current code block. | ||
| 1681 | |||
| 1682 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1683 | |||
| 1684 | * ob.el (org-babel-next-src-block): Now raising more informative | ||
| 1685 | error when no further code blocks can be found | ||
| 1686 | (org-babel-previous-src-block): Now raising more informative error | ||
| 1687 | when no previous code blocks can be found. | ||
| 1688 | |||
| 1689 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1690 | |||
| 1691 | * org-exp-blocks.el | ||
| 1692 | (org-export-preprocess-after-include-files-hook): Now using this | ||
| 1693 | hook instead of `org-export-preprocess-hook'. | ||
| 1694 | |||
| 1695 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1696 | |||
| 1697 | * ob-plantuml.el (org-babel-execute:plantuml): | ||
| 1698 | |||
| 1699 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 1700 | |||
| 1701 | * ob-python.el (org-babel-python-evaluate): Refactor as call to | ||
| 1702 | either `org-babel-python-evaluate-external-process' or | ||
| 1703 | `org-babel-python-evaluate-session'. | ||
| 1704 | (org-babel-python-evaluate-external-process): New function to | ||
| 1705 | handle evaluation in external process. | ||
| 1706 | (org-babel-python-evaluate-session): New function to handle | ||
| 1707 | evaluation in emacs inferior process. | ||
| 1708 | |||
| 1709 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1710 | |||
| 1711 | * ob-org.el (org-babel-execute:org): Evaluates body to latex ascii | ||
| 1712 | or html respecting :results header arg | ||
| 1713 | (org-babel-org-export): Exports a string of text to an output | ||
| 1714 | format. | ||
| 1715 | |||
| 1716 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1717 | |||
| 1718 | * ob.el (org-babel-insert-result): Remove existing results when | ||
| 1719 | nil results are returned. | ||
| 1720 | |||
| 1721 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 1722 | |||
| 1723 | * org-ascii.el (org-export-as-ascii): Bind and set link path for | ||
| 1724 | link type specific markup function. | ||
| 1725 | |||
| 1726 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 1727 | |||
| 1728 | * org-clock.el (notifications-notify): Properly declare function | ||
| 1729 | to silence byte compiler. | ||
| 1730 | |||
| 1731 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 1732 | |||
| 1733 | * org-list.el (org-insert-item): Check invisibility of point at a | ||
| 1734 | meaningful location. | ||
| 1735 | |||
| 1736 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 1737 | |||
| 1738 | * org-list.el (org-list-insert-item-generic): Updating checkboxes | ||
| 1739 | can modifiy bottom point of a list, so make it a marker before | ||
| 1740 | calling `org-update-checkbox-count-maybe'. | ||
| 1741 | |||
| 1742 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 1743 | |||
| 1744 | * org.el (org-src-fontify-natively): Set to nil by default. | ||
| 1745 | Supply cutomize interface. | ||
| 1746 | |||
| 1747 | 2010-11-11 Bastien Guerry <bzg@altern.org> | ||
| 1748 | |||
| 1749 | * org-ascii.el (org-export-as-ascii): Fix bug in ASCII export: use | ||
| 1750 | `org-bracket-link-analytic-regexp++' to match the link type. | ||
| 1751 | |||
| 1752 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1753 | |||
| 1754 | * ob-tangle.el (org-babel-tangle-collect-blocks): Rename `lang' to | ||
| 1755 | `language'. | ||
| 1756 | |||
| 1757 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1758 | |||
| 1759 | * ob-tangle.el (org-babel-tangle-comment-format-beg): Format | ||
| 1760 | string specifying the link-comment preceding a code block | ||
| 1761 | (org-babel-tangle-comment-format-end): Format string specifying | ||
| 1762 | the link-comment following a code block | ||
| 1763 | (org-babel-tangle-collect-blocks): Storing more information in the | ||
| 1764 | spec of a tangling code block | ||
| 1765 | (org-babel-spec-to-string): Now makes use of customizable | ||
| 1766 | link-comment formats. | ||
| 1767 | |||
| 1768 | 2010-11-11 Achim Gratz <Stromeko@stromeko.net> (tiny change) | ||
| 1769 | |||
| 1770 | * org.el (org-delete-backward-char): Check for nil overwrite-mode | ||
| 1771 | before inserting spaces. | ||
| 1772 | |||
| 1773 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 1774 | |||
| 1775 | * org-icalendar.el (org-print-icalendar-entries): Exclude tags | ||
| 1776 | from summary of non-TODO ical entries. | ||
| 1777 | (org-print-icalendar-entries): Use `org-complex-heading-regexp' to | ||
| 1778 | exclude tags from summary of TODO ical entries. | ||
| 1779 | |||
| 1780 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1781 | |||
| 1782 | * ob.el (org-babel-map-src-blocks): Now exposes much information | ||
| 1783 | about the code block in the form of let-bound local variables. | ||
| 1784 | |||
| 1785 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 1786 | |||
| 1787 | * org-list.el (org-outline-regexp, org-ts-regexp) | ||
| 1788 | (org-ts-regexp-both, org-in-regexps-block-p) | ||
| 1789 | (org-level-increment, org-at-heading-p) | ||
| 1790 | (outline-previous-heading, org-icompleting-read) | ||
| 1791 | (org-time-string-to-seconds): Declare to fix compiler warning. | ||
| 1792 | |||
| 1793 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 1794 | |||
| 1795 | * org-list.el (org-toggle-checkbox): Ignore items in drawers when | ||
| 1796 | used from an heading. Send an error when no item is in region. | ||
| 1797 | |||
| 1798 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 1799 | |||
| 1800 | * ob.el (org-babel-do-in-edit-buffer): Use unwind-protect to | ||
| 1801 | ensure that edit buffer is exited. | ||
| 1802 | |||
| 1803 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1804 | |||
| 1805 | * ob-tangle.el (org-babel-tangle-pad-newline): Can be used to | ||
| 1806 | control the amount of extra newlines inserted into tangled code | ||
| 1807 | (org-babel-tangle-collect-blocks): Now conditionally collects | ||
| 1808 | information to be used for "org" style comments | ||
| 1809 | (org-babel-spec-to-string): Now inserts "org" style comments, and | ||
| 1810 | obeys the newline configuration variable when inserting whitespace. | ||
| 1811 | |||
| 1812 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1813 | |||
| 1814 | * ob-tangle.el (org-babel-pre-tangle-hook): Defines new tangle | ||
| 1815 | hook | ||
| 1816 | (org-babel-tangle): Calls new tangle hook. | ||
| 1817 | |||
| 1818 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 1819 | |||
| 1820 | * org-capture.el (org-capture): Compute the length of the correct | ||
| 1821 | string when removing properties. | ||
| 1822 | |||
| 1823 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1824 | |||
| 1825 | * ob-plantuml.el (org-babel-execute:plantuml): Now expanding file | ||
| 1826 | names before shell quoting. | ||
| 1827 | |||
| 1828 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 1829 | |||
| 1830 | * org-src.el (org-src-tab-indents-natively): New variable | ||
| 1831 | controlling whether language-native TAB action should be performed | ||
| 1832 | (org-src-native-tab-command-maybe): New function to perform | ||
| 1833 | language-native TAB action. | ||
| 1834 | (org-tab-first-hook): Add `org-src-native-tab-command-maybe'. | ||
| 1835 | |||
| 1836 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1837 | |||
| 1838 | * ob-plantuml.el (org-babel-execute:plantuml): Explicitly check | ||
| 1839 | `org-plantuml-jar-path' before use. | ||
| 1840 | |||
| 1841 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 1842 | |||
| 1843 | * org-src.el (org-src-font-lock-fontify-block): Re-use hidden | ||
| 1844 | language major mode buffers during fontification. | ||
| 1845 | |||
| 1846 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 1847 | |||
| 1848 | * org.el (org-fontify-meta-lines-and-blocks): Alter main regexp to | ||
| 1849 | match code blocks with switches and header args. Call | ||
| 1850 | `org-src-font-lock-fontify-block' for automatic fontification of | ||
| 1851 | code in code blocks, controlled by variable | ||
| 1852 | `org-src-fontify-natively'. | ||
| 1853 | (org-src-fontify-natively): New variable. | ||
| 1854 | |||
| 1855 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1856 | |||
| 1857 | * ob-ruby.el (org-babel-expand-body:ruby): Removed requirement of | ||
| 1858 | inf-ruby. | ||
| 1859 | |||
| 1860 | 2010-11-11 Noorul Islam <noorul@noorul.com> (tiny change) | ||
| 1861 | |||
| 1862 | * org-html.el (org-html-make-link): (Expand-file-name ) removes | ||
| 1863 | one "/" from "///path-to-file", so add one. Anything other than | ||
| 1864 | 'file' type should be exported along with the type. | ||
| 1865 | |||
| 1866 | 2010-11-11 Noorul Islam <noorul@noorul.com> (tiny change) | ||
| 1867 | |||
| 1868 | * org.el (org-insert-subheading) : Fix compiler warning | ||
| 1869 | (org-insert-todo-subheading) : Fix compiler warning. | ||
| 1870 | |||
| 1871 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 1872 | |||
| 1873 | * org-capture.el (org-capture): Remove read-only text properties | ||
| 1874 | from capture text. | ||
| 1875 | (org-capture-set-target-location): Throw an error if file+headline | ||
| 1876 | target does not point into a file which is in Org mode. | ||
| 1877 | |||
| 1878 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1879 | |||
| 1880 | * ob.el (org-babel-map-src-blocks): Prefer `when' to `if'. | ||
| 1881 | |||
| 1882 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 1883 | |||
| 1884 | * org-src.el (org-edit-src-code): Improve docstring. | ||
| 1885 | |||
| 1886 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 1887 | |||
| 1888 | * ob.el (org-babel-execute-src-block): Document prefix argument in | ||
| 1889 | docstring. | ||
| 1890 | |||
| 1891 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 1892 | |||
| 1893 | * ob-ditaa.el (org-babel-execute:ditaa): Now expanding | ||
| 1894 | org-ditaa-jar-path with expand-file-name. | ||
| 1895 | |||
| 1896 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 1897 | |||
| 1898 | * ob.el (org-babel-execute-subtree): Pass prefix arg through to | ||
| 1899 | `org-babel-execute-src-block'. | ||
| 1900 | |||
| 1901 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 1902 | |||
| 1903 | * org-ascii.el (org-export-ascii-preprocess): Allow [@start:x] and | ||
| 1904 | [@x] syntax for list numbering. | ||
| 1905 | |||
| 1906 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 1907 | |||
| 1908 | * org.el (org-indent-line-function): Indentation of source block | ||
| 1909 | is left to `org-edit-src-exit' and shouldn't be modified by | ||
| 1910 | `org-indent-line-function'. Indentation of others blocks should be | ||
| 1911 | the same as the #+begin line. | ||
| 1912 | |||
| 1913 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 1914 | |||
| 1915 | * ob.el (org-babel-map-src-blocks): If FILE is nil evaluate BODY | ||
| 1916 | forms on source blocks in current buffer; restore point in current | ||
| 1917 | buffer. | ||
| 1918 | |||
| 1919 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 1920 | |||
| 1921 | * org-list.el (org-list-struct): Accept list boundaries as an | ||
| 1922 | argument in order to avoid computing `org-list-top-point' and | ||
| 1923 | `org-list-bottom-point' twice when indenting. | ||
| 1924 | |||
| 1925 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 1926 | |||
| 1927 | * org-list.el (org-list-ending-method): Default value is now | ||
| 1928 | `both', to ensure maximum compatibility before previous | ||
| 1929 | implementation. | ||
| 1930 | |||
| 1931 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 1932 | |||
| 1933 | * org-list.el (org-list-in-item-p-with-indent): Test if first line | ||
| 1934 | is the item beginning. | ||
| 1935 | |||
| 1936 | * org-list.el (org-list-top-point-with-indent): Test if first line | ||
| 1937 | is a valid list beginning. | ||
| 1938 | |||
| 1939 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 1940 | |||
| 1941 | * org-list.el (org-list-ending-method): New customizable variable | ||
| 1942 | to tell Org Mode how lists end. See docstring. | ||
| 1943 | |||
| 1944 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 1945 | |||
| 1946 | * org-list.el (org-indent-item-tree): Shifting step of top-level | ||
| 1947 | item depends on `org-level-increment'. | ||
| 1948 | |||
| 1949 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 1950 | |||
| 1951 | * org.el (org-indent-line-function): Indent first non blank line | ||
| 1952 | after a list according to current heading level. | ||
| 1953 | |||
| 1954 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 1955 | |||
| 1956 | * org-docbook.el (org-export-as-docbook): Removed check for | ||
| 1957 | indentation on lines that do not start with a list bullet. | ||
| 1958 | |||
| 1959 | * org-html.el (org-export-as-html): Same thing. | ||
| 1960 | |||
| 1961 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 1962 | |||
| 1963 | * org-list.el (org-list-bottom-point): Take into consideration | ||
| 1964 | that bound of search can be before true ending of the list. | ||
| 1965 | |||
| 1966 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 1967 | |||
| 1968 | * org-list.el (org-list-struct-apply-struct): No longer shift | ||
| 1969 | item's body twice: one after replacing bullet and one after | ||
| 1970 | changing indentation. | ||
| 1971 | |||
| 1972 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 1973 | |||
| 1974 | * org-list.el (org-list-struct-indent): Added code to replace | ||
| 1975 | bullets if needed when indenting. | ||
| 1976 | |||
| 1977 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 1978 | |||
| 1979 | * org-list.el (org-list-insert-item-generic): A single item | ||
| 1980 | already counting blank lines in his body should be separated with | ||
| 1981 | the next one by a blank line. Moreover, if user already provided | ||
| 1982 | blank lines, follow his wishes. | ||
| 1983 | |||
| 1984 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 1985 | |||
| 1986 | * org-list.el (org-indent-item-tree): When moving top item of a | ||
| 1987 | *-list to column 0, only the first item had its bullet changed to | ||
| 1988 | -. It now changes all items of the top-level list, as expected. | ||
| 1989 | |||
| 1990 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 1991 | |||
| 1992 | * org-list.el (org-toggle-checkbox): Go to beginning of line | ||
| 1993 | before processing. | ||
| 1994 | |||
| 1995 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 1996 | |||
| 1997 | * org-list.el (org-list-struct-apply-struct): Check if ancestor | ||
| 1998 | exists. | ||
| 1999 | |||
| 2000 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2001 | |||
| 2002 | * org-list.el (org-renumber-ordered-list): Check for [@start:x] is | ||
| 2003 | done at each item. | ||
| 2004 | |||
| 2005 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2006 | |||
| 2007 | * org-list.el : Removed unused variable | ||
| 2008 | `org-suppress-item-indentation'. | ||
| 2009 | |||
| 2010 | * org-list.el (org-renumber-ordered-list): Skip item if bullet | ||
| 2011 | number is already good. | ||
| 2012 | |||
| 2013 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2014 | |||
| 2015 | * org-list.el (org-list-automatic-rules): Doc-string reflects this | ||
| 2016 | change. | ||
| 2017 | |||
| 2018 | * org-list.el (org-indent-item-tree): Prevent whole list from | ||
| 2019 | being moved when user is not moving subtree. Thus) | ||
| 2020 | (`org-cycle-item-indentation' will not allow to move the list. | ||
| 2021 | |||
| 2022 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2023 | |||
| 2024 | * org-list.el (org-indent-item-tree): Removed region code. It was | ||
| 2025 | prone to errors and undocumented. | ||
| 2026 | |||
| 2027 | * org-list.el (org-item-indent-positions): Better heuristics to | ||
| 2028 | determine what bullet the item will have when demoted. | ||
| 2029 | |||
| 2030 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2031 | |||
| 2032 | * org-list.el (org-list-bullet-string): First check if | ||
| 2033 | `org-list-two-spaces-after-bullet-regexp' isn't nil. | ||
| 2034 | |||
| 2035 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2036 | |||
| 2037 | * org-list.el (org-list-bullet-string): Do not modify match-data. | ||
| 2038 | |||
| 2039 | * org.el (org-toggle-item): Now working again when changing list | ||
| 2040 | items into plain text. Moreover take into consideration | ||
| 2041 | `org-list-two-spaces-after-bullet-regexp'. | ||
| 2042 | |||
| 2043 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2044 | |||
| 2045 | * org-list.el (org-indent-item-tree): Removed unnecessary bullets | ||
| 2046 | fix, and improved heuristics to determine bullet when indenting. | ||
| 2047 | |||
| 2048 | * org-list.el (org-item-indent-positions): Function now returns | ||
| 2049 | sane results when there are two lists separated with blank lines | ||
| 2050 | only. | ||
| 2051 | |||
| 2052 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2053 | |||
| 2054 | * org-docbook.el (org-export-as-docbook): Use override="num" in | ||
| 2055 | any listitem matching [@start:num] | ||
| 2056 | |||
| 2057 | * org-html.el (org-export-as-html): Use value="num" in any li | ||
| 2058 | matching | ||
| 2059 | [@start:num] | ||
| 2060 | |||
| 2061 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2062 | |||
| 2063 | * org.el (org-set-font-lock-defaults): Correct fontification for | ||
| 2064 | checkboxes found after [@start:?]. | ||
| 2065 | |||
| 2066 | * org-list.el (org-list-at-regexp-after-bullet-p): Skip any | ||
| 2067 | [@start:?] when looking at a regex after a bullet. | ||
| 2068 | |||
| 2069 | * org-list.el (org-toggle-checkbox): Correct insertion of | ||
| 2070 | checkboxes when there is already a [@start:?] in the item. | ||
| 2071 | |||
| 2072 | * org-list.el (org-checkbox-blocked-p): Properly check if there's | ||
| 2073 | an unchecked item before. | ||
| 2074 | |||
| 2075 | * org-list.el (org-list-parse-list): Function handles items having | ||
| 2076 | both a counter and a checkbox. | ||
| 2077 | |||
| 2078 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2079 | |||
| 2080 | * org-list.el (org-cycle-item-indentation): Org-tab-ind-state | ||
| 2081 | stores both indentation and bullet when cycle started. | ||
| 2082 | |||
| 2083 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2084 | |||
| 2085 | * org-list.el: `org-at-description-p' renamed to | ||
| 2086 | `org-at-item-description-p', `org-first-list-item-p' renamed to | ||
| 2087 | `org-list-first-item-p', `org-end-of-item-text-before-children' | ||
| 2088 | renamed to `org-end-of-item-or-at-child'. | ||
| 2089 | |||
| 2090 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2091 | |||
| 2092 | * org.el (org-ctrl-c-ctrl-c): Call `org-fix-bullet-type' instead | ||
| 2093 | of `org-maybe-renumber-ordered-list' and `org-fix-bullet-type' | ||
| 2094 | before toggling a checkbox. | ||
| 2095 | |||
| 2096 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2097 | |||
| 2098 | * org-list.el (org-list-bullet-string): New function returning | ||
| 2099 | bullet concatenated with an appropriate number of white spaces. | ||
| 2100 | |||
| 2101 | * org-list.el (org-list-insert-item-generic): Insert the right | ||
| 2102 | bullet, with help of `org-list-bullet-string'. | ||
| 2103 | |||
| 2104 | * org-list.el (org-indent-item-tree): Use | ||
| 2105 | `org-list-bullet-string'. | ||
| 2106 | |||
| 2107 | * org-list.el (org-fix-bullet-type): Use `org-list-bullet-string'. | ||
| 2108 | |||
| 2109 | * org-list.el (org-toggle-checkbox): Send an error when | ||
| 2110 | `org-toggle-checkbox' is trying to insert a checkbox at a | ||
| 2111 | description item. | ||
| 2112 | |||
| 2113 | * org-list.el (org-item-re): Modified regexp so it can catch | ||
| 2114 | correct number of white space before item body. | ||
| 2115 | |||
| 2116 | * org-list.el (org-list-at-regexp-after-bullet-p): Take into | ||
| 2117 | consideration new `org-item-re'. | ||
| 2118 | |||
| 2119 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2120 | |||
| 2121 | * org-list.el (org-list-insert-item-generic): The second item in a | ||
| 2122 | list will be separated from its predecessor with the number of | ||
| 2123 | blank lines separating the first item from its parent, if any, or | ||
| 2124 | no blank line. | ||
| 2125 | |||
| 2126 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2127 | |||
| 2128 | * org-list.el (org-indent-item-tree): Fix and reorder every list | ||
| 2129 | and sublist, from parent of list that has moved if indenting, or | ||
| 2130 | from list at point if outdenting. | ||
| 2131 | |||
| 2132 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2133 | |||
| 2134 | * org-list.el (org-indent-item-tree): Try to keep relative | ||
| 2135 | position on line. It can't if point is in white spaces before | ||
| 2136 | bullet because mixed tabs and spaces make some columns | ||
| 2137 | unattainable. | ||
| 2138 | |||
| 2139 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2140 | |||
| 2141 | * org-list.el (org-cycle-item-indentation): Cycle when the whole | ||
| 2142 | item only contains bullet and maybe a checkbox. Previously, TAB | ||
| 2143 | would cycle when the first line of the item was blank. | ||
| 2144 | |||
| 2145 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2146 | |||
| 2147 | * org-list.el (org-cycle-item-indentation): Allow a point just | ||
| 2148 | after a description item or a checkboxed item to start cycling. | ||
| 2149 | |||
| 2150 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2151 | |||
| 2152 | * org-list.el (org-cycle-list-bullet): Check | ||
| 2153 | `org-plain-list-ordered-item-terminator' before allowing 1. or 1) | ||
| 2154 | as valid bullets when cycling. | ||
| 2155 | |||
| 2156 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2157 | |||
| 2158 | * org-list.el (org-cycle-item-indentation): Do return t if and | ||
| 2159 | only if cycling is possible and succeded. | ||
| 2160 | |||
| 2161 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2162 | |||
| 2163 | * org-list.el (org-indent-item-tree): When outdenting a subtree, | ||
| 2164 | the last item shouldn't have a children. | ||
| 2165 | |||
| 2166 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2167 | |||
| 2168 | * org-list.el (org-cycle-item-indentation): Cycling should play | ||
| 2169 | nicely with indent rule in `org-list-automatic-rules'. | ||
| 2170 | |||
| 2171 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2172 | |||
| 2173 | * org-list.el (org-indent-item-tree): If indent rule is activated, | ||
| 2174 | it should be impossible to outdent an item having children without | ||
| 2175 | moving its subtree. Improved reordering of lists modified by | ||
| 2176 | cycling indentation. | ||
| 2177 | |||
| 2178 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2179 | |||
| 2180 | * org-list.el (org-maybe-renumber-ordered-list): Removed call for | ||
| 2181 | `org-fix-bullet-type' to prevent infinite loop, and some checks | ||
| 2182 | already done in `org-renumber-ordered-list'. | ||
| 2183 | |||
| 2184 | * org-list.el (org-fix-bullet-type): Remove a check and call | ||
| 2185 | directly `org-maybe-renumber-ordered-list'. | ||
| 2186 | |||
| 2187 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2188 | |||
| 2189 | * org-list.el (org-indent-item-tree): It shouldn't be possible to | ||
| 2190 | indent the first item of a sublist (though outdent is possible) as | ||
| 2191 | it would break list's structure. | ||
| 2192 | |||
| 2193 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2194 | |||
| 2195 | * org-list.el (org-list-insert-item-generic): When local search | ||
| 2196 | doesn't help, search the list globally for blank lines. Moreover, | ||
| 2197 | don't bother with new lists, and add 1 blank line. | ||
| 2198 | |||
| 2199 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2200 | |||
| 2201 | * org-capture.el (org-capture-place-item): Use | ||
| 2202 | `org-search-forward-unenclosed' and | ||
| 2203 | `org-search-backward-unenclosed' and new variable | ||
| 2204 | `org-item-beginning-re'. | ||
| 2205 | |||
| 2206 | * org-list.el (org-item-beginning-re): Regexp matching beginning | ||
| 2207 | of an item. | ||
| 2208 | |||
| 2209 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2210 | |||
| 2211 | * org-list.el (org-cycle-list-bullet): Put back support for | ||
| 2212 | 'previous argument. | ||
| 2213 | |||
| 2214 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2215 | |||
| 2216 | * org-list.el (org-in-item-p): Handle case when point is at an | ||
| 2217 | heading. | ||
| 2218 | |||
| 2219 | * org-list.el (org-list-make-subtree): Add protection when used | ||
| 2220 | outside of list | ||
| 2221 | |||
| 2222 | * org-list.el (org-insert-item): Removed useless hack now | ||
| 2223 | `org-in-item-p' is fixed. | ||
| 2224 | |||
| 2225 | * org-timer.el (org-timer-item): Removed useless hack now | ||
| 2226 | `org-in-item-p' is fixed. | ||
| 2227 | |||
| 2228 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2229 | |||
| 2230 | * org-list.el (org-cycle-list-bullet): Prevent description items | ||
| 2231 | from being numbered. String argument is also recognized now, as | ||
| 2232 | long as it is a valid bullet. | ||
| 2233 | |||
| 2234 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2235 | |||
| 2236 | * org-list.el (org-indent-item-tree): Moving indentation of top | ||
| 2237 | list item will make the whole list move. | ||
| 2238 | |||
| 2239 | * org-list.el (org-apply-on-list): Function is less sensitive to | ||
| 2240 | changes of indentation. | ||
| 2241 | |||
| 2242 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2243 | |||
| 2244 | * org-list.el (org-at-item-checkbox-p): Add whitespaces at the end | ||
| 2245 | of the regexp. | ||
| 2246 | |||
| 2247 | * org-list.el (org-checkbox-blocked-p): Use new checkbox regexp. | ||
| 2248 | |||
| 2249 | * org-list.el (org-cycle-item-indentation): Allow cycling | ||
| 2250 | description items and checkbox items. | ||
| 2251 | |||
| 2252 | * org-list.el (org-toggle-checkbox): Use new checkbox regexp. | ||
| 2253 | |||
| 2254 | * org-list.el (org-reset-checkbox-state-subtree): Use new checkbox | ||
| 2255 | regexp. | ||
| 2256 | |||
| 2257 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2258 | |||
| 2259 | * org-list.el (org-insert-item-internal): Guessing of blank lines | ||
| 2260 | number is made by looking at neighbours items, if any. | ||
| 2261 | |||
| 2262 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2263 | |||
| 2264 | * org-list.el (org-sort-list): Add the possibility to sort timer | ||
| 2265 | lists with the ?t or ?T options. | ||
| 2266 | |||
| 2267 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2268 | |||
| 2269 | * org-list.el (org-search-unenclosed-internal): New function to | ||
| 2270 | handle both `org-search-forward-unenclosed' and | ||
| 2271 | `org-search-backward-unenclosed'. | ||
| 2272 | |||
| 2273 | * org-list.el (org-search-backward-unenclosed): Can send errors | ||
| 2274 | now. Removed useless usage of COUNT. | ||
| 2275 | |||
| 2276 | * org-list.el (org-search-forward-unenclosed): Can send errors | ||
| 2277 | now. Removed useless usage of COUNT. | ||
| 2278 | |||
| 2279 | * org-list.el (org-update-checkbox-count): Use | ||
| 2280 | `org-search-forward-unenclosed' and | ||
| 2281 | `org-search-backward-unenclosed' instead of `re-search-forward' | ||
| 2282 | and `re-search-backward'. | ||
| 2283 | |||
| 2284 | * org-list.el (org-sort-list): Use `org-search-forward-unenclosed' | ||
| 2285 | and `org-search-backward-unenclosed' instead of | ||
| 2286 | `re-search-forward' and `re-search-backward'. | ||
| 2287 | |||
| 2288 | * org-list.el (org-list-make-subtree): Use | ||
| 2289 | `org-search-forward-unenclosed' and | ||
| 2290 | `org-search-backward-unenclosed' instead of `re-search-forward' | ||
| 2291 | and `re-search-backward'. | ||
| 2292 | |||
| 2293 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2294 | |||
| 2295 | * org-list.el (org-insert-item-internal): Fixes the problem when | ||
| 2296 | point was before the first char of the item's body. | ||
| 2297 | |||
| 2298 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2299 | |||
| 2300 | * org-timer.el (org-timer-item): Refactoring. Compute timer string | ||
| 2301 | before inserting it in the buffer | ||
| 2302 | |||
| 2303 | * org-timer.el (org-timer): Added an optional argument to return | ||
| 2304 | timer string instead of inserting it. | ||
| 2305 | |||
| 2306 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2307 | |||
| 2308 | * org-list.el (org-insert-item-internal): New function to handle | ||
| 2309 | positionning and contents of an item being inserted at a specific | ||
| 2310 | pos. It is not possible anymore to split a term in a description | ||
| 2311 | list or a checkbox when inserting a new item. | ||
| 2312 | |||
| 2313 | * org-list.el (org-insert-item): Refactored by using the new | ||
| 2314 | `org-insert-item-internal' function. | ||
| 2315 | |||
| 2316 | * org-timer.el (org-timer-item): Refactored by using the new | ||
| 2317 | `org-insert-item-internal' function. | ||
| 2318 | |||
| 2319 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2320 | |||
| 2321 | * org-list.el (org-list-bottom-point): Be sure to check real | ||
| 2322 | ORG-OUTLINE-REGEXP and not outline-regexp, that might be modified. | ||
| 2323 | |||
| 2324 | * org.el (org-cycle-internal-local): Cycle up to end of subtree or | ||
| 2325 | end of item if we are in a list. | ||
| 2326 | |||
| 2327 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2328 | |||
| 2329 | * org-list.el (org-insert-item): Move before any special block in | ||
| 2330 | a list prior to add a new item. | ||
| 2331 | |||
| 2332 | * org-timer.el (org-timer-item): When in a timer list, insert a | ||
| 2333 | new timer item like `org-insert-item'. If in another list, send an | ||
| 2334 | error. Otherwise, start a new timer list. | ||
| 2335 | |||
| 2336 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2337 | |||
| 2338 | * org-list.el: Minor refactoring. | ||
| 2339 | |||
| 2340 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2341 | |||
| 2342 | * org-timer.el (org-timer-item): Insert description list item at | ||
| 2343 | the right column. | ||
| 2344 | |||
| 2345 | * org-list.el (org-insert-item): Insert the right number of blank | ||
| 2346 | lines before a relative timer. | ||
| 2347 | |||
| 2348 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2349 | |||
| 2350 | * org-list.el (org-insert-item): Remove restriction on latex | ||
| 2351 | blocks. | ||
| 2352 | |||
| 2353 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2354 | |||
| 2355 | * org-list.el (org-search-backward-unenclosed): Do not stop in | ||
| 2356 | protected places. | ||
| 2357 | |||
| 2358 | * org-list.el (org-search-forward-unenclosed): Do not stop in | ||
| 2359 | protected places. | ||
| 2360 | |||
| 2361 | * org-latex.el (org-export-latex-lists): Use the fact that | ||
| 2362 | org-search-forward do not stop anymore at protected places. | ||
| 2363 | |||
| 2364 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2365 | |||
| 2366 | * org-list.el (org-search-backward-unenclosed): Do not prevent | ||
| 2367 | list items from being inside LaTeX blocks. | ||
| 2368 | |||
| 2369 | * org-list.el (org-search-forward-unenclosed): Do not prevent list | ||
| 2370 | items from being inside LaTeX blocks. | ||
| 2371 | |||
| 2372 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2373 | |||
| 2374 | * org-list.el (org-in-item-p): Do not widen before checking if we | ||
| 2375 | are in item. | ||
| 2376 | |||
| 2377 | * org-list.el (org-list-send-list): We cannot count on | ||
| 2378 | `org-list-top-point' and `org-list-bottom-point' before buffer is | ||
| 2379 | narrowed. Find bounds of list otherwise. | ||
| 2380 | |||
| 2381 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2382 | |||
| 2383 | * org-list.el (org-list-end-regexp): By default, list ending is | ||
| 2384 | exactly 2 blank lines. | ||
| 2385 | |||
| 2386 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2387 | |||
| 2388 | * org-docbook.el (org-export-as-docbook): When we find an empty | ||
| 2389 | line, we do not need to check for | ||
| 2390 | `org-empty-line-terminates-plain-lists' because we would have | ||
| 2391 | found end-list marker before. | ||
| 2392 | |||
| 2393 | * org-html.el (org-export-as-html): Same. | ||
| 2394 | |||
| 2395 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2396 | |||
| 2397 | * org-list.el (org-insert-item): Simplify count of blank lines to | ||
| 2398 | insert. | ||
| 2399 | |||
| 2400 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2401 | |||
| 2402 | * org-list.el (org-list-end-regexp): New customizable variable to | ||
| 2403 | define what string should end lists. | ||
| 2404 | |||
| 2405 | * org-list.el (org-list-end-re): Function is now aware of | ||
| 2406 | `org-list-end-regexp'. | ||
| 2407 | |||
| 2408 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2409 | |||
| 2410 | * org-html.el (org-export-as-html): Code cleanup. | ||
| 2411 | |||
| 2412 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2413 | |||
| 2414 | * org-docbook.el (org-export-as-docbook): Properly close any open | ||
| 2415 | list when seeing ORG-LIST-END. Removed any reference to now | ||
| 2416 | unneeded DIDCLOSE variable. | ||
| 2417 | |||
| 2418 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2419 | |||
| 2420 | * org-exp.el (org-export-mark-list-ending): Fix number of blank | ||
| 2421 | lines inserted after a list. | ||
| 2422 | |||
| 2423 | * org-list.el (org-list-parse-list): Fix case when | ||
| 2424 | `org-list-end-re' would have an indentation greater than current | ||
| 2425 | list. | ||
| 2426 | |||
| 2427 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2428 | |||
| 2429 | * org-exp.el (org-export-mark-list-ending): Differentiate between | ||
| 2430 | export backends, and replace `org-list-end-re' by a blank line | ||
| 2431 | upon exporting. | ||
| 2432 | |||
| 2433 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2434 | |||
| 2435 | * org-html.el (org-export-as-html): Delete didclose and everything | ||
| 2436 | related to it, as it is no longer needed. | ||
| 2437 | |||
| 2438 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2439 | |||
| 2440 | * org-html.el (org-export-html-preprocess): Remove unneeded | ||
| 2441 | insertion of list end marker, as it is now handled by | ||
| 2442 | `org-export-mark-list-ending'. | ||
| 2443 | |||
| 2444 | * org-html.el (org-export-as-html): Cleaner termination of lists. | ||
| 2445 | |||
| 2446 | * org-exp.el (org-export-mark-list-ending): New function to insert | ||
| 2447 | specific markers at the end of lists when exporting to a backend | ||
| 2448 | not using `org-list-parse-list'. This function is called early in | ||
| 2449 | `org-export-preprocess-string', while it is still able to | ||
| 2450 | recognize lists. | ||
| 2451 | |||
| 2452 | * org-latex.el (org-export-latex-lists): Better search for | ||
| 2453 | lists. It now only finds items not enclosed and not protected. | ||
| 2454 | |||
| 2455 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2456 | |||
| 2457 | * org-list.el: Replaced `re-search-forward' by | ||
| 2458 | `org-search-forward-unenclosed' where it made sense. | ||
| 2459 | |||
| 2460 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2461 | |||
| 2462 | * org-list.el (org-apply-to-list): Now a return value is handed at | ||
| 2463 | each new call of the function applied. | ||
| 2464 | |||
| 2465 | * org-list.el (org-fix-bullet-type): Use the new | ||
| 2466 | `org-apply-to-list' format. | ||
| 2467 | |||
| 2468 | * org-list.el (org-renumber-ordered-list): Use the new | ||
| 2469 | `org-apply-to-list' format. | ||
| 2470 | |||
| 2471 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2472 | |||
| 2473 | * org.el (org-in-regexps-block-p): Minor fix: limit wasn't | ||
| 2474 | correctly used. | ||
| 2475 | |||
| 2476 | * org-list.el (org-search-forward-unenclosed): Better regexp used. | ||
| 2477 | |||
| 2478 | * org-list.el (org-search-backward-unenclosed): Better regexp | ||
| 2479 | used. | ||
| 2480 | |||
| 2481 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2482 | |||
| 2483 | * org-list.el (org-sort-list): End-rec function was ill-defined. | ||
| 2484 | |||
| 2485 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2486 | |||
| 2487 | * org-list.el (org-search-forward-unenclosed): Fix behavior when | ||
| 2488 | last occurence was enclosed. | ||
| 2489 | |||
| 2490 | * org-list.el (org-search-backward-unenclosed): Fix behavior when | ||
| 2491 | last occurence was enclosed. | ||
| 2492 | |||
| 2493 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2494 | |||
| 2495 | * org.el (org-in-regexps-block-p): Fix documentation. | ||
| 2496 | |||
| 2497 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2498 | |||
| 2499 | * org-list.el (org-search-backward-unenclosed): Fix block regexp. | ||
| 2500 | |||
| 2501 | * org-list.el (org-search-forward-unenclosed): Fix block regexp. | ||
| 2502 | |||
| 2503 | * org-list.el (org-list-parse-list): Minor fix. | ||
| 2504 | |||
| 2505 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2506 | |||
| 2507 | * org-list.el (org-list-parse-list): Delete `org-list-end-re' when | ||
| 2508 | called with t argument. | ||
| 2509 | |||
| 2510 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2511 | |||
| 2512 | * org-html.el (org-export-html-preprocess): Replace | ||
| 2513 | `org-list-end-re' by a blank line during pre-process. | ||
| 2514 | |||
| 2515 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2516 | |||
| 2517 | * org-list.el (org-list-bottom-point): No need for square brackets | ||
| 2518 | for `skip-chars-backward'. | ||
| 2519 | |||
| 2520 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2521 | |||
| 2522 | * org-html.el: Do not delete space between end of list and | ||
| 2523 | beginning of the following. | ||
| 2524 | |||
| 2525 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2526 | |||
| 2527 | * org-html.el: preprocess buffer string and add ORG-LIST-END where | ||
| 2528 | needed. Lists should not end before seeing this. | ||
| 2529 | |||
| 2530 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2531 | |||
| 2532 | * org-html.el: Notice end of lists. | ||
| 2533 | |||
| 2534 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2535 | |||
| 2536 | * org-list.el (org-list-parse-list): Better handling of | ||
| 2537 | restrictions when function is called on a list with sublists. | ||
| 2538 | |||
| 2539 | * org-list.el (org-list-send-list): Find the true ending of the | ||
| 2540 | list being sent. | ||
| 2541 | |||
| 2542 | * org-list.el (org-list-radio-list-templates): Templates are more | ||
| 2543 | specific to lists. | ||
| 2544 | |||
| 2545 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 2546 | |||
| 2547 | * ob-js.el (org-babel-js-eoe): Indicate end of input | ||
| 2548 | (org-babel-execute:js): Support for session evaluation | ||
| 2549 | (org-babel-prep-session:js): Fleshed out definition | ||
| 2550 | (org-babel-js-initiate-session): Can initiate a session using | ||
| 2551 | mozrepl. | ||
| 2552 | |||
| 2553 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 2554 | |||
| 2555 | * org.el (org-set-regexps-and-options): Protect escape char in | ||
| 2556 | `org-complex-heading-regexp-format'. | ||
| 2557 | |||
| 2558 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 2559 | |||
| 2560 | * ob-scheme.el (org-babel-scheme-eoe): For marking the end of | ||
| 2561 | session-based evaluation | ||
| 2562 | (org-babel-execute:scheme): Now supports session-based evaluation | ||
| 2563 | (org-babel-prep-session:scheme): Now works and defines variables | ||
| 2564 | (org-babel-scheme-initiate-session): Now works using run-scheme | ||
| 2565 | from cmuscheme. | ||
| 2566 | |||
| 2567 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 2568 | |||
| 2569 | * org.el (org-export-latex-default-packages-alist): Remove the | ||
| 2570 | t1enc package - this is already covered by fontenc. | ||
| 2571 | |||
| 2572 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 2573 | |||
| 2574 | * ob.el (with-parsed-tramp-file-name): Declared | ||
| 2575 | (org-babel-tramp-localname): Ensure variable name exists locally. | ||
| 2576 | |||
| 2577 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 2578 | |||
| 2579 | * ob.el (org-babel-temp-file): Don't use babel temporary directory | ||
| 2580 | in remote case; use make-temp-file with remote file name so that | ||
| 2581 | temp file is guaranteed not to exist previously on remote machine. | ||
| 2582 | (org-babel-tramp-localname): New function to return local name | ||
| 2583 | portion of possibly remote file specification. | ||
| 2584 | |||
| 2585 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 2586 | |||
| 2587 | * ob-R.el (org-babel-R-write-object-command): New unified R | ||
| 2588 | command for writing results to file | ||
| 2589 | (org-babel-R-wrapper-method): Remove variable | ||
| 2590 | (org-babel-R-wrapper-lastvar): Remove variable | ||
| 2591 | (org-babel-R-evaluate-external-process): Use new R command | ||
| 2592 | (org-babel-R-evaluate-session): Use new R command. | ||
| 2593 | |||
| 2594 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 2595 | |||
| 2596 | * ob-comint.el | ||
| 2597 | (org-babel-comint-eval-invisibly-and-wait-for-file): New function | ||
| 2598 | to evaluate code invisibly and block until output file exists. | ||
| 2599 | |||
| 2600 | * ob-R.el (org-babel-R-evaluate-session): Use `ess-eval-buffer' to | ||
| 2601 | evaluate R code in session for :results value. Write result to | ||
| 2602 | file invisibly using new function | ||
| 2603 | `org-babel-comint-eval-invisibly-and-wait-for-file'. | ||
| 2604 | |||
| 2605 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 2606 | |||
| 2607 | * org-capture.el (org-capture-fill-template): Align tags after | ||
| 2608 | insertion. | ||
| 2609 | |||
| 2610 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 2611 | |||
| 2612 | * org-exp.el (org-export-concatenate-multiline-emphasis): Ignore | ||
| 2613 | matches that start in a headline. | ||
| 2614 | |||
| 2615 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 2616 | |||
| 2617 | * ob-plantuml.el (org-babel-execute:plantuml): Wrapping in-file | ||
| 2618 | and out-file in shell-quote-argument. | ||
| 2619 | |||
| 2620 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 2621 | |||
| 2622 | * org-docview.el (org-docview-store-link): Use expanded macro to | ||
| 2623 | get current page. | ||
| 2624 | (doc-view-goto-page, image-mode-window-get): Declare functions for | ||
| 2625 | byte compiler. | ||
| 2626 | |||
| 2627 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 2628 | |||
| 2629 | * ob-scheme.el: very preliminary support for evaluating scheme | ||
| 2630 | code blocks | ||
| 2631 | |||
| 2632 | * org.el (org-babel-load-languages): Adding scheme. | ||
| 2633 | |||
| 2634 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 2635 | |||
| 2636 | * ob.el (require): Remove circular (require 'org). | ||
| 2637 | |||
| 2638 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 2639 | |||
| 2640 | * ob-R.el (ess-make-buffer-current): Declared | ||
| 2641 | (ess-ask-for-ess-directory): Declared | ||
| 2642 | (ess-local-process-name): Declared | ||
| 2643 | |||
| 2644 | * ob-latex.el (org-babel-latex-tex-to-pdf): Capturing free | ||
| 2645 | variable | ||
| 2646 | |||
| 2647 | * ob.el (org-edit-src-code): Fixing arguments | ||
| 2648 | (org-edit-src-exit): Declared | ||
| 2649 | (org-outline-overlay-data): Declared | ||
| 2650 | (org-set-outline-overlay-data): Declared. | ||
| 2651 | |||
| 2652 | 2010-11-11 Glenn Morris <rgm@gnu.org> | ||
| 2653 | |||
| 2654 | * ob.el: Require org when compiling. | ||
| 2655 | (org-save-outline-visibility): Remove macro declaration. | ||
| 2656 | |||
| 2657 | * ob-emacs-lisp.el: Require ob-comint when compiling, for macros. | ||
| 2658 | Remove unnecessary/macro declarations. | ||
| 2659 | |||
| 2660 | * org-docview.el: Require doc-view when compiling. | ||
| 2661 | (doc-view-goto-page): Autoload rather than declaring. | ||
| 2662 | (doc-view-current-page): Remove macro declaration. | ||
| 2663 | |||
| 2664 | * ob.el (tramp-compat-make-temp-file, org-edit-src-code) | ||
| 2665 | (org-entry-get, org-table-import): Fix declarations. | ||
| 2666 | (org-match-string-no-properties): Remove declaration. | ||
| 2667 | |||
| 2668 | * ob-sh.el (org-babel-comint-in-buffer) | ||
| 2669 | (org-babel-comint-wait-for-output, org-babel-comint-buffer-livep) | ||
| 2670 | (org-babel-comint-with-output): Remove unnecessary declarations. | ||
| 2671 | |||
| 2672 | * ob-R.el (orgtbl-to-tsv): Fix declaration. | ||
| 2673 | |||
| 2674 | * org-list.el (org-entry-get): Fix declaration. | ||
| 2675 | |||
| 2676 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 2677 | |||
| 2678 | * ob.el (org-babel-remove-temporary-directory): Removed explicit | ||
| 2679 | second argument. | ||
| 2680 | |||
| 2681 | 2010-11-11 Magnus Henoch <magnus.henoch@gmail.com> (tiny change) | ||
| 2682 | |||
| 2683 | * org-clock.el (org-clocktable-steps): Allow ts and te to be day | ||
| 2684 | numbers. | ||
| 2685 | |||
| 2686 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 2687 | |||
| 2688 | * org-macs.el (org-save-outline-visibility): Moved from org.el. | ||
| 2689 | |||
| 2690 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 2691 | |||
| 2692 | * ob-org.el (org-babel-default-header-args:org): Additional | ||
| 2693 | ":results silent" default header argument for org code blocks. | ||
| 2694 | |||
| 2695 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 2696 | |||
| 2697 | * ob-exp.el (org-babel-exp-do-export): Remove hacky ":noeval", | ||
| 2698 | which is now an alias to ":eval no" | ||
| 2699 | |||
| 2700 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 2701 | |||
| 2702 | * ob.el (org-babel-remove-temporary-directory): The version of | ||
| 2703 | `delete-directory' found in files.el can not be assumed to be | ||
| 2704 | present on all versions, so this copies the recursive behavior of | ||
| 2705 | that command in such a way that all calls to delete-directory will | ||
| 2706 | also work with the built-in internal C implementation of that | ||
| 2707 | function. This is not overly difficult as all elements of the | ||
| 2708 | directory can be assumed to be files. | ||
| 2709 | |||
| 2710 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 2711 | |||
| 2712 | * ob-C.el (org-babel-C-execute): Corrected arguments to | ||
| 2713 | org-babel-temp-file. | ||
| 2714 | |||
| 2715 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 2716 | |||
| 2717 | * ob.el (org-babel-temporary-directory): Variable to hold the | ||
| 2718 | value of the Babel temporary directory. | ||
| 2719 | |||
| 2720 | 2010-11-11 Aditya Siram <aditya.siram@gmail.com> | ||
| 2721 | |||
| 2722 | * ob.el (org-babel-load-in-session): Expanding noweb references | ||
| 2723 | when appropriate. | ||
| 2724 | |||
| 2725 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 2726 | |||
| 2727 | * org.el (org-make-link-regexps): Modified regexp of | ||
| 2728 | org-plain-link-re. | ||
| 2729 | |||
| 2730 | 2010-11-11 Noorul Islam <noorul@noorul.com> (tiny change) | ||
| 2731 | |||
| 2732 | * org-habit.el (org-habit-parse-todo): Find sr-days only if | ||
| 2733 | scheduled-repeat is non nil. Use 4th element of the list returned | ||
| 2734 | by (org-heading-components) as habit-entry. Modify the error | ||
| 2735 | message to be more meaningful. | ||
| 2736 | |||
| 2737 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 2738 | |||
| 2739 | * ob-latex.el (org-babel-execute:latex): Adding new ":fit" and | ||
| 2740 | ":border" header arguments which both use the "preview" latex | ||
| 2741 | package to fit the resulting pdf image to the figure. | ||
| 2742 | |||
| 2743 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 2744 | |||
| 2745 | * org-wl.el (org-wl-store-link): Don't try to store link if point | ||
| 2746 | is at end of buffer. | ||
| 2747 | |||
| 2748 | 2010-11-11 Harri Kiiskinen <harkiisk@gmail.com> | ||
| 2749 | |||
| 2750 | * org-publish.el (org-publish-project-alist): Document the new | ||
| 2751 | body-only property. | ||
| 2752 | (org-publish-org-to): Use the body-only property. | ||
| 2753 | |||
| 2754 | 2010-11-11 Jambunathan K <kjambunathan@gmail.com> (tiny change) | ||
| 2755 | |||
| 2756 | * org.el (org-store-link): Return link when invoked | ||
| 2757 | non-interactively from an agenda buffer. | ||
| 2758 | |||
| 2759 | 2010-11-11 Jambunathan K <kjambunathan@gmail.com> (tiny change) | ||
| 2760 | |||
| 2761 | * org.el (org-store-link): Storing of links to headlines in | ||
| 2762 | indirect buffers was broken. Fix it. | ||
| 2763 | |||
| 2764 | 2010-11-11 Aidan Kehoe <kehoea@parhasard.net> | ||
| 2765 | |||
| 2766 | * ob-tangle.el (org-babel-tangle): Change the MODE argument to | ||
| 2767 | #'set-file-modes to use integer, not character syntax, avoiding | ||
| 2768 | compile problems with recent XEmacs. | ||
| 2769 | |||
| 2770 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 2771 | |||
| 2772 | * org-agenda.el (org-agenda-add-entry-text): Make sure we move | ||
| 2773 | forward even if there is no text to be added. | ||
| 2774 | |||
| 2775 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 2776 | |||
| 2777 | * org.el (org-make-tags-matcher): Read "\\-" as "-" in the | ||
| 2778 | tags/property matcher. | ||
| 2779 | |||
| 2780 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 2781 | |||
| 2782 | * org-exp.el (org-infile-export-plist): Bind case-fold-search to | ||
| 2783 | t. | ||
| 2784 | |||
| 2785 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 2786 | |||
| 2787 | * org-agenda.el (org-agenda-with-point-at-orig-entry): New macro. | ||
| 2788 | |||
| 2789 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 2790 | |||
| 2791 | * org-latex.el (org-export-latex-set-initial-vars): Bind | ||
| 2792 | `case-fold-search' to t around the search for special LaTeX setup. | ||
| 2793 | |||
| 2794 | * org-beamer.el (org-beamer-after-initial-vars): Bind | ||
| 2795 | `case-fold-search' to t around the search for special BEAMER | ||
| 2796 | setup. | ||
| 2797 | |||
| 2798 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 2799 | |||
| 2800 | * org-agenda.el (org-write-agenda): Delete postscript file after | ||
| 2801 | creating conversion to pdf. | ||
| 2802 | |||
| 2803 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 2804 | |||
| 2805 | * org-agenda.el (org-write-agenda): Move require statements to | ||
| 2806 | proper place in evaluated lisp expression. | ||
| 2807 | |||
| 2808 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 2809 | |||
| 2810 | * org-agenda.el (org-write-agenda): Rename temporary buffer to | ||
| 2811 | remove dependency of `flet' macro. | ||
| 2812 | |||
| 2813 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 2814 | |||
| 2815 | * ob-lob.el (org-babel-lob-get-info): Edit docstring. | ||
| 2816 | |||
| 2817 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 2818 | |||
| 2819 | * ob-exp.el (org-babel-exp-lob-one-liners): Get parameter values | ||
| 2820 | from all standard sources when executing #+lob/#+call lines. | ||
| 2821 | |||
| 2822 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 2823 | |||
| 2824 | * ob-R.el (org-babel-R-evaluate): Break the two branches into two | ||
| 2825 | separate functions | ||
| 2826 | (org-babel-R-evaluate-external-process): New function to handle | ||
| 2827 | external process evaluation | ||
| 2828 | (org-babel-R-evaluate-session): New function to handle session | ||
| 2829 | evaluation. | ||
| 2830 | |||
| 2831 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 2832 | |||
| 2833 | * ob.el (org-babel-initiate-session): New function derived from | ||
| 2834 | previous `org-babel-switch-to-session' | ||
| 2835 | (org-babel-switch-to-session): Refactored to use new | ||
| 2836 | `org-babel-initiate-session'. | ||
| 2837 | |||
| 2838 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 2839 | |||
| 2840 | * ob.el (org-babel-switch-to-session): Supply missing "P" argument | ||
| 2841 | to (interactive). | ||
| 2842 | |||
| 2843 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 2844 | |||
| 2845 | * org-feed.el (org-feed-format-entry): Decode entry according to | ||
| 2846 | its character encoding. | ||
| 2847 | |||
| 2848 | 2010-11-11 David Maus <dmaus@ictsoc.de> (tiny change) | ||
| 2849 | |||
| 2850 | * org-feed.el (xml-substitute-special): Declare function for byte | ||
| 2851 | compiler. | ||
| 2852 | (org-feed-unescape): Removed. | ||
| 2853 | (org-feed-parse-rss-entry, org-feed-parse-atom-entry): Use | ||
| 2854 | `xml-substitute-special' to unescape XML entities. | ||
| 2855 | |||
| 2856 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 2857 | |||
| 2858 | * ob.el (org-babel-switch-to-session): Throw error if block if | ||
| 2859 | :session not in effect for the block. | ||
| 2860 | |||
| 2861 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 2862 | |||
| 2863 | * org-table.el (org-table-create-with-table.el): Align table | ||
| 2864 | before converting. | ||
| 2865 | |||
| 2866 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 2867 | |||
| 2868 | * ob.el (org-babel-do-in-edit-buffer): Suppress message and check | ||
| 2869 | that org-src buffer is current before attempting exit. | ||
| 2870 | |||
| 2871 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 2872 | |||
| 2873 | * org-src.el (ob-comint): Require 'ob-comint | ||
| 2874 | (org-src-babel-info): Define variable. | ||
| 2875 | |||
| 2876 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 2877 | |||
| 2878 | * ob.el (org-babel-do-in-edit-buffer): New macro to evaluate lisp | ||
| 2879 | in the language major mode edit buffer. | ||
| 2880 | (org-babel-do-key-sequence-in-edit-buffer): New function to call | ||
| 2881 | an arbitrary key sequence in the language major mode edit buffer | ||
| 2882 | |||
| 2883 | * org-src.el (org-src-switch-to-buffer): Add new allowed value | ||
| 2884 | 'switch-invisibly for `org-src-window-setup'. | ||
| 2885 | |||
| 2886 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 2887 | |||
| 2888 | * org-src.el (ob-keys): Require ob-keys, because `org-babel-map' | ||
| 2889 | is used. | ||
| 2890 | (org-src-do-at-code-block): New macro to evaluate lisp with point | ||
| 2891 | at the start of the Org code block containing the code in this | ||
| 2892 | edit buffer. | ||
| 2893 | (org-src-do-key-sequence-at-code-block): New function to execute | ||
| 2894 | command bound to key at the Org code block containing the code in | ||
| 2895 | this edit buffer. | ||
| 2896 | |||
| 2897 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 2898 | |||
| 2899 | * ob-R.el (org-babel-R-associate-session): New function to | ||
| 2900 | associate R code edit buffers with ESS comint session. | ||
| 2901 | |||
| 2902 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 2903 | |||
| 2904 | * org-src.el (org-edit-src-code): If at src block, store babel | ||
| 2905 | info as buffer local variable. | ||
| 2906 | (org-src-associate-babel-session): New function to associate code | ||
| 2907 | edit buffer with comint session. Does nothing unless a | ||
| 2908 | language-specific function named | ||
| 2909 | `org-babel-LANG-associate-session' exists. | ||
| 2910 | (org-src-babel-configure-edit-buffer): New function to be called | ||
| 2911 | in `org-src-mode-hook'. | ||
| 2912 | (org-src-mode-hook): Add `org-src-babel-configure-edit-buffer' to | ||
| 2913 | hook. | ||
| 2914 | |||
| 2915 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 2916 | |||
| 2917 | * ob.el (org-babel-switch-to-session-with-code): New function to | ||
| 2918 | generate split frame displaying edit buffer and session. | ||
| 2919 | |||
| 2920 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 2921 | |||
| 2922 | * org.el (org-set-tags): Consider org-indent-mode when computing | ||
| 2923 | the tags column. | ||
| 2924 | |||
| 2925 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 2926 | |||
| 2927 | * org-compat.el (org-looking-at-p): Only use looking-at-p when | ||
| 2928 | defined. | ||
| 2929 | |||
| 2930 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 2931 | |||
| 2932 | * org-agenda.el (org-finalize-agenda-entries): Delete excluded | ||
| 2933 | lines directly after call to sorting filter function. | ||
| 2934 | |||
| 2935 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 2936 | |||
| 2937 | * org.el (org-complex-heading-regexp-format): Document the | ||
| 2938 | variable. | ||
| 2939 | (org-get-refile-targets): Use `org-complex-heading-regexp-format' | ||
| 2940 | to make the regular expression for matching the headline. | ||
| 2941 | |||
| 2942 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 2943 | |||
| 2944 | * org.el (org-refile-check-position): New function. | ||
| 2945 | (org-goto): | ||
| 2946 | (org-refile-get-location): Call `org-refile-check-position'. | ||
| 2947 | |||
| 2948 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 2949 | |||
| 2950 | * ob-python.el (org-babel-python-initiate-session-by-key): Use eq | ||
| 2951 | instead of equal to compare symbols. | ||
| 2952 | |||
| 2953 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 2954 | |||
| 2955 | * org-agenda.el (org-agenda-before-sorting-filter-function): New | ||
| 2956 | hook function. | ||
| 2957 | (org-finalize-agenda-entries): Apply | ||
| 2958 | `org-agenda-before-sorting-filter-function'. | ||
| 2959 | |||
| 2960 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 2961 | |||
| 2962 | * org-latex.el (org-export-latex-first-lines): Do not protect meta | ||
| 2963 | lines that have nothing to do with babel. | ||
| 2964 | |||
| 2965 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 2966 | |||
| 2967 | * org-capture.el (org-capture-place-template): Handle the | ||
| 2968 | checkitem case. | ||
| 2969 | (org-capture-place-item): Provide boundaries for the search to | ||
| 2970 | make sure we do not get a match in a different tree. | ||
| 2971 | |||
| 2972 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 2973 | |||
| 2974 | * org-exp.el (org-export-preprocess-apply-macros): Fix the macro | ||
| 2975 | argument parser. | ||
| 2976 | |||
| 2977 | 2010-11-11 Noorul Islam <noorul@noorul.com> | ||
| 2978 | |||
| 2979 | * org-latex.el (org-latex-to-pdf-process): Add output-directory | ||
| 2980 | option for the command pdflatex. | ||
| 2981 | (org-export-as-pdf): Respect directory in path of | ||
| 2982 | EXPORT_FILE_NAME. | ||
| 2983 | |||
| 2984 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 2985 | |||
| 2986 | * org-exp.el (org-export-with-LaTeX-fragments): New default t, | ||
| 2987 | which now means to use MathJax processing for HTML. Also allow | ||
| 2988 | new value `dvipng' to force the old image processing. | ||
| 2989 | (org-infile-export-plist): Parse for MATHJAX setup line. | ||
| 2990 | |||
| 2991 | * org-html.el (org-export-html-mathjax-options): New option. | ||
| 2992 | (org-export-html-mathjax-config): New function. | ||
| 2993 | (org-export-html-mathjax-template): New option. | ||
| 2994 | (org-export-html-preprocess): Call the LaTeX snippet processor | ||
| 2995 | with an additional argument to declare special ways of processing. | ||
| 2996 | (org-export-as-html): Bind the dynamical variable | ||
| 2997 | `org-export-have-math'. Insert the MathJax script template when | ||
| 2998 | it is needed by the document. | ||
| 2999 | |||
| 3000 | * org.el (org-preview-latex-fragment): Call `org-format-latex' | ||
| 3001 | with the additional processing argument. | ||
| 3002 | (org-export-have-math): New variable, for dynamic scoping. | ||
| 3003 | (org-format-latex): Implement specific ways of processing. New | ||
| 3004 | function argument for processing type. | ||
| 3005 | (org-org-menu): Remove the entry to configure LaTeX snippet | ||
| 3006 | processing. | ||
| 3007 | |||
| 3008 | 2010-11-11 Bastien Guerry <bzg@altern.org> | ||
| 3009 | |||
| 3010 | * org-agenda.el (org-agenda-clock-goto): Use `\C-c\C-x\C-j' for | ||
| 3011 | `org-clock-goto' and `J' for `org-agenda-clock-goto'. If the | ||
| 3012 | heading currently clocked in is not listed in the agenda, display | ||
| 3013 | this entry in another buffer. If there is no running clock, | ||
| 3014 | display a help message. | ||
| 3015 | |||
| 3016 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 3017 | |||
| 3018 | * org-latex.el (org-export-latex-tables): Return "" instead of nil | ||
| 3019 | when no label is attached. | ||
| 3020 | |||
| 3021 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 3022 | |||
| 3023 | * org-agenda.el (org-agenda-menu-show-match): New option. | ||
| 3024 | (org-agenda-menu-two-column): New option. | ||
| 3025 | (org-agenda-get-restriction-and-command): Implement dispatch menu | ||
| 3026 | without showing the matcher, and with two-column display. | ||
| 3027 | |||
| 3028 | 2010-11-11 Bernt Hansen <bernt@norang.ca> | ||
| 3029 | |||
| 3030 | * org-indent.el (org-indent-mode): Fix grammar for message when | ||
| 3031 | mode is refused. | ||
| 3032 | |||
| 3033 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 3034 | |||
| 3035 | * ob.el (org-babel-insert-result): Ensures `beg' is set, even if | ||
| 3036 | no previous result exists. | ||
| 3037 | |||
| 3038 | 2010-11-11 Noorul Islam <noorul@noorul.com> | ||
| 3039 | |||
| 3040 | * ob.el Declare org-babel-lob-execute-maybe() to avoid compiler | ||
| 3041 | warning. | ||
| 3042 | |||
| 3043 | 2010-11-11 Noorul Islam <noorul@noorul.com> | ||
| 3044 | |||
| 3045 | * org.el: org-set-visibility-according-to-property () Use backward | ||
| 3046 | search instead of forward, so that top hierarchy gets priority. | ||
| 3047 | |||
| 3048 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 3049 | |||
| 3050 | * org-agenda.el (org-timeline): Allow indirect buffer. | ||
| 3051 | |||
| 3052 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 3053 | |||
| 3054 | * org-exp.el (org-export-preprocess-after-radio-targets-hook): | ||
| 3055 | (org-export-define-heading-targets-headline-hook): New hooks. | ||
| 3056 | |||
| 3057 | * org.el (org-modules): Add entry for org-wikinodes.el. | ||
| 3058 | (org-font-lock-set-keywords-hook): New hook. | ||
| 3059 | (org-open-at-point-functions): New hook. | ||
| 3060 | (org-find-exact-headling-in-buffer): | ||
| 3061 | (org-find-exact-heading-in-directory): New functions. | ||
| 3062 | (org-mode-flyspell-verify): Better cursor position for checking if | ||
| 3063 | flyspell should ignore a word. | ||
| 3064 | |||
| 3065 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 3066 | |||
| 3067 | * org-indent.el (org-indent-remove-properties): | ||
| 3068 | (org-indent-add-properties): Make sure changing these properties | ||
| 3069 | does not trigger modification hooks. | ||
| 3070 | |||
| 3071 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 3072 | |||
| 3073 | * org.el (org-link-search-must-match-exact-headline): New option. | ||
| 3074 | (org-link-search-inhibit-query): New variable. | ||
| 3075 | (org-link-search): Search for exact headline match in Org files. | ||
| 3076 | |||
| 3077 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 3078 | |||
| 3079 | * ob.el (org-babel-execute-src-block-maybe): Remove check for | ||
| 3080 | `org-babel-no-eval-on-ctrl-c-ctrl-c'; this is done in the new | ||
| 3081 | function `org-babel-execute-safely-maybe'. | ||
| 3082 | |||
| 3083 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 3084 | |||
| 3085 | * ob.el (org-babel-load-in-session): Set directory in case :dir | ||
| 3086 | arg is in effect. | ||
| 3087 | |||
| 3088 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 3089 | |||
| 3090 | * ob-tangle.el (org-babel-tangle-collect-blocks): Don't throw | ||
| 3091 | errors when we're not under of a headline. | ||
| 3092 | |||
| 3093 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 3094 | |||
| 3095 | * ob-octave.el (org-babel-octave-wrapper-method): Use dlmwrite to | ||
| 3096 | write delimited text instead of save -ascii | ||
| 3097 | (org-babel-octave-import-elisp-from-file): Specify that data | ||
| 3098 | written to file is tab-delimited. | ||
| 3099 | |||
| 3100 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 3101 | |||
| 3102 | * ob-R.el (org-babel-R-evaluate): Specify that tabular data is | ||
| 3103 | tab-delimited. | ||
| 3104 | |||
| 3105 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 3106 | |||
| 3107 | * ob.el (org-babel-import-elisp-from-file): Allow separator to be | ||
| 3108 | specified. | ||
| 3109 | |||
| 3110 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 3111 | |||
| 3112 | * ob-python.el (org-babel-python-table-or-string): Fix recognition | ||
| 3113 | of lists and tuples. | ||
| 3114 | |||
| 3115 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 3116 | |||
| 3117 | * ob-octave.el (org-babel-octave-evaluate-external-process): Allow | ||
| 3118 | remote files. | ||
| 3119 | |||
| 3120 | 2010-11-11 Juan Pechiar <pechiar@computer.org> | ||
| 3121 | |||
| 3122 | * ob-octave.el (org-babel-octave-evaluate-external-process): Use | ||
| 3123 | `org-babel-octave-import-elisp-from-file' instead of | ||
| 3124 | `org-babel-eval-read-file'. | ||
| 3125 | (org-babel-octave-var-to-octave): Separate matrix rows with ';', | ||
| 3126 | and use '%s' as format specifier instead of '%S'. | ||
| 3127 | |||
| 3128 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 3129 | |||
| 3130 | * ob-octave.el only (require 'matlab) when necessary | ||
| 3131 | (org-babel-octave-initiate-session) (require) octave-inf or matlab | ||
| 3132 | as appropriate | ||
| 3133 | (org-babel-execute:matlab): Remove (require) | ||
| 3134 | (org-babel-prep-session:matlab): Remove (require) | ||
| 3135 | (org-babel-matlab-initiate-session): Remove (require). | ||
| 3136 | |||
| 3137 | 2010-11-11 Dan Davison <davison@stats.ox.ac.uk> | ||
| 3138 | |||
| 3139 | * ob-octave.el (org-babel-octave-evaluate): Fix formal argument | ||
| 3140 | list. | ||
| 3141 | |||
| 3142 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 3143 | |||
| 3144 | * ob-python.el (org-babel-python-table-or-string): Can now handle | ||
| 3145 | VERY long result lines. | ||
| 3146 | |||
| 3147 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 3148 | |||
| 3149 | * org-latex.el (org-export-latex-tables): Add label if any | ||
| 3150 | |||
| 3151 | * org-latex.el (org-export-latex-convert-table.el-table): Fix | ||
| 3152 | little mistake when inserting label. | ||
| 3153 | |||
| 3154 | 2010-11-11 Nicolas Goaziou <n.goaziou@gmail.com> | ||
| 3155 | |||
| 3156 | * org.el (org-cycle-internal-local): Removed an unnecessary call | ||
| 3157 | to `org-back-to-heading' that was preventing point to stay at its | ||
| 3158 | column when cycling visibility. | ||
| 3159 | |||
| 3160 | 2010-11-11 Noorul Islam <noorul@noorul.com> | ||
| 3161 | |||
| 3162 | * org-capture.el (org-capture-finalize): Make messages consistent. | ||
| 3163 | |||
| 3164 | 2010-11-11 Noorul Islam <noorul@noorul.com> | ||
| 3165 | |||
| 3166 | * org-gnus.el: Suppress compiler warning by declaring outside | ||
| 3167 | function nnimap-retrieve-headers-from-file. | ||
| 3168 | |||
| 3169 | 2010-11-11 Noorul Islam <noorul@noorul.com> | ||
| 3170 | |||
| 3171 | * org-colview.el Use org-beamer-select-environment instead of | ||
| 3172 | org-beamer-set-environment-tag. | ||
| 3173 | |||
| 3174 | 2010-11-11 Matt Lundin <mdl@imapmail.org> | ||
| 3175 | |||
| 3176 | * org.el (org-insert-time-stamp): Fix org-insert-time-stamp so | ||
| 3177 | that the value of org-last-inserted-timestamp includes time range. | ||
| 3178 | |||
| 3179 | 2010-11-11 David Maus <dmaus@ictsoc.de> | ||
| 3180 | |||
| 3181 | * org-wl.el (org-wl-store-link-message): Provide link property for | ||
| 3182 | message-id without angle brackets. | ||
| 3183 | |||
| 3184 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 3185 | |||
| 3186 | * ob-R.el (org-babel-R-evaluate): Improved prompt-stripping regexp. | ||
| 3187 | |||
| 3188 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 3189 | |||
| 3190 | * ob-tangle.el (org-babel-find-file-noselect-refresh): Finds a | ||
| 3191 | file ensuing that the latest changes on disk are represented. | ||
| 3192 | |||
| 3193 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 3194 | |||
| 3195 | * ob-sqlite.el (org-babel-sqlite-expand-vars): Now inserts string | ||
| 3196 | arguments w/o quotes. | ||
| 3197 | |||
| 3198 | 2010-11-11 Bernt Hansen <bernt@norang.ca> | ||
| 3199 | |||
| 3200 | * org-capture.el (org-capture-finalize): Fix clock in of | ||
| 3201 | interrupted task during capture finalize. | ||
| 3202 | |||
| 3203 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 3204 | |||
| 3205 | * ob-R.el (org-babel-R-evaluate): Clean up extra prompts in | ||
| 3206 | session output. | ||
| 3207 | |||
| 3208 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 3209 | |||
| 3210 | * ob-C.el (org-babel-C-ensure-main-wrap): More generous regular | ||
| 3211 | expression for matching main function. | ||
| 3212 | |||
| 3213 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 3214 | |||
| 3215 | * ob-lob.el (org-babel-lob-one-liner-regexp): Fixed error in lob | ||
| 3216 | regexp -- it wasn't matching lob lines w/o indices. | ||
| 3217 | |||
| 3218 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 3219 | |||
| 3220 | * org-exp.el (org-export-latex-listings-w-names): Fix compiler | ||
| 3221 | warning in org-exp.el. | ||
| 3222 | |||
| 3223 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 3224 | |||
| 3225 | * org-publish.el (org-publish-file): Better error message if | ||
| 3226 | base-directory or publishing-directory are not defined. | ||
| 3227 | |||
| 3228 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 3229 | |||
| 3230 | * org-colview.el (org-columns-display-here): Use overlays to | ||
| 3231 | overrule line prefix properties during column view. | ||
| 3232 | |||
| 3233 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 3234 | |||
| 3235 | * org-agenda.el (org-agenda-filter-preset): Document the | ||
| 3236 | limitation for the filter preset - it can only be used for an | ||
| 3237 | entire agenda view, not in an individual block in a block agenda. | ||
| 3238 | |||
| 3239 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 3240 | |||
| 3241 | * ob-table.el (sbe): Now able to accept range references from | ||
| 3242 | tables. | ||
| 3243 | |||
| 3244 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 3245 | |||
| 3246 | * ob.el (org-babel-pick-name): If colnames or rownames contain a | ||
| 3247 | list of names, then use those directly. | ||
| 3248 | |||
| 3249 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 3250 | |||
| 3251 | * org-exp.el (org-export-format-source-code-or-example): Escape | ||
| 3252 | underscores in code block names on latex listings export. | ||
| 3253 | |||
| 3254 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 3255 | |||
| 3256 | * ob-tangle.el (org-babel-with-temp-filebuffer): Use | ||
| 3257 | find-file-noselect to avoid excess buffer movement. | ||
| 3258 | |||
| 3259 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 3260 | |||
| 3261 | * org-html.el (org-html-should-inline-p): Only inline images if | ||
| 3262 | they should be. | ||
| 3263 | |||
| 3264 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 3265 | |||
| 3266 | * org-id.el (org-id-store-link): Autoload. | ||
| 3267 | |||
| 3268 | * org.el ("org-id"): Autoload `org-id-store-link'. | ||
| 3269 | |||
| 3270 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 3271 | |||
| 3272 | * org-html.el (org-html-should-inline-p): Only inline images if | ||
| 3273 | they should be. | ||
| 3274 | |||
| 3275 | 2010-11-11 Eric S Fraga <e.fraga@ucl.ac.uk> | ||
| 3276 | |||
| 3277 | * org-icalendar.el (org-icalendar-alarm-time): New option. | ||
| 3278 | |||
| 3279 | * org-icalendar.el (org-print-icalendar-entries): Timed events are | ||
| 3280 | exported with alarm events, a.k.a. reminders. | ||
| 3281 | |||
| 3282 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 3283 | |||
| 3284 | * org-capture.el (org-capture-target-buffer): Throw an error if we | ||
| 3285 | have no target file. | ||
| 3286 | (org-capture-select-template): Use a default template if the user | ||
| 3287 | has not specified any. | ||
| 3288 | |||
| 3289 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 3290 | |||
| 3291 | * org.el (org-modules): Add entry for org-velocity. | ||
| 3292 | |||
| 3293 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 3294 | |||
| 3295 | * ob-lob.el (org-babel-lob-execute): Changing indentation to | ||
| 3296 | improve line length. | ||
| 3297 | |||
| 3298 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 3299 | |||
| 3300 | * org-exp.el (org-export-handle-table-metalines): Choose a better | ||
| 3301 | position for checking protectedness. | ||
| 3302 | |||
| 3303 | 2010-11-11 Eric Schulte <schulte.eric@gmail.com> | ||
| 3304 | |||
| 3305 | * org-table.el (org-table-convert-region): Don't continue csv | ||
| 3306 | importation which the point catches the end, this fixes an | ||
| 3307 | infinite loop which was caused by the (point) never catching up | ||
| 3308 | with the "end" marker. | ||
| 3309 | |||
| 3310 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 3311 | |||
| 3312 | * org-macs.el (org-string-nw-p): New function. | ||
| 3313 | |||
| 3314 | * org-capture.el (org-capture-import-remember-templates): | ||
| 3315 | Interpret an empty string as request to use | ||
| 3316 | `org-default-notes-file'. | ||
| 3317 | (org-capture-target-buffer): If the FILE is not a (non-empty) | ||
| 3318 | string, use `org-default-notes-file'. | ||
| 3319 | |||
| 3320 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 3321 | |||
| 3322 | * org-capture.el (org-capture-templates): Fix customize type. | ||
| 3323 | |||
| 3324 | 2010-11-11 Carsten Dominik <carsten.dominik@gmail.com> | ||
| 3325 | |||
| 3326 | * org-colview-xemacs.el (org-columns-compile-map): | ||
| 3327 | (org-columns-number-to-string): | ||
| 3328 | (org-columns-string-to-number): Handle estimate ranges. | ||
| 3329 | (org-estimate-mean-and-var): New function. | ||
| 3330 | (org-estimate-combine): New function. | ||
| 3331 | (org-estimate-print): New function. | ||
| 3332 | (org-string-to-estimate): New function. | ||
| 3333 | |||
| 1 | 2010-09-25 Juanma Barranquero <lekktu@gmail.com> | 3334 | 2010-09-25 Juanma Barranquero <lekktu@gmail.com> |
| 2 | 3335 | ||
| 3 | * org.el (org-refile-targets): | 3336 | * org.el (org-refile-targets): |
diff --git a/lisp/org/ob-C.el b/lisp/org/ob-C.el index 086079f9082..1c8eac65ace 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.01 | 8 | ;; Version: 7.3 |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -33,7 +33,6 @@ | |||
| 33 | ;;; Code: | 33 | ;;; Code: |
| 34 | (require 'ob) | 34 | (require 'ob) |
| 35 | (require 'ob-eval) | 35 | (require 'ob-eval) |
| 36 | (require 'org) | ||
| 37 | (require 'cc-mode) | 36 | (require 'cc-mode) |
| 38 | 37 | ||
| 39 | (declare-function org-entry-get "org" | 38 | (declare-function org-entry-get "org" |
| @@ -65,31 +64,30 @@ is currently being evaluated.") | |||
| 65 | called by `org-babel-execute-src-block'." | 64 | called by `org-babel-execute-src-block'." |
| 66 | (let ((org-babel-c-variant 'cpp)) (org-babel-C-execute body params))) | 65 | (let ((org-babel-c-variant 'cpp)) (org-babel-C-execute body params))) |
| 67 | 66 | ||
| 68 | (defun org-babel-expand-body:c++ (body params &optional processed-params) | 67 | (defun org-babel-expand-body:c++ (body params) |
| 69 | "Expand a block of C++ code with org-babel according to it's | 68 | "Expand a block of C++ code with org-babel according to it's |
| 70 | header arguments (calls `org-babel-C-expand')." | 69 | header arguments (calls `org-babel-C-expand')." |
| 71 | (let ((org-babel-c-variant 'cpp)) (org-babel-C-expand body params processed-params))) | 70 | (let ((org-babel-c-variant 'cpp)) (org-babel-C-expand body params))) |
| 72 | 71 | ||
| 73 | (defun org-babel-execute:C (body params) | 72 | (defun org-babel-execute:C (body params) |
| 74 | "Execute a block of C code with org-babel. This function is | 73 | "Execute a block of C code with org-babel. This function is |
| 75 | called by `org-babel-execute-src-block'." | 74 | called by `org-babel-execute-src-block'." |
| 76 | (let ((org-babel-c-variant 'c)) (org-babel-C-execute body params))) | 75 | (let ((org-babel-c-variant 'c)) (org-babel-C-execute body params))) |
| 77 | 76 | ||
| 78 | (defun org-babel-expand-body:c (body params &optional processed-params) | 77 | (defun org-babel-expand-body:c (body params) |
| 79 | "Expand a block of C code with org-babel according to it's | 78 | "Expand a block of C code with org-babel according to it's |
| 80 | header arguments (calls `org-babel-C-expand')." | 79 | header arguments (calls `org-babel-C-expand')." |
| 81 | (let ((org-babel-c-variant 'c)) (org-babel-C-expand body params processed-params))) | 80 | (let ((org-babel-c-variant 'c)) (org-babel-C-expand body params))) |
| 82 | 81 | ||
| 83 | (defun org-babel-C-execute (body params) | 82 | (defun org-babel-C-execute (body params) |
| 84 | "This function should only be called by `org-babel-execute:C' | 83 | "This function should only be called by `org-babel-execute:C' |
| 85 | or `org-babel-execute:c++'." | 84 | or `org-babel-execute:c++'." |
| 86 | (let* ((processed-params (org-babel-process-params params)) | 85 | (let* ((tmp-src-file (org-babel-temp-file |
| 87 | (tmp-src-file (make-temp-file "org-babel-C-src" nil | 86 | "C-src-" |
| 88 | (cond | 87 | (cond |
| 89 | ((equal org-babel-c-variant 'c) ".c") | 88 | ((equal org-babel-c-variant 'c) ".c") |
| 90 | ((equal org-babel-c-variant 'cpp) ".cpp")))) | 89 | ((equal org-babel-c-variant 'cpp) ".cpp")))) |
| 91 | (tmp-bin-file (make-temp-file "org-babel-C-bin")) | 90 | (tmp-bin-file (org-babel-temp-file "C-bin-")) |
| 92 | (tmp-out-file (make-temp-file "org-babel-C-out")) | ||
| 93 | (cmdline (cdr (assoc :cmdline params))) | 91 | (cmdline (cdr (assoc :cmdline params))) |
| 94 | (flags (cdr (assoc :flags params))) | 92 | (flags (cdr (assoc :flags params))) |
| 95 | (full-body (org-babel-C-expand body params)) | 93 | (full-body (org-babel-C-expand body params)) |
| @@ -101,37 +99,35 @@ or `org-babel-execute:c++'." | |||
| 101 | (cond | 99 | (cond |
| 102 | ((equal org-babel-c-variant 'c) org-babel-C-compiler) | 100 | ((equal org-babel-c-variant 'c) org-babel-C-compiler) |
| 103 | ((equal org-babel-c-variant 'cpp) org-babel-c++-compiler)) | 101 | ((equal org-babel-c-variant 'cpp) org-babel-c++-compiler)) |
| 104 | tmp-bin-file | 102 | (org-babel-process-file-name tmp-bin-file) |
| 105 | (mapconcat 'identity | 103 | (mapconcat 'identity |
| 106 | (if (listp flags) flags (list flags)) " ") | 104 | (if (listp flags) flags (list flags)) " ") |
| 107 | tmp-src-file) "")))) | 105 | (org-babel-process-file-name tmp-src-file)) "")))) |
| 108 | ((lambda (results) | 106 | ((lambda (results) |
| 109 | (org-babel-reassemble-table | 107 | (org-babel-reassemble-table |
| 110 | (if (member "vector" (nth 2 processed-params)) | 108 | (if (member "vector" (cdr (assoc :result-params params))) |
| 111 | (let ((tmp-file (make-temp-file "ob-c"))) | 109 | (let ((tmp-file (org-babel-temp-file "c-"))) |
| 112 | (with-temp-file tmp-file (insert results)) | 110 | (with-temp-file tmp-file (insert results)) |
| 113 | (org-babel-import-elisp-from-file tmp-file)) | 111 | (org-babel-import-elisp-from-file tmp-file)) |
| 114 | (org-babel-read results)) | 112 | (org-babel-read results)) |
| 115 | (org-babel-pick-name | 113 | (org-babel-pick-name |
| 116 | (nth 4 processed-params) (cdr (assoc :colnames params))) | 114 | (cdr (assoc :colname-names params)) (cdr (assoc :colnames params))) |
| 117 | (org-babel-pick-name | 115 | (org-babel-pick-name |
| 118 | (nth 5 processed-params) (cdr (assoc :rownames params))))) | 116 | (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params))))) |
| 119 | (org-babel-trim | 117 | (org-babel-trim |
| 120 | (org-babel-eval | 118 | (org-babel-eval |
| 121 | (concat tmp-bin-file (if cmdline (concat " " cmdline) "")) ""))))) | 119 | (concat tmp-bin-file (if cmdline (concat " " cmdline) "")) ""))))) |
| 122 | 120 | ||
| 123 | (defun org-babel-C-expand (body params &optional processed-params) | 121 | (defun org-babel-C-expand (body params) |
| 124 | "Expand a block of C or C++ code with org-babel according to | 122 | "Expand a block of C or C++ code with org-babel according to |
| 125 | it's header arguments." | 123 | it's header arguments." |
| 126 | (let ((vars (nth 1 (or processed-params | 124 | (let ((vars (mapcar #'cdr (org-babel-get-header params :var))) |
| 127 | (org-babel-process-params params)))) | ||
| 128 | (main-p (not (string= (cdr (assoc :main params)) "no"))) | 125 | (main-p (not (string= (cdr (assoc :main params)) "no"))) |
| 129 | (includes (or (cdr (assoc :includes params)) | 126 | (includes (or (cdr (assoc :includes params)) |
| 130 | (org-babel-read (org-entry-get nil "includes" t)))) | 127 | (org-babel-read (org-entry-get nil "includes" t)))) |
| 131 | (defines (org-babel-read | 128 | (defines (org-babel-read |
| 132 | (or (cdr (assoc :defines params)) | 129 | (or (cdr (assoc :defines params)) |
| 133 | (org-babel-read (org-entry-get nil "defines" t)))))) | 130 | (org-babel-read (org-entry-get nil "defines" t)))))) |
| 134 | (org-babel-trim | ||
| 135 | (mapconcat 'identity | 131 | (mapconcat 'identity |
| 136 | (list | 132 | (list |
| 137 | ;; includes | 133 | ;; includes |
| @@ -147,11 +143,11 @@ it's header arguments." | |||
| 147 | ;; body | 143 | ;; body |
| 148 | (if main-p | 144 | (if main-p |
| 149 | (org-babel-C-ensure-main-wrap body) | 145 | (org-babel-C-ensure-main-wrap body) |
| 150 | body) "\n") "\n")))) | 146 | body) "\n") "\n"))) |
| 151 | 147 | ||
| 152 | (defun org-babel-C-ensure-main-wrap (body) | 148 | (defun org-babel-C-ensure-main-wrap (body) |
| 153 | "Wrap body in a \"main\" function call if none exists." | 149 | "Wrap body in a \"main\" function call if none exists." |
| 154 | (if (string-match "^[ \t]*[intvod]+[ \t]*main[ \t]*(.*)" body) | 150 | (if (string-match "^[ \t]*[intvod]+[ \t\n\r]*main[ \t]*(.*)" body) |
| 155 | body | 151 | body |
| 156 | (format "int main() {\n%s\n}\n" body))) | 152 | (format "int main() {\n%s\n}\n" body))) |
| 157 | 153 | ||
diff --git a/lisp/org/ob-R.el b/lisp/org/ob-R.el index d990d69b357..2be79926a44 100644 --- a/lisp/org/ob-R.el +++ b/lisp/org/ob-R.el | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | ;; Author: Eric Schulte, Dan Davison | 5 | ;; Author: Eric Schulte, Dan Davison |
| 6 | ;; Keywords: literate programming, reproducible research, R, statistics | 6 | ;; Keywords: literate programming, reproducible research, R, statistics |
| 7 | ;; Homepage: http://orgmode.org | 7 | ;; Homepage: http://orgmode.org |
| 8 | ;; Version: 7.01 | 8 | ;; Version: 7.3 |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -36,6 +36,9 @@ | |||
| 36 | (declare-function orgtbl-to-tsv "org-table" (table params)) | 36 | (declare-function orgtbl-to-tsv "org-table" (table params)) |
| 37 | (declare-function R "ext:essd-r" (&optional start-args)) | 37 | (declare-function R "ext:essd-r" (&optional start-args)) |
| 38 | (declare-function inferior-ess-send-input "ext:ess-inf" ()) | 38 | (declare-function inferior-ess-send-input "ext:ess-inf" ()) |
| 39 | (declare-function ess-make-buffer-current "ext:ess-inf" ()) | ||
| 40 | (declare-function ess-eval-buffer "ext:ess-inf" (vis)) | ||
| 41 | (declare-function org-number-sequence "org-compat" (from &optional to inc)) | ||
| 39 | 42 | ||
| 40 | (defconst org-babel-header-arg-names:R | 43 | (defconst org-babel-header-arg-names:R |
| 41 | '(width height bg units pointsize antialias quality compression | 44 | '(width height bg units pointsize antialias quality compression |
| @@ -48,21 +51,11 @@ | |||
| 48 | (defvar org-babel-R-command "R --slave --no-save" | 51 | (defvar org-babel-R-command "R --slave --no-save" |
| 49 | "Name of command to use for executing R code.") | 52 | "Name of command to use for executing R code.") |
| 50 | 53 | ||
| 51 | (defun org-babel-expand-body:R (body params &optional processed-params) | 54 | (defun org-babel-expand-body:R (body params) |
| 52 | "Expand BODY according to PARAMS, return the expanded body." | 55 | "Expand BODY according to PARAMS, return the expanded body." |
| 53 | (let* ((processed-params (or processed-params | 56 | (let ((out-file (cdr (assoc :file params)))) |
| 54 | (org-babel-process-params params))) | 57 | (mapconcat |
| 55 | (vars (mapcar | 58 | #'identity |
| 56 | (lambda (i) | ||
| 57 | (cons (car (nth i (nth 1 processed-params))) | ||
| 58 | (org-babel-reassemble-table | ||
| 59 | (cdr (nth i (nth 1 processed-params))) | ||
| 60 | (cdr (nth i (nth 4 processed-params))) | ||
| 61 | (cdr (nth i (nth 5 processed-params)))))) | ||
| 62 | (number-sequence 0 (1- (length (nth 1 processed-params)))))) | ||
| 63 | (out-file (cdr (assoc :file params)))) | ||
| 64 | (mapconcat ;; define any variables | ||
| 65 | #'org-babel-trim | ||
| 66 | ((lambda (inside) | 59 | ((lambda (inside) |
| 67 | (if out-file | 60 | (if out-file |
| 68 | (append | 61 | (append |
| @@ -70,49 +63,36 @@ | |||
| 70 | inside | 63 | inside |
| 71 | (list "dev.off()")) | 64 | (list "dev.off()")) |
| 72 | inside)) | 65 | inside)) |
| 73 | (append | 66 | (append (org-babel-variable-assignments:R params) |
| 74 | (mapcar | 67 | (list body))) "\n"))) |
| 75 | (lambda (pair) | ||
| 76 | (org-babel-R-assign-elisp | ||
| 77 | (car pair) (cdr pair) | ||
| 78 | (equal "yes" (cdr (assoc :colnames params))) | ||
| 79 | (equal "yes" (cdr (assoc :rownames params))))) | ||
| 80 | vars) | ||
| 81 | (list body))) "\n"))) | ||
| 82 | 68 | ||
| 83 | (defun org-babel-execute:R (body params) | 69 | (defun org-babel-execute:R (body params) |
| 84 | "Execute a block of R code. | 70 | "Execute a block of R code. |
| 85 | This function is called by `org-babel-execute-src-block'." | 71 | This function is called by `org-babel-execute-src-block'." |
| 86 | (save-excursion | 72 | (save-excursion |
| 87 | (let* ((processed-params (org-babel-process-params params)) | 73 | (let* ((result-type (cdr (assoc :result-type params))) |
| 88 | (result-type (nth 3 processed-params)) | ||
| 89 | (session (org-babel-R-initiate-session | 74 | (session (org-babel-R-initiate-session |
| 90 | (first processed-params) params)) | 75 | (cdr (assoc :session params)) params)) |
| 91 | (colnames-p (cdr (assoc :colnames params))) | 76 | (colnames-p (cdr (assoc :colnames params))) |
| 92 | (rownames-p (cdr (assoc :rownames params))) | 77 | (rownames-p (cdr (assoc :rownames params))) |
| 93 | (out-file (cdr (assoc :file params))) | 78 | (out-file (cdr (assoc :file params))) |
| 94 | (full-body (org-babel-expand-body:R body params processed-params)) | 79 | (full-body (org-babel-expand-body:R body params)) |
| 95 | (result | 80 | (result |
| 96 | (org-babel-R-evaluate | 81 | (org-babel-R-evaluate |
| 97 | session full-body result-type | 82 | session full-body result-type |
| 98 | (or (equal "yes" colnames-p) | 83 | (or (equal "yes" colnames-p) |
| 99 | (org-babel-pick-name (nth 4 processed-params) colnames-p)) | 84 | (org-babel-pick-name |
| 85 | (cdr (assoc :colname-names params)) colnames-p)) | ||
| 100 | (or (equal "yes" rownames-p) | 86 | (or (equal "yes" rownames-p) |
| 101 | (org-babel-pick-name (nth 5 processed-params) rownames-p))))) | 87 | (org-babel-pick-name |
| 88 | (cdr (assoc :rowname-names params)) rownames-p))))) | ||
| 102 | (message "result is %S" result) | 89 | (message "result is %S" result) |
| 103 | (or out-file result)))) | 90 | (or out-file result)))) |
| 104 | 91 | ||
| 105 | (defun org-babel-prep-session:R (session params) | 92 | (defun org-babel-prep-session:R (session params) |
| 106 | "Prepare SESSION according to the header arguments specified in PARAMS." | 93 | "Prepare SESSION according to the header arguments specified in PARAMS." |
| 107 | (let* ((session (org-babel-R-initiate-session session params)) | 94 | (let* ((session (org-babel-R-initiate-session session params)) |
| 108 | (vars (org-babel-ref-variables params)) | 95 | (var-lines (org-babel-variable-assignments:R params))) |
| 109 | (var-lines | ||
| 110 | (mapcar | ||
| 111 | (lambda (pair) (org-babel-R-assign-elisp | ||
| 112 | (car pair) (cdr pair) | ||
| 113 | (equal (cdr (assoc :colnames params)) "yes") | ||
| 114 | (equal (cdr (assoc :rownames params)) "yes"))) | ||
| 115 | vars))) | ||
| 116 | (org-babel-comint-in-buffer session | 96 | (org-babel-comint-in-buffer session |
| 117 | (mapc (lambda (var) | 97 | (mapc (lambda (var) |
| 118 | (end-of-line 1) (insert var) (comint-send-input nil t) | 98 | (end-of-line 1) (insert var) (comint-send-input nil t) |
| @@ -130,6 +110,24 @@ This function is called by `org-babel-execute-src-block'." | |||
| 130 | 110 | ||
| 131 | ;; helper functions | 111 | ;; helper functions |
| 132 | 112 | ||
| 113 | (defun org-babel-variable-assignments:R (params) | ||
| 114 | "Return list of R statements assigning the block's variables" | ||
| 115 | (let ((vars (mapcar #'cdr (org-babel-get-header params :var)))) | ||
| 116 | (mapcar | ||
| 117 | (lambda (pair) | ||
| 118 | (org-babel-R-assign-elisp | ||
| 119 | (car pair) (cdr pair) | ||
| 120 | (equal "yes" (cdr (assoc :colnames params))) | ||
| 121 | (equal "yes" (cdr (assoc :rownames params))))) | ||
| 122 | (mapcar | ||
| 123 | (lambda (i) | ||
| 124 | (cons (car (nth i vars)) | ||
| 125 | (org-babel-reassemble-table | ||
| 126 | (cdr (nth i vars)) | ||
| 127 | (cdr (nth i (cdr (assoc :colname-names params)))) | ||
| 128 | (cdr (nth i (cdr (assoc :rowname-names params))))))) | ||
| 129 | (org-number-sequence 0 (1- (length vars))))))) | ||
| 130 | |||
| 133 | (defun org-babel-R-quote-tsv-field (s) | 131 | (defun org-babel-R-quote-tsv-field (s) |
| 134 | "Quote field S for export to R." | 132 | "Quote field S for export to R." |
| 135 | (if (stringp s) | 133 | (if (stringp s) |
| @@ -139,23 +137,25 @@ This function is called by `org-babel-execute-src-block'." | |||
| 139 | (defun org-babel-R-assign-elisp (name value colnames-p rownames-p) | 137 | (defun org-babel-R-assign-elisp (name value colnames-p rownames-p) |
| 140 | "Construct R code assigning the elisp VALUE to a variable named NAME." | 138 | "Construct R code assigning the elisp VALUE to a variable named NAME." |
| 141 | (if (listp value) | 139 | (if (listp value) |
| 142 | (let ((transition-file (make-temp-file "org-babel-R-import"))) | 140 | (let ((transition-file (org-babel-temp-file "R-import-"))) |
| 143 | ;; ensure VALUE has an orgtbl structure (depth of at least 2) | 141 | ;; ensure VALUE has an orgtbl structure (depth of at least 2) |
| 144 | (unless (listp (car value)) (setq value (list value))) | 142 | (unless (listp (car value)) (setq value (list value))) |
| 145 | (with-temp-file (org-babel-maybe-remote-file transition-file) | 143 | (with-temp-file transition-file |
| 146 | (insert (orgtbl-to-tsv value '(:fmt org-babel-R-quote-tsv-field))) | 144 | (insert (orgtbl-to-tsv value '(:fmt org-babel-R-quote-tsv-field))) |
| 147 | (insert "\n")) | 145 | (insert "\n")) |
| 148 | (format "%s <- read.table(\"%s\", header=%s, row.names=%s, sep=\"\\t\", as.is=TRUE)" | 146 | (format "%s <- read.table(\"%s\", header=%s, row.names=%s, sep=\"\\t\", as.is=TRUE)" |
| 149 | name transition-file | 147 | name (org-babel-process-file-name transition-file 'noquote) |
| 150 | (if (or (eq (nth 1 value) 'hline) colnames-p) "TRUE" "FALSE") | 148 | (if (or (eq (nth 1 value) 'hline) colnames-p) "TRUE" "FALSE") |
| 151 | (if rownames-p "1" "NULL"))) | 149 | (if rownames-p "1" "NULL"))) |
| 152 | (format "%s <- %s" name (org-babel-R-quote-tsv-field value)))) | 150 | (format "%s <- %s" name (org-babel-R-quote-tsv-field value)))) |
| 153 | 151 | ||
| 152 | (defvar ess-ask-for-ess-directory nil) | ||
| 154 | (defun org-babel-R-initiate-session (session params) | 153 | (defun org-babel-R-initiate-session (session params) |
| 155 | "If there is not a current R process then create one." | 154 | "If there is not a current R process then create one." |
| 156 | (unless (string= session "none") | 155 | (unless (string= session "none") |
| 157 | (let ((session (or session "*R*")) | 156 | (let ((session (or session "*R*")) |
| 158 | (ess-ask-for-ess-directory (not (cdr (assoc :dir params))))) | 157 | (ess-ask-for-ess-directory |
| 158 | (and ess-ask-for-ess-directory (not (cdr (assoc :dir params)))))) | ||
| 159 | (if (org-babel-comint-buffer-livep session) | 159 | (if (org-babel-comint-buffer-livep session) |
| 160 | session | 160 | session |
| 161 | (save-window-excursion | 161 | (save-window-excursion |
| @@ -168,6 +168,15 @@ This function is called by `org-babel-execute-src-block'." | |||
| 168 | (buffer-name)))) | 168 | (buffer-name)))) |
| 169 | (current-buffer)))))) | 169 | (current-buffer)))))) |
| 170 | 170 | ||
| 171 | (defvar ess-local-process-name nil) | ||
| 172 | (defun org-babel-R-associate-session (session) | ||
| 173 | "Associate R code buffer with an R session. | ||
| 174 | Make SESSION be the inferior ESS process associated with the | ||
| 175 | current code buffer." | ||
| 176 | (setq ess-local-process-name | ||
| 177 | (process-name (get-buffer-process session))) | ||
| 178 | (ess-make-buffer-current)) | ||
| 179 | |||
| 171 | (defun org-babel-R-construct-graphics-device-call (out-file params) | 180 | (defun org-babel-R-construct-graphics-device-call (out-file params) |
| 172 | "Construct the call to the graphics device." | 181 | "Construct the call to the graphics device." |
| 173 | (let ((devices | 182 | (let ((devices |
| @@ -205,65 +214,78 @@ This function is called by `org-babel-execute-src-block'." | |||
| 205 | 214 | ||
| 206 | (defvar org-babel-R-eoe-indicator "'org_babel_R_eoe'") | 215 | (defvar org-babel-R-eoe-indicator "'org_babel_R_eoe'") |
| 207 | (defvar org-babel-R-eoe-output "[1] \"org_babel_R_eoe\"") | 216 | (defvar org-babel-R-eoe-output "[1] \"org_babel_R_eoe\"") |
| 208 | (defvar org-babel-R-wrapper-method "main <- function ()\n{\n%s\n} | 217 | (defvar org-babel-R-write-object-command "{function(object, transfer.file) {invisible(if(inherits(try(write.table(object, file=transfer.file, sep=\"\\t\", na=\"nil\",row.names=%s, col.names=%s, quote=FALSE), silent=TRUE),\"try-error\")) {if(!file.exists(transfer.file)) file.create(transfer.file)})}}(object=%s, transfer.file=\"%s\")") |
| 209 | write.table(main(), file=\"%s\", sep=\"\\t\", na=\"nil\",row.names=%s, col.names=%s, quote=FALSE)") | ||
| 210 | (defvar org-babel-R-wrapper-lastvar "write.table(.Last.value, file=\"%s\", sep=\"\\t\", na=\"nil\",row.names=%s, col.names=%s, quote=FALSE)") | ||
| 211 | 218 | ||
| 212 | (defun org-babel-R-evaluate | 219 | (defun org-babel-R-evaluate |
| 213 | (session body result-type column-names-p row-names-p) | 220 | (session body result-type column-names-p row-names-p) |
| 214 | "Pass BODY to the R process in SESSION. | 221 | "Evaluate R code in BODY." |
| 215 | If RESULT-TYPE equals 'output then return a list of the outputs | 222 | (if session |
| 216 | of the statements in BODY, if RESULT-TYPE equals 'value then | 223 | (org-babel-R-evaluate-session |
| 217 | return the value of the last statement in BODY, as elisp." | 224 | session body result-type column-names-p row-names-p) |
| 218 | (if (not session) | 225 | (org-babel-R-evaluate-external-process |
| 219 | ;; external process evaluation | 226 | body result-type column-names-p row-names-p))) |
| 220 | (case result-type | 227 | |
| 221 | (output (org-babel-eval org-babel-R-command body)) | 228 | (defun org-babel-R-evaluate-external-process |
| 222 | (value | 229 | (body result-type column-names-p row-names-p) |
| 223 | (let ((tmp-file (make-temp-file "org-babel-R-results-"))) | 230 | "Evaluate BODY in external R process. |
| 224 | (org-babel-eval org-babel-R-command | 231 | If RESULT-TYPE equals 'output then return standard output as a |
| 225 | (format org-babel-R-wrapper-method | 232 | string. If RESULT-TYPE equals 'value then return the value of the |
| 226 | body tmp-file | 233 | last statement in BODY, as elisp." |
| 227 | (if row-names-p "TRUE" "FALSE") | 234 | (case result-type |
| 228 | (if column-names-p | 235 | (value |
| 229 | (if row-names-p "NA" "TRUE") | 236 | (let ((tmp-file (org-babel-temp-file "R-"))) |
| 230 | "FALSE"))) | 237 | (org-babel-eval org-babel-R-command |
| 231 | (org-babel-R-process-value-result | 238 | (format org-babel-R-write-object-command |
| 232 | (org-babel-import-elisp-from-file | 239 | (if row-names-p "TRUE" "FALSE") |
| 233 | (org-babel-maybe-remote-file tmp-file)) column-names-p)))) | 240 | (if column-names-p |
| 234 | ;; comint session evaluation | 241 | (if row-names-p "NA" "TRUE") |
| 235 | (case result-type | 242 | "FALSE") |
| 236 | (value | 243 | (format "{function ()\n{\n%s\n}}()" body) |
| 237 | (let ((tmp-file (make-temp-file "org-babel-R")) | 244 | (org-babel-process-file-name tmp-file 'noquote))) |
| 238 | broke) | 245 | (org-babel-R-process-value-result |
| 239 | (org-babel-comint-with-output (session org-babel-R-eoe-output) | 246 | (org-babel-import-elisp-from-file tmp-file '(16)) column-names-p))) |
| 240 | (insert (mapconcat | 247 | (output (org-babel-eval org-babel-R-command body)))) |
| 241 | #'org-babel-chomp | 248 | |
| 242 | (list | 249 | (defun org-babel-R-evaluate-session |
| 243 | body | 250 | (session body result-type column-names-p row-names-p) |
| 244 | (format org-babel-R-wrapper-lastvar | 251 | "Evaluate BODY in SESSION. |
| 245 | tmp-file | 252 | If RESULT-TYPE equals 'output then return standard output as a |
| 246 | (if row-names-p "TRUE" "FALSE") | 253 | string. If RESULT-TYPE equals 'value then return the value of the |
| 247 | (if column-names-p | 254 | last statement in BODY, as elisp." |
| 248 | (if row-names-p "NA" "TRUE") | 255 | (case result-type |
| 249 | "FALSE")) | 256 | (value |
| 250 | org-babel-R-eoe-indicator) "\n")) | 257 | (with-temp-buffer |
| 251 | (inferior-ess-send-input)) | 258 | (insert (org-babel-chomp body)) |
| 252 | (org-babel-R-process-value-result | 259 | (let ((ess-local-process-name |
| 253 | (org-babel-import-elisp-from-file | 260 | (process-name (get-buffer-process session)))) |
| 254 | (org-babel-maybe-remote-file tmp-file)) column-names-p))) | 261 | (ess-eval-buffer nil))) |
| 255 | (output | 262 | (let ((tmp-file (org-babel-temp-file "R-"))) |
| 256 | (mapconcat | 263 | (org-babel-comint-eval-invisibly-and-wait-for-file |
| 257 | #'org-babel-chomp | 264 | session tmp-file |
| 258 | (butlast | 265 | (format org-babel-R-write-object-command |
| 259 | (delq nil | 266 | (if row-names-p "TRUE" "FALSE") |
| 260 | (mapcar | 267 | (if column-names-p |
| 261 | #'identity | 268 | (if row-names-p "NA" "TRUE") |
| 262 | (org-babel-comint-with-output (session org-babel-R-eoe-output) | 269 | "FALSE") |
| 263 | (insert (mapconcat #'org-babel-chomp | 270 | ".Last.value" (org-babel-process-file-name tmp-file 'noquote))) |
| 264 | (list body org-babel-R-eoe-indicator) | 271 | (org-babel-R-process-value-result |
| 265 | "\n")) | 272 | (org-babel-import-elisp-from-file tmp-file '(16)) column-names-p))) |
| 266 | (inferior-ess-send-input)))) 2) "\n"))))) | 273 | (output |
| 274 | (mapconcat | ||
| 275 | #'org-babel-chomp | ||
| 276 | (butlast | ||
| 277 | (delq nil | ||
| 278 | (mapcar | ||
| 279 | (lambda (line) ;; cleanup extra prompts left in output | ||
| 280 | (if (string-match | ||
| 281 | "^\\([ ]*[>+][ ]?\\)+\\([[0-9]+\\|[ ]\\)" line) | ||
| 282 | (substring line (match-end 1)) | ||
| 283 | line)) | ||
| 284 | (org-babel-comint-with-output (session org-babel-R-eoe-output) | ||
| 285 | (insert (mapconcat #'org-babel-chomp | ||
| 286 | (list body org-babel-R-eoe-indicator) | ||
| 287 | "\n")) | ||
| 288 | (inferior-ess-send-input)))) 2) "\n")))) | ||
| 267 | 289 | ||
| 268 | (defun org-babel-R-process-value-result (result column-names-p) | 290 | (defun org-babel-R-process-value-result (result column-names-p) |
| 269 | "R-specific processing of return value. | 291 | "R-specific processing of return value. |
diff --git a/lisp/org/ob-asymptote.el b/lisp/org/ob-asymptote.el index 043bc4c5ff7..43d65462612 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.01 | 8 | ;; Version: 7.3 |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -55,32 +55,30 @@ | |||
| 55 | '((:results . "file") (:exports . "results")) | 55 | '((:results . "file") (:exports . "results")) |
| 56 | "Default arguments when evaluating an Asymptote source block.") | 56 | "Default arguments when evaluating an Asymptote source block.") |
| 57 | 57 | ||
| 58 | (defun org-babel-expand-body:asymptote (body params &optional processed-params) | ||
| 59 | "Expand BODY according to PARAMS, return the expanded body." | ||
| 60 | (let ((vars (nth 1 (or processed-params | ||
| 61 | (org-babel-process-params params))))) | ||
| 62 | (concat (mapconcat 'org-babel-asymptote-var-to-asymptote vars "\n") | ||
| 63 | "\n" body "\n"))) | ||
| 64 | |||
| 65 | (defun org-babel-execute:asymptote (body params) | 58 | (defun org-babel-execute:asymptote (body params) |
| 66 | "Execute a block of Asymptote code. | 59 | "Execute a block of Asymptote code. |
| 67 | This function is called by `org-babel-execute-src-block'." | 60 | This function is called by `org-babel-execute-src-block'." |
| 68 | (let* ((processed-params (org-babel-process-params params)) | 61 | (let* ((result-params (split-string (or (cdr (assoc :results params)) ""))) |
| 69 | (result-params (split-string (or (cdr (assoc :results params)) ""))) | ||
| 70 | (out-file (cdr (assoc :file params))) | 62 | (out-file (cdr (assoc :file params))) |
| 71 | (format (or (and out-file | 63 | (format (or (and out-file |
| 72 | (string-match ".+\\.\\(.+\\)" out-file) | 64 | (string-match ".+\\.\\(.+\\)" out-file) |
| 73 | (match-string 1 out-file)) | 65 | (match-string 1 out-file)) |
| 74 | "pdf")) | 66 | "pdf")) |
| 75 | (cmdline (cdr (assoc :cmdline params))) | 67 | (cmdline (cdr (assoc :cmdline params))) |
| 76 | (in-file (make-temp-file "org-babel-asymptote")) | 68 | (in-file (org-babel-temp-file "asymptote-")) |
| 77 | (cmd (concat "asy " | 69 | (cmd |
| 78 | (if out-file | 70 | (concat "asy " |
| 79 | (concat "-globalwrite -f " format " -o " out-file) | 71 | (if out-file |
| 80 | "-V") | 72 | (concat |
| 81 | " " cmdline " " in-file))) | 73 | "-globalwrite -f " format |
| 74 | " -o " (org-babel-process-file-name out-file)) | ||
| 75 | "-V") | ||
| 76 | " " cmdline | ||
| 77 | " " (org-babel-process-file-name in-file)))) | ||
| 82 | (with-temp-file in-file | 78 | (with-temp-file in-file |
| 83 | (insert (org-babel-expand-body:asymptote body params processed-params))) | 79 | (insert (org-babel-expand-body:generic |
| 80 | body params | ||
| 81 | (org-babel-variable-assignments:asymptote params)))) | ||
| 84 | (message cmd) (shell-command cmd) | 82 | (message cmd) (shell-command cmd) |
| 85 | out-file)) | 83 | out-file)) |
| 86 | 84 | ||
| @@ -89,6 +87,11 @@ This function is called by `org-babel-execute-src-block'." | |||
| 89 | Asymptote does not support sessions" | 87 | Asymptote does not support sessions" |
| 90 | (error "Asymptote does not support sessions")) | 88 | (error "Asymptote does not support sessions")) |
| 91 | 89 | ||
| 90 | (defun org-babel-variable-assignments:asymptote (params) | ||
| 91 | "Return list of asymptote statements assigning the block's variables" | ||
| 92 | (mapcar #'org-babel-asymptote-var-to-asymptote | ||
| 93 | (mapcar #'cdr (org-babel-get-header params :var)))) | ||
| 94 | |||
| 92 | (defun org-babel-asymptote-var-to-asymptote (pair) | 95 | (defun org-babel-asymptote-var-to-asymptote (pair) |
| 93 | "Convert an elisp value into an Asymptote variable. | 96 | "Convert an elisp value into an Asymptote variable. |
| 94 | The elisp value PAIR is converted into Asymptote code specifying | 97 | The elisp value PAIR is converted into Asymptote code specifying |
diff --git a/lisp/org/ob-calc.el b/lisp/org/ob-calc.el new file mode 100644 index 00000000000..ce752008b4c --- /dev/null +++ b/lisp/org/ob-calc.el | |||
| @@ -0,0 +1,67 @@ | |||
| 1 | ;;; ob-calc.el --- org-babel functions for calc code evaluation | ||
| 2 | |||
| 3 | ;; Copyright (C) 2010 Free Software Foundation, Inc | ||
| 4 | |||
| 5 | ;; Author: Eric Schulte | ||
| 6 | ;; Keywords: literate programming, reproducible research | ||
| 7 | ;; Homepage: http://orgmode.org | ||
| 8 | ;; Version: 7.3 | ||
| 9 | |||
| 10 | ;; This file is part of GNU Emacs. | ||
| 11 | |||
| 12 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 13 | ;; it under the terms of the GNU General Public License as published by | ||
| 14 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 15 | ;; (at your option) any later version. | ||
| 16 | |||
| 17 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 18 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 20 | ;; GNU General Public License for more details. | ||
| 21 | |||
| 22 | ;; You should have received a copy of the GNU General Public License | ||
| 23 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | ||
| 24 | |||
| 25 | ;;; Commentary: | ||
| 26 | |||
| 27 | ;; Org-Babel support for evaluating calc code | ||
| 28 | |||
| 29 | ;;; Code: | ||
| 30 | (require 'ob) | ||
| 31 | (require 'calc) | ||
| 32 | (require 'calc-trail) | ||
| 33 | (eval-when-compile (require 'ob-comint)) | ||
| 34 | |||
| 35 | (defvar org-babel-default-header-args:calc nil | ||
| 36 | "Default arguments for evaluating an calc source block.") | ||
| 37 | |||
| 38 | (defun org-babel-expand-body:calc (body params) | ||
| 39 | "Expand BODY according to PARAMS, return the expanded body." body) | ||
| 40 | |||
| 41 | (defun org-babel-execute:calc (body params) | ||
| 42 | "Execute a block of calc code with Babel." | ||
| 43 | (mapcar | ||
| 44 | (lambda (line) | ||
| 45 | (when (> (length line) 0) | ||
| 46 | (if (string= "'" (substring line 0 1)) | ||
| 47 | (funcall (lookup-key calc-mode-map (substring line 1)) nil) | ||
| 48 | (calc-push-list | ||
| 49 | (list ((lambda (res) | ||
| 50 | (cond | ||
| 51 | ((numberp res) res) | ||
| 52 | ((listp res) (error "calc error \"%s\" on input \"%s\"" | ||
| 53 | (cadr res) line)) | ||
| 54 | (t res)) | ||
| 55 | (if (numberp res) res (math-read-number res))) | ||
| 56 | (calc-eval line))))))) | ||
| 57 | (mapcar #'org-babel-trim | ||
| 58 | (split-string (org-babel-expand-body:calc body params) "[\n\r]"))) | ||
| 59 | (save-excursion | ||
| 60 | (set-buffer (get-buffer "*Calculator*")) | ||
| 61 | (calc-eval (calc-top 1)))) | ||
| 62 | |||
| 63 | (provide 'ob-calc) | ||
| 64 | |||
| 65 | ;; arch-tag: 5c57a3b7-5818-4c6c-acda-7a94831a6449 | ||
| 66 | |||
| 67 | ;;; ob-calc.el ends here | ||
diff --git a/lisp/org/ob-clojure.el b/lisp/org/ob-clojure.el index c42d9b4db38..0a76e827125 100644 --- a/lisp/org/ob-clojure.el +++ b/lisp/org/ob-clojure.el | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | ;; Author: Joel Boehland | 5 | ;; Author: Joel Boehland |
| 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.01 | 8 | ;; Version: 7.3 |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -45,7 +45,6 @@ | |||
| 45 | (declare-function slime-eval-async "ext:slime" (sexp &optional cont package)) | 45 | (declare-function slime-eval-async "ext:slime" (sexp &optional cont package)) |
| 46 | (declare-function slime-eval "ext:slime" (sexp &optional package)) | 46 | (declare-function slime-eval "ext:slime" (sexp &optional package)) |
| 47 | (declare-function swank-clojure-concat-paths "ext:slime" (paths)) | 47 | (declare-function swank-clojure-concat-paths "ext:slime" (paths)) |
| 48 | (declare-function org-babel-ref-variables "ext:slime" (params)) | ||
| 49 | (declare-function slime "ext:slime" (&optional command coding-system)) | 48 | (declare-function slime "ext:slime" (&optional command coding-system)) |
| 50 | (declare-function slime-output-buffer "ext:slime" (&optional noprompt)) | 49 | (declare-function slime-output-buffer "ext:slime" (&optional noprompt)) |
| 51 | (declare-function slime-filter-buffers "ext:slime" (predicate)) | 50 | (declare-function slime-filter-buffers "ext:slime" (predicate)) |
| @@ -92,28 +91,28 @@ | |||
| 92 | (defvar swank-clojure-extra-classpaths) | 91 | (defvar swank-clojure-extra-classpaths) |
| 93 | (defun org-babel-clojure-babel-clojure-cmd () | 92 | (defun org-babel-clojure-babel-clojure-cmd () |
| 94 | "Create the command to start clojure according to current settings." | 93 | "Create the command to start clojure according to current settings." |
| 95 | (if (and (not swank-clojure-binary) (not swank-clojure-classpath)) | 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")))) | ||
| 96 | (error "%s" (concat "You must specifiy either a `swank-clojure-binary' " | 114 | (error "%s" (concat "You must specifiy either a `swank-clojure-binary' " |
| 97 | "or a `swank-clojure-jar-path'")) | 115 | "or a `swank-clojure-classpath'")))) |
| 98 | (if swank-clojure-binary | ||
| 99 | (if (listp swank-clojure-binary) | ||
| 100 | swank-clojure-binary | ||
| 101 | (list swank-clojure-binary)) | ||
| 102 | (delq | ||
| 103 | nil | ||
| 104 | (append | ||
| 105 | (list swank-clojure-java-path) | ||
| 106 | swank-clojure-extra-vm-args | ||
| 107 | (list | ||
| 108 | (when swank-clojure-library-paths | ||
| 109 | (concat "-Djava.library.path=" | ||
| 110 | (swank-clojure-concat-paths swank-clojure-library-paths))) | ||
| 111 | "-classpath" | ||
| 112 | (swank-clojure-concat-paths | ||
| 113 | (append | ||
| 114 | swank-clojure-classpath | ||
| 115 | swank-clojure-extra-classpaths)) | ||
| 116 | "clojure.main")))))) | ||
| 117 | 116 | ||
| 118 | (defun org-babel-clojure-table-or-string (results) | 117 | (defun org-babel-clojure-table-or-string (results) |
| 119 | "Convert RESULTS to an elisp value. | 118 | "Convert RESULTS to an elisp value. |
| @@ -155,7 +154,7 @@ code specifying a variable of the same value." | |||
| 155 | "Prepare SESSION according to the header arguments specified in PARAMS." | 154 | "Prepare SESSION according to the header arguments specified in PARAMS." |
| 156 | (require 'slime) (require 'swank-clojure) | 155 | (require 'slime) (require 'swank-clojure) |
| 157 | (let* ((session-buf (org-babel-clojure-initiate-session session)) | 156 | (let* ((session-buf (org-babel-clojure-initiate-session session)) |
| 158 | (vars (org-babel-ref-variables params)) | 157 | (vars (mapcar #'cdr (org-babel-get-header params :var))) |
| 159 | (var-lines (mapcar ;; define any top level session variables | 158 | (var-lines (mapcar ;; define any top level session variables |
| 160 | (lambda (pair) | 159 | (lambda (pair) |
| 161 | (format "(def %s %s)\n" (car pair) | 160 | (format "(def %s %s)\n" (car pair) |
| @@ -261,9 +260,13 @@ repl buffer." | |||
| 261 | " ")))) | 260 | " ")))) |
| 262 | (case result-type | 261 | (case result-type |
| 263 | (output (org-babel-eval cmd body)) | 262 | (output (org-babel-eval cmd body)) |
| 264 | (value (let* ((tmp-file (make-temp-file "org-babel-clojure-results-"))) | 263 | (value (let* ((tmp-file (org-babel-temp-file "clojure-"))) |
| 265 | (org-babel-eval cmd (format org-babel-clojure-wrapper-method | 264 | (org-babel-eval |
| 266 | body tmp-file tmp-file)) | 265 | cmd |
| 266 | (format | ||
| 267 | org-babel-clojure-wrapper-method | ||
| 268 | body | ||
| 269 | (org-babel-process-file-name tmp-file 'noquote))) | ||
| 267 | (org-babel-clojure-table-or-string | 270 | (org-babel-clojure-table-or-string |
| 268 | (org-babel-eval-read-file tmp-file))))))) | 271 | (org-babel-eval-read-file tmp-file))))))) |
| 269 | 272 | ||
| @@ -290,24 +293,23 @@ return the value of the last statement in BODY as elisp." | |||
| 290 | (org-babel-clojure-evaluate-session buffer body result-type) | 293 | (org-babel-clojure-evaluate-session buffer body result-type) |
| 291 | (org-babel-clojure-evaluate-external-process buffer body result-type))) | 294 | (org-babel-clojure-evaluate-external-process buffer body result-type))) |
| 292 | 295 | ||
| 293 | (defun org-babel-expand-body:clojure (body params &optional processed-params) | 296 | (defun org-babel-expand-body:clojure (body params) |
| 294 | "Expand BODY according to PARAMS, return the expanded body." | 297 | "Expand BODY according to PARAMS, return the expanded body." |
| 295 | (org-babel-clojure-build-full-form | 298 | (org-babel-clojure-build-full-form |
| 296 | body (nth 1 (or processed-params (org-babel-process-params params))))) | 299 | body (mapcar #'cdr (org-babel-get-header params :var)))) |
| 297 | 300 | ||
| 298 | (defun org-babel-execute:clojure (body params) | 301 | (defun org-babel-execute:clojure (body params) |
| 299 | "Execute a block of Clojure code." | 302 | "Execute a block of Clojure code." |
| 300 | (require 'slime) (require 'swank-clojure) | 303 | (require 'slime) (require 'swank-clojure) |
| 301 | (let* ((processed-params (org-babel-process-params params)) | 304 | (let* ((body (org-babel-expand-body:clojure body params)) |
| 302 | (body (org-babel-expand-body:clojure body params processed-params)) | ||
| 303 | (session (org-babel-clojure-initiate-session | 305 | (session (org-babel-clojure-initiate-session |
| 304 | (first processed-params)))) | 306 | (cdr (assoc :session params))))) |
| 305 | (org-babel-reassemble-table | 307 | (org-babel-reassemble-table |
| 306 | (org-babel-clojure-evaluate session body (nth 3 processed-params)) | 308 | (org-babel-clojure-evaluate session body (cdr (assoc :result-type params))) |
| 307 | (org-babel-pick-name | 309 | (org-babel-pick-name |
| 308 | (nth 4 processed-params) (cdr (assoc :colnames params))) | 310 | (cdr (assoc :colname-names params)) (cdr (assoc :colnames params))) |
| 309 | (org-babel-pick-name | 311 | (org-babel-pick-name |
| 310 | (nth 5 processed-params) (cdr (assoc :rownames params)))))) | 312 | (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params)))))) |
| 311 | 313 | ||
| 312 | (provide 'ob-clojure) | 314 | (provide 'ob-clojure) |
| 313 | 315 | ||
diff --git a/lisp/org/ob-comint.el b/lisp/org/ob-comint.el index 732f2766b28..d05b7fbfa40 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.01 | 8 | ;; Version: 7.3 |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -34,6 +34,8 @@ | |||
| 34 | (require 'ob) | 34 | (require 'ob) |
| 35 | (require 'comint) | 35 | (require 'comint) |
| 36 | (eval-when-compile (require 'cl)) | 36 | (eval-when-compile (require 'cl)) |
| 37 | (declare-function with-parsed-tramp-file-name "tramp" (filename var &rest body)) | ||
| 38 | (declare-function tramp-flush-directory-property "tramp" (vec directory)) | ||
| 37 | 39 | ||
| 38 | (defun org-babel-comint-buffer-livep (buffer) | 40 | (defun org-babel-comint-buffer-livep (buffer) |
| 39 | "Check if BUFFER is a comint buffer with a live process." | 41 | "Check if BUFFER is a comint buffer with a live process." |
| @@ -43,7 +45,7 @@ | |||
| 43 | (defmacro org-babel-comint-in-buffer (buffer &rest body) | 45 | (defmacro org-babel-comint-in-buffer (buffer &rest body) |
| 44 | "Check BUFFER and execute BODY. | 46 | "Check BUFFER and execute BODY. |
| 45 | BUFFER is checked with `org-babel-comint-buffer-livep'. BODY is | 47 | BUFFER is checked with `org-babel-comint-buffer-livep'. BODY is |
| 46 | executed inside the protection of `save-window-excursion' and | 48 | executed inside the protection of `save-excursion' and |
| 47 | `save-match-data'." | 49 | `save-match-data'." |
| 48 | (declare (indent 1)) | 50 | (declare (indent 1)) |
| 49 | `(save-excursion | 51 | `(save-excursion |
| @@ -136,6 +138,24 @@ statement (not large blocks of code)." | |||
| 136 | "comint-highlight-prompt")))) | 138 | "comint-highlight-prompt")))) |
| 137 | (accept-process-output (get-buffer-process buffer))))) | 139 | (accept-process-output (get-buffer-process buffer))))) |
| 138 | 140 | ||
| 141 | (defun org-babel-comint-eval-invisibly-and-wait-for-file | ||
| 142 | (buffer file string &optional period) | ||
| 143 | "Evaluate STRING in BUFFER invisibly. | ||
| 144 | Don't return until FILE exists. Code in STRING must ensure that | ||
| 145 | FILE exists at end of evaluation." | ||
| 146 | (unless (org-babel-comint-buffer-livep buffer) | ||
| 147 | (error "buffer %s doesn't exist or has no process" buffer)) | ||
| 148 | (if (file-exists-p file) (delete-file file)) | ||
| 149 | (process-send-string | ||
| 150 | (get-buffer-process buffer) | ||
| 151 | (if (string-match "\n$" string) string (concat string "\n"))) | ||
| 152 | ;; From Tramp 2.1.19 the following cache flush is not necessary | ||
| 153 | (if (file-remote-p default-directory) | ||
| 154 | (let (v) | ||
| 155 | (with-parsed-tramp-file-name default-directory nil | ||
| 156 | (tramp-flush-directory-property v "")))) | ||
| 157 | (while (not (file-exists-p file)) (sit-for (or period 0.25)))) | ||
| 158 | |||
| 139 | (provide 'ob-comint) | 159 | (provide 'ob-comint) |
| 140 | 160 | ||
| 141 | ;; arch-tag: 9adddce6-0864-4be3-b0b5-6c5157dc7889 | 161 | ;; arch-tag: 9adddce6-0864-4be3-b0b5-6c5157dc7889 |
diff --git a/lisp/org/ob-css.el b/lisp/org/ob-css.el index 0a279b24573..d93f28dcebc 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.01 | 8 | ;; Version: 7.3 |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -32,9 +32,6 @@ | |||
| 32 | 32 | ||
| 33 | (defvar org-babel-default-header-args:css '()) | 33 | (defvar org-babel-default-header-args:css '()) |
| 34 | 34 | ||
| 35 | (defun org-babel-expand-body:css (body params &optional processed-params) | ||
| 36 | "Expand BODY according to PARAMS, return the expanded body." body) | ||
| 37 | |||
| 38 | (defun org-babel-execute:css (body params) | 35 | (defun org-babel-execute:css (body params) |
| 39 | "Execute a block of CSS code. | 36 | "Execute a block of CSS code. |
| 40 | This function is called by `org-babel-execute-src-block'." | 37 | This function is called by `org-babel-execute-src-block'." |
diff --git a/lisp/org/ob-ditaa.el b/lisp/org/ob-ditaa.el index 336eaa93f12..a9b6b3ceaf1 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.01 | 8 | ;; Version: 7.3 |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -43,22 +43,24 @@ | |||
| 43 | '((:results . "file") (:exports . "results")) | 43 | '((:results . "file") (:exports . "results")) |
| 44 | "Default arguments for evaluating a ditaa source block.") | 44 | "Default arguments for evaluating a ditaa source block.") |
| 45 | 45 | ||
| 46 | (defun org-babel-expand-body:ditaa (body params &optional processed-params) | ||
| 47 | "Expand BODY according to PARAMS, return the expanded body." body) | ||
| 48 | |||
| 49 | (defvar org-ditaa-jar-path) | 46 | (defvar org-ditaa-jar-path) |
| 50 | (defun org-babel-execute:ditaa (body params) | 47 | (defun org-babel-execute:ditaa (body params) |
| 51 | "Execute a block of Ditaa code with org-babel. | 48 | "Execute a block of Ditaa code with org-babel. |
| 52 | This function is called by `org-babel-execute-src-block'." | 49 | This function is called by `org-babel-execute-src-block'." |
| 53 | (let ((result-params (split-string (or (cdr (assoc :results params)) ""))) | 50 | (let* ((result-params (split-string (or (cdr (assoc :results params)) ""))) |
| 54 | (out-file (cdr (assoc :file params))) | 51 | (out-file (cdr (assoc :file params))) |
| 55 | (cmdline (cdr (assoc :cmdline params))) | 52 | (cmdline (cdr (assoc :cmdline params))) |
| 56 | (in-file (make-temp-file "org-babel-ditaa"))) | 53 | (in-file (org-babel-temp-file "ditaa-")) |
| 54 | (cmd (concat "java -jar " | ||
| 55 | (shell-quote-argument | ||
| 56 | (expand-file-name org-ditaa-jar-path)) | ||
| 57 | " " cmdline | ||
| 58 | " " (org-babel-process-file-name in-file) | ||
| 59 | " " (org-babel-process-file-name out-file)))) | ||
| 57 | (unless (file-exists-p org-ditaa-jar-path) | 60 | (unless (file-exists-p org-ditaa-jar-path) |
| 58 | (error "Could not find ditaa.jar at %s" org-ditaa-jar-path)) | 61 | (error "Could not find ditaa.jar at %s" org-ditaa-jar-path)) |
| 59 | (with-temp-file in-file (insert body)) | 62 | (with-temp-file in-file (insert body)) |
| 60 | (message (concat "java -jar " org-ditaa-jar-path " " cmdline " " in-file " " out-file)) | 63 | (message cmd) (shell-command cmd) |
| 61 | (shell-command (concat "java -jar " (shell-quote-argument org-ditaa-jar-path) " " cmdline " " in-file " " out-file)) | ||
| 62 | out-file)) | 64 | out-file)) |
| 63 | 65 | ||
| 64 | (defun org-babel-prep-session:ditaa (session params) | 66 | (defun org-babel-prep-session:ditaa (session params) |
diff --git a/lisp/org/ob-dot.el b/lisp/org/ob-dot.el index 4657fb80ba0..c78f3dbee0d 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.01 | 8 | ;; Version: 7.3 |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -46,10 +46,9 @@ | |||
| 46 | '((:results . "file") (:exports . "results")) | 46 | '((:results . "file") (:exports . "results")) |
| 47 | "Default arguments to use when evaluating a dot source block.") | 47 | "Default arguments to use when evaluating a dot source block.") |
| 48 | 48 | ||
| 49 | (defun org-babel-expand-body:dot (body params &optional processed-params) | 49 | (defun org-babel-expand-body:dot (body params) |
| 50 | "Expand BODY according to PARAMS, return the expanded body." | 50 | "Expand BODY according to PARAMS, return the expanded body." |
| 51 | (let ((vars (nth 1 (or processed-params | 51 | (let ((vars (mapcar #'cdr (org-babel-get-header params :var)))) |
| 52 | (org-babel-process-params params))))) | ||
| 53 | (mapc | 52 | (mapc |
| 54 | (lambda (pair) | 53 | (lambda (pair) |
| 55 | (let ((name (symbol-name (car pair))) | 54 | (let ((name (symbol-name (car pair))) |
| @@ -65,15 +64,19 @@ | |||
| 65 | (defun org-babel-execute:dot (body params) | 64 | (defun org-babel-execute:dot (body params) |
| 66 | "Execute a block of Dot code with org-babel. | 65 | "Execute a block of Dot code with org-babel. |
| 67 | This function is called by `org-babel-execute-src-block'." | 66 | This function is called by `org-babel-execute-src-block'." |
| 68 | (let ((processed-params (org-babel-process-params params)) | 67 | (let* ((result-params (cdr (assoc :result-params params))) |
| 69 | (result-params (split-string (or (cdr (assoc :results params)) ""))) | 68 | (out-file (cdr (assoc :file params))) |
| 70 | (out-file (cdr (assoc :file params))) | 69 | (cmdline (or (cdr (assoc :cmdline params)) |
| 71 | (cmdline (cdr (assoc :cmdline params))) | 70 | (format "-T%s" (file-name-extension out-file)))) |
| 72 | (cmd (or (cdr (assoc :cmd params)) "dot")) | 71 | (cmd (or (cdr (assoc :cmd params)) "dot")) |
| 73 | (in-file (make-temp-file "org-babel-dot"))) | 72 | (in-file (org-babel-temp-file "dot-"))) |
| 74 | (with-temp-file in-file | 73 | (with-temp-file in-file |
| 75 | (insert (org-babel-expand-body:dot body params processed-params))) | 74 | (insert (org-babel-expand-body:dot body params))) |
| 76 | (org-babel-eval (concat cmd " " in-file " " cmdline " -o " out-file) "") | 75 | (org-babel-eval |
| 76 | (concat cmd | ||
| 77 | " " (org-babel-process-file-name in-file) | ||
| 78 | " " cmdline | ||
| 79 | " -o " (org-babel-process-file-name out-file)) "") | ||
| 77 | out-file)) | 80 | out-file)) |
| 78 | 81 | ||
| 79 | (defun org-babel-prep-session:dot (session params) | 82 | (defun org-babel-prep-session:dot (session params) |
diff --git a/lisp/org/ob-emacs-lisp.el b/lisp/org/ob-emacs-lisp.el index 2ec729f7dcd..d74a7a579da 100644 --- a/lisp/org/ob-emacs-lisp.el +++ b/lisp/org/ob-emacs-lisp.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.01 | 8 | ;; Version: 7.3 |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -36,16 +36,16 @@ | |||
| 36 | 36 | ||
| 37 | (declare-function orgtbl-to-generic "org-table" (table params)) | 37 | (declare-function orgtbl-to-generic "org-table" (table params)) |
| 38 | 38 | ||
| 39 | (defun org-babel-expand-body:emacs-lisp (body params &optional processed-params) | 39 | (defun org-babel-expand-body:emacs-lisp (body params) |
| 40 | "Expand BODY according to PARAMS, return the expanded body." | 40 | "Expand BODY according to PARAMS, return the expanded body." |
| 41 | (let* ((processed-params (or processed-params (org-babel-process-params params))) | 41 | (let* ((vars (mapcar #'cdr (org-babel-get-header params :var))) |
| 42 | (vars (nth 1 processed-params)) | 42 | (result-params (cdr (assoc :result-params params))) |
| 43 | (result-params (nth 2 processed-params)) | ||
| 44 | (print-level nil) (print-length nil) | 43 | (print-level nil) (print-length nil) |
| 45 | (body (if (> (length vars) 0) | 44 | (body (if (> (length vars) 0) |
| 46 | (concat "(let (" | 45 | (concat "(let (" |
| 47 | (mapconcat | 46 | (mapconcat |
| 48 | (lambda (var) (format "%S" (print `(,(car var) ',(cdr var))))) | 47 | (lambda (var) |
| 48 | (format "%S" (print `(,(car var) ',(cdr var))))) | ||
| 49 | vars "\n ") | 49 | vars "\n ") |
| 50 | ")\n" body ")") | 50 | ")\n" body ")") |
| 51 | body))) | 51 | body))) |
| @@ -56,13 +56,13 @@ | |||
| 56 | (defun org-babel-execute:emacs-lisp (body params) | 56 | (defun org-babel-execute:emacs-lisp (body params) |
| 57 | "Execute a block of emacs-lisp code with Babel." | 57 | "Execute a block of emacs-lisp code with Babel." |
| 58 | (save-window-excursion | 58 | (save-window-excursion |
| 59 | (let ((processed-params (org-babel-process-params params))) | 59 | (org-babel-reassemble-table |
| 60 | (org-babel-reassemble-table | 60 | (eval (read (format "(progn %s)" |
| 61 | (eval (read (format "(progn %s)" | 61 | (org-babel-expand-body:emacs-lisp body params)))) |
| 62 | (org-babel-expand-body:emacs-lisp | 62 | (org-babel-pick-name (cdr (assoc :colname-names params)) |
| 63 | body params processed-params)))) | 63 | (cdr (assoc :colnames params))) |
| 64 | (org-babel-pick-name (nth 4 processed-params) (cdr (assoc :colnames params))) | 64 | (org-babel-pick-name (cdr (assoc :rowname-names params)) |
| 65 | (org-babel-pick-name (nth 5 processed-params) (cdr (assoc :rownames params))))))) | 65 | (cdr (assoc :rownames params)))))) |
| 66 | 66 | ||
| 67 | (provide 'ob-emacs-lisp) | 67 | (provide 'ob-emacs-lisp) |
| 68 | 68 | ||
diff --git a/lisp/org/ob-eval.el b/lisp/org/ob-eval.el index dea39f12089..57f4dc509aa 100644 --- a/lisp/org/ob-eval.el +++ b/lisp/org/ob-eval.el | |||
| @@ -1,11 +1,11 @@ | |||
| 1 | ;;; ob-run.el --- org-babel functions for external code evaluation | 1 | ;;; ob-eval.el --- org-babel functions for external 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, comint | 6 | ;; Keywords: literate programming, reproducible research, comint |
| 7 | ;; Homepage: http://orgmode.org | 7 | ;; Homepage: http://orgmode.org |
| 8 | ;; Version: 7.01 | 8 | ;; Version: 7.3 |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -42,7 +42,7 @@ | |||
| 42 | 42 | ||
| 43 | (defun org-babel-eval (cmd body) | 43 | (defun org-babel-eval (cmd body) |
| 44 | "Run CMD on BODY. | 44 | "Run CMD on BODY. |
| 45 | If CMD succeeds then return it's results, otherwise display | 45 | If CMD succeeds then return its results, otherwise display |
| 46 | STDERR with `org-babel-eval-error-notify'." | 46 | STDERR with `org-babel-eval-error-notify'." |
| 47 | (let ((err-buff (get-buffer-create "*Org-Babel Error*")) exit-code) | 47 | (let ((err-buff (get-buffer-create "*Org-Babel Error*")) exit-code) |
| 48 | (with-current-buffer err-buff (erase-buffer)) | 48 | (with-current-buffer err-buff (erase-buffer)) |
| @@ -60,8 +60,7 @@ STDERR with `org-babel-eval-error-notify'." | |||
| 60 | 60 | ||
| 61 | (defun org-babel-eval-read-file (file) | 61 | (defun org-babel-eval-read-file (file) |
| 62 | "Return the contents of FILE as a string." | 62 | "Return the contents of FILE as a string." |
| 63 | (with-temp-buffer (insert-file-contents | 63 | (with-temp-buffer (insert-file-contents file) |
| 64 | (org-babel-maybe-remote-file file)) | ||
| 65 | (buffer-string))) | 64 | (buffer-string))) |
| 66 | 65 | ||
| 67 | (defun org-babel-shell-command-on-region (start end command | 66 | (defun org-babel-shell-command-on-region (start end command |
| @@ -252,4 +251,4 @@ specifies the value of ERROR-BUFFER." | |||
| 252 | 251 | ||
| 253 | ;; arch-tag: 5328b17f-957d-42d9-94da-a2952682d04d | 252 | ;; arch-tag: 5328b17f-957d-42d9-94da-a2952682d04d |
| 254 | 253 | ||
| 255 | ;;; ob-comint.el ends here | 254 | ;;; ob-eval.el ends here |
diff --git a/lisp/org/ob-exp.el b/lisp/org/ob-exp.el index 4c074887ef1..52da00103f6 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.01 | 8 | ;; Version: 7.3 |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -49,7 +49,7 @@ | |||
| 49 | 49 | ||
| 50 | (defcustom org-export-babel-evaluate t | 50 | (defcustom org-export-babel-evaluate t |
| 51 | "Switch controlling code evaluation during export. | 51 | "Switch controlling code evaluation during export. |
| 52 | When set to nil no code will be exported as part of the export | 52 | When set to nil no code will be evaluated as part of the export |
| 53 | process." | 53 | process." |
| 54 | :group 'org-babel | 54 | :group 'org-babel |
| 55 | :type 'boolean) | 55 | :type 'boolean) |
| @@ -77,6 +77,30 @@ be indented by this many characters. See | |||
| 77 | `org-babel-function-def-export-name' for the definition of a | 77 | `org-babel-function-def-export-name' for the definition of a |
| 78 | source block function.") | 78 | source block function.") |
| 79 | 79 | ||
| 80 | (defmacro org-babel-exp-in-export-file (&rest body) | ||
| 81 | `(let* ((lang-headers (intern (concat "org-babel-default-header-args:" lang))) | ||
| 82 | (heading (nth 4 (ignore-errors (org-heading-components)))) | ||
| 83 | (link (when org-current-export-file | ||
| 84 | (org-make-link-string | ||
| 85 | (if heading | ||
| 86 | (concat org-current-export-file "::" heading) | ||
| 87 | org-current-export-file)))) | ||
| 88 | (export-buffer (current-buffer)) results) | ||
| 89 | (when link | ||
| 90 | ;; resolve parameters in the original file so that | ||
| 91 | ;; headline and file-wide parameters are included, attempt | ||
| 92 | ;; to go to the same heading in the original file | ||
| 93 | (set-buffer (get-file-buffer org-current-export-file)) | ||
| 94 | (save-restriction | ||
| 95 | (condition-case nil | ||
| 96 | (org-open-link-from-string link) | ||
| 97 | (error (when heading | ||
| 98 | (goto-char (point-min)) | ||
| 99 | (re-search-forward (regexp-quote heading) nil t)))) | ||
| 100 | (setq results ,@body)) | ||
| 101 | (set-buffer export-buffer) | ||
| 102 | results))) | ||
| 103 | |||
| 80 | (defun org-babel-exp-src-blocks (body &rest headers) | 104 | (defun org-babel-exp-src-blocks (body &rest headers) |
| 81 | "Process source block for export. | 105 | "Process source block for export. |
| 82 | Depending on the 'export' headers argument in replace the source | 106 | Depending on the 'export' headers argument in replace the source |
| @@ -95,18 +119,27 @@ none ----- do not display either code or results upon export" | |||
| 95 | (message "org-babel-exp processing...") | 119 | (message "org-babel-exp processing...") |
| 96 | (save-excursion | 120 | (save-excursion |
| 97 | (goto-char (match-beginning 0)) | 121 | (goto-char (match-beginning 0)) |
| 98 | (let* ((info (org-babel-get-src-block-info)) | 122 | (let* ((info (org-babel-get-src-block-info 'light)) |
| 99 | (params (nth 2 info))) | 123 | (lang (nth 0 info)) |
| 124 | (raw-params (nth 2 info))) | ||
| 100 | ;; bail if we couldn't get any info from the block | 125 | ;; bail if we couldn't get any info from the block |
| 101 | (when info | 126 | (when info |
| 127 | (org-babel-exp-in-export-file | ||
| 128 | (setf (nth 2 info) | ||
| 129 | (org-babel-merge-params | ||
| 130 | org-babel-default-header-args | ||
| 131 | (org-babel-params-from-buffer) | ||
| 132 | (org-babel-params-from-properties lang) | ||
| 133 | (if (boundp lang-headers) (eval lang-headers) nil) | ||
| 134 | raw-params))) | ||
| 102 | ;; expand noweb references in the original file | 135 | ;; expand noweb references in the original file |
| 103 | (setf (nth 1 info) | 136 | (setf (nth 1 info) |
| 104 | (if (and (cdr (assoc :noweb params)) | 137 | (if (and (cdr (assoc :noweb (nth 2 info))) |
| 105 | (string= "yes" (cdr (assoc :noweb params)))) | 138 | (string= "yes" (cdr (assoc :noweb (nth 2 info))))) |
| 106 | (org-babel-expand-noweb-references | 139 | (org-babel-expand-noweb-references |
| 107 | info (get-file-buffer org-current-export-file)) | 140 | info (get-file-buffer org-current-export-file)) |
| 108 | (nth 1 info)))) | 141 | (nth 1 info))) |
| 109 | (org-babel-exp-do-export info 'block)))) | 142 | (org-babel-exp-do-export info 'block))))) |
| 110 | 143 | ||
| 111 | (defun org-babel-exp-inline-src-blocks (start end) | 144 | (defun org-babel-exp-inline-src-blocks (start end) |
| 112 | "Process inline source blocks between START and END for export. | 145 | "Process inline source blocks between START and END for export. |
| @@ -178,6 +211,8 @@ options are taken from `org-babel-default-header-args'." | |||
| 178 | (list "emacs-lisp" "results" | 211 | (list "emacs-lisp" "results" |
| 179 | (org-babel-merge-params | 212 | (org-babel-merge-params |
| 180 | org-babel-default-header-args | 213 | org-babel-default-header-args |
| 214 | (org-babel-params-from-buffer) | ||
| 215 | (org-babel-params-from-properties) | ||
| 181 | (org-babel-parse-header-arguments | 216 | (org-babel-parse-header-arguments |
| 182 | (org-babel-clean-text-properties | 217 | (org-babel-clean-text-properties |
| 183 | (concat ":var results=" | 218 | (concat ":var results=" |
| @@ -193,8 +228,7 @@ options are taken from `org-babel-default-header-args'." | |||
| 193 | The function respects the value of the :exports header argument." | 228 | The function respects the value of the :exports header argument." |
| 194 | (flet ((silently () (let ((session (cdr (assoc :session (nth 2 info))))) | 229 | (flet ((silently () (let ((session (cdr (assoc :session (nth 2 info))))) |
| 195 | (when (and session | 230 | (when (and session |
| 196 | (not (equal "none" session)) | 231 | (not (equal "none" session))) |
| 197 | (not (assoc :noeval (nth 2 info)))) | ||
| 198 | (org-babel-exp-results info type 'silent)))) | 232 | (org-babel-exp-results info type 'silent)))) |
| 199 | (clean () (org-babel-remove-result info))) | 233 | (clean () (org-babel-remove-result info))) |
| 200 | (case (intern (or (cdr (assoc :exports (nth 2 info))) "code")) | 234 | (case (intern (or (cdr (assoc :exports (nth 2 info))) "code")) |
| @@ -208,16 +242,14 @@ The function respects the value of the :exports header argument." | |||
| 208 | (defvar backend) | 242 | (defvar backend) |
| 209 | (defun org-babel-exp-code (info type) | 243 | (defun org-babel-exp-code (info type) |
| 210 | "Prepare and return code in the current code block for export. | 244 | "Prepare and return code in the current code block for export. |
| 211 | Code is prepared in a manner suitable for exportat by | 245 | Code is prepared in a manner suitable for export by |
| 212 | org-mode. This function is called by `org-babel-exp-do-export'. | 246 | org-mode. This function is called by `org-babel-exp-do-export'. |
| 213 | The code block is not evaluated." | 247 | The code block is not evaluated." |
| 214 | (let ((lang (nth 0 info)) | 248 | (let ((lang (nth 0 info)) |
| 215 | (body (nth 1 info)) | 249 | (body (nth 1 info)) |
| 216 | (switches (nth 3 info)) | 250 | (switches (nth 3 info)) |
| 217 | (name (nth 4 info)) | 251 | (name (nth 4 info)) |
| 218 | (args (mapcar | 252 | (args (mapcar #'cdr (org-babel-get-header (nth 2 info) :var)))) |
| 219 | #'cdr | ||
| 220 | (org-remove-if-not (lambda (el) (eq :var (car el))) (nth 2 info))))) | ||
| 221 | (case type | 253 | (case type |
| 222 | ('inline (format "=%s=" body)) | 254 | ('inline (format "=%s=" body)) |
| 223 | ('block | 255 | ('block |
| @@ -249,62 +281,45 @@ Results are prepared in a manner suitable for export by org-mode. | |||
| 249 | This function is called by `org-babel-exp-do-export'. The code | 281 | This function is called by `org-babel-exp-do-export'. The code |
| 250 | block will be evaluated. Optional argument SILENT can be used to | 282 | block will be evaluated. Optional argument SILENT can be used to |
| 251 | inhibit insertion of results into the buffer." | 283 | inhibit insertion of results into the buffer." |
| 252 | (if org-export-babel-evaluate | 284 | (or |
| 253 | (let ((lang (nth 0 info)) | 285 | (when org-export-babel-evaluate |
| 254 | (body (nth 1 info)) | 286 | (let ((lang (nth 0 info)) |
| 255 | (params | 287 | (body (nth 1 info))) |
| 256 | ;; lets ensure that we lookup references in the original file | 288 | (setf (nth 2 info) (org-babel-exp-in-export-file |
| 257 | (mapcar | 289 | (org-babel-process-params (nth 2 info)))) |
| 258 | (lambda (pair) | 290 | ;; skip code blocks which we can't evaluate |
| 259 | (if (and org-current-export-file | 291 | (when (fboundp (intern (concat "org-babel-execute:" lang))) |
| 260 | (eq (car pair) :var) | 292 | (if (equal type 'inline) |
| 261 | (string-match org-babel-ref-split-regexp (cdr pair)) | 293 | (let ((raw (org-babel-execute-src-block |
| 262 | (equal :ob-must-be-reference | 294 | nil info '((:results . "silent")))) |
| 263 | (org-babel-ref-literal | 295 | (result-params (split-string |
| 264 | (match-string 2 (cdr pair))))) | 296 | (cdr (assoc :results (nth 2 info)))))) |
| 265 | `(:var . ,(concat (match-string 1 (cdr pair)) | 297 | (unless silent |
| 266 | "=" org-current-export-file | 298 | (cond ;; respect the value of the :results header argument |
| 267 | ":" (match-string 2 (cdr pair)))) | 299 | ((member "file" result-params) |
| 268 | pair)) | 300 | (org-babel-result-to-file raw)) |
| 269 | (nth 2 info)))) | 301 | ((or (member "raw" result-params) |
| 270 | ;; skip code blocks which we can't evaluate | 302 | (member "org" result-params)) |
| 271 | (if (fboundp (intern (concat "org-babel-execute:" lang))) | 303 | (format "%s" raw)) |
| 272 | (case type | 304 | ((member "code" result-params) |
| 273 | ('inline | 305 | (format "src_%s{%s}" lang raw)) |
| 274 | (let ((raw (org-babel-execute-src-block | 306 | (t |
| 275 | nil info '((:results . "silent")))) | 307 | (if (stringp raw) |
| 276 | (result-params (split-string | 308 | (if (= 0 (length raw)) "=(no results)=" |
| 277 | (cdr (assoc :results params))))) | 309 | (format "%s" raw)) |
| 278 | (unless silent | 310 | (format "%S" raw)))))) |
| 279 | (cond ;; respect the value of the :results header argument | 311 | (prog1 nil |
| 280 | ((member "file" result-params) | 312 | (setf (nth 2 info) |
| 281 | (org-babel-result-to-file raw)) | 313 | (org-babel-merge-params |
| 282 | ((or (member "raw" result-params) | 314 | (nth 2 info) |
| 283 | (member "org" result-params)) | 315 | `((:results . ,(if silent "silent" "replace"))))) |
| 284 | (format "%s" raw)) | 316 | (cond |
| 285 | ((member "code" result-params) | 317 | ((equal type 'block) (org-babel-execute-src-block nil info)) |
| 286 | (format "src_%s{%s}" lang raw)) | 318 | ((equal type 'lob) |
| 287 | (t | ||
| 288 | (if (stringp raw) | ||
| 289 | (if (= 0 (length raw)) "=(no results)=" | ||
| 290 | (format "%s" raw)) | ||
| 291 | (format "%S" raw))))))) | ||
| 292 | ('block | ||
| 293 | (org-babel-execute-src-block | ||
| 294 | nil info (org-babel-merge-params | ||
| 295 | params | ||
| 296 | `((:results . ,(if silent "silent" "replace"))))) | ||
| 297 | "") | ||
| 298 | ('lob | ||
| 299 | (save-excursion | 319 | (save-excursion |
| 300 | (re-search-backward org-babel-lob-one-liner-regexp nil t) | 320 | (re-search-backward org-babel-lob-one-liner-regexp nil t) |
| 301 | (org-babel-execute-src-block | 321 | (org-babel-execute-src-block nil info))))))))) |
| 302 | nil info (org-babel-merge-params | 322 | "")) |
| 303 | params | ||
| 304 | `((:results . ,(if silent "silent" "replace"))))) | ||
| 305 | ""))) | ||
| 306 | "")) | ||
| 307 | "")) | ||
| 308 | 323 | ||
| 309 | (provide 'ob-exp) | 324 | (provide 'ob-exp) |
| 310 | 325 | ||
diff --git a/lisp/org/ob-gnuplot.el b/lisp/org/ob-gnuplot.el index 40543d720b0..053d154610b 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.01 | 8 | ;; Version: 7.3 |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -68,11 +68,11 @@ code." | |||
| 68 | (car pair) ;; variable name | 68 | (car pair) ;; variable name |
| 69 | (if (listp (cdr pair)) ;; variable value | 69 | (if (listp (cdr pair)) ;; variable value |
| 70 | (org-babel-gnuplot-table-to-data | 70 | (org-babel-gnuplot-table-to-data |
| 71 | (cdr pair) (make-temp-file "org-babel-gnuplot") params) | 71 | (cdr pair) (org-babel-temp-file "gnuplot-") params) |
| 72 | (cdr pair)))) | 72 | (cdr pair)))) |
| 73 | (org-babel-ref-variables params))) | 73 | (mapcar #'cdr (org-babel-get-header params :var)))) |
| 74 | 74 | ||
| 75 | (defun org-babel-expand-body:gnuplot (body params &optional processed-params) | 75 | (defun org-babel-expand-body:gnuplot (body params) |
| 76 | "Expand BODY according to PARAMS, return the expanded body." | 76 | "Expand BODY according to PARAMS, return the expanded body." |
| 77 | (save-window-excursion | 77 | (save-window-excursion |
| 78 | (let* ((vars (org-babel-gnuplot-process-vars params)) | 78 | (let* ((vars (org-babel-gnuplot-process-vars params)) |
| @@ -118,9 +118,9 @@ code." | |||
| 118 | ;; insert variables into code body: this should happen last | 118 | ;; insert variables into code body: this should happen last |
| 119 | ;; placing the variables at the *top* of the code in case their | 119 | ;; placing the variables at the *top* of the code in case their |
| 120 | ;; values are used later | 120 | ;; values are used later |
| 121 | (add-to-body (mapconcat | 121 | (add-to-body (mapconcat #'identity |
| 122 | (lambda (pair) (format "%s = \"%s\"" (car pair) (cdr pair))) | 122 | (org-babel-variable-assignments:gnuplot params) |
| 123 | vars "\n")) | 123 | "\n")) |
| 124 | ;; replace any variable names preceded by '$' with the actual | 124 | ;; replace any variable names preceded by '$' with the actual |
| 125 | ;; value of the variable | 125 | ;; value of the variable |
| 126 | (mapc (lambda (pair) | 126 | (mapc (lambda (pair) |
| @@ -141,12 +141,15 @@ This function is called by `org-babel-execute-src-block'." | |||
| 141 | (save-window-excursion | 141 | (save-window-excursion |
| 142 | ;; evaluate the code body with gnuplot | 142 | ;; evaluate the code body with gnuplot |
| 143 | (if (string= session "none") | 143 | (if (string= session "none") |
| 144 | (let ((script-file (make-temp-file "org-babel-gnuplot-script"))) | 144 | (let ((script-file (org-babel-temp-file "gnuplot-script-"))) |
| 145 | (with-temp-file script-file | 145 | (with-temp-file script-file |
| 146 | (insert (concat body "\n"))) | 146 | (insert (concat body "\n"))) |
| 147 | (message "gnuplot \"%s\"" script-file) | 147 | (message "gnuplot \"%s\"" script-file) |
| 148 | (setq output | 148 | (setq output |
| 149 | (shell-command-to-string (format "gnuplot \"%s\"" script-file))) | 149 | (shell-command-to-string |
| 150 | (format | ||
| 151 | "gnuplot \"%s\"" | ||
| 152 | (org-babel-process-file-name script-file)))) | ||
| 150 | (message output)) | 153 | (message output)) |
| 151 | (with-temp-buffer | 154 | (with-temp-buffer |
| 152 | (insert (concat body "\n")) | 155 | (insert (concat body "\n")) |
| @@ -159,10 +162,7 @@ This function is called by `org-babel-execute-src-block'." | |||
| 159 | (defun org-babel-prep-session:gnuplot (session params) | 162 | (defun org-babel-prep-session:gnuplot (session params) |
| 160 | "Prepare SESSION according to the header arguments in PARAMS." | 163 | "Prepare SESSION according to the header arguments in PARAMS." |
| 161 | (let* ((session (org-babel-gnuplot-initiate-session session)) | 164 | (let* ((session (org-babel-gnuplot-initiate-session session)) |
| 162 | (vars (org-babel-ref-variables params)) | 165 | (var-lines (org-babel-variable-assignments:gnuplot params))) |
| 163 | (var-lines (mapcar | ||
| 164 | (lambda (pair) (format "%s = \"%s\"" (car pair) (cdr pair))) | ||
| 165 | vars))) | ||
| 166 | (message "%S" session) | 166 | (message "%S" session) |
| 167 | (org-babel-comint-in-buffer session | 167 | (org-babel-comint-in-buffer session |
| 168 | (mapc (lambda (var-line) | 168 | (mapc (lambda (var-line) |
| @@ -180,6 +180,12 @@ This function is called by `org-babel-execute-src-block'." | |||
| 180 | (insert (org-babel-chomp body))) | 180 | (insert (org-babel-chomp body))) |
| 181 | buffer))) | 181 | buffer))) |
| 182 | 182 | ||
| 183 | (defun org-babel-variable-assignments:gnuplot (params) | ||
| 184 | "Return list of gnuplot statements assigning the block's variables" | ||
| 185 | (mapcar | ||
| 186 | (lambda (pair) (format "%s = \"%s\"" (car pair) (cdr pair))) | ||
| 187 | (org-babel-gnuplot-process-vars params))) | ||
| 188 | |||
| 183 | (defvar gnuplot-buffer) | 189 | (defvar gnuplot-buffer) |
| 184 | (defun org-babel-gnuplot-initiate-session (&optional session params) | 190 | (defun org-babel-gnuplot-initiate-session (&optional session params) |
| 185 | "Initiate a gnuplot session. | 191 | "Initiate a gnuplot session. |
diff --git a/lisp/org/ob-haskell.el b/lisp/org/ob-haskell.el index e0803347a64..1ae8fba66b6 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.01 | 8 | ;; Version: 7.3 |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -59,23 +59,14 @@ | |||
| 59 | 59 | ||
| 60 | (defvar org-babel-haskell-eoe "\"org-babel-haskell-eoe\"") | 60 | (defvar org-babel-haskell-eoe "\"org-babel-haskell-eoe\"") |
| 61 | 61 | ||
| 62 | (defun org-babel-expand-body:haskell (body params &optional processed-params) | ||
| 63 | "Expand BODY according to PARAMS, return the expanded body." | ||
| 64 | (let ((vars (nth 1 (or processed-params (org-babel-process-params params))))) | ||
| 65 | (concat | ||
| 66 | (mapconcat | ||
| 67 | (lambda (pair) (format "let %s = %s" | ||
| 68 | (car pair) | ||
| 69 | (org-babel-haskell-var-to-haskell (cdr pair)))) | ||
| 70 | vars "\n") "\n" body "\n"))) | ||
| 71 | |||
| 72 | (defun org-babel-execute:haskell (body params) | 62 | (defun org-babel-execute:haskell (body params) |
| 73 | "Execute a block of Haskell code." | 63 | "Execute a block of Haskell code." |
| 74 | (let* ((processed-params (org-babel-process-params params)) | 64 | (let* ((session (cdr (assoc :session params))) |
| 75 | (session (nth 0 processed-params)) | 65 | (vars (mapcar #'cdr (org-babel-get-header params :var))) |
| 76 | (vars (nth 1 processed-params)) | 66 | (result-type (cdr (assoc :result-type params))) |
| 77 | (result-type (nth 3 processed-params)) | 67 | (full-body (org-babel-expand-body:generic |
| 78 | (full-body (org-babel-expand-body:haskell body params processed-params)) | 68 | body params |
| 69 | (org-babel-variable-assignments:haskell params))) | ||
| 79 | (session (org-babel-haskell-initiate-session session params)) | 70 | (session (org-babel-haskell-initiate-session session params)) |
| 80 | (raw (org-babel-comint-with-output | 71 | (raw (org-babel-comint-with-output |
| 81 | (session org-babel-haskell-eoe t full-body) | 72 | (session org-babel-haskell-eoe t full-body) |
| @@ -93,8 +84,10 @@ | |||
| 93 | (mapconcat #'identity (reverse (cdr results)) "\n")) | 84 | (mapconcat #'identity (reverse (cdr results)) "\n")) |
| 94 | ((equal result-type 'value) | 85 | ((equal result-type 'value) |
| 95 | (org-babel-haskell-table-or-string (car results)))) | 86 | (org-babel-haskell-table-or-string (car results)))) |
| 96 | (org-babel-pick-name (nth 4 processed-params) (cdr (assoc :colnames params))) | 87 | (org-babel-pick-name (cdr (assoc :colname-names params)) |
| 97 | (org-babel-pick-name (nth 5 processed-params) (cdr (assoc :rownames params)))))) | 88 | (cdr (assoc :colname-names params))) |
| 89 | (org-babel-pick-name (cdr (assoc :rowname-names params)) | ||
| 90 | (cdr (assoc :rowname-names params)))))) | ||
| 98 | 91 | ||
| 99 | (defun org-babel-haskell-read-string (string) | 92 | (defun org-babel-haskell-read-string (string) |
| 100 | "Strip \\\"s from around a haskell string." | 93 | "Strip \\\"s from around a haskell string." |
| @@ -110,34 +103,35 @@ then create one. Return the initialized session." | |||
| 110 | (or (get-buffer "*haskell*") | 103 | (or (get-buffer "*haskell*") |
| 111 | (save-window-excursion (run-haskell) (sleep-for 0.25) (current-buffer)))) | 104 | (save-window-excursion (run-haskell) (sleep-for 0.25) (current-buffer)))) |
| 112 | 105 | ||
| 113 | (defun org-babel-load-session:haskell | 106 | (defun org-babel-load-session:haskell (session body params) |
| 114 | (session body params &optional processed-params) | ||
| 115 | "Load BODY into SESSION." | 107 | "Load BODY into SESSION." |
| 116 | (save-window-excursion | 108 | (save-window-excursion |
| 117 | (let* ((buffer (org-babel-prep-session:haskell | 109 | (let* ((buffer (org-babel-prep-session:haskell session params)) |
| 118 | session params processed-params)) | 110 | (load-file (concat (org-babel-temp-file "haskell-load-") ".hs"))) |
| 119 | (load-file (concat (make-temp-file "org-babel-haskell-load") ".hs"))) | ||
| 120 | (with-temp-buffer | 111 | (with-temp-buffer |
| 121 | (insert body) (write-file load-file) | 112 | (insert body) (write-file load-file) |
| 122 | (haskell-mode) (inferior-haskell-load-file)) | 113 | (haskell-mode) (inferior-haskell-load-file)) |
| 123 | buffer))) | 114 | buffer))) |
| 124 | 115 | ||
| 125 | (defun org-babel-prep-session:haskell | 116 | (defun org-babel-prep-session:haskell (session params) |
| 126 | (session params &optional processed-params) | ||
| 127 | "Prepare SESSION according to the header arguments in PARAMS." | 117 | "Prepare SESSION according to the header arguments in PARAMS." |
| 128 | (save-window-excursion | 118 | (save-window-excursion |
| 129 | (let ((pp (or processed-params (org-babel-process-params params))) | 119 | (let ((buffer (org-babel-haskell-initiate-session session))) |
| 130 | (buffer (org-babel-haskell-initiate-session session))) | ||
| 131 | (org-babel-comint-in-buffer buffer | 120 | (org-babel-comint-in-buffer buffer |
| 132 | (mapc | 121 | (mapc (lambda (line) |
| 133 | (lambda (pair) | 122 | (insert line) |
| 134 | (insert (format "let %s = %s" | 123 | (comint-send-input nil t)) |
| 135 | (car pair) | 124 | (org-babel-variable-assignments:haskell params))) |
| 136 | (org-babel-haskell-var-to-haskell (cdr pair)))) | ||
| 137 | (comint-send-input nil t)) | ||
| 138 | (nth 1 pp))) | ||
| 139 | (current-buffer)))) | 125 | (current-buffer)))) |
| 140 | 126 | ||
| 127 | (defun org-babel-variable-assignments:haskell (params) | ||
| 128 | "Return list of haskell statements assigning the block's variables" | ||
| 129 | (mapcar (lambda (pair) | ||
| 130 | (format "let %s = %s" | ||
| 131 | (car pair) | ||
| 132 | (org-babel-haskell-var-to-haskell (cdr pair)))) | ||
| 133 | (mapcar #'cdr (org-babel-get-header params :var)))) | ||
| 134 | |||
| 141 | (defun org-babel-haskell-table-or-string (results) | 135 | (defun org-babel-haskell-table-or-string (results) |
| 142 | "Convert RESULTS to an Emacs-lisp table or string. | 136 | "Convert RESULTS to an Emacs-lisp table or string. |
| 143 | If RESULTS look like a table, then convert them into an | 137 | If RESULTS look like a table, then convert them into an |
| @@ -177,12 +171,14 @@ constructs (header arguments, no-web syntax etc...) are ignored." | |||
| 177 | (concat "^\\([ \t]*\\)#\\+begin_src[ \t]haskell*\\(.*\\)?[\r\n]" | 171 | (concat "^\\([ \t]*\\)#\\+begin_src[ \t]haskell*\\(.*\\)?[\r\n]" |
| 178 | "\\([^\000]*?\\)[\r\n][ \t]*#\\+end_src.*")) | 172 | "\\([^\000]*?\\)[\r\n][ \t]*#\\+end_src.*")) |
| 179 | (base-name (file-name-sans-extension (buffer-file-name))) | 173 | (base-name (file-name-sans-extension (buffer-file-name))) |
| 180 | (tmp-file (make-temp-file "ob-haskell")) | 174 | (tmp-file (org-babel-temp-file "haskell-")) |
| 181 | (tmp-org-file (concat tmp-file ".org")) | 175 | (tmp-org-file (concat tmp-file ".org")) |
| 182 | (tmp-tex-file (concat tmp-file ".tex")) | 176 | (tmp-tex-file (concat tmp-file ".tex")) |
| 183 | (lhs-file (concat base-name ".lhs")) | 177 | (lhs-file (concat base-name ".lhs")) |
| 184 | (tex-file (concat base-name ".tex")) | 178 | (tex-file (concat base-name ".tex")) |
| 185 | (command (concat org-babel-haskell-lhs2tex-command " " lhs-file " > " tex-file)) | 179 | (command (concat org-babel-haskell-lhs2tex-command |
| 180 | " " (org-babel-process-file-name lhs-file) | ||
| 181 | " > " (org-babel-process-file-name tex-file))) | ||
| 186 | (preserve-indentp org-src-preserve-indentation) | 182 | (preserve-indentp org-src-preserve-indentation) |
| 187 | indentation) | 183 | indentation) |
| 188 | ;; escape haskell source-code blocks | 184 | ;; escape haskell source-code blocks |
diff --git a/lisp/org/ob-js.el b/lisp/org/ob-js.el new file mode 100644 index 00000000000..2f7d67ec603 --- /dev/null +++ b/lisp/org/ob-js.el | |||
| @@ -0,0 +1,165 @@ | |||
| 1 | ;;; ob-js.el --- org-babel functions for Javascript | ||
| 2 | |||
| 3 | ;; Copyright (C) 2010 Free Software Foundation | ||
| 4 | |||
| 5 | ;; Author: Eric Schulte | ||
| 6 | ;; Keywords: literate programming, reproducible research, js | ||
| 7 | ;; Homepage: http://orgmode.org | ||
| 8 | ;; Version: 7.3 | ||
| 9 | |||
| 10 | ;;; License: | ||
| 11 | |||
| 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 | ||
| 14 | ;; the Free Software Foundation; either version 3, or (at your option) | ||
| 15 | ;; any later version. | ||
| 16 | ;; | ||
| 17 | ;; This program is distributed in the hope that it will be useful, | ||
| 18 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 20 | ;; GNU General Public License for more details. | ||
| 21 | ;; | ||
| 22 | ;; You should have received a copy of the GNU General Public License | ||
| 23 | ;; along with GNU Emacs; 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. | ||
| 26 | |||
| 27 | ;;; Commentary: | ||
| 28 | |||
| 29 | ;; Now working with SBCL for both session and external evaluation. | ||
| 30 | ;; | ||
| 31 | ;; This certainly isn't optimally robust, but it seems to be working | ||
| 32 | ;; for the basic use cases. | ||
| 33 | |||
| 34 | ;;; Requirements: | ||
| 35 | |||
| 36 | ;; - a non-browser javascript engine such as node.js http://nodejs.org/ | ||
| 37 | ;; or mozrepl http://wiki.github.com/bard/mozrepl/ | ||
| 38 | ;; | ||
| 39 | ;; - for session based evaluation mozrepl and moz.el are required see | ||
| 40 | ;; http://wiki.github.com/bard/mozrepl/emacs-integration for | ||
| 41 | ;; configuration instructions | ||
| 42 | |||
| 43 | ;;; Code: | ||
| 44 | (require 'ob) | ||
| 45 | (require 'ob-ref) | ||
| 46 | (require 'ob-comint) | ||
| 47 | (require 'ob-eval) | ||
| 48 | (eval-when-compile (require 'cl)) | ||
| 49 | |||
| 50 | (declare-function run-mozilla "ext:moz" (arg)) | ||
| 51 | |||
| 52 | (defvar org-babel-default-header-args:js '() | ||
| 53 | "Default header arguments for js code blocks.") | ||
| 54 | |||
| 55 | (defvar org-babel-js-eoe "org-babel-js-eoe" | ||
| 56 | "String to indicate that evaluation has completed.") | ||
| 57 | |||
| 58 | (defcustom org-babel-js-cmd "node" | ||
| 59 | "Name of command used to evaluate js blocks." | ||
| 60 | :group 'org-babel | ||
| 61 | :type 'string) | ||
| 62 | |||
| 63 | (defvar org-babel-js-function-wrapper | ||
| 64 | "require('sys').print(require('sys').inspect(function(){%s}()));" | ||
| 65 | "Javascript code to print value of body.") | ||
| 66 | |||
| 67 | (defun org-babel-execute:js (body params) | ||
| 68 | "Execute a block of Javascript code with org-babel. | ||
| 69 | This function is called by `org-babel-execute-src-block'" | ||
| 70 | (let* ((org-babel-js-cmd (or (cdr (assoc :cmd params)) org-babel-js-cmd)) | ||
| 71 | (result-type (cdr (assoc :result-type params))) | ||
| 72 | (full-body (org-babel-expand-body:generic | ||
| 73 | body params (org-babel-variable-assignments:js params)))) | ||
| 74 | (org-babel-js-read | ||
| 75 | (if (not (string= (cdr (assoc :session params)) "none")) | ||
| 76 | ;; session evaluation | ||
| 77 | (let ((session (org-babel-prep-session:js | ||
| 78 | (cdr (assoc :session params)) params))) | ||
| 79 | (nth 1 | ||
| 80 | (org-babel-comint-with-output | ||
| 81 | (session (format "%S" org-babel-js-eoe) t body) | ||
| 82 | (mapc | ||
| 83 | (lambda (line) | ||
| 84 | (insert (org-babel-chomp line)) (comint-send-input nil t)) | ||
| 85 | (list body (format "%S" org-babel-js-eoe)))))) | ||
| 86 | ;; external evaluation | ||
| 87 | (let ((script-file (org-babel-temp-file "js-script-"))) | ||
| 88 | (with-temp-file script-file | ||
| 89 | (insert | ||
| 90 | ;; return the value or the output | ||
| 91 | (if (string= result-type "value") | ||
| 92 | (format org-babel-js-function-wrapper full-body) | ||
| 93 | full-body))) | ||
| 94 | (org-babel-eval | ||
| 95 | (format "%s %s" org-babel-js-cmd | ||
| 96 | (org-babel-process-file-name script-file)) "")))))) | ||
| 97 | |||
| 98 | (defun org-babel-js-read (results) | ||
| 99 | "Convert RESULTS into an appropriate elisp value. | ||
| 100 | If RESULTS look like a table, then convert them into an | ||
| 101 | Emacs-lisp table, otherwise return the results as a string." | ||
| 102 | (org-babel-read | ||
| 103 | (if (and (stringp results) (string-match "^\\[.+\\]$" results)) | ||
| 104 | (org-babel-read | ||
| 105 | (concat "'" | ||
| 106 | (replace-regexp-in-string | ||
| 107 | "\\[" "(" (replace-regexp-in-string | ||
| 108 | "\\]" ")" (replace-regexp-in-string | ||
| 109 | ", " " " (replace-regexp-in-string | ||
| 110 | "'" "\"" results)))))) | ||
| 111 | results))) | ||
| 112 | |||
| 113 | (defun org-babel-js-var-to-js (var) | ||
| 114 | "Convert VAR into a js variable. | ||
| 115 | Convert an elisp value into a string of js source code | ||
| 116 | specifying a variable of the same value." | ||
| 117 | (if (listp var) | ||
| 118 | (concat "[" (mapconcat #'org-babel-js-var-to-js var ", ") "]") | ||
| 119 | (format "%S" var))) | ||
| 120 | |||
| 121 | (defun org-babel-prep-session:js (session params) | ||
| 122 | "Prepare SESSION according to the header arguments specified in PARAMS." | ||
| 123 | (let* ((session (org-babel-js-initiate-session session)) | ||
| 124 | (var-lines (org-babel-variable-assignments:js params))) | ||
| 125 | (when session | ||
| 126 | (org-babel-comint-in-buffer session | ||
| 127 | (sit-for .5) (goto-char (point-max)) | ||
| 128 | (mapc (lambda (var) | ||
| 129 | (insert var) (comint-send-input nil t) | ||
| 130 | (org-babel-comint-wait-for-output session) | ||
| 131 | (sit-for .1) (goto-char (point-max))) var-lines))) | ||
| 132 | session)) | ||
| 133 | |||
| 134 | (defun org-babel-variable-assignments:js (params) | ||
| 135 | "Return list of Javascript statements assigning the block's variables" | ||
| 136 | (mapcar | ||
| 137 | (lambda (pair) (format "var %s=%s;" | ||
| 138 | (car pair) (org-babel-js-var-to-js (cdr pair)))) | ||
| 139 | (mapcar #'cdr (org-babel-get-header params :var)))) | ||
| 140 | |||
| 141 | (defun org-babel-js-initiate-session (&optional session) | ||
| 142 | "If there is not a current inferior-process-buffer in SESSION | ||
| 143 | then create. Return the initialized session." | ||
| 144 | (unless (string= session "none") | ||
| 145 | (cond | ||
| 146 | ((string= "mozrepl" org-babel-js-cmd) | ||
| 147 | (require 'moz) | ||
| 148 | (let ((session-buffer (save-window-excursion | ||
| 149 | (run-mozilla nil) | ||
| 150 | (rename-buffer session) | ||
| 151 | (current-buffer)))) | ||
| 152 | (if (org-babel-comint-buffer-livep session-buffer) | ||
| 153 | (progn (sit-for .25) session-buffer) | ||
| 154 | (sit-for .5) | ||
| 155 | (org-babel-js-initiate-session session)))) | ||
| 156 | ((string= "node" org-babel-js-cmd ) | ||
| 157 | (error "session evaluation with node.js is not supported")) | ||
| 158 | (t | ||
| 159 | (error "sessions are only supported with mozrepl add \":cmd mozrepl\""))))) | ||
| 160 | |||
| 161 | (provide 'ob-js) | ||
| 162 | |||
| 163 | ;; arch-tag: 84401fb3-b8d9-4bb6-9a90-cbe2d103d494 | ||
| 164 | |||
| 165 | ;;; ob-js.el ends here | ||
diff --git a/lisp/org/ob-keys.el b/lisp/org/ob-keys.el index 3f8e83b4f91..e04d9ade6bc 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.01 | 8 | ;; Version: 7.3 |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -52,12 +52,14 @@ functions which are assigned key bindings, and see | |||
| 52 | ("\C-p" . org-babel-previous-src-block) | 52 | ("\C-p" . org-babel-previous-src-block) |
| 53 | ("n" . org-babel-next-src-block) | 53 | ("n" . org-babel-next-src-block) |
| 54 | ("\C-n" . org-babel-next-src-block) | 54 | ("\C-n" . org-babel-next-src-block) |
| 55 | ("e" . org-babel-execute-src-block) | 55 | ("e" . org-babel-execute-maybe) |
| 56 | ("\C-e" . org-babel-execute-src-block) | 56 | ("\C-e" . org-babel-execute-maybe) |
| 57 | ("o" . org-babel-open-src-block-result) | 57 | ("o" . org-babel-open-src-block-result) |
| 58 | ("\C-o" . org-babel-open-src-block-result) | 58 | ("\C-o" . org-babel-open-src-block-result) |
| 59 | ("\C-v" . org-babel-expand-src-block) | 59 | ("\C-v" . org-babel-expand-src-block) |
| 60 | ("v" . org-babel-expand-src-block) | 60 | ("v" . org-babel-expand-src-block) |
| 61 | ("u" . org-babel-goto-src-block-head) | ||
| 62 | ("\C-u" . org-babel-goto-src-block-head) | ||
| 61 | ("g" . org-babel-goto-named-src-block) | 63 | ("g" . org-babel-goto-named-src-block) |
| 62 | ("r" . org-babel-goto-named-result) | 64 | ("r" . org-babel-goto-named-result) |
| 63 | ("\C-r" . org-babel-goto-named-result) | 65 | ("\C-r" . org-babel-goto-named-result) |
| @@ -65,17 +67,24 @@ functions which are assigned key bindings, and see | |||
| 65 | ("b" . org-babel-execute-buffer) | 67 | ("b" . org-babel-execute-buffer) |
| 66 | ("\C-s" . org-babel-execute-subtree) | 68 | ("\C-s" . org-babel-execute-subtree) |
| 67 | ("s" . org-babel-execute-subtree) | 69 | ("s" . org-babel-execute-subtree) |
| 70 | ("\C-d" . org-babel-demarcate-block) | ||
| 71 | ("d" . org-babel-demarcate-block) | ||
| 68 | ("\C-t" . org-babel-tangle) | 72 | ("\C-t" . org-babel-tangle) |
| 69 | ("t" . org-babel-tangle) | 73 | ("t" . org-babel-tangle) |
| 70 | ("\C-f" . org-babel-tangle-file) | 74 | ("\C-f" . org-babel-tangle-file) |
| 71 | ("f" . org-babel-tangle-file) | 75 | ("f" . org-babel-tangle-file) |
| 72 | ("\C-l" . org-babel-lob-ingest) | 76 | ("\C-l" . org-babel-load-in-session) |
| 73 | ("l" . org-babel-lob-ingest) | 77 | ("l" . org-babel-load-in-session) |
| 78 | ("\C-i" . org-babel-lob-ingest) | ||
| 79 | ("i" . org-babel-lob-ingest) | ||
| 74 | ("\C-z" . org-babel-switch-to-session) | 80 | ("\C-z" . org-babel-switch-to-session) |
| 75 | ("z" . org-babel-switch-to-session) | 81 | ("z" . org-babel-switch-to-session-with-code) |
| 76 | ("\C-a" . org-babel-sha1-hash) | 82 | ("\C-a" . org-babel-sha1-hash) |
| 77 | ("a" . org-babel-sha1-hash) | 83 | ("a" . org-babel-sha1-hash) |
| 78 | ("h" . org-babel-describe-bindings)) | 84 | ("h" . org-babel-describe-bindings) |
| 85 | ("\C-x" . org-babel-do-key-sequence-in-edit-buffer) | ||
| 86 | ("x" . org-babel-do-key-sequence-in-edit-buffer) | ||
| 87 | ("\C-\M-h" . org-babel-mark-block)) | ||
| 79 | "Alist of key bindings and interactive Babel functions. | 88 | "Alist of key bindings and interactive Babel functions. |
| 80 | This list associates interactive Babel functions | 89 | This list associates interactive Babel functions |
| 81 | with keys. Each element of this list will add an entry to the | 90 | with keys. Each element of this list will add an entry to the |
diff --git a/lisp/org/ob-latex.el b/lisp/org/ob-latex.el index e5b01463a51..f4cf0802de6 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.01 | 8 | ;; Version: 7.3 |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -37,14 +37,23 @@ | |||
| 37 | (declare-function org-splice-latex-header "org" | 37 | (declare-function org-splice-latex-header "org" |
| 38 | (tpl def-pkg pkg snippets-p &optional extra)) | 38 | (tpl def-pkg pkg snippets-p &optional extra)) |
| 39 | (declare-function org-export-latex-fix-inputenc "org-latex" ()) | 39 | (declare-function org-export-latex-fix-inputenc "org-latex" ()) |
| 40 | |||
| 41 | (add-to-list 'org-babel-tangle-lang-exts '("latex" . "tex")) | 40 | (add-to-list 'org-babel-tangle-lang-exts '("latex" . "tex")) |
| 42 | 41 | ||
| 42 | (defvar org-format-latex-header) | ||
| 43 | (defvar org-format-latex-header-extra) | ||
| 44 | (defvar org-export-latex-packages-alist) | ||
| 45 | (defvar org-export-latex-default-packages-alist) | ||
| 46 | (defvar org-export-pdf-logfiles) | ||
| 47 | (defvar org-latex-to-pdf-process) | ||
| 48 | (defvar org-export-pdf-remove-logfiles) | ||
| 49 | (defvar org-format-latex-options) | ||
| 50 | (defvar org-export-latex-packages-alist) | ||
| 51 | |||
| 43 | (defvar org-babel-default-header-args:latex | 52 | (defvar org-babel-default-header-args:latex |
| 44 | '((:results . "latex") (:exports . "results")) | 53 | '((:results . "latex") (:exports . "results")) |
| 45 | "Default arguments to use when evaluating a LaTeX source block.") | 54 | "Default arguments to use when evaluating a LaTeX source block.") |
| 46 | 55 | ||
| 47 | (defun org-babel-expand-body:latex (body params &optional processed-params) | 56 | (defun org-babel-expand-body:latex (body params) |
| 48 | "Expand BODY according to PARAMS, return the expanded body." | 57 | "Expand BODY according to PARAMS, return the expanded body." |
| 49 | (mapc (lambda (pair) ;; replace variables | 58 | (mapc (lambda (pair) ;; replace variables |
| 50 | (setq body | 59 | (setq body |
| @@ -52,30 +61,62 @@ | |||
| 52 | (regexp-quote (format "%S" (car pair))) | 61 | (regexp-quote (format "%S" (car pair))) |
| 53 | (if (stringp (cdr pair)) | 62 | (if (stringp (cdr pair)) |
| 54 | (cdr pair) (format "%S" (cdr pair))) | 63 | (cdr pair) (format "%S" (cdr pair))) |
| 55 | body))) (nth 1 (org-babel-process-params params))) | 64 | body))) (mapcar #'cdr (org-babel-get-header params :var))) |
| 56 | body) | 65 | (org-babel-trim body)) |
| 57 | 66 | ||
| 58 | (defvar org-format-latex-options) | ||
| 59 | (defvar org-export-latex-packages-alist) | ||
| 60 | (defun org-babel-execute:latex (body params) | 67 | (defun org-babel-execute:latex (body params) |
| 61 | "Execute a block of Latex code with Babel. | 68 | "Execute a block of Latex code with Babel. |
| 62 | This function is called by `org-babel-execute-src-block'." | 69 | This function is called by `org-babel-execute-src-block'." |
| 63 | (setq body (org-babel-expand-body:latex body params)) | 70 | (setq body (org-babel-expand-body:latex body params)) |
| 64 | (if (cdr (assoc :file params)) | 71 | (if (cdr (assoc :file params)) |
| 65 | (let ((out-file (cdr (assoc :file params))) | 72 | (let* ((out-file (cdr (assoc :file params))) |
| 66 | (tex-file (make-temp-file "org-babel-latex" nil ".tex")) | 73 | (tex-file (org-babel-temp-file "latex-" ".tex")) |
| 67 | (pdfheight (cdr (assoc :pdfheight params))) | 74 | (border (cdr (assoc :border params))) |
| 68 | (pdfwidth (cdr (assoc :pdfwidth params))) | 75 | (fit (or (cdr (assoc :fit params)) border)) |
| 69 | (in-buffer (not (string= "no" (cdr (assoc :buffer params))))) | 76 | (height (and fit (cdr (assoc :pdfheight params)))) |
| 70 | (org-export-latex-packages-alist | 77 | (width (and fit (cdr (assoc :pdfwidth params)))) |
| 71 | (append (cdr (assoc :packages params)) | 78 | (headers (cdr (assoc :headers params))) |
| 72 | org-export-latex-packages-alist))) | 79 | (in-buffer (not (string= "no" (cdr (assoc :buffer params))))) |
| 80 | (org-export-latex-packages-alist | ||
| 81 | (append (cdr (assoc :packages params)) | ||
| 82 | org-export-latex-packages-alist))) | ||
| 73 | (cond | 83 | (cond |
| 74 | ((string-match "\\.png$" out-file) | 84 | ((string-match "\\.png$" out-file) |
| 75 | (org-create-formula-image | 85 | (org-create-formula-image |
| 76 | body out-file org-format-latex-options in-buffer)) | 86 | body out-file org-format-latex-options in-buffer)) |
| 77 | ((string-match "\\.pdf$" out-file) | 87 | ((string-match "\\.pdf$" out-file) |
| 78 | (org-babel-latex-body-to-tex-file tex-file body pdfheight pdfwidth) | 88 | (require 'org-latex) |
| 89 | (with-temp-file tex-file | ||
| 90 | (insert | ||
| 91 | (org-splice-latex-header | ||
| 92 | org-format-latex-header | ||
| 93 | (delq | ||
| 94 | nil | ||
| 95 | (mapcar | ||
| 96 | (lambda (el) | ||
| 97 | (unless (and (listp el) (string= "hyperref" (cadr el))) | ||
| 98 | el)) | ||
| 99 | org-export-latex-default-packages-alist)) | ||
| 100 | org-export-latex-packages-alist | ||
| 101 | org-format-latex-header-extra) | ||
| 102 | (if fit "\n\\usepackage[active, tightpage]{preview}\n" "") | ||
| 103 | (if border (format "\\setlength{\\PreviewBorder}{%s}" border) "") | ||
| 104 | (if height (concat "\n" (format "\\pdfpageheight %s" height)) "") | ||
| 105 | (if width (concat "\n" (format "\\pdfpagewidth %s" width)) "") | ||
| 106 | (if headers | ||
| 107 | (concat "\n" | ||
| 108 | (if (listp headers) | ||
| 109 | (mapconcat #'identity headers "\n") | ||
| 110 | headers) "\n") | ||
| 111 | "") | ||
| 112 | (if org-format-latex-header-extra | ||
| 113 | (concat "\n" org-format-latex-header-extra) | ||
| 114 | "") | ||
| 115 | (if fit | ||
| 116 | (concat "\n\\begin{document}\n\\begin{preview}\n" body | ||
| 117 | "\n\\end{preview}\n\\end{document}\n") | ||
| 118 | (concat "\n\\begin{document}\n" body "\n\\end{document}\n"))) | ||
| 119 | (org-export-latex-fix-inputenc)) | ||
| 79 | (when (file-exists-p out-file) (delete-file out-file)) | 120 | (when (file-exists-p out-file) (delete-file out-file)) |
| 80 | (rename-file (org-babel-latex-tex-to-pdf tex-file) out-file)) | 121 | (rename-file (org-babel-latex-tex-to-pdf tex-file) out-file)) |
| 81 | ((string-match "\\.\\([^\\.]+\\)$" out-file) | 122 | ((string-match "\\.\\([^\\.]+\\)$" out-file) |
| @@ -84,67 +125,48 @@ This function is called by `org-babel-execute-src-block'." | |||
| 84 | out-file) | 125 | out-file) |
| 85 | body)) | 126 | body)) |
| 86 | 127 | ||
| 87 | (defvar org-format-latex-header) | 128 | (defun org-babel-latex-tex-to-pdf (file) |
| 88 | (defvar org-format-latex-header-extra) | 129 | "Generate a pdf file according to the contents FILE. |
| 89 | (defvar org-export-latex-packages-alist) | ||
| 90 | (defvar org-export-latex-default-packages-alist) | ||
| 91 | (defun org-babel-latex-body-to-tex-file (tex-file body &optional height width) | ||
| 92 | "Place the contents of BODY into TEX-FILE. | ||
| 93 | Extracted from `org-create-formula-image' in org.el." | ||
| 94 | (with-temp-file tex-file | ||
| 95 | (insert (org-splice-latex-header | ||
| 96 | org-format-latex-header | ||
| 97 | (delq | ||
| 98 | nil | ||
| 99 | (mapcar | ||
| 100 | (lambda (el) (unless (and (listp el) (string= "hyperref" (cadr el))) | ||
| 101 | el)) | ||
| 102 | org-export-latex-default-packages-alist)) | ||
| 103 | org-export-latex-packages-alist | ||
| 104 | org-format-latex-header-extra) | ||
| 105 | (if height (concat "\n" (format "\\pdfpageheight %s" height)) "") | ||
| 106 | (if width (concat "\n" (format "\\pdfpagewidth %s" width)) "") | ||
| 107 | (if org-format-latex-header-extra | ||
| 108 | (concat "\n" org-format-latex-header-extra) | ||
| 109 | "") | ||
| 110 | "\n\\begin{document}\n" body "\n\\end{document}\n") | ||
| 111 | (org-export-latex-fix-inputenc))) | ||
| 112 | |||
| 113 | (defvar org-export-pdf-logfiles) | ||
| 114 | (defvar org-latex-to-pdf-process) | ||
| 115 | (defvar org-export-pdf-remove-logfiles) | ||
| 116 | (defun org-babel-latex-tex-to-pdf (tex-file) | ||
| 117 | "Generate a pdf file according to the contents TEX-FILE. | ||
| 118 | Extracted from `org-export-as-pdf' in org-latex.el." | 130 | Extracted from `org-export-as-pdf' in org-latex.el." |
| 119 | (let* ((wconfig (current-window-configuration)) | 131 | (let* ((wconfig (current-window-configuration)) |
| 120 | (default-directory (file-name-directory tex-file)) | 132 | (default-directory (file-name-directory file)) |
| 121 | (base (file-name-sans-extension tex-file)) | 133 | (base (file-name-sans-extension file)) |
| 122 | (pdffile (concat base ".pdf")) | 134 | (pdffile (concat base ".pdf")) |
| 123 | (cmds org-latex-to-pdf-process) | 135 | (cmds org-latex-to-pdf-process) |
| 124 | (outbuf (get-buffer-create "*Org PDF LaTeX Output*")) | 136 | (outbuf (get-buffer-create "*Org PDF LaTeX Output*")) |
| 125 | cmd) | 137 | output-dir cmd) |
| 138 | (with-current-buffer outbuf (erase-buffer)) | ||
| 139 | (message (concat "Processing LaTeX file " file "...")) | ||
| 140 | (setq output-dir (file-name-directory file)) | ||
| 126 | (if (and cmds (symbolp cmds)) | 141 | (if (and cmds (symbolp cmds)) |
| 127 | (funcall cmds tex-file) | 142 | (funcall cmds (shell-quote-argument file)) |
| 128 | (while cmds | 143 | (while cmds |
| 129 | (setq cmd (pop cmds)) | 144 | (setq cmd (pop cmds)) |
| 130 | (while (string-match "%b" cmd) | 145 | (while (string-match "%b" cmd) |
| 131 | (setq cmd (replace-match | 146 | (setq cmd (replace-match |
| 132 | (save-match-data | 147 | (save-match-data |
| 133 | (shell-quote-argument base)) | 148 | (shell-quote-argument base)) |
| 134 | t t cmd))) | 149 | t t cmd))) |
| 135 | (while (string-match "%s" cmd) | 150 | (while (string-match "%f" cmd) |
| 136 | (setq cmd (replace-match | 151 | (setq cmd (replace-match |
| 137 | (save-match-data | 152 | (save-match-data |
| 138 | (shell-quote-argument tex-file)) | 153 | (shell-quote-argument file)) |
| 139 | t t cmd))) | 154 | t t cmd))) |
| 140 | (shell-command cmd outbuf outbuf))) | 155 | (while (string-match "%o" cmd) |
| 156 | (setq cmd (replace-match | ||
| 157 | (save-match-data | ||
| 158 | (shell-quote-argument output-dir)) | ||
| 159 | t t cmd))) | ||
| 160 | (shell-command cmd outbuf))) | ||
| 161 | (message (concat "Processing LaTeX file " file "...done")) | ||
| 141 | (if (not (file-exists-p pdffile)) | 162 | (if (not (file-exists-p pdffile)) |
| 142 | (error "PDF file was not produced from %s" tex-file) | 163 | (error (concat "PDF file " pdffile " was not produced")) |
| 143 | (set-window-configuration wconfig) | 164 | (set-window-configuration wconfig) |
| 144 | (when org-export-pdf-remove-logfiles | 165 | (when org-export-pdf-remove-logfiles |
| 145 | (dolist (ext org-export-pdf-logfiles) | 166 | (dolist (ext org-export-pdf-logfiles) |
| 146 | (setq tex-file (concat base "." ext)) | 167 | (setq file (concat base "." ext)) |
| 147 | (and (file-exists-p tex-file) (delete-file tex-file)))) | 168 | (and (file-exists-p file) (delete-file file)))) |
| 169 | (message "Exporting to PDF...done") | ||
| 148 | pdffile))) | 170 | pdffile))) |
| 149 | 171 | ||
| 150 | (defun org-babel-prep-session:latex (session params) | 172 | (defun org-babel-prep-session:latex (session params) |
diff --git a/lisp/org/ob-ledger.el b/lisp/org/ob-ledger.el new file mode 100644 index 00000000000..33ec9d3a898 --- /dev/null +++ b/lisp/org/ob-ledger.el | |||
| @@ -0,0 +1,72 @@ | |||
| 1 | ;;; ob-ledger.el --- org-babel functions for ledger evaluation | ||
| 2 | |||
| 3 | ;; Copyright (C) 2010 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Eric S Fraga | ||
| 6 | ;; Keywords: literate programming, reproducible research, accounting | ||
| 7 | ;; Homepage: http://orgmode.org | ||
| 8 | ;; Version: 7.3 | ||
| 9 | |||
| 10 | ;; This file is part of GNU Emacs. | ||
| 11 | |||
| 12 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 13 | ;; it under the terms of the GNU General Public License as published by | ||
| 14 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 15 | ;; (at your option) any later version. | ||
| 16 | |||
| 17 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 18 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 20 | ;; GNU General Public License for more details. | ||
| 21 | |||
| 22 | ;; You should have received a copy of the GNU General Public License | ||
| 23 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | ||
| 24 | |||
| 25 | ;;; Commentary: | ||
| 26 | |||
| 27 | ;; Org-Babel support for evaluating ledger entries. | ||
| 28 | ;; | ||
| 29 | ;; This differs from most standard languages in that | ||
| 30 | ;; | ||
| 31 | ;; 1) there is no such thing as a "session" in ledger | ||
| 32 | ;; | ||
| 33 | ;; 2) we are generally only going to return output from the leger program | ||
| 34 | ;; | ||
| 35 | ;; 3) we are adding the "cmdline" header argument | ||
| 36 | ;; | ||
| 37 | ;; 4) there are no variables | ||
| 38 | |||
| 39 | ;;; Code: | ||
| 40 | (require 'ob) | ||
| 41 | |||
| 42 | (defvar org-babel-default-header-args:ledger | ||
| 43 | '((:results . "output") (:cmdline . "bal")) | ||
| 44 | "Default arguments to use when evaluating a ledger source block.") | ||
| 45 | |||
| 46 | (defun org-babel-execute:ledger (body params) | ||
| 47 | "Execute a block of Ledger entries with org-babel. This function is | ||
| 48 | called by `org-babel-execute-src-block'." | ||
| 49 | (message "executing Ledger source code block") | ||
| 50 | (let ((result-params (split-string (or (cdr (assoc :results params)) ""))) | ||
| 51 | (cmdline (cdr (assoc :cmdline params))) | ||
| 52 | (in-file (org-babel-temp-file "ledger-")) | ||
| 53 | (out-file (org-babel-temp-file "ledger-output-"))) | ||
| 54 | (with-temp-file in-file (insert body)) | ||
| 55 | (message (concat "ledger" | ||
| 56 | " -f " (org-babel-process-file-name in-file) | ||
| 57 | " " cmdline)) | ||
| 58 | (with-output-to-string | ||
| 59 | (shell-command (concat "ledger" | ||
| 60 | " -f " (org-babel-process-file-name in-file) | ||
| 61 | " " cmdline | ||
| 62 | " > " (org-babel-process-file-name out-file)))) | ||
| 63 | (with-temp-buffer (insert-file-contents out-file) (buffer-string)))) | ||
| 64 | |||
| 65 | (defun org-babel-prep-session:ledger (session params) | ||
| 66 | (error "Ledger does not support sessions")) | ||
| 67 | |||
| 68 | (provide 'ob-ledger) | ||
| 69 | |||
| 70 | ;; arch-tag: 7bbb529e-95a1-4236-9d29-b0000b918c7c | ||
| 71 | |||
| 72 | ;;; ob-ledger.el ends here | ||
diff --git a/lisp/org/ob-lisp.el b/lisp/org/ob-lisp.el new file mode 100644 index 00000000000..f550a54e1e3 --- /dev/null +++ b/lisp/org/ob-lisp.el | |||
| @@ -0,0 +1,106 @@ | |||
| 1 | ;;; ob-lisp.el --- org-babel functions for Common Lisp | ||
| 2 | |||
| 3 | ;; Copyright (C) 2010 Free Software Foundation | ||
| 4 | |||
| 5 | ;; Author: David T. O'Toole <dto@gnu.org>, Eric Schulte | ||
| 6 | ;; Keywords: literate programming, reproducible research, lisp | ||
| 7 | ;; Homepage: http://orgmode.org | ||
| 8 | ;; Version: 7.3 | ||
| 9 | |||
| 10 | ;;; License: | ||
| 11 | |||
| 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 | ||
| 14 | ;; the Free Software Foundation; either version 3, or (at your option) | ||
| 15 | ;; any later version. | ||
| 16 | ;; | ||
| 17 | ;; This program is distributed in the hope that it will be useful, | ||
| 18 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 20 | ;; GNU General Public License for more details. | ||
| 21 | ;; | ||
| 22 | ;; You should have received a copy of the GNU General Public License | ||
| 23 | ;; along with GNU Emacs; 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. | ||
| 26 | |||
| 27 | ;;; Commentary: | ||
| 28 | |||
| 29 | ;; Now working with SBCL for both session and external evaluation. | ||
| 30 | ;; | ||
| 31 | ;; This certainly isn't optimally robust, but it seems to be working | ||
| 32 | ;; for the basic use cases. | ||
| 33 | |||
| 34 | ;;; Requirements: | ||
| 35 | |||
| 36 | ;; Requires SLIME (Superior Lisp Interaction Mode for Emacs.) | ||
| 37 | ;; See http://common-lisp.net/project/slime/ | ||
| 38 | |||
| 39 | ;;; Code: | ||
| 40 | (require 'ob) | ||
| 41 | (require 'ob-ref) | ||
| 42 | (require 'ob-comint) | ||
| 43 | (require 'ob-eval) | ||
| 44 | (require 'slime) | ||
| 45 | |||
| 46 | (defvar org-babel-default-header-args:lisp '() | ||
| 47 | "Default header arguments for lisp code blocks.") | ||
| 48 | |||
| 49 | (defcustom org-babel-lisp-cmd "sbcl --script" | ||
| 50 | "Name of command used to evaluate lisp blocks.") | ||
| 51 | |||
| 52 | (defun org-babel-expand-body:lisp (body params) | ||
| 53 | "Expand BODY according to PARAMS, return the expanded body." | ||
| 54 | (let ((vars (mapcar #'cdr (org-babel-get-header params :var)))) | ||
| 55 | (if (> (length vars) 0) | ||
| 56 | (concat "(let (" | ||
| 57 | (mapconcat | ||
| 58 | (lambda (var) (format "%S" (print `(,(car var) ',(cdr var))))) | ||
| 59 | vars "\n ") | ||
| 60 | ")\n" body ")") | ||
| 61 | body))) | ||
| 62 | |||
| 63 | (defun org-babel-execute:lisp (body params) | ||
| 64 | "Execute a block of Lisp code with org-babel. | ||
| 65 | This function is called by `org-babel-execute-src-block'" | ||
| 66 | (message "executing Lisp source code block") | ||
| 67 | (let* ((session (org-babel-lisp-initiate-session | ||
| 68 | (cdr (assoc :session params)))) | ||
| 69 | (result-type (cdr (assoc :result-type params))) | ||
| 70 | (full-body (org-babel-expand-body:lisp body params))) | ||
| 71 | (read | ||
| 72 | (if session | ||
| 73 | ;; session evaluation | ||
| 74 | (save-window-excursion | ||
| 75 | (cadr (slime-eval `(swank:eval-and-grab-output ,full-body)))) | ||
| 76 | ;; external evaluation | ||
| 77 | (let ((script-file (org-babel-temp-file "lisp-script-"))) | ||
| 78 | (with-temp-file script-file | ||
| 79 | (insert | ||
| 80 | ;; return the value or the output | ||
| 81 | (if (string= result-type "value") | ||
| 82 | (format "(print %s)" full-body) | ||
| 83 | full-body))) | ||
| 84 | (org-babel-eval | ||
| 85 | (format "%s %s" org-babel-lisp-cmd | ||
| 86 | (org-babel-process-file-name script-file)) "")))))) | ||
| 87 | |||
| 88 | ;; This function should be used to assign any variables in params in | ||
| 89 | ;; the context of the session environment. | ||
| 90 | (defun org-babel-prep-session:lisp (session params) | ||
| 91 | "Prepare SESSION according to the header arguments specified in PARAMS." | ||
| 92 | (error "not yet implemented")) | ||
| 93 | |||
| 94 | (defun org-babel-lisp-initiate-session (&optional session) | ||
| 95 | "If there is not a current inferior-process-buffer in SESSION | ||
| 96 | then create. Return the initialized session." | ||
| 97 | (unless (string= session "none") | ||
| 98 | (save-window-excursion | ||
| 99 | (or (slime-connected-p) | ||
| 100 | (slime-process))))) | ||
| 101 | |||
| 102 | (provide 'ob-lisp) | ||
| 103 | |||
| 104 | ;; arch-tag: 18086168-009f-4947-bbb5-3532375d851d | ||
| 105 | |||
| 106 | ;;; ob-lisp.el ends here | ||
diff --git a/lisp/org/ob-lob.el b/lisp/org/ob-lob.el index f806668e2e8..d7818c21154 100644 --- a/lisp/org/ob-lob.el +++ b/lisp/org/ob-lob.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.01 | 8 | ;; Version: 7.3 |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -45,15 +45,22 @@ To add files to this list use the `org-babel-lob-ingest' command." | |||
| 45 | 45 | ||
| 46 | ;;;###autoload | 46 | ;;;###autoload |
| 47 | (defun org-babel-lob-ingest (&optional file) | 47 | (defun org-babel-lob-ingest (&optional file) |
| 48 | "Add all source-blocks defined in FILE to `org-babel-library-of-babel'." | 48 | "Add all named source-blocks defined in FILE to |
| 49 | `org-babel-library-of-babel'." | ||
| 49 | (interactive "f") | 50 | (interactive "f") |
| 50 | (org-babel-map-src-blocks file | 51 | (let ((lob-ingest-count 0)) |
| 51 | (let* ((info (org-babel-get-src-block-info)) | 52 | (org-babel-map-src-blocks file |
| 52 | (source-name (intern (nth 4 info)))) | 53 | (let* ((info (org-babel-get-src-block-info 'light)) |
| 53 | (when source-name | 54 | (source-name (nth 4 info))) |
| 54 | (setq org-babel-library-of-babel | 55 | (when source-name |
| 55 | (cons (cons source-name info) | 56 | (setq source-name (intern source-name) |
| 56 | (assq-delete-all source-name org-babel-library-of-babel))))))) | 57 | org-babel-library-of-babel |
| 58 | (cons (cons source-name info) | ||
| 59 | (assq-delete-all source-name org-babel-library-of-babel)) | ||
| 60 | lob-ingest-count (1+ lob-ingest-count))))) | ||
| 61 | (message "%d src block%s added to Library of Babel" | ||
| 62 | lob-ingest-count (if (> lob-ingest-count 1) "s" "")) | ||
| 63 | lob-ingest-count)) | ||
| 57 | 64 | ||
| 58 | (defconst org-babel-lob-call-aliases '("lob" "call") | 65 | (defconst org-babel-lob-call-aliases '("lob" "call") |
| 59 | "Aliases to call a source block function. | 66 | "Aliases to call a source block function. |
| @@ -61,9 +68,10 @@ If you change the value of this variable then your files may | |||
| 61 | become unusable by other org-babel users, and vice versa.") | 68 | become unusable by other org-babel users, and vice versa.") |
| 62 | 69 | ||
| 63 | (defconst org-babel-lob-one-liner-regexp | 70 | (defconst org-babel-lob-one-liner-regexp |
| 64 | (concat "^\\([ \t]*\\)#\\+\\(?:" | 71 | (concat |
| 65 | (mapconcat #'regexp-quote org-babel-lob-call-aliases "\\|") | 72 | "^\\([ \t]*\\)#\\+\\(?:" |
| 66 | "\\):[ \t]+\\([^\(\)\n]+\\)\(\\([^\n]*\\)\)[ \t]*\\([^\n]*\\)") | 73 | (mapconcat #'regexp-quote org-babel-lob-call-aliases "\\|") |
| 74 | "\\):[ \t]+\\([^\(\)\n]+\\)\(\\([^\n]*\\)\)\\(\\[.+\\]\\|\\)[ \t]*\\([^\n]*\\)") | ||
| 67 | "Regexp to match calls to predefined source block functions.") | 75 | "Regexp to match calls to predefined source block functions.") |
| 68 | 76 | ||
| 69 | ;; functions for executing lob one-liners | 77 | ;; functions for executing lob one-liners |
| @@ -76,36 +84,32 @@ if so then run the appropriate source block from the Library." | |||
| 76 | (let ((info (org-babel-lob-get-info))) | 84 | (let ((info (org-babel-lob-get-info))) |
| 77 | (if (nth 0 info) (progn (org-babel-lob-execute info) t) nil))) | 85 | (if (nth 0 info) (progn (org-babel-lob-execute info) t) nil))) |
| 78 | 86 | ||
| 79 | (add-hook 'org-ctrl-c-ctrl-c-hook 'org-babel-lob-execute-maybe) | ||
| 80 | |||
| 81 | ;;;###autoload | 87 | ;;;###autoload |
| 82 | (defun org-babel-lob-get-info () | 88 | (defun org-babel-lob-get-info () |
| 83 | "Return a Library of Babel function call as a string. | 89 | "Return a Library of Babel function call as a string." |
| 84 | |||
| 85 | This function is analogous to org-babel-get-src-block-name. For | ||
| 86 | both functions, after they are called, (match-string 1) matches | ||
| 87 | the function name, and (match-string 2) matches the function | ||
| 88 | arguments inside the parentheses. I think perhaps these functions | ||
| 89 | should be renamed to bring out this similarity, perhaps involving | ||
| 90 | the word 'call'." | ||
| 91 | (let ((case-fold-search t)) | 90 | (let ((case-fold-search t)) |
| 92 | (save-excursion | 91 | (save-excursion |
| 93 | (beginning-of-line 1) | 92 | (beginning-of-line 1) |
| 94 | (if (looking-at org-babel-lob-one-liner-regexp) | 93 | (if (looking-at org-babel-lob-one-liner-regexp) |
| 95 | (append (mapcar #'org-babel-clean-text-properties | 94 | (append |
| 96 | (list (format "%s(%s)" (match-string 2) (match-string 3)) | 95 | (mapcar #'org-babel-clean-text-properties |
| 97 | (match-string 4))) | 96 | (list |
| 98 | (list (length (match-string 1)))))))) | 97 | (format "%s(%s)%s" |
| 98 | (match-string 2) (match-string 3) (match-string 4)) | ||
| 99 | (match-string 5))) | ||
| 100 | (list (length (match-string 1)))))))) | ||
| 99 | 101 | ||
| 100 | (defun org-babel-lob-execute (info) | 102 | (defun org-babel-lob-execute (info) |
| 101 | "Execute the lob call specified by INFO." | 103 | "Execute the lob call specified by INFO." |
| 102 | (let ((params (org-babel-merge-params | 104 | (let ((params (org-babel-process-params |
| 103 | org-babel-default-header-args | 105 | (org-babel-merge-params |
| 104 | (org-babel-params-from-buffer) | 106 | org-babel-default-header-args |
| 105 | (org-babel-params-from-properties) | 107 | (org-babel-params-from-buffer) |
| 106 | (org-babel-parse-header-arguments | 108 | (org-babel-params-from-properties) |
| 107 | (org-babel-clean-text-properties | 109 | (org-babel-parse-header-arguments |
| 108 | (concat ":var results=" (mapconcat #'identity (butlast info) " "))))))) | 110 | (org-babel-clean-text-properties |
| 111 | (concat ":var results=" | ||
| 112 | (mapconcat #'identity (butlast info) " ")))))))) | ||
| 109 | (org-babel-execute-src-block | 113 | (org-babel-execute-src-block |
| 110 | nil (list "emacs-lisp" "results" params nil nil (nth 2 info))))) | 114 | nil (list "emacs-lisp" "results" params nil nil (nth 2 info))))) |
| 111 | 115 | ||
diff --git a/lisp/org/ob-matlab.el b/lisp/org/ob-matlab.el index 0728edf49dc..c75d806cc62 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.01 | 8 | ;; Version: 7.3 |
| 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 a78e0b6bd68..119d28cfba0 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.01 | 8 | ;; Version: 7.3 |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -62,9 +62,6 @@ | |||
| 62 | '((:results . "file") (:exports . "results")) | 62 | '((:results . "file") (:exports . "results")) |
| 63 | "Default arguments to use when evaluating a mscgen source block.") | 63 | "Default arguments to use when evaluating a mscgen source block.") |
| 64 | 64 | ||
| 65 | (defun org-babel-expand-body:mscgen (body params &optional processed-params) | ||
| 66 | "Expand BODY according to PARAMS, return the expanded body." body) | ||
| 67 | |||
| 68 | (defun org-babel-execute:mscgen (body params) | 65 | (defun org-babel-execute:mscgen (body params) |
| 69 | "Execute a block of Mscgen code with Babel. | 66 | "Execute a block of Mscgen code with Babel. |
| 70 | This function is called by `org-babel-execute-src-block'. | 67 | This function is called by `org-babel-execute-src-block'. |
diff --git a/lisp/org/ob-ocaml.el b/lisp/org/ob-ocaml.el index f5add5c5754..2217118e537 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.01 | 8 | ;; Version: 7.3 |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -51,20 +51,12 @@ | |||
| 51 | (defvar org-babel-ocaml-eoe-indicator "\"org-babel-ocaml-eoe\";;") | 51 | (defvar org-babel-ocaml-eoe-indicator "\"org-babel-ocaml-eoe\";;") |
| 52 | (defvar org-babel-ocaml-eoe-output "org-babel-ocaml-eoe") | 52 | (defvar org-babel-ocaml-eoe-output "org-babel-ocaml-eoe") |
| 53 | 53 | ||
| 54 | (defun org-babel-expand-body:ocaml (body params &optional processed-params) | ||
| 55 | "Expand BODY according to PARAMS, return the expanded body." | ||
| 56 | (let ((vars (nth 1 (or processed-params (org-babel-process-params params))))) | ||
| 57 | (concat | ||
| 58 | (mapconcat | ||
| 59 | (lambda (pair) (format "let %s = %s;;" (car pair) | ||
| 60 | (org-babel-ocaml-elisp-to-ocaml (cdr pair)))) | ||
| 61 | vars "\n") "\n" body "\n"))) | ||
| 62 | |||
| 63 | (defun org-babel-execute:ocaml (body params) | 54 | (defun org-babel-execute:ocaml (body params) |
| 64 | "Execute a block of Ocaml code with Babel." | 55 | "Execute a block of Ocaml code with Babel." |
| 65 | (let* ((processed-params (org-babel-process-params params)) | 56 | (let* ((vars (mapcar #'cdr (org-babel-get-header params :var))) |
| 66 | (vars (nth 1 processed-params)) | 57 | (full-body (org-babel-expand-body:generic |
| 67 | (full-body (org-babel-expand-body:ocaml body params processed-params)) | 58 | body params |
| 59 | (org-babel-variable-assignments:ocaml params))) | ||
| 68 | (session (org-babel-prep-session:ocaml | 60 | (session (org-babel-prep-session:ocaml |
| 69 | (cdr (assoc :session params)) params)) | 61 | (cdr (assoc :session params)) params)) |
| 70 | (raw (org-babel-comint-with-output | 62 | (raw (org-babel-comint-with-output |
| @@ -84,9 +76,9 @@ | |||
| 84 | (org-babel-reassemble-table | 76 | (org-babel-reassemble-table |
| 85 | (org-babel-ocaml-parse-output (org-babel-trim clean)) | 77 | (org-babel-ocaml-parse-output (org-babel-trim clean)) |
| 86 | (org-babel-pick-name | 78 | (org-babel-pick-name |
| 87 | (nth 4 processed-params) (cdr (assoc :colnames params))) | 79 | (cdr (assoc :colname-names params)) (cdr (assoc :colnames params))) |
| 88 | (org-babel-pick-name | 80 | (org-babel-pick-name |
| 89 | (nth 5 processed-params) (cdr (assoc :rownames params)))))) | 81 | (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params)))))) |
| 90 | 82 | ||
| 91 | (defvar tuareg-interactive-buffer-name) | 83 | (defvar tuareg-interactive-buffer-name) |
| 92 | (defun org-babel-prep-session:ocaml (session params) | 84 | (defun org-babel-prep-session:ocaml (session params) |
| @@ -100,6 +92,13 @@ | |||
| 100 | (save-window-excursion (tuareg-run-caml) | 92 | (save-window-excursion (tuareg-run-caml) |
| 101 | (get-buffer tuareg-interactive-buffer-name)))) | 93 | (get-buffer tuareg-interactive-buffer-name)))) |
| 102 | 94 | ||
| 95 | (defun org-babel-variable-assignments:ocaml (params) | ||
| 96 | "Return list of ocaml statements assigning the block's variables" | ||
| 97 | (mapcar | ||
| 98 | (lambda (pair) (format "let %s = %s;;" (car pair) | ||
| 99 | (org-babel-ocaml-elisp-to-ocaml (cdr pair)))) | ||
| 100 | (mapcar #'cdr (org-babel-get-header params :var)))) | ||
| 101 | |||
| 103 | (defun org-babel-ocaml-elisp-to-ocaml (val) | 102 | (defun org-babel-ocaml-elisp-to-ocaml (val) |
| 104 | "Return a string of ocaml code which evaluates to VAL." | 103 | "Return a string of ocaml code which evaluates to VAL." |
| 105 | (if (listp val) | 104 | (if (listp val) |
diff --git a/lisp/org/ob-octave.el b/lisp/org/ob-octave.el index 2cdbaa0468c..d6affecd74d 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.01 | 8 | ;; Version: 7.3 |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -47,20 +47,6 @@ | |||
| 47 | (defvar org-babel-octave-shell-command "octave -q" | 47 | (defvar org-babel-octave-shell-command "octave -q" |
| 48 | "Shell command to run octave as an external process.") | 48 | "Shell command to run octave as an external process.") |
| 49 | 49 | ||
| 50 | (defun org-babel-expand-body:matlab (body params &optional processed-params) | ||
| 51 | "Expand BODY according to PARAMS, return the expanded body." | ||
| 52 | (org-babel-expand-body:octave body params processed-params)) | ||
| 53 | (defun org-babel-expand-body:octave (body params &optional processed-params) | ||
| 54 | "Expand BODY according to PARAMS, return the expanded body." | ||
| 55 | (let ((vars (nth 1 (or processed-params (org-babel-process-params params))))) | ||
| 56 | (concat | ||
| 57 | (mapconcat | ||
| 58 | (lambda (pair) | ||
| 59 | (format "%s=%s" | ||
| 60 | (car pair) | ||
| 61 | (org-babel-octave-var-to-octave (cdr pair)))) | ||
| 62 | vars "\n") "\n" body "\n"))) | ||
| 63 | |||
| 64 | (defvar org-babel-matlab-with-emacs-link nil | 50 | (defvar org-babel-matlab-with-emacs-link nil |
| 65 | "If non-nil use matlab-shell-run-region for session evaluation. | 51 | "If non-nil use matlab-shell-run-region for session evaluation. |
| 66 | This will use EmacsLink if (matlab-with-emacs-link) evaluates | 52 | This will use EmacsLink if (matlab-with-emacs-link) evaluates |
| @@ -76,7 +62,7 @@ delete('%s') | |||
| 76 | (defvar org-babel-octave-wrapper-method | 62 | (defvar org-babel-octave-wrapper-method |
| 77 | "%s | 63 | "%s |
| 78 | if ischar(ans), fid = fopen('%s', 'w'); fprintf(fid, '%%s\\n', ans); fclose(fid); | 64 | if ischar(ans), fid = fopen('%s', 'w'); fprintf(fid, '%%s\\n', ans); fclose(fid); |
| 79 | else, save -ascii %s ans | 65 | else, dlmwrite('%s', ans, '\\t') |
| 80 | end") | 66 | end") |
| 81 | 67 | ||
| 82 | (defvar org-babel-octave-eoe-indicator "\'org_babel_eoe\'") | 68 | (defvar org-babel-octave-eoe-indicator "\'org_babel_eoe\'") |
| @@ -85,53 +71,60 @@ end") | |||
| 85 | 71 | ||
| 86 | (defun org-babel-execute:matlab (body params) | 72 | (defun org-babel-execute:matlab (body params) |
| 87 | "Execute a block of matlab code with Babel." | 73 | "Execute a block of matlab code with Babel." |
| 88 | (require 'matlab) | ||
| 89 | (org-babel-execute:octave body params 'matlab)) | 74 | (org-babel-execute:octave body params 'matlab)) |
| 75 | |||
| 90 | (defun org-babel-execute:octave (body params &optional matlabp) | 76 | (defun org-babel-execute:octave (body params &optional matlabp) |
| 91 | "Execute a block of octave code with Babel." | 77 | "Execute a block of octave code with Babel." |
| 92 | (let* ((processed-params (org-babel-process-params params)) | 78 | (let* ((session |
| 93 | (session | ||
| 94 | (funcall (intern (format "org-babel-%s-initiate-session" | 79 | (funcall (intern (format "org-babel-%s-initiate-session" |
| 95 | (if matlabp "matlab" "octave"))) | 80 | (if matlabp "matlab" "octave"))) |
| 96 | (nth 0 processed-params) params)) | 81 | (cdr (assoc :session params)) params)) |
| 97 | (vars (nth 1 processed-params)) | 82 | (vars (mapcar #'cdr (org-babel-get-header params :var))) |
| 98 | (result-params (nth 2 processed-params)) | 83 | (result-params (cdr (assoc :result-params params))) |
| 99 | (result-type (nth 3 processed-params)) | 84 | (result-type (cdr (assoc :result-type params))) |
| 100 | (out-file (cdr (assoc :file params))) | 85 | (out-file (cdr (assoc :file params))) |
| 101 | (augmented-body | 86 | (full-body |
| 102 | (org-babel-expand-body:octave body params processed-params)) | 87 | (org-babel-expand-body:generic |
| 88 | body params (org-babel-variable-assignments:octave params))) | ||
| 103 | (result (org-babel-octave-evaluate | 89 | (result (org-babel-octave-evaluate |
| 104 | session augmented-body result-type matlabp))) | 90 | session full-body result-type matlabp))) |
| 105 | (or out-file | 91 | (or out-file |
| 106 | (org-babel-reassemble-table | 92 | (org-babel-reassemble-table |
| 107 | result | 93 | result |
| 108 | (org-babel-pick-name | 94 | (org-babel-pick-name |
| 109 | (nth 4 processed-params) (cdr (assoc :colnames params))) | 95 | (cdr (assoc :colname-names params)) (cdr (assoc :colnames params))) |
| 110 | (org-babel-pick-name | 96 | (org-babel-pick-name |
| 111 | (nth 5 processed-params) (cdr (assoc :rownames params))))))) | 97 | (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params))))))) |
| 112 | 98 | ||
| 113 | (defun org-babel-prep-session:matlab (session params) | 99 | (defun org-babel-prep-session:matlab (session params) |
| 114 | "Prepare SESSION according to PARAMS." | 100 | "Prepare SESSION according to PARAMS." |
| 115 | (require 'matlab) | ||
| 116 | (org-babel-prep-session:octave session params 'matlab)) | 101 | (org-babel-prep-session:octave session params 'matlab)) |
| 102 | |||
| 103 | (defun org-babel-variable-assignments:octave (params) | ||
| 104 | "Return list of octave statements assigning the block's variables" | ||
| 105 | (mapcar | ||
| 106 | (lambda (pair) | ||
| 107 | (format "%s=%s" | ||
| 108 | (car pair) | ||
| 109 | (org-babel-octave-var-to-octave (cdr pair)))) | ||
| 110 | (mapcar #'cdr (org-babel-get-header params :var)))) | ||
| 111 | |||
| 112 | (defalias 'org-babel-variable-assignments:matlab | ||
| 113 | 'org-babel-variable-assignments:octave) | ||
| 114 | |||
| 117 | (defun org-babel-octave-var-to-octave (var) | 115 | (defun org-babel-octave-var-to-octave (var) |
| 118 | "Convert an emacs-lisp value into an octave variable. | 116 | "Convert an emacs-lisp value into an octave variable. |
| 119 | Converts an emacs-lisp variable into a string of octave code | 117 | Converts an emacs-lisp variable into a string of octave code |
| 120 | specifying a variable of the same value." | 118 | specifying a variable of the same value." |
| 121 | (if (listp var) | 119 | (if (listp var) |
| 122 | (concat "[" (mapconcat #'org-babel-octave-var-to-octave var ", ") "]") | 120 | (concat "[" (mapconcat #'org-babel-octave-var-to-octave var |
| 123 | (format "%S" var))) | 121 | (if (listp (car var)) "; " ",")) "]") |
| 122 | (format "%s" (or var "nil")))) | ||
| 124 | 123 | ||
| 125 | (defun org-babel-prep-session:octave (session params &optional matlabp) | 124 | (defun org-babel-prep-session:octave (session params &optional matlabp) |
| 126 | "Prepare SESSION according to the header arguments specified in PARAMS." | 125 | "Prepare SESSION according to the header arguments specified in PARAMS." |
| 127 | (let* ((session (org-babel-octave-initiate-session session params matlabp)) | 126 | (let* ((session (org-babel-octave-initiate-session session params matlabp)) |
| 128 | (vars (org-babel-ref-variables params)) | 127 | (var-lines (org-babel-variable-assignments:octave params))) |
| 129 | (var-lines (mapcar | ||
| 130 | (lambda (pair) | ||
| 131 | (format "%s=%s" | ||
| 132 | (car pair) | ||
| 133 | (org-babel-octave-var-to-octave (cdr pair)))) | ||
| 134 | vars))) | ||
| 135 | (org-babel-comint-in-buffer session | 128 | (org-babel-comint-in-buffer session |
| 136 | (mapc (lambda (var) | 129 | (mapc (lambda (var) |
| 137 | (end-of-line 1) (insert var) (comint-send-input nil t) | 130 | (end-of-line 1) (insert var) (comint-send-input nil t) |
| @@ -142,13 +135,13 @@ specifying a variable of the same value." | |||
| 142 | "Create a matlab inferior process buffer. | 135 | "Create a matlab inferior process buffer. |
| 143 | If there is not a current inferior-process-buffer in SESSION then | 136 | If there is not a current inferior-process-buffer in SESSION then |
| 144 | create. Return the initialized session." | 137 | create. Return the initialized session." |
| 145 | (require 'matlab) | ||
| 146 | (org-babel-octave-initiate-session session params 'matlab)) | 138 | (org-babel-octave-initiate-session session params 'matlab)) |
| 139 | |||
| 147 | (defun org-babel-octave-initiate-session (&optional session params matlabp) | 140 | (defun org-babel-octave-initiate-session (&optional session params matlabp) |
| 148 | "Create an octave inferior process buffer. | 141 | "Create an octave inferior process buffer. |
| 149 | If there is not a current inferior-process-buffer in SESSION then | 142 | If there is not a current inferior-process-buffer in SESSION then |
| 150 | create. Return the initialized session." | 143 | create. Return the initialized session." |
| 151 | (require 'octave-inf) | 144 | (if matlabp (require 'matlab) (require 'octave-inf)) |
| 152 | (unless (string= session "none") | 145 | (unless (string= session "none") |
| 153 | (let ((session (or session | 146 | (let ((session (or session |
| 154 | (if matlabp "*Inferior Matlab*" "*Inferior Octave*")))) | 147 | (if matlabp "*Inferior Matlab*" "*Inferior Octave*")))) |
| @@ -161,7 +154,7 @@ create. Return the initialized session." | |||
| 161 | (current-buffer)))))) | 154 | (current-buffer)))))) |
| 162 | 155 | ||
| 163 | (defun org-babel-octave-evaluate | 156 | (defun org-babel-octave-evaluate |
| 164 | (session body result-type lang &optional matlabp) | 157 | (session body result-type &optional matlabp) |
| 165 | "Pass BODY to the octave process in SESSION. | 158 | "Pass BODY to the octave process in SESSION. |
| 166 | If RESULT-TYPE equals 'output then return the outputs of the | 159 | If RESULT-TYPE equals 'output then return the outputs of the |
| 167 | statements in BODY, if RESULT-TYPE equals 'value then return the | 160 | statements in BODY, if RESULT-TYPE equals 'value then return the |
| @@ -177,17 +170,19 @@ value of the last statement in BODY, as elisp." | |||
| 177 | org-babel-octave-shell-command))) | 170 | org-babel-octave-shell-command))) |
| 178 | (case result-type | 171 | (case result-type |
| 179 | (output (org-babel-eval cmd body)) | 172 | (output (org-babel-eval cmd body)) |
| 180 | (value (let ((tmp-file (make-temp-file "org-babel-results-"))) | 173 | (value (let ((tmp-file (org-babel-temp-file "octave-"))) |
| 181 | (org-babel-eval | 174 | (org-babel-eval |
| 182 | cmd | 175 | cmd |
| 183 | (format org-babel-octave-wrapper-method body tmp-file tmp-file)) | 176 | (format org-babel-octave-wrapper-method body |
| 184 | (org-babel-eval-read-file tmp-file)))))) | 177 | (org-babel-process-file-name tmp-file 'noquote) |
| 178 | (org-babel-process-file-name tmp-file 'noquote))) | ||
| 179 | (org-babel-octave-import-elisp-from-file tmp-file)))))) | ||
| 185 | 180 | ||
| 186 | (defun org-babel-octave-evaluate-session | 181 | (defun org-babel-octave-evaluate-session |
| 187 | (session body result-type &optional matlabp) | 182 | (session body result-type &optional matlabp) |
| 188 | "Evaluate BODY in SESSION." | 183 | "Evaluate BODY in SESSION." |
| 189 | (let* ((tmp-file (make-temp-file "org-babel-results-")) | 184 | (let* ((tmp-file (org-babel-temp-file (if matlabp "matlab-" "octave-"))) |
| 190 | (wait-file (make-temp-file "org-babel-matlab-emacs-link-wait-signal-")) | 185 | (wait-file (org-babel-temp-file "matlab-emacs-link-wait-signal-")) |
| 191 | (full-body | 186 | (full-body |
| 192 | (case result-type | 187 | (case result-type |
| 193 | (output | 188 | (output |
| @@ -198,11 +193,15 @@ value of the last statement in BODY, as elisp." | |||
| 198 | (if (and matlabp org-babel-matlab-with-emacs-link) | 193 | (if (and matlabp org-babel-matlab-with-emacs-link) |
| 199 | (concat | 194 | (concat |
| 200 | (format org-babel-matlab-emacs-link-wrapper-method | 195 | (format org-babel-matlab-emacs-link-wrapper-method |
| 201 | body tmp-file tmp-file wait-file) "\n") | 196 | body |
| 197 | (org-babel-process-file-name tmp-file 'noquote) | ||
| 198 | (org-babel-process-file-name tmp-file 'noquote) wait-file) "\n") | ||
| 202 | (mapconcat | 199 | (mapconcat |
| 203 | #'org-babel-chomp | 200 | #'org-babel-chomp |
| 204 | (list (format org-babel-octave-wrapper-method | 201 | (list (format org-babel-octave-wrapper-method |
| 205 | body tmp-file tmp-file) | 202 | body |
| 203 | (org-babel-process-file-name tmp-file 'noquote) | ||
| 204 | (org-babel-process-file-name tmp-file 'noquote)) | ||
| 206 | org-babel-octave-eoe-indicator) "\n"))))) | 205 | org-babel-octave-eoe-indicator) "\n"))))) |
| 207 | (raw (if (and matlabp org-babel-matlab-with-emacs-link) | 206 | (raw (if (and matlabp org-babel-matlab-with-emacs-link) |
| 208 | (save-window-excursion | 207 | (save-window-excursion |
| @@ -225,8 +224,7 @@ value of the last statement in BODY, as elisp." | |||
| 225 | (insert full-body) (comint-send-input nil t)))) results) | 224 | (insert full-body) (comint-send-input nil t)))) results) |
| 226 | (case result-type | 225 | (case result-type |
| 227 | (value | 226 | (value |
| 228 | (org-babel-octave-import-elisp-from-file | 227 | (org-babel-octave-import-elisp-from-file tmp-file)) |
| 229 | (org-babel-maybe-remote-file tmp-file))) | ||
| 230 | (output | 228 | (output |
| 231 | (progn | 229 | (progn |
| 232 | (setq results | 230 | (setq results |
| @@ -244,14 +242,14 @@ value of the last statement in BODY, as elisp." | |||
| 244 | "Import data from FILE-NAME. | 242 | "Import data from FILE-NAME. |
| 245 | This removes initial blank and comment lines and then calls | 243 | This removes initial blank and comment lines and then calls |
| 246 | `org-babel-import-elisp-from-file'." | 244 | `org-babel-import-elisp-from-file'." |
| 247 | (let ((temp-file (make-temp-file "org-babel-results-")) beg end) | 245 | (let ((temp-file (org-babel-temp-file "octave-matlab-")) beg end) |
| 248 | (with-temp-file temp-file | 246 | (with-temp-file temp-file |
| 249 | (insert-file-contents file-name) | 247 | (insert-file-contents file-name) |
| 250 | (re-search-forward "^[ \t]*[^# \t]" nil t) | 248 | (re-search-forward "^[ \t]*[^# \t]" nil t) |
| 251 | (if (< (setq beg (point-min)) | 249 | (if (< (setq beg (point-min)) |
| 252 | (setq end (point-at-bol))) | 250 | (setq end (point-at-bol))) |
| 253 | (delete-region beg end))) | 251 | (delete-region beg end))) |
| 254 | (org-babel-import-elisp-from-file temp-file))) | 252 | (org-babel-import-elisp-from-file temp-file '(16)))) |
| 255 | 253 | ||
| 256 | (defun org-babel-octave-read-string (string) | 254 | (defun org-babel-octave-read-string (string) |
| 257 | "Strip \\\"s from around octave string" | 255 | "Strip \\\"s from around octave string" |
diff --git a/lisp/org/ob-org.el b/lisp/org/ob-org.el new file mode 100644 index 00000000000..86abbabfb13 --- /dev/null +++ b/lisp/org/ob-org.el | |||
| @@ -0,0 +1,62 @@ | |||
| 1 | ;;; ob-org.el --- org-babel functions for org code block evaluation | ||
| 2 | |||
| 3 | ;; Copyright (C) 2010 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Eric Schulte | ||
| 6 | ;; Keywords: literate programming, reproducible research | ||
| 7 | ;; Homepage: http://orgmode.org | ||
| 8 | ;; Version: 7.3 | ||
| 9 | |||
| 10 | ;; This file is part of GNU Emacs. | ||
| 11 | |||
| 12 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 13 | ;; it under the terms of the GNU General Public License as published by | ||
| 14 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 15 | ;; (at your option) any later version. | ||
| 16 | |||
| 17 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 18 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 20 | ;; GNU General Public License for more details. | ||
| 21 | |||
| 22 | ;; You should have received a copy of the GNU General Public License | ||
| 23 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | ||
| 24 | |||
| 25 | ;;; Commentary: | ||
| 26 | |||
| 27 | ;; This is the simplest of code blocks, where upon evaluation the | ||
| 28 | ;; contents of the code block are returned in a raw result. | ||
| 29 | |||
| 30 | ;;; Code: | ||
| 31 | (require 'ob) | ||
| 32 | |||
| 33 | (declare-function org-export-string "org-exp" (string fmt &optional dir)) | ||
| 34 | |||
| 35 | (defvar org-babel-default-header-args:org | ||
| 36 | '((:results . "raw silent") (:exports . "results")) | ||
| 37 | "Default arguments for evaluating a org source block.") | ||
| 38 | |||
| 39 | (defvar org-babel-org-default-header | ||
| 40 | "#+TITLE: default empty header\n" | ||
| 41 | "Default header inserted during export of org blocks.") | ||
| 42 | |||
| 43 | (defun org-babel-execute:org (body params) | ||
| 44 | "Execute a block of Org code with. | ||
| 45 | This function is called by `org-babel-execute-src-block'." | ||
| 46 | (let ((result-params (split-string (or (cdr (assoc :results params)) ""))) | ||
| 47 | (body (replace-regexp-in-string "^," "" body))) | ||
| 48 | (cond | ||
| 49 | ((member "latex" result-params) (org-export-string body "latex")) | ||
| 50 | ((member "html" result-params) (org-export-string body "html")) | ||
| 51 | ((member "ascii" result-params) (org-export-string body "ascii")) | ||
| 52 | (t body)))) | ||
| 53 | |||
| 54 | (defun org-babel-prep-session:org (session params) | ||
| 55 | "Return an error because org does not support sessions." | ||
| 56 | (error "Org does not support sessions")) | ||
| 57 | |||
| 58 | (provide 'ob-org) | ||
| 59 | |||
| 60 | ;; arch-tag: 130af5fe-cc56-46bd-9508-fa0ebd94cb1f | ||
| 61 | |||
| 62 | ;;; ob-org.el ends here | ||
diff --git a/lisp/org/ob-perl.el b/lisp/org/ob-perl.el index bfba158d4a8..0be667c8ce8 100644 --- a/lisp/org/ob-perl.el +++ b/lisp/org/ob-perl.el | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | ;; Author: Dan Davison, Eric Schulte | 5 | ;; Author: Dan Davison, 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.01 | 8 | ;; Version: 7.3 |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -38,39 +38,35 @@ | |||
| 38 | (defvar org-babel-perl-command "perl" | 38 | (defvar org-babel-perl-command "perl" |
| 39 | "Name of command to use for executing perl code.") | 39 | "Name of command to use for executing perl code.") |
| 40 | 40 | ||
| 41 | (defun org-babel-expand-body:perl (body params &optional processed-params) | ||
| 42 | "Expand BODY according to PARAMS, return the expanded body." | ||
| 43 | (let ((vars (nth 1 (or processed-params (org-babel-process-params params))))) | ||
| 44 | (concat | ||
| 45 | (mapconcat ;; define any variables | ||
| 46 | (lambda (pair) | ||
| 47 | (format "$%s=%s;" | ||
| 48 | (car pair) | ||
| 49 | (org-babel-perl-var-to-perl (cdr pair)))) | ||
| 50 | vars "\n") "\n" (org-babel-trim body) "\n"))) | ||
| 51 | |||
| 52 | (defun org-babel-execute:perl (body params) | 41 | (defun org-babel-execute:perl (body params) |
| 53 | "Execute a block of Perl code with Babel. | 42 | "Execute a block of Perl code with Babel. |
| 54 | This function is called by `org-babel-execute-src-block'." | 43 | This function is called by `org-babel-execute-src-block'." |
| 55 | (let* ((processed-params (org-babel-process-params params)) | 44 | (let* ((session (cdr (assoc :session params))) |
| 56 | (session (nth 0 processed-params)) | 45 | (result-params (cdr (assoc :result-params params))) |
| 57 | (vars (nth 1 processed-params)) | 46 | (result-type (cdr (assoc :result-type params))) |
| 58 | (result-params (nth 2 processed-params)) | 47 | (full-body (org-babel-expand-body:generic |
| 59 | (result-type (nth 3 processed-params)) | 48 | body params (org-babel-variable-assignments:perl params))) |
| 60 | (full-body (org-babel-expand-body:perl | ||
| 61 | body params processed-params)) | ||
| 62 | (session (org-babel-perl-initiate-session session))) | 49 | (session (org-babel-perl-initiate-session session))) |
| 63 | (org-babel-reassemble-table | 50 | (org-babel-reassemble-table |
| 64 | (org-babel-perl-evaluate session full-body result-type) | 51 | (org-babel-perl-evaluate session full-body result-type) |
| 65 | (org-babel-pick-name | 52 | (org-babel-pick-name |
| 66 | (nth 4 processed-params) (cdr (assoc :colnames params))) | 53 | (cdr (assoc :colname-names params)) (cdr (assoc :colnames params))) |
| 67 | (org-babel-pick-name | 54 | (org-babel-pick-name |
| 68 | (nth 5 processed-params) (cdr (assoc :rownames params)))))) | 55 | (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params)))))) |
| 69 | 56 | ||
| 70 | (defun org-babel-prep-session:perl (session params) | 57 | (defun org-babel-prep-session:perl (session params) |
| 71 | "Prepare SESSION according to the header arguments in PARAMS." | 58 | "Prepare SESSION according to the header arguments in PARAMS." |
| 72 | (error "Sessions are not supported for Perl.")) | 59 | (error "Sessions are not supported for Perl.")) |
| 73 | 60 | ||
| 61 | (defun org-babel-variable-assignments:perl (params) | ||
| 62 | "Return list of perl statements assigning the block's variables" | ||
| 63 | (mapcar | ||
| 64 | (lambda (pair) | ||
| 65 | (format "$%s=%s;" | ||
| 66 | (car pair) | ||
| 67 | (org-babel-perl-var-to-perl (cdr pair)))) | ||
| 68 | (mapcar #'cdr (org-babel-get-header params :var)))) | ||
| 69 | |||
| 74 | ;; helper functions | 70 | ;; helper functions |
| 75 | 71 | ||
| 76 | (defun org-babel-perl-var-to-perl (var) | 72 | (defun org-babel-perl-var-to-perl (var) |
| @@ -107,10 +103,11 @@ return the value of the last statement in BODY, as elisp." | |||
| 107 | (when session (error "Sessions are not supported for Perl.")) | 103 | (when session (error "Sessions are not supported for Perl.")) |
| 108 | (case result-type | 104 | (case result-type |
| 109 | (output (org-babel-eval org-babel-perl-command body)) | 105 | (output (org-babel-eval org-babel-perl-command body)) |
| 110 | (value (let ((tmp-file (make-temp-file "org-babel-perl-results-"))) | 106 | (value (let ((tmp-file (org-babel-temp-file "perl-"))) |
| 111 | (org-babel-eval | 107 | (org-babel-eval |
| 112 | org-babel-perl-command | 108 | org-babel-perl-command |
| 113 | (format org-babel-perl-wrapper-method body tmp-file)) | 109 | (format org-babel-perl-wrapper-method body |
| 110 | (org-babel-process-file-name tmp-file 'noquote))) | ||
| 114 | (org-babel-eval-read-file tmp-file))))) | 111 | (org-babel-eval-read-file tmp-file))))) |
| 115 | 112 | ||
| 116 | (provide 'ob-perl) | 113 | (provide 'ob-perl) |
diff --git a/lisp/org/ob-plantuml.el b/lisp/org/ob-plantuml.el new file mode 100644 index 00000000000..37561020cb0 --- /dev/null +++ b/lisp/org/ob-plantuml.el | |||
| @@ -0,0 +1,83 @@ | |||
| 1 | ;;; ob-plantuml.el --- org-babel functions for plantuml evaluation | ||
| 2 | |||
| 3 | ;; Copyright (C) 2010 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Zhang Weize | ||
| 6 | ;; Keywords: literate programming, reproducible research | ||
| 7 | ;; Homepage: http://orgmode.org | ||
| 8 | ;; Version: 7.3 | ||
| 9 | |||
| 10 | ;; This file is part of GNU Emacs. | ||
| 11 | |||
| 12 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 13 | ;; it under the terms of the GNU General Public License as published by | ||
| 14 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 15 | ;; (at your option) any later version. | ||
| 16 | |||
| 17 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 18 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 20 | ;; GNU General Public License for more details. | ||
| 21 | |||
| 22 | ;; You should have received a copy of the GNU General Public License | ||
| 23 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | ||
| 24 | |||
| 25 | ;;; Commentary: | ||
| 26 | |||
| 27 | ;; Org-Babel support for evaluating plantuml script. | ||
| 28 | ;; | ||
| 29 | ;; Inspired by Ian Yang's org-export-blocks-format-plantuml | ||
| 30 | ;; http://www.emacswiki.org/emacs/org-export-blocks-format-plantuml.el | ||
| 31 | |||
| 32 | ;;; Requirements: | ||
| 33 | |||
| 34 | ;; plantuml | http://plantuml.sourceforge.net/ | ||
| 35 | ;; plantuml.jar | `org-plantuml-jar-path' should point to the jar file | ||
| 36 | |||
| 37 | ;;; Code: | ||
| 38 | (require 'ob) | ||
| 39 | (require 'ob-eval) | ||
| 40 | |||
| 41 | (defvar org-babel-default-header-args:plantuml | ||
| 42 | '((:results . "file") (:exports . "results")) | ||
| 43 | "Default arguments for evaluating a plantuml source block.") | ||
| 44 | |||
| 45 | (defcustom org-plantuml-jar-path nil | ||
| 46 | "Path to the plantuml.jar file." | ||
| 47 | :group 'org-babel | ||
| 48 | :type 'string) | ||
| 49 | |||
| 50 | (defun org-babel-execute:plantuml (body params) | ||
| 51 | "Execute a block of plantuml code with org-babel. | ||
| 52 | This function is called by `org-babel-execute-src-block'." | ||
| 53 | (let* ((result-params (split-string (or (cdr (assoc :results params)) ""))) | ||
| 54 | (out-file (or (cdr (assoc :file params)) | ||
| 55 | (error "plantuml requires a \":file\" header argument"))) | ||
| 56 | (cmdline (cdr (assoc :cmdline params))) | ||
| 57 | (in-file (org-babel-temp-file "plantuml-")) | ||
| 58 | (cmd (if (not org-plantuml-jar-path) | ||
| 59 | (error "`org-plantuml-jar-path' is not set") | ||
| 60 | (concat "java -jar " | ||
| 61 | (shell-quote-argument | ||
| 62 | (expand-file-name org-plantuml-jar-path)) | ||
| 63 | (if (string= (file-name-extension out-file) "svg") | ||
| 64 | " -tsvg" "") | ||
| 65 | " -p " cmdline " < " | ||
| 66 | (org-babel-process-file-name in-file) | ||
| 67 | " > " | ||
| 68 | (org-babel-process-file-name out-file))))) | ||
| 69 | (unless (file-exists-p org-plantuml-jar-path) | ||
| 70 | (error "Could not find plantuml.jar at %s" org-plantuml-jar-path)) | ||
| 71 | (with-temp-file in-file (insert (concat "@startuml\n" body "\n@enduml"))) | ||
| 72 | (message "%s" cmd) (org-babel-eval cmd "") | ||
| 73 | out-file)) | ||
| 74 | |||
| 75 | (defun org-babel-prep-session:plantuml (session params) | ||
| 76 | "Return an error because plantuml does not support sessions." | ||
| 77 | (error "Plantuml does not support sessions")) | ||
| 78 | |||
| 79 | (provide 'ob-plantuml) | ||
| 80 | |||
| 81 | ;; arch-tag: 451f50c5-e779-407e-ad64-70e0e8f161d1 | ||
| 82 | |||
| 83 | ;;; ob-plantuml.el ends here | ||
diff --git a/lisp/org/ob-python.el b/lisp/org/ob-python.el index c082188bea7..5aaa1059a47 100644 --- a/lisp/org/ob-python.el +++ b/lisp/org/ob-python.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.01 | 8 | ;; Version: 7.3 |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -47,46 +47,34 @@ | |||
| 47 | (defvar org-babel-python-mode (if (featurep 'xemacs) 'python-mode 'python) | 47 | (defvar org-babel-python-mode (if (featurep 'xemacs) 'python-mode 'python) |
| 48 | "Preferred python mode for use in running python interactively.") | 48 | "Preferred python mode for use in running python interactively.") |
| 49 | 49 | ||
| 50 | (defun org-babel-expand-body:python (body params &optional processed-params) | 50 | (defvar org-src-preserve-indentation) |
| 51 | "Expand BODY according to PARAMS, return the expanded body." | ||
| 52 | (concat | ||
| 53 | (mapconcat ;; define any variables | ||
| 54 | (lambda (pair) | ||
| 55 | (format "%s=%s" | ||
| 56 | (car pair) | ||
| 57 | (org-babel-python-var-to-python (cdr pair)))) | ||
| 58 | (nth 1 (or processed-params (org-babel-process-params params))) "\n") | ||
| 59 | "\n" (org-babel-trim body) "\n")) | ||
| 60 | 51 | ||
| 61 | (defun org-babel-execute:python (body params) | 52 | (defun org-babel-execute:python (body params) |
| 62 | "Execute a block of Python code with Babel. | 53 | "Execute a block of Python code with Babel. |
| 63 | This function is called by `org-babel-execute-src-block'." | 54 | This function is called by `org-babel-execute-src-block'." |
| 64 | (let* ((processed-params (org-babel-process-params params)) | 55 | (let* ((session (org-babel-python-initiate-session |
| 65 | (session (org-babel-python-initiate-session (first processed-params))) | 56 | (cdr (assoc :session params)))) |
| 66 | (result-params (nth 2 processed-params)) | 57 | (result-params (cdr (assoc :result-params params))) |
| 67 | (result-type (nth 3 processed-params)) | 58 | (result-type (cdr (assoc :result-type params))) |
| 68 | (full-body (org-babel-expand-body:python | 59 | (full-body |
| 69 | body params processed-params)) | 60 | (org-babel-expand-body:generic |
| 61 | body params (org-babel-variable-assignments:python params))) | ||
| 70 | (result (org-babel-python-evaluate | 62 | (result (org-babel-python-evaluate |
| 71 | session full-body result-type result-params))) | 63 | session full-body result-type result-params))) |
| 72 | (or (cdr (assoc :file params)) | 64 | (or (cdr (assoc :file params)) |
| 73 | (org-babel-reassemble-table | 65 | (org-babel-reassemble-table |
| 74 | result | 66 | result |
| 75 | (org-babel-pick-name (nth 4 processed-params) | 67 | (org-babel-pick-name (cdr (assoc :colname-names params)) |
| 76 | (cdr (assoc :colnames params))) | 68 | (cdr (assoc :colnames params))) |
| 77 | (org-babel-pick-name (nth 5 processed-params) | 69 | (org-babel-pick-name (cdr (assoc :rowname-names params)) |
| 78 | (cdr (assoc :rownames params))))))) | 70 | (cdr (assoc :rownames params))))))) |
| 79 | 71 | ||
| 80 | (defun org-babel-prep-session:python (session params) | 72 | (defun org-babel-prep-session:python (session params) |
| 81 | "Prepare SESSION according to the header arguments in PARAMS." | 73 | "Prepare SESSION according to the header arguments in PARAMS. |
| 74 | VARS contains resolved variable references" | ||
| 82 | (let* ((session (org-babel-python-initiate-session session)) | 75 | (let* ((session (org-babel-python-initiate-session session)) |
| 83 | (vars (org-babel-ref-variables params)) | 76 | (var-lines |
| 84 | (var-lines (mapcar ;; define any variables | 77 | (org-babel-variable-assignments:python params))) |
| 85 | (lambda (pair) | ||
| 86 | (format "%s=%s" | ||
| 87 | (car pair) | ||
| 88 | (org-babel-python-var-to-python (cdr pair)))) | ||
| 89 | vars))) | ||
| 90 | (org-babel-comint-in-buffer session | 78 | (org-babel-comint-in-buffer session |
| 91 | (mapc (lambda (var) | 79 | (mapc (lambda (var) |
| 92 | (end-of-line 1) (insert var) (comint-send-input) | 80 | (end-of-line 1) (insert var) (comint-send-input) |
| @@ -104,6 +92,15 @@ This function is called by `org-babel-execute-src-block'." | |||
| 104 | 92 | ||
| 105 | ;; helper functions | 93 | ;; helper functions |
| 106 | 94 | ||
| 95 | (defun org-babel-variable-assignments:python (params) | ||
| 96 | "Return list of python statements assigning the block's variables" | ||
| 97 | (mapcar | ||
| 98 | (lambda (pair) | ||
| 99 | (format "%s=%s" | ||
| 100 | (car pair) | ||
| 101 | (org-babel-python-var-to-python (cdr pair)))) | ||
| 102 | (mapcar #'cdr (org-babel-get-header params :var)))) | ||
| 103 | |||
| 107 | (defun org-babel-python-var-to-python (var) | 104 | (defun org-babel-python-var-to-python (var) |
| 108 | "Convert an elisp value to a python variable. | 105 | "Convert an elisp value to a python variable. |
| 109 | Convert an elisp value, VAR, into a string of python source code | 106 | Convert an elisp value, VAR, into a string of python source code |
| @@ -125,8 +122,7 @@ Emacs-lisp table, otherwise return the results as a string." | |||
| 125 | (mapcar (lambda (el) (if (equal el 'None) 'hline el)) res) | 122 | (mapcar (lambda (el) (if (equal el 'None) 'hline el)) res) |
| 126 | res)) | 123 | res)) |
| 127 | (org-babel-read | 124 | (org-babel-read |
| 128 | (if (or (string-match "^\\[.+\\]$" results) | 125 | (if (and (stringp results) (string-match "^[([].+[])]$" results)) |
| 129 | (string-match "^(.+)$" results)) | ||
| 130 | (org-babel-read | 126 | (org-babel-read |
| 131 | (concat "'" | 127 | (concat "'" |
| 132 | (replace-regexp-in-string | 128 | (replace-regexp-in-string |
| @@ -151,10 +147,10 @@ then create. Return the initialized session." | |||
| 151 | (let* ((session (if session (intern session) :default)) | 147 | (let* ((session (if session (intern session) :default)) |
| 152 | (python-buffer (org-babel-python-session-buffer session))) | 148 | (python-buffer (org-babel-python-session-buffer session))) |
| 153 | (cond | 149 | (cond |
| 154 | ((and (equal 'python org-babel-python-mode) | 150 | ((and (eq 'python org-babel-python-mode) |
| 155 | (fboundp 'run-python)) ; python.el | 151 | (fboundp 'run-python)) ; python.el |
| 156 | (run-python)) | 152 | (run-python)) |
| 157 | ((and (equal 'python-mode org-babel-python-mode) | 153 | ((and (eq 'python-mode org-babel-python-mode) |
| 158 | (fboundp 'py-shell)) ; python-mode.el | 154 | (fboundp 'py-shell)) ; python-mode.el |
| 159 | ;; `py-shell' creates a buffer whose name is the value of | 155 | ;; `py-shell' creates a buffer whose name is the value of |
| 160 | ;; `py-which-bufname' with '*'s at the beginning and end | 156 | ;; `py-which-bufname' with '*'s at the beginning and end |
| @@ -195,73 +191,89 @@ def main(): | |||
| 195 | open('%s', 'w').write( pprint.pformat(main()) )") | 191 | open('%s', 'w').write( pprint.pformat(main()) )") |
| 196 | 192 | ||
| 197 | (defun org-babel-python-evaluate | 193 | (defun org-babel-python-evaluate |
| 198 | (buffer body &optional result-type result-params) | 194 | (session body &optional result-type result-params) |
| 199 | "Pass BODY to the Python process in BUFFER. | 195 | "Evaluate BODY as python code." |
| 200 | If RESULT-TYPE equals 'output then return a list of the outputs | 196 | (if session |
| 201 | of the statements in BODY, if RESULT-TYPE equals 'value then | 197 | (org-babel-python-evaluate-session |
| 202 | return the value of the last statement in BODY, as elisp." | 198 | session body result-type result-params) |
| 203 | (if (not buffer) | 199 | (org-babel-python-evaluate-external-process |
| 204 | ;; external process evaluation | 200 | body result-type result-params))) |
| 205 | (case result-type | 201 | |
| 206 | (output (org-babel-eval org-babel-python-command body)) | 202 | (defun org-babel-python-evaluate-external-process |
| 207 | (value (let ((tmp-file (make-temp-file "org-babel-python-results-"))) | 203 | (body &optional result-type result-params) |
| 208 | (org-babel-eval org-babel-python-command | 204 | "Evaluate BODY in external python process. |
| 209 | (format | 205 | If RESULT-TYPE equals 'output then return standard output as a |
| 210 | (if (member "pp" result-params) | 206 | string. If RESULT-TYPE equals 'value then return the value of the |
| 211 | org-babel-python-pp-wrapper-method | 207 | last statement in BODY, as elisp." |
| 212 | org-babel-python-wrapper-method) | 208 | (case result-type |
| 213 | (mapconcat | 209 | (output (org-babel-eval org-babel-python-command body)) |
| 214 | (lambda (line) (format "\t%s" line)) | 210 | (value (let ((tmp-file (org-babel-temp-file "python-"))) |
| 215 | (split-string | 211 | (org-babel-eval org-babel-python-command |
| 216 | (org-remove-indentation | 212 | (format |
| 217 | (org-babel-trim body)) | 213 | (if (member "pp" result-params) |
| 218 | "[\r\n]") "\n") | 214 | org-babel-python-pp-wrapper-method |
| 219 | tmp-file)) | 215 | org-babel-python-wrapper-method) |
| 220 | ((lambda (raw) | 216 | (mapconcat |
| 221 | (if (or (member "code" result-params) | 217 | (lambda (line) (format "\t%s" line)) |
| 222 | (member "pp" result-params)) | 218 | (split-string |
| 223 | raw | 219 | (org-remove-indentation |
| 224 | (org-babel-python-table-or-string raw))) | 220 | (org-babel-trim body)) |
| 225 | (org-babel-eval-read-file tmp-file))))) | 221 | "[\r\n]") "\n") |
| 226 | ;; comint session evaluation | 222 | (org-babel-process-file-name tmp-file 'noquote))) |
| 227 | (flet ((dump-last-value (tmp-file pp) | 223 | ((lambda (raw) |
| 228 | (mapc | 224 | (if (or (member "code" result-params) |
| 229 | (lambda (statement) (insert statement) (comint-send-input)) | 225 | (member "pp" result-params)) |
| 230 | (if pp | 226 | raw |
| 231 | (list | 227 | (org-babel-python-table-or-string raw))) |
| 232 | "import pp" | 228 | (org-babel-eval-read-file tmp-file)))))) |
| 233 | (format "open('%s', 'w').write(pprint.pformat(_))" tmp-file)) | 229 | |
| 234 | (list (format "open('%s', 'w').write(str(_))" tmp-file))))) | 230 | (defun org-babel-python-evaluate-session |
| 235 | (input-body (body) | 231 | (session body &optional result-type result-params) |
| 236 | (mapc (lambda (statement) (insert statement) (comint-send-input)) | 232 | "Pass BODY to the Python process in SESSION. |
| 237 | (split-string (org-babel-trim body) "[\r\n]+")) | 233 | If RESULT-TYPE equals 'output then return standard output as a |
| 238 | (comint-send-input) (comint-send-input))) | 234 | string. If RESULT-TYPE equals 'value then return the value of the |
| 239 | (case result-type | 235 | last statement in BODY, as elisp." |
| 240 | (output | 236 | (flet ((dump-last-value |
| 241 | (mapconcat | 237 | (tmp-file pp) |
| 242 | #'org-babel-trim | 238 | (mapc |
| 243 | (butlast | 239 | (lambda (statement) (insert statement) (comint-send-input)) |
| 244 | (org-babel-comint-with-output | 240 | (if pp |
| 245 | (buffer org-babel-python-eoe-indicator t body) | 241 | (list |
| 246 | (let ((comint-process-echoes nil)) | 242 | "import pp" |
| 247 | (input-body body) | 243 | (format "open('%s', 'w').write(pprint.pformat(_))" |
| 248 | (insert org-babel-python-eoe-indicator) | 244 | (org-babel-process-file-name tmp-file 'noquote))) |
| 249 | (comint-send-input))) 2) "\n")) | 245 | (list (format "open('%s', 'w').write(str(_))" |
| 250 | (value | 246 | (org-babel-process-file-name tmp-file 'noquote)))))) |
| 251 | ((lambda (results) | 247 | (input-body (body) |
| 252 | (if (or (member "code" result-params) (member "pp" result-params)) | 248 | (mapc (lambda (statement) (insert statement) (comint-send-input)) |
| 253 | results | 249 | (split-string (org-babel-trim body) "[\r\n]+")) |
| 254 | (org-babel-python-table-or-string results))) | 250 | (comint-send-input) (comint-send-input))) |
| 255 | (let ((tmp-file (make-temp-file "org-babel-python-results-"))) | 251 | (case result-type |
| 256 | (org-babel-comint-with-output | 252 | (output |
| 257 | (buffer org-babel-python-eoe-indicator t body) | 253 | (mapconcat |
| 258 | (let ((comint-process-echoes nil)) | 254 | #'org-babel-trim |
| 259 | (input-body body) | 255 | (butlast |
| 260 | (dump-last-value tmp-file (member "pp" result-params)) | 256 | (org-babel-comint-with-output |
| 261 | (comint-send-input) (comint-send-input) | 257 | (session org-babel-python-eoe-indicator t body) |
| 262 | (insert org-babel-python-eoe-indicator) | 258 | (let ((comint-process-echoes nil)) |
| 263 | (comint-send-input))) | 259 | (input-body body) |
| 264 | (org-babel-eval-read-file tmp-file)))))))) | 260 | (insert org-babel-python-eoe-indicator) |
| 261 | (comint-send-input))) 2) "\n")) | ||
| 262 | (value | ||
| 263 | ((lambda (results) | ||
| 264 | (if (or (member "code" result-params) (member "pp" result-params)) | ||
| 265 | results | ||
| 266 | (org-babel-python-table-or-string results))) | ||
| 267 | (let ((tmp-file (org-babel-temp-file "python-"))) | ||
| 268 | (org-babel-comint-with-output | ||
| 269 | (session org-babel-python-eoe-indicator t body) | ||
| 270 | (let ((comint-process-echoes nil)) | ||
| 271 | (input-body body) | ||
| 272 | (dump-last-value tmp-file (member "pp" result-params)) | ||
| 273 | (comint-send-input) (comint-send-input) | ||
| 274 | (insert org-babel-python-eoe-indicator) | ||
| 275 | (comint-send-input))) | ||
| 276 | (org-babel-eval-read-file tmp-file))))))) | ||
| 265 | 277 | ||
| 266 | (defun org-babel-python-read-string (string) | 278 | (defun org-babel-python-read-string (string) |
| 267 | "Strip 's from around python string" | 279 | "Strip 's from around python string" |
diff --git a/lisp/org/ob-ref.el b/lisp/org/ob-ref.el index 4c344e6761e..16881e824de 100644 --- a/lisp/org/ob-ref.el +++ b/lisp/org/ob-ref.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.01 | 8 | ;; Version: 7.3 |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -57,36 +57,26 @@ | |||
| 57 | (declare-function org-at-table-p "org" (&optional table-type)) | 57 | (declare-function org-at-table-p "org" (&optional table-type)) |
| 58 | (declare-function org-count "org" (CL-ITEM CL-SEQ)) | 58 | (declare-function org-count "org" (CL-ITEM CL-SEQ)) |
| 59 | 59 | ||
| 60 | (defun org-babel-ref-variables (params) | ||
| 61 | "Convert PARAMS to variable names and values. | ||
| 62 | Takes a parameter alist, and return an alist of variable names, | ||
| 63 | and the emacs-lisp representation of the related value." | ||
| 64 | (let ((assignments | ||
| 65 | (delq nil (mapcar (lambda (pair) (if (eq (car pair) :var) (cdr pair))) params))) | ||
| 66 | (others | ||
| 67 | (delq nil (mapcar (lambda (pair) (unless (eq :var (car pair)) pair)) params)))) | ||
| 68 | (mapcar (lambda (assignment) (org-babel-ref-parse assignment)) assignments))) | ||
| 69 | |||
| 70 | (defvar org-babel-ref-split-regexp | 60 | (defvar org-babel-ref-split-regexp |
| 71 | "[ \f\t\n\r\v]*\\(.+?\\)[ \f\t\n\r\v]*=[ \f\t\n\r\v]*\\(.+\\)[ \f\t\n\r\v]*") | 61 | "[ \f\t\n\r\v]*\\(.+?\\)[ \f\t\n\r\v]*=[ \f\t\n\r\v]*\\(.+\\)[ \f\t\n\r\v]*") |
| 72 | 62 | ||
| 73 | (defun org-babel-ref-parse (assignment &optional params) | 63 | (defun org-babel-ref-parse (assignment) |
| 74 | "Parse a variable ASSIGNMENT in a header argument. | 64 | "Parse a variable ASSIGNMENT in a header argument. |
| 75 | If the right hand side of the assignment has a literal value | 65 | If the right hand side of the assignment has a literal value |
| 76 | return that value, otherwise interpret as a reference to an | 66 | return that value, otherwise interpret as a reference to an |
| 77 | external resource and find it's value using | 67 | external resource and find it's value using |
| 78 | `org-babel-ref-resolve-reference'. Return a list with two | 68 | `org-babel-ref-resolve'. Return a list with two elements. The |
| 79 | elements. The first element of the list will be the name of the | 69 | first element of the list will be the name of the variable, and |
| 80 | variable, and the second will be an emacs-lisp representation of | 70 | the second will be an emacs-lisp representation of the value of |
| 81 | the value of the variable." | 71 | the variable." |
| 82 | (if (string-match org-babel-ref-split-regexp assignment) | 72 | (when (string-match org-babel-ref-split-regexp assignment) |
| 83 | (let ((var (match-string 1 assignment)) | 73 | (let ((var (match-string 1 assignment)) |
| 84 | (ref (match-string 2 assignment))) | 74 | (ref (match-string 2 assignment))) |
| 85 | (cons (intern var) | 75 | (cons (intern var) |
| 86 | ((lambda (val) | 76 | ((lambda (val) |
| 87 | (if (equal :ob-must-be-reference val) | 77 | (if (equal :ob-must-be-reference val) |
| 88 | (org-babel-ref-resolve-reference ref params) | 78 | (org-babel-ref-resolve ref) val)) |
| 89 | val)) (org-babel-ref-literal ref)))))) | 79 | (org-babel-ref-literal ref)))))) |
| 90 | 80 | ||
| 91 | (defun org-babel-ref-literal (ref) | 81 | (defun org-babel-ref-literal (ref) |
| 92 | "Return the value of REF if it is a literal value. | 82 | "Return the value of REF if it is a literal value. |
| @@ -103,7 +93,7 @@ return nil." | |||
| 103 | out))) | 93 | out))) |
| 104 | 94 | ||
| 105 | (defvar org-babel-library-of-babel) | 95 | (defvar org-babel-library-of-babel) |
| 106 | (defun org-babel-ref-resolve-reference (ref &optional params) | 96 | (defun org-babel-ref-resolve (ref) |
| 107 | "Resolve the reference REF and return its value." | 97 | "Resolve the reference REF and return its value." |
| 108 | (save-excursion | 98 | (save-excursion |
| 109 | (let ((case-fold-search t) | 99 | (let ((case-fold-search t) |
| @@ -119,12 +109,10 @@ return nil." | |||
| 119 | (when (string-match "^\\(.+?\\)\(\\(.*\\)\)$" ref) | 109 | (when (string-match "^\\(.+?\\)\(\\(.*\\)\)$" ref) |
| 120 | (setq new-refere (match-string 1 ref)) | 110 | (setq new-refere (match-string 1 ref)) |
| 121 | (setq new-referent (match-string 2 ref)) | 111 | (setq new-referent (match-string 2 ref)) |
| 122 | ;; (message "new-refere=%S, new-referent=%S" new-refere new-referent) ;; debugging | ||
| 123 | (when (> (length new-refere) 0) | 112 | (when (> (length new-refere) 0) |
| 124 | (if (> (length new-referent) 0) | 113 | (if (> (length new-referent) 0) |
| 125 | (setq args (mapcar (lambda (ref) (cons :var ref)) | 114 | (setq args (mapcar (lambda (ref) (cons :var ref)) |
| 126 | (org-babel-ref-split-args new-referent)))) | 115 | (org-babel-ref-split-args new-referent)))) |
| 127 | ;; (message "args=%S" args) ;; debugging | ||
| 128 | (setq ref new-refere))) | 116 | (setq ref new-refere))) |
| 129 | (when (string-match "^\\(.+\\):\\(.+\\)$" ref) | 117 | (when (string-match "^\\(.+\\):\\(.+\\)$" ref) |
| 130 | (setq split-file (match-string 1 ref)) | 118 | (setq split-file (match-string 1 ref)) |
| @@ -133,7 +121,8 @@ return nil." | |||
| 133 | (save-restriction | 121 | (save-restriction |
| 134 | (widen) | 122 | (widen) |
| 135 | (goto-char (point-min)) | 123 | (goto-char (point-min)) |
| 136 | (if (let ((result_regexp (concat "^[ \t]*#\\+\\(TBLNAME\\|RESNAME\\|RESULTS\\):[ \t]*" | 124 | (if (let ((result_regexp (concat "^[ \t]*#\\+\\(TBLNAME\\|RESNAME" |
| 125 | "\\|RESULTS\\):[ \t]*" | ||
| 137 | (regexp-quote ref) "[ \t]*$")) | 126 | (regexp-quote ref) "[ \t]*$")) |
| 138 | (regexp (concat org-babel-src-name-regexp | 127 | (regexp (concat org-babel-src-name-regexp |
| 139 | (regexp-quote ref) "\\(\(.*\)\\)?" "[ \t]*$"))) | 128 | (regexp-quote ref) "\\(\(.*\)\\)?" "[ \t]*$"))) |
| @@ -144,7 +133,8 @@ return nil." | |||
| 144 | (re-search-forward regexp nil t) | 133 | (re-search-forward regexp nil t) |
| 145 | (re-search-backward regexp nil t) | 134 | (re-search-backward regexp nil t) |
| 146 | ;; check the Library of Babel | 135 | ;; check the Library of Babel |
| 147 | (setq lob-info (cdr (assoc (intern ref) org-babel-library-of-babel))))) | 136 | (setq lob-info (cdr (assoc (intern ref) |
| 137 | org-babel-library-of-babel))))) | ||
| 148 | (unless lob-info (goto-char (match-beginning 0))) | 138 | (unless lob-info (goto-char (match-beginning 0))) |
| 149 | ;; ;; TODO: allow searching for names in other buffers | 139 | ;; ;; TODO: allow searching for names in other buffers |
| 150 | ;; (setq id-loc (org-id-find ref 'marker) | 140 | ;; (setq id-loc (org-id-find ref 'marker) |
| @@ -159,14 +149,14 @@ return nil." | |||
| 159 | (beginning-of-line) | 149 | (beginning-of-line) |
| 160 | (if (or (= (point) (point-min)) (= (point) (point-max))) | 150 | (if (or (= (point) (point-min)) (= (point) (point-max))) |
| 161 | (error "reference not found")))) | 151 | (error "reference not found")))) |
| 162 | (setq params (org-babel-merge-params params args '((:results . "silent")))) | 152 | (let ((params (append args '((:results . "silent"))))) |
| 163 | (setq result | 153 | (setq result |
| 164 | (case type | 154 | (case type |
| 165 | ('results-line (org-babel-read-result)) | 155 | ('results-line (org-babel-read-result)) |
| 166 | ('table (org-babel-read-table)) | 156 | ('table (org-babel-read-table)) |
| 167 | ('file (org-babel-read-link)) | 157 | ('file (org-babel-read-link)) |
| 168 | ('source-block (org-babel-execute-src-block nil nil params)) | 158 | ('source-block (org-babel-execute-src-block nil nil params)) |
| 169 | ('lob (org-babel-execute-src-block nil lob-info params)))) | 159 | ('lob (org-babel-execute-src-block nil lob-info params))))) |
| 170 | (if (symbolp result) | 160 | (if (symbolp result) |
| 171 | (format "%S" result) | 161 | (format "%S" result) |
| 172 | (if (and index (listp result)) | 162 | (if (and index (listp result)) |
| @@ -199,7 +189,7 @@ to \"0:-1\"." | |||
| 199 | (if (or (= 0 (length portion)) (string-match ind-re portion)) | 189 | (if (or (= 0 (length portion)) (string-match ind-re portion)) |
| 200 | (mapcar | 190 | (mapcar |
| 201 | (lambda (n) (nth n lis)) | 191 | (lambda (n) (nth n lis)) |
| 202 | (apply 'number-sequence | 192 | (apply 'org-number-sequence |
| 203 | (if (and (> (length portion) 0) (match-string 2 portion)) | 193 | (if (and (> (length portion) 0) (match-string 2 portion)) |
| 204 | (list | 194 | (list |
| 205 | (wrap (string-to-number (match-string 2 portion))) | 195 | (wrap (string-to-number (match-string 2 portion))) |
diff --git a/lisp/org/ob-ruby.el b/lisp/org/ob-ruby.el index e557c80ef1a..9a9f21cde60 100644 --- a/lisp/org/ob-ruby.el +++ b/lisp/org/ob-ruby.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.01 | 8 | ;; Version: 7.3 |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -52,48 +52,30 @@ | |||
| 52 | (defvar org-babel-ruby-command "ruby" | 52 | (defvar org-babel-ruby-command "ruby" |
| 53 | "Name of command to use for executing ruby code.") | 53 | "Name of command to use for executing ruby code.") |
| 54 | 54 | ||
| 55 | (defun org-babel-expand-body:ruby (body params &optional processed-params) | ||
| 56 | "Expand BODY according to PARAMS, return the expanded body." | ||
| 57 | (require 'inf-ruby) | ||
| 58 | (let ((vars (nth 1 (or processed-params (org-babel-process-params params))))) | ||
| 59 | (concat | ||
| 60 | (mapconcat ;; define any variables | ||
| 61 | (lambda (pair) | ||
| 62 | (format "%s=%s" | ||
| 63 | (car pair) | ||
| 64 | (org-babel-ruby-var-to-ruby (cdr pair)))) | ||
| 65 | vars "\n") "\n" body "\n"))) | ||
| 66 | |||
| 67 | (defun org-babel-execute:ruby (body params) | 55 | (defun org-babel-execute:ruby (body params) |
| 68 | "Execute a block of Ruby code with Babel. | 56 | "Execute a block of Ruby code with Babel. |
| 69 | This function is called by `org-babel-execute-src-block'." | 57 | This function is called by `org-babel-execute-src-block'." |
| 70 | (let* ((processed-params (org-babel-process-params params)) | 58 | (let* ((session (org-babel-ruby-initiate-session |
| 71 | (session (org-babel-ruby-initiate-session (first processed-params))) | 59 | (cdr (assoc :session params)))) |
| 72 | (result-params (nth 2 processed-params)) | 60 | (result-params (cdr (assoc :result-params params))) |
| 73 | (result-type (nth 3 processed-params)) | 61 | (result-type (cdr (assoc :result-type params))) |
| 74 | (full-body (org-babel-expand-body:ruby | 62 | (full-body (org-babel-expand-body:generic |
| 75 | body params processed-params)) | 63 | body params (org-babel-variable-assignments:ruby params))) |
| 76 | (result (org-babel-ruby-evaluate | 64 | (result (org-babel-ruby-evaluate |
| 77 | session full-body result-type result-params))) | 65 | session full-body result-type result-params))) |
| 78 | (or (cdr (assoc :file params)) | 66 | (or (cdr (assoc :file params)) |
| 79 | (org-babel-reassemble-table | 67 | (org-babel-reassemble-table |
| 80 | result | 68 | result |
| 81 | (org-babel-pick-name (nth 4 processed-params) | 69 | (org-babel-pick-name (cdr (assoc :colname-names params)) |
| 82 | (cdr (assoc :colnames params))) | 70 | (cdr (assoc :colnames params))) |
| 83 | (org-babel-pick-name (nth 5 processed-params) | 71 | (org-babel-pick-name (cdr (assoc :rowname-names params)) |
| 84 | (cdr (assoc :rownames params))))))) | 72 | (cdr (assoc :rownames params))))))) |
| 85 | 73 | ||
| 86 | (defun org-babel-prep-session:ruby (session params) | 74 | (defun org-babel-prep-session:ruby (session params) |
| 87 | "Prepare SESSION according to the header arguments specified in PARAMS." | 75 | "Prepare SESSION according to the header arguments specified in PARAMS." |
| 88 | ;; (message "params=%S" params) ;; debugging | 76 | ;; (message "params=%S" params) ;; debugging |
| 89 | (let* ((session (org-babel-ruby-initiate-session session)) | 77 | (let* ((session (org-babel-ruby-initiate-session session)) |
| 90 | (vars (org-babel-ref-variables params)) | 78 | (var-lines (org-babel-variable-assignments:ruby params))) |
| 91 | (var-lines (mapcar ;; define any variables | ||
| 92 | (lambda (pair) | ||
| 93 | (format "%s=%s" | ||
| 94 | (car pair) | ||
| 95 | (org-babel-ruby-var-to-ruby (cdr pair)))) | ||
| 96 | vars))) | ||
| 97 | (org-babel-comint-in-buffer session | 79 | (org-babel-comint-in-buffer session |
| 98 | (sit-for .5) (goto-char (point-max)) | 80 | (sit-for .5) (goto-char (point-max)) |
| 99 | (mapc (lambda (var) | 81 | (mapc (lambda (var) |
| @@ -113,6 +95,15 @@ This function is called by `org-babel-execute-src-block'." | |||
| 113 | 95 | ||
| 114 | ;; helper functions | 96 | ;; helper functions |
| 115 | 97 | ||
| 98 | (defun org-babel-variable-assignments:ruby (params) | ||
| 99 | "Return list of ruby statements assigning the block's variables" | ||
| 100 | (mapcar | ||
| 101 | (lambda (pair) | ||
| 102 | (format "%s=%s" | ||
| 103 | (car pair) | ||
| 104 | (org-babel-ruby-var-to-ruby (cdr pair)))) | ||
| 105 | (mapcar #'cdr (org-babel-get-header params :var)))) | ||
| 106 | |||
| 116 | (defun org-babel-ruby-var-to-ruby (var) | 107 | (defun org-babel-ruby-var-to-ruby (var) |
| 117 | "Convert VAR into a ruby variable. | 108 | "Convert VAR into a ruby variable. |
| 118 | Convert an elisp value into a string of ruby source code | 109 | Convert an elisp value into a string of ruby source code |
| @@ -186,12 +177,13 @@ return the value of the last statement in BODY, as elisp." | |||
| 186 | ;; external process evaluation | 177 | ;; external process evaluation |
| 187 | (case result-type | 178 | (case result-type |
| 188 | (output (org-babel-eval org-babel-ruby-command body)) | 179 | (output (org-babel-eval org-babel-ruby-command body)) |
| 189 | (value (let ((tmp-file (make-temp-file "org-babel-ruby-results-"))) | 180 | (value (let ((tmp-file (org-babel-temp-file "ruby-"))) |
| 190 | (org-babel-eval org-babel-ruby-command | 181 | (org-babel-eval |
| 191 | (format (if (member "pp" result-params) | 182 | org-babel-ruby-command |
| 192 | org-babel-ruby-pp-wrapper-method | 183 | (format (if (member "pp" result-params) |
| 193 | org-babel-ruby-wrapper-method) | 184 | org-babel-ruby-pp-wrapper-method |
| 194 | body tmp-file)) | 185 | org-babel-ruby-wrapper-method) |
| 186 | body (org-babel-process-file-name tmp-file 'noquote))) | ||
| 195 | ((lambda (raw) | 187 | ((lambda (raw) |
| 196 | (if (or (member "code" result-params) | 188 | (if (or (member "code" result-params) |
| 197 | (member "pp" result-params)) | 189 | (member "pp" result-params)) |
| @@ -221,7 +213,7 @@ return the value of the last statement in BODY, as elisp." | |||
| 221 | (if (or (member "code" result-params) (member "pp" result-params)) | 213 | (if (or (member "code" result-params) (member "pp" result-params)) |
| 222 | results | 214 | results |
| 223 | (org-babel-ruby-table-or-string results))) | 215 | (org-babel-ruby-table-or-string results))) |
| 224 | (let* ((tmp-file (make-temp-file "org-babel-ruby-results-")) | 216 | (let* ((tmp-file (org-babel-temp-file "ruby-")) |
| 225 | (ppp (or (member "code" result-params) | 217 | (ppp (or (member "code" result-params) |
| 226 | (member "pp" result-params)))) | 218 | (member "pp" result-params)))) |
| 227 | (org-babel-comint-with-output | 219 | (org-babel-comint-with-output |
| @@ -233,10 +225,12 @@ return the value of the last statement in BODY, as elisp." | |||
| 233 | (append | 225 | (append |
| 234 | (list body) | 226 | (list body) |
| 235 | (if (not ppp) | 227 | (if (not ppp) |
| 236 | (list (format org-babel-ruby-f-write tmp-file)) | 228 | (list (format org-babel-ruby-f-write |
| 229 | (org-babel-process-file-name tmp-file 'noquote))) | ||
| 237 | (list | 230 | (list |
| 238 | "results=_" "require 'pp'" "orig_out = $stdout" | 231 | "results=_" "require 'pp'" "orig_out = $stdout" |
| 239 | (format org-babel-ruby-pp-f-write tmp-file))) | 232 | (format org-babel-ruby-pp-f-write |
| 233 | (org-babel-process-file-name tmp-file 'noquote)))) | ||
| 240 | (list org-babel-ruby-eoe-indicator))) | 234 | (list org-babel-ruby-eoe-indicator))) |
| 241 | (comint-send-input nil t)) | 235 | (comint-send-input nil t)) |
| 242 | (org-babel-eval-read-file tmp-file))))))) | 236 | (org-babel-eval-read-file tmp-file))))))) |
diff --git a/lisp/org/ob-sass.el b/lisp/org/ob-sass.el index 87f9ff46ecc..7f241e0320d 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.01 | 8 | ;; Version: 7.3 |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -43,20 +43,19 @@ | |||
| 43 | 43 | ||
| 44 | (defvar org-babel-default-header-args:sass '()) | 44 | (defvar org-babel-default-header-args:sass '()) |
| 45 | 45 | ||
| 46 | (defun org-babel-expand-body:sass (body params &optional processed-params) | ||
| 47 | "Expand BODY according to PARAMS, return the expanded body." body) | ||
| 48 | |||
| 49 | (defun org-babel-execute:sass (body params) | 46 | (defun org-babel-execute:sass (body params) |
| 50 | "Execute a block of Sass code with Babel. | 47 | "Execute a block of Sass code with Babel. |
| 51 | This function is called by `org-babel-execute-src-block'." | 48 | This function is called by `org-babel-execute-src-block'." |
| 52 | (let* ((result-params (split-string (or (cdr (assoc :results params)) ""))) | 49 | (let* ((result-params (split-string (or (cdr (assoc :results params)) ""))) |
| 53 | (file (cdr (assoc :file params))) | 50 | (file (cdr (assoc :file params))) |
| 54 | (out-file (or file (make-temp-file "org-babel-sass-out"))) | 51 | (out-file (or file (org-babel-temp-file "sass-out-"))) |
| 55 | (cmdline (cdr (assoc :cmdline params))) | 52 | (cmdline (cdr (assoc :cmdline params))) |
| 56 | (in-file (make-temp-file "org-babel-sass-in")) | 53 | (in-file (org-babel-temp-file "sass-in-")) |
| 57 | (cmd (concat "sass " (or cmdline "") in-file " " out-file))) | 54 | (cmd (concat "sass " (or cmdline "") |
| 55 | " " (org-babel-process-file-name in-file) | ||
| 56 | " " (org-babel-process-file-name out-file)))) | ||
| 58 | (with-temp-file in-file | 57 | (with-temp-file in-file |
| 59 | (insert (org-babel-expand-body:sass body params))) (shell-command cmd) | 58 | (insert (org-babel-expand-body:generic body params))) (shell-command cmd) |
| 60 | (or file (with-temp-buffer (insert-file-contents out-file) (buffer-string))))) | 59 | (or file (with-temp-buffer (insert-file-contents out-file) (buffer-string))))) |
| 61 | 60 | ||
| 62 | (defun org-babel-prep-session:sass (session params) | 61 | (defun org-babel-prep-session:sass (session params) |
diff --git a/lisp/org/ob-scheme.el b/lisp/org/ob-scheme.el new file mode 100644 index 00000000000..943deadc02c --- /dev/null +++ b/lisp/org/ob-scheme.el | |||
| @@ -0,0 +1,139 @@ | |||
| 1 | ;;; ob-scheme.el --- org-babel functions for Scheme | ||
| 2 | |||
| 3 | ;; Copyright (C) 2010 Free Software Foundation | ||
| 4 | |||
| 5 | ;; Author: Eric Schulte | ||
| 6 | ;; Keywords: literate programming, reproducible research, scheme | ||
| 7 | ;; Homepage: http://orgmode.org | ||
| 8 | ;; Version: 7.3 | ||
| 9 | |||
| 10 | ;;; License: | ||
| 11 | |||
| 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 | ||
| 14 | ;; the Free Software Foundation; either version 3, or (at your option) | ||
| 15 | ;; any later version. | ||
| 16 | ;; | ||
| 17 | ;; This program is distributed in the hope that it will be useful, | ||
| 18 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 20 | ;; GNU General Public License for more details. | ||
| 21 | ;; | ||
| 22 | ;; You should have received a copy of the GNU General Public License | ||
| 23 | ;; along with GNU Emacs; 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. | ||
| 26 | |||
| 27 | ;;; Commentary: | ||
| 28 | |||
| 29 | ;; Now working with SBCL for both session and external evaluation. | ||
| 30 | ;; | ||
| 31 | ;; This certainly isn't optimally robust, but it seems to be working | ||
| 32 | ;; for the basic use cases. | ||
| 33 | |||
| 34 | ;;; Requirements: | ||
| 35 | |||
| 36 | ;; - a working scheme implementation | ||
| 37 | ;; (e.g. guile http://www.gnu.org/software/guile/guile.html) | ||
| 38 | ;; | ||
| 39 | ;; - for session based evaluation cmuscheme.el is required which is | ||
| 40 | ;; included in Emacs | ||
| 41 | |||
| 42 | ;;; Code: | ||
| 43 | (require 'ob) | ||
| 44 | (require 'ob-ref) | ||
| 45 | (require 'ob-comint) | ||
| 46 | (require 'ob-eval) | ||
| 47 | (eval-when-compile (require 'cl)) | ||
| 48 | |||
| 49 | (declare-function run-scheme "ext:cmuscheme" (cmd)) | ||
| 50 | |||
| 51 | (defvar org-babel-default-header-args:scheme '() | ||
| 52 | "Default header arguments for scheme code blocks.") | ||
| 53 | |||
| 54 | (defvar org-babel-scheme-eoe "org-babel-scheme-eoe" | ||
| 55 | "String to indicate that evaluation has completed.") | ||
| 56 | |||
| 57 | (defcustom org-babel-scheme-cmd "guile" | ||
| 58 | "Name of command used to evaluate scheme blocks." | ||
| 59 | :group 'org-babel | ||
| 60 | :type 'string) | ||
| 61 | |||
| 62 | (defun org-babel-expand-body:scheme (body params) | ||
| 63 | "Expand BODY according to PARAMS, return the expanded body." | ||
| 64 | (let ((vars (mapcar #'cdr (org-babel-get-header params :var)))) | ||
| 65 | (if (> (length vars) 0) | ||
| 66 | (concat "(let (" | ||
| 67 | (mapconcat | ||
| 68 | (lambda (var) (format "%S" (print `(,(car var) ',(cdr var))))) | ||
| 69 | vars "\n ") | ||
| 70 | ")\n" body ")") | ||
| 71 | body))) | ||
| 72 | |||
| 73 | (defvar scheme-program-name) | ||
| 74 | (defun org-babel-execute:scheme (body params) | ||
| 75 | "Execute a block of Scheme code with org-babel. | ||
| 76 | This function is called by `org-babel-execute-src-block'" | ||
| 77 | (let* ((result-type (cdr (assoc :result-type params))) | ||
| 78 | (org-babel-scheme-cmd (or (cdr (assoc :scheme params)) | ||
| 79 | org-babel-scheme-cmd)) | ||
| 80 | (full-body (org-babel-expand-body:scheme body params))) | ||
| 81 | (read | ||
| 82 | (if (not (string= (cdr (assoc :session params)) "none")) | ||
| 83 | ;; session evaluation | ||
| 84 | (let ((session (org-babel-prep-session:scheme | ||
| 85 | (cdr (assoc :session params)) params))) | ||
| 86 | (org-babel-comint-with-output | ||
| 87 | (session (format "%S" org-babel-scheme-eoe) t body) | ||
| 88 | (mapc | ||
| 89 | (lambda (line) | ||
| 90 | (insert (org-babel-chomp line)) (comint-send-input nil t)) | ||
| 91 | (list body (format "%S" org-babel-scheme-eoe))))) | ||
| 92 | ;; external evaluation | ||
| 93 | (let ((script-file (org-babel-temp-file "scheme-script-"))) | ||
| 94 | (with-temp-file script-file | ||
| 95 | (insert | ||
| 96 | ;; return the value or the output | ||
| 97 | (if (string= result-type "value") | ||
| 98 | (format "(display %s)" full-body) | ||
| 99 | full-body))) | ||
| 100 | (org-babel-eval | ||
| 101 | (format "%s %s" org-babel-scheme-cmd | ||
| 102 | (org-babel-process-file-name script-file)) "")))))) | ||
| 103 | |||
| 104 | (defun org-babel-prep-session:scheme (session params) | ||
| 105 | "Prepare SESSION according to the header arguments specified in PARAMS." | ||
| 106 | (let* ((session (org-babel-scheme-initiate-session session)) | ||
| 107 | (vars (mapcar #'cdr (org-babel-get-header params :var))) | ||
| 108 | (var-lines | ||
| 109 | (mapcar | ||
| 110 | (lambda (var) (format "%S" (print `(define ,(car var) ',(cdr var))))) | ||
| 111 | vars))) | ||
| 112 | (when session | ||
| 113 | (org-babel-comint-in-buffer session | ||
| 114 | (sit-for .5) (goto-char (point-max)) | ||
| 115 | (mapc (lambda (var) | ||
| 116 | (insert var) (comint-send-input nil t) | ||
| 117 | (org-babel-comint-wait-for-output session) | ||
| 118 | (sit-for .1) (goto-char (point-max))) var-lines))) | ||
| 119 | session)) | ||
| 120 | |||
| 121 | (defun org-babel-scheme-initiate-session (&optional session) | ||
| 122 | "If there is not a current inferior-process-buffer in SESSION | ||
| 123 | then create. Return the initialized session." | ||
| 124 | (require 'cmuscheme) | ||
| 125 | (unless (string= session "none") | ||
| 126 | (let ((session-buffer (save-window-excursion | ||
| 127 | (run-scheme org-babel-scheme-cmd) | ||
| 128 | (rename-buffer session) | ||
| 129 | (current-buffer)))) | ||
| 130 | (if (org-babel-comint-buffer-livep session-buffer) | ||
| 131 | (progn (sit-for .25) session-buffer) | ||
| 132 | (sit-for .5) | ||
| 133 | (org-babel-scheme-initiate-session session))))) | ||
| 134 | |||
| 135 | (provide 'ob-scheme) | ||
| 136 | |||
| 137 | ;; arch-tag: 6b2fe76f-4b25-4e87-ad1c-225b2f282a71 | ||
| 138 | |||
| 139 | ;;; ob-scheme.el ends here | ||
diff --git a/lisp/org/ob-screen.el b/lisp/org/ob-screen.el index 7e575aa02ec..f877f0d147b 100644 --- a/lisp/org/ob-screen.el +++ b/lisp/org/ob-screen.el | |||
| @@ -5,7 +5,7 @@ | |||
| 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.01 | 8 | ;; Version: 7.3 |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -45,28 +45,21 @@ In case you want to use a different screen than one selected by your $PATH") | |||
| 45 | '((:results . "silent") (:session . "default") (:cmd . "sh") (:terminal . "xterm")) | 45 | '((:results . "silent") (:session . "default") (:cmd . "sh") (:terminal . "xterm")) |
| 46 | "Default arguments to use when running screen source blocks.") | 46 | "Default arguments to use when running screen source blocks.") |
| 47 | 47 | ||
| 48 | (defun org-babel-expand-body:screen (body params &optional processed-params) | ||
| 49 | "Expand BODY according to PARAMS, return the expanded body." body) | ||
| 50 | |||
| 51 | (defun org-babel-execute:screen (body params) | 48 | (defun org-babel-execute:screen (body params) |
| 52 | "Send a block of code via screen to a terminal using Babel. | 49 | "Send a block of code via screen to a terminal using Babel. |
| 53 | \"default\" session is be used when none is specified." | 50 | \"default\" session is used when none is specified." |
| 54 | (message "Sending source code block to interactive terminal session...") | 51 | (message "Sending source code block to interactive terminal session...") |
| 55 | (save-window-excursion | 52 | (save-window-excursion |
| 56 | (let* ((processed-params (org-babel-process-params params)) | 53 | (let* ((session (cdr (assoc :session params))) |
| 57 | (session (nth 0 processed-params)) | ||
| 58 | (socket (org-babel-screen-session-socketname session))) | 54 | (socket (org-babel-screen-session-socketname session))) |
| 59 | (unless socket (org-babel-prep-session:screen session params)) | 55 | (unless socket (org-babel-prep-session:screen session params)) |
| 60 | (org-babel-screen-session-execute-string | 56 | (org-babel-screen-session-execute-string |
| 61 | session (org-babel-expand-body:screen body params))))) | 57 | session (org-babel-expand-body:generic body params))))) |
| 62 | 58 | ||
| 63 | (defun org-babel-prep-session:screen (session params) | 59 | (defun org-babel-prep-session:screen (session params) |
| 64 | "Prepare SESSION according to the header arguments specified in PARAMS." | 60 | "Prepare SESSION according to the header arguments specified in PARAMS." |
| 65 | (let* ((processed-params (org-babel-process-params params)) | 61 | (let* ((session (cdr (assoc :session params))) |
| 66 | (session (nth 0 processed-params)) | ||
| 67 | (vars (nth 1 processed-params)) | ||
| 68 | (socket (org-babel-screen-session-socketname session)) | 62 | (socket (org-babel-screen-session-socketname session)) |
| 69 | (vars (org-babel-ref-variables params)) | ||
| 70 | (cmd (cdr (assoc :cmd params))) | 63 | (cmd (cdr (assoc :cmd params))) |
| 71 | (terminal (cdr (assoc :terminal params))) | 64 | (terminal (cdr (assoc :terminal params))) |
| 72 | (process-name (concat "org-babel: terminal (" session ")"))) | 65 | (process-name (concat "org-babel: terminal (" session ")"))) |
diff --git a/lisp/org/ob-sh.el b/lisp/org/ob-sh.el index 072bc91af1c..e86386426cd 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.01 | 8 | ;; Version: 7.3 |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -33,7 +33,10 @@ | |||
| 33 | (require 'shell) | 33 | (require 'shell) |
| 34 | (eval-when-compile (require 'cl)) | 34 | (eval-when-compile (require 'cl)) |
| 35 | 35 | ||
| 36 | (declare-function org-babel-ref-variables "ob-ref" (params)) | 36 | (declare-function org-babel-comint-in-buffer "ob-comint" (buffer &rest body)) |
| 37 | (declare-function org-babel-comint-wait-for-output "ob-comint" (buffer)) | ||
| 38 | (declare-function org-babel-comint-buffer-livep "ob-comint" (buffer)) | ||
| 39 | (declare-function org-babel-comint-with-output "ob-comint" (meta &rest body)) | ||
| 37 | (declare-function orgtbl-to-generic "org-table" (table params)) | 40 | (declare-function orgtbl-to-generic "org-table" (table params)) |
| 38 | 41 | ||
| 39 | (defvar org-babel-default-header-args:sh '()) | 42 | (defvar org-babel-default-header-args:sh '()) |
| @@ -42,44 +45,25 @@ | |||
| 42 | "Command used to invoke a shell. | 45 | "Command used to invoke a shell. |
| 43 | This will be passed to `shell-command-on-region'") | 46 | This will be passed to `shell-command-on-region'") |
| 44 | 47 | ||
| 45 | (defun org-babel-expand-body:sh (body params &optional processed-params) | ||
| 46 | "Expand BODY according to PARAMS, return the expanded body." | ||
| 47 | (let ((vars (nth 1 (or processed-params (org-babel-process-params params)))) | ||
| 48 | (sep (cdr (assoc :separator params)))) | ||
| 49 | (concat | ||
| 50 | (mapconcat ;; define any variables | ||
| 51 | (lambda (pair) | ||
| 52 | (format "%s=%s" | ||
| 53 | (car pair) | ||
| 54 | (org-babel-sh-var-to-sh (cdr pair) sep))) | ||
| 55 | vars "\n") "\n" body "\n\n"))) | ||
| 56 | |||
| 57 | (defun org-babel-execute:sh (body params) | 48 | (defun org-babel-execute:sh (body params) |
| 58 | "Execute a block of Shell commands with Babel. | 49 | "Execute a block of Shell commands with Babel. |
| 59 | This function is called by `org-babel-execute-src-block'." | 50 | This function is called by `org-babel-execute-src-block'." |
| 60 | (let* ((processed-params (org-babel-process-params params)) | 51 | (let* ((session (org-babel-sh-initiate-session |
| 61 | (session (org-babel-sh-initiate-session (nth 0 processed-params))) | 52 | (cdr (assoc :session params)))) |
| 62 | (result-params (nth 2 processed-params)) | 53 | (result-params (cdr (assoc :result-params params))) |
| 63 | (full-body (org-babel-expand-body:sh | 54 | (full-body (org-babel-expand-body:generic |
| 64 | body params processed-params))) | 55 | body params (org-babel-variable-assignments:sh params)))) |
| 65 | (org-babel-reassemble-table | 56 | (org-babel-reassemble-table |
| 66 | (org-babel-sh-evaluate session full-body result-params) | 57 | (org-babel-sh-evaluate session full-body result-params) |
| 67 | (org-babel-pick-name | 58 | (org-babel-pick-name |
| 68 | (nth 4 processed-params) (cdr (assoc :colnames params))) | 59 | (cdr (assoc :colname-names params)) (cdr (assoc :colnames params))) |
| 69 | (org-babel-pick-name | 60 | (org-babel-pick-name |
| 70 | (nth 5 processed-params) (cdr (assoc :rownames params)))))) | 61 | (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params)))))) |
| 71 | 62 | ||
| 72 | (defun org-babel-prep-session:sh (session params) | 63 | (defun org-babel-prep-session:sh (session params) |
| 73 | "Prepare SESSION according to the header arguments specified in PARAMS." | 64 | "Prepare SESSION according to the header arguments specified in PARAMS." |
| 74 | (let* ((session (org-babel-sh-initiate-session session)) | 65 | (let* ((session (org-babel-sh-initiate-session session)) |
| 75 | (vars (org-babel-ref-variables params)) | 66 | (var-lines (org-babel-variable-assignments:sh params))) |
| 76 | (sep (cdr (assoc :separator params))) | ||
| 77 | (var-lines (mapcar ;; define any variables | ||
| 78 | (lambda (pair) | ||
| 79 | (format "%s=%s" | ||
| 80 | (car pair) | ||
| 81 | (org-babel-sh-var-to-sh (cdr pair) sep))) | ||
| 82 | vars))) | ||
| 83 | (org-babel-comint-in-buffer session | 67 | (org-babel-comint-in-buffer session |
| 84 | (mapc (lambda (var) | 68 | (mapc (lambda (var) |
| 85 | (insert var) (comint-send-input nil t) | 69 | (insert var) (comint-send-input nil t) |
| @@ -97,6 +81,16 @@ This function is called by `org-babel-execute-src-block'." | |||
| 97 | 81 | ||
| 98 | ;; helper functions | 82 | ;; helper functions |
| 99 | 83 | ||
| 84 | (defun org-babel-variable-assignments:sh (params) | ||
| 85 | "Return list of shell statements assigning the block's variables" | ||
| 86 | (let ((sep (cdr (assoc :separator params)))) | ||
| 87 | (mapcar | ||
| 88 | (lambda (pair) | ||
| 89 | (format "%s=%s" | ||
| 90 | (car pair) | ||
| 91 | (org-babel-sh-var-to-sh (cdr pair) sep))) | ||
| 92 | (mapcar #'cdr (org-babel-get-header params :var))))) | ||
| 93 | |||
| 100 | (defun org-babel-sh-var-to-sh (var &optional sep) | 94 | (defun org-babel-sh-var-to-sh (var &optional sep) |
| 101 | "Convert an elisp value to a shell variable. | 95 | "Convert an elisp value to a shell variable. |
| 102 | Convert an elisp var into a string of shell commands specifying a | 96 | Convert an elisp var into a string of shell commands specifying a |
| @@ -108,7 +102,8 @@ var of the same value." | |||
| 108 | (org-babel-sh-var-to-sh el sep)))) | 102 | (org-babel-sh-var-to-sh el sep)))) |
| 109 | (format "$(cat <<BABEL_TABLE\n%s\nBABEL_TABLE\n)" | 103 | (format "$(cat <<BABEL_TABLE\n%s\nBABEL_TABLE\n)" |
| 110 | (orgtbl-to-generic | 104 | (orgtbl-to-generic |
| 111 | (deep-string var) (list :sep (or sep "\t"))))) | 105 | (deep-string (if (listp (car var)) var (list var))) |
| 106 | (list :sep (or sep "\t"))))) | ||
| 112 | (if (stringp var) | 107 | (if (stringp var) |
| 113 | (if (string-match "[\n\r]" var) | 108 | (if (string-match "[\n\r]" var) |
| 114 | (format "$(cat <<BABEL_STRING\n%s\nBABEL_STRING\n)" var) | 109 | (format "$(cat <<BABEL_STRING\n%s\nBABEL_STRING\n)" var) |
| @@ -148,29 +143,29 @@ If RESULT-TYPE equals 'output then return a list of the outputs | |||
| 148 | of the statements in BODY, if RESULT-TYPE equals 'value then | 143 | of the statements in BODY, if RESULT-TYPE equals 'value then |
| 149 | return the value of the last statement in BODY." | 144 | return the value of the last statement in BODY." |
| 150 | ((lambda (results) | 145 | ((lambda (results) |
| 151 | (if (or (member "scalar" result-params) | 146 | (when results |
| 152 | (member "output" result-params)) | 147 | (if (or (member "scalar" result-params) |
| 153 | results | 148 | (member "output" result-params)) |
| 154 | (let ((tmp-file (make-temp-file "org-babel-sh"))) | 149 | results |
| 155 | (with-temp-file tmp-file (insert results)) | 150 | (let ((tmp-file (org-babel-temp-file "sh-"))) |
| 156 | (org-babel-import-elisp-from-file tmp-file)))) | 151 | (with-temp-file tmp-file (insert results)) |
| 152 | (org-babel-import-elisp-from-file tmp-file))))) | ||
| 157 | (if (not session) | 153 | (if (not session) |
| 158 | (org-babel-eval org-babel-sh-command (org-babel-trim body)) | 154 | (org-babel-eval org-babel-sh-command (org-babel-trim body)) |
| 159 | (let ((tmp-file (make-temp-file "org-babel-sh"))) | 155 | (mapconcat |
| 160 | (mapconcat | 156 | #'org-babel-sh-strip-weird-long-prompt |
| 161 | #'org-babel-sh-strip-weird-long-prompt | 157 | (mapcar |
| 162 | (mapcar | 158 | #'org-babel-trim |
| 163 | #'org-babel-trim | 159 | (butlast |
| 164 | (butlast | 160 | (org-babel-comint-with-output |
| 165 | (org-babel-comint-with-output | 161 | (session org-babel-sh-eoe-output t body) |
| 166 | (session org-babel-sh-eoe-output t body) | 162 | (mapc |
| 167 | (mapc | 163 | (lambda (line) |
| 168 | (lambda (line) | 164 | (insert line) (comint-send-input nil t) (sleep-for 0.25)) |
| 169 | (insert line) (comint-send-input nil t) (sleep-for 0.25)) | 165 | (append |
| 170 | (append | 166 | (split-string (org-babel-trim body) "\n") |
| 171 | (split-string (org-babel-trim body) "\n") | 167 | (list org-babel-sh-eoe-indicator)))) |
| 172 | (list org-babel-sh-eoe-indicator)))) | 168 | 2)) "\n")))) |
| 173 | 2)) "\n"))))) | ||
| 174 | 169 | ||
| 175 | (defun org-babel-sh-strip-weird-long-prompt (string) | 170 | (defun org-babel-sh-strip-weird-long-prompt (string) |
| 176 | "Remove prompt cruft from a string of shell output." | 171 | "Remove prompt cruft from a string of shell output." |
diff --git a/lisp/org/ob-sql.el b/lisp/org/ob-sql.el index 184c755f7b8..78e8a3b4377 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.01 | 8 | ;; Version: 7.3 |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -50,33 +50,37 @@ | |||
| 50 | 50 | ||
| 51 | (defvar org-babel-default-header-args:sql '()) | 51 | (defvar org-babel-default-header-args:sql '()) |
| 52 | 52 | ||
| 53 | (defun org-babel-expand-body:sql (body params &optional processed-params) | ||
| 54 | "Expand BODY according to PARAMS, return the expanded body." body) | ||
| 55 | |||
| 56 | (defun org-babel-execute:sql (body params) | 53 | (defun org-babel-execute:sql (body params) |
| 57 | "Execute a block of Sql code with Babel. | 54 | "Execute a block of Sql code with Babel. |
| 58 | This function is called by `org-babel-execute-src-block'." | 55 | This function is called by `org-babel-execute-src-block'." |
| 59 | (let* ((result-params (split-string (or (cdr (assoc :results params)) ""))) | 56 | (let* ((result-params (cdr (assoc :result-params params))) |
| 60 | (processed-params (org-babel-process-params params)) | ||
| 61 | (cmdline (cdr (assoc :cmdline params))) | 57 | (cmdline (cdr (assoc :cmdline params))) |
| 62 | (engine (cdr (assoc :engine params))) | 58 | (engine (cdr (assoc :engine params))) |
| 63 | (in-file (make-temp-file "org-babel-sql-in")) | 59 | (in-file (org-babel-temp-file "sql-in-")) |
| 64 | (out-file (or (cdr (assoc :out-file params)) | 60 | (out-file (or (cdr (assoc :out-file params)) |
| 65 | (make-temp-file "org-babel-sql-out"))) | 61 | (org-babel-temp-file "sql-out-"))) |
| 66 | (command (case (intern engine) | 62 | (command (case (intern engine) |
| 67 | ('mysql (format "mysql %s -e \"source %s\" > %s" | 63 | ('mysql (format "mysql %s -e \"source %s\" > %s" |
| 68 | (or cmdline "") in-file out-file)) | 64 | (or cmdline "") |
| 65 | (org-babel-process-file-name in-file) | ||
| 66 | (org-babel-process-file-name out-file))) | ||
| 67 | ('postgresql (format "psql -A -P footer=off -F \"\t\" -f %s -o %s %s" | ||
| 68 | (org-babel-process-file-name in-file) | ||
| 69 | (org-babel-process-file-name out-file) | ||
| 70 | (or cmdline ""))) | ||
| 69 | (t (error "no support for the %s sql engine" engine))))) | 71 | (t (error "no support for the %s sql engine" engine))))) |
| 70 | (with-temp-file in-file | 72 | (with-temp-file in-file |
| 71 | (insert (org-babel-expand-body:sql body params))) | 73 | (insert (org-babel-expand-body:generic body params))) |
| 72 | (message command) | 74 | (message command) |
| 73 | (shell-command command) | 75 | (shell-command command) |
| 74 | (with-temp-buffer | 76 | (with-temp-buffer |
| 75 | (org-table-import out-file nil) | 77 | (org-table-import out-file nil) |
| 76 | (org-babel-reassemble-table | 78 | (org-babel-reassemble-table |
| 77 | (org-table-to-lisp) | 79 | (org-table-to-lisp) |
| 78 | (org-babel-pick-name (nth 4 processed-params) (cdr (assoc :colnames params))) | 80 | (org-babel-pick-name (cdr (assoc :colname-names params)) |
| 79 | (org-babel-pick-name (nth 5 processed-params) (cdr (assoc :rownames params))))))) | 81 | (cdr (assoc :colnames params))) |
| 82 | (org-babel-pick-name (cdr (assoc :rowname-names params)) | ||
| 83 | (cdr (assoc :rownames params))))))) | ||
| 80 | 84 | ||
| 81 | 85 | ||
| 82 | (defun org-babel-prep-session:sql (session params) | 86 | (defun org-babel-prep-session:sql (session params) |
diff --git a/lisp/org/ob-sqlite.el b/lisp/org/ob-sqlite.el index 7d6930abd4b..c744e4334ec 100644 --- a/lisp/org/ob-sqlite.el +++ b/lisp/org/ob-sqlite.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.01 | 8 | ;; Version: 7.3 |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -41,9 +41,10 @@ | |||
| 41 | '(db header echo bail csv column html line list separator nullvalue) | 41 | '(db header echo bail csv column html line list separator nullvalue) |
| 42 | "Sqlite specific header args.") | 42 | "Sqlite specific header args.") |
| 43 | 43 | ||
| 44 | (defun org-babel-expand-body:sqlite (body params &optional processed-params) | 44 | (defun org-babel-expand-body:sqlite (body params) |
| 45 | "Expand BODY according to the values of PARAMS." | ||
| 45 | (org-babel-sqlite-expand-vars | 46 | (org-babel-sqlite-expand-vars |
| 46 | body (or (nth 1 processed-params) (org-babel-ref-variables params)))) | 47 | body (mapcar #'cdr (org-babel-get-header params :var)))) |
| 47 | 48 | ||
| 48 | (defvar org-babel-sqlite3-command "sqlite3") | 49 | (defvar org-babel-sqlite3-command "sqlite3") |
| 49 | 50 | ||
| @@ -51,7 +52,7 @@ | |||
| 51 | "Execute a block of Sqlite code with Babel. | 52 | "Execute a block of Sqlite code with Babel. |
| 52 | This function is called by `org-babel-execute-src-block'." | 53 | This function is called by `org-babel-execute-src-block'." |
| 53 | (let ((result-params (split-string (or (cdr (assoc :results params)) ""))) | 54 | (let ((result-params (split-string (or (cdr (assoc :results params)) ""))) |
| 54 | (vars (org-babel-ref-variables params)) | 55 | (vars (org-babel-get-header params :var)) |
| 55 | (db (cdr (assoc :db params))) | 56 | (db (cdr (assoc :db params))) |
| 56 | (separator (cdr (assoc :separator params))) | 57 | (separator (cdr (assoc :separator params))) |
| 57 | (nullvalue (cdr (assoc :nullvalue params))) | 58 | (nullvalue (cdr (assoc :nullvalue params))) |
| @@ -70,10 +71,9 @@ This function is called by `org-babel-execute-src-block'." | |||
| 70 | (list | 71 | (list |
| 71 | (cons "body" ((lambda (sql-file) | 72 | (cons "body" ((lambda (sql-file) |
| 72 | (with-temp-file sql-file | 73 | (with-temp-file sql-file |
| 73 | (insert (org-babel-expand-body:sqlite | 74 | (insert (org-babel-expand-body:sqlite body params))) |
| 74 | body nil (list nil vars)))) | ||
| 75 | sql-file) | 75 | sql-file) |
| 76 | (make-temp-file "ob-sqlite-sql"))) | 76 | (org-babel-temp-file "sqlite-sql-"))) |
| 77 | (cons "cmd" org-babel-sqlite3-command) | 77 | (cons "cmd" org-babel-sqlite3-command) |
| 78 | (cons "header" (if headers-p "-header" "-noheader")) | 78 | (cons "header" (if headers-p "-header" "-noheader")) |
| 79 | (cons "separator" | 79 | (cons "separator" |
| @@ -117,8 +117,8 @@ This function is called by `org-babel-execute-src-block'." | |||
| 117 | el | 117 | el |
| 118 | (format "%S" el))))))) | 118 | (format "%S" el))))))) |
| 119 | data-file) | 119 | data-file) |
| 120 | (make-temp-file "ob-sqlite-data")) | 120 | (org-babel-temp-file "sqlite-data-")) |
| 121 | (format "%S" val))) | 121 | (if (stringp val) val (format "%S" val)))) |
| 122 | (cdr pair)) | 122 | (cdr pair)) |
| 123 | body))) | 123 | body))) |
| 124 | vars) | 124 | vars) |
diff --git a/lisp/org/ob-table.el b/lisp/org/ob-table.el index f1506550829..cdc7a6250fe 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.01 | 8 | ;; Version: 7.3 |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -79,13 +79,24 @@ references to source-code blocks, to force interpretation of a | |||
| 79 | cell's value as a string, prefix the identifier with two \"$\"s | 79 | cell's value as a string, prefix the identifier with two \"$\"s |
| 80 | rather than a single \"$\" (i.e. \"$$2\" instead of \"$2\" in the | 80 | rather than a single \"$\" (i.e. \"$$2\" instead of \"$2\" in the |
| 81 | example above." | 81 | example above." |
| 82 | (let ((variables (mapcar | 82 | (let* (quote |
| 83 | (lambda (var) | 83 | (variables |
| 84 | (if (and (= 3 (length var)) (eq (nth 1 var) '$)) | 84 | (mapcar |
| 85 | (list (car var) (format "\"%s\"" (last var))) | 85 | (lambda (var) |
| 86 | var)) | 86 | ;; ensure that all cells prefixed with $'s are strings |
| 87 | variables))) | 87 | (cons (car var) |
| 88 | (unless (stringp source-block) (setq source-block (symbol-name source-block))) | 88 | (delq nil (mapcar |
| 89 | (lambda (el) | ||
| 90 | (if (eq '$ el) | ||
| 91 | (setq quote t) | ||
| 92 | (prog1 (if quote | ||
| 93 | (format "\"%s\"" el) | ||
| 94 | (org-babel-clean-text-properties el)) | ||
| 95 | (setq quote nil)))) | ||
| 96 | (cdr var))))) | ||
| 97 | variables))) | ||
| 98 | (unless (stringp source-block) | ||
| 99 | (setq source-block (symbol-name source-block))) | ||
| 89 | (org-babel-table-truncate-at-newline ;; org-table cells can't be multi-line | 100 | (org-babel-table-truncate-at-newline ;; org-table cells can't be multi-line |
| 90 | (if (and source-block (> (length source-block) 0)) | 101 | (if (and source-block (> (length source-block) 0)) |
| 91 | (let ((params | 102 | (let ((params |
| @@ -93,13 +104,18 @@ example above." | |||
| 93 | (concat ":var results=" | 104 | (concat ":var results=" |
| 94 | ,source-block | 105 | ,source-block |
| 95 | "(" | 106 | "(" |
| 96 | (mapconcat (lambda (var-spec) | 107 | (mapconcat |
| 97 | (format "%S=%s" (nth 0 var-spec) (nth 1 var-spec))) | 108 | (lambda (var-spec) |
| 98 | ',variables ", ") | 109 | (if (> (length (cdr var-spec)) 1) |
| 110 | (format "%S='%S" | ||
| 111 | (car var-spec) | ||
| 112 | (mapcar #'read (cdr var-spec))) | ||
| 113 | (format "%S=%s" | ||
| 114 | (car var-spec) (cadr var-spec)))) | ||
| 115 | ',variables ", ") | ||
| 99 | ")"))))) | 116 | ")"))))) |
| 100 | (org-babel-execute-src-block | 117 | (org-babel-execute-src-block |
| 101 | nil (list "emacs-lisp" "results" | 118 | nil (list "emacs-lisp" "results" params) '((:results . "silent")))) |
| 102 | (org-babel-merge-params '((:results . "silent")) params)))) | ||
| 103 | "")))) | 119 | "")))) |
| 104 | 120 | ||
| 105 | (provide 'ob-table) | 121 | (provide 'ob-table) |
diff --git a/lisp/org/ob-tangle.el b/lisp/org/ob-tangle.el index 85f69ede357..e197ff37d36 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.01 | 8 | ;; Version: 7.3 |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -34,7 +34,11 @@ | |||
| 34 | 34 | ||
| 35 | (declare-function org-link-escape "org" (text &optional table)) | 35 | (declare-function org-link-escape "org" (text &optional table)) |
| 36 | (declare-function org-heading-components "org" ()) | 36 | (declare-function org-heading-components "org" ()) |
| 37 | (declare-function org-back-to-heading "org" (invisible-ok)) | ||
| 38 | (declare-function org-fill-template "org" (template alist)) | ||
| 39 | (declare-function org-babel-update-block-body "org" (new-body)) | ||
| 37 | 40 | ||
| 41 | ;;;###autoload | ||
| 38 | (defcustom org-babel-tangle-lang-exts | 42 | (defcustom org-babel-tangle-lang-exts |
| 39 | '(("emacs-lisp" . "el")) | 43 | '(("emacs-lisp" . "el")) |
| 40 | "Alist mapping languages to their file extensions. | 44 | "Alist mapping languages to their file extensions. |
| @@ -53,18 +57,66 @@ then the name of the language is used." | |||
| 53 | :group 'org-babel | 57 | :group 'org-babel |
| 54 | :type 'hook) | 58 | :type 'hook) |
| 55 | 59 | ||
| 60 | (defcustom org-babel-pre-tangle-hook '(save-buffer) | ||
| 61 | "Hook run at the beginning of `org-babel-tangle'." | ||
| 62 | :group 'org-babel | ||
| 63 | :type 'hook) | ||
| 64 | |||
| 65 | (defcustom org-babel-tangle-pad-newline t | ||
| 66 | "Switch indicating whether to pad tangled code with newlines." | ||
| 67 | :group 'org-babel | ||
| 68 | :type 'boolean) | ||
| 69 | |||
| 70 | (defcustom org-babel-tangle-comment-format-beg "[[%link][%source-name]]" | ||
| 71 | "Format of inserted comments in tangled code files. | ||
| 72 | The following format strings can be used to insert special | ||
| 73 | information into the output using `org-fill-template'. | ||
| 74 | %start-line --- the line number at the start of the code block | ||
| 75 | %file --------- the file from which the code block was tangled | ||
| 76 | %link --------- Org-mode style link to the code block | ||
| 77 | %source-name -- name of the code block | ||
| 78 | |||
| 79 | Whether or not comments are inserted during tangling is | ||
| 80 | controlled by the :comments header argument." | ||
| 81 | :group 'org-babel | ||
| 82 | :type 'string) | ||
| 83 | |||
| 84 | (defcustom org-babel-tangle-comment-format-end "%source-name ends here" | ||
| 85 | "Format of inserted comments in tangled code files. | ||
| 86 | The following format strings can be used to insert special | ||
| 87 | information into the output using `org-fill-template'. | ||
| 88 | %start-line --- the line number at the start of the code block | ||
| 89 | %file --------- the file from which the code block was tangled | ||
| 90 | %link --------- Org-mode style link to the code block | ||
| 91 | %source-name -- name of the code block | ||
| 92 | |||
| 93 | Whether or not comments are inserted during tangling is | ||
| 94 | controlled by the :comments header argument." | ||
| 95 | :group 'org-babel | ||
| 96 | :type 'string) | ||
| 97 | |||
| 98 | (defun org-babel-find-file-noselect-refresh (file) | ||
| 99 | "Find file ensuring that the latest changes on disk are | ||
| 100 | represented in the file." | ||
| 101 | (find-file-noselect file) | ||
| 102 | (with-current-buffer (get-file-buffer file) | ||
| 103 | (revert-buffer t t t))) | ||
| 104 | |||
| 56 | (defmacro org-babel-with-temp-filebuffer (file &rest body) | 105 | (defmacro org-babel-with-temp-filebuffer (file &rest body) |
| 57 | "Open FILE into a temporary buffer execute BODY there like | 106 | "Open FILE into a temporary buffer execute BODY there like |
| 58 | `progn', then kill the FILE buffer returning the result of | 107 | `progn', then kill the FILE buffer returning the result of |
| 59 | evaluating BODY." | 108 | evaluating BODY." |
| 60 | (declare (indent 1)) | 109 | (declare (indent 1)) |
| 61 | (let ((temp-result (make-symbol "temp-result")) | 110 | (let ((temp-result (make-symbol "temp-result")) |
| 62 | (temp-file (make-symbol "temp-file"))) | 111 | (temp-file (make-symbol "temp-file")) |
| 63 | `(let (,temp-result ,temp-file) | 112 | (visited-p (make-symbol "visited-p"))) |
| 64 | (find-file ,file) | 113 | `(let (,temp-result ,temp-file |
| 65 | (setf ,temp-file (current-buffer)) | 114 | (,visited-p (get-file-buffer ,file))) |
| 66 | (setf ,temp-result (progn ,@body)) | 115 | (org-babel-find-file-noselect-refresh ,file) |
| 67 | (kill-buffer ,temp-file) | 116 | (setf ,temp-file (get-file-buffer ,file)) |
| 117 | (with-current-buffer ,temp-file | ||
| 118 | (setf ,temp-result (progn ,@body))) | ||
| 119 | (unless ,visited-p (kill-buffer ,temp-file)) | ||
| 68 | ,temp-result))) | 120 | ,temp-result))) |
| 69 | 121 | ||
| 70 | ;;;###autoload | 122 | ;;;###autoload |
| @@ -117,7 +169,7 @@ TARGET-FILE can be used to specify a default export file for all | |||
| 117 | source blocks. Optional argument LANG can be used to limit the | 169 | source blocks. Optional argument LANG can be used to limit the |
| 118 | exported source code blocks by language." | 170 | exported source code blocks by language." |
| 119 | (interactive) | 171 | (interactive) |
| 120 | (save-buffer) | 172 | (run-hooks 'org-babel-pre-tangle-hook) |
| 121 | (save-excursion | 173 | (save-excursion |
| 122 | (let ((block-counter 0) | 174 | (let ((block-counter 0) |
| 123 | (org-babel-default-header-args | 175 | (org-babel-default-header-args |
| @@ -142,7 +194,7 @@ exported source code blocks by language." | |||
| 142 | (mapc | 194 | (mapc |
| 143 | (lambda (spec) | 195 | (lambda (spec) |
| 144 | (flet ((get-spec (name) | 196 | (flet ((get-spec (name) |
| 145 | (cdr (assoc name (nth 2 spec))))) | 197 | (cdr (assoc name (nth 4 spec))))) |
| 146 | (let* ((tangle (get-spec :tangle)) | 198 | (let* ((tangle (get-spec :tangle)) |
| 147 | (she-bang ((lambda (sheb) (when (> (length sheb) 0) sheb)) | 199 | (she-bang ((lambda (sheb) (when (> (length sheb) 0) sheb)) |
| 148 | (get-spec :shebang))) | 200 | (get-spec :shebang))) |
| @@ -177,14 +229,15 @@ exported source code blocks by language." | |||
| 177 | (insert content) | 229 | (insert content) |
| 178 | (write-region nil nil file-name)))) | 230 | (write-region nil nil file-name)))) |
| 179 | ;; if files contain she-bangs, then make the executable | 231 | ;; if files contain she-bangs, then make the executable |
| 180 | (when she-bang (set-file-modes file-name ?\755)) | 232 | (when she-bang (set-file-modes file-name #o755)) |
| 181 | ;; update counter | 233 | ;; update counter |
| 182 | (setq block-counter (+ 1 block-counter)) | 234 | (setq block-counter (+ 1 block-counter)) |
| 183 | (add-to-list 'path-collector file-name))))) | 235 | (add-to-list 'path-collector file-name))))) |
| 184 | specs))) | 236 | specs))) |
| 185 | (org-babel-tangle-collect-blocks lang)) | 237 | (org-babel-tangle-collect-blocks lang)) |
| 186 | (message "tangled %d code block%s" block-counter | 238 | (message "tangled %d code block%s from %s" block-counter |
| 187 | (if (= block-counter 1) "" "s")) | 239 | (if (= block-counter 1) "" "s") |
| 240 | (file-name-nondirectory (buffer-file-name (current-buffer)))) | ||
| 188 | ;; run `org-babel-post-tangle-hook' in all tangled files | 241 | ;; run `org-babel-post-tangle-hook' in all tangled files |
| 189 | (when org-babel-post-tangle-hook | 242 | (when org-babel-post-tangle-hook |
| 190 | (mapc | 243 | (mapc |
| @@ -209,7 +262,7 @@ references." | |||
| 209 | (save-excursion (end-of-line 1) (forward-char 1) (point))))) | 262 | (save-excursion (end-of-line 1) (forward-char 1) (point))))) |
| 210 | 263 | ||
| 211 | (defvar org-stored-links) | 264 | (defvar org-stored-links) |
| 212 | (defun org-babel-tangle-collect-blocks (&optional lang) | 265 | (defun org-babel-tangle-collect-blocks (&optional language) |
| 213 | "Collect source blocks in the current Org-mode file. | 266 | "Collect source blocks in the current Org-mode file. |
| 214 | Return an association list of source-code block specifications of | 267 | Return an association list of source-code block specifications of |
| 215 | the form used by `org-babel-spec-to-string' grouped by language. | 268 | the form used by `org-babel-spec-to-string' grouped by language. |
| @@ -224,44 +277,69 @@ code blocks by language." | |||
| 224 | (setq current-heading new-heading)) | 277 | (setq current-heading new-heading)) |
| 225 | (setq block-counter (+ 1 block-counter)))) | 278 | (setq block-counter (+ 1 block-counter)))) |
| 226 | (replace-regexp-in-string "[ \t]" "-" | 279 | (replace-regexp-in-string "[ \t]" "-" |
| 227 | (nth 4 (org-heading-components)))) | 280 | (condition-case nil |
| 228 | (let* ((link (progn (call-interactively 'org-store-link) | 281 | (nth 4 (org-heading-components)) |
| 229 | (org-babel-clean-text-properties | 282 | (error (buffer-file-name))))) |
| 230 | (car (pop org-stored-links))))) | 283 | (let* ((start-line (save-restriction (widen) |
| 231 | (info (org-babel-get-src-block-info)) | 284 | (+ 1 (line-number-at-pos (point))))) |
| 232 | (source-name (intern (or (nth 4 info) | 285 | (file (buffer-file-name)) |
| 233 | (format "%s:%d" | 286 | (info (org-babel-get-src-block-info 'light)) |
| 234 | current-heading block-counter)))) | 287 | (src-lang (nth 0 info))) |
| 235 | (src-lang (nth 0 info)) | 288 | (unless (string= (cdr (assoc :tangle (nth 2 info))) "no") |
| 236 | (expand-cmd (intern (concat "org-babel-expand-body:" src-lang))) | 289 | (unless (and language (not (string= language src-lang))) |
| 237 | (params (nth 2 info)) | 290 | (let* ((info (org-babel-get-src-block-info)) |
| 238 | by-lang) | 291 | (params (nth 2 info)) |
| 239 | (unless (string= (cdr (assoc :tangle params)) "no") ;; skip | 292 | (link (progn (call-interactively 'org-store-link) |
| 240 | (unless (and lang (not (string= lang src-lang))) ;; limit by language | 293 | (org-babel-clean-text-properties |
| 241 | ;; add the spec for this block to blocks under it's language | 294 | (car (pop org-stored-links))))) |
| 242 | (setq by-lang (cdr (assoc src-lang blocks))) | 295 | (source-name |
| 243 | (setq blocks (delq (assoc src-lang blocks) blocks)) | 296 | (intern (or (nth 4 info) |
| 244 | (setq blocks | 297 | (format "%s:%d" |
| 245 | (cons | 298 | current-heading block-counter)))) |
| 246 | (cons src-lang | 299 | (expand-cmd |
| 247 | (cons (list link source-name params | 300 | (intern (concat "org-babel-expand-body:" src-lang))) |
| 248 | ((lambda (body) | 301 | (assignments-cmd |
| 249 | (if (assoc :no-expand params) | 302 | (intern (concat "org-babel-variable-assignments:" src-lang))) |
| 250 | body | 303 | (body |
| 251 | (funcall | 304 | ((lambda (body) |
| 252 | (if (fboundp expand-cmd) | 305 | (if (assoc :no-expand params) |
| 253 | expand-cmd | 306 | body |
| 254 | 'org-babel-expand-body:generic) | 307 | (if (fboundp expand-cmd) |
| 255 | body | 308 | (funcall expand-cmd body params) |
| 256 | params))) | 309 | (org-babel-expand-body:generic |
| 257 | (if (and (cdr (assoc :noweb params)) | 310 | body params |
| 258 | (string= | 311 | (and (fboundp assignments-cmd) |
| 259 | "yes" | 312 | (funcall assignments-cmd params)))))) |
| 260 | (cdr (assoc :noweb params)))) | 313 | (if (and (cdr (assoc :noweb params)) |
| 261 | (org-babel-expand-noweb-references | 314 | (let ((nowebs (split-string |
| 262 | info) | 315 | (cdr (assoc :noweb params))))) |
| 263 | (nth 1 info)))) | 316 | (or (member "yes" nowebs) |
| 264 | by-lang)) blocks)))))) | 317 | (member "tangle" nowebs)))) |
| 318 | (org-babel-expand-noweb-references info) | ||
| 319 | (nth 1 info)))) | ||
| 320 | (comment | ||
| 321 | (when (or (string= "both" (cdr (assoc :comments params))) | ||
| 322 | (string= "org" (cdr (assoc :comments params)))) | ||
| 323 | ;; from the previous heading or code-block end | ||
| 324 | (buffer-substring | ||
| 325 | (max (condition-case nil | ||
| 326 | (save-excursion | ||
| 327 | (org-back-to-heading t) (point)) | ||
| 328 | (error 0)) | ||
| 329 | (save-excursion | ||
| 330 | (re-search-backward | ||
| 331 | org-babel-src-block-regexp nil t) | ||
| 332 | (match-end 0))) | ||
| 333 | (point)))) | ||
| 334 | by-lang) | ||
| 335 | ;; add the spec for this block to blocks under it's language | ||
| 336 | (setq by-lang (cdr (assoc src-lang blocks))) | ||
| 337 | (setq blocks (delq (assoc src-lang blocks) blocks)) | ||
| 338 | (setq blocks (cons | ||
| 339 | (cons src-lang | ||
| 340 | (cons (list start-line file link | ||
| 341 | source-name params body comment) | ||
| 342 | by-lang)) blocks))))))) | ||
| 265 | ;; ensure blocks in the correct order | 343 | ;; ensure blocks in the correct order |
| 266 | (setq blocks | 344 | (setq blocks |
| 267 | (mapcar | 345 | (mapcar |
| @@ -276,22 +354,97 @@ source code file. This function uses `comment-region' which | |||
| 276 | assumes that the appropriate major-mode is set. SPEC has the | 354 | assumes that the appropriate major-mode is set. SPEC has the |
| 277 | form | 355 | form |
| 278 | 356 | ||
| 279 | (link source-name params body)" | 357 | (start-line file link source-name params body comment)" |
| 280 | (let ((link (nth 0 spec)) | 358 | (let* ((start-line (nth 0 spec)) |
| 281 | (source-name (nth 1 spec)) | 359 | (file (nth 1 spec)) |
| 282 | (body (nth 3 spec)) | 360 | (link (org-link-escape (nth 2 spec))) |
| 283 | (commentable (string= (cdr (assoc :comments (nth 2 spec))) "yes"))) | 361 | (source-name (nth 3 spec)) |
| 362 | (body (nth 5 spec)) | ||
| 363 | (comment (nth 6 spec)) | ||
| 364 | (comments (cdr (assoc :comments (nth 4 spec)))) | ||
| 365 | (link-p (or (string= comments "both") (string= comments "link") | ||
| 366 | (string= comments "yes"))) | ||
| 367 | (link-data (mapcar (lambda (el) | ||
| 368 | (cons (symbol-name el) | ||
| 369 | ((lambda (le) | ||
| 370 | (if (stringp le) le (format "%S" le))) | ||
| 371 | (eval el)))) | ||
| 372 | '(start-line file link source-name)))) | ||
| 284 | (flet ((insert-comment (text) | 373 | (flet ((insert-comment (text) |
| 285 | (when commentable | 374 | (let ((text (org-babel-trim text))) |
| 286 | (insert "\n") | 375 | (when (and comments (not (string= comments "no")) |
| 287 | (comment-region (point) | 376 | (> (length text) 0)) |
| 288 | (progn (insert text) (point))) | 377 | (when org-babel-tangle-pad-newline (insert "\n")) |
| 289 | (end-of-line nil) | 378 | (comment-region (point) (progn (insert text) (point))) |
| 290 | (insert "\n")))) | 379 | (end-of-line nil) (insert "\n"))))) |
| 291 | (insert-comment (format "[[%s][%s]]" (org-link-escape link) source-name)) | 380 | (when comment (insert-comment comment)) |
| 292 | (insert (format "\n%s\n" (replace-regexp-in-string | 381 | (when link-p |
| 293 | "^," "" (org-babel-chomp body)))) | 382 | (insert-comment |
| 294 | (insert-comment (format "%s ends here" source-name))))) | 383 | (org-fill-template org-babel-tangle-comment-format-beg link-data))) |
| 384 | (when org-babel-tangle-pad-newline (insert "\n")) | ||
| 385 | (insert | ||
| 386 | (format | ||
| 387 | "%s\n" | ||
| 388 | (replace-regexp-in-string | ||
| 389 | "^," "" | ||
| 390 | (org-babel-trim body (if org-src-preserve-indentation "[\f\n\r\v]"))))) | ||
| 391 | (when link-p | ||
| 392 | (insert-comment | ||
| 393 | (org-fill-template org-babel-tangle-comment-format-end link-data)))))) | ||
| 394 | |||
| 395 | ;; detangling functions | ||
| 396 | (defvar org-bracket-link-analytic-regexp) | ||
| 397 | (defun org-babel-detangle (&optional source-code-file) | ||
| 398 | "Propagate changes in source file back original to Org-mode file. | ||
| 399 | This requires that code blocks were tangled with link comments | ||
| 400 | which enable the original code blocks to be found." | ||
| 401 | (interactive) | ||
| 402 | (save-excursion | ||
| 403 | (when source-code-file (find-file source-code-file)) | ||
| 404 | (goto-char (point-min)) | ||
| 405 | (let ((counter 0) new-body end) | ||
| 406 | (while (re-search-forward org-bracket-link-analytic-regexp nil t) | ||
| 407 | (when (re-search-forward | ||
| 408 | (concat " " (regexp-quote (match-string 5)) " ends here")) | ||
| 409 | (setq end (match-end 0)) | ||
| 410 | (forward-line -1) | ||
| 411 | (save-excursion | ||
| 412 | (when (setq new-body (org-babel-tangle-jump-to-org)) | ||
| 413 | (org-babel-update-block-body new-body))) | ||
| 414 | (setq counter (+ 1 counter))) | ||
| 415 | (goto-char end)) | ||
| 416 | (prog1 counter (message "detangled %d code blocks" counter))))) | ||
| 417 | |||
| 418 | (defun org-babel-tangle-jump-to-org () | ||
| 419 | "Jump from a tangled code file to the related Org-mode file." | ||
| 420 | (interactive) | ||
| 421 | (let ((mid (point)) | ||
| 422 | target-buffer target-char | ||
| 423 | start end link path block-name body) | ||
| 424 | (save-window-excursion | ||
| 425 | (save-excursion | ||
| 426 | (unless (and (re-search-backward org-bracket-link-analytic-regexp nil t) | ||
| 427 | (setq start (point-at-eol)) | ||
| 428 | (setq link (match-string 0)) | ||
| 429 | (setq path (match-string 3)) | ||
| 430 | (setq block-name (match-string 5)) | ||
| 431 | (re-search-forward | ||
| 432 | (concat " " (regexp-quote block-name) " ends here") nil t) | ||
| 433 | (setq end (point-at-bol)) | ||
| 434 | (< start mid) (< mid end)) | ||
| 435 | (error "not in tangled code")) | ||
| 436 | (setq body (org-babel-trim (buffer-substring start end)))) | ||
| 437 | (when (string-match "::" path) | ||
| 438 | (setq path (substring path 0 (match-beginning 0)))) | ||
| 439 | (find-file path) (setq target-buffer (current-buffer)) | ||
| 440 | (goto-char start) (org-open-link-from-string link) | ||
| 441 | (if (string-match "[^ \t\n\r]:\\([[:digit:]]+\\)" block-name) | ||
| 442 | (org-babel-next-src-block | ||
| 443 | (string-to-number (match-string 1 block-name))) | ||
| 444 | (org-babel-goto-named-src-block block-name)) | ||
| 445 | (setq target-char (point))) | ||
| 446 | (pop-to-buffer target-buffer) | ||
| 447 | (prog1 body (goto-char target-char)))) | ||
| 295 | 448 | ||
| 296 | (provide 'ob-tangle) | 449 | (provide 'ob-tangle) |
| 297 | 450 | ||
diff --git a/lisp/org/ob.el b/lisp/org/ob.el index a58fb4eca8a..44557c6624a 100644 --- a/lisp/org/ob.el +++ b/lisp/org/ob.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.01 | 8 | ;; Version: 7.3 |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -40,28 +40,38 @@ | |||
| 40 | (declare-function tramp-dissect-file-name "tramp" (name &optional nodefault)) | 40 | (declare-function tramp-dissect-file-name "tramp" (name &optional nodefault)) |
| 41 | (declare-function tramp-file-name-user "tramp" (vec)) | 41 | (declare-function tramp-file-name-user "tramp" (vec)) |
| 42 | (declare-function tramp-file-name-host "tramp" (vec)) | 42 | (declare-function tramp-file-name-host "tramp" (vec)) |
| 43 | (declare-function with-parsed-tramp-file-name "tramp" (filename var &rest body)) | ||
| 43 | (declare-function org-icompleting-read "org" (&rest args)) | 44 | (declare-function org-icompleting-read "org" (&rest args)) |
| 44 | (declare-function org-edit-src-code "org-src" | 45 | (declare-function org-edit-src-code "org-src" |
| 45 | (&optional context code edit-buffer-name)) | 46 | (&optional context code edit-buffer-name quietp)) |
| 47 | (declare-function org-edit-src-exit "org-src" (&optional context)) | ||
| 46 | (declare-function org-open-at-point "org" (&optional in-emacs reference-buffer)) | 48 | (declare-function org-open-at-point "org" (&optional in-emacs reference-buffer)) |
| 49 | (declare-function org-save-outline-visibility "org" (use-markers &rest body)) | ||
| 50 | (declare-function org-outline-overlay-data "org" (&optional use-markers)) | ||
| 51 | (declare-function org-set-outline-overlay-data "org" (data)) | ||
| 47 | (declare-function org-narrow-to-subtree "org" ()) | 52 | (declare-function org-narrow-to-subtree "org" ()) |
| 48 | (declare-function org-entry-get "org" (pom property &optional inherit literal-nil)) | 53 | (declare-function org-entry-get "org" |
| 54 | (pom property &optional inherit literal-nil)) | ||
| 49 | (declare-function org-make-options-regexp "org" (kwds &optional extra)) | 55 | (declare-function org-make-options-regexp "org" (kwds &optional extra)) |
| 50 | (declare-function org-do-remove-indentation "org" (&optional n)) | 56 | (declare-function org-do-remove-indentation "org" (&optional n)) |
| 51 | (declare-function org-show-context "org" (&optional key)) | 57 | (declare-function org-show-context "org" (&optional key)) |
| 52 | (declare-function org-at-table-p "org" (&optional table-type)) | 58 | (declare-function org-at-table-p "org" (&optional table-type)) |
| 53 | (declare-function org-cycle "org" (&optional arg)) | 59 | (declare-function org-cycle "org" (&optional arg)) |
| 54 | (declare-function org-uniquify "org" (list)) | 60 | (declare-function org-uniquify "org" (list)) |
| 61 | (declare-function org-current-level "org" ()) | ||
| 55 | (declare-function org-table-import "org-table" (file arg)) | 62 | (declare-function org-table-import "org-table" (file arg)) |
| 56 | (declare-function org-add-hook "org-compat" (hook function &optional append local)) | 63 | (declare-function org-add-hook "org-compat" |
| 64 | (hook function &optional append local)) | ||
| 57 | (declare-function org-table-align "org-table" ()) | 65 | (declare-function org-table-align "org-table" ()) |
| 58 | (declare-function org-table-end "org-table" (&optional table-type)) | 66 | (declare-function org-table-end "org-table" (&optional table-type)) |
| 59 | (declare-function orgtbl-to-generic "org-table" (table params)) | 67 | (declare-function orgtbl-to-generic "org-table" (table params)) |
| 60 | (declare-function orgtbl-to-orgtbl "org-table" (table params)) | 68 | (declare-function orgtbl-to-orgtbl "org-table" (table params)) |
| 61 | (declare-function org-babel-lob-get-info "ob-lob" nil) | 69 | (declare-function org-babel-lob-get-info "ob-lob" nil) |
| 62 | (declare-function org-babel-ref-split-args "ob-ref" (arg-string)) | 70 | (declare-function org-babel-ref-split-args "ob-ref" (arg-string)) |
| 63 | (declare-function org-babel-ref-variables "ob-ref" (params)) | 71 | (declare-function org-babel-ref-parse "ob-ref" (assignment)) |
| 64 | (declare-function org-babel-ref-resolve-reference "ob-ref" (ref &optional params)) | 72 | (declare-function org-babel-ref-resolve "ob-ref" (ref)) |
| 73 | (declare-function org-babel-lob-execute-maybe "ob-lob" ()) | ||
| 74 | (declare-function org-number-sequence "org-compat" (from &optional to inc)) | ||
| 65 | 75 | ||
| 66 | (defgroup org-babel nil | 76 | (defgroup org-babel nil |
| 67 | "Code block evaluation and management in `org-mode' documents." | 77 | "Code block evaluation and management in `org-mode' documents." |
| @@ -100,8 +110,15 @@ remove code block execution from the C-c C-c keybinding." | |||
| 100 | "^[ \t]*#\\+\\(srcname\\|source\\|function\\):[ \t]*" | 110 | "^[ \t]*#\\+\\(srcname\\|source\\|function\\):[ \t]*" |
| 101 | "Regular expression used to match a source name line.") | 111 | "Regular expression used to match a source name line.") |
| 102 | 112 | ||
| 113 | (defvar org-babel-multi-line-header-regexp | ||
| 114 | "^[ \t]*#\\+headers?:[ \t]*\\([^\n]*\\)$" | ||
| 115 | "Regular expression used to match multi-line header arguments.") | ||
| 116 | |||
| 103 | (defvar org-babel-src-name-w-name-regexp | 117 | (defvar org-babel-src-name-w-name-regexp |
| 104 | (concat org-babel-src-name-regexp | 118 | (concat org-babel-src-name-regexp |
| 119 | "\\(" | ||
| 120 | org-babel-multi-line-header-regexp | ||
| 121 | "\\)*" | ||
| 105 | "\\([^ ()\f\t\n\r\v]+\\)\\(\(\\(.*\\)\)\\|\\)") | 122 | "\\([^ ()\f\t\n\r\v]+\\)\\(\(\\(.*\\)\)\\|\\)") |
| 106 | "Regular expression matching source name lines with a name.") | 123 | "Regular expression matching source name lines with a name.") |
| 107 | 124 | ||
| @@ -127,51 +144,54 @@ remove code block execution from the C-c C-c keybinding." | |||
| 127 | "{\\([^\f\n\r\v]+?\\)}\\)") | 144 | "{\\([^\f\n\r\v]+?\\)}\\)") |
| 128 | "Regexp used to identify inline src-blocks.") | 145 | "Regexp used to identify inline src-blocks.") |
| 129 | 146 | ||
| 130 | (defun org-babel-get-src-block-info (&optional header-vars-only) | 147 | (defun org-babel-get-header (params key &optional others) |
| 148 | "Select only header argument of type KEY from a list. | ||
| 149 | Optional argument OTHERS indicates that only the header that do | ||
| 150 | not match KEY should be returned." | ||
| 151 | (delq nil | ||
| 152 | (mapcar | ||
| 153 | (lambda (p) (when (funcall (if others #'not #'identity) (eq (car p) key)) p)) | ||
| 154 | params))) | ||
| 155 | |||
| 156 | (defun org-babel-get-src-block-info (&optional light) | ||
| 131 | "Get information on the current source block. | 157 | "Get information on the current source block. |
| 132 | 158 | ||
| 159 | Optional argument LIGHT does not resolve remote variable | ||
| 160 | references; a process which could likely result in the execution | ||
| 161 | of other code blocks. | ||
| 162 | |||
| 133 | Returns a list | 163 | Returns a list |
| 134 | (language body header-arguments-alist switches name function-args indent). | 164 | (language body header-arguments-alist switches name indent)." |
| 135 | Unless HEADER-VARS-ONLY is non-nil, any variable | 165 | (let ((case-fold-search t) head info name indent) |
| 136 | references provided in 'function call style' (i.e. in a | 166 | ;; full code block |
| 137 | parenthesised argument list following the src block name) are | ||
| 138 | added to the header-arguments-alist." | ||
| 139 | (let ((case-fold-search t) head info args indent) | ||
| 140 | (if (setq head (org-babel-where-is-src-block-head)) | 167 | (if (setq head (org-babel-where-is-src-block-head)) |
| 141 | (save-excursion | 168 | (save-excursion |
| 142 | (goto-char head) | 169 | (goto-char head) |
| 143 | (setq info (org-babel-parse-src-block-match)) | 170 | (setq info (org-babel-parse-src-block-match)) |
| 144 | (setq indent (car (last info))) | 171 | (setq indent (car (last info))) |
| 145 | (setq info (butlast info)) | 172 | (setq info (butlast info)) |
| 146 | (forward-line -1) | 173 | (while (and (forward-line -1) |
| 147 | (if (and (looking-at org-babel-src-name-w-name-regexp) | 174 | (looking-at org-babel-multi-line-header-regexp)) |
| 148 | (match-string 2)) | 175 | (setf (nth 2 info) |
| 149 | (progn | 176 | (org-babel-merge-params |
| 150 | (setq info (append info (list (org-babel-clean-text-properties | 177 | (org-babel-parse-header-arguments (match-string 1)) |
| 151 | (match-string 2))))) | 178 | (nth 2 info)))) |
| 152 | ;; Note that e.g. "name()" and "name( )" result in | 179 | (when (looking-at org-babel-src-name-w-name-regexp) |
| 153 | ;; ((:var . "")). We maintain that behaviour, and the | 180 | (setq name (org-babel-clean-text-properties (match-string 4))) |
| 154 | ;; resulting non-nil sixth element is relied upon in | 181 | (when (match-string 6) |
| 155 | ;; org-babel-exp-code to detect a functional-style | 182 | (setf (nth 2 info) ;; merge functional-syntax vars and header-args |
| 156 | ;; block in those cases. However, "name" without any | 183 | (org-babel-merge-params |
| 157 | ;; parentheses would result in the same thing, so we | 184 | (mapcar (lambda (ref) (cons :var ref)) |
| 158 | ;; explicitly avoid that. | 185 | (org-babel-ref-split-args (match-string 6))) |
| 159 | (if (setq args (match-string 4)) | 186 | (nth 2 info)))))) |
| 160 | (setq info | 187 | ;; inline source block |
| 161 | (append info (list | 188 | (when (save-excursion (re-search-backward "[ \f\t\n\r\v]" nil t) |
| 162 | (mapcar | 189 | (looking-at org-babel-inline-src-block-regexp)) |
| 163 | (lambda (ref) (cons :var ref)) | 190 | (setq info (org-babel-parse-inline-src-block-match)))) |
| 164 | (org-babel-ref-split-args args)))))) | 191 | ;; resolve variable references and add summary parameters |
| 165 | (unless header-vars-only | 192 | (when (and info (not light)) |
| 166 | (setf (nth 2 info) | 193 | (setf (nth 2 info) (org-babel-process-params (nth 2 info)))) |
| 167 | (org-babel-merge-params (nth 5 info) (nth 2 info))))) | 194 | (when info (append info (list name indent))))) |
| 168 | (setq info (append info (list nil nil)))) | ||
| 169 | (append info (list indent))) | ||
| 170 | (if (save-excursion ;; inline source block | ||
| 171 | (re-search-backward "[ \f\t\n\r\v]" nil t) | ||
| 172 | (looking-at org-babel-inline-src-block-regexp)) | ||
| 173 | (org-babel-parse-inline-src-block-match) | ||
| 174 | nil)))) | ||
| 175 | 195 | ||
| 176 | (defun org-babel-confirm-evaluate (info) | 196 | (defun org-babel-confirm-evaluate (info) |
| 177 | "Confirm evaluation of the code block INFO. | 197 | "Confirm evaluation of the code block INFO. |
| @@ -182,31 +202,42 @@ confirmation from the user. | |||
| 182 | 202 | ||
| 183 | Note disabling confirmation may result in accidental evaluation | 203 | Note disabling confirmation may result in accidental evaluation |
| 184 | of potentially harmful code." | 204 | of potentially harmful code." |
| 185 | (let* ((eval (cdr (assoc :eval (nth 2 info)))) | 205 | (let* ((eval (or (cdr (assoc :eval (nth 2 info))) |
| 206 | (when (assoc :noeval (nth 2 info)) "no"))) | ||
| 186 | (query (or (equal eval "query") | 207 | (query (or (equal eval "query") |
| 187 | (and (functionp org-confirm-babel-evaluate) | 208 | (if (functionp org-confirm-babel-evaluate) |
| 188 | (funcall org-confirm-babel-evaluate | 209 | (funcall org-confirm-babel-evaluate |
| 189 | (nth 0 info) (nth 1 info))) | 210 | (nth 0 info) (nth 1 info)) |
| 190 | org-confirm-babel-evaluate))) | 211 | org-confirm-babel-evaluate)))) |
| 191 | (when (or (equal eval "never") | 212 | (if (or (equal eval "never") (equal eval "no") |
| 192 | (and query | 213 | (and query |
| 193 | (not (yes-or-no-p | 214 | (not (yes-or-no-p |
| 194 | (format "Evaluate this%scode on your system? " | 215 | (format "Evaluate this%scode on your system? " |
| 195 | (if info (format " %s " (nth 0 info)) " ")))))) | 216 | (if info (format " %s " (nth 0 info)) " ")))))) |
| 196 | (error "evaluation aborted")))) | 217 | (prog1 nil (message "evaluation aborted")) |
| 218 | t))) | ||
| 197 | 219 | ||
| 198 | ;;;###autoload | 220 | ;;;###autoload |
| 221 | (defun org-babel-execute-safely-maybe () | ||
| 222 | (unless org-babel-no-eval-on-ctrl-c-ctrl-c | ||
| 223 | (org-babel-execute-maybe))) | ||
| 224 | |||
| 225 | (add-hook 'org-ctrl-c-ctrl-c-hook 'org-babel-execute-safely-maybe) | ||
| 226 | |||
| 227 | ;;;###autoload | ||
| 228 | (defun org-babel-execute-maybe () | ||
| 229 | (interactive) | ||
| 230 | (or (org-babel-execute-src-block-maybe) | ||
| 231 | (org-babel-lob-execute-maybe))) | ||
| 232 | |||
| 199 | (defun org-babel-execute-src-block-maybe () | 233 | (defun org-babel-execute-src-block-maybe () |
| 200 | "Conditionally execute a source block. | 234 | "Conditionally execute a source block. |
| 201 | Detect if this is context for a Babel src-block and if so | 235 | Detect if this is context for a Babel src-block and if so |
| 202 | then run `org-babel-execute-src-block'." | 236 | then run `org-babel-execute-src-block'." |
| 203 | (interactive) | 237 | (interactive) |
| 204 | (if (not org-babel-no-eval-on-ctrl-c-ctrl-c) | 238 | (let ((info (org-babel-get-src-block-info))) |
| 205 | (let ((info (org-babel-get-src-block-info))) | 239 | (if info |
| 206 | (if info | 240 | (progn (org-babel-execute-src-block current-prefix-arg info) t) nil))) |
| 207 | (progn (org-babel-execute-src-block current-prefix-arg info) t) nil)) | ||
| 208 | nil)) | ||
| 209 | (add-hook 'org-ctrl-c-ctrl-c-hook 'org-babel-execute-src-block-maybe) | ||
| 210 | 241 | ||
| 211 | ;;;###autoload | 242 | ;;;###autoload |
| 212 | (defun org-babel-expand-src-block-maybe () | 243 | (defun org-babel-expand-src-block-maybe () |
| @@ -245,7 +276,7 @@ then run `org-babel-pop-to-session'." | |||
| 245 | 276 | ||
| 246 | (defconst org-babel-header-arg-names | 277 | (defconst org-babel-header-arg-names |
| 247 | '(cache cmdline colnames dir exports file noweb results | 278 | '(cache cmdline colnames dir exports file noweb results |
| 248 | session tangle var noeval comments) | 279 | session tangle var eval noeval comments) |
| 249 | "Common header arguments used by org-babel. | 280 | "Common header arguments used by org-babel. |
| 250 | Note that individual languages may define their own language | 281 | Note that individual languages may define their own language |
| 251 | specific header arguments as well.") | 282 | specific header arguments as well.") |
| @@ -259,7 +290,8 @@ specific header arguments as well.") | |||
| 259 | '((:session . "none") (:results . "silent") (:exports . "results")) | 290 | '((:session . "none") (:results . "silent") (:exports . "results")) |
| 260 | "Default arguments to use when evaluating an inline source block.") | 291 | "Default arguments to use when evaluating an inline source block.") |
| 261 | 292 | ||
| 262 | (defvar org-babel-current-buffer-properties) | 293 | (defvar org-babel-current-buffer-properties nil |
| 294 | "Local cache for buffer properties.") | ||
| 263 | (make-variable-buffer-local 'org-babel-current-buffer-properties) | 295 | (make-variable-buffer-local 'org-babel-current-buffer-properties) |
| 264 | 296 | ||
| 265 | (defvar org-babel-result-regexp | 297 | (defvar org-babel-result-regexp |
| @@ -299,12 +331,17 @@ can not be resolved.") | |||
| 299 | ;;; functions | 331 | ;;; functions |
| 300 | (defvar call-process-region) | 332 | (defvar call-process-region) |
| 301 | ;;;###autoload | 333 | ;;;###autoload |
| 334 | |||
| 302 | (defun org-babel-execute-src-block (&optional arg info params) | 335 | (defun org-babel-execute-src-block (&optional arg info params) |
| 303 | "Execute the current source code block. | 336 | "Execute the current source code block. |
| 304 | Insert the results of execution into the buffer. Source code | 337 | Insert the results of execution into the buffer. Source code |
| 305 | execution and the collection and formatting of results can be | 338 | execution and the collection and formatting of results can be |
| 306 | controlled through a variety of header arguments. | 339 | controlled through a variety of header arguments. |
| 307 | 340 | ||
| 341 | With prefix argument ARG, force re-execution even if a an | ||
| 342 | existing result cached in the buffer would otherwise have been | ||
| 343 | returned. | ||
| 344 | |||
| 308 | Optionally supply a value for INFO in the form returned by | 345 | Optionally supply a value for INFO in the form returned by |
| 309 | `org-babel-get-src-block-info'. | 346 | `org-babel-get-src-block-info'. |
| 310 | 347 | ||
| @@ -312,73 +349,73 @@ Optionally supply a value for PARAMS which will be merged with | |||
| 312 | the header arguments specified at the front of the source code | 349 | the header arguments specified at the front of the source code |
| 313 | block." | 350 | block." |
| 314 | (interactive) | 351 | (interactive) |
| 315 | (let* ((info (or info (org-babel-get-src-block-info))) | 352 | (let ((info (or info (org-babel-get-src-block-info)))) |
| 316 | ;; note the `evaluation-confirmed' variable is currently not | 353 | (when (org-babel-confirm-evaluate info) |
| 317 | ;; used, but could be used later to avoid the need for | 354 | (let* ((lang (nth 0 info)) |
| 318 | ;; chaining confirmations | 355 | (params (if params |
| 319 | (evaluation-confirmed (org-babel-confirm-evaluate info)) | 356 | (org-babel-process-params |
| 320 | (lang (nth 0 info)) | 357 | (org-babel-merge-params (nth 2 info) params)) |
| 321 | (params (setf (nth 2 info) | 358 | (nth 2 info))) |
| 322 | (sort (org-babel-merge-params (nth 2 info) params) | 359 | (cache? (and (not arg) (cdr (assoc :cache params)) |
| 323 | (lambda (el1 el2) (string< (symbol-name (car el1)) | 360 | (string= "yes" (cdr (assoc :cache params))))) |
| 324 | (symbol-name (car el2))))))) | 361 | (result-params (cdr (assoc :result-params params))) |
| 325 | (new-hash | 362 | (new-hash (when cache? (org-babel-sha1-hash info))) |
| 326 | (if (and (cdr (assoc :cache params)) | 363 | (old-hash (when cache? (org-babel-result-hash info))) |
| 327 | (string= "yes" (cdr (assoc :cache params)))) | 364 | (body (setf (nth 1 info) |
| 328 | (org-babel-sha1-hash info))) | 365 | (if (and (cdr (assoc :noweb params)) |
| 329 | (old-hash (org-babel-result-hash info)) | 366 | (string= "yes" (cdr (assoc :noweb params)))) |
| 330 | (body (setf (nth 1 info) | 367 | (org-babel-expand-noweb-references info) |
| 331 | (if (and (cdr (assoc :noweb params)) | 368 | (nth 1 info)))) |
| 332 | (string= "yes" (cdr (assoc :noweb params)))) | 369 | (cmd (intern (concat "org-babel-execute:" lang))) |
| 333 | (org-babel-expand-noweb-references info) | 370 | (dir (cdr (assoc :dir params))) |
| 334 | (nth 1 info)))) | 371 | (default-directory |
| 335 | (result-params (split-string (or (cdr (assoc :results params)) ""))) | 372 | (or (and dir (file-name-as-directory dir)) default-directory)) |
| 336 | (result-type (cond ((member "output" result-params) 'output) | 373 | (org-babel-call-process-region-original |
| 337 | ((member "value" result-params) 'value) | 374 | (if (boundp 'org-babel-call-process-region-original) |
| 338 | (t 'value))) | 375 | org-babel-call-process-region-original |
| 339 | (cmd (intern (concat "org-babel-execute:" lang))) | 376 | (symbol-function 'call-process-region))) |
| 340 | (dir (cdr (assoc :dir params))) | 377 | (indent (car (last info))) |
| 341 | (default-directory | 378 | result) |
| 342 | (or (and dir (file-name-as-directory dir)) default-directory)) | 379 | (unwind-protect |
| 343 | (org-babel-call-process-region-original | 380 | (flet ((call-process-region (&rest args) |
| 344 | (if (boundp 'org-babel-call-process-region-original) org-babel-call-process-region-original | 381 | (apply 'org-babel-tramp-handle-call-process-region args))) |
| 345 | (symbol-function 'call-process-region))) | 382 | (unless (fboundp cmd) |
| 346 | (indent (car (last info))) | 383 | (error "No org-babel-execute function for %s!" lang)) |
| 347 | result) | 384 | (if (and (not arg) new-hash (equal new-hash old-hash)) |
| 348 | (unwind-protect | 385 | (save-excursion ;; return cached result |
| 349 | (flet ((call-process-region (&rest args) | 386 | (goto-char (org-babel-where-is-src-block-result nil info)) |
| 350 | (apply 'org-babel-tramp-handle-call-process-region args))) | 387 | (end-of-line 1) (forward-char 1) |
| 351 | (unless (fboundp cmd) | 388 | (setq result (org-babel-read-result)) |
| 352 | (error "No org-babel-execute function for %s!" lang)) | 389 | (message (replace-regexp-in-string |
| 353 | (if (and (not arg) new-hash (equal new-hash old-hash)) | 390 | "%" "%%" (format "%S" result))) result) |
| 354 | (save-excursion ;; return cached result | 391 | (message "executing %s code block%s..." |
| 355 | (goto-char (org-babel-where-is-src-block-result nil info)) | 392 | (capitalize lang) |
| 356 | (end-of-line 1) (forward-char 1) | 393 | (if (nth 4 info) (format " (%s)" (nth 4 info)) "")) |
| 357 | (setq result (org-babel-read-result)) | 394 | (setq result |
| 358 | (message (replace-regexp-in-string "%" "%%" | 395 | ((lambda (result) |
| 359 | (format "%S" result))) result) | 396 | (cond |
| 360 | (message "executing %s code block%s..." | 397 | ((member "file" result-params) |
| 361 | (capitalize lang) | 398 | (cdr (assoc :file params))) |
| 362 | (if (nth 4 info) (format " (%s)" (nth 4 info)) "")) | 399 | ((and (eq (cdr (assoc :result-type params)) 'value) |
| 363 | (setq result (funcall cmd body params)) | 400 | (or (member "vector" result-params) |
| 364 | (if (eq result-type 'value) | 401 | (member "table" result-params)) |
| 365 | (setq result (if (and (or (member "vector" result-params) | 402 | (not (listp result))) |
| 366 | (member "table" result-params)) | 403 | (list (list result))) |
| 367 | (not (listp result))) | 404 | (t result))) |
| 368 | (list (list result)) | 405 | (funcall cmd body params))) |
| 369 | result))) | 406 | (org-babel-insert-result |
| 370 | (org-babel-insert-result | 407 | result result-params info new-hash indent lang) |
| 371 | result result-params info new-hash indent lang) | 408 | (run-hooks 'org-babel-after-execute-hook) |
| 372 | (run-hooks 'org-babel-after-execute-hook) | 409 | result)) |
| 373 | result)) | 410 | (setq call-process-region 'org-babel-call-process-region-original)))))) |
| 374 | (setq call-process-region 'org-babel-call-process-region-original)))) | 411 | |
| 375 | 412 | (defun org-babel-expand-body:generic (body params &optional var-lines) | |
| 376 | (defun org-babel-expand-body:generic (body params &optional processed-params) | ||
| 377 | "Expand BODY with PARAMS. | 413 | "Expand BODY with PARAMS. |
| 378 | Expand a block of code with org-babel according to it's header | 414 | Expand a block of code with org-babel according to it's header |
| 379 | arguments. This generic implementation of body expansion is | 415 | arguments. This generic implementation of body expansion is |
| 380 | called for languages which have not defined their own specific | 416 | called for languages which have not defined their own specific |
| 381 | org-babel-expand-body:lang function." body) | 417 | org-babel-expand-body:lang function." |
| 418 | (mapconcat #'identity (append var-lines (list body)) "\n")) | ||
| 382 | 419 | ||
| 383 | ;;;###autoload | 420 | ;;;###autoload |
| 384 | (defun org-babel-expand-src-block (&optional arg info params) | 421 | (defun org-babel-expand-src-block (&optional arg info params) |
| @@ -391,14 +428,17 @@ arguments and pop open the results in a preview buffer." | |||
| 391 | (params (setf (nth 2 info) | 428 | (params (setf (nth 2 info) |
| 392 | (sort (org-babel-merge-params (nth 2 info) params) | 429 | (sort (org-babel-merge-params (nth 2 info) params) |
| 393 | (lambda (el1 el2) (string< (symbol-name (car el1)) | 430 | (lambda (el1 el2) (string< (symbol-name (car el1)) |
| 394 | (symbol-name (car el2))))))) | 431 | (symbol-name (car el2))))))) |
| 395 | (body (setf (nth 1 info) | 432 | (body (setf (nth 1 info) |
| 396 | (if (and (cdr (assoc :noweb params)) | 433 | (if (and (cdr (assoc :noweb params)) |
| 397 | (string= "yes" (cdr (assoc :noweb params)))) | 434 | (string= "yes" (cdr (assoc :noweb params)))) |
| 398 | (org-babel-expand-noweb-references info) (nth 1 info)))) | 435 | (org-babel-expand-noweb-references info) (nth 1 info)))) |
| 399 | (cmd (intern (concat "org-babel-expand-body:" lang))) | 436 | (expand-cmd (intern (concat "org-babel-expand-body:" lang))) |
| 400 | (expanded (funcall (if (fboundp cmd) cmd 'org-babel-expand-body:generic) | 437 | (assignments-cmd (intern (concat "org-babel-variable-assignments:" lang))) |
| 401 | body params))) | 438 | (expanded |
| 439 | (if (fboundp expand-cmd) (funcall expand-cmd body params) | ||
| 440 | (org-babel-expand-body:generic | ||
| 441 | body params (and (fboundp assignments-cmd) (funcall assignments-cmd params)))))) | ||
| 402 | (org-edit-src-code | 442 | (org-edit-src-code |
| 403 | nil expanded (concat "*Org-Babel Preview " (buffer-name) "[ " lang " ]*")))) | 443 | nil expanded (concat "*Org-Babel Preview " (buffer-name) "[ " lang " ]*")))) |
| 404 | 444 | ||
| @@ -411,9 +451,16 @@ session." | |||
| 411 | (interactive) | 451 | (interactive) |
| 412 | (let* ((info (or info (org-babel-get-src-block-info))) | 452 | (let* ((info (or info (org-babel-get-src-block-info))) |
| 413 | (lang (nth 0 info)) | 453 | (lang (nth 0 info)) |
| 414 | (body (nth 1 info)) | ||
| 415 | (params (nth 2 info)) | 454 | (params (nth 2 info)) |
| 455 | (body (setf (nth 1 info) | ||
| 456 | (if (and (cdr (assoc :noweb params)) | ||
| 457 | (string= "yes" (cdr (assoc :noweb params)))) | ||
| 458 | (org-babel-expand-noweb-references info) | ||
| 459 | (nth 1 info)))) | ||
| 416 | (session (cdr (assoc :session params))) | 460 | (session (cdr (assoc :session params))) |
| 461 | (dir (cdr (assoc :dir params))) | ||
| 462 | (default-directory | ||
| 463 | (or (and dir (file-name-as-directory dir)) default-directory)) | ||
| 417 | (cmd (intern (concat "org-babel-load-session:" lang)))) | 464 | (cmd (intern (concat "org-babel-load-session:" lang)))) |
| 418 | (unless (fboundp cmd) | 465 | (unless (fboundp cmd) |
| 419 | (error "No org-babel-load-session function for %s!" lang)) | 466 | (error "No org-babel-load-session function for %s!" lang)) |
| @@ -421,13 +468,13 @@ session." | |||
| 421 | (end-of-line 1))) | 468 | (end-of-line 1))) |
| 422 | 469 | ||
| 423 | ;;;###autoload | 470 | ;;;###autoload |
| 424 | (defun org-babel-switch-to-session (&optional arg info) | 471 | (defun org-babel-initiate-session (&optional arg info) |
| 425 | "Switch to the session of the current source-code block. | 472 | "Initiate session for current code block. |
| 426 | If called with a prefix argument then evaluate the header arguments | 473 | If called with a prefix argument then resolve any variable |
| 427 | for the source block before entering the session. Copy the body | 474 | references in the header arguments and assign these variables in |
| 428 | of the source block to the kill ring." | 475 | the session. Copy the body of the code block to the kill ring." |
| 429 | (interactive) | 476 | (interactive "P") |
| 430 | (let* ((info (or info (org-babel-get-src-block-info))) | 477 | (let* ((info (or info (org-babel-get-src-block-info (not arg)))) |
| 431 | (lang (nth 0 info)) | 478 | (lang (nth 0 info)) |
| 432 | (body (nth 1 info)) | 479 | (body (nth 1 info)) |
| 433 | (params (nth 2 info)) | 480 | (params (nth 2 info)) |
| @@ -435,23 +482,74 @@ of the source block to the kill ring." | |||
| 435 | (dir (cdr (assoc :dir params))) | 482 | (dir (cdr (assoc :dir params))) |
| 436 | (default-directory | 483 | (default-directory |
| 437 | (or (and dir (file-name-as-directory dir)) default-directory)) | 484 | (or (and dir (file-name-as-directory dir)) default-directory)) |
| 438 | (cmd (intern (format "org-babel-%s-initiate-session" lang))) | 485 | (init-cmd (intern (format "org-babel-%s-initiate-session" lang))) |
| 439 | (cmd2 (intern (concat "org-babel-prep-session:" lang)))) | 486 | (prep-cmd (intern (concat "org-babel-prep-session:" lang)))) |
| 440 | (unless (fboundp cmd) | 487 | (if (and (stringp session) (string= session "none")) |
| 488 | (error "This block is not using a session!")) | ||
| 489 | (unless (fboundp init-cmd) | ||
| 441 | (error "No org-babel-initiate-session function for %s!" lang)) | 490 | (error "No org-babel-initiate-session function for %s!" lang)) |
| 442 | ;; copy body to the kill ring | ||
| 443 | (with-temp-buffer (insert (org-babel-trim body)) | 491 | (with-temp-buffer (insert (org-babel-trim body)) |
| 444 | (copy-region-as-kill (point-min) (point-max))) | 492 | (copy-region-as-kill (point-min) (point-max))) |
| 445 | ;; if called with a prefix argument, then process header arguments | 493 | (when arg |
| 446 | (unless (fboundp cmd2) | 494 | (unless (fboundp prep-cmd) |
| 447 | (error "No org-babel-prep-session function for %s!" lang)) | 495 | (error "No org-babel-prep-session function for %s!" lang)) |
| 448 | (when arg (funcall cmd2 session params)) | 496 | (funcall prep-cmd session params)) |
| 449 | ;; just to the session using pop-to-buffer | 497 | (funcall init-cmd session params))) |
| 450 | (pop-to-buffer (funcall cmd session params)) | 498 | |
| 451 | (end-of-line 1))) | 499 | ;;;###autoload |
| 500 | (defun org-babel-switch-to-session (&optional arg info) | ||
| 501 | "Switch to the session of the current code block. | ||
| 502 | Uses `org-babel-initiate-session' to start the session. If called | ||
| 503 | with a prefix argument then this is passed on to | ||
| 504 | `org-babel-initiate-session'." | ||
| 505 | (interactive "P") | ||
| 506 | (pop-to-buffer (org-babel-initiate-session arg info)) | ||
| 507 | (end-of-line 1)) | ||
| 452 | 508 | ||
| 453 | (defalias 'org-babel-pop-to-session 'org-babel-switch-to-session) | 509 | (defalias 'org-babel-pop-to-session 'org-babel-switch-to-session) |
| 454 | 510 | ||
| 511 | ;;;###autoload | ||
| 512 | (defun org-babel-switch-to-session-with-code (&optional arg info) | ||
| 513 | "Switch to code buffer and display session." | ||
| 514 | (interactive "P") | ||
| 515 | (flet ((swap-windows | ||
| 516 | () | ||
| 517 | (let ((other-window-buffer (window-buffer (next-window)))) | ||
| 518 | (set-window-buffer (next-window) (current-buffer)) | ||
| 519 | (set-window-buffer (selected-window) other-window-buffer)) | ||
| 520 | (other-window 1))) | ||
| 521 | (let ((info (org-babel-get-src-block-info)) | ||
| 522 | (org-src-window-setup 'reorganize-frame)) | ||
| 523 | (save-excursion | ||
| 524 | (org-babel-switch-to-session arg info)) | ||
| 525 | (org-edit-src-code)) | ||
| 526 | (swap-windows))) | ||
| 527 | |||
| 528 | (defmacro org-babel-do-in-edit-buffer (&rest body) | ||
| 529 | "Evaluate BODY in edit buffer if there is a code block at point. | ||
| 530 | Return t if a code block was found at point, nil otherwise." | ||
| 531 | `(let ((org-src-window-setup 'switch-invisibly)) | ||
| 532 | (when (and (org-babel-where-is-src-block-head) | ||
| 533 | (org-edit-src-code nil nil nil 'quietly)) | ||
| 534 | (unwind-protect (progn ,@body) | ||
| 535 | (if (org-bound-and-true-p org-edit-src-from-org-mode) | ||
| 536 | (org-edit-src-exit))) | ||
| 537 | t))) | ||
| 538 | |||
| 539 | (defun org-babel-do-key-sequence-in-edit-buffer (key) | ||
| 540 | "Read key sequence and execute the command in edit buffer. | ||
| 541 | Enter a key sequence to be executed in the language major-mode | ||
| 542 | edit buffer. For example, TAB will alter the contents of the | ||
| 543 | Org-mode code block according to the effect of TAB in the | ||
| 544 | language major-mode buffer. For languages that support | ||
| 545 | interactive sessions, this can be used to send code from the Org | ||
| 546 | buffer to the session for evaluation using the native major-mode | ||
| 547 | evaluation mechanisms." | ||
| 548 | (interactive "kEnter key-sequence to execute in edit buffer: ") | ||
| 549 | (org-babel-do-in-edit-buffer | ||
| 550 | (call-interactively | ||
| 551 | (key-binding (or key (read-key-sequence nil)))))) | ||
| 552 | |||
| 455 | (defvar org-bracket-link-regexp) | 553 | (defvar org-bracket-link-regexp) |
| 456 | ;;;###autoload | 554 | ;;;###autoload |
| 457 | (defun org-babel-open-src-block-result (&optional re-run) | 555 | (defun org-babel-open-src-block-result (&optional re-run) |
| @@ -490,15 +588,9 @@ results already exist." | |||
| 490 | Call `org-babel-execute-src-block' on every source block in | 588 | Call `org-babel-execute-src-block' on every source block in |
| 491 | the current buffer." | 589 | the current buffer." |
| 492 | (interactive "P") | 590 | (interactive "P") |
| 493 | (save-excursion | 591 | (org-save-outline-visibility t |
| 494 | (org-save-outline-visibility t | 592 | (org-babel-map-src-blocks nil |
| 495 | (goto-char (point-min)) | 593 | (org-babel-execute-src-block arg)))) |
| 496 | (show-all) | ||
| 497 | (while (re-search-forward org-babel-src-block-regexp nil t) | ||
| 498 | (let ((pos-end (match-end 0))) | ||
| 499 | (goto-char (match-beginning 0)) | ||
| 500 | (org-babel-execute-src-block arg) | ||
| 501 | (goto-char pos-end)))))) | ||
| 502 | 594 | ||
| 503 | ;;;###autoload | 595 | ;;;###autoload |
| 504 | (defun org-babel-execute-subtree (&optional arg) | 596 | (defun org-babel-execute-subtree (&optional arg) |
| @@ -509,19 +601,34 @@ the current subtree." | |||
| 509 | (save-restriction | 601 | (save-restriction |
| 510 | (save-excursion | 602 | (save-excursion |
| 511 | (org-narrow-to-subtree) | 603 | (org-narrow-to-subtree) |
| 512 | (org-babel-execute-buffer) | 604 | (org-babel-execute-buffer arg) |
| 513 | (widen)))) | 605 | (widen)))) |
| 514 | 606 | ||
| 515 | ;;;###autoload | 607 | ;;;###autoload |
| 516 | (defun org-babel-sha1-hash (&optional info) | 608 | (defun org-babel-sha1-hash (&optional info) |
| 517 | "Generate an sha1 hash based on the value of info." | 609 | "Generate an sha1 hash based on the value of info." |
| 518 | (interactive) | 610 | (interactive) |
| 519 | (let* ((info (or info (org-babel-get-src-block-info))) | 611 | (let ((print-level nil) |
| 520 | (hash (sha1 (format "%s-%s" (mapconcat (lambda (arg) (format "%S" arg)) | 612 | (info (or info (org-babel-get-src-block-info)))) |
| 521 | (nth 2 info) ":") | 613 | (setf (nth 2 info) |
| 522 | (nth 1 info))))) | 614 | (sort (copy-sequence (nth 2 info)) |
| 523 | (when (interactive-p) (message hash)) | 615 | (lambda (a b) (string< (car a) (car b))))) |
| 524 | hash)) | 616 | (let ((hash (sha1 |
| 617 | (format "%s-%s" | ||
| 618 | (mapconcat | ||
| 619 | #'identity | ||
| 620 | (delq nil | ||
| 621 | (mapcar | ||
| 622 | (lambda (arg) | ||
| 623 | (let ((v (cdr arg))) | ||
| 624 | (when (and v (not (and (sequencep v) | ||
| 625 | (not (consp v)) | ||
| 626 | (= (length v) 0)))) | ||
| 627 | (format "%S" v)))) | ||
| 628 | (nth 2 info))) ":") | ||
| 629 | (nth 1 info))))) | ||
| 630 | (when (interactive-p) (message hash)) | ||
| 631 | hash))) | ||
| 525 | 632 | ||
| 526 | (defun org-babel-result-hash (&optional info) | 633 | (defun org-babel-result-hash (&optional info) |
| 527 | "Return the in-buffer hash associated with INFO." | 634 | "Return the in-buffer hash associated with INFO." |
| @@ -647,23 +754,58 @@ portions of results lines." | |||
| 647 | ;; Remove overlays when changing major mode | 754 | ;; Remove overlays when changing major mode |
| 648 | (add-hook 'org-mode-hook | 755 | (add-hook 'org-mode-hook |
| 649 | (lambda () (org-add-hook 'change-major-mode-hook | 756 | (lambda () (org-add-hook 'change-major-mode-hook |
| 650 | 'org-babel-show-result-all 'append 'local))) | 757 | 'org-babel-show-result-all 'append 'local))) |
| 651 | 758 | ||
| 652 | (defmacro org-babel-map-src-blocks (file &rest body) | 759 | (defmacro org-babel-map-src-blocks (file &rest body) |
| 653 | "Evaluate BODY forms on each source-block in FILE." | 760 | "Evaluate BODY forms on each source-block in FILE. |
| 761 | If FILE is nil evaluate BODY forms on source blocks in current | ||
| 762 | buffer. During evaluation of BODY the following local variables | ||
| 763 | are set relative to the currently matched code block. | ||
| 764 | |||
| 765 | full-block ------- string holding the entirety of the code block | ||
| 766 | beg-block -------- point at the beginning of the code block | ||
| 767 | end-block -------- point at the end of the matched code block | ||
| 768 | lang ------------- string holding the language of the code block | ||
| 769 | beg-lang --------- point at the beginning of the lang | ||
| 770 | end-lang --------- point at the end of the lang | ||
| 771 | switches --------- string holding the switches | ||
| 772 | beg-switches ----- point at the beginning of the switches | ||
| 773 | end-switches ----- point at the end of the switches | ||
| 774 | header-args ------ string holding the header-args | ||
| 775 | beg-header-args -- point at the beginning of the header-args | ||
| 776 | end-header-args -- point at the end of the header-args | ||
| 777 | body ------------- string holding the body of the code block | ||
| 778 | beg-body --------- point at the beginning of the body | ||
| 779 | end-body --------- point at the end of the body" | ||
| 654 | (declare (indent 1)) | 780 | (declare (indent 1)) |
| 655 | `(let ((visited-p (get-file-buffer (expand-file-name ,file))) | 781 | `(let ((visited-p (or (null ,file) |
| 656 | to-be-removed) | 782 | (get-file-buffer (expand-file-name ,file)))) |
| 783 | (point (point)) to-be-removed) | ||
| 657 | (save-window-excursion | 784 | (save-window-excursion |
| 658 | (find-file ,file) | 785 | (when ,file (find-file ,file)) |
| 659 | (setq to-be-removed (current-buffer)) | 786 | (setq to-be-removed (current-buffer)) |
| 660 | (goto-char (point-min)) | 787 | (goto-char (point-min)) |
| 661 | (while (re-search-forward org-babel-src-block-regexp nil t) | 788 | (while (re-search-forward org-babel-src-block-regexp nil t) |
| 662 | (goto-char (match-beginning 0)) | 789 | (goto-char (match-beginning 0)) |
| 663 | (save-match-data ,@body) | 790 | (let ((full-block (match-string 0)) |
| 664 | (goto-char (match-end 0)))) | 791 | (beg-block (match-beginning 0)) |
| 665 | (unless visited-p | 792 | (end-block (match-end 0)) |
| 666 | (kill-buffer to-be-removed)))) | 793 | (lang (match-string 2)) |
| 794 | (beg-lang (match-beginning 2)) | ||
| 795 | (end-lang (match-end 2)) | ||
| 796 | (switches (match-string 3)) | ||
| 797 | (beg-switches (match-beginning 3)) | ||
| 798 | (end-switches (match-end 3)) | ||
| 799 | (header-args (match-string 4)) | ||
| 800 | (beg-header-args (match-beginning 4)) | ||
| 801 | (end-header-args (match-end 4)) | ||
| 802 | (body (match-string 5)) | ||
| 803 | (beg-body (match-beginning 5)) | ||
| 804 | (end-body (match-end 5))) | ||
| 805 | ,@body | ||
| 806 | (goto-char end-block)))) | ||
| 807 | (unless visited-p (kill-buffer to-be-removed)) | ||
| 808 | (goto-char point))) | ||
| 667 | 809 | ||
| 668 | (defvar org-file-properties) | 810 | (defvar org-file-properties) |
| 669 | (defun org-babel-params-from-properties (&optional lang) | 811 | (defun org-babel-params-from-properties (&optional lang) |
| @@ -680,7 +822,8 @@ may be specified in the properties of the current outline entry." | |||
| 680 | (org-entry-get (point) header-arg t) | 822 | (org-entry-get (point) header-arg t) |
| 681 | (error nil)) | 823 | (error nil)) |
| 682 | (cdr (assoc header-arg org-file-properties)))) | 824 | (cdr (assoc header-arg org-file-properties)))) |
| 683 | (cons (intern (concat ":" header-arg)) val))) | 825 | (cons (intern (concat ":" header-arg)) |
| 826 | (org-babel-read val)))) | ||
| 684 | (mapcar | 827 | (mapcar |
| 685 | 'symbol-name | 828 | 'symbol-name |
| 686 | (append | 829 | (append |
| @@ -757,30 +900,33 @@ may be specified at the top of the current buffer." | |||
| 757 | "\\([^ \f\t\n\r\v]+\\)[ \f\t\n\r\v]+\\([^ \f\t\n\r\v]+.*\\)" | 900 | "\\([^ \f\t\n\r\v]+\\)[ \f\t\n\r\v]+\\([^ \f\t\n\r\v]+.*\\)" |
| 758 | arg) | 901 | arg) |
| 759 | (cons (intern (concat ":" (match-string 1 arg))) | 902 | (cons (intern (concat ":" (match-string 1 arg))) |
| 760 | (let ((raw (org-babel-chomp (match-string 2 arg)))) | 903 | (org-babel-read (org-babel-chomp (match-string 2 arg)))) |
| 761 | (if (org-babel-number-p raw) | ||
| 762 | raw (org-babel-read raw)))) | ||
| 763 | (cons (intern (concat ":" arg)) nil))) | 904 | (cons (intern (concat ":" arg)) nil))) |
| 764 | (split-string (concat " " arg-string) "[ \f\t\n\r\v]+:" t))))) | 905 | (split-string (concat " " arg-string) "[ \f\t\n\r\v]+:" t))))) |
| 765 | 906 | ||
| 766 | (defun org-babel-process-params (params) | 907 | (defun org-babel-process-params (params) |
| 767 | "Parse params and resolve references. | 908 | "Expand variables in PARAMS and add summary parameters." |
| 768 | 909 | (let* ((vars-and-names (org-babel-disassemble-tables | |
| 769 | Return a list (session vars result-params result-type colnames rownames)." | 910 | (mapcar (lambda (el) |
| 770 | (let* ((session (cdr (assoc :session params))) | 911 | (if (consp (cdr el)) |
| 771 | (vars-and-names (org-babel-disassemble-tables | 912 | (cdr el) (org-babel-ref-parse (cdr el)))) |
| 772 | (org-babel-ref-variables params) | 913 | (org-babel-get-header params :var)) |
| 773 | (cdr (assoc :hlines params)) | 914 | (cdr (assoc :hlines params)) |
| 774 | (cdr (assoc :colnames params)) | 915 | (cdr (assoc :colnames params)) |
| 775 | (cdr (assoc :rownames params)))) | 916 | (cdr (assoc :rownames params)))) |
| 776 | (vars (car vars-and-names)) | 917 | (result-params (append |
| 777 | (colnames (cadr vars-and-names)) | 918 | (split-string (or (cdr (assoc :results params)) "")) |
| 778 | (rownames (caddr vars-and-names)) | 919 | (cdr (assoc :result-params params))))) |
| 779 | (result-params (split-string (or (cdr (assoc :results params)) ""))) | 920 | (append |
| 780 | (result-type (cond ((member "output" result-params) 'output) | 921 | (mapcar (lambda (var) (cons :var var)) (car vars-and-names)) |
| 781 | ((member "value" result-params) 'value) | 922 | (list |
| 782 | (t 'value)))) | 923 | (cons :colname-names (cadr vars-and-names)) |
| 783 | (list session vars result-params result-type colnames rownames))) | 924 | (cons :rowname-names (caddr vars-and-names)) |
| 925 | (cons :result-params result-params) | ||
| 926 | (cons :result-type (cond ((member "output" result-params) 'output) | ||
| 927 | ((member "value" result-params) 'value) | ||
| 928 | (t 'value)))) | ||
| 929 | (org-babel-get-header params :var 'other)))) | ||
| 784 | 930 | ||
| 785 | ;; row and column names | 931 | ;; row and column names |
| 786 | (defun org-babel-del-hlines (table) | 932 | (defun org-babel-del-hlines (table) |
| @@ -802,12 +948,14 @@ Return a cons cell, the `car' of which contains the TABLE less | |||
| 802 | colnames, and the `cdr' of which contains a list of the column | 948 | colnames, and the `cdr' of which contains a list of the column |
| 803 | names. Note: this function removes any hlines in TABLE." | 949 | names. Note: this function removes any hlines in TABLE." |
| 804 | (flet ((trans (table) (apply #'mapcar* #'list table))) | 950 | (flet ((trans (table) (apply #'mapcar* #'list table))) |
| 805 | (let* ((width (apply 'max (mapcar (lambda (el) (if (listp el) (length el) 0)) table))) | 951 | (let* ((width (apply 'max |
| 952 | (mapcar (lambda (el) (if (listp el) (length el) 0)) table))) | ||
| 806 | (table (trans (mapcar (lambda (row) | 953 | (table (trans (mapcar (lambda (row) |
| 807 | (if (not (equal row 'hline)) | 954 | (if (not (equal row 'hline)) |
| 808 | row | 955 | row |
| 809 | (setq row '()) | 956 | (setq row '()) |
| 810 | (dotimes (n width) (setq row (cons 'hline row))) | 957 | (dotimes (n width) |
| 958 | (setq row (cons 'hline row))) | ||
| 811 | row)) | 959 | row)) |
| 812 | table)))) | 960 | table)))) |
| 813 | (cons (mapcar (lambda (row) (if (equal (car row) 'hline) 'hline row)) | 961 | (cons (mapcar (lambda (row) (if (equal (car row) 'hline) 'hline row)) |
| @@ -828,13 +976,18 @@ names. Note: this function removes any hlines in TABLE." | |||
| 828 | table)) | 976 | table)) |
| 829 | 977 | ||
| 830 | (defun org-babel-pick-name (names selector) | 978 | (defun org-babel-pick-name (names selector) |
| 831 | "Select one out of an alist of row or column names." | 979 | "Select one out of an alist of row or column names. |
| 832 | (when names | 980 | SELECTOR can be either a list of names in which case those names |
| 833 | (if (and selector (symbolp selector) (not (equal t selector))) | 981 | will be returned directly, or an index into the list NAMES in |
| 834 | (cdr (assoc selector names)) | 982 | which case the indexed names will be return." |
| 835 | (if (integerp selector) | 983 | (if (listp selector) |
| 836 | (nth (- selector 1) names) | 984 | selector |
| 837 | (cdr (car (last names))))))) | 985 | (when names |
| 986 | (if (and selector (symbolp selector) (not (equal t selector))) | ||
| 987 | (cdr (assoc selector names)) | ||
| 988 | (if (integerp selector) | ||
| 989 | (nth (- selector 1) names) | ||
| 990 | (cdr (car (last names)))))))) | ||
| 838 | 991 | ||
| 839 | (defun org-babel-disassemble-tables (vars hlines colnames rownames) | 992 | (defun org-babel-disassemble-tables (vars hlines colnames rownames) |
| 840 | "Parse tables for further processing. | 993 | "Parse tables for further processing. |
| @@ -903,6 +1056,14 @@ If the point is not on a source block then return nil." | |||
| 903 | (point)))))) | 1056 | (point)))))) |
| 904 | 1057 | ||
| 905 | ;;;###autoload | 1058 | ;;;###autoload |
| 1059 | (defun org-babel-goto-src-block-head () | ||
| 1060 | "Go to the beginning of the current code block." | ||
| 1061 | (interactive) | ||
| 1062 | ((lambda (head) | ||
| 1063 | (if head (goto-char head) (error "not currently in a code block"))) | ||
| 1064 | (org-babel-where-is-src-block-head))) | ||
| 1065 | |||
| 1066 | ;;;###autoload | ||
| 906 | (defun org-babel-goto-named-src-block (name) | 1067 | (defun org-babel-goto-named-src-block (name) |
| 907 | "Go to a named source-code block." | 1068 | "Go to a named source-code block." |
| 908 | (interactive | 1069 | (interactive |
| @@ -934,7 +1095,7 @@ org-babel-named-src-block-regexp." | |||
| 934 | (when file (find-file file)) (goto-char (point-min)) | 1095 | (when file (find-file file)) (goto-char (point-min)) |
| 935 | (let (names) | 1096 | (let (names) |
| 936 | (while (re-search-forward org-babel-src-name-w-name-regexp nil t) | 1097 | (while (re-search-forward org-babel-src-name-w-name-regexp nil t) |
| 937 | (setq names (cons (org-babel-clean-text-properties (match-string 2)) | 1098 | (setq names (cons (org-babel-clean-text-properties (match-string 3)) |
| 938 | names))) | 1099 | names))) |
| 939 | names))) | 1100 | names))) |
| 940 | 1101 | ||
| @@ -978,7 +1139,9 @@ buffer or nil if no such result exists." | |||
| 978 | With optional prefix argument ARG, jump forward ARG many source blocks." | 1139 | With optional prefix argument ARG, jump forward ARG many source blocks." |
| 979 | (interactive "P") | 1140 | (interactive "P") |
| 980 | (when (looking-at org-babel-src-block-regexp) (forward-char 1)) | 1141 | (when (looking-at org-babel-src-block-regexp) (forward-char 1)) |
| 981 | (re-search-forward org-babel-src-block-regexp nil nil (or arg 1)) | 1142 | (condition-case nil |
| 1143 | (re-search-forward org-babel-src-block-regexp nil nil (or arg 1)) | ||
| 1144 | (error (error "No further code blocks"))) | ||
| 982 | (goto-char (match-beginning 0)) (org-show-context)) | 1145 | (goto-char (match-beginning 0)) (org-show-context)) |
| 983 | 1146 | ||
| 984 | ;;;###autoload | 1147 | ;;;###autoload |
| @@ -986,9 +1149,68 @@ With optional prefix argument ARG, jump forward ARG many source blocks." | |||
| 986 | "Jump to the previous source block. | 1149 | "Jump to the previous source block. |
| 987 | With optional prefix argument ARG, jump backward ARG many source blocks." | 1150 | With optional prefix argument ARG, jump backward ARG many source blocks." |
| 988 | (interactive "P") | 1151 | (interactive "P") |
| 989 | (re-search-backward org-babel-src-block-regexp nil nil (or arg 1)) | 1152 | (condition-case nil |
| 1153 | (re-search-backward org-babel-src-block-regexp nil nil (or arg 1)) | ||
| 1154 | (error (error "No previous code blocks"))) | ||
| 990 | (goto-char (match-beginning 0)) (org-show-context)) | 1155 | (goto-char (match-beginning 0)) (org-show-context)) |
| 991 | 1156 | ||
| 1157 | (defvar org-babel-load-languages) | ||
| 1158 | |||
| 1159 | ;;;###autoload | ||
| 1160 | (defun org-babel-mark-block () | ||
| 1161 | "Mark current src block" | ||
| 1162 | (interactive) | ||
| 1163 | ((lambda (head) | ||
| 1164 | (when head | ||
| 1165 | (save-excursion | ||
| 1166 | (goto-char head) | ||
| 1167 | (looking-at org-babel-src-block-regexp)) | ||
| 1168 | (push-mark (match-end 5) nil t) | ||
| 1169 | (goto-char (match-beginning 5)))) | ||
| 1170 | (org-babel-where-is-src-block-head))) | ||
| 1171 | |||
| 1172 | (defun org-babel-demarcate-block (&optional arg) | ||
| 1173 | "Wrap or split the code in the region or on the point. | ||
| 1174 | When called from inside of a code block the current block is | ||
| 1175 | split. When called from outside of a code block a new code block | ||
| 1176 | is created. In both cases if the region is demarcated and if the | ||
| 1177 | region is not active then the point is demarcated." | ||
| 1178 | (interactive "P") | ||
| 1179 | (let ((info (org-babel-get-src-block-info 'light)) | ||
| 1180 | (stars (concat (make-string (or (org-current-level) 1) ?*) " "))) | ||
| 1181 | (if info | ||
| 1182 | (mapc | ||
| 1183 | (lambda (place) | ||
| 1184 | (save-excursion | ||
| 1185 | (goto-char place) | ||
| 1186 | (let ((lang (nth 0 info)) | ||
| 1187 | (indent (make-string (nth 5 info) ? ))) | ||
| 1188 | (when (string-match "^[[:space:]]*$" | ||
| 1189 | (buffer-substring (point-at-bol) | ||
| 1190 | (point-at-eol))) | ||
| 1191 | (delete-region (point-at-bol) (point-at-eol))) | ||
| 1192 | (insert (concat (if (looking-at "^") "" "\n") | ||
| 1193 | indent "#+end_src\n" | ||
| 1194 | (if arg stars indent) "\n" | ||
| 1195 | indent "#+begin_src " lang | ||
| 1196 | (if (looking-at "[\n\r]") "" "\n"))))) | ||
| 1197 | (move-end-of-line 2)) | ||
| 1198 | (sort (if (region-active-p) (list (mark) (point)) (list (point))) #'>)) | ||
| 1199 | (let ((start (point)) | ||
| 1200 | (lang (org-icompleting-read "Lang: " | ||
| 1201 | (mapcar (lambda (el) (symbol-name (car el))) | ||
| 1202 | org-babel-load-languages))) | ||
| 1203 | (body (delete-and-extract-region | ||
| 1204 | (if (region-active-p) (mark) (point)) (point)))) | ||
| 1205 | (insert (concat (if (looking-at "^") "" "\n") | ||
| 1206 | (if arg (concat stars "\n") "") | ||
| 1207 | "#+begin_src " lang "\n" | ||
| 1208 | body | ||
| 1209 | (if (or (= (length body) 0) | ||
| 1210 | (string-match "[\r\n]$" body)) "" "\n") | ||
| 1211 | "#+end_src\n")) | ||
| 1212 | (goto-char start) (move-end-of-line 1))))) | ||
| 1213 | |||
| 992 | (defvar org-babel-lob-one-liner-regexp) | 1214 | (defvar org-babel-lob-one-liner-regexp) |
| 993 | (defun org-babel-where-is-src-block-result (&optional insert info hash indent) | 1215 | (defun org-babel-where-is-src-block-result (&optional insert info hash indent) |
| 994 | "Find where the current source block results begin. | 1216 | "Find where the current source block results begin. |
| @@ -1050,7 +1272,7 @@ following the source block." | |||
| 1050 | (if indent | 1272 | (if indent |
| 1051 | (mapconcat | 1273 | (mapconcat |
| 1052 | (lambda (el) " ") | 1274 | (lambda (el) " ") |
| 1053 | (number-sequence 1 indent) "") | 1275 | (org-number-sequence 1 indent) "") |
| 1054 | "") | 1276 | "") |
| 1055 | "#+results" | 1277 | "#+results" |
| 1056 | (when hash (concat "["hash"]")) | 1278 | (when hash (concat "["hash"]")) |
| @@ -1130,7 +1352,12 @@ raw ----- results are added directly to the org-mode file. This | |||
| 1130 | is a good option if you code block will output org-mode | 1352 | is a good option if you code block will output org-mode |
| 1131 | formatted text. | 1353 | formatted text. |
| 1132 | 1354 | ||
| 1133 | org ----- this is the same as the 'raw' option | 1355 | org ----- similar in effect to raw, only the results are wrapped |
| 1356 | in an org code block. Similar to the raw option, on | ||
| 1357 | export the results will be interpreted as org-formatted | ||
| 1358 | text, however by wrapping the results in an org code | ||
| 1359 | block they can be replaced upon re-execution of the | ||
| 1360 | code block. | ||
| 1134 | 1361 | ||
| 1135 | html ---- results are added inside of a #+BEGIN_HTML block. This | 1362 | html ---- results are added inside of a #+BEGIN_HTML block. This |
| 1136 | is a good option if you code block will output html | 1363 | is a good option if you code block will output html |
| @@ -1151,73 +1378,79 @@ code ---- the results are extracted in the syntax of the source | |||
| 1151 | (when (member "file" result-params) | 1378 | (when (member "file" result-params) |
| 1152 | (setq result (org-babel-result-to-file result)))) | 1379 | (setq result (org-babel-result-to-file result)))) |
| 1153 | (unless (listp result) (setq result (format "%S" result)))) | 1380 | (unless (listp result) (setq result (format "%S" result)))) |
| 1154 | (if (= (length result) 0) | 1381 | (if (and result-params (member "silent" result-params)) |
| 1155 | (if (member "value" result-params) | 1382 | (progn |
| 1156 | (message "No result returned by source block") | 1383 | (message (replace-regexp-in-string "%" "%%" (format "%S" result))) |
| 1157 | (message "Source block produced no output")) | 1384 | result) |
| 1158 | (if (and result-params (member "silent" result-params)) | 1385 | (when (and (stringp result) ;; ensure results end in a newline |
| 1159 | (progn | 1386 | (> (length result) 0) |
| 1160 | (message (replace-regexp-in-string "%" "%%" (format "%S" result))) | 1387 | (not (or (string-equal (substring result -1) "\n") |
| 1161 | result) | 1388 | (string-equal (substring result -1) "\r")))) |
| 1162 | (when (and (stringp result) ;; ensure results end in a newline | 1389 | (setq result (concat result "\n"))) |
| 1163 | (not (or (string-equal (substring result -1) "\n") | 1390 | (save-excursion |
| 1164 | (string-equal (substring result -1) "\r")))) | 1391 | (let ((existing-result (org-babel-where-is-src-block-result |
| 1165 | (setq result (concat result "\n"))) | 1392 | t info hash indent)) |
| 1166 | (save-excursion | 1393 | (results-switches |
| 1167 | (let ((existing-result (org-babel-where-is-src-block-result | 1394 | (cdr (assoc :results_switches (nth 2 info)))) |
| 1168 | t info hash indent)) | 1395 | beg end) |
| 1169 | (results-switches | 1396 | (if (not existing-result) |
| 1170 | (cdr (assoc :results_switches (nth 2 info)))) | ||
| 1171 | beg end) | ||
| 1172 | (when existing-result | ||
| 1173 | (goto-char existing-result) | ||
| 1174 | (save-excursion | ||
| 1175 | (re-search-forward "#" nil t) | ||
| 1176 | (setq indent (- (current-column) 1))) | ||
| 1177 | (forward-line 1) | ||
| 1178 | (setq beg (point)) | 1397 | (setq beg (point)) |
| 1179 | (cond | 1398 | (goto-char existing-result) |
| 1180 | ((member "replace" result-params) | 1399 | (save-excursion |
| 1181 | (delete-region (point) (org-babel-result-end))) | 1400 | (re-search-forward "#" nil t) |
| 1182 | ((member "append" result-params) | 1401 | (setq indent (- (current-column) 1))) |
| 1183 | (goto-char (org-babel-result-end)) (setq beg (point))) | 1402 | (forward-line 1) |
| 1184 | ((member "prepend" result-params) ;; already there | 1403 | (setq beg (point)) |
| 1185 | ))) | ||
| 1186 | (setq results-switches | ||
| 1187 | (if results-switches (concat " " results-switches) "")) | ||
| 1188 | (cond | 1404 | (cond |
| 1189 | ;; assume the result is a table if it's not a string | 1405 | ((member "replace" result-params) |
| 1190 | ((not (stringp result)) | 1406 | (delete-region (point) (org-babel-result-end))) |
| 1191 | (insert (concat (orgtbl-to-orgtbl | 1407 | ((member "append" result-params) |
| 1192 | (if (or (eq 'hline (car result)) | 1408 | (goto-char (org-babel-result-end)) (setq beg (point))) |
| 1193 | (and (listp (car result)) | 1409 | ((member "prepend" result-params) ;; already there |
| 1194 | (listp (cdr (car result))))) | 1410 | ))) |
| 1195 | result (list result)) | 1411 | (setq results-switches |
| 1196 | '(:fmt (lambda (cell) (format "%s" cell)))) "\n")) | 1412 | (if results-switches (concat " " results-switches) "")) |
| 1197 | (goto-char beg) (when (org-at-table-p) (org-table-align))) | 1413 | (cond |
| 1198 | ((member "file" result-params) | 1414 | ;; do nothing for an empty result |
| 1199 | (insert result)) | 1415 | ((= (length result) 0)) |
| 1200 | ((member "html" result-params) | 1416 | ;; assume the result is a table if it's not a string |
| 1201 | (insert (format "#+BEGIN_HTML%s\n%s#+END_HTML\n" | 1417 | ((not (stringp result)) |
| 1202 | results-switches result))) | 1418 | (insert (concat (orgtbl-to-orgtbl |
| 1203 | ((member "latex" result-params) | 1419 | (if (or (eq 'hline (car result)) |
| 1204 | (insert (format "#+BEGIN_LaTeX%s\n%s#+END_LaTeX\n" | 1420 | (and (listp (car result)) |
| 1205 | results-switches result))) | 1421 | (listp (cdr (car result))))) |
| 1206 | ((member "code" result-params) | 1422 | result (list result)) |
| 1207 | (insert (format "#+BEGIN_SRC %s%s\n%s#+END_SRC\n" | 1423 | '(:fmt (lambda (cell) (format "%s" cell)))) "\n")) |
| 1208 | (or lang "none") results-switches result))) | 1424 | (goto-char beg) (when (org-at-table-p) (org-table-align))) |
| 1209 | ((or (member "raw" result-params) (member "org" result-params)) | 1425 | ((member "file" result-params) |
| 1210 | (save-excursion (insert result)) (if (org-at-table-p) (org-cycle))) | 1426 | (insert result)) |
| 1211 | (t | 1427 | ((member "html" result-params) |
| 1212 | (org-babel-examplize-region | 1428 | (insert (format "#+BEGIN_HTML%s\n%s#+END_HTML\n" |
| 1213 | (point) (progn (insert result) (point)) results-switches))) | 1429 | results-switches result))) |
| 1214 | ;; possibly indent the results to match the #+results line | 1430 | ((member "latex" result-params) |
| 1215 | (setq end (if (listp result) (org-table-end) (point))) | 1431 | (insert (format "#+BEGIN_LaTeX%s\n%s#+END_LaTeX\n" |
| 1216 | (when (and indent (> indent 0) | 1432 | results-switches result))) |
| 1217 | ;; in this case `table-align' does the work for us | 1433 | ((member "code" result-params) |
| 1218 | (not (and (listp result) | 1434 | (insert (format "#+BEGIN_SRC %s%s\n%s#+END_SRC\n" |
| 1219 | (member "append" result-params)))) | 1435 | (or lang "none") results-switches result))) |
| 1220 | (indent-rigidly beg end indent)))) | 1436 | ((member "org" result-params) |
| 1437 | (insert (format "#+BEGIN_SRC org\n%s#+END_SRC\n" result))) | ||
| 1438 | ((member "raw" result-params) | ||
| 1439 | (save-excursion (insert result)) (if (org-at-table-p) (org-cycle))) | ||
| 1440 | (t | ||
| 1441 | (org-babel-examplize-region | ||
| 1442 | (point) (progn (insert result) (point)) results-switches))) | ||
| 1443 | ;; possibly indent the results to match the #+results line | ||
| 1444 | (setq end (if (listp result) (org-table-end) (point))) | ||
| 1445 | (when (and indent (> indent 0) | ||
| 1446 | ;; in this case `table-align' does the work for us | ||
| 1447 | (not (and (listp result) | ||
| 1448 | (member "append" result-params)))) | ||
| 1449 | (indent-rigidly beg end indent)))) | ||
| 1450 | (if (= (length result) 0) | ||
| 1451 | (if (member "value" result-params) | ||
| 1452 | (message "No result returned by source block") | ||
| 1453 | (message "Source block produced no output")) | ||
| 1221 | (message "finished")))) | 1454 | (message "finished")))) |
| 1222 | 1455 | ||
| 1223 | (defun org-babel-remove-result (&optional info) | 1456 | (defun org-babel-remove-result (&optional info) |
| @@ -1272,7 +1505,7 @@ file's directory then expand relative links." | |||
| 1272 | (let ((size (count-lines beg end))) | 1505 | (let ((size (count-lines beg end))) |
| 1273 | (save-excursion | 1506 | (save-excursion |
| 1274 | (cond ((= size 0) | 1507 | (cond ((= size 0) |
| 1275 | (error (concat "This should be impossible:" | 1508 | (error (concat "This should not be impossible:" |
| 1276 | "a newline was appended to result if missing"))) | 1509 | "a newline was appended to result if missing"))) |
| 1277 | ((< size org-babel-min-lines-for-block-output) | 1510 | ((< size org-babel-min-lines-for-block-output) |
| 1278 | (goto-char beg) | 1511 | (goto-char beg) |
| @@ -1286,6 +1519,14 @@ file's directory then expand relative links." | |||
| 1286 | (forward-char (- end beg)) | 1519 | (forward-char (- end beg)) |
| 1287 | (insert "#+end_example\n")))))) | 1520 | (insert "#+end_example\n")))))) |
| 1288 | 1521 | ||
| 1522 | (defun org-babel-update-block-body (new-body) | ||
| 1523 | "Update the body of the current code block to NEW-BODY." | ||
| 1524 | (if (not (org-babel-where-is-src-block-head)) | ||
| 1525 | (error "not in source block") | ||
| 1526 | (save-match-data | ||
| 1527 | (replace-match (concat (org-babel-trim new-body) "\n") nil nil nil 5)) | ||
| 1528 | (indent-rigidly (match-beginning 5) (match-end 5) 2))) | ||
| 1529 | |||
| 1289 | (defun org-babel-merge-params (&rest plists) | 1530 | (defun org-babel-merge-params (&rest plists) |
| 1290 | "Combine all parameter association lists in PLISTS. | 1531 | "Combine all parameter association lists in PLISTS. |
| 1291 | Later elements of PLISTS override the values of previous element. | 1532 | Later elements of PLISTS override the values of previous element. |
| @@ -1298,7 +1539,7 @@ parameters when merging lists." | |||
| 1298 | ("output" "value"))) | 1539 | ("output" "value"))) |
| 1299 | (exports-exclusive-groups | 1540 | (exports-exclusive-groups |
| 1300 | '(("code" "results" "both" "none"))) | 1541 | '(("code" "results" "both" "none"))) |
| 1301 | params results exports tangle noweb cache vars var ref shebang comments) | 1542 | params results exports tangle noweb cache vars shebang comments) |
| 1302 | (flet ((e-merge (exclusive-groups &rest result-params) | 1543 | (flet ((e-merge (exclusive-groups &rest result-params) |
| 1303 | ;; maintain exclusivity of mutually exclusive parameters | 1544 | ;; maintain exclusivity of mutually exclusive parameters |
| 1304 | (let (output) | 1545 | (let (output) |
| @@ -1318,63 +1559,60 @@ parameters when merging lists." | |||
| 1318 | new-params)) | 1559 | new-params)) |
| 1319 | result-params) | 1560 | result-params) |
| 1320 | output))) | 1561 | output))) |
| 1321 | (mapc (lambda (plist) | 1562 | (mapc |
| 1322 | (mapc (lambda (pair) | 1563 | (lambda (plist) |
| 1323 | (case (car pair) | 1564 | (mapc |
| 1324 | (:var | 1565 | (lambda (pair) |
| 1325 | ;; we want only one specification per variable | 1566 | (case (car pair) |
| 1326 | (when (string-match | 1567 | (:var |
| 1327 | (concat "^\\([^= \f\t\n\r\v]+\\)[ \t]*=" | 1568 | (let ((name (if (listp (cdr pair)) |
| 1328 | "[ \t]*\\([^\f\n\r\v]+\\)$") (cdr pair)) | 1569 | (cadr pair) |
| 1329 | ;; TODO: When is this not true? | 1570 | (and (string-match "^\\([^= \f\t\n\r\v]+\\)[ \t]*=" |
| 1330 | (setq var (intern (match-string 1 (cdr pair))) | 1571 | (cdr pair)) |
| 1331 | ref (match-string 2 (cdr pair)) | 1572 | (intern (match-string 1 (cdr pair))))))) |
| 1332 | vars (cons (cons var ref) | 1573 | (when name |
| 1333 | (assq-delete-all var vars))))) | 1574 | (setq vars |
| 1334 | (:results | 1575 | (cons (cons name pair) |
| 1335 | (setq results | 1576 | (if (member name (mapcar #'car vars)) |
| 1336 | (e-merge results-exclusive-groups | 1577 | (delq nil |
| 1337 | results (split-string (cdr pair))))) | 1578 | (mapcar |
| 1338 | (:file | 1579 | (lambda (p) (unless (equal (car p) name) p)) |
| 1339 | (when (cdr pair) | 1580 | vars)) |
| 1340 | (setq results (e-merge results-exclusive-groups | 1581 | vars)))))) |
| 1341 | results '("file"))) | 1582 | (:results |
| 1342 | (unless (or (member "both" exports) | 1583 | (setq results (e-merge results-exclusive-groups |
| 1343 | (member "none" exports) | 1584 | results (split-string (cdr pair))))) |
| 1344 | (member "code" exports)) | 1585 | (:file |
| 1345 | (setq exports (e-merge exports-exclusive-groups | 1586 | (when (cdr pair) |
| 1346 | exports '("results")))) | 1587 | (setq results (e-merge results-exclusive-groups |
| 1347 | (setq params | 1588 | results '("file"))) |
| 1348 | (cons pair | 1589 | (unless (or (member "both" exports) |
| 1349 | (assq-delete-all (car pair) params))))) | 1590 | (member "none" exports) |
| 1350 | (:exports | 1591 | (member "code" exports)) |
| 1351 | (setq exports | 1592 | (setq exports (e-merge exports-exclusive-groups |
| 1352 | (e-merge exports-exclusive-groups | 1593 | exports '("results")))) |
| 1353 | exports (split-string (cdr pair))))) | 1594 | (setq params (cons pair (assq-delete-all (car pair) params))))) |
| 1354 | (:tangle ;; take the latest -- always overwrite | 1595 | (:exports |
| 1355 | (setq tangle (or (list (cdr pair)) tangle))) | 1596 | (setq exports (e-merge exports-exclusive-groups |
| 1356 | (:noweb | 1597 | exports (split-string (cdr pair))))) |
| 1357 | (setq noweb | 1598 | (:tangle ;; take the latest -- always overwrite |
| 1358 | (e-merge '(("yes" "no")) noweb | 1599 | (setq tangle (or (list (cdr pair)) tangle))) |
| 1359 | (split-string (or (cdr pair) ""))))) | 1600 | (:noweb |
| 1360 | (:cache | 1601 | (setq noweb (e-merge '(("yes" "no")) noweb |
| 1361 | (setq cache | 1602 | (split-string (or (cdr pair) ""))))) |
| 1362 | (e-merge '(("yes" "no")) cache | 1603 | (:cache |
| 1363 | (split-string (or (cdr pair) ""))))) | 1604 | (setq cache (e-merge '(("yes" "no")) cache |
| 1364 | (:shebang ;; take the latest -- always overwrite | 1605 | (split-string (or (cdr pair) ""))))) |
| 1365 | (setq shebang (or (list (cdr pair)) shebang))) | 1606 | (:shebang ;; take the latest -- always overwrite |
| 1366 | (:comments | 1607 | (setq shebang (or (list (cdr pair)) shebang))) |
| 1367 | (setq comments | 1608 | (:comments |
| 1368 | (e-merge '(("yes" "no")) comments | 1609 | (setq comments (e-merge '(("yes" "no")) comments |
| 1369 | (split-string (or (cdr pair) ""))))) | 1610 | (split-string (or (cdr pair) ""))))) |
| 1370 | (t ;; replace: this covers e.g. :session | 1611 | (t ;; replace: this covers e.g. :session |
| 1371 | (setq params | 1612 | (setq params (cons pair (assq-delete-all (car pair) params)))))) |
| 1372 | (cons pair | 1613 | plist)) |
| 1373 | (assq-delete-all (car pair) params)))))) | 1614 | plists)) |
| 1374 | plist)) | 1615 | (while vars (setq params (cons (cons :var (cddr (pop vars))) params))) |
| 1375 | plists)) | ||
| 1376 | (setq vars (mapcar (lambda (pair) (format "%s=%s" (car pair) (cdr pair))) vars)) | ||
| 1377 | (while vars (setq params (cons (cons :var (pop vars)) params))) | ||
| 1378 | (cons (cons :comments (mapconcat 'identity comments " ")) | 1616 | (cons (cons :comments (mapconcat 'identity comments " ")) |
| 1379 | (cons (cons :shebang (mapconcat 'identity shebang " ")) | 1617 | (cons (cons :shebang (mapconcat 'identity shebang " ")) |
| 1380 | (cons (cons :cache (mapconcat 'identity cache " ")) | 1618 | (cons (cons :cache (mapconcat 'identity cache " ")) |
| @@ -1445,8 +1683,7 @@ block but are passed literally to the \"example-block\"." | |||
| 1445 | #'identity | 1683 | #'identity |
| 1446 | (split-string | 1684 | (split-string |
| 1447 | (if evaluate | 1685 | (if evaluate |
| 1448 | (let ((raw (org-babel-ref-resolve-reference | 1686 | (let ((raw (org-babel-ref-resolve source-name))) |
| 1449 | source-name nil))) | ||
| 1450 | (if (stringp raw) raw (format "%S" raw))) | 1687 | (if (stringp raw) raw (format "%S" raw))) |
| 1451 | (save-restriction | 1688 | (save-restriction |
| 1452 | (widen) | 1689 | (widen) |
| @@ -1497,14 +1734,14 @@ This is taken almost directly from `org-read-prop'." | |||
| 1497 | cell)) | 1734 | cell)) |
| 1498 | 1735 | ||
| 1499 | (defun org-babel-number-p (string) | 1736 | (defun org-babel-number-p (string) |
| 1500 | "Return t if STRING represents a number." | 1737 | "If STRING represents a number return it's value." |
| 1501 | (if (and (string-match "^-?[0-9]*\\.?[0-9]*$" string) | 1738 | (if (and (string-match "^-?[0-9]*\\.?[0-9]*$" string) |
| 1502 | (= (length (substring string (match-beginning 0) | 1739 | (= (length (substring string (match-beginning 0) |
| 1503 | (match-end 0))) | 1740 | (match-end 0))) |
| 1504 | (length string))) | 1741 | (length string))) |
| 1505 | (string-to-number string))) | 1742 | (string-to-number string))) |
| 1506 | 1743 | ||
| 1507 | (defun org-babel-import-elisp-from-file (file-name) | 1744 | (defun org-babel-import-elisp-from-file (file-name &optional separator) |
| 1508 | "Read the results located at FILE-NAME into an elisp table. | 1745 | "Read the results located at FILE-NAME into an elisp table. |
| 1509 | If the table is trivial, then return it as a scalar." | 1746 | If the table is trivial, then return it as a scalar." |
| 1510 | (let (result) | 1747 | (let (result) |
| @@ -1512,7 +1749,7 @@ If the table is trivial, then return it as a scalar." | |||
| 1512 | (with-temp-buffer | 1749 | (with-temp-buffer |
| 1513 | (condition-case nil | 1750 | (condition-case nil |
| 1514 | (progn | 1751 | (progn |
| 1515 | (org-table-import file-name nil) | 1752 | (org-table-import file-name separator) |
| 1516 | (delete-file file-name) | 1753 | (delete-file file-name) |
| 1517 | (setq result (mapcar (lambda (row) | 1754 | (setq result (mapcar (lambda (row) |
| 1518 | (mapcar #'org-babel-string-read row)) | 1755 | (mapcar #'org-babel-string-read row)) |
| @@ -1569,22 +1806,78 @@ Fixes a bug in `tramp-handle-call-process-region'." | |||
| 1569 | ;; bug in tramp | 1806 | ;; bug in tramp |
| 1570 | (apply 'process-file program tmpfile buffer display args) | 1807 | (apply 'process-file program tmpfile buffer display args) |
| 1571 | (delete-file tmpfile))) | 1808 | (delete-file tmpfile))) |
| 1572 | ;; org-babel-call-process-region-original is the original emacs definition. It | 1809 | ;; org-babel-call-process-region-original is the original emacs |
| 1573 | ;; is in scope from the let binding in org-babel-execute-src-block | 1810 | ;; definition. It is in scope from the let binding in |
| 1811 | ;; org-babel-execute-src-block | ||
| 1574 | (apply org-babel-call-process-region-original | 1812 | (apply org-babel-call-process-region-original |
| 1575 | start end program delete buffer display args))) | 1813 | start end program delete buffer display args))) |
| 1576 | 1814 | ||
| 1577 | (defun org-babel-maybe-remote-file (file) | 1815 | (defun org-babel-local-file-name (file) |
| 1578 | "Conditionally parse information on a remote connnection. | 1816 | "Return the local name component of FILE." |
| 1579 | If FILE specifies a remove file, then parse the information on | 1817 | (if (file-remote-p file) |
| 1580 | the remote connection." | 1818 | (let (localname) |
| 1581 | (if (file-remote-p default-directory) | 1819 | (with-parsed-tramp-file-name file nil |
| 1582 | (let* ((vec (tramp-dissect-file-name default-directory)) | 1820 | localname)) |
| 1583 | (user (tramp-file-name-user vec)) | ||
| 1584 | (host (tramp-file-name-host vec))) | ||
| 1585 | (concat "/" user (when user "@") host ":" file)) | ||
| 1586 | file)) | 1821 | file)) |
| 1587 | 1822 | ||
| 1823 | (defun org-babel-process-file-name (name &optional no-quote-p) | ||
| 1824 | "Prepare NAME to be used in an external process. | ||
| 1825 | If NAME specifies a remote location, the remote portion of the | ||
| 1826 | name is removed, since in that case the process will be executing | ||
| 1827 | remotely. The file name is then processed by | ||
| 1828 | `expand-file-name'. Unless second argument NO-QUOTE-P is non-nil, | ||
| 1829 | the file name is additionally processed by | ||
| 1830 | `shell-quote-argument'" | ||
| 1831 | ((lambda (f) (if no-quote-p f (shell-quote-argument f))) | ||
| 1832 | (expand-file-name (org-babel-local-file-name name)))) | ||
| 1833 | |||
| 1834 | (defvar org-babel-temporary-directory) | ||
| 1835 | (unless (or noninteractive (boundp 'org-babel-temporary-directory)) | ||
| 1836 | (defvar org-babel-temporary-directory | ||
| 1837 | (or (and (boundp 'org-babel-temporary-directory) | ||
| 1838 | (file-exists-p org-babel-temporary-directory) | ||
| 1839 | org-babel-temporary-directory) | ||
| 1840 | (make-temp-file "babel-" t)) | ||
| 1841 | "Directory to hold temporary files created to execute code blocks. | ||
| 1842 | Used by `org-babel-temp-file'. This directory will be removed on | ||
| 1843 | Emacs shutdown.")) | ||
| 1844 | |||
| 1845 | (defun org-babel-temp-file (prefix &optional suffix) | ||
| 1846 | "Create a temporary file in the `org-babel-temporary-directory'. | ||
| 1847 | Passes PREFIX and SUFFIX directly to `make-temp-file' with the | ||
| 1848 | value of `temporary-file-directory' temporarily set to the value | ||
| 1849 | of `org-babel-temporary-directory'." | ||
| 1850 | (if (file-remote-p default-directory) | ||
| 1851 | (make-temp-file | ||
| 1852 | (concat (file-remote-p default-directory) | ||
| 1853 | (expand-file-name | ||
| 1854 | prefix temporary-file-directory) | ||
| 1855 | nil suffix)) | ||
| 1856 | (let ((temporary-file-directory | ||
| 1857 | (or (and (file-exists-p org-babel-temporary-directory) | ||
| 1858 | org-babel-temporary-directory) | ||
| 1859 | temporary-file-directory))) | ||
| 1860 | (make-temp-file prefix nil suffix)))) | ||
| 1861 | |||
| 1862 | (defun org-babel-remove-temporary-directory () | ||
| 1863 | "Remove `org-babel-temporary-directory' on Emacs shutdown." | ||
| 1864 | (when (and (boundp 'org-babel-temporary-directory) | ||
| 1865 | (file-exists-p org-babel-temporary-directory)) | ||
| 1866 | ;; taken from `delete-directory' in files.el | ||
| 1867 | (mapc (lambda (file) | ||
| 1868 | ;; This test is equivalent to | ||
| 1869 | ;; (and (file-directory-p fn) (not (file-symlink-p fn))) | ||
| 1870 | ;; but more efficient | ||
| 1871 | (if (eq t (car (file-attributes file))) | ||
| 1872 | (delete-directory file) | ||
| 1873 | (delete-file file))) | ||
| 1874 | ;; We do not want to delete "." and "..". | ||
| 1875 | (directory-files org-babel-temporary-directory 'full | ||
| 1876 | "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*")) | ||
| 1877 | (delete-directory org-babel-temporary-directory))) | ||
| 1878 | |||
| 1879 | (add-hook 'kill-emacs-hook 'org-babel-remove-temporary-directory) | ||
| 1880 | |||
| 1588 | (provide 'ob) | 1881 | (provide 'ob) |
| 1589 | 1882 | ||
| 1590 | ;; arch-tag: 01a7ebee-06c5-4ee4-a709-e660d28c0af1 | 1883 | ;; arch-tag: 01a7ebee-06c5-4ee4-a709-e660d28c0af1 |
diff --git a/lisp/org/org-agenda.el b/lisp/org/org-agenda.el index 68a592b5fae..1c9d6d4a3de 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.01 | 9 | ;; Version: 7.3 |
| 10 | ;; | 10 | ;; |
| 11 | ;; This file is part of GNU Emacs. | 11 | ;; This file is part of GNU Emacs. |
| 12 | ;; | 12 | ;; |
| @@ -62,6 +62,7 @@ | |||
| 62 | (declare-function org-habit-parse-todo "org-habit" (&optional pom)) | 62 | (declare-function org-habit-parse-todo "org-habit" (&optional pom)) |
| 63 | (declare-function org-habit-get-priority "org-habit" (habit &optional moment)) | 63 | (declare-function org-habit-get-priority "org-habit" (habit &optional moment)) |
| 64 | (defvar calendar-mode-map) | 64 | (defvar calendar-mode-map) |
| 65 | (defvar org-clock-current-task) ; defined in org-clock.el | ||
| 65 | (defvar org-mobile-force-id-on-agenda-items) ; defined in org-mobile.el | 66 | (defvar org-mobile-force-id-on-agenda-items) ; defined in org-mobile.el |
| 66 | (defvar org-habit-show-habits) | 67 | (defvar org-habit-show-habits) |
| 67 | (defvar org-habit-show-habits-only-for-today) | 68 | (defvar org-habit-show-habits-only-for-today) |
| @@ -749,6 +750,22 @@ N days, just insert a special line indicating the size of the gap." | |||
| 749 | :tag "Org Agenda Startup" | 750 | :tag "Org Agenda Startup" |
| 750 | :group 'org-agenda) | 751 | :group 'org-agenda) |
| 751 | 752 | ||
| 753 | (defcustom org-agenda-menu-show-matcher t | ||
| 754 | "Non-nil menas show the match string in the agenda dispatcher menu. | ||
| 755 | When nil, the matcher string is not shown, but is put into the help-echo | ||
| 756 | property so than moving the mouse over the command shows it. | ||
| 757 | Setting it to nil is good if matcher strings are very long and/or if | ||
| 758 | you wnat to use two-column display (see `org-agenda-menu-two-column')." | ||
| 759 | :group 'org-agenda | ||
| 760 | :type 'boolean) | ||
| 761 | |||
| 762 | (defcustom org-agenda-menu-two-column nil | ||
| 763 | "Non-nil means, use two columns to show custom commands in the dispatcher. | ||
| 764 | If you use this, you probably want to set `org-agenda-menu-show-matcher' | ||
| 765 | to nil." | ||
| 766 | :group 'org-agenda | ||
| 767 | :type 'boolean) | ||
| 768 | |||
| 752 | (defcustom org-finalize-agenda-hook nil | 769 | (defcustom org-finalize-agenda-hook nil |
| 753 | "Hook run just before displaying an agenda buffer." | 770 | "Hook run just before displaying an agenda buffer." |
| 754 | :group 'org-agenda-startup | 771 | :group 'org-agenda-startup |
| @@ -1359,7 +1376,7 @@ When non-nil, this must be the number of minutes, e.g. 60 for one hour." | |||
| 1359 | "Regular expression used to filter away specific tags in agenda views. | 1376 | "Regular expression used to filter away specific tags in agenda views. |
| 1360 | This means that these tags will be present, but not be shown in the agenda | 1377 | This means that these tags will be present, but not be shown in the agenda |
| 1361 | line. Secondary filtering will still work on the hidden tags. | 1378 | line. Secondary filtering will still work on the hidden tags. |
| 1362 | The value nil means don't hide any tags." | 1379 | Nil means don't hide any tags." |
| 1363 | :group 'org-agenda-line-format | 1380 | :group 'org-agenda-line-format |
| 1364 | :type '(choice | 1381 | :type '(choice |
| 1365 | (const :tag "Hide none" nil) | 1382 | (const :tag "Hide none" nil) |
| @@ -1471,6 +1488,18 @@ the lower-case version of all tags." | |||
| 1471 | (require 'cl)) | 1488 | (require 'cl)) |
| 1472 | (require 'org) | 1489 | (require 'org) |
| 1473 | 1490 | ||
| 1491 | (defmacro org-agenda-with-point-at-orig-entry (string &rest body) | ||
| 1492 | "Execute BODY with point at location given by `org-hd-marker' property. | ||
| 1493 | If STRING is non-nil, the text property will be fetched from position 0 | ||
| 1494 | in that string. If STRING is nil, it will be fetched from the beginning | ||
| 1495 | of the current line." | ||
| 1496 | `(let ((marker (get-text-property (if string 0 (point-at-bol)) | ||
| 1497 | 'org-hd-marker string))) | ||
| 1498 | (with-current-buffer (marker-buffer marker) | ||
| 1499 | (save-excursion | ||
| 1500 | (goto-char marker) | ||
| 1501 | ,@body)))) | ||
| 1502 | |||
| 1474 | (defun org-add-agenda-custom-command (entry) | 1503 | (defun org-add-agenda-custom-command (entry) |
| 1475 | "Replace or add a command in `org-agenda-custom-commands'. | 1504 | "Replace or add a command in `org-agenda-custom-commands'. |
| 1476 | This is mostly for hacking and trying a new command - once the command | 1505 | This is mostly for hacking and trying a new command - once the command |
| @@ -1651,7 +1680,7 @@ The following commands are available: | |||
| 1651 | (org-defkey org-agenda-mode-map "\C-c\C-x\C-x" 'org-agenda-clock-cancel) | 1680 | (org-defkey org-agenda-mode-map "\C-c\C-x\C-x" 'org-agenda-clock-cancel) |
| 1652 | (org-defkey org-agenda-mode-map "X" 'org-agenda-clock-cancel) | 1681 | (org-defkey org-agenda-mode-map "X" 'org-agenda-clock-cancel) |
| 1653 | (org-defkey org-agenda-mode-map "\C-c\C-x\C-j" 'org-clock-goto) | 1682 | (org-defkey org-agenda-mode-map "\C-c\C-x\C-j" 'org-clock-goto) |
| 1654 | (org-defkey org-agenda-mode-map "J" 'org-clock-goto) | 1683 | (org-defkey org-agenda-mode-map "J" 'org-agenda-clock-goto) |
| 1655 | (org-defkey org-agenda-mode-map "+" 'org-agenda-priority-up) | 1684 | (org-defkey org-agenda-mode-map "+" 'org-agenda-priority-up) |
| 1656 | (org-defkey org-agenda-mode-map "-" 'org-agenda-priority-down) | 1685 | (org-defkey org-agenda-mode-map "-" 'org-agenda-priority-down) |
| 1657 | (org-defkey org-agenda-mode-map [(shift up)] 'org-agenda-priority-up) | 1686 | (org-defkey org-agenda-mode-map [(shift up)] 'org-agenda-priority-up) |
| @@ -2073,7 +2102,8 @@ Pressing `<' twice means to restrict to the current subtree or region | |||
| 2073 | (custom org-agenda-custom-commands) | 2102 | (custom org-agenda-custom-commands) |
| 2074 | (selstring "") | 2103 | (selstring "") |
| 2075 | restriction second-time | 2104 | restriction second-time |
| 2076 | c entry key type match prefixes rmheader header-end custom1 desc) | 2105 | c entry key type match prefixes rmheader header-end custom1 desc |
| 2106 | line lines left right n n1) | ||
| 2077 | (save-window-excursion | 2107 | (save-window-excursion |
| 2078 | (delete-other-windows) | 2108 | (delete-other-windows) |
| 2079 | (org-switch-to-buffer-other-window " *Agenda Commands*") | 2109 | (org-switch-to-buffer-other-window " *Agenda Commands*") |
| @@ -2111,56 +2141,91 @@ s Search for keywords C Configure custom agenda commands | |||
| 2111 | (move-marker header-end (match-end 0))) | 2141 | (move-marker header-end (match-end 0))) |
| 2112 | (goto-char header-end) | 2142 | (goto-char header-end) |
| 2113 | (delete-region (point) (point-max)) | 2143 | (delete-region (point) (point-max)) |
| 2144 | |||
| 2145 | ;; Produce all the lines that describe custom commands and prefixes | ||
| 2146 | (setq lines nil) | ||
| 2114 | (while (setq entry (pop custom1)) | 2147 | (while (setq entry (pop custom1)) |
| 2115 | (setq key (car entry) desc (nth 1 entry) | 2148 | (setq key (car entry) desc (nth 1 entry) |
| 2116 | type (nth 2 entry) | 2149 | type (nth 2 entry) |
| 2117 | match (nth 3 entry)) | 2150 | match (nth 3 entry)) |
| 2118 | (if (> (length key) 1) | 2151 | (if (> (length key) 1) |
| 2119 | (add-to-list 'prefixes (string-to-char key)) | 2152 | (add-to-list 'prefixes (string-to-char key)) |
| 2120 | (insert | 2153 | (setq line |
| 2121 | (format | 2154 | (format |
| 2122 | "\n%-4s%-14s: %s" | 2155 | "%-4s%-14s" |
| 2123 | (org-add-props (copy-sequence key) | 2156 | (org-add-props (copy-sequence key) |
| 2124 | '(face bold)) | 2157 | '(face bold)) |
| 2125 | (cond | 2158 | (cond |
| 2126 | ((string-match "\\S-" desc) desc) | 2159 | ((string-match "\\S-" desc) desc) |
| 2127 | ((eq type 'agenda) "Agenda for current week or day") | 2160 | ((eq type 'agenda) "Agenda for current week or day") |
| 2128 | ((eq type 'alltodo) "List of all TODO entries") | 2161 | ((eq type 'alltodo) "List of all TODO entries") |
| 2129 | ((eq type 'search) "Word search") | 2162 | ((eq type 'search) "Word search") |
| 2130 | ((eq type 'stuck) "List of stuck projects") | 2163 | ((eq type 'stuck) "List of stuck projects") |
| 2131 | ((eq type 'todo) "TODO keyword") | 2164 | ((eq type 'todo) "TODO keyword") |
| 2132 | ((eq type 'tags) "Tags query") | 2165 | ((eq type 'tags) "Tags query") |
| 2133 | ((eq type 'tags-todo) "Tags (TODO)") | 2166 | ((eq type 'tags-todo) "Tags (TODO)") |
| 2134 | ((eq type 'tags-tree) "Tags tree") | 2167 | ((eq type 'tags-tree) "Tags tree") |
| 2135 | ((eq type 'todo-tree) "TODO kwd tree") | 2168 | ((eq type 'todo-tree) "TODO kwd tree") |
| 2136 | ((eq type 'occur-tree) "Occur tree") | 2169 | ((eq type 'occur-tree) "Occur tree") |
| 2137 | ((functionp type) (if (symbolp type) | 2170 | ((functionp type) (if (symbolp type) |
| 2138 | (symbol-name type) | 2171 | (symbol-name type) |
| 2139 | "Lambda expression")) | 2172 | "Lambda expression")) |
| 2140 | (t "???")) | 2173 | (t "???")))) |
| 2141 | (cond | 2174 | (if org-agenda-menu-show-matcher |
| 2142 | ((stringp match) | 2175 | (setq line |
| 2143 | (setq match (copy-sequence match)) | 2176 | (concat line ": " |
| 2144 | (org-add-props match nil 'face 'org-warning)) | 2177 | (cond |
| 2145 | (match | 2178 | ((stringp match) |
| 2146 | (format "set of %d commands" (length match))) | 2179 | (setq match (copy-sequence match)) |
| 2147 | (t "")))))) | 2180 | (org-add-props match nil 'face 'org-warning)) |
| 2181 | (match | ||
| 2182 | (format "set of %d commands" (length match))) | ||
| 2183 | (t "")))) | ||
| 2184 | (if (org-string-nw-p match) | ||
| 2185 | (add-text-properties | ||
| 2186 | 0 (length line) (list 'help-echo | ||
| 2187 | (concat "Matcher: "match)) line))) | ||
| 2188 | (push line lines))) | ||
| 2189 | (setq lines (nreverse lines)) | ||
| 2148 | (when prefixes | 2190 | (when prefixes |
| 2149 | (mapc (lambda (x) | 2191 | (mapc (lambda (x) |
| 2150 | (insert | 2192 | (push |
| 2151 | (format "\n%s %s" | 2193 | (format "%s %s" |
| 2152 | (org-add-props (char-to-string x) | 2194 | (org-add-props (char-to-string x) |
| 2153 | nil 'face 'bold) | 2195 | nil 'face 'bold) |
| 2154 | (or (cdr (assoc (concat selstring (char-to-string x)) | 2196 | (or (cdr (assoc (concat selstring |
| 2197 | (char-to-string x)) | ||
| 2155 | prefix-descriptions)) | 2198 | prefix-descriptions)) |
| 2156 | "Prefix key")))) | 2199 | "Prefix key")) |
| 2200 | lines)) | ||
| 2157 | prefixes)) | 2201 | prefixes)) |
| 2202 | |||
| 2203 | ;; Check if we should display in two columns | ||
| 2204 | (if org-agenda-menu-two-column | ||
| 2205 | (progn | ||
| 2206 | (setq n (length lines) | ||
| 2207 | n1 (+ (/ n 2) (mod n 2)) | ||
| 2208 | right (nthcdr n1 lines) | ||
| 2209 | left (copy-sequence lines)) | ||
| 2210 | (setcdr (nthcdr (1- n1) left) nil)) | ||
| 2211 | (setq left lines right nil)) | ||
| 2212 | (while left | ||
| 2213 | (insert "\n" (pop left)) | ||
| 2214 | (when right | ||
| 2215 | (if (< (current-column) 40) | ||
| 2216 | (move-to-column 40 t) | ||
| 2217 | (insert " ")) | ||
| 2218 | (insert (pop right)))) | ||
| 2219 | |||
| 2220 | ;; Make the window the right size | ||
| 2158 | (goto-char (point-min)) | 2221 | (goto-char (point-min)) |
| 2159 | (if second-time | 2222 | (if second-time |
| 2160 | (if (not (pos-visible-in-window-p (point-max))) | 2223 | (if (not (pos-visible-in-window-p (point-max))) |
| 2161 | (org-fit-window-to-buffer)) | 2224 | (org-fit-window-to-buffer)) |
| 2162 | (setq second-time t) | 2225 | (setq second-time t) |
| 2163 | (org-fit-window-to-buffer)) | 2226 | (org-fit-window-to-buffer)) |
| 2227 | |||
| 2228 | ;; Ask for selection | ||
| 2164 | (message "Press key for agenda command%s:" | 2229 | (message "Press key for agenda command%s:" |
| 2165 | (if (or restrict-ok org-agenda-overriding-restriction) | 2230 | (if (or restrict-ok org-agenda-overriding-restriction) |
| 2166 | (if org-agenda-overriding-restriction | 2231 | (if org-agenda-overriding-restriction |
| @@ -2450,16 +2515,15 @@ higher priority settings." | |||
| 2450 | (interactive "FWrite agenda to file: \nP") | 2515 | (interactive "FWrite agenda to file: \nP") |
| 2451 | (if (not (file-writable-p file)) | 2516 | (if (not (file-writable-p file)) |
| 2452 | (error "Cannot write agenda to file %s" file)) | 2517 | (error "Cannot write agenda to file %s" file)) |
| 2453 | (cond | ||
| 2454 | ((string-match "\\.html?\\'" file) (require 'htmlize)) | ||
| 2455 | ((string-match "\\.ps\\'" file) (require 'ps-print))) | ||
| 2456 | (org-let (if nosettings nil org-agenda-exporter-settings) | 2518 | (org-let (if nosettings nil org-agenda-exporter-settings) |
| 2457 | `(save-excursion | 2519 | '(save-excursion |
| 2458 | (save-window-excursion | 2520 | (save-window-excursion |
| 2459 | (org-agenda-mark-filtered-text) | 2521 | (org-agenda-mark-filtered-text) |
| 2460 | (let ((bs (copy-sequence (buffer-string))) beg) | 2522 | (let ((bs (copy-sequence (buffer-string))) beg) |
| 2461 | (org-agenda-unmark-filtered-text) | 2523 | (org-agenda-unmark-filtered-text) |
| 2462 | (with-temp-buffer | 2524 | (with-temp-buffer |
| 2525 | (rename-buffer "Agenda View" t) | ||
| 2526 | (set-buffer-modified-p nil) | ||
| 2463 | (insert bs) | 2527 | (insert bs) |
| 2464 | (org-agenda-remove-marked-text 'org-filtered) | 2528 | (org-agenda-remove-marked-text 'org-filtered) |
| 2465 | (while (setq beg (text-property-any (point-min) (point-max) | 2529 | (while (setq beg (text-property-any (point-min) (point-max) |
| @@ -2472,6 +2536,7 @@ higher priority settings." | |||
| 2472 | ((org-bound-and-true-p org-mobile-creating-agendas) | 2536 | ((org-bound-and-true-p org-mobile-creating-agendas) |
| 2473 | (org-mobile-write-agenda-for-mobile file)) | 2537 | (org-mobile-write-agenda-for-mobile file)) |
| 2474 | ((string-match "\\.html?\\'" file) | 2538 | ((string-match "\\.html?\\'" file) |
| 2539 | (require 'htmlize) | ||
| 2475 | (set-buffer (htmlize-buffer (current-buffer))) | 2540 | (set-buffer (htmlize-buffer (current-buffer))) |
| 2476 | 2541 | ||
| 2477 | (when (and org-agenda-export-html-style | 2542 | (when (and org-agenda-export-html-style |
| @@ -2486,18 +2551,17 @@ higher priority settings." | |||
| 2486 | (message "HTML written to %s" file)) | 2551 | (message "HTML written to %s" file)) |
| 2487 | ((string-match "\\.ps\\'" file) | 2552 | ((string-match "\\.ps\\'" file) |
| 2488 | (require 'ps-print) | 2553 | (require 'ps-print) |
| 2489 | ,(flet ((ps-get-buffer-name () "Agenda View")) | 2554 | (ps-print-buffer-with-faces file) |
| 2490 | (ps-print-buffer-with-faces file)) | ||
| 2491 | (message "Postscript written to %s" file)) | 2555 | (message "Postscript written to %s" file)) |
| 2492 | ((string-match "\\.pdf\\'" file) | 2556 | ((string-match "\\.pdf\\'" file) |
| 2493 | (require 'ps-print) | 2557 | (require 'ps-print) |
| 2494 | ,(flet ((ps-get-buffer-name () "Agenda View")) | 2558 | (ps-print-buffer-with-faces |
| 2495 | (ps-print-buffer-with-faces | 2559 | (concat (file-name-sans-extension file) ".ps")) |
| 2496 | (concat (file-name-sans-extension file) ".ps"))) | ||
| 2497 | (call-process "ps2pdf" nil nil nil | 2560 | (call-process "ps2pdf" nil nil nil |
| 2498 | (expand-file-name | 2561 | (expand-file-name |
| 2499 | (concat (file-name-sans-extension file) ".ps")) | 2562 | (concat (file-name-sans-extension file) ".ps")) |
| 2500 | (expand-file-name file)) | 2563 | (expand-file-name file)) |
| 2564 | (delete-file (concat (file-name-sans-extension file) ".ps")) | ||
| 2501 | (message "PDF written to %s" file)) | 2565 | (message "PDF written to %s" file)) |
| 2502 | ((string-match "\\.ics\\'" file) | 2566 | ((string-match "\\.ics\\'" file) |
| 2503 | (require 'org-icalendar) | 2567 | (require 'org-icalendar) |
| @@ -2563,7 +2627,9 @@ Drawers will be excluded, also the line with scheduling/deadline info." | |||
| 2563 | (setq txt (org-agenda-get-some-entry-text | 2627 | (setq txt (org-agenda-get-some-entry-text |
| 2564 | m org-agenda-add-entry-text-maxlines " > ")) | 2628 | m org-agenda-add-entry-text-maxlines " > ")) |
| 2565 | (end-of-line 1) | 2629 | (end-of-line 1) |
| 2566 | (if (string-match "\\S-" txt) (insert "\n" txt))))))) | 2630 | (if (string-match "\\S-" txt) |
| 2631 | (insert "\n" txt) | ||
| 2632 | (or (eobp) (forward-char 1)))))))) | ||
| 2567 | 2633 | ||
| 2568 | (defun org-agenda-get-some-entry-text (marker n-lines &optional indent | 2634 | (defun org-agenda-get-some-entry-text (marker n-lines &optional indent |
| 2569 | &rest keep) | 2635 | &rest keep) |
| @@ -2717,7 +2783,10 @@ removed from the entry content. Currently only `planning' is allowed here." | |||
| 2717 | This must be a list of strings, each string must be a single tag preceded | 2783 | This must be a list of strings, each string must be a single tag preceded |
| 2718 | by \"+\" or \"-\". | 2784 | by \"+\" or \"-\". |
| 2719 | This variable should not be set directly, but agenda custom commands can | 2785 | This variable should not be set directly, but agenda custom commands can |
| 2720 | bind it in the options section.") | 2786 | bind it in the options section. The preset filter is a global property of |
| 2787 | the entire agenda view. In a block agenda, it will not work reliably to | ||
| 2788 | define a filter for one of the individual blocks. You need to set it in | ||
| 2789 | the global options and expect it to be applied to the entire view.") | ||
| 2721 | 2790 | ||
| 2722 | (defun org-prepare-agenda (&optional name) | 2791 | (defun org-prepare-agenda (&optional name) |
| 2723 | (setq org-todo-keywords-for-agenda nil) | 2792 | (setq org-todo-keywords-for-agenda nil) |
| @@ -2760,7 +2829,11 @@ bind it in the options section.") | |||
| 2760 | (switch-to-buffer-other-frame abuf)) | 2829 | (switch-to-buffer-other-frame abuf)) |
| 2761 | ((equal org-agenda-window-setup 'reorganize-frame) | 2830 | ((equal org-agenda-window-setup 'reorganize-frame) |
| 2762 | (delete-other-windows) | 2831 | (delete-other-windows) |
| 2763 | (org-switch-to-buffer-other-window abuf)))) | 2832 | (org-switch-to-buffer-other-window abuf))) |
| 2833 | ;; additional test in case agenda is invoked from within agenda | ||
| 2834 | ;; buffer via elisp link | ||
| 2835 | (unless (equal (current-buffer) abuf) | ||
| 2836 | (switch-to-buffer abuf))) | ||
| 2764 | (setq buffer-read-only nil) | 2837 | (setq buffer-read-only nil) |
| 2765 | (let ((inhibit-read-only t)) (erase-buffer)) | 2838 | (let ((inhibit-read-only t)) (erase-buffer)) |
| 2766 | (org-agenda-mode) | 2839 | (org-agenda-mode) |
| @@ -3009,7 +3082,8 @@ dates." | |||
| 3009 | (let* ((dopast t) | 3082 | (let* ((dopast t) |
| 3010 | (dotodo include-all) | 3083 | (dotodo include-all) |
| 3011 | (doclosed org-agenda-show-log) | 3084 | (doclosed org-agenda-show-log) |
| 3012 | (entry buffer-file-name) | 3085 | (entry (buffer-file-name (or (buffer-base-buffer (current-buffer)) |
| 3086 | (current-buffer)))) | ||
| 3013 | (date (calendar-current-date)) | 3087 | (date (calendar-current-date)) |
| 3014 | (beg (if (org-region-active-p) (region-beginning) (point-min))) | 3088 | (beg (if (org-region-active-p) (region-beginning) (point-min))) |
| 3015 | (end (if (org-region-active-p) (region-end) (point-max))) | 3089 | (end (if (org-region-active-p) (region-end) (point-max))) |
| @@ -3031,8 +3105,7 @@ dates." | |||
| 3031 | (setq day-numbers (delq nil (mapcar (lambda(x) | 3105 | (setq day-numbers (delq nil (mapcar (lambda(x) |
| 3032 | (if (>= x today) x nil)) | 3106 | (if (>= x today) x nil)) |
| 3033 | day-numbers)))) | 3107 | day-numbers)))) |
| 3034 | (org-prepare-agenda (concat "Timeline " | 3108 | (org-prepare-agenda (concat "Timeline " (file-name-nondirectory entry))) |
| 3035 | (file-name-nondirectory buffer-file-name))) | ||
| 3036 | (if doclosed (push :closed args)) | 3109 | (if doclosed (push :closed args)) |
| 3037 | (push :timestamp args) | 3110 | (push :timestamp args) |
| 3038 | (push :deadline args) | 3111 | (push :deadline args) |
| @@ -3483,6 +3556,20 @@ in `org-agenda-text-search-extra-files'." | |||
| 3483 | (member (string-to-char words) '(?- ?+ ?\{))) | 3556 | (member (string-to-char words) '(?- ?+ ?\{))) |
| 3484 | (setq boolean t)) | 3557 | (setq boolean t)) |
| 3485 | (setq words (org-split-string words)) | 3558 | (setq words (org-split-string words)) |
| 3559 | (let (www w) | ||
| 3560 | (while (setq w (pop words)) | ||
| 3561 | (while (and (string-match "\\\\\\'" w) words) | ||
| 3562 | (setq w (concat (substring w 0 -1) " " (pop words)))) | ||
| 3563 | (push w www)) | ||
| 3564 | (setq words (nreverse www) www nil) | ||
| 3565 | (while (setq w (pop words)) | ||
| 3566 | (when (and (string-match "\\`[-+]?{" w) | ||
| 3567 | (not (string-match "}\\'" w))) | ||
| 3568 | (while (and words (not (string-match "}\\'" (car words)))) | ||
| 3569 | (setq w (concat w " " (pop words)))) | ||
| 3570 | (setq w (concat w " " (pop words)))) | ||
| 3571 | (push w www)) | ||
| 3572 | (setq words (nreverse www))) | ||
| 3486 | (setq org-agenda-last-search-view-search-was-boolean boolean) | 3573 | (setq org-agenda-last-search-view-search-was-boolean boolean) |
| 3487 | (when boolean | 3574 | (when boolean |
| 3488 | (let (wds w) | 3575 | (let (wds w) |
| @@ -3933,8 +4020,7 @@ The remainder is either a list of TODO keywords, or a state symbol | |||
| 3933 | "Create agenda view for projects that are stuck. | 4020 | "Create agenda view for projects that are stuck. |
| 3934 | Stuck projects are project that have no next actions. For the definitions | 4021 | Stuck projects are project that have no next actions. For the definitions |
| 3935 | of what a project is and how to check if it stuck, customize the variable | 4022 | of what a project is and how to check if it stuck, customize the variable |
| 3936 | `org-stuck-projects'. | 4023 | `org-stuck-projects'." |
| 3937 | MATCH is being ignored." | ||
| 3938 | (interactive) | 4024 | (interactive) |
| 3939 | (let* ((org-agenda-skip-function | 4025 | (let* ((org-agenda-skip-function |
| 3940 | 'org-agenda-skip-entry-when-regexp-matches-in-subtree) | 4026 | 'org-agenda-skip-entry-when-regexp-matches-in-subtree) |
| @@ -3956,11 +4042,11 @@ MATCH is being ignored." | |||
| 3956 | "\\)\\>")) | 4042 | "\\)\\>")) |
| 3957 | (tags (nth 2 org-stuck-projects)) | 4043 | (tags (nth 2 org-stuck-projects)) |
| 3958 | (tags-re (if (member "*" tags) | 4044 | (tags-re (if (member "*" tags) |
| 3959 | (org-re "^\\*+ .*:[[:alnum:]_@]+:[ \t]*$") | 4045 | (org-re "^\\*+ .*:[[:alnum:]_@#%]+:[ \t]*$") |
| 3960 | (if tags | 4046 | (if tags |
| 3961 | (concat "^\\*+ .*:\\(" | 4047 | (concat "^\\*+ .*:\\(" |
| 3962 | (mapconcat 'identity tags "\\|") | 4048 | (mapconcat 'identity tags "\\|") |
| 3963 | (org-re "\\):[[:alnum:]_@:]*[ \t]*$"))))) | 4049 | (org-re "\\):[[:alnum:]_@#%:]*[ \t]*$"))))) |
| 3964 | (gen-re (nth 3 org-stuck-projects)) | 4050 | (gen-re (nth 3 org-stuck-projects)) |
| 3965 | (re-list | 4051 | (re-list |
| 3966 | (delq nil | 4052 | (delq nil |
| @@ -4413,17 +4499,20 @@ the documentation of `org-diary'." | |||
| 4413 | category (org-get-category beg) | 4499 | category (org-get-category beg) |
| 4414 | todo-state (org-get-todo-state)) | 4500 | todo-state (org-get-todo-state)) |
| 4415 | 4501 | ||
| 4416 | (if (string-match "\\S-" result) | 4502 | (dolist (r (if (stringp result) |
| 4417 | (setq txt result) | 4503 | (list result) |
| 4418 | (setq txt "SEXP entry returned empty string")) | 4504 | result)) ;; we expect a list here |
| 4419 | 4505 | (if (string-match "\\S-" r) | |
| 4420 | (setq txt (org-format-agenda-item | 4506 | (setq txt r) |
| 4421 | "" txt category tags 'time)) | 4507 | (setq txt "SEXP entry returned empty string")) |
| 4422 | (org-add-props txt props 'org-marker marker) | 4508 | |
| 4423 | (org-add-props txt nil | 4509 | (setq txt (org-format-agenda-item |
| 4424 | 'org-category category 'date date 'todo-state todo-state | 4510 | "" txt category tags 'time)) |
| 4425 | 'type "sexp") | 4511 | (org-add-props txt props 'org-marker marker) |
| 4426 | (push txt ee)))) | 4512 | (org-add-props txt nil |
| 4513 | 'org-category category 'date date 'todo-state todo-state | ||
| 4514 | 'type "sexp") | ||
| 4515 | (push txt ee))))) | ||
| 4427 | (nreverse ee))) | 4516 | (nreverse ee))) |
| 4428 | 4517 | ||
| 4429 | (defun org-diary-class (m1 d1 y1 m2 d2 y2 dayname &rest skip-weeks) | 4518 | (defun org-diary-class (m1 d1 y1 m2 d2 y2 dayname &rest skip-weeks) |
| @@ -4919,7 +5008,7 @@ Any match of REMOVE-RE will be removed from TXT." | |||
| 4919 | (setq h (/ m 60) m (- m (* h 60))) | 5008 | (setq h (/ m 60) m (- m (* h 60))) |
| 4920 | (setq s2 (format "%02d:%02d" h m)))) | 5009 | (setq s2 (format "%02d:%02d" h m)))) |
| 4921 | 5010 | ||
| 4922 | (when (string-match (org-re "\\([ \t]+\\)\\(:[[:alnum:]_@:]+:\\)[ \t]*$") | 5011 | (when (string-match (org-re "\\([ \t]+\\)\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$") |
| 4923 | txt) | 5012 | txt) |
| 4924 | ;; Tags are in the string | 5013 | ;; Tags are in the string |
| 4925 | (if (or (eq org-agenda-remove-tags t) | 5014 | (if (or (eq org-agenda-remove-tags t) |
| @@ -4993,7 +5082,7 @@ Any match of REMOVE-RE will be removed from TXT." | |||
| 4993 | The modified list may contain inherited tags, and tags matched by | 5082 | The modified list may contain inherited tags, and tags matched by |
| 4994 | `org-agenda-hide-tags-regexp' will be removed." | 5083 | `org-agenda-hide-tags-regexp' will be removed." |
| 4995 | (when (or add-inherited hide-re) | 5084 | (when (or add-inherited hide-re) |
| 4996 | (if (string-match (org-re "\\([ \t]+\\)\\(:[[:alnum:]_@:]+:\\)[ \t]*$") txt) | 5085 | (if (string-match (org-re "\\([ \t]+\\)\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$") txt) |
| 4997 | (setq txt (substring txt 0 (match-beginning 0)))) | 5086 | (setq txt (substring txt 0 (match-beginning 0)))) |
| 4998 | (setq tags | 5087 | (setq tags |
| 4999 | (delq nil | 5088 | (delq nil |
| @@ -5049,13 +5138,13 @@ The modified list may contain inherited tags, and tags matched by | |||
| 5049 | (throw 'exit list)) | 5138 | (throw 'exit list)) |
| 5050 | (while (setq time (pop gridtimes)) | 5139 | (while (setq time (pop gridtimes)) |
| 5051 | (unless (and remove (member time have)) | 5140 | (unless (and remove (member time have)) |
| 5052 | (setq time (int-to-string time)) | 5141 | (setq time (replace-regexp-in-string " " "0" (format "%04s" time))) |
| 5053 | (push (org-format-agenda-item | 5142 | (push (org-format-agenda-item |
| 5054 | nil string "" nil | 5143 | nil string "" nil |
| 5055 | (concat (substring time 0 -2) ":" (substring time -2))) | 5144 | (concat (substring time 0 -2) ":" (substring time -2))) |
| 5056 | new) | 5145 | new) |
| 5057 | (put-text-property | 5146 | (put-text-property |
| 5058 | 1 (length (car new)) 'face 'org-time-grid (car new)))) | 5147 | 2 (length (car new)) 'face 'org-time-grid (car new)))) |
| 5059 | (if (member 'time-up org-agenda-sorting-strategy-selected) | 5148 | (if (member 'time-up org-agenda-sorting-strategy-selected) |
| 5060 | (append new list) | 5149 | (append new list) |
| 5061 | (append list new))))) | 5150 | (append list new))))) |
| @@ -5142,11 +5231,33 @@ HH:MM." | |||
| 5142 | (int-to-string t0)))) | 5231 | (int-to-string t0)))) |
| 5143 | (if string (concat (substring t1 -4 -2) ":" (substring t1 -2)) t0))))) | 5232 | (if string (concat (substring t1 -4 -2) ":" (substring t1 -2)) t0))))) |
| 5144 | 5233 | ||
| 5234 | (defvar org-agenda-before-sorting-filter-function nil | ||
| 5235 | "Function to be applied to agenda items prior to sorting. | ||
| 5236 | Prior to sorting also means just before they are inserted into the agenda. | ||
| 5237 | |||
| 5238 | To aid sorting, you may revisit the original entries and add more text | ||
| 5239 | properties which will later be used by the sorting functions. | ||
| 5240 | |||
| 5241 | The function should take a string argument, an agenda line. | ||
| 5242 | It has access to the text properties in that line, which contain among | ||
| 5243 | other things, the property `org-hd-marker' that points to the entry | ||
| 5244 | where the line comes from. Note that not all lines going into the agenda | ||
| 5245 | have this property, only most. | ||
| 5246 | |||
| 5247 | The function should return the modified string. It is probably best | ||
| 5248 | to ONLY change text properties. | ||
| 5249 | |||
| 5250 | You can also use this function as a filter, by returning nil for lines | ||
| 5251 | you don't want to have in the agenda at all. For this application, you | ||
| 5252 | could bind the variable in the options section of a custom command.") | ||
| 5253 | |||
| 5145 | (defun org-finalize-agenda-entries (list &optional nosort) | 5254 | (defun org-finalize-agenda-entries (list &optional nosort) |
| 5146 | "Sort and concatenate the agenda items." | 5255 | "Sort and concatenate the agenda items." |
| 5147 | (setq list (mapcar 'org-agenda-highlight-todo list)) | 5256 | (setq list (mapcar 'org-agenda-highlight-todo list)) |
| 5148 | (if nosort | 5257 | (if nosort |
| 5149 | list | 5258 | list |
| 5259 | (when org-agenda-before-sorting-filter-function | ||
| 5260 | (setq list (delq nil (mapcar org-agenda-before-sorting-filter-function list)))) | ||
| 5150 | (mapconcat 'identity (sort list 'org-entries-lessp) "\n"))) | 5261 | (mapconcat 'identity (sort list 'org-entries-lessp) "\n"))) |
| 5151 | 5262 | ||
| 5152 | (defun org-agenda-highlight-todo (x) | 5263 | (defun org-agenda-highlight-todo (x) |
| @@ -5312,8 +5423,9 @@ HH:MM." | |||
| 5312 | (alpha-up (and (org-em 'alpha-up 'alpha-down ss) | 5423 | (alpha-up (and (org-em 'alpha-up 'alpha-down ss) |
| 5313 | (org-cmp-alpha a b))) | 5424 | (org-cmp-alpha a b))) |
| 5314 | (alpha-down (if alpha-up (- alpha-up) nil)) | 5425 | (alpha-down (if alpha-up (- alpha-up) nil)) |
| 5426 | (need-user-cmp (org-em 'user-defined-up 'user-defined-down ss)) | ||
| 5315 | user-defined-up user-defined-down) | 5427 | user-defined-up user-defined-down) |
| 5316 | (if (and org-agenda-cmp-user-defined | 5428 | (if (and need-user-cmp org-agenda-cmp-user-defined |
| 5317 | (functionp org-agenda-cmp-user-defined)) | 5429 | (functionp org-agenda-cmp-user-defined)) |
| 5318 | (setq user-defined-up | 5430 | (setq user-defined-up |
| 5319 | (funcall org-agenda-cmp-user-defined a b) | 5431 | (funcall org-agenda-cmp-user-defined a b) |
| @@ -5635,7 +5747,9 @@ If the line does not have an effort defined, return nil." | |||
| 5635 | (if (not (eval org-agenda-filter-form)) | 5747 | (if (not (eval org-agenda-filter-form)) |
| 5636 | (org-agenda-filter-by-tag-hide-line)) | 5748 | (org-agenda-filter-by-tag-hide-line)) |
| 5637 | (beginning-of-line 2)) | 5749 | (beginning-of-line 2)) |
| 5638 | (beginning-of-line 2)))))) | 5750 | (beginning-of-line 2)))) |
| 5751 | (if (get-char-property (point) 'invisible) | ||
| 5752 | (org-agenda-previous-line)))) | ||
| 5639 | 5753 | ||
| 5640 | (defun org-agenda-filter-by-tag-hide-line () | 5754 | (defun org-agenda-filter-by-tag-hide-line () |
| 5641 | (let (ov) | 5755 | (let (ov) |
| @@ -5712,7 +5826,9 @@ Negative selection means regexp must not match for selection of an entry." | |||
| 5712 | 5826 | ||
| 5713 | (defun org-agenda-goto-date (date) | 5827 | (defun org-agenda-goto-date (date) |
| 5714 | "Jump to DATE in agenda." | 5828 | "Jump to DATE in agenda." |
| 5715 | (interactive (list (org-read-date))) | 5829 | (interactive (list (let ((org-read-date-prefer-future |
| 5830 | (eval org-agenda-jump-prefer-future))) | ||
| 5831 | (org-read-date)))) | ||
| 5716 | (org-agenda-list nil date)) | 5832 | (org-agenda-list nil date)) |
| 5717 | 5833 | ||
| 5718 | (defun org-agenda-goto-today () | 5834 | (defun org-agenda-goto-today () |
| @@ -6636,7 +6752,7 @@ If FORCE-TAGS is non nil, the car of it returns the new tags." | |||
| 6636 | (let ((inhibit-read-only t) l c) | 6752 | (let ((inhibit-read-only t) l c) |
| 6637 | (save-excursion | 6753 | (save-excursion |
| 6638 | (goto-char (if line (point-at-bol) (point-min))) | 6754 | (goto-char (if line (point-at-bol) (point-min))) |
| 6639 | (while (re-search-forward (org-re "\\([ \t]+\\)\\(:[[:alnum:]_@:]+:\\)[ \t]*$") | 6755 | (while (re-search-forward (org-re "\\([ \t]+\\)\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$") |
| 6640 | (if line (point-at-eol) nil) t) | 6756 | (if line (point-at-eol) nil) t) |
| 6641 | (add-text-properties | 6757 | (add-text-properties |
| 6642 | (match-beginning 2) (match-end 2) | 6758 | (match-beginning 2) (match-end 2) |
| @@ -7059,9 +7175,9 @@ The cursor may be at a date in the calendar, or in the Org agenda." | |||
| 7059 | (setq newhead (org-get-heading))) | 7175 | (setq newhead (org-get-heading))) |
| 7060 | (org-agenda-change-all-lines newhead hdmarker))))) | 7176 | (org-agenda-change-all-lines newhead hdmarker))))) |
| 7061 | 7177 | ||
| 7062 | (defun org-agenda-clock-out (&optional arg) | 7178 | (defun org-agenda-clock-out () |
| 7063 | "Stop the currently running clock." | 7179 | "Stop the currently running clock." |
| 7064 | (interactive "P") | 7180 | (interactive) |
| 7065 | (unless (marker-buffer org-clock-marker) | 7181 | (unless (marker-buffer org-clock-marker) |
| 7066 | (error "No running clock")) | 7182 | (error "No running clock")) |
| 7067 | (let ((marker (make-marker)) newhead) | 7183 | (let ((marker (make-marker)) newhead) |
| @@ -7086,6 +7202,23 @@ The cursor may be at a date in the calendar, or in the Org agenda." | |||
| 7086 | (org-with-remote-undo (marker-buffer org-clock-marker) | 7202 | (org-with-remote-undo (marker-buffer org-clock-marker) |
| 7087 | (org-clock-cancel))) | 7203 | (org-clock-cancel))) |
| 7088 | 7204 | ||
| 7205 | (defun org-agenda-clock-goto () | ||
| 7206 | "Jump to the currently clocked in task within the agenda. | ||
| 7207 | If the currently clocked in task is not listed in the agenda | ||
| 7208 | buffer, display it in another window." | ||
| 7209 | (interactive) | ||
| 7210 | (let (pos) | ||
| 7211 | (mapc (lambda (o) | ||
| 7212 | (if (eq (overlay-get o 'type) 'org-agenda-clocking) | ||
| 7213 | (setq pos (overlay-start o)))) | ||
| 7214 | (overlays-in (point-min) (point-max))) | ||
| 7215 | (cond (pos (goto-char pos)) | ||
| 7216 | ;; If the currently clocked entry is not in the agenda | ||
| 7217 | ;; buffer, we visit it in another window: | ||
| 7218 | (org-clock-current-task | ||
| 7219 | (org-switch-to-buffer-other-window (org-clock-goto))) | ||
| 7220 | (t (message "No running clock, use `C-c C-x C-j' to jump to the most recent one"))))) | ||
| 7221 | |||
| 7089 | (defun org-agenda-diary-entry-in-org-file () | 7222 | (defun org-agenda-diary-entry-in-org-file () |
| 7090 | "Make a diary entry in the file `org-agenda-diary-file'." | 7223 | "Make a diary entry in the file `org-agenda-diary-file'." |
| 7091 | (let (d1 d2 char (text "") dp1 dp2) | 7224 | (let (d1 d2 char (text "") dp1 dp2) |
| @@ -7171,7 +7304,8 @@ the resulting entry will not be shown. When TEXT is empty, switch to | |||
| 7171 | (let ((calendar-date-display-form | 7304 | (let ((calendar-date-display-form |
| 7172 | (if (if (boundp 'calendar-date-style) | 7305 | (if (if (boundp 'calendar-date-style) |
| 7173 | (eq calendar-date-style 'european) | 7306 | (eq calendar-date-style 'european) |
| 7174 | (org-bound-and-true-p european-calendar-style)) ; Emacs 22 | 7307 | (with-no-warnings ;; european-calendar-style is obsolete as of version 23.1 |
| 7308 | (org-bound-and-true-p european-calendar-style))) ; Emacs 22 | ||
| 7175 | '(day " " month " " year) | 7309 | '(day " " month " " year) |
| 7176 | '(month " " day " " year)))) | 7310 | '(month " " day " " year)))) |
| 7177 | 7311 | ||
diff --git a/lisp/org/org-archive.el b/lisp/org/org-archive.el index 31ae488d4d8..8c1f9a13a12 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.01 | 9 | ;; Version: 7.3 |
| 10 | ;; | 10 | ;; |
| 11 | ;; This file is part of GNU Emacs. | 11 | ;; This file is part of GNU Emacs. |
| 12 | ;; | 12 | ;; |
| @@ -115,7 +115,7 @@ information." | |||
| 115 | ((or (re-search-backward re nil t) | 115 | ((or (re-search-backward re nil t) |
| 116 | (re-search-forward re nil t)) | 116 | (re-search-forward re nil t)) |
| 117 | (match-string 1)) | 117 | (match-string 1)) |
| 118 | (t org-archive-location (match-string 1))))))) | 118 | (t org-archive-location)))))) |
| 119 | 119 | ||
| 120 | (defun org-add-archive-files (files) | 120 | (defun org-add-archive-files (files) |
| 121 | "Splice the archive files into the list of files. | 121 | "Splice the archive files into the list of files. |
| @@ -268,7 +268,7 @@ this heading." | |||
| 268 | (progn | 268 | (progn |
| 269 | (if (re-search-forward | 269 | (if (re-search-forward |
| 270 | (concat "^" (regexp-quote heading) | 270 | (concat "^" (regexp-quote heading) |
| 271 | (org-re "[ \t]*\\(:[[:alnum:]_@:]+:\\)?[ \t]*\\($\\|\r\\)")) | 271 | (org-re "[ \t]*\\(:[[:alnum:]_@#%:]+:\\)?[ \t]*\\($\\|\r\\)")) |
| 272 | nil t) | 272 | nil t) |
| 273 | (goto-char (match-end 0)) | 273 | (goto-char (match-end 0)) |
| 274 | ;; Heading not found, just insert it at the end | 274 | ;; Heading not found, just insert it at the end |
diff --git a/lisp/org/org-ascii.el b/lisp/org/org-ascii.el index 730f8bdfa41..b48f8efa1cd 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.01 | 9 | ;; Version: 7.3 |
| 10 | ;; | 10 | ;; |
| 11 | ;; This file is part of GNU Emacs. | 11 | ;; This file is part of GNU Emacs. |
| 12 | ;; | 12 | ;; |
| @@ -311,7 +311,7 @@ publishing directory." | |||
| 311 | :add-text (plist-get opt-plist :text)) | 311 | :add-text (plist-get opt-plist :text)) |
| 312 | "\n")) | 312 | "\n")) |
| 313 | thetoc have-headings first-heading-pos | 313 | thetoc have-headings first-heading-pos |
| 314 | table-open table-buffer link-buffer link desc desc0 rpl wrap) | 314 | table-open table-buffer link-buffer link type path desc desc0 rpl wrap fnc) |
| 315 | (let ((inhibit-read-only t)) | 315 | (let ((inhibit-read-only t)) |
| 316 | (org-unmodified | 316 | (org-unmodified |
| 317 | (remove-text-properties (point-min) (point-max) | 317 | (remove-text-properties (point-min) (point-max) |
| @@ -347,7 +347,7 @@ publishing directory." | |||
| 347 | 347 | ||
| 348 | (if (and (or author email) | 348 | (if (and (or author email) |
| 349 | org-export-author-info) | 349 | org-export-author-info) |
| 350 | (insert(concat (nth 1 lang-words) ": " (or author "") | 350 | (insert (concat (nth 1 lang-words) ": " (or author "") |
| 351 | (if (and org-export-email-info | 351 | (if (and org-export-email-info |
| 352 | email (string-match "\\S-" email)) | 352 | email (string-match "\\S-" email)) |
| 353 | (concat " <" email ">") "") | 353 | (concat " <" email ">") "") |
| @@ -400,7 +400,7 @@ publishing directory." | |||
| 400 | 400 | ||
| 401 | (if (and (memq org-export-with-tags '(not-in-toc nil)) | 401 | (if (and (memq org-export-with-tags '(not-in-toc nil)) |
| 402 | (string-match | 402 | (string-match |
| 403 | (org-re "[ \t]+:[[:alnum:]_@:]+:[ \t]*$") | 403 | (org-re "[ \t]+:[[:alnum:]_@#%:]+:[ \t]*$") |
| 404 | txt)) | 404 | txt)) |
| 405 | (setq txt (replace-match "" t t txt))) | 405 | (setq txt (replace-match "" t t txt))) |
| 406 | (if (string-match quote-re0 txt) | 406 | (if (string-match quote-re0 txt) |
| @@ -431,10 +431,12 @@ publishing directory." | |||
| 431 | ;; Remove the quoted HTML tags. | 431 | ;; Remove the quoted HTML tags. |
| 432 | (setq line (org-html-expand-for-ascii line)) | 432 | (setq line (org-html-expand-for-ascii line)) |
| 433 | ;; Replace links with the description when possible | 433 | ;; Replace links with the description when possible |
| 434 | (while (string-match org-bracket-link-regexp line) | 434 | (while (string-match org-bracket-link-analytic-regexp++ line) |
| 435 | (setq link (match-string 1 line) | 435 | (setq path (match-string 3 line) |
| 436 | desc0 (match-string 3 line) | 436 | link (concat (match-string 1 line) path) |
| 437 | desc (or desc0 (match-string 1 line))) | 437 | type (match-string 2 line) |
| 438 | desc0 (match-string 5 line) | ||
| 439 | desc (or desc0 link)) | ||
| 438 | (if (and (> (length link) 8) | 440 | (if (and (> (length link) 8) |
| 439 | (equal (substring link 0 8) "coderef:")) | 441 | (equal (substring link 0 8) "coderef:")) |
| 440 | (setq line (replace-match | 442 | (setq line (replace-match |
| @@ -443,15 +445,18 @@ publishing directory." | |||
| 443 | (substring link 8) | 445 | (substring link 8) |
| 444 | org-export-code-refs))) | 446 | org-export-code-refs))) |
| 445 | t t line)) | 447 | t t line)) |
| 446 | (setq rpl (concat "[" | 448 | (setq rpl (concat "[" desc "]")) |
| 447 | (or (match-string 3 line) (match-string 1 line)) | 449 | (if (functionp (setq fnc (nth 2 (assoc type org-link-protocols)))) |
| 448 | "]")) | 450 | (setq rpl (or (save-match-data |
| 449 | (when (and desc0 (not (equal desc0 link))) | 451 | (funcall fnc (org-link-unescape path) |
| 450 | (if org-export-ascii-links-to-notes | 452 | desc0 'ascii)) |
| 451 | (push (cons desc0 link) link-buffer) | 453 | rpl)) |
| 452 | (setq rpl (concat rpl " (" link ")") | 454 | (when (and desc0 (not (equal desc0 link))) |
| 453 | wrap (+ (length line) (- (length (match-string 0 line))) | 455 | (if org-export-ascii-links-to-notes |
| 454 | (length desc))))) | 456 | (push (cons desc0 link) link-buffer) |
| 457 | (setq rpl (concat rpl " (" link ")") | ||
| 458 | wrap (+ (length line) (- (length (match-string 0 line))) | ||
| 459 | (length desc)))))) | ||
| 455 | (setq line (replace-match rpl t t line)))) | 460 | (setq line (replace-match rpl t t line)))) |
| 456 | (when custom-times | 461 | (when custom-times |
| 457 | (setq line (org-translate-time line))) | 462 | (setq line (org-translate-time line))) |
| @@ -482,7 +487,8 @@ publishing directory." | |||
| 482 | (org-format-table-ascii table-buffer) | 487 | (org-format-table-ascii table-buffer) |
| 483 | "\n") "\n"))) | 488 | "\n") "\n"))) |
| 484 | (t | 489 | (t |
| 485 | (if (string-match "^\\([ \t]*\\)\\([-+*][ \t]+\\)\\(.*?\\)\\( ::\\)" line) | 490 | (if (string-match "^\\([ \t]*\\)\\([-+*][ \t]+\\)\\(.*?\\)\\( ::\\)" |
| 491 | line) | ||
| 486 | (setq line (replace-match "\\1\\3:" t nil line))) | 492 | (setq line (replace-match "\\1\\3:" t nil line))) |
| 487 | (setq line (org-fix-indentation line org-ascii-current-indentation)) | 493 | (setq line (org-fix-indentation line org-ascii-current-indentation)) |
| 488 | ;; Remove forced line breaks | 494 | ;; Remove forced line breaks |
| @@ -571,9 +577,12 @@ publishing directory." | |||
| 571 | (replace-match "\\1\\2"))) | 577 | (replace-match "\\1\\2"))) |
| 572 | ;; Remove list start counters | 578 | ;; Remove list start counters |
| 573 | (goto-char (point-min)) | 579 | (goto-char (point-min)) |
| 574 | (while (re-search-forward "\\[@start:[0-9]+\\] ?" nil t) | 580 | (while (org-search-forward-unenclosed |
| 575 | (org-if-unprotected | 581 | "\\[@\\(?:start:\\)?[0-9]+\\][ \t]*" nil t) |
| 576 | (replace-match "")))) | 582 | (replace-match "")) |
| 583 | (remove-text-properties | ||
| 584 | (point-min) (point-max) | ||
| 585 | '(face nil font-lock-fontified nil font-lock-multiline nil line-prefix nil wrap-prefix nil))) | ||
| 577 | 586 | ||
| 578 | (defun org-html-expand-for-ascii (line) | 587 | (defun org-html-expand-for-ascii (line) |
| 579 | "Handle quoted HTML for ASCII export." | 588 | "Handle quoted HTML for ASCII export." |
| @@ -586,7 +595,7 @@ publishing directory." | |||
| 586 | (defun org-ascii-replace-entities () | 595 | (defun org-ascii-replace-entities () |
| 587 | "Replace entities with the ASCII representation." | 596 | "Replace entities with the ASCII representation." |
| 588 | (let (e) | 597 | (let (e) |
| 589 | (while (re-search-forward "\\\\\\([a-zA-Z]+[0-9]*\\)" nil t) | 598 | (while (re-search-forward "\\\\\\([a-zA-Z]+[0-9]*\\)\\({}\\)?" nil t) |
| 590 | (org-if-unprotected-at (match-beginning 1) | 599 | (org-if-unprotected-at (match-beginning 1) |
| 591 | (setq e (org-entity-get-representation (match-string 1) | 600 | (setq e (org-entity-get-representation (match-string 1) |
| 592 | org-export-ascii-entities)) | 601 | org-export-ascii-entities)) |
| @@ -645,7 +654,7 @@ publishing directory." | |||
| 645 | (insert "\n")) | 654 | (insert "\n")) |
| 646 | (setq char (nth (- umax level) (reverse org-export-ascii-underline))) | 655 | (setq char (nth (- umax level) (reverse org-export-ascii-underline))) |
| 647 | (unless org-export-with-tags | 656 | (unless org-export-with-tags |
| 648 | (if (string-match (org-re "[ \t]+\\(:[[:alnum:]_@:]+:\\)[ \t]*$") title) | 657 | (if (string-match (org-re "[ \t]+\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$") title) |
| 649 | (setq title (replace-match "" t t title)))) | 658 | (setq title (replace-match "" t t title)))) |
| 650 | (if org-export-with-section-numbers | 659 | (if org-export-with-section-numbers |
| 651 | (setq title (concat (org-section-number level) " " title))) | 660 | (setq title (concat (org-section-number level) " " title))) |
diff --git a/lisp/org/org-attach.el b/lisp/org/org-attach.el index 573244beed4..d98254cb659 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.01 | 7 | ;; Version: 7.3 |
| 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 0d7b5fa086a..d5a09cab63b 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.01 | 10 | ;; Version: 7.3 |
| 11 | ;; | 11 | ;; |
| 12 | ;; This file is part of GNU Emacs. | 12 | ;; This file is part of GNU Emacs. |
| 13 | ;; | 13 | ;; |
| @@ -322,8 +322,8 @@ This is used by Org to re-create the anniversary hash table." | |||
| 322 | (when rec | 322 | (when rec |
| 323 | (let* ((class (or (nth 2 rec) | 323 | (let* ((class (or (nth 2 rec) |
| 324 | org-bbdb-default-anniversary-format)) | 324 | org-bbdb-default-anniversary-format)) |
| 325 | (form (or (cdr (assoc class | 325 | (form (or (cdr (assoc-string |
| 326 | org-bbdb-anniversary-format-alist)) | 326 | class org-bbdb-anniversary-format-alist t)) |
| 327 | class)) ; (as format string) | 327 | class)) ; (as format string) |
| 328 | (name (nth 1 rec)) | 328 | (name (nth 1 rec)) |
| 329 | (years (- y (car rec))) | 329 | (years (- y (car rec))) |
| @@ -338,8 +338,7 @@ This is used by Org to re-create the anniversary hash table." | |||
| 338 | (setq text (append text (list tmp))) | 338 | (setq text (append text (list tmp))) |
| 339 | (setq text (list tmp))))) | 339 | (setq text (list tmp))))) |
| 340 | )) | 340 | )) |
| 341 | (when text | 341 | text)) |
| 342 | (mapconcat 'identity text "; ")))) | ||
| 343 | 342 | ||
| 344 | (defun org-bbdb-complete-link () | 343 | (defun org-bbdb-complete-link () |
| 345 | "Read a bbdb link with name completion." | 344 | "Read a bbdb link with name completion." |
diff --git a/lisp/org/org-beamer.el b/lisp/org/org-beamer.el index 06853b8bd63..d3f0f47e45c 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.01 | 5 | ;; Version: 7.3 |
| 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 |
| @@ -373,7 +373,7 @@ The need to be after the begin statement of the environment." | |||
| 373 | (let (dovl) | 373 | (let (dovl) |
| 374 | (goto-char (point-min)) | 374 | (goto-char (point-min)) |
| 375 | (while (re-search-forward | 375 | (while (re-search-forward |
| 376 | "^[ \t]*\\\\begin{\\(itemize\\|enumerate\\|desctiption\\)}[ \t\n]*\\\\item\\>\\( ?\\(<[^<>\n]*>\\|\\[[^][\n*]\\]\\)\\)?[ \t]*\\S-" nil t) | 376 | "^[ \t]*\\\\begin{\\(itemize\\|enumerate\\|description\\)}[ \t\n]*\\\\item\\>\\( ?\\(<[^<>\n]*>\\|\\[[^][\n*]\\]\\)\\)?[ \t]*\\S-" nil t) |
| 377 | (if (setq dovl (cdr (assoc "BEAMER_dovl" | 377 | (if (setq dovl (cdr (assoc "BEAMER_dovl" |
| 378 | (get-text-property (match-end 0) | 378 | (get-text-property (match-end 0) |
| 379 | 'org-props)))) | 379 | 'org-props)))) |
| @@ -382,7 +382,7 @@ The need to be after the begin statement of the environment." | |||
| 382 | (insert dovl))))))) | 382 | (insert dovl))))))) |
| 383 | 383 | ||
| 384 | (defun org-beamer-amend-header () | 384 | (defun org-beamer-amend-header () |
| 385 | "Add `org-beamer-header-extra' to the LaTeX herder. | 385 | "Add `org-beamer-header-extra' to the LaTeX header. |
| 386 | If the file contains the string BEAMER-HEADER-EXTRA-HERE on a line | 386 | If the file contains the string BEAMER-HEADER-EXTRA-HERE on a line |
| 387 | by itself, it will be replaced with `org-beamer-header-extra'. If not, | 387 | by itself, it will be replaced with `org-beamer-header-extra'. If not, |
| 388 | the value will be inserted right after the documentclass statement." | 388 | the value will be inserted right after the documentclass statement." |
diff --git a/lisp/org/org-bibtex.el b/lisp/org/org-bibtex.el index f7f6595f5a1..b9018b023ba 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.01 | 8 | ;; Version: 7.3 |
| 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 c6197d69fb3..b463d29a389 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.01 | 8 | ;; Version: 7.3 |
| 9 | ;; | 9 | ;; |
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | ;; | 11 | ;; |
| @@ -76,6 +76,7 @@ | |||
| 76 | :tag "Org Capture" | 76 | :tag "Org Capture" |
| 77 | :group 'org) | 77 | :group 'org) |
| 78 | 78 | ||
| 79 | ;;;###autoload | ||
| 79 | (defcustom org-capture-templates nil | 80 | (defcustom org-capture-templates nil |
| 80 | "Templates for the creation of new entries. | 81 | "Templates for the creation of new entries. |
| 81 | 82 | ||
| @@ -185,6 +186,10 @@ properties are: | |||
| 185 | which means that the new line should become the third | 186 | which means that the new line should become the third |
| 186 | line before the second horizontal separator line. | 187 | line before the second horizontal separator line. |
| 187 | 188 | ||
| 189 | :kill-buffer If the target file was not yet visited by a buffer when | ||
| 190 | capture was invoked, kill the buffer again after capture | ||
| 191 | is finalized. | ||
| 192 | |||
| 188 | The template defines the text to be inserted. Often this is an org-mode | 193 | The template defines the text to be inserted. Often this is an org-mode |
| 189 | entry (so the first line should start with a star) that will be filed as a | 194 | entry (so the first line should start with a star) that will be filed as a |
| 190 | child of the target headline. It can also be freely formatted text. | 195 | child of the target headline. It can also be freely formatted text. |
| @@ -220,20 +225,23 @@ Furthermore, the following %-escapes will be replaced with content: | |||
| 220 | Apart from these general escapes, you can access information specific to the | 225 | Apart from these general escapes, you can access information specific to the |
| 221 | link type that is created. For example, calling `org-capture' in emails | 226 | link type that is created. For example, calling `org-capture' in emails |
| 222 | or gnus will record the author and the subject of the message, which you | 227 | or gnus will record the author and the subject of the message, which you |
| 223 | can access with \"%:author\" and \"%:subject\", respectively. Here is a | 228 | can access with \"%:from\" and \"%:subject\", respectively. Here is a |
| 224 | complete list of what is recorded for each link type. | 229 | complete list of what is recorded for each link type. |
| 225 | 230 | ||
| 226 | Link type | Available information | 231 | Link type | Available information |
| 227 | -------------------+------------------------------------------------------ | 232 | ------------------------+------------------------------------------------------ |
| 228 | bbdb | %:type %:name %:company | 233 | bbdb | %:type %:name %:company |
| 229 | vm, wl, mh, rmail | %:type %:subject %:message-id | 234 | vm, wl, mh, mew, rmail | %:type %:subject %:message-id |
| 230 | | %:from %:fromname %:fromaddress | 235 | | %:from %:fromname %:fromaddress |
| 231 | | %:to %:toname %:toaddress | 236 | | %:to %:toname %:toaddress |
| 232 | | %:fromto (either \"to NAME\" or \"from NAME\") | 237 | | %:fromto (either \"to NAME\" or \"from NAME\") |
| 233 | gnus | %:group, for messages also all email fields | 238 | | %:date |
| 234 | w3, w3m | %:type %:url | 239 | | %:date-timestamp (as active timestamp) |
| 235 | info | %:type %:file %:node | 240 | | %:date-timestamp-inactive (as inactive timestamp) |
| 236 | calendar | %:type %:date" | 241 | gnus | %:group, for messages also all email fields |
| 242 | w3, w3m | %:type %:url | ||
| 243 | info | %:type %:file %:node | ||
| 244 | calendar | %:type %:date" | ||
| 237 | :group 'org-capture | 245 | :group 'org-capture |
| 238 | :type | 246 | :type |
| 239 | '(repeat | 247 | '(repeat |
| @@ -289,7 +297,7 @@ calendar | %:type %:date" | |||
| 289 | (file :tag "Template file")) | 297 | (file :tag "Template file")) |
| 290 | (list :tag "Function" | 298 | (list :tag "Function" |
| 291 | (const :format "" function) | 299 | (const :format "" function) |
| 292 | (file :tag "Template function"))) | 300 | (function :tag "Template function"))) |
| 293 | (plist :inline t | 301 | (plist :inline t |
| 294 | ;; Give the most common options as checkboxes | 302 | ;; Give the most common options as checkboxes |
| 295 | :options (((const :format "%v " :prepend) (const t)) | 303 | :options (((const :format "%v " :prepend) (const t)) |
| @@ -297,7 +305,8 @@ calendar | %:type %:date" | |||
| 297 | ((const :format "%v " :empty-lines) (const 1)) | 305 | ((const :format "%v " :empty-lines) (const 1)) |
| 298 | ((const :format "%v " :clock-in) (const t)) | 306 | ((const :format "%v " :clock-in) (const t)) |
| 299 | ((const :format "%v " :clock-resume) (const t)) | 307 | ((const :format "%v " :clock-resume) (const t)) |
| 300 | ((const :format "%v " :unnarrowed) (const t)))))))) | 308 | ((const :format "%v " :unnarrowed) (const t)) |
| 309 | ((const :format "%v " :kill-buffer) (const t)))))))) | ||
| 301 | 310 | ||
| 302 | (defcustom org-capture-before-finalize-hook nil | 311 | (defcustom org-capture-before-finalize-hook nil |
| 303 | "Hook that is run right before a remember process is finalized. | 312 | "Hook that is run right before a remember process is finalized. |
| @@ -382,6 +391,11 @@ bypassed." | |||
| 382 | (initial (and (org-region-active-p) | 391 | (initial (and (org-region-active-p) |
| 383 | (buffer-substring (point) (mark)))) | 392 | (buffer-substring (point) (mark)))) |
| 384 | (entry (org-capture-select-template keys))) | 393 | (entry (org-capture-select-template keys))) |
| 394 | (when (stringp initial) | ||
| 395 | (remove-text-properties 0 (length initial) '(read-only t) initial)) | ||
| 396 | (when (stringp annotation) | ||
| 397 | (remove-text-properties 0 (length annotation) | ||
| 398 | '(read-only t) annotation)) | ||
| 385 | (cond | 399 | (cond |
| 386 | ((equal entry "C") | 400 | ((equal entry "C") |
| 387 | (customize-variable 'org-capture-templates)) | 401 | (customize-variable 'org-capture-templates)) |
| @@ -467,8 +481,9 @@ bypassed." | |||
| 467 | (markerp (org-capture-get :interrupted-clock 'local)) | 481 | (markerp (org-capture-get :interrupted-clock 'local)) |
| 468 | (buffer-live-p (marker-buffer | 482 | (buffer-live-p (marker-buffer |
| 469 | (org-capture-get :interrupted-clock 'local)))) | 483 | (org-capture-get :interrupted-clock 'local)))) |
| 470 | (org-with-point-at (org-capture-get :interrupted-clock 'local) | 484 | (let ((clock-in-task (org-capture-get :interrupted-clock 'local))) |
| 471 | (org-clock-in)) | 485 | (org-with-point-at clock-in-task |
| 486 | (org-clock-in))) | ||
| 472 | (message "Interrupted clock has been resumed"))) | 487 | (message "Interrupted clock has been resumed"))) |
| 473 | 488 | ||
| 474 | (let ((beg (point-min)) | 489 | (let ((beg (point-min)) |
| @@ -519,14 +534,25 @@ bypassed." | |||
| 519 | 534 | ||
| 520 | ;; Kill the indirect buffer | 535 | ;; Kill the indirect buffer |
| 521 | (save-buffer) | 536 | (save-buffer) |
| 522 | (let ((return-wconf (org-capture-get :return-to-wconf 'local))) | 537 | (let ((return-wconf (org-capture-get :return-to-wconf 'local)) |
| 538 | (new-buffer (org-capture-get :new-buffer 'local)) | ||
| 539 | (kill-buffer (org-capture-get :kill-buffer 'local)) | ||
| 540 | (base-buffer (buffer-base-buffer (current-buffer)))) | ||
| 541 | |||
| 542 | ;; Kill the indiret buffer | ||
| 523 | (kill-buffer (current-buffer)) | 543 | (kill-buffer (current-buffer)) |
| 544 | |||
| 545 | ;; Kill the target buffer if that is desired | ||
| 546 | (when (and base-buffer new-buffer kill-buffer) | ||
| 547 | (with-current-buffer base-buffer (save-buffer)) | ||
| 548 | (kill-buffer base-buffer)) | ||
| 549 | |||
| 524 | ;; Restore the window configuration before capture | 550 | ;; Restore the window configuration before capture |
| 525 | (set-window-configuration return-wconf)) | 551 | (set-window-configuration return-wconf)) |
| 526 | (when abort-note | 552 | (when abort-note |
| 527 | (cond | 553 | (cond |
| 528 | ((equal abort-note 'clean) | 554 | ((equal abort-note 'clean) |
| 529 | (message "Capture process aborted and target file cleaned up")) | 555 | (message "Capture process aborted and target buffer cleaned up")) |
| 530 | ((equal abort-note 'dirty) | 556 | ((equal abort-note 'dirty) |
| 531 | (error "Capture process aborted, but target buffer could not be cleaned up correctly")))))) | 557 | (error "Capture process aborted, but target buffer could not be cleaned up correctly")))))) |
| 532 | 558 | ||
| @@ -588,6 +614,8 @@ already gone." | |||
| 588 | (set-buffer (org-capture-target-buffer (nth 1 target))) | 614 | (set-buffer (org-capture-target-buffer (nth 1 target))) |
| 589 | (let ((hd (nth 2 target))) | 615 | (let ((hd (nth 2 target))) |
| 590 | (goto-char (point-min)) | 616 | (goto-char (point-min)) |
| 617 | (unless (org-mode-p) | ||
| 618 | (error "Target buffer for file+headline should be in Org mode")) | ||
| 591 | (if (re-search-forward | 619 | (if (re-search-forward |
| 592 | (format org-complex-heading-regexp-format (regexp-quote hd)) | 620 | (format org-complex-heading-regexp-format (regexp-quote hd)) |
| 593 | nil t) | 621 | nil t) |
| @@ -651,8 +679,12 @@ already gone." | |||
| 651 | 679 | ||
| 652 | (defun org-capture-target-buffer (file) | 680 | (defun org-capture-target-buffer (file) |
| 653 | "Get a buffer for FILE." | 681 | "Get a buffer for FILE." |
| 682 | (setq file (or (org-string-nw-p file) | ||
| 683 | org-default-notes-file | ||
| 684 | (error "No notes file specified, and no default available"))) | ||
| 654 | (or (org-find-base-buffer-visiting file) | 685 | (or (org-find-base-buffer-visiting file) |
| 655 | (find-file-noselect (expand-file-name file org-directory)))) | 686 | (progn (org-capture-put :new-buffer t) |
| 687 | (find-file-noselect (expand-file-name file org-directory))))) | ||
| 656 | 688 | ||
| 657 | (defun org-capture-steal-local-variables (buffer) | 689 | (defun org-capture-steal-local-variables (buffer) |
| 658 | "Install Org-mode local variables." | 690 | "Install Org-mode local variables." |
| @@ -666,6 +698,7 @@ already gone." | |||
| 666 | (delete-other-windows) | 698 | (delete-other-windows) |
| 667 | (org-switch-to-buffer-other-window | 699 | (org-switch-to-buffer-other-window |
| 668 | (org-capture-get-indirect-buffer (org-capture-get :buffer) "CAPTURE")) | 700 | (org-capture-get-indirect-buffer (org-capture-get :buffer) "CAPTURE")) |
| 701 | (widen) | ||
| 669 | (show-all) | 702 | (show-all) |
| 670 | (goto-char (org-capture-get :pos)) | 703 | (goto-char (org-capture-get :pos)) |
| 671 | (org-set-local 'org-capture-target-marker | 704 | (org-set-local 'org-capture-target-marker |
| @@ -676,7 +709,8 @@ already gone." | |||
| 676 | ((nil entry) (org-capture-place-entry)) | 709 | ((nil entry) (org-capture-place-entry)) |
| 677 | (table-line (org-capture-place-table-line)) | 710 | (table-line (org-capture-place-table-line)) |
| 678 | (plain (org-capture-place-plain-text)) | 711 | (plain (org-capture-place-plain-text)) |
| 679 | (item (org-capture-place-item)))) | 712 | (item (org-capture-place-item)) |
| 713 | (checkitem (org-capture-place-item)))) | ||
| 680 | (org-capture-mode 1) | 714 | (org-capture-mode 1) |
| 681 | (org-set-local 'org-capture-current-plist org-capture-plist)) | 715 | (org-set-local 'org-capture-current-plist org-capture-plist)) |
| 682 | 716 | ||
| @@ -695,7 +729,8 @@ already gone." | |||
| 695 | (setq level 1) | 729 | (setq level 1) |
| 696 | (if reversed | 730 | (if reversed |
| 697 | (progn (goto-char (point-min)) | 731 | (progn (goto-char (point-min)) |
| 698 | (outline-next-heading)) | 732 | (or (org-at-heading-p) |
| 733 | (outline-next-heading))) | ||
| 699 | (goto-char (point-max)) | 734 | (goto-char (point-max)) |
| 700 | (or (bolp) (insert "\n")))) | 735 | (or (bolp) (insert "\n")))) |
| 701 | (t | 736 | (t |
| @@ -718,6 +753,7 @@ already gone." | |||
| 718 | (setq end (point)) | 753 | (setq end (point)) |
| 719 | (org-capture-mark-kill-region beg (1- end)) | 754 | (org-capture-mark-kill-region beg (1- end)) |
| 720 | (org-capture-narrow beg (1- end)) | 755 | (org-capture-narrow beg (1- end)) |
| 756 | (goto-char beg) | ||
| 721 | (if (re-search-forward "%\\?" end t) (replace-match "")))) | 757 | (if (re-search-forward "%\\?" end t) (replace-match "")))) |
| 722 | 758 | ||
| 723 | (defun org-capture-place-item () | 759 | (defun org-capture-place-item () |
| @@ -738,14 +774,14 @@ already gone." | |||
| 738 | (if (org-capture-get :prepend) | 774 | (if (org-capture-get :prepend) |
| 739 | (progn | 775 | (progn |
| 740 | (goto-char beg) | 776 | (goto-char beg) |
| 741 | (if (re-search-forward (concat "^" (org-item-re)) nil t) | 777 | (if (org-search-forward-unenclosed org-item-beginning-re end t) |
| 742 | (progn | 778 | (progn |
| 743 | (goto-char (match-beginning 0)) | 779 | (goto-char (match-beginning 0)) |
| 744 | (setq ind (org-get-indentation))) | 780 | (setq ind (org-get-indentation))) |
| 745 | (goto-char end) | 781 | (goto-char end) |
| 746 | (setq ind 0))) | 782 | (setq ind 0))) |
| 747 | (goto-char end) | 783 | (goto-char end) |
| 748 | (if (re-search-backward (concat "^" (org-item-re)) nil t) | 784 | (if (org-search-backward-unenclosed org-item-beginning-re beg t) |
| 749 | (progn | 785 | (progn |
| 750 | (setq ind (org-get-indentation)) | 786 | (setq ind (org-get-indentation)) |
| 751 | (org-end-of-item)) | 787 | (org-end-of-item)) |
| @@ -929,7 +965,7 @@ Point will be after the empty lines, so insertion can directly be done." | |||
| 929 | (let ((pos (point))) | 965 | (let ((pos (point))) |
| 930 | (org-back-over-empty-lines) | 966 | (org-back-over-empty-lines) |
| 931 | (delete-region (point) pos) | 967 | (delete-region (point) pos) |
| 932 | (newline n))) | 968 | (if (> n 0) (newline n)))) |
| 933 | 969 | ||
| 934 | (defun org-capture-empty-lines-after (&optional n) | 970 | (defun org-capture-empty-lines-after (&optional n) |
| 935 | "Arrange for the correct number of empty lines after the inserted string. | 971 | "Arrange for the correct number of empty lines after the inserted string. |
| @@ -938,7 +974,7 @@ Point will remain at the first line after the inserted text." | |||
| 938 | (org-back-over-empty-lines) | 974 | (org-back-over-empty-lines) |
| 939 | (while (looking-at "[ \t]*\n") (replace-match "")) | 975 | (while (looking-at "[ \t]*\n") (replace-match "")) |
| 940 | (let ((pos (point))) | 976 | (let ((pos (point))) |
| 941 | (newline n) | 977 | (if (> n 0) (newline n)) |
| 942 | (goto-char pos))) | 978 | (goto-char pos))) |
| 943 | 979 | ||
| 944 | (defvar org-clock-marker) ; Defined in org.el | 980 | (defvar org-clock-marker) ; Defined in org.el |
| @@ -967,7 +1003,7 @@ Point will remain at the first line after the inserted text." | |||
| 967 | (insert template) | 1003 | (insert template) |
| 968 | (org-capture-empty-lines-after) | 1004 | (org-capture-empty-lines-after) |
| 969 | (goto-char beg) | 1005 | (goto-char beg) |
| 970 | (org-maybe-renumber-ordered-list) | 1006 | (org-list-repair) |
| 971 | (org-end-of-item) | 1007 | (org-end-of-item) |
| 972 | (setq end (point))) | 1008 | (setq end (point))) |
| 973 | (t (insert template))) | 1009 | (t (insert template))) |
| @@ -1023,17 +1059,19 @@ Use PREFIX as a prefix for the name of the indirect buffer." | |||
| 1023 | (defun org-capture-select-template (&optional keys) | 1059 | (defun org-capture-select-template (&optional keys) |
| 1024 | "Select a capture template. | 1060 | "Select a capture template. |
| 1025 | Lisp programs can force the template by setting KEYS to a string." | 1061 | Lisp programs can force the template by setting KEYS to a string." |
| 1026 | (when org-capture-templates | 1062 | (if org-capture-templates |
| 1027 | (if keys | 1063 | (if keys |
| 1028 | (or (assoc keys org-capture-templates) | 1064 | (or (assoc keys org-capture-templates) |
| 1029 | (error "No capture template referred to by \"%s\" keys" keys)) | 1065 | (error "No capture template referred to by \"%s\" keys" keys)) |
| 1030 | (if (= 1 (length org-capture-templates)) | 1066 | (if (= 1 (length org-capture-templates)) |
| 1031 | (car org-capture-templates) | 1067 | (car org-capture-templates) |
| 1032 | (org-mks org-capture-templates | 1068 | (org-mks org-capture-templates |
| 1033 | "Select a capture template\n=========================" | 1069 | "Select a capture template\n=========================" |
| 1034 | "Template key: " | 1070 | "Template key: " |
| 1035 | '(("C" "Customize org-capture-templates") | 1071 | '(("C" "Customize org-capture-templates") |
| 1036 | ("q" "Abort"))))))) | 1072 | ("q" "Abort"))))) |
| 1073 | ;; Use an arbitrary default template | ||
| 1074 | '("t" "Task" entry (file+headline "" "Tasks") "* TODO %?\n %u\n %a"))) | ||
| 1037 | 1075 | ||
| 1038 | (defun org-capture-fill-template (&optional template initial annotation) | 1076 | (defun org-capture-fill-template (&optional template initial annotation) |
| 1039 | "Fill a template and return the filled template as a string. | 1077 | "Fill a template and return the filled template as a string. |
| @@ -1098,6 +1136,7 @@ The template may still contain \"%?\" for cursor positioning." | |||
| 1098 | (plist-put org-store-link-plist :annotation v-a) | 1136 | (plist-put org-store-link-plist :annotation v-a) |
| 1099 | org-store-link-plist | 1137 | org-store-link-plist |
| 1100 | (plist-put org-store-link-plist :initial v-i)) | 1138 | (plist-put org-store-link-plist :initial v-i)) |
| 1139 | (setq initial v-i) | ||
| 1101 | 1140 | ||
| 1102 | (unless template (setq template "") (message "No template") (ding) | 1141 | (unless template (setq template "") (message "No template") (ding) |
| 1103 | (sit-for 1)) | 1142 | (sit-for 1)) |
| @@ -1138,6 +1177,7 @@ The template may still contain \"%?\" for cursor positioning." | |||
| 1138 | (insert result))))) | 1177 | (insert result))))) |
| 1139 | 1178 | ||
| 1140 | ;; Simple %-escapes | 1179 | ;; Simple %-escapes |
| 1180 | (goto-char (point-min)) | ||
| 1141 | (while (re-search-forward "%\\([tTuUaiAcxkKI]\\)" nil t) | 1181 | (while (re-search-forward "%\\([tTuUaiAcxkKI]\\)" nil t) |
| 1142 | (unless (org-capture-escaped-%) | 1182 | (unless (org-capture-escaped-%) |
| 1143 | (when (and initial (equal (match-string 0) "%i")) | 1183 | (when (and initial (equal (match-string 0) "%i")) |
| @@ -1181,6 +1221,7 @@ The template may still contain \"%?\" for cursor positioning." | |||
| 1181 | "org-capture-template-prompt-history::" | 1221 | "org-capture-template-prompt-history::" |
| 1182 | (or prompt ""))) | 1222 | (or prompt ""))) |
| 1183 | completions (mapcar 'list completions))) | 1223 | completions (mapcar 'list completions))) |
| 1224 | (unless (boundp histvar) (set histvar nil)) | ||
| 1184 | (cond | 1225 | (cond |
| 1185 | ((member char '("G" "g")) | 1226 | ((member char '("G" "g")) |
| 1186 | (let* ((org-last-tags-completion-table | 1227 | (let* ((org-last-tags-completion-table |
| @@ -1195,12 +1236,13 @@ The template may still contain \"%?\" for cursor positioning." | |||
| 1195 | 'org-tags-history))) | 1236 | 'org-tags-history))) |
| 1196 | (setq ins (mapconcat 'identity | 1237 | (setq ins (mapconcat 'identity |
| 1197 | (org-split-string | 1238 | (org-split-string |
| 1198 | ins (org-re "[^[:alnum:]_@]+")) | 1239 | ins (org-re "[^[:alnum:]_@#%]+")) |
| 1199 | ":")) | 1240 | ":")) |
| 1200 | (when (string-match "\\S-" ins) | 1241 | (when (string-match "\\S-" ins) |
| 1201 | (or (equal (char-before) ?:) (insert ":")) | 1242 | (or (equal (char-before) ?:) (insert ":")) |
| 1202 | (insert ins) | 1243 | (insert ins) |
| 1203 | (or (equal (char-after) ?:) (insert ":"))))) | 1244 | (or (equal (char-after) ?:) (insert ":")) |
| 1245 | (and (org-on-heading-p) (org-set-tags nil 'align))))) | ||
| 1204 | ((equal char "C") | 1246 | ((equal char "C") |
| 1205 | (cond ((= (length clipboards) 1) (insert (car clipboards))) | 1247 | (cond ((= (length clipboards) 1) (insert (car clipboards))) |
| 1206 | ((> (length clipboards) 1) | 1248 | ((> (length clipboards) 1) |
diff --git a/lisp/org/org-clock.el b/lisp/org/org-clock.el index f451cf80792..457a4dcb2f0 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.01 | 9 | ;; Version: 7.3 |
| 10 | ;; | 10 | ;; |
| 11 | ;; This file is part of GNU Emacs. | 11 | ;; This file is part of GNU Emacs. |
| 12 | ;; | 12 | ;; |
| @@ -35,6 +35,7 @@ | |||
| 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 | (defvar org-time-stamp-formats) | 39 | (defvar org-time-stamp-formats) |
| 39 | 40 | ||
| 40 | (defgroup org-clock nil | 41 | (defgroup org-clock nil |
| @@ -557,6 +558,14 @@ use libnotify if available, or fall back on a message." | |||
| 557 | ((stringp org-show-notification-handler) | 558 | ((stringp org-show-notification-handler) |
| 558 | (start-process "emacs-timer-notification" nil | 559 | (start-process "emacs-timer-notification" nil |
| 559 | org-show-notification-handler notification)) | 560 | org-show-notification-handler notification)) |
| 561 | ((featurep 'notifications) | ||
| 562 | (require 'notifications) | ||
| 563 | (notifications-notify | ||
| 564 | :title "Org-mode message" | ||
| 565 | :body notification | ||
| 566 | ;; FIXME how to link to the Org icon? | ||
| 567 | ;; :app-icon "~/.emacs.d/icons/mail.png" | ||
| 568 | :urgency 'low)) | ||
| 560 | ((org-program-exists "notify-send") | 569 | ((org-program-exists "notify-send") |
| 561 | (start-process "emacs-timer-notification" nil | 570 | (start-process "emacs-timer-notification" nil |
| 562 | "notify-send" notification)) | 571 | "notify-send" notification)) |
| @@ -950,7 +959,7 @@ the clocking selection, associated with the letter `d'." | |||
| 950 | ;; We are interrupting the clocking of a different task. | 959 | ;; We are interrupting the clocking of a different task. |
| 951 | ;; Save a marker to this task, so that we can go back. | 960 | ;; Save a marker to this task, so that we can go back. |
| 952 | ;; First check if we are trying to clock into the same task! | 961 | ;; First check if we are trying to clock into the same task! |
| 953 | (if (save-excursion | 962 | (when (save-excursion |
| 954 | (unless selected-task | 963 | (unless selected-task |
| 955 | (org-back-to-heading t)) | 964 | (org-back-to-heading t)) |
| 956 | (and (equal (marker-buffer org-clock-hd-marker) | 965 | (and (equal (marker-buffer org-clock-hd-marker) |
| @@ -961,13 +970,13 @@ the clocking selection, associated with the letter `d'." | |||
| 961 | (if selected-task | 970 | (if selected-task |
| 962 | (marker-position selected-task) | 971 | (marker-position selected-task) |
| 963 | (point))))) | 972 | (point))))) |
| 964 | (message "Clock continues in \"%s\"" org-clock-heading) | 973 | (message "Clock continues in \"%s\"" org-clock-heading) |
| 965 | (progn | 974 | (throw 'abort nil)) |
| 966 | (move-marker org-clock-interrupted-task | 975 | (move-marker org-clock-interrupted-task |
| 967 | (marker-position org-clock-marker) | 976 | (marker-position org-clock-marker) |
| 968 | (org-clocking-buffer)) | 977 | (marker-buffer org-clock-marker)) |
| 969 | (let ((org-clock-clocking-in t)) | 978 | (let ((org-clock-clocking-in t)) |
| 970 | (org-clock-out t))))) | 979 | (org-clock-out t))) |
| 971 | 980 | ||
| 972 | (when (equal select '(16)) | 981 | (when (equal select '(16)) |
| 973 | ;; Mark as default clocking task | 982 | ;; Mark as default clocking task |
| @@ -1098,6 +1107,7 @@ the clocking selection, associated with the letter `d'." | |||
| 1098 | (defun org-clock-set-current () | 1107 | (defun org-clock-set-current () |
| 1099 | "Set `org-clock-current-task' to the task currently clocked in." | 1108 | "Set `org-clock-current-task' to the task currently clocked in." |
| 1100 | (setq org-clock-current-task (nth 4 (org-heading-components)))) | 1109 | (setq org-clock-current-task (nth 4 (org-heading-components)))) |
| 1110 | |||
| 1101 | (defun org-clock-delete-current () | 1111 | (defun org-clock-delete-current () |
| 1102 | "Reset `org-clock-current-task' to nil." | 1112 | "Reset `org-clock-current-task' to nil." |
| 1103 | (setq org-clock-current-task nil)) | 1113 | (setq org-clock-current-task nil)) |
| @@ -1830,6 +1840,7 @@ the currently selected interval size." | |||
| 1830 | (org-prepare-agenda-buffers files) | 1840 | (org-prepare-agenda-buffers files) |
| 1831 | (while (setq file (pop files)) | 1841 | (while (setq file (pop files)) |
| 1832 | (with-current-buffer (find-buffer-visiting file) | 1842 | (with-current-buffer (find-buffer-visiting file) |
| 1843 | (setq org-clock-file-total-minutes 0) | ||
| 1833 | (setq tbl1 (org-dblock-write:clocktable p1)) | 1844 | (setq tbl1 (org-dblock-write:clocktable p1)) |
| 1834 | (when tbl1 | 1845 | (when tbl1 |
| 1835 | (push (org-clocktable-add-file | 1846 | (push (org-clocktable-add-file |
| @@ -1862,7 +1873,7 @@ the currently selected interval size." | |||
| 1862 | (when (setq time (get-text-property p :org-clock-minutes)) | 1873 | (when (setq time (get-text-property p :org-clock-minutes)) |
| 1863 | (save-excursion | 1874 | (save-excursion |
| 1864 | (beginning-of-line 1) | 1875 | (beginning-of-line 1) |
| 1865 | (when (and (looking-at (org-re "\\(\\*+\\)[ \t]+\\(.*?\\)\\([ \t]+:[[:alnum:]_@:]+:\\)?[ \t]*$")) | 1876 | (when (and (looking-at (org-re "\\(\\*+\\)[ \t]+\\(.*?\\)\\([ \t]+:[[:alnum:]_@#%:]+:\\)?[ \t]*$")) |
| 1866 | (setq level (org-reduced-level | 1877 | (setq level (org-reduced-level |
| 1867 | (- (match-end 1) (match-beginning 1)))) | 1878 | (- (match-end 1) (match-beginning 1)))) |
| 1868 | (<= level maxlevel)) | 1879 | (<= level maxlevel)) |
| @@ -1970,10 +1981,22 @@ the currently selected interval size." | |||
| 1970 | (when block | 1981 | (when block |
| 1971 | (setq cc (org-clock-special-range block nil t) | 1982 | (setq cc (org-clock-special-range block nil t) |
| 1972 | ts (car cc) te (nth 1 cc) range-text (nth 2 cc))) | 1983 | ts (car cc) te (nth 1 cc) range-text (nth 2 cc))) |
| 1973 | (if ts (setq ts (org-float-time | 1984 | (cond |
| 1974 | (apply 'encode-time (org-parse-time-string ts))))) | 1985 | ((numberp ts) |
| 1975 | (if te (setq te (org-float-time | 1986 | ;; If ts is a number, it's an absolute day number from org-agenda. |
| 1976 | (apply 'encode-time (org-parse-time-string te))))) | 1987 | (destructuring-bind (month day year) (calendar-gregorian-from-absolute ts) |
| 1988 | (setq ts (org-float-time (encode-time 0 0 0 day month year))))) | ||
| 1989 | (ts | ||
| 1990 | (setq ts (org-float-time | ||
| 1991 | (apply 'encode-time (org-parse-time-string ts)))))) | ||
| 1992 | (cond | ||
| 1993 | ((numberp te) | ||
| 1994 | ;; Likewise for te. | ||
| 1995 | (destructuring-bind (month day year) (calendar-gregorian-from-absolute te) | ||
| 1996 | (setq te (org-float-time (encode-time 0 0 0 day month year))))) | ||
| 1997 | (te | ||
| 1998 | (setq te (org-float-time | ||
| 1999 | (apply 'encode-time (org-parse-time-string te)))))) | ||
| 1977 | (setq p1 (plist-put p1 :header "")) | 2000 | (setq p1 (plist-put p1 :header "")) |
| 1978 | (setq p1 (plist-put p1 :step nil)) | 2001 | (setq p1 (plist-put p1 :step nil)) |
| 1979 | (setq p1 (plist-put p1 :block nil)) | 2002 | (setq p1 (plist-put p1 :block nil)) |
diff --git a/lisp/org/org-colview.el b/lisp/org/org-colview.el index 8e45fdf3e3c..15dc7b37a62 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.01 | 9 | ;; Version: 7.3 |
| 10 | ;; | 10 | ;; |
| 11 | ;; This file is part of GNU Emacs. | 11 | ;; This file is part of GNU Emacs. |
| 12 | ;; | 12 | ;; |
| @@ -228,7 +228,9 @@ This is the compiled version of the format.") | |||
| 228 | (overlay-put ov 'org-columns-value (cdr ass)) | 228 | (overlay-put ov 'org-columns-value (cdr ass)) |
| 229 | (overlay-put ov 'org-columns-value-modified modval) | 229 | (overlay-put ov 'org-columns-value-modified modval) |
| 230 | (overlay-put ov 'org-columns-pom pom) | 230 | (overlay-put ov 'org-columns-pom pom) |
| 231 | (overlay-put ov 'org-columns-format f)) | 231 | (overlay-put ov 'org-columns-format f) |
| 232 | (overlay-put ov 'line-prefix "") | ||
| 233 | (overlay-put ov 'wrap-prefix "")) | ||
| 232 | (if (or (not (char-after beg)) | 234 | (if (or (not (char-after beg)) |
| 233 | (equal (char-after beg) ?\n)) | 235 | (equal (char-after beg) ?\n)) |
| 234 | (let ((inhibit-read-only t)) | 236 | (let ((inhibit-read-only t)) |
| @@ -241,6 +243,8 @@ This is the compiled version of the format.") | |||
| 241 | (overlay-put ov 'invisible t) | 243 | (overlay-put ov 'invisible t) |
| 242 | (overlay-put ov 'keymap org-columns-map) | 244 | (overlay-put ov 'keymap org-columns-map) |
| 243 | (overlay-put ov 'intangible t) | 245 | (overlay-put ov 'intangible t) |
| 246 | (overlay-put ov 'line-prefix "") | ||
| 247 | (overlay-put ov 'wrap-prefix "") | ||
| 244 | (push ov org-columns-overlays) | 248 | (push ov org-columns-overlays) |
| 245 | (setq ov (make-overlay (1- (point-at-eol)) (1+ (point-at-eol)))) | 249 | (setq ov (make-overlay (1- (point-at-eol)) (1+ (point-at-eol)))) |
| 246 | (overlay-put ov 'keymap org-columns-map) | 250 | (overlay-put ov 'keymap org-columns-map) |
| @@ -464,7 +468,7 @@ Where possible, use the standard interface for changing this line." | |||
| 464 | (call-interactively 'org-schedule)))) | 468 | (call-interactively 'org-schedule)))) |
| 465 | ((equal key "BEAMER_env") | 469 | ((equal key "BEAMER_env") |
| 466 | (setq eval '(org-with-point-at pom | 470 | (setq eval '(org-with-point-at pom |
| 467 | (call-interactively 'org-beamer-set-environment-tag)))) | 471 | (call-interactively 'org-beamer-select-environment)))) |
| 468 | (t | 472 | (t |
| 469 | (setq allowed (org-property-get-allowed-values pom key 'table)) | 473 | (setq allowed (org-property-get-allowed-values pom key 'table)) |
| 470 | (if allowed | 474 | (if allowed |
| @@ -515,7 +519,7 @@ Where possible, use the standard interface for changing this line." | |||
| 515 | (txt (match-string 3)) | 519 | (txt (match-string 3)) |
| 516 | (post "") | 520 | (post "") |
| 517 | txt2) | 521 | txt2) |
| 518 | (if (string-match (org-re "[ \t]+:[[:alnum:]:_@]+:[ \t]*$") txt) | 522 | (if (string-match (org-re "[ \t]+:[[:alnum:]:_@#%]+:[ \t]*$") txt) |
| 519 | (setq post (match-string 0 txt) | 523 | (setq post (match-string 0 txt) |
| 520 | txt (substring txt 0 (match-beginning 0)))) | 524 | txt (substring txt 0 (match-beginning 0)))) |
| 521 | (setq txt2 (read-string "Edit: " txt)) | 525 | (setq txt2 (read-string "Edit: " txt)) |
| @@ -746,7 +750,8 @@ around it." | |||
| 746 | ("@max" max_age max (lambda (x) (- org-columns-time x))) | 750 | ("@max" max_age max (lambda (x) (- org-columns-time x))) |
| 747 | ("@mean" mean_age | 751 | ("@mean" mean_age |
| 748 | (lambda (&rest x) (/ (apply '+ x) (float (length x)))) | 752 | (lambda (&rest x) (/ (apply '+ x) (float (length x)))) |
| 749 | (lambda (x) (- org-columns-time x)))) | 753 | (lambda (x) (- org-columns-time x))) |
| 754 | ("est+" estimate org-estimate-combine)) | ||
| 750 | "Operator <-> format,function,calc map. | 755 | "Operator <-> format,function,calc map. |
| 751 | Used to compile/uncompile columns format and completing read in | 756 | Used to compile/uncompile columns format and completing read in |
| 752 | interactive function `org-columns-new'. | 757 | interactive function `org-columns-new'. |
| @@ -1031,6 +1036,7 @@ Don't set this, this is meant for dynamic scoping.") | |||
| 1031 | (defun org-columns-number-to-string (n fmt &optional printf) | 1036 | (defun org-columns-number-to-string (n fmt &optional printf) |
| 1032 | "Convert a computed column number to a string value, according to FMT." | 1037 | "Convert a computed column number to a string value, according to FMT." |
| 1033 | (cond | 1038 | (cond |
| 1039 | ((memq fmt '(estimate)) (org-estimate-print n printf)) | ||
| 1034 | ((not (numberp n)) "") | 1040 | ((not (numberp n)) "") |
| 1035 | ((memq fmt '(add_times max_times min_times mean_times)) | 1041 | ((memq fmt '(add_times max_times min_times mean_times)) |
| 1036 | (let* ((h (floor n)) (m (floor (+ 0.5 (* 60 (- n h)))))) | 1042 | (let* ((h (floor n)) (m (floor (+ 0.5 (* 60 (- n h)))))) |
| @@ -1054,28 +1060,30 @@ Don't set this, this is meant for dynamic scoping.") | |||
| 1054 | (format "[%d/%d]" n m) | 1060 | (format "[%d/%d]" n m) |
| 1055 | (format "[%d%%]"(floor (+ 0.5 (* 100. (/ (* 1.0 n) m))))))) | 1061 | (format "[%d%%]"(floor (+ 0.5 (* 100. (/ (* 1.0 n) m))))))) |
| 1056 | 1062 | ||
| 1063 | |||
| 1057 | (defun org-columns-string-to-number (s fmt) | 1064 | (defun org-columns-string-to-number (s fmt) |
| 1058 | "Convert a column value to a number that can be used for column computing." | 1065 | "Convert a column value to a number that can be used for column computing." |
| 1059 | (if s | 1066 | (if s |
| 1060 | (cond | 1067 | (cond |
| 1061 | ((memq fmt '(min_age max_age mean_age)) | 1068 | ((memq fmt '(min_age max_age mean_age)) |
| 1062 | (cond ((string= s "") org-columns-time) | 1069 | (cond ((string= s "") org-columns-time) |
| 1063 | ((string-match | 1070 | ((string-match |
| 1064 | "\\([0-9]+\\)d \\([0-9]+\\)h \\([0-9]+\\)m \\([0-9]+\\)s" | 1071 | "\\([0-9]+\\)d \\([0-9]+\\)h \\([0-9]+\\)m \\([0-9]+\\)s" |
| 1065 | s) | 1072 | s) |
| 1066 | (+ (* 60 (+ (* 60 (+ (* 24 (string-to-number (match-string 1 s))) | 1073 | (+ (* 60 (+ (* 60 (+ (* 24 (string-to-number (match-string 1 s))) |
| 1067 | (string-to-number (match-string 2 s)))) | 1074 | (string-to-number (match-string 2 s)))) |
| 1068 | (string-to-number (match-string 3 s)))) | 1075 | (string-to-number (match-string 3 s)))) |
| 1069 | (string-to-number (match-string 4 s)))) | 1076 | (string-to-number (match-string 4 s)))) |
| 1070 | (t (time-to-number-of-days (apply 'encode-time | 1077 | (t (time-to-number-of-days (apply 'encode-time |
| 1071 | (org-parse-time-string s t)))))) | 1078 | (org-parse-time-string s t)))))) |
| 1072 | ((string-match ":" s) | 1079 | ((string-match ":" s) |
| 1073 | (let ((l (nreverse (org-split-string s ":"))) (sum 0.0)) | 1080 | (let ((l (nreverse (org-split-string s ":"))) (sum 0.0)) |
| 1074 | (while l | 1081 | (while l |
| 1075 | (setq sum (+ (string-to-number (pop l)) (/ sum 60)))) | 1082 | (setq sum (+ (string-to-number (pop l)) (/ sum 60)))) |
| 1076 | sum)) | 1083 | sum)) |
| 1077 | ((memq fmt '(checkbox checkbox-n-of-m checkbox-percent)) | 1084 | ((memq fmt '(checkbox checkbox-n-of-m checkbox-percent)) |
| 1078 | (if (equal s "[X]") 1. 0.000001)) | 1085 | (if (equal s "[X]") 1. 0.000001)) |
| 1086 | ((memq fmt '(estimate)) (org-string-to-estimate s)) | ||
| 1079 | (t (string-to-number s))))) | 1087 | (t (string-to-number s))))) |
| 1080 | 1088 | ||
| 1081 | (defun org-columns-uncompile-format (cfmt) | 1089 | (defun org-columns-uncompile-format (cfmt) |
| @@ -1491,6 +1499,41 @@ This will add overlays to the date lines, to show the summary for each day." | |||
| 1491 | (format "%dd %02dh %02dm %02ds" days hours minutes seconds)) | 1499 | (format "%dd %02dh %02dm %02ds" days hours minutes seconds)) |
| 1492 | "")) | 1500 | "")) |
| 1493 | 1501 | ||
| 1502 | (defun org-estimate-mean-and-var (v) | ||
| 1503 | "Return the mean and variance of an estimate." | ||
| 1504 | (let* ((low (float (car v))) | ||
| 1505 | (high (float (cadr v))) | ||
| 1506 | (mean (/ (+ low high) 2.0)) | ||
| 1507 | (var (/ (+ (expt (- mean low) 2.0) (expt (- high mean) 2.0)) 2.0))) | ||
| 1508 | (list mean var))) | ||
| 1509 | |||
| 1510 | (defun org-estimate-combine (&rest el) | ||
| 1511 | "Combine a list of estimates, using mean and variance. | ||
| 1512 | The mean and variance of the result will be the sum of the means | ||
| 1513 | and variances (respectively) of the individual estimates." | ||
| 1514 | (let ((mean 0) | ||
| 1515 | (var 0)) | ||
| 1516 | (mapc (lambda (e) | ||
| 1517 | (let ((stats (org-estimate-mean-and-var e))) | ||
| 1518 | (setq mean (+ mean (car stats))) | ||
| 1519 | (setq var (+ var (cadr stats))))) | ||
| 1520 | el) | ||
| 1521 | (let ((stdev (sqrt var))) | ||
| 1522 | (list (- mean stdev) (+ mean stdev))))) | ||
| 1523 | |||
| 1524 | (defun org-estimate-print (e &optional fmt) | ||
| 1525 | "Prepare a string representation of an estimate. | ||
| 1526 | This formats these numbers as two numbers with a \"-\" between them." | ||
| 1527 | (if (null fmt) (set 'fmt "%.0f")) | ||
| 1528 | (format "%s" (mapconcat (lambda (n) (format fmt n)) e "-"))) | ||
| 1529 | |||
| 1530 | (defun org-string-to-estimate (s) | ||
| 1531 | "Convert a string to an estimate. | ||
| 1532 | The string should be two numbers joined with a \"-\"." | ||
| 1533 | (if (string-match "\\(.*\\)-\\(.*\\)" s) | ||
| 1534 | (list (string-to-number (match-string 1 s)) | ||
| 1535 | (string-to-number(match-string 2 s))) | ||
| 1536 | (list (string-to-number s) (string-to-number s)))) | ||
| 1494 | 1537 | ||
| 1495 | (provide 'org-colview) | 1538 | (provide 'org-colview) |
| 1496 | 1539 | ||
diff --git a/lisp/org/org-compat.el b/lisp/org/org-compat.el index 1b96b8d0535..324464803f2 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.01 | 9 | ;; Version: 7.3 |
| 10 | ;; | 10 | ;; |
| 11 | ;; This file is part of GNU Emacs. | 11 | ;; This file is part of GNU Emacs. |
| 12 | ;; | 12 | ;; |
| @@ -162,6 +162,15 @@ If DELETE is non-nil, delete all those overlays." | |||
| 162 | (let ((x (org-get-x-clipboard-compat value))) | 162 | (let ((x (org-get-x-clipboard-compat value))) |
| 163 | (if x (org-no-properties x))))) | 163 | (if x (org-no-properties x))))) |
| 164 | 164 | ||
| 165 | (defsubst org-decompose-region (beg end) | ||
| 166 | "Decompose from BEG to END." | ||
| 167 | (if (featurep 'xemacs) | ||
| 168 | (let ((modified-p (buffer-modified-p)) | ||
| 169 | (buffer-read-only nil)) | ||
| 170 | (remove-text-properties beg end '(composition nil)) | ||
| 171 | (set-buffer-modified-p modified-p)) | ||
| 172 | (decompose-region beg end))) | ||
| 173 | |||
| 165 | ;; Miscellaneous functions | 174 | ;; Miscellaneous functions |
| 166 | 175 | ||
| 167 | (defun org-add-hook (hook function &optional append local) | 176 | (defun org-add-hook (hook function &optional append local) |
| @@ -197,6 +206,26 @@ ignored in this case." | |||
| 197 | (shrink-window-if-larger-than-buffer window))) | 206 | (shrink-window-if-larger-than-buffer window))) |
| 198 | (or window (selected-window))) | 207 | (or window (selected-window))) |
| 199 | 208 | ||
| 209 | (defun org-number-sequence (from &optional to inc) | ||
| 210 | "Call `number-sequence or emulate it." | ||
| 211 | (if (fboundp 'number-sequence) | ||
| 212 | (number-sequence from to inc) | ||
| 213 | (if (or (not to) (= from to)) | ||
| 214 | (list from) | ||
| 215 | (or inc (setq inc 1)) | ||
| 216 | (when (zerop inc) (error "The increment can not be zero")) | ||
| 217 | (let (seq (n 0) (next from)) | ||
| 218 | (if (> inc 0) | ||
| 219 | (while (<= next to) | ||
| 220 | (setq seq (cons next seq) | ||
| 221 | n (1+ n) | ||
| 222 | next (+ from (* n inc)))) | ||
| 223 | (while (>= next to) | ||
| 224 | (setq seq (cons next seq) | ||
| 225 | n (1+ n) | ||
| 226 | next (+ from (* n inc))))) | ||
| 227 | (nreverse seq))))) | ||
| 228 | |||
| 200 | ;; Region compatibility | 229 | ;; Region compatibility |
| 201 | 230 | ||
| 202 | (defvar org-ignore-region nil | 231 | (defvar org-ignore-region nil |
| @@ -353,7 +382,7 @@ TIME defaults to the current time." | |||
| 353 | (if (fboundp 'looking-at-p) | 382 | (if (fboundp 'looking-at-p) |
| 354 | (apply 'looking-at-p args) | 383 | (apply 'looking-at-p args) |
| 355 | (save-match-data | 384 | (save-match-data |
| 356 | (apply 'looking-at-p args)))) | 385 | (apply 'looking-at args)))) |
| 357 | 386 | ||
| 358 | ; XEmacs does not have `looking-back'. | 387 | ; XEmacs does not have `looking-back'. |
| 359 | (if (fboundp 'looking-back) | 388 | (if (fboundp 'looking-back) |
diff --git a/lisp/org/org-crypt.el b/lisp/org/org-crypt.el index d93981227e5..693f3ac6a87 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.01 | 7 | ;; Version: 7.3 |
| 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 fc6b192e566..71e1b1b6a7e 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.01 | 6 | ;; Version: 7.3 |
| 7 | 7 | ||
| 8 | ;; Keywords: org, wp | 8 | ;; Keywords: org, wp |
| 9 | ;; Version: 7.01 | 9 | ;; Version: 7.3 |
| 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 331d6d6a1d1..286cdc9a1ae 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.01 | 8 | ;; Version: 7.3 |
| 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 12ab96deff9..7d90ec32fbe 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.01 | 7 | ;; Version: 7.3 |
| 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 |
| @@ -552,9 +552,9 @@ publishing directory." | |||
| 552 | (nth 2 (assoc "=" org-export-docbook-emphasis-alist))) | 552 | (nth 2 (assoc "=" org-export-docbook-emphasis-alist))) |
| 553 | table-open type | 553 | table-open type |
| 554 | table-buffer table-orig-buffer | 554 | table-buffer table-orig-buffer |
| 555 | ind item-type starter didclose | 555 | ind item-type starter |
| 556 | rpl path attr caption label desc descp desc1 desc2 link | 556 | rpl path attr caption label desc descp desc1 desc2 link |
| 557 | fnc item-tag initial-number | 557 | fnc item-tag item-number |
| 558 | footref-seen footnote-list | 558 | footref-seen footnote-list |
| 559 | id-file | 559 | id-file |
| 560 | ) | 560 | ) |
| @@ -671,7 +671,21 @@ publishing directory." | |||
| 671 | (org-export-docbook-open-para)) | 671 | (org-export-docbook-open-para)) |
| 672 | (throw 'nextline nil)) | 672 | (throw 'nextline nil)) |
| 673 | 673 | ||
| 674 | (org-export-docbook-close-lists-maybe line) | 674 | ;; List ender: close every open list. |
| 675 | (when (equal "ORG-LIST-END" line) | ||
| 676 | (while local-list-type | ||
| 677 | (let ((listtype (car local-list-type))) | ||
| 678 | (org-export-docbook-close-li listtype) | ||
| 679 | (insert (cond | ||
| 680 | ((equal listtype "o") "</orderedlist>\n") | ||
| 681 | ((equal listtype "u") "</itemizedlist>\n") | ||
| 682 | ((equal listtype "d") "</variablelist>\n")))) | ||
| 683 | (pop local-list-type)) | ||
| 684 | ;; We did close a list, normal text follows: need <para> | ||
| 685 | (org-export-docbook-open-para) | ||
| 686 | (setq local-list-indent nil | ||
| 687 | in-local-list nil) | ||
| 688 | (throw 'nextline nil)) | ||
| 675 | 689 | ||
| 676 | ;; Protected HTML | 690 | ;; Protected HTML |
| 677 | (when (get-text-property 0 'org-protected line) | 691 | (when (get-text-property 0 'org-protected line) |
| @@ -963,18 +977,6 @@ publishing directory." | |||
| 963 | txt (match-string 2 line)) | 977 | txt (match-string 2 line)) |
| 964 | (if (string-match quote-re0 txt) | 978 | (if (string-match quote-re0 txt) |
| 965 | (setq txt (replace-match "" t t txt))) | 979 | (setq txt (replace-match "" t t txt))) |
| 966 | (when in-local-list | ||
| 967 | ;; Close any local lists before inserting a new header line | ||
| 968 | (while local-list-type | ||
| 969 | (let ((listtype (car local-list-type))) | ||
| 970 | (org-export-docbook-close-li listtype) | ||
| 971 | (insert (cond | ||
| 972 | ((equal listtype "o") "</orderedlist>\n") | ||
| 973 | ((equal listtype "u") "</itemizedlist>\n") | ||
| 974 | ((equal listtype "d") "</variablelist>\n")))) | ||
| 975 | (pop local-list-type)) | ||
| 976 | (setq local-list-indent nil | ||
| 977 | in-local-list nil)) | ||
| 978 | (org-export-docbook-level-start level txt) | 980 | (org-export-docbook-level-start level txt) |
| 979 | ;; QUOTES | 981 | ;; QUOTES |
| 980 | (when (string-match quote-re line) | 982 | (when (string-match quote-re line) |
| @@ -1003,7 +1005,9 @@ publishing directory." | |||
| 1003 | table-orig-buffer (nreverse table-orig-buffer)) | 1005 | table-orig-buffer (nreverse table-orig-buffer)) |
| 1004 | (org-export-docbook-close-para-maybe) | 1006 | (org-export-docbook-close-para-maybe) |
| 1005 | (insert (org-export-docbook-finalize-table | 1007 | (insert (org-export-docbook-finalize-table |
| 1006 | (org-format-table-html table-buffer table-orig-buffer))))) | 1008 | (org-format-table-html table-buffer table-orig-buffer |
| 1009 | 'no-css))))) | ||
| 1010 | |||
| 1007 | (t | 1011 | (t |
| 1008 | ;; Normal lines | 1012 | ;; Normal lines |
| 1009 | (when (string-match | 1013 | (when (string-match |
| @@ -1020,34 +1024,14 @@ publishing directory." | |||
| 1020 | (substring (match-string 2 line) 0 -1)) | 1024 | (substring (match-string 2 line) 0 -1)) |
| 1021 | line (substring line (match-beginning 5)) | 1025 | line (substring line (match-beginning 5)) |
| 1022 | item-tag nil | 1026 | item-tag nil |
| 1023 | initial-number nil) | 1027 | item-number nil) |
| 1024 | (if (string-match "\\`\\[@start:\\([0-9]+\\)\\][ \t]?" line) | 1028 | (if (string-match "\\[@\\(?:start:\\)?\\([0-9]+\\)\\][ \t]?" line) |
| 1025 | (setq initial-number (match-string 1 line) | 1029 | (setq item-number (match-string 1 line) |
| 1026 | line (replace-match "" t t line))) | 1030 | line (replace-match "" t t line))) |
| 1027 | (if (and starter (string-match "\\(.*?\\) ::[ \t]*" line)) | 1031 | (if (and starter (string-match "\\(.*?\\) ::[ \t]*" line)) |
| 1028 | (setq item-type "d" | 1032 | (setq item-type "d" |
| 1029 | item-tag (match-string 1 line) | 1033 | item-tag (match-string 1 line) |
| 1030 | line (substring line (match-end 0)))) | 1034 | line (substring line (match-end 0)))) |
| 1031 | (when (and (not (equal item-type "d")) | ||
| 1032 | (not (string-match "[^ \t]" line))) | ||
| 1033 | ;; Empty line. Pretend indentation is large. | ||
| 1034 | (setq ind (if org-empty-line-terminates-plain-lists | ||
| 1035 | 0 | ||
| 1036 | (1+ (or (car local-list-indent) 1))))) | ||
| 1037 | (setq didclose nil) | ||
| 1038 | (while (and in-local-list | ||
| 1039 | (or (and (= ind (car local-list-indent)) | ||
| 1040 | (not starter)) | ||
| 1041 | (< ind (car local-list-indent)))) | ||
| 1042 | (setq didclose t) | ||
| 1043 | (let ((listtype (car local-list-type))) | ||
| 1044 | (org-export-docbook-close-li listtype) | ||
| 1045 | (insert (cond | ||
| 1046 | ((equal listtype "o") "</orderedlist>\n") | ||
| 1047 | ((equal listtype "u") "</itemizedlist>\n") | ||
| 1048 | ((equal listtype "d") "</variablelist>\n")))) | ||
| 1049 | (pop local-list-type) (pop local-list-indent) | ||
| 1050 | (setq in-local-list local-list-indent)) | ||
| 1051 | (cond | 1035 | (cond |
| 1052 | ((and starter | 1036 | ((and starter |
| 1053 | (or (not in-local-list) | 1037 | (or (not in-local-list) |
| @@ -1056,7 +1040,7 @@ publishing directory." | |||
| 1056 | (org-export-docbook-close-para-maybe) | 1040 | (org-export-docbook-close-para-maybe) |
| 1057 | (insert (cond | 1041 | (insert (cond |
| 1058 | ((equal item-type "u") "<itemizedlist>\n<listitem>\n") | 1042 | ((equal item-type "u") "<itemizedlist>\n<listitem>\n") |
| 1059 | ((equal item-type "o") | 1043 | ((and (equal item-type "o") item-number) |
| 1060 | ;; Check for a specific start number. If it | 1044 | ;; Check for a specific start number. If it |
| 1061 | ;; is specified, we use the ``override'' | 1045 | ;; is specified, we use the ``override'' |
| 1062 | ;; attribute of element <listitem> to pass the | 1046 | ;; attribute of element <listitem> to pass the |
| @@ -1064,10 +1048,8 @@ publishing directory." | |||
| 1064 | ;; ``startingnumber'' attribute of element | 1048 | ;; ``startingnumber'' attribute of element |
| 1065 | ;; <orderedlist>, but the former works on both | 1049 | ;; <orderedlist>, but the former works on both |
| 1066 | ;; DocBook 5.0 and prior versions. | 1050 | ;; DocBook 5.0 and prior versions. |
| 1067 | (if initial-number | 1051 | (format "<orderedlist>\n<listitem override=\"%s\">\n" item-number)) |
| 1068 | (format "<orderedlist>\n<listitem override=\"%s\">\n" | 1052 | ((equal item-type "o") "<orderedlist>\n<listitem>\n") |
| 1069 | initial-number) | ||
| 1070 | "<orderedlist>\n<listitem>\n")) | ||
| 1071 | ((equal item-type "d") | 1053 | ((equal item-type "d") |
| 1072 | (format "<variablelist>\n<varlistentry><term>%s</term><listitem>\n" item-tag)))) | 1054 | (format "<variablelist>\n<varlistentry><term>%s</term><listitem>\n" item-tag)))) |
| 1073 | ;; For DocBook, we need to open a para right after tag | 1055 | ;; For DocBook, we need to open a para right after tag |
| @@ -1076,11 +1058,27 @@ publishing directory." | |||
| 1076 | (push item-type local-list-type) | 1058 | (push item-type local-list-type) |
| 1077 | (push ind local-list-indent) | 1059 | (push ind local-list-indent) |
| 1078 | (setq in-local-list t)) | 1060 | (setq in-local-list t)) |
| 1079 | (starter | ||
| 1080 | ;; Continue current list | 1061 | ;; Continue current list |
| 1062 | (starter | ||
| 1063 | ;; terminate any previous sublist but first ensure | ||
| 1064 | ;; list is not ill-formed | ||
| 1065 | (let ((min-ind (apply 'min local-list-indent))) | ||
| 1066 | (when (< ind min-ind) (setq ind min-ind))) | ||
| 1067 | (while (< ind (car local-list-indent)) | ||
| 1068 | (let ((listtype (car local-list-type))) | ||
| 1069 | (org-export-docbook-close-li listtype) | ||
| 1070 | (insert (cond | ||
| 1071 | ((equal listtype "o") "</orderedlist>\n") | ||
| 1072 | ((equal listtype "u") "</itemizedlist>\n") | ||
| 1073 | ((equal listtype "d") "</variablelist>\n")))) | ||
| 1074 | (pop local-list-type) (pop local-list-indent) | ||
| 1075 | (setq in-local-list local-list-indent)) | ||
| 1076 | ;; insert new item | ||
| 1081 | (let ((listtype (car local-list-type))) | 1077 | (let ((listtype (car local-list-type))) |
| 1082 | (org-export-docbook-close-li listtype) | 1078 | (org-export-docbook-close-li listtype) |
| 1083 | (insert (cond | 1079 | (insert (cond |
| 1080 | ((and (equal listtype "o") item-number) | ||
| 1081 | (format "<listitem override=\"%s\">" item-number)) | ||
| 1084 | ((equal listtype "o") "<listitem>") | 1082 | ((equal listtype "o") "<listitem>") |
| 1085 | ((equal listtype "u") "<listitem>") | 1083 | ((equal listtype "u") "<listitem>") |
| 1086 | ((equal listtype "d") (format | 1084 | ((equal listtype "d") (format |
| @@ -1089,9 +1087,6 @@ publishing directory." | |||
| 1089 | "???")))))) | 1087 | "???")))))) |
| 1090 | ;; For DocBook, we need to open a para right after tag | 1088 | ;; For DocBook, we need to open a para right after tag |
| 1091 | ;; <listitem>. | 1089 | ;; <listitem>. |
| 1092 | (org-export-docbook-open-para)) | ||
| 1093 | (didclose | ||
| 1094 | ;; We did close a list, normal text follows: need <para> | ||
| 1095 | (org-export-docbook-open-para))) | 1090 | (org-export-docbook-open-para))) |
| 1096 | ;; Checkboxes. | 1091 | ;; Checkboxes. |
| 1097 | (if (string-match "^[ \t]*\\(\\[[X -]\\]\\)" line) | 1092 | (if (string-match "^[ \t]*\\(\\[[X -]\\]\\)" line) |
| @@ -1134,18 +1129,7 @@ publishing directory." | |||
| 1134 | (when inquote | 1129 | (when inquote |
| 1135 | (insert "]]></programlisting>\n") | 1130 | (insert "]]></programlisting>\n") |
| 1136 | (org-export-docbook-open-para)) | 1131 | (org-export-docbook-open-para)) |
| 1137 | (when in-local-list | 1132 | |
| 1138 | ;; Close any local lists before inserting a new header line | ||
| 1139 | (while local-list-type | ||
| 1140 | (let ((listtype (car local-list-type))) | ||
| 1141 | (org-export-docbook-close-li listtype) | ||
| 1142 | (insert (cond | ||
| 1143 | ((equal listtype "o") "</orderedlist>\n") | ||
| 1144 | ((equal listtype "u") "</itemizedlist>\n") | ||
| 1145 | ((equal listtype "d") "</variablelist>\n")))) | ||
| 1146 | (pop local-list-type)) | ||
| 1147 | (setq local-list-indent nil | ||
| 1148 | in-local-list nil)) | ||
| 1149 | ;; Close all open sections. | 1133 | ;; Close all open sections. |
| 1150 | (org-export-docbook-level-start 1 nil) | 1134 | (org-export-docbook-level-start 1 nil) |
| 1151 | 1135 | ||
| @@ -1212,24 +1196,6 @@ publishing directory." | |||
| 1212 | (defvar in-local-list) | 1196 | (defvar in-local-list) |
| 1213 | (defvar local-list-indent) | 1197 | (defvar local-list-indent) |
| 1214 | (defvar local-list-type) | 1198 | (defvar local-list-type) |
| 1215 | (defun org-export-docbook-close-lists-maybe (line) | ||
| 1216 | (let ((ind (or (get-text-property 0 'original-indentation line))) | ||
| 1217 | ; (and (string-match "\\S-" line) | ||
| 1218 | ; (org-get-indentation line)))) | ||
| 1219 | didclose) | ||
| 1220 | (when ind | ||
| 1221 | (while (and in-local-list | ||
| 1222 | (<= ind (car local-list-indent))) | ||
| 1223 | (setq didclose t) | ||
| 1224 | (let ((listtype (car local-list-type))) | ||
| 1225 | (org-export-docbook-close-li listtype) | ||
| 1226 | (insert (cond | ||
| 1227 | ((equal listtype "o") "</orderedlist>\n") | ||
| 1228 | ((equal listtype "u") "</itemizedlist>\n") | ||
| 1229 | ((equal listtype "d") "</variablelist>\n")))) | ||
| 1230 | (pop local-list-type) (pop local-list-indent) | ||
| 1231 | (setq in-local-list local-list-indent)) | ||
| 1232 | (and didclose (org-export-docbook-open-para))))) | ||
| 1233 | 1199 | ||
| 1234 | (defun org-export-docbook-level-start (level title) | 1200 | (defun org-export-docbook-level-start (level title) |
| 1235 | "Insert a new level in DocBook export. | 1201 | "Insert a new level in DocBook export. |
| @@ -1249,7 +1215,7 @@ When TITLE is nil, just close all open levels." | |||
| 1249 | ;; all levels, so the rest is done only if title is given. | 1215 | ;; all levels, so the rest is done only if title is given. |
| 1250 | ;; | 1216 | ;; |
| 1251 | ;; Format tags: put them into a superscript like format. | 1217 | ;; Format tags: put them into a superscript like format. |
| 1252 | (when (string-match (org-re "\\(:[[:alnum:]_@:]+:\\)[ \t]*$") title) | 1218 | (when (string-match (org-re "\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$") title) |
| 1253 | (setq title | 1219 | (setq title |
| 1254 | (replace-match | 1220 | (replace-match |
| 1255 | (if org-export-with-tags | 1221 | (if org-export-with-tags |
| @@ -1273,7 +1239,7 @@ When TITLE is nil, just close all open levels." | |||
| 1273 | Applies all active conversions. If there are links in the | 1239 | Applies all active conversions. If there are links in the |
| 1274 | string, don't modify these." | 1240 | string, don't modify these." |
| 1275 | (let* ((re (concat org-bracket-link-regexp "\\|" | 1241 | (let* ((re (concat org-bracket-link-regexp "\\|" |
| 1276 | (org-re "[ \t]+\\(:[[:alnum:]_@:]+:\\)[ \t]*$"))) | 1242 | (org-re "[ \t]+\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$"))) |
| 1277 | m s l res) | 1243 | m s l res) |
| 1278 | (while (setq m (string-match re string)) | 1244 | (while (setq m (string-match re string)) |
| 1279 | (setq s (substring string 0 m) | 1245 | (setq s (substring string 0 m) |
diff --git a/lisp/org/org-docview.el b/lisp/org/org-docview.el index 0ef5df0fda6..0c77b690765 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.01 | 8 | ;; Version: 7.3 |
| 9 | ;; | 9 | ;; |
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | ;; | 11 | ;; |
| @@ -45,7 +45,10 @@ | |||
| 45 | 45 | ||
| 46 | 46 | ||
| 47 | (require 'org) | 47 | (require 'org) |
| 48 | (eval-when-compile (require 'doc-view)) ; doc-view-current-page macro | 48 | |
| 49 | (declare-function doc-view-goto-page "ext:doc-view" (page)) | ||
| 50 | (declare-function image-mode-window-get "ext:image-mode" | ||
| 51 | (prop &optional winprops)) | ||
| 49 | 52 | ||
| 50 | (autoload 'doc-view-goto-page "doc-view") | 53 | (autoload 'doc-view-goto-page "doc-view") |
| 51 | 54 | ||
| @@ -66,7 +69,7 @@ | |||
| 66 | (when (eq major-mode 'doc-view-mode) | 69 | (when (eq major-mode 'doc-view-mode) |
| 67 | ;; This buffer is in doc-view-mode | 70 | ;; This buffer is in doc-view-mode |
| 68 | (let* ((path buffer-file-name) | 71 | (let* ((path buffer-file-name) |
| 69 | (page (doc-view-current-page)) | 72 | (page (image-mode-window-get 'page)) |
| 70 | (link (concat "docview:" path "::" (number-to-string page))) | 73 | (link (concat "docview:" path "::" (number-to-string page))) |
| 71 | (description "")) | 74 | (description "")) |
| 72 | (org-store-link-props | 75 | (org-store-link-props |
diff --git a/lisp/org/org-entities.el b/lisp/org/org-entities.el index 70c88afa6a2..5ce5fd7531c 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.01 | 9 | ;; Version: 7.3 |
| 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 4676f5b1aaf..3751e68e057 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.01 | 7 | ;; Version: 7.3 |
| 8 | 8 | ||
| 9 | ;; This file is part of GNU Emacs. | 9 | ;; This file is part of GNU Emacs. |
| 10 | ;; | 10 | ;; |
| @@ -201,7 +201,8 @@ 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-hook 'org-export-blocks-preprocess) | 204 | (add-hook 'org-export-preprocess-after-include-files-hook |
| 205 | 'org-export-blocks-preprocess) | ||
| 205 | 206 | ||
| 206 | ;;================================================================================ | 207 | ;;================================================================================ |
| 207 | ;; type specific functions | 208 | ;; type specific functions |
diff --git a/lisp/org/org-exp.el b/lisp/org/org-exp.el index c3f27cf0e15..73e0951334d 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.01 | 9 | ;; Version: 7.3 |
| 10 | ;; | 10 | ;; |
| 11 | ;; This file is part of GNU Emacs. | 11 | ;; This file is part of GNU Emacs. |
| 12 | ;; | 12 | ;; |
| @@ -181,7 +181,7 @@ This option can also be set with the +OPTIONS line, e.g. \"-:nil\"." | |||
| 181 | ("no" "Forfatter" "Dato" "Innhold" "Fotnoter") | 181 | ("no" "Forfatter" "Dato" "Innhold" "Fotnoter") |
| 182 | ("nb" "Forfatter" "Dato" "Innhold" "Fotnoter") ;; nb = Norsk (bokm.l) | 182 | ("nb" "Forfatter" "Dato" "Innhold" "Fotnoter") ;; nb = Norsk (bokm.l) |
| 183 | ("nn" "Forfattar" "Dato" "Innhald" "Fotnotar") ;; nn = Norsk (nynorsk) | 183 | ("nn" "Forfattar" "Dato" "Innhald" "Fotnotar") ;; nn = Norsk (nynorsk) |
| 184 | ("pl" "Autor" "Data" "Spis treści" "Przypis") | 184 | ("pl" "Autor" "Data" "Spis treści" "Przypis") |
| 185 | ("sv" "Författare" "Datum" "Innehåll" "Fotnoter")) | 185 | ("sv" "Författare" "Datum" "Innehåll" "Fotnoter")) |
| 186 | "Terms used in export text, translated to different languages. | 186 | "Terms used in export text, translated to different languages. |
| 187 | Use the variable `org-export-default-language' to set the language, | 187 | Use the variable `org-export-default-language' to set the language, |
| @@ -417,6 +417,10 @@ This is run just before backend-specific blocks get selected.") | |||
| 417 | This is run after blockquote/quote/verse/center have been marked | 417 | This is run after blockquote/quote/verse/center have been marked |
| 418 | with cookies.") | 418 | with cookies.") |
| 419 | 419 | ||
| 420 | (defvar org-export-preprocess-after-radio-targets-hook nil | ||
| 421 | "Hook for preprocessing an export buffer. | ||
| 422 | This is run after radio target processing.") | ||
| 423 | |||
| 420 | (defvar org-export-preprocess-before-normalizing-links-hook nil | 424 | (defvar org-export-preprocess-before-normalizing-links-hook nil |
| 421 | "Hook for preprocessing an export buffer. | 425 | "Hook for preprocessing an export buffer. |
| 422 | This hook is run before links are normalized.") | 426 | This hook is run before links are normalized.") |
| @@ -467,20 +471,34 @@ This option can also be set with the +OPTIONS line, e.g. \"TeX:nil\"." | |||
| 467 | :group 'org-export-latex | 471 | :group 'org-export-latex |
| 468 | :type 'boolean) | 472 | :type 'boolean) |
| 469 | 473 | ||
| 470 | (defcustom org-export-with-LaTeX-fragments nil | 474 | (defcustom org-export-with-LaTeX-fragments t |
| 471 | "Non-nil means convert LaTeX fragments to images when exporting to HTML. | 475 | "Non-nil means process LaTeX math fragments for HTML display. |
| 472 | When set, the exporter will find LaTeX environments if the \\begin line is | 476 | When set, the exporter will find and process LaTeX environments if the |
| 473 | the first non-white thing on a line. It will also find the math delimiters | 477 | \\begin line is the first non-white thing on a line. It will also find |
| 474 | like $a=b$ and \\( a=b \\) for inline math, $$a=b$$ and \\[ a=b \\] for | 478 | and process the math delimiters like $a=b$ and \\( a=b \\) for inline math, |
| 475 | display math. | 479 | $$a=b$$ and \\[ a=b \\] for display math. |
| 480 | |||
| 481 | This option can also be set with the +OPTIONS line, e.g. \"LaTeX:mathjax\". | ||
| 476 | 482 | ||
| 477 | This option can also be set with the +OPTIONS line, e.g. \"LaTeX:t\". | 483 | Allowed values are: |
| 484 | |||
| 485 | nil Don't do anything. | ||
| 486 | verbatim Keep eveything in verbatim | ||
| 487 | dvipng Process the LaTeX fragments to images. | ||
| 488 | This will also include processing of non-math environments. | ||
| 489 | t Do MathJax preprocessing if there is at least on math snippet, | ||
| 490 | and arrange for MathJax.js to be loaded. | ||
| 478 | 491 | ||
| 479 | The default is nil, because this option needs the `dvipng' program which | 492 | The default is nil, because this option needs the `dvipng' program which |
| 480 | is not available on all systems." | 493 | is not available on all systems." |
| 481 | :group 'org-export-translation | 494 | :group 'org-export-translation |
| 482 | :group 'org-export-latex | 495 | :group 'org-export-latex |
| 483 | :type 'boolean) | 496 | :type '(choice |
| 497 | (const :tag "Do not process math in any way" nil) | ||
| 498 | (const :tag "Obsolete, use dvipng setting" t) | ||
| 499 | (const :tag "Use dvipng to make images" dvipng) | ||
| 500 | (const :tag "Use MathJax to display math" mathjax) | ||
| 501 | (const :tag "Leave math verbatim" verbatim))) | ||
| 484 | 502 | ||
| 485 | (defcustom org-export-with-fixed-width t | 503 | (defcustom org-export-with-fixed-width t |
| 486 | "Non-nil means lines starting with \":\" will be in fixed width font. | 504 | "Non-nil means lines starting with \":\" will be in fixed width font. |
| @@ -671,12 +689,14 @@ modified) list.") | |||
| 671 | (let ((re (org-make-options-regexp | 689 | (let ((re (org-make-options-regexp |
| 672 | (append | 690 | (append |
| 673 | '("TITLE" "AUTHOR" "DATE" "EMAIL" "TEXT" "OPTIONS" "LANGUAGE" | 691 | '("TITLE" "AUTHOR" "DATE" "EMAIL" "TEXT" "OPTIONS" "LANGUAGE" |
| 692 | "MATHJAX" | ||
| 674 | "LINK_UP" "LINK_HOME" "SETUPFILE" "STYLE" | 693 | "LINK_UP" "LINK_HOME" "SETUPFILE" "STYLE" |
| 675 | "LATEX_HEADER" "LATEX_CLASS" | 694 | "LATEX_HEADER" "LATEX_CLASS" |
| 676 | "EXPORT_SELECT_TAGS" "EXPORT_EXCLUDE_TAGS" | 695 | "EXPORT_SELECT_TAGS" "EXPORT_EXCLUDE_TAGS" |
| 677 | "KEYWORDS" "DESCRIPTION" "MACRO" "BIND" "XSLT") | 696 | "KEYWORDS" "DESCRIPTION" "MACRO" "BIND" "XSLT") |
| 678 | (mapcar 'car org-export-inbuffer-options-extra)))) | 697 | (mapcar 'car org-export-inbuffer-options-extra)))) |
| 679 | p key val text options a pr style | 698 | (case-fold-search t) |
| 699 | p key val text options mathjax a pr style | ||
| 680 | latex-header latex-class macros letbind | 700 | latex-header latex-class macros letbind |
| 681 | ext-setup-or-nil setup-contents (start 0)) | 701 | ext-setup-or-nil setup-contents (start 0)) |
| 682 | (while (or (and ext-setup-or-nil | 702 | (while (or (and ext-setup-or-nil |
| @@ -708,6 +728,8 @@ modified) list.") | |||
| 708 | (setq text (if text (concat text "\n" val) val))) | 728 | (setq text (if text (concat text "\n" val) val))) |
| 709 | ((string-equal key "OPTIONS") | 729 | ((string-equal key "OPTIONS") |
| 710 | (setq options (concat val " " options))) | 730 | (setq options (concat val " " options))) |
| 731 | ((string-equal key "MATHJAX") | ||
| 732 | (setq mathjax (concat val " " mathjax))) | ||
| 711 | ((string-equal key "BIND") | 733 | ((string-equal key "BIND") |
| 712 | (push (read (concat "(" val ")")) letbind)) | 734 | (push (read (concat "(" val ")")) letbind)) |
| 713 | ((string-equal key "XSLT") | 735 | ((string-equal key "XSLT") |
| @@ -744,9 +766,12 @@ modified) list.") | |||
| 744 | (setq p (plist-put p :latex-class latex-class))) | 766 | (setq p (plist-put p :latex-class latex-class))) |
| 745 | (when options | 767 | (when options |
| 746 | (setq p (org-export-add-options-to-plist p options))) | 768 | (setq p (org-export-add-options-to-plist p options))) |
| 769 | (when mathjax | ||
| 770 | (setq p (plist-put p :mathjax mathjax))) | ||
| 747 | ;; Add macro definitions | 771 | ;; Add macro definitions |
| 748 | (setq p (plist-put p :macro-date "(eval (format-time-string \"$1\"))")) | 772 | (setq p (plist-put p :macro-date "(eval (format-time-string \"$1\"))")) |
| 749 | (setq p (plist-put p :macro-time "(eval (format-time-string \"$1\"))")) | 773 | (setq p (plist-put p :macro-time "(eval (format-time-string \"$1\"))")) |
| 774 | (setq p (plist-put p :macro-property "(eval (org-entry-get nil \"$1\" 'selective))")) | ||
| 750 | (setq p (plist-put | 775 | (setq p (plist-put |
| 751 | p :macro-modification-time | 776 | p :macro-modification-time |
| 752 | (and (buffer-file-name) | 777 | (and (buffer-file-name) |
| @@ -1052,6 +1077,9 @@ on this string to produce the exported version." | |||
| 1052 | (plist-get parameters :exclude-tags)) | 1077 | (plist-get parameters :exclude-tags)) |
| 1053 | (run-hooks 'org-export-preprocess-after-tree-selection-hook) | 1078 | (run-hooks 'org-export-preprocess-after-tree-selection-hook) |
| 1054 | 1079 | ||
| 1080 | ;; Mark end of lists | ||
| 1081 | (org-export-mark-list-ending backend) | ||
| 1082 | |||
| 1055 | ;; Handle source code snippets | 1083 | ;; Handle source code snippets |
| 1056 | (org-export-replace-src-segments-and-examples backend) | 1084 | (org-export-replace-src-segments-and-examples backend) |
| 1057 | 1085 | ||
| @@ -1120,6 +1148,7 @@ on this string to produce the exported version." | |||
| 1120 | 1148 | ||
| 1121 | ;; Find matches for radio targets and turn them into internal links | 1149 | ;; Find matches for radio targets and turn them into internal links |
| 1122 | (org-export-mark-radio-links) | 1150 | (org-export-mark-radio-links) |
| 1151 | (run-hooks 'org-export-preprocess-after-radio-targets-hook) | ||
| 1123 | 1152 | ||
| 1124 | ;; Find all links that contain a newline and put them into a single line | 1153 | ;; Find all links that contain a newline and put them into a single line |
| 1125 | (org-export-concatenate-multiline-links) | 1154 | (org-export-concatenate-multiline-links) |
| @@ -1138,7 +1167,8 @@ on this string to produce the exported version." | |||
| 1138 | (when (plist-get parameters :emph-multiline) | 1167 | (when (plist-get parameters :emph-multiline) |
| 1139 | (org-export-concatenate-multiline-emphasis)) | 1168 | (org-export-concatenate-multiline-emphasis)) |
| 1140 | 1169 | ||
| 1141 | ;; Remove special table lines | 1170 | ;; Remove special table lines, and store alignment information |
| 1171 | (org-store-forced-table-alignment) | ||
| 1142 | (when org-export-table-remove-special-lines | 1172 | (when org-export-table-remove-special-lines |
| 1143 | (org-export-remove-special-table-lines)) | 1173 | (org-export-remove-special-table-lines)) |
| 1144 | 1174 | ||
| @@ -1185,6 +1215,10 @@ on this string to produce the exported version." | |||
| 1185 | p (or (next-single-property-change p :org-license-to-kill) | 1215 | p (or (next-single-property-change p :org-license-to-kill) |
| 1186 | (point-max)))))) | 1216 | (point-max)))))) |
| 1187 | 1217 | ||
| 1218 | (defvar org-export-define-heading-targets-headline-hook nil | ||
| 1219 | "Hook that is run when a headline was matched during target search. | ||
| 1220 | This is part of the preprocessing for export.") | ||
| 1221 | |||
| 1188 | (defun org-export-define-heading-targets (target-alist) | 1222 | (defun org-export-define-heading-targets (target-alist) |
| 1189 | "Find all headings and define the targets for them. | 1223 | "Find all headings and define the targets for them. |
| 1190 | The new targets are added to TARGET-ALIST, which is also returned. | 1224 | The new targets are added to TARGET-ALIST, which is also returned. |
| @@ -1228,7 +1262,8 @@ Also find all ID and CUSTOM_ID properties and store them." | |||
| 1228 | (push (cons target target) target-alist) | 1262 | (push (cons target target) target-alist) |
| 1229 | (add-text-properties | 1263 | (add-text-properties |
| 1230 | (point-at-bol) (point-at-eol) | 1264 | (point-at-bol) (point-at-eol) |
| 1231 | (list 'target target)))))) | 1265 | (list 'target target)) |
| 1266 | (run-hooks 'org-export-define-heading-targets-headline-hook))))) | ||
| 1232 | target-alist) | 1267 | target-alist) |
| 1233 | 1268 | ||
| 1234 | (defun org-export-handle-invisible-targets (target-alist) | 1269 | (defun org-export-handle-invisible-targets (target-alist) |
| @@ -1289,18 +1324,19 @@ the current file." | |||
| 1289 | (string-match "^\\." link)) | 1324 | (string-match "^\\." link)) |
| 1290 | nil) | 1325 | nil) |
| 1291 | (t | 1326 | (t |
| 1292 | (save-excursion | 1327 | (let ((org-link-search-inhibit-query t)) |
| 1293 | (setq found (condition-case nil (org-link-search link) | 1328 | (save-excursion |
| 1294 | (error nil))) | 1329 | (setq found (condition-case nil (org-link-search link) |
| 1295 | (when (and found | 1330 | (error nil))) |
| 1296 | (or (org-on-heading-p) | 1331 | (when (and found |
| 1297 | (not (eq found 'dedicated)))) | 1332 | (or (org-on-heading-p) |
| 1298 | (or (get-text-property (point) 'target) | 1333 | (not (eq found 'dedicated)))) |
| 1299 | (get-text-property | 1334 | (or (get-text-property (point) 'target) |
| 1300 | (max (point-min) | 1335 | (get-text-property |
| 1301 | (1- (or (previous-single-property-change | 1336 | (max (point-min) |
| 1302 | (point) 'target) 0))) | 1337 | (1- (or (previous-single-property-change |
| 1303 | 'target)))))))) | 1338 | (point) 'target) 0))) |
| 1339 | 'target))))))))) | ||
| 1304 | (when target | 1340 | (when target |
| 1305 | (set-match-data md) | 1341 | (set-match-data md) |
| 1306 | (goto-char (match-beginning 1)) | 1342 | (goto-char (match-beginning 1)) |
| @@ -1316,7 +1352,7 @@ the current file." | |||
| 1316 | (goto-char (point-min)) | 1352 | (goto-char (point-min)) |
| 1317 | (let (class) | 1353 | (let (class) |
| 1318 | (while (re-search-forward | 1354 | (while (re-search-forward |
| 1319 | "^[ \t]*:HTML_CONTAINER_CLASS:[ \t]+\\(\\S-+\\)" nil t) | 1355 | "^[ \t]*:HTML_CONTAINER_CLASS:[ \t]+\\(.+\\)$" nil t) |
| 1320 | (setq class (match-string 1)) | 1356 | (setq class (match-string 1)) |
| 1321 | (save-excursion | 1357 | (save-excursion |
| 1322 | (org-back-to-heading t) | 1358 | (org-back-to-heading t) |
| @@ -1446,7 +1482,7 @@ from the buffer." | |||
| 1446 | (goto-char (point-min)) | 1482 | (goto-char (point-min)) |
| 1447 | (while (re-search-forward re-archive nil t) | 1483 | (while (re-search-forward re-archive nil t) |
| 1448 | (if (not (org-on-heading-p t)) | 1484 | (if (not (org-on-heading-p t)) |
| 1449 | (org-end-of-subtree t) | 1485 | (goto-char (point-at-eol)) |
| 1450 | (beginning-of-line 1) | 1486 | (beginning-of-line 1) |
| 1451 | (setq a (if export-archived-trees | 1487 | (setq a (if export-archived-trees |
| 1452 | (1+ (point-at-eol)) (point)) | 1488 | (1+ (point-at-eol)) (point)) |
| @@ -1595,6 +1631,31 @@ These special cookies will later be interpreted by the backend." | |||
| 1595 | (delete-region beg end) | 1631 | (delete-region beg end) |
| 1596 | (insert (org-add-props content nil 'original-indentation ind)))))) | 1632 | (insert (org-add-props content nil 'original-indentation ind)))))) |
| 1597 | 1633 | ||
| 1634 | (defun org-export-mark-list-ending (backend) | ||
| 1635 | "Mark list endings with special cookies. | ||
| 1636 | These special cookies will later be interpreted by the backend. | ||
| 1637 | `org-list-end-re' is replaced by a blank line in the process." | ||
| 1638 | (let ((process-buffer | ||
| 1639 | (lambda (end-list-marker) | ||
| 1640 | (goto-char (point-min)) | ||
| 1641 | (while (org-search-forward-unenclosed org-item-beginning-re nil t) | ||
| 1642 | (goto-char (org-list-bottom-point)) | ||
| 1643 | (when (and (not (eq org-list-ending-method 'indent)) | ||
| 1644 | (looking-at (org-list-end-re))) | ||
| 1645 | (replace-match "\n")) | ||
| 1646 | (insert end-list-marker))))) | ||
| 1647 | ;; We need to divide backends into 3 categories. | ||
| 1648 | (cond | ||
| 1649 | ;; 1. Backends using `org-list-parse-list' do not need markers. | ||
| 1650 | ((memq backend '(latex)) | ||
| 1651 | nil) | ||
| 1652 | ;; 2. Line-processing backends need to be told where lists end. | ||
| 1653 | ((memq backend '(html docbook)) | ||
| 1654 | (funcall process-buffer "ORG-LIST-END\n")) | ||
| 1655 | ;; 3. Others backends do not need to know this: clean list enders. | ||
| 1656 | (t | ||
| 1657 | (funcall process-buffer ""))))) | ||
| 1658 | |||
| 1598 | (defun org-export-attach-captions-and-attributes (backend target-alist) | 1659 | (defun org-export-attach-captions-and-attributes (backend target-alist) |
| 1599 | "Move #+CAPTION, #+ATTR_BACKEND, and #+LABEL text into text properties. | 1660 | "Move #+CAPTION, #+ATTR_BACKEND, and #+LABEL text into text properties. |
| 1600 | If the next thing following is a table, add the text properties to the first | 1661 | If the next thing following is a table, add the text properties to the first |
| @@ -1691,7 +1752,7 @@ When it is nil, all comments will be removed." | |||
| 1691 | (while (or (looking-at re) | 1752 | (while (or (looking-at re) |
| 1692 | (re-search-forward re nil t)) | 1753 | (re-search-forward re nil t)) |
| 1693 | (setq pos (match-beginning 0)) | 1754 | (setq pos (match-beginning 0)) |
| 1694 | (if (get-text-property (point) 'org-protected) | 1755 | (if (get-text-property (match-beginning 1) 'org-protected) |
| 1695 | (goto-char (1+ pos)) | 1756 | (goto-char (1+ pos)) |
| 1696 | (goto-char (1+ pos)) | 1757 | (goto-char (1+ pos)) |
| 1697 | (replace-match "") | 1758 | (replace-match "") |
| @@ -1712,8 +1773,30 @@ When it is nil, all comments will be removed." | |||
| 1712 | (org-if-unprotected | 1773 | (org-if-unprotected |
| 1713 | (replace-match "\\1[[\\2]]"))))))) | 1774 | (replace-match "\\1[[\\2]]"))))))) |
| 1714 | 1775 | ||
| 1776 | (defun org-store-forced-table-alignment () | ||
| 1777 | "Find table lines which force alignment, store the results in properties." | ||
| 1778 | (let (line cnt aligns) | ||
| 1779 | (goto-char (point-min)) | ||
| 1780 | (while (re-search-forward "|[ \t]*<[lrc][0-9]*>[ \t]*|" nil t) | ||
| 1781 | ;; OK, this looks like a table line with an alignment cookie | ||
| 1782 | (org-if-unprotected | ||
| 1783 | (setq line (buffer-substring (point-at-bol) (point-at-eol))) | ||
| 1784 | (when (and (org-at-table-p) | ||
| 1785 | (org-table-cookie-line-p line)) | ||
| 1786 | (setq cnt 0 aligns nil) | ||
| 1787 | (mapc | ||
| 1788 | (lambda (x) | ||
| 1789 | (setq cnt (1+ cnt)) | ||
| 1790 | (if (string-match "\\`<\\([lrc]\\)" x) | ||
| 1791 | (push (cons cnt (downcase (match-string 1 x))) aligns))) | ||
| 1792 | (org-split-string line "[ \t]*|[ \t]*")) | ||
| 1793 | (add-text-properties (org-table-begin) (org-table-end) | ||
| 1794 | (list 'org-forced-aligns aligns)))) | ||
| 1795 | (goto-char (point-at-eol))))) | ||
| 1796 | |||
| 1715 | (defun org-export-remove-special-table-lines () | 1797 | (defun org-export-remove-special-table-lines () |
| 1716 | "Remove tables lines that are used for internal purposes." | 1798 | "Remove tables lines that are used for internal purposes. |
| 1799 | Also, store forcedalignment information found in such lines." | ||
| 1717 | (goto-char (point-min)) | 1800 | (goto-char (point-min)) |
| 1718 | (while (re-search-forward "^[ \t]*|" nil t) | 1801 | (while (re-search-forward "^[ \t]*|" nil t) |
| 1719 | (org-if-unprotected-at (1- (point)) | 1802 | (org-if-unprotected-at (1- (point)) |
| @@ -1726,7 +1809,7 @@ When it is nil, all comments will be removed." | |||
| 1726 | (lambda (f) | 1809 | (lambda (f) |
| 1727 | (or (= (length f) 0) | 1810 | (or (= (length f) 0) |
| 1728 | (string-match | 1811 | (string-match |
| 1729 | "\\`<\\([0-9]\\|[rl]\\|[rl][0-9]+\\)>\\'" f))) | 1812 | "\\`<\\([0-9]\\|[lrc]\\|[lrc][0-9]+\\)>\\'" f))) |
| 1730 | (org-split-string ;; FIXME, can't we do without splitting??? | 1813 | (org-split-string ;; FIXME, can't we do without splitting??? |
| 1731 | (buffer-substring (point-at-bol) (point-at-eol)) | 1814 | (buffer-substring (point-at-bol) (point-at-eol)) |
| 1732 | "[ \t]*|[ \t]*"))))) | 1815 | "[ \t]*|[ \t]*"))))) |
| @@ -1747,16 +1830,19 @@ When it is nil, all comments will be removed." | |||
| 1747 | nodesc) | 1830 | nodesc) |
| 1748 | (goto-char (point-min)) | 1831 | (goto-char (point-min)) |
| 1749 | (while (re-search-forward re-plain-link nil t) | 1832 | (while (re-search-forward re-plain-link nil t) |
| 1750 | (goto-char (1- (match-end 0))) | 1833 | (unless (org-string-match-p |
| 1751 | (org-if-unprotected-at (1+ (match-beginning 0)) | 1834 | "\\[\\[\\S+:\\S-*?\\<" |
| 1752 | (let* ((s (concat (match-string 1) | 1835 | (buffer-substring (point-at-bol) (match-beginning 0))) |
| 1753 | "[[" (match-string 2) ":" (match-string 3) | 1836 | (goto-char (1- (match-end 0))) |
| 1754 | "][" (match-string 2) ":" (org-export-protect-sub-super | 1837 | (org-if-unprotected-at (1+ (match-beginning 0)) |
| 1755 | (match-string 3)) | 1838 | (let* ((s (concat (match-string 1) |
| 1756 | "]]"))) | 1839 | "[[" (match-string 2) ":" (match-string 3) |
| 1757 | ;; added 'org-link face to links | 1840 | "][" (match-string 2) ":" (org-export-protect-sub-super |
| 1758 | (put-text-property 0 (length s) 'face 'org-link s) | 1841 | (match-string 3)) |
| 1759 | (replace-match s t t)))) | 1842 | "]]"))) |
| 1843 | ;; added 'org-link face to links | ||
| 1844 | (put-text-property 0 (length s) 'face 'org-link s) | ||
| 1845 | (replace-match s t t))))) | ||
| 1760 | (goto-char (point-min)) | 1846 | (goto-char (point-min)) |
| 1761 | (while (re-search-forward re-angle-link nil t) | 1847 | (while (re-search-forward re-angle-link nil t) |
| 1762 | (goto-char (1- (match-end 0))) | 1848 | (goto-char (1- (match-end 0))) |
| @@ -1807,7 +1893,9 @@ can work correctly." | |||
| 1807 | (if (and (not (= (char-after (match-beginning 3)) | 1893 | (if (and (not (= (char-after (match-beginning 3)) |
| 1808 | (char-after (match-beginning 4)))) | 1894 | (char-after (match-beginning 4)))) |
| 1809 | (save-excursion (goto-char (match-beginning 0)) | 1895 | (save-excursion (goto-char (match-beginning 0)) |
| 1810 | (save-match-data (not (org-at-table-p))))) | 1896 | (save-match-data |
| 1897 | (and (not (org-at-table-p)) | ||
| 1898 | (not (org-at-heading-p)))))) | ||
| 1811 | (org-if-unprotected | 1899 | (org-if-unprotected |
| 1812 | (subst-char-in-region (match-beginning 0) (match-end 0) | 1900 | (subst-char-in-region (match-beginning 0) (match-end 0) |
| 1813 | ?\n ?\ t) | 1901 | ?\n ?\ t) |
| @@ -1976,16 +2064,15 @@ TYPE must be a string, any of: | |||
| 1976 | (intern (concat ":" key))))) | 2064 | (intern (concat ":" key))))) |
| 1977 | (save-match-data | 2065 | (save-match-data |
| 1978 | (when args | 2066 | (when args |
| 1979 | (setq args (org-split-string args ",[ \t\n]*") args2 nil) | 2067 | (setq args (org-split-string args ",") args2 nil) |
| 1980 | (setq args (mapcar 'org-trim args)) | ||
| 1981 | (while args | 2068 | (while args |
| 1982 | (while (string-match "\\\\\\'" (car args)) | 2069 | (while (string-match "\\\\\\'" (car args)) |
| 1983 | ;; repair bad splits | 2070 | ;; repair bad splits |
| 1984 | (setcar (cdr args) (concat (substring (car args) 0 -1) | 2071 | (setcar (cdr args) (concat (substring (car args) 0 -1) |
| 1985 | ";" (nth 1 args))) | 2072 | "," (nth 1 args))) |
| 1986 | (pop args)) | 2073 | (pop args)) |
| 1987 | (push (pop args) args2)) | 2074 | (push (pop args) args2)) |
| 1988 | (setq args (nreverse args2)) | 2075 | (setq args (mapcar 'org-trim (nreverse args2))) |
| 1989 | (setq s 0) | 2076 | (setq s 0) |
| 1990 | (while (string-match "\\$\\([0-9]+\\)" val s) | 2077 | (while (string-match "\\$\\([0-9]+\\)" val s) |
| 1991 | (setq s (1+ (match-beginning 0)) | 2078 | (setq s (1+ (match-beginning 0)) |
| @@ -2146,6 +2233,9 @@ in the list) and remove property and value from the list in LISTVAR." | |||
| 2146 | (defvar org-export-latex-verbatim-wrap) ;; defined in org-latex.el | 2233 | (defvar org-export-latex-verbatim-wrap) ;; defined in org-latex.el |
| 2147 | (defvar org-export-latex-listings) ;; defined in org-latex.el | 2234 | (defvar org-export-latex-listings) ;; defined in org-latex.el |
| 2148 | (defvar org-export-latex-listings-langs) ;; defined in org-latex.el | 2235 | (defvar org-export-latex-listings-langs) ;; defined in org-latex.el |
| 2236 | (defvar org-export-latex-listings-w-names) ;; defined in org-latex.el | ||
| 2237 | (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 | ||
| 2149 | 2239 | ||
| 2150 | (defun org-export-format-source-code-or-example | 2240 | (defun org-export-format-source-code-or-example |
| 2151 | (backend lang code &optional opts indent caption) | 2241 | (backend lang code &optional opts indent caption) |
| @@ -2275,32 +2365,56 @@ INDENT was the original indentation of the block." | |||
| 2275 | (setq rtn (org-export-number-lines rtn 'latex 0 0 num cont rpllbl fmt)) | 2365 | (setq rtn (org-export-number-lines rtn 'latex 0 0 num cont rpllbl fmt)) |
| 2276 | (concat "#+BEGIN_LaTeX\n" | 2366 | (concat "#+BEGIN_LaTeX\n" |
| 2277 | (org-add-props | 2367 | (org-add-props |
| 2278 | (if org-export-latex-listings | 2368 | (cond |
| 2279 | (concat | 2369 | ((and org-export-latex-listings |
| 2280 | (if lang | 2370 | (not (eq org-export-latex-listings 'minted))) |
| 2281 | (let* | 2371 | (concat |
| 2282 | ((lang-sym (intern lang)) | 2372 | (if lang |
| 2283 | (lstlang | 2373 | (let* |
| 2284 | (or (cadr | 2374 | ((lang-sym (intern lang)) |
| 2285 | (assq | 2375 | (lstlang |
| 2286 | lang-sym | 2376 | (or (cadr |
| 2287 | org-export-latex-listings-langs)) | 2377 | (assq |
| 2288 | lang))) | 2378 | lang-sym |
| 2289 | (format "\\lstset{language=%s}\n" lstlang)) | 2379 | org-export-latex-listings-langs)) |
| 2290 | "\n") | 2380 | lang))) |
| 2291 | (when caption | 2381 | (format "\\lstset{language=%s}\n" lstlang)) |
| 2292 | (format "\n%s $\\equiv$ \n" caption)) | 2382 | "\n") |
| 2293 | "\\begin{lstlisting}\n" | 2383 | (when (and caption |
| 2294 | rtn "\\end{lstlisting}\n") | 2384 | org-export-latex-listings-w-names) |
| 2295 | (concat (car org-export-latex-verbatim-wrap) | 2385 | (format "\n%s $\\equiv$ \n" |
| 2296 | rtn (cdr org-export-latex-verbatim-wrap))) | 2386 | (replace-regexp-in-string |
| 2297 | '(org-protected t org-example t)) | 2387 | "_" "\\\\_" caption))) |
| 2298 | "#+END_LaTeX\n")) | 2388 | "\\begin{lstlisting}\n" |
| 2299 | ((eq backend 'ascii) | 2389 | rtn "\\end{lstlisting}\n")) |
| 2300 | ;; This is not HTML or LaTeX, so just make it an example. | 2390 | ((eq org-export-latex-listings 'minted) |
| 2301 | (setq rtn (org-export-number-lines rtn 'ascii 0 0 num cont rpllbl fmt)) | 2391 | (if lang |
| 2302 | (concat caption "\n" | 2392 | (let* |
| 2303 | "#+BEGIN_ASCII\n" | 2393 | ((lang-sym (intern lang)) |
| 2394 | (minted-lang | ||
| 2395 | (or (cadr | ||
| 2396 | (assq | ||
| 2397 | lang-sym | ||
| 2398 | org-export-latex-minted-langs)) | ||
| 2399 | (downcase lang)))) | ||
| 2400 | (concat | ||
| 2401 | (when (and caption | ||
| 2402 | org-export-latex-listings-w-names) | ||
| 2403 | (format "\n%s $\\equiv$ \n" | ||
| 2404 | (replace-regexp-in-string | ||
| 2405 | "_" "\\\\_" caption))) | ||
| 2406 | (format | ||
| 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")))) | ||
| 2409 | (t (concat (car org-export-latex-verbatim-wrap) | ||
| 2410 | rtn (cdr org-export-latex-verbatim-wrap)))) | ||
| 2411 | '(org-protected t org-example t)) | ||
| 2412 | "#+END_LaTeX\n")) | ||
| 2413 | ((eq backend 'ascii) | ||
| 2414 | ;; This is not HTML or LaTeX, so just make it an example. | ||
| 2415 | (setq rtn (org-export-number-lines rtn 'ascii 0 0 num cont rpllbl fmt)) | ||
| 2416 | (concat caption "\n" | ||
| 2417 | "#+BEGIN_ASCII\n" | ||
| 2304 | (org-add-props | 2418 | (org-add-props |
| 2305 | (concat | 2419 | (concat |
| 2306 | (mapconcat | 2420 | (mapconcat |
| @@ -2498,6 +2612,28 @@ command." | |||
| 2498 | 2612 | ||
| 2499 | (defvar org-export-htmlized-org-css-url) ;; defined in org-html.el | 2613 | (defvar org-export-htmlized-org-css-url) ;; defined in org-html.el |
| 2500 | 2614 | ||
| 2615 | (defun org-export-string (string fmt &optional dir) | ||
| 2616 | "Export STRING to FMT using existing export facilities. | ||
| 2617 | During export STRING is saved to a temporary file whose location | ||
| 2618 | could vary. Optional argument DIR can be used to force the | ||
| 2619 | directory in which the temporary file is created during export | ||
| 2620 | which can be useful for resolving relative paths. Dir defaults | ||
| 2621 | to the value of `temporary-file-directory'." | ||
| 2622 | (let ((temporary-file-directory (or dir temporary-file-directory)) | ||
| 2623 | (tmp-file (make-temp-file "org-"))) | ||
| 2624 | (unwind-protect | ||
| 2625 | (with-temp-buffer | ||
| 2626 | (insert string) | ||
| 2627 | (write-file tmp-file) | ||
| 2628 | (org-load-modules-maybe) | ||
| 2629 | (unless org-local-vars | ||
| 2630 | (setq org-local-vars (org-get-local-variables))) | ||
| 2631 | (eval ;; convert to fmt -- mimicing `org-run-like-in-org-mode' | ||
| 2632 | (list 'let org-local-vars | ||
| 2633 | (list (intern (concat "org-export-as-" fmt)) | ||
| 2634 | nil nil nil ''string t)))) | ||
| 2635 | (delete-file tmp-file)))) | ||
| 2636 | |||
| 2501 | ;;;###autoload | 2637 | ;;;###autoload |
| 2502 | (defun org-export-as-org (arg &optional hidden ext-plist | 2638 | (defun org-export-as-org (arg &optional hidden ext-plist |
| 2503 | to-buffer body-only pub-dir) | 2639 | to-buffer body-only pub-dir) |
| @@ -2760,7 +2896,7 @@ If yes remove the column and the special lines." | |||
| 2760 | (defun org-export-cleanup-toc-line (s) | 2896 | (defun org-export-cleanup-toc-line (s) |
| 2761 | "Remove tags and timestamps from lines going into the toc." | 2897 | "Remove tags and timestamps from lines going into the toc." |
| 2762 | (when (memq org-export-with-tags '(not-in-toc nil)) | 2898 | (when (memq org-export-with-tags '(not-in-toc nil)) |
| 2763 | (if (string-match (org-re " +:[[:alnum:]_@:]+: *$") s) | 2899 | (if (string-match (org-re " +:[[:alnum:]_@#%:]+: *$") s) |
| 2764 | (setq s (replace-match "" t t s)))) | 2900 | (setq s (replace-match "" t t s)))) |
| 2765 | (when org-export-remove-timestamps-from-toc | 2901 | (when org-export-remove-timestamps-from-toc |
| 2766 | (while (string-match org-maybe-keyword-time-regexp s) | 2902 | (while (string-match org-maybe-keyword-time-regexp s) |
diff --git a/lisp/org/org-faces.el b/lisp/org/org-faces.el index 740f2629f2b..e4e17f15c5d 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.01 | 9 | ;; Version: 7.3 |
| 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-feed.el b/lisp/org/org-feed.el index 9d14daea9df..8bda3098e0a 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.01 | 8 | ;; Version: 7.3 |
| 9 | ;; | 9 | ;; |
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | ;; | 11 | ;; |
| @@ -99,11 +99,11 @@ | |||
| 99 | (declare-function xml-get-children "xml" (node child-name)) | 99 | (declare-function xml-get-children "xml" (node child-name)) |
| 100 | (declare-function xml-get-attribute "xml" (node attribute)) | 100 | (declare-function xml-get-attribute "xml" (node attribute)) |
| 101 | (declare-function xml-get-attribute-or-nil "xml" (node attribute)) | 101 | (declare-function xml-get-attribute-or-nil "xml" (node attribute)) |
| 102 | (defvar xml-entity-alist) | 102 | (declare-function xml-substitute-special "xml" (string)) |
| 103 | 103 | ||
| 104 | (defgroup org-feed nil | 104 | (defgroup org-feed nil |
| 105 | "Options concerning RSS feeds as inputs for Org files." | 105 | "Options concerning RSS feeds as inputs for Org files." |
| 106 | :tag "Org ID" | 106 | :tag "Org Feed" |
| 107 | :group 'org) | 107 | :group 'org) |
| 108 | 108 | ||
| 109 | (defcustom org-feed-alist nil | 109 | (defcustom org-feed-alist nil |
| @@ -269,17 +269,6 @@ have been saved." | |||
| 269 | (defvar org-feed-buffer "*Org feed*" | 269 | (defvar org-feed-buffer "*Org feed*" |
| 270 | "The buffer used to retrieve a feed.") | 270 | "The buffer used to retrieve a feed.") |
| 271 | 271 | ||
| 272 | (defun org-feed-unescape (s) | ||
| 273 | "Unescape protected entities in S." | ||
| 274 | (require 'xml) | ||
| 275 | (let ((re (concat "&\\(" | ||
| 276 | (mapconcat 'car xml-entity-alist "\\|") | ||
| 277 | "\\);"))) | ||
| 278 | (while (string-match re s) | ||
| 279 | (setq s (replace-match | ||
| 280 | (cdr (assoc (match-string 1 s) xml-entity-alist)) nil nil s))) | ||
| 281 | s)) | ||
| 282 | |||
| 283 | ;;;###autoload | 272 | ;;;###autoload |
| 284 | (defun org-feed-update-all () | 273 | (defun org-feed-update-all () |
| 285 | "Get inbox items from all feeds in `org-feed-alist'." | 274 | "Get inbox items from all feeds in `org-feed-alist'." |
| @@ -553,7 +542,8 @@ If that property is already present, nothing changes." | |||
| 553 | (setq tmp (org-feed-make-indented-block | 542 | (setq tmp (org-feed-make-indented-block |
| 554 | tmp (org-get-indentation)))))) | 543 | tmp (org-get-indentation)))))) |
| 555 | (replace-match tmp t t)))) | 544 | (replace-match tmp t t)))) |
| 556 | (buffer-string))))) | 545 | (decode-coding-string |
| 546 | (buffer-string) (detect-coding-region (point-min) (point-max) t)))))) | ||
| 557 | 547 | ||
| 558 | (defun org-feed-make-indented-block (s n) | 548 | (defun org-feed-make-indented-block (s n) |
| 559 | "Add indentation of N spaces to a multiline string S." | 549 | "Add indentation of N spaces to a multiline string S." |
| @@ -613,6 +603,7 @@ containing the properties `:guid' and `:item-full-text'." | |||
| 613 | 603 | ||
| 614 | (defun org-feed-parse-rss-entry (entry) | 604 | (defun org-feed-parse-rss-entry (entry) |
| 615 | "Parse the `:item-full-text' field for xml tags and create new properties." | 605 | "Parse the `:item-full-text' field for xml tags and create new properties." |
| 606 | (require 'xml) | ||
| 616 | (with-temp-buffer | 607 | (with-temp-buffer |
| 617 | (insert (plist-get entry :item-full-text)) | 608 | (insert (plist-get entry :item-full-text)) |
| 618 | (goto-char (point-min)) | 609 | (goto-char (point-min)) |
| @@ -620,7 +611,7 @@ containing the properties `:guid' and `:item-full-text'." | |||
| 620 | nil t) | 611 | nil t) |
| 621 | (setq entry (plist-put entry | 612 | (setq entry (plist-put entry |
| 622 | (intern (concat ":" (match-string 1))) | 613 | (intern (concat ":" (match-string 1))) |
| 623 | (org-feed-unescape (match-string 2))))) | 614 | (xml-substitute-special (match-string 2))))) |
| 624 | (goto-char (point-min)) | 615 | (goto-char (point-min)) |
| 625 | (unless (re-search-forward "isPermaLink[ \t]*=[ \t]*\"false\"" nil t) | 616 | (unless (re-search-forward "isPermaLink[ \t]*=[ \t]*\"false\"" nil t) |
| 626 | (setq entry (plist-put entry :guid-permalink t)))) | 617 | (setq entry (plist-put entry :guid-permalink t)))) |
| @@ -654,7 +645,7 @@ formatted as a string, not the original XML data." | |||
| 654 | 'href))) | 645 | 'href))) |
| 655 | ;; Add <title/> as :title. | 646 | ;; Add <title/> as :title. |
| 656 | (setq entry (plist-put entry :title | 647 | (setq entry (plist-put entry :title |
| 657 | (org-feed-unescape | 648 | (xml-substitute-special |
| 658 | (car (xml-node-children | 649 | (car (xml-node-children |
| 659 | (car (xml-get-children xml 'title))))))) | 650 | (car (xml-get-children xml 'title))))))) |
| 660 | (let* ((content (car (xml-get-children xml 'content))) | 651 | (let* ((content (car (xml-get-children xml 'content))) |
| @@ -664,12 +655,12 @@ formatted as a string, not the original XML data." | |||
| 664 | ((string= type "text") | 655 | ((string= type "text") |
| 665 | ;; We like plain text. | 656 | ;; We like plain text. |
| 666 | (setq entry (plist-put entry :description | 657 | (setq entry (plist-put entry :description |
| 667 | (org-feed-unescape | 658 | (xml-substitute-special |
| 668 | (car (xml-node-children content)))))) | 659 | (car (xml-node-children content)))))) |
| 669 | ((string= type "html") | 660 | ((string= type "html") |
| 670 | ;; TODO: convert HTML to Org markup. | 661 | ;; TODO: convert HTML to Org markup. |
| 671 | (setq entry (plist-put entry :description | 662 | (setq entry (plist-put entry :description |
| 672 | (org-feed-unescape | 663 | (xml-substitute-special |
| 673 | (car (xml-node-children content)))))) | 664 | (car (xml-node-children content)))))) |
| 674 | ((string= type "xhtml") | 665 | ((string= type "xhtml") |
| 675 | ;; TODO: convert XHTML to Org markup. | 666 | ;; TODO: convert XHTML to Org markup. |
diff --git a/lisp/org/org-footnote.el b/lisp/org/org-footnote.el index 2a2c4c0f426..2a97b54db6f 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.01 | 8 | ;; Version: 7.3 |
| 9 | ;; | 9 | ;; |
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | ;; | 11 | ;; |
| @@ -49,6 +49,7 @@ | |||
| 49 | (declare-function org-in-verbatim-emphasis "org" ()) | 49 | (declare-function org-in-verbatim-emphasis "org" ()) |
| 50 | (declare-function org-inside-latex-macro-p "org" ()) | 50 | (declare-function org-inside-latex-macro-p "org" ()) |
| 51 | (defvar org-odd-levels-only) ;; defined in org.el | 51 | (defvar org-odd-levels-only) ;; defined in org.el |
| 52 | (defvar message-signature-separator) ;; defined in message.el | ||
| 52 | 53 | ||
| 53 | (defconst org-footnote-re | 54 | (defconst org-footnote-re |
| 54 | (concat "[^][\n]" ; to make sure it is not at the beginning of a line | 55 | (concat "[^][\n]" ; to make sure it is not at the beginning of a line |
| @@ -188,7 +189,7 @@ with start and label of the footnote if there is a definition at point." | |||
| 188 | (message "Edit definition and go back with `C-c &' or, if unique, with `C-c C-c'.")))) | 189 | (message "Edit definition and go back with `C-c &' or, if unique, with `C-c C-c'.")))) |
| 189 | 190 | ||
| 190 | (defun org-footnote-goto-previous-reference (label) | 191 | (defun org-footnote-goto-previous-reference (label) |
| 191 | "Find the next previous of the footnote with label LABEL." | 192 | "Find the first closest (to point) reference of footnote with label LABEL." |
| 192 | (interactive "sLabel: ") | 193 | (interactive "sLabel: ") |
| 193 | (org-mark-ring-push) | 194 | (org-mark-ring-push) |
| 194 | (setq label (org-footnote-normalize-label label)) | 195 | (setq label (org-footnote-normalize-label label)) |
| @@ -302,15 +303,19 @@ or new, let the user edit the definition of the footnote." | |||
| 302 | (t | 303 | (t |
| 303 | (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]*$")) |
| 304 | (unless (re-search-forward re nil t) | 305 | (unless (re-search-forward re nil t) |
| 305 | (goto-char (point-max)) | 306 | (let ((max (if (and (eq major-mode 'message-mode) |
| 306 | (skip-chars-backward " \t\r\n") | 307 | (re-search-forward message-signature-separator nil t)) |
| 307 | (insert "\n\n") | 308 | (progn (beginning-of-line) (point)) |
| 308 | (delete-region (point) (point-max)) | 309 | (goto-char (point-max))))) |
| 309 | (insert org-footnote-tag-for-non-org-mode-files "\n")) | 310 | (skip-chars-backward " \t\r\n") |
| 310 | (goto-char (point-max)) | 311 | (delete-region (point) max) |
| 311 | (skip-chars-backward " \t\r\n"))) | 312 | (insert "\n\n") |
| 312 | (insert "\n\n") | 313 | (insert org-footnote-tag-for-non-org-mode-files "\n"))))) |
| 313 | (insert "[" label "] ") | 314 | ;; Skip existing footnotes |
| 315 | (while (re-search-forward "^[[:space:]]*\\[[^]]+\\] " nil t) | ||
| 316 | (forward-line)) | ||
| 317 | (insert "[" label "] \n") | ||
| 318 | (goto-char (1- (point))) | ||
| 314 | (message "Edit definition and go back with `C-c &' or, if unique, with `C-c C-c'."))) | 319 | (message "Edit definition and go back with `C-c &' or, if unique, with `C-c C-c'."))) |
| 315 | 320 | ||
| 316 | ;;;###autoload | 321 | ;;;###autoload |
| @@ -506,7 +511,8 @@ ENTRY is (fn-label num-mark definition)." | |||
| 506 | (beginning-of-line 0)) | 511 | (beginning-of-line 0)) |
| 507 | (if (looking-at "[ \t]*#\\+TBLFM:") (beginning-of-line 2)) | 512 | (if (looking-at "[ \t]*#\\+TBLFM:") (beginning-of-line 2)) |
| 508 | (end-of-line 1) | 513 | (end-of-line 1) |
| 509 | (skip-chars-backward "\n\r\t ")) | 514 | (skip-chars-backward "\n\r\t ") |
| 515 | (forward-line)) | ||
| 510 | 516 | ||
| 511 | (defun org-footnote-delete (&optional label) | 517 | (defun org-footnote-delete (&optional label) |
| 512 | "Delete the footnote at point. | 518 | "Delete the footnote at point. |
diff --git a/lisp/org/org-freemind.el b/lisp/org/org-freemind.el index 06285e4b7d1..736cc577ce7 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: 6.35i | 8 | ;; Version: 7.3 |
| 9 | ;; | 9 | ;; |
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | ;; | 11 | ;; |
| @@ -81,31 +81,35 @@ | |||
| 81 | 81 | ||
| 82 | (require 'xml) | 82 | (require 'xml) |
| 83 | (require 'org) | 83 | (require 'org) |
| 84 | (require 'rx) | 84 | ;(require 'rx) |
| 85 | (require 'org-exp) | 85 | (require 'org-exp) |
| 86 | (eval-when-compile (require 'cl)) | 86 | (eval-when-compile (require 'cl)) |
| 87 | 87 | ||
| 88 | (defgroup org-freemind nil | ||
| 89 | "Customization group for org-freemind export/import." | ||
| 90 | :group 'org) | ||
| 91 | |||
| 88 | ;; Fix-me: I am not sure these are useful: | 92 | ;; Fix-me: I am not sure these are useful: |
| 89 | ;; | 93 | ;; |
| 90 | ;; (defcustom org-freemind-main-fgcolor "black" | 94 | ;; (defcustom org-freemind-main-fgcolor "black" |
| 91 | ;; "Color of main node's text." | 95 | ;; "Color of main node's text." |
| 92 | ;; :type 'color | 96 | ;; :type 'color |
| 93 | ;; :group 'freemind) | 97 | ;; :group 'org-freemind) |
| 94 | 98 | ||
| 95 | ;; (defcustom org-freemind-main-color "black" | 99 | ;; (defcustom org-freemind-main-color "black" |
| 96 | ;; "Background color of main node." | 100 | ;; "Background color of main node." |
| 97 | ;; :type 'color | 101 | ;; :type 'color |
| 98 | ;; :group 'freemind) | 102 | ;; :group 'org-freemind) |
| 99 | 103 | ||
| 100 | ;; (defcustom org-freemind-child-fgcolor "black" | 104 | ;; (defcustom org-freemind-child-fgcolor "black" |
| 101 | ;; "Color of child nodes' text." | 105 | ;; "Color of child nodes' text." |
| 102 | ;; :type 'color | 106 | ;; :type 'color |
| 103 | ;; :group 'freemind) | 107 | ;; :group 'org-freemind) |
| 104 | 108 | ||
| 105 | ;; (defcustom org-freemind-child-color "black" | 109 | ;; (defcustom org-freemind-child-color "black" |
| 106 | ;; "Background color of child nodes." | 110 | ;; "Background color of child nodes." |
| 107 | ;; :type 'color | 111 | ;; :type 'color |
| 108 | ;; :group 'freemind) | 112 | ;; :group 'org-freemind) |
| 109 | 113 | ||
| 110 | (defvar org-freemind-node-style nil "Internal use.") | 114 | (defvar org-freemind-node-style nil "Internal use.") |
| 111 | 115 | ||
| @@ -152,11 +156,25 @@ NOT READY YET." | |||
| 152 | (string :tag "Font name" :value "SansSerif")) | 156 | (string :tag "Font name" :value "SansSerif")) |
| 153 | (list :format "%v" (const :format "" font-size) | 157 | (list :format "%v" (const :format "" font-size) |
| 154 | (integer :tag "Font size" :value 12))))))) | 158 | (integer :tag "Font size" :value 12))))))) |
| 155 | :group 'freemind) | 159 | :group 'org-freemind) |
| 156 | 160 | ||
| 157 | ;;;###autoload | 161 | ;;;###autoload |
| 158 | (defun org-export-as-freemind (arg &optional hidden ext-plist | 162 | (defun org-export-as-freemind (&optional hidden ext-plist |
| 159 | to-buffer body-only pub-dir) | 163 | to-buffer body-only pub-dir) |
| 164 | "Export the current buffer as a Freemind file. | ||
| 165 | If there is an active region, export only the region. HIDDEN is | ||
| 166 | obsolete and does nothing. EXT-PLIST is a property list with | ||
| 167 | external parameters overriding org-mode's default settings, but | ||
| 168 | still inferior to file-local settings. When TO-BUFFER is | ||
| 169 | non-nil, create a buffer with that name and export to that | ||
| 170 | buffer. If TO-BUFFER is the symbol `string', don't leave any | ||
| 171 | buffer behind but just return the resulting HTML as a string. | ||
| 172 | When BODY-ONLY is set, don't produce the file header and footer, | ||
| 173 | simply return the content of the document (all top level | ||
| 174 | sections). When PUB-DIR is set, use this as the publishing | ||
| 175 | directory. | ||
| 176 | |||
| 177 | See `org-freemind-from-org-mode' for more information." | ||
| 160 | (interactive "P") | 178 | (interactive "P") |
| 161 | (let* ((opt-plist (org-combine-plists (org-default-export-plist) | 179 | (let* ((opt-plist (org-combine-plists (org-default-export-plist) |
| 162 | ext-plist | 180 | ext-plist |
| @@ -203,7 +221,20 @@ NOT READY YET." | |||
| 203 | (let ((name (read-file-name "FreeMind file: " | 221 | (let ((name (read-file-name "FreeMind file: " |
| 204 | nil nil nil | 222 | nil nil nil |
| 205 | (if (buffer-file-name) | 223 | (if (buffer-file-name) |
| 206 | (file-name-nondirectory (buffer-file-name)) | 224 | (let* ((name-ext (file-name-nondirectory (buffer-file-name))) |
| 225 | (name (file-name-sans-extension name-ext)) | ||
| 226 | (ext (file-name-extension name-ext))) | ||
| 227 | (cond | ||
| 228 | ((string= "mm" ext) | ||
| 229 | name-ext) | ||
| 230 | ((string= "org" ext) | ||
| 231 | (let ((name-mm (concat name ".mm"))) | ||
| 232 | (if (file-exists-p name-mm) | ||
| 233 | name-mm | ||
| 234 | (message "Not exported to Freemind format yet") | ||
| 235 | ""))) | ||
| 236 | (t | ||
| 237 | ""))) | ||
| 207 | "") | 238 | "") |
| 208 | ;; Fix-me: Is this an Emacs bug? | 239 | ;; Fix-me: Is this an Emacs bug? |
| 209 | ;; This predicate function is never | 240 | ;; This predicate function is never |
| @@ -227,7 +258,7 @@ The characters \"&<> will be escaped." | |||
| 227 | (dolist (cc chars) | 258 | (dolist (cc chars) |
| 228 | (setq fm-str | 259 | (setq fm-str |
| 229 | (concat fm-str | 260 | (concat fm-str |
| 230 | (if (< cc 256) | 261 | (if (< cc 160) |
| 231 | (cond | 262 | (cond |
| 232 | ((= cc ?\") """) | 263 | ((= cc ?\") """) |
| 233 | ((= cc ?\&) "&") | 264 | ((= cc ?\&) "&") |
| @@ -265,52 +296,84 @@ will also unescape &#nn;." | |||
| 265 | ))) | 296 | ))) |
| 266 | org-str)))) | 297 | org-str)))) |
| 267 | 298 | ||
| 268 | ;; (org-freemind-test-escape) | 299 | ;; (let* ((str1 "a quote: \", an amp: &, lt: <; over 256: öåäÖÅÄ") |
| 269 | (defun org-freemind-test-escape () | 300 | ;; (str2 (org-freemind-escape-str-from-org str1)) |
| 270 | (let* ((str1 "a quote: \", an amp: &, lt: <; over 256: öåäÖÅÄ") | 301 | ;; (str3 (org-freemind-unescape-str-to-org str2))) |
| 271 | (str2 (org-freemind-escape-str-from-org str1)) | 302 | ;; (unless (string= str1 str3) |
| 272 | (str3 (org-freemind-unescape-str-to-org str2)) | 303 | ;; (error "Error str3=%s" str3))) |
| 304 | |||
| 305 | (defun org-freemind-convert-links-helper (matched) | ||
| 306 | "Helper for `org-freemind-convert-links-from-org'. | ||
| 307 | MATCHED is the link just matched." | ||
| 308 | (let* ((link (match-string 1 matched)) | ||
| 309 | (text (match-string 2 matched)) | ||
| 310 | (ext (file-name-extension link)) | ||
| 311 | (col-pos (string-match-p ":" link)) | ||
| 312 | (is-img (and (image-type-from-file-name link) | ||
| 313 | (let ((url-type (substring link 0 col-pos))) | ||
| 314 | (member url-type '("file" "http" "https"))))) | ||
| 273 | ) | 315 | ) |
| 274 | (unless (string= str1 str3) | 316 | (if is-img |
| 275 | (error "str3=%s" str3)) | 317 | ;; Fix-me: I can't find a way to get the border to "shrink |
| 276 | )) | 318 | ;; wrap" around the image using <div>. |
| 319 | ;; | ||
| 320 | ;; (concat "<div style=\"border: solid 1px #ddd; width:auto;\">" | ||
| 321 | ;; "<img src=\"" link "\" alt=\"" text "\" />" | ||
| 322 | ;; "<br />" | ||
| 323 | ;; "<i>" text "</i>" | ||
| 324 | ;; "</div>") | ||
| 325 | (concat "<table border=\"0\" style=\"border: solid 1px #ddd;\"><tr><td>" | ||
| 326 | "<img src=\"" link "\" alt=\"" text "\" />" | ||
| 327 | "<br />" | ||
| 328 | "<i>" text "</i>" | ||
| 329 | "</td></tr></table>") | ||
| 330 | (concat "<a href=\"" link "\">" text "</a>")))) | ||
| 277 | 331 | ||
| 278 | (defun org-freemind-convert-links-from-org (org-str) | 332 | (defun org-freemind-convert-links-from-org (org-str) |
| 279 | "Convert org links in ORG-STR to freemind links and return the result." | 333 | "Convert org links in ORG-STR to freemind links and return the result." |
| 280 | (let ((fm-str (replace-regexp-in-string | 334 | (let ((fm-str (replace-regexp-in-string |
| 281 | (rx (not (any "[\"")) | 335 | ;;(rx (not (any "[\"")) |
| 282 | (submatch | 336 | ;; (submatch |
| 283 | "http" | 337 | ;; "http" |
| 284 | (opt ?\s) | 338 | ;; (opt ?\s) |
| 285 | "://" | 339 | ;; "://" |
| 286 | (1+ | 340 | ;; (1+ |
| 287 | (any "-%.?@a-zA-Z0-9()_/:~=&#")))) | 341 | ;; (any "-%.?@a-zA-Z0-9()_/:~=&#")))) |
| 342 | "[^\"[]\\(http ?://[--:#%&()=?-Z_a-z~]+\\)" | ||
| 288 | "[[\\1][\\1]]" | 343 | "[[\\1][\\1]]" |
| 289 | org-str))) | 344 | org-str |
| 290 | (replace-regexp-in-string (rx "[[" | 345 | nil ;; fixedcase |
| 291 | (submatch (*? nonl)) | 346 | nil ;; literal |
| 292 | "][" | 347 | 1 ;; subexp |
| 293 | (submatch (*? nonl)) | 348 | ))) |
| 294 | "]]") | 349 | (replace-regexp-in-string |
| 295 | "<a href=\"\\1\">\\2</a>" | 350 | ;;(rx "[[" |
| 296 | fm-str))) | 351 | ;; (submatch (*? nonl)) |
| 352 | ;; "][" | ||
| 353 | ;; (submatch (*? nonl)) | ||
| 354 | ;; "]]") | ||
| 355 | "\\[\\[\\(.*?\\)]\\[\\(.*?\\)]]" | ||
| 356 | ;;"<a href=\"\\1\">\\2</a>" | ||
| 357 | 'org-freemind-convert-links-helper | ||
| 358 | fm-str))) | ||
| 297 | 359 | ||
| 298 | ;;(org-freemind-convert-links-to-org "<a href=\"http://www.somewhere/\">link-text</a>") | 360 | ;;(org-freemind-convert-links-to-org "<a href=\"http://www.somewhere/\">link-text</a>") |
| 299 | (defun org-freemind-convert-links-to-org (fm-str) | 361 | (defun org-freemind-convert-links-to-org (fm-str) |
| 300 | "Convert freemind links in FM-STR to org links and return the result." | 362 | "Convert freemind links in FM-STR to org links and return the result." |
| 301 | (let ((org-str (replace-regexp-in-string | 363 | (let ((org-str (replace-regexp-in-string |
| 302 | (rx "<a" | 364 | ;;(rx "<a" |
| 303 | space | 365 | ;; space |
| 304 | (0+ | 366 | ;; (0+ |
| 305 | (0+ (not (any ">"))) | 367 | ;; (0+ (not (any ">"))) |
| 306 | space) | 368 | ;; space) |
| 307 | "href=\"" | 369 | ;; "href=\"" |
| 308 | (submatch (0+ (not (any "\"")))) | 370 | ;; (submatch (0+ (not (any "\"")))) |
| 309 | "\"" | 371 | ;; "\"" |
| 310 | (0+ (not (any ">"))) | 372 | ;; (0+ (not (any ">"))) |
| 311 | ">" | 373 | ;; ">" |
| 312 | (submatch (0+ (not (any "<")))) | 374 | ;; (submatch (0+ (not (any "<")))) |
| 313 | "</a>") | 375 | ;; "</a>") |
| 376 | "<a[[:space:]]\\(?:[^>]*[[:space:]]\\)*href=\"\\([^\"]*\\)\"[^>]*>\\([^<]*\\)</a>" | ||
| 314 | "[[\\1][\\2]]" | 377 | "[[\\1][\\2]]" |
| 315 | fm-str))) | 378 | fm-str))) |
| 316 | org-str)) | 379 | org-str)) |
| @@ -319,29 +382,60 @@ will also unescape &#nn;." | |||
| 319 | ;;(defun org-freemind-convert-drawers-from-org (text) | 382 | ;;(defun org-freemind-convert-drawers-from-org (text) |
| 320 | ;; ) | 383 | ;; ) |
| 321 | 384 | ||
| 322 | ;; (org-freemind-test-links) | ||
| 323 | ;; (defun org-freemind-test-links () | ||
| 324 | ;; (let* ((str1 "[[http://www.somewhere/][link-text]") | 385 | ;; (let* ((str1 "[[http://www.somewhere/][link-text]") |
| 325 | ;; (str2 (org-freemind-convert-links-from-org str1)) | 386 | ;; (str2 (org-freemind-convert-links-from-org str1)) |
| 326 | ;; (str3 (org-freemind-convert-links-to-org str2)) | 387 | ;; (str3 (org-freemind-convert-links-to-org str2))) |
| 327 | ;; ) | ||
| 328 | ;; (unless (string= str1 str3) | 388 | ;; (unless (string= str1 str3) |
| 329 | ;; (error "str3=%s" str3)) | 389 | ;; (error "Error str3=%s" str3))) |
| 330 | ;; )) | ||
| 331 | 390 | ||
| 332 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 391 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 333 | ;;; Org => FreeMind | 392 | ;;; Org => FreeMind |
| 334 | 393 | ||
| 394 | (defvar org-freemind-bol-helper-base-indent nil) | ||
| 395 | |||
| 396 | (defun org-freemind-bol-helper (matched) | ||
| 397 | "Helper for `org-freemind-convert-text-p'. | ||
| 398 | MATCHED is the link just matched." | ||
| 399 | (let ((res "") | ||
| 400 | (bi org-freemind-bol-helper-base-indent)) | ||
| 401 | (dolist (cc (append matched nil)) | ||
| 402 | (if (= 32 cc) | ||
| 403 | ;;(setq res (concat res " ")) | ||
| 404 | ;; We need to use the numerical version. Otherwise Freemind | ||
| 405 | ;; ver 0.9.0 RC9 can not export to html/javascript. | ||
| 406 | (progn | ||
| 407 | (if (< 0 bi) | ||
| 408 | (setq bi (1- bi)) | ||
| 409 | (setq res (concat res " ")))) | ||
| 410 | (setq res (concat res (char-to-string cc))))) | ||
| 411 | res)) | ||
| 412 | ;; (setq x (replace-regexp-in-string "\n +" 'org-freemind-bol-nbsp-helper "\n ")) | ||
| 413 | |||
| 335 | (defun org-freemind-convert-text-p (text) | 414 | (defun org-freemind-convert-text-p (text) |
| 336 | "Convert TEXT to html with <p> paragraphs." | 415 | "Convert TEXT to html with <p> paragraphs." |
| 416 | ;; (string-match-p "[^ ]" " a") | ||
| 417 | (setq org-freemind-bol-helper-base-indent (string-match-p "[^ ]" text)) | ||
| 337 | (setq text (org-freemind-escape-str-from-org text)) | 418 | (setq text (org-freemind-escape-str-from-org text)) |
| 338 | (setq text (replace-regexp-in-string (rx "\n" (0+ blank) "\n") "</p><p>\n" text)) | 419 | |
| 339 | ;;(setq text (replace-regexp-in-string (rx bol (1+ blank) eol) "" text)) | 420 | (setq text (replace-regexp-in-string "\\([[:space:]]\\)\\(/\\)\\([^/]+\\)\\(/\\)\\([[:space:]]\\)" "\\1<i>\\3</i>\\5" text)) |
| 340 | ;;(setq text (replace-regexp-in-string (rx bol (1+ blank)) "<br />" text)) | 421 | (setq text (replace-regexp-in-string "\\([[:space:]]\\)\\(\*\\)\\([^*]+\\)\\(\*\\)\\([[:space:]]\\)" "\\1<b>\\3</b>\\5" text)) |
| 422 | |||
| 423 | (setq text (concat "<p>" text)) | ||
| 424 | (setq text (replace-regexp-in-string "\n[[:blank:]]*\n" "</p><p>" text)) | ||
| 425 | (setq text (replace-regexp-in-string "\\(?:<p>\\|\n\\) +" 'org-freemind-bol-helper text)) | ||
| 341 | (setq text (replace-regexp-in-string "\n" "<br />" text)) | 426 | (setq text (replace-regexp-in-string "\n" "<br />" text)) |
| 342 | (concat "<p>" | 427 | (setq text (concat text "</p>")) |
| 343 | (org-freemind-convert-links-from-org text) | 428 | |
| 344 | "</p>\n")) | 429 | (org-freemind-convert-links-from-org text)) |
| 430 | |||
| 431 | (defcustom org-freemind-node-css-style | ||
| 432 | "p { margin-top: 3px; margin-bottom: 3px; }" | ||
| 433 | "CSS style for Freemind nodes." | ||
| 434 | ;; Fix-me: I do not understand this. It worked to export from Freemind | ||
| 435 | ;; with this setting now, but not before??? Was this perhaps a java | ||
| 436 | ;; bug or is it a windows xp bug (some resource gets exhausted if you | ||
| 437 | ;; use sticky keys which I do). | ||
| 438 | :group 'org-freemind) | ||
| 345 | 439 | ||
| 346 | (defun org-freemind-org-text-to-freemind-subnode/note (node-name start end drawers-regexp) | 440 | (defun org-freemind-org-text-to-freemind-subnode/note (node-name start end drawers-regexp) |
| 347 | "Convert text part of org node to freemind subnode or note. | 441 | "Convert text part of org node to freemind subnode or note. |
| @@ -390,11 +484,14 @@ DRAWERS-REGEXP are converted to freemind notes." | |||
| 390 | "<node style=\"bubble\" background_color=\"#eeee00\">\n" | 484 | "<node style=\"bubble\" background_color=\"#eeee00\">\n" |
| 391 | "<richcontent TYPE=\"NODE\"><html>\n" | 485 | "<richcontent TYPE=\"NODE\"><html>\n" |
| 392 | "<head>\n" | 486 | "<head>\n" |
| 487 | (if (= 0 (length org-freemind-node-css-style)) | ||
| 488 | "" | ||
| 489 | (concat | ||
| 393 | "<style type=\"text/css\">\n" | 490 | "<style type=\"text/css\">\n" |
| 394 | "<!--\n" | 491 | "<!--\n" |
| 395 | "p { margin-top: 0 }\n" | 492 | org-freemind-node-css-style |
| 396 | "-->\n" | 493 | "-->\n" |
| 397 | "</style>\n" | 494 | "</style>\n")) |
| 398 | "</head>\n" | 495 | "</head>\n" |
| 399 | "<body>\n")) | 496 | "<body>\n")) |
| 400 | (let ((begin-html-mark (regexp-quote "#+BEGIN_HTML")) | 497 | (let ((begin-html-mark (regexp-quote "#+BEGIN_HTML")) |
| @@ -427,21 +524,28 @@ DRAWERS-REGEXP are converted to freemind notes." | |||
| 427 | "</html>\n" | 524 | "</html>\n" |
| 428 | "</richcontent>\n" | 525 | "</richcontent>\n" |
| 429 | ;; Put a note that this is for the parent node | 526 | ;; Put a note that this is for the parent node |
| 430 | "<richcontent TYPE=\"NOTE\"><html>" | 527 | ;; "<richcontent TYPE=\"NOTE\"><html>" |
| 431 | "<head>" | 528 | ;; "<head>" |
| 432 | "</head>" | 529 | ;; "</head>" |
| 433 | "<body>" | 530 | ;; "<body>" |
| 434 | "<p>" | 531 | ;; "<p>" |
| 435 | "-- This is more about \"" node-name "\" --" | 532 | ;; "-- This is more about \"" node-name "\" --" |
| 436 | "</p>" | 533 | ;; "</p>" |
| 437 | "</body>" | 534 | ;; "</body>" |
| 438 | "</html>" | 535 | ;; "</html>" |
| 439 | "</richcontent>\n" | 536 | ;; "</richcontent>\n" |
| 537 | note-res | ||
| 440 | "</node>\n" ;; ok | 538 | "</node>\n" ;; ok |
| 441 | ))) | 539 | ))) |
| 442 | (list node-res note-res)))) | 540 | (list node-res note-res)))) |
| 443 | 541 | ||
| 444 | (defun org-freemind-write-node (mm-buffer drawers-regexp num-left-nodes base-level current-level next-level this-m2 this-node-end this-children-visible next-node-start next-has-some-visible-child) | 542 | (defun org-freemind-write-node (mm-buffer drawers-regexp |
| 543 | num-left-nodes base-level | ||
| 544 | current-level next-level this-m2 | ||
| 545 | this-node-end | ||
| 546 | this-children-visible | ||
| 547 | next-node-start | ||
| 548 | next-has-some-visible-child) | ||
| 445 | (let* (this-icons | 549 | (let* (this-icons |
| 446 | this-bg-color | 550 | this-bg-color |
| 447 | this-m2-escaped | 551 | this-m2-escaped |
| @@ -503,7 +607,7 @@ DRAWERS-REGEXP are converted to freemind notes." | |||
| 503 | (insert "<icon builtin=\"" icon "\"/>\n"))) | 607 | (insert "<icon builtin=\"" icon "\"/>\n"))) |
| 504 | ) | 608 | ) |
| 505 | (with-current-buffer mm-buffer | 609 | (with-current-buffer mm-buffer |
| 506 | (when this-rich-note (insert this-rich-note)) | 610 | ;;(when this-rich-note (insert this-rich-note)) |
| 507 | (when this-rich-node (insert this-rich-node)))) | 611 | (when this-rich-node (insert this-rich-node)))) |
| 508 | num-left-nodes) | 612 | num-left-nodes) |
| 509 | 613 | ||
| @@ -521,11 +625,13 @@ Otherwise give an error say the file exists." | |||
| 521 | (error "File %s already exists" file)) | 625 | (error "File %s already exists" file)) |
| 522 | t)) | 626 | t)) |
| 523 | 627 | ||
| 524 | (defvar org-freemind-node-pattern (rx bol | 628 | (defvar org-freemind-node-pattern |
| 525 | (submatch (1+ "*")) | 629 | ;;(rx bol |
| 526 | (1+ space) | 630 | ;; (submatch (1+ "*")) |
| 527 | (submatch (*? nonl)) | 631 | ;; (1+ space) |
| 528 | eol)) | 632 | ;; (submatch (*? nonl)) |
| 633 | ;; eol) | ||
| 634 | "^\\(\\*+\\)[[:space:]]+\\(.*?\\)$") | ||
| 529 | 635 | ||
| 530 | (defun org-freemind-look-for-visible-child (node-level) | 636 | (defun org-freemind-look-for-visible-child (node-level) |
| 531 | (save-excursion | 637 | (save-excursion |
| @@ -573,27 +679,31 @@ Otherwise give an error say the file exists." | |||
| 573 | node-at-line-last) | 679 | node-at-line-last) |
| 574 | (with-current-buffer mm-buffer | 680 | (with-current-buffer mm-buffer |
| 575 | (erase-buffer) | 681 | (erase-buffer) |
| 576 | (insert "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n") | 682 | (setq buffer-file-coding-system 'utf-8) |
| 683 | ;; Fix-me: Currentl Freemind (ver 0.9.0 RC9) does not support this: | ||
| 684 | ;;(insert "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n") | ||
| 577 | (insert "<map version=\"0.9.0\">\n") | 685 | (insert "<map version=\"0.9.0\">\n") |
| 578 | (insert "<!-- To view this file, download free mind mapping software FreeMind from http://freemind.sourceforge.net -->\n")) | 686 | (insert "<!-- To view this file, download free mind mapping software FreeMind from http://freemind.sourceforge.net -->\n")) |
| 579 | (save-excursion | 687 | (save-excursion |
| 580 | ;; Get special buffer vars: | 688 | ;; Get special buffer vars: |
| 581 | (goto-char (point-min)) | 689 | (goto-char (point-min)) |
| 582 | (while (re-search-forward (rx bol "#+DRAWERS:") nil t) | 690 | (message "Writing Freemind file...") |
| 691 | (while (re-search-forward "^#\\+DRAWERS:" nil t) | ||
| 583 | (let ((dr-txt (buffer-substring-no-properties (match-end 0) (line-end-position)))) | 692 | (let ((dr-txt (buffer-substring-no-properties (match-end 0) (line-end-position)))) |
| 584 | (setq drawers (append drawers (split-string dr-txt) nil)))) | 693 | (setq drawers (append drawers (split-string dr-txt) nil)))) |
| 585 | (setq drawers-regexp | 694 | (setq drawers-regexp |
| 586 | (concat (rx bol (0+ blank) ":") | 695 | (concat "^[[:blank:]]*:" |
| 587 | (regexp-opt drawers) | 696 | (regexp-opt drawers) |
| 588 | (rx ":" (0+ blank) | 697 | ;;(rx ":" (0+ blank) |
| 589 | "\n" | 698 | ;; "\n" |
| 590 | (*? anything) | 699 | ;; (*? anything) |
| 591 | "\n" | 700 | ;; "\n" |
| 592 | (0+ blank) | 701 | ;; (0+ blank) |
| 593 | ":END:" | 702 | ;; ":END:" |
| 594 | (0+ blank) | 703 | ;; (0+ blank) |
| 595 | eol) | 704 | ;; eol) |
| 596 | )) | 705 | ":[[:blank:]]*\n\\(?:.\\|\n\\)*?\n[[:blank:]]*:END:[[:blank:]]*$" |
| 706 | )) | ||
| 597 | 707 | ||
| 598 | (if node-at-line | 708 | (if node-at-line |
| 599 | ;; Get number of top nodes and last line for this node | 709 | ;; Get number of top nodes and last line for this node |
| @@ -795,7 +905,8 @@ Otherwise give an error say the file exists." | |||
| 795 | 905 | ||
| 796 | ;;;###autoload | 906 | ;;;###autoload |
| 797 | (defun org-freemind-from-org-mode-node (node-line mm-file) | 907 | (defun org-freemind-from-org-mode-node (node-line mm-file) |
| 798 | "Convert node at line NODE-LINE to the FreeMind file MM-FILE." | 908 | "Convert node at line NODE-LINE to the FreeMind file MM-FILE. |
| 909 | See `org-freemind-from-org-mode' for more information." | ||
| 799 | (interactive | 910 | (interactive |
| 800 | (progn | 911 | (progn |
| 801 | (unless (org-back-to-heading nil) | 912 | (unless (org-back-to-heading nil) |
| @@ -808,20 +919,29 @@ Otherwise give an error say the file exists." | |||
| 808 | ".mm")) | 919 | ".mm")) |
| 809 | (mm-file (read-file-name "Output FreeMind file: " nil nil nil default-mm-file))) | 920 | (mm-file (read-file-name "Output FreeMind file: " nil nil nil default-mm-file))) |
| 810 | (list line mm-file)))) | 921 | (list line mm-file)))) |
| 811 | (when (org-freemind-check-overwrite mm-file (called-interactively-p 'any)) | 922 | (when (org-freemind-check-overwrite mm-file (org-called-interactively-p 'any)) |
| 812 | (let ((org-buffer (current-buffer)) | 923 | (let ((org-buffer (current-buffer)) |
| 813 | (mm-buffer (find-file-noselect mm-file))) | 924 | (mm-buffer (find-file-noselect mm-file))) |
| 814 | (org-freemind-write-mm-buffer org-buffer mm-buffer node-line) | 925 | (org-freemind-write-mm-buffer org-buffer mm-buffer node-line) |
| 815 | (with-current-buffer mm-buffer | 926 | (with-current-buffer mm-buffer |
| 816 | (basic-save-buffer) | 927 | (basic-save-buffer) |
| 817 | (when (called-interactively-p 'any) | 928 | (when (org-called-interactively-p 'any) |
| 818 | (switch-to-buffer-other-window mm-buffer) | 929 | (switch-to-buffer-other-window mm-buffer) |
| 819 | (when (y-or-n-p "Show in FreeMind? ") | 930 | (when (y-or-n-p "Show in FreeMind? ") |
| 820 | (org-freemind-show buffer-file-name))))))) | 931 | (org-freemind-show buffer-file-name))))))) |
| 821 | 932 | ||
| 822 | ;;;###autoload | 933 | ;;;###autoload |
| 823 | (defun org-freemind-from-org-mode (org-file mm-file) | 934 | (defun org-freemind-from-org-mode (org-file mm-file) |
| 824 | "Convert the `org-mode' file ORG-FILE to the FreeMind file MM-FILE." | 935 | "Convert the `org-mode' file ORG-FILE to the FreeMind file MM-FILE. |
| 936 | All the nodes will be opened or closed in Freemind just as you | ||
| 937 | have them in `org-mode'. | ||
| 938 | |||
| 939 | Note that exporting to Freemind also gives you an alternative way | ||
| 940 | to export from `org-mode' to html. You can create a dynamic html | ||
| 941 | version of the your org file, by first exporting to Freemind and | ||
| 942 | then exporting from Freemind to html. The 'As | ||
| 943 | XHTML (JavaScript)' version in Freemind works very well \(and you | ||
| 944 | can use a CSS stylesheet to style it)." | ||
| 825 | ;; Fix-me: better doc, include recommendations etc. | 945 | ;; Fix-me: better doc, include recommendations etc. |
| 826 | (interactive | 946 | (interactive |
| 827 | (let* ((org-file buffer-file-name) | 947 | (let* ((org-file buffer-file-name) |
| @@ -832,13 +952,13 @@ Otherwise give an error say the file exists." | |||
| 832 | ".mm")) | 952 | ".mm")) |
| 833 | (mm-file (read-file-name "Output FreeMind file: " nil nil nil default-mm-file))) | 953 | (mm-file (read-file-name "Output FreeMind file: " nil nil nil default-mm-file))) |
| 834 | (list org-file mm-file))) | 954 | (list org-file mm-file))) |
| 835 | (when (org-freemind-check-overwrite mm-file (called-interactively-p 'any)) | 955 | (when (org-freemind-check-overwrite mm-file (org-called-interactively-p 'any)) |
| 836 | (let ((org-buffer (if org-file (find-file-noselect org-file) (current-buffer))) | 956 | (let ((org-buffer (if org-file (find-file-noselect org-file) (current-buffer))) |
| 837 | (mm-buffer (find-file-noselect mm-file))) | 957 | (mm-buffer (find-file-noselect mm-file))) |
| 838 | (org-freemind-write-mm-buffer org-buffer mm-buffer nil) | 958 | (org-freemind-write-mm-buffer org-buffer mm-buffer nil) |
| 839 | (with-current-buffer mm-buffer | 959 | (with-current-buffer mm-buffer |
| 840 | (basic-save-buffer) | 960 | (basic-save-buffer) |
| 841 | (when (called-interactively-p 'any) | 961 | (when (org-called-interactively-p 'any) |
| 842 | (switch-to-buffer-other-window mm-buffer) | 962 | (switch-to-buffer-other-window mm-buffer) |
| 843 | (when (y-or-n-p "Show in FreeMind? ") | 963 | (when (y-or-n-p "Show in FreeMind? ") |
| 844 | (org-freemind-show buffer-file-name))))))) | 964 | (org-freemind-show buffer-file-name))))))) |
| @@ -855,7 +975,7 @@ Otherwise give an error say the file exists." | |||
| 855 | "-sparse.mm")) | 975 | "-sparse.mm")) |
| 856 | (mm-file (read-file-name "Output FreeMind file: " nil nil nil default-mm-file))) | 976 | (mm-file (read-file-name "Output FreeMind file: " nil nil nil default-mm-file))) |
| 857 | (list (current-buffer) mm-file))) | 977 | (list (current-buffer) mm-file))) |
| 858 | (when (org-freemind-check-overwrite mm-file (called-interactively-p 'any)) | 978 | (when (org-freemind-check-overwrite mm-file (org-called-interactively-p 'any)) |
| 859 | (let (org-buffer | 979 | (let (org-buffer |
| 860 | (mm-buffer (find-file-noselect mm-file))) | 980 | (mm-buffer (find-file-noselect mm-file))) |
| 861 | (save-window-excursion | 981 | (save-window-excursion |
| @@ -864,7 +984,7 @@ Otherwise give an error say the file exists." | |||
| 864 | (org-freemind-write-mm-buffer org-buffer mm-buffer nil) | 984 | (org-freemind-write-mm-buffer org-buffer mm-buffer nil) |
| 865 | (with-current-buffer mm-buffer | 985 | (with-current-buffer mm-buffer |
| 866 | (basic-save-buffer) | 986 | (basic-save-buffer) |
| 867 | (when (called-interactively-p 'any) | 987 | (when (org-called-interactively-p 'any) |
| 868 | (switch-to-buffer-other-window mm-buffer) | 988 | (switch-to-buffer-other-window mm-buffer) |
| 869 | (when (y-or-n-p "Show in FreeMind? ") | 989 | (when (y-or-n-p "Show in FreeMind? ") |
| 870 | (org-freemind-show buffer-file-name))))))) | 990 | (org-freemind-show buffer-file-name))))))) |
| @@ -1019,7 +1139,7 @@ PATH should be a list of steps, where each step has the form | |||
| 1019 | (save-match-data | 1139 | (save-match-data |
| 1020 | (let* ((rc (org-freemind-get-richcontent-node node)) | 1140 | (let* ((rc (org-freemind-get-richcontent-node node)) |
| 1021 | (txt (org-freemind-get-tree-text rc))) | 1141 | (txt (org-freemind-get-tree-text rc))) |
| 1022 | ;;(when txt (setq txt (replace-regexp-in-string (rx (1+ whitespace)) " " txt))) | 1142 | ;;(when txt (setq txt (replace-regexp-in-string "[[:space:]]+" " " txt))) |
| 1023 | txt | 1143 | txt |
| 1024 | ))) | 1144 | ))) |
| 1025 | 1145 | ||
| @@ -1028,7 +1148,7 @@ PATH should be a list of steps, where each step has the form | |||
| 1028 | (save-match-data | 1148 | (save-match-data |
| 1029 | (let* ((rc (org-freemind-get-richcontent-note node)) | 1149 | (let* ((rc (org-freemind-get-richcontent-note node)) |
| 1030 | (txt (when rc (org-freemind-get-tree-text rc)))) | 1150 | (txt (when rc (org-freemind-get-tree-text rc)))) |
| 1031 | ;;(when txt (setq txt (replace-regexp-in-string (rx (1+ whitespace)) " " txt))) | 1151 | ;;(when txt (setq txt (replace-regexp-in-string "[[:space:]]+" " " txt))) |
| 1032 | txt | 1152 | txt |
| 1033 | ))) | 1153 | ))) |
| 1034 | 1154 | ||
| @@ -1044,6 +1164,7 @@ PATH should be a list of steps, where each step has the form | |||
| 1044 | (let ((qname (car node)) | 1164 | (let ((qname (car node)) |
| 1045 | (attributes (cadr node)) | 1165 | (attributes (cadr node)) |
| 1046 | text | 1166 | text |
| 1167 | ;; Fix-me: note is never inserted | ||
| 1047 | (note (org-freemind-get-richcontent-note-text node)) | 1168 | (note (org-freemind-get-richcontent-note-text node)) |
| 1048 | (mark "-- This is more about ") | 1169 | (mark "-- This is more about ") |
| 1049 | (icons (org-freemind-get-icon-names node)) | 1170 | (icons (org-freemind-get-icon-names node)) |
| @@ -1074,6 +1195,8 @@ PATH should be a list of steps, where each step has the form | |||
| 1074 | (case qname | 1195 | (case qname |
| 1075 | ('node | 1196 | ('node |
| 1076 | (insert (make-string (- level skip-levels) ?*) " " text "\n") | 1197 | (insert (make-string (- level skip-levels) ?*) " " text "\n") |
| 1198 | (when note | ||
| 1199 | (insert ":COMMENT:\n" note "\n:END:\n")) | ||
| 1077 | )))) | 1200 | )))) |
| 1078 | (dolist (child children) | 1201 | (dolist (child children) |
| 1079 | (unless (or (null child) | 1202 | (unless (or (null child) |
| @@ -1091,7 +1214,7 @@ PATH should be a list of steps, where each step has the form | |||
| 1091 | (default-org-file (concat (file-name-nondirectory mm-file) ".org")) | 1214 | (default-org-file (concat (file-name-nondirectory mm-file) ".org")) |
| 1092 | (org-file (read-file-name "Output org-mode file: " nil nil nil default-org-file))) | 1215 | (org-file (read-file-name "Output org-mode file: " nil nil nil default-org-file))) |
| 1093 | (list mm-file org-file)))) | 1216 | (list mm-file org-file)))) |
| 1094 | (when (org-freemind-check-overwrite org-file (called-interactively-p 'any)) | 1217 | (when (org-freemind-check-overwrite org-file (org-called-interactively-p 'any)) |
| 1095 | (let ((mm-buffer (find-file-noselect mm-file)) | 1218 | (let ((mm-buffer (find-file-noselect mm-file)) |
| 1096 | (org-buffer (find-file-noselect org-file))) | 1219 | (org-buffer (find-file-noselect org-file))) |
| 1097 | (with-current-buffer mm-buffer | 1220 | (with-current-buffer mm-buffer |
| @@ -1100,7 +1223,7 @@ PATH should be a list of steps, where each step has the form | |||
| 1100 | (note (org-freemind-get-richcontent-note-text top-node)) | 1223 | (note (org-freemind-get-richcontent-note-text top-node)) |
| 1101 | (skip-levels | 1224 | (skip-levels |
| 1102 | (if (and note | 1225 | (if (and note |
| 1103 | (string-match (rx bol "--org-mode: WHOLE FILE" eol) note)) | 1226 | (string-match "^--org-mode: WHOLE FILE$" note)) |
| 1104 | 1 | 1227 | 1 |
| 1105 | 0))) | 1228 | 0))) |
| 1106 | (with-current-buffer org-buffer | 1229 | (with-current-buffer org-buffer |
diff --git a/lisp/org/org-gnus.el b/lisp/org/org-gnus.el index f2fca8c29f4..6d782759a75 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.01 | 10 | ;; Version: 7.3 |
| 11 | ;; | 11 | ;; |
| 12 | ;; This file is part of GNU Emacs. | 12 | ;; This file is part of GNU Emacs. |
| 13 | ;; | 13 | ;; |
| @@ -39,9 +39,9 @@ | |||
| 39 | ;; Declare external functions and variables | 39 | ;; Declare external functions and variables |
| 40 | (declare-function message-fetch-field "message" (header &optional not-all)) | 40 | (declare-function message-fetch-field "message" (header &optional not-all)) |
| 41 | (declare-function message-narrow-to-head-1 "message" nil) | 41 | (declare-function message-narrow-to-head-1 "message" nil) |
| 42 | (declare-function nnimap-group-overview-filename "nnimap" (group server)) | ||
| 42 | ;; The following line suppresses a compiler warning stemming from gnus-sum.el | 43 | ;; The following line suppresses a compiler warning stemming from gnus-sum.el |
| 43 | (declare-function gnus-summary-last-subject "gnus-sum" nil) | 44 | (declare-function gnus-summary-last-subject "gnus-sum" nil) |
| 44 | |||
| 45 | ;; Customization variables | 45 | ;; Customization variables |
| 46 | 46 | ||
| 47 | (when (fboundp 'defvaralias) | 47 | (when (fboundp 'defvaralias) |
| @@ -55,6 +55,17 @@ negates this setting for the duration of the command." | |||
| 55 | :group 'org-link-store | 55 | :group 'org-link-store |
| 56 | :type 'boolean) | 56 | :type 'boolean) |
| 57 | 57 | ||
| 58 | (defcustom org-gnus-nnimap-query-article-no-from-file nil | ||
| 59 | "If non-nil, `org-gnus-follow-link' will try to translate | ||
| 60 | Message-Ids to article numbers by querying the .overview file. | ||
| 61 | Normally, this translation is done by querying the IMAP server, | ||
| 62 | which is usually very fast. Unfortunately, some (maybe badly | ||
| 63 | configured) IMAP servers don't support this operation quickly. | ||
| 64 | So if following a link to a Gnus article takes ages, try setting | ||
| 65 | this variable to `t'." | ||
| 66 | :group 'org-link-store | ||
| 67 | :type 'boolean) | ||
| 68 | |||
| 58 | 69 | ||
| 59 | ;; Install the link type | 70 | ;; Install the link type |
| 60 | (org-add-link-type "gnus" 'org-gnus-open) | 71 | (org-add-link-type "gnus" 'org-gnus-open) |
| @@ -62,6 +73,22 @@ negates this setting for the duration of the command." | |||
| 62 | 73 | ||
| 63 | ;; Implementation | 74 | ;; Implementation |
| 64 | 75 | ||
| 76 | (defun org-gnus-nnimap-cached-article-number (group server message-id) | ||
| 77 | "Return cached article number (uid) of message in GROUP on SERVER. | ||
| 78 | MESSAGE-ID is the message-id header field that identifies the | ||
| 79 | message. If the uid is not cached, return nil." | ||
| 80 | (with-temp-buffer | ||
| 81 | (let ((nov (nnimap-group-overview-filename group server))) | ||
| 82 | (when (file-exists-p nov) | ||
| 83 | (mm-insert-file-contents nov) | ||
| 84 | (set-buffer-modified-p nil) | ||
| 85 | (goto-char (point-min)) | ||
| 86 | (catch 'found | ||
| 87 | (while (search-forward message-id nil t) | ||
| 88 | (let ((hdr (split-string (thing-at-point 'line) "\t"))) | ||
| 89 | (if (string= (nth 4 hdr) message-id) | ||
| 90 | (throw 'found (nth 0 hdr)))))))))) | ||
| 91 | |||
| 65 | (defun org-gnus-group-link (group) | 92 | (defun org-gnus-group-link (group) |
| 66 | "Create a link to the Gnus group GROUP. | 93 | "Create a link to the Gnus group GROUP. |
| 67 | If GROUP is a newsgroup and `org-gnus-prefer-web-links' is | 94 | If GROUP is a newsgroup and `org-gnus-prefer-web-links' is |
| @@ -125,6 +152,11 @@ If `org-store-link' was called with a prefix arg the meaning of | |||
| 125 | (from (mail-header-from header)) | 152 | (from (mail-header-from header)) |
| 126 | (message-id (org-remove-angle-brackets (mail-header-id header))) | 153 | (message-id (org-remove-angle-brackets (mail-header-id header))) |
| 127 | (date (mail-header-date header)) | 154 | (date (mail-header-date header)) |
| 155 | (date-ts (and date (format-time-string | ||
| 156 | (org-time-stamp-format t) (date-to-time date)))) | ||
| 157 | (date-ts-ia (and date (format-time-string | ||
| 158 | (org-time-stamp-format t t) | ||
| 159 | (date-to-time date)))) | ||
| 128 | (subject (copy-sequence (mail-header-subject header))) | 160 | (subject (copy-sequence (mail-header-subject header))) |
| 129 | (to (cdr (assq 'To (mail-header-extra header)))) | 161 | (to (cdr (assq 'To (mail-header-extra header)))) |
| 130 | newsgroups x-no-archive desc link) | 162 | newsgroups x-no-archive desc link) |
| @@ -140,14 +172,27 @@ If `org-store-link' was called with a prefix arg the meaning of | |||
| 140 | (setq to (or to (gnus-fetch-original-field "To")) | 172 | (setq to (or to (gnus-fetch-original-field "To")) |
| 141 | newsgroups (gnus-fetch-original-field "Newsgroups") | 173 | newsgroups (gnus-fetch-original-field "Newsgroups") |
| 142 | x-no-archive (gnus-fetch-original-field "x-no-archive"))) | 174 | x-no-archive (gnus-fetch-original-field "x-no-archive"))) |
| 143 | (org-store-link-props :type "gnus" :from from :subject subject | 175 | (org-store-link-props :type "gnus" :from from :subject subject |
| 144 | :message-id message-id :group group :to to) | 176 | :message-id message-id :group group :to to) |
| 177 | (when date | ||
| 178 | (org-add-link-props :date date :date-timestamp date-ts | ||
| 179 | :date-timestamp-inactive date-ts-ia)) | ||
| 145 | (setq desc (org-email-link-description) | 180 | (setq desc (org-email-link-description) |
| 146 | link (org-gnus-article-link | 181 | link (org-gnus-article-link |
| 147 | group newsgroups message-id x-no-archive)) | 182 | group newsgroups message-id x-no-archive)) |
| 148 | (org-add-link-props :link link :description desc) | 183 | (org-add-link-props :link link :description desc) |
| 149 | link)))) | 184 | link)))) |
| 150 | 185 | ||
| 186 | (defun org-gnus-open-nntp (path) | ||
| 187 | "Follow the nntp: link specified by PATH." | ||
| 188 | (let* ((spec (split-string path "/")) | ||
| 189 | (server (split-string (nth 2 spec) "@")) | ||
| 190 | (group (nth 3 spec)) | ||
| 191 | (article (nth 4 spec))) | ||
| 192 | (org-gnus-follow-link | ||
| 193 | (format "nntp+%s:%s" (or (cdr server) (car server)) group) | ||
| 194 | article))) | ||
| 195 | |||
| 151 | (defun org-gnus-open (path) | 196 | (defun org-gnus-open (path) |
| 152 | "Follow the Gnus message or folder link specified by PATH." | 197 | "Follow the Gnus message or folder link specified by PATH." |
| 153 | (let (group article) | 198 | (let (group article) |
| @@ -173,7 +218,9 @@ If `org-store-link' was called with a prefix arg the meaning of | |||
| 173 | (cond ((and group article) | 218 | (cond ((and group article) |
| 174 | (gnus-activate-group group t) | 219 | (gnus-activate-group group t) |
| 175 | (condition-case nil | 220 | (condition-case nil |
| 176 | (let ((backend (car (gnus-find-method-for-group group)))) | 221 | (let* ((method (gnus-find-method-for-group group)) |
| 222 | (backend (car method)) | ||
| 223 | (server (cadr method))) | ||
| 177 | (cond | 224 | (cond |
| 178 | ((eq backend 'nndoc) | 225 | ((eq backend 'nndoc) |
| 179 | (if (gnus-group-read-group t nil group) | 226 | (if (gnus-group-read-group t nil group) |
| @@ -183,6 +230,12 @@ If `org-store-link' was called with a prefix arg the meaning of | |||
| 183 | (t | 230 | (t |
| 184 | (let ((articles 1) | 231 | (let ((articles 1) |
| 185 | group-opened) | 232 | group-opened) |
| 233 | (when (and (eq backend 'nnimap) | ||
| 234 | org-gnus-nnimap-query-article-no-from-file) | ||
| 235 | (setq article | ||
| 236 | (or (org-gnus-nnimap-cached-article-number | ||
| 237 | (nth 1 (split-string group ":")) | ||
| 238 | server (concat "<" article ">")) article))) | ||
| 186 | (while (and (not group-opened) | 239 | (while (and (not group-opened) |
| 187 | ;; stop on integer overflows | 240 | ;; stop on integer overflows |
| 188 | (> articles 0)) | 241 | (> articles 0)) |
diff --git a/lisp/org/org-habit.el b/lisp/org/org-habit.el index 71e0a9583f1..394b4fb05db 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.01 | 8 | ;; Version: 7.3 |
| 9 | ;; | 9 | ;; |
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | ;; | 11 | ;; |
| @@ -149,15 +149,17 @@ This list represents a \"habit\" for the rest of this module." | |||
| 149 | (assert (org-is-habit-p (point))) | 149 | (assert (org-is-habit-p (point))) |
| 150 | (let* ((scheduled (org-get-scheduled-time (point))) | 150 | (let* ((scheduled (org-get-scheduled-time (point))) |
| 151 | (scheduled-repeat (org-get-repeat org-scheduled-string)) | 151 | (scheduled-repeat (org-get-repeat org-scheduled-string)) |
| 152 | (sr-days (org-habit-duration-to-days scheduled-repeat)) | ||
| 153 | (end (org-entry-end-position)) | 152 | (end (org-entry-end-position)) |
| 154 | (habit-entry (org-no-properties (nth 5 (org-heading-components)))) | 153 | (habit-entry (org-no-properties (nth 4 (org-heading-components)))) |
| 155 | closed-dates deadline dr-days) | 154 | closed-dates deadline dr-days sr-days) |
| 156 | (if scheduled | 155 | (if scheduled |
| 157 | (setq scheduled (time-to-days scheduled)) | 156 | (setq scheduled (time-to-days scheduled)) |
| 158 | (error "Habit %s has no scheduled date" habit-entry)) | 157 | (error "Habit %s has no scheduled date" habit-entry)) |
| 159 | (unless scheduled-repeat | 158 | (unless scheduled-repeat |
| 160 | (error "Habit %s has no scheduled repeat period" habit-entry)) | 159 | (error |
| 160 | "Habit '%s' has no scheduled repeat period or has an incorrect one" | ||
| 161 | habit-entry)) | ||
| 162 | (setq sr-days (org-habit-duration-to-days scheduled-repeat)) | ||
| 161 | (unless (> sr-days 0) | 163 | (unless (> sr-days 0) |
| 162 | (error "Habit %s scheduled repeat period is less than 1d" habit-entry)) | 164 | (error "Habit %s scheduled repeat period is less than 1d" habit-entry)) |
| 163 | (when (string-match "/\\([0-9]+[dwmy]\\)" scheduled-repeat) | 165 | (when (string-match "/\\([0-9]+[dwmy]\\)" scheduled-repeat) |
diff --git a/lisp/org/org-html.el b/lisp/org/org-html.el index e20b92147fc..68fee5b8df5 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.01 | 9 | ;; Version: 7.3 |
| 10 | ;; | 10 | ;; |
| 11 | ;; This file is part of GNU Emacs. | 11 | ;; This file is part of GNU Emacs. |
| 12 | ;; | 12 | ;; |
| @@ -126,6 +126,9 @@ not be modified." | |||
| 126 | .target { } | 126 | .target { } |
| 127 | .timestamp { color: #bebebe; } | 127 | .timestamp { color: #bebebe; } |
| 128 | .timestamp-kwd { color: #5f9ea0; } | 128 | .timestamp-kwd { color: #5f9ea0; } |
| 129 | .right {margin-left:auto; margin-right:0px; text-align:right;} | ||
| 130 | .left {margin-left:0px; margin-right:auto; text-align:left;} | ||
| 131 | .center {margin-left:auto; margin-right:auto; text-align:center;} | ||
| 129 | p.verse { margin-left: 3% } | 132 | p.verse { margin-left: 3% } |
| 130 | pre { | 133 | pre { |
| 131 | border: 1pt solid #AEBDCC; | 134 | border: 1pt solid #AEBDCC; |
| @@ -136,7 +139,13 @@ not be modified." | |||
| 136 | overflow:auto; | 139 | overflow:auto; |
| 137 | } | 140 | } |
| 138 | table { border-collapse: collapse; } | 141 | table { border-collapse: collapse; } |
| 139 | td, th { vertical-align: top; } | 142 | td, th { vertical-align: top; } |
| 143 | th.right { text-align:center; } | ||
| 144 | th.left { text-align:center; } | ||
| 145 | th.center { text-align:center; } | ||
| 146 | td.right { text-align:right; } | ||
| 147 | td.left { text-align:left; } | ||
| 148 | td.center { text-align:center; } | ||
| 140 | dt { font-weight: bold; } | 149 | dt { font-weight: bold; } |
| 141 | div.figure { padding: 0.5em; } | 150 | div.figure { padding: 0.5em; } |
| 142 | div.figure p { text-align: center; } | 151 | div.figure p { text-align: center; } |
| @@ -209,6 +218,112 @@ settings with <style>...</style> tags." | |||
| 209 | ;;;###autoload | 218 | ;;;###autoload |
| 210 | (put 'org-export-html-style-extra 'safe-local-variable 'stringp) | 219 | (put 'org-export-html-style-extra 'safe-local-variable 'stringp) |
| 211 | 220 | ||
| 221 | (defcustom org-export-html-mathjax-options | ||
| 222 | '((path "http://orgmode.org/mathjax/MathJax.js") | ||
| 223 | (scale "100") | ||
| 224 | (align "center") | ||
| 225 | (indent "2em") | ||
| 226 | (mathml nil)) | ||
| 227 | "Options for MathJax setup. | ||
| 228 | |||
| 229 | path The path where to find MathJax | ||
| 230 | scale Scaling for the HTML-CSS backend, usually between 100 and 133 | ||
| 231 | align How to align display math: left, center, or right | ||
| 232 | indent If align is not center, how far from the left/right side? | ||
| 233 | mathml Should a MathML player be used if available? | ||
| 234 | This is faster and reduces bandwidth use, but currently | ||
| 235 | sometimes has lower spacing quality. Therefore, the default is | ||
| 236 | nil. When browsers get better, this switch can be flipped. | ||
| 237 | |||
| 238 | You can also customize this for each buffer, using something like | ||
| 239 | |||
| 240 | #+MATHJAX: scale:\"133\" align:\"right\" mathml:t path:\"/MathJax/\"" | ||
| 241 | :group 'org-export-html | ||
| 242 | :type '(list :greedy t | ||
| 243 | (list :tag "path (the path from where to load MathJax.js)" | ||
| 244 | (const :format " " path) (string)) | ||
| 245 | (list :tag "scale (scaling for the displayed math)" | ||
| 246 | (const :format " " scale) (string)) | ||
| 247 | (list :tag "align (alignment of displayed equations)" | ||
| 248 | (const :format " " align) (string)) | ||
| 249 | (list :tag "indent (indentation with left or right alignment)" | ||
| 250 | (const :format " " indent) (string)) | ||
| 251 | (list :tag "mathml (should MathML display be used is possible)" | ||
| 252 | (const :format " " mathml) (boolean)))) | ||
| 253 | |||
| 254 | (defun org-export-html-mathjax-config (template options in-buffer) | ||
| 255 | "Insert the user setup into the matchjax template." | ||
| 256 | (let (name val (yes " ") (no "// ") x) | ||
| 257 | (mapc | ||
| 258 | (lambda (e) | ||
| 259 | (setq name (car e) val (nth 1 e)) | ||
| 260 | (if (string-match (concat "\\<" (symbol-name name) ":") in-buffer) | ||
| 261 | (setq val (car (read-from-string | ||
| 262 | (substring in-buffer (match-end 0)))))) | ||
| 263 | (if (not (stringp val)) (setq val (format "%s" val))) | ||
| 264 | (if (string-match (concat "%" (upcase (symbol-name name))) template) | ||
| 265 | (setq template (replace-match val t t template)))) | ||
| 266 | options) | ||
| 267 | (setq val (nth 1 (assq 'mathml options))) | ||
| 268 | (if (string-match (concat "\\<mathml:") in-buffer) | ||
| 269 | (setq val (car (read-from-string | ||
| 270 | (substring in-buffer (match-end 0)))))) | ||
| 271 | ;; Exchange prefixes depending on mathml setting | ||
| 272 | (if (not val) (setq x yes yes no no x)) | ||
| 273 | ;; Replace cookies to turn on or off the config/jax lines | ||
| 274 | (if (string-match ":MMLYES:" template) | ||
| 275 | (setq template (replace-match yes t t template))) | ||
| 276 | (if (string-match ":MMLNO:" template) | ||
| 277 | (setq template (replace-match no t t template))) | ||
| 278 | ;; Return the modified template | ||
| 279 | template)) | ||
| 280 | |||
| 281 | (defcustom org-export-html-mathjax-template | ||
| 282 | "<script type=\"text/javascript\" src=\"%PATH\"> | ||
| 283 | <!--/*--><![CDATA[/*><!--*/ | ||
| 284 | MathJax.Hub.Config({ | ||
| 285 | // Only one of the two following lines, depending on user settings | ||
| 286 | // First allows browser-native MathML display, second forces HTML/CSS | ||
| 287 | :MMLYES: config: [\"MMLorHTML.js\"], jax: [\"input/TeX\"], | ||
| 288 | :MMLNO: jax: [\"input/TeX\", \"output/HTML-CSS\"], | ||
| 289 | extensions: [\"tex2jax.js\",\"TeX/AMSmath.js\",\"TeX/AMSsymbols.js\", | ||
| 290 | \"TeX/noUndefined.js\"], | ||
| 291 | tex2jax: { | ||
| 292 | inlineMath: [ [\"\\\\(\",\"\\\\)\"] ], | ||
| 293 | displayMath: [ ['$$','$$'], [\"\\\\[\",\"\\\\]\"] ], | ||
| 294 | skipTags: [\"script\",\"noscript\",\"style\",\"textarea\",\"pre\",\"code\"], | ||
| 295 | ignoreClass: \"tex2jax_ignore\", | ||
| 296 | processEscapes: false, | ||
| 297 | processEnvironments: true, | ||
| 298 | preview: \"TeX\" | ||
| 299 | }, | ||
| 300 | showProcessingMessages: true, | ||
| 301 | displayAlign: \"%ALIGN\", | ||
| 302 | displayIndent: \"%INDENT\", | ||
| 303 | |||
| 304 | \"HTML-CSS\": { | ||
| 305 | scale: %SCALE, | ||
| 306 | availableFonts: [\"STIX\",\"TeX\"], | ||
| 307 | preferredFont: \"TeX\", | ||
| 308 | webFont: \"TeX\", | ||
| 309 | imageFont: \"TeX\", | ||
| 310 | showMathMenu: true, | ||
| 311 | }, | ||
| 312 | MMLorHTML: { | ||
| 313 | prefer: { | ||
| 314 | MSIE: \"MML\", | ||
| 315 | Firefox: \"MML\", | ||
| 316 | Opera: \"HTML\", | ||
| 317 | other: \"HTML\" | ||
| 318 | } | ||
| 319 | } | ||
| 320 | }); | ||
| 321 | /*]]>*///--> | ||
| 322 | </script>" | ||
| 323 | "The MathJax setup for XHTML files." | ||
| 324 | :group 'org-export-html | ||
| 325 | :type 'string) | ||
| 326 | |||
| 212 | (defcustom org-export-html-tag-class-prefix "" | 327 | (defcustom org-export-html-tag-class-prefix "" |
| 213 | "Prefix to class names for TODO keywords. | 328 | "Prefix to class names for TODO keywords. |
| 214 | Each tag gets a class given by the tag itself, with this prefix. | 329 | Each tag gets a class given by the tag itself, with this prefix. |
| @@ -281,7 +396,7 @@ be linked only." | |||
| 281 | (const :tag "When there is no description" maybe))) | 396 | (const :tag "When there is no description" maybe))) |
| 282 | 397 | ||
| 283 | (defcustom org-export-html-inline-image-extensions | 398 | (defcustom org-export-html-inline-image-extensions |
| 284 | '("png" "jpeg" "jpg" "gif") | 399 | '("png" "jpeg" "jpg" "gif" "svg") |
| 285 | "Extensions of image files that can be inlined into HTML." | 400 | "Extensions of image files that can be inlined into HTML." |
| 286 | :group 'org-export-html | 401 | :group 'org-export-html |
| 287 | :type '(repeat (string :tag "Extension"))) | 402 | :type '(repeat (string :tag "Extension"))) |
| @@ -294,17 +409,22 @@ borders and spacing." | |||
| 294 | :group 'org-export-html | 409 | :group 'org-export-html |
| 295 | :type 'string) | 410 | :type 'string) |
| 296 | 411 | ||
| 297 | (defcustom org-export-table-header-tags '("<th scope=\"%s\">" . "</th>") | 412 | (defcustom org-export-table-header-tags '("<th scope=\"%s\"%s>" . "</th>") |
| 298 | "The opening tag for table header fields. | 413 | "The opening tag for table header fields. |
| 299 | This is customizable so that alignment options can be specified. | 414 | This is customizable so that alignment options can be specified. |
| 300 | %s will be filled with the scope of the field, either row or col. | 415 | The first %s will be filled with the scope of the field, either row or col. |
| 301 | See also the variable `org-export-html-table-use-header-tags-for-first-column'." | 416 | The second %s will be replaced by a style entry to align the field. |
| 417 | See also the variable `org-export-html-table-use-header-tags-for-first-column'. | ||
| 418 | See also the variable `org-export-html-table-align-individual-fields'." | ||
| 302 | :group 'org-export-tables | 419 | :group 'org-export-tables |
| 303 | :type '(cons (string :tag "Opening tag") (string :tag "Closing tag"))) | 420 | :type '(cons (string :tag "Opening tag") (string :tag "Closing tag"))) |
| 304 | 421 | ||
| 305 | (defcustom org-export-table-data-tags '("<td>" . "</td>") | 422 | (defcustom org-export-table-data-tags '("<td%s>" . "</td>") |
| 306 | "The opening tag for table data fields. | 423 | "The opening tag for table data fields. |
| 307 | This is customizable so that alignment options can be specified." | 424 | This is customizable so that alignment options can be specified. |
| 425 | The first %s will be filled with the scope of the field, either row or col. | ||
| 426 | The second %s will be replaced by a style entry to align the field. | ||
| 427 | See also the variable `org-export-html-table-align-individual-fields'." | ||
| 308 | :group 'org-export-tables | 428 | :group 'org-export-tables |
| 309 | :type '(cons (string :tag "Opening tag") (string :tag "Closing tag"))) | 429 | :type '(cons (string :tag "Opening tag") (string :tag "Closing tag"))) |
| 310 | 430 | ||
| @@ -335,7 +455,13 @@ will give even lines the class \"tr-even\" and odd lines the class \"tr-odd\"." | |||
| 335 | (string :tag "Specify") | 455 | (string :tag "Specify") |
| 336 | (sexp)))) | 456 | (sexp)))) |
| 337 | 457 | ||
| 338 | 458 | (defcustom org-export-html-table-align-individual-fields t | |
| 459 | "Non-nil means attach style attributes for alignment to each table field. | ||
| 460 | When nil, alignment will only be specified in the column tags, but this | ||
| 461 | is ignored by some browsers (like Firefox, Safari). Opera does it right | ||
| 462 | though." | ||
| 463 | :group 'org-export-tables | ||
| 464 | :type 'boolean) | ||
| 339 | 465 | ||
| 340 | (defcustom org-export-html-table-use-header-tags-for-first-column nil | 466 | (defcustom org-export-html-table-use-header-tags-for-first-column nil |
| 341 | "Non-nil means format column one in tables with header tags. | 467 | "Non-nil means format column one in tables with header tags. |
| @@ -413,7 +539,7 @@ with a link to this URL." | |||
| 413 | "Preamble, to be inserted just after <body>. Set by publishing functions. | 539 | "Preamble, to be inserted just after <body>. Set by publishing functions. |
| 414 | This may also be a function, building and inserting the preamble.") | 540 | This may also be a function, building and inserting the preamble.") |
| 415 | (defvar org-export-html-postamble nil | 541 | (defvar org-export-html-postamble nil |
| 416 | "Preamble, to be inserted just before </body>. Set by publishing functions. | 542 | "Postamble, to be inserted just before </body>. Set by publishing functions. |
| 417 | This may also be a function, building and inserting the postamble.") | 543 | This may also be a function, building and inserting the postamble.") |
| 418 | (defvar org-export-html-auto-preamble t | 544 | (defvar org-export-html-auto-preamble t |
| 419 | "Should default preamble be inserted? Set by publishing functions.") | 545 | "Should default preamble be inserted? Set by publishing functions.") |
| @@ -439,7 +565,13 @@ This may also be a function, building and inserting the postamble.") | |||
| 439 | (file-name-nondirectory | 565 | (file-name-nondirectory |
| 440 | org-current-export-file))) | 566 | org-current-export-file))) |
| 441 | org-current-export-dir nil "Creating LaTeX image %s" | 567 | org-current-export-dir nil "Creating LaTeX image %s" |
| 442 | nil nil (eq (plist-get parameters :LaTeX-fragments) 'verbatim))) | 568 | nil nil |
| 569 | (cond | ||
| 570 | ((eq (plist-get parameters :LaTeX-fragments) 'verbatim) 'verbatim) | ||
| 571 | ((eq (plist-get parameters :LaTeX-fragments) 'mathjax ) 'mathjax) | ||
| 572 | ((eq (plist-get parameters :LaTeX-fragments) t ) 'mathjax) | ||
| 573 | ((eq (plist-get parameters :LaTeX-fragments) 'dvipng ) 'dvipng) | ||
| 574 | (t nil)))) | ||
| 443 | (goto-char (point-min)) | 575 | (goto-char (point-min)) |
| 444 | (let (label l1) | 576 | (let (label l1) |
| 445 | (while (re-search-forward "\\\\ref{\\([^{}\n]+\\)}" nil t) | 577 | (while (re-search-forward "\\\\ref{\\([^{}\n]+\\)}" nil t) |
| @@ -562,7 +694,7 @@ See variable `org-export-html-link-org-files-as-html'" | |||
| 562 | (string-match "\\.org$" path) | 694 | (string-match "\\.org$" path) |
| 563 | (progn | 695 | (progn |
| 564 | (list | 696 | (list |
| 565 | "http" | 697 | "file" |
| 566 | (concat | 698 | (concat |
| 567 | (substring path 0 (match-beginning 0)) | 699 | (substring path 0 (match-beginning 0)) |
| 568 | "." | 700 | "." |
| @@ -579,13 +711,10 @@ description. See variables `org-export-html-inline-images' and | |||
| 579 | (declare (special | 711 | (declare (special |
| 580 | org-export-html-inline-images | 712 | org-export-html-inline-images |
| 581 | org-export-html-inline-image-extensions)) | 713 | org-export-html-inline-image-extensions)) |
| 582 | (or | 714 | (and (or (eq t org-export-html-inline-images) |
| 583 | (eq t org-export-html-inline-images) | 715 | (and org-export-html-inline-images (not descp))) |
| 584 | (and | 716 | (org-file-image-p |
| 585 | org-export-html-inline-images | 717 | filename org-export-html-inline-image-extensions))) |
| 586 | (not descp))) | ||
| 587 | (org-file-image-p | ||
| 588 | filename org-export-html-inline-image-extensions)) | ||
| 589 | 718 | ||
| 590 | ;;; org-html-make-link | 719 | ;;; org-html-make-link |
| 591 | (defun org-html-make-link (opt-plist type path fragment desc attr | 720 | (defun org-html-make-link (opt-plist type path fragment desc attr |
| @@ -611,7 +740,7 @@ MAY-INLINE-P allows inlining it as an image." | |||
| 611 | ;;Substitute just if original path was absolute. | 740 | ;;Substitute just if original path was absolute. |
| 612 | ;;(Otherwise path must remain relative) | 741 | ;;(Otherwise path must remain relative) |
| 613 | (if (file-name-absolute-p path) | 742 | (if (file-name-absolute-p path) |
| 614 | (expand-file-name path) | 743 | (concat "file://" (expand-file-name path)) |
| 615 | path))) | 744 | path))) |
| 616 | ((string= type "") | 745 | ((string= type "") |
| 617 | (list nil path)) | 746 | (list nil path)) |
| @@ -637,7 +766,8 @@ MAY-INLINE-P allows inlining it as an image." | |||
| 637 | ((or | 766 | ((or |
| 638 | (not type) | 767 | (not type) |
| 639 | (string= type "http") | 768 | (string= type "http") |
| 640 | (string= type "https")) | 769 | (string= type "https") |
| 770 | (string= type "file")) | ||
| 641 | (if fragment | 771 | (if fragment |
| 642 | (setq thefile (concat thefile "#" fragment)))) | 772 | (setq thefile (concat thefile "#" fragment)))) |
| 643 | 773 | ||
| @@ -647,8 +777,7 @@ MAY-INLINE-P allows inlining it as an image." | |||
| 647 | (setq thefile | 777 | (setq thefile |
| 648 | (let | 778 | (let |
| 649 | ((str (org-export-html-format-href thefile))) | 779 | ((str (org-export-html-format-href thefile))) |
| 650 | (if (and type (not (string= "file" type)) | 780 | (if (and type (not (string= "file" type))) |
| 651 | (org-string-match-p "^//" str)) | ||
| 652 | (concat type ":" str) | 781 | (concat type ":" str) |
| 653 | str))) | 782 | str))) |
| 654 | 783 | ||
| @@ -781,8 +910,8 @@ PUB-DIR is set, use this as the publishing directory." | |||
| 781 | (string-match "\\S-" (plist-get opt-plist :link-up)) | 910 | (string-match "\\S-" (plist-get opt-plist :link-up)) |
| 782 | (plist-get opt-plist :link-up))) | 911 | (plist-get opt-plist :link-up))) |
| 783 | (link-home (and (plist-get opt-plist :link-home) | 912 | (link-home (and (plist-get opt-plist :link-home) |
| 784 | (string-match "\\S-" (plist-get opt-plist :link-home)) | 913 | (string-match "\\S-" (plist-get opt-plist :link-home)) |
| 785 | (plist-get opt-plist :link-home))) | 914 | (plist-get opt-plist :link-home))) |
| 786 | (dummy (setq opt-plist (plist-put opt-plist :title title))) | 915 | (dummy (setq opt-plist (plist-put opt-plist :title title))) |
| 787 | (html-table-tag (plist-get opt-plist :html-table-tag)) | 916 | (html-table-tag (plist-get opt-plist :html-table-tag)) |
| 788 | (quote-re0 (concat "^[ \t]*" org-quote-string "\\>")) | 917 | (quote-re0 (concat "^[ \t]*" org-quote-string "\\>")) |
| @@ -815,6 +944,7 @@ PUB-DIR is set, use this as the publishing directory." | |||
| 815 | (buffer-substring | 944 | (buffer-substring |
| 816 | (if region-p (region-beginning) (point-min)) | 945 | (if region-p (region-beginning) (point-min)) |
| 817 | (if region-p (region-end) (point-max)))) | 946 | (if region-p (region-end) (point-max)))) |
| 947 | (org-export-have-math nil) | ||
| 818 | (lines | 948 | (lines |
| 819 | (org-split-string | 949 | (org-split-string |
| 820 | (org-export-preprocess-string | 950 | (org-export-preprocess-string |
| @@ -838,11 +968,21 @@ PUB-DIR is set, use this as the publishing directory." | |||
| 838 | :LaTeX-fragments | 968 | :LaTeX-fragments |
| 839 | (plist-get opt-plist :LaTeX-fragments)) | 969 | (plist-get opt-plist :LaTeX-fragments)) |
| 840 | "[\r\n]")) | 970 | "[\r\n]")) |
| 971 | (mathjax | ||
| 972 | (if (or (eq (plist-get opt-plist :LaTeX-fragments) 'mathjax) | ||
| 973 | (and org-export-have-math | ||
| 974 | (eq (plist-get opt-plist :LaTeX-fragments) t))) | ||
| 975 | |||
| 976 | (org-export-html-mathjax-config | ||
| 977 | org-export-html-mathjax-template | ||
| 978 | org-export-html-mathjax-options | ||
| 979 | (or (plist-get opt-plist :mathjax) "")) | ||
| 980 | "")) | ||
| 841 | table-open type | 981 | table-open type |
| 842 | table-buffer table-orig-buffer | 982 | table-buffer table-orig-buffer |
| 843 | ind item-type starter didclose | 983 | ind item-type starter |
| 844 | rpl path attr desc descp desc1 desc2 link | 984 | rpl path attr desc descp desc1 desc2 link |
| 845 | snumber fnc item-tag initial-number | 985 | snumber fnc item-tag item-number |
| 846 | footnotes footref-seen | 986 | footnotes footref-seen |
| 847 | id-file href | 987 | id-file href |
| 848 | ) | 988 | ) |
| @@ -907,6 +1047,7 @@ lang=\"%s\" xml:lang=\"%s\"> | |||
| 907 | <meta name=\"description\" content=\"%s\"/> | 1047 | <meta name=\"description\" content=\"%s\"/> |
| 908 | <meta name=\"keywords\" content=\"%s\"/> | 1048 | <meta name=\"keywords\" content=\"%s\"/> |
| 909 | %s | 1049 | %s |
| 1050 | %s | ||
| 910 | </head> | 1051 | </head> |
| 911 | <body> | 1052 | <body> |
| 912 | <div id=\"content\"> | 1053 | <div id=\"content\"> |
| @@ -925,6 +1066,7 @@ lang=\"%s\" xml:lang=\"%s\"> | |||
| 925 | (or charset "iso-8859-1") | 1066 | (or charset "iso-8859-1") |
| 926 | date author description keywords | 1067 | date author description keywords |
| 927 | style | 1068 | style |
| 1069 | mathjax | ||
| 928 | (if (or link-up link-home) | 1070 | (if (or link-up link-home) |
| 929 | (concat | 1071 | (concat |
| 930 | (format org-export-html-home/up-format | 1072 | (format org-export-html-home/up-format |
| @@ -950,73 +1092,73 @@ lang=\"%s\" xml:lang=\"%s\"> | |||
| 950 | (push "<ul>\n<li>" thetoc) | 1092 | (push "<ul>\n<li>" thetoc) |
| 951 | (setq lines | 1093 | (setq lines |
| 952 | (mapcar '(lambda (line) | 1094 | (mapcar '(lambda (line) |
| 953 | (if (and (string-match org-todo-line-regexp line) | 1095 | (if (and (string-match org-todo-line-regexp line) |
| 954 | (not (get-text-property 0 'org-protected line))) | 1096 | (not (get-text-property 0 'org-protected line))) |
| 955 | ;; This is a headline | 1097 | ;; This is a headline |
| 956 | (progn | 1098 | (progn |
| 957 | (setq have-headings t) | 1099 | (setq have-headings t) |
| 958 | (setq level (- (match-end 1) (match-beginning 1) | 1100 | (setq level (- (match-end 1) (match-beginning 1) |
| 959 | level-offset) | 1101 | level-offset) |
| 960 | level (org-tr-level level) | 1102 | level (org-tr-level level) |
| 961 | txt (save-match-data | 1103 | txt (save-match-data |
| 962 | (org-html-expand | 1104 | (org-html-expand |
| 963 | (org-export-cleanup-toc-line | 1105 | (org-export-cleanup-toc-line |
| 964 | (match-string 3 line)))) | 1106 | (match-string 3 line)))) |
| 965 | todo | 1107 | todo |
| 966 | (or (and org-export-mark-todo-in-toc | 1108 | (or (and org-export-mark-todo-in-toc |
| 967 | (match-beginning 2) | 1109 | (match-beginning 2) |
| 968 | (not (member (match-string 2 line) | 1110 | (not (member (match-string 2 line) |
| 969 | org-done-keywords))) | 1111 | org-done-keywords))) |
| 970 | ; TODO, not DONE | 1112 | ; TODO, not DONE |
| 971 | (and org-export-mark-todo-in-toc | 1113 | (and org-export-mark-todo-in-toc |
| 972 | (= level umax-toc) | 1114 | (= level umax-toc) |
| 973 | (org-search-todo-below | 1115 | (org-search-todo-below |
| 974 | line lines level)))) | 1116 | line lines level)))) |
| 975 | (if (string-match | 1117 | (if (string-match |
| 976 | (org-re "[ \t]+:\\([[:alnum:]_@:]+\\):[ \t]*$") txt) | 1118 | (org-re "[ \t]+:\\([[:alnum:]_@:]+\\):[ \t]*$") txt) |
| 977 | (setq txt (replace-match " <span class=\"tag\"> \\1</span>" t nil txt))) | 1119 | (setq txt (replace-match " <span class=\"tag\"> \\1</span>" t nil txt))) |
| 978 | (if (string-match quote-re0 txt) | 1120 | (if (string-match quote-re0 txt) |
| 979 | (setq txt (replace-match "" t t txt))) | 1121 | (setq txt (replace-match "" t t txt))) |
| 980 | (setq snumber (org-section-number level)) | 1122 | (setq snumber (org-section-number level)) |
| 981 | (if org-export-with-section-numbers | 1123 | (if org-export-with-section-numbers |
| 982 | (setq txt (concat snumber " " txt))) | 1124 | (setq txt (concat snumber " " txt))) |
| 983 | (if (<= level (max umax umax-toc)) | 1125 | (if (<= level (max umax umax-toc)) |
| 984 | (setq head-count (+ head-count 1))) | 1126 | (setq head-count (+ head-count 1))) |
| 985 | (if (<= level umax-toc) | 1127 | (if (<= level umax-toc) |
| 986 | (progn | 1128 | (progn |
| 987 | (if (> level org-last-level) | 1129 | (if (> level org-last-level) |
| 988 | (progn | 1130 | (progn |
| 989 | (setq cnt (- level org-last-level)) | 1131 | (setq cnt (- level org-last-level)) |
| 990 | (while (>= (setq cnt (1- cnt)) 0) | 1132 | (while (>= (setq cnt (1- cnt)) 0) |
| 991 | (push "\n<ul>\n<li>" thetoc)) | 1133 | (push "\n<ul>\n<li>" thetoc)) |
| 992 | (push "\n" thetoc))) | 1134 | (push "\n" thetoc))) |
| 993 | (if (< level org-last-level) | 1135 | (if (< level org-last-level) |
| 994 | (progn | 1136 | (progn |
| 995 | (setq cnt (- org-last-level level)) | 1137 | (setq cnt (- org-last-level level)) |
| 996 | (while (>= (setq cnt (1- cnt)) 0) | 1138 | (while (>= (setq cnt (1- cnt)) 0) |
| 997 | (push "</li>\n</ul>" thetoc)) | 1139 | (push "</li>\n</ul>" thetoc)) |
| 998 | (push "\n" thetoc))) | 1140 | (push "\n" thetoc))) |
| 999 | ;; Check for targets | 1141 | ;; Check for targets |
| 1000 | (while (string-match org-any-target-regexp line) | 1142 | (while (string-match org-any-target-regexp line) |
| 1001 | (setq line (replace-match | 1143 | (setq line (replace-match |
| 1002 | (concat "@<span class=\"target\">" (match-string 1 line) "@</span> ") | 1144 | (concat "@<span class=\"target\">" (match-string 1 line) "@</span> ") |
| 1003 | t t line))) | 1145 | t t line))) |
| 1004 | (while (string-match "<\\(<\\)+\\|>\\(>\\)+" txt) | 1146 | (while (string-match "<\\(<\\)+\\|>\\(>\\)+" txt) |
| 1005 | (setq txt (replace-match "" t t txt))) | 1147 | (setq txt (replace-match "" t t txt))) |
| 1006 | (setq href | 1148 | (setq href |
| 1007 | (replace-regexp-in-string | 1149 | (replace-regexp-in-string |
| 1008 | "\\." "_" (format "sec-%s" snumber))) | 1150 | "\\." "_" (format "sec-%s" snumber))) |
| 1009 | (setq href (or (cdr (assoc href org-export-preferred-target-alist)) href)) | 1151 | (setq href (or (cdr (assoc href org-export-preferred-target-alist)) href)) |
| 1010 | (push | 1152 | (push |
| 1011 | (format | 1153 | (format |
| 1012 | (if todo | 1154 | (if todo |
| 1013 | "</li>\n<li><a href=\"#%s\"><span class=\"todo\">%s</span></a>" | 1155 | "</li>\n<li><a href=\"#%s\"><span class=\"todo\">%s</span></a>" |
| 1014 | "</li>\n<li><a href=\"#%s\">%s</a>") | 1156 | "</li>\n<li><a href=\"#%s\">%s</a>") |
| 1015 | href txt) thetoc) | 1157 | href txt) thetoc) |
| 1016 | 1158 | ||
| 1017 | (setq org-last-level level)) | 1159 | (setq org-last-level level)) |
| 1018 | ))) | 1160 | ))) |
| 1019 | line) | 1161 | line) |
| 1020 | lines)) | 1162 | lines)) |
| 1021 | (while (> org-last-level (1- org-min-level)) | 1163 | (while (> org-last-level (1- org-min-level)) |
| 1022 | (setq org-last-level (1- org-last-level)) | 1164 | (setq org-last-level (1- org-last-level)) |
| @@ -1059,7 +1201,16 @@ lang=\"%s\" xml:lang=\"%s\"> | |||
| 1059 | (org-open-par)) | 1201 | (org-open-par)) |
| 1060 | (throw 'nextline nil)) | 1202 | (throw 'nextline nil)) |
| 1061 | 1203 | ||
| 1062 | (org-export-html-close-lists-maybe line) | 1204 | ;; Explicit list closure |
| 1205 | (when (equal "ORG-LIST-END" line) | ||
| 1206 | (while local-list-indent | ||
| 1207 | (org-close-li (car local-list-type)) | ||
| 1208 | (insert (format "</%sl>\n" (car local-list-type))) | ||
| 1209 | (pop local-list-type) | ||
| 1210 | (pop local-list-indent)) | ||
| 1211 | (setq in-local-list nil) | ||
| 1212 | (org-open-par) | ||
| 1213 | (throw 'nextline nil)) | ||
| 1063 | 1214 | ||
| 1064 | ;; Protected HTML | 1215 | ;; Protected HTML |
| 1065 | (when (get-text-property 0 'org-protected line) | 1216 | (when (get-text-property 0 'org-protected line) |
| @@ -1178,79 +1329,79 @@ lang=\"%s\" xml:lang=\"%s\"> | |||
| 1178 | desc2 (if (match-end 2) (concat type ":" path) path) | 1329 | desc2 (if (match-end 2) (concat type ":" path) path) |
| 1179 | descp (and desc1 (not (equal desc1 desc2))) | 1330 | descp (and desc1 (not (equal desc1 desc2))) |
| 1180 | desc (or desc1 desc2)) | 1331 | desc (or desc1 desc2)) |
| 1181 | ;; Make an image out of the description if that is so wanted | 1332 | ;; Make an image out of the description if that is so wanted |
| 1182 | (when (and descp (org-file-image-p | 1333 | (when (and descp (org-file-image-p |
| 1183 | desc org-export-html-inline-image-extensions)) | 1334 | desc org-export-html-inline-image-extensions)) |
| 1184 | (save-match-data | 1335 | (save-match-data |
| 1185 | (if (string-match "^file:" desc) | 1336 | (if (string-match "^file:" desc) |
| 1186 | (setq desc (substring desc (match-end 0))))) | 1337 | (setq desc (substring desc (match-end 0))))) |
| 1187 | (setq desc (org-add-props | 1338 | (setq desc (org-add-props |
| 1188 | (concat "<img src=\"" desc "\"/>") | 1339 | (concat "<img src=\"" desc "\"/>") |
| 1189 | '(org-protected t)))) | 1340 | '(org-protected t)))) |
| 1190 | (cond | 1341 | (cond |
| 1191 | ((equal type "internal") | 1342 | ((equal type "internal") |
| 1192 | (let | 1343 | (let |
| 1193 | ((frag-0 | 1344 | ((frag-0 |
| 1194 | (if (= (string-to-char path) ?#) | 1345 | (if (= (string-to-char path) ?#) |
| 1195 | (substring path 1) | 1346 | (substring path 1) |
| 1196 | path))) | 1347 | path))) |
| 1197 | (setq rpl | 1348 | (setq rpl |
| 1198 | (org-html-make-link | 1349 | (org-html-make-link |
| 1199 | opt-plist | 1350 | opt-plist |
| 1200 | "" | 1351 | "" |
| 1201 | "" | 1352 | "" |
| 1202 | (org-solidify-link-text | 1353 | (org-solidify-link-text |
| 1203 | (save-match-data (org-link-unescape frag-0)) | 1354 | (save-match-data (org-link-unescape frag-0)) |
| 1204 | nil) | 1355 | nil) |
| 1205 | desc attr nil)))) | 1356 | desc attr nil)))) |
| 1206 | ((and (equal type "id") | 1357 | ((and (equal type "id") |
| 1207 | (setq id-file (org-id-find-id-file path))) | 1358 | (setq id-file (org-id-find-id-file path))) |
| 1208 | ;; This is an id: link to another file (if it was the same file, | 1359 | ;; This is an id: link to another file (if it was the same file, |
| 1209 | ;; it would have become an internal link...) | 1360 | ;; it would have become an internal link...) |
| 1210 | (save-match-data | 1361 | (save-match-data |
| 1211 | (setq id-file (file-relative-name | 1362 | (setq id-file (file-relative-name |
| 1212 | id-file | 1363 | id-file |
| 1213 | (file-name-directory org-current-export-file))) | 1364 | (file-name-directory org-current-export-file))) |
| 1214 | (setq rpl | 1365 | (setq rpl |
| 1215 | (org-html-make-link opt-plist | 1366 | (org-html-make-link opt-plist |
| 1216 | "file" id-file | 1367 | "file" id-file |
| 1217 | (concat (if (org-uuidgen-p path) "ID-") path) | 1368 | (concat (if (org-uuidgen-p path) "ID-") path) |
| 1218 | desc | 1369 | desc |
| 1219 | attr | 1370 | attr |
| 1220 | nil)))) | 1371 | nil)))) |
| 1221 | ((member type '("http" "https")) | 1372 | ((member type '("http" "https")) |
| 1222 | ;; standard URL, can inline as image | 1373 | ;; standard URL, can inline as image |
| 1223 | (setq rpl | 1374 | (setq rpl |
| 1224 | (org-html-make-link opt-plist | 1375 | (org-html-make-link opt-plist |
| 1225 | type path nil | 1376 | type path nil |
| 1226 | desc | 1377 | desc |
| 1227 | attr | 1378 | attr |
| 1228 | (org-html-should-inline-p path descp)))) | 1379 | (org-html-should-inline-p path descp)))) |
| 1229 | ((member type '("ftp" "mailto" "news")) | 1380 | ((member type '("ftp" "mailto" "news")) |
| 1230 | ;; standard URL, can't inline as image | 1381 | ;; standard URL, can't inline as image |
| 1231 | (setq rpl | 1382 | (setq rpl |
| 1232 | (org-html-make-link opt-plist | 1383 | (org-html-make-link opt-plist |
| 1233 | type path nil | 1384 | type path nil |
| 1234 | desc | 1385 | desc |
| 1235 | attr | 1386 | attr |
| 1236 | nil))) | 1387 | nil))) |
| 1237 | 1388 | ||
| 1238 | ((string= type "coderef") | 1389 | ((string= type "coderef") |
| 1239 | (let* | 1390 | (let* |
| 1240 | ((coderef-str (format "coderef-%s" path)) | 1391 | ((coderef-str (format "coderef-%s" path)) |
| 1241 | (attr-1 | 1392 | (attr-1 |
| 1242 | (format "class=\"coderef\" onmouseover=\"CodeHighlightOn(this, '%s');\" onmouseout=\"CodeHighlightOff(this, '%s');\"" | 1393 | (format "class=\"coderef\" onmouseover=\"CodeHighlightOn(this, '%s');\" onmouseout=\"CodeHighlightOff(this, '%s');\"" |
| 1243 | coderef-str coderef-str))) | 1394 | coderef-str coderef-str))) |
| 1244 | (setq rpl | 1395 | (setq rpl |
| 1245 | (org-html-make-link opt-plist | 1396 | (org-html-make-link opt-plist |
| 1246 | type "" coderef-str | 1397 | type "" coderef-str |
| 1247 | (format | 1398 | (format |
| 1248 | (org-export-get-coderef-format | 1399 | (org-export-get-coderef-format |
| 1249 | path | 1400 | path |
| 1250 | (and descp desc)) | 1401 | (and descp desc)) |
| 1251 | (cdr (assoc path org-export-code-refs))) | 1402 | (cdr (assoc path org-export-code-refs))) |
| 1252 | attr-1 | 1403 | attr-1 |
| 1253 | nil)))) | 1404 | nil)))) |
| 1254 | 1405 | ||
| 1255 | ((functionp (setq fnc (nth 2 (assoc type org-link-protocols)))) | 1406 | ((functionp (setq fnc (nth 2 (assoc type org-link-protocols)))) |
| 1256 | ;; The link protocol has a function for format the link | 1407 | ;; The link protocol has a function for format the link |
| @@ -1259,55 +1410,55 @@ lang=\"%s\" xml:lang=\"%s\"> | |||
| 1259 | (funcall fnc (org-link-unescape path) desc1 'html)))) | 1410 | (funcall fnc (org-link-unescape path) desc1 'html)))) |
| 1260 | 1411 | ||
| 1261 | ((string= type "file") | 1412 | ((string= type "file") |
| 1262 | ;; FILE link | 1413 | ;; FILE link |
| 1263 | (save-match-data | 1414 | (save-match-data |
| 1264 | (let* | 1415 | (let* |
| 1265 | ((components | 1416 | ((components |
| 1266 | (if | 1417 | (if |
| 1267 | (string-match "::\\(.*\\)" path) | 1418 | (string-match "::\\(.*\\)" path) |
| 1268 | (list | 1419 | (list |
| 1269 | (replace-match "" t nil path) | 1420 | (replace-match "" t nil path) |
| 1270 | (match-string 1 path)) | 1421 | (match-string 1 path)) |
| 1271 | (list path nil))) | 1422 | (list path nil))) |
| 1272 | 1423 | ||
| 1273 | ;;The proper path, without a fragment | 1424 | ;;The proper path, without a fragment |
| 1274 | (path-1 | 1425 | (path-1 |
| 1275 | (first components)) | 1426 | (first components)) |
| 1276 | 1427 | ||
| 1277 | ;;The raw fragment | 1428 | ;;The raw fragment |
| 1278 | (fragment-0 | 1429 | (fragment-0 |
| 1279 | (second components)) | 1430 | (second components)) |
| 1280 | 1431 | ||
| 1281 | ;;Check the fragment. If it can't be used as | 1432 | ;;Check the fragment. If it can't be used as |
| 1282 | ;;target fragment we'll pass nil instead. | 1433 | ;;target fragment we'll pass nil instead. |
| 1283 | (fragment-1 | 1434 | (fragment-1 |
| 1284 | (if | 1435 | (if |
| 1285 | (and fragment-0 | 1436 | (and fragment-0 |
| 1286 | (not (string-match "^[0-9]*$" fragment-0)) | 1437 | (not (string-match "^[0-9]*$" fragment-0)) |
| 1287 | (not (string-match "^\\*" fragment-0)) | 1438 | (not (string-match "^\\*" fragment-0)) |
| 1288 | (not (string-match "^/.*/$" fragment-0))) | 1439 | (not (string-match "^/.*/$" fragment-0))) |
| 1289 | (org-solidify-link-text | 1440 | (org-solidify-link-text |
| 1290 | (org-link-unescape fragment-0)) | 1441 | (org-link-unescape fragment-0)) |
| 1291 | nil)) | 1442 | nil)) |
| 1292 | (desc-2 | 1443 | (desc-2 |
| 1293 | ;;Description minus "file:" and ".org" | 1444 | ;;Description minus "file:" and ".org" |
| 1294 | (if (string-match "^file:" desc) | 1445 | (if (string-match "^file:" desc) |
| 1295 | (let | 1446 | (let |
| 1296 | ((desc-1 (replace-match "" t t desc))) | 1447 | ((desc-1 (replace-match "" t t desc))) |
| 1297 | (if (string-match "\\.org$" desc-1) | 1448 | (if (string-match "\\.org$" desc-1) |
| 1298 | (replace-match "" t t desc-1) | 1449 | (replace-match "" t t desc-1) |
| 1299 | desc-1)) | 1450 | desc-1)) |
| 1300 | desc))) | 1451 | desc))) |
| 1301 | 1452 | ||
| 1302 | (setq rpl | 1453 | (setq rpl |
| 1303 | (if | 1454 | (if |
| 1304 | (and | 1455 | (and |
| 1305 | (functionp link-validate) | 1456 | (functionp link-validate) |
| 1306 | (not (funcall link-validate path-1 current-dir))) | 1457 | (not (funcall link-validate path-1 current-dir))) |
| 1307 | desc | 1458 | desc |
| 1308 | (org-html-make-link opt-plist | 1459 | (org-html-make-link opt-plist |
| 1309 | "file" path-1 fragment-1 desc-2 attr | 1460 | "file" path-1 fragment-1 desc-2 attr |
| 1310 | (org-html-should-inline-p path-1 descp))))))) | 1461 | (org-html-should-inline-p path-1 descp))))))) |
| 1311 | 1462 | ||
| 1312 | (t | 1463 | (t |
| 1313 | ;; just publish the path, as default | 1464 | ;; just publish the path, as default |
| @@ -1364,14 +1515,6 @@ lang=\"%s\" xml:lang=\"%s\"> | |||
| 1364 | (setq txt (replace-match "" t t txt))) | 1515 | (setq txt (replace-match "" t t txt))) |
| 1365 | (if (<= level (max umax umax-toc)) | 1516 | (if (<= level (max umax umax-toc)) |
| 1366 | (setq head-count (+ head-count 1))) | 1517 | (setq head-count (+ head-count 1))) |
| 1367 | (when in-local-list | ||
| 1368 | ;; Close any local lists before inserting a new header line | ||
| 1369 | (while local-list-type | ||
| 1370 | (org-close-li (car local-list-type)) | ||
| 1371 | (insert (format "</%sl>\n" (car local-list-type))) | ||
| 1372 | (pop local-list-type)) | ||
| 1373 | (setq local-list-indent nil | ||
| 1374 | in-local-list nil)) | ||
| 1375 | (setq first-heading-pos (or first-heading-pos (point))) | 1518 | (setq first-heading-pos (or first-heading-pos (point))) |
| 1376 | (org-html-level-start level txt umax | 1519 | (org-html-level-start level txt umax |
| 1377 | (and org-export-with-toc (<= level umax)) | 1520 | (and org-export-with-toc (<= level umax)) |
| @@ -1383,19 +1526,6 @@ lang=\"%s\" xml:lang=\"%s\"> | |||
| 1383 | (insert "<pre>") | 1526 | (insert "<pre>") |
| 1384 | (setq inquote t))) | 1527 | (setq inquote t))) |
| 1385 | 1528 | ||
| 1386 | ((string-match "^[ \t]*- __+[ \t]*$" line) | ||
| 1387 | ;; Explicit list closure | ||
| 1388 | (when local-list-type | ||
| 1389 | (let ((ind (org-get-indentation line))) | ||
| 1390 | (while (and local-list-indent | ||
| 1391 | (<= ind (car local-list-indent))) | ||
| 1392 | (org-close-li (car local-list-type)) | ||
| 1393 | (insert (format "</%sl>\n" (car local-list-type))) | ||
| 1394 | (pop local-list-type) | ||
| 1395 | (pop local-list-indent)) | ||
| 1396 | (or local-list-indent (setq in-local-list nil)))) | ||
| 1397 | (throw 'nextline nil)) | ||
| 1398 | |||
| 1399 | ((and org-export-with-tables | 1529 | ((and org-export-with-tables |
| 1400 | (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)" line)) | 1530 | (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)" line)) |
| 1401 | (when (not table-open) | 1531 | (when (not table-open) |
| @@ -1428,66 +1558,57 @@ lang=\"%s\" xml:lang=\"%s\"> | |||
| 1428 | starter (if (match-beginning 2) | 1558 | starter (if (match-beginning 2) |
| 1429 | (substring (match-string 2 line) 0 -1)) | 1559 | (substring (match-string 2 line) 0 -1)) |
| 1430 | line (substring line (match-beginning 5)) | 1560 | line (substring line (match-beginning 5)) |
| 1431 | initial-number nil | 1561 | item-number nil |
| 1432 | item-tag nil) | 1562 | item-tag nil) |
| 1433 | (if (string-match "\\`\\[@start:\\([0-9]+\\)\\][ \t]?" line) | 1563 | (if (string-match "\\[@\\(?:start:\\)?\\([0-9]+\\)\\][ \t]?" line) |
| 1434 | (setq initial-number (match-string 1 line) | 1564 | (setq item-number (match-string 1 line) |
| 1435 | line (replace-match "" t t line))) | 1565 | line (replace-match "" t t line))) |
| 1436 | (if (and starter (string-match "\\(.*?\\) ::[ \t]*" line)) | 1566 | (if (and starter (string-match "\\(.*?\\) ::[ \t]*" line)) |
| 1437 | (setq item-type "d" | 1567 | (setq item-type "d" |
| 1438 | item-tag (match-string 1 line) | 1568 | item-tag (match-string 1 line) |
| 1439 | line (substring line (match-end 0)))) | 1569 | line (substring line (match-end 0)))) |
| 1440 | (when (and (not (equal item-type "d")) | ||
| 1441 | (not (string-match "[^ \t]" line))) | ||
| 1442 | ;; empty line. Pretend indentation is large. | ||
| 1443 | (setq ind (if org-empty-line-terminates-plain-lists | ||
| 1444 | 0 | ||
| 1445 | (1+ (or (car local-list-indent) 1))))) | ||
| 1446 | (setq didclose nil) | ||
| 1447 | (while (and in-local-list | ||
| 1448 | (or (and (= ind (car local-list-indent)) | ||
| 1449 | (not starter)) | ||
| 1450 | (< ind (car local-list-indent)))) | ||
| 1451 | (setq didclose t) | ||
| 1452 | (org-close-li (car local-list-type)) | ||
| 1453 | (insert (format "</%sl>\n" (car local-list-type))) | ||
| 1454 | (pop local-list-type) (pop local-list-indent) | ||
| 1455 | (setq in-local-list local-list-indent)) | ||
| 1456 | (cond | 1570 | (cond |
| 1457 | ((and starter | 1571 | ((and starter |
| 1458 | (or (not in-local-list) | 1572 | (or (not in-local-list) |
| 1459 | (> ind (car local-list-indent)))) | 1573 | (> ind (car local-list-indent)))) |
| 1460 | ;; check for a specified start number | ||
| 1461 | ;; Start new (level of) list | 1574 | ;; Start new (level of) list |
| 1462 | (org-close-par-maybe) | 1575 | (org-close-par-maybe) |
| 1463 | (insert (cond | 1576 | (insert (cond |
| 1464 | ((equal item-type "u") "<ul>\n<li>\n") | 1577 | ((equal item-type "u") "<ul>\n<li>\n") |
| 1465 | ((equal item-type "o") | 1578 | ((and (equal item-type "o") item-number) |
| 1466 | (if initial-number | 1579 | (format "<ol>\n<li value=\"%s\">\n" item-number)) |
| 1467 | (format "<ol start=%s>\n<li>\n" initial-number) | 1580 | ((equal item-type "o") "<ol>\n<li>\n") |
| 1468 | "<ol>\n<li>\n")) | ||
| 1469 | ((equal item-type "d") | 1581 | ((equal item-type "d") |
| 1470 | (format "<dl>\n<dt>%s</dt><dd>\n" item-tag)))) | 1582 | (format "<dl>\n<dt>%s</dt><dd>\n" item-tag)))) |
| 1471 | (push item-type local-list-type) | 1583 | (push item-type local-list-type) |
| 1472 | (push ind local-list-indent) | 1584 | (push ind local-list-indent) |
| 1473 | (setq in-local-list t)) | 1585 | (setq in-local-list t)) |
| 1586 | ;; Continue list | ||
| 1474 | (starter | 1587 | (starter |
| 1475 | ;; continue current list | 1588 | ;; terminate any previous sublist but first ensure |
| 1589 | ;; list is not ill-formed. | ||
| 1590 | (let ((min-ind (apply 'min local-list-indent))) | ||
| 1591 | (when (< ind min-ind) (setq ind min-ind))) | ||
| 1592 | (while (< ind (car local-list-indent)) | ||
| 1593 | (org-close-li (car local-list-type)) | ||
| 1594 | (insert (format "</%sl>\n" (car local-list-type))) | ||
| 1595 | (pop local-list-type) (pop local-list-indent) | ||
| 1596 | (setq in-local-list local-list-indent)) | ||
| 1597 | ;; insert new item | ||
| 1476 | (org-close-li (car local-list-type)) | 1598 | (org-close-li (car local-list-type)) |
| 1477 | (insert (cond | 1599 | (insert (cond |
| 1478 | ((equal (car local-list-type) "d") | 1600 | ((equal (car local-list-type) "d") |
| 1479 | (format "<dt>%s</dt><dd>\n" (or item-tag "???"))) | 1601 | (format "<dt>%s</dt><dd>\n" (or item-tag "???"))) |
| 1480 | (t "<li>\n")))) | 1602 | ((and (equal item-type "o") item-number) |
| 1481 | (didclose | 1603 | (format "<li value=\"%s\">\n" item-number)) |
| 1482 | ;; we did close a list, normal text follows: need <p> | 1604 | (t "<li>\n"))))) |
| 1483 | (org-open-par))) | ||
| 1484 | (if (string-match "^[ \t]*\\[\\([X ]\\)\\]" line) | 1605 | (if (string-match "^[ \t]*\\[\\([X ]\\)\\]" line) |
| 1485 | (setq line | 1606 | (setq line |
| 1486 | (replace-match | 1607 | (replace-match |
| 1487 | (if (equal (match-string 1 line) "X") | 1608 | (if (equal (match-string 1 line) "X") |
| 1488 | "<b>[X]</b>" | 1609 | "<b>[X]</b>" |
| 1489 | "<b>[<span style=\"visibility:hidden;\">X</span>]</b>") | 1610 | "<b>[<span style=\"visibility:hidden;\">X</span>]</b>") |
| 1490 | t t line)))) | 1611 | t t line)))) |
| 1491 | 1612 | ||
| 1492 | ;; Horizontal line | 1613 | ;; Horizontal line |
| 1493 | (when (string-match "^[ \t]*-\\{5,\\}[ \t]*$" line) | 1614 | (when (string-match "^[ \t]*-\\{5,\\}[ \t]*$" line) |
| @@ -1542,14 +1663,7 @@ lang=\"%s\" xml:lang=\"%s\"> | |||
| 1542 | (when inquote | 1663 | (when inquote |
| 1543 | (insert "</pre>\n") | 1664 | (insert "</pre>\n") |
| 1544 | (org-open-par)) | 1665 | (org-open-par)) |
| 1545 | (when in-local-list | 1666 | |
| 1546 | ;; Close any local lists before inserting a new header line | ||
| 1547 | (while local-list-type | ||
| 1548 | (org-close-li (car local-list-type)) | ||
| 1549 | (insert (format "</%sl>\n" (car local-list-type))) | ||
| 1550 | (pop local-list-type)) | ||
| 1551 | (setq local-list-indent nil | ||
| 1552 | in-local-list nil)) | ||
| 1553 | (org-html-level-start 1 nil umax | 1667 | (org-html-level-start 1 nil umax |
| 1554 | (and org-export-with-toc (<= level umax)) | 1668 | (and org-export-with-toc (<= level umax)) |
| 1555 | head-count) | 1669 | head-count) |
| @@ -1630,8 +1744,6 @@ lang=\"%s\" xml:lang=\"%s\"> | |||
| 1630 | (while (re-search-forward "<li>[ \r\n\t]*</li>\n?" nil t) | 1744 | (while (re-search-forward "<li>[ \r\n\t]*</li>\n?" nil t) |
| 1631 | (replace-match "")) | 1745 | (replace-match "")) |
| 1632 | (goto-char (point-min)) | 1746 | (goto-char (point-min)) |
| 1633 | (while (re-search-forward "</ul>\\s-*<ul>\n?" nil t) | ||
| 1634 | (replace-match "")) | ||
| 1635 | ;; Convert whitespace place holders | 1747 | ;; Convert whitespace place holders |
| 1636 | (goto-char (point-min)) | 1748 | (goto-char (point-min)) |
| 1637 | (let (beg end n) | 1749 | (let (beg end n) |
| @@ -1726,13 +1838,14 @@ lang=\"%s\" xml:lang=\"%s\"> | |||
| 1726 | nil)))) | 1838 | nil)))) |
| 1727 | 1839 | ||
| 1728 | (defvar org-table-number-regexp) ; defined in org-table.el | 1840 | (defvar org-table-number-regexp) ; defined in org-table.el |
| 1729 | (defun org-format-table-html (lines olines) | 1841 | (defun org-format-table-html (lines olines &optional no-css) |
| 1730 | "Find out which HTML converter to use and return the HTML code." | 1842 | "Find out which HTML converter to use and return the HTML code. |
| 1843 | NO-CSS is passed to the exporter." | ||
| 1731 | (if (stringp lines) | 1844 | (if (stringp lines) |
| 1732 | (setq lines (org-split-string lines "\n"))) | 1845 | (setq lines (org-split-string lines "\n"))) |
| 1733 | (if (string-match "^[ \t]*|" (car lines)) | 1846 | (if (string-match "^[ \t]*|" (car lines)) |
| 1734 | ;; A normal org table | 1847 | ;; A normal org table |
| 1735 | (org-format-org-table-html lines) | 1848 | (org-format-org-table-html lines nil no-css) |
| 1736 | ;; Table made by table.el - test for spanning | 1849 | ;; Table made by table.el - test for spanning |
| 1737 | (let* ((hlines (delq nil (mapcar | 1850 | (let* ((hlines (delq nil (mapcar |
| 1738 | (lambda (x) | 1851 | (lambda (x) |
| @@ -1753,8 +1866,12 @@ lang=\"%s\" xml:lang=\"%s\"> | |||
| 1753 | (org-format-table-table-html-using-table-generate-source olines))))) | 1866 | (org-format-table-table-html-using-table-generate-source olines))))) |
| 1754 | 1867 | ||
| 1755 | (defvar org-table-number-fraction) ; defined in org-table.el | 1868 | (defvar org-table-number-fraction) ; defined in org-table.el |
| 1756 | (defun org-format-org-table-html (lines &optional splice) | 1869 | (defun org-format-org-table-html (lines &optional splice no-css) |
| 1757 | "Format a table into HTML." | 1870 | "Format a table into HTML. |
| 1871 | LINES is a list of lines. Optional argument SPLICE means, do not | ||
| 1872 | insert header and surrounding <table> tags, just format the lines. | ||
| 1873 | Optional argument NO-CSS means use XHTML attributes instead of CSS | ||
| 1874 | for formatting. This is required for the DocBook exporter." | ||
| 1758 | (require 'org-table) | 1875 | (require 'org-table) |
| 1759 | ;; Get rid of hlines at beginning and end | 1876 | ;; Get rid of hlines at beginning and end |
| 1760 | (if (string-match "^[ \t]*|-" (car lines)) (setq lines (cdr lines))) | 1877 | (if (string-match "^[ \t]*|-" (car lines)) (setq lines (cdr lines))) |
| @@ -1768,6 +1885,8 @@ lang=\"%s\" xml:lang=\"%s\"> | |||
| 1768 | 1885 | ||
| 1769 | (let* ((caption (org-find-text-property-in-string 'org-caption (car lines))) | 1886 | (let* ((caption (org-find-text-property-in-string 'org-caption (car lines))) |
| 1770 | (label (org-find-text-property-in-string 'org-label (car lines))) | 1887 | (label (org-find-text-property-in-string 'org-label (car lines))) |
| 1888 | (forced-aligns (org-find-text-property-in-string 'org-forced-aligns | ||
| 1889 | (car lines))) | ||
| 1771 | (attributes (org-find-text-property-in-string 'org-attributes | 1890 | (attributes (org-find-text-property-in-string 'org-attributes |
| 1772 | (car lines))) | 1891 | (car lines))) |
| 1773 | (html-table-tag (org-export-splice-attributes | 1892 | (html-table-tag (org-export-splice-attributes |
| @@ -1776,10 +1895,13 @@ lang=\"%s\" xml:lang=\"%s\"> | |||
| 1776 | (delq nil (mapcar | 1895 | (delq nil (mapcar |
| 1777 | (lambda (x) (string-match "^[ \t]*|-" x)) | 1896 | (lambda (x) (string-match "^[ \t]*|-" x)) |
| 1778 | (cdr lines))))) | 1897 | (cdr lines))))) |
| 1779 | 1898 | (nline 0) fnum nfields i (cnt 0) | |
| 1780 | (nline 0) fnum nfields i | 1899 | tbopen line fields html gr colgropen rowstart rowend |
| 1781 | tbopen line fields html gr colgropen rowstart rowend) | 1900 | ali align aligns n) |
| 1782 | (setq caption (and caption (org-html-do-expand caption))) | 1901 | (setq caption (and caption (org-html-do-expand caption))) |
| 1902 | (when (and forced-aligns org-table-clean-did-remove-column) | ||
| 1903 | (setq forced-aligns | ||
| 1904 | (mapcar (lambda (x) (cons (1- (car x)) (cdr x))) forced-aligns))) | ||
| 1783 | (if splice (setq head nil)) | 1905 | (if splice (setq head nil)) |
| 1784 | (unless splice (push (if head "<thead>" "<tbody>") html)) | 1906 | (unless splice (push (if head "<thead>" "<tbody>") html)) |
| 1785 | (setq tbopen t) | 1907 | (setq tbopen t) |
| @@ -1803,23 +1925,26 @@ lang=\"%s\" xml:lang=\"%s\"> | |||
| 1803 | (push (concat rowstart | 1925 | (push (concat rowstart |
| 1804 | (mapconcat | 1926 | (mapconcat |
| 1805 | (lambda (x) | 1927 | (lambda (x) |
| 1806 | (setq i (1+ i)) | 1928 | (setq i (1+ i) ali (format "@@class%03d@@" i)) |
| 1807 | (if (and (< i nfields) ; make sure no rogue line causes an error here | 1929 | (if (and (< i nfields) ; make sure no rogue line causes an error here |
| 1808 | (string-match org-table-number-regexp x)) | 1930 | (string-match org-table-number-regexp x)) |
| 1809 | (incf (aref fnum i))) | 1931 | (incf (aref fnum i))) |
| 1810 | (cond | 1932 | (cond |
| 1811 | (head | 1933 | (head |
| 1812 | (concat | 1934 | (concat |
| 1813 | (format (car org-export-table-header-tags) "col") | 1935 | (format (car org-export-table-header-tags) |
| 1936 | "col" ali) | ||
| 1814 | x | 1937 | x |
| 1815 | (cdr org-export-table-header-tags))) | 1938 | (cdr org-export-table-header-tags))) |
| 1816 | ((and (= i 0) org-export-html-table-use-header-tags-for-first-column) | 1939 | ((and (= i 0) org-export-html-table-use-header-tags-for-first-column) |
| 1817 | (concat | 1940 | (concat |
| 1818 | (format (car org-export-table-header-tags) "row") | 1941 | (format (car org-export-table-header-tags) |
| 1942 | "row" ali) | ||
| 1819 | x | 1943 | x |
| 1820 | (cdr org-export-table-header-tags))) | 1944 | (cdr org-export-table-header-tags))) |
| 1821 | (t | 1945 | (t |
| 1822 | (concat (car org-export-table-data-tags) x | 1946 | (concat (format (car org-export-table-data-tags) ali) |
| 1947 | x | ||
| 1823 | (cdr org-export-table-data-tags))))) | 1948 | (cdr org-export-table-data-tags))))) |
| 1824 | fields "") | 1949 | fields "") |
| 1825 | rowend) | 1950 | rowend) |
| @@ -1832,23 +1957,38 @@ lang=\"%s\" xml:lang=\"%s\"> | |||
| 1832 | (unless (car org-table-colgroup-info) | 1957 | (unless (car org-table-colgroup-info) |
| 1833 | (setq org-table-colgroup-info | 1958 | (setq org-table-colgroup-info |
| 1834 | (cons :start (cdr org-table-colgroup-info)))) | 1959 | (cons :start (cdr org-table-colgroup-info)))) |
| 1960 | (setq i 0) | ||
| 1835 | (push (mapconcat | 1961 | (push (mapconcat |
| 1836 | (lambda (x) | 1962 | (lambda (x) |
| 1837 | (setq gr (pop org-table-colgroup-info)) | 1963 | (setq gr (pop org-table-colgroup-info) |
| 1838 | (format "%s<col align=\"%s\" />%s" | 1964 | i (1+ i) |
| 1965 | align (if (assoc i forced-aligns) | ||
| 1966 | (cdr (assoc (cdr (assoc i forced-aligns)) | ||
| 1967 | '(("l" . "left") ("r" . "right") | ||
| 1968 | ("c" . "center")))) | ||
| 1969 | (if (> (/ (float x) nline) | ||
| 1970 | org-table-number-fraction) | ||
| 1971 | "right" "left"))) | ||
| 1972 | (push align aligns) | ||
| 1973 | (format (if no-css | ||
| 1974 | "%s<col align=\"%s\" />%s" | ||
| 1975 | "%s<col class=\"%s\" />%s") | ||
| 1839 | (if (memq gr '(:start :startend)) | 1976 | (if (memq gr '(:start :startend)) |
| 1840 | (prog1 | 1977 | (prog1 |
| 1841 | (if colgropen "</colgroup>\n<colgroup>" "<colgroup>") | 1978 | (if colgropen |
| 1979 | "</colgroup>\n<colgroup>" | ||
| 1980 | "<colgroup>") | ||
| 1842 | (setq colgropen t)) | 1981 | (setq colgropen t)) |
| 1843 | "") | 1982 | "") |
| 1844 | (if (> (/ (float x) nline) org-table-number-fraction) | 1983 | align |
| 1845 | "right" "left") | ||
| 1846 | (if (memq gr '(:end :startend)) | 1984 | (if (memq gr '(:end :startend)) |
| 1847 | (progn (setq colgropen nil) "</colgroup>") | 1985 | (progn (setq colgropen nil) "</colgroup>") |
| 1848 | ""))) | 1986 | ""))) |
| 1849 | fnum "") | 1987 | fnum "") |
| 1850 | html) | 1988 | html) |
| 1851 | (if colgropen (setq html (cons (car html) (cons "</colgroup>" (cdr html))))) | 1989 | (setq aligns (nreverse aligns)) |
| 1990 | (if colgropen (setq html (cons (car html) | ||
| 1991 | (cons "</colgroup>" (cdr html))))) | ||
| 1852 | ;; Since the output of HTML table formatter can also be used in | 1992 | ;; Since the output of HTML table formatter can also be used in |
| 1853 | ;; DocBook document, we want to always include the caption to make | 1993 | ;; DocBook document, we want to always include the caption to make |
| 1854 | ;; DocBook XML file valid. | 1994 | ;; DocBook XML file valid. |
| @@ -1856,6 +1996,18 @@ lang=\"%s\" xml:lang=\"%s\"> | |||
| 1856 | (when label (push (format "<a name=\"%s\" id=\"%s\"></a>" label label) | 1996 | (when label (push (format "<a name=\"%s\" id=\"%s\"></a>" label label) |
| 1857 | html)) | 1997 | html)) |
| 1858 | (push html-table-tag html)) | 1998 | (push html-table-tag html)) |
| 1999 | (setq html (mapcar | ||
| 2000 | (lambda (x) | ||
| 2001 | (replace-regexp-in-string | ||
| 2002 | "@@class\\([0-9]+\\)@@" | ||
| 2003 | (lambda (txt) | ||
| 2004 | (if (not org-export-html-table-align-individual-fields) | ||
| 2005 | "" | ||
| 2006 | (setq n (string-to-number (match-string 1 txt))) | ||
| 2007 | (format (if no-css " align=\"%s\"" " class=\"%s\"") | ||
| 2008 | (or (nth n aligns) "left")))) | ||
| 2009 | x)) | ||
| 2010 | html)) | ||
| 1859 | (concat (mapconcat 'identity html "\n") "\n"))) | 2011 | (concat (mapconcat 'identity html "\n") "\n"))) |
| 1860 | 2012 | ||
| 1861 | (defun org-export-splice-attributes (tag attributes) | 2013 | (defun org-export-splice-attributes (tag attributes) |
| @@ -1900,10 +2052,10 @@ But it has the disadvantage, that no cell- or row-spanning is allowed." | |||
| 1900 | (if (equal x "") (setq x empty)) | 2052 | (if (equal x "") (setq x empty)) |
| 1901 | (if head | 2053 | (if head |
| 1902 | (concat | 2054 | (concat |
| 1903 | (format (car org-export-table-header-tags) "col") | 2055 | (format (car org-export-table-header-tags) "col" "") |
| 1904 | x | 2056 | x |
| 1905 | (cdr org-export-table-header-tags)) | 2057 | (cdr org-export-table-header-tags)) |
| 1906 | (concat (car org-export-table-data-tags) x | 2058 | (concat (format (car org-export-table-data-tags) "") x |
| 1907 | (cdr org-export-table-data-tags)))) | 2059 | (cdr org-export-table-data-tags)))) |
| 1908 | field-buffer "\n") | 2060 | field-buffer "\n") |
| 1909 | "</tr>\n")) | 2061 | "</tr>\n")) |
| @@ -2042,7 +2194,7 @@ that uses these same face definitions." | |||
| 2042 | "Prepare STRING for HTML export. Apply all active conversions. | 2194 | "Prepare STRING for HTML export. Apply all active conversions. |
| 2043 | If there are links in the string, don't modify these." | 2195 | If there are links in the string, don't modify these." |
| 2044 | (let* ((re (concat org-bracket-link-regexp "\\|" | 2196 | (let* ((re (concat org-bracket-link-regexp "\\|" |
| 2045 | (org-re "[ \t]+\\(:[[:alnum:]_@:]+:\\)[ \t]*$"))) | 2197 | (org-re "[ \t]+\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$"))) |
| 2046 | m s l res) | 2198 | m s l res) |
| 2047 | (if (string-match "^[ \t]*\\+-[-+]*\\+[ \t]*$" string) | 2199 | (if (string-match "^[ \t]*\\+-[-+]*\\+[ \t]*$" string) |
| 2048 | string | 2200 | string |
| @@ -2152,28 +2304,6 @@ If there are links in the string, don't modify these." | |||
| 2152 | (defvar in-local-list) | 2304 | (defvar in-local-list) |
| 2153 | (defvar local-list-indent) | 2305 | (defvar local-list-indent) |
| 2154 | (defvar local-list-type) | 2306 | (defvar local-list-type) |
| 2155 | (defun org-export-html-close-lists-maybe (line) | ||
| 2156 | "Close local lists based on the original indentation of the line." | ||
| 2157 | (let* ((rawhtml (and in-local-list | ||
| 2158 | (get-text-property 0 'org-protected line) | ||
| 2159 | (not (get-text-property 0 'org-example line)))) | ||
| 2160 | ;; rawhtml means: This was between #+begin_html..#+end_html | ||
| 2161 | ;; originally, thus it excludes stuff that was a source code example | ||
| 2162 | ;; Actually, this code seems wrong, I don't know why it works, but | ||
| 2163 | ;; it seems to work.... So keep it like this for now. | ||
| 2164 | (ind (if rawhtml | ||
| 2165 | (org-get-indentation line) | ||
| 2166 | (get-text-property 0 'original-indentation line))) | ||
| 2167 | didclose) | ||
| 2168 | (when ind | ||
| 2169 | (while (and in-local-list | ||
| 2170 | (<= ind (car local-list-indent))) | ||
| 2171 | (setq didclose t) | ||
| 2172 | (org-close-li (car local-list-type)) | ||
| 2173 | (insert (format "</%sl>\n" (car local-list-type))) | ||
| 2174 | (pop local-list-type) (pop local-list-indent) | ||
| 2175 | (setq in-local-list local-list-indent)) | ||
| 2176 | (and didclose (org-open-par))))) | ||
| 2177 | 2307 | ||
| 2178 | (defvar body-only) ; dynamically scoped into this. | 2308 | (defvar body-only) ; dynamically scoped into this. |
| 2179 | (defun org-html-level-start (level title umax with-toc head-count) | 2309 | (defun org-html-level-start (level title umax with-toc head-count) |
| @@ -2206,7 +2336,7 @@ When TITLE is nil, just close all open levels." | |||
| 2206 | (when title | 2336 | (when title |
| 2207 | ;; If title is nil, this means this function is called to close | 2337 | ;; If title is nil, this means this function is called to close |
| 2208 | ;; all levels, so the rest is done only if title is given | 2338 | ;; all levels, so the rest is done only if title is given |
| 2209 | (when (string-match (org-re "\\(:[[:alnum:]_@:]+:\\)[ \t]*$") title) | 2339 | (when (string-match (org-re "\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$") title) |
| 2210 | (setq title (replace-match | 2340 | (setq title (replace-match |
| 2211 | (if org-export-with-tags | 2341 | (if org-export-with-tags |
| 2212 | (save-match-data | 2342 | (save-match-data |
diff --git a/lisp/org/org-icalendar.el b/lisp/org/org-icalendar.el index 1c4d7d6ac5b..fe6e97c72dd 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.01 | 9 | ;; Version: 7.3 |
| 10 | ;; | 10 | ;; |
| 11 | ;; This file is part of GNU Emacs. | 11 | ;; This file is part of GNU Emacs. |
| 12 | ;; | 12 | ;; |
| @@ -47,13 +47,24 @@ The file name should be absolute, the file will be overwritten without warning." | |||
| 47 | :group 'org-export-icalendar | 47 | :group 'org-export-icalendar |
| 48 | :type 'file) | 48 | :type 'file) |
| 49 | 49 | ||
| 50 | (defcustom org-icalendar-alarm-time 0 | ||
| 51 | "Number of minutes for triggering an alarm for exported timed events. | ||
| 52 | A zero value (the default) turns off the definition of an alarm trigger | ||
| 53 | for timed events. If non-zero, alarms are created. | ||
| 54 | |||
| 55 | - a single alarm per entry is defined | ||
| 56 | - The alarm will go off N minutes before the event | ||
| 57 | - only a DISPLAY action is defined." | ||
| 58 | :group 'org-export-icalendar | ||
| 59 | :type 'integer) | ||
| 60 | |||
| 50 | (defcustom org-icalendar-combined-name "OrgMode" | 61 | (defcustom org-icalendar-combined-name "OrgMode" |
| 51 | "Calendar name for the combined iCalendar representing all agenda files." | 62 | "Calendar name for the combined iCalendar representing all agenda files." |
| 52 | :group 'org-export-icalendar | 63 | :group 'org-export-icalendar |
| 53 | :type 'string) | 64 | :type 'string) |
| 54 | 65 | ||
| 55 | (defcustom org-icalendar-combined-description nil | 66 | (defcustom org-icalendar-combined-description nil |
| 56 | "Calendar description for the combined iCalendar representing all agenda files." | 67 | "Calendar description for the combined iCalendar (all agenda files)." |
| 57 | :group 'org-export-icalendar | 68 | :group 'org-export-icalendar |
| 58 | :type 'string) | 69 | :type 'string) |
| 59 | 70 | ||
| @@ -183,6 +194,13 @@ When nil of the empty string, use the abbreviation retrieved from Emacs." | |||
| 183 | (const :tag "Unspecified" nil) | 194 | (const :tag "Unspecified" nil) |
| 184 | (string :tag "Time zone"))) | 195 | (string :tag "Time zone"))) |
| 185 | 196 | ||
| 197 | (defcustom org-icalendar-use-UTC-date-time () | ||
| 198 | "Non-nil force the use of the universal time for iCalendar DATE-TIME. | ||
| 199 | The iCalendar DATE-TIME can be expressed with local time or universal Time, | ||
| 200 | universal time could be more compatible with some external tools." | ||
| 201 | :group 'org-export-icalendar | ||
| 202 | :type 'boolean) | ||
| 203 | |||
| 186 | ;;; iCalendar export | 204 | ;;; iCalendar export |
| 187 | 205 | ||
| 188 | ;;;###autoload | 206 | ;;;###autoload |
| @@ -282,7 +300,7 @@ When COMBINE is non nil, add the category to each line." | |||
| 282 | "DTSTART")) | 300 | "DTSTART")) |
| 283 | hd ts ts2 state status (inc t) pos b sexp rrule | 301 | hd ts ts2 state status (inc t) pos b sexp rrule |
| 284 | scheduledp deadlinep todo prefix due start | 302 | scheduledp deadlinep todo prefix due start |
| 285 | tmp pri categories location summary desc uid | 303 | tmp pri categories location summary desc uid alarm |
| 286 | (sexp-buffer (get-buffer-create "*ical-tmp*"))) | 304 | (sexp-buffer (get-buffer-create "*ical-tmp*"))) |
| 287 | (org-refresh-category-properties) | 305 | (org-refresh-category-properties) |
| 288 | (save-excursion | 306 | (save-excursion |
| @@ -300,7 +318,7 @@ When COMBINE is non nil, add the category to each line." | |||
| 300 | inc t | 318 | inc t |
| 301 | hd (condition-case nil | 319 | hd (condition-case nil |
| 302 | (org-icalendar-cleanup-string | 320 | (org-icalendar-cleanup-string |
| 303 | (org-get-heading)) | 321 | (org-get-heading t)) |
| 304 | (error (throw :skip nil))) | 322 | (error (throw :skip nil))) |
| 305 | summary (org-icalendar-cleanup-string | 323 | summary (org-icalendar-cleanup-string |
| 306 | (org-entry-get nil "SUMMARY")) | 324 | (org-entry-get nil "SUMMARY")) |
| @@ -314,6 +332,7 @@ When COMBINE is non nil, add the category to each line." | |||
| 314 | (org-id-get-create) | 332 | (org-id-get-create) |
| 315 | (or (org-id-get) (org-id-new))) | 333 | (or (org-id-get) (org-id-new))) |
| 316 | categories (org-export-get-categories) | 334 | categories (org-export-get-categories) |
| 335 | alarm "" | ||
| 317 | deadlinep nil scheduledp nil) | 336 | deadlinep nil scheduledp nil) |
| 318 | (if (looking-at re2) | 337 | (if (looking-at re2) |
| 319 | (progn | 338 | (progn |
| @@ -362,6 +381,17 @@ When COMBINE is non nil, add the category to each line." | |||
| 362 | ";INTERVAL=" (match-string 1 ts))) | 381 | ";INTERVAL=" (match-string 1 ts))) |
| 363 | (setq rrule "")) | 382 | (setq rrule "")) |
| 364 | (setq summary (or summary hd)) | 383 | (setq summary (or summary hd)) |
| 384 | ;; create an alarm entry if the entry is timed. this is not very general in that: | ||
| 385 | ;; (a) only one alarm per entry is defined, | ||
| 386 | ;; (b) only minutes are allowed for the trigger period ahead of the start time, and | ||
| 387 | ;; (c) only a DISPLAY action is defined. | ||
| 388 | ;; [ESF] | ||
| 389 | (let ((t1 (ignore-errors (org-parse-time-string ts 'nodefault)))) | ||
| 390 | (if (and (> org-icalendar-alarm-time 0) | ||
| 391 | (car t1) (nth 1 t1) (nth 2 t1)) | ||
| 392 | (setq alarm (format "\nBEGIN:VALARM\nACTION:DISPLAY\nDESCRIPTION:%s\nTRIGGER:-P0D0H%dM0S\nEND:VALARM" summary org-icalendar-alarm-time)) | ||
| 393 | (setq alarm "")) | ||
| 394 | ) | ||
| 365 | (if (string-match org-bracket-link-regexp summary) | 395 | (if (string-match org-bracket-link-regexp summary) |
| 366 | (setq summary | 396 | (setq summary |
| 367 | (replace-match (if (match-end 3) | 397 | (replace-match (if (match-end 3) |
| @@ -378,7 +408,7 @@ UID: %s | |||
| 378 | %s | 408 | %s |
| 379 | %s%s | 409 | %s%s |
| 380 | SUMMARY:%s%s%s | 410 | SUMMARY:%s%s%s |
| 381 | CATEGORIES:%s | 411 | CATEGORIES:%s%s |
| 382 | END:VEVENT\n" | 412 | END:VEVENT\n" |
| 383 | (concat prefix uid) | 413 | (concat prefix uid) |
| 384 | (org-ical-ts-to-string ts "DTSTART") | 414 | (org-ical-ts-to-string ts "DTSTART") |
| @@ -388,7 +418,8 @@ END:VEVENT\n" | |||
| 388 | (concat "\nDESCRIPTION: " desc) "") | 418 | (concat "\nDESCRIPTION: " desc) "") |
| 389 | (if (and location (string-match "\\S-" location)) | 419 | (if (and location (string-match "\\S-" location)) |
| 390 | (concat "\nLOCATION: " location) "") | 420 | (concat "\nLOCATION: " location) "") |
| 391 | categories))))) | 421 | categories |
| 422 | alarm))))) | ||
| 392 | (when (and org-icalendar-include-sexps | 423 | (when (and org-icalendar-include-sexps |
| 393 | (condition-case nil (require 'icalendar) (error nil)) | 424 | (condition-case nil (require 'icalendar) (error nil)) |
| 394 | (fboundp 'icalendar-export-region)) | 425 | (fboundp 'icalendar-export-region)) |
| @@ -415,7 +446,7 @@ END:VEVENT\n" | |||
| 415 | (when org-icalendar-include-todo | 446 | (when org-icalendar-include-todo |
| 416 | (setq prefix "TODO-") | 447 | (setq prefix "TODO-") |
| 417 | (goto-char (point-min)) | 448 | (goto-char (point-min)) |
| 418 | (while (re-search-forward org-todo-line-regexp nil t) | 449 | (while (re-search-forward org-complex-heading-regexp nil t) |
| 419 | (catch :skip | 450 | (catch :skip |
| 420 | (org-agenda-skip) | 451 | (org-agenda-skip) |
| 421 | (when org-icalendar-verify-function | 452 | (when org-icalendar-verify-function |
| @@ -447,7 +478,7 @@ END:VEVENT\n" | |||
| 447 | ((eq org-icalendar-include-todo t) | 478 | ((eq org-icalendar-include-todo t) |
| 448 | ;; include everything that is not done | 479 | ;; include everything that is not done |
| 449 | (member state org-not-done-keywords)))) | 480 | (member state org-not-done-keywords)))) |
| 450 | (setq hd (match-string 3) | 481 | (setq hd (match-string 4) |
| 451 | summary (org-icalendar-cleanup-string | 482 | summary (org-icalendar-cleanup-string |
| 452 | (org-entry-get nil "SUMMARY")) | 483 | (org-entry-get nil "SUMMARY")) |
| 453 | desc (org-icalendar-cleanup-string | 484 | desc (org-icalendar-cleanup-string |
| @@ -610,8 +641,13 @@ a time), or the day by one (if it does not contain a time)." | |||
| 610 | (setq h (+ 2 h))) | 641 | (setq h (+ 2 h))) |
| 611 | (setq d (1+ d)))) | 642 | (setq d (1+ d)))) |
| 612 | (setq time (encode-time s mi h d m y))) | 643 | (setq time (encode-time s mi h d m y))) |
| 613 | (setq fmt (if have-time ":%Y%m%dT%H%M%S" ";VALUE=DATE:%Y%m%d")) | 644 | (setq fmt (if have-time (if org-icalendar-use-UTC-date-time |
| 614 | (concat keyword (format-time-string fmt time))))) | 645 | ":%Y%m%dT%H%M%SZ" |
| 646 | ":%Y%m%dT%H%M%S") | ||
| 647 | ";VALUE=DATE:%Y%m%d")) | ||
| 648 | (concat keyword (format-time-string fmt time | ||
| 649 | (and org-icalendar-use-UTC-date-time | ||
| 650 | have-time)))))) | ||
| 615 | 651 | ||
| 616 | (provide 'org-icalendar) | 652 | (provide 'org-icalendar) |
| 617 | 653 | ||
diff --git a/lisp/org/org-id.el b/lisp/org/org-id.el index d16e5d81c8e..fcca58831d1 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.01 | 8 | ;; Version: 7.3 |
| 9 | ;; | 9 | ;; |
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | ;; | 11 | ;; |
| @@ -596,6 +596,7 @@ optional argument MARKERP, return the position as a new marker." | |||
| 596 | ;; Calling the following function is hard-coded into `org-store-link', | 596 | ;; Calling the following function is hard-coded into `org-store-link', |
| 597 | ;; so we do have to add it to `org-store-link-functions'. | 597 | ;; so we do have to add it to `org-store-link-functions'. |
| 598 | 598 | ||
| 599 | ;;;###autoload | ||
| 599 | (defun org-id-store-link () | 600 | (defun org-id-store-link () |
| 600 | "Store a link to the current entry, using its ID." | 601 | "Store a link to the current entry, using its ID." |
| 601 | (interactive) | 602 | (interactive) |
diff --git a/lisp/org/org-indent.el b/lisp/org/org-indent.el index d88688d19ba..39ba445eb93 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.01 | 7 | ;; Version: 7.3 |
| 8 | ;; | 8 | ;; |
| 9 | ;; This file is part of GNU Emacs. | 9 | ;; This file is part of GNU Emacs. |
| 10 | ;; | 10 | ;; |
| @@ -135,11 +135,11 @@ FIXME: How to update when broken?" | |||
| 135 | ((org-bound-and-true-p org-inhibit-startup) | 135 | ((org-bound-and-true-p org-inhibit-startup) |
| 136 | (setq org-indent-mode nil)) | 136 | (setq org-indent-mode nil)) |
| 137 | ((and org-indent-mode (featurep 'xemacs)) | 137 | ((and org-indent-mode (featurep 'xemacs)) |
| 138 | (message "org-indent-mode does not work in XEmacs - refused to turn it on") | 138 | (message "org-indent-mode does not work in XEmacs - refusing to turn it on") |
| 139 | (setq org-indent-mode nil)) | 139 | (setq org-indent-mode nil)) |
| 140 | ((and org-indent-mode | 140 | ((and org-indent-mode |
| 141 | (not (org-version-check "23.1.50" "Org Indent mode" :predicate))) | 141 | (not (org-version-check "23.1.50" "Org Indent mode" :predicate))) |
| 142 | (message "org-indent-mode is can crash Emacs 23.1 - refused to turn it on!") | 142 | (message "org-indent-mode can crash Emacs 23.1 - refusing to turn it on!") |
| 143 | (ding) | 143 | (ding) |
| 144 | (sit-for 1) | 144 | (sit-for 1) |
| 145 | (setq org-indent-mode nil)) | 145 | (setq org-indent-mode nil)) |
| @@ -203,8 +203,9 @@ useful to make it ever so slightly different." | |||
| 203 | 203 | ||
| 204 | (defun org-indent-remove-properties (beg end) | 204 | (defun org-indent-remove-properties (beg end) |
| 205 | "Remove indentations between BEG and END." | 205 | "Remove indentations between BEG and END." |
| 206 | (org-unmodified | 206 | (let ((inhibit-modification-hooks t)) |
| 207 | (remove-text-properties beg end '(line-prefix nil wrap-prefix nil)))) | 207 | (with-silent-modifications |
| 208 | (remove-text-properties beg end '(line-prefix nil wrap-prefix nil))))) | ||
| 208 | 209 | ||
| 209 | (defun org-indent-remove-properties-from-string (string) | 210 | (defun org-indent-remove-properties-from-string (string) |
| 210 | "Remove indentations between BEG and END." | 211 | "Remove indentations between BEG and END." |
| @@ -219,8 +220,9 @@ useful to make it ever so slightly different." | |||
| 219 | "Add indentation properties between BEG and END. | 220 | "Add indentation properties between BEG and END. |
| 220 | Assumes that BEG is at the beginning of a line." | 221 | Assumes that BEG is at the beginning of a line." |
| 221 | (when (or t org-indent-mode) | 222 | (when (or t org-indent-mode) |
| 222 | (let (ov b e n level exit nstars) | 223 | (let ((inhibit-modification-hooks t) |
| 223 | (org-unmodified | 224 | ov b e n level exit nstars) |
| 225 | (with-silent-modifications | ||
| 224 | (save-excursion | 226 | (save-excursion |
| 225 | (goto-char beg) | 227 | (goto-char beg) |
| 226 | (while (not exit) | 228 | (while (not exit) |
diff --git a/lisp/org/org-info.el b/lisp/org/org-info.el index 3c6bf7d2ca4..6ea192b1765 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.01 | 9 | ;; Version: 7.3 |
| 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 43d59b0b558..29d8c40eed2 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.01 | 8 | ;; Version: 7.3 |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -90,7 +90,9 @@ or to a number smaller than this one. In fact, when `org-cycle-max-level' is | |||
| 90 | not set, it will be assumed to be one less than the value of smaller than | 90 | not set, it will be assumed to be one less than the value of smaller than |
| 91 | the value of this variable." | 91 | the value of this variable." |
| 92 | :group 'org-inlinetask | 92 | :group 'org-inlinetask |
| 93 | :type 'boolean) | 93 | :type '(choice |
| 94 | (const :tag "Off" nil) | ||
| 95 | (integer))) | ||
| 94 | 96 | ||
| 95 | (defcustom org-inlinetask-export t | 97 | (defcustom org-inlinetask-export t |
| 96 | "Non-nil means export inline tasks. | 98 | "Non-nil means export inline tasks. |
| @@ -104,7 +106,7 @@ When nil, they will not be exported." | |||
| 104 | (defvar org-complex-heading-regexp) | 106 | (defvar org-complex-heading-regexp) |
| 105 | (defvar org-property-end-re) | 107 | (defvar org-property-end-re) |
| 106 | 108 | ||
| 107 | (defcustom org-inlinetask-defaut-state nil | 109 | (defcustom org-inlinetask-default-state nil |
| 108 | "Non-nil means make inline tasks have a TODO keyword initially. | 110 | "Non-nil means make inline tasks have a TODO keyword initially. |
| 109 | This should be the state `org-inlinetask-insert-task' should use by | 111 | This should be the state `org-inlinetask-insert-task' should use by |
| 110 | default, or nil of no state should be assigned." | 112 | default, or nil of no state should be assigned." |
| @@ -115,20 +117,36 @@ default, or nil of no state should be assigned." | |||
| 115 | 117 | ||
| 116 | (defun org-inlinetask-insert-task (&optional no-state) | 118 | (defun org-inlinetask-insert-task (&optional no-state) |
| 117 | "Insert an inline task. | 119 | "Insert an inline task. |
| 118 | If prefix arg NO-STATE is set, ignore `org-inlinetask-defaut-state'." | 120 | If prefix arg NO-STATE is set, ignore `org-inlinetask-default-state'." |
| 119 | (interactive "P") | 121 | (interactive "P") |
| 120 | (or (bolp) (newline)) | 122 | (or (bolp) (newline)) |
| 121 | (let ((indent org-inlinetask-min-level)) | 123 | (let ((indent org-inlinetask-min-level)) |
| 122 | (if org-odd-levels-only | 124 | (if org-odd-levels-only |
| 123 | (setq indent (- (* 2 indent) 1))) | 125 | (setq indent (- (* 2 indent) 1))) |
| 124 | (insert (make-string indent ?*) | 126 | (insert (make-string indent ?*) |
| 125 | (if (or no-state (not org-inlinetask-defaut-state)) | 127 | (if (or no-state (not org-inlinetask-default-state)) |
| 126 | " \n" | 128 | " \n" |
| 127 | (concat " " org-inlinetask-defaut-state " \n")) | 129 | (concat " " org-inlinetask-default-state " \n")) |
| 128 | (make-string indent ?*) " END\n")) | 130 | (make-string indent ?*) " END\n")) |
| 129 | (end-of-line -1)) | 131 | (end-of-line -1)) |
| 130 | (define-key org-mode-map "\C-c\C-xt" 'org-inlinetask-insert-task) | 132 | (define-key org-mode-map "\C-c\C-xt" 'org-inlinetask-insert-task) |
| 131 | 133 | ||
| 134 | (defun org-inlinetask-in-task-p () | ||
| 135 | "Return true if point is inside an inline task." | ||
| 136 | (save-excursion | ||
| 137 | (let* ((nstars (if org-odd-levels-only | ||
| 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 "\\(?:.*\\)")) | ||
| 144 | (task-end-re (concat stars-re "\\(?:END\\|end\\)"))) | ||
| 145 | (beginning-of-line) | ||
| 146 | (or (looking-at task-beg-re) | ||
| 147 | (and (re-search-forward "^\\*+[ \t]+" nil t) | ||
| 148 | (progn (beginning-of-line) (looking-at task-end-re))))))) | ||
| 149 | |||
| 132 | (defvar htmlp) ; dynamically scoped into the next function | 150 | (defvar htmlp) ; dynamically scoped into the next function |
| 133 | (defvar latexp) ; dynamically scoped into the next function | 151 | (defvar latexp) ; dynamically scoped into the next function |
| 134 | (defun org-inlinetask-export-handler () | 152 | (defun org-inlinetask-export-handler () |
diff --git a/lisp/org/org-irc.el b/lisp/org/org-irc.el index 3e3631ae979..3dd9680c8ff 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.01 | 7 | ;; Version: 7.3 |
| 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 de0f46d5293..d435d814679 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.01 | 9 | ;; Version: 7.3 |
| 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 55444c08bbe..2cf947312d8 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.01 | 7 | ;; Version: 7.3 |
| 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 |
| @@ -280,6 +280,11 @@ markup defined, the first one in the association list will be used." | |||
| 280 | (string :tag "Keyword") | 280 | (string :tag "Keyword") |
| 281 | (string :tag "Markup"))))) | 281 | (string :tag "Markup"))))) |
| 282 | 282 | ||
| 283 | (defcustom org-export-latex-tag-markup "\\textbf{%s}" | ||
| 284 | "Markup for tags, as a printf format." | ||
| 285 | :group 'org-export-latex | ||
| 286 | :type 'string) | ||
| 287 | |||
| 283 | (defcustom org-export-latex-timestamp-markup "\\textit{%s}" | 288 | (defcustom org-export-latex-timestamp-markup "\\textit{%s}" |
| 284 | "A printf format string to be applied to time stamps." | 289 | "A printf format string to be applied to time stamps." |
| 285 | :group 'org-export-latex | 290 | :group 'org-export-latex |
| @@ -371,12 +376,30 @@ for example using customize, or with something like | |||
| 371 | 376 | ||
| 372 | (require 'org-latex) | 377 | (require 'org-latex) |
| 373 | (add-to-list 'org-export-latex-packages-alist '(\"\" \"listings\")) | 378 | (add-to-list 'org-export-latex-packages-alist '(\"\" \"listings\")) |
| 374 | (add-to-list 'org-export-latex-packages-alist '(\"\" \"color\"))" | 379 | (add-to-list 'org-export-latex-packages-alist '(\"\" \"color\")) |
| 380 | |||
| 381 | Alternatively, | ||
| 382 | |||
| 383 | (setq org-export-latex-listings 'minted) | ||
| 384 | |||
| 385 | causes source code to be exported using the minted package as | ||
| 386 | opposed to listings. If you want to use minted, you need to add | ||
| 387 | the minted package to `org-export-latex-packages-alist', for | ||
| 388 | example using customize, or with | ||
| 389 | |||
| 390 | (require 'org-latex) | ||
| 391 | (add-to-list 'org-export-latex-packages-alist '(\"\" \"minted\")) | ||
| 392 | |||
| 393 | In addition, it is neccessary to install | ||
| 394 | pygments (http://pygments.org), and to configure | ||
| 395 | `org-latex-to-pdf-process' so that the -shell-escape option is | ||
| 396 | passed to pdflatex. | ||
| 397 | " | ||
| 375 | :group 'org-export-latex | 398 | :group 'org-export-latex |
| 376 | :type 'boolean) | 399 | :type 'boolean) |
| 377 | 400 | ||
| 378 | (defcustom org-export-latex-listings-langs | 401 | (defcustom org-export-latex-listings-langs |
| 379 | '((emacs-lisp "Lisp") (lisp "Lisp") | 402 | '((emacs-lisp "Lisp") (lisp "Lisp") (clojure "Lisp") |
| 380 | (c "C") (cc "C++") | 403 | (c "C") (cc "C++") |
| 381 | (fortran "fortran") | 404 | (fortran "fortran") |
| 382 | (perl "Perl") (cperl "Perl") (python "Python") (ruby "Ruby") | 405 | (perl "Perl") (cperl "Perl") (python "Python") (ruby "Ruby") |
| @@ -398,6 +421,44 @@ hurt if it is present." | |||
| 398 | (symbol :tag "Major mode ") | 421 | (symbol :tag "Major mode ") |
| 399 | (string :tag "Listings language")))) | 422 | (string :tag "Listings language")))) |
| 400 | 423 | ||
| 424 | (defcustom org-export-latex-listings-w-names t | ||
| 425 | "Non-nil means export names of named code blocks. | ||
| 426 | Code blocks exported with the listings package (controlled by the | ||
| 427 | `org-export-latex-listings' variable) can be named in the style | ||
| 428 | of noweb." | ||
| 429 | :group 'org-export-latex | ||
| 430 | :type 'boolean) | ||
| 431 | |||
| 432 | (defcustom org-export-latex-minted-langs | ||
| 433 | '((emacs-lisp "common-lisp") | ||
| 434 | (cc "c++") | ||
| 435 | (cperl "perl") | ||
| 436 | (shell-script "bash") | ||
| 437 | (caml "ocaml")) | ||
| 438 | "Alist mapping languages to their minted language counterpart. | ||
| 439 | The key is a symbol, the major mode symbol without the \"-mode\". | ||
| 440 | The value is the string that should be inserted as the language parameter | ||
| 441 | for the minted package. If the mode name and the listings name are | ||
| 442 | the same, the language does not need an entry in this list - but it does not | ||
| 443 | hurt if it is present. | ||
| 444 | |||
| 445 | Note that minted uses all lower case for language identifiers, | ||
| 446 | and that the full list of language identifiers can be obtained | ||
| 447 | with: | ||
| 448 | pygmentize -L lexers | ||
| 449 | " | ||
| 450 | :group 'org-export-latex | ||
| 451 | :type '(repeat | ||
| 452 | (list | ||
| 453 | (symbol :tag "Major mode ") | ||
| 454 | (string :tag "Listings language")))) | ||
| 455 | |||
| 456 | (defcustom org-export-latex-minted-with-line-numbers nil | ||
| 457 | "Should source code line numbers be included when exporting | ||
| 458 | with the latex minted package?" | ||
| 459 | :group 'org-export-latex | ||
| 460 | :type 'boolean) | ||
| 461 | |||
| 401 | (defcustom org-export-latex-remove-from-headlines | 462 | (defcustom org-export-latex-remove-from-headlines |
| 402 | '(:todo nil :priority nil :tags nil) | 463 | '(:todo nil :priority nil :tags nil) |
| 403 | "A plist of keywords to remove from headlines. OBSOLETE. | 464 | "A plist of keywords to remove from headlines. OBSOLETE. |
| @@ -443,24 +504,53 @@ allowed. The default we use here encompasses both." | |||
| 443 | :group 'org-export) | 504 | :group 'org-export) |
| 444 | 505 | ||
| 445 | (defcustom org-latex-to-pdf-process | 506 | (defcustom org-latex-to-pdf-process |
| 446 | '("pdflatex -interaction nonstopmode %s" | 507 | '("pdflatex -interaction nonstopmode -output-directory %o %f" |
| 447 | "pdflatex -interaction nonstopmode %s") | 508 | "pdflatex -interaction nonstopmode -output-directory %o %f" |
| 509 | "pdflatex -interaction nonstopmode -output-directory %o %f") | ||
| 448 | "Commands to process a LaTeX file to a PDF file. | 510 | "Commands to process a LaTeX file to a PDF file. |
| 449 | This is a list of strings, each of them will be given to the shell | 511 | This is a list of strings, each of them will be given to the shell |
| 450 | as a command. %s in the command will be replaced by the full file name, %b | 512 | as a command. %f in the command will be replaced by the full file name, %b |
| 451 | by the file base name (i.e. without extension). | 513 | by the file base name (i.e. without extension) and %o by the base directory |
| 514 | of the file. | ||
| 515 | |||
| 452 | The reason why this is a list is that it usually takes several runs of | 516 | The reason why this is a list is that it usually takes several runs of |
| 453 | pdflatex, maybe mixed with a call to bibtex. Org does not have a clever | 517 | `pdflatex', maybe mixed with a call to `bibtex'. Org does not have a clever |
| 454 | mechanism to detect which of these commands have to be run to get to a stable | 518 | mechanism to detect which of these commands have to be run to get to a stable |
| 455 | result, and it also does not do any error checking. | 519 | result, and it also does not do any error checking. |
| 456 | 520 | ||
| 521 | By default, Org uses 3 runs of `pdflatex' to do the processing. If you | ||
| 522 | have texi2dvi on your system and if that does not cause the infamous | ||
| 523 | egrep/locale bug: | ||
| 524 | |||
| 525 | http://lists.gnu.org/archive/html/bug-texinfo/2010-03/msg00031.html | ||
| 526 | |||
| 527 | then `texi2dvi' is the superior choice. Org does offer it as one | ||
| 528 | of the customize options. | ||
| 529 | |||
| 457 | Alternatively, this may be a Lisp function that does the processing, so you | 530 | Alternatively, this may be a Lisp function that does the processing, so you |
| 458 | could use this to apply the machinery of AUCTeX or the Emacs LaTeX mode. | 531 | could use this to apply the machinery of AUCTeX or the Emacs LaTeX mode. |
| 459 | This function should accept the file name as its single argument." | 532 | This function should accept the file name as its single argument." |
| 460 | :group 'org-export-pdf | 533 | :group 'org-export-pdf |
| 461 | :type '(choice (repeat :tag "Shell command sequence" | 534 | :type '(choice |
| 535 | (repeat :tag "Shell command sequence" | ||
| 462 | (string :tag "Shell command")) | 536 | (string :tag "Shell command")) |
| 463 | (function))) | 537 | (const :tag "2 runs of pdflatex" |
| 538 | ("pdflatex -interaction nonstopmode -output-directory %o %f" | ||
| 539 | "pdflatex -interaction nonstopmode -output-directory %o %f")) | ||
| 540 | (const :tag "3 runs of pdflatex" | ||
| 541 | ("pdflatex -interaction nonstopmode -output-directory %o %f" | ||
| 542 | "pdflatex -interaction nonstopmode -output-directory %o %f" | ||
| 543 | "pdflatex -interaction nonstopmode -output-directory %o %f")) | ||
| 544 | (const :tag "pdflatex,bibtex,pdflatex,pdflatex" | ||
| 545 | ("pdflatex -interaction nonstopmode -output-directory %o %f" | ||
| 546 | "bibtex %b" | ||
| 547 | "pdflatex -interaction nonstopmode -output-directory %o %f" | ||
| 548 | "pdflatex -interaction nonstopmode -output-directory %o %f")) | ||
| 549 | (const :tag "texi2dvi" | ||
| 550 | ("texi2dvi -p -b -c -V %f")) | ||
| 551 | (const :tag "rubber" | ||
| 552 | ("rubber -d --into %o %f")) | ||
| 553 | (function))) | ||
| 464 | 554 | ||
| 465 | (defcustom org-export-pdf-logfiles | 555 | (defcustom org-export-pdf-logfiles |
| 466 | '("aux" "idx" "log" "out" "toc" "nav" "snm" "vrb") | 556 | '("aux" "idx" "log" "out" "toc" "nav" "snm" "vrb") |
| @@ -832,9 +922,10 @@ when PUB-DIR is set, use this as the publishing directory." | |||
| 832 | (save-excursion | 922 | (save-excursion |
| 833 | (goto-char (point-min)) | 923 | (goto-char (point-min)) |
| 834 | (re-search-forward "\\\\bibliography{" nil t)))) | 924 | (re-search-forward "\\\\bibliography{" nil t)))) |
| 835 | cmd) | 925 | cmd output-dir errors) |
| 836 | (with-current-buffer outbuf (erase-buffer)) | 926 | (with-current-buffer outbuf (erase-buffer)) |
| 837 | (message "Processing LaTeX file...") | 927 | (message (concat "Processing LaTeX file " file "...")) |
| 928 | (setq output-dir (file-name-directory file)) | ||
| 838 | (if (and cmds (symbolp cmds)) | 929 | (if (and cmds (symbolp cmds)) |
| 839 | (funcall cmds (shell-quote-argument file)) | 930 | (funcall cmds (shell-quote-argument file)) |
| 840 | (while cmds | 931 | (while cmds |
| @@ -844,23 +935,52 @@ when PUB-DIR is set, use this as the publishing directory." | |||
| 844 | (save-match-data | 935 | (save-match-data |
| 845 | (shell-quote-argument base)) | 936 | (shell-quote-argument base)) |
| 846 | t t cmd))) | 937 | t t cmd))) |
| 847 | (while (string-match "%s" cmd) | 938 | (while (string-match "%f" cmd) |
| 848 | (setq cmd (replace-match | 939 | (setq cmd (replace-match |
| 849 | (save-match-data | 940 | (save-match-data |
| 850 | (shell-quote-argument file)) | 941 | (shell-quote-argument file)) |
| 851 | t t cmd))) | 942 | t t cmd))) |
| 852 | (shell-command cmd outbuf outbuf))) | 943 | (while (string-match "%o" cmd) |
| 853 | (message "Processing LaTeX file...done") | 944 | (setq cmd (replace-match |
| 945 | (save-match-data | ||
| 946 | (shell-quote-argument output-dir)) | ||
| 947 | t t cmd))) | ||
| 948 | (shell-command cmd outbuf))) | ||
| 949 | (message (concat "Processing LaTeX file " file "...done")) | ||
| 950 | (setq errors (org-export-latex-get-error outbuf)) | ||
| 854 | (if (not (file-exists-p pdffile)) | 951 | (if (not (file-exists-p pdffile)) |
| 855 | (error "PDF file was not produced") | 952 | (error (concat "PDF file " pdffile " was not produced" |
| 953 | (if errors (concat ":" errors "") ""))) | ||
| 856 | (set-window-configuration wconfig) | 954 | (set-window-configuration wconfig) |
| 857 | (when org-export-pdf-remove-logfiles | 955 | (when org-export-pdf-remove-logfiles |
| 858 | (dolist (ext org-export-pdf-logfiles) | 956 | (dolist (ext org-export-pdf-logfiles) |
| 859 | (setq file (concat base "." ext)) | 957 | (setq file (concat base "." ext)) |
| 860 | (and (file-exists-p file) (delete-file file)))) | 958 | (and (file-exists-p file) (delete-file file)))) |
| 861 | (message "Exporting to PDF...done") | 959 | (message (concat |
| 960 | "Exporting to PDF...done" | ||
| 961 | (if errors | ||
| 962 | (concat ", with some errors:" errors) | ||
| 963 | ""))) | ||
| 862 | pdffile))) | 964 | pdffile))) |
| 863 | 965 | ||
| 966 | (defun org-export-latex-get-error (buf) | ||
| 967 | "Collect the kinds of errors that remain in pdflatex processing." | ||
| 968 | (with-current-buffer buf | ||
| 969 | (save-excursion | ||
| 970 | (goto-char (point-max)) | ||
| 971 | (when (re-search-backward "^[ \t]*This is pdf.*?TeX.*?Version" nil t) | ||
| 972 | ;; OK, we are at the location of the final run | ||
| 973 | (let ((pos (point)) (errors "") (case-fold-search t)) | ||
| 974 | (if (re-search-forward "Reference.*?undefined" nil t) | ||
| 975 | (setq errors (concat errors " [undefined reference]"))) | ||
| 976 | (goto-char pos) | ||
| 977 | (if (re-search-forward "Citation.*?undefined" nil t) | ||
| 978 | (setq errors (concat errors " [undefined citation]"))) | ||
| 979 | (goto-char pos) | ||
| 980 | (if (re-search-forward "Undefined control sequence" nil t) | ||
| 981 | (setq errors (concat errors " [undefined control sequence]"))) | ||
| 982 | (and (org-string-nw-p errors) errors)))))) | ||
| 983 | |||
| 864 | ;;;###autoload | 984 | ;;;###autoload |
| 865 | (defun org-export-as-pdf-and-open (arg) | 985 | (defun org-export-as-pdf-and-open (arg) |
| 866 | "Export as LaTeX, then process through to PDF, and open." | 986 | "Export as LaTeX, then process through to PDF, and open." |
| @@ -1158,7 +1278,7 @@ OPT-PLIST is the options plist for current buffer." | |||
| 1158 | (plist-get opt-plist :latex-header-extra))) | 1278 | (plist-get opt-plist :latex-header-extra))) |
| 1159 | ;; append another special variable | 1279 | ;; append another special variable |
| 1160 | (org-export-apply-macros-in-string org-export-latex-append-header) | 1280 | (org-export-apply-macros-in-string org-export-latex-append-header) |
| 1161 | ;; define align if not yet defined | 1281 | ;; define alert if not yet defined |
| 1162 | "\n\\providecommand{\\alert}[1]{\\textbf{#1}}" | 1282 | "\n\\providecommand{\\alert}[1]{\\textbf{#1}}" |
| 1163 | ;; insert the title | 1283 | ;; insert the title |
| 1164 | (format | 1284 | (format |
| @@ -1227,9 +1347,13 @@ If END is non-nil, it is the end of the region." | |||
| 1227 | '(:org-license-to-kill t)) | 1347 | '(:org-license-to-kill t)) |
| 1228 | (save-excursion | 1348 | (save-excursion |
| 1229 | (goto-char pt) | 1349 | (goto-char pt) |
| 1230 | (while (re-search-forward "^[ \t]*#+.*\n?" limit t) | 1350 | (while (re-search-forward "^[ \t]*#\\+.*\n?" limit t) |
| 1231 | (remove-text-properties (match-beginning 0) (match-end 0) | 1351 | (let ((case-fold-search t)) |
| 1232 | '(:org-license-to-kill t)))))))))) | 1352 | (unless (org-string-match-p |
| 1353 | "^[ \t]*#\\+\\(attr_\\|caption\\>\\|label\\>\\)" | ||
| 1354 | (match-string 0)) | ||
| 1355 | (remove-text-properties (match-beginning 0) (match-end 0) | ||
| 1356 | '(:org-license-to-kill t)))))))))))) | ||
| 1233 | 1357 | ||
| 1234 | 1358 | ||
| 1235 | (defvar org-export-latex-header-defs nil | 1359 | (defvar org-export-latex-header-defs nil |
| @@ -1310,13 +1434,13 @@ links, keywords, lists, tables, fixed-width" | |||
| 1310 | (replace-match "") | 1434 | (replace-match "") |
| 1311 | (replace-match (format "\\textbf{%s}" (match-string 0)) t t))) | 1435 | (replace-match (format "\\textbf{%s}" (match-string 0)) t t))) |
| 1312 | ;; convert tags | 1436 | ;; convert tags |
| 1313 | (when (re-search-forward "\\(:[a-zA-Z0-9_@]+\\)+:" nil t) | 1437 | (when (re-search-forward "\\(:[a-zA-Z0-9_@#%]+\\)+:" nil t) |
| 1314 | (if (or (not org-export-with-tags) | 1438 | (if (or (not org-export-with-tags) |
| 1315 | (plist-get remove-list :tags)) | 1439 | (plist-get remove-list :tags)) |
| 1316 | (replace-match "") | 1440 | (replace-match "") |
| 1317 | (replace-match | 1441 | (replace-match |
| 1318 | (org-export-latex-protect-string | 1442 | (org-export-latex-protect-string |
| 1319 | (format "\\textbf{%s}" | 1443 | (format org-export-latex-tag-markup |
| 1320 | (save-match-data | 1444 | (save-match-data |
| 1321 | (replace-regexp-in-string | 1445 | (replace-regexp-in-string |
| 1322 | "_" "\\\\_" (match-string 0))))) | 1446 | "_" "\\\\_" (match-string 0))))) |
| @@ -1589,7 +1713,7 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER." | |||
| 1589 | (org-table-last-column-widths (copy-sequence | 1713 | (org-table-last-column-widths (copy-sequence |
| 1590 | org-table-last-column-widths)) | 1714 | org-table-last-column-widths)) |
| 1591 | fnum fields line lines olines gr colgropen line-fmt align | 1715 | fnum fields line lines olines gr colgropen line-fmt align |
| 1592 | caption shortn label attr floatp longtblp) | 1716 | caption shortn label attr floatp placement longtblp) |
| 1593 | (if org-export-latex-tables-verbatim | 1717 | (if org-export-latex-tables-verbatim |
| 1594 | (let* ((tbl (concat "\\begin{verbatim}\n" raw-table | 1718 | (let* ((tbl (concat "\\begin{verbatim}\n" raw-table |
| 1595 | "\\end{verbatim}\n"))) | 1719 | "\\end{verbatim}\n"))) |
| @@ -1609,7 +1733,12 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER." | |||
| 1609 | align (and attr (stringp attr) | 1733 | align (and attr (stringp attr) |
| 1610 | (string-match "\\<align=\\([^ \t\n\r]+\\)" attr) | 1734 | (string-match "\\<align=\\([^ \t\n\r]+\\)" attr) |
| 1611 | (match-string 1 attr)) | 1735 | (match-string 1 attr)) |
| 1612 | floatp (or caption label)) | 1736 | floatp (or caption label) |
| 1737 | placement (if (and attr | ||
| 1738 | (stringp attr) | ||
| 1739 | (string-match "[ \t]*\\<placement=\\(\\S-+\\)" attr)) | ||
| 1740 | (match-string 1 attr) | ||
| 1741 | "[htb]")) | ||
| 1613 | (setq caption (and caption (org-export-latex-fontify-headline caption))) | 1742 | (setq caption (and caption (org-export-latex-fontify-headline caption))) |
| 1614 | (setq lines (org-split-string raw-table "\n")) | 1743 | (setq lines (org-split-string raw-table "\n")) |
| 1615 | (apply 'delete-region (list beg end)) | 1744 | (apply 'delete-region (list beg end)) |
| @@ -1664,12 +1793,13 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER." | |||
| 1664 | (concat | 1793 | (concat |
| 1665 | (if longtblp | 1794 | (if longtblp |
| 1666 | (concat "\\begin{longtable}{" align "}\n") | 1795 | (concat "\\begin{longtable}{" align "}\n") |
| 1667 | (if floatp "\\begin{table}[htb]\n")) | 1796 | (if floatp (format "\\begin{table}%s\n" placement))) |
| 1668 | (if floatp | 1797 | (if floatp |
| 1669 | (format | 1798 | (format |
| 1670 | "\\caption%s{%s}" | 1799 | "\\caption%s{%s} %s" |
| 1671 | (if shortn (concat "[" shortn "]") "") | 1800 | (if shortn (concat "[" shortn "]") "") |
| 1672 | (or caption ""))) | 1801 | (or caption "") |
| 1802 | (if label (format "\\label{%s}" label) ""))) | ||
| 1673 | (if (and longtblp caption) "\\\\\n" "\n") | 1803 | (if (and longtblp caption) "\\\\\n" "\n") |
| 1674 | (if (and org-export-latex-tables-centered (not longtblp)) | 1804 | (if (and org-export-latex-tables-centered (not longtblp)) |
| 1675 | "\\begin{center}\n") | 1805 | "\\begin{center}\n") |
| @@ -1741,7 +1871,7 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER." | |||
| 1741 | (setq tbl (concat "\\begin{center}\n" tbl "\\end{center}"))) | 1871 | (setq tbl (concat "\\begin{center}\n" tbl "\\end{center}"))) |
| 1742 | (when floatp | 1872 | (when floatp |
| 1743 | (setq tbl (concat "\\begin{table}\n" | 1873 | (setq tbl (concat "\\begin{table}\n" |
| 1744 | (format "\\caption%s{%s%s}\n" | 1874 | (format "\\caption%s{%s}%s\n" |
| 1745 | (if shortn (format "[%s]" shortn) "") | 1875 | (if shortn (format "[%s]" shortn) "") |
| 1746 | (if label (format "\\label{%s}" label) "") | 1876 | (if label (format "\\label{%s}" label) "") |
| 1747 | (or caption "")) | 1877 | (or caption "")) |
| @@ -2213,11 +2343,11 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER." | |||
| 2213 | "Convert plain text lists in current buffer into LaTeX lists." | 2343 | "Convert plain text lists in current buffer into LaTeX lists." |
| 2214 | (let (res) | 2344 | (let (res) |
| 2215 | (goto-char (point-min)) | 2345 | (goto-char (point-min)) |
| 2216 | (while (org-re-search-forward-unprotected org-list-beginning-re nil t) | 2346 | (while (org-search-forward-unenclosed org-item-beginning-re nil t) |
| 2217 | (beginning-of-line) | 2347 | (beginning-of-line) |
| 2218 | (setq res (org-list-to-latex (org-list-parse-list t) | 2348 | (setq res (org-list-to-latex (org-list-parse-list t) |
| 2219 | org-export-latex-list-parameters)) | 2349 | org-export-latex-list-parameters)) |
| 2220 | (while (string-match "^\\(\\\\item[ \t]+\\)\\[@start:\\([0-9]+\\)\\]" | 2350 | (while (string-match "^\\(\\\\item[ \t]+\\)\\[@\\(?:start:\\)?\\([0-9]+\\)\\]" |
| 2221 | res) | 2351 | res) |
| 2222 | (setq res (replace-match | 2352 | (setq res (replace-match |
| 2223 | (concat (format "\\setcounter{enumi}{%d}" | 2353 | (concat (format "\\setcounter{enumi}{%d}" |
diff --git a/lisp/org/org-list.el b/lisp/org/org-list.el index 19ba1a96395..4ea466f379d 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.01 | 10 | ;; Version: 7.3 |
| 11 | ;; | 11 | ;; |
| 12 | ;; This file is part of GNU Emacs. | 12 | ;; This file is part of GNU Emacs. |
| 13 | ;; | 13 | ;; |
| @@ -40,21 +40,31 @@ | |||
| 40 | (defvar org-M-RET-may-split-line) | 40 | (defvar org-M-RET-may-split-line) |
| 41 | (defvar org-complex-heading-regexp) | 41 | (defvar org-complex-heading-regexp) |
| 42 | (defvar org-odd-levels-only) | 42 | (defvar org-odd-levels-only) |
| 43 | (defvar org-outline-regexp) | ||
| 44 | (defvar org-ts-regexp) | ||
| 45 | (defvar org-ts-regexp-both) | ||
| 43 | 46 | ||
| 44 | (declare-function org-invisible-p "org" ()) | 47 | (declare-function org-invisible-p "org" ()) |
| 45 | (declare-function org-on-heading-p "org" (&optional invisible-ok)) | 48 | (declare-function org-on-heading-p "org" (&optional invisible-ok)) |
| 46 | (declare-function outline-next-heading "outline" ()) | 49 | (declare-function outline-next-heading "outline" ()) |
| 47 | (declare-function org-back-to-heading "org" (&optional invisible-ok)) | 50 | (declare-function org-back-to-heading "org" (&optional invisible-ok)) |
| 48 | (declare-function org-back-over-empty-lines "org" ()) | 51 | (declare-function org-back-over-empty-lines "org" ()) |
| 49 | (declare-function org-skip-whitespace "org" ()) | ||
| 50 | (declare-function org-trim "org" (s)) | 52 | (declare-function org-trim "org" (s)) |
| 51 | (declare-function org-get-indentation "org" (&optional line)) | 53 | (declare-function org-get-indentation "org" (&optional line)) |
| 52 | (declare-function org-timer-item "org-timer" (&optional arg)) | 54 | (declare-function org-timer-item "org-timer" (&optional arg)) |
| 55 | (declare-function org-timer-hms-to-secs "org-timer" (hms)) | ||
| 53 | (declare-function org-combine-plists "org" (&rest plists)) | 56 | (declare-function org-combine-plists "org" (&rest plists)) |
| 54 | (declare-function org-entry-get "org" | 57 | (declare-function org-entry-get "org" |
| 55 | (pom property &optional inherit literal-nil)) | 58 | (pom property &optional inherit literal-nil)) |
| 56 | (declare-function org-narrow-to-subtree "org" ()) | 59 | (declare-function org-narrow-to-subtree "org" ()) |
| 57 | (declare-function org-show-subtree "org" ()) | 60 | (declare-function org-show-subtree "org" ()) |
| 61 | (declare-function org-in-regexps-block-p "org" | ||
| 62 | (start-re end-re &optional bound)) | ||
| 63 | (declare-function org-level-increment "org" ()) | ||
| 64 | (declare-function org-at-heading-p "org" (&optional ignored)) | ||
| 65 | (declare-function outline-previous-heading "outline" ()) | ||
| 66 | (declare-function org-icompleting-read "org" (&rest args)) | ||
| 67 | (declare-function org-time-string-to-seconds "org" (s)) | ||
| 58 | 68 | ||
| 59 | (defgroup org-plain-lists nil | 69 | (defgroup org-plain-lists nil |
| 60 | "Options concerning plain lists in Org-mode." | 70 | "Options concerning plain lists in Org-mode." |
| @@ -63,7 +73,6 @@ | |||
| 63 | 73 | ||
| 64 | (defcustom org-cycle-include-plain-lists t | 74 | (defcustom org-cycle-include-plain-lists t |
| 65 | "When t, make TAB cycle visibility on plain list items. | 75 | "When t, make TAB cycle visibility on plain list items. |
| 66 | |||
| 67 | Cycling plain lists works only when the cursor is on a plain list | 76 | Cycling plain lists works only when the cursor is on a plain list |
| 68 | item. When the cursor is on an outline heading, plain lists are | 77 | item. When the cursor is on an outline heading, plain lists are |
| 69 | treated as text. This is the most stable way of handling this, | 78 | treated as text. This is the most stable way of handling this, |
| @@ -140,38 +149,88 @@ the safe choice." | |||
| 140 | (defcustom org-list-two-spaces-after-bullet-regexp nil | 149 | (defcustom org-list-two-spaces-after-bullet-regexp nil |
| 141 | "A regular expression matching bullets that should have 2 spaces after them. | 150 | "A regular expression matching bullets that should have 2 spaces after them. |
| 142 | When nil, no bullet will have two spaces after them. | 151 | When nil, no bullet will have two spaces after them. |
| 143 | When a string, it will be used as a regular expression. When the bullet | 152 | When a string, it will be used as a regular expression. When the |
| 144 | type of a list is changed, the new bullet type will be matched against this | 153 | bullet type of a list is changed, the new bullet type will be |
| 145 | regexp. If it matches, there will be two spaces instead of one after | 154 | matched against this regexp. If it matches, there will be two |
| 146 | the bullet in each item of he list." | 155 | spaces instead of one after the bullet in each item of the list." |
| 147 | :group 'org-plain-lists | 156 | :group 'org-plain-lists |
| 148 | :type '(choice | 157 | :type '(choice |
| 149 | (const :tag "never" nil) | 158 | (const :tag "never" nil) |
| 150 | (regexp))) | 159 | (regexp))) |
| 151 | 160 | ||
| 152 | (defcustom org-empty-line-terminates-plain-lists nil | 161 | (defcustom org-list-ending-method 'both |
| 153 | "Non-nil means an empty line ends all plain list levels. | 162 | "Determine where plain lists should end. |
| 154 | This is currently effective only during export. It should also have | 163 | Valid values are: `regexp', `indent' or `both'. |
| 155 | an effect for indentation and plain list folding, but it does not. | 164 | |
| 156 | When nil, empty lines are part of the preceding item." | 165 | When set to `regexp', Org will look into two variables, |
| 166 | `org-empty-line-terminates-plain-lists' and the more general | ||
| 167 | `org-list-end-regexp', to determine what will end lists. This is | ||
| 168 | the fastest method. | ||
| 169 | |||
| 170 | When set to `indent', a list will end whenever a line following | ||
| 171 | an item, but not starting one, is less or equally indented than | ||
| 172 | it. | ||
| 173 | |||
| 174 | When set to `both', each of the preceding methods is applied to | ||
| 175 | determine lists endings. This is the default method." | ||
| 157 | :group 'org-plain-lists | 176 | :group 'org-plain-lists |
| 158 | :type 'boolean) | 177 | :type '(choice |
| 178 | (const :tag "With a regexp defining ending" regexp) | ||
| 179 | (const :tag "With indentation of regular (no bullet) text" indent) | ||
| 180 | (const :tag "With both methods" both))) | ||
| 159 | 181 | ||
| 160 | (defcustom org-auto-renumber-ordered-lists t | 182 | (defcustom org-empty-line-terminates-plain-lists nil |
| 161 | "Non-nil means automatically renumber ordered plain lists. | 183 | "Non-nil means an empty line ends all plain list levels. |
| 162 | Renumbering happens when the sequence have been changed with | 184 | This variable only makes sense if `org-list-ending-method' is set |
| 163 | \\[org-shiftmetaup] or \\[org-shiftmetadown]. After other editing commands, | 185 | to `regexp' or `both'. This is then equivalent to set |
| 164 | use \\[org-ctrl-c-ctrl-c] to trigger renumbering." | 186 | `org-list-end-regexp' to \"^[ \\t]*$\"." |
| 165 | :group 'org-plain-lists | 187 | :group 'org-plain-lists |
| 166 | :type 'boolean) | 188 | :type 'boolean) |
| 167 | 189 | ||
| 168 | (defcustom org-provide-checkbox-statistics t | 190 | (defcustom org-list-end-regexp "^[ \t]*\n[ \t]*\n" |
| 169 | "Non-nil means update checkbox statistics after insert and toggle. | 191 | "Regexp matching the end of all plain list levels. |
| 170 | When this is set, checkbox statistics is updated each time you | 192 | It must start with \"^\" and end with \"\\n\". It defaults to 2 |
| 171 | either insert a new checkbox with \\[org-insert-todo-heading] or | 193 | blank lines. `org-empty-line-terminates-plain-lists' has |
| 172 | toggle a checkbox with \\[org-ctrl-c-ctrl-c]." | 194 | precedence over it." |
| 173 | :group 'org-plain-lists | 195 | :group 'org-plain-lists |
| 174 | :type 'boolean) | 196 | :type 'string) |
| 197 | |||
| 198 | (defcustom org-list-automatic-rules '((bullet . t) | ||
| 199 | (checkbox . t) | ||
| 200 | (indent . t) | ||
| 201 | (insert . t)) | ||
| 202 | "Non-nil means apply set of rules when acting on lists. | ||
| 203 | By default, automatic actions are taken when using | ||
| 204 | \\[org-meta-return], \\[org-metaright], \\[org-metaleft], | ||
| 205 | \\[org-shiftmetaright], \\[org-shiftmetaleft], | ||
| 206 | \\[org-ctrl-c-minus], \\[org-toggle-checkbox] or | ||
| 207 | \\[org-insert-todo-heading]. You can disable individually these | ||
| 208 | rules by setting them to nil. Valid rules are: | ||
| 209 | |||
| 210 | bullet when non-nil, cycling bullet do not allow lists at | ||
| 211 | column 0 to have * as a bullet and descriptions lists | ||
| 212 | to be numbered. | ||
| 213 | checkbox when non-nil, checkbox statistics is updated each time | ||
| 214 | you either insert a new checkbox or toggle a checkbox. | ||
| 215 | It also prevents from inserting a checkbox in a | ||
| 216 | description item. | ||
| 217 | indent when non-nil, indenting or outdenting list top-item | ||
| 218 | with its subtree will move the whole list and | ||
| 219 | outdenting a list whose bullet is * to column 0 will | ||
| 220 | change that bullet to - | ||
| 221 | insert when non-nil, trying to insert an item inside a block | ||
| 222 | will insert it right before the block instead of | ||
| 223 | throwing an error." | ||
| 224 | :group 'org-plain-lists | ||
| 225 | :type '(alist :tag "Sets of rules" | ||
| 226 | :key-type | ||
| 227 | (choice | ||
| 228 | (const :tag "Bullet" bullet) | ||
| 229 | (const :tag "Checkbox" checkbox) | ||
| 230 | (const :tag "Indent" indent) | ||
| 231 | (const :tag "Insert" insert)) | ||
| 232 | :value-type | ||
| 233 | (boolean :tag "Activate" :value t))) | ||
| 175 | 234 | ||
| 176 | (defcustom org-hierarchical-checkbox-statistics t | 235 | (defcustom org-hierarchical-checkbox-statistics t |
| 177 | "Non-nil means checkbox statistics counts only the state of direct children. | 236 | "Non-nil means checkbox statistics counts only the state of direct children. |
| @@ -188,9 +247,6 @@ When the indentation would be larger than this, it will become | |||
| 188 | :group 'org-plain-lists | 247 | :group 'org-plain-lists |
| 189 | :type 'integer) | 248 | :type 'integer) |
| 190 | 249 | ||
| 191 | (defvar org-list-beginning-re | ||
| 192 | "^\\([ \t]*\\)\\([-+]\\|[0-9]+[.)]\\) +\\(.*\\)$") | ||
| 193 | |||
| 194 | (defcustom org-list-radio-list-templates | 250 | (defcustom org-list-radio-list-templates |
| 195 | '((latex-mode "% BEGIN RECEIVE ORGLST %n | 251 | '((latex-mode "% BEGIN RECEIVE ORGLST %n |
| 196 | % END RECEIVE ORGLST %n | 252 | % END RECEIVE ORGLST %n |
| @@ -218,9 +274,14 @@ list, obtained by prompting the user." | |||
| 218 | (list (symbol :tag "Major mode") | 274 | (list (symbol :tag "Major mode") |
| 219 | (string :tag "Format")))) | 275 | (string :tag "Format")))) |
| 220 | 276 | ||
| 221 | ;;;; Plain list items, including checkboxes | 277 | ;;; Internal functions |
| 222 | 278 | ||
| 223 | ;;; Plain list items | 279 | (defun org-list-end-re () |
| 280 | "Return the regex corresponding to the end of a list. | ||
| 281 | It depends on `org-empty-line-terminates-plain-lists'." | ||
| 282 | (if org-empty-line-terminates-plain-lists | ||
| 283 | "^[ \t]*\n" | ||
| 284 | org-list-end-regexp)) | ||
| 224 | 285 | ||
| 225 | (defun org-item-re (&optional general) | 286 | (defun org-item-re (&optional general) |
| 226 | "Return the correct regular expression for plain lists. | 287 | "Return the correct regular expression for plain lists. |
| @@ -228,19 +289,526 @@ If GENERAL is non-nil, return the general regexp independent of the value | |||
| 228 | of `org-plain-list-ordered-item-terminator'." | 289 | of `org-plain-list-ordered-item-terminator'." |
| 229 | (cond | 290 | (cond |
| 230 | ((or general (eq org-plain-list-ordered-item-terminator t)) | 291 | ((or general (eq org-plain-list-ordered-item-terminator t)) |
| 231 | "\\([ \t]*\\([-+]\\|\\([0-9]+[.)]\\)\\)\\|[ \t]+\\*\\)\\( \\|$\\)") | 292 | "\\([ \t]*\\([-+]\\|\\([0-9]+[.)]\\)\\)\\|[ \t]+\\*\\)\\([ \t]+\\|$\\)") |
| 232 | ((= org-plain-list-ordered-item-terminator ?.) | 293 | ((= org-plain-list-ordered-item-terminator ?.) |
| 233 | "\\([ \t]*\\([-+]\\|\\([0-9]+\\.\\)\\)\\|[ \t]+\\*\\)\\( \\|$\\)") | 294 | "\\([ \t]*\\([-+]\\|\\([0-9]+\\.\\)\\)\\|[ \t]+\\*\\)\\([ \t]+\\|$\\)") |
| 234 | ((= org-plain-list-ordered-item-terminator ?\)) | 295 | ((= org-plain-list-ordered-item-terminator ?\)) |
| 235 | "\\([ \t]*\\([-+]\\|\\([0-9]+)\\)\\)\\|[ \t]+\\*\\)\\( \\|$\\)") | 296 | "\\([ \t]*\\([-+]\\|\\([0-9]+)\\)\\)\\|[ \t]+\\*\\)\\([ \t]+\\|$\\)") |
| 236 | (t (error "Invalid value of `org-plain-list-ordered-item-terminator'")))) | 297 | (t (error "Invalid value of `org-plain-list-ordered-item-terminator'")))) |
| 237 | 298 | ||
| 299 | (defconst org-item-beginning-re (concat "^" (org-item-re)) | ||
| 300 | "Regexp matching the beginning of a plain list item.") | ||
| 301 | |||
| 302 | (defun org-list-ending-between (min max &optional firstp) | ||
| 303 | "Find the position of a list ending between MIN and MAX, or nil. | ||
| 304 | This function looks for `org-list-end-re' outside a block. | ||
| 305 | |||
| 306 | If FIRSTP in non-nil, return the point at the beginning of the | ||
| 307 | nearest valid terminator from MIN. Otherwise, return the point at | ||
| 308 | the end of the nearest terminator from MAX." | ||
| 309 | (save-excursion | ||
| 310 | (let* ((start (if firstp min max)) | ||
| 311 | (end (if firstp max min)) | ||
| 312 | (search-fun (if firstp | ||
| 313 | #'org-search-forward-unenclosed | ||
| 314 | #'org-search-backward-unenclosed)) | ||
| 315 | (list-end-p (progn | ||
| 316 | (goto-char start) | ||
| 317 | (funcall search-fun (org-list-end-re) end t)))) | ||
| 318 | ;; Is there a valid list ending somewhere ? | ||
| 319 | (and list-end-p | ||
| 320 | ;; we want to be on the first line of the list ender | ||
| 321 | (match-beginning 0))))) | ||
| 322 | |||
| 323 | (defun org-list-maybe-skip-block (search limit) | ||
| 324 | "Return non-nil value if point is in a block, skipping it on the way. | ||
| 325 | It looks for the boundary of the block in SEARCH direction, | ||
| 326 | stopping at LIMIT." | ||
| 327 | (save-match-data | ||
| 328 | (let ((case-fold-search t) | ||
| 329 | (boundary (if (eq search 're-search-forward) 3 5))) | ||
| 330 | (when (save-excursion | ||
| 331 | (and (funcall search "^[ \t]*#\\+\\(begin\\|end\\)_" limit t) | ||
| 332 | (= (length (match-string 1)) boundary))) | ||
| 333 | ;; We're in a block: get out of it | ||
| 334 | (goto-char (match-beginning 0)))))) | ||
| 335 | |||
| 336 | (defun org-list-search-unenclosed-generic (search re bound noerr) | ||
| 337 | "Search a string outside blocks and protected places. | ||
| 338 | Arguments SEARCH, RE, BOUND and NOERR are similar to those in | ||
| 339 | `search-forward', `search-backward', `re-search-forward' and | ||
| 340 | `re-search-backward'." | ||
| 341 | (catch 'exit | ||
| 342 | (let ((origin (point))) | ||
| 343 | (while t | ||
| 344 | ;; 1. No match: return to origin or bound, depending on NOERR. | ||
| 345 | (unless (funcall search re bound noerr) | ||
| 346 | (throw 'exit (and (goto-char (if (memq noerr '(t nil)) origin bound)) | ||
| 347 | nil))) | ||
| 348 | ;; 2. Match not in block or protected: return point. Else | ||
| 349 | ;; skip the block and carry on. | ||
| 350 | (unless (or (get-text-property (match-beginning 0) 'org-protected) | ||
| 351 | (org-list-maybe-skip-block search bound)) | ||
| 352 | (throw 'exit (point))))))) | ||
| 353 | |||
| 354 | (defun org-search-backward-unenclosed (regexp &optional bound noerror) | ||
| 355 | "Like `re-search-backward' but don't stop inside blocks or protected places. | ||
| 356 | Arguments REGEXP, BOUND and NOERROR are similar to those used in | ||
| 357 | `re-search-backward'." | ||
| 358 | (org-list-search-unenclosed-generic | ||
| 359 | #'re-search-backward regexp (or bound (point-min)) noerror)) | ||
| 360 | |||
| 361 | (defun org-search-forward-unenclosed (regexp &optional bound noerror) | ||
| 362 | "Like `re-search-forward' but don't stop inside blocks or protected places. | ||
| 363 | Arguments REGEXP, BOUND and NOERROR are similar to those used in | ||
| 364 | `re-search-forward'." | ||
| 365 | (org-list-search-unenclosed-generic | ||
| 366 | #'re-search-forward regexp (or bound (point-max)) noerror)) | ||
| 367 | |||
| 368 | (defun org-list-in-item-p-with-indent (limit) | ||
| 369 | "Is the cursor inside a plain list? | ||
| 370 | Plain lists are considered ending when a non-blank line is less | ||
| 371 | indented than the previous item within LIMIT." | ||
| 372 | (save-excursion | ||
| 373 | (beginning-of-line) | ||
| 374 | (cond | ||
| 375 | ;; do not start searching inside a block... | ||
| 376 | ((org-list-maybe-skip-block #'re-search-backward limit)) | ||
| 377 | ;; ... or at a blank line | ||
| 378 | ((looking-at "^[ \t]*$") | ||
| 379 | (skip-chars-backward " \r\t\n") | ||
| 380 | (beginning-of-line))) | ||
| 381 | (beginning-of-line) | ||
| 382 | (or (org-at-item-p) | ||
| 383 | (let* ((case-fold-search t) | ||
| 384 | (ind-ref (org-get-indentation)) | ||
| 385 | ;; Ensure there is at least an item above | ||
| 386 | (up-item-p (save-excursion | ||
| 387 | (org-search-backward-unenclosed | ||
| 388 | org-item-beginning-re limit t)))) | ||
| 389 | (and up-item-p | ||
| 390 | (catch 'exit | ||
| 391 | (while t | ||
| 392 | (cond | ||
| 393 | ((org-at-item-p) | ||
| 394 | (throw 'exit (< (org-get-indentation) ind-ref))) | ||
| 395 | ((looking-at "^[ \t]*$") | ||
| 396 | (skip-chars-backward " \r\t\n") | ||
| 397 | (beginning-of-line)) | ||
| 398 | ((looking-at "^[ \t]*#\\+end_") | ||
| 399 | (re-search-backward "^[ \t]*#\\+begin_")) | ||
| 400 | (t | ||
| 401 | (setq ind-ref (min (org-get-indentation) ind-ref)) | ||
| 402 | (forward-line -1)))))))))) | ||
| 403 | |||
| 404 | (defun org-list-in-item-p-with-regexp (limit) | ||
| 405 | "Is the cursor inside a plain list? | ||
| 406 | Plain lists end when `org-list-end-regexp' is matched, or at a | ||
| 407 | blank line if `org-empty-line-terminates-plain-lists' is true. | ||
| 408 | |||
| 409 | Argument LIMIT specifies the upper-bound of the search." | ||
| 410 | (save-excursion | ||
| 411 | (let* ((actual-pos (goto-char (point-at-eol))) | ||
| 412 | ;; Moved to eol so current line can be matched by | ||
| 413 | ;; `org-item-re'. | ||
| 414 | (last-item-start (save-excursion | ||
| 415 | (org-search-backward-unenclosed | ||
| 416 | org-item-beginning-re limit t))) | ||
| 417 | (list-ender (org-list-ending-between | ||
| 418 | last-item-start actual-pos))) | ||
| 419 | ;; We are in a list when we are on an item line or when we can | ||
| 420 | ;; find an item before point and there is no valid list ender | ||
| 421 | ;; between it and the point. | ||
| 422 | (and last-item-start (not list-ender))))) | ||
| 423 | |||
| 424 | (defun org-list-top-point-with-regexp (limit) | ||
| 425 | "Return point at the top level item in a list. | ||
| 426 | Argument LIMIT specifies the upper-bound of the search. | ||
| 427 | |||
| 428 | List ending is determined by regexp. See | ||
| 429 | `org-list-ending-method'. for more information." | ||
| 430 | (save-excursion | ||
| 431 | (let ((pos (point-at-eol))) | ||
| 432 | ;; Is there some list above this one ? If so, go to its ending. | ||
| 433 | ;; Otherwise, go back to the heading above or bob. | ||
| 434 | (goto-char (or (org-list-ending-between limit pos) limit)) | ||
| 435 | ;; From there, search down our list. | ||
| 436 | (org-search-forward-unenclosed org-item-beginning-re pos t) | ||
| 437 | (point-at-bol)))) | ||
| 438 | |||
| 439 | (defun org-list-bottom-point-with-regexp (limit) | ||
| 440 | "Return point just before list ending. | ||
| 441 | Argument LIMIT specifies the lower-bound of the search. | ||
| 442 | |||
| 443 | List ending is determined by regexp. See | ||
| 444 | `org-list-ending-method'. for more information." | ||
| 445 | (save-excursion | ||
| 446 | (let ((pos (org-get-item-beginning))) | ||
| 447 | ;; The list ending is either first point matching | ||
| 448 | ;; `org-list-end-re', point at first white-line before next | ||
| 449 | ;; heading, or eob. | ||
| 450 | (or (org-list-ending-between (min pos limit) limit t) limit)))) | ||
| 451 | |||
| 452 | (defun org-list-top-point-with-indent (limit) | ||
| 453 | "Return point at the top level in a list. | ||
| 454 | Argument LIMIT specifies the upper-bound of the search. | ||
| 455 | |||
| 456 | List ending is determined by indentation of text. See | ||
| 457 | `org-list-ending-method'. for more information." | ||
| 458 | (save-excursion | ||
| 459 | (let ((case-fold-search t)) | ||
| 460 | (let ((item-ref (goto-char (org-get-item-beginning))) | ||
| 461 | (ind-ref 10000)) | ||
| 462 | (forward-line -1) | ||
| 463 | (catch 'exit | ||
| 464 | (while t | ||
| 465 | (let ((ind (org-get-indentation))) | ||
| 466 | (cond | ||
| 467 | ((looking-at "^[ \t]*:END:") | ||
| 468 | (throw 'exit item-ref)) | ||
| 469 | ((<= (point) limit) | ||
| 470 | (throw 'exit | ||
| 471 | (if (and (org-at-item-p) (< ind ind-ref)) | ||
| 472 | (point-at-bol) | ||
| 473 | item-ref))) | ||
| 474 | ((looking-at "^[ \t]*$") | ||
| 475 | (skip-chars-backward " \r\t\n") | ||
| 476 | (beginning-of-line)) | ||
| 477 | ((looking-at "^[ \t]*#\\+end_") | ||
| 478 | (re-search-backward "^[ \t]*#\\+begin_")) | ||
| 479 | ((not (org-at-item-p)) | ||
| 480 | (setq ind-ref (min ind ind-ref)) | ||
| 481 | (forward-line -1)) | ||
| 482 | ((>= ind ind-ref) | ||
| 483 | (throw 'exit item-ref)) | ||
| 484 | (t | ||
| 485 | (setq item-ref (point-at-bol) ind-ref 10000) | ||
| 486 | (forward-line -1)))))))))) | ||
| 487 | |||
| 488 | (defun org-list-bottom-point-with-indent (limit) | ||
| 489 | "Return point just before list ending or nil if not in a list. | ||
| 490 | Argument LIMIT specifies the lower-bound of the search. | ||
| 491 | |||
| 492 | List ending is determined by the indentation of text. See | ||
| 493 | `org-list-ending-method' for more information." | ||
| 494 | (save-excursion | ||
| 495 | (let ((ind-ref (progn | ||
| 496 | (goto-char (org-get-item-beginning)) | ||
| 497 | (org-get-indentation))) | ||
| 498 | (case-fold-search t)) | ||
| 499 | ;; do not start inside a block | ||
| 500 | (org-list-maybe-skip-block #'re-search-forward limit) | ||
| 501 | (beginning-of-line) | ||
| 502 | (catch 'exit | ||
| 503 | (while t | ||
| 504 | (skip-chars-forward " \t") | ||
| 505 | (let ((ind (org-get-indentation))) | ||
| 506 | (cond | ||
| 507 | ((or (>= (point) limit) | ||
| 508 | (looking-at ":END:")) | ||
| 509 | (throw 'exit (progn | ||
| 510 | ;; Ensure bottom is just after a | ||
| 511 | ;; non-blank line. | ||
| 512 | (skip-chars-backward " \r\t\n") | ||
| 513 | (min (point-max) (1+ (point-at-eol)))))) | ||
| 514 | ((= (point) (point-at-eol)) | ||
| 515 | (skip-chars-forward " \r\t\n") | ||
| 516 | (beginning-of-line)) | ||
| 517 | ((org-at-item-p) | ||
| 518 | (setq ind-ref ind) | ||
| 519 | (forward-line 1)) | ||
| 520 | ((<= ind ind-ref) | ||
| 521 | (throw 'exit (point-at-bol))) | ||
| 522 | ((looking-at "#\\+begin_") | ||
| 523 | (re-search-forward "[ \t]*#\\+end_") | ||
| 524 | (forward-line 1)) | ||
| 525 | (t (forward-line 1))))))))) | ||
| 526 | |||
| 527 | (defun org-list-at-regexp-after-bullet-p (regexp) | ||
| 528 | "Is point at a list item with REGEXP after bullet?" | ||
| 529 | (and (org-at-item-p) | ||
| 530 | (save-excursion | ||
| 531 | (goto-char (match-end 0)) | ||
| 532 | ;; Ignore counter if any | ||
| 533 | (when (looking-at "\\(?:\\[@\\(?:start:\\)?[0-9]+\\][ \t]*\\)?") | ||
| 534 | (goto-char (match-end 0))) | ||
| 535 | (looking-at regexp)))) | ||
| 536 | |||
| 537 | (defun org-list-get-item-same-level (search-fun pos limit pre-move) | ||
| 538 | "Return point at the beginning of next item at the same level. | ||
| 539 | Search items using function SEARCH-FUN, from POS to LIMIT. It | ||
| 540 | uses PRE-MOVE before search. Return nil if no item was found." | ||
| 541 | (save-excursion | ||
| 542 | (goto-char pos) | ||
| 543 | (let* ((start (org-get-item-beginning)) | ||
| 544 | (ind (progn (goto-char start) (org-get-indentation)))) | ||
| 545 | ;; We don't want to match the current line. | ||
| 546 | (funcall pre-move) | ||
| 547 | ;; Skip any sublist on the way | ||
| 548 | (while (and (funcall search-fun org-item-beginning-re limit t) | ||
| 549 | (> (org-get-indentation) ind))) | ||
| 550 | (when (and (/= (point-at-bol) start) ; Have we moved ? | ||
| 551 | (= (org-get-indentation) ind)) | ||
| 552 | (point-at-bol))))) | ||
| 553 | |||
| 554 | (defun org-list-separating-blank-lines-number (pos top bottom) | ||
| 555 | "Return number of blank lines that should separate items in list. | ||
| 556 | POS is the position of point to be considered. | ||
| 557 | |||
| 558 | TOP and BOTTOM are respectively position of list beginning and | ||
| 559 | list ending. | ||
| 560 | |||
| 561 | Assume point is at item's beginning. If the item is alone, apply | ||
| 562 | some heuristics to guess the result." | ||
| 563 | (save-excursion | ||
| 564 | (let ((insert-blank-p | ||
| 565 | (cdr (assq 'plain-list-item org-blank-before-new-entry))) | ||
| 566 | usr-blank) | ||
| 567 | (cond | ||
| 568 | ;; Trivial cases where there should be none. | ||
| 569 | ((or (and (not (eq org-list-ending-method 'indent)) | ||
| 570 | org-empty-line-terminates-plain-lists) | ||
| 571 | (not insert-blank-p)) 0) | ||
| 572 | ;; When `org-blank-before-new-entry' says so, it is 1. | ||
| 573 | ((eq insert-blank-p t) 1) | ||
| 574 | ;; plain-list-item is 'auto. Count blank lines separating | ||
| 575 | ;; neighbours items in list. | ||
| 576 | (t (let ((next-p (org-get-next-item (point) bottom))) | ||
| 577 | (cond | ||
| 578 | ;; Is there a next item? | ||
| 579 | (next-p (goto-char next-p) | ||
| 580 | (org-back-over-empty-lines)) | ||
| 581 | ;; Is there a previous item? | ||
| 582 | ((org-get-previous-item (point) top) | ||
| 583 | (org-back-over-empty-lines)) | ||
| 584 | ;; User inserted blank lines, trust him | ||
| 585 | ((and (> pos (org-end-of-item-before-blank bottom)) | ||
| 586 | (> (save-excursion | ||
| 587 | (goto-char pos) | ||
| 588 | (skip-chars-backward " \t") | ||
| 589 | (setq usr-blank (org-back-over-empty-lines))) 0)) | ||
| 590 | usr-blank) | ||
| 591 | ;; Are there blank lines inside the item ? | ||
| 592 | ((save-excursion | ||
| 593 | (org-search-forward-unenclosed | ||
| 594 | "^[ \t]*$" (org-end-of-item-before-blank bottom) t)) 1) | ||
| 595 | ;; No parent: no blank line. | ||
| 596 | (t 0)))))))) | ||
| 597 | |||
| 598 | (defun org-list-insert-item-generic (pos &optional checkbox after-bullet) | ||
| 599 | "Insert a new list item at POS. | ||
| 600 | If POS is before first character after bullet of the item, the | ||
| 601 | new item will be created before the current one. | ||
| 602 | |||
| 603 | Insert a checkbox if CHECKBOX is non-nil, and string AFTER-BULLET | ||
| 604 | after the bullet. Cursor will be after this text once the | ||
| 605 | function ends." | ||
| 606 | (goto-char pos) | ||
| 607 | ;; Is point in a special block? | ||
| 608 | (when (org-in-regexps-block-p | ||
| 609 | "^[ \t]*#\\+\\(begin\\|BEGIN\\)_\\([a-zA-Z0-9_]+\\)" | ||
| 610 | '(concat "^[ \t]*#\\+\\(end\\|END\\)_" (match-string 2))) | ||
| 611 | (if (not (cdr (assq 'insert org-list-automatic-rules))) | ||
| 612 | ;; Rule in `org-list-automatic-rules' forbids insertion. | ||
| 613 | (error "Cannot insert item inside a block") | ||
| 614 | ;; Else, move before it prior to add a new item. | ||
| 615 | (end-of-line) | ||
| 616 | (re-search-backward "^[ \t]*#\\+\\(begin\\|BEGIN\\)_" nil t) | ||
| 617 | (end-of-line 0))) | ||
| 618 | (let* ((true-pos (point)) | ||
| 619 | (top (org-list-top-point)) | ||
| 620 | (bottom (copy-marker (org-list-bottom-point))) | ||
| 621 | (bullet (and (goto-char (org-get-item-beginning)) | ||
| 622 | (org-list-bullet-string (org-get-bullet)))) | ||
| 623 | (ind (org-get-indentation)) | ||
| 624 | (before-p (progn | ||
| 625 | ;; Description item: text starts after colons. | ||
| 626 | (or (org-at-item-description-p) | ||
| 627 | ;; At a checkbox: text starts after it. | ||
| 628 | (org-at-item-checkbox-p) | ||
| 629 | ;; Otherwise, text starts after bullet. | ||
| 630 | (org-at-item-p)) | ||
| 631 | (<= true-pos (match-end 0)))) | ||
| 632 | (blank-lines-nb (org-list-separating-blank-lines-number | ||
| 633 | true-pos top bottom)) | ||
| 634 | (insert-fun | ||
| 635 | (lambda (text) | ||
| 636 | ;; insert bullet above item in order to avoid bothering | ||
| 637 | ;; with possible blank lines ending last item. | ||
| 638 | (goto-char (org-get-item-beginning)) | ||
| 639 | (indent-to-column ind) | ||
| 640 | (insert (concat bullet (when checkbox "[ ] ") after-bullet)) | ||
| 641 | ;; Stay between after-bullet and before text. | ||
| 642 | (save-excursion | ||
| 643 | (insert (concat text (make-string (1+ blank-lines-nb) ?\n)))) | ||
| 644 | (unless before-p | ||
| 645 | ;; store bottom: exchanging items doesn't change list | ||
| 646 | ;; bottom point but will modify marker anyway | ||
| 647 | (setq bottom (marker-position bottom)) | ||
| 648 | (let ((col (current-column))) | ||
| 649 | (org-list-exchange-items | ||
| 650 | (org-get-item-beginning) (org-get-next-item (point) bottom) | ||
| 651 | bottom) | ||
| 652 | ;; recompute next-item: last sexp modified list | ||
| 653 | (goto-char (org-get-next-item (point) bottom)) | ||
| 654 | (org-move-to-column col))) | ||
| 655 | ;; checkbox update might modify bottom point, so use a | ||
| 656 | ;; marker here | ||
| 657 | (setq bottom (copy-marker bottom)) | ||
| 658 | (when checkbox (org-update-checkbox-count-maybe)) | ||
| 659 | (org-list-repair nil top bottom)))) | ||
| 660 | (goto-char true-pos) | ||
| 661 | (cond | ||
| 662 | (before-p (funcall insert-fun nil) t) | ||
| 663 | ;; Can't split item: insert bullet at the end of item. | ||
| 664 | ((not (org-get-alist-option org-M-RET-may-split-line 'item)) | ||
| 665 | (funcall insert-fun nil) t) | ||
| 666 | ;; else, insert a new bullet along with everything from point | ||
| 667 | ;; down to last non-blank line of item. | ||
| 668 | (t | ||
| 669 | (delete-horizontal-space) | ||
| 670 | ;; Get pos again in case previous command modified line. | ||
| 671 | (let* ((pos (point)) | ||
| 672 | (end-before-blank (org-end-of-item-before-blank bottom)) | ||
| 673 | (after-text | ||
| 674 | (when (< pos end-before-blank) | ||
| 675 | (prog1 | ||
| 676 | (delete-and-extract-region pos end-before-blank) | ||
| 677 | ;; delete any blank line at and before point. | ||
| 678 | (beginning-of-line) | ||
| 679 | (while (looking-at "^[ \t]*$") | ||
| 680 | (delete-region (point-at-bol) (1+ (point-at-eol))) | ||
| 681 | (beginning-of-line 0)))))) | ||
| 682 | (funcall insert-fun after-text) t))))) | ||
| 683 | |||
| 684 | (defvar org-last-indent-begin-marker (make-marker)) | ||
| 685 | (defvar org-last-indent-end-marker (make-marker)) | ||
| 686 | |||
| 687 | (defun org-list-indent-item-generic (arg no-subtree top bottom) | ||
| 688 | "Indent a local list item including its children. | ||
| 689 | When number ARG is a negative, item will be outdented, otherwise | ||
| 690 | it will be indented. | ||
| 691 | |||
| 692 | If a region is active, all items inside will be moved. | ||
| 693 | |||
| 694 | If NO-SUBTREE is non-nil, only indent the item itself, not its | ||
| 695 | children. | ||
| 696 | |||
| 697 | TOP and BOTTOM are respectively position at item beginning and at | ||
| 698 | item ending. | ||
| 699 | |||
| 700 | Return t if successful." | ||
| 701 | (let* ((regionp (org-region-active-p)) | ||
| 702 | (rbeg (and regionp (region-beginning))) | ||
| 703 | (rend (and regionp (region-end)))) | ||
| 704 | (cond | ||
| 705 | ((and regionp | ||
| 706 | (goto-char rbeg) | ||
| 707 | (not (org-search-forward-unenclosed org-item-beginning-re rend t))) | ||
| 708 | (error "No item in region")) | ||
| 709 | ((not (org-at-item-p)) | ||
| 710 | (error "Not on an item")) | ||
| 711 | (t | ||
| 712 | ;; Are we going to move the whole list? | ||
| 713 | (let* ((specialp (and (cdr (assq 'indent org-list-automatic-rules)) | ||
| 714 | (not no-subtree) | ||
| 715 | (= top (point-at-bol))))) | ||
| 716 | ;; Determine begin and end points of zone to indent. If moving | ||
| 717 | ;; more than one item, ensure we keep them on subsequent moves. | ||
| 718 | (unless (and (memq last-command '(org-shiftmetaright org-shiftmetaleft)) | ||
| 719 | (memq this-command '(org-shiftmetaright org-shiftmetaleft))) | ||
| 720 | (if regionp | ||
| 721 | (progn | ||
| 722 | (set-marker org-last-indent-begin-marker rbeg) | ||
| 723 | (set-marker org-last-indent-end-marker rend)) | ||
| 724 | (set-marker org-last-indent-begin-marker (point-at-bol)) | ||
| 725 | (set-marker org-last-indent-end-marker | ||
| 726 | (save-excursion | ||
| 727 | (cond | ||
| 728 | (specialp bottom) | ||
| 729 | (no-subtree (org-end-of-item-or-at-child bottom)) | ||
| 730 | (t (org-get-end-of-item bottom))))))) | ||
| 731 | ;; Get everything ready | ||
| 732 | (let* ((beg (marker-position org-last-indent-begin-marker)) | ||
| 733 | (end (marker-position org-last-indent-end-marker)) | ||
| 734 | (struct (org-list-struct | ||
| 735 | beg end top (if specialp end bottom) (< arg 0))) | ||
| 736 | (origins (org-list-struct-origins struct)) | ||
| 737 | (beg-item (assq beg struct))) | ||
| 738 | (cond | ||
| 739 | ;; Special case: moving top-item with indent rule | ||
| 740 | (specialp | ||
| 741 | (let* ((level-skip (org-level-increment)) | ||
| 742 | (offset (if (< arg 0) (- level-skip) level-skip)) | ||
| 743 | (top-ind (nth 1 beg-item))) | ||
| 744 | (if (< (+ top-ind offset) 0) | ||
| 745 | (error "Cannot outdent beyond margin") | ||
| 746 | ;; Change bullet if necessary | ||
| 747 | (when (and (= (+ top-ind offset) 0) | ||
| 748 | (string-match "*" (nth 2 beg-item))) | ||
| 749 | (setcdr beg-item (list (nth 1 beg-item) | ||
| 750 | (org-list-bullet-string "-")))) | ||
| 751 | ;; Shift ancestor | ||
| 752 | (let ((anc (car struct))) | ||
| 753 | (setcdr anc (list (+ (nth 1 anc) offset) "" nil))) | ||
| 754 | (org-list-struct-fix-struct struct origins) | ||
| 755 | (org-list-struct-apply-struct struct end)))) | ||
| 756 | ;; Forbidden move | ||
| 757 | ((and (< arg 0) | ||
| 758 | (or (and no-subtree | ||
| 759 | (not regionp) | ||
| 760 | (org-list-struct-get-child beg-item struct)) | ||
| 761 | (let ((last-item (save-excursion | ||
| 762 | (goto-char end) | ||
| 763 | (skip-chars-backward " \r\t\n") | ||
| 764 | (goto-char (org-get-item-beginning)) | ||
| 765 | (org-list-struct-assoc-at-point)))) | ||
| 766 | (org-list-struct-get-child last-item struct)))) | ||
| 767 | (error "Cannot outdent an item without its children")) | ||
| 768 | ;; Normal shifting | ||
| 769 | (t | ||
| 770 | (let* ((shifted-ori (if (< arg 0) | ||
| 771 | (org-list-struct-outdent beg end origins) | ||
| 772 | (org-list-struct-indent beg end origins struct)))) | ||
| 773 | (org-list-struct-fix-struct struct shifted-ori) | ||
| 774 | (org-list-struct-apply-struct struct bottom)))))))))) | ||
| 775 | |||
| 776 | ;;; Predicates | ||
| 777 | |||
| 778 | (defun org-in-item-p () | ||
| 779 | "Is the cursor inside a plain list? | ||
| 780 | This checks `org-list-ending-method'." | ||
| 781 | (unless (let ((outline-regexp org-outline-regexp)) (org-at-heading-p)) | ||
| 782 | (let* ((prev-head (save-excursion (outline-previous-heading))) | ||
| 783 | (bound (if prev-head | ||
| 784 | (or (save-excursion | ||
| 785 | (let ((case-fold-search t)) | ||
| 786 | (re-search-backward "^[ \t]*:END:" prev-head t))) | ||
| 787 | prev-head) | ||
| 788 | (point-min)))) | ||
| 789 | (cond | ||
| 790 | ((eq org-list-ending-method 'regexp) | ||
| 791 | (org-list-in-item-p-with-regexp bound)) | ||
| 792 | ((eq org-list-ending-method 'indent) | ||
| 793 | (org-list-in-item-p-with-indent bound)) | ||
| 794 | (t (and (org-list-in-item-p-with-regexp bound) | ||
| 795 | (org-list-in-item-p-with-indent bound))))))) | ||
| 796 | |||
| 797 | (defun org-list-first-item-p (top) | ||
| 798 | "Is this item the first item in a plain list? | ||
| 799 | Assume point is at an item. | ||
| 800 | |||
| 801 | TOP is the position of list's top-item." | ||
| 802 | (save-excursion | ||
| 803 | (beginning-of-line) | ||
| 804 | (let ((ind (org-get-indentation))) | ||
| 805 | (or (not (org-search-backward-unenclosed org-item-beginning-re top t)) | ||
| 806 | (< (org-get-indentation) ind))))) | ||
| 807 | |||
| 238 | (defun org-at-item-p () | 808 | (defun org-at-item-p () |
| 239 | "Is point in a line starting a hand-formatted item?" | 809 | "Is point in a line starting a hand-formatted item?" |
| 240 | |||
| 241 | (save-excursion | 810 | (save-excursion |
| 242 | (goto-char (point-at-bol)) | 811 | (beginning-of-line) (looking-at org-item-beginning-re))) |
| 243 | (looking-at (org-item-re)))) | ||
| 244 | 812 | ||
| 245 | (defun org-at-item-bullet-p () | 813 | (defun org-at-item-bullet-p () |
| 246 | "Is point at the bullet of a plain list item?" | 814 | "Is point at the bullet of a plain list item?" |
| @@ -248,170 +816,18 @@ of `org-plain-list-ordered-item-terminator'." | |||
| 248 | (not (member (char-after) '(?\ ?\t))) | 816 | (not (member (char-after) '(?\ ?\t))) |
| 249 | (< (point) (match-end 0)))) | 817 | (< (point) (match-end 0)))) |
| 250 | 818 | ||
| 251 | (defun org-in-item-p () | 819 | (defun org-at-item-timer-p () |
| 252 | "Is the cursor inside a plain list item. | 820 | "Is point at a line starting a plain list item with a timer?" |
| 253 | Does not have to be the first line." | 821 | (org-list-at-regexp-after-bullet-p |
| 254 | (save-excursion | 822 | "\\([0-9]+:[0-9]+:[0-9]+\\)[ \t]+::[ \t]+")) |
| 255 | (condition-case nil | ||
| 256 | (progn | ||
| 257 | (org-beginning-of-item) | ||
| 258 | (org-at-item-p) | ||
| 259 | t) | ||
| 260 | (error nil)))) | ||
| 261 | |||
| 262 | (defun org-insert-item (&optional checkbox) | ||
| 263 | "Insert a new item at the current level. | ||
| 264 | Return t when things worked, nil when we are not in an item." | ||
| 265 | (when (save-excursion | ||
| 266 | (condition-case nil | ||
| 267 | (progn | ||
| 268 | (org-beginning-of-item) | ||
| 269 | (org-at-item-p) | ||
| 270 | (if (org-invisible-p) (error "Invisible item")) | ||
| 271 | t) | ||
| 272 | (error nil))) | ||
| 273 | (let* ((bul (match-string 0)) | ||
| 274 | (descp (save-excursion (goto-char (match-beginning 0)) | ||
| 275 | (beginning-of-line 1) | ||
| 276 | (save-match-data | ||
| 277 | (and (looking-at "[ \t]*\\(.*?\\) ::") | ||
| 278 | (match-string 1))))) | ||
| 279 | (empty-line-p (save-excursion | ||
| 280 | (goto-char (match-beginning 0)) | ||
| 281 | (and (not (bobp)) | ||
| 282 | (or (beginning-of-line 0) t) | ||
| 283 | (save-match-data | ||
| 284 | (looking-at "[ \t]*$"))))) | ||
| 285 | (timerp (and descp | ||
| 286 | (save-match-data | ||
| 287 | (string-match "^[-+*][ \t]+[0-9]+:[0-9]+:[0-9]+$" | ||
| 288 | descp)))) | ||
| 289 | (eow (save-excursion (beginning-of-line 1) (looking-at "[ \t]*") | ||
| 290 | (match-end 0))) | ||
| 291 | (blank-a (if org-empty-line-terminates-plain-lists | ||
| 292 | nil | ||
| 293 | (cdr (assq 'plain-list-item org-blank-before-new-entry)))) | ||
| 294 | (blank (if (eq blank-a 'auto) empty-line-p blank-a)) | ||
| 295 | pos) | ||
| 296 | (if descp (setq checkbox nil)) | ||
| 297 | (if timerp | ||
| 298 | (progn (org-timer-item) t) | ||
| 299 | (cond | ||
| 300 | ((and (org-at-item-p) (<= (point) eow)) | ||
| 301 | ;; before the bullet | ||
| 302 | (beginning-of-line 1) | ||
| 303 | (open-line (if blank 2 1))) | ||
| 304 | ((<= (point) eow) | ||
| 305 | (beginning-of-line 1)) | ||
| 306 | (t | ||
| 307 | (unless (org-get-alist-option org-M-RET-may-split-line 'item) | ||
| 308 | (end-of-line 1) | ||
| 309 | (delete-horizontal-space)) | ||
| 310 | (newline (if blank 2 1)))) | ||
| 311 | (insert bul | ||
| 312 | (if checkbox "[ ]" "") | ||
| 313 | (if descp (concat (if checkbox " " "") | ||
| 314 | (read-string "Term: ") " :: ") "")) | ||
| 315 | (just-one-space) | ||
| 316 | (setq pos (point)) | ||
| 317 | (end-of-line 1) | ||
| 318 | (unless (= (point) pos) (just-one-space) (backward-delete-char 1))) | ||
| 319 | (org-maybe-renumber-ordered-list) | ||
| 320 | (and checkbox (org-update-checkbox-count-maybe)) | ||
| 321 | t))) | ||
| 322 | 823 | ||
| 323 | ;;; Checkboxes | 824 | (defun org-at-item-description-p () |
| 825 | "Is point at a description list item?" | ||
| 826 | (org-list-at-regexp-after-bullet-p "\\(\\S-.+\\)[ \t]+::[ \t]+")) | ||
| 324 | 827 | ||
| 325 | (defun org-at-item-checkbox-p () | 828 | (defun org-at-item-checkbox-p () |
| 326 | "Is point at a line starting a plain-list item with a checklet?" | 829 | "Is point at a line starting a plain-list item with a checklet?" |
| 327 | (and (org-at-item-p) | 830 | (org-list-at-regexp-after-bullet-p "\\(\\[[- X]\\]\\)[ \t]+")) |
| 328 | (save-excursion | ||
| 329 | (goto-char (match-end 0)) | ||
| 330 | (skip-chars-forward " \t") | ||
| 331 | (looking-at "\\[[- X]\\]")))) | ||
| 332 | |||
| 333 | (defun org-toggle-checkbox (&optional toggle-presence) | ||
| 334 | "Toggle the checkbox in the current line. | ||
| 335 | With prefix arg TOGGLE-PRESENCE, add or remove checkboxes. | ||
| 336 | With double prefix, set checkbox to [-]. | ||
| 337 | When there is an active region, toggle status or presence of the checkbox | ||
| 338 | in the first line, and make every item in the region have the same | ||
| 339 | status or presence, respectively. | ||
| 340 | If the cursor is in a headline, apply this to all checkbox items in the | ||
| 341 | text below the heading." | ||
| 342 | (interactive "P") | ||
| 343 | (catch 'exit | ||
| 344 | (let (beg end status first-present first-status blocked) | ||
| 345 | (cond | ||
| 346 | ((org-region-active-p) | ||
| 347 | (setq beg (region-beginning) end (region-end))) | ||
| 348 | ((org-on-heading-p) | ||
| 349 | (setq beg (point) end (save-excursion (outline-next-heading) (point)))) | ||
| 350 | ((org-at-item-checkbox-p) | ||
| 351 | (save-excursion | ||
| 352 | (if (equal toggle-presence '(4)) | ||
| 353 | (progn | ||
| 354 | (replace-match "") | ||
| 355 | (goto-char (match-beginning 0)) | ||
| 356 | (just-one-space)) | ||
| 357 | (when (setq blocked (org-checkbox-blocked-p)) | ||
| 358 | (error "Checkbox blocked because of unchecked box in line %d" | ||
| 359 | blocked)) | ||
| 360 | (replace-match | ||
| 361 | (cond ((equal toggle-presence '(16)) "[-]") | ||
| 362 | ((member (match-string 0) '("[ ]" "[-]")) "[X]") | ||
| 363 | (t "[ ]")) | ||
| 364 | t t))) | ||
| 365 | (throw 'exit t)) | ||
| 366 | ((org-at-item-p) | ||
| 367 | ;; add a checkbox | ||
| 368 | (save-excursion | ||
| 369 | (goto-char (match-end 0)) | ||
| 370 | (insert "[ ] ")) | ||
| 371 | (throw 'exit t)) | ||
| 372 | (t (error "Not at a checkbox or heading, and no active region"))) | ||
| 373 | (setq end (move-marker (make-marker) end)) | ||
| 374 | (save-excursion | ||
| 375 | (goto-char beg) | ||
| 376 | (setq first-present (org-at-item-checkbox-p) | ||
| 377 | first-status | ||
| 378 | (save-excursion | ||
| 379 | (and (re-search-forward "[ \t]\\(\\[[ X]\\]\\)" end t) | ||
| 380 | (equal (match-string 1) "[X]")))) | ||
| 381 | (while (< (point) end) | ||
| 382 | (if toggle-presence | ||
| 383 | (cond | ||
| 384 | ((and first-present (org-at-item-checkbox-p)) | ||
| 385 | (save-excursion | ||
| 386 | (replace-match "") | ||
| 387 | (goto-char (match-beginning 0)) | ||
| 388 | (just-one-space))) | ||
| 389 | ((and (not first-present) (not (org-at-item-checkbox-p)) | ||
| 390 | (org-at-item-p)) | ||
| 391 | (save-excursion | ||
| 392 | (goto-char (match-end 0)) | ||
| 393 | (insert "[ ] ")))) | ||
| 394 | (when (org-at-item-checkbox-p) | ||
| 395 | (setq status (equal (match-string 0) "[X]")) | ||
| 396 | (replace-match | ||
| 397 | (if first-status "[ ]" "[X]") t t))) | ||
| 398 | (beginning-of-line 2))))) | ||
| 399 | (org-update-checkbox-count-maybe)) | ||
| 400 | |||
| 401 | (defun org-reset-checkbox-state-subtree () | ||
| 402 | "Reset all checkboxes in an entry subtree." | ||
| 403 | (interactive "*") | ||
| 404 | (save-restriction | ||
| 405 | (save-excursion | ||
| 406 | (org-narrow-to-subtree) | ||
| 407 | (org-show-subtree) | ||
| 408 | (goto-char (point-min)) | ||
| 409 | (let ((end (point-max))) | ||
| 410 | (while (< (point) end) | ||
| 411 | (when (org-at-item-checkbox-p) | ||
| 412 | (replace-match "[ ]" t t)) | ||
| 413 | (beginning-of-line 2)))) | ||
| 414 | (org-update-checkbox-count-maybe))) | ||
| 415 | 831 | ||
| 416 | (defun org-checkbox-blocked-p () | 832 | (defun org-checkbox-blocked-p () |
| 417 | "Is the current checkbox blocked from for being checked now? | 833 | "Is the current checkbox blocked from for being checked now? |
| @@ -424,417 +840,621 @@ A checkbox is blocked if all of the following conditions are fulfilled: | |||
| 424 | (save-match-data | 840 | (save-match-data |
| 425 | (save-excursion | 841 | (save-excursion |
| 426 | (unless (org-at-item-checkbox-p) (throw 'exit nil)) | 842 | (unless (org-at-item-checkbox-p) (throw 'exit nil)) |
| 427 | (when (equal (match-string 0) "[X]") | 843 | (when (equal (match-string 1) "[X]") |
| 428 | ;; the box is already checked! | 844 | ;; the box is already checked! |
| 429 | (throw 'exit nil)) | 845 | (throw 'exit nil)) |
| 430 | (let ((end (point-at-bol))) | 846 | (let ((end (point-at-bol))) |
| 431 | (condition-case nil (org-back-to-heading t) | 847 | (condition-case nil (org-back-to-heading t) |
| 432 | (error (throw 'exit nil))) | 848 | (error (throw 'exit nil))) |
| 433 | (unless (org-entry-get nil "ORDERED") (throw 'exit nil)) | 849 | (unless (org-entry-get nil "ORDERED") (throw 'exit nil)) |
| 434 | (if (re-search-forward "^[ \t]*[-+*0-9.)] \\[[- ]\\]" end t) | 850 | (when (org-search-forward-unenclosed |
| 435 | (org-current-line) | 851 | "^[ \t]*[-+*0-9.)]+[ \t]+\\(\\[@\\(?:start:\\)?[0-9]+\\][ \t]*\\)?\\[[- ]\\]" end t) |
| 436 | nil)))))) | 852 | (org-current-line))))))) |
| 853 | |||
| 854 | ;;; Navigate | ||
| 855 | |||
| 856 | ;; Every interactive navigation function is derived from a | ||
| 857 | ;; non-interactive one, which doesn't move point, assumes point is | ||
| 858 | ;; already in a list and doesn't compute list boundaries. | ||
| 859 | |||
| 860 | ;; If you plan to use more than one org-list function is some code, | ||
| 861 | ;; you should therefore first check if point is in a list with | ||
| 862 | ;; `org-in-item-p' or `org-at-item-p', then compute list boundaries | ||
| 863 | ;; with `org-list-top-point' and `org-list-bottom-point', and make use | ||
| 864 | ;; of non-interactive forms. | ||
| 865 | |||
| 866 | (defun org-list-top-point () | ||
| 867 | "Return point at the top level in a list. | ||
| 868 | Assume point is in a list." | ||
| 869 | (let* ((prev-head (save-excursion (outline-previous-heading))) | ||
| 870 | (bound (if prev-head | ||
| 871 | (or (save-excursion | ||
| 872 | (let ((case-fold-search t)) | ||
| 873 | (re-search-backward "^[ \t]*:END:" prev-head t))) | ||
| 874 | prev-head) | ||
| 875 | (point-min)))) | ||
| 876 | (cond | ||
| 877 | ((eq org-list-ending-method 'regexp) | ||
| 878 | (org-list-top-point-with-regexp bound)) | ||
| 879 | ((eq org-list-ending-method 'indent) | ||
| 880 | (org-list-top-point-with-indent bound)) | ||
| 881 | (t (let ((top-re (org-list-top-point-with-regexp bound))) | ||
| 882 | (org-list-top-point-with-indent (or top-re bound))))))) | ||
| 883 | |||
| 884 | (defun org-list-bottom-point () | ||
| 885 | "Return point just before list ending. | ||
| 886 | Assume point is in a list." | ||
| 887 | (let* ((next-head (save-excursion | ||
| 888 | (and (let ((outline-regexp org-outline-regexp)) | ||
| 889 | ;; Use default regexp because folding | ||
| 890 | ;; changes OUTLINE-REGEXP. | ||
| 891 | (outline-next-heading))))) | ||
| 892 | (limit (or (save-excursion | ||
| 893 | (and (re-search-forward "^[ \t]*:END:" next-head t) | ||
| 894 | (point-at-bol))) | ||
| 895 | next-head | ||
| 896 | (point-max)))) | ||
| 897 | (cond | ||
| 898 | ((eq org-list-ending-method 'regexp) | ||
| 899 | (org-list-bottom-point-with-regexp limit)) | ||
| 900 | ((eq org-list-ending-method 'indent) | ||
| 901 | (org-list-bottom-point-with-indent limit)) | ||
| 902 | (t (let ((bottom-re (org-list-bottom-point-with-regexp limit))) | ||
| 903 | (org-list-bottom-point-with-indent (or bottom-re limit))))))) | ||
| 904 | |||
| 905 | (defun org-get-item-beginning () | ||
| 906 | "Return position of current item beginning." | ||
| 907 | (save-excursion | ||
| 908 | ;; possibly match current line | ||
| 909 | (end-of-line) | ||
| 910 | (org-search-backward-unenclosed org-item-beginning-re nil t) | ||
| 911 | (point-at-bol))) | ||
| 437 | 912 | ||
| 438 | (defvar org-checkbox-statistics-hook nil | 913 | (defun org-beginning-of-item () |
| 439 | "Hook that is run whenever Org thinks checkbox statistics should be updated. | 914 | "Go to the beginning of the current hand-formatted item. |
| 440 | This hook runs even if `org-provide-checkbox-statistics' is nil, to it can | 915 | If the cursor is not in an item, throw an error." |
| 441 | be used to implement alternative ways of collecting statistics information.") | 916 | (interactive) |
| 917 | (if (org-in-item-p) | ||
| 918 | (goto-char (org-get-item-beginning)) | ||
| 919 | (error "Not in an item"))) | ||
| 442 | 920 | ||
| 443 | (defun org-update-checkbox-count-maybe () | 921 | (defun org-get-beginning-of-list (top) |
| 444 | "Update checkbox statistics unless turned off by user." | 922 | "Return position of the first item of the current list or sublist. |
| 445 | (when org-provide-checkbox-statistics | 923 | TOP is the position at list beginning." |
| 446 | (org-update-checkbox-count)) | 924 | (save-excursion |
| 447 | (run-hooks 'org-checkbox-statistics-hook)) | 925 | (let (prev-p) |
| 926 | (while (setq prev-p (org-get-previous-item (point) top)) | ||
| 927 | (goto-char prev-p)) | ||
| 928 | (point-at-bol)))) | ||
| 448 | 929 | ||
| 449 | (defun org-update-checkbox-count (&optional all) | 930 | (defun org-beginning-of-item-list () |
| 450 | "Update the checkbox statistics in the current section. | 931 | "Go to the beginning item of the current list or sublist. |
| 451 | This will find all statistic cookies like [57%] and [6/12] and update them | 932 | Return an error if not in a list." |
| 452 | with the current numbers. With optional prefix argument ALL, do this for | 933 | (interactive) |
| 453 | the whole buffer." | 934 | (if (org-in-item-p) |
| 454 | (interactive "P") | 935 | (goto-char (org-get-beginning-of-list (org-list-top-point))) |
| 455 | (save-excursion | 936 | (error "Not in an item"))) |
| 456 | (let* ((buffer-invisibility-spec (org-inhibit-invisibility)) ; Emacs 21 | ||
| 457 | (beg (condition-case nil | ||
| 458 | (progn (org-back-to-heading) (point)) | ||
| 459 | (error (point-min)))) | ||
| 460 | (end (move-marker (make-marker) | ||
| 461 | (progn (outline-next-heading) (point)))) | ||
| 462 | (re "\\(\\(\\[[0-9]*%\\]\\)\\|\\(\\[[0-9]*/[0-9]*\\]\\)\\)") | ||
| 463 | (re-box "^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +\\(\\[[- X]\\]\\)") | ||
| 464 | (re-find (concat re "\\|" re-box)) | ||
| 465 | beg-cookie end-cookie is-percent c-on c-off lim new | ||
| 466 | eline curr-ind next-ind continue-from startsearch | ||
| 467 | (recursive | ||
| 468 | (or (not org-hierarchical-checkbox-statistics) | ||
| 469 | (string-match "\\<recursive\\>" | ||
| 470 | (or (ignore-errors | ||
| 471 | (org-entry-get nil "COOKIE_DATA")) | ||
| 472 | "")))) | ||
| 473 | (cstat 0) | ||
| 474 | ) | ||
| 475 | (when all | ||
| 476 | (goto-char (point-min)) | ||
| 477 | (outline-next-heading) | ||
| 478 | (setq beg (point) end (point-max))) | ||
| 479 | (goto-char end) | ||
| 480 | ;; find each statistics cookie | ||
| 481 | (while (and (re-search-backward re-find beg t) | ||
| 482 | (not (save-match-data | ||
| 483 | (and (org-on-heading-p) | ||
| 484 | (string-match "\\<todo\\>" | ||
| 485 | (downcase | ||
| 486 | (or (org-entry-get | ||
| 487 | nil "COOKIE_DATA") | ||
| 488 | ""))))))) | ||
| 489 | (setq beg-cookie (match-beginning 1) | ||
| 490 | end-cookie (match-end 1) | ||
| 491 | cstat (+ cstat (if end-cookie 1 0)) | ||
| 492 | startsearch (point-at-eol) | ||
| 493 | continue-from (match-beginning 0) | ||
| 494 | is-percent (match-beginning 2) | ||
| 495 | lim (cond | ||
| 496 | ((org-on-heading-p) (outline-next-heading) (point)) | ||
| 497 | ((org-at-item-p) (org-end-of-item) (point)) | ||
| 498 | (t nil)) | ||
| 499 | c-on 0 | ||
| 500 | c-off 0) | ||
| 501 | (when lim | ||
| 502 | ;; find first checkbox for this cookie and gather | ||
| 503 | ;; statistics from all that are at this indentation level | ||
| 504 | (goto-char startsearch) | ||
| 505 | (if (re-search-forward re-box lim t) | ||
| 506 | (progn | ||
| 507 | (org-beginning-of-item) | ||
| 508 | (setq curr-ind (org-get-indentation)) | ||
| 509 | (setq next-ind curr-ind) | ||
| 510 | (while (and (bolp) (org-at-item-p) | ||
| 511 | (if recursive | ||
| 512 | (<= curr-ind next-ind) | ||
| 513 | (= curr-ind next-ind))) | ||
| 514 | (save-excursion (end-of-line) (setq eline (point))) | ||
| 515 | (if (re-search-forward re-box eline t) | ||
| 516 | (if (member (match-string 2) '("[ ]" "[-]")) | ||
| 517 | (setq c-off (1+ c-off)) | ||
| 518 | (setq c-on (1+ c-on)))) | ||
| 519 | (if (not recursive) | ||
| 520 | (org-end-of-item) | ||
| 521 | (end-of-line) | ||
| 522 | (when (re-search-forward org-list-beginning-re lim t) | ||
| 523 | (beginning-of-line))) | ||
| 524 | (setq next-ind (org-get-indentation))))) | ||
| 525 | (goto-char continue-from) | ||
| 526 | ;; update cookie | ||
| 527 | (when end-cookie | ||
| 528 | (setq new (if is-percent | ||
| 529 | (format "[%d%%]" (/ (* 100 c-on) (max 1 (+ c-on c-off)))) | ||
| 530 | (format "[%d/%d]" c-on (+ c-on c-off)))) | ||
| 531 | (goto-char beg-cookie) | ||
| 532 | (insert new) | ||
| 533 | (delete-region (point) (+ (point) (- end-cookie beg-cookie)))) | ||
| 534 | ;; update items checkbox if it has one | ||
| 535 | (when (org-at-item-p) | ||
| 536 | (org-beginning-of-item) | ||
| 537 | (when (and (> (+ c-on c-off) 0) | ||
| 538 | (re-search-forward re-box (point-at-eol) t)) | ||
| 539 | (setq beg-cookie (match-beginning 2) | ||
| 540 | end-cookie (match-end 2)) | ||
| 541 | (delete-region beg-cookie end-cookie) | ||
| 542 | (goto-char beg-cookie) | ||
| 543 | (cond ((= c-off 0) (insert "[X]")) | ||
| 544 | ((= c-on 0) (insert "[ ]")) | ||
| 545 | (t (insert "[-]"))) | ||
| 546 | ))) | ||
| 547 | (goto-char continue-from)) | ||
| 548 | (when (interactive-p) | ||
| 549 | (message "Checkbox statistics updated %s (%d places)" | ||
| 550 | (if all "in entire file" "in current outline entry") cstat))))) | ||
| 551 | 937 | ||
| 552 | (defun org-get-checkbox-statistics-face () | 938 | (defun org-get-end-of-list (bottom) |
| 553 | "Select the face for checkbox statistics. | 939 | "Return position at the end of the current list or sublist. |
| 554 | The face will be `org-done' when all relevant boxes are checked. Otherwise | 940 | BOTTOM is the position at list ending." |
| 555 | it will be `org-todo'." | 941 | (save-excursion |
| 556 | (if (match-end 1) | 942 | (goto-char (org-get-item-beginning)) |
| 557 | (if (equal (match-string 1) "100%") | 943 | (let ((ind (org-get-indentation))) |
| 558 | 'org-checkbox-statistics-done | 944 | (while (and (/= (point) bottom) |
| 559 | 'org-checkbox-statistics-todo) | 945 | (>= (org-get-indentation) ind)) |
| 560 | (if (and (> (match-end 2) (match-beginning 2)) | 946 | (org-search-forward-unenclosed org-item-beginning-re bottom 'move)) |
| 561 | (equal (match-string 2) (match-string 3))) | 947 | (if (= (point) bottom) bottom (point-at-bol))))) |
| 562 | 'org-checkbox-statistics-done | ||
| 563 | 'org-checkbox-statistics-todo))) | ||
| 564 | 948 | ||
| 565 | (defun org-beginning-of-item () | 949 | (defun org-end-of-item-list () |
| 566 | "Go to the beginning of the current hand-formatted item. | 950 | "Go to the end of the current list or sublist. |
| 567 | If the cursor is not in an item, throw an error." | 951 | If the cursor in not in an item, throw an error." |
| 568 | (interactive) | 952 | (interactive) |
| 569 | (let ((pos (point)) | 953 | (if (org-in-item-p) |
| 570 | (limit (save-excursion | 954 | (goto-char (org-get-end-of-list (org-list-bottom-point))) |
| 571 | (condition-case nil | 955 | (error "Not in an item"))) |
| 572 | (progn | 956 | |
| 573 | (org-back-to-heading) | 957 | (defun org-get-end-of-item (bottom) |
| 574 | (beginning-of-line 2) (point)) | 958 | "Return position at the end of the current item. |
| 575 | (error (point-min))))) | 959 | BOTTOM is the position at list ending." |
| 576 | (ind-empty (if org-empty-line-terminates-plain-lists 0 10000)) | 960 | (or (org-get-next-item (point) bottom) |
| 577 | ind ind1) | 961 | (org-get-end-of-list bottom))) |
| 578 | (if (org-at-item-p) | ||
| 579 | (beginning-of-line 1) | ||
| 580 | (beginning-of-line 1) | ||
| 581 | (skip-chars-forward " \t") | ||
| 582 | (setq ind (current-column)) | ||
| 583 | (if (catch 'exit | ||
| 584 | (while t | ||
| 585 | (beginning-of-line 0) | ||
| 586 | (if (or (bobp) (< (point) limit)) (throw 'exit nil)) | ||
| 587 | |||
| 588 | (if (looking-at "[ \t]*$") | ||
| 589 | (setq ind1 ind-empty) | ||
| 590 | (skip-chars-forward " \t") | ||
| 591 | (setq ind1 (current-column))) | ||
| 592 | (if (< ind1 ind) | ||
| 593 | (progn (beginning-of-line 1) (throw 'exit (org-at-item-p)))))) | ||
| 594 | nil | ||
| 595 | (goto-char pos) | ||
| 596 | (error "Not in an item"))))) | ||
| 597 | 962 | ||
| 598 | (defun org-end-of-item () | 963 | (defun org-end-of-item () |
| 599 | "Go to the end of the current hand-formatted item. | 964 | "Go to the end of the current hand-formatted item. |
| 600 | If the cursor is not in an item, throw an error." | 965 | If the cursor is not in an item, throw an error." |
| 601 | (interactive) | 966 | (interactive) |
| 602 | (let* ((pos (point)) | 967 | (if (org-in-item-p) |
| 603 | ind1 | 968 | (goto-char (org-get-end-of-item (org-list-bottom-point))) |
| 604 | (ind-empty (if org-empty-line-terminates-plain-lists 0 10000)) | 969 | (error "Not in an item"))) |
| 605 | (limit (save-excursion (outline-next-heading) (point))) | 970 | |
| 606 | (ind (save-excursion | 971 | (defun org-end-of-item-or-at-child (bottom) |
| 607 | (org-beginning-of-item) | 972 | "Move to the end of the item, stops before the first child if any. |
| 608 | (skip-chars-forward " \t") | 973 | BOTTOM is the position at list ending." |
| 609 | (current-column))) | 974 | (end-of-line) |
| 610 | (end (catch 'exit | ||
| 611 | (while t | ||
| 612 | (beginning-of-line 2) | ||
| 613 | (if (eobp) (throw 'exit (point))) | ||
| 614 | (if (>= (point) limit) (throw 'exit (point-at-bol))) | ||
| 615 | (if (looking-at "[ \t]*$") | ||
| 616 | (setq ind1 ind-empty) | ||
| 617 | (skip-chars-forward " \t") | ||
| 618 | (setq ind1 (current-column))) | ||
| 619 | (if (<= ind1 ind) | ||
| 620 | (throw 'exit (point-at-bol))))))) | ||
| 621 | (if end | ||
| 622 | (goto-char end) | ||
| 623 | (goto-char pos) | ||
| 624 | (error "Not in an item")))) | ||
| 625 | |||
| 626 | (defun org-end-of-item-text-before-children () | ||
| 627 | "Move to the end of the item text, stops before the first child if any. | ||
| 628 | Assumes that the cursor is in the first line of an item." | ||
| 629 | (goto-char | 975 | (goto-char |
| 630 | (min (save-excursion (org-end-of-item) (point)) | 976 | (if (org-search-forward-unenclosed org-item-beginning-re bottom t) |
| 631 | (save-excursion | 977 | (point-at-bol) |
| 632 | (goto-char (point-at-eol)) | 978 | (org-get-end-of-item bottom)))) |
| 633 | (if (re-search-forward (concat "^" (org-item-re t)) nil 'move) | ||
| 634 | (match-beginning 0) | ||
| 635 | (point-max)))))) | ||
| 636 | 979 | ||
| 637 | (defun org-next-item () | 980 | (defun org-end-of-item-before-blank (bottom) |
| 638 | "Move to the beginning of the next item in the current plain list. | 981 | "Return point at end of item, before any blank line. |
| 639 | Error if not at a plain list, or if this is the last item in the list." | 982 | Point returned is at eol. |
| 640 | (interactive) | 983 | |
| 641 | (let (ind ind1 (pos (point))) | 984 | BOTTOM is the position at list ending." |
| 642 | (org-beginning-of-item) | 985 | (save-excursion |
| 643 | (setq ind (org-get-indentation)) | 986 | (goto-char (org-get-end-of-item bottom)) |
| 644 | (org-end-of-item) | 987 | (skip-chars-backward " \r\t\n") |
| 645 | (setq ind1 (org-get-indentation)) | 988 | (point-at-eol))) |
| 646 | (unless (and (org-at-item-p) (= ind ind1)) | 989 | |
| 647 | (goto-char pos) | 990 | (defun org-get-previous-item (pos limit) |
| 648 | (error "On last item")))) | 991 | "Return point of the previous item at the same level as POS. |
| 992 | Stop searching at LIMIT. Return nil if no item is found." | ||
| 993 | (org-list-get-item-same-level | ||
| 994 | #'org-search-backward-unenclosed pos limit #'beginning-of-line)) | ||
| 649 | 995 | ||
| 650 | (defun org-previous-item () | 996 | (defun org-previous-item () |
| 651 | "Move to the beginning of the previous item in the current plain list. | 997 | "Move to the beginning of the previous item. |
| 652 | Error if not at a plain list, or if this is the first item in the list." | 998 | Item is at the same level in the current plain list. Error if not |
| 999 | in a plain list, or if this is the first item in the list." | ||
| 653 | (interactive) | 1000 | (interactive) |
| 654 | (let (beg ind ind1 (pos (point))) | 1001 | (if (not (org-in-item-p)) |
| 655 | (org-beginning-of-item) | 1002 | (error "Not in an item") |
| 656 | (setq beg (point)) | 1003 | (let ((prev-p (org-get-previous-item (point) (org-list-top-point)))) |
| 657 | (setq ind (org-get-indentation)) | 1004 | (if prev-p (goto-char prev-p) (error "On first item"))))) |
| 658 | (goto-char beg) | 1005 | |
| 659 | (catch 'exit | 1006 | (defun org-get-next-item (pos limit) |
| 660 | (while t | 1007 | "Return point of the next item at the same level as POS. |
| 661 | (beginning-of-line 0) | 1008 | Stop searching at LIMIT. Return nil if no item is found." |
| 662 | (if (looking-at "[ \t]*$") | 1009 | (org-list-get-item-same-level |
| 663 | nil | 1010 | #'org-search-forward-unenclosed pos limit #'end-of-line)) |
| 664 | (if (<= (setq ind1 (org-get-indentation)) ind) | 1011 | |
| 665 | (throw 'exit t))) | 1012 | (defun org-next-item () |
| 666 | (if (bobp) (throw 'exit t)))) | 1013 | "Move to the beginning of the next item. |
| 667 | (condition-case nil | 1014 | Item is at the same level in the current plain list. Error if not |
| 668 | (if (or (not (org-at-item-p)) | 1015 | in a plain list, or if this is the last item in the list." |
| 669 | (< ind1 (1- ind))) | 1016 | (interactive) |
| 670 | (error "") | 1017 | (if (not (org-in-item-p)) |
| 671 | (org-beginning-of-item)) | 1018 | (error "Not in an item") |
| 672 | (error (goto-char pos) | 1019 | (let ((next-p (org-get-next-item (point) (org-list-bottom-point)))) |
| 673 | (error "On first item"))))) | 1020 | (if next-p (goto-char next-p) (error "On last item"))))) |
| 674 | 1021 | ||
| 675 | (defun org-first-list-item-p () | 1022 | ;;; Manipulate |
| 676 | "Is this heading the first item in a plain list?" | 1023 | |
| 677 | (unless (org-at-item-p) | 1024 | (defun org-list-exchange-items (beg-A beg-B bottom) |
| 678 | (error "Not at a plain list item")) | 1025 | "Swap item starting at BEG-A with item starting at BEG-B. |
| 1026 | Blank lines at the end of items are left in place. Assume BEG-A | ||
| 1027 | is lesser than BEG-B. | ||
| 1028 | |||
| 1029 | BOTTOM is the position at list ending." | ||
| 679 | (save-excursion | 1030 | (save-excursion |
| 680 | (org-beginning-of-item) | 1031 | (let* ((end-of-item-no-blank |
| 681 | (= (point) (save-excursion (org-beginning-of-item-list))))) | 1032 | (lambda (pos) |
| 1033 | (goto-char pos) | ||
| 1034 | (goto-char (org-end-of-item-before-blank bottom)))) | ||
| 1035 | (end-A-no-blank (funcall end-of-item-no-blank beg-A)) | ||
| 1036 | (end-B-no-blank (funcall end-of-item-no-blank beg-B)) | ||
| 1037 | (body-A (buffer-substring beg-A end-A-no-blank)) | ||
| 1038 | (body-B (buffer-substring beg-B end-B-no-blank)) | ||
| 1039 | (between-A-no-blank-and-B (buffer-substring end-A-no-blank beg-B))) | ||
| 1040 | (goto-char beg-A) | ||
| 1041 | (delete-region beg-A end-B-no-blank) | ||
| 1042 | (insert (concat body-B between-A-no-blank-and-B body-A))))) | ||
| 682 | 1043 | ||
| 683 | (defun org-move-item-down () | 1044 | (defun org-move-item-down () |
| 684 | "Move the plain list item at point down, i.e. swap with following item. | 1045 | "Move the plain list item at point down, i.e. swap with following item. |
| 685 | Subitems (items with larger indentation) are considered part of the item, | 1046 | Subitems (items with larger indentation) are considered part of the item, |
| 686 | so this really moves item trees." | 1047 | so this really moves item trees." |
| 687 | (interactive) | 1048 | (interactive) |
| 688 | (let ((col (current-column)) | 1049 | (if (not (org-at-item-p)) |
| 689 | (pos (point)) | 1050 | (error "Not at an item") |
| 690 | beg beg0 end end0 ind ind1 txt ne-end ne-beg) | 1051 | (let* ((pos (point)) |
| 691 | (org-beginning-of-item) | 1052 | (col (current-column)) |
| 692 | (setq beg0 (point)) | 1053 | (bottom (org-list-bottom-point)) |
| 693 | (save-excursion | 1054 | (actual-item (goto-char (org-get-item-beginning))) |
| 694 | (setq ne-beg (org-back-over-empty-lines)) | 1055 | (next-item (org-get-next-item (point) bottom))) |
| 695 | (setq beg (point))) | 1056 | (if (not next-item) |
| 696 | (goto-char beg0) | 1057 | (progn |
| 697 | (setq ind (org-get-indentation)) | 1058 | (goto-char pos) |
| 698 | (org-end-of-item) | 1059 | (error "Cannot move this item further down")) |
| 699 | (setq end0 (point)) | 1060 | (org-list-exchange-items actual-item next-item bottom) |
| 700 | (setq ind1 (org-get-indentation)) | 1061 | (org-list-repair nil nil bottom) |
| 701 | (setq ne-end (org-back-over-empty-lines)) | 1062 | (goto-char (org-get-next-item (point) bottom)) |
| 702 | (setq end (point)) | 1063 | (move-to-column col))))) |
| 703 | (goto-char beg0) | 1064 | |
| 704 | (when (and (org-first-list-item-p) (< ne-end ne-beg)) | 1065 | (defun org-move-item-up () |
| 705 | ;; include less whitespace | ||
| 706 | (save-excursion | ||
| 707 | (goto-char beg) | ||
| 708 | (forward-line (- ne-beg ne-end)) | ||
| 709 | (setq beg (point)))) | ||
| 710 | (goto-char end0) | ||
| 711 | (if (and (org-at-item-p) (= ind ind1)) | ||
| 712 | (progn | ||
| 713 | (org-end-of-item) | ||
| 714 | (org-back-over-empty-lines) | ||
| 715 | (setq txt (buffer-substring beg end)) | ||
| 716 | (save-excursion | ||
| 717 | (delete-region beg end)) | ||
| 718 | (setq pos (point)) | ||
| 719 | (insert txt) | ||
| 720 | (goto-char pos) (org-skip-whitespace) | ||
| 721 | (org-maybe-renumber-ordered-list) | ||
| 722 | (move-to-column col)) | ||
| 723 | (goto-char pos) | ||
| 724 | (move-to-column col) | ||
| 725 | (error "Cannot move this item further down")))) | ||
| 726 | |||
| 727 | (defun org-move-item-up (arg) | ||
| 728 | "Move the plain list item at point up, i.e. swap with previous item. | 1066 | "Move the plain list item at point up, i.e. swap with previous item. |
| 729 | Subitems (items with larger indentation) are considered part of the item, | 1067 | Subitems (items with larger indentation) are considered part of the item, |
| 730 | so this really moves item trees." | 1068 | so this really moves item trees." |
| 731 | (interactive "p") | ||
| 732 | (let ((col (current-column)) (pos (point)) | ||
| 733 | beg beg0 end ind ind1 txt | ||
| 734 | ne-beg ne-ins ins-end) | ||
| 735 | (org-beginning-of-item) | ||
| 736 | (setq beg0 (point)) | ||
| 737 | (setq ind (org-get-indentation)) | ||
| 738 | (save-excursion | ||
| 739 | (setq ne-beg (org-back-over-empty-lines)) | ||
| 740 | (setq beg (point))) | ||
| 741 | (goto-char beg0) | ||
| 742 | (org-end-of-item) | ||
| 743 | (org-back-over-empty-lines) | ||
| 744 | (setq end (point)) | ||
| 745 | (goto-char beg0) | ||
| 746 | (catch 'exit | ||
| 747 | (while t | ||
| 748 | (beginning-of-line 0) | ||
| 749 | (if (looking-at "[ \t]*$") | ||
| 750 | (if org-empty-line-terminates-plain-lists | ||
| 751 | (progn | ||
| 752 | (goto-char pos) | ||
| 753 | (error "Cannot move this item further up")) | ||
| 754 | nil) | ||
| 755 | (if (<= (setq ind1 (org-get-indentation)) ind) | ||
| 756 | (throw 'exit t))))) | ||
| 757 | (condition-case nil | ||
| 758 | (org-beginning-of-item) | ||
| 759 | (error (goto-char beg0) | ||
| 760 | (move-to-column col) | ||
| 761 | (error "Cannot move this item further up"))) | ||
| 762 | (setq ind1 (org-get-indentation)) | ||
| 763 | (if (and (org-at-item-p) (= ind ind1)) | ||
| 764 | (progn | ||
| 765 | (setq ne-ins (org-back-over-empty-lines)) | ||
| 766 | (setq txt (buffer-substring beg end)) | ||
| 767 | (save-excursion | ||
| 768 | (delete-region beg end)) | ||
| 769 | (setq pos (point)) | ||
| 770 | (insert txt) | ||
| 771 | (setq ins-end (point)) | ||
| 772 | (goto-char pos) (org-skip-whitespace) | ||
| 773 | |||
| 774 | (when (and (org-first-list-item-p) (> ne-ins ne-beg)) | ||
| 775 | ;; Move whitespace back to beginning | ||
| 776 | (save-excursion | ||
| 777 | (goto-char ins-end) | ||
| 778 | (let ((kill-whole-line t)) | ||
| 779 | (kill-line (- ne-ins ne-beg)) (point))) | ||
| 780 | (insert (make-string (- ne-ins ne-beg) ?\n))) | ||
| 781 | |||
| 782 | (org-maybe-renumber-ordered-list) | ||
| 783 | (move-to-column col)) | ||
| 784 | (goto-char pos) | ||
| 785 | (move-to-column col) | ||
| 786 | (error "Cannot move this item further up")))) | ||
| 787 | |||
| 788 | (defun org-maybe-renumber-ordered-list () | ||
| 789 | "Renumber the ordered list at point if setup allows it. | ||
| 790 | This tests the user option `org-auto-renumber-ordered-lists' before | ||
| 791 | doing the renumbering." | ||
| 792 | (interactive) | 1069 | (interactive) |
| 793 | (when (and org-auto-renumber-ordered-lists | 1070 | (if (not (org-at-item-p)) |
| 794 | (org-at-item-p)) | 1071 | (error "Not at an item") |
| 795 | (if (match-beginning 3) | 1072 | (let* ((pos (point)) |
| 796 | (org-renumber-ordered-list 1) | 1073 | (col (current-column)) |
| 797 | (org-fix-bullet-type)))) | 1074 | (top (org-list-top-point)) |
| 798 | 1075 | (bottom (org-list-bottom-point)) | |
| 799 | (defun org-maybe-renumber-ordered-list-safe () | 1076 | (actual-item (goto-char (org-get-item-beginning))) |
| 800 | (condition-case nil | 1077 | (prev-item (org-get-previous-item (point) top))) |
| 801 | (save-excursion | 1078 | (if (not prev-item) |
| 802 | (org-maybe-renumber-ordered-list)) | 1079 | (progn |
| 803 | (error nil))) | 1080 | (goto-char pos) |
| 1081 | (error "Cannot move this item further up")) | ||
| 1082 | (org-list-exchange-items prev-item actual-item bottom) | ||
| 1083 | (org-list-repair nil top bottom) | ||
| 1084 | (move-to-column col))))) | ||
| 804 | 1085 | ||
| 805 | (defun org-cycle-list-bullet (&optional which) | 1086 | (defun org-insert-item (&optional checkbox) |
| 806 | "Cycle through the different itemize/enumerate bullets. | 1087 | "Insert a new item at the current level. |
| 807 | This cycle the entire list level through the sequence: | 1088 | If cursor is before first character after bullet of the item, the |
| 1089 | new item will be created before the current one. | ||
| 808 | 1090 | ||
| 809 | `-' -> `+' -> `*' -> `1.' -> `1)' | 1091 | If CHECKBOX is non-nil, add a checkbox next to the bullet. |
| 810 | 1092 | ||
| 811 | If WHICH is a string, use that as the new bullet. If WHICH is an integer, | 1093 | Return t when things worked, nil when we are not in an item, or |
| 812 | 0 means `-', 1 means `+' etc." | 1094 | item is invisible." |
| 813 | (interactive "P") | 1095 | (unless (or (not (org-in-item-p)) |
| 814 | (org-preserve-lc | 1096 | (save-excursion |
| 815 | (org-beginning-of-item-list) | 1097 | (goto-char (org-get-item-beginning)) |
| 816 | (org-at-item-p) | 1098 | (org-invisible-p))) |
| 817 | (beginning-of-line 1) | 1099 | (if (save-excursion |
| 818 | (let ((current (match-string 0)) | 1100 | (goto-char (org-get-item-beginning)) |
| 819 | (prevp (eq which 'previous)) | 1101 | (org-at-item-timer-p)) |
| 820 | new old) | 1102 | ;; Timer list: delegate to `org-timer-item'. |
| 821 | (setq new (cond | 1103 | (progn (org-timer-item) t) |
| 822 | ((and (numberp which) | 1104 | ;; if we're in a description list, ask for the new term. |
| 823 | (nth (1- which) '("-" "+" "*" "1." "1)")))) | 1105 | (let ((desc-text (when (save-excursion |
| 824 | ((string-match "-" current) (if prevp "1)" "+")) | 1106 | (and (goto-char (org-get-item-beginning)) |
| 825 | ((string-match "\\+" current) | 1107 | (org-at-item-description-p))) |
| 826 | (if prevp "-" (if (looking-at "\\S-") "1." "*"))) | 1108 | (concat (read-string "Term: ") " :: ")))) |
| 827 | ((string-match "\\*" current) (if prevp "+" "1.")) | 1109 | ;; Don't insert a checkbox if checkbox rule is applied and it |
| 828 | ((string-match "\\." current) | 1110 | ;; is a description item. |
| 829 | (if prevp (if (looking-at "\\S-") "+" "*") "1)")) | 1111 | (org-list-insert-item-generic |
| 830 | ((string-match ")" current) (if prevp "1." "-")) | 1112 | (point) (and checkbox |
| 831 | (t (error "This should not happen")))) | 1113 | (or (not desc-text) |
| 832 | (and (looking-at "\\([ \t]*\\)\\(\\S-+\\)") | 1114 | (not (cdr (assq 'checkbox org-list-automatic-rules))))) |
| 833 | (setq old (match-string 2)) | 1115 | desc-text))))) |
| 834 | (replace-match (concat "\\1" new))) | 1116 | |
| 835 | (org-shift-item-indentation (- (length new) (length old))) | 1117 | ;;; Structures |
| 836 | (org-fix-bullet-type) | 1118 | |
| 837 | (org-maybe-renumber-ordered-list)))) | 1119 | ;; The idea behind structures is to avoid moving back and forth in the |
| 1120 | ;; buffer on costly operations like indenting or fixing bullets. | ||
| 1121 | |||
| 1122 | ;; It achieves this by taking a snapshot of an interesting part of the | ||
| 1123 | ;; list, in the shape of an alist, using `org-list-struct'. | ||
| 1124 | |||
| 1125 | ;; It then proceeds to changes directly on the alist, with the help of | ||
| 1126 | ;; and `org-list-struct-origins'. When those are done, | ||
| 1127 | ;; `org-list-struct-apply-struct' applies the changes to the buffer. | ||
| 1128 | |||
| 1129 | (defun org-list-struct-assoc-at-point () | ||
| 1130 | "Return the structure association at point. | ||
| 1131 | It is a cons-cell whose key is point and values are indentation, | ||
| 1132 | bullet string and bullet counter, if any." | ||
| 1133 | (save-excursion | ||
| 1134 | (beginning-of-line) | ||
| 1135 | (list (point-at-bol) | ||
| 1136 | (org-get-indentation) | ||
| 1137 | (progn | ||
| 1138 | (looking-at "^[ \t]*\\([-+*0-9.)]+[ \t]+\\)") | ||
| 1139 | (match-string 1)) | ||
| 1140 | (progn | ||
| 1141 | (goto-char (match-end 0)) | ||
| 1142 | (and (looking-at "\\[@\\(?:start:\\)?\\([0-9]+\\)\\]") | ||
| 1143 | (match-string 1)))))) | ||
| 1144 | |||
| 1145 | (defun org-list-struct (begin end top bottom &optional outdent) | ||
| 1146 | "Return the structure containing the list between BEGIN and END. | ||
| 1147 | A structure is an alist where key is point of item and values | ||
| 1148 | are, in that order, indentation, bullet string and value of | ||
| 1149 | counter, if any. A structure contains every list and sublist that | ||
| 1150 | has items between BEGIN and END along with their common ancestor. | ||
| 1151 | If no such ancestor can be found, the function will add a virtual | ||
| 1152 | ancestor at position 0. | ||
| 1153 | |||
| 1154 | TOP and BOTTOM are respectively the position of list beginning | ||
| 1155 | and list ending. | ||
| 1156 | |||
| 1157 | If OUTDENT is non-nil, it will also grab all of the parent list | ||
| 1158 | and the grand-parent. Setting OUTDENT to t is mandatory when next | ||
| 1159 | change is an outdent." | ||
| 1160 | (save-excursion | ||
| 1161 | (let* (struct | ||
| 1162 | (extend | ||
| 1163 | (lambda (struct) | ||
| 1164 | (let* ((ind-min (apply 'min (mapcar 'cadr struct))) | ||
| 1165 | (begin (caar struct)) | ||
| 1166 | (end (caar (last struct))) | ||
| 1167 | pre-list post-list) | ||
| 1168 | (goto-char begin) | ||
| 1169 | ;; Find beginning of most outdented list (min list) | ||
| 1170 | (while (and (org-search-backward-unenclosed | ||
| 1171 | org-item-beginning-re top t) | ||
| 1172 | (>= (org-get-indentation) ind-min)) | ||
| 1173 | (setq pre-list (cons (org-list-struct-assoc-at-point) | ||
| 1174 | pre-list))) | ||
| 1175 | ;; Now get the parent. If none, add a virtual ancestor | ||
| 1176 | (if (< (org-get-indentation) ind-min) | ||
| 1177 | (setq pre-list (cons (org-list-struct-assoc-at-point) | ||
| 1178 | pre-list)) | ||
| 1179 | (setq pre-list (cons (list 0 (org-get-indentation) "" nil) | ||
| 1180 | pre-list))) | ||
| 1181 | ;; Find end of min list | ||
| 1182 | (goto-char end) | ||
| 1183 | (end-of-line) | ||
| 1184 | (while (and (org-search-forward-unenclosed | ||
| 1185 | org-item-beginning-re bottom 'move) | ||
| 1186 | (>= (org-get-indentation) ind-min)) | ||
| 1187 | (setq post-list (cons (org-list-struct-assoc-at-point) | ||
| 1188 | post-list))) | ||
| 1189 | ;; Is list is malformed? If some items are less | ||
| 1190 | ;; indented that top-item, add them anyhow. | ||
| 1191 | (when (and (= (caar pre-list) 0) (< (point) bottom)) | ||
| 1192 | (beginning-of-line) | ||
| 1193 | (while (org-search-forward-unenclosed | ||
| 1194 | org-item-beginning-re bottom t) | ||
| 1195 | (setq post-list (cons (org-list-struct-assoc-at-point) | ||
| 1196 | post-list)))) | ||
| 1197 | (append pre-list struct (reverse post-list)))))) | ||
| 1198 | ;; Here we start: first get the core zone... | ||
| 1199 | (goto-char end) | ||
| 1200 | (while (org-search-backward-unenclosed org-item-beginning-re begin t) | ||
| 1201 | (setq struct (cons (org-list-struct-assoc-at-point) struct))) | ||
| 1202 | ;; ... then, extend it to make it a structure... | ||
| 1203 | (let ((extended (funcall extend struct))) | ||
| 1204 | ;; ... twice when OUTDENT is non-nil and struct still can be | ||
| 1205 | ;; extended | ||
| 1206 | (if (and outdent (> (caar extended) 0)) | ||
| 1207 | (funcall extend extended) | ||
| 1208 | extended))))) | ||
| 1209 | |||
| 1210 | (defun org-list-struct-origins (struct) | ||
| 1211 | "Return an alist where key is item's position and value parent's. | ||
| 1212 | STRUCT is the list's structure looked up." | ||
| 1213 | (let* ((struct-rev (reverse struct)) | ||
| 1214 | (acc (list (cons (nth 1 (car struct)) 0))) | ||
| 1215 | (prev-item (lambda (item) | ||
| 1216 | (car (nth 1 (member (assq item struct) struct-rev))))) | ||
| 1217 | (get-origins | ||
| 1218 | (lambda (item) | ||
| 1219 | (let* ((item-pos (car item)) | ||
| 1220 | (ind (nth 1 item)) | ||
| 1221 | (prev-ind (caar acc))) | ||
| 1222 | (cond | ||
| 1223 | ;; List closing. | ||
| 1224 | ((> prev-ind ind) | ||
| 1225 | (let ((current-origin (or (member (assq ind acc) acc) | ||
| 1226 | ;; needed if top-point is | ||
| 1227 | ;; not the most outdented | ||
| 1228 | (last acc)))) | ||
| 1229 | (setq acc current-origin) | ||
| 1230 | (cons item-pos (cdar acc)))) | ||
| 1231 | ;; New list | ||
| 1232 | ((< prev-ind ind) | ||
| 1233 | (let ((origin (funcall prev-item item-pos))) | ||
| 1234 | (setq acc (cons (cons ind origin) acc)) | ||
| 1235 | (cons item-pos origin))) | ||
| 1236 | ;; Current list going on | ||
| 1237 | (t (cons item-pos (cdar acc)))))))) | ||
| 1238 | (cons '(0 . 0) (mapcar get-origins (cdr struct))))) | ||
| 1239 | |||
| 1240 | (defun org-list-struct-get-parent (item struct origins) | ||
| 1241 | "Return parent association of ITEM in STRUCT or nil. | ||
| 1242 | ORIGINS is the alist of parents. See `org-list-struct-origins'." | ||
| 1243 | (let* ((parent-pos (cdr (assq (car item) origins)))) | ||
| 1244 | (when (> parent-pos 0) (assq parent-pos struct)))) | ||
| 1245 | |||
| 1246 | (defun org-list-struct-get-child (item struct) | ||
| 1247 | "Return child association of ITEM in STRUCT or nil." | ||
| 1248 | (let ((ind (nth 1 item)) | ||
| 1249 | (next-item (cadr (member item struct)))) | ||
| 1250 | (when (and next-item (> (nth 1 next-item) ind)) next-item))) | ||
| 1251 | |||
| 1252 | (defun org-list-struct-fix-bul (struct origins) | ||
| 1253 | "Verify and correct bullets for every association in STRUCT. | ||
| 1254 | ORIGINS is the alist of parents. See `org-list-struct-origins'. | ||
| 1255 | |||
| 1256 | This function modifies STRUCT." | ||
| 1257 | (let* (acc | ||
| 1258 | (init-bul (lambda (item) | ||
| 1259 | (let ((counter (nth 3 item)) | ||
| 1260 | (bullet (org-list-bullet-string (nth 2 item)))) | ||
| 1261 | (cond | ||
| 1262 | ((and (string-match "[0-9]+" bullet) counter) | ||
| 1263 | (replace-match counter nil nil bullet)) | ||
| 1264 | ((string-match "[0-9]+" bullet) | ||
| 1265 | (replace-match "1" nil nil bullet)) | ||
| 1266 | (t bullet))))) | ||
| 1267 | (set-bul (lambda (item bullet) | ||
| 1268 | (setcdr item (list (nth 1 item) bullet (nth 3 item))))) | ||
| 1269 | (get-bul (lambda (item bullet) | ||
| 1270 | (let* ((counter (nth 3 item))) | ||
| 1271 | (if (and counter (string-match "[0-9]+" bullet)) | ||
| 1272 | (replace-match counter nil nil bullet) | ||
| 1273 | bullet)))) | ||
| 1274 | (fix-bul | ||
| 1275 | (lambda (item) struct | ||
| 1276 | (let* ((parent (cdr (assq (car item) origins))) | ||
| 1277 | (orig-ref (assq parent acc))) | ||
| 1278 | (if orig-ref | ||
| 1279 | ;; Continuing previous list | ||
| 1280 | (let* ((prev-bul (cdr orig-ref)) | ||
| 1281 | (new-bul (funcall get-bul item prev-bul))) | ||
| 1282 | (setcdr orig-ref (org-list-inc-bullet-maybe new-bul)) | ||
| 1283 | (funcall set-bul item new-bul)) | ||
| 1284 | ;; A new list is starting | ||
| 1285 | (let ((new-bul (funcall init-bul item))) | ||
| 1286 | (funcall set-bul item new-bul) | ||
| 1287 | (setq acc (cons (cons parent | ||
| 1288 | (org-list-inc-bullet-maybe new-bul)) | ||
| 1289 | acc)))))))) | ||
| 1290 | (mapc fix-bul (cdr struct)))) | ||
| 1291 | |||
| 1292 | (defun org-list-struct-fix-ind (struct origins) | ||
| 1293 | "Verify and correct indentation for every association in STRUCT. | ||
| 1294 | ORIGINS is the alist of parents. See `org-list-struct-origins'. | ||
| 1295 | |||
| 1296 | This function modifies STRUCT." | ||
| 1297 | (let* ((headless (cdr struct)) | ||
| 1298 | (ancestor (car struct)) | ||
| 1299 | (top-ind (+ (nth 1 ancestor) (length (nth 2 ancestor)))) | ||
| 1300 | (new-ind | ||
| 1301 | (lambda (item) | ||
| 1302 | (let* ((parent (org-list-struct-get-parent item headless origins))) | ||
| 1303 | (if parent | ||
| 1304 | ;; Indent like parent + length of parent's bullet | ||
| 1305 | (setcdr item (cons (+ (length (nth 2 parent)) (nth 1 parent)) | ||
| 1306 | (cddr item))) | ||
| 1307 | ;; If no parent, indent like top-point | ||
| 1308 | (setcdr item (cons top-ind (cddr item)))))))) | ||
| 1309 | (mapc new-ind headless))) | ||
| 1310 | |||
| 1311 | (defun org-list-struct-fix-struct (struct origins) | ||
| 1312 | "Return STRUCT with correct bullets and indentation. | ||
| 1313 | ORIGINS is the alist of parents. See `org-list-struct-origins'. | ||
| 1314 | |||
| 1315 | Only elements of STRUCT that have changed are returned." | ||
| 1316 | (let ((old (copy-alist struct))) | ||
| 1317 | (org-list-struct-fix-bul struct origins) | ||
| 1318 | (org-list-struct-fix-ind struct origins) | ||
| 1319 | (delq nil (mapcar (lambda (e) (when (not (equal (pop old) e)) e)) struct)))) | ||
| 1320 | |||
| 1321 | (defun org-list-struct-outdent (start end origins) | ||
| 1322 | "Outdent items in a structure. | ||
| 1323 | Items are indented when their key is between START, included, and | ||
| 1324 | END, excluded. | ||
| 1325 | |||
| 1326 | ORIGINS is the alist of parents. See `org-list-struct-origins'. | ||
| 1327 | |||
| 1328 | STRUCT is the concerned structure." | ||
| 1329 | (let* (acc | ||
| 1330 | (out (lambda (cell) | ||
| 1331 | (let* ((item (car cell)) | ||
| 1332 | (parent (cdr cell))) | ||
| 1333 | (cond | ||
| 1334 | ;; Item not yet in zone: keep association | ||
| 1335 | ((< item start) cell) | ||
| 1336 | ;; Item out of zone: follow associations in acc | ||
| 1337 | ((>= item end) | ||
| 1338 | (let ((convert (assq parent acc))) | ||
| 1339 | (if convert (cons item (cdr convert)) cell))) | ||
| 1340 | ;; Item has no parent: error | ||
| 1341 | ((<= parent 0) | ||
| 1342 | (error "Cannot outdent top-level items")) | ||
| 1343 | ;; Parent is outdented: keep association | ||
| 1344 | ((>= parent start) | ||
| 1345 | (setq acc (cons (cons parent item) acc)) cell) | ||
| 1346 | (t | ||
| 1347 | ;; Parent isn't outdented: reparent to grand-parent | ||
| 1348 | (let ((grand-parent (cdr (assq parent origins)))) | ||
| 1349 | (setq acc (cons (cons parent item) acc)) | ||
| 1350 | (cons item grand-parent)))))))) | ||
| 1351 | (mapcar out origins))) | ||
| 1352 | |||
| 1353 | (defun org-list-struct-indent (start end origins struct) | ||
| 1354 | "Indent items in a structure. | ||
| 1355 | Items are indented when their key is between START, included, and | ||
| 1356 | END, excluded. | ||
| 1357 | |||
| 1358 | ORIGINS is the alist of parents. See `org-list-struct-origins'. | ||
| 1359 | |||
| 1360 | STRUCT is the concerned structure. It may be modified if | ||
| 1361 | `org-list-demote-modify-bullet' matches bullets between START and | ||
| 1362 | END." | ||
| 1363 | (let* (acc | ||
| 1364 | (orig-rev (reverse origins)) | ||
| 1365 | (get-prev-item | ||
| 1366 | (lambda (cell parent) | ||
| 1367 | (car (rassq parent (cdr (memq cell orig-rev)))))) | ||
| 1368 | (set-assoc | ||
| 1369 | (lambda (cell) | ||
| 1370 | (setq acc (cons cell acc)) cell)) | ||
| 1371 | (change-bullet-maybe | ||
| 1372 | (lambda (item) | ||
| 1373 | (let* ((full-item (assq item struct)) | ||
| 1374 | (item-bul (org-trim (nth 2 full-item))) | ||
| 1375 | (new-bul-p (cdr (assoc item-bul org-list-demote-modify-bullet)))) | ||
| 1376 | (when new-bul-p | ||
| 1377 | ;; new bullet is stored without space to ensure item | ||
| 1378 | ;; will be modified | ||
| 1379 | (setcdr full-item | ||
| 1380 | (list (nth 1 full-item) | ||
| 1381 | new-bul-p | ||
| 1382 | (nth 3 full-item))))))) | ||
| 1383 | (ind | ||
| 1384 | (lambda (cell) | ||
| 1385 | (let* ((item (car cell)) | ||
| 1386 | (parent (cdr cell))) | ||
| 1387 | (cond | ||
| 1388 | ;; Item not yet in zone: keep association | ||
| 1389 | ((< item start) cell) | ||
| 1390 | ((>= item end) | ||
| 1391 | ;; Item out of zone: follow associations in acc | ||
| 1392 | (let ((convert (assq parent acc))) | ||
| 1393 | (if convert (cons item (cdr convert)) cell))) | ||
| 1394 | (t | ||
| 1395 | ;; Item is in zone... | ||
| 1396 | (let ((prev (funcall get-prev-item cell parent))) | ||
| 1397 | ;; Check if bullet needs to be changed | ||
| 1398 | (funcall change-bullet-maybe item) | ||
| 1399 | (cond | ||
| 1400 | ;; First item indented but not parent: error | ||
| 1401 | ((and (or (not prev) (= prev 0)) (< parent start)) | ||
| 1402 | (error "Cannot indent the first item of a list")) | ||
| 1403 | ;; First item and parent indented: keep same parent | ||
| 1404 | ((or (not prev) (= prev 0)) | ||
| 1405 | (funcall set-assoc cell)) | ||
| 1406 | ;; Previous item not indented: reparent to it | ||
| 1407 | ((< prev start) | ||
| 1408 | (funcall set-assoc (cons item prev))) | ||
| 1409 | ;; Previous item indented: reparent like it | ||
| 1410 | (t | ||
| 1411 | (funcall set-assoc (cons item | ||
| 1412 | (cdr (assq prev acc))))))))))))) | ||
| 1413 | (mapcar ind origins))) | ||
| 1414 | |||
| 1415 | (defun org-list-struct-apply-struct (struct bottom) | ||
| 1416 | "Apply modifications to list so it mirrors STRUCT. | ||
| 1417 | BOTTOM is position at list ending. | ||
| 1418 | |||
| 1419 | Initial position is restored after the changes." | ||
| 1420 | (let* ((pos (copy-marker (point))) | ||
| 1421 | (ancestor (caar struct)) | ||
| 1422 | (modify | ||
| 1423 | (lambda (item) | ||
| 1424 | (goto-char (car item)) | ||
| 1425 | (let* ((new-ind (nth 1 item)) | ||
| 1426 | (new-bul (org-list-bullet-string (nth 2 item))) | ||
| 1427 | (old-ind (org-get-indentation)) | ||
| 1428 | (old-bul (progn | ||
| 1429 | (looking-at "[ \t]*\\(\\S-+[ \t]*\\)") | ||
| 1430 | (match-string 1))) | ||
| 1431 | (old-body-ind (+ (length old-bul) old-ind)) | ||
| 1432 | (new-body-ind (+ (length new-bul) new-ind))) | ||
| 1433 | ;; 1. Shift item's body | ||
| 1434 | (unless (= old-body-ind new-body-ind) | ||
| 1435 | (org-shift-item-indentation | ||
| 1436 | (- new-body-ind old-body-ind) bottom)) | ||
| 1437 | ;; 2. Replace bullet | ||
| 1438 | (unless (equal new-bul old-bul) | ||
| 1439 | (save-excursion | ||
| 1440 | (looking-at "[ \t]*\\(\\S-+[ \t]*\\)") | ||
| 1441 | (replace-match new-bul nil nil nil 1))) | ||
| 1442 | ;; 3. Indent item to appropriate column | ||
| 1443 | (unless (= new-ind old-ind) | ||
| 1444 | (delete-region (point-at-bol) | ||
| 1445 | (progn | ||
| 1446 | (skip-chars-forward " \t") | ||
| 1447 | (point))) | ||
| 1448 | (indent-to new-ind))))) | ||
| 1449 | ;; Remove ancestor if it is left. | ||
| 1450 | (struct-to-apply (if (or (not ancestor) (= 0 ancestor)) | ||
| 1451 | (cdr struct) | ||
| 1452 | struct))) | ||
| 1453 | ;; Apply changes from bottom to top | ||
| 1454 | (mapc modify (nreverse struct-to-apply)) | ||
| 1455 | (goto-char pos))) | ||
| 1456 | |||
| 1457 | ;;; Indentation | ||
| 838 | 1458 | ||
| 839 | (defun org-get-string-indentation (s) | 1459 | (defun org-get-string-indentation (s) |
| 840 | "What indentation has S due to SPACE and TAB at the beginning of the string?" | 1460 | "What indentation has S due to SPACE and TAB at the beginning of the string?" |
| @@ -847,299 +1467,555 @@ If WHICH is a string, use that as the new bullet. If WHICH is an integer, | |||
| 847 | (t (throw 'exit t))))) | 1467 | (t (throw 'exit t))))) |
| 848 | i)) | 1468 | i)) |
| 849 | 1469 | ||
| 850 | (defun org-renumber-ordered-list (arg) | 1470 | (defun org-shift-item-indentation (delta bottom) |
| 851 | "Renumber an ordered plain list. | 1471 | "Shift the indentation in current item by DELTA. |
| 852 | Cursor needs to be in the first line of an item, the line that starts | 1472 | Sub-items are not moved. |
| 853 | with something like \"1.\" or \"2)\"." | 1473 | |
| 854 | (interactive "p") | 1474 | BOTTOM is position at list ending." |
| 855 | (unless (and (org-at-item-p) | 1475 | (save-excursion |
| 856 | (match-beginning 3)) | 1476 | (let ((beg (point-at-bol)) |
| 857 | (error "This is not an ordered list")) | 1477 | (end (org-end-of-item-or-at-child bottom))) |
| 858 | (let ((line (org-current-line)) | 1478 | (beginning-of-line (unless (eolp) 0)) |
| 859 | (col (current-column)) | 1479 | (while (> (point) beg) |
| 860 | (ind (org-get-string-indentation | 1480 | (when (looking-at "[ \t]*\\S-") |
| 861 | (buffer-substring (point-at-bol) (match-beginning 3)))) | 1481 | ;; this is not an empty line |
| 862 | ;; (term (substring (match-string 3) -1)) | 1482 | (let ((i (org-get-indentation))) |
| 863 | ind1 (n (1- arg)) | 1483 | (when (and (> i 0) (> (+ i delta) 0)) |
| 864 | fmt bobp old new delta) | 1484 | (indent-line-to (+ i delta))))) |
| 865 | ;; find where this list begins | 1485 | (beginning-of-line 0))))) |
| 866 | (org-beginning-of-item-list) | 1486 | |
| 867 | (setq bobp (bobp)) | 1487 | (defun org-outdent-item () |
| 868 | (looking-at "[ \t]*[0-9]+\\([.)]\\)") | 1488 | "Outdent a local list item, but not its children. |
| 869 | (setq fmt (concat "%d" (or (match-string 1) "."))) | 1489 | If a region is active, all items inside will be moved." |
| 870 | (save-excursion | ||
| 871 | (goto-char (match-end 0)) | ||
| 872 | (if (looking-at "[ \t]*\\[@start:\\([0-9]+\\)") | ||
| 873 | (setq n (1- (string-to-number (match-string 1)))))) | ||
| 874 | (beginning-of-line 0) | ||
| 875 | ;; walk forward and replace these numbers | ||
| 876 | (catch 'exit | ||
| 877 | (while t | ||
| 878 | (catch 'next | ||
| 879 | (if bobp (setq bobp nil) (beginning-of-line 2)) | ||
| 880 | (if (eobp) (throw 'exit nil)) | ||
| 881 | (if (looking-at "[ \t]*$") (throw 'next nil)) | ||
| 882 | (skip-chars-forward " \t") (setq ind1 (current-column)) | ||
| 883 | (if (> ind1 ind) (throw 'next t)) | ||
| 884 | (if (< ind1 ind) (throw 'exit t)) | ||
| 885 | (if (not (org-at-item-p)) (throw 'exit nil)) | ||
| 886 | (setq old (match-string 2)) | ||
| 887 | (delete-region (match-beginning 2) (match-end 2)) | ||
| 888 | (goto-char (match-beginning 2)) | ||
| 889 | (insert (setq new (format fmt (setq n (1+ n))))) | ||
| 890 | (setq delta (- (length new) (length old))) | ||
| 891 | (org-shift-item-indentation delta) | ||
| 892 | (if (= (org-current-line) line) (setq col (+ col delta)))))) | ||
| 893 | (org-goto-line line) | ||
| 894 | (org-move-to-column col))) | ||
| 895 | |||
| 896 | (defvar org-suppress-item-indentation) ; dynamically scoped parameter | ||
| 897 | (defun org-fix-bullet-type (&optional force-bullet) | ||
| 898 | "Make sure all items in this list have the same bullet as the first item. | ||
| 899 | Also, fix the indentation." | ||
| 900 | (interactive) | 1490 | (interactive) |
| 901 | (unless (org-at-item-p) (error "This is not a list")) | 1491 | (org-list-indent-item-generic |
| 902 | (let ((line (org-current-line)) | 1492 | -1 t (org-list-top-point) (org-list-bottom-point))) |
| 903 | (chars-from-eol (- (point-at-eol) (point))) | ||
| 904 | (ind (current-indentation)) | ||
| 905 | ind1 bullet oldbullet) | ||
| 906 | ;; find where this list begins | ||
| 907 | (org-beginning-of-item-list) | ||
| 908 | (beginning-of-line 1) | ||
| 909 | ;; find out what the bullet type is | ||
| 910 | (looking-at "[ \t]*\\(\\S-+\\)") | ||
| 911 | (setq bullet (concat (or force-bullet (match-string 1)) " ")) | ||
| 912 | (if (and org-list-two-spaces-after-bullet-regexp | ||
| 913 | (string-match org-list-two-spaces-after-bullet-regexp bullet)) | ||
| 914 | (setq bullet (concat bullet " "))) | ||
| 915 | ;; walk forward and replace these numbers | ||
| 916 | (beginning-of-line 0) | ||
| 917 | (catch 'exit | ||
| 918 | (while t | ||
| 919 | (catch 'next | ||
| 920 | (beginning-of-line 2) | ||
| 921 | (if (eobp) (throw 'exit nil)) | ||
| 922 | (if (looking-at "[ \t]*$") (throw 'next nil)) | ||
| 923 | (skip-chars-forward " \t") (setq ind1 (current-column)) | ||
| 924 | (if (> ind1 ind) (throw 'next t)) | ||
| 925 | (if (< ind1 ind) (throw 'exit t)) | ||
| 926 | (if (not (org-at-item-p)) (throw 'exit nil)) | ||
| 927 | (skip-chars-forward " \t") | ||
| 928 | (looking-at "\\S-+ *") | ||
| 929 | (setq oldbullet (match-string 0)) | ||
| 930 | (unless (equal bullet oldbullet) (replace-match bullet)) | ||
| 931 | (org-shift-item-indentation (- (length bullet) | ||
| 932 | (length oldbullet)))))) | ||
| 933 | (org-goto-line line) | ||
| 934 | (goto-char (max (point-at-bol) (- (point-at-eol) chars-from-eol))) | ||
| 935 | (if (string-match "[0-9]" bullet) | ||
| 936 | (org-renumber-ordered-list 1)))) | ||
| 937 | |||
| 938 | (defun org-shift-item-indentation (delta) | ||
| 939 | "Shift the indentation in current item by DELTA." | ||
| 940 | (unless (org-bound-and-true-p org-suppress-item-indentation) | ||
| 941 | (save-excursion | ||
| 942 | (let ((beg (point-at-bol)) | ||
| 943 | (end (progn (org-end-of-item) (point))) | ||
| 944 | i) | ||
| 945 | (goto-char end) | ||
| 946 | (beginning-of-line 0) | ||
| 947 | (while (> (point) beg) | ||
| 948 | (when (looking-at "[ \t]*\\S-") | ||
| 949 | ;; this is not an empty line | ||
| 950 | (setq i (org-get-indentation)) | ||
| 951 | (if (and (> i 0) (> (setq i (+ i delta)) 0)) | ||
| 952 | (indent-line-to i))) | ||
| 953 | (beginning-of-line 0)))))) | ||
| 954 | 1493 | ||
| 955 | (defun org-beginning-of-item-list () | 1494 | (defun org-indent-item () |
| 956 | "Go to the beginning of the current item list. | 1495 | "Indent a local list item, but not its children. |
| 957 | I.e. to the first item in this list." | 1496 | If a region is active, all items inside will be moved." |
| 958 | (interactive) | 1497 | (interactive) |
| 959 | (org-beginning-of-item) | 1498 | (org-list-indent-item-generic |
| 960 | (let ((pos (point-at-bol)) | 1499 | 1 t (org-list-top-point) (org-list-bottom-point))) |
| 961 | (ind (org-get-indentation)) | ||
| 962 | ind1) | ||
| 963 | ;; find where this list begins | ||
| 964 | (catch 'exit | ||
| 965 | (while t | ||
| 966 | (catch 'next | ||
| 967 | (beginning-of-line 0) | ||
| 968 | (if (looking-at "[ \t]*$") | ||
| 969 | (throw (if (bobp) 'exit 'next) t)) | ||
| 970 | (skip-chars-forward " \t") (setq ind1 (current-column)) | ||
| 971 | (if (or (< ind1 ind) | ||
| 972 | (and (= ind1 ind) | ||
| 973 | (not (org-at-item-p))) | ||
| 974 | (and (= (point-at-bol) (point-min)) | ||
| 975 | (setq pos (point-min)))) | ||
| 976 | (throw 'exit t) | ||
| 977 | (when (org-at-item-p) (setq pos (point-at-bol))))))) | ||
| 978 | (goto-char pos))) | ||
| 979 | 1500 | ||
| 980 | (defun org-end-of-item-list () | 1501 | (defun org-outdent-item-tree () |
| 981 | "Go to the end of the current item list. | 1502 | "Outdent a local list item including its children. |
| 982 | I.e. to the text after the last item." | 1503 | If a region is active, all items inside will be moved." |
| 983 | (interactive) | 1504 | (interactive) |
| 984 | (org-beginning-of-item) | 1505 | (org-list-indent-item-generic |
| 985 | (let ((pos (point-at-bol)) | 1506 | -1 nil (org-list-top-point) (org-list-bottom-point))) |
| 1507 | |||
| 1508 | (defun org-indent-item-tree () | ||
| 1509 | "Indent a local list item including its children. | ||
| 1510 | If a region is active, all items inside will be moved." | ||
| 1511 | (interactive) | ||
| 1512 | (org-list-indent-item-generic | ||
| 1513 | 1 nil (org-list-top-point) (org-list-bottom-point))) | ||
| 1514 | |||
| 1515 | (defvar org-tab-ind-state) | ||
| 1516 | (defun org-cycle-item-indentation () | ||
| 1517 | "Cycle levels of indentation of an empty item. | ||
| 1518 | The first run indent the item, if applicable. Subsequents runs | ||
| 1519 | outdent it at meaningful levels in the list. When done, item is | ||
| 1520 | put back at its original position with its original bullet. | ||
| 1521 | |||
| 1522 | Return t at each successful move." | ||
| 1523 | (let ((org-adapt-indentation nil) | ||
| 986 | (ind (org-get-indentation)) | 1524 | (ind (org-get-indentation)) |
| 987 | ind1) | 1525 | (bottom (and (org-at-item-p) (org-list-bottom-point)))) |
| 988 | ;; find where this list begins | 1526 | (when (and (or (org-at-item-description-p) |
| 989 | (catch 'exit | 1527 | (org-at-item-checkbox-p) |
| 990 | (while t | 1528 | (org-at-item-p)) |
| 991 | (catch 'next | 1529 | ;; Check that item is really empty |
| 992 | (beginning-of-line 2) | 1530 | (>= (match-end 0) (save-excursion |
| 993 | (if (looking-at "[ \t]*$") | 1531 | (org-end-of-item-or-at-child bottom) |
| 994 | (if (eobp) | 1532 | (skip-chars-backward " \r\t\n") |
| 995 | (progn (setq pos (point)) (throw 'exit t)) | 1533 | (point)))) |
| 996 | (throw 'next t))) | 1534 | (setq this-command 'org-cycle-item-indentation) |
| 997 | (skip-chars-forward " \t") (setq ind1 (current-column)) | 1535 | (let ((top (org-list-top-point))) |
| 998 | (if (or (< ind1 ind) | 1536 | ;; When in the middle of the cycle, try to outdent first. If it |
| 999 | (and (= ind1 ind) | 1537 | ;; fails, and point is still at initial position, indent. Else, |
| 1000 | (not (org-at-item-p))) | 1538 | ;; go back to original position. |
| 1001 | (eobp)) | 1539 | (if (eq last-command 'org-cycle-item-indentation) |
| 1002 | (progn | 1540 | (cond |
| 1003 | (setq pos (point-at-bol)) | 1541 | ((ignore-errors (org-list-indent-item-generic -1 t top bottom))) |
| 1004 | (throw 'exit t)))))) | 1542 | ((and (= (org-get-indentation) (car org-tab-ind-state)) |
| 1005 | (goto-char pos))) | 1543 | (ignore-errors |
| 1544 | (org-list-indent-item-generic 1 t top bottom)))) | ||
| 1545 | (t (back-to-indentation) | ||
| 1546 | (indent-to-column (car org-tab-ind-state)) | ||
| 1547 | (end-of-line) | ||
| 1548 | (org-list-repair (cdr org-tab-ind-state)) | ||
| 1549 | ;; Break cycle | ||
| 1550 | (setq this-command 'identity))) | ||
| 1551 | ;; If a cycle is starting, remember indentation and bullet, | ||
| 1552 | ;; then try to indent. If it fails, try to outdent. | ||
| 1553 | (setq org-tab-ind-state (cons ind (org-get-bullet))) | ||
| 1554 | (cond | ||
| 1555 | ((ignore-errors (org-list-indent-item-generic 1 t top bottom))) | ||
| 1556 | ((ignore-errors (org-list-indent-item-generic -1 t top bottom))) | ||
| 1557 | (t (error "Cannot move item"))))) | ||
| 1558 | t))) | ||
| 1006 | 1559 | ||
| 1560 | ;;; Bullets | ||
| 1007 | 1561 | ||
| 1008 | (defvar org-last-indent-begin-marker (make-marker)) | 1562 | (defun org-get-bullet () |
| 1009 | (defvar org-last-indent-end-marker (make-marker)) | 1563 | "Return the bullet of the item at point. |
| 1564 | Assume cursor is at an item." | ||
| 1565 | (save-excursion | ||
| 1566 | (beginning-of-line) | ||
| 1567 | (and (looking-at "[ \t]*\\(\\S-+\\)") (match-string 1)))) | ||
| 1568 | |||
| 1569 | (defun org-list-bullet-string (bullet) | ||
| 1570 | "Return BULLET with the correct number of whitespaces. | ||
| 1571 | It determines the number of whitespaces to append by looking at | ||
| 1572 | `org-list-two-spaces-after-bullet-regexp'." | ||
| 1573 | (save-match-data | ||
| 1574 | (string-match "\\S-+\\([ \t]*\\)" bullet) | ||
| 1575 | (replace-match | ||
| 1576 | (save-match-data | ||
| 1577 | (concat | ||
| 1578 | " " | ||
| 1579 | ;; Do we need to concat another white space ? | ||
| 1580 | (when (and org-list-two-spaces-after-bullet-regexp | ||
| 1581 | (string-match org-list-two-spaces-after-bullet-regexp bullet)) | ||
| 1582 | " "))) | ||
| 1583 | nil nil bullet 1))) | ||
| 1584 | |||
| 1585 | (defun org-list-inc-bullet-maybe (bullet) | ||
| 1586 | "Increment BULLET if applicable." | ||
| 1587 | (if (string-match "[0-9]+" bullet) | ||
| 1588 | (replace-match | ||
| 1589 | (number-to-string (1+ (string-to-number (match-string 0 bullet)))) | ||
| 1590 | nil nil bullet) | ||
| 1591 | bullet)) | ||
| 1592 | |||
| 1593 | (defun org-list-repair (&optional force-bullet top bottom) | ||
| 1594 | "Make sure all items are correctly indented, with the right bullet. | ||
| 1595 | This function scans the list at point, along with any sublist. | ||
| 1596 | |||
| 1597 | If FORCE-BULLET is a string, ensure all items in list share this | ||
| 1598 | bullet, or a logical successor in the case of an ordered list. | ||
| 1599 | |||
| 1600 | When non-nil, TOP and BOTTOM specify respectively position of | ||
| 1601 | list beginning and list ending. | ||
| 1602 | |||
| 1603 | Item's body is not indented, only shifted with the bullet." | ||
| 1604 | (interactive) | ||
| 1605 | (unless (org-at-item-p) (error "This is not a list")) | ||
| 1606 | (let* ((bottom (or bottom (org-list-bottom-point))) | ||
| 1607 | (struct (org-list-struct | ||
| 1608 | (point-at-bol) (point-at-eol) | ||
| 1609 | (or top (org-list-top-point)) bottom)) | ||
| 1610 | (origins (org-list-struct-origins struct)) | ||
| 1611 | fixed-struct) | ||
| 1612 | (if (stringp force-bullet) | ||
| 1613 | (let ((begin (nth 1 struct))) | ||
| 1614 | (setcdr begin (list (nth 1 begin) | ||
| 1615 | (org-list-bullet-string force-bullet) | ||
| 1616 | (nth 3 begin))) | ||
| 1617 | (setq fixed-struct | ||
| 1618 | (cons begin (org-list-struct-fix-struct struct origins)))) | ||
| 1619 | (setq fixed-struct (org-list-struct-fix-struct struct origins))) | ||
| 1620 | (org-list-struct-apply-struct fixed-struct bottom))) | ||
| 1010 | 1621 | ||
| 1011 | (defun org-outdent-item (arg) | 1622 | (defun org-cycle-list-bullet (&optional which) |
| 1012 | "Outdent a local list item, but not its children." | 1623 | "Cycle through the different itemize/enumerate bullets. |
| 1013 | (interactive "p") | 1624 | This cycle the entire list level through the sequence: |
| 1014 | (org-indent-item-tree (- arg) 'no-subtree)) | ||
| 1015 | 1625 | ||
| 1016 | (defun org-indent-item (arg) | 1626 | `-' -> `+' -> `*' -> `1.' -> `1)' |
| 1017 | "Indent a local list item, but not its children." | ||
| 1018 | (interactive "p") | ||
| 1019 | (org-indent-item-tree arg 'no-subtree)) | ||
| 1020 | 1627 | ||
| 1021 | (defun org-outdent-item-tree (arg &optional no-subtree) | 1628 | If WHICH is a valid string, use that as the new bullet. If WHICH |
| 1022 | "Outdent a local list item including its children. | 1629 | is an integer, 0 means `-', 1 means `+' etc. If WHICH is |
| 1023 | If NO-SUBTREE is set, only outdent the item itself, not its children." | 1630 | 'previous, cycle backwards." |
| 1024 | (interactive "p") | 1631 | (interactive "P") |
| 1025 | (org-indent-item-tree (- arg) no-subtree)) | 1632 | (let* ((top (org-list-top-point)) |
| 1633 | (bullet (save-excursion | ||
| 1634 | (goto-char (org-get-beginning-of-list top)) | ||
| 1635 | (org-get-bullet))) | ||
| 1636 | (current (cond | ||
| 1637 | ((string-match "\\." bullet) "1.") | ||
| 1638 | ((string-match ")" bullet) "1)") | ||
| 1639 | (t bullet))) | ||
| 1640 | (bullet-rule-p (cdr (assq 'bullet org-list-automatic-rules))) | ||
| 1641 | (bullet-list (append '("-" "+" ) | ||
| 1642 | ;; *-bullets are not allowed at column 0 | ||
| 1643 | (unless (and bullet-rule-p | ||
| 1644 | (looking-at "\\S-")) '("*")) | ||
| 1645 | ;; Description items cannot be numbered | ||
| 1646 | (unless (and bullet-rule-p | ||
| 1647 | (or (eq org-plain-list-ordered-item-terminator ?\)) | ||
| 1648 | (org-at-item-description-p))) '("1.")) | ||
| 1649 | (unless (and bullet-rule-p | ||
| 1650 | (or (eq org-plain-list-ordered-item-terminator ?.) | ||
| 1651 | (org-at-item-description-p))) '("1)")))) | ||
| 1652 | (len (length bullet-list)) | ||
| 1653 | (item-index (- len (length (member current bullet-list)))) | ||
| 1654 | (get-value (lambda (index) (nth (mod index len) bullet-list))) | ||
| 1655 | (new (cond | ||
| 1656 | ((member which bullet-list) which) | ||
| 1657 | ((numberp which) (funcall get-value which)) | ||
| 1658 | ((eq 'previous which) (funcall get-value (1- item-index))) | ||
| 1659 | (t (funcall get-value (1+ item-index)))))) | ||
| 1660 | (org-list-repair new top))) | ||
| 1026 | 1661 | ||
| 1027 | (defun org-indent-item-tree (arg &optional no-subtree) | 1662 | ;;; Checkboxes |
| 1028 | "Indent a local list item including its children. | 1663 | |
| 1029 | If NO-SUBTREE is set, only indent the item itself, not its children." | 1664 | (defun org-toggle-checkbox (&optional toggle-presence) |
| 1030 | (interactive "p") | 1665 | "Toggle the checkbox in the current line. |
| 1031 | (and (org-region-active-p) (org-cursor-to-region-beginning)) | 1666 | With prefix arg TOGGLE-PRESENCE, add or remove checkboxes. With |
| 1032 | (unless (org-at-item-p) | 1667 | double prefix, set checkbox to [-]. |
| 1033 | (error "Not on an item")) | 1668 | |
| 1034 | (let (beg end ind ind1 ind-bul delta ind-down ind-up firstp) | 1669 | When there is an active region, toggle status or presence of the |
| 1035 | (setq firstp (org-first-list-item-p)) | 1670 | first checkbox there, and make every item inside have the |
| 1671 | same status or presence, respectively. | ||
| 1672 | |||
| 1673 | If the cursor is in a headline, apply this to all checkbox items | ||
| 1674 | in the text below the heading, taking as reference the first item | ||
| 1675 | in subtree, ignoring drawers." | ||
| 1676 | (interactive "P") | ||
| 1677 | ;; Bounds is a list of type (beg end single-p) where single-p is t | ||
| 1678 | ;; when `org-toggle-checkbox' is applied to a single item. Only | ||
| 1679 | ;; toggles on single items will return errors. | ||
| 1680 | (let* ((bounds | ||
| 1681 | (cond | ||
| 1682 | ((org-region-active-p) | ||
| 1683 | (let ((rbeg (region-beginning)) | ||
| 1684 | (rend (region-end))) | ||
| 1685 | (save-excursion | ||
| 1686 | (goto-char rbeg) | ||
| 1687 | (if (org-search-forward-unenclosed org-item-beginning-re rend 'move) | ||
| 1688 | (list (point-at-bol) rend nil) | ||
| 1689 | (error "No item in region"))))) | ||
| 1690 | ((org-on-heading-p) | ||
| 1691 | ;; In this case, reference line is the first item in | ||
| 1692 | ;; subtree outside drawers | ||
| 1693 | (let ((pos (point)) | ||
| 1694 | (limit (save-excursion (outline-next-heading) (point)))) | ||
| 1695 | (save-excursion | ||
| 1696 | (goto-char limit) | ||
| 1697 | (org-search-backward-unenclosed ":END:" pos 'move) | ||
| 1698 | (org-search-forward-unenclosed | ||
| 1699 | org-item-beginning-re limit 'move) | ||
| 1700 | (list (point) limit nil)))) | ||
| 1701 | ((org-at-item-p) | ||
| 1702 | (list (point-at-bol) (1+ (point-at-eol)) t)) | ||
| 1703 | (t (error "Not at an item or heading, and no active region")))) | ||
| 1704 | (beg (car bounds)) | ||
| 1705 | ;; marker is needed because deleting or inserting checkboxes | ||
| 1706 | ;; will change bottom point | ||
| 1707 | (end (copy-marker (nth 1 bounds))) | ||
| 1708 | (single-p (nth 2 bounds)) | ||
| 1709 | (ref-presence (save-excursion | ||
| 1710 | (goto-char beg) | ||
| 1711 | (org-at-item-checkbox-p))) | ||
| 1712 | (ref-status (equal (match-string 1) "[X]")) | ||
| 1713 | (act-on-item | ||
| 1714 | (lambda (ref-pres ref-stat) | ||
| 1715 | (if (equal toggle-presence '(4)) | ||
| 1716 | (cond | ||
| 1717 | ((and ref-pres (org-at-item-checkbox-p)) | ||
| 1718 | (replace-match "")) | ||
| 1719 | ((and (not ref-pres) | ||
| 1720 | (not (org-at-item-checkbox-p)) | ||
| 1721 | (org-at-item-p)) | ||
| 1722 | (goto-char (match-end 0)) | ||
| 1723 | ;; Ignore counter, if any | ||
| 1724 | (when (looking-at "\\(?:\\[@\\(?:start:\\)?[0-9]+\\][ \t]*\\)?") | ||
| 1725 | (goto-char (match-end 0))) | ||
| 1726 | (let ((desc-p (and (org-at-item-description-p) | ||
| 1727 | (cdr (assq 'checkbox org-list-automatic-rules))))) | ||
| 1728 | (cond | ||
| 1729 | ((and single-p desc-p) | ||
| 1730 | (error "Cannot add a checkbox in a description list")) | ||
| 1731 | ((not desc-p) (insert "[ ] ")))))) | ||
| 1732 | (let ((blocked (org-checkbox-blocked-p))) | ||
| 1733 | (cond | ||
| 1734 | ((and blocked single-p) | ||
| 1735 | (error "Checkbox blocked because of unchecked box in line %d" blocked)) | ||
| 1736 | (blocked nil) | ||
| 1737 | ((org-at-item-checkbox-p) | ||
| 1738 | (replace-match | ||
| 1739 | (cond ((equal toggle-presence '(16)) "[-]") | ||
| 1740 | (ref-stat "[ ]") | ||
| 1741 | (t "[X]")) | ||
| 1742 | t t nil 1)))))))) | ||
| 1036 | (save-excursion | 1743 | (save-excursion |
| 1037 | (setq end (and (org-region-active-p) (region-end))) | ||
| 1038 | (if (and (memq last-command '(org-shiftmetaright org-shiftmetaleft)) | ||
| 1039 | (memq this-command '(org-shiftmetaright org-shiftmetaleft))) | ||
| 1040 | (setq beg org-last-indent-begin-marker | ||
| 1041 | end org-last-indent-end-marker) | ||
| 1042 | (org-beginning-of-item) | ||
| 1043 | (setq beg (move-marker org-last-indent-begin-marker (point))) | ||
| 1044 | (if no-subtree | ||
| 1045 | (org-end-of-item-text-before-children) | ||
| 1046 | (org-end-of-item)) | ||
| 1047 | (setq end (move-marker org-last-indent-end-marker (or end (point))))) | ||
| 1048 | (goto-char beg) | 1744 | (goto-char beg) |
| 1049 | (setq ind-bul (org-item-indent-positions) | ||
| 1050 | ind (caar ind-bul) | ||
| 1051 | ind-down (car (nth 2 ind-bul)) | ||
| 1052 | ind-up (car (nth 1 ind-bul)) | ||
| 1053 | delta (if (> arg 0) | ||
| 1054 | (if ind-down (- ind-down ind) 2) | ||
| 1055 | (if ind-up (- ind-up ind) -2))) | ||
| 1056 | (if (< (+ delta ind) 0) (error "Cannot outdent beyond margin")) | ||
| 1057 | (while (< (point) end) | 1745 | (while (< (point) end) |
| 1058 | (beginning-of-line 1) | 1746 | (funcall act-on-item ref-presence ref-status) |
| 1059 | (skip-chars-forward " \t") (setq ind1 (current-column)) | 1747 | (org-search-forward-unenclosed org-item-beginning-re end 'move))) |
| 1060 | (delete-region (point-at-bol) (point)) | 1748 | (org-update-checkbox-count-maybe))) |
| 1061 | (or (eolp) (org-indent-to-column (+ ind1 delta))) | 1749 | |
| 1062 | (beginning-of-line 2))) | 1750 | (defun org-reset-checkbox-state-subtree () |
| 1063 | (org-fix-bullet-type | 1751 | "Reset all checkboxes in an entry subtree." |
| 1064 | (and (> arg 0) | 1752 | (interactive "*") |
| 1065 | (not firstp) | 1753 | (save-restriction |
| 1066 | (cdr (assoc (cdr (nth 0 ind-bul)) org-list-demote-modify-bullet)))) | ||
| 1067 | (org-maybe-renumber-ordered-list-safe) | ||
| 1068 | (save-excursion | ||
| 1069 | (beginning-of-line 0) | ||
| 1070 | (condition-case nil (org-beginning-of-item) (error nil)) | ||
| 1071 | (org-maybe-renumber-ordered-list-safe)))) | ||
| 1072 | |||
| 1073 | (defun org-item-indent-positions () | ||
| 1074 | "Return indentation for plain list items. | ||
| 1075 | This returns a list with three values: The current indentation, the | ||
| 1076 | parent indentation and the indentation a child should have. | ||
| 1077 | Assumes cursor in item line." | ||
| 1078 | (let* ((bolpos (point-at-bol)) | ||
| 1079 | (ind (org-get-indentation)) | ||
| 1080 | (bullet (org-get-bullet)) | ||
| 1081 | ind-down ind-up bullet-up bullet-down pos) | ||
| 1082 | (save-excursion | ||
| 1083 | (org-beginning-of-item-list) | ||
| 1084 | (skip-chars-backward "\n\r \t") | ||
| 1085 | (when (org-in-item-p) | ||
| 1086 | (org-beginning-of-item) | ||
| 1087 | (setq ind-up (org-get-indentation)) | ||
| 1088 | (setq bullet-up (org-get-bullet)))) | ||
| 1089 | (setq pos (point)) | ||
| 1090 | (save-excursion | 1754 | (save-excursion |
| 1091 | (cond | 1755 | (org-narrow-to-subtree) |
| 1092 | ((and (condition-case nil (progn (org-previous-item) t) | 1756 | (org-show-subtree) |
| 1093 | (error nil)) | 1757 | (goto-char (point-min)) |
| 1094 | (or (forward-char 1) t) | 1758 | (let ((end (point-max))) |
| 1095 | (re-search-forward "^\\([ \t]*\\([-+]\\|\\([0-9]+[.)]\\)\\)\\|[ \t]+\\*\\)\\( \\|$\\)" bolpos t)) | 1759 | (while (< (point) end) |
| 1096 | (setq ind-down (org-get-indentation) | 1760 | (when (org-at-item-checkbox-p) |
| 1097 | bullet-down (org-get-bullet))) | 1761 | (replace-match "[ ]" t t nil 1)) |
| 1098 | ((and (goto-char pos) | 1762 | (beginning-of-line 2)))) |
| 1099 | (org-at-item-p)) | 1763 | (org-update-checkbox-count-maybe))) |
| 1100 | (goto-char (match-end 0)) | ||
| 1101 | (skip-chars-forward " \t") | ||
| 1102 | (setq ind-down (current-column) | ||
| 1103 | bullet-down (org-get-bullet))))) | ||
| 1104 | (if (and bullet-down (string-match "\\`[0-9]+\\(\\.\\|)\\)\\'" bullet-down)) | ||
| 1105 | (setq bullet-down (concat "1" (match-string 1 bullet-down)))) | ||
| 1106 | (if (and bullet-up (string-match "\\`[0-9]+\\(\\.\\|)\\)\\'" bullet-up)) | ||
| 1107 | (setq bullet-up (concat "1" (match-string 1 bullet-up)))) | ||
| 1108 | (if (and bullet (string-match "\\`[0-9]+\\(\\.\\|)\\)\\'" bullet)) | ||
| 1109 | (setq bullet (concat "1" (match-string 1 bullet)))) | ||
| 1110 | (list (cons ind bullet) | ||
| 1111 | (cons ind-up bullet-up) | ||
| 1112 | (cons ind-down bullet-down)))) | ||
| 1113 | |||
| 1114 | (defvar org-tab-ind-state) ; defined in org.el | ||
| 1115 | (defun org-cycle-item-indentation () | ||
| 1116 | (let ((org-suppress-item-indentation t) | ||
| 1117 | (org-adapt-indentation nil)) | ||
| 1118 | (cond | ||
| 1119 | ((and (looking-at "[ \t]*$") | ||
| 1120 | (org-looking-back "^\\([ \t]*\\)\\([-+*]\\|[0-9]+[).]\\)[ \t]+")) | ||
| 1121 | (setq this-command 'org-cycle-item-indentation) | ||
| 1122 | (if (eq last-command 'org-cycle-item-indentation) | ||
| 1123 | (condition-case nil | ||
| 1124 | (progn (org-outdent-item 1) | ||
| 1125 | (if (equal org-tab-ind-state (org-get-indentation)) | ||
| 1126 | (org-outdent-item 1)) | ||
| 1127 | (end-of-line 1)) | ||
| 1128 | (error | ||
| 1129 | (progn | ||
| 1130 | (while (< (org-get-indentation) org-tab-ind-state) | ||
| 1131 | (progn (org-indent-item 1) (end-of-line 1))) | ||
| 1132 | (setq this-command 'org-cycle)))) | ||
| 1133 | (setq org-tab-ind-state (org-get-indentation)) | ||
| 1134 | (org-indent-item 1)) | ||
| 1135 | t)))) | ||
| 1136 | 1764 | ||
| 1137 | (defun org-get-bullet () | 1765 | (defvar org-checkbox-statistics-hook nil |
| 1766 | "Hook that is run whenever Org thinks checkbox statistics should be updated. | ||
| 1767 | This hook runs even if checkbox rule in | ||
| 1768 | `org-list-automatic-rules' does not apply, so it can be used to | ||
| 1769 | implement alternative ways of collecting statistics | ||
| 1770 | information.") | ||
| 1771 | |||
| 1772 | (defun org-update-checkbox-count-maybe () | ||
| 1773 | "Update checkbox statistics unless turned off by user." | ||
| 1774 | (when (cdr (assq 'checkbox org-list-automatic-rules)) | ||
| 1775 | (org-update-checkbox-count)) | ||
| 1776 | (run-hooks 'org-checkbox-statistics-hook)) | ||
| 1777 | |||
| 1778 | (defun org-update-checkbox-count (&optional all) | ||
| 1779 | "Update the checkbox statistics in the current section. | ||
| 1780 | This will find all statistic cookies like [57%] and [6/12] and update them | ||
| 1781 | with the current numbers. With optional prefix argument ALL, do this for | ||
| 1782 | the whole buffer." | ||
| 1783 | (interactive "P") | ||
| 1138 | (save-excursion | 1784 | (save-excursion |
| 1139 | (goto-char (point-at-bol)) | 1785 | (let ((cstat 0)) |
| 1140 | (and (looking-at | 1786 | (catch 'exit |
| 1141 | "^\\([ \t]*\\([-+]\\|\\([0-9]+[.)]\\)\\)\\|[ \t]+\\(\\*\\)\\)\\( \\|$\\)") | 1787 | (while t |
| 1142 | (or (match-string 2) (match-string 4))))) | 1788 | (let* ((buffer-invisibility-spec (org-inhibit-invisibility)) ; Emacs 21 |
| 1789 | (beg (condition-case nil | ||
| 1790 | (progn (org-back-to-heading) (point)) | ||
| 1791 | (error (point-min)))) | ||
| 1792 | (end (copy-marker (save-excursion | ||
| 1793 | (outline-next-heading) (point)))) | ||
| 1794 | (re-cookie "\\(\\(\\[[0-9]*%\\]\\)\\|\\(\\[[0-9]*/[0-9]*\\]\\)\\)") | ||
| 1795 | (re-box "^[ \t]*\\([-+*]\\|[0-9]+[.)]\\)[ \t]+\\(?:\\[@\\(?:start:\\)?[0-9]+\\][ \t]*\\)?\\(\\[[- X]\\]\\)") | ||
| 1796 | beg-cookie end-cookie is-percent c-on c-off lim new | ||
| 1797 | curr-ind next-ind continue-from startsearch list-beg list-end | ||
| 1798 | (recursive | ||
| 1799 | (or (not org-hierarchical-checkbox-statistics) | ||
| 1800 | (string-match "\\<recursive\\>" | ||
| 1801 | (or (ignore-errors | ||
| 1802 | (org-entry-get nil "COOKIE_DATA")) | ||
| 1803 | ""))))) | ||
| 1804 | (goto-char end) | ||
| 1805 | ;; find each statistics cookie | ||
| 1806 | (while (and (org-search-backward-unenclosed re-cookie beg 'move) | ||
| 1807 | (not (save-match-data | ||
| 1808 | (and (org-on-heading-p) | ||
| 1809 | (string-match "\\<todo\\>" | ||
| 1810 | (downcase | ||
| 1811 | (or (org-entry-get | ||
| 1812 | nil "COOKIE_DATA") | ||
| 1813 | ""))))))) | ||
| 1814 | (setq beg-cookie (match-beginning 1) | ||
| 1815 | end-cookie (match-end 1) | ||
| 1816 | cstat (+ cstat (if end-cookie 1 0)) | ||
| 1817 | startsearch (point-at-eol) | ||
| 1818 | continue-from (match-beginning 0) | ||
| 1819 | is-percent (match-beginning 2) | ||
| 1820 | lim (cond | ||
| 1821 | ((org-on-heading-p) (outline-next-heading) (point)) | ||
| 1822 | ;; Ensure many cookies in the same list won't imply | ||
| 1823 | ;; computing list boundaries as many times. | ||
| 1824 | ((org-at-item-p) | ||
| 1825 | (unless (and list-beg (>= (point) list-beg)) | ||
| 1826 | (setq list-beg (org-list-top-point) | ||
| 1827 | list-end (copy-marker | ||
| 1828 | (org-list-bottom-point)))) | ||
| 1829 | (org-get-end-of-item list-end)) | ||
| 1830 | (t nil)) | ||
| 1831 | c-on 0 | ||
| 1832 | c-off 0) | ||
| 1833 | (when lim | ||
| 1834 | ;; find first checkbox for this cookie and gather | ||
| 1835 | ;; statistics from all that are at this indentation level | ||
| 1836 | (goto-char startsearch) | ||
| 1837 | (if (org-search-forward-unenclosed re-box lim t) | ||
| 1838 | (progn | ||
| 1839 | (beginning-of-line) | ||
| 1840 | (setq curr-ind (org-get-indentation)) | ||
| 1841 | (setq next-ind curr-ind) | ||
| 1842 | (while (and (bolp) (org-at-item-p) | ||
| 1843 | (if recursive | ||
| 1844 | (<= curr-ind next-ind) | ||
| 1845 | (= curr-ind next-ind))) | ||
| 1846 | (when (org-at-item-checkbox-p) | ||
| 1847 | (if (member (match-string 1) '("[ ]" "[-]")) | ||
| 1848 | (setq c-off (1+ c-off)) | ||
| 1849 | (setq c-on (1+ c-on)))) | ||
| 1850 | (if (not recursive) | ||
| 1851 | ;; org-get-next-item goes through list-enders | ||
| 1852 | ;; with proper limit. | ||
| 1853 | (goto-char (or (org-get-next-item (point) lim) lim)) | ||
| 1854 | (end-of-line) | ||
| 1855 | (when (org-search-forward-unenclosed | ||
| 1856 | org-item-beginning-re lim t) | ||
| 1857 | (beginning-of-line))) | ||
| 1858 | (setq next-ind (org-get-indentation))))) | ||
| 1859 | (goto-char continue-from) | ||
| 1860 | ;; update cookie | ||
| 1861 | (when end-cookie | ||
| 1862 | (setq new (if is-percent | ||
| 1863 | (format "[%d%%]" (/ (* 100 c-on) | ||
| 1864 | (max 1 (+ c-on c-off)))) | ||
| 1865 | (format "[%d/%d]" c-on (+ c-on c-off)))) | ||
| 1866 | (goto-char beg-cookie) | ||
| 1867 | (insert new) | ||
| 1868 | (delete-region (point) (+ (point) (- end-cookie beg-cookie)))) | ||
| 1869 | ;; update items checkbox if it has one | ||
| 1870 | (when (and (org-at-item-checkbox-p) | ||
| 1871 | (> (+ c-on c-off) 0)) | ||
| 1872 | (setq beg-cookie (match-beginning 1) | ||
| 1873 | end-cookie (match-end 1)) | ||
| 1874 | (delete-region beg-cookie end-cookie) | ||
| 1875 | (goto-char beg-cookie) | ||
| 1876 | (cond ((= c-off 0) (insert "[X]")) | ||
| 1877 | ((= c-on 0) (insert "[ ]")) | ||
| 1878 | (t (insert "[-]"))))) | ||
| 1879 | (goto-char continue-from))) | ||
| 1880 | (unless (and all (outline-next-heading)) (throw 'exit nil)))) | ||
| 1881 | (when (interactive-p) | ||
| 1882 | (message "Checkbox statistics updated %s (%d places)" | ||
| 1883 | (if all "in entire file" "in current outline entry") cstat))))) | ||
| 1884 | |||
| 1885 | (defun org-get-checkbox-statistics-face () | ||
| 1886 | "Select the face for checkbox statistics. | ||
| 1887 | The face will be `org-done' when all relevant boxes are checked. | ||
| 1888 | Otherwise it will be `org-todo'." | ||
| 1889 | (if (match-end 1) | ||
| 1890 | (if (equal (match-string 1) "100%") | ||
| 1891 | 'org-checkbox-statistics-done | ||
| 1892 | 'org-checkbox-statistics-todo) | ||
| 1893 | (if (and (> (match-end 2) (match-beginning 2)) | ||
| 1894 | (equal (match-string 2) (match-string 3))) | ||
| 1895 | 'org-checkbox-statistics-done | ||
| 1896 | 'org-checkbox-statistics-todo))) | ||
| 1897 | |||
| 1898 | ;;; Misc Tools | ||
| 1899 | |||
| 1900 | (defun org-apply-on-list (function init-value &rest args) | ||
| 1901 | "Call FUNCTION on each item of the list at point. | ||
| 1902 | FUNCTION must be called with at least one argument: INIT-VALUE, | ||
| 1903 | that will contain the value returned by the function at the | ||
| 1904 | previous item, plus ARGS extra arguments. | ||
| 1905 | |||
| 1906 | As an example, (org-apply-on-list (lambda (result) (1+ result)) 0) | ||
| 1907 | will return the number of items in the current list. | ||
| 1908 | |||
| 1909 | Sublists of the list are skipped. Cursor is always at the | ||
| 1910 | beginning of the item." | ||
| 1911 | (let* ((pos (copy-marker (point))) | ||
| 1912 | (end (copy-marker (org-list-bottom-point))) | ||
| 1913 | (next-p (copy-marker (org-get-beginning-of-list (org-list-top-point)))) | ||
| 1914 | (value init-value)) | ||
| 1915 | (while (< next-p end) | ||
| 1916 | (goto-char next-p) | ||
| 1917 | (set-marker next-p (or (org-get-next-item (point) end) end)) | ||
| 1918 | (setq value (apply function value args))) | ||
| 1919 | (goto-char pos) | ||
| 1920 | value)) | ||
| 1921 | |||
| 1922 | (defun org-sort-list (&optional with-case sorting-type getkey-func compare-func) | ||
| 1923 | "Sort plain list items. | ||
| 1924 | The cursor may be at any item of the list that should be sorted. | ||
| 1925 | Sublists are not sorted. Checkboxes, if any, are ignored. | ||
| 1926 | |||
| 1927 | Sorting can be alphabetically, numerically, by date/time as given by | ||
| 1928 | a time stamp, by a property or by priority. | ||
| 1929 | |||
| 1930 | Comparing entries ignores case by default. However, with an | ||
| 1931 | optional argument WITH-CASE, the sorting considers case as well. | ||
| 1932 | |||
| 1933 | The command prompts for the sorting type unless it has been given | ||
| 1934 | to the function through the SORTING-TYPE argument, which needs to | ||
| 1935 | be a character, \(?n ?N ?a ?A ?t ?T ?f ?F). Here is the precise | ||
| 1936 | meaning of each character: | ||
| 1937 | |||
| 1938 | n Numerically, by converting the beginning of the item to a number. | ||
| 1939 | a Alphabetically. Only the first line of item is checked. | ||
| 1940 | t By date/time, either the first active time stamp in the entry, if | ||
| 1941 | any, or by the first inactive one. In a timer list, sort the timers. | ||
| 1942 | |||
| 1943 | Capital letters will reverse the sort order. | ||
| 1944 | |||
| 1945 | If the SORTING-TYPE is ?f or ?F, then GETKEY-FUNC specifies a | ||
| 1946 | function to be called with point at the beginning of the record. | ||
| 1947 | It must return either a string or a number that should serve as | ||
| 1948 | the sorting key for that record. It will then use COMPARE-FUNC to | ||
| 1949 | compare entries." | ||
| 1950 | (interactive "P") | ||
| 1951 | (let* ((case-func (if with-case 'identity 'downcase)) | ||
| 1952 | (top (org-list-top-point)) | ||
| 1953 | (bottom (org-list-bottom-point)) | ||
| 1954 | (start (org-get-beginning-of-list top)) | ||
| 1955 | (end (org-get-end-of-list bottom)) | ||
| 1956 | (sorting-type | ||
| 1957 | (progn | ||
| 1958 | (message | ||
| 1959 | "Sort plain list: [a]lpha [n]umeric [t]ime [f]unc A/N/T/F means reversed:") | ||
| 1960 | (read-char-exclusive))) | ||
| 1961 | (getkey-func (and (= (downcase sorting-type) ?f) | ||
| 1962 | (org-icompleting-read "Sort using function: " | ||
| 1963 | obarray 'fboundp t nil nil) | ||
| 1964 | (intern getkey-func)))) | ||
| 1965 | (message "Sorting items...") | ||
| 1966 | (save-restriction | ||
| 1967 | (narrow-to-region start end) | ||
| 1968 | (goto-char (point-min)) | ||
| 1969 | (let* ((dcst (downcase sorting-type)) | ||
| 1970 | (case-fold-search nil) | ||
| 1971 | (now (current-time)) | ||
| 1972 | (sort-func (cond | ||
| 1973 | ((= dcst ?a) 'string<) | ||
| 1974 | ((= dcst ?f) compare-func) | ||
| 1975 | ((= dcst ?t) '<) | ||
| 1976 | (t nil))) | ||
| 1977 | (begin-record (lambda () | ||
| 1978 | (skip-chars-forward " \r\t\n") | ||
| 1979 | (beginning-of-line))) | ||
| 1980 | (end-record (lambda () | ||
| 1981 | (goto-char (org-end-of-item-before-blank end)))) | ||
| 1982 | (value-to-sort | ||
| 1983 | (lambda () | ||
| 1984 | (when (looking-at "[ \t]*[-+*0-9.)]+\\([ \t]+\\[[- X]\\]\\)?[ \t]+") | ||
| 1985 | (cond | ||
| 1986 | ((= dcst ?n) | ||
| 1987 | (string-to-number (buffer-substring (match-end 0) | ||
| 1988 | (point-at-eol)))) | ||
| 1989 | ((= dcst ?a) | ||
| 1990 | (buffer-substring (match-end 0) (point-at-eol))) | ||
| 1991 | ((= dcst ?t) | ||
| 1992 | (cond | ||
| 1993 | ;; If it is a timer list, convert timer to seconds | ||
| 1994 | ((org-at-item-timer-p) | ||
| 1995 | (org-timer-hms-to-secs (match-string 1))) | ||
| 1996 | ((or (org-search-forward-unenclosed org-ts-regexp | ||
| 1997 | (point-at-eol) t) | ||
| 1998 | (org-search-forward-unenclosed org-ts-regexp-both | ||
| 1999 | (point-at-eol) t)) | ||
| 2000 | (org-time-string-to-seconds (match-string 0))) | ||
| 2001 | (t (org-float-time now)))) | ||
| 2002 | ((= dcst ?f) | ||
| 2003 | (if getkey-func | ||
| 2004 | (let ((value (funcall getkey-func))) | ||
| 2005 | (if (stringp value) | ||
| 2006 | (funcall case-func value) | ||
| 2007 | value)) | ||
| 2008 | (error "Invalid key function `%s'" getkey-func))) | ||
| 2009 | (t (error "Invalid sorting type `%c'" sorting-type))))))) | ||
| 2010 | (sort-subr (/= dcst sorting-type) | ||
| 2011 | begin-record | ||
| 2012 | end-record | ||
| 2013 | value-to-sort | ||
| 2014 | nil | ||
| 2015 | sort-func) | ||
| 2016 | (org-list-repair nil top bottom) | ||
| 2017 | (run-hooks 'org-after-sorting-entries-or-items-hook) | ||
| 2018 | (message "Sorting items...done"))))) | ||
| 1143 | 2019 | ||
| 1144 | ;;; Send and receive lists | 2020 | ;;; Send and receive lists |
| 1145 | 2021 | ||
| @@ -1147,85 +2023,55 @@ Assumes cursor in item line." | |||
| 1147 | "Parse the list at point and maybe DELETE it. | 2023 | "Parse the list at point and maybe DELETE it. |
| 1148 | Return a list containing first level items as strings and | 2024 | Return a list containing first level items as strings and |
| 1149 | sublevels as a list of strings." | 2025 | sublevels as a list of strings." |
| 1150 | (let* ((item-beginning (org-list-item-beginning)) | 2026 | (let* ((start (goto-char (org-list-top-point))) |
| 1151 | (start (car item-beginning)) | 2027 | (end (org-list-bottom-point)) |
| 1152 | (end (save-excursion | ||
| 1153 | (goto-char (org-list-end (cdr item-beginning))) | ||
| 1154 | (org-back-over-empty-lines) | ||
| 1155 | (point))) | ||
| 1156 | output itemsep ltype) | 2028 | output itemsep ltype) |
| 1157 | (while (re-search-forward org-list-beginning-re end t) | 2029 | (while (org-search-forward-unenclosed org-item-beginning-re end t) |
| 1158 | (goto-char (match-beginning 3)) | 2030 | (save-excursion |
| 1159 | (save-match-data | 2031 | (beginning-of-line) |
| 1160 | (cond ((string-match "[0-9]" (match-string 2)) | 2032 | (setq ltype (cond ((looking-at-p "^[ \t]*[0-9]") 'ordered) |
| 1161 | (setq itemsep "[0-9]+\\(?:\\.\\|)\\)" | 2033 | ((org-at-item-description-p) 'descriptive) |
| 1162 | ltype 'ordered)) | 2034 | (t 'unordered)))) |
| 1163 | ((string-match "^.*::" (match-string 0)) | 2035 | (let* ((indent1 (org-get-indentation)) |
| 1164 | (setq itemsep "[-+]" ltype 'descriptive)) | 2036 | (nextitem (or (org-get-next-item (point) end) end)) |
| 1165 | (t (setq itemsep "[-+]" ltype 'unordered)))) | 2037 | (item (org-trim (buffer-substring (point) |
| 1166 | (let* ((indent1 (match-string 1)) | 2038 | (org-end-of-item-or-at-child end)))) |
| 1167 | (nextitem (save-excursion | 2039 | (nextindent (if (= (point) end) 0 (org-get-indentation))) |
| 1168 | (save-match-data | 2040 | (item (if (string-match |
| 1169 | (or (and (re-search-forward | 2041 | "^\\(?:\\[@\\(?:start:\\)?[0-9]+\\][ \t]*\\)?\\[\\([xX ]\\)\\]" |
| 1170 | (concat "^" indent1 itemsep " *?") end t) | 2042 | item) |
| 1171 | (match-beginning 0)) end)))) | ||
| 1172 | (item (buffer-substring | ||
| 1173 | (point) | ||
| 1174 | (or (and (org-re-search-forward-unprotected | ||
| 1175 | org-list-beginning-re end t) | ||
| 1176 | (goto-char (match-beginning 0))) | ||
| 1177 | (goto-char end)))) | ||
| 1178 | (nextindent (match-string 1)) | ||
| 1179 | (item (org-trim item)) | ||
| 1180 | (item (if (string-match "^\\[\\([xX ]\\)\\]" item) | ||
| 1181 | (replace-match (if (equal (match-string 1 item) " ") | 2043 | (replace-match (if (equal (match-string 1 item) " ") |
| 1182 | "[CBOFF]" | 2044 | "CBOFF" |
| 1183 | "[CBON]") | 2045 | "CBON") |
| 1184 | t nil item) | 2046 | t nil item 1) |
| 1185 | item))) | 2047 | item))) |
| 1186 | (push item output) | 2048 | (push item output) |
| 1187 | (when (> (length nextindent) | 2049 | (when (> nextindent indent1) |
| 1188 | (length indent1)) | 2050 | (save-restriction |
| 1189 | (narrow-to-region (point) nextitem) | 2051 | (narrow-to-region (point) nextitem) |
| 1190 | (push (org-list-parse-list) output) | 2052 | (push (org-list-parse-list) output))))) |
| 1191 | (widen)))) | 2053 | (when delete |
| 1192 | (when delete (delete-region start end)) | 2054 | (delete-region start end) |
| 2055 | (save-match-data | ||
| 2056 | (when (and (not (eq org-list-ending-method 'indent)) | ||
| 2057 | (looking-at (org-list-end-re))) | ||
| 2058 | (replace-match "\n")))) | ||
| 1193 | (setq output (nreverse output)) | 2059 | (setq output (nreverse output)) |
| 1194 | (push ltype output))) | 2060 | (push ltype output))) |
| 1195 | 2061 | ||
| 1196 | (defun org-list-item-beginning () | ||
| 1197 | "Find the beginning of the list item. | ||
| 1198 | Return a cons which car is the beginning position of the item and | ||
| 1199 | cdr is the indentation string." | ||
| 1200 | (save-excursion | ||
| 1201 | (if (not (or (looking-at org-list-beginning-re) | ||
| 1202 | (re-search-backward | ||
| 1203 | org-list-beginning-re nil t))) | ||
| 1204 | (progn (goto-char (point-min)) (point)) | ||
| 1205 | (cons (match-beginning 0) (match-string 1))))) | ||
| 1206 | |||
| 1207 | (defun org-list-goto-true-beginning () | ||
| 1208 | "Go to the beginning of the list at point." | ||
| 1209 | (beginning-of-line 1) | ||
| 1210 | (while (looking-at org-list-beginning-re) | ||
| 1211 | (beginning-of-line 0)) | ||
| 1212 | (progn | ||
| 1213 | (re-search-forward org-list-beginning-re nil t) | ||
| 1214 | (goto-char (match-beginning 0)))) | ||
| 1215 | |||
| 1216 | (defun org-list-make-subtree () | 2062 | (defun org-list-make-subtree () |
| 1217 | "Convert the plain list at point into a subtree." | 2063 | "Convert the plain list at point into a subtree." |
| 1218 | (interactive) | 2064 | (interactive) |
| 1219 | (org-list-goto-true-beginning) | 2065 | (if (not (org-in-item-p)) |
| 1220 | (let ((list (org-list-parse-list t)) nstars) | 2066 | (error "Not in a list") |
| 1221 | (save-excursion | 2067 | (let ((list (org-list-parse-list t)) nstars) |
| 1222 | (if (condition-case nil | 2068 | (save-excursion |
| 1223 | (org-back-to-heading) | 2069 | (if (ignore-errors |
| 1224 | (error nil)) | 2070 | (org-back-to-heading)) |
| 1225 | (progn (re-search-forward org-complex-heading-regexp nil t) | 2071 | (progn (looking-at org-complex-heading-regexp) |
| 1226 | (setq nstars (length (match-string 1)))) | 2072 | (setq nstars (length (match-string 1)))) |
| 1227 | (setq nstars 0))) | 2073 | (setq nstars 0))) |
| 1228 | (org-list-make-subtrees list (1+ nstars)))) | 2074 | (org-list-make-subtrees list (1+ nstars))))) |
| 1229 | 2075 | ||
| 1230 | (defun org-list-make-subtrees (list level) | 2076 | (defun org-list-make-subtrees (list level) |
| 1231 | "Convert LIST into subtrees starting at LEVEL." | 2077 | "Convert LIST into subtrees starting at LEVEL." |
| @@ -1239,20 +2085,6 @@ cdr is the indentation string." | |||
| 1239 | (org-list-make-subtrees item (1+ level)))) | 2085 | (org-list-make-subtrees item (1+ level)))) |
| 1240 | list))) | 2086 | list))) |
| 1241 | 2087 | ||
| 1242 | (defun org-list-end (indent) | ||
| 1243 | "Return the position of the end of the list. | ||
| 1244 | INDENT is the indentation of the list, as a string." | ||
| 1245 | (save-excursion | ||
| 1246 | (catch 'exit | ||
| 1247 | (while (or (looking-at org-list-beginning-re) | ||
| 1248 | (looking-at (concat "^" indent "[ \t]+\\|^$")) | ||
| 1249 | (> (or (get-text-property (point) 'original-indentation) -1) | ||
| 1250 | (length indent))) | ||
| 1251 | (if (eq (point) (point-max)) | ||
| 1252 | (throw 'exit (point-max))) | ||
| 1253 | (forward-line 1))) | ||
| 1254 | (point))) | ||
| 1255 | |||
| 1256 | (defun org-list-insert-radio-list () | 2088 | (defun org-list-insert-radio-list () |
| 1257 | "Insert a radio list template appropriate for this major mode." | 2089 | "Insert a radio list template appropriate for this major mode." |
| 1258 | (interactive) | 2090 | (interactive) |
| @@ -1274,20 +2106,29 @@ With argument MAYBE, fail quietly if no transformation is defined for | |||
| 1274 | this list." | 2106 | this list." |
| 1275 | (interactive) | 2107 | (interactive) |
| 1276 | (catch 'exit | 2108 | (catch 'exit |
| 1277 | (unless (org-at-item-p) (error "Not at a list")) | 2109 | (unless (org-at-item-p) (error "Not at a list item")) |
| 1278 | (save-excursion | 2110 | (save-excursion |
| 1279 | (org-list-goto-true-beginning) | 2111 | (re-search-backward "#\\+ORGLST" nil t) |
| 1280 | (beginning-of-line 0) | ||
| 1281 | (unless (looking-at "[ \t]*#\\+ORGLST[: \t][ \t]*SEND[ \t]+\\([^ \t\r\n]+\\)[ \t]+\\([^ \t\r\n]+\\)\\([ \t]+.*\\)?") | 2112 | (unless (looking-at "[ \t]*#\\+ORGLST[: \t][ \t]*SEND[ \t]+\\([^ \t\r\n]+\\)[ \t]+\\([^ \t\r\n]+\\)\\([ \t]+.*\\)?") |
| 1282 | (if maybe | 2113 | (if maybe |
| 1283 | (throw 'exit nil) | 2114 | (throw 'exit nil) |
| 1284 | (error "Don't know how to transform this list")))) | 2115 | (error "Don't know how to transform this list")))) |
| 1285 | (let* ((name (match-string 1)) | 2116 | (let* ((name (match-string 1)) |
| 1286 | (transform (intern (match-string 2))) | 2117 | (transform (intern (match-string 2))) |
| 1287 | (item-beginning (org-list-item-beginning)) | 2118 | (bottom-point |
| 1288 | (list (save-excursion (org-list-goto-true-beginning) | 2119 | (save-excursion |
| 1289 | (org-list-parse-list))) | 2120 | (re-search-forward |
| 1290 | txt beg) | 2121 | "\\(\\\\end{comment}\\|@end ignore\\|-->\\)" nil t) |
| 2122 | (match-beginning 0))) | ||
| 2123 | (top-point | ||
| 2124 | (progn | ||
| 2125 | (re-search-backward "#\\+ORGLST" nil t) | ||
| 2126 | (re-search-forward org-item-beginning-re bottom-point t) | ||
| 2127 | (match-beginning 0))) | ||
| 2128 | (list (save-restriction | ||
| 2129 | (narrow-to-region top-point bottom-point) | ||
| 2130 | (org-list-parse-list))) | ||
| 2131 | beg txt) | ||
| 1291 | (unless (fboundp transform) | 2132 | (unless (fboundp transform) |
| 1292 | (error "No such transformation function %s" transform)) | 2133 | (error "No such transformation function %s" transform)) |
| 1293 | (let ((txt (funcall transform list))) | 2134 | (let ((txt (funcall transform list))) |
| @@ -1295,22 +2136,22 @@ this list." | |||
| 1295 | (save-excursion | 2136 | (save-excursion |
| 1296 | (goto-char (point-min)) | 2137 | (goto-char (point-min)) |
| 1297 | (unless (re-search-forward | 2138 | (unless (re-search-forward |
| 1298 | (concat "BEGIN RECEIVE ORGLST +" name "\\([ \t]\\|$\\)") nil t) | 2139 | (concat "BEGIN RECEIVE ORGLST +" |
| 2140 | name | ||
| 2141 | "\\([ \t]\\|$\\)") nil t) | ||
| 1299 | (error "Don't know where to insert translated list")) | 2142 | (error "Don't know where to insert translated list")) |
| 1300 | (goto-char (match-beginning 0)) | 2143 | (goto-char (match-beginning 0)) |
| 1301 | (beginning-of-line 2) | 2144 | (beginning-of-line 2) |
| 1302 | (setq beg (point)) | 2145 | (setq beg (point)) |
| 1303 | (unless (re-search-forward (concat "END RECEIVE ORGLST +" name) nil t) | 2146 | (unless (re-search-forward (concat "END RECEIVE ORGLST +" name) nil t) |
| 1304 | (error "Cannot find end of insertion region")) | 2147 | (error "Cannot find end of insertion region")) |
| 1305 | (beginning-of-line 1) | 2148 | (delete-region beg (point-at-bol)) |
| 1306 | (delete-region beg (point)) | ||
| 1307 | (goto-char beg) | 2149 | (goto-char beg) |
| 1308 | (insert txt "\n"))) | 2150 | (insert txt "\n"))) |
| 1309 | (message "List converted and installed at receiver location")))) | 2151 | (message "List converted and installed at receiver location")))) |
| 1310 | 2152 | ||
| 1311 | (defun org-list-to-generic (list params) | 2153 | (defun org-list-to-generic (list params) |
| 1312 | "Convert a LIST parsed through `org-list-parse-list' to other formats. | 2154 | "Convert a LIST parsed through `org-list-parse-list' to other formats. |
| 1313 | |||
| 1314 | Valid parameters PARAMS are | 2155 | Valid parameters PARAMS are |
| 1315 | 2156 | ||
| 1316 | :ustart String to start an unordered list | 2157 | :ustart String to start an unordered list |
| @@ -1339,21 +2180,21 @@ Valid parameters PARAMS are | |||
| 1339 | (interactive) | 2180 | (interactive) |
| 1340 | (let* ((p params) sublist | 2181 | (let* ((p params) sublist |
| 1341 | (splicep (plist-get p :splice)) | 2182 | (splicep (plist-get p :splice)) |
| 1342 | (ostart (plist-get p :ostart)) | 2183 | (ostart (plist-get p :ostart)) |
| 1343 | (oend (plist-get p :oend)) | 2184 | (oend (plist-get p :oend)) |
| 1344 | (ustart (plist-get p :ustart)) | 2185 | (ustart (plist-get p :ustart)) |
| 1345 | (uend (plist-get p :uend)) | 2186 | (uend (plist-get p :uend)) |
| 1346 | (dstart (plist-get p :dstart)) | 2187 | (dstart (plist-get p :dstart)) |
| 1347 | (dend (plist-get p :dend)) | 2188 | (dend (plist-get p :dend)) |
| 1348 | (dtstart (plist-get p :dtstart)) | 2189 | (dtstart (plist-get p :dtstart)) |
| 1349 | (dtend (plist-get p :dtend)) | 2190 | (dtend (plist-get p :dtend)) |
| 1350 | (ddstart (plist-get p :ddstart)) | 2191 | (ddstart (plist-get p :ddstart)) |
| 1351 | (ddend (plist-get p :ddend)) | 2192 | (ddend (plist-get p :ddend)) |
| 1352 | (istart (plist-get p :istart)) | 2193 | (istart (plist-get p :istart)) |
| 1353 | (iend (plist-get p :iend)) | 2194 | (iend (plist-get p :iend)) |
| 1354 | (isep (plist-get p :isep)) | 2195 | (isep (plist-get p :isep)) |
| 1355 | (lsep (plist-get p :lsep)) | 2196 | (lsep (plist-get p :lsep)) |
| 1356 | (cbon (plist-get p :cbon)) | 2197 | (cbon (plist-get p :cbon)) |
| 1357 | (cboff (plist-get p :cboff))) | 2198 | (cboff (plist-get p :cboff))) |
| 1358 | (let ((wrapper | 2199 | (let ((wrapper |
| 1359 | (cond ((eq (car list) 'ordered) | 2200 | (cond ((eq (car list) 'ordered) |
| @@ -1366,22 +2207,24 @@ Valid parameters PARAMS are | |||
| 1366 | (while (setq sublist (pop list)) | 2207 | (while (setq sublist (pop list)) |
| 1367 | (cond ((symbolp sublist) nil) | 2208 | (cond ((symbolp sublist) nil) |
| 1368 | ((stringp sublist) | 2209 | ((stringp sublist) |
| 1369 | (when (string-match "^\\(.*\\) ::" sublist) | 2210 | (when (string-match "^\\(.*\\)[ \t]+::" sublist) |
| 1370 | (setq term (org-trim (format (concat dtstart "%s" dtend) | 2211 | (setq term (org-trim (format (concat dtstart "%s" dtend) |
| 1371 | (match-string 1 sublist)))) | 2212 | (match-string 1 sublist)))) |
| 1372 | (setq sublist (substring sublist (1+ (length term))))) | 2213 | (setq sublist (concat ddstart |
| 2214 | (org-trim (substring sublist | ||
| 2215 | (match-end 0))) | ||
| 2216 | ddend))) | ||
| 1373 | (if (string-match "\\[CBON\\]" sublist) | 2217 | (if (string-match "\\[CBON\\]" sublist) |
| 1374 | (setq sublist (replace-match cbon t t sublist))) | 2218 | (setq sublist (replace-match cbon t t sublist))) |
| 1375 | (if (string-match "\\[CBOFF\\]" sublist) | 2219 | (if (string-match "\\[CBOFF\\]" sublist) |
| 1376 | (setq sublist (replace-match cboff t t sublist))) | 2220 | (setq sublist (replace-match cboff t t sublist))) |
| 1377 | (if (string-match "\\[-\\]" sublist) | 2221 | (if (string-match "\\[-\\]" sublist) |
| 1378 | (setq sublist (replace-match "$\\boxminus$" t t sublist))) | 2222 | (setq sublist (replace-match "$\\boxminus$" t t sublist))) |
| 1379 | (setq rtn (concat rtn istart term ddstart | 2223 | (setq rtn (concat rtn istart term sublist iend isep))) |
| 1380 | sublist ddend iend isep))) | 2224 | (t (setq rtn (concat rtn ;; previous list |
| 1381 | (t (setq rtn (concat rtn ;; previous list | 2225 | lsep ;; list separator |
| 1382 | lsep ;; list separator | ||
| 1383 | (org-list-to-generic sublist p) | 2226 | (org-list-to-generic sublist p) |
| 1384 | lsep ;; list separator | 2227 | lsep ;; list separator |
| 1385 | ))))) | 2228 | ))))) |
| 1386 | (format wrapper rtn)))) | 2229 | (format wrapper rtn)))) |
| 1387 | 2230 | ||
diff --git a/lisp/org/org-mac-message.el b/lisp/org/org-mac-message.el index 06591703da9..afac5ca71b1 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.01 | 8 | ;; Version: 7.3 |
| 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 212fae4fcc9..5a5612387fd 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.01 | 9 | ;; Version: 7.3 |
| 10 | ;; | 10 | ;; |
| 11 | ;; This file is part of GNU Emacs. | 11 | ;; This file is part of GNU Emacs. |
| 12 | ;; | 12 | ;; |
| @@ -38,11 +38,27 @@ | |||
| 38 | (defmacro declare-function (fn file &optional arglist fileonly)))) | 38 | (defmacro declare-function (fn file &optional arglist fileonly)))) |
| 39 | 39 | ||
| 40 | (declare-function org-add-props "org-compat" (string plist &rest props)) | 40 | (declare-function org-add-props "org-compat" (string plist &rest props)) |
| 41 | (declare-function org-string-match-p "org-compat" (&rest args)) | ||
| 42 | |||
| 43 | (defmacro org-called-interactively-p (&optional kind) | ||
| 44 | `(if (featurep 'xemacs) | ||
| 45 | (interactive-p) | ||
| 46 | (if (or (> emacs-major-version 23) | ||
| 47 | (and (>= emacs-major-version 23) | ||
| 48 | (>= emacs-minor-version 2))) | ||
| 49 | (called-interactively-p ,kind) | ||
| 50 | (interactive-p)))) | ||
| 41 | 51 | ||
| 42 | (defmacro org-bound-and-true-p (var) | 52 | (defmacro org-bound-and-true-p (var) |
| 43 | "Return the value of symbol VAR if it is bound, else nil." | 53 | "Return the value of symbol VAR if it is bound, else nil." |
| 44 | `(and (boundp (quote ,var)) ,var)) | 54 | `(and (boundp (quote ,var)) ,var)) |
| 45 | 55 | ||
| 56 | (defun org-string-nw-p (s) | ||
| 57 | "Is S a string with a non-white character?" | ||
| 58 | (and (stringp s) | ||
| 59 | (org-string-match-p "\\S-" s) | ||
| 60 | s)) | ||
| 61 | |||
| 46 | (defun org-not-nil (v) | 62 | (defun org-not-nil (v) |
| 47 | "If V not nil, and also not the string \"nil\", then return V. | 63 | "If V not nil, and also not the string \"nil\", then return V. |
| 48 | Otherwise return nil." | 64 | Otherwise return nil." |
| @@ -283,63 +299,6 @@ This is in contrast to merely setting it to 0." | |||
| 283 | (match-beginning 0) string))) | 299 | (match-beginning 0) string))) |
| 284 | (replace-match newtext fixedcase literal string)) | 300 | (replace-match newtext fixedcase literal string)) |
| 285 | 301 | ||
| 286 | (defmacro org-with-limited-levels (&rest body) | ||
| 287 | "Execute BODY with limited number of outline levels." | ||
| 288 | `(let* ((outline-regexp (org-get-limited-outline-regexp))) | ||
| 289 | ,@body)) | ||
| 290 | |||
| 291 | (defvar org-odd-levels-only) ; defined in org.el | ||
| 292 | (defvar org-inlinetask-min-level) ; defined in org-inlinetask.el | ||
| 293 | (defun org-get-limited-outline-regexp () | ||
| 294 | "Return outline-regexp with limited number of levels. | ||
| 295 | The number of levels is controlled by `org-inlinetask-min-level'" | ||
| 296 | (if (or (not (org-mode-p)) (not (featurep 'org-inlinetask))) | ||
| 297 | |||
| 298 | outline-regexp | ||
| 299 | (let* ((limit-level (1- org-inlinetask-min-level)) | ||
| 300 | (nstars (if org-odd-levels-only (1- (* limit-level 2)) limit-level))) | ||
| 301 | (format "\\*\\{1,%d\\} " nstars)))) | ||
| 302 | |||
| 303 | |||
| 304 | ;;; Saving and restoring visibility | ||
| 305 | |||
| 306 | (defun org-outline-overlay-data (&optional use-markers) | ||
| 307 | "Return a list of the locations of all outline overlays. | ||
| 308 | The are overlays with the `invisible' property value `outline'. | ||
| 309 | The return values is a list of cons cells, with start and stop | ||
| 310 | positions for each overlay. | ||
| 311 | If USE-MARKERS is set, return the positions as markers." | ||
| 312 | (let (beg end) | ||
| 313 | (save-excursion | ||
| 314 | (save-restriction | ||
| 315 | (widen) | ||
| 316 | (delq nil | ||
| 317 | (mapcar (lambda (o) | ||
| 318 | (when (eq (overlay-get o 'invisible) 'outline) | ||
| 319 | (setq beg (overlay-start o) | ||
| 320 | end (overlay-end o)) | ||
| 321 | (and beg end (> end beg) | ||
| 322 | (if use-markers | ||
| 323 | (cons (move-marker (make-marker) beg) | ||
| 324 | (move-marker (make-marker) end)) | ||
| 325 | (cons beg end))))) | ||
| 326 | (overlays-in (point-min) (point-max)))))))) | ||
| 327 | |||
| 328 | (autoload 'show-all "outline" nil t) | ||
| 329 | |||
| 330 | (defun org-set-outline-overlay-data (data) | ||
| 331 | "Create visibility overlays for all positions in DATA. | ||
| 332 | DATA should have been made by `org-outline-overlay-data'." | ||
| 333 | (let (o) | ||
| 334 | (save-excursion | ||
| 335 | (save-restriction | ||
| 336 | (widen) | ||
| 337 | (show-all) | ||
| 338 | (mapc (lambda (c) | ||
| 339 | (setq o (make-overlay (car c) (cdr c))) | ||
| 340 | (overlay-put o 'invisible 'outline)) | ||
| 341 | data))))) | ||
| 342 | |||
| 343 | (defmacro org-save-outline-visibility (use-markers &rest body) | 302 | (defmacro org-save-outline-visibility (use-markers &rest body) |
| 344 | "Save and restore outline visibility around BODY. | 303 | "Save and restore outline visibility around BODY. |
| 345 | If USE-MARKERS is non-nil, use markers for the positions. | 304 | If USE-MARKERS is non-nil, use markers for the positions. |
| @@ -359,6 +318,22 @@ point nowhere." | |||
| 359 | (and (markerp (cdr c)) (move-marker (cdr c) nil))) | 318 | (and (markerp (cdr c)) (move-marker (cdr c) nil))) |
| 360 | data))))) | 319 | data))))) |
| 361 | 320 | ||
| 321 | (defmacro org-with-limited-levels (&rest body) | ||
| 322 | "Execute BODY with limited number of outline levels." | ||
| 323 | `(let* ((outline-regexp (org-get-limited-outline-regexp))) | ||
| 324 | ,@body)) | ||
| 325 | |||
| 326 | (defvar org-odd-levels-only) ; defined in org.el | ||
| 327 | (defvar org-inlinetask-min-level) ; defined in org-inlinetask.el | ||
| 328 | (defun org-get-limited-outline-regexp () | ||
| 329 | "Return outline-regexp with limited number of levels. | ||
| 330 | The number of levels is controlled by `org-inlinetask-min-level'" | ||
| 331 | (if (or (not (org-mode-p)) (not (featurep 'org-inlinetask))) | ||
| 332 | |||
| 333 | outline-regexp | ||
| 334 | (let* ((limit-level (1- org-inlinetask-min-level)) | ||
| 335 | (nstars (if org-odd-levels-only (1- (* limit-level 2)) limit-level))) | ||
| 336 | (format "\\*\\{1,%d\\} " nstars)))) | ||
| 362 | 337 | ||
| 363 | (provide 'org-macs) | 338 | (provide 'org-macs) |
| 364 | 339 | ||
diff --git a/lisp/org/org-mew.el b/lisp/org/org-mew.el index 92ac2342dae..efedef8ec5c 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.01 | 8 | ;; Version: 7.3 |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -81,7 +81,7 @@ | |||
| 81 | (mew-case-folder (mew-sinfo-get-case) | 81 | (mew-case-folder (mew-sinfo-get-case) |
| 82 | (nth 1 (mew-refile-get msgnum))) | 82 | (nth 1 (mew-refile-get msgnum))) |
| 83 | (mew-summary-folder-name))) | 83 | (mew-summary-folder-name))) |
| 84 | message-id from to subject desc link) | 84 | message-id from to subject desc link date date-ts date-ts-ia) |
| 85 | (save-window-excursion | 85 | (save-window-excursion |
| 86 | (if (fboundp 'mew-summary-set-message-buffer) | 86 | (if (fboundp 'mew-summary-set-message-buffer) |
| 87 | (mew-summary-set-message-buffer folder-name msgnum) | 87 | (mew-summary-set-message-buffer folder-name msgnum) |
| @@ -89,9 +89,19 @@ | |||
| 89 | (setq message-id (mew-header-get-value "Message-Id:")) | 89 | (setq message-id (mew-header-get-value "Message-Id:")) |
| 90 | (setq from (mew-header-get-value "From:")) | 90 | (setq from (mew-header-get-value "From:")) |
| 91 | (setq to (mew-header-get-value "To:")) | 91 | (setq to (mew-header-get-value "To:")) |
| 92 | (setq date (mew-header-get-value "Date:")) | ||
| 93 | (setq date-ts (and date (format-time-string | ||
| 94 | (org-time-stamp-format t) | ||
| 95 | (date-to-time date)))) | ||
| 96 | (setq date-ts-ia (and date (format-time-string | ||
| 97 | (org-time-stamp-format t t) | ||
| 98 | (date-to-time date)))) | ||
| 92 | (setq subject (mew-header-get-value "Subject:"))) | 99 | (setq subject (mew-header-get-value "Subject:"))) |
| 93 | (org-store-link-props :type "mew" :from from :to to | 100 | (org-store-link-props :type "mew" :from from :to to |
| 94 | :subject subject :message-id message-id) | 101 | :subject subject :message-id message-id) |
| 102 | (when date | ||
| 103 | (org-add-link-props :date date :date-timestamp date-ts | ||
| 104 | :date-timestamp-inactive date-ts-ia)) | ||
| 95 | (setq message-id (org-remove-angle-brackets message-id)) | 105 | (setq message-id (org-remove-angle-brackets message-id)) |
| 96 | (setq desc (org-email-link-description)) | 106 | (setq desc (org-email-link-description)) |
| 97 | (setq link (org-make-link "mew:" folder-name | 107 | (setq link (org-make-link "mew:" folder-name |
diff --git a/lisp/org/org-mhe.el b/lisp/org/org-mhe.el index 91551cd828f..b1024a000e2 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.01 | 9 | ;; Version: 7.3 |
| 10 | ;; | 10 | ;; |
| 11 | ;; This file is part of GNU Emacs. | 11 | ;; This file is part of GNU Emacs. |
| 12 | ;; | 12 | ;; |
| @@ -83,13 +83,22 @@ supported by MH-E." | |||
| 83 | "Store a link to an MH-E folder or message." | 83 | "Store a link to an MH-E folder or message." |
| 84 | (when (or (equal major-mode 'mh-folder-mode) | 84 | (when (or (equal major-mode 'mh-folder-mode) |
| 85 | (equal major-mode 'mh-show-mode)) | 85 | (equal major-mode 'mh-show-mode)) |
| 86 | (let ((from (org-mhe-get-header "From:")) | 86 | (let* ((from (org-mhe-get-header "From:")) |
| 87 | (to (org-mhe-get-header "To:")) | 87 | (to (org-mhe-get-header "To:")) |
| 88 | (message-id (org-mhe-get-header "Message-Id:")) | 88 | (message-id (org-mhe-get-header "Message-Id:")) |
| 89 | (subject (org-mhe-get-header "Subject:")) | 89 | (subject (org-mhe-get-header "Subject:")) |
| 90 | link desc) | 90 | (date (org-mhe-get-header "Date:")) |
| 91 | (date-ts (and date (format-time-string | ||
| 92 | (org-time-stamp-format t) (date-to-time date)))) | ||
| 93 | (date-ts-ia (and date (format-time-string | ||
| 94 | (org-time-stamp-format t t) | ||
| 95 | (date-to-time date)))) | ||
| 96 | link desc) | ||
| 91 | (org-store-link-props :type "mh" :from from :to to | 97 | (org-store-link-props :type "mh" :from from :to to |
| 92 | :subject subject :message-id message-id) | 98 | :subject subject :message-id message-id) |
| 99 | (when date | ||
| 100 | (org-add-link-props :date date :date-timestamp date-ts | ||
| 101 | :date-timestamp-inactive date-ts-ia)) | ||
| 93 | (setq desc (org-email-link-description)) | 102 | (setq desc (org-email-link-description)) |
| 94 | (setq link (org-make-link "mhe:" (org-mhe-get-message-real-folder) "#" | 103 | (setq link (org-make-link "mhe:" (org-mhe-get-message-real-folder) "#" |
| 95 | (org-remove-angle-brackets message-id))) | 104 | (org-remove-angle-brackets message-id))) |
| @@ -181,7 +190,7 @@ you have a better idea of how to do this then please let us know." | |||
| 181 | (if (equal major-mode 'mh-folder-mode) | 190 | (if (equal major-mode 'mh-folder-mode) |
| 182 | (mh-show) | 191 | (mh-show) |
| 183 | (mh-show-show)) | 192 | (mh-show-show)) |
| 184 | header-field))) | 193 | (org-trim header-field)))) |
| 185 | 194 | ||
| 186 | (defun org-mhe-follow-link (folder article) | 195 | (defun org-mhe-follow-link (folder article) |
| 187 | "Follow an MH-E link to FOLDER and ARTICLE. | 196 | "Follow an MH-E link to FOLDER and ARTICLE. |
diff --git a/lisp/org/org-mks.el b/lisp/org/org-mks.el index 4a567614af3..2d429a79152 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.01 | 8 | ;; Version: 7.3 |
| 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 e9c1ad2bf3f..a278fb16d0a 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.01 | 7 | ;; Version: 7.3 |
| 8 | ;; | 8 | ;; |
| 9 | ;; This file is part of GNU Emacs. | 9 | ;; This file is part of GNU Emacs. |
| 10 | ;; | 10 | ;; |
| @@ -26,10 +26,11 @@ | |||
| 26 | ;;; Commentary: | 26 | ;;; Commentary: |
| 27 | ;; | 27 | ;; |
| 28 | ;; This file contains the code to interact with Richard Moreland's iPhone | 28 | ;; This file contains the code to interact with Richard Moreland's iPhone |
| 29 | ;; application MobileOrg. This code is documented in Appendix B of the | 29 | ;; application MobileOrg, as well as with the Android version by Matthew Jones. |
| 30 | ;; Org-mode manual. The code is not specific for the iPhone, however. | 30 | ;; This code is documented in Appendix B of the Org-mode manual. The code is |
| 31 | ;; Any external viewer/flagging/editing application that uses the same | 31 | ;; not specific for the iPhone and Android - any external |
| 32 | ;; conventions could be used. | 32 | ;; viewer/flagging/editing application that uses the same conventions could |
| 33 | ;; be used. | ||
| 33 | 34 | ||
| 34 | (require 'org) | 35 | (require 'org) |
| 35 | (require 'org-agenda) | 36 | (require 'org-agenda) |
| @@ -90,12 +91,29 @@ You might want to put this file into a directory where only you have access." | |||
| 90 | This is a single password which is used for AES-256 encryption. The same | 91 | This is a single password which is used for AES-256 encryption. The same |
| 91 | password must also be set in the MobileOrg application. All Org files, | 92 | password must also be set in the MobileOrg application. All Org files, |
| 92 | including mobileorg.org will be encrypted using this password. | 93 | including mobileorg.org will be encrypted using this password. |
| 94 | |||
| 95 | SECURITY CONSIDERATIONS: | ||
| 96 | |||
| 93 | Note that, when Org runs the encryption commands, the password could | 97 | Note that, when Org runs the encryption commands, the password could |
| 94 | be visible on your system with the `ps' command. So this method is only | 98 | be visible briefly on your system with the `ps' command. So this method is |
| 95 | intended to keep the files secure on the server, not on your own machine." | 99 | only intended to keep the files secure on the server, not on your own machine. |
| 100 | |||
| 101 | Also, if you set this variable in an init file (.emacs or .emacs.d/init.el | ||
| 102 | or custom.el...) and if that file is stored in a way so that other can read | ||
| 103 | it, this also limits the security of this approach. You can also leave | ||
| 104 | this variable empty - Org will then ask for the password once per Emacs | ||
| 105 | session." | ||
| 96 | :group 'org-mobile | 106 | :group 'org-mobile |
| 97 | :type '(string :tag "Password")) | 107 | :type '(string :tag "Password")) |
| 98 | 108 | ||
| 109 | (defvar org-mobile-encryption-password-session nil) | ||
| 110 | |||
| 111 | (defun org-mobile-encryption-password () | ||
| 112 | (or (org-string-nw-p org-mobile-encryption-password) | ||
| 113 | (org-string-nw-p org-mobile-encryption-password-session) | ||
| 114 | (setq org-mobile-encryption-password-session | ||
| 115 | (read-passwd "Password for MobileOrg: " t)))) | ||
| 116 | |||
| 99 | (defcustom org-mobile-inbox-for-pull "~/org/from-mobile.org" | 117 | (defcustom org-mobile-inbox-for-pull "~/org/from-mobile.org" |
| 100 | "The file where captured notes and flags will be appended to. | 118 | "The file where captured notes and flags will be appended to. |
| 101 | During the execution of `org-mobile-pull', the file | 119 | During the execution of `org-mobile-pull', the file |
| @@ -133,7 +151,7 @@ list a list of selection key(s) as string." | |||
| 133 | (string :tag "Selection Keys")))) | 151 | (string :tag "Selection Keys")))) |
| 134 | 152 | ||
| 135 | (defcustom org-mobile-force-id-on-agenda-items t | 153 | (defcustom org-mobile-force-id-on-agenda-items t |
| 136 | "Non-nil means make all agenda items carry and ID." | 154 | "Non-nil means make all agenda items carry an ID." |
| 137 | :group 'org-mobile | 155 | :group 'org-mobile |
| 138 | :type 'boolean) | 156 | :type 'boolean) |
| 139 | 157 | ||
| @@ -331,6 +349,7 @@ agenda view showing the flagged items." | |||
| 331 | 349 | ||
| 332 | (defun org-mobile-check-setup () | 350 | (defun org-mobile-check-setup () |
| 333 | "Check if org-mobile-directory has been set up." | 351 | "Check if org-mobile-directory has been set up." |
| 352 | (org-mobile-cleanup-encryption-tempfile) | ||
| 334 | (unless (and org-directory | 353 | (unless (and org-directory |
| 335 | (stringp org-directory) | 354 | (stringp org-directory) |
| 336 | (string-match "\\S-" org-directory) | 355 | (string-match "\\S-" org-directory) |
| @@ -356,7 +375,7 @@ agenda view showing the flagged items." | |||
| 356 | (string-match "\\S-" org-mobile-checksum-binary)) | 375 | (string-match "\\S-" org-mobile-checksum-binary)) |
| 357 | (error "No executable found to compute checksums")) | 376 | (error "No executable found to compute checksums")) |
| 358 | (when org-mobile-use-encryption | 377 | (when org-mobile-use-encryption |
| 359 | (unless (string-match "\\S-" org-mobile-encryption-password) | 378 | (unless (string-match "\\S-" (org-mobile-encryption-password)) |
| 360 | (error | 379 | (error |
| 361 | "To use encryption, you must set `org-mobile-encryption-password'")) | 380 | "To use encryption, you must set `org-mobile-encryption-password'")) |
| 362 | (unless (file-writable-p org-mobile-encryption-tempfile) | 381 | (unless (file-writable-p org-mobile-encryption-tempfile) |
| @@ -371,6 +390,8 @@ agenda view showing the flagged items." | |||
| 371 | (lambda (a b) (string< (cdr a) (cdr b))))) | 390 | (lambda (a b) (string< (cdr a) (cdr b))))) |
| 372 | (def-todo (default-value 'org-todo-keywords)) | 391 | (def-todo (default-value 'org-todo-keywords)) |
| 373 | (def-tags (default-value 'org-tag-alist)) | 392 | (def-tags (default-value 'org-tag-alist)) |
| 393 | (target-file (expand-file-name org-mobile-index-file | ||
| 394 | org-mobile-directory)) | ||
| 374 | file link-name todo-kwds done-kwds tags drawers entry kwds dwds twds) | 395 | file link-name todo-kwds done-kwds tags drawers entry kwds dwds twds) |
| 375 | 396 | ||
| 376 | (org-prepare-agenda-buffers (mapcar 'car files-alist)) | 397 | (org-prepare-agenda-buffers (mapcar 'car files-alist)) |
| @@ -389,7 +410,9 @@ agenda view showing the flagged items." | |||
| 389 | (t nil))) | 410 | (t nil))) |
| 390 | org-tag-alist-for-agenda)))) | 411 | org-tag-alist-for-agenda)))) |
| 391 | (with-temp-file | 412 | (with-temp-file |
| 392 | (expand-file-name org-mobile-index-file org-mobile-directory) | 413 | (if org-mobile-use-encryption |
| 414 | org-mobile-encryption-tempfile | ||
| 415 | target-file) | ||
| 393 | (while (setq entry (pop def-todo)) | 416 | (while (setq entry (pop def-todo)) |
| 394 | (insert "#+READONLY\n") | 417 | (insert "#+READONLY\n") |
| 395 | (setq kwds (mapcar (lambda (x) (if (string-match "(" x) | 418 | (setq kwds (mapcar (lambda (x) (if (string-match "(" x) |
| @@ -430,7 +453,11 @@ agenda view showing the flagged items." | |||
| 430 | (insert (format "* [[file:%s][%s]]\n" | 453 | (insert (format "* [[file:%s][%s]]\n" |
| 431 | link-name link-name))) | 454 | link-name link-name))) |
| 432 | (push (cons org-mobile-index-file (md5 (buffer-string))) | 455 | (push (cons org-mobile-index-file (md5 (buffer-string))) |
| 433 | org-mobile-checksum-files)))) | 456 | org-mobile-checksum-files)) |
| 457 | (when org-mobile-use-encryption | ||
| 458 | (org-mobile-encrypt-and-move org-mobile-encryption-tempfile | ||
| 459 | target-file) | ||
| 460 | (org-mobile-cleanup-encryption-tempfile)))) | ||
| 434 | 461 | ||
| 435 | (defun org-mobile-copy-agenda-files () | 462 | (defun org-mobile-copy-agenda-files () |
| 436 | "Copy all agenda files to the stage or WebDAV directory." | 463 | "Copy all agenda files to the stage or WebDAV directory." |
| @@ -452,14 +479,20 @@ agenda view showing the flagged items." | |||
| 452 | (when (string-match "[a-fA-F0-9]\\{30,40\\}" check) | 479 | (when (string-match "[a-fA-F0-9]\\{30,40\\}" check) |
| 453 | (push (cons link-name (match-string 0 check)) | 480 | (push (cons link-name (match-string 0 check)) |
| 454 | org-mobile-checksum-files)))) | 481 | org-mobile-checksum-files)))) |
| 482 | |||
| 455 | (setq file (expand-file-name org-mobile-capture-file | 483 | (setq file (expand-file-name org-mobile-capture-file |
| 456 | org-mobile-directory)) | 484 | org-mobile-directory)) |
| 457 | (save-excursion | 485 | (save-excursion |
| 458 | (setq buf (find-file file)) | 486 | (setq buf (find-file file)) |
| 459 | (and (= (point-min) (point-max)) (insert "\n")) | 487 | (when (and (= (point-min) (point-max))) |
| 460 | (save-buffer) | 488 | (insert "\n") |
| 489 | (save-buffer) | ||
| 490 | (when org-mobile-use-encryption | ||
| 491 | (write-file org-mobile-encryption-tempfile) | ||
| 492 | (org-mobile-encrypt-and-move org-mobile-encryption-tempfile file))) | ||
| 461 | (push (cons org-mobile-capture-file (md5 (buffer-string))) | 493 | (push (cons org-mobile-capture-file (md5 (buffer-string))) |
| 462 | org-mobile-checksum-files)) | 494 | org-mobile-checksum-files)) |
| 495 | (org-mobile-cleanup-encryption-tempfile) | ||
| 463 | (kill-buffer buf))) | 496 | (kill-buffer buf))) |
| 464 | 497 | ||
| 465 | (defun org-mobile-write-checksums () | 498 | (defun org-mobile-write-checksums () |
| @@ -606,14 +639,30 @@ The table of checksums is written to the file mobile-checksums." | |||
| 606 | (if (org-bound-and-true-p | 639 | (if (org-bound-and-true-p |
| 607 | org-mobile-force-id-on-agenda-items) | 640 | org-mobile-force-id-on-agenda-items) |
| 608 | (org-id-get m 'create) | 641 | (org-id-get m 'create) |
| 609 | (org-entry-get m "ID"))) | 642 | (or (org-entry-get m "ID") |
| 643 | (org-mobile-get-outline-path-link m)))) | ||
| 610 | (insert " :PROPERTIES:\n :ORIGINAL_ID: " id | 644 | (insert " :PROPERTIES:\n :ORIGINAL_ID: " id |
| 611 | "\n :END:\n"))))) | 645 | "\n :END:\n"))))) |
| 612 | (beginning-of-line 2)) | 646 | (beginning-of-line 2)) |
| 613 | (push (cons (file-name-nondirectory file) (md5 (buffer-string))) | 647 | (push (cons "agendas.org" (md5 (buffer-string))) |
| 614 | org-mobile-checksum-files)) | 648 | org-mobile-checksum-files)) |
| 615 | (message "Agenda written to Org file %s" file))) | 649 | (message "Agenda written to Org file %s" file))) |
| 616 | 650 | ||
| 651 | (defun org-mobile-get-outline-path-link (pom) | ||
| 652 | (org-with-point-at pom | ||
| 653 | (concat "olp:" | ||
| 654 | (org-mobile-escape-olp (file-name-nondirectory buffer-file-name)) | ||
| 655 | "/" | ||
| 656 | (mapconcat 'org-mobile-escape-olp | ||
| 657 | (org-get-outline-path) | ||
| 658 | "/") | ||
| 659 | "/" | ||
| 660 | (org-mobile-escape-olp (nth 4 (org-heading-components)))))) | ||
| 661 | |||
| 662 | (defun org-mobile-escape-olp (s) | ||
| 663 | (let ((table '((?: . "%3a") (?\[ . "%5b") (?\] . "%5d") (?/ . "%2f")))) | ||
| 664 | (org-link-escape s table))) | ||
| 665 | |||
| 617 | ;;;###autoload | 666 | ;;;###autoload |
| 618 | (defun org-mobile-create-sumo-agenda () | 667 | (defun org-mobile-create-sumo-agenda () |
| 619 | "Create a file that contains all custom agenda views." | 668 | "Create a file that contains all custom agenda views." |
| @@ -632,8 +681,9 @@ The table of checksums is written to the file mobile-checksums." | |||
| 632 | (when sumo | 681 | (when sumo |
| 633 | (org-store-agenda-views)) | 682 | (org-store-agenda-views)) |
| 634 | (when org-mobile-use-encryption | 683 | (when org-mobile-use-encryption |
| 635 | (org-mobile-encrypt-file file1 file) | 684 | (org-mobile-encrypt-and-move file1 file) |
| 636 | (delete-file file1)))) | 685 | (delete-file file1) |
| 686 | (org-mobile-cleanup-encryption-tempfile)))) | ||
| 637 | 687 | ||
| 638 | (defun org-mobile-encrypt-and-move (infile outfile) | 688 | (defun org-mobile-encrypt-and-move (infile outfile) |
| 639 | "Encrypt INFILE locally to INFILE_enc, then move it to OUTFILE. | 689 | "Encrypt INFILE locally to INFILE_enc, then move it to OUTFILE. |
| @@ -649,7 +699,8 @@ encryption program does not understand them." | |||
| 649 | "Encrypt INFILE to OUTFILE, using `org-mobile-encryption-password'." | 699 | "Encrypt INFILE to OUTFILE, using `org-mobile-encryption-password'." |
| 650 | (shell-command | 700 | (shell-command |
| 651 | (format "openssl enc -aes-256-cbc -salt -pass %s -in %s -out %s" | 701 | (format "openssl enc -aes-256-cbc -salt -pass %s -in %s -out %s" |
| 652 | (shell-quote-argument (concat "pass:" org-mobile-encryption-password)) | 702 | (shell-quote-argument (concat "pass:" |
| 703 | (org-mobile-encryption-password))) | ||
| 653 | (shell-quote-argument (expand-file-name infile)) | 704 | (shell-quote-argument (expand-file-name infile)) |
| 654 | (shell-quote-argument (expand-file-name outfile))))) | 705 | (shell-quote-argument (expand-file-name outfile))))) |
| 655 | 706 | ||
| @@ -657,10 +708,17 @@ encryption program does not understand them." | |||
| 657 | "Decrypt INFILE to OUTFILE, using `org-mobile-encryption-password'." | 708 | "Decrypt INFILE to OUTFILE, using `org-mobile-encryption-password'." |
| 658 | (shell-command | 709 | (shell-command |
| 659 | (format "openssl enc -d -aes-256-cbc -salt -pass %s -in %s -out %s" | 710 | (format "openssl enc -d -aes-256-cbc -salt -pass %s -in %s -out %s" |
| 660 | (shell-quote-argument (concat "pass:" org-mobile-encryption-password)) | 711 | (shell-quote-argument (concat "pass:" |
| 712 | (org-mobile-encryption-password))) | ||
| 661 | (shell-quote-argument (expand-file-name infile)) | 713 | (shell-quote-argument (expand-file-name infile)) |
| 662 | (shell-quote-argument (expand-file-name outfile))))) | 714 | (shell-quote-argument (expand-file-name outfile))))) |
| 663 | 715 | ||
| 716 | (defun org-mobile-cleanup-encryption-tempfile () | ||
| 717 | "Remove the encryption tempfile if it exists." | ||
| 718 | (and (stringp org-mobile-encryption-tempfile) | ||
| 719 | (file-exists-p org-mobile-encryption-tempfile) | ||
| 720 | (delete-file org-mobile-encryption-tempfile))) | ||
| 721 | |||
| 664 | (defun org-mobile-move-capture () | 722 | (defun org-mobile-move-capture () |
| 665 | "Move the contents of the capture file to the inbox file. | 723 | "Move the contents of the capture file to the inbox file. |
| 666 | Return a marker to the location where the new content has been added. | 724 | Return a marker to the location where the new content has been added. |
| @@ -673,7 +731,7 @@ If nothing new has been added, return nil." | |||
| 673 | (capture-buffer | 731 | (capture-buffer |
| 674 | (if (not org-mobile-use-encryption) | 732 | (if (not org-mobile-use-encryption) |
| 675 | (find-file-noselect capture-file) | 733 | (find-file-noselect capture-file) |
| 676 | (delete-file org-mobile-encryption-tempfile) | 734 | (org-mobile-cleanup-encryption-tempfile) |
| 677 | (setq encfile (concat org-mobile-encryption-tempfile "_enc")) | 735 | (setq encfile (concat org-mobile-encryption-tempfile "_enc")) |
| 678 | (copy-file capture-file encfile) | 736 | (copy-file capture-file encfile) |
| 679 | (org-mobile-decrypt-file encfile org-mobile-encryption-tempfile) | 737 | (org-mobile-decrypt-file encfile org-mobile-encryption-tempfile) |
| @@ -698,7 +756,8 @@ If nothing new has been added, return nil." | |||
| 698 | (kill-buffer capture-buffer) | 756 | (kill-buffer capture-buffer) |
| 699 | (when org-mobile-use-encryption | 757 | (when org-mobile-use-encryption |
| 700 | (org-mobile-encrypt-and-move org-mobile-encryption-tempfile | 758 | (org-mobile-encrypt-and-move org-mobile-encryption-tempfile |
| 701 | capture-file)) | 759 | capture-file) |
| 760 | (org-mobile-cleanup-encryption-tempfile)) | ||
| 702 | (if not-empty insertion-point))) | 761 | (if not-empty insertion-point))) |
| 703 | 762 | ||
| 704 | (defun org-mobile-update-checksum-for-capture-file (buffer-string) | 763 | (defun org-mobile-update-checksum-for-capture-file (buffer-string) |
diff --git a/lisp/org/org-mouse.el b/lisp/org/org-mouse.el index 12a7dcb85af..e16c9778d77 100644 --- a/lisp/org/org-mouse.el +++ b/lisp/org/org-mouse.el | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | ;; | 4 | ;; |
| 5 | ;; Author: Piotr Zielinski <piotr dot zielinski at gmail dot com> | 5 | ;; Author: Piotr Zielinski <piotr dot zielinski at gmail dot com> |
| 6 | ;; Maintainer: Carsten Dominik <carsten at orgmode dot org> | 6 | ;; Maintainer: Carsten Dominik <carsten at orgmode dot org> |
| 7 | ;; Version: 7.01 | 7 | ;; Version: 7.3 |
| 8 | ;; | 8 | ;; |
| 9 | ;; This file is part of GNU Emacs. | 9 | ;; This file is part of GNU Emacs. |
| 10 | ;; | 10 | ;; |
| @@ -148,6 +148,7 @@ | |||
| 148 | (declare-function org-agenda-change-all-lines "org-agenda" | 148 | (declare-function org-agenda-change-all-lines "org-agenda" |
| 149 | (newhead hdmarker &optional fixface just-this)) | 149 | (newhead hdmarker &optional fixface just-this)) |
| 150 | (declare-function org-verify-change-for-undo "org-agenda" (l1 l2)) | 150 | (declare-function org-verify-change-for-undo "org-agenda" (l1 l2)) |
| 151 | (declare-function org-apply-on-list "org-list" (function init-value &rest args)) | ||
| 151 | 152 | ||
| 152 | (defvar org-mouse-plain-list-regexp "\\([ \t]*\\)\\([-+*]\\|[0-9]+[.)]\\) " | 153 | (defvar org-mouse-plain-list-regexp "\\([ \t]*\\)\\([-+*]\\|[0-9]+[.)]\\) " |
| 153 | "Regular expression that matches a plain list.") | 154 | "Regular expression that matches a plain list.") |
| @@ -576,14 +577,11 @@ SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:" | |||
| 576 | (goto-char (second contextdata)) | 577 | (goto-char (second contextdata)) |
| 577 | (re-search-forward ".*" (third contextdata)))))) | 578 | (re-search-forward ".*" (third contextdata)))))) |
| 578 | 579 | ||
| 579 | (defun org-mouse-for-each-item (function) | 580 | (defun org-mouse-for-each-item (funct) |
| 580 | (save-excursion | 581 | ;; Functions called by `org-apply-on-list' need an argument |
| 581 | (ignore-errors | 582 | (let ((wrap-fun (lambda (c) (funcall funct)))) |
| 582 | (while t (org-previous-item))) | 583 | (when (org-in-item-p) |
| 583 | (ignore-errors | 584 | (org-apply-on-list wrap-fun nil)))) |
| 584 | (while t | ||
| 585 | (funcall function) | ||
| 586 | (org-next-item))))) | ||
| 587 | 585 | ||
| 588 | (defun org-mouse-bolp () | 586 | (defun org-mouse-bolp () |
| 589 | "Return true if there only spaces, tabs, and '*' before point. | 587 | "Return true if there only spaces, tabs, and '*' before point. |
diff --git a/lisp/org/org-plot.el b/lisp/org/org-plot.el index c6953f11d37..274d3f94c8a 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.01 | 8 | ;; Version: 7.3 |
| 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 2c6345ab817..3a20c5f729c 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.01 | 12 | ;; Version: 7.3 |
| 13 | 13 | ||
| 14 | ;; This file is part of GNU Emacs. | 14 | ;; This file is part of GNU Emacs. |
| 15 | ;; | 15 | ;; |
| @@ -260,7 +260,7 @@ Here is an example: | |||
| 260 | :group 'org-protocol | 260 | :group 'org-protocol |
| 261 | :type '(alist)) | 261 | :type '(alist)) |
| 262 | 262 | ||
| 263 | (defcustom org-protocol-default-template-key "w" | 263 | (defcustom org-protocol-default-template-key nil |
| 264 | "The default org-remember-templates key to use." | 264 | "The default org-remember-templates key to use." |
| 265 | :group 'org-protocol | 265 | :group 'org-protocol |
| 266 | :type 'string) | 266 | :type 'string) |
diff --git a/lisp/org/org-publish.el b/lisp/org/org-publish.el index 943bbca6b7b..51db9f652d1 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.01 | 8 | ;; Version: 7.3 |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | ;; | 11 | ;; |
| @@ -71,11 +71,14 @@ Each element of the alist is a publishing 'project.' The CAR of | |||
| 71 | each element is a string, uniquely identifying the project. The | 71 | each element is a string, uniquely identifying the project. The |
| 72 | CDR of each element is in one of the following forms: | 72 | CDR of each element is in one of the following forms: |
| 73 | 73 | ||
| 74 | (:property value :property value ... ) | 74 | 1. A well-formed property list with an even number of elements, alternating |
| 75 | keys and values, specifying parameters for the publishing process. | ||
| 75 | 76 | ||
| 76 | OR, | 77 | (:property value :property value ... ) |
| 77 | 78 | ||
| 78 | (:components (\"project-1\" \"project-2\" ...)) | 79 | 2. A meta-project definition, specifying of a list of sub-projects: |
| 80 | |||
| 81 | (:components (\"project-1\" \"project-2\" ...)) | ||
| 79 | 82 | ||
| 80 | When the CDR of an element of org-publish-project-alist is in | 83 | When the CDR of an element of org-publish-project-alist is in |
| 81 | this second form, the elements of the list after :components are | 84 | this second form, the elements of the list after :components are |
| @@ -92,7 +95,8 @@ Most properties are optional, but some should always be set: | |||
| 92 | 95 | ||
| 93 | :base-directory Directory containing publishing source files | 96 | :base-directory Directory containing publishing source files |
| 94 | :base-extension Extension (without the dot!) of source files. | 97 | :base-extension Extension (without the dot!) of source files. |
| 95 | This can be a regular expression. | 98 | This can be a regular expression. If not given, |
| 99 | \"org\" will be used as default extension. | ||
| 96 | :publishing-directory Directory (possibly remote) where output | 100 | :publishing-directory Directory (possibly remote) where output |
| 97 | files will be published | 101 | files will be published |
| 98 | 102 | ||
| @@ -188,7 +192,14 @@ sitemap of files or summary page for a given project. | |||
| 188 | 192 | ||
| 189 | The following properties control the creation of a concept index. | 193 | The following properties control the creation of a concept index. |
| 190 | 194 | ||
| 191 | :makeindex Create a concept index." | 195 | :makeindex Create a concept index. |
| 196 | |||
| 197 | Other properties affecting publication. | ||
| 198 | |||
| 199 | :body-only Set this to 't' to publish only the body of the | ||
| 200 | documents, excluding everything outside and | ||
| 201 | including the <body> tags in HTML, or | ||
| 202 | \begin{document}..\end{document} in LaTeX." | ||
| 192 | :group 'org-publish | 203 | :group 'org-publish |
| 193 | :type 'alist) | 204 | :type 'alist) |
| 194 | 205 | ||
| @@ -464,13 +475,19 @@ matching filenames." | |||
| 464 | (unless (plist-get (cdr prj) :components) | 475 | (unless (plist-get (cdr prj) :components) |
| 465 | ;; [[info:org:Selecting%20files]] shows how this is supposed to work: | 476 | ;; [[info:org:Selecting%20files]] shows how this is supposed to work: |
| 466 | (let* ((r (plist-get (cdr prj) :recursive)) | 477 | (let* ((r (plist-get (cdr prj) :recursive)) |
| 467 | (b (expand-file-name (plist-get (cdr prj) :base-directory))) | 478 | (b (expand-file-name (file-name-as-directory |
| 479 | (plist-get (cdr prj) :base-directory)))) | ||
| 468 | (x (or (plist-get (cdr prj) :base-extension) "org")) | 480 | (x (or (plist-get (cdr prj) :base-extension) "org")) |
| 469 | (e (plist-get (cdr prj) :exclude)) | 481 | (e (plist-get (cdr prj) :exclude)) |
| 470 | (i (plist-get (cdr prj) :include)) | 482 | (i (plist-get (cdr prj) :include)) |
| 471 | (xm (concat "^" b (if r ".+" "[^/]+") "\\.\\(" x "\\)$"))) | 483 | (xm (concat "^" b (if r ".+" "[^/]+") "\\.\\(" x "\\)$"))) |
| 472 | (when (or | 484 | (when (or |
| 473 | (and i (string-match i filename)) | 485 | (and |
| 486 | i | ||
| 487 | (member filename | ||
| 488 | (mapcar | ||
| 489 | (lambda (file) (expand-file-name file b)) | ||
| 490 | i))) | ||
| 474 | (and | 491 | (and |
| 475 | (not (and e (string-match e filename))) | 492 | (not (and e (string-match e filename))) |
| 476 | (string-match xm filename))) | 493 | (string-match xm filename))) |
| @@ -507,7 +524,9 @@ PUB-DIR is the publishing directory." | |||
| 507 | (setq export-buf-or-file | 524 | (setq export-buf-or-file |
| 508 | (funcall (intern (concat "org-export-as-" format)) | 525 | (funcall (intern (concat "org-export-as-" format)) |
| 509 | (plist-get plist :headline-levels) | 526 | (plist-get plist :headline-levels) |
| 510 | nil plist nil nil pub-dir)) | 527 | nil plist nil |
| 528 | (plist-get plist :body-only) | ||
| 529 | pub-dir)) | ||
| 511 | (when (and (bufferp export-buf-or-file) | 530 | (when (and (bufferp export-buf-or-file) |
| 512 | (buffer-live-p export-buf-or-file)) | 531 | (buffer-live-p export-buf-or-file)) |
| 513 | (set-buffer export-buf-or-file) | 532 | (set-buffer export-buf-or-file) |
| @@ -558,14 +577,32 @@ See `org-publish-org-to' to the list of arguments." | |||
| 558 | See `org-publish-org-to' to the list of arguments." | 577 | See `org-publish-org-to' to the list of arguments." |
| 559 | (org-publish-org-to "org" plist filename pub-dir)) | 578 | (org-publish-org-to "org" plist filename pub-dir)) |
| 560 | 579 | ||
| 580 | (defun org-publish-org-to-ascii (plist filename pub-dir) | ||
| 581 | "Publish an org file to ASCII. | ||
| 582 | See `org-publish-org-to' to the list of arguments." | ||
| 583 | (org-publish-with-aux-preprocess-maybe | ||
| 584 | (org-publish-org-to "ascii" plist filename pub-dir))) | ||
| 585 | |||
| 586 | (defun org-publish-org-to-latin1 (plist filename pub-dir) | ||
| 587 | "Publish an org file to Latin-1. | ||
| 588 | See `org-publish-org-to' to the list of arguments." | ||
| 589 | (org-publish-with-aux-preprocess-maybe | ||
| 590 | (org-publish-org-to "latin1" plist filename pub-dir))) | ||
| 591 | |||
| 592 | (defun org-publish-org-to-utf8 (plist filename pub-dir) | ||
| 593 | "Publish an org file to UTF-8. | ||
| 594 | See `org-publish-org-to' to the list of arguments." | ||
| 595 | (org-publish-with-aux-preprocess-maybe | ||
| 596 | (org-publish-org-to "utf8" plist filename pub-dir))) | ||
| 597 | |||
| 561 | (defun org-publish-attachment (plist filename pub-dir) | 598 | (defun org-publish-attachment (plist filename pub-dir) |
| 562 | "Publish a file with no transformation of any kind. | 599 | "Publish a file with no transformation of any kind. |
| 563 | See `org-publish-org-to' to the list of arguments." | 600 | See `org-publish-org-to' to the list of arguments." |
| 564 | ;; make sure eshell/cp code is loaded | 601 | ;; make sure eshell/cp code is loaded |
| 565 | (unless (file-directory-p pub-dir) | 602 | (unless (file-directory-p pub-dir) |
| 566 | (make-directory pub-dir t)) | 603 | (make-directory pub-dir t)) |
| 567 | (or (equal (expand-file-name (file-name-directory filename)) | 604 | (or (equal (expand-file-name (file-name-directory filename)) |
| 568 | (file-name-as-directory (expand-file-name pub-dir))) | 605 | (file-name-as-directory (expand-file-name pub-dir))) |
| 569 | (copy-file filename | 606 | (copy-file filename |
| 570 | (expand-file-name (file-name-nondirectory filename) pub-dir) | 607 | (expand-file-name (file-name-nondirectory filename) pub-dir) |
| 571 | t))) | 608 | t))) |
| @@ -585,14 +622,22 @@ See `org-publish-projects'." | |||
| 585 | (error "File %s not part of any known project" | 622 | (error "File %s not part of any known project" |
| 586 | (abbreviate-file-name filename))))) | 623 | (abbreviate-file-name filename))))) |
| 587 | (project-plist (cdr project)) | 624 | (project-plist (cdr project)) |
| 588 | (ftname (file-truename filename)) | 625 | (ftname (expand-file-name filename)) |
| 589 | (publishing-function | 626 | (publishing-function |
| 590 | (or (plist-get project-plist :publishing-function) | 627 | (or (plist-get project-plist :publishing-function) |
| 591 | 'org-publish-org-to-html)) | 628 | 'org-publish-org-to-html)) |
| 592 | (base-dir (file-name-as-directory | 629 | (base-dir |
| 593 | (file-truename (plist-get project-plist :base-directory)))) | 630 | (file-name-as-directory |
| 594 | (pub-dir (file-name-as-directory | 631 | (expand-file-name |
| 595 | (file-truename (plist-get project-plist :publishing-directory)))) | 632 | (or (plist-get project-plist :base-directory) |
| 633 | (error "Project %s does not have :base-directory defined" | ||
| 634 | (car project)))))) | ||
| 635 | (pub-dir | ||
| 636 | (file-name-as-directory | ||
| 637 | (file-truename | ||
| 638 | (or (plist-get project-plist :publishing-directory) | ||
| 639 | (error "Project %s does not have :publishing-directory defined" | ||
| 640 | (car project)))))) | ||
| 596 | tmp-pub-dir) | 641 | tmp-pub-dir) |
| 597 | 642 | ||
| 598 | (unless no-cache | 643 | (unless no-cache |
| @@ -770,7 +815,6 @@ directory and force publishing all files." | |||
| 770 | (interactive "P") | 815 | (interactive "P") |
| 771 | (when force | 816 | (when force |
| 772 | (org-publish-remove-all-timestamps)) | 817 | (org-publish-remove-all-timestamps)) |
| 773 | ;; (org-publish-initialize-files-alist force) | ||
| 774 | (save-window-excursion | 818 | (save-window-excursion |
| 775 | (let ((org-publish-use-timestamps-flag | 819 | (let ((org-publish-use-timestamps-flag |
| 776 | (if force nil org-publish-use-timestamps-flag))) | 820 | (if force nil org-publish-use-timestamps-flag))) |
diff --git a/lisp/org/org-remember.el b/lisp/org/org-remember.el index d8252b65c3d..a15825a51ec 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.01 | 9 | ;; Version: 7.3 |
| 10 | ;; | 10 | ;; |
| 11 | ;; This file is part of GNU Emacs. | 11 | ;; This file is part of GNU Emacs. |
| 12 | ;; | 12 | ;; |
| @@ -157,7 +157,7 @@ Furthermore, the following %-escapes will be replaced with content: | |||
| 157 | Apart from these general escapes, you can access information specific to the | 157 | Apart from these general escapes, you can access information specific to the |
| 158 | link type that is created. For example, calling `remember' in emails or gnus | 158 | link type that is created. For example, calling `remember' in emails or gnus |
| 159 | will record the author and the subject of the message, which you can access | 159 | will record the author and the subject of the message, which you can access |
| 160 | with %:author and %:subject, respectively. Here is a complete list of what | 160 | with %:fromname and %:subject, respectively. Here is a complete list of what |
| 161 | is recorded for each link type. | 161 | is recorded for each link type. |
| 162 | 162 | ||
| 163 | Link type | Available information | 163 | Link type | Available information |
| @@ -167,7 +167,8 @@ vm, wl, mh, rmail | %:type %:subject %:message-id | |||
| 167 | | %:from %:fromname %:fromaddress | 167 | | %:from %:fromname %:fromaddress |
| 168 | | %:to %:toname %:toaddress | 168 | | %:to %:toname %:toaddress |
| 169 | | %:fromto (either \"to NAME\" or \"from NAME\") | 169 | | %:fromto (either \"to NAME\" or \"from NAME\") |
| 170 | gnus | %:group, for messages also all email fields | 170 | gnus | %:group, for messages also all email fields and |
| 171 | | %:org-date (the Date: header in Org format) | ||
| 171 | w3, w3m | %:type %:url | 172 | w3, w3m | %:type %:url |
| 172 | info | %:type %:file %:node | 173 | info | %:type %:file %:node |
| 173 | calendar | %:type %:date" | 174 | calendar | %:type %:date" |
| @@ -574,7 +575,7 @@ to be run from that hook to function properly." | |||
| 574 | 'org-tags-completion-function nil nil nil | 575 | 'org-tags-completion-function nil nil nil |
| 575 | 'org-tags-history))) | 576 | 'org-tags-history))) |
| 576 | (setq ins (mapconcat 'identity | 577 | (setq ins (mapconcat 'identity |
| 577 | (org-split-string ins (org-re "[^[:alnum:]_@]+")) | 578 | (org-split-string ins (org-re "[^[:alnum:]_@#%]+")) |
| 578 | ":")) | 579 | ":")) |
| 579 | (when (string-match "\\S-" ins) | 580 | (when (string-match "\\S-" ins) |
| 580 | (or (equal (char-before) ?:) (insert ":")) | 581 | (or (equal (char-before) ?:) (insert ":")) |
diff --git a/lisp/org/org-rmail.el b/lisp/org/org-rmail.el index 4ddfadaafa5..5574bf77ac4 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.01 | 9 | ;; Version: 7.3 |
| 10 | ;; | 10 | ;; |
| 11 | ;; This file is part of GNU Emacs. | 11 | ;; This file is part of GNU Emacs. |
| 12 | ;; | 12 | ;; |
| @@ -59,10 +59,20 @@ | |||
| 59 | (from (mail-fetch-field "from")) | 59 | (from (mail-fetch-field "from")) |
| 60 | (to (mail-fetch-field "to")) | 60 | (to (mail-fetch-field "to")) |
| 61 | (subject (mail-fetch-field "subject")) | 61 | (subject (mail-fetch-field "subject")) |
| 62 | (date (mail-fetch-field "date")) | ||
| 63 | (date-ts (and date (format-time-string | ||
| 64 | (org-time-stamp-format t) | ||
| 65 | (date-to-time date)))) | ||
| 66 | (date-ts-ia (and date (format-time-string | ||
| 67 | (org-time-stamp-format t t) | ||
| 68 | (date-to-time date)))) | ||
| 62 | desc link) | 69 | desc link) |
| 63 | (org-store-link-props | 70 | (org-store-link-props |
| 64 | :type "rmail" :from from :to to | 71 | :type "rmail" :from from :to to |
| 65 | :subject subject :message-id message-id) | 72 | :subject subject :message-id message-id) |
| 73 | (when date | ||
| 74 | (org-add-link-props :date date :date-timestamp date-ts | ||
| 75 | :date-timestamp-inactive date-ts-ia)) | ||
| 66 | (setq message-id (org-remove-angle-brackets message-id)) | 76 | (setq message-id (org-remove-angle-brackets message-id)) |
| 67 | (setq desc (org-email-link-description)) | 77 | (setq desc (org-email-link-description)) |
| 68 | (setq link (org-make-link "rmail:" folder "#" message-id)) | 78 | (setq link (org-make-link "rmail:" folder "#" message-id)) |
diff --git a/lisp/org/org-src.el b/lisp/org/org-src.el index 453f3b0b534..c4f0065ec34 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.01 | 11 | ;; Version: 7.3 |
| 12 | ;; | 12 | ;; |
| 13 | ;; This file is part of GNU Emacs. | 13 | ;; This file is part of GNU Emacs. |
| 14 | ;; | 14 | ;; |
| @@ -34,6 +34,8 @@ | |||
| 34 | 34 | ||
| 35 | (require 'org-macs) | 35 | (require 'org-macs) |
| 36 | (require 'org-compat) | 36 | (require 'org-compat) |
| 37 | (require 'ob-keys) | ||
| 38 | (require 'ob-comint) | ||
| 37 | (eval-when-compile | 39 | (eval-when-compile |
| 38 | (require 'cl)) | 40 | (require 'cl)) |
| 39 | 41 | ||
| @@ -107,6 +109,10 @@ editing it with \\[org-edit-src-code]. Has no effect if | |||
| 107 | :group 'org-edit-structure | 109 | :group 'org-edit-structure |
| 108 | :type 'integer) | 110 | :type 'integer) |
| 109 | 111 | ||
| 112 | (defvar org-src-strip-leading-and-trailing-blank-lines nil | ||
| 113 | "If non-nil, blank lines are removed when exiting the code edit | ||
| 114 | buffer.") | ||
| 115 | |||
| 110 | (defcustom org-edit-src-persistent-message t | 116 | (defcustom org-edit-src-persistent-message t |
| 111 | "Non-nil means show persistent exit help message while editing src examples. | 117 | "Non-nil means show persistent exit help message while editing src examples. |
| 112 | The message is shown in the header-line, which will be created in the | 118 | The message is shown in the header-line, which will be created in the |
| @@ -147,7 +153,8 @@ but which mess up the display of a snippet in Org exported files.") | |||
| 147 | 153 | ||
| 148 | (defcustom org-src-lang-modes | 154 | (defcustom org-src-lang-modes |
| 149 | '(("ocaml" . tuareg) ("elisp" . emacs-lisp) ("ditaa" . artist) | 155 | '(("ocaml" . tuareg) ("elisp" . emacs-lisp) ("ditaa" . artist) |
| 150 | ("asymptote" . asy) ("dot" . fundamental) ("sqlite" . sql)) | 156 | ("asymptote" . asy) ("dot" . fundamental) ("sqlite" . sql) |
| 157 | ("calc" . fundamental)) | ||
| 151 | "Alist mapping languages to their major mode. | 158 | "Alist mapping languages to their major mode. |
| 152 | The key is the language name, the value is the string that should | 159 | The key is the language name, the value is the string that should |
| 153 | be inserted as the name of the major mode. For many languages this is | 160 | be inserted as the name of the major mode. For many languages this is |
| @@ -165,6 +172,7 @@ For example, there is no ocaml-mode in Emacs, but the mode to use is | |||
| 165 | 172 | ||
| 166 | (defvar org-src-mode-map (make-sparse-keymap)) | 173 | (defvar org-src-mode-map (make-sparse-keymap)) |
| 167 | (define-key org-src-mode-map "\C-c'" 'org-edit-src-exit) | 174 | (define-key org-src-mode-map "\C-c'" 'org-edit-src-exit) |
| 175 | |||
| 168 | (defvar org-edit-src-force-single-line nil) | 176 | (defvar org-edit-src-force-single-line nil) |
| 169 | (defvar org-edit-src-from-org-mode nil) | 177 | (defvar org-edit-src-from-org-mode nil) |
| 170 | (defvar org-edit-src-allow-write-back-p t) | 178 | (defvar org-edit-src-allow-write-back-p t) |
| @@ -181,6 +189,8 @@ For example, there is no ocaml-mode in Emacs, but the mode to use is | |||
| 181 | immediately; otherwise it will ask whether you want to return | 189 | immediately; otherwise it will ask whether you want to return |
| 182 | to the existing edit buffer.") | 190 | to the existing edit buffer.") |
| 183 | 191 | ||
| 192 | (defvar org-src-babel-info nil) | ||
| 193 | |||
| 184 | (define-minor-mode org-src-mode | 194 | (define-minor-mode org-src-mode |
| 185 | "Minor mode for language major mode buffers generated by org. | 195 | "Minor mode for language major mode buffers generated by org. |
| 186 | This minor mode is turned on in two situations: | 196 | This minor mode is turned on in two situations: |
| @@ -189,26 +199,30 @@ This minor mode is turned on in two situations: | |||
| 189 | There is a mode hook, and keybindings for `org-edit-src-exit' and | 199 | There is a mode hook, and keybindings for `org-edit-src-exit' and |
| 190 | `org-edit-src-save'") | 200 | `org-edit-src-save'") |
| 191 | 201 | ||
| 192 | (defun org-edit-src-code (&optional context code edit-buffer-name) | 202 | (defun org-edit-src-code (&optional context code edit-buffer-name quietp) |
| 193 | "Edit the source code example at point. | 203 | "Edit the source code example at point. |
| 194 | The example is copied to a separate buffer, and that buffer is switched | 204 | The example is copied to a separate buffer, and that buffer is |
| 195 | to the correct language mode. When done, exit with \\[org-edit-src-exit]. | 205 | switched to the correct language mode. When done, exit with |
| 196 | This will remove the original code in the Org buffer, and replace it with | 206 | \\[org-edit-src-exit]. This will remove the original code in the |
| 197 | the edited version. Optional argument CONTEXT is used by | 207 | Org buffer, and replace it with the edited version. Optional |
| 198 | \\[org-edit-src-save] when calling this function." | 208 | argument CONTEXT is used by \\[org-edit-src-save] when calling |
| 209 | this function. See \\[org-src-window-setup] to configure the | ||
| 210 | display of windows containing the Org buffer and the code | ||
| 211 | buffer." | ||
| 199 | (interactive) | 212 | (interactive) |
| 200 | (unless (eq context 'save) | 213 | (unless (eq context 'save) |
| 201 | (setq org-edit-src-saved-temp-window-config (current-window-configuration))) | 214 | (setq org-edit-src-saved-temp-window-config (current-window-configuration))) |
| 202 | (let ((line (org-current-line)) | 215 | (let ((mark (and (org-region-active-p) (mark))) |
| 203 | (col (current-column)) | ||
| 204 | (case-fold-search t) | 216 | (case-fold-search t) |
| 205 | (info (org-edit-src-find-region-and-lang)) | 217 | (info (org-edit-src-find-region-and-lang)) |
| 218 | (babel-info (org-babel-get-src-block-info 'light)) | ||
| 206 | (org-mode-p (eq major-mode 'org-mode)) | 219 | (org-mode-p (eq major-mode 'org-mode)) |
| 207 | (beg (make-marker)) | 220 | (beg (make-marker)) |
| 208 | (end (make-marker)) | 221 | (end (make-marker)) |
| 209 | (preserve-indentation org-src-preserve-indentation) | 222 | (preserve-indentation org-src-preserve-indentation) |
| 210 | (allow-write-back-p (null code)) | 223 | (allow-write-back-p (null code)) |
| 211 | block-nindent total-nindent ovl lang lang-f single lfmt begline buffer msg) | 224 | block-nindent total-nindent ovl lang lang-f single lfmt buffer msg |
| 225 | begline markline markcol line col) | ||
| 212 | (if (not info) | 226 | (if (not info) |
| 213 | nil | 227 | nil |
| 214 | (setq beg (move-marker beg (nth 0 info)) | 228 | (setq beg (move-marker beg (nth 0 info)) |
| @@ -226,6 +240,10 @@ the edited version. Optional argument CONTEXT is used by | |||
| 226 | block-nindent (nth 5 info) | 240 | block-nindent (nth 5 info) |
| 227 | lang-f (intern (concat lang "-mode")) | 241 | lang-f (intern (concat lang "-mode")) |
| 228 | 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)) | ||
| 244 | (save-excursion (goto-char mark) | ||
| 245 | (setq markline (org-current-line) | ||
| 246 | markcol (current-column)))) | ||
| 229 | (if (equal lang-f 'table.el-mode) | 247 | (if (equal lang-f 'table.el-mode) |
| 230 | (setq lang-f (lambda () | 248 | (setq lang-f (lambda () |
| 231 | (text-mode) | 249 | (text-mode) |
| @@ -235,7 +253,10 @@ the edited version. Optional argument CONTEXT is used by | |||
| 235 | (org-set-local 'org-edit-src-content-indentation 0)))) | 253 | (org-set-local 'org-edit-src-content-indentation 0)))) |
| 236 | (unless (functionp lang-f) | 254 | (unless (functionp lang-f) |
| 237 | (error "No such language mode: %s" lang-f)) | 255 | (error "No such language mode: %s" lang-f)) |
| 238 | (org-goto-line line) | 256 | (save-excursion |
| 257 | (if (> (point) end) (goto-char end)) | ||
| 258 | (setq line (org-current-line) | ||
| 259 | col (current-column))) | ||
| 239 | (if (and (setq buffer (org-edit-src-find-buffer beg end)) | 260 | (if (and (setq buffer (org-edit-src-find-buffer beg end)) |
| 240 | (if org-src-ask-before-returning-to-edit-buffer | 261 | (if org-src-ask-before-returning-to-edit-buffer |
| 241 | (y-or-n-p "Return to existing edit buffer? [n] will revert changes: ") t)) | 262 | (y-or-n-p "Return to existing edit buffer? [n] will revert changes: ") t)) |
| @@ -267,11 +288,16 @@ the edited version. Optional argument CONTEXT is used by | |||
| 267 | (unless preserve-indentation | 288 | (unless preserve-indentation |
| 268 | (setq total-nindent (or (org-do-remove-indentation) 0))) | 289 | (setq total-nindent (or (org-do-remove-indentation) 0))) |
| 269 | (let ((org-inhibit-startup t)) | 290 | (let ((org-inhibit-startup t)) |
| 270 | (funcall lang-f)) | 291 | (condition-case e |
| 292 | (funcall lang-f) | ||
| 293 | (error | ||
| 294 | (error "Language mode `%s' fails with: %S" lang-f (nth 1 e))))) | ||
| 271 | (set (make-local-variable 'org-edit-src-force-single-line) single) | 295 | (set (make-local-variable 'org-edit-src-force-single-line) single) |
| 272 | (set (make-local-variable 'org-edit-src-from-org-mode) org-mode-p) | 296 | (set (make-local-variable 'org-edit-src-from-org-mode) org-mode-p) |
| 273 | (set (make-local-variable 'org-edit-src-allow-write-back-p) allow-write-back-p) | 297 | (set (make-local-variable 'org-edit-src-allow-write-back-p) allow-write-back-p) |
| 274 | (set (make-local-variable 'org-src-preserve-indentation) preserve-indentation) | 298 | (set (make-local-variable 'org-src-preserve-indentation) preserve-indentation) |
| 299 | (when babel-info | ||
| 300 | (set (make-local-variable 'org-src-babel-info) babel-info)) | ||
| 275 | (when lfmt | 301 | (when lfmt |
| 276 | (set (make-local-variable 'org-coderef-label-format) lfmt)) | 302 | (set (make-local-variable 'org-coderef-label-format) lfmt)) |
| 277 | (when org-mode-p | 303 | (when org-mode-p |
| @@ -279,6 +305,12 @@ the edited version. Optional argument CONTEXT is used by | |||
| 279 | (while (re-search-forward "^," nil t) | 305 | (while (re-search-forward "^," nil t) |
| 280 | (if (eq (org-current-line) line) (setq total-nindent (1+ total-nindent))) | 306 | (if (eq (org-current-line) line) (setq total-nindent (1+ total-nindent))) |
| 281 | (replace-match ""))) | 307 | (replace-match ""))) |
| 308 | (when markline | ||
| 309 | (org-goto-line (1+ (- markline begline))) | ||
| 310 | (org-move-to-column | ||
| 311 | (if preserve-indentation markcol (max 0 (- markcol total-nindent)))) | ||
| 312 | (push-mark (point) 'no-message t) | ||
| 313 | (setq deactivate-mark nil)) | ||
| 282 | (org-goto-line (1+ (- line begline))) | 314 | (org-goto-line (1+ (- line begline))) |
| 283 | (org-move-to-column | 315 | (org-move-to-column |
| 284 | (if preserve-indentation col (max 0 (- col total-nindent)))) | 316 | (if preserve-indentation col (max 0 (- col total-nindent)))) |
| @@ -290,7 +322,7 @@ the edited version. Optional argument CONTEXT is used by | |||
| 290 | (set-buffer-modified-p nil) | 322 | (set-buffer-modified-p nil) |
| 291 | (and org-edit-src-persistent-message | 323 | (and org-edit-src-persistent-message |
| 292 | (org-set-local 'header-line-format msg))) | 324 | (org-set-local 'header-line-format msg))) |
| 293 | (message "%s" msg) | 325 | (unless quietp (message "%s" msg)) |
| 294 | t))) | 326 | t))) |
| 295 | 327 | ||
| 296 | (defun org-edit-src-continue (e) | 328 | (defun org-edit-src-continue (e) |
| @@ -321,6 +353,8 @@ the edited version. Optional argument CONTEXT is used by | |||
| 321 | (if (eq context 'edit) (delete-other-windows)) | 353 | (if (eq context 'edit) (delete-other-windows)) |
| 322 | (org-switch-to-buffer-other-window buffer) | 354 | (org-switch-to-buffer-other-window buffer) |
| 323 | (if (eq context 'exit) (delete-other-windows))) | 355 | (if (eq context 'exit) (delete-other-windows))) |
| 356 | ('switch-invisibly | ||
| 357 | (set-buffer buffer)) | ||
| 324 | (t | 358 | (t |
| 325 | (message "Invalid value %s for org-src-window-setup" | 359 | (message "Invalid value %s for org-src-window-setup" |
| 326 | (symbol-name org-src-window-setup)) | 360 | (symbol-name org-src-window-setup)) |
| @@ -552,11 +586,12 @@ the language, a switch telling if the content should be in a single line." | |||
| 552 | (delta 0) code line col indent) | 586 | (delta 0) code line col indent) |
| 553 | (when allow-write-back-p | 587 | (when allow-write-back-p |
| 554 | (unless preserve-indentation (untabify (point-min) (point-max))) | 588 | (unless preserve-indentation (untabify (point-min) (point-max))) |
| 555 | (save-excursion | 589 | (if org-src-strip-leading-and-trailing-blank-lines |
| 556 | (goto-char (point-min)) | 590 | (save-excursion |
| 557 | (if (looking-at "[ \t\n]*\n") (replace-match "")) | 591 | (goto-char (point-min)) |
| 558 | (unless macro | 592 | (if (looking-at "[ \t\n]*\n") (replace-match "")) |
| 559 | (if (re-search-forward "\n[ \t\n]*\\'" nil t) (replace-match ""))))) | 593 | (unless macro |
| 594 | (if (re-search-forward "\n[ \t\n]*\\'" nil t) (replace-match "")))))) | ||
| 560 | (setq line (if (org-bound-and-true-p org-edit-src-force-single-line) | 595 | (setq line (if (org-bound-and-true-p org-edit-src-force-single-line) |
| 561 | 1 | 596 | 1 |
| 562 | (org-current-line)) | 597 | (org-current-line)) |
| @@ -654,6 +689,122 @@ the language, a switch telling if the content should be in a single line." | |||
| 654 | 689 | ||
| 655 | (org-add-hook 'org-src-mode-hook 'org-src-mode-configure-edit-buffer) | 690 | (org-add-hook 'org-src-mode-hook 'org-src-mode-configure-edit-buffer) |
| 656 | 691 | ||
| 692 | |||
| 693 | (defun org-src-associate-babel-session (info) | ||
| 694 | "Associate edit buffer with comint session." | ||
| 695 | (interactive) | ||
| 696 | (let ((session (cdr (assoc :session (nth 2 info))))) | ||
| 697 | (and session (not (string= session "none")) | ||
| 698 | (org-babel-comint-buffer-livep session) | ||
| 699 | ((lambda (f) (and (fboundp f) (funcall f session))) | ||
| 700 | (intern (format "org-babel-%s-associate-session" (nth 0 info))))))) | ||
| 701 | |||
| 702 | (defun org-src-babel-configure-edit-buffer () | ||
| 703 | (when org-src-babel-info | ||
| 704 | (org-src-associate-babel-session org-src-babel-info))) | ||
| 705 | |||
| 706 | (org-add-hook 'org-src-mode-hook 'org-src-babel-configure-edit-buffer) | ||
| 707 | (defmacro org-src-do-at-code-block (&rest body) | ||
| 708 | "Execute a command from an edit buffer in the Org-mode buffer." | ||
| 709 | `(let ((beg-marker org-edit-src-beg-marker)) | ||
| 710 | (if beg-marker | ||
| 711 | (with-current-buffer (marker-buffer beg-marker) | ||
| 712 | (goto-char (marker-position beg-marker)) | ||
| 713 | ,@body)))) | ||
| 714 | |||
| 715 | (defun org-src-do-key-sequence-at-code-block (&optional key) | ||
| 716 | "Execute key sequence at code block in the source Org buffer. | ||
| 717 | The command bound to KEY in the Org-babel key map is executed | ||
| 718 | remotely with point temporarily at the start of the code block in | ||
| 719 | the Org buffer. | ||
| 720 | |||
| 721 | This command is not bound to a key by default, to avoid conflicts | ||
| 722 | with language major mode bindings. To bind it to C-c @ in all | ||
| 723 | language major modes, you could use | ||
| 724 | |||
| 725 | (add-hook 'org-src-mode-hook | ||
| 726 | (lambda () (define-key org-src-mode-map \"\\C-c@\" | ||
| 727 | 'org-src-do-key-sequence-at-code-block))) | ||
| 728 | |||
| 729 | In that case, for example, C-c @ t issued in code edit buffers | ||
| 730 | would tangle the current Org code block, C-c @ e would execute | ||
| 731 | the block and C-c @ h would display the other available | ||
| 732 | Org-babel commands." | ||
| 733 | (interactive "kOrg-babel key: ") | ||
| 734 | (if (equal key (kbd "C-g")) (keyboard-quit) | ||
| 735 | (org-edit-src-save) | ||
| 736 | (org-src-do-at-code-block | ||
| 737 | (call-interactively | ||
| 738 | (lookup-key org-babel-map key))))) | ||
| 739 | |||
| 740 | (defcustom org-src-tab-acts-natively nil | ||
| 741 | "If non-nil, the effect of TAB in a code block is as if it were | ||
| 742 | issued in the language major mode buffer." | ||
| 743 | :type 'boolean | ||
| 744 | :group 'org-babel) | ||
| 745 | |||
| 746 | (defun org-src-native-tab-command-maybe () | ||
| 747 | "Perform language-specific TAB action. | ||
| 748 | Alter code block according to effect of TAB in the language major | ||
| 749 | mode." | ||
| 750 | (and org-src-tab-acts-natively | ||
| 751 | (let ((org-src-strip-leading-and-trailing-blank-lines nil)) | ||
| 752 | (org-babel-do-key-sequence-in-edit-buffer (kbd "TAB"))))) | ||
| 753 | |||
| 754 | (add-hook 'org-tab-first-hook 'org-src-native-tab-command-maybe) | ||
| 755 | |||
| 756 | (defun org-src-font-lock-fontify-block (lang start end) | ||
| 757 | "Fontify code block. | ||
| 758 | This function is called by emacs automatic fontification, as long | ||
| 759 | as `org-src-fontify-natively' is non-nil. For manual | ||
| 760 | fontification of code blocks see `org-src-fontify-block' and | ||
| 761 | `org-src-fontify-buffer'" | ||
| 762 | (let* ((lang-mode (org-src-get-lang-mode lang)) | ||
| 763 | (string (buffer-substring-no-properties start end)) | ||
| 764 | (modified (buffer-modified-p)) | ||
| 765 | (org-buffer (current-buffer)) pos next) | ||
| 766 | (remove-text-properties start end '(face nil)) | ||
| 767 | (with-current-buffer | ||
| 768 | (get-buffer-create | ||
| 769 | (concat " org-src-fontification:" (symbol-name lang-mode))) | ||
| 770 | (delete-region (point-min) (point-max)) | ||
| 771 | (insert string) | ||
| 772 | (unless (eq major-mode lang-mode) (funcall lang-mode)) | ||
| 773 | (font-lock-fontify-buffer) | ||
| 774 | (setq pos (point-min)) | ||
| 775 | (while (setq next (next-single-property-change pos 'face)) | ||
| 776 | (put-text-property | ||
| 777 | (+ start (1- pos)) (+ start next) 'face | ||
| 778 | (get-text-property pos 'face) org-buffer) | ||
| 779 | (setq pos next))) | ||
| 780 | (add-text-properties | ||
| 781 | start end | ||
| 782 | '(font-lock-fontified t fontified t font-lock-multiline t)) | ||
| 783 | (set-buffer-modified-p modified)) | ||
| 784 | t) ;; Tell `org-fontify-meta-lines-and-blocks' that we fontified | ||
| 785 | |||
| 786 | (defun org-src-fontify-block () | ||
| 787 | "Fontify code block at point." | ||
| 788 | (interactive) | ||
| 789 | (save-excursion | ||
| 790 | (let ((org-src-fontify-natively t) | ||
| 791 | (info (org-edit-src-find-region-and-lang))) | ||
| 792 | (font-lock-fontify-region (nth 0 info) (nth 1 info))))) | ||
| 793 | |||
| 794 | (defun org-src-fontify-buffer () | ||
| 795 | "Fontify all code blocks in the current buffer" | ||
| 796 | (interactive) | ||
| 797 | (org-babel-map-src-blocks nil | ||
| 798 | (org-src-fontify-block))) | ||
| 799 | |||
| 800 | (defun org-src-get-lang-mode (lang) | ||
| 801 | "Return major mode that should be used for LANG. | ||
| 802 | LANG is a string, and the returned major mode is a symbol." | ||
| 803 | (intern | ||
| 804 | (concat | ||
| 805 | ((lambda (l) (if (symbolp l) (symbol-name l) l)) | ||
| 806 | (or (cdr (assoc lang org-src-lang-modes)) lang)) "-mode"))) | ||
| 807 | |||
| 657 | (provide 'org-src) | 808 | (provide 'org-src) |
| 658 | 809 | ||
| 659 | ;; arch-tag: 6a1fc84f-dec7-47be-a416-64be56bea5d8 | 810 | ;; arch-tag: 6a1fc84f-dec7-47be-a416-64be56bea5d8 |
diff --git a/lisp/org/org-table.el b/lisp/org/org-table.el index 6a7120e0e55..0d61a782270 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.01 | 9 | ;; Version: 7.3 |
| 10 | ;; | 10 | ;; |
| 11 | ;; This file is part of GNU Emacs. | 11 | ;; This file is part of GNU Emacs. |
| 12 | ;; | 12 | ;; |
| @@ -342,17 +342,21 @@ available parameters." | |||
| 342 | 342 | ||
| 343 | (defun org-table-cookie-line-p (line) | 343 | (defun org-table-cookie-line-p (line) |
| 344 | "Is this a table line with only alignment/width cookies?" | 344 | "Is this a table line with only alignment/width cookies?" |
| 345 | |||
| 346 | (save-match-data | 345 | (save-match-data |
| 347 | (and (string-match "[<>]\\|&[lg]t;" line) | 346 | (and (string-match "[<>]\\|&[lg]t;" line) |
| 348 | (or (string-match "\\`[ \t]*|[ \t]*/[ \t]*\\(|[ \t<>0-9|lgt&;]+\\)\\'" line) | 347 | (or (string-match |
| 349 | (string-match "\\(\\`[ \t<>lr0-9|gt&;]+\\'\\)" line)) | 348 | "\\`[ \t]*|[ \t]*/[ \t]*\\(|[ \t<>0-9|lrcgt&;]+\\)\\'" line) |
| 349 | (string-match "\\(\\`[ \t<>lrc0-9|gt&;]+\\'\\)" line)) | ||
| 350 | (not (delq nil (mapcar | 350 | (not (delq nil (mapcar |
| 351 | (lambda (s) | 351 | (lambda (s) |
| 352 | (not (or (equal s "") | 352 | (not (or (equal s "") |
| 353 | (string-match "\\`<\\([lr]?[0-9]+\\|[lr]\\)>\\'" s) | 353 | (string-match |
| 354 | (string-match "\\`<\\([lr]?[0-9]+\\|[lr]\\)>\\'" s)))) | 354 | "\\`<\\([lrc]?[0-9]+\\|[lrc]\\)>\\'" s) |
| 355 | (org-split-string (match-string 1 line) "[ \t]*|[ \t]*"))))))) | 355 | (string-match |
| 356 | "\\`<\\([lrc]?[0-9]+\\|[lrc]\\)>\\'" | ||
| 357 | s)))) | ||
| 358 | (org-split-string (match-string 1 line) | ||
| 359 | "[ \t]*|[ \t]*"))))))) | ||
| 356 | 360 | ||
| 357 | (defconst org-table-translate-regexp | 361 | (defconst org-table-translate-regexp |
| 358 | (concat "\\(" "@[-0-9I$]+" "\\|" "[a-zA-Z]\\{1,2\\}\\([0-9]+\\|&\\)" "\\)") | 362 | (concat "\\(" "@[-0-9I$]+" "\\|" "[a-zA-Z]\\{1,2\\}\\([0-9]+\\|&\\)" "\\)") |
| @@ -369,8 +373,9 @@ and table.el tables." | |||
| 369 | (if (y-or-n-p "Convert table to Org-mode table? ") | 373 | (if (y-or-n-p "Convert table to Org-mode table? ") |
| 370 | (org-table-convert))) | 374 | (org-table-convert))) |
| 371 | ((org-at-table-p) | 375 | ((org-at-table-p) |
| 372 | (if (y-or-n-p "Convert table to table.el table? ") | 376 | (when (y-or-n-p "Convert table to table.el table? ") |
| 373 | (org-table-convert))) | 377 | (org-table-align) |
| 378 | (org-table-convert))) | ||
| 374 | (t (call-interactively 'table-insert)))) | 379 | (t (call-interactively 'table-insert)))) |
| 375 | 380 | ||
| 376 | (defun org-table-create-or-convert-from-region (arg) | 381 | (defun org-table-create-or-convert-from-region (arg) |
| @@ -453,7 +458,7 @@ nil When nil, the command tries to be smart and figure out the | |||
| 453 | (t 1)))) | 458 | (t 1)))) |
| 454 | (goto-char beg) | 459 | (goto-char beg) |
| 455 | (if (equal separator '(4)) | 460 | (if (equal separator '(4)) |
| 456 | (while (<= (point) end) | 461 | (while (< (point) end) |
| 457 | ;; parse the csv stuff | 462 | ;; parse the csv stuff |
| 458 | (cond | 463 | (cond |
| 459 | ((looking-at "^") (insert "| ")) | 464 | ((looking-at "^") (insert "| ")) |
| @@ -656,9 +661,9 @@ When nil, simply write \"#ERROR\" in corrupted fields.") | |||
| 656 | (goto-char beg) | 661 | (goto-char beg) |
| 657 | (setq narrow (and org-table-do-narrow | 662 | (setq narrow (and org-table-do-narrow |
| 658 | org-format-transports-properties-p | 663 | org-format-transports-properties-p |
| 659 | (re-search-forward "<[rl]?[0-9]+>" end t))) | 664 | (re-search-forward "<[lrc]?[0-9]+>" end t))) |
| 660 | (goto-char beg) | 665 | (goto-char beg) |
| 661 | (setq falign (re-search-forward "<[rl][0-9]*>" end t)) | 666 | (setq falign (re-search-forward "<[lrc][0-9]*>" end t)) |
| 662 | (goto-char beg) | 667 | (goto-char beg) |
| 663 | ;; Get the rows | 668 | ;; Get the rows |
| 664 | (setq lines (org-split-string | 669 | (setq lines (org-split-string |
| @@ -699,7 +704,7 @@ When nil, simply write \"#ERROR\" in corrupted fields.") | |||
| 699 | (setq c column fmax nil falign1 nil) | 704 | (setq c column fmax nil falign1 nil) |
| 700 | (while c | 705 | (while c |
| 701 | (setq e (pop c)) | 706 | (setq e (pop c)) |
| 702 | (when (and (stringp e) (string-match "^<\\([rl]\\)?\\([0-9]+\\)?>$" e)) | 707 | (when (and (stringp e) (string-match "^<\\([lrc]\\)?\\([0-9]+\\)?>$" e)) |
| 703 | (if (match-end 1) (setq falign1 (match-string 1 e))) | 708 | (if (match-end 1) (setq falign1 (match-string 1 e))) |
| 704 | (if (and org-table-do-narrow (match-end 2)) | 709 | (if (and org-table-do-narrow (match-end 2)) |
| 705 | (setq fmax (string-to-number (match-string 2 e)) c nil)))) | 710 | (setq fmax (string-to-number (match-string 2 e)) c nil)))) |
| @@ -1150,11 +1155,14 @@ is always the old value." | |||
| 1150 | 1155 | ||
| 1151 | (defun org-table-current-column () | 1156 | (defun org-table-current-column () |
| 1152 | "Find out which column we are in." | 1157 | "Find out which column we are in." |
| 1158 | (interactive) | ||
| 1159 | (if (interactive-p) (org-table-check-inside-data-field)) | ||
| 1153 | (save-excursion | 1160 | (save-excursion |
| 1154 | (let ((cnt 0) (pos (point))) | 1161 | (let ((cnt 0) (pos (point))) |
| 1155 | (beginning-of-line 1) | 1162 | (beginning-of-line 1) |
| 1156 | (while (search-forward "|" pos t) | 1163 | (while (search-forward "|" pos t) |
| 1157 | (setq cnt (1+ cnt))) | 1164 | (setq cnt (1+ cnt))) |
| 1165 | (if (interactive-p) (message "In table column %d" cnt)) | ||
| 1158 | cnt))) | 1166 | cnt))) |
| 1159 | 1167 | ||
| 1160 | (defun org-table-current-dline () | 1168 | (defun org-table-current-dline () |
| @@ -4254,7 +4262,7 @@ so you cannot specify parameters for it." | |||
| 4254 | (lambda (x) | 4262 | (lambda (x) |
| 4255 | (if (eq x 'hline) | 4263 | (if (eq x 'hline) |
| 4256 | "|----+----|" | 4264 | "|----+----|" |
| 4257 | (concat "| " (mapconcat 'identity x " | ") " |"))) | 4265 | (concat "| " (mapconcat 'org-html-expand x " | ") " |"))) |
| 4258 | table) | 4266 | table) |
| 4259 | splicep)) | 4267 | splicep)) |
| 4260 | (if (string-match "\n+\\'" html) | 4268 | (if (string-match "\n+\\'" html) |
diff --git a/lisp/org/org-taskjuggler.el b/lisp/org/org-taskjuggler.el index da9e156870e..d03cd591b81 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.01 | 7 | ;; Version: 7.3 |
| 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 |
| @@ -503,7 +503,7 @@ finally add more underscore characters (\"_\")." | |||
| 503 | (parts (split-string headline)) | 503 | (parts (split-string headline)) |
| 504 | (id (org-taskjuggler-clean-id (downcase (pop parts))))) | 504 | (id (org-taskjuggler-clean-id (downcase (pop parts))))) |
| 505 | ; try to add more parts of the headline to make it unique | 505 | ; try to add more parts of the headline to make it unique |
| 506 | (while (member id unique-ids) | 506 | (while (and (member id unique-ids) (car parts)) |
| 507 | (setq id (concat id "_" (org-taskjuggler-clean-id (downcase (pop parts)))))) | 507 | (setq id (concat id "_" (org-taskjuggler-clean-id (downcase (pop parts)))))) |
| 508 | ; if its still not unique add "_" | 508 | ; if its still not unique add "_" |
| 509 | (while (member id unique-ids) | 509 | (while (member id unique-ids) |
diff --git a/lisp/org/org-timer.el b/lisp/org/org-timer.el index b773274e93b..6c1f4984cf1 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.01 | 8 | ;; Version: 7.3 |
| 9 | ;; | 9 | ;; |
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | ;; | 11 | ;; |
| @@ -31,7 +31,7 @@ | |||
| 31 | 31 | ||
| 32 | (require 'org) | 32 | (require 'org) |
| 33 | 33 | ||
| 34 | (declare-function org-show-notification "org-clock" (parameters)) | 34 | (declare-function org-notify "org-clock" (notification &optional play-sound)) |
| 35 | (declare-function org-agenda-error "org-agenda" ()) | 35 | (declare-function org-agenda-error "org-agenda" ()) |
| 36 | 36 | ||
| 37 | (defvar org-timer-start-time nil | 37 | (defvar org-timer-start-time nil |
| @@ -145,25 +145,33 @@ With prefix arg STOP, stop it entirely." | |||
| 145 | (org-timer-set-mode-line 'off)) | 145 | (org-timer-set-mode-line 'off)) |
| 146 | 146 | ||
| 147 | ;;;###autoload | 147 | ;;;###autoload |
| 148 | (defun org-timer (&optional restart) | 148 | (defun org-timer (&optional restart no-insert-p) |
| 149 | "Insert a H:MM:SS string from the timer into the buffer. | 149 | "Insert a H:MM:SS string from the timer into the buffer. |
| 150 | The first time this command is used, the timer is started. When used with | 150 | The first time this command is used, the timer is started. When used with |
| 151 | a \\[universal-argument] prefix, force restarting the timer. | 151 | a \\[universal-argument] prefix, force restarting the timer. |
| 152 | When used with a double prefix argument \ | 152 | When used with a double prefix argument \\[universal-argument], change all the timer string |
| 153 | \\[universal-argument] \\universal-argument], change all the timer string | ||
| 154 | in the region by a fixed amount. This can be used to recalibrate a timer | 153 | in the region by a fixed amount. This can be used to recalibrate a timer |
| 155 | that was not started at the correct moment." | 154 | that was not started at the correct moment. |
| 155 | |||
| 156 | If NO-INSERT-P is non-nil, return the string instead of inserting | ||
| 157 | it in the buffer." | ||
| 156 | (interactive "P") | 158 | (interactive "P") |
| 157 | (if (equal restart '(4)) (org-timer-start)) | 159 | (when (or (equal restart '(4)) (not org-timer-start-time)) |
| 158 | (or org-timer-start-time (org-timer-start)) | 160 | (org-timer-start)) |
| 159 | (insert (org-timer-value-string))) | 161 | (if no-insert-p |
| 162 | (org-timer-value-string) | ||
| 163 | (insert (org-timer-value-string)))) | ||
| 160 | 164 | ||
| 161 | (defun org-timer-value-string () | 165 | (defun org-timer-value-string () |
| 162 | (format org-timer-format (org-timer-secs-to-hms (floor (org-timer-seconds))))) | 166 | (format org-timer-format (org-timer-secs-to-hms (floor (org-timer-seconds))))) |
| 163 | 167 | ||
| 168 | (defvar org-timer-timer-is-countdown nil) | ||
| 164 | (defun org-timer-seconds () | 169 | (defun org-timer-seconds () |
| 165 | (- (org-float-time (or org-timer-pause-time (current-time))) | 170 | (if org-timer-timer-is-countdown |
| 166 | (org-float-time org-timer-start-time))) | 171 | (- (org-float-time org-timer-start-time) |
| 172 | (org-float-time (current-time))) | ||
| 173 | (- (org-float-time (or org-timer-pause-time (current-time))) | ||
| 174 | (org-float-time org-timer-start-time)))) | ||
| 167 | 175 | ||
| 168 | ;;;###autoload | 176 | ;;;###autoload |
| 169 | (defun org-timer-change-times-in-region (beg end delta) | 177 | (defun org-timer-change-times-in-region (beg end delta) |
| @@ -195,19 +203,22 @@ that was not started at the correct moment." | |||
| 195 | (defun org-timer-item (&optional arg) | 203 | (defun org-timer-item (&optional arg) |
| 196 | "Insert a description-type item with the current timer value." | 204 | "Insert a description-type item with the current timer value." |
| 197 | (interactive "P") | 205 | (interactive "P") |
| 198 | (let ((ind 0)) | 206 | (cond |
| 199 | (save-excursion | 207 | ;; In a timer list, insert with `org-list-insert-item-generic'. |
| 200 | (skip-chars-backward " \n\t") | 208 | ((and (org-in-item-p) |
| 201 | (condition-case nil | 209 | (save-excursion (org-beginning-of-item) (org-at-item-timer-p))) |
| 202 | (progn | 210 | (org-list-insert-item-generic |
| 203 | (org-beginning-of-item) | 211 | (point) nil (concat (org-timer (when arg '(4)) t) ":: "))) |
| 204 | (setq ind (org-get-indentation))) | 212 | ;; In a list of another type, don't break anything: throw an error. |
| 205 | (error nil))) | 213 | ((org-in-item-p) |
| 206 | (or (bolp) (newline)) | 214 | (error "This is not a timer list")) |
| 207 | (org-indent-line-to ind) | 215 | ;; Else, insert the timer correctly indented at bol. |
| 208 | (insert "- ") | 216 | (t |
| 209 | (org-timer (if arg '(4))) | 217 | (beginning-of-line) |
| 210 | (insert ":: "))) | 218 | (org-indent-line-function) |
| 219 | (insert "- ") | ||
| 220 | (org-timer (when arg '(4))) | ||
| 221 | (insert ":: ")))) | ||
| 211 | 222 | ||
| 212 | (defun org-timer-fix-incomplete (hms) | 223 | (defun org-timer-fix-incomplete (hms) |
| 213 | "If hms is a H:MM:SS string with missing hour or hour and minute, fix it." | 224 | "If hms is a H:MM:SS string with missing hour or hour and minute, fix it." |
| @@ -292,7 +303,9 @@ VALUE can be `on', `off', or `pause'." | |||
| 292 | (when (eval org-timer-current-timer) | 303 | (when (eval org-timer-current-timer) |
| 293 | (run-hooks 'org-timer-cancel-hook) | 304 | (run-hooks 'org-timer-cancel-hook) |
| 294 | (cancel-timer org-timer-current-timer) | 305 | (cancel-timer org-timer-current-timer) |
| 295 | (setq org-timer-current-timer nil)) | 306 | (setq org-timer-current-timer nil) |
| 307 | (setq org-timer-timer-is-countdown nil) | ||
| 308 | (org-timer-set-mode-line 'off)) | ||
| 296 | (message "Last timer canceled")) | 309 | (message "Last timer canceled")) |
| 297 | 310 | ||
| 298 | (defun org-timer-show-remaining-time () | 311 | (defun org-timer-show-remaining-time () |
| @@ -309,17 +322,13 @@ VALUE can be `on', `off', or `pause'." | |||
| 309 | (message "%d minute(s) %d seconds left before next time out" | 322 | (message "%d minute(s) %d seconds left before next time out" |
| 310 | rmins rsecs)))) | 323 | rmins rsecs)))) |
| 311 | 324 | ||
| 312 | (defun bzg-test (&optional test) | ||
| 313 | (interactive "P") | ||
| 314 | test) | ||
| 315 | |||
| 316 | ;;;###autoload | 325 | ;;;###autoload |
| 317 | (defun org-timer-set-timer (&optional opt) | 326 | (defun org-timer-set-timer (&optional opt) |
| 318 | "Prompt for a duration and set a timer. | 327 | "Prompt for a duration and set a timer. |
| 319 | 328 | ||
| 320 | If `org-timer-default-timer' is not zero, suggest this value as | 329 | If `org-timer-default-timer' is not zero, suggest this value as |
| 321 | the default duration for the timer. If a timer is already set, | 330 | the default duration for the timer. If a timer is already set, |
| 322 | prompt the use if she wants to replace it. | 331 | prompt the user if she wants to replace it. |
| 323 | 332 | ||
| 324 | Called with a numeric prefix argument, use this numeric value as | 333 | Called with a numeric prefix argument, use this numeric value as |
| 325 | the duration of the timer. | 334 | the duration of the timer. |
| @@ -353,9 +362,11 @@ replace any running timer." | |||
| 353 | (widen) | 362 | (widen) |
| 354 | (goto-char pos) | 363 | (goto-char pos) |
| 355 | (org-show-entry) | 364 | (org-show-entry) |
| 356 | (org-get-heading)))) | 365 | (or (ignore-errors (org-get-heading)) |
| 366 | (concat "File:" (file-name-nondirectory (buffer-file-name))))))) | ||
| 357 | ((eq major-mode 'org-mode) | 367 | ((eq major-mode 'org-mode) |
| 358 | (org-get-heading)) | 368 | (or (ignore-errors (org-get-heading)) |
| 369 | (concat "File:" (file-name-nondirectory (buffer-file-name))))) | ||
| 359 | (t (error "Not in an Org buffer")))) | 370 | (t (error "Not in an Org buffer")))) |
| 360 | timer-set) | 371 | timer-set) |
| 361 | (if (or (and org-timer-current-timer | 372 | (if (or (and org-timer-current-timer |
| @@ -363,6 +374,7 @@ replace any running timer." | |||
| 363 | (y-or-n-p "Replace current timer? "))) | 374 | (y-or-n-p "Replace current timer? "))) |
| 364 | (not org-timer-current-timer)) | 375 | (not org-timer-current-timer)) |
| 365 | (progn | 376 | (progn |
| 377 | (require 'org-clock) | ||
| 366 | (when org-timer-current-timer | 378 | (when org-timer-current-timer |
| 367 | (cancel-timer org-timer-current-timer)) | 379 | (cancel-timer org-timer-current-timer)) |
| 368 | (setq org-timer-current-timer | 380 | (setq org-timer-current-timer |
| @@ -370,8 +382,14 @@ replace any running timer." | |||
| 370 | secs nil `(lambda () | 382 | secs nil `(lambda () |
| 371 | (setq org-timer-current-timer nil) | 383 | (setq org-timer-current-timer nil) |
| 372 | (org-notify ,(format "%s: time out" hl) t) | 384 | (org-notify ,(format "%s: time out" hl) t) |
| 385 | (setq org-timer-timer-is-countdown nil) | ||
| 386 | (org-timer-set-mode-line 'off) | ||
| 373 | (run-hooks 'org-timer-done-hook)))) | 387 | (run-hooks 'org-timer-done-hook)))) |
| 374 | (run-hooks 'org-timer-set-hook)) | 388 | (run-hooks 'org-timer-set-hook) |
| 389 | (setq org-timer-timer-is-countdown t | ||
| 390 | org-timer-start-time | ||
| 391 | (time-add (current-time) (seconds-to-time (* mins 60)))) | ||
| 392 | (org-timer-set-mode-line 'on)) | ||
| 375 | (message "No timer set")))))) | 393 | (message "No timer set")))))) |
| 376 | 394 | ||
| 377 | (provide 'org-timer) | 395 | (provide 'org-timer) |
diff --git a/lisp/org/org-vm.el b/lisp/org/org-vm.el index 4a28df6caa0..629258dec94 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.01 | 9 | ;; Version: 7.3 |
| 10 | ;; | 10 | ;; |
| 11 | ;; This file is part of GNU Emacs. | 11 | ;; This file is part of GNU Emacs. |
| 12 | ;; | 12 | ;; |
| @@ -66,9 +66,19 @@ | |||
| 66 | (to (vm-get-header-contents message "To")) | 66 | (to (vm-get-header-contents message "To")) |
| 67 | (from (vm-get-header-contents message "From")) | 67 | (from (vm-get-header-contents message "From")) |
| 68 | (message-id (vm-su-message-id message)) | 68 | (message-id (vm-su-message-id message)) |
| 69 | (date (vm-get-header-contents message "Date")) | ||
| 70 | (date-ts (and date (format-time-string | ||
| 71 | (org-time-stamp-format t) | ||
| 72 | (date-to-time date)))) | ||
| 73 | (date-ts-ia (and date (format-time-string | ||
| 74 | (org-time-stamp-format t t) | ||
| 75 | (date-to-time date)))) | ||
| 69 | desc link) | 76 | desc link) |
| 70 | (org-store-link-props :type "vm" :from from :to to :subject subject | 77 | (org-store-link-props :type "vm" :from from :to to :subject subject |
| 71 | :message-id message-id) | 78 | :message-id message-id) |
| 79 | (when date | ||
| 80 | (org-add-link-props :date date :date-timestamp date-ts | ||
| 81 | :date-timestamp-inactive date-ts-ia)) | ||
| 72 | (setq message-id (org-remove-angle-brackets message-id)) | 82 | (setq message-id (org-remove-angle-brackets message-id)) |
| 73 | (setq folder (abbreviate-file-name folder)) | 83 | (setq folder (abbreviate-file-name folder)) |
| 74 | (if (and vm-folder-directory | 84 | (if (and vm-folder-directory |
diff --git a/lisp/org/org-w3m.el b/lisp/org/org-w3m.el index b457156f573..072020a65e7 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.01 | 8 | ;; Version: 7.3 |
| 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 4d2f8ec1280..54d35c98f2f 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.01 | 10 | ;; Version: 7.3 |
| 11 | ;; | 11 | ;; |
| 12 | ;; This file is part of GNU Emacs. | 12 | ;; This file is part of GNU Emacs. |
| 13 | ;; | 13 | ;; |
| @@ -84,6 +84,8 @@ googlegroups otherwise." | |||
| 84 | (declare-function wl-summary-buffer-msgdb "ext:wl-folder" () t) | 84 | (declare-function wl-summary-buffer-msgdb "ext:wl-folder" () t) |
| 85 | (declare-function wl-summary-jump-to-msg-by-message-id "ext:wl-summary" | 85 | (declare-function wl-summary-jump-to-msg-by-message-id "ext:wl-summary" |
| 86 | (&optional id)) | 86 | (&optional id)) |
| 87 | (declare-function wl-summary-jump-to-msg "ext:wl-summary" | ||
| 88 | (&optional number beg end)) | ||
| 87 | (declare-function wl-summary-line-from "ext:wl-summary" ()) | 89 | (declare-function wl-summary-line-from "ext:wl-summary" ()) |
| 88 | (declare-function wl-summary-line-subject "ext:wl-summary" ()) | 90 | (declare-function wl-summary-line-subject "ext:wl-summary" ()) |
| 89 | (declare-function wl-summary-message-number "ext:wl-summary" ()) | 91 | (declare-function wl-summary-message-number "ext:wl-summary" ()) |
| @@ -100,6 +102,7 @@ googlegroups otherwise." | |||
| 100 | (defvar wl-summary-buffer-folder-name) | 102 | (defvar wl-summary-buffer-folder-name) |
| 101 | (defvar wl-folder-group-regexp) | 103 | (defvar wl-folder-group-regexp) |
| 102 | (defvar wl-auto-check-folder-name) | 104 | (defvar wl-auto-check-folder-name) |
| 105 | (defvar elmo-nntp-default-server) | ||
| 103 | 106 | ||
| 104 | (defconst org-wl-folder-types | 107 | (defconst org-wl-folder-types |
| 105 | '(("%" . imap) ("-" . nntp) ("+" . mh) ("=" . spool) | 108 | '(("%" . imap) ("-" . nntp) ("+" . mh) ("=" . spool) |
| @@ -137,18 +140,19 @@ folder name determines the the folder type." | |||
| 137 | "Return content of FIELD in ENTITY. | 140 | "Return content of FIELD in ENTITY. |
| 138 | FIELD is a symbol of a rfc822 message header field. | 141 | FIELD is a symbol of a rfc822 message header field. |
| 139 | ENTITY is a message entity." | 142 | ENTITY is a message entity." |
| 140 | (let ((content (elmo-message-entity-field entity field))) | 143 | (let ((content (elmo-message-entity-field entity field 'string))) |
| 141 | (if (listp content) (car content) content))) | 144 | (if (listp content) (car content) content))) |
| 142 | 145 | ||
| 143 | (defun org-wl-store-link () | 146 | (defun org-wl-store-link () |
| 144 | "Store a link to a WL message or folder." | 147 | "Store a link to a WL message or folder." |
| 145 | (cond | 148 | (unless (eobp) |
| 146 | ((memq major-mode '(wl-summary-mode mime-view-mode)) | 149 | (cond |
| 147 | (org-wl-store-link-message)) | 150 | ((memq major-mode '(wl-summary-mode mime-view-mode)) |
| 148 | ((eq major-mode 'wl-folder-mode) | 151 | (org-wl-store-link-message)) |
| 149 | (org-wl-store-link-folder)) | 152 | ((eq major-mode 'wl-folder-mode) |
| 150 | (t | 153 | (org-wl-store-link-folder)) |
| 151 | nil))) | 154 | (t |
| 155 | nil)))) | ||
| 152 | 156 | ||
| 153 | (defun org-wl-store-link-folder () | 157 | (defun org-wl-store-link-folder () |
| 154 | "Store a link to a WL folder." | 158 | "Store a link to a WL folder." |
| @@ -189,10 +193,19 @@ ENTITY is a message entity." | |||
| 189 | msgnum (wl-summary-buffer-msgdb)))) | 193 | msgnum (wl-summary-buffer-msgdb)))) |
| 190 | (message-id | 194 | (message-id |
| 191 | (org-wl-message-field 'message-id wl-message-entity)) | 195 | (org-wl-message-field 'message-id wl-message-entity)) |
| 196 | (message-id-no-brackets | ||
| 197 | (org-remove-angle-brackets message-id)) | ||
| 192 | (from (org-wl-message-field 'from wl-message-entity)) | 198 | (from (org-wl-message-field 'from wl-message-entity)) |
| 193 | (to (org-wl-message-field 'to wl-message-entity)) | 199 | (to (org-wl-message-field 'to wl-message-entity)) |
| 194 | (xref (org-wl-message-field 'xref wl-message-entity)) | 200 | (xref (org-wl-message-field 'xref wl-message-entity)) |
| 195 | (subject (org-wl-message-field 'subject wl-message-entity)) | 201 | (subject (org-wl-message-field 'subject wl-message-entity)) |
| 202 | (date (org-wl-message-field 'date wl-message-entity)) | ||
| 203 | (date-ts (and date (format-time-string | ||
| 204 | (org-time-stamp-format t) | ||
| 205 | (date-to-time date)))) | ||
| 206 | (date-ts-ia (and date (format-time-string | ||
| 207 | (org-time-stamp-format t t) | ||
| 208 | (date-to-time date)))) | ||
| 196 | desc link) | 209 | desc link) |
| 197 | 210 | ||
| 198 | ;; remove text properties of subject string to avoid possible bug | 211 | ;; remove text properties of subject string to avoid possible bug |
| @@ -212,6 +225,7 @@ ENTITY is a message entity." | |||
| 212 | org-wl-shimbun-prefer-web-links xref) | 225 | org-wl-shimbun-prefer-web-links xref) |
| 213 | (org-store-link-props :type "http" :link xref :description subject | 226 | (org-store-link-props :type "http" :link xref :description subject |
| 214 | :from from :to to :message-id message-id | 227 | :from from :to to :message-id message-id |
| 228 | :message-id-no-brackets message-id-no-brackets | ||
| 215 | :subject subject)) | 229 | :subject subject)) |
| 216 | ((and (eq folder-type 'nntp) org-wl-nntp-prefer-web-links) | 230 | ((and (eq folder-type 'nntp) org-wl-nntp-prefer-web-links) |
| 217 | (setq link | 231 | (setq link |
| @@ -222,16 +236,35 @@ ENTITY is a message entity." | |||
| 222 | (org-fixup-message-id-for-http message-id))) | 236 | (org-fixup-message-id-for-http message-id))) |
| 223 | (org-store-link-props :type "http" :link link :description subject | 237 | (org-store-link-props :type "http" :link link :description subject |
| 224 | :from from :to to :message-id message-id | 238 | :from from :to to :message-id message-id |
| 239 | :message-id-no-brackets message-id-no-brackets | ||
| 225 | :subject subject)) | 240 | :subject subject)) |
| 226 | (t | 241 | (t |
| 227 | (org-store-link-props :type "wl" :from from :to to | 242 | (org-store-link-props :type "wl" :from from :to to |
| 228 | :subject subject :message-id message-id) | 243 | :subject subject :message-id message-id |
| 229 | (setq message-id (org-remove-angle-brackets message-id)) | 244 | :message-id-no-brackets message-id-no-brackets) |
| 230 | (setq desc (org-email-link-description)) | 245 | (setq desc (org-email-link-description)) |
| 231 | (setq link (org-make-link "wl:" folder-name "#" message-id)) | 246 | (setq link (org-make-link "wl:" folder-name "#" message-id-no-brackets)) |
| 232 | (org-add-link-props :link link :description desc))) | 247 | (org-add-link-props :link link :description desc))) |
| 248 | (when date | ||
| 249 | (org-add-link-props :date date :date-timestamp date-ts | ||
| 250 | :date-timestamp-inactive date-ts-ia)) | ||
| 233 | (or link xref))))))) | 251 | (or link xref))))))) |
| 234 | 252 | ||
| 253 | (defun org-wl-open-nntp (path) | ||
| 254 | "Follow the nntp: link specified by PATH." | ||
| 255 | (let* ((spec (split-string path "/")) | ||
| 256 | (server (split-string (nth 2 spec) "@")) | ||
| 257 | (group (nth 3 spec)) | ||
| 258 | (article (nth 4 spec))) | ||
| 259 | (org-wl-open | ||
| 260 | (concat "-" group ":" (if (cdr server) | ||
| 261 | (car (split-string (car server) ":")) | ||
| 262 | "") | ||
| 263 | (if (string= elmo-nntp-default-server (nth 2 spec)) | ||
| 264 | "" | ||
| 265 | (concat "@" (or (cdr server) (car server)))) | ||
| 266 | (if article (concat "#" article) ""))))) | ||
| 267 | |||
| 235 | (defun org-wl-open (path) | 268 | (defun org-wl-open (path) |
| 236 | "Follow the WL message link specified by PATH. | 269 | "Follow the WL message link specified by PATH. |
| 237 | When called with one prefix, open message in namazu search folder | 270 | When called with one prefix, open message in namazu search folder |
| @@ -267,8 +300,12 @@ for namazu index." | |||
| 267 | ;; beginning of the current line. So, restore the point | 300 | ;; beginning of the current line. So, restore the point |
| 268 | ;; in the old buffer. | 301 | ;; in the old buffer. |
| 269 | (goto-char old-point)) | 302 | (goto-char old-point)) |
| 270 | (and article (wl-summary-jump-to-msg-by-message-id (org-add-angle-brackets | 303 | (when article |
| 271 | article)) | 304 | (if (org-string-match-p "@" article) |
| 305 | (wl-summary-jump-to-msg-by-message-id (org-add-angle-brackets | ||
| 306 | article)) | ||
| 307 | (or (wl-summary-jump-to-msg (string-to-number article)) | ||
| 308 | (error "No such message: %s" article))) | ||
| 272 | (wl-summary-redisplay)))))) | 309 | (wl-summary-redisplay)))))) |
| 273 | 310 | ||
| 274 | (provide 'org-wl) | 311 | (provide 'org-wl) |
diff --git a/lisp/org/org-xoxo.el b/lisp/org/org-xoxo.el index af501058e86..b5656d9406f 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.01 | 9 | ;; Version: 7.3 |
| 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 19759371023..f7e7c9fd2f4 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.01 | 9 | ;; Version: 7.3 |
| 10 | ;; | 10 | ;; |
| 11 | ;; This file is part of GNU Emacs. | 11 | ;; This file is part of GNU Emacs. |
| 12 | ;; | 12 | ;; |
| @@ -86,10 +86,6 @@ | |||
| 86 | (unless (boundp 'diary-fancy-buffer) | 86 | (unless (boundp 'diary-fancy-buffer) |
| 87 | (defvaralias 'diary-fancy-buffer 'fancy-diary-buffer))) | 87 | (defvaralias 'diary-fancy-buffer 'fancy-diary-buffer))) |
| 88 | 88 | ||
| 89 | ;; For XEmacs, noutline is not yet provided by outline.el, so arrange for | ||
| 90 | ;; the file noutline.el being loaded. | ||
| 91 | (if (featurep 'xemacs) (condition-case nil (require 'noutline))) | ||
| 92 | ;; We require noutline, which might be provided in outline.el | ||
| 93 | (require 'outline) (require 'noutline) | 89 | (require 'outline) (require 'noutline) |
| 94 | ;; Other stuff we need. | 90 | ;; Other stuff we need. |
| 95 | (require 'time-date) | 91 | (require 'time-date) |
| @@ -151,6 +147,7 @@ requirements) is loaded." | |||
| 151 | (const :tag "C" C) | 147 | (const :tag "C" C) |
| 152 | (const :tag "R" R) | 148 | (const :tag "R" R) |
| 153 | (const :tag "Asymptote" asymptote) | 149 | (const :tag "Asymptote" asymptote) |
| 150 | (const :tag "Calc" calc) | ||
| 154 | (const :tag "Clojure" clojure) | 151 | (const :tag "Clojure" clojure) |
| 155 | (const :tag "CSS" css) | 152 | (const :tag "CSS" css) |
| 156 | (const :tag "Ditaa" ditaa) | 153 | (const :tag "Ditaa" ditaa) |
| @@ -158,15 +155,20 @@ requirements) is loaded." | |||
| 158 | (const :tag "Emacs Lisp" emacs-lisp) | 155 | (const :tag "Emacs Lisp" emacs-lisp) |
| 159 | (const :tag "Gnuplot" gnuplot) | 156 | (const :tag "Gnuplot" gnuplot) |
| 160 | (const :tag "Haskell" haskell) | 157 | (const :tag "Haskell" haskell) |
| 158 | (const :tag "Javascript" js) | ||
| 161 | (const :tag "Latex" latex) | 159 | (const :tag "Latex" latex) |
| 160 | (const :tag "Ledger" ledger) | ||
| 162 | (const :tag "Matlab" matlab) | 161 | (const :tag "Matlab" matlab) |
| 163 | (const :tag "Mscgen" mscgen) | 162 | (const :tag "Mscgen" mscgen) |
| 164 | (const :tag "Ocaml" ocaml) | 163 | (const :tag "Ocaml" ocaml) |
| 165 | (const :tag "Octave" octave) | 164 | (const :tag "Octave" octave) |
| 165 | (const :tag "Org" org) | ||
| 166 | (const :tag "Perl" perl) | 166 | (const :tag "Perl" perl) |
| 167 | (const :tag "PlantUML" plantuml) | ||
| 167 | (const :tag "Python" python) | 168 | (const :tag "Python" python) |
| 168 | (const :tag "Ruby" ruby) | 169 | (const :tag "Ruby" ruby) |
| 169 | (const :tag "Sass" sass) | 170 | (const :tag "Sass" sass) |
| 171 | (const :tag "Scheme" scheme) | ||
| 170 | (const :tag "Screen" screen) | 172 | (const :tag "Screen" screen) |
| 171 | (const :tag "Shell Script" sh) | 173 | (const :tag "Shell Script" sh) |
| 172 | (const :tag "Sql" sql) | 174 | (const :tag "Sql" sql) |
| @@ -184,7 +186,7 @@ identifier." | |||
| 184 | 186 | ||
| 185 | ;;; Version | 187 | ;;; Version |
| 186 | 188 | ||
| 187 | (defconst org-version "7.01" | 189 | (defconst org-version "7.3" |
| 188 | "The version number of the file org.el.") | 190 | "The version number of the file org.el.") |
| 189 | 191 | ||
| 190 | (defun org-version (&optional here) | 192 | (defun org-version (&optional here) |
| @@ -295,6 +297,7 @@ to add the symbol `xyz', and the package must have a call to | |||
| 295 | (const :tag " wl: Links to Wanderlust folders/messages" org-wl) | 297 | (const :tag " wl: Links to Wanderlust folders/messages" org-wl) |
| 296 | (const :tag " w3m: Special cut/paste from w3m to Org-mode." org-w3m) | 298 | (const :tag " w3m: Special cut/paste from w3m to Org-mode." org-w3m) |
| 297 | (const :tag " mouse: Additional mouse support" org-mouse) | 299 | (const :tag " mouse: Additional mouse support" org-mouse) |
| 300 | (const :tag " TaskJuggler: Export tasks to a TaskJuggler project" org-taskjuggler) | ||
| 298 | 301 | ||
| 299 | (const :tag "C annotate-file: Annotate a file with org syntax" org-annotate-file) | 302 | (const :tag "C annotate-file: Annotate a file with org syntax" org-annotate-file) |
| 300 | (const :tag "C bookmark: Org-mode links to bookmarks" org-bookmark) | 303 | (const :tag "C bookmark: Org-mode links to bookmarks" org-bookmark) |
| @@ -328,7 +331,8 @@ to add the symbol `xyz', and the package must have a call to | |||
| 328 | (const :tag "C sqlinsert: Convert Org-mode tables to SQL insertions" orgtbl-sqlinsert) | 331 | (const :tag "C sqlinsert: Convert Org-mode tables to SQL insertions" orgtbl-sqlinsert) |
| 329 | (const :tag "C toc: Table of contents for Org-mode buffer" org-toc) | 332 | (const :tag "C toc: Table of contents for Org-mode buffer" org-toc) |
| 330 | (const :tag "C track: Keep up with Org-mode development" org-track) | 333 | (const :tag "C track: Keep up with Org-mode development" org-track) |
| 331 | (const :tag "C TaskJuggler: Export tasks to a TaskJuggler project" org-taskjuggler) | 334 | (const :tag "C velocity Something like Notational Velocity for Org" org-velocity) |
| 335 | (const :tag "C wikinodes: CamelCase wiki-like links" org-wikinodes) | ||
| 332 | (repeat :tag "External packages" :inline t (symbol :tag "Package")))) | 336 | (repeat :tag "External packages" :inline t (symbol :tag "Package")))) |
| 333 | 337 | ||
| 334 | (defcustom org-support-shift-select nil | 338 | (defcustom org-support-shift-select nil |
| @@ -468,6 +472,15 @@ the following lines anywhere in the buffer: | |||
| 468 | :group 'org-startup | 472 | :group 'org-startup |
| 469 | :type 'boolean) | 473 | :type 'boolean) |
| 470 | 474 | ||
| 475 | (defcustom org-startup-with-inline-images nil | ||
| 476 | "Non-nil means show inline images when loading a new Org file. | ||
| 477 | This can also be configured on a per-file basis by adding one of | ||
| 478 | the following lines anywhere in the buffer: | ||
| 479 | #+STARTUP: inlineimages | ||
| 480 | #+STARTUP: noinlineimages" | ||
| 481 | :group 'org-startup | ||
| 482 | :type 'boolean) | ||
| 483 | |||
| 471 | (defcustom org-insert-mode-line-in-empty-file nil | 484 | (defcustom org-insert-mode-line-in-empty-file nil |
| 472 | "Non-nil means insert the first line setting Org-mode in empty files. | 485 | "Non-nil means insert the first line setting Org-mode in empty files. |
| 473 | When the function `org-mode' is called interactively in an empty file, this | 486 | When the function `org-mode' is called interactively in an empty file, this |
| @@ -1064,9 +1077,13 @@ for the duration of the command." | |||
| 1064 | (plain-list-item . auto)) | 1077 | (plain-list-item . auto)) |
| 1065 | "Should `org-insert-heading' leave a blank line before new heading/item? | 1078 | "Should `org-insert-heading' leave a blank line before new heading/item? |
| 1066 | The value is an alist, with `heading' and `plain-list-item' as car, | 1079 | The value is an alist, with `heading' and `plain-list-item' as car, |
| 1067 | and a boolean flag as cdr. For plain lists, if the variable | 1080 | and a boolean flag as cdr. The cdr may lso be the symbol `auto', and then |
| 1068 | `org-empty-line-terminates-plain-lists' is set, the setting here | 1081 | Org will look at the surrounding headings/items and try to make an |
| 1069 | is ignored and no empty line is inserted, to keep the list in tact." | 1082 | intelligent decision wether to insert a blank line or not. |
| 1083 | |||
| 1084 | For plain lists, if the variable `org-empty-line-terminates-plain-lists' is | ||
| 1085 | set, the setting here is ignored and no empty line is inserted, to avoid | ||
| 1086 | breaking the list structure." | ||
| 1070 | :group 'org-edit-structure | 1087 | :group 'org-edit-structure |
| 1071 | :type '(list | 1088 | :type '(list |
| 1072 | (cons (const heading) | 1089 | (cons (const heading) |
| @@ -1258,7 +1275,7 @@ type. In principle, it does not hurt to turn on most link types - there may | |||
| 1258 | be a small gain when turning off unused link types. The types are: | 1275 | be a small gain when turning off unused link types. The types are: |
| 1259 | 1276 | ||
| 1260 | bracket The recommended [[link][description]] or [[link]] links with hiding. | 1277 | bracket The recommended [[link][description]] or [[link]] links with hiding. |
| 1261 | angular Links in angular brackets that may contain whitespace like | 1278 | angle Links in angular brackets that may contain whitespace like |
| 1262 | <bbdb:Carsten Dominik>. | 1279 | <bbdb:Carsten Dominik>. |
| 1263 | plain Plain links in normal text, no whitespace, like http://google.com. | 1280 | plain Plain links in normal text, no whitespace, like http://google.com. |
| 1264 | radio Text that is matched by a radio target, see manual for details. | 1281 | radio Text that is matched by a radio target, see manual for details. |
| @@ -1269,8 +1286,8 @@ footnote Footnote labels. | |||
| 1269 | Changing this variable requires a restart of Emacs to become effective." | 1286 | Changing this variable requires a restart of Emacs to become effective." |
| 1270 | :group 'org-link | 1287 | :group 'org-link |
| 1271 | :type '(set :greedy t | 1288 | :type '(set :greedy t |
| 1272 | (const :tag "Double bracket links (new style)" bracket) | 1289 | (const :tag "Double bracket links" bracket) |
| 1273 | (const :tag "Angular bracket links (old style)" angular) | 1290 | (const :tag "Angular bracket links" angle) |
| 1274 | (const :tag "Plain text links" plain) | 1291 | (const :tag "Plain text links" plain) |
| 1275 | (const :tag "Radio target matches" radio) | 1292 | (const :tag "Radio target matches" radio) |
| 1276 | (const :tag "Tags" tag) | 1293 | (const :tag "Tags" tag) |
| @@ -1437,6 +1454,17 @@ Changing this requires a restart of Emacs to work correctly." | |||
| 1437 | :group 'org-link-follow | 1454 | :group 'org-link-follow |
| 1438 | :type 'integer) | 1455 | :type 'integer) |
| 1439 | 1456 | ||
| 1457 | (defcustom org-link-search-must-match-exact-headline 'query-to-create | ||
| 1458 | "Non-nil means internal links in Org files must exactly match a headline. | ||
| 1459 | When nil, the link search tries to match a phrase will all words | ||
| 1460 | in the search text." | ||
| 1461 | :group 'org-link-follow | ||
| 1462 | :type '(choice | ||
| 1463 | (const :tag "Use fuzy text search" nil) | ||
| 1464 | (const :tag "Match only exact headline" t) | ||
| 1465 | (const :tag "Match extact headline or query to create it" | ||
| 1466 | query-to-create))) | ||
| 1467 | |||
| 1440 | (defcustom org-link-frame-setup | 1468 | (defcustom org-link-frame-setup |
| 1441 | '((vm . vm-visit-folder-other-frame) | 1469 | '((vm . vm-visit-folder-other-frame) |
| 1442 | (gnus . org-gnus-no-new-news) | 1470 | (gnus . org-gnus-no-new-news) |
| @@ -1797,8 +1825,8 @@ This is list of cons cells. Each cell contains: | |||
| 1797 | - a specification of the files to be considered, either a list of files, | 1825 | - a specification of the files to be considered, either a list of files, |
| 1798 | or a symbol whose function or variable value will be used to retrieve | 1826 | or a symbol whose function or variable value will be used to retrieve |
| 1799 | a file name or a list of file names. If you use `org-agenda-files' for | 1827 | a file name or a list of file names. If you use `org-agenda-files' for |
| 1800 | that, all agenda files will be scanned for targets. The value nil means | 1828 | that, all agenda files will be scanned for targets. Nil means consider |
| 1801 | consider headings in the current buffer. | 1829 | headings in the current buffer. |
| 1802 | - A specification of how to find candidate refile targets. This may be | 1830 | - A specification of how to find candidate refile targets. This may be |
| 1803 | any of: | 1831 | any of: |
| 1804 | - a cons cell (:tag . \"TAG\") to identify refile targets by a tag. | 1832 | - a cons cell (:tag . \"TAG\") to identify refile targets by a tag. |
| @@ -2568,13 +2596,28 @@ will work: | |||
| 2568 | Currently none of this works for ISO week specifications. | 2596 | Currently none of this works for ISO week specifications. |
| 2569 | 2597 | ||
| 2570 | When this option is nil, the current day, month and year will always be | 2598 | When this option is nil, the current day, month and year will always be |
| 2571 | used as defaults." | 2599 | used as defaults. |
| 2600 | |||
| 2601 | See also `org-agenda-jump-prefer-future'." | ||
| 2572 | :group 'org-time | 2602 | :group 'org-time |
| 2573 | :type '(choice | 2603 | :type '(choice |
| 2574 | (const :tag "Never" nil) | 2604 | (const :tag "Never" nil) |
| 2575 | (const :tag "Check month and day" t) | 2605 | (const :tag "Check month and day" t) |
| 2576 | (const :tag "Check month, day, and time" time))) | 2606 | (const :tag "Check month, day, and time" time))) |
| 2577 | 2607 | ||
| 2608 | (defcustom org-agenda-jump-prefer-future 'org-read-date-prefer-future | ||
| 2609 | "Should the agenda jump command prefer the future for incomplete dates? | ||
| 2610 | The default is to do the same as configured in `org-read-date-prefer-future'. | ||
| 2611 | But you can alse set a deviating value here. | ||
| 2612 | This may t or nil, or the symbol `org-read-date-prefer-future'." | ||
| 2613 | :group 'org-agenda | ||
| 2614 | :group 'org-time | ||
| 2615 | :type '(choice | ||
| 2616 | (const :tag "Use org-aread-date-prefer-future" | ||
| 2617 | org-read-date-prefer-future) | ||
| 2618 | (const :tag "Never" nil) | ||
| 2619 | (const :tag "Always" t))) | ||
| 2620 | |||
| 2578 | (defcustom org-read-date-display-live t | 2621 | (defcustom org-read-date-display-live t |
| 2579 | "Non-nil means display current interpretation of date prompt live. | 2622 | "Non-nil means display current interpretation of date prompt live. |
| 2580 | This display will be in an overlay, in the minibuffer." | 2623 | This display will be in an overlay, in the minibuffer." |
| @@ -3074,15 +3117,15 @@ points to a file, `org-agenda-diary-entry' will be used instead." | |||
| 3074 | 3117 | ||
| 3075 | (defcustom org-format-latex-options | 3118 | (defcustom org-format-latex-options |
| 3076 | '(:foreground default :background default :scale 1.0 | 3119 | '(:foreground default :background default :scale 1.0 |
| 3077 | :html-foreground "Black" :html-background "Transparent" :html-scale 1.0 | 3120 | :html-foreground "Black" :html-background "Transparent" |
| 3078 | :matchers ("begin" "$1" "$" "$$" "\\(" "\\[")) | 3121 | :html-scale 1.0 :matchers ("begin" "$1" "$" "$$" "\\(" "\\[")) |
| 3079 | "Options for creating images from LaTeX fragments. | 3122 | "Options for creating images from LaTeX fragments. |
| 3080 | This is a property list with the following properties: | 3123 | This is a property list with the following properties: |
| 3081 | :foreground the foreground color for images embedded in Emacs, e.g. \"Black\". | 3124 | :foreground the foreground color for images embedded in Emacs, e.g. \"Black\". |
| 3082 | `default' means use the foreground of the default face. | 3125 | `default' means use the foreground of the default face. |
| 3083 | :background the background color, or \"Transparent\". | 3126 | :background the background color, or \"Transparent\". |
| 3084 | `default' means use the background of the default face. | 3127 | `default' means use the background of the default face. |
| 3085 | :scale a scaling factor for the size of the images. | 3128 | :scale a scaling factor for the size of the images, to get more pixels |
| 3086 | :html-foreground, :html-background, :html-scale | 3129 | :html-foreground, :html-background, :html-scale |
| 3087 | the same numbers for HTML export. | 3130 | the same numbers for HTML export. |
| 3088 | :matchers a list indicating which matchers should be used to | 3131 | :matchers a list indicating which matchers should be used to |
| @@ -3162,7 +3205,6 @@ will be appended." | |||
| 3162 | ("" "float" nil) | 3205 | ("" "float" nil) |
| 3163 | ("" "wrapfig" nil) | 3206 | ("" "wrapfig" nil) |
| 3164 | ("" "soul" t) | 3207 | ("" "soul" t) |
| 3165 | ("" "t1enc" t) | ||
| 3166 | ("" "textcomp" t) | 3208 | ("" "textcomp" t) |
| 3167 | ("" "marvosym" t) | 3209 | ("" "marvosym" t) |
| 3168 | ("" "wasysym" t) | 3210 | ("" "wasysym" t) |
| @@ -3177,7 +3219,7 @@ with another package you are using. | |||
| 3177 | The packages in this list are needed by one part or another of Org-mode | 3219 | The packages in this list are needed by one part or another of Org-mode |
| 3178 | to function properly. | 3220 | to function properly. |
| 3179 | 3221 | ||
| 3180 | - inputenc, fontenc, t1enc: for basic font and character selection | 3222 | - inputenc, fontenc: for basic font and character selection |
| 3181 | - textcomp, marvosymb, wasysym, latexsym, amssym: for various symbols used | 3223 | - textcomp, marvosymb, wasysym, latexsym, amssym: for various symbols used |
| 3182 | for interpreting the entities in `org-entities'. You can skip some of these | 3224 | for interpreting the entities in `org-entities'. You can skip some of these |
| 3183 | packages if you don't use any of the symbols in it. | 3225 | packages if you don't use any of the symbols in it. |
| @@ -3311,6 +3353,8 @@ When nil, the \\name form remains in the buffer." | |||
| 3311 | (defvar org-emph-re nil | 3353 | (defvar org-emph-re nil |
| 3312 | "Regular expression for matching emphasis. | 3354 | "Regular expression for matching emphasis. |
| 3313 | After a match, the match groups contain these elements: | 3355 | After a match, the match groups contain these elements: |
| 3356 | 0 The match of the full regular expression, including the characters | ||
| 3357 | before and after the proper match | ||
| 3314 | 1 The character before the proper match, or empty at beginning of line | 3358 | 1 The character before the proper match, or empty at beginning of line |
| 3315 | 2 The proper match, including the leading and trailing markers | 3359 | 2 The proper match, including the leading and trailing markers |
| 3316 | 3 The leading marker like * or /, indicating the type of highlighting | 3360 | 3 The leading marker like * or /, indicating the type of highlighting |
| @@ -3510,6 +3554,7 @@ Normal means no org-mode-specific context." | |||
| 3510 | (declare-function org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item | 3554 | (declare-function org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item |
| 3511 | "org-agenda" (&optional end)) | 3555 | "org-agenda" (&optional end)) |
| 3512 | (declare-function org-inlinetask-remove-END-maybe "org-inlinetask" ()) | 3556 | (declare-function org-inlinetask-remove-END-maybe "org-inlinetask" ()) |
| 3557 | (declare-function org-inlinetask-in-task-p "org-inlinetask" ()) | ||
| 3513 | (declare-function org-indent-mode "org-indent" (&optional arg)) | 3558 | (declare-function org-indent-mode "org-indent" (&optional arg)) |
| 3514 | (declare-function parse-time-string "parse-time" (string)) | 3559 | (declare-function parse-time-string "parse-time" (string)) |
| 3515 | (declare-function org-attach-reveal "org-attach" (&optional if-exists)) | 3560 | (declare-function org-attach-reveal "org-attach" (&optional if-exists)) |
| @@ -3701,7 +3746,6 @@ If TABLE-TYPE is non-nil, also check for table.el-type tables." | |||
| 3701 | 3746 | ||
| 3702 | ;; Autoload org-clock.el | 3747 | ;; Autoload org-clock.el |
| 3703 | 3748 | ||
| 3704 | |||
| 3705 | (declare-function org-clock-save-markers-for-cut-and-paste "org-clock" | 3749 | (declare-function org-clock-save-markers-for-cut-and-paste "org-clock" |
| 3706 | (beg end)) | 3750 | (beg end)) |
| 3707 | (declare-function org-clock-update-mode-line "org-clock" ()) | 3751 | (declare-function org-clock-update-mode-line "org-clock" ()) |
| @@ -3991,7 +4035,7 @@ collapsed state." | |||
| 3991 | (org-autoload "org-id" | 4035 | (org-autoload "org-id" |
| 3992 | '(org-id-get-create org-id-new org-id-copy org-id-get | 4036 | '(org-id-get-create org-id-new org-id-copy org-id-get |
| 3993 | org-id-get-with-outline-path-completion | 4037 | org-id-get-with-outline-path-completion |
| 3994 | org-id-get-with-outline-drilling | 4038 | org-id-get-with-outline-drilling org-id-store-link |
| 3995 | org-id-goto org-id-find org-id-store-link)) | 4039 | org-id-goto org-id-find org-id-store-link)) |
| 3996 | 4040 | ||
| 3997 | ;; Autoload Plotting Code | 4041 | ;; Autoload Plotting Code |
| @@ -4024,7 +4068,11 @@ group 3: Priority cookie | |||
| 4024 | group 4: True headline | 4068 | group 4: True headline |
| 4025 | group 5: Tags") | 4069 | group 5: Tags") |
| 4026 | (make-variable-buffer-local 'org-complex-heading-regexp) | 4070 | (make-variable-buffer-local 'org-complex-heading-regexp) |
| 4027 | (defvar org-complex-heading-regexp-format nil) | 4071 | (defvar org-complex-heading-regexp-format nil |
| 4072 | "Printf format to make regexp to match an exact headline. | ||
| 4073 | This regexp will match the headline of any node which hase the exact | ||
| 4074 | headline text that is put into the format, but may have any TODO state, | ||
| 4075 | priority and tags.") | ||
| 4028 | (make-variable-buffer-local 'org-complex-heading-regexp-format) | 4076 | (make-variable-buffer-local 'org-complex-heading-regexp-format) |
| 4029 | (defvar org-todo-line-tags-regexp nil | 4077 | (defvar org-todo-line-tags-regexp nil |
| 4030 | "Matches a headline and puts TODO state into group 2 if present. | 4078 | "Matches a headline and puts TODO state into group 2 if present. |
| @@ -4129,6 +4177,8 @@ After a match, the following groups carry important information: | |||
| 4129 | ("oddeven" org-odd-levels-only nil) | 4177 | ("oddeven" org-odd-levels-only nil) |
| 4130 | ("align" org-startup-align-all-tables t) | 4178 | ("align" org-startup-align-all-tables t) |
| 4131 | ("noalign" org-startup-align-all-tables nil) | 4179 | ("noalign" org-startup-align-all-tables nil) |
| 4180 | ("inlineimages" org-startup-with-inline-images t) | ||
| 4181 | ("noinlineimages" org-startup-with-inline-images nil) | ||
| 4132 | ("customtime" org-display-custom-times t) | 4182 | ("customtime" org-display-custom-times t) |
| 4133 | ("logdone" org-log-done time) | 4183 | ("logdone" org-log-done time) |
| 4134 | ("lognotedone" org-log-done note) | 4184 | ("lognotedone" org-log-done note) |
| @@ -4357,7 +4407,7 @@ means to push this value onto the list in the variable.") | |||
| 4357 | ((equal e "{") (push '(:startgroup) tgs)) | 4407 | ((equal e "{") (push '(:startgroup) tgs)) |
| 4358 | ((equal e "}") (push '(:endgroup) tgs)) | 4408 | ((equal e "}") (push '(:endgroup) tgs)) |
| 4359 | ((equal e "\\n") (push '(:newline) tgs)) | 4409 | ((equal e "\\n") (push '(:newline) tgs)) |
| 4360 | ((string-match (org-re "^\\([[:alnum:]_@]+\\)(\\(.\\))$") e) | 4410 | ((string-match (org-re "^\\([[:alnum:]_@#%]+\\)(\\(.\\))$") e) |
| 4361 | (push (cons (match-string 1 e) | 4411 | (push (cons (match-string 1 e) |
| 4362 | (string-to-char (match-string 2 e))) | 4412 | (string-to-char (match-string 2 e))) |
| 4363 | tgs)) | 4413 | tgs)) |
| @@ -4401,7 +4451,7 @@ means to push this value onto the list in the variable.") | |||
| 4401 | (concat "^\\(\\*+\\)[ \t]+\\(?:\\(" | 4451 | (concat "^\\(\\*+\\)[ \t]+\\(?:\\(" |
| 4402 | (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") | 4452 | (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") |
| 4403 | "\\)\\>\\)?\\(?:[ \t]*\\(\\[#.\\]\\)\\)?[ \t]*\\(.*?\\)" | 4453 | "\\)\\>\\)?\\(?:[ \t]*\\(\\[#.\\]\\)\\)?[ \t]*\\(.*?\\)" |
| 4404 | "\\(?:[ \t]+\\(:[[:alnum:]_@:]+:\\)\\)?[ \t]*$") | 4454 | "\\(?:[ \t]+\\(:[[:alnum:]_@#%:]+:\\)\\)?[ \t]*$") |
| 4405 | org-complex-heading-regexp-format | 4455 | org-complex-heading-regexp-format |
| 4406 | (concat "^\\(\\*+\\)[ \t]+\\(?:\\(" | 4456 | (concat "^\\(\\*+\\)[ \t]+\\(?:\\(" |
| 4407 | (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") | 4457 | (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") |
| @@ -4410,7 +4460,7 @@ means to push this value onto the list in the variable.") | |||
| 4410 | "\\(?:[ \t]*\\(?:\\[[0-9%%/]+\\]\\)\\)?" ;; stats cookie | 4460 | "\\(?:[ \t]*\\(?:\\[[0-9%%/]+\\]\\)\\)?" ;; stats cookie |
| 4411 | "[ \t]*\\(%s\\)" | 4461 | "[ \t]*\\(%s\\)" |
| 4412 | "\\(?:[ \t]*\\(?:\\[[0-9%%/]+\\]\\)\\)?" ;; stats cookie | 4462 | "\\(?:[ \t]*\\(?:\\[[0-9%%/]+\\]\\)\\)?" ;; stats cookie |
| 4413 | "\\(?:[ \t]+\\(:[[:alnum:]_@:]+:\\)\\)?[ \t]*$") | 4463 | "\\(?:[ \t]+\\(:[[:alnum:]_@#%%:]+:\\)\\)?[ \t]*$") |
| 4414 | org-nl-done-regexp | 4464 | org-nl-done-regexp |
| 4415 | (concat "\n\\*+[ \t]+" | 4465 | (concat "\n\\*+[ \t]+" |
| 4416 | "\\(?:" (mapconcat 'regexp-quote org-done-keywords "\\|") | 4466 | "\\(?:" (mapconcat 'regexp-quote org-done-keywords "\\|") |
| @@ -4419,7 +4469,7 @@ means to push this value onto the list in the variable.") | |||
| 4419 | (concat "^\\(\\*+\\)[ \t]+\\(?:\\(" | 4469 | (concat "^\\(\\*+\\)[ \t]+\\(?:\\(" |
| 4420 | (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") | 4470 | (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") |
| 4421 | (org-re | 4471 | (org-re |
| 4422 | "\\)\\>\\)? *\\(.*?\\([ \t]:[[:alnum:]:_@]+:[ \t]*\\)?$\\)")) | 4472 | "\\)\\>\\)? *\\(.*?\\([ \t]:[[:alnum:]:_@#%]+:[ \t]*\\)?$\\)")) |
| 4423 | org-looking-at-done-regexp | 4473 | org-looking-at-done-regexp |
| 4424 | (concat "^" "\\(?:" | 4474 | (concat "^" "\\(?:" |
| 4425 | (mapconcat 'regexp-quote org-done-keywords "\\|") "\\)" | 4475 | (mapconcat 'regexp-quote org-done-keywords "\\|") "\\)" |
| @@ -4699,6 +4749,8 @@ The following commands are available: | |||
| 4699 | (let ((bmp (buffer-modified-p))) | 4749 | (let ((bmp (buffer-modified-p))) |
| 4700 | (org-table-map-tables 'org-table-align 'quietly) | 4750 | (org-table-map-tables 'org-table-align 'quietly) |
| 4701 | (set-buffer-modified-p bmp))) | 4751 | (set-buffer-modified-p bmp))) |
| 4752 | (when org-startup-with-inline-images | ||
| 4753 | (org-display-inline-images)) | ||
| 4702 | (when org-startup-indented | 4754 | (when org-startup-indented |
| 4703 | (require 'org-indent) | 4755 | (require 'org-indent) |
| 4704 | (org-indent-mode 1)) | 4756 | (org-indent-mode 1)) |
| @@ -4736,7 +4788,7 @@ The following commands are available: | |||
| 4736 | 4788 | ||
| 4737 | (defconst org-non-link-chars "]\t\n\r<>") | 4789 | (defconst org-non-link-chars "]\t\n\r<>") |
| 4738 | (defvar org-link-types '("http" "https" "ftp" "mailto" "file" "news" | 4790 | (defvar org-link-types '("http" "https" "ftp" "mailto" "file" "news" |
| 4739 | "shell" "elisp" "doi")) | 4791 | "shell" "elisp" "doi" "message")) |
| 4740 | (defvar org-link-types-re nil | 4792 | (defvar org-link-types-re nil |
| 4741 | "Matches a link that has a url-like prefix like \"http:\"") | 4793 | "Matches a link that has a url-like prefix like \"http:\"") |
| 4742 | (defvar org-link-re-with-space nil | 4794 | (defvar org-link-re-with-space nil |
| @@ -4837,7 +4889,7 @@ This should be called after the variable `org-link-types' has changed." | |||
| 4837 | org-plain-link-re | 4889 | org-plain-link-re |
| 4838 | (concat | 4890 | (concat |
| 4839 | "\\<\\(" (mapconcat 'regexp-quote org-link-types "\\|") "\\):" | 4891 | "\\<\\(" (mapconcat 'regexp-quote org-link-types "\\|") "\\):" |
| 4840 | (org-re "\\([^ \t\n()<>]+\\(?:([[:word:]0-9]+)\\|\\([^[:punct:] \t\n]\\|/\\)\\)\\)")) | 4892 | (org-re "\\([^ \t\n()<>]+\\(?:([[:word:]0-9_]+)\\|\\([^[:punct:] \t\n]\\|/\\)\\)\\)")) |
| 4841 | ;; "\\([^]\t\n\r<>() ]+[^]\t\n\r<>,.;() ]\\)") | 4893 | ;; "\\([^]\t\n\r<>() ]+[^]\t\n\r<>,.;() ]\\)") |
| 4842 | org-bracket-link-regexp | 4894 | org-bracket-link-regexp |
| 4843 | "\\[\\[\\([^][]+\\)\\]\\(\\[\\([^][]+\\)\\]\\)?\\]" | 4895 | "\\[\\[\\([^][]+\\)\\]\\(\\[\\([^][]+\\)\\]\\)?\\]" |
| @@ -5003,13 +5055,22 @@ will be prompted for." | |||
| 5003 | '(display t invisible t intangible t)) | 5055 | '(display t invisible t intangible t)) |
| 5004 | t))) | 5056 | t))) |
| 5005 | 5057 | ||
| 5058 | (defcustom org-src-fontify-natively nil | ||
| 5059 | "When non-nil, fontify code in code blocks." | ||
| 5060 | :type 'boolean | ||
| 5061 | :group 'org-appearance | ||
| 5062 | :group 'org-babel) | ||
| 5063 | |||
| 5006 | (defun org-fontify-meta-lines-and-blocks (limit) | 5064 | (defun org-fontify-meta-lines-and-blocks (limit) |
| 5007 | "Fontify #+ lines and blocks, in the correct ways." | 5065 | "Fontify #+ lines and blocks, in the correct ways." |
| 5008 | (let ((case-fold-search t)) | 5066 | (let ((case-fold-search t)) |
| 5009 | (if (re-search-forward | 5067 | (if (re-search-forward |
| 5010 | "^\\([ \t]*#\\+\\(\\([a-zA-Z]+:?\\| \\|$\\)\\(_\\([a-zA-Z]+\\)\\)?\\)\\(.*\\)\\)" | 5068 | "^\\([ \t]*#\\+\\(\\([a-zA-Z]+:?\\| \\|$\\)\\(_\\([a-zA-Z]+\\)\\)?\\)[ \t]*\\(\\([^ \t\n]*\\)[ \t]*\\(.*\\)\\)\\)" |
| 5011 | limit t) | 5069 | limit t) |
| 5012 | (let ((beg (match-beginning 0)) | 5070 | (let ((beg (match-beginning 0)) |
| 5071 | (block-start (match-end 0)) | ||
| 5072 | (block-end nil) | ||
| 5073 | (lang (match-string 7)) | ||
| 5013 | (beg1 (line-beginning-position 2)) | 5074 | (beg1 (line-beginning-position 2)) |
| 5014 | (dc1 (downcase (match-string 2))) | 5075 | (dc1 (downcase (match-string 2))) |
| 5015 | (dc3 (downcase (match-string 3))) | 5076 | (dc3 (downcase (match-string 3))) |
| @@ -5022,8 +5083,9 @@ will be prompted for." | |||
| 5022 | '(display t invisible t intangible t)) | 5083 | '(display t invisible t intangible t)) |
| 5023 | (add-text-properties (match-beginning 1) (match-end 3) | 5084 | (add-text-properties (match-beginning 1) (match-end 3) |
| 5024 | '(font-lock-fontified t face org-meta-line)) | 5085 | '(font-lock-fontified t face org-meta-line)) |
| 5025 | (add-text-properties (match-beginning 6) (match-end 6) | 5086 | (add-text-properties (match-beginning 6) (+ (match-end 6) 1) |
| 5026 | '(font-lock-fontified t face org-block)) | 5087 | '(font-lock-fontified t face org-block)) |
| 5088 | ; for backend-specific code | ||
| 5027 | t) | 5089 | t) |
| 5028 | ((and (match-end 4) (equal dc3 "begin")) | 5090 | ((and (match-end 4) (equal dc3 "begin")) |
| 5029 | ;; Truly a block | 5091 | ;; Truly a block |
| @@ -5033,6 +5095,7 @@ will be prompted for." | |||
| 5033 | (concat "^[ \t]*#\\+end" (match-string 4) "\\>.*") | 5095 | (concat "^[ \t]*#\\+end" (match-string 4) "\\>.*") |
| 5034 | nil t) ;; on purpose, we look further than LIMIT | 5096 | nil t) ;; on purpose, we look further than LIMIT |
| 5035 | (setq end (match-end 0) end1 (1- (match-beginning 0))) | 5097 | (setq end (match-end 0) end1 (1- (match-beginning 0))) |
| 5098 | (setq block-end (match-beginning 0)) | ||
| 5036 | (when quoting | 5099 | (when quoting |
| 5037 | (remove-text-properties beg end | 5100 | (remove-text-properties beg end |
| 5038 | '(display t invisible t intangible t))) | 5101 | '(display t invisible t intangible t))) |
| @@ -5040,10 +5103,15 @@ will be prompted for." | |||
| 5040 | beg end | 5103 | beg end |
| 5041 | '(font-lock-fontified t font-lock-multiline t)) | 5104 | '(font-lock-fontified t font-lock-multiline t)) |
| 5042 | (add-text-properties beg beg1 '(face org-meta-line)) | 5105 | (add-text-properties beg beg1 '(face org-meta-line)) |
| 5043 | (add-text-properties end1 end '(face org-meta-line)) | 5106 | (add-text-properties end1 (+ end 1) '(face org-meta-line)) |
| 5107 | ; for end_src | ||
| 5044 | (cond | 5108 | (cond |
| 5109 | ((and lang org-src-fontify-natively) | ||
| 5110 | (org-src-font-lock-fontify-block lang block-start block-end)) | ||
| 5045 | (quoting | 5111 | (quoting |
| 5046 | (add-text-properties beg1 end1 '(face org-block))) | 5112 | (add-text-properties beg1 (+ end1 1) '(face |
| 5113 | org-block))) | ||
| 5114 | ; end of source block | ||
| 5047 | ((not org-fontify-quote-and-verse-blocks)) | 5115 | ((not org-fontify-quote-and-verse-blocks)) |
| 5048 | ((string= block-type "quote") | 5116 | ((string= block-type "quote") |
| 5049 | (add-text-properties beg1 end1 '(face org-quote))) | 5117 | (add-text-properties beg1 end1 '(face org-quote))) |
| @@ -5329,7 +5397,7 @@ between words." | |||
| 5329 | "\\)\\>"))) | 5397 | "\\)\\>"))) |
| 5330 | 5398 | ||
| 5331 | (defun org-activate-tags (limit) | 5399 | (defun org-activate-tags (limit) |
| 5332 | (if (re-search-forward (org-re "^\\*+.*[ \t]\\(:[[:alnum:]_@:]+:\\)[ \r\n]") limit t) | 5400 | (if (re-search-forward (org-re "^\\*+.*[ \t]\\(:[[:alnum:]_@#%:]+:\\)[ \r\n]") limit t) |
| 5333 | (progn | 5401 | (progn |
| 5334 | (org-remove-flyspell-overlays-in (match-beginning 1) (match-end 1)) | 5402 | (org-remove-flyspell-overlays-in (match-beginning 1) (match-end 1)) |
| 5335 | (add-text-properties (match-beginning 1) (match-end 1) | 5403 | (add-text-properties (match-beginning 1) (match-end 1) |
| @@ -5360,6 +5428,12 @@ For plain list items, if they are matched by `outline-regexp', this returns | |||
| 5360 | (defvar org-font-lock-hook nil | 5428 | (defvar org-font-lock-hook nil |
| 5361 | "Functions to be called for special font lock stuff.") | 5429 | "Functions to be called for special font lock stuff.") |
| 5362 | 5430 | ||
| 5431 | (defvar org-font-lock-set-keywords-hook nil | ||
| 5432 | "Functions that can manipulate `org-font-lock-extra-keywords'. | ||
| 5433 | This is calles after `org-font-lock-extra-keywords' is defined, but before | ||
| 5434 | it is installed to be used by font lock. This can be useful if something | ||
| 5435 | needs to be inserted at a specific position in the font-lock sequence.") | ||
| 5436 | |||
| 5363 | (defun org-font-lock-hook (limit) | 5437 | (defun org-font-lock-hook (limit) |
| 5364 | (run-hook-with-args 'org-font-lock-hook limit)) | 5438 | (run-hook-with-args 'org-font-lock-hook limit)) |
| 5365 | 5439 | ||
| @@ -5384,7 +5458,7 @@ For plain list items, if they are matched by `outline-regexp', this returns | |||
| 5384 | '("^[ \t]*|\\(?:.*?|\\)? *\\(:?=[^|\n]*\\)" (1 'org-formula t)) | 5458 | '("^[ \t]*|\\(?:.*?|\\)? *\\(:?=[^|\n]*\\)" (1 'org-formula t)) |
| 5385 | '("^[ \t]*| *\\([#*]\\) *|" (1 'org-formula t)) | 5459 | '("^[ \t]*| *\\([#*]\\) *|" (1 'org-formula t)) |
| 5386 | '("^[ \t]*|\\( *\\([$!_^/]\\) *|.*\\)|" (1 'org-formula t)) | 5460 | '("^[ \t]*|\\( *\\([$!_^/]\\) *|.*\\)|" (1 'org-formula t)) |
| 5387 | '("| *\\(<[lr]?[0-9]*>\\)" (1 'org-formula t)) | 5461 | '("| *\\(<[lrc]?[0-9]*>\\)" (1 'org-formula t)) |
| 5388 | ;; Drawers | 5462 | ;; Drawers |
| 5389 | (list org-drawer-regexp '(0 'org-special-keyword t)) | 5463 | (list org-drawer-regexp '(0 'org-special-keyword t)) |
| 5390 | (list "^[ \t]*:END:" '(0 'org-special-keyword t)) | 5464 | (list "^[ \t]*:END:" '(0 'org-special-keyword t)) |
| @@ -5428,13 +5502,13 @@ For plain list items, if they are matched by `outline-regexp', this returns | |||
| 5428 | '(org-do-emphasis-faces (0 nil append)) | 5502 | '(org-do-emphasis-faces (0 nil append)) |
| 5429 | '(org-do-emphasis-faces))) | 5503 | '(org-do-emphasis-faces))) |
| 5430 | ;; Checkboxes | 5504 | ;; Checkboxes |
| 5431 | '("^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +\\(\\[[- X]\\]\\)" | 5505 | '("^[ \t]*\\(?:[-+*]\\|[0-9]+[.)]\\)[ \t]+\\(?:\\[@\\(?:start:\\)?[0-9]+\\][ \t]*\\)?\\(\\[[- X]\\]\\)" |
| 5432 | 2 'org-checkbox prepend) | 5506 | 1 'org-checkbox prepend) |
| 5433 | (if org-provide-checkbox-statistics | 5507 | (if (cdr (assq 'checkbox org-list-automatic-rules)) |
| 5434 | '("\\[\\([0-9]*%\\)\\]\\|\\[\\([0-9]*\\)/\\([0-9]*\\)\\]" | 5508 | '("\\[\\([0-9]*%\\)\\]\\|\\[\\([0-9]*\\)/\\([0-9]*\\)\\]" |
| 5435 | (0 (org-get-checkbox-statistics-face) t))) | 5509 | (0 (org-get-checkbox-statistics-face) t))) |
| 5436 | ;; Description list items | 5510 | ;; Description list items |
| 5437 | '("^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +\\(.*? ::\\)" | 5511 | '("^[ \t]*\\([-+*]\\|[0-9]+[.)]\\)[ \t]+\\(.*? ::\\)" |
| 5438 | 2 'bold prepend) | 5512 | 2 'bold prepend) |
| 5439 | ;; ARCHIVEd headings | 5513 | ;; ARCHIVEd headings |
| 5440 | (list (concat "^\\*+ \\(.*:" org-archive-tag ":.*\\)") | 5514 | (list (concat "^\\*+ \\(.*:" org-archive-tag ":.*\\)") |
| @@ -5454,6 +5528,7 @@ For plain list items, if they are matched by `outline-regexp', this returns | |||
| 5454 | '(org-fontify-meta-lines-and-blocks) | 5528 | '(org-fontify-meta-lines-and-blocks) |
| 5455 | ))) | 5529 | ))) |
| 5456 | (setq org-font-lock-extra-keywords (delq nil org-font-lock-extra-keywords)) | 5530 | (setq org-font-lock-extra-keywords (delq nil org-font-lock-extra-keywords)) |
| 5531 | (run-hooks 'org-font-lock-set-keywords-hook) | ||
| 5457 | ;; Now set the full font-lock-keywords | 5532 | ;; Now set the full font-lock-keywords |
| 5458 | (org-set-local 'org-font-lock-keywords org-font-lock-extra-keywords) | 5533 | (org-set-local 'org-font-lock-keywords org-font-lock-extra-keywords) |
| 5459 | (org-set-local 'font-lock-defaults | 5534 | (org-set-local 'font-lock-defaults |
| @@ -5469,7 +5544,7 @@ For plain list items, if they are matched by `outline-regexp', this returns | |||
| 5469 | (message "Entities are displayed as UTF8 characers") | 5544 | (message "Entities are displayed as UTF8 characers") |
| 5470 | (save-restriction | 5545 | (save-restriction |
| 5471 | (widen) | 5546 | (widen) |
| 5472 | (decompose-region (point-min) (point-max)) | 5547 | (org-decompose-region (point-min) (point-max)) |
| 5473 | (message "Entities are displayed plain")))) | 5548 | (message "Entities are displayed plain")))) |
| 5474 | 5549 | ||
| 5475 | (defun org-fontify-entities (limit) | 5550 | (defun org-fontify-entities (limit) |
| @@ -5569,7 +5644,7 @@ If KWD is a number, get the corresponding match group." | |||
| 5569 | (inhibit-read-only t) (inhibit-point-motion-hooks t) | 5644 | (inhibit-read-only t) (inhibit-point-motion-hooks t) |
| 5570 | (inhibit-modification-hooks t) | 5645 | (inhibit-modification-hooks t) |
| 5571 | deactivate-mark buffer-file-name buffer-file-truename) | 5646 | deactivate-mark buffer-file-name buffer-file-truename) |
| 5572 | (decompose-region beg end) | 5647 | (org-decompose-region beg end) |
| 5573 | (remove-text-properties | 5648 | (remove-text-properties |
| 5574 | beg end | 5649 | beg end |
| 5575 | (if org-indent-mode | 5650 | (if org-indent-mode |
| @@ -5698,7 +5773,8 @@ in special contexts. | |||
| 5698 | `org-cycle-emulate-tab' for details. | 5773 | `org-cycle-emulate-tab' for details. |
| 5699 | 5774 | ||
| 5700 | - Special case: if point is at the beginning of the buffer and there is | 5775 | - Special case: if point is at the beginning of the buffer and there is |
| 5701 | no headline in line 1, this function will act as if called with prefix arg. | 5776 | no headline in line 1, this function will act as if called with prefix arg |
| 5777 | (C-u TAB, same as S-TAB) also when called without prefix arg. | ||
| 5702 | But only if also the variable `org-cycle-global-at-bob' is t." | 5778 | But only if also the variable `org-cycle-global-at-bob' is t." |
| 5703 | (interactive "P") | 5779 | (interactive "P") |
| 5704 | (org-load-modules-maybe) | 5780 | (org-load-modules-maybe) |
| @@ -5724,7 +5800,7 @@ in special contexts. | |||
| 5724 | (if nstars (format "\\{1,%d\\}" nstars) "+") | 5800 | (if nstars (format "\\{1,%d\\}" nstars) "+") |
| 5725 | " \\|\\([ \t]*\\)\\([-+*]\\|[0-9]+[.)]\\) \\)")) | 5801 | " \\|\\([ \t]*\\)\\([-+*]\\|[0-9]+[.)]\\) \\)")) |
| 5726 | (t (concat "\\*" (if nstars (format "\\{1,%d\\} " nstars) "+ "))))) | 5802 | (t (concat "\\*" (if nstars (format "\\{1,%d\\} " nstars) "+ "))))) |
| 5727 | (bob-special (and org-cycle-global-at-bob (bobp) | 5803 | (bob-special (and org-cycle-global-at-bob (not arg) (bobp) |
| 5728 | (not (looking-at outline-regexp)))) | 5804 | (not (looking-at outline-regexp)))) |
| 5729 | (org-cycle-hook | 5805 | (org-cycle-hook |
| 5730 | (if bob-special | 5806 | (if bob-special |
| @@ -5740,6 +5816,7 @@ in special contexts. | |||
| 5740 | (cond | 5816 | (cond |
| 5741 | 5817 | ||
| 5742 | ((equal arg '(16)) | 5818 | ((equal arg '(16)) |
| 5819 | (setq last-command 'dummy) | ||
| 5743 | (org-set-startup-visibility) | 5820 | (org-set-startup-visibility) |
| 5744 | (message "Startup visibility, plus VISIBILITY properties")) | 5821 | (message "Startup visibility, plus VISIBILITY properties")) |
| 5745 | 5822 | ||
| @@ -5847,7 +5924,6 @@ in special contexts. | |||
| 5847 | 5924 | ||
| 5848 | (defun org-cycle-internal-local () | 5925 | (defun org-cycle-internal-local () |
| 5849 | "Do the local cycling action." | 5926 | "Do the local cycling action." |
| 5850 | (org-back-to-heading) | ||
| 5851 | (let ((goal-column 0) eoh eol eos level has-children children-skipped) | 5927 | (let ((goal-column 0) eoh eol eos level has-children children-skipped) |
| 5852 | ;; First, some boundaries | 5928 | ;; First, some boundaries |
| 5853 | (save-excursion | 5929 | (save-excursion |
| @@ -5871,12 +5947,15 @@ in special contexts. | |||
| 5871 | (outline-next-heading) | 5947 | (outline-next-heading) |
| 5872 | (setq has-children (and (org-at-heading-p t) | 5948 | (setq has-children (and (org-at-heading-p t) |
| 5873 | (> (funcall outline-level) level)))) | 5949 | (> (funcall outline-level) level)))) |
| 5874 | (org-end-of-subtree t) | 5950 | ;; if we're in a list, org-end-of-subtree is in fact org-end-of-item. |
| 5875 | (unless (eobp) | 5951 | (if (org-at-item-p) |
| 5876 | (skip-chars-forward " \t\n") | 5952 | (setq eos (if (and (org-end-of-item) (bolp)) |
| 5877 | (beginning-of-line 1) ; in case this is an item | 5953 | (1- (point)) |
| 5878 | ) | 5954 | (point))) |
| 5879 | (setq eos (if (eobp) (point) (1- (point))))) | 5955 | (org-end-of-subtree t) |
| 5956 | (unless (eobp) | ||
| 5957 | (skip-chars-forward " \t\n")) | ||
| 5958 | (setq eos (if (eobp) (point) (1- (point)))))) | ||
| 5880 | ;; Find out what to do next and set `this-command' | 5959 | ;; Find out what to do next and set `this-command' |
| 5881 | (cond | 5960 | (cond |
| 5882 | ((= eos eoh) | 5961 | ((= eos eoh) |
| @@ -5910,14 +5989,14 @@ in special contexts. | |||
| 5910 | ;; We just showed the children, or no children are there, | 5989 | ;; We just showed the children, or no children are there, |
| 5911 | ;; now show everything. | 5990 | ;; now show everything. |
| 5912 | (run-hook-with-args 'org-pre-cycle-hook 'subtree) | 5991 | (run-hook-with-args 'org-pre-cycle-hook 'subtree) |
| 5913 | (org-show-subtree) | 5992 | (outline-flag-region eoh eos nil) |
| 5914 | (message (if children-skipped "SUBTREE (NO CHILDREN)" "SUBTREE")) | 5993 | (message (if children-skipped "SUBTREE (NO CHILDREN)" "SUBTREE")) |
| 5915 | (setq org-cycle-subtree-status 'subtree) | 5994 | (setq org-cycle-subtree-status 'subtree) |
| 5916 | (run-hook-with-args 'org-cycle-hook 'subtree)) | 5995 | (run-hook-with-args 'org-cycle-hook 'subtree)) |
| 5917 | (t | 5996 | (t |
| 5918 | ;; Default action: hide the subtree. | 5997 | ;; Default action: hide the subtree. |
| 5919 | (run-hook-with-args 'org-pre-cycle-hook 'folded) | 5998 | (run-hook-with-args 'org-pre-cycle-hook 'folded) |
| 5920 | (hide-subtree) | 5999 | (outline-flag-region eoh eos t) |
| 5921 | (message "FOLDED") | 6000 | (message "FOLDED") |
| 5922 | (setq org-cycle-subtree-status 'folded) | 6001 | (setq org-cycle-subtree-status 'folded) |
| 5923 | (run-hook-with-args 'org-cycle-hook 'folded))))) | 6002 | (run-hook-with-args 'org-cycle-hook 'folded))))) |
| @@ -5961,8 +6040,8 @@ With a numeric prefix, show all headlines up to that level." | |||
| 5961 | (interactive) | 6040 | (interactive) |
| 5962 | (let (org-show-entry-below state) | 6041 | (let (org-show-entry-below state) |
| 5963 | (save-excursion | 6042 | (save-excursion |
| 5964 | (goto-char (point-min)) | 6043 | (goto-char (point-max)) |
| 5965 | (while (re-search-forward | 6044 | (while (re-search-backward |
| 5966 | "^[ \t]*:VISIBILITY:[ \t]+\\([a-z]+\\)" | 6045 | "^[ \t]*:VISIBILITY:[ \t]+\\([a-z]+\\)" |
| 5967 | nil t) | 6046 | nil t) |
| 5968 | (setq state (match-string 1)) | 6047 | (setq state (match-string 1)) |
| @@ -6190,6 +6269,42 @@ Optional argument N means put the headline into the Nth line of the window." | |||
| 6190 | (beginning-of-line) | 6269 | (beginning-of-line) |
| 6191 | (recenter (prefix-numeric-value N)))) | 6270 | (recenter (prefix-numeric-value N)))) |
| 6192 | 6271 | ||
| 6272 | ;;; Saving and restoring visibility | ||
| 6273 | |||
| 6274 | (defun org-outline-overlay-data (&optional use-markers) | ||
| 6275 | "Return a list of the locations of all outline overlays. | ||
| 6276 | These are overlays with the `invisible' property value `outline'. | ||
| 6277 | The return value is a list of cons cells, with start and stop | ||
| 6278 | positions for each overlay. | ||
| 6279 | If USE-MARKERS is set, return the positions as markers." | ||
| 6280 | (let (beg end) | ||
| 6281 | (save-excursion | ||
| 6282 | (save-restriction | ||
| 6283 | (widen) | ||
| 6284 | (delq nil | ||
| 6285 | (mapcar (lambda (o) | ||
| 6286 | (when (eq (overlay-get o 'invisible) 'outline) | ||
| 6287 | (setq beg (overlay-start o) | ||
| 6288 | end (overlay-end o)) | ||
| 6289 | (and beg end (> end beg) | ||
| 6290 | (if use-markers | ||
| 6291 | (cons (move-marker (make-marker) beg) | ||
| 6292 | (move-marker (make-marker) end)) | ||
| 6293 | (cons beg end))))) | ||
| 6294 | (overlays-in (point-min) (point-max)))))))) | ||
| 6295 | |||
| 6296 | (defun org-set-outline-overlay-data (data) | ||
| 6297 | "Create visibility overlays for all positions in DATA. | ||
| 6298 | DATA should have been made by `org-outline-overlay-data'." | ||
| 6299 | (let (o) | ||
| 6300 | (save-excursion | ||
| 6301 | (save-restriction | ||
| 6302 | (widen) | ||
| 6303 | (show-all) | ||
| 6304 | (mapc (lambda (c) | ||
| 6305 | (setq o (make-overlay (car c) (cdr c))) | ||
| 6306 | (overlay-put o 'invisible 'outline)) | ||
| 6307 | data))))) | ||
| 6193 | 6308 | ||
| 6194 | ;;; Folding of blocks | 6309 | ;;; Folding of blocks |
| 6195 | 6310 | ||
| @@ -6360,7 +6475,9 @@ the headline hierarchy above." | |||
| 6360 | (selected-point | 6475 | (selected-point |
| 6361 | (if (eq interface 'outline) | 6476 | (if (eq interface 'outline) |
| 6362 | (car (org-get-location (current-buffer) org-goto-help)) | 6477 | (car (org-get-location (current-buffer) org-goto-help)) |
| 6363 | (nth 3 (org-refile-get-location "Goto: "))))) | 6478 | (let ((pa (org-refile-get-location "Goto: "))) |
| 6479 | (org-refile-check-position pa) | ||
| 6480 | (nth 3 pa))))) | ||
| 6364 | (if selected-point | 6481 | (if selected-point |
| 6365 | (progn | 6482 | (progn |
| 6366 | (org-mark-ring-push org-goto-start-pos) | 6483 | (org-mark-ring-push org-goto-start-pos) |
| @@ -6582,22 +6699,40 @@ frame is not changed." | |||
| 6582 | "Insert a new heading or item with same depth at point. | 6699 | "Insert a new heading or item with same depth at point. |
| 6583 | If point is in a plain list and FORCE-HEADING is nil, create a new list item. | 6700 | If point is in a plain list and FORCE-HEADING is nil, create a new list item. |
| 6584 | If point is at the beginning of a headline, insert a sibling before the | 6701 | If point is at the beginning of a headline, insert a sibling before the |
| 6585 | current headline. If point is not at the beginning, do not split the line, | 6702 | current headline. If point is not at the beginning, split the line, |
| 6586 | but create the new headline after the current line. | 6703 | create the new headline with the text in the current line after point |
| 6704 | \(but see also the variable `org-M-RET-may-split-line'). | ||
| 6705 | |||
| 6587 | When INVISIBLE-OK is set, stop at invisible headlines when going back. | 6706 | When INVISIBLE-OK is set, stop at invisible headlines when going back. |
| 6588 | This is important for non-interactive uses of the command." | 6707 | This is important for non-interactive uses of the command." |
| 6589 | (interactive "P") | 6708 | (interactive "P") |
| 6590 | (if (or (= (buffer-size) 0) | 6709 | (if (or (= (buffer-size) 0) |
| 6591 | (and (not (save-excursion (and (ignore-errors (org-back-to-heading invisible-ok)) | 6710 | (and (not (save-excursion |
| 6592 | (org-on-heading-p)))) | 6711 | (and (ignore-errors (org-back-to-heading invisible-ok)) |
| 6712 | (org-on-heading-p)))) | ||
| 6593 | (not (org-in-item-p)))) | 6713 | (not (org-in-item-p)))) |
| 6594 | (insert "\n* ") | 6714 | (progn |
| 6715 | (insert "\n* ") | ||
| 6716 | (run-hooks 'org-insert-heading-hook)) | ||
| 6595 | (when (or force-heading (not (org-insert-item))) | 6717 | (when (or force-heading (not (org-insert-item))) |
| 6596 | (let* ((empty-line-p nil) | 6718 | (let* ((empty-line-p nil) |
| 6719 | (level nil) | ||
| 6720 | (on-heading (org-on-heading-p)) | ||
| 6597 | (head (save-excursion | 6721 | (head (save-excursion |
| 6598 | (condition-case nil | 6722 | (condition-case nil |
| 6599 | (progn | 6723 | (progn |
| 6600 | (org-back-to-heading invisible-ok) | 6724 | (org-back-to-heading invisible-ok) |
| 6725 | (when (and (not on-heading) | ||
| 6726 | (featurep 'org-inlinetask) | ||
| 6727 | (integerp org-inlinetask-min-level) | ||
| 6728 | (>= (length (match-string 0)) | ||
| 6729 | org-inlinetask-min-level)) | ||
| 6730 | ;; Find a heading level before the inline task | ||
| 6731 | (while (and (setq level (org-up-heading-safe)) | ||
| 6732 | (>= level org-inlinetask-min-level))) | ||
| 6733 | (if (org-on-heading-p) | ||
| 6734 | (org-back-to-heading invisible-ok) | ||
| 6735 | (error "This should not happen"))) | ||
| 6601 | (setq empty-line-p (org-previous-line-empty-p)) | 6736 | (setq empty-line-p (org-previous-line-empty-p)) |
| 6602 | (match-string 0)) | 6737 | (match-string 0)) |
| 6603 | (error "*")))) | 6738 | (error "*")))) |
| @@ -6635,6 +6770,12 @@ This is important for non-interactive uses of the command." | |||
| 6635 | (cond | 6770 | (cond |
| 6636 | (org-insert-heading-respect-content | 6771 | (org-insert-heading-respect-content |
| 6637 | (org-end-of-subtree nil t) | 6772 | (org-end-of-subtree nil t) |
| 6773 | (when (featurep 'org-inlinetask) | ||
| 6774 | (while (and (not (eobp)) | ||
| 6775 | (looking-at "\\(\\*+\\)[ \t]+") | ||
| 6776 | (>= (length (match-string 1)) | ||
| 6777 | org-inlinetask-min-level)) | ||
| 6778 | (org-end-of-subtree nil t))) | ||
| 6638 | (or (bolp) (newline)) | 6779 | (or (bolp) (newline)) |
| 6639 | (or (org-previous-line-empty-p) | 6780 | (or (org-previous-line-empty-p) |
| 6640 | (and blank (newline))) | 6781 | (and blank (newline))) |
| @@ -6643,7 +6784,7 @@ This is important for non-interactive uses of the command." | |||
| 6643 | (when hide-previous | 6784 | (when hide-previous |
| 6644 | (show-children) | 6785 | (show-children) |
| 6645 | (org-show-entry)) | 6786 | (org-show-entry)) |
| 6646 | (looking-at ".*?\\([ \t]+\\(:[[:alnum:]_@:]+:\\)\\)?[ \t]*$") | 6787 | (looking-at ".*?\\([ \t]+\\(:[[:alnum:]_@#%:]+:\\)\\)?[ \t]*$") |
| 6647 | (setq tags (and (match-end 2) (match-string 2))) | 6788 | (setq tags (and (match-end 2) (match-string 2))) |
| 6648 | (and (match-end 1) | 6789 | (and (match-end 1) |
| 6649 | (delete-region (match-beginning 1) (match-end 1))) | 6790 | (delete-region (match-beginning 1) (match-end 1))) |
| @@ -6679,7 +6820,7 @@ This is important for non-interactive uses of the command." | |||
| 6679 | (org-back-to-heading t) | 6820 | (org-back-to-heading t) |
| 6680 | (if (looking-at | 6821 | (if (looking-at |
| 6681 | (if no-tags | 6822 | (if no-tags |
| 6682 | (org-re "\\*+[ \t]+\\([^\n\r]*?\\)\\([ \t]+:[[:alnum:]:_@]+:[ \t]*\\)?$") | 6823 | (org-re "\\*+[ \t]+\\([^\n\r]*?\\)\\([ \t]+:[[:alnum:]:_@#%]+:[ \t]*\\)?$") |
| 6683 | "\\*+[ \t]+\\([^\r\n]*\\)")) | 6824 | "\\*+[ \t]+\\([^\r\n]*\\)")) |
| 6684 | (match-string 1) ""))) | 6825 | (match-string 1) ""))) |
| 6685 | 6826 | ||
| @@ -6764,7 +6905,7 @@ Works for outline headings and for plain lists alike." | |||
| 6764 | (org-insert-heading arg) | 6905 | (org-insert-heading arg) |
| 6765 | (cond | 6906 | (cond |
| 6766 | ((org-on-heading-p) (org-do-demote)) | 6907 | ((org-on-heading-p) (org-do-demote)) |
| 6767 | ((org-at-item-p) (org-indent-item 1)))) | 6908 | ((org-at-item-p) (org-indent-item)))) |
| 6768 | 6909 | ||
| 6769 | (defun org-insert-todo-subheading (arg) | 6910 | (defun org-insert-todo-subheading (arg) |
| 6770 | "Insert a new subheading with TODO keyword or checkbox and demote it. | 6911 | "Insert a new subheading with TODO keyword or checkbox and demote it. |
| @@ -6773,7 +6914,7 @@ Works for outline headings and for plain lists alike." | |||
| 6773 | (org-insert-todo-heading arg) | 6914 | (org-insert-todo-heading arg) |
| 6774 | (cond | 6915 | (cond |
| 6775 | ((org-on-heading-p) (org-do-demote)) | 6916 | ((org-on-heading-p) (org-do-demote)) |
| 6776 | ((org-at-item-p) (org-indent-item 1)))) | 6917 | ((org-at-item-p) (org-indent-item)))) |
| 6777 | 6918 | ||
| 6778 | ;;; Promotion and Demotion | 6919 | ;;; Promotion and Demotion |
| 6779 | 6920 | ||
| @@ -7449,13 +7590,15 @@ and still retain the repeater to cover future instances of the task." | |||
| 7449 | ;;; Outline Sorting | 7590 | ;;; Outline Sorting |
| 7450 | 7591 | ||
| 7451 | (defun org-sort (with-case) | 7592 | (defun org-sort (with-case) |
| 7452 | "Call `org-sort-entries-or-items' or `org-table-sort-lines'. | 7593 | "Call `org-sort-entries', `org-table-sort-lines' or `org-sort-list'. |
| 7453 | Optional argument WITH-CASE means sort case-sensitively. | 7594 | Optional argument WITH-CASE means sort case-sensitively. |
| 7454 | With a double prefix argument, also remove duplicate entries." | 7595 | With a double prefix argument, also remove duplicate entries." |
| 7455 | (interactive "P") | 7596 | (interactive "P") |
| 7456 | (if (org-at-table-p) | 7597 | (cond |
| 7457 | (org-call-with-arg 'org-table-sort-lines with-case) | 7598 | ((org-at-table-p) (org-call-with-arg 'org-table-sort-lines with-case)) |
| 7458 | (org-call-with-arg 'org-sort-entries-or-items with-case))) | 7599 | ((org-at-item-p) (org-call-with-arg 'org-sort-list with-case)) |
| 7600 | (t | ||
| 7601 | (org-call-with-arg 'org-sort-entries with-case)))) | ||
| 7459 | 7602 | ||
| 7460 | (defun org-sort-remove-invisible (s) | 7603 | (defun org-sort-remove-invisible (s) |
| 7461 | (remove-text-properties 0 (length s) org-rm-props s) | 7604 | (remove-text-properties 0 (length s) org-rm-props s) |
| @@ -7473,14 +7616,12 @@ When children are sorted, the cursor is in the parent line when this | |||
| 7473 | hook gets called. When a region or a plain list is sorted, the cursor | 7616 | hook gets called. When a region or a plain list is sorted, the cursor |
| 7474 | will be in the first entry of the sorted region/list.") | 7617 | will be in the first entry of the sorted region/list.") |
| 7475 | 7618 | ||
| 7476 | (defun org-sort-entries-or-items | 7619 | (defun org-sort-entries |
| 7477 | (&optional with-case sorting-type getkey-func compare-func property) | 7620 | (&optional with-case sorting-type getkey-func compare-func property) |
| 7478 | "Sort entries on a certain level of an outline tree, or plain list items. | 7621 | "Sort entries on a certain level of an outline tree. |
| 7479 | If there is an active region, the entries in the region are sorted. | 7622 | If there is an active region, the entries in the region are sorted. |
| 7480 | Else, if the cursor is before the first entry, sort the top-level items. | 7623 | Else, if the cursor is before the first entry, sort the top-level items. |
| 7481 | Else, the children of the entry at point are sorted. | 7624 | Else, the children of the entry at point are sorted. |
| 7482 | If the cursor is at the first item in a plain list, the list items will be | ||
| 7483 | sorted. | ||
| 7484 | 7625 | ||
| 7485 | Sorting can be alphabetically, numerically, by date/time as given by | 7626 | Sorting can be alphabetically, numerically, by date/time as given by |
| 7486 | a time stamp, by a property or by priority. | 7627 | a time stamp, by a property or by priority. |
| @@ -7494,7 +7635,6 @@ n Numerically, by converting the beginning of the entry/item to a number. | |||
| 7494 | a Alphabetically, ignoring the TODO keyword and the priority, if any. | 7635 | a Alphabetically, ignoring the TODO keyword and the priority, if any. |
| 7495 | t By date/time, either the first active time stamp in the entry, or, if | 7636 | t By date/time, either the first active time stamp in the entry, or, if |
| 7496 | none exist, by the first inactive one. | 7637 | none exist, by the first inactive one. |
| 7497 | In items, only the first line will be checked. | ||
| 7498 | s By the scheduled date/time. | 7638 | s By the scheduled date/time. |
| 7499 | d By deadline date/time. | 7639 | d By deadline date/time. |
| 7500 | c By creation time, which is assumed to be the first inactive time stamp | 7640 | c By creation time, which is assumed to be the first inactive time stamp |
| @@ -7513,7 +7653,7 @@ WITH-CASE, the sorting considers case as well." | |||
| 7513 | (interactive "P") | 7653 | (interactive "P") |
| 7514 | (let ((case-func (if with-case 'identity 'downcase)) | 7654 | (let ((case-func (if with-case 'identity 'downcase)) |
| 7515 | start beg end stars re re2 | 7655 | start beg end stars re re2 |
| 7516 | txt what tmp plain-list-p) | 7656 | txt what tmp) |
| 7517 | ;; Find beginning and end of region to sort | 7657 | ;; Find beginning and end of region to sort |
| 7518 | (cond | 7658 | (cond |
| 7519 | ((org-region-active-p) | 7659 | ((org-region-active-p) |
| @@ -7523,15 +7663,6 @@ WITH-CASE, the sorting considers case as well." | |||
| 7523 | (goto-char (region-beginning)) | 7663 | (goto-char (region-beginning)) |
| 7524 | (if (not (org-on-heading-p)) (outline-next-heading)) | 7664 | (if (not (org-on-heading-p)) (outline-next-heading)) |
| 7525 | (setq start (point))) | 7665 | (setq start (point))) |
| 7526 | ((org-at-item-p) | ||
| 7527 | ;; we will sort this plain list | ||
| 7528 | (org-beginning-of-item-list) (setq start (point)) | ||
| 7529 | (org-end-of-item-list) | ||
| 7530 | (or (bolp) (insert "\n")) | ||
| 7531 | (setq end (point)) | ||
| 7532 | (goto-char start) | ||
| 7533 | (setq plain-list-p t | ||
| 7534 | what "plain list")) | ||
| 7535 | ((or (org-on-heading-p) | 7666 | ((or (org-on-heading-p) |
| 7536 | (condition-case nil (progn (org-back-to-heading) t) (error nil))) | 7667 | (condition-case nil (progn (org-back-to-heading) t) (error nil))) |
| 7537 | ;; we will sort the children of the current headline | 7668 | ;; we will sort the children of the current headline |
| @@ -7564,43 +7695,39 @@ WITH-CASE, the sorting considers case as well." | |||
| 7564 | (setq beg (point)) | 7695 | (setq beg (point)) |
| 7565 | (if (>= beg end) (error "Nothing to sort")) | 7696 | (if (>= beg end) (error "Nothing to sort")) |
| 7566 | 7697 | ||
| 7567 | (unless plain-list-p | 7698 | (looking-at "\\(\\*+\\)") |
| 7568 | (looking-at "\\(\\*+\\)") | 7699 | (setq stars (match-string 1) |
| 7569 | (setq stars (match-string 1) | 7700 | re (concat "^" (regexp-quote stars) " +") |
| 7570 | re (concat "^" (regexp-quote stars) " +") | 7701 | re2 (concat "^" (regexp-quote (substring stars 0 -1)) "[^*]") |
| 7571 | re2 (concat "^" (regexp-quote (substring stars 0 -1)) "[^*]") | 7702 | txt (buffer-substring beg end)) |
| 7572 | txt (buffer-substring beg end)) | 7703 | (if (not (equal (substring txt -1) "\n")) (setq txt (concat txt "\n"))) |
| 7573 | (if (not (equal (substring txt -1) "\n")) (setq txt (concat txt "\n"))) | 7704 | (if (and (not (equal stars "*")) (string-match re2 txt)) |
| 7574 | (if (and (not (equal stars "*")) (string-match re2 txt)) | 7705 | (error "Region to sort contains a level above the first entry")) |
| 7575 | (error "Region to sort contains a level above the first entry"))) | ||
| 7576 | 7706 | ||
| 7577 | (unless sorting-type | 7707 | (unless sorting-type |
| 7578 | (message | 7708 | (message |
| 7579 | (if plain-list-p | 7709 | "Sort %s: [a]lpha [n]umeric [p]riority p[r]operty todo[o]rder [f]unc |
| 7580 | "Sort %s: [a]lpha [n]umeric [t]ime [f]unc A/N/T/F means reversed:" | ||
| 7581 | "Sort %s: [a]lpha [n]umeric [p]riority p[r]operty todo[o]rder [f]unc | ||
| 7582 | [t]ime [s]cheduled [d]eadline [c]reated | 7710 | [t]ime [s]cheduled [d]eadline [c]reated |
| 7583 | A/N/T/S/D/C/P/O/F means reversed:") | 7711 | A/N/T/S/D/C/P/O/F means reversed:" |
| 7584 | what) | 7712 | what) |
| 7585 | (setq sorting-type (read-char-exclusive)) | 7713 | (setq sorting-type (read-char-exclusive)) |
| 7586 | 7714 | ||
| 7587 | (and (= (downcase sorting-type) ?f) | 7715 | (and (= (downcase sorting-type) ?f) |
| 7588 | (setq getkey-func | 7716 | (setq getkey-func |
| 7589 | (org-icompleting-read "Sort using function: " | 7717 | (org-icompleting-read "Sort using function: " |
| 7590 | obarray 'fboundp t nil nil)) | 7718 | obarray 'fboundp t nil nil)) |
| 7591 | (setq getkey-func (intern getkey-func))) | 7719 | (setq getkey-func (intern getkey-func))) |
| 7592 | 7720 | ||
| 7593 | (and (= (downcase sorting-type) ?r) | 7721 | (and (= (downcase sorting-type) ?r) |
| 7594 | (setq property | 7722 | (setq property |
| 7595 | (org-icompleting-read "Property: " | 7723 | (org-icompleting-read "Property: " |
| 7596 | (mapcar 'list (org-buffer-property-keys t)) | 7724 | (mapcar 'list (org-buffer-property-keys t)) |
| 7597 | nil t)))) | 7725 | nil t)))) |
| 7598 | 7726 | ||
| 7599 | (message "Sorting entries...") | 7727 | (message "Sorting entries...") |
| 7600 | 7728 | ||
| 7601 | (save-restriction | 7729 | (save-restriction |
| 7602 | (narrow-to-region start end) | 7730 | (narrow-to-region start end) |
| 7603 | |||
| 7604 | (let ((dcst (downcase sorting-type)) | 7731 | (let ((dcst (downcase sorting-type)) |
| 7605 | (case-fold-search nil) | 7732 | (case-fold-search nil) |
| 7606 | (now (current-time))) | 7733 | (now (current-time))) |
| @@ -7608,99 +7735,70 @@ WITH-CASE, the sorting considers case as well." | |||
| 7608 | (/= dcst sorting-type) | 7735 | (/= dcst sorting-type) |
| 7609 | ;; This function moves to the beginning character of the "record" to | 7736 | ;; This function moves to the beginning character of the "record" to |
| 7610 | ;; be sorted. | 7737 | ;; be sorted. |
| 7611 | (if plain-list-p | 7738 | (lambda nil |
| 7612 | (lambda nil | 7739 | (if (re-search-forward re nil t) |
| 7613 | (if (org-at-item-p) t (goto-char (point-max)))) | 7740 | (goto-char (match-beginning 0)) |
| 7614 | (lambda nil | 7741 | (goto-char (point-max)))) |
| 7615 | (if (re-search-forward re nil t) | ||
| 7616 | (goto-char (match-beginning 0)) | ||
| 7617 | (goto-char (point-max))))) | ||
| 7618 | ;; This function moves to the last character of the "record" being | 7742 | ;; This function moves to the last character of the "record" being |
| 7619 | ;; sorted. | 7743 | ;; sorted. |
| 7620 | (if plain-list-p | 7744 | (lambda nil |
| 7621 | 'org-end-of-item | 7745 | (save-match-data |
| 7622 | (lambda nil | 7746 | (condition-case nil |
| 7623 | (save-match-data | 7747 | (outline-forward-same-level 1) |
| 7624 | (condition-case nil | 7748 | (error |
| 7625 | (outline-forward-same-level 1) | 7749 | (goto-char (point-max)))))) |
| 7626 | (error | ||
| 7627 | (goto-char (point-max))))))) | ||
| 7628 | |||
| 7629 | ;; This function returns the value that gets sorted against. | 7750 | ;; This function returns the value that gets sorted against. |
| 7630 | (if plain-list-p | 7751 | (lambda nil |
| 7631 | (lambda nil | 7752 | (cond |
| 7632 | (when (looking-at "[ \t]*[-+*0-9.)]+[ \t]+") | 7753 | ((= dcst ?n) |
| 7633 | (cond | 7754 | (if (looking-at org-complex-heading-regexp) |
| 7634 | ((= dcst ?n) | 7755 | (string-to-number (match-string 4)) |
| 7635 | (string-to-number (buffer-substring (match-end 0) | 7756 | nil)) |
| 7636 | (point-at-eol)))) | 7757 | ((= dcst ?a) |
| 7637 | ((= dcst ?a) | 7758 | (if (looking-at org-complex-heading-regexp) |
| 7638 | (buffer-substring (match-end 0) (point-at-eol))) | 7759 | (funcall case-func (match-string 4)) |
| 7639 | ((= dcst ?t) | 7760 | nil)) |
| 7640 | (if (or (re-search-forward org-ts-regexp (point-at-eol) t) | 7761 | ((= dcst ?t) |
| 7641 | (re-search-forward org-ts-regexp-both | 7762 | (let ((end (save-excursion (outline-next-heading) (point)))) |
| 7642 | (point-at-eol) t)) | 7763 | (if (or (re-search-forward org-ts-regexp end t) |
| 7643 | (org-time-string-to-seconds (match-string 0)) | 7764 | (re-search-forward org-ts-regexp-both end t)) |
| 7644 | (org-float-time now))) | 7765 | (org-time-string-to-seconds (match-string 0)) |
| 7645 | ((= dcst ?f) | 7766 | (org-float-time now)))) |
| 7646 | (if getkey-func | 7767 | ((= dcst ?c) |
| 7647 | (progn | 7768 | (let ((end (save-excursion (outline-next-heading) (point)))) |
| 7648 | (setq tmp (funcall getkey-func)) | 7769 | (if (re-search-forward |
| 7649 | (if (stringp tmp) (setq tmp (funcall case-func tmp))) | 7770 | (concat "^[ \t]*\\[" org-ts-regexp1 "\\]") |
| 7650 | tmp) | 7771 | end t) |
| 7651 | (error "Invalid key function `%s'" getkey-func))) | 7772 | (org-time-string-to-seconds (match-string 0)) |
| 7652 | (t (error "Invalid sorting type `%c'" sorting-type))))) | 7773 | (org-float-time now)))) |
| 7653 | (lambda nil | 7774 | ((= dcst ?s) |
| 7654 | (cond | 7775 | (let ((end (save-excursion (outline-next-heading) (point)))) |
| 7655 | ((= dcst ?n) | 7776 | (if (re-search-forward org-scheduled-time-regexp end t) |
| 7656 | (if (looking-at org-complex-heading-regexp) | 7777 | (org-time-string-to-seconds (match-string 1)) |
| 7657 | (string-to-number (match-string 4)) | 7778 | (org-float-time now)))) |
| 7658 | nil)) | 7779 | ((= dcst ?d) |
| 7659 | ((= dcst ?a) | 7780 | (let ((end (save-excursion (outline-next-heading) (point)))) |
| 7660 | (if (looking-at org-complex-heading-regexp) | 7781 | (if (re-search-forward org-deadline-time-regexp end t) |
| 7661 | (funcall case-func (match-string 4)) | 7782 | (org-time-string-to-seconds (match-string 1)) |
| 7662 | nil)) | 7783 | (org-float-time now)))) |
| 7663 | ((= dcst ?t) | 7784 | ((= dcst ?p) |
| 7664 | (let ((end (save-excursion (outline-next-heading) (point)))) | 7785 | (if (re-search-forward org-priority-regexp (point-at-eol) t) |
| 7665 | (if (or (re-search-forward org-ts-regexp end t) | 7786 | (string-to-char (match-string 2)) |
| 7666 | (re-search-forward org-ts-regexp-both end t)) | 7787 | org-default-priority)) |
| 7667 | (org-time-string-to-seconds (match-string 0)) | 7788 | ((= dcst ?r) |
| 7668 | (org-float-time now)))) | 7789 | (or (org-entry-get nil property) "")) |
| 7669 | ((= dcst ?c) | 7790 | ((= dcst ?o) |
| 7670 | (let ((end (save-excursion (outline-next-heading) (point)))) | 7791 | (if (looking-at org-complex-heading-regexp) |
| 7671 | (if (re-search-forward | 7792 | (- 9999 (length (member (match-string 2) |
| 7672 | (concat "^[ \t]*\\[" org-ts-regexp1 "\\]") | 7793 | org-todo-keywords-1))))) |
| 7673 | end t) | 7794 | ((= dcst ?f) |
| 7674 | (org-time-string-to-seconds (match-string 0)) | 7795 | (if getkey-func |
| 7675 | (org-float-time now)))) | 7796 | (progn |
| 7676 | ((= dcst ?s) | 7797 | (setq tmp (funcall getkey-func)) |
| 7677 | (let ((end (save-excursion (outline-next-heading) (point)))) | 7798 | (if (stringp tmp) (setq tmp (funcall case-func tmp))) |
| 7678 | (if (re-search-forward org-scheduled-time-regexp end t) | 7799 | tmp) |
| 7679 | (org-time-string-to-seconds (match-string 1)) | 7800 | (error "Invalid key function `%s'" getkey-func))) |
| 7680 | (org-float-time now)))) | 7801 | (t (error "Invalid sorting type `%c'" sorting-type)))) |
| 7681 | ((= dcst ?d) | ||
| 7682 | (let ((end (save-excursion (outline-next-heading) (point)))) | ||
| 7683 | (if (re-search-forward org-deadline-time-regexp end t) | ||
| 7684 | (org-time-string-to-seconds (match-string 1)) | ||
| 7685 | (org-float-time now)))) | ||
| 7686 | ((= dcst ?p) | ||
| 7687 | (if (re-search-forward org-priority-regexp (point-at-eol) t) | ||
| 7688 | (string-to-char (match-string 2)) | ||
| 7689 | org-default-priority)) | ||
| 7690 | ((= dcst ?r) | ||
| 7691 | (or (org-entry-get nil property) "")) | ||
| 7692 | ((= dcst ?o) | ||
| 7693 | (if (looking-at org-complex-heading-regexp) | ||
| 7694 | (- 9999 (length (member (match-string 2) | ||
| 7695 | org-todo-keywords-1))))) | ||
| 7696 | ((= dcst ?f) | ||
| 7697 | (if getkey-func | ||
| 7698 | (progn | ||
| 7699 | (setq tmp (funcall getkey-func)) | ||
| 7700 | (if (stringp tmp) (setq tmp (funcall case-func tmp))) | ||
| 7701 | tmp) | ||
| 7702 | (error "Invalid key function `%s'" getkey-func))) | ||
| 7703 | (t (error "Invalid sorting type `%c'" sorting-type))))) | ||
| 7704 | nil | 7802 | nil |
| 7705 | (cond | 7803 | (cond |
| 7706 | ((= dcst ?a) 'string<) | 7804 | ((= dcst ?a) 'string<) |
| @@ -8105,11 +8203,13 @@ It should be a function accepting three arguments: | |||
| 8105 | 8203 | ||
| 8106 | path the path of the link, the text after the prefix (like \"http:\") | 8204 | path the path of the link, the text after the prefix (like \"http:\") |
| 8107 | desc the description of the link, if any, nil if there was no description | 8205 | desc the description of the link, if any, nil if there was no description |
| 8108 | format the export format, a symbol like `html' or `latex'. | 8206 | format the export format, a symbol like `html' or `latex' or `ascii'.. |
| 8109 | 8207 | ||
| 8110 | The function may use the FORMAT information to return different values | 8208 | The function may use the FORMAT information to return different values |
| 8111 | depending on the format. The return value will be put literally into | 8209 | depending on the format. The return value will be put literally into |
| 8112 | the exported file. | 8210 | the exported file. If the return value is nil, this means Org should |
| 8211 | do what it normally does with links which do not have EXPORT defined. | ||
| 8212 | |||
| 8113 | Org-mode has a built-in default for exporting links. If you are happy with | 8213 | Org-mode has a built-in default for exporting links. If you are happy with |
| 8114 | this default, there is no need to define an export function for the link | 8214 | this default, there is no need to define an export function for the link |
| 8115 | type. For a simple example of an export function, see `org-bbdb.el'." | 8215 | type. For a simple example of an export function, see `org-bbdb.el'." |
| @@ -8134,7 +8234,7 @@ For file links, arg negates `org-context-in-file-links'." | |||
| 8134 | (org-load-modules-maybe) | 8234 | (org-load-modules-maybe) |
| 8135 | (setq org-store-link-plist nil) ; reset | 8235 | (setq org-store-link-plist nil) ; reset |
| 8136 | (let ((outline-regexp (org-get-limited-outline-regexp)) | 8236 | (let ((outline-regexp (org-get-limited-outline-regexp)) |
| 8137 | link cpltxt desc description search txt custom-id) | 8237 | link cpltxt desc description search txt custom-id agenda-link) |
| 8138 | (cond | 8238 | (cond |
| 8139 | 8239 | ||
| 8140 | ((run-hook-with-args-until-success 'org-store-link-functions) | 8240 | ((run-hook-with-args-until-success 'org-store-link-functions) |
| @@ -8166,9 +8266,10 @@ For file links, arg negates `org-context-in-file-links'." | |||
| 8166 | (get-text-property (point) 'org-marker)))) | 8266 | (get-text-property (point) 'org-marker)))) |
| 8167 | (when m | 8267 | (when m |
| 8168 | (org-with-point-at m | 8268 | (org-with-point-at m |
| 8169 | (if (interactive-p) | 8269 | (setq agenda-link |
| 8170 | (call-interactively 'org-store-link) | 8270 | (if (interactive-p) |
| 8171 | (org-store-link nil)))))) | 8271 | (call-interactively 'org-store-link) |
| 8272 | (org-store-link nil))))))) | ||
| 8172 | 8273 | ||
| 8173 | ((eq major-mode 'calendar-mode) | 8274 | ((eq major-mode 'calendar-mode) |
| 8174 | (let ((cd (calendar-cursor-to-date))) | 8275 | (let ((cd (calendar-cursor-to-date))) |
| @@ -8216,13 +8317,14 @@ For file links, arg negates `org-context-in-file-links'." | |||
| 8216 | (setq cpltxt (concat "file:" file) | 8317 | (setq cpltxt (concat "file:" file) |
| 8217 | link (org-make-link cpltxt)))) | 8318 | link (org-make-link cpltxt)))) |
| 8218 | 8319 | ||
| 8219 | ((and buffer-file-name (org-mode-p)) | 8320 | ((and (buffer-file-name (buffer-base-buffer)) (org-mode-p)) |
| 8220 | (setq custom-id (ignore-errors (org-entry-get nil "CUSTOM_ID"))) | 8321 | (setq custom-id (ignore-errors (org-entry-get nil "CUSTOM_ID"))) |
| 8221 | (cond | 8322 | (cond |
| 8222 | ((org-in-regexp "<<\\(.*?\\)>>") | 8323 | ((org-in-regexp "<<\\(.*?\\)>>") |
| 8223 | (setq cpltxt | 8324 | (setq cpltxt |
| 8224 | (concat "file:" | 8325 | (concat "file:" |
| 8225 | (abbreviate-file-name buffer-file-name) | 8326 | (abbreviate-file-name |
| 8327 | (buffer-file-name (buffer-base-buffer))) | ||
| 8226 | "::" (match-string 1)) | 8328 | "::" (match-string 1)) |
| 8227 | link (org-make-link cpltxt))) | 8329 | link (org-make-link cpltxt))) |
| 8228 | ((and (featurep 'org-id) | 8330 | ((and (featurep 'org-id) |
| @@ -8244,11 +8346,13 @@ For file links, arg negates `org-context-in-file-links'." | |||
| 8244 | (error | 8346 | (error |
| 8245 | ;; probably before first headline, link to file only | 8347 | ;; probably before first headline, link to file only |
| 8246 | (concat "file:" | 8348 | (concat "file:" |
| 8247 | (abbreviate-file-name buffer-file-name)))))) | 8349 | (abbreviate-file-name |
| 8350 | (buffer-file-name (buffer-base-buffer)))))))) | ||
| 8248 | (t | 8351 | (t |
| 8249 | ;; Just link to current headline | 8352 | ;; Just link to current headline |
| 8250 | (setq cpltxt (concat "file:" | 8353 | (setq cpltxt (concat "file:" |
| 8251 | (abbreviate-file-name buffer-file-name))) | 8354 | (abbreviate-file-name |
| 8355 | (buffer-file-name (buffer-base-buffer))))) | ||
| 8252 | ;; Add a context search string | 8356 | ;; Add a context search string |
| 8253 | (when (org-xor org-context-in-file-links arg) | 8357 | (when (org-xor org-context-in-file-links arg) |
| 8254 | (setq txt (cond | 8358 | (setq txt (cond |
| @@ -8305,7 +8409,7 @@ For file links, arg negates `org-context-in-file-links'." | |||
| 8305 | "::#" custom-id)) | 8409 | "::#" custom-id)) |
| 8306 | (setq org-stored-links | 8410 | (setq org-stored-links |
| 8307 | (cons (list link desc) org-stored-links)))) | 8411 | (cons (list link desc) org-stored-links)))) |
| 8308 | (and link (org-make-link-string link desc))))) | 8412 | (or agenda-link (and link (org-make-link-string link desc)))))) |
| 8309 | 8413 | ||
| 8310 | (defun org-store-link-props (&rest plist) | 8414 | (defun org-store-link-props (&rest plist) |
| 8311 | "Store link properties, extract names and addresses." | 8415 | "Store link properties, extract names and addresses." |
| @@ -8369,7 +8473,7 @@ according to FMT (default from `org-email-link-description-format')." | |||
| 8369 | ;; We are using a headline, clean up garbage in there. | 8473 | ;; We are using a headline, clean up garbage in there. |
| 8370 | (if (string-match org-todo-regexp s) | 8474 | (if (string-match org-todo-regexp s) |
| 8371 | (setq s (replace-match "" t t s))) | 8475 | (setq s (replace-match "" t t s))) |
| 8372 | (if (string-match (org-re ":[[:alnum:]_@:]+:[ \t]*$") s) | 8476 | (if (string-match (org-re ":[[:alnum:]_@#%:]+:[ \t]*$") s) |
| 8373 | (setq s (replace-match "" t t s))) | 8477 | (setq s (replace-match "" t t s))) |
| 8374 | (setq s (org-trim s)) | 8478 | (setq s (org-trim s)) |
| 8375 | (if (string-match (concat "^\\(" org-quote-string "\\|" | 8479 | (if (string-match (concat "^\\(" org-quote-string "\\|" |
| @@ -8377,8 +8481,6 @@ according to FMT (default from `org-email-link-description-format')." | |||
| 8377 | (setq s (replace-match "" t t s))) | 8481 | (setq s (replace-match "" t t s))) |
| 8378 | (while (string-match org-ts-regexp s) | 8482 | (while (string-match org-ts-regexp s) |
| 8379 | (setq s (replace-match "" t t s)))) | 8483 | (setq s (replace-match "" t t s)))) |
| 8380 | (while (string-match "[^a-zA-Z_0-9 \t]+" s) | ||
| 8381 | (setq s (replace-match " " t t s))) | ||
| 8382 | (or string (setq s (concat "*" s))) ; Add * for headlines | 8484 | (or string (setq s (concat "*" s))) ; Add * for headlines |
| 8383 | (mapconcat 'identity (org-split-string s "[ \t]+") " "))) | 8485 | (mapconcat 'identity (org-split-string s "[ \t]+") " "))) |
| 8384 | 8486 | ||
| @@ -8406,7 +8508,11 @@ according to FMT (default from `org-email-link-description-format')." | |||
| 8406 | (when (and (not description) | 8508 | (when (and (not description) |
| 8407 | (not (equal link (org-link-escape link)))) | 8509 | (not (equal link (org-link-escape link)))) |
| 8408 | (setq description (org-extract-attributes link))) | 8510 | (setq description (org-extract-attributes link))) |
| 8409 | (concat "[[" (org-link-escape link) "]" | 8511 | (setq link (if (string-match org-link-types-re link) |
| 8512 | (concat (match-string 1 link) | ||
| 8513 | (org-link-escape (substring link (match-end 1)))) | ||
| 8514 | (org-link-escape link))) | ||
| 8515 | (concat "[[" link "]" | ||
| 8410 | (if description (concat "[" description "]") "") | 8516 | (if description (concat "[" description "]") "") |
| 8411 | "]")) | 8517 | "]")) |
| 8412 | 8518 | ||
| @@ -8914,6 +9020,13 @@ Org-mode syntax." | |||
| 8914 | org-link-abbrev-alist-local))) | 9020 | org-link-abbrev-alist-local))) |
| 8915 | (org-open-at-point arg reference-buffer))))) | 9021 | (org-open-at-point arg reference-buffer))))) |
| 8916 | 9022 | ||
| 9023 | (defvar org-open-at-point-functions nil | ||
| 9024 | "Hook that is run when following a link at point. | ||
| 9025 | |||
| 9026 | Functions in this hook must return t if they identify and follow | ||
| 9027 | a link at point. If they don't find anything interesting at point, | ||
| 9028 | they must return nil.") | ||
| 9029 | |||
| 8917 | (defun org-open-at-point (&optional in-emacs reference-buffer) | 9030 | (defun org-open-at-point (&optional in-emacs reference-buffer) |
| 8918 | "Open link at or after point. | 9031 | "Open link at or after point. |
| 8919 | If there is no link at point, this function will search forward up to | 9032 | If there is no link at point, this function will search forward up to |
| @@ -8939,6 +9052,7 @@ application the system uses for this file type." | |||
| 8939 | (not (get-text-property (point) 'org-linked-text))) | 9052 | (not (get-text-property (point) 'org-linked-text))) |
| 8940 | (or (org-offer-links-in-entry in-emacs) | 9053 | (or (org-offer-links-in-entry in-emacs) |
| 8941 | (progn (require 'org-attach) (org-attach-reveal 'if-exists)))) | 9054 | (progn (require 'org-attach) (org-attach-reveal 'if-exists)))) |
| 9055 | ((run-hook-with-args-until-success 'org-open-at-point-functions)) | ||
| 8942 | ((org-at-timestamp-p t) (org-follow-timestamp-link)) | 9056 | ((org-at-timestamp-p t) (org-follow-timestamp-link)) |
| 8943 | ((or (org-footnote-at-reference-p) (org-footnote-at-definition-p)) | 9057 | ((or (org-footnote-at-reference-p) (org-footnote-at-definition-p)) |
| 8944 | (org-footnote-action)) | 9058 | (org-footnote-action)) |
| @@ -8977,7 +9091,7 @@ application the system uses for this file type." | |||
| 8977 | (setq type (match-string 1) path (match-string 2)) | 9091 | (setq type (match-string 1) path (match-string 2)) |
| 8978 | (throw 'match t))) | 9092 | (throw 'match t))) |
| 8979 | (save-excursion | 9093 | (save-excursion |
| 8980 | (when (org-in-regexp (org-re "\\(:[[:alnum:]_@:]+\\):[ \t]*$")) | 9094 | (when (org-in-regexp (org-re "\\(:[[:alnum:]_@#%:]+\\):[ \t]*$")) |
| 8981 | (setq type "tags" | 9095 | (setq type "tags" |
| 8982 | path (match-string 1)) | 9096 | path (match-string 1)) |
| 8983 | (while (string-match ":" path) | 9097 | (while (string-match ":" path) |
| @@ -9243,6 +9357,7 @@ the window configuration before `org-open-at-point' was called using: | |||
| 9243 | 9357 | ||
| 9244 | (set-window-configuration org-window-config-before-follow-link)") | 9358 | (set-window-configuration org-window-config-before-follow-link)") |
| 9245 | 9359 | ||
| 9360 | (defvar org-link-search-inhibit-query nil) ;; dynamically scoped | ||
| 9246 | (defun org-link-search (s &optional type avoid-pos) | 9361 | (defun org-link-search (s &optional type avoid-pos) |
| 9247 | "Search for a link search option. | 9362 | "Search for a link search option. |
| 9248 | If S is surrounded by forward slashes, it is interpreted as a | 9363 | If S is surrounded by forward slashes, it is interpreted as a |
| @@ -9260,7 +9375,7 @@ in all files. If AVOID-POS is given, ignore matches near that position." | |||
| 9260 | (pre nil) (post nil) | 9375 | (pre nil) (post nil) |
| 9261 | words re0 re1 re2 re3 re4_ re4 re5 re2a re2a_ reall) | 9376 | words re0 re1 re2 re3 re4_ re4 re5 re2a re2a_ reall) |
| 9262 | (cond | 9377 | (cond |
| 9263 | ;; First check if there are any special | 9378 | ;; First check if there are any special search functions |
| 9264 | ((run-hook-with-args-until-success 'org-execute-file-search-functions s)) | 9379 | ((run-hook-with-args-until-success 'org-execute-file-search-functions s)) |
| 9265 | ;; Now try the builtin stuff | 9380 | ;; Now try the builtin stuff |
| 9266 | ((and (equal (string-to-char s0) ?#) | 9381 | ((and (equal (string-to-char s0) ?#) |
| @@ -9305,12 +9420,33 @@ in all files. If AVOID-POS is given, ignore matches near that position." | |||
| 9305 | ;;((eq major-mode 'dired-mode) | 9420 | ;;((eq major-mode 'dired-mode) |
| 9306 | ;; (grep (concat "grep -n -e '" (match-string 1 s) "' *"))) | 9421 | ;; (grep (concat "grep -n -e '" (match-string 1 s) "' *"))) |
| 9307 | (t (org-do-occur (match-string 1 s))))) | 9422 | (t (org-do-occur (match-string 1 s))))) |
| 9423 | ((and (org-mode-p) org-link-search-must-match-exact-headline) | ||
| 9424 | (and (equal (string-to-char s) ?*) (setq s (substring s 1))) | ||
| 9425 | (goto-char (point-min)) | ||
| 9426 | (cond | ||
| 9427 | ((let (case-fold-search) | ||
| 9428 | (re-search-forward (format org-complex-heading-regexp-format | ||
| 9429 | (regexp-quote s)) | ||
| 9430 | nil t)) | ||
| 9431 | ;; OK, found a match | ||
| 9432 | (setq type 'dedicated) | ||
| 9433 | (goto-char (match-beginning 0))) | ||
| 9434 | ((and (not org-link-search-inhibit-query) | ||
| 9435 | (eq org-link-search-must-match-exact-headline 'query-to-create) | ||
| 9436 | (y-or-n-p "No match - create this as a new heading? ")) | ||
| 9437 | (goto-char (point-max)) | ||
| 9438 | (or (bolp) (newline)) | ||
| 9439 | (insert "* " s "\n") | ||
| 9440 | (beginning-of-line 0)) | ||
| 9441 | (t | ||
| 9442 | (goto-char pos) | ||
| 9443 | (error "No match")))) | ||
| 9308 | (t | 9444 | (t |
| 9309 | ;; A normal search strings | 9445 | ;; A normal search string |
| 9310 | (when (equal (string-to-char s) ?*) | 9446 | (when (equal (string-to-char s) ?*) |
| 9311 | ;; Anchor on headlines, post may include tags. | 9447 | ;; Anchor on headlines, post may include tags. |
| 9312 | (setq pre "^\\*+[ \t]+\\(?:\\sw+\\)?[ \t]*" | 9448 | (setq pre "^\\*+[ \t]+\\(?:\\sw+\\)?[ \t]*" |
| 9313 | post (org-re "[ \t]*\\(?:[ \t]+:[[:alnum:]_@:+]:[ \t]*\\)?$") | 9449 | post (org-re "[ \t]*\\(?:[ \t]+:[[:alnum:]_@#%:+]:[ \t]*\\)?$") |
| 9314 | s (substring s 1))) | 9450 | s (substring s 1))) |
| 9315 | (remove-text-properties | 9451 | (remove-text-properties |
| 9316 | 0 (length s) | 9452 | 0 (length s) |
| @@ -9351,13 +9487,7 @@ in all files. If AVOID-POS is given, ignore matches near that position." | |||
| 9351 | ) | 9487 | ) |
| 9352 | (goto-char (match-beginning 1)) | 9488 | (goto-char (match-beginning 1)) |
| 9353 | (goto-char pos) | 9489 | (goto-char pos) |
| 9354 | (error "No match"))))) | 9490 | (error "No match")))))) |
| 9355 | (t | ||
| 9356 | ;; Normal string-search | ||
| 9357 | (goto-char (point-min)) | ||
| 9358 | (if (search-forward s nil t) | ||
| 9359 | (goto-char (match-beginning 0)) | ||
| 9360 | (error "No match")))) | ||
| 9361 | (and (org-mode-p) (org-show-context 'link-search)) | 9491 | (and (org-mode-p) (org-show-context 'link-search)) |
| 9362 | type)) | 9492 | type)) |
| 9363 | 9493 | ||
| @@ -9836,15 +9966,9 @@ on the system \"/user@host:\"." | |||
| 9836 | (setq level (org-reduced-level | 9966 | (setq level (org-reduced-level |
| 9837 | (- (match-end 1) (match-beginning 1))) | 9967 | (- (match-end 1) (match-beginning 1))) |
| 9838 | txt (org-link-display-format (match-string 4)) | 9968 | txt (org-link-display-format (match-string 4)) |
| 9839 | re (concat "^" (regexp-quote | 9969 | txt (replace-regexp-in-string "\\( *\[[0-9]+/?[0-9]*%?\]\\)+$" "" txt) |
| 9840 | (buffer-substring | 9970 | re (format org-complex-heading-regexp-format |
| 9841 | (match-beginning 1) | 9971 | (regexp-quote (match-string 4)))) |
| 9842 | (match-end 4))))) | ||
| 9843 | (if (match-end 5) (setq re (concat | ||
| 9844 | re "[ \t]+" | ||
| 9845 | (regexp-quote | ||
| 9846 | (match-string 5))))) | ||
| 9847 | (setq re (concat re "[ \t]*$")) | ||
| 9848 | (when org-refile-use-outline-path | 9972 | (when org-refile-use-outline-path |
| 9849 | (setq txt (mapconcat | 9973 | (setq txt (mapconcat |
| 9850 | 'org-protect-slash | 9974 | 'org-protect-slash |
| @@ -10143,6 +10267,7 @@ This can be done with a 0 prefix: `C-0 C-c C-w'" | |||
| 10143 | (setq answ (funcall cfunc prompt tbl nil (not new-nodes) | 10267 | (setq answ (funcall cfunc prompt tbl nil (not new-nodes) |
| 10144 | nil 'org-refile-history)) | 10268 | nil 'org-refile-history)) |
| 10145 | (setq pa (or (assoc answ tbl) (assoc (concat answ "/") tbl))) | 10269 | (setq pa (or (assoc answ tbl) (assoc (concat answ "/") tbl))) |
| 10270 | (org-refile-check-position pa) | ||
| 10146 | (if pa | 10271 | (if pa |
| 10147 | (progn | 10272 | (progn |
| 10148 | (when (or (not org-refile-history) | 10273 | (when (or (not org-refile-history) |
| @@ -10169,6 +10294,26 @@ This can be done with a 0 prefix: `C-0 C-c C-w'" | |||
| 10169 | (org-refile-new-child parent-target child))) | 10294 | (org-refile-new-child parent-target child))) |
| 10170 | (error "Invalid target location"))))) | 10295 | (error "Invalid target location"))))) |
| 10171 | 10296 | ||
| 10297 | (defun org-refile-check-position (refile-pointer) | ||
| 10298 | "Check if the refile pointer matches the readline to which it points." | ||
| 10299 | (let* ((file (nth 1 refile-pointer)) | ||
| 10300 | (re (nth 2 refile-pointer)) | ||
| 10301 | (pos (nth 3 refile-pointer)) | ||
| 10302 | buffer) | ||
| 10303 | (when (org-string-nw-p re) | ||
| 10304 | (setq buffer (if (markerp pos) | ||
| 10305 | (marker-buffer pos) | ||
| 10306 | (or (find-buffer-visiting file) | ||
| 10307 | (find-file-noselect file)))) | ||
| 10308 | (with-current-buffer buffer | ||
| 10309 | (save-excursion | ||
| 10310 | (save-restriction | ||
| 10311 | (widen) | ||
| 10312 | (goto-char pos) | ||
| 10313 | (beginning-of-line 1) | ||
| 10314 | (unless (org-looking-at-p re) | ||
| 10315 | (error "Invalid refile position, please rebuild the cache")))))))) | ||
| 10316 | |||
| 10172 | (defun org-refile-new-child (parent-target child) | 10317 | (defun org-refile-new-child (parent-target child) |
| 10173 | "Use refile target PARENT-TARGET to add new CHILD below it." | 10318 | "Use refile target PARENT-TARGET to add new CHILD below it." |
| 10174 | (unless parent-target | 10319 | (unless parent-target |
| @@ -10378,7 +10523,7 @@ This function can be used in a hook." | |||
| 10378 | "BEGIN_VERSE" "END_VERSE" | 10523 | "BEGIN_VERSE" "END_VERSE" |
| 10379 | "BEGIN_CENTER" "END_CENTER" | 10524 | "BEGIN_CENTER" "END_CENTER" |
| 10380 | "BEGIN_SRC" "END_SRC" | 10525 | "BEGIN_SRC" "END_SRC" |
| 10381 | "CATEGORY" "COLUMNS" | 10526 | "CATEGORY" "COLUMNS" "PROPERTY" |
| 10382 | "CAPTION" "LABEL" | 10527 | "CAPTION" "LABEL" |
| 10383 | "SETUPFILE" | 10528 | "SETUPFILE" |
| 10384 | "BIND" | 10529 | "BIND" |
| @@ -10482,7 +10627,7 @@ At all other locations, this simply calls the value of | |||
| 10482 | (let* ((a nil) | 10627 | (let* ((a nil) |
| 10483 | (end (point)) | 10628 | (end (point)) |
| 10484 | (beg1 (save-excursion | 10629 | (beg1 (save-excursion |
| 10485 | (skip-chars-backward (org-re "[:alnum:]_@")) | 10630 | (skip-chars-backward (org-re "[:alnum:]_@#%")) |
| 10486 | (point))) | 10631 | (point))) |
| 10487 | (beg (save-excursion | 10632 | (beg (save-excursion |
| 10488 | (skip-chars-backward "a-zA-Z0-9_:$") | 10633 | (skip-chars-backward "a-zA-Z0-9_:$") |
| @@ -10497,8 +10642,10 @@ At all other locations, this simply calls the value of | |||
| 10497 | (throw 'exit t))) | 10642 | (throw 'exit t))) |
| 10498 | (tag (and (equal (char-before beg1) ?:) | 10643 | (tag (and (equal (char-before beg1) ?:) |
| 10499 | (equal (char-after (point-at-bol)) ?*))) | 10644 | (equal (char-after (point-at-bol)) ?*))) |
| 10500 | (prop (and (equal (char-before beg1) ?:) | 10645 | (prop (or (and (equal (char-before beg1) ?:) |
| 10501 | (not (equal (char-after (point-at-bol)) ?*)))) | 10646 | (not (equal (char-after (point-at-bol)) ?*))) |
| 10647 | (string-match "^#\\+PROPERTY:.*" | ||
| 10648 | (buffer-substring (point-at-bol) (point))))) | ||
| 10502 | (texp (equal (char-before beg) ?\\)) | 10649 | (texp (equal (char-before beg) ?\\)) |
| 10503 | (link (equal (char-before beg) ?\[)) | 10650 | (link (equal (char-before beg) ?\[)) |
| 10504 | (opt (equal (buffer-substring (max (point-at-bol) (- beg 2)) | 10651 | (opt (equal (buffer-substring (max (point-at-bol) (- beg 2)) |
| @@ -10575,7 +10722,10 @@ At all other locations, this simply calls the value of | |||
| 10575 | (delete-window (get-buffer-window "*Completions*"))) | 10722 | (delete-window (get-buffer-window "*Completions*"))) |
| 10576 | (if (assoc completion table) | 10723 | (if (assoc completion table) |
| 10577 | (if (eq type :todo) (insert " ") | 10724 | (if (eq type :todo) (insert " ") |
| 10578 | (if (memq type '(:tag :prop)) (insert ":")))) | 10725 | (if (and (memq type '(:tag :prop)) |
| 10726 | (not (string-match "^#[ \t]*\\+property:" | ||
| 10727 | (org-current-line-string t)))) | ||
| 10728 | (insert ":")))) | ||
| 10579 | (if (and (equal type :opt) (assoc completion table)) | 10729 | (if (and (equal type :opt) (assoc completion table)) |
| 10580 | (message "%s" (substitute-command-keys | 10730 | (message "%s" (substitute-command-keys |
| 10581 | "Press \\[org-complete] again to insert example settings")))) | 10731 | "Press \\[org-complete] again to insert example settings")))) |
| @@ -10613,27 +10763,6 @@ this is nil.") | |||
| 10613 | 10763 | ||
| 10614 | (defvar org-setting-tags nil) ; dynamically skipped | 10764 | (defvar org-setting-tags nil) ; dynamically skipped |
| 10615 | 10765 | ||
| 10616 | (defun org-parse-local-options (string var) | ||
| 10617 | "Parse STRING for startup setting relevant for variable VAR." | ||
| 10618 | (let ((rtn (symbol-value var)) | ||
| 10619 | e opts) | ||
| 10620 | (save-match-data | ||
| 10621 | (if (or (not string) (not (string-match "\\S-" string))) | ||
| 10622 | rtn | ||
| 10623 | (setq opts (delq nil (mapcar (lambda (x) | ||
| 10624 | (setq e (assoc x org-startup-options)) | ||
| 10625 | (if (eq (nth 1 e) var) e nil)) | ||
| 10626 | (org-split-string string "[ \t]+")))) | ||
| 10627 | (if (not opts) | ||
| 10628 | rtn | ||
| 10629 | (setq rtn nil) | ||
| 10630 | (while (setq e (pop opts)) | ||
| 10631 | (if (not (nth 3 e)) | ||
| 10632 | (setq rtn (nth 2 e)) | ||
| 10633 | (if (not (listp rtn)) (setq rtn nil)) | ||
| 10634 | (push (nth 2 e) rtn))) | ||
| 10635 | rtn))))) | ||
| 10636 | |||
| 10637 | (defvar org-todo-setup-filter-hook nil | 10766 | (defvar org-todo-setup-filter-hook nil |
| 10638 | "Hook for functions that pre-filter todo specs. | 10767 | "Hook for functions that pre-filter todo specs. |
| 10639 | Each function takes a todo spec and returns either nil or the spec | 10768 | Each function takes a todo spec and returns either nil or the spec |
| @@ -11313,7 +11442,6 @@ This function is run automatically after each state change to a DONE state." | |||
| 11313 | (msg "Entry repeats: ") | 11442 | (msg "Entry repeats: ") |
| 11314 | (org-log-done nil) | 11443 | (org-log-done nil) |
| 11315 | (org-todo-log-states nil) | 11444 | (org-todo-log-states nil) |
| 11316 | (nshiftmax 10) (nshift 0) | ||
| 11317 | re type n what ts time to-state) | 11445 | re type n what ts time to-state) |
| 11318 | (when repeat | 11446 | (when repeat |
| 11319 | (if (eq org-log-repeat t) (setq org-log-repeat 'state)) | 11447 | (if (eq org-log-repeat t) (setq org-log-repeat 'state)) |
| @@ -11360,15 +11488,17 @@ This function is run automatically after each state change to a DONE state." | |||
| 11360 | (- (time-to-days (current-time)) (time-to-days time)) | 11488 | (- (time-to-days (current-time)) (time-to-days time)) |
| 11361 | 'day)) | 11489 | 'day)) |
| 11362 | ((equal (match-string 1 ts) "+") | 11490 | ((equal (match-string 1 ts) "+") |
| 11363 | (while (or (= nshift 0) | 11491 | (let ((nshiftmax 10) (nshift 0)) |
| 11364 | (<= (time-to-days time) (time-to-days (current-time)))) | 11492 | (while (or (= nshift 0) |
| 11365 | (when (= (incf nshift) nshiftmax) | 11493 | (<= (time-to-days time) |
| 11366 | (or (y-or-n-p (message "%d repeater intervals were not enough to shift date past today. Continue? " nshift)) | 11494 | (time-to-days (current-time)))) |
| 11367 | (error "Abort"))) | 11495 | (when (= (incf nshift) nshiftmax) |
| 11368 | (org-timestamp-change n (cdr (assoc what whata))) | 11496 | (or (y-or-n-p (message "%d repeater intervals were not enough to shift date past today. Continue? " nshift)) |
| 11369 | (org-at-timestamp-p t) | 11497 | (error "Abort"))) |
| 11370 | (setq ts (match-string 1)) | 11498 | (org-timestamp-change n (cdr (assoc what whata))) |
| 11371 | (setq time (save-match-data (org-time-string-to-time ts)))) | 11499 | (org-at-timestamp-p t) |
| 11500 | (setq ts (match-string 1)) | ||
| 11501 | (setq time (save-match-data (org-time-string-to-time ts))))) | ||
| 11372 | (org-timestamp-change (- n) (cdr (assoc what whata))) | 11502 | (org-timestamp-change (- n) (cdr (assoc what whata))) |
| 11373 | ;; rematch, so that we have everything in place for the real shift | 11503 | ;; rematch, so that we have everything in place for the real shift |
| 11374 | (org-at-timestamp-p t) | 11504 | (org-at-timestamp-p t) |
| @@ -11631,7 +11761,7 @@ This is done in the same way as adding a state change note." | |||
| 11631 | 11761 | ||
| 11632 | (defvar org-property-end-re) | 11762 | (defvar org-property-end-re) |
| 11633 | (defun org-add-log-setup (&optional purpose state prev-state | 11763 | (defun org-add-log-setup (&optional purpose state prev-state |
| 11634 | findpos how &optional extra) | 11764 | findpos how extra) |
| 11635 | "Set up the post command hook to take a note. | 11765 | "Set up the post command hook to take a note. |
| 11636 | If this is about to TODO state change, the new state is expected in STATE. | 11766 | If this is about to TODO state change, the new state is expected in STATE. |
| 11637 | When FINDPOS is non-nil, find the correct position for the note in | 11767 | When FINDPOS is non-nil, find the correct position for the note in |
| @@ -11692,10 +11822,11 @@ EXTRA is additional text that will be inserted into the notes buffer." | |||
| 11692 | (defun org-skip-over-state-notes () | 11822 | (defun org-skip-over-state-notes () |
| 11693 | "Skip past the list of State notes in an entry." | 11823 | "Skip past the list of State notes in an entry." |
| 11694 | (if (looking-at "\n[ \t]*- State") (forward-char 1)) | 11824 | (if (looking-at "\n[ \t]*- State") (forward-char 1)) |
| 11695 | (while (looking-at "[ \t]*- State") | 11825 | (when (org-in-item-p) |
| 11696 | (condition-case nil | 11826 | (let ((limit (org-list-bottom-point))) |
| 11697 | (org-next-item) | 11827 | (while (looking-at "[ \t]*- State") |
| 11698 | (error (org-end-of-item))))) | 11828 | (goto-char (or (org-get-next-item (point) limit) |
| 11829 | (org-get-end-of-item limit))))))) | ||
| 11699 | 11830 | ||
| 11700 | (defun org-add-log-note (&optional purpose) | 11831 | (defun org-add-log-note (&optional purpose) |
| 11701 | "Pop up a window for taking a note, and add this note later at point." | 11832 | "Pop up a window for taking a note, and add this note later at point." |
| @@ -11740,7 +11871,7 @@ EXTRA is additional text that will be inserted into the notes buffer." | |||
| 11740 | "Finish taking a log note, and insert it to where it belongs." | 11871 | "Finish taking a log note, and insert it to where it belongs." |
| 11741 | (let ((txt (buffer-string)) | 11872 | (let ((txt (buffer-string)) |
| 11742 | (note (cdr (assq org-log-note-purpose org-log-note-headings))) | 11873 | (note (cdr (assq org-log-note-purpose org-log-note-headings))) |
| 11743 | lines ind) | 11874 | lines ind bul) |
| 11744 | (kill-buffer (current-buffer)) | 11875 | (kill-buffer (current-buffer)) |
| 11745 | (while (string-match "\\`#.*\n[ \t\n]*" txt) | 11876 | (while (string-match "\\`#.*\n[ \t\n]*" txt) |
| 11746 | (setq txt (replace-match "" t t txt))) | 11877 | (setq txt (replace-match "" t t txt))) |
| @@ -11780,13 +11911,26 @@ EXTRA is additional text that will be inserted into the notes buffer." | |||
| 11780 | (move-marker org-log-note-marker nil) | 11911 | (move-marker org-log-note-marker nil) |
| 11781 | (end-of-line 1) | 11912 | (end-of-line 1) |
| 11782 | (if (not (bolp)) (let ((inhibit-read-only t)) (insert "\n"))) | 11913 | (if (not (bolp)) (let ((inhibit-read-only t)) (insert "\n"))) |
| 11783 | (insert "- " (pop lines)) | 11914 | (setq ind (save-excursion |
| 11784 | (org-indent-line-function) | 11915 | (if (org-in-item-p) |
| 11785 | (beginning-of-line 1) | 11916 | (progn |
| 11786 | (looking-at "[ \t]*") | 11917 | (goto-char (org-list-top-point)) |
| 11787 | (setq ind (concat (match-string 0) " ")) | 11918 | (org-get-indentation)) |
| 11788 | (end-of-line 1) | 11919 | (skip-chars-backward " \r\t\n") |
| 11789 | (while lines (insert "\n" ind (pop lines))) | 11920 | (cond |
| 11921 | ((and (org-at-heading-p) | ||
| 11922 | org-adapt-indentation) | ||
| 11923 | (1+ (org-current-level))) | ||
| 11924 | ((org-at-heading-p) 0) | ||
| 11925 | (t (org-get-indentation)))))) | ||
| 11926 | (setq bul (org-list-bullet-string "-")) | ||
| 11927 | (org-indent-line-to ind) | ||
| 11928 | (insert bul (pop lines)) | ||
| 11929 | (let ((ind-body (+ (length bul) ind))) | ||
| 11930 | (while lines | ||
| 11931 | (insert "\n") | ||
| 11932 | (org-indent-line-to ind-body) | ||
| 11933 | (insert (pop lines)))) | ||
| 11790 | (message "Note stored") | 11934 | (message "Note stored") |
| 11791 | (org-back-to-heading t) | 11935 | (org-back-to-heading t) |
| 11792 | (org-cycle-hide-drawers 'children))))) | 11936 | (org-cycle-hide-drawers 'children))))) |
| @@ -12024,7 +12168,8 @@ ACTION can be `set', `up', `down', or a character." | |||
| 12024 | (setq new action) | 12168 | (setq new action) |
| 12025 | (message "Priority %c-%c, SPC to remove: " | 12169 | (message "Priority %c-%c, SPC to remove: " |
| 12026 | org-highest-priority org-lowest-priority) | 12170 | org-highest-priority org-lowest-priority) |
| 12027 | (setq new (read-char-exclusive))) | 12171 | (save-match-data |
| 12172 | (setq new (read-char-exclusive)))) | ||
| 12028 | (if (and (= (upcase org-highest-priority) org-highest-priority) | 12173 | (if (and (= (upcase org-highest-priority) org-highest-priority) |
| 12029 | (= (upcase org-lowest-priority) org-lowest-priority)) | 12174 | (= (upcase org-lowest-priority) org-lowest-priority)) |
| 12030 | (setq new (upcase new))) | 12175 | (setq new (upcase new))) |
| @@ -12109,7 +12254,7 @@ only lines with a TODO keyword are included in the output." | |||
| 12109 | (let* ((re (concat "^" outline-regexp " *\\(\\<\\(" | 12254 | (let* ((re (concat "^" outline-regexp " *\\(\\<\\(" |
| 12110 | (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") | 12255 | (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") |
| 12111 | (org-re | 12256 | (org-re |
| 12112 | "\\>\\)\\)? *\\(.*?\\)\\(:[[:alnum:]_@:]+:\\)?[ \t]*$"))) | 12257 | "\\>\\)\\)? *\\(.*?\\)\\(:[[:alnum:]_@#%:]+:\\)?[ \t]*$"))) |
| 12113 | (props (list 'face 'default | 12258 | (props (list 'face 'default |
| 12114 | 'done-face 'org-agenda-done | 12259 | 'done-face 'org-agenda-done |
| 12115 | 'undone-face 'default | 12260 | 'undone-face 'default |
| @@ -12309,7 +12454,7 @@ also TODO lines." | |||
| 12309 | 12454 | ||
| 12310 | ;; Parse the string and create a lisp form | 12455 | ;; Parse the string and create a lisp form |
| 12311 | (let ((match0 match) | 12456 | (let ((match0 match) |
| 12312 | (re (org-re "^&?\\([-+:]\\)?\\({[^}]+}\\|LEVEL\\([<=>]\\{1,2\\}\\)\\([0-9]+\\)\\|\\([[:alnum:]_]+\\)\\([<>=]\\{1,2\\}\\)\\({[^}]+}\\|\"[^\"]*\"\\|-?[.0-9]+\\(?:[eE][-+]?[0-9]+\\)?\\)\\|[[:alnum:]_@]+\\)")) | 12457 | (re (org-re "^&?\\([-+:]\\)?\\({[^}]+}\\|LEVEL\\([<=>]\\{1,2\\}\\)\\([0-9]+\\)\\|\\(\\(?:[[:alnum:]_]+\\(?:\\\\-\\)*\\)+\\)\\([<>=]\\{1,2\\}\\)\\({[^}]+}\\|\"[^\"]*\"\\|-?[.0-9]+\\(?:[eE][-+]?[0-9]+\\)?\\)\\|[[:alnum:]_@#%]+\\)")) |
| 12313 | minus tag mm | 12458 | minus tag mm |
| 12314 | tagsmatch todomatch tagsmatcher todomatcher kwd matcher | 12459 | tagsmatch todomatch tagsmatcher todomatcher kwd matcher |
| 12315 | orterms term orlist re-p str-p level-p level-op time-p | 12460 | orterms term orlist re-p str-p level-p level-op time-p |
| @@ -12337,7 +12482,9 @@ also TODO lines." | |||
| 12337 | (setq rest (substring term (match-end 0)) | 12482 | (setq rest (substring term (match-end 0)) |
| 12338 | minus (and (match-end 1) | 12483 | minus (and (match-end 1) |
| 12339 | (equal (match-string 1 term) "-")) | 12484 | (equal (match-string 1 term) "-")) |
| 12340 | tag (match-string 2 term) | 12485 | tag (save-match-data (replace-regexp-in-string |
| 12486 | "\\\\-" "-" | ||
| 12487 | (match-string 2 term))) | ||
| 12341 | re-p (equal (string-to-char tag) ?{) | 12488 | re-p (equal (string-to-char tag) ?{) |
| 12342 | level-p (match-end 4) | 12489 | level-p (match-end 4) |
| 12343 | prop-p (match-end 5) | 12490 | prop-p (match-end 5) |
| @@ -12516,7 +12663,7 @@ ignore inherited ones." | |||
| 12516 | (while (not (equal lastpos (point))) | 12663 | (while (not (equal lastpos (point))) |
| 12517 | (setq lastpos (point)) | 12664 | (setq lastpos (point)) |
| 12518 | (when (looking-at | 12665 | (when (looking-at |
| 12519 | (org-re "[^\r\n]+?:\\([[:alnum:]_@:]+\\):[ \t]*$")) | 12666 | (org-re "[^\r\n]+?:\\([[:alnum:]_@#%:]+\\):[ \t]*$")) |
| 12520 | (setq ltags (org-split-string | 12667 | (setq ltags (org-split-string |
| 12521 | (org-match-string-no-properties 1) ":")) | 12668 | (org-match-string-no-properties 1) ":")) |
| 12522 | (when parent | 12669 | (when parent |
| @@ -12543,7 +12690,7 @@ If ONOFF is `on' or `off', don't toggle but set to this state." | |||
| 12543 | (let (res current) | 12690 | (let (res current) |
| 12544 | (save-excursion | 12691 | (save-excursion |
| 12545 | (org-back-to-heading t) | 12692 | (org-back-to-heading t) |
| 12546 | (if (re-search-forward (org-re "[ \t]:\\([[:alnum:]_@:]+\\):[ \t]*$") | 12693 | (if (re-search-forward (org-re "[ \t]:\\([[:alnum:]_@#%:]+\\):[ \t]*$") |
| 12547 | (point-at-eol) t) | 12694 | (point-at-eol) t) |
| 12548 | (progn | 12695 | (progn |
| 12549 | (setq current (match-string 1)) | 12696 | (setq current (match-string 1)) |
| @@ -12573,7 +12720,7 @@ If ONOFF is `on' or `off', don't toggle but set to this state." | |||
| 12573 | ;; Assumes that this is a headline | 12720 | ;; Assumes that this is a headline |
| 12574 | (let ((pos (point)) (col (current-column)) ncol tags-l p) | 12721 | (let ((pos (point)) (col (current-column)) ncol tags-l p) |
| 12575 | (beginning-of-line 1) | 12722 | (beginning-of-line 1) |
| 12576 | (if (and (looking-at (org-re ".*?\\([ \t]+\\)\\(:[[:alnum:]_@:]+:\\)[ \t]*$")) | 12723 | (if (and (looking-at (org-re ".*?\\([ \t]+\\)\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$")) |
| 12577 | (< pos (match-beginning 2))) | 12724 | (< pos (match-beginning 2))) |
| 12578 | (progn | 12725 | (progn |
| 12579 | (setq tags-l (- (match-end 2) (match-beginning 2))) | 12726 | (setq tags-l (- (match-end 2) (match-beginning 2))) |
| @@ -12643,6 +12790,7 @@ If DATA is nil or the empty string, any tags will be removed." | |||
| 12643 | (org-set-tags t) | 12790 | (org-set-tags t) |
| 12644 | (message "No headings")))) | 12791 | (message "No headings")))) |
| 12645 | 12792 | ||
| 12793 | (defvar org-indent-indentation-per-level) | ||
| 12646 | (defun org-set-tags (&optional arg just-align) | 12794 | (defun org-set-tags (&optional arg just-align) |
| 12647 | "Set the tags for the current headline. | 12795 | "Set the tags for the current headline. |
| 12648 | With prefix ARG, realign all tags in headings in the current buffer." | 12796 | With prefix ARG, realign all tags in headings in the current buffer." |
| @@ -12652,7 +12800,7 @@ With prefix ARG, realign all tags in headings in the current buffer." | |||
| 12652 | (col (current-column)) | 12800 | (col (current-column)) |
| 12653 | (org-setting-tags t) | 12801 | (org-setting-tags t) |
| 12654 | table current-tags inherited-tags ; computed below when needed | 12802 | table current-tags inherited-tags ; computed below when needed |
| 12655 | tags p0 c0 c1 rpl) | 12803 | tags p0 c0 c1 rpl di tc level) |
| 12656 | (if arg | 12804 | (if arg |
| 12657 | (save-excursion | 12805 | (save-excursion |
| 12658 | (goto-char (point-min)) | 12806 | (goto-char (point-min)) |
| @@ -12667,8 +12815,10 @@ With prefix ARG, realign all tags in headings in the current buffer." | |||
| 12667 | (save-excursion | 12815 | (save-excursion |
| 12668 | (setq table (append org-tag-persistent-alist | 12816 | (setq table (append org-tag-persistent-alist |
| 12669 | (or org-tag-alist (org-get-buffer-tags)) | 12817 | (or org-tag-alist (org-get-buffer-tags)) |
| 12670 | (and org-complete-tags-always-offer-all-agenda-tags | 12818 | (and |
| 12671 | (org-global-tags-completion-table (org-agenda-files)))) | 12819 | org-complete-tags-always-offer-all-agenda-tags |
| 12820 | (org-global-tags-completion-table | ||
| 12821 | (org-agenda-files)))) | ||
| 12672 | org-last-tags-completion-table table | 12822 | org-last-tags-completion-table table |
| 12673 | current-tags (org-split-string current ":") | 12823 | current-tags (org-split-string current ":") |
| 12674 | inherited-tags (nreverse | 12824 | inherited-tags (nreverse |
| @@ -12680,19 +12830,24 @@ With prefix ARG, realign all tags in headings in the current buffer." | |||
| 12680 | (delq nil (mapcar 'cdr table)))) | 12830 | (delq nil (mapcar 'cdr table)))) |
| 12681 | (org-fast-tag-selection | 12831 | (org-fast-tag-selection |
| 12682 | current-tags inherited-tags table | 12832 | current-tags inherited-tags table |
| 12683 | (if org-fast-tag-selection-include-todo org-todo-key-alist)) | 12833 | (if org-fast-tag-selection-include-todo |
| 12834 | org-todo-key-alist)) | ||
| 12684 | (let ((org-add-colon-after-tag-completion t)) | 12835 | (let ((org-add-colon-after-tag-completion t)) |
| 12685 | (org-trim | 12836 | (org-trim |
| 12686 | (org-without-partial-completion | 12837 | (org-without-partial-completion |
| 12687 | (org-icompleting-read "Tags: " 'org-tags-completion-function | 12838 | (org-icompleting-read "Tags: " |
| 12839 | 'org-tags-completion-function | ||
| 12688 | nil nil current 'org-tags-history))))))) | 12840 | nil nil current 'org-tags-history))))))) |
| 12689 | (while (string-match "[-+&]+" tags) | 12841 | (while (string-match "[-+&]+" tags) |
| 12690 | ;; No boolean logic, just a list | 12842 | ;; No boolean logic, just a list |
| 12691 | (setq tags (replace-match ":" t t tags)))) | 12843 | (setq tags (replace-match ":" t t tags)))) |
| 12692 | 12844 | ||
| 12845 | (setq tags (replace-regexp-in-string "[ ,]" ":" tags)) | ||
| 12846 | |||
| 12693 | (if org-tags-sort-function | 12847 | (if org-tags-sort-function |
| 12694 | (setq tags (mapconcat 'identity | 12848 | (setq tags (mapconcat 'identity |
| 12695 | (sort (org-split-string tags (org-re "[^[:alnum:]_@]+")) | 12849 | (sort (org-split-string |
| 12850 | tags (org-re "[^[:alnum:]_@#%]+")) | ||
| 12696 | org-tags-sort-function) ":"))) | 12851 | org-tags-sort-function) ":"))) |
| 12697 | 12852 | ||
| 12698 | (if (string-match "\\`[\t ]*\\'" tags) | 12853 | (if (string-match "\\`[\t ]*\\'" tags) |
| @@ -12702,6 +12857,9 @@ With prefix ARG, realign all tags in headings in the current buffer." | |||
| 12702 | 12857 | ||
| 12703 | ;; Insert new tags at the correct column | 12858 | ;; Insert new tags at the correct column |
| 12704 | (beginning-of-line 1) | 12859 | (beginning-of-line 1) |
| 12860 | (setq level (or (and (looking-at org-outline-regexp) | ||
| 12861 | (- (match-end 0) (point) 1)) | ||
| 12862 | 1)) | ||
| 12705 | (cond | 12863 | (cond |
| 12706 | ((and (equal current "") (equal tags ""))) | 12864 | ((and (equal current "") (equal tags ""))) |
| 12707 | ((re-search-forward | 12865 | ((re-search-forward |
| @@ -12710,11 +12868,14 @@ With prefix ARG, realign all tags in headings in the current buffer." | |||
| 12710 | (if (equal tags "") | 12868 | (if (equal tags "") |
| 12711 | (setq rpl "") | 12869 | (setq rpl "") |
| 12712 | (goto-char (match-beginning 0)) | 12870 | (goto-char (match-beginning 0)) |
| 12713 | (setq c0 (current-column) p0 (if (equal (char-before) ?*) | 12871 | (setq c0 (current-column) |
| 12714 | (1+ (point)) (point)) | 12872 | ;; compute offset for the case of org-indent-mode active |
| 12715 | c1 (max (1+ c0) (if (> org-tags-column 0) | 12873 | di (if org-indent-mode |
| 12716 | org-tags-column | 12874 | (* (1- org-indent-indentation-per-level) (1- level)) |
| 12717 | (- (- org-tags-column) (length tags)))) | 12875 | 0) |
| 12876 | p0 (if (equal (char-before) ?*) (1+ (point)) (point)) | ||
| 12877 | tc (+ org-tags-column (if (> org-tags-column 0) (- di) di)) | ||
| 12878 | c1 (max (1+ c0) (if (> tc 0) tc (- (- tc) (length tags)))) | ||
| 12718 | rpl (concat (make-string (max 0 (- c1 c0)) ?\ ) tags))) | 12879 | rpl (concat (make-string (max 0 (- c1 c0)) ?\ ) tags))) |
| 12719 | (replace-match rpl t t) | 12880 | (replace-match rpl t t) |
| 12720 | (and (not (featurep 'xemacs)) c0 indent-tabs-mode (tabify p0 (point))) | 12881 | (and (not (featurep 'xemacs)) c0 indent-tabs-mode (tabify p0 (point))) |
| @@ -12766,7 +12927,7 @@ This works in the agenda, and also in an org-mode buffer." | |||
| 12766 | (defun org-tags-completion-function (string predicate &optional flag) | 12927 | (defun org-tags-completion-function (string predicate &optional flag) |
| 12767 | (let (s1 s2 rtn (ctable org-last-tags-completion-table) | 12928 | (let (s1 s2 rtn (ctable org-last-tags-completion-table) |
| 12768 | (confirm (lambda (x) (stringp (car x))))) | 12929 | (confirm (lambda (x) (stringp (car x))))) |
| 12769 | (if (string-match "^\\(.*[-+:&|]\\)\\([^-+:&|]*\\)$" string) | 12930 | (if (string-match "^\\(.*[-+:&,|]\\)\\([^-+:&,|]*\\)$" string) |
| 12770 | (setq s1 (match-string 1 string) | 12931 | (setq s1 (match-string 1 string) |
| 12771 | s2 (match-string 2 string)) | 12932 | s2 (match-string 2 string)) |
| 12772 | (setq s1 "" s2 string)) | 12933 | (setq s1 "" s2 string)) |
| @@ -12843,7 +13004,7 @@ Returns the new tags string, or nil to not change the current settings." | |||
| 12843 | (save-excursion | 13004 | (save-excursion |
| 12844 | (beginning-of-line 1) | 13005 | (beginning-of-line 1) |
| 12845 | (if (looking-at | 13006 | (if (looking-at |
| 12846 | (org-re ".*[ \t]\\(:[[:alnum:]_@:]+:\\)[ \t]*$")) | 13007 | (org-re ".*[ \t]\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$")) |
| 12847 | (setq ov-start (match-beginning 1) | 13008 | (setq ov-start (match-beginning 1) |
| 12848 | ov-end (match-end 1) | 13009 | ov-end (match-end 1) |
| 12849 | ov-prefix "") | 13010 | ov-prefix "") |
| @@ -12993,7 +13154,7 @@ Returns the new tags string, or nil to not change the current settings." | |||
| 12993 | (org-fast-tag-insert "Current" current c-face) | 13154 | (org-fast-tag-insert "Current" current c-face) |
| 12994 | (org-set-current-tags-overlay current ov-prefix) | 13155 | (org-set-current-tags-overlay current ov-prefix) |
| 12995 | (while (re-search-forward | 13156 | (while (re-search-forward |
| 12996 | (org-re "\\[.\\] \\([[:alnum:]_@]+\\)") nil t) | 13157 | (org-re "\\[.\\] \\([[:alnum:]_@#%]+\\)") nil t) |
| 12997 | (setq tg (match-string 1)) | 13158 | (setq tg (match-string 1)) |
| 12998 | (add-text-properties | 13159 | (add-text-properties |
| 12999 | (match-beginning 1) (match-end 1) | 13160 | (match-beginning 1) (match-end 1) |
| @@ -13014,7 +13175,7 @@ Returns the new tags string, or nil to not change the current settings." | |||
| 13014 | (error "Not on a heading")) | 13175 | (error "Not on a heading")) |
| 13015 | (save-excursion | 13176 | (save-excursion |
| 13016 | (beginning-of-line 1) | 13177 | (beginning-of-line 1) |
| 13017 | (if (looking-at (org-re ".*[ \t]\\(:[[:alnum:]_@:]+:\\)[ \t]*$")) | 13178 | (if (looking-at (org-re ".*[ \t]\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$")) |
| 13018 | (org-match-string-no-properties 1) | 13179 | (org-match-string-no-properties 1) |
| 13019 | ""))) | 13180 | ""))) |
| 13020 | 13181 | ||
| @@ -13028,7 +13189,7 @@ Returns the new tags string, or nil to not change the current settings." | |||
| 13028 | (save-excursion | 13189 | (save-excursion |
| 13029 | (goto-char (point-min)) | 13190 | (goto-char (point-min)) |
| 13030 | (while (re-search-forward | 13191 | (while (re-search-forward |
| 13031 | (org-re "[ \t]:\\([[:alnum:]_@:]+\\):[ \t\r\n]") nil t) | 13192 | (org-re "[ \t]:\\([[:alnum:]_@#%:]+\\):[ \t\r\n]") nil t) |
| 13032 | (when (equal (char-after (point-at-bol 0)) ?*) | 13193 | (when (equal (char-after (point-at-bol 0)) ?*) |
| 13033 | (mapc (lambda (x) (add-to-list 'tags x)) | 13194 | (mapc (lambda (x) (add-to-list 'tags x)) |
| 13034 | (org-split-string (org-match-string-no-properties 1) ":"))))) | 13195 | (org-split-string (org-match-string-no-properties 1) ":"))))) |
| @@ -13899,6 +14060,42 @@ only headings." | |||
| 13899 | (when (org-on-heading-p) | 14060 | (when (org-on-heading-p) |
| 13900 | (move-marker (make-marker) (point)))))))) | 14061 | (move-marker (make-marker) (point)))))))) |
| 13901 | 14062 | ||
| 14063 | (defun org-find-exact-headline-in-buffer (heading &optional buffer pos-only) | ||
| 14064 | "Find node HEADING in BUFFER. | ||
| 14065 | Return a marker to the heading if it was found, or nil if not. | ||
| 14066 | If POS-ONLY is set, return just the position instead of a marker. | ||
| 14067 | |||
| 14068 | The heading text must match exact, but it may have a TODO keyword, | ||
| 14069 | a priority cookie and tags in the standard locations." | ||
| 14070 | (with-current-buffer (or buffer (current-buffer)) | ||
| 14071 | (save-excursion | ||
| 14072 | (save-restriction | ||
| 14073 | (widen) | ||
| 14074 | (goto-char (point-min)) | ||
| 14075 | (let (case-fold-search) | ||
| 14076 | (if (re-search-forward | ||
| 14077 | (format org-complex-heading-regexp-format | ||
| 14078 | (regexp-quote heading)) nil t) | ||
| 14079 | (if pos-only | ||
| 14080 | (match-beginning 0) | ||
| 14081 | (move-marker (make-marker) (match-beginning 0))))))))) | ||
| 14082 | |||
| 14083 | (defun org-find-exact-heading-in-directory (heading &optional dir) | ||
| 14084 | "Find Org node headline HEADING in all .org files in directory DIR. | ||
| 14085 | When the target headline is found, return a marker to this location." | ||
| 14086 | (let ((files (directory-files (or dir default-directory) | ||
| 14087 | nil "\\`[^.#].*\\.org\\'")) | ||
| 14088 | file visiting m buffer) | ||
| 14089 | (catch 'found | ||
| 14090 | (while (setq file (pop files)) | ||
| 14091 | (message "trying %s" file) | ||
| 14092 | (setq visiting (org-find-base-buffer-visiting file)) | ||
| 14093 | (setq buffer (or visiting (find-file-noselect file))) | ||
| 14094 | (setq m (org-find-exact-headline-in-buffer | ||
| 14095 | heading buffer)) | ||
| 14096 | (when (and (not m) (not visiting)) (kill-buffer buffer)) | ||
| 14097 | (and m (throw 'found m)))))) | ||
| 14098 | |||
| 13902 | (defun org-find-entry-with-id (ident) | 14099 | (defun org-find-entry-with-id (ident) |
| 13903 | "Locate the entry that contains the ID property with exact value IDENT. | 14100 | "Locate the entry that contains the ID property with exact value IDENT. |
| 13904 | IDENT can be a string, a symbol or a number, this function will search for | 14101 | IDENT can be a string, a symbol or a number, this function will search for |
| @@ -14190,6 +14387,10 @@ user." | |||
| 14190 | (setq org-read-date-overlay nil))))) | 14387 | (setq org-read-date-overlay nil))))) |
| 14191 | 14388 | ||
| 14192 | (setq final (org-read-date-analyze ans def defdecode)) | 14389 | (setq final (org-read-date-analyze ans def defdecode)) |
| 14390 | |||
| 14391 | ;; One round trip to get rid of 34th of August and stuff like that.... | ||
| 14392 | (setq final (decode-time (apply 'encode-time final))) | ||
| 14393 | |||
| 14193 | (setq org-read-date-final-answer ans) | 14394 | (setq org-read-date-final-answer ans) |
| 14194 | 14395 | ||
| 14195 | (if to-time | 14396 | (if to-time |
| @@ -14457,9 +14658,10 @@ user function argument order change dependent on argument order." | |||
| 14457 | (list arg2 arg1 arg3)) | 14658 | (list arg2 arg1 arg3)) |
| 14458 | ((eq calendar-date-style 'iso) | 14659 | ((eq calendar-date-style 'iso) |
| 14459 | (list arg2 arg3 arg1))) | 14660 | (list arg2 arg3 arg1))) |
| 14460 | (if (org-bound-and-true-p european-calendar-style) | 14661 | (with-no-warnings ;; european-calendar-style is obsolete as of version 23.1 |
| 14461 | (list arg2 arg1 arg3) | 14662 | (if (org-bound-and-true-p european-calendar-style) |
| 14462 | (list arg1 arg2 arg3)))) | 14663 | (list arg2 arg1 arg3) |
| 14664 | (list arg1 arg2 arg3))))) | ||
| 14463 | 14665 | ||
| 14464 | (defun org-eval-in-calendar (form &optional keepdate) | 14666 | (defun org-eval-in-calendar (form &optional keepdate) |
| 14465 | "Eval FORM in the calendar window and return to current window. | 14667 | "Eval FORM in the calendar window and return to current window. |
| @@ -14498,7 +14700,6 @@ The command returns the inserted time stamp." | |||
| 14498 | stamp) | 14700 | stamp) |
| 14499 | (if inactive (setq fmt (concat "[" (substring fmt 1 -1) "]"))) | 14701 | (if inactive (setq fmt (concat "[" (substring fmt 1 -1) "]"))) |
| 14500 | (insert-before-markers (or pre "")) | 14702 | (insert-before-markers (or pre "")) |
| 14501 | (insert-before-markers (setq stamp (format-time-string fmt time))) | ||
| 14502 | (when (listp extra) | 14703 | (when (listp extra) |
| 14503 | (setq extra (car extra)) | 14704 | (setq extra (car extra)) |
| 14504 | (if (and (stringp extra) | 14705 | (if (and (stringp extra) |
| @@ -14508,9 +14709,8 @@ The command returns the inserted time stamp." | |||
| 14508 | (string-to-number (match-string 2 extra)))) | 14709 | (string-to-number (match-string 2 extra)))) |
| 14509 | (setq extra nil))) | 14710 | (setq extra nil))) |
| 14510 | (when extra | 14711 | (when extra |
| 14511 | (backward-char 1) | 14712 | (setq fmt (concat (substring fmt 0 -1) extra (substring fmt -1)))) |
| 14512 | (insert-before-markers extra) | 14713 | (insert-before-markers (setq stamp (format-time-string fmt time))) |
| 14513 | (forward-char 1)) | ||
| 14514 | (insert-before-markers (or post "")) | 14714 | (insert-before-markers (or post "")) |
| 14515 | (setq org-last-inserted-timestamp stamp))) | 14715 | (setq org-last-inserted-timestamp stamp))) |
| 14516 | 14716 | ||
| @@ -14827,7 +15027,10 @@ D may be an absolute day number, or a calendar-type list (month day year)." | |||
| 14827 | (sleep-for 2)))))) | 15027 | (sleep-for 2)))))) |
| 14828 | (cond ((stringp result) result) | 15028 | (cond ((stringp result) result) |
| 14829 | ((and (consp result) | 15029 | ((and (consp result) |
| 15030 | (not (consp (cdr result))) | ||
| 14830 | (stringp (cdr result))) (cdr result)) | 15031 | (stringp (cdr result))) (cdr result)) |
| 15032 | ((and (consp result) | ||
| 15033 | (stringp (car result))) result) | ||
| 14831 | (result entry) | 15034 | (result entry) |
| 14832 | (t nil)))) | 15035 | (t nil)))) |
| 14833 | 15036 | ||
| @@ -15747,7 +15950,7 @@ The images can be removed again with \\[org-ctrl-c-ctrl-c]." | |||
| 15747 | (concat "ltxpng/" (file-name-sans-extension | 15950 | (concat "ltxpng/" (file-name-sans-extension |
| 15748 | (file-name-nondirectory | 15951 | (file-name-nondirectory |
| 15749 | buffer-file-name))) | 15952 | buffer-file-name))) |
| 15750 | default-directory 'overlays msg at 'forbuffer) | 15953 | default-directory 'overlays msg at 'forbuffer 'dvipng) |
| 15751 | (message msg "done. Use `C-c C-c' to remove images."))))) | 15954 | (message msg "done. Use `C-c C-c' to remove images."))))) |
| 15752 | 15955 | ||
| 15753 | (defvar org-latex-regexps | 15956 | (defvar org-latex-regexps |
| @@ -15761,8 +15964,9 @@ The images can be removed again with \\[org-ctrl-c-ctrl-c]." | |||
| 15761 | ("$$" "\\$\\$[^\000]*?\\$\\$" 0 nil)) | 15964 | ("$$" "\\$\\$[^\000]*?\\$\\$" 0 nil)) |
| 15762 | "Regular expressions for matching embedded LaTeX.") | 15965 | "Regular expressions for matching embedded LaTeX.") |
| 15763 | 15966 | ||
| 15967 | (defvar org-export-have-math nil) ;; dynamic scoping | ||
| 15764 | (defun org-format-latex (prefix &optional dir overlays msg at | 15968 | (defun org-format-latex (prefix &optional dir overlays msg at |
| 15765 | forbuffer protect-only) | 15969 | forbuffer processing-type) |
| 15766 | "Replace LaTeX fragments with links to an image, and produce images. | 15970 | "Replace LaTeX fragments with links to an image, and produce images. |
| 15767 | Some of the options can be changed using the variable | 15971 | Some of the options can be changed using the variable |
| 15768 | `org-format-latex-options'." | 15972 | `org-format-latex-options'." |
| @@ -15776,7 +15980,7 @@ Some of the options can be changed using the variable | |||
| 15776 | (org-format-latex-header-extra | 15980 | (org-format-latex-header-extra |
| 15777 | (plist-get (org-infile-export-plist) :latex-header-extra)) | 15981 | (plist-get (org-infile-export-plist) :latex-header-extra)) |
| 15778 | (cnt 0) txt hash link beg end re e checkdir | 15982 | (cnt 0) txt hash link beg end re e checkdir |
| 15779 | executables-checked | 15983 | executables-checked string |
| 15780 | m n block linkfile movefile ov) | 15984 | m n block linkfile movefile ov) |
| 15781 | ;; Check the different regular expressions | 15985 | ;; Check the different regular expressions |
| 15782 | (while (setq e (pop re-list)) | 15986 | (while (setq e (pop re-list)) |
| @@ -15792,9 +15996,26 @@ Some of the options can be changed using the variable | |||
| 15792 | (not (eq (get-char-property (match-beginning n) | 15996 | (not (eq (get-char-property (match-beginning n) |
| 15793 | 'org-overlay-type) | 15997 | 'org-overlay-type) |
| 15794 | 'org-latex-overlay)))) | 15998 | 'org-latex-overlay)))) |
| 15795 | (if protect-only | 15999 | (setq org-export-have-math t) |
| 16000 | (cond | ||
| 16001 | ((eq processing-type 'verbatim) | ||
| 16002 | ;; Leave the text verbatim, just protect it | ||
| 16003 | (add-text-properties (match-beginning n) (match-end n) | ||
| 16004 | '(org-protected t))) | ||
| 16005 | ((eq processing-type 'mathjax) | ||
| 16006 | ;; Prepare for MathJax processing | ||
| 16007 | (setq string (match-string n)) | ||
| 16008 | (if (member m '("$" "$1")) | ||
| 16009 | (save-excursion | ||
| 16010 | (delete-region (match-beginning n) (match-end n)) | ||
| 16011 | (goto-char (match-beginning n)) | ||
| 16012 | (insert (org-add-props (concat "\\(" (substring string 1 -1) | ||
| 16013 | "\\)") | ||
| 16014 | '(org-protected t)))) | ||
| 15796 | (add-text-properties (match-beginning n) (match-end n) | 16015 | (add-text-properties (match-beginning n) (match-end n) |
| 15797 | '(org-protected t)) | 16016 | '(org-protected t)))) |
| 16017 | ((or (eq processing-type 'dvipng) t) | ||
| 16018 | ;; Process to an image | ||
| 15798 | (setq txt (match-string n) | 16019 | (setq txt (match-string n) |
| 15799 | beg (match-beginning n) end (match-end n) | 16020 | beg (match-beginning n) end (match-end n) |
| 15800 | cnt (1+ cnt)) | 16021 | cnt (1+ cnt)) |
| @@ -15813,15 +16034,15 @@ Some of the options can be changed using the variable | |||
| 15813 | (goto-char beg) | 16034 | (goto-char beg) |
| 15814 | (unless checkdir ; make sure the directory exists | 16035 | (unless checkdir ; make sure the directory exists |
| 15815 | (setq checkdir t) | 16036 | (setq checkdir t) |
| 15816 | (or (file-directory-p todir) (make-directory todir))) | 16037 | (or (file-directory-p todir) (make-directory todir t))) |
| 15817 | 16038 | ||
| 15818 | (unless executables-checked | 16039 | (unless executables-checked |
| 15819 | (org-check-external-command | 16040 | (org-check-external-command |
| 15820 | "latex" "needed to convert LaTeX fragments to images") | 16041 | "latex" "needed to convert LaTeX fragments to images") |
| 15821 | (org-check-external-command | 16042 | (org-check-external-command |
| 15822 | "dvipng" "needed to convert LaTeX fragments to images") | 16043 | "dvipng" "needed to convert LaTeX fragments to images") |
| 15823 | (setq executables-checked t)) | 16044 | (setq executables-checked t)) |
| 15824 | 16045 | ||
| 15825 | (unless (file-exists-p movefile) | 16046 | (unless (file-exists-p movefile) |
| 15826 | (org-create-formula-image | 16047 | (org-create-formula-image |
| 15827 | txt movefile opt forbuffer)) | 16048 | txt movefile opt forbuffer)) |
| @@ -15848,7 +16069,8 @@ Some of the options can be changed using the variable | |||
| 15848 | (delete-region beg end) | 16069 | (delete-region beg end) |
| 15849 | (insert (org-add-props link | 16070 | (insert (org-add-props link |
| 15850 | (list 'org-latex-src | 16071 | (list 'org-latex-src |
| 15851 | (replace-regexp-in-string "\"" "" txt)))))))))))) | 16072 | (replace-regexp-in-string |
| 16073 | "\"" "" txt))))))))))))) | ||
| 15852 | 16074 | ||
| 15853 | ;; This function borrows from Ganesh Swami's latex2png.el | 16075 | ;; This function borrows from Ganesh Swami's latex2png.el |
| 15854 | (defun org-create-formula-image (string tofile options buffer) | 16076 | (defun org-create-formula-image (string tofile options buffer) |
| @@ -16019,7 +16241,7 @@ BEG and END default to the buffer boundaries." | |||
| 16019 | (widen) | 16241 | (widen) |
| 16020 | (setq beg (or beg (point-min)) end (or end (point-max))) | 16242 | (setq beg (or beg (point-min)) end (or end (point-max))) |
| 16021 | (goto-char (point-min)) | 16243 | (goto-char (point-min)) |
| 16022 | (let ((re (concat "\\[\\[\\(\\(file:\\)\\|\\([./~]\\)\\)\\([-+~.:/\\_0-9a-zA-Z ]+" | 16244 | (let ((re (concat "\\[\\[\\(\\(file:\\)\\|\\([./~]\\)\\)\\([^]\n]+?" |
| 16023 | (substring (org-image-file-name-regexp) 0 -2) | 16245 | (substring (org-image-file-name-regexp) 0 -2) |
| 16024 | "\\)\\]" (if include-linked "" "\\]"))) | 16246 | "\\)\\]" (if include-linked "" "\\]"))) |
| 16025 | old file ov img) | 16247 | old file ov img) |
| @@ -16031,7 +16253,7 @@ BEG and END default to the buffer boundaries." | |||
| 16031 | (when (file-exists-p file) | 16253 | (when (file-exists-p file) |
| 16032 | (if (and (car-safe old) refresh) | 16254 | (if (and (car-safe old) refresh) |
| 16033 | (image-refresh (overlay-get (cdr old) 'display)) | 16255 | (image-refresh (overlay-get (cdr old) 'display)) |
| 16034 | (setq img (create-image file)) | 16256 | (setq img (save-match-data (create-image file))) |
| 16035 | (when img | 16257 | (when img |
| 16036 | (setq ov (make-overlay (match-beginning 0) (match-end 0))) | 16258 | (setq ov (make-overlay (match-beginning 0) (match-end 0))) |
| 16037 | (overlay-put ov 'display img) | 16259 | (overlay-put ov 'display img) |
| @@ -16236,10 +16458,12 @@ BEG and END default to the buffer boundaries." | |||
| 16236 | (org-defkey org-mode-map "\C-c\C-xo" 'org-toggle-ordered-property) | 16458 | (org-defkey org-mode-map "\C-c\C-xo" 'org-toggle-ordered-property) |
| 16237 | (org-defkey org-mode-map "\C-c\C-xi" 'org-insert-columns-dblock) | 16459 | (org-defkey org-mode-map "\C-c\C-xi" 'org-insert-columns-dblock) |
| 16238 | (org-defkey org-mode-map [(control ?c) (control ?x) ?\;] 'org-timer-set-timer) | 16460 | (org-defkey org-mode-map [(control ?c) (control ?x) ?\;] 'org-timer-set-timer) |
| 16461 | (org-defkey org-mode-map [(control ?c) (control ?x) ?\:] 'org-timer-cancel-timer) | ||
| 16239 | 16462 | ||
| 16240 | (org-defkey org-mode-map "\C-c\C-x." 'org-timer) | 16463 | (org-defkey org-mode-map "\C-c\C-x." 'org-timer) |
| 16241 | (org-defkey org-mode-map "\C-c\C-x-" 'org-timer-item) | 16464 | (org-defkey org-mode-map "\C-c\C-x-" 'org-timer-item) |
| 16242 | (org-defkey org-mode-map "\C-c\C-x0" 'org-timer-start) | 16465 | (org-defkey org-mode-map "\C-c\C-x0" 'org-timer-start) |
| 16466 | (org-defkey org-mode-map "\C-c\C-x_" 'org-timer-stop) | ||
| 16243 | (org-defkey org-mode-map "\C-c\C-x," 'org-timer-pause-or-continue) | 16467 | (org-defkey org-mode-map "\C-c\C-x," 'org-timer-pause-or-continue) |
| 16244 | 16468 | ||
| 16245 | (define-key org-mode-map "\C-c\C-x\C-c" 'org-columns) | 16469 | (define-key org-mode-map "\C-c\C-x\C-c" 'org-columns) |
| @@ -16300,6 +16524,8 @@ BEG and END default to the buffer boundaries." | |||
| 16300 | ("Misc") | 16524 | ("Misc") |
| 16301 | ("o" . org-open-at-point) | 16525 | ("o" . org-open-at-point) |
| 16302 | ("?" . org-speed-command-help) | 16526 | ("?" . org-speed-command-help) |
| 16527 | ("<" . (org-agenda-set-restriction-lock 'subtree)) | ||
| 16528 | (">" . (org-agenda-remove-restriction-lock)) | ||
| 16303 | ) | 16529 | ) |
| 16304 | "The default speed commands.") | 16530 | "The default speed commands.") |
| 16305 | 16531 | ||
| @@ -16346,6 +16572,40 @@ If not, return to the original position and throw an error." | |||
| 16346 | 16572 | ||
| 16347 | (defvar org-table-auto-blank-field) ; defined in org-table.el | 16573 | (defvar org-table-auto-blank-field) ; defined in org-table.el |
| 16348 | (defvar org-speed-command nil) | 16574 | (defvar org-speed-command nil) |
| 16575 | |||
| 16576 | (defun org-speed-command-default-hook (keys) | ||
| 16577 | "Hook for activating single-letter speed commands. | ||
| 16578 | `org-speed-commands-default' specifies a minimal command set. Use | ||
| 16579 | `org-speed-commands-user' for further customization." | ||
| 16580 | (when (or (and (bolp) (looking-at outline-regexp)) | ||
| 16581 | (and (functionp org-use-speed-commands) | ||
| 16582 | (funcall org-use-speed-commands))) | ||
| 16583 | (cdr (assoc keys (append org-speed-commands-user | ||
| 16584 | org-speed-commands-default))))) | ||
| 16585 | |||
| 16586 | (defun org-babel-speed-command-hook (keys) | ||
| 16587 | "Hook for activating single-letter code block commands." | ||
| 16588 | (when (and (bolp) (looking-at org-babel-src-block-regexp)) | ||
| 16589 | (cdr (assoc keys org-babel-key-bindings)))) | ||
| 16590 | |||
| 16591 | (defcustom org-speed-command-hook | ||
| 16592 | '(org-speed-command-default-hook org-babel-speed-command-hook) | ||
| 16593 | "Hook for activating speed commands at strategic locations. | ||
| 16594 | Hook functions are called in sequence until a valid handler is | ||
| 16595 | found. | ||
| 16596 | |||
| 16597 | Each hook takes a single argument, a user-pressed command key | ||
| 16598 | which is also a `self-insert-command' from the global map. | ||
| 16599 | |||
| 16600 | Within the hook, examine the cursor position and the command key | ||
| 16601 | and return nil or a valid handler as appropriate. Handler could | ||
| 16602 | be one of an interactive command, a function, or a form. | ||
| 16603 | |||
| 16604 | Set `org-use-speed-commands' to non-nil value to enable this | ||
| 16605 | hook. The default setting is `org-speed-command-default-hook'." | ||
| 16606 | :group 'org-structure | ||
| 16607 | :type 'hook) | ||
| 16608 | |||
| 16349 | (defun org-self-insert-command (N) | 16609 | (defun org-self-insert-command (N) |
| 16350 | "Like `self-insert-command', use overwrite-mode for whitespace in tables. | 16610 | "Like `self-insert-command', use overwrite-mode for whitespace in tables. |
| 16351 | If the cursor is in a table looking at whitespace, the whitespace is | 16611 | If the cursor is in a table looking at whitespace, the whitespace is |
| @@ -16353,13 +16613,9 @@ overwritten, and the table is not marked as requiring realignment." | |||
| 16353 | (interactive "p") | 16613 | (interactive "p") |
| 16354 | (cond | 16614 | (cond |
| 16355 | ((and org-use-speed-commands | 16615 | ((and org-use-speed-commands |
| 16356 | (or (and (bolp) (looking-at outline-regexp)) | 16616 | (setq org-speed-command |
| 16357 | (and (functionp org-use-speed-commands) | 16617 | (run-hook-with-args-until-success |
| 16358 | (funcall org-use-speed-commands))) | 16618 | 'org-speed-command-hook (this-command-keys)))) |
| 16359 | (setq | ||
| 16360 | org-speed-command | ||
| 16361 | (or (cdr (assoc (this-command-keys) org-speed-commands-user)) | ||
| 16362 | (cdr (assoc (this-command-keys) org-speed-commands-default))))) | ||
| 16363 | (cond | 16619 | (cond |
| 16364 | ((commandp org-speed-command) | 16620 | ((commandp org-speed-command) |
| 16365 | (setq this-command org-speed-command) | 16621 | (setq this-command org-speed-command) |
| @@ -16426,9 +16682,11 @@ because, in this case the deletion might narrow the column." | |||
| 16426 | (noalign (looking-at "[^|\n\r]* |")) | 16682 | (noalign (looking-at "[^|\n\r]* |")) |
| 16427 | (c org-table-may-need-update)) | 16683 | (c org-table-may-need-update)) |
| 16428 | (backward-delete-char N) | 16684 | (backward-delete-char N) |
| 16429 | (skip-chars-forward "^|") | 16685 | (if (not overwrite-mode) |
| 16430 | (insert " ") | 16686 | (progn |
| 16431 | (goto-char (1- pos)) | 16687 | (skip-chars-forward "^|") |
| 16688 | (insert " ") | ||
| 16689 | (goto-char (1- pos)))) | ||
| 16432 | ;; noalign: if there were two spaces at the end, this field | 16690 | ;; noalign: if there were two spaces at the end, this field |
| 16433 | ;; does not determine the width of the column. | 16691 | ;; does not determine the width of the column. |
| 16434 | (if noalign (setq org-table-may-need-update c))) | 16692 | (if noalign (setq org-table-may-need-update c))) |
| @@ -17022,13 +17280,10 @@ This command does many different things, depending on context: | |||
| 17022 | 17280 | ||
| 17023 | - If the cursor is a the beginning of a dynamic block, update it. | 17281 | - If the cursor is a the beginning of a dynamic block, update it. |
| 17024 | 17282 | ||
| 17025 | - If the current buffer is a remember buffer, close note and file | 17283 | - If the current buffer is a capture buffer, close note and file it. |
| 17026 | it. A prefix argument of 1 files to the default location | ||
| 17027 | without further interaction. A prefix argument of 2 files to | ||
| 17028 | the currently clocking task. | ||
| 17029 | 17284 | ||
| 17030 | - If the cursor is on a <<<target>>>, update radio targets and corresponding | 17285 | - If the cursor is on a <<<target>>>, update radio targets and |
| 17031 | links in this buffer. | 17286 | corresponding links in this buffer. |
| 17032 | 17287 | ||
| 17033 | - If the cursor is on a numbered item in a plain list, renumber the | 17288 | - If the cursor is on a numbered item in a plain list, renumber the |
| 17034 | ordered list. | 17289 | ordered list. |
| @@ -17074,12 +17329,12 @@ This command does many different things, depending on context: | |||
| 17074 | (org-footnote-at-definition-p)) | 17329 | (org-footnote-at-definition-p)) |
| 17075 | (call-interactively 'org-footnote-action)) | 17330 | (call-interactively 'org-footnote-action)) |
| 17076 | ((org-at-item-checkbox-p) | 17331 | ((org-at-item-checkbox-p) |
| 17332 | (call-interactively 'org-list-repair) | ||
| 17077 | (call-interactively 'org-toggle-checkbox) | 17333 | (call-interactively 'org-toggle-checkbox) |
| 17078 | (org-list-send-list 'maybe)) | 17334 | (org-list-send-list 'maybe)) |
| 17079 | ((org-at-item-p) | 17335 | ((org-at-item-p) |
| 17080 | (if arg | 17336 | (call-interactively 'org-list-repair) |
| 17081 | (call-interactively 'org-toggle-checkbox) | 17337 | (when arg (call-interactively 'org-toggle-checkbox)) |
| 17082 | (call-interactively 'org-maybe-renumber-ordered-list)) | ||
| 17083 | (org-list-send-list 'maybe)) | 17338 | (org-list-send-list 'maybe)) |
| 17084 | ((save-excursion (beginning-of-line 1) (looking-at org-dblock-start-re)) | 17339 | ((save-excursion (beginning-of-line 1) (looking-at org-dblock-start-re)) |
| 17085 | ;; Dynamic block | 17340 | ;; Dynamic block |
| @@ -17136,7 +17391,7 @@ See the individual commands for more information." | |||
| 17136 | (call-interactively 'org-open-at-point)) | 17391 | (call-interactively 'org-open-at-point)) |
| 17137 | ((and (org-at-heading-p) | 17392 | ((and (org-at-heading-p) |
| 17138 | (looking-at | 17393 | (looking-at |
| 17139 | (org-re "\\([ \t]+\\(:[[:alnum:]_@:]+:\\)\\)[ \t]*$"))) | 17394 | (org-re "\\([ \t]+\\(:[[:alnum:]_@#%:]+:\\)\\)[ \t]*$"))) |
| 17140 | (org-show-entry) | 17395 | (org-show-entry) |
| 17141 | (end-of-line 1) | 17396 | (end-of-line 1) |
| 17142 | (newline)) | 17397 | (newline)) |
| @@ -17202,21 +17457,21 @@ If the first line is normal text, add an item bullet to each line." | |||
| 17202 | ;; We already have items, de-itemize | 17457 | ;; We already have items, de-itemize |
| 17203 | (while (< (setq l (1+ l)) l2) | 17458 | (while (< (setq l (1+ l)) l2) |
| 17204 | (when (org-at-item-p) | 17459 | (when (org-at-item-p) |
| 17205 | (goto-char (match-beginning 2)) | 17460 | (skip-chars-forward " \t") |
| 17206 | (delete-region (match-beginning 2) (match-end 2)) | 17461 | (delete-region (point) (match-end 0))) |
| 17207 | (and (looking-at "[ \t]+") (replace-match ""))) | ||
| 17208 | (beginning-of-line 2)) | 17462 | (beginning-of-line 2)) |
| 17209 | (if (org-on-heading-p) | 17463 | (if (org-on-heading-p) |
| 17210 | ;; Headings, convert to items | 17464 | ;; Headings, convert to items |
| 17211 | (while (< (setq l (1+ l)) l2) | 17465 | (while (< (setq l (1+ l)) l2) |
| 17212 | (if (looking-at org-outline-regexp) | 17466 | (if (looking-at org-outline-regexp) |
| 17213 | (replace-match "- " t t)) | 17467 | (replace-match (org-list-bullet-string "-") t t)) |
| 17214 | (beginning-of-line 2)) | 17468 | (beginning-of-line 2)) |
| 17215 | ;; normal lines, turn them into items | 17469 | ;; normal lines, turn them into items |
| 17216 | (while (< (setq l (1+ l)) l2) | 17470 | (while (< (setq l (1+ l)) l2) |
| 17217 | (unless (org-at-item-p) | 17471 | (unless (org-at-item-p) |
| 17218 | (if (looking-at "\\([ \t]*\\)\\(\\S-\\)") | 17472 | (if (looking-at "\\([ \t]*\\)\\(\\S-\\)") |
| 17219 | (replace-match "\\1- \\2"))) | 17473 | (replace-match |
| 17474 | (concat "\\1" (org-list-bullet-string "-") "\\2")))) | ||
| 17220 | (beginning-of-line 2))))))) | 17475 | (beginning-of-line 2))))))) |
| 17221 | 17476 | ||
| 17222 | (defun org-toggle-heading (&optional nstars) | 17477 | (defun org-toggle-heading (&optional nstars) |
| @@ -17518,14 +17773,6 @@ See the individual commands for more information." | |||
| 17518 | (org-inside-LaTeX-fragment-p)] | 17773 | (org-inside-LaTeX-fragment-p)] |
| 17519 | ["Insert citation" org-reftex-citation t] | 17774 | ["Insert citation" org-reftex-citation t] |
| 17520 | "--" | 17775 | "--" |
| 17521 | ["Export LaTeX fragments as images" | ||
| 17522 | (if (featurep 'org-exp) | ||
| 17523 | (setq org-export-with-LaTeX-fragments | ||
| 17524 | (not org-export-with-LaTeX-fragments)) | ||
| 17525 | (require 'org-exp)) | ||
| 17526 | :style toggle :selected (and (boundp 'org-export-with-LaTeX-fragments) | ||
| 17527 | org-export-with-LaTeX-fragments)] | ||
| 17528 | "--" | ||
| 17529 | ["Template for BEAMER" org-insert-beamer-options-template t]) | 17776 | ["Template for BEAMER" org-insert-beamer-options-template t]) |
| 17530 | "--" | 17777 | "--" |
| 17531 | ("MobileOrg" | 17778 | ("MobileOrg" |
| @@ -18107,16 +18354,23 @@ really on, so that the block visually is on the match." | |||
| 18107 | (throw 'exit t))) | 18354 | (throw 'exit t))) |
| 18108 | nil)))) | 18355 | nil)))) |
| 18109 | 18356 | ||
| 18110 | (defun org-in-regexps-block-p (start-re end-re) | 18357 | (defun org-in-regexps-block-p (start-re end-re &optional bound) |
| 18111 | "Return t if the current point is between matches of START-RE and END-RE. | 18358 | "Return t if the current point is between matches of START-RE and END-RE. |
| 18112 | This will also return to if point is on one of the two matches." | 18359 | This will also return t if point is on one of the two matches or |
| 18113 | (interactive) | 18360 | in an unfinished block. END-RE can be a string or a form |
| 18114 | (let ((p (point))) | 18361 | returning a string. |
| 18362 | |||
| 18363 | An optional third argument bounds the search for START-RE. It | ||
| 18364 | defaults to previous heading or `point-min'." | ||
| 18365 | (let ((pos (point)) | ||
| 18366 | (limit (or bound (save-excursion (outline-previous-heading))))) | ||
| 18115 | (save-excursion | 18367 | (save-excursion |
| 18116 | (and (or (org-at-regexp-p start-re) | 18368 | ;; we're on a block when point is on start-re... |
| 18117 | (re-search-backward start-re nil t)) | 18369 | (or (org-at-regexp-p start-re) |
| 18118 | (re-search-forward end-re nil t) | 18370 | ;; ... or start-re can be found above... |
| 18119 | (>= (point) p))))) | 18371 | (and (re-search-backward start-re limit t) |
| 18372 | ;; ... but no end-re between start-re and point. | ||
| 18373 | (not (re-search-forward (eval end-re) pos t))))))) | ||
| 18120 | 18374 | ||
| 18121 | (defun org-occur-in-agenda-files (regexp &optional nlines) | 18375 | (defun org-occur-in-agenda-files (regexp &optional nlines) |
| 18122 | "Call `multi-occur' with buffers for all agenda files." | 18376 | "Call `multi-occur' with buffers for all agenda files." |
| @@ -18392,61 +18646,90 @@ which make use of the date at the cursor." | |||
| 18392 | (itemp (org-at-item-p)) | 18646 | (itemp (org-at-item-p)) |
| 18393 | (case-fold-search t) | 18647 | (case-fold-search t) |
| 18394 | (org-drawer-regexp (or org-drawer-regexp "\000")) | 18648 | (org-drawer-regexp (or org-drawer-regexp "\000")) |
| 18649 | (inline-task-p (and (featurep 'org-inlinetask) | ||
| 18650 | (org-inlinetask-in-task-p))) | ||
| 18395 | column bpos bcol tpos tcol bullet btype bullet-type) | 18651 | column bpos bcol tpos tcol bullet btype bullet-type) |
| 18396 | ;; Find the previous relevant line | 18652 | ;; Find the previous relevant line |
| 18397 | (beginning-of-line 1) | 18653 | (beginning-of-line 1) |
| 18398 | (cond | 18654 | (cond |
| 18655 | ;; Comments | ||
| 18399 | ((looking-at "#") (setq column 0)) | 18656 | ((looking-at "#") (setq column 0)) |
| 18657 | ;; Headings | ||
| 18400 | ((looking-at "\\*+ ") (setq column 0)) | 18658 | ((looking-at "\\*+ ") (setq column 0)) |
| 18659 | ;; Drawers | ||
| 18401 | ((and (looking-at "[ \t]*:END:") | 18660 | ((and (looking-at "[ \t]*:END:") |
| 18402 | (save-excursion (re-search-backward org-drawer-regexp nil t))) | 18661 | (save-excursion (re-search-backward org-drawer-regexp nil t))) |
| 18403 | (save-excursion | 18662 | (save-excursion |
| 18404 | (goto-char (1- (match-beginning 1))) | 18663 | (goto-char (1- (match-beginning 1))) |
| 18405 | (setq column (current-column)))) | 18664 | (setq column (current-column)))) |
| 18406 | ((and (looking-at "[ \t]+#\\+end_\\([a-z]+\\)") | 18665 | ;; Special blocks |
| 18666 | ((and (looking-at "[ \t]*#\\+end_\\([a-z]+\\)") | ||
| 18407 | (save-excursion | 18667 | (save-excursion |
| 18408 | (re-search-backward | 18668 | (re-search-backward |
| 18409 | (concat "^[ \t]*#\\+begin_" (downcase (match-string 1))) nil t))) | 18669 | (concat "^[ \t]*#\\+begin_" (downcase (match-string 1))) nil t))) |
| 18410 | (setq column (org-get-indentation (match-string 0)))) | 18670 | (setq column (org-get-indentation (match-string 0)))) |
| 18671 | ((and (not (looking-at "[ \t]*#\\+begin_")) | ||
| 18672 | (org-in-regexps-block-p "^[ \t]*#\\+begin_" "[ \t]*#\\+end_")) | ||
| 18673 | (save-excursion | ||
| 18674 | (re-search-backward "^[ \t]*#\\+begin_\\([a-z]+\\)" nil t)) | ||
| 18675 | (setq column | ||
| 18676 | (if (equal (downcase (match-string 1)) "src") | ||
| 18677 | ;; src blocks: let `org-edit-src-exit' handle them | ||
| 18678 | (org-get-indentation) | ||
| 18679 | (org-get-indentation (match-string 0))))) | ||
| 18680 | ;; Lists | ||
| 18681 | ((org-in-item-p) | ||
| 18682 | (org-beginning-of-item) | ||
| 18683 | (looking-at "[ \t]*\\(\\S-+\\)[ \t]*\\(\\(:?\\[@\\(:?start:\\)?[0-9]+\\][ \t]*\\)?\\[[- X]\\][ \t]*\\|.*? :: \\)?") | ||
| 18684 | (setq bpos (match-beginning 1) tpos (match-end 0) | ||
| 18685 | bcol (progn (goto-char bpos) (current-column)) | ||
| 18686 | 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)) | ||
| 18690 | (setq tcol (+ bcol 5))) | ||
| 18691 | (if (not itemp) | ||
| 18692 | (setq column tcol) | ||
| 18693 | (beginning-of-line 1) | ||
| 18694 | (goto-char pos) | ||
| 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. | ||
| 18411 | (t | 18704 | (t |
| 18412 | (beginning-of-line 0) | 18705 | (beginning-of-line 0) |
| 18413 | (while (and (not (bobp)) (looking-at "[ \t]*[\n:#|]") | 18706 | (while (and (not (bobp)) |
| 18414 | (not (looking-at "[ \t]*:END:")) | 18707 | ;; skip comments, verbatim, empty lines, tables, |
| 18415 | (not (looking-at org-drawer-regexp))) | 18708 | ;; inline tasks |
| 18416 | (beginning-of-line 0)) | 18709 | (or (looking-at "[ \t]*[\n:#|]") |
| 18710 | (and (org-in-item-p) (goto-char (org-list-top-point))) | ||
| 18711 | (and (not inline-task-p) | ||
| 18712 | (featurep 'org-inlinetask) | ||
| 18713 | (org-inlinetask-in-task-p))) | ||
| 18714 | (not (looking-at "[ \t]*:END:")) | ||
| 18715 | (not (looking-at org-drawer-regexp))) | ||
| 18716 | (beginning-of-line 0)) | ||
| 18417 | (cond | 18717 | (cond |
| 18718 | ;; There was an heading above. | ||
| 18418 | ((looking-at "\\*+[ \t]+") | 18719 | ((looking-at "\\*+[ \t]+") |
| 18419 | (if (not org-adapt-indentation) | 18720 | (if (not org-adapt-indentation) |
| 18420 | (setq column 0) | 18721 | (setq column 0) |
| 18421 | (goto-char (match-end 0)) | 18722 | (goto-char (match-end 0)) |
| 18422 | (setq column (current-column)))) | 18723 | (setq column (current-column)))) |
| 18724 | ;; A drawer had started and is unfinished: indent consequently. | ||
| 18423 | ((looking-at org-drawer-regexp) | 18725 | ((looking-at org-drawer-regexp) |
| 18424 | (goto-char (1- (match-beginning 1))) | 18726 | (goto-char (1- (match-beginning 1))) |
| 18425 | (setq column (current-column))) | 18727 | (setq column (current-column))) |
| 18728 | ;; The drawer had ended: indent like its :END: line. | ||
| 18426 | ((looking-at "\\([ \t]*\\):END:") | 18729 | ((looking-at "\\([ \t]*\\):END:") |
| 18427 | (goto-char (match-end 1)) | 18730 | (goto-char (match-end 1)) |
| 18428 | (setq column (current-column))) | 18731 | (setq column (current-column))) |
| 18429 | ((org-in-item-p) | 18732 | ;; Else, nothing noticeable found: get indentation and go on. |
| 18430 | (org-beginning-of-item) | ||
| 18431 | (looking-at "[ \t]*\\(\\S-+\\)[ \t]*\\(\\[[- X]\\][ \t]*\\|.*? :: \\)?") | ||
| 18432 | (setq bpos (match-beginning 1) tpos (match-end 0) | ||
| 18433 | bcol (progn (goto-char bpos) (current-column)) | ||
| 18434 | tcol (progn (goto-char tpos) (current-column)) | ||
| 18435 | bullet (match-string 1) | ||
| 18436 | bullet-type (if (string-match "[0-9]" bullet) "n" bullet)) | ||
| 18437 | (if (> tcol (+ bcol org-description-max-indent)) | ||
| 18438 | (setq tcol (+ bcol 5))) | ||
| 18439 | (if (not itemp) | ||
| 18440 | (setq column tcol) | ||
| 18441 | (goto-char pos) | ||
| 18442 | (beginning-of-line 1) | ||
| 18443 | (if (looking-at "\\S-") | ||
| 18444 | (progn | ||
| 18445 | (looking-at "[ \t]*\\(\\S-+\\)[ \t]*") | ||
| 18446 | (setq bullet (match-string 1) | ||
| 18447 | btype (if (string-match "[0-9]" bullet) "n" bullet)) | ||
| 18448 | (setq column (if (equal btype bullet-type) bcol tcol))) | ||
| 18449 | (setq column (org-get-indentation))))) | ||
| 18450 | (t (setq column (org-get-indentation)))))) | 18733 | (t (setq column (org-get-indentation)))))) |
| 18451 | (goto-char pos) | 18734 | (goto-char pos) |
| 18452 | (if (<= (current-column) (current-indentation)) | 18735 | (if (<= (current-column) (current-indentation)) |
| @@ -18705,7 +18988,7 @@ beyond the end of the headline." | |||
| 18705 | (t 'end-of-line))) | 18988 | (t 'end-of-line))) |
| 18706 | (let ((pos (point))) | 18989 | (let ((pos (point))) |
| 18707 | (beginning-of-line 1) | 18990 | (beginning-of-line 1) |
| 18708 | (if (looking-at (org-re ".*?\\(?:\\([ \t]*\\)\\(:[[:alnum:]_@:]+:\\)?[ \t]*\\)?$")) | 18991 | (if (looking-at (org-re ".*?\\(?:\\([ \t]*\\)\\(:[[:alnum:]_@#%:]+:\\)?[ \t]*\\)?$")) |
| 18709 | (if (eq special t) | 18992 | (if (eq special t) |
| 18710 | (if (or (< pos (match-beginning 1)) | 18993 | (if (or (< pos (match-beginning 1)) |
| 18711 | (= pos (match-end 0))) | 18994 | (= pos (match-end 0))) |
| @@ -18759,7 +19042,7 @@ depending on context." | |||
| 18759 | (not (y-or-n-p "Kill hidden subtree along with headline? "))) | 19042 | (not (y-or-n-p "Kill hidden subtree along with headline? "))) |
| 18760 | (error "C-k aborted - would kill hidden subtree"))) | 19043 | (error "C-k aborted - would kill hidden subtree"))) |
| 18761 | (call-interactively 'kill-line)) | 19044 | (call-interactively 'kill-line)) |
| 18762 | ((looking-at (org-re ".*?\\S-\\([ \t]+\\(:[[:alnum:]_@:]+:\\)\\)[ \t]*$")) | 19045 | ((looking-at (org-re ".*?\\S-\\([ \t]+\\(:[[:alnum:]_@#%:]+:\\)\\)[ \t]*$")) |
| 18763 | (kill-region (point) (match-beginning 1)) | 19046 | (kill-region (point) (match-beginning 1)) |
| 18764 | (org-set-tags nil t)) | 19047 | (org-set-tags nil t)) |
| 18765 | (t (kill-region (point) (point-at-eol))))) | 19048 | (t (kill-region (point) (point-at-eol))))) |
| @@ -19003,6 +19286,18 @@ move point." | |||
| 19003 | (while (org-goto-sibling 'previous) | 19286 | (while (org-goto-sibling 'previous) |
| 19004 | (org-flag-heading nil)))) | 19287 | (org-flag-heading nil)))) |
| 19005 | 19288 | ||
| 19289 | (defun org-goto-first-child () | ||
| 19290 | "Goto the first child, even if it is invisible. | ||
| 19291 | Return t when a child was found. Otherwise don't move point and | ||
| 19292 | return nil." | ||
| 19293 | (let (level (pos (point)) (re (concat "^" outline-regexp))) | ||
| 19294 | (when (condition-case nil (org-back-to-heading t) (error nil)) | ||
| 19295 | (setq level (outline-level)) | ||
| 19296 | (forward-char 1) | ||
| 19297 | (if (and (re-search-forward re nil t) (> (outline-level) level)) | ||
| 19298 | (progn (goto-char (match-beginning 0)) t) | ||
| 19299 | (goto-char pos) nil)))) | ||
| 19300 | |||
| 19006 | (defun org-show-hidden-entry () | 19301 | (defun org-show-hidden-entry () |
| 19007 | "Show an entry where even the heading is hidden." | 19302 | "Show an entry where even the heading is hidden." |
| 19008 | (save-excursion | 19303 | (save-excursion |
| @@ -19094,7 +19389,9 @@ If there is no such heading, return nil." | |||
| 19094 | 19389 | ||
| 19095 | (defun org-forward-same-level (arg &optional invisible-ok) | 19390 | (defun org-forward-same-level (arg &optional invisible-ok) |
| 19096 | "Move forward to the arg'th subheading at same level as this one. | 19391 | "Move forward to the arg'th subheading at same level as this one. |
| 19097 | Stop at the first and last subheadings of a superior heading." | 19392 | Stop at the first and last subheadings of a superior heading. |
| 19393 | Normally this only looks at visible headings, but when INVISIBLE-OK is non-nil | ||
| 19394 | it wil also look at invisible ones." | ||
| 19098 | (interactive "p") | 19395 | (interactive "p") |
| 19099 | (org-back-to-heading invisible-ok) | 19396 | (org-back-to-heading invisible-ok) |
| 19100 | (org-on-heading-p) | 19397 | (org-on-heading-p) |
| @@ -19311,8 +19608,8 @@ To get rid of the restriction, use \\[org-agenda-remove-restriction-lock]." | |||
| 19311 | ;; Make flyspell not check words in links, to not mess up our keymap | 19608 | ;; Make flyspell not check words in links, to not mess up our keymap |
| 19312 | (defun org-mode-flyspell-verify () | 19609 | (defun org-mode-flyspell-verify () |
| 19313 | "Don't let flyspell put overlays at active buttons." | 19610 | "Don't let flyspell put overlays at active buttons." |
| 19314 | (and (not (get-text-property (point) 'keymap)) | 19611 | (and (not (get-text-property (max (1- (point)) (point-min)) 'keymap)) |
| 19315 | (not (get-text-property (point) 'org-no-flyspell)))) | 19612 | (not (get-text-property (max (1- (point)) (point-min)) 'org-no-flyspell)))) |
| 19316 | 19613 | ||
| 19317 | (defun org-remove-flyspell-overlays-in (beg end) | 19614 | (defun org-remove-flyspell-overlays-in (beg end) |
| 19318 | "Remove flyspell overlays in region." | 19615 | "Remove flyspell overlays in region." |