aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Wiegley2007-09-07 20:16:46 +0000
committerJohn Wiegley2007-09-07 20:16:46 +0000
commit0b8568f5fb30911898750578dcdf4bc4c974de60 (patch)
tree6ca91f436733d8151547e0c9839551147613c0c4
parent179cef4807becdf73e2a81a4ba52bff81b4530ee (diff)
downloademacs-0b8568f5fb30911898750578dcdf4bc4c974de60.tar.gz
emacs-0b8568f5fb30911898750578dcdf4bc4c974de60.zip
Updated to org-mode 5.08
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/textmodes/org-export-latex.el470
-rw-r--r--lisp/textmodes/org-publish.el6
-rw-r--r--lisp/textmodes/org.el403
4 files changed, 554 insertions, 329 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 3e45f5f9513..8b6b086d107 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,7 @@
12007-09-07 Carsten Dominik <dominik@science.uva.nl>
2
3 * textmodes/org.el: Updated to org-mode 5.08.
4
12007-09-07 Stefan Monnier <monnier@iro.umontreal.ca> 52007-09-07 Stefan Monnier <monnier@iro.umontreal.ca>
2 6
3 * simple.el (normal-erase-is-backspace-setup-frame): Massage. 7 * simple.el (normal-erase-is-backspace-setup-frame): Massage.
diff --git a/lisp/textmodes/org-export-latex.el b/lisp/textmodes/org-export-latex.el
index 1ba50894501..7b2dfd191a7 100644
--- a/lisp/textmodes/org-export-latex.el
+++ b/lisp/textmodes/org-export-latex.el
@@ -3,27 +3,29 @@
3;; 3;;
4;; Author: Bastien Guerry <bzg AT altern DOT org> 4;; Author: Bastien Guerry <bzg AT altern DOT org>
5;; Keywords: org organizer latex export convert 5;; Keywords: org organizer latex export convert
6;; Version: $Id: org-export-latex.el,v 0.28a 2007/08/31 06:22:06 guerry Exp guerry $
6;; X-URL: <http://www.cognition.ens.fr/~guerry/u/org-export-latex.el> 7;; X-URL: <http://www.cognition.ens.fr/~guerry/u/org-export-latex.el>
7;; 8;;
8;; This file is part of GNU Emacs. 9;; This file is part of GNU Emacs.
9;; 10;;
10;; This program is free software; you can redistribute it and/or modify 11;; GNU Emacs is free software; you can redistribute it and/or modify it
11;; it under the terms of the GNU General Public License as published by 12;; under the terms of the GNU General Public License as published by the
12;; the Free Software Foundation; either version 3, or (at your option) 13;; Free Software Foundation; either version 3, or (at your option) any
13;; any later version. 14;; later version.
14;; 15;;
15;; This program is distributed in the hope that it will be useful, 16;; GNU Emacs is distributed in the hope that it will be useful, but WITHOUT
16;; but WITHOUT ANY WARRANTY; without even the implied warranty of 17;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18;; GNU General Public License for more details. 19;; more details.
20;;
21;; You should have received a copy of the GNU General Public License along
22;; with GNU Emacs; see the file COPYING. If not, write to the Free Software
23;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24;; 02110-1301, USA.
19;; 25;;
20;; You should have received a copy of the GNU General Public License
21;; along with this program; if not, write to the Free Software
22;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23
24;;; Commentary: 26;;; Commentary:
25 27;;
26;; This library is a LaTeX exporter for org-mode. 28;; This library implements a LaTeX exporter for org-mode.
27;; 29;;
28;; Put this file into your load-path and the following into your ~/.emacs: 30;; Put this file into your load-path and the following into your ~/.emacs:
29;; (require 'org-export-latex) 31;; (require 'org-export-latex)
@@ -35,18 +37,16 @@
35;; M-x `org-export-as-latex-to-buffer' 37;; M-x `org-export-as-latex-to-buffer'
36;; M-x `org-export-region-as-latex' 38;; M-x `org-export-region-as-latex'
37;; M-x `org-replace-region-by-latex' 39;; M-x `org-replace-region-by-latex'
38 40;;
39;;; History:
40;;
41;; I started this piece of code in may 2007. Special thanks to Carsten
42;; Dominik for helping me on this.
43;;
44
45;;; Code: 41;;; Code:
46 42
47(require 'org) 43(eval-when-compile
44 (require 'cl))
45
48(require 'footnote) 46(require 'footnote)
47(require 'org)
49 48
49;;; Variables:
50(defvar org-latex-options-plist nil) 50(defvar org-latex-options-plist nil)
51(defvar org-latex-todo-keywords-1 nil) 51(defvar org-latex-todo-keywords-1 nil)
52(defvar org-latex-all-targets-regexp nil) 52(defvar org-latex-all-targets-regexp nil)
@@ -60,6 +60,11 @@
60 org-clock-string) 60 org-clock-string)
61 "A list of regexps to convert as special keywords.") 61 "A list of regexps to convert as special keywords.")
62 62
63(defvar latexp) ; dynamically scoped from org.el
64(defvar re-quote) ; dynamically scoped from org.el
65(defvar commentsp) ; dynamically scoped from org.el
66
67;;; Custom variables:
63(defcustom org-export-latex-sectioning-alist 68(defcustom org-export-latex-sectioning-alist
64 '((1 "\\section{%s}" "\\section*{%s}") 69 '((1 "\\section{%s}" "\\section*{%s}")
65 (2 "\\subsection{%s}" "\\subsection*{%s}") 70 (2 "\\subsection{%s}" "\\subsection*{%s}")
@@ -150,6 +155,8 @@ This value is overriden by any infile language setup."
150;; FIXME Do we want this one? 155;; FIXME Do we want this one?
151;; (defun org-export-as-latex-and-open (arg) ...) 156;; (defun org-export-as-latex-and-open (arg) ...)
152 157
158
159;;; Autoload functions:
153;;;###autoload 160;;;###autoload
154(defun org-export-as-latex-batch () 161(defun org-export-as-latex-batch ()
155 "Call `org-export-as-latex', may be used in batch processing as 162 "Call `org-export-as-latex', may be used in batch processing as
@@ -283,6 +290,7 @@ in a window. A non-interactive call will only retunr the buffer."
283 :LaTeX-fragments nil))) 290 :LaTeX-fragments nil)))
284 (set-buffer buffer) 291 (set-buffer buffer)
285 (erase-buffer) 292 (erase-buffer)
293
286 (unless body-only (insert preamble)) 294 (unless body-only (insert preamble))
287 (when text (insert (org-export-latex-content text) "\n\n")) 295 (when text (insert (org-export-latex-content text) "\n\n"))
288 (unless skip (insert first-lines)) 296 (unless skip (insert first-lines))
@@ -305,7 +313,7 @@ in a window. A non-interactive call will only retunr the buffer."
305 (org-export-latex-parse-global level odd)))) 313 (org-export-latex-parse-global level odd))))
306 314
307 (unless body-only (insert "\n\\end{document}")) 315 (unless body-only (insert "\n\\end{document}"))
308 (or to-buffer (write-file filename)) 316 (or to-buffer (save-buffer))
309 (goto-char (point-min)) 317 (goto-char (point-min))
310 (message "Exporting to LaTeX...done") 318 (message "Exporting to LaTeX...done")
311 (if (eq to-buffer 'string) 319 (if (eq to-buffer 'string)
@@ -313,88 +321,8 @@ in a window. A non-interactive call will only retunr the buffer."
313 (kill-buffer (current-buffer))) 321 (kill-buffer (current-buffer)))
314 (current-buffer)))) 322 (current-buffer))))
315 323
316(defun org-export-latex-set-initial-vars (ext-plist)
317 "Store org local variables required for LaTeX export.
318EXT-PLIST is an optional additional plist."
319 (setq org-latex-todo-keywords-1 org-todo-keywords-1
320 org-latex-all-targets-regexp
321 (org-make-target-link-regexp (org-all-targets))
322 org-latex-options-plist
323 (org-combine-plists (org-default-export-plist) ext-plist
324 (org-infile-export-plist))
325 org-latex-sectioning-depth
326 (let ((hl-levels (plist-get org-latex-options-plist :headline-levels))
327 (sec-depth (length org-export-latex-sectioning-alist)))
328 ;; Fall back on org-export-latex-sectioning-alist length if
329 ;; headline-levels goes beyond it
330 (if (> hl-levels sec-depth) sec-depth hl-levels))))
331
332(defun org-export-latex-make-preamble (opt-plist)
333 "Make the LaTeX preamble and return it as a string.
334Argument OPT-PLIST is the options plist for current buffer."
335 (let ((toc (plist-get opt-plist :table-of-contents)))
336 (format (concat org-export-latex-preamble
337 "
338%s
339
340\\begin{document}
341
342\\title{%s}
343%s
344%s
345\\maketitle
346%s
347%s
348")
349 (if org-export-latex-packages-alist
350 (mapconcat (lambda(p)
351 (if (equal "" (car p))
352 (format "\\usepackage{%s}" (cadr p))
353 (format "\\usepackage[%s]{%s}"
354 (car p) (cadr p))))
355 org-export-latex-packages-alist "\n") "")
356 (or (plist-get opt-plist :title)
357 (and (not
358 (plist-get opt-plist :skip-before-1st-heading))
359 (org-export-grab-title-from-buffer))
360 (and buffer-file-name
361 (file-name-sans-extension
362 (file-name-nondirectory buffer-file-name)))
363 "UNTITLED")
364 (if (plist-get opt-plist :author-info)
365 (format "\\author{%s}"
366 (or (plist-get opt-plist :author) user-full-name))
367 (format "%%\\author{%s}"
368 (or (plist-get opt-plist :author) user-full-name)))
369 (if (plist-get opt-plist :timestamps)
370 (format "\\date{%s}"
371 (format-time-string (or org-export-latex-date-format
372 (car org-time-stamp-formats))))
373 "%\\date{}")
374 (if (and (plist-get opt-plist :section-numbers) toc)
375 (format "\\setcounter{tocdepth}{%s}"
376 (plist-get opt-plist :headline-levels)) "")
377 (if (and (plist-get opt-plist :section-numbers) toc)
378 "\\tableofcontents" ""))))
379
380(defun org-export-latex-first-lines (&optional comments)
381 "Export the first lines before first headline.
382COMMENTS is either nil to replace them with the empty string or a
383formatting string like %%%%s if we want to comment them out."
384 (save-excursion
385 (goto-char (point-min))
386 (let* ((end (if (re-search-forward "^\\*" nil t)
387 (goto-char (match-beginning 0))
388 (goto-char (point-max)))))
389 (org-export-latex-content
390 (org-latex-cleaned-string-for-export
391 (buffer-substring (point-min) end)
392 :for-html nil
393 :for-LaTeX t
394 :comments nil
395 :skip-before-1st-heading nil
396 :LaTeX-fragments nil)))))
397 324
325;;; Parsing functions:
398(defun org-export-latex-parse-global (level odd) 326(defun org-export-latex-parse-global (level odd)
399 "Parse the current buffer recursively, starting at LEVEL. 327 "Parse the current buffer recursively, starting at LEVEL.
400If ODD is non-nil, assume the buffer only contains odd sections. 328If ODD is non-nil, assume the buffer only contains odd sections.
@@ -463,6 +391,8 @@ If ODD Is non-nil, assume subcontent only contains odd sections."
463 nil ; subcontent is nil 391 nil ; subcontent is nil
464 (org-export-latex-parse-global (+ (if odd 2 1) level) odd))) 392 (org-export-latex-parse-global (+ (if odd 2 1) level) odd)))
465 393
394
395;;; Rendering functions:
466(defun org-export-latex-global (content) 396(defun org-export-latex-global (content)
467 "Export CONTENT to LaTeX. 397 "Export CONTENT to LaTeX.
468CONTENT is an element of the list produced by 398CONTENT is an element of the list produced by
@@ -509,7 +439,105 @@ and its content."
509 (cond ((stringp subcontent) (insert subcontent)) 439 (cond ((stringp subcontent) (insert subcontent))
510 ((listp subcontent) (org-export-latex-sub subcontent))))))))) 440 ((listp subcontent) (org-export-latex-sub subcontent)))))))))
511 441
512(defun org-export-latex-special-keywords-maybe (remove-list) 442
443;;; Exporting internals:
444(defun org-latex-protect (string)
445 (add-text-properties 0 (length string) '(org-protected t) string) string)
446
447(defun org-export-latex-protect-char-in-string (char-list string)
448 "Add org-protected text-property to char from CHAR-LIST in STRING."
449 (with-temp-buffer
450 (save-match-data
451 (insert string)
452 (goto-char (point-min))
453 (while (re-search-forward (regexp-opt char-list) nil t)
454 (add-text-properties (match-beginning 0)
455 (match-end 0) '(org-protected t)))
456 (buffer-string))))
457
458(defun org-export-latex-set-initial-vars (ext-plist)
459 "Store org local variables required for LaTeX export.
460EXT-PLIST is an optional additional plist."
461 (setq org-latex-todo-keywords-1 org-todo-keywords-1
462 org-latex-all-targets-regexp
463 (org-make-target-link-regexp (org-all-targets))
464 org-latex-options-plist
465 (org-combine-plists (org-default-export-plist) ext-plist
466 (org-infile-export-plist))
467 org-latex-sectioning-depth
468 (let ((hl-levels (plist-get org-latex-options-plist :headline-levels))
469 (sec-depth (length org-export-latex-sectioning-alist)))
470 ;; Fall back on org-export-latex-sectioning-alist length if
471 ;; headline-levels goes beyond it
472 (if (> hl-levels sec-depth) sec-depth hl-levels))))
473
474(defun org-export-latex-make-preamble (opt-plist)
475 "Make the LaTeX preamble and return it as a string.
476Argument OPT-PLIST is the options plist for current buffer."
477 (let ((toc (plist-get opt-plist :table-of-contents)))
478 (format (concat org-export-latex-preamble
479 "
480%s
481
482\\begin{document}
483
484\\title{%s}
485%s
486%s
487\\maketitle
488%s
489%s
490")
491 (if org-export-latex-packages-alist
492 (mapconcat (lambda(p)
493 (if (equal "" (car p))
494 (format "\\usepackage{%s}" (cadr p))
495 (format "\\usepackage[%s]{%s}"
496 (car p) (cadr p))))
497 org-export-latex-packages-alist "\n") "")
498 (or (plist-get opt-plist :title)
499 (and (not
500 (plist-get opt-plist :skip-before-1st-heading))
501 (org-export-grab-title-from-buffer))
502 (and buffer-file-name
503 (file-name-sans-extension
504 (file-name-nondirectory buffer-file-name)))
505 "UNTITLED")
506 (if (plist-get opt-plist :author-info)
507 (format "\\author{%s}"
508 (or (plist-get opt-plist :author) user-full-name))
509 (format "%%\\author{%s}"
510 (or (plist-get opt-plist :author) user-full-name)))
511 (if (plist-get opt-plist :timestamps)
512 (format "\\date{%s}"
513 (format-time-string (or org-export-latex-date-format
514 (car org-time-stamp-formats))))
515 "%\\date{}")
516 (if (and (plist-get opt-plist :section-numbers) toc)
517 (format "\\setcounter{tocdepth}{%s}"
518 (plist-get opt-plist :headline-levels)) "")
519 (if (and (plist-get opt-plist :section-numbers) toc)
520 "\\tableofcontents" ""))))
521
522(defun org-export-latex-first-lines (&optional comments)
523 "Export the first lines before first headline.
524COMMENTS is either nil to replace them with the empty string or a
525formatting string like %%%%s if we want to comment them out."
526 (save-excursion
527 (goto-char (point-min))
528 (let* ((end (if (re-search-forward "^\\*" nil t)
529 (goto-char (match-beginning 0))
530 (goto-char (point-max)))))
531 (org-export-latex-content
532 (org-latex-cleaned-string-for-export
533 (buffer-substring (point-min) end)
534 :for-html nil
535 :for-LaTeX t
536 :comments nil
537 :skip-before-1st-heading nil
538 :LaTeX-fragments nil)))))
539
540(defun org-export-latex-keywords-maybe (remove-list)
513 "Maybe remove keywords depending on rules in REMOVE-LIST." 541 "Maybe remove keywords depending on rules in REMOVE-LIST."
514 (goto-char (point-min)) 542 (goto-char (point-min))
515 (let ((re-todo (mapconcat 'identity org-latex-todo-keywords-1 "\\|"))) 543 (let ((re-todo (mapconcat 'identity org-latex-todo-keywords-1 "\\|")))
@@ -525,7 +553,8 @@ and its content."
525 (replace-match (format "\\texttt{%s}" (match-string 0)) t t))) 553 (replace-match (format "\\texttt{%s}" (match-string 0)) t t)))
526 ;; convert tags 554 ;; convert tags
527 (when (re-search-forward "\\(:[a-zA-Z0-9]+\\)+:" nil t) 555 (when (re-search-forward "\\(:[a-zA-Z0-9]+\\)+:" nil t)
528 (if (plist-get remove-list :tags) 556 (if (or (not org-export-with-tags)
557 (plist-get remove-list :tags))
529 (replace-match "") 558 (replace-match "")
530 (replace-match (format "\\texttt{%s}" (match-string 0)) t t))))) 559 (replace-match (format "\\texttt{%s}" (match-string 0)) t t)))))
531 560
@@ -536,40 +565,41 @@ and its content."
536 ;; the beginning of the buffer - inserting "\n" is safe here though. 565 ;; the beginning of the buffer - inserting "\n" is safe here though.
537 (insert "\n" headline) 566 (insert "\n" headline)
538 (goto-char (point-min)) 567 (goto-char (point-min))
539 (org-export-latex-fontify)
540 (org-export-latex-special-chars 568 (org-export-latex-special-chars
541 (plist-get org-latex-options-plist :sub-superscript)) 569 (plist-get org-latex-options-plist :sub-superscript))
542 (org-export-latex-special-keywords-maybe 570 (when (plist-get org-latex-options-plist :emphasize)
571 (org-export-latex-fontify))
572 (org-export-latex-keywords-maybe
543 org-export-latex-remove-from-headines) 573 org-export-latex-remove-from-headines)
544 (org-export-latex-links) 574 (org-export-latex-links)
545 (org-trim (buffer-substring-no-properties (point-min) (point-max))))) 575 (org-trim (buffer-substring-no-properties (point-min) (point-max)))))
546 576
577(defun org-export-latex-fix-invisible-strings ()
578 "Comment out (INVISIBLE) warnings."
579 (goto-char (point-min))
580 (while (re-search-forward "(INVISIBLE)" nil t)
581 (replace-match "%\\&")))
582
547(defun org-export-latex-content (content) 583(defun org-export-latex-content (content)
548 "Convert CONTENT string to LaTeX." 584 "Convert CONTENT string to LaTeX."
549 (with-temp-buffer 585 (with-temp-buffer
550 (insert content) 586 (insert content)
551 (org-export-latex-quotation-marks) 587 (org-export-latex-quotation-marks)
552 (when (plist-get org-latex-options-plist :emphasize)
553 (org-export-latex-fontify))
554 (org-export-latex-special-chars 588 (org-export-latex-special-chars
555 (plist-get org-latex-options-plist :sub-superscript)) 589 (plist-get org-latex-options-plist :sub-superscript))
590 (when (plist-get org-latex-options-plist :emphasize)
591 (org-export-latex-fontify))
556 (org-export-latex-links) 592 (org-export-latex-links)
557 (org-export-latex-special-keywords) 593 (org-export-latex-keywords)
558 (org-export-latex-itemize) 594 (org-export-latex-itemize)
559 (org-export-latex-enumerate) 595 (org-export-latex-enumerate)
560 (org-export-latex-tables 596 (org-export-latex-tables
561 (plist-get org-latex-options-plist :tables)) 597 (plist-get org-latex-options-plist :tables))
562 (org-export-latex-fixed-width 598 (org-export-latex-fixed-width
563 (plist-get org-latex-options-plist :fixed-width)) 599 (plist-get org-latex-options-plist :fixed-width))
564 (org-export-fix-invisible-strings) 600 (org-export-latex-fix-invisible-strings)
565 (buffer-substring (point-min) (point-max)))) 601 (buffer-substring (point-min) (point-max))))
566 602
567(defun org-export-fix-invisible-strings ()
568 "Comment out (INVISIBLE) warnings."
569 (goto-char (point-min))
570 (while (re-search-forward "(INVISIBLE)" nil t)
571 (replace-match "%\\&")))
572
573(defun org-export-latex-quotation-marks () 603(defun org-export-latex-quotation-marks ()
574 "Export question marks depending on language conventions. 604 "Export question marks depending on language conventions.
575Local definition of the language overrides 605Local definition of the language overrides
@@ -628,11 +658,12 @@ See the `org-export-latex.el' code for a complete conversion table."
628 (replace-match (concat (match-string 1) "\\" 658 (replace-match (concat (match-string 1) "\\"
629 (match-string 2)) t t))) 659 (match-string 2)) t t)))
630 ((equal (match-string 2) "~") 660 ((equal (match-string 2) "~")
631 (unless (get-text-property 0 'org-protected (match-string 2)) 661 (cond ((equal (match-string 1) "\\") nil)
632 (if (equal (match-string 1) "\\") nil 662 ((eq 'org-link (get-text-property 0 'face (match-string 2)))
633 (replace-match 663 (replace-match (concat (match-string 1) "\\~") t t))
634 (org-latex-protect 664 (t (replace-match
635 (concat (match-string 1) "\\textasciitilde{}")) t t)))) 665 (org-latex-protect
666 (concat (match-string 1) "\\~{}")) t t))))
636 ((member (match-string 2) '("{" "}")) 667 ((member (match-string 2) '("{" "}"))
637 (unless (save-match-data (org-inside-LaTeX-fragment-p)) 668 (unless (save-match-data (org-inside-LaTeX-fragment-p))
638 (if (equal (match-string 1) "\\") 669 (if (equal (match-string 1) "\\")
@@ -653,8 +684,8 @@ See the `org-export-latex.el' code for a complete conversion table."
653 (match-string 2) 684 (match-string 2)
654 (match-string 3))) "") t t))))))) 685 (match-string 3))) "") t t)))))))
655 '("^\\([^\n$]*?\\|^\\)\\(\\\\?\\$\\)\\([^\n$]*\\)$" 686 '("^\\([^\n$]*?\\|^\\)\\(\\\\?\\$\\)\\([^\n$]*\\)$"
656 "\\([a-za-z0-9]+\\|[ \t\n]\\|\\\\\\)\\(_\\|\\^\\)\\([a-za-z0-9]+\\|[ \t\n]\\|[:punct:]\\|{[a-za-z0-9]+}\\|([a-za-z0-9]+)\\)" 687 "\\([a-za-z0-9]+\\|[ \t\n]\\|\\b\\|\\\\\\)\\(_\\|\\^\\)\\([a-za-z0-9]+\\|[ \t\n]\\|[:punct:]\\|{[a-za-z0-9]+}\\|([a-za-z0-9]+)\\)"
657 "\\(.\\|^\\)\\(\\\\\\)\\([ \t\n]\\|[a-za-z&#%{}]+\\)" 688 "\\(.\\|^\\)\\(\\\\\\)\\([ \t\n]\\|[a-zA-Z&#%{}\"]+\\)"
658 "\\(.\\|^\\)\\(&\\)" 689 "\\(.\\|^\\)\\(&\\)"
659 "\\(.\\|^\\)\\(#\\)" 690 "\\(.\\|^\\)\\(#\\)"
660 "\\(.\\|^\\)\\(%\\)" 691 "\\(.\\|^\\)\\(%\\)"
@@ -672,7 +703,7 @@ Convert CHAR depending on STRING-BEFORE and STRING-AFTER."
672 ;; this is part of a math formula 703 ;; this is part of a math formula
673 ((and (string-match "\\S-+" string-before) 704 ((and (string-match "\\S-+" string-before)
674 (string-match "\\S-+" string-after)) 705 (string-match "\\S-+" string-after))
675 (cond ((get-text-property 0 'org-protected char) 706 (cond ((eq 'org-link (get-text-property 0 'face char))
676 (concat string-before "\\" char string-after)) 707 (concat string-before "\\" char string-after))
677 ((save-match-data (org-inside-LaTeX-fragment-p)) 708 ((save-match-data (org-inside-LaTeX-fragment-p))
678 (if subsup 709 (if subsup
@@ -681,13 +712,13 @@ Convert CHAR depending on STRING-BEFORE and STRING-AFTER."
681 ((string-match "[({]?\\([^)}]+\\)[)}]?" string-after) 712 ((string-match "[({]?\\([^)}]+\\)[)}]?" string-after)
682 (format "%s%s{%s}" string-before char 713 (format "%s%s{%s}" string-before char
683 (match-string 1 string-after)))))) 714 (match-string 1 string-after))))))
684 ((and subsup 715 ((and subsup
685 (> (length string-after) 1) 716 (> (length string-after) 1)
686 (string-match "[({]?\\([^)}]+\\)[)}]?" string-after)) 717 (string-match "[({]?\\([^)}]+\\)[)}]?" string-after))
687 (format "$%s%s{%s}$" string-before char 718 (format "$%s%s{%s}$" string-before char
688 (match-string 1 string-after))) 719 (match-string 1 string-after)))
689 (subsup (concat "$" string-before char string-after "$")) 720 (subsup (concat "$" string-before char string-after "$"))
690 (t (concat string-before char string-after)))) 721 (t (concat string-before "\\" char string-after))))
691 (t (concat string-before "\\" char string-after)))) 722 (t (concat string-before "\\" char string-after))))
692 723
693(defun org-export-latex-treat-backslash-char (string-before string-after) 724(defun org-export-latex-treat-backslash-char (string-before string-after)
@@ -699,7 +730,7 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
699 (or (cdar (member (list string-after) org-html-entities)) 730 (or (cdar (member (list string-after) org-html-entities))
700 string-after) "$")) 731 string-after) "$"))
701 ((and (not (string-match "^[ \n\t]" string-after)) 732 ((and (not (string-match "^[ \n\t]" string-after))
702 (not (string-match "[ \n\t]\\'" string-before))) 733 (not (string-match "[ \t]\\'\\|^" string-before)))
703 ;; backslash is inside a word 734 ;; backslash is inside a word
704 (concat string-before "$\\backslash$" string-after)) 735 (concat string-before "$\\backslash$" string-after))
705 ((not (or (equal string-after "") 736 ((not (or (equal string-after "")
@@ -713,6 +744,16 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
713 (concat string-before "$\\backslash$" string-after)) 744 (concat string-before "$\\backslash$" string-after))
714 (t (concat string-before "$\\backslash$" string-after)))) 745 (t (concat string-before "$\\backslash$" string-after))))
715 746
747(defun org-export-latex-keywords ()
748 "Convert special keywords to LaTeX.
749Regexps are those from `org-latex-special-string-regexps'."
750 (let ((rg org-latex-special-string-regexps) r)
751 (while (setq r (pop rg))
752 (goto-char (point-min))
753 (while (re-search-forward (eval r) nil t)
754 (replace-match (format "\\\\texttt{%s}" (match-string 0)) t)))))
755
756;; FIXME - we need better implementation for nested lists
716(defun org-export-latex-fixed-width (opt) 757(defun org-export-latex-fixed-width (opt)
717 "When OPT is non-nil convert fixed-width sections to LaTeX." 758 "When OPT is non-nil convert fixed-width sections to LaTeX."
718 (goto-char (point-min)) 759 (goto-char (point-min))
@@ -731,12 +772,13 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
731 (match-string 2)) t t) 772 (match-string 2)) t t)
732 (forward-line)))))) 773 (forward-line))))))
733 774
775;; FIXME Use org-export-highlight-first-table-line ?
734(defun org-export-latex-tables (opt) 776(defun org-export-latex-tables (opt)
735 "When OPT is non-nil convert tables to LaTeX." 777 "When OPT is non-nil convert tables to LaTeX."
736 (goto-char (point-min)) 778 (goto-char (point-min))
737 (while (re-search-forward "^\\([ \t]*\\)|" nil t) 779 (while (re-search-forward "^\\([ \t]*\\)|" nil t)
738 ;; Re-align the table to update org-table-last-alignment 780 ;; Re-align the table to update org-table-last-alignment
739 (save-excursion (save-match-data (org-table-align))) 781 (save-window-excursion (save-match-data (org-table-align)))
740 (let (tbl-list 782 (let (tbl-list
741 (beg (match-beginning 0)) 783 (beg (match-beginning 0))
742 (end (save-excursion 784 (end (save-excursion
@@ -749,21 +791,11 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
749 (push (split-string (org-trim (match-string 1)) "|") tbl-list) 791 (push (split-string (org-trim (match-string 1)) "|") tbl-list)
750 (push 'hline tbl-list)) 792 (push 'hline tbl-list))
751 (forward-line)) 793 (forward-line))
752 ;; comment region out instead of deleting it ? 794 ;; comment region out instead of deleting it ?
753 (apply 'delete-region (list beg end)) 795 (apply 'delete-region (list beg end))
754 (when opt (insert (orgtbl-to-latex (nreverse tbl-list) 796 (when opt (insert (orgtbl-to-latex (nreverse tbl-list)
755 nil) "\n\n"))))) 797 nil) "\n\n")))))
756 798
757(defun org-export-latex-special-keywords ()
758 "Convert special keywords to LaTeX.
759Regexps are those from `org-latex-special-string-regexps'."
760 (let ((rg org-latex-special-string-regexps) r)
761 (while (setq r (pop rg))
762 (goto-char (point-min))
763 (while (re-search-forward (eval r) nil t)
764 (replace-match (format "\\\\texttt{%s}" (match-string 0)) t)))))
765
766;; FIXME - we need better implementation for nested lists
767(defun org-export-latex-list (srch0 srch1 srch2 rpl0 rpl1) 799(defun org-export-latex-list (srch0 srch1 srch2 rpl0 rpl1)
768 "Convert lists to LaTeX." 800 "Convert lists to LaTeX."
769 (goto-char (point-min)) 801 (goto-char (point-min))
@@ -829,17 +861,6 @@ Regexps are those from `org-latex-special-string-regexps'."
829 (match-string 5)) t t) 861 (match-string 5)) t t)
830 (backward-char)))) 862 (backward-char))))
831 863
832(defun org-export-latex-protect-char-in-string (char-list string)
833 "Add org-protected text-property to char from CHAR-LIST in STRING."
834 (with-temp-buffer
835 (save-match-data
836 (insert string)
837 (goto-char (point-min))
838 (while (re-search-forward (regexp-opt char-list) nil t)
839 (add-text-properties (match-beginning 0)
840 (match-end 0) '(org-protected t)))
841 (buffer-string))))
842
843(defun org-export-latex-links () 864(defun org-export-latex-links ()
844 ;; Make sure to use the LaTeX hyperref and graphicx package 865 ;; Make sure to use the LaTeX hyperref and graphicx package
845 ;; or send some warnings. 866 ;; or send some warnings.
@@ -888,6 +909,7 @@ Regexps are those from `org-latex-special-string-regexps'."
888 (t (insert "\\texttt{" desc "}"))))))) 909 (t (insert "\\texttt{" desc "}")))))))
889 910
890 911
912;;; org-latex-cleaned-string-for-export:
891(defun org-latex-cleaned-string-for-export (string &rest parameters) 913(defun org-latex-cleaned-string-for-export (string &rest parameters)
892 "Cleanup a buffer STRING so that links can be created safely." 914 "Cleanup a buffer STRING so that links can be created safely."
893 (interactive) 915 (interactive)
@@ -988,17 +1010,6 @@ Regexps are those from `org-latex-special-string-regexps'."
988 (add-text-properties (point) (org-end-of-subtree t) 1010 (add-text-properties (point) (org-end-of-subtree t)
989 '(org-protected t))))) 1011 '(org-protected t)))))
990 1012
991 ;; Remove or replace comments
992 ;; If :comments is set, use this char for commenting out comments and
993 ;; protect them. otherwise delete them
994 (goto-char (point-min))
995 (while (re-search-forward "^#\\(.*\n?\\)" nil t)
996 (if commentsp
997 (progn (add-text-properties
998 (match-beginning 0) (match-end 0) '(org-protected t))
999 (replace-match (format commentsp (match-string 1)) t t))
1000 (replace-match "")))
1001
1002 ;; Find matches for radio targets and turn them into internal links 1013 ;; Find matches for radio targets and turn them into internal links
1003 (goto-char (point-min)) 1014 (goto-char (point-min))
1004 (when re-radio 1015 (when re-radio
@@ -1031,7 +1042,7 @@ Regexps are those from `org-latex-special-string-regexps'."
1031 (let* ((s (concat (match-string 1) "[[" (match-string 2) 1042 (let* ((s (concat (match-string 1) "[[" (match-string 2)
1032 ":" (match-string 3) "]]"))) 1043 ":" (match-string 3) "]]")))
1033 ;; added 'org-protected property to links 1044 ;; added 'org-protected property to links
1034 (add-text-properties 0 (length s) '(org-protected t) s) 1045 (put-text-property 0 (length s) 'face 'org-link s)
1035 (replace-match s t t)))) 1046 (replace-match s t t))))
1036 (goto-char (point-min)) 1047 (goto-char (point-min))
1037 (while (re-search-forward re-angle-link nil t) 1048 (while (re-search-forward re-angle-link nil t)
@@ -1039,7 +1050,7 @@ Regexps are those from `org-latex-special-string-regexps'."
1039 (org-if-unprotected 1050 (org-if-unprotected
1040 (let* ((s (concat (match-string 1) "[[" (match-string 2) 1051 (let* ((s (concat (match-string 1) "[[" (match-string 2)
1041 ":" (match-string 3) "]]"))) 1052 ":" (match-string 3) "]]")))
1042 (add-text-properties 0 (length s) '(org-protected t) s) 1053 (put-text-property 0 (length s) 'face 'org-link s)
1043 (replace-match s t t)))) 1054 (replace-match s t t))))
1044 (goto-char (point-min)) 1055 (goto-char (point-min))
1045 (while (re-search-forward org-bracket-link-regexp nil t) 1056 (while (re-search-forward org-bracket-link-regexp nil t)
@@ -1051,7 +1062,7 @@ Regexps are those from `org-latex-special-string-regexps'."
1051 (match-string 2) 1062 (match-string 2)
1052 (concat "[" xx "]")) 1063 (concat "[" xx "]"))
1053 "]"))) 1064 "]")))
1054 (add-text-properties 0 (length s) '(org-protected t) s) 1065 (put-text-property 0 (length s) 'face 'org-link s)
1055 (replace-match s t t)))) 1066 (replace-match s t t))))
1056 1067
1057 ;; Find multiline emphasis and put them into single line 1068 ;; Find multiline emphasis and put them into single line
@@ -1070,27 +1081,23 @@ Regexps are those from `org-latex-special-string-regexps'."
1070 (kill-buffer " org-mode-tmp") 1081 (kill-buffer " org-mode-tmp")
1071 rtn)) 1082 rtn))
1072 1083
1073(defsubst org-latex-protect (string)
1074 (add-text-properties 0 (length string) '(org-protected t) string)
1075 string)
1076
1077(defun org-export-latex-cleaned-string () 1084(defun org-export-latex-cleaned-string ()
1078 "Clean stuff in the LaTeX export." 1085 "Clean stuff in the LaTeX export."
1079 1086
1080 ;; preserve line breaks 1087 ;; Preserve line breaks
1081 (goto-char (point-min)) 1088 (goto-char (point-min))
1082 (while (re-search-forward "\\\\\\\\" nil t) 1089 (while (re-search-forward "\\\\\\\\" nil t)
1083 (add-text-properties (match-beginning 0) (match-end 0) 1090 (add-text-properties (match-beginning 0) (match-end 0)
1084 '(org-protected t))) 1091 '(org-protected t)))
1085 1092
1086 ;; convert LaTeX to @LaTeX{} 1093 ;; Convert LaTeX to @LaTeX{}
1087 (goto-char (point-min)) 1094 (goto-char (point-min))
1088 (let ((case-fold-search nil) rpl) 1095 (let ((case-fold-search nil) rpl)
1089 (while (re-search-forward "\\([^+_]\\)LaTeX" nil t) 1096 (while (re-search-forward "\\([^+_]\\)LaTeX" nil t)
1090 (replace-match (org-latex-protect 1097 (replace-match (org-latex-protect
1091 (concat (match-string 1) "\\LaTeX{}")) t t))) 1098 (concat (match-string 1) "\\LaTeX{}")) t t)))
1092 1099
1093 ;; convert horizontal rules 1100 ;; Convert horizontal rules
1094 (goto-char (point-min)) 1101 (goto-char (point-min))
1095 (while (re-search-forward "^----+.$" nil t) 1102 (while (re-search-forward "^----+.$" nil t)
1096 (replace-match (org-latex-protect "\\hrule") t t)) 1103 (replace-match (org-latex-protect "\\hrule") t t))
@@ -1103,10 +1110,10 @@ Regexps are those from `org-latex-special-string-regexps'."
1103 nil t) 1110 nil t)
1104 (beginning-of-line) 1111 (beginning-of-line)
1105 (org-cut-subtree)) 1112 (org-cut-subtree))
1106 1113
1107 ;; protect LaTeX \commands{...} 1114 ;; Protect LaTeX \commands{...}
1108 (goto-char (point-min)) 1115 (goto-char (point-min))
1109 (while (re-search-forward "\\\\[a-z]+{.+}" nil t) 1116 (while (re-search-forward "\\\\[a-zA-Z]+\\(?:\\[.*\\]\\)?{.*}" nil t)
1110 (add-text-properties (match-beginning 0) (match-end 0) 1117 (add-text-properties (match-beginning 0) (match-end 0)
1111 '(org-protected t))) 1118 '(org-protected t)))
1112 1119
@@ -1117,64 +1124,24 @@ Regexps are those from `org-latex-special-string-regexps'."
1117 (replace-match 1124 (replace-match
1118 (org-latex-protect (format "\\label{%s}" (match-string 1))) t t))) 1125 (org-latex-protect (format "\\label{%s}" (match-string 1))) t t)))
1119 1126
1120 ;; delete @<br /> cookies 1127 ;; Delete @<...> constructs
1121 (goto-char (point-min)) 1128 (goto-char (point-min))
1122 (while (re-search-forward "@<[^<>\n]*>" nil t) 1129 ;; Thanks to Daniel Clemente for this regexp
1130 (while (re-search-forward "@<\\(?:[^\"\n]\\|\".*\"\\)*?>" nil t)
1123 (replace-match "")) 1131 (replace-match ""))
1124 1132
1125 ;; add #+BEGIN_LaTeX before any \begin{...} 1133 ;; Add #+BEGIN_LaTeX before any \begin{...}
1126 (goto-char (point-min)) 1134 (goto-char (point-min))
1127 (while (re-search-forward "^ *\\\\begin{" nil t) 1135 (while (re-search-forward "^ *\\\\begin{" nil t)
1128 (replace-match "#+BEGIN_LaTeX:\n\\&" t)) 1136 (replace-match "#+BEGIN_LaTeX:\n\\&" t))
1129 1137
1130 ;; add #+END_LaTeX after any \end{...} 1138 ;; Add #+END_LaTeX after any \end{...}
1131 (goto-char (point-min)) 1139 (goto-char (point-min))
1132 (while (re-search-forward "^ *\\\\end{.+}.*$" nil t) 1140 (while (re-search-forward "^ *\\\\end{.+}.*$" nil t)
1133 (replace-match "\\&\n#+END_LaTeX" t)) 1141 (replace-match "\\&\n#+END_LaTeX" t))
1134 1142
1135 ;; When converting to LaTeX, replace footnotes
1136 ;; FIXME: don't protect footnotes from conversion
1137 (when (plist-get org-latex-options-plist :footnotes)
1138 (goto-char (point-min))
1139 (while (re-search-forward "\\[[0-9]+\\]" nil t)
1140 (when (save-match-data
1141 (save-excursion (beginning-of-line)
1142 (looking-at "[^:|]")))
1143 (let ((foot-beg (match-beginning 0))
1144 (foot-end (match-end 0))
1145 (foot-prefix (match-string 0))
1146 footnote footnote-rpl)
1147 (when (and (re-search-forward (regexp-quote foot-prefix) nil t))
1148 (replace-match "")
1149 (let ((end (save-excursion
1150 (if (re-search-forward "^$\\|\\[[0-9]+\\]" nil t)
1151 (match-beginning 0) (point-max)))))
1152 (setq footnote (concat
1153 (org-trim (buffer-substring (point) end))
1154 ;; FIXME stupid workaround for cases where
1155 ;; `org-bracket-link-analytic-regexp' matches
1156 ;; }. as part of the link.
1157 " "))
1158 (delete-region (point) end)))
1159 (goto-char foot-beg)
1160 (delete-region foot-beg foot-end)
1161 (setq footnote-rpl (format "\\footnote{%s}" footnote))
1162 (add-text-properties 0 1 '(org-protected t) footnote-rpl)
1163 (add-text-properties 9 10 '(org-protected t) footnote-rpl)
1164 (add-text-properties (1- (length footnote-rpl))
1165 (length footnote-rpl)
1166 '(org-protected t) footnote-rpl)
1167 (insert footnote-rpl))))
1168
1169 ;; Replace footnote section tag for LaTeX
1170 (goto-char (point-min))
1171 (while (re-search-forward
1172 (concat "^" footnote-section-tag-regexp) nil t)
1173 (replace-match "")))
1174
1175 ;; Protect stuff from LaTeX processing. 1143 ;; Protect stuff from LaTeX processing.
1176 ;; We will get rid on this once org.el integrate org-export-latex.el 1144 ;; We will get rid on this once org.el integrate org-export-latex.el
1177 ;; FIXME: #+LaTeX should be aware of the preceeding indentation in lists
1178 (goto-char (point-min)) 1145 (goto-char (point-min))
1179 (let ((formatters `((,latexp "LaTeX" "BEGIN_LaTeX" "END_LaTeX"))) fmt) 1146 (let ((formatters `((,latexp "LaTeX" "BEGIN_LaTeX" "END_LaTeX"))) fmt)
1180 (while (re-search-forward "^[ \t]*:.*\\(\n[ \t]*:.*\\)*" nil t) 1147 (while (re-search-forward "^[ \t]*:.*\\(\n[ \t]*:.*\\)*" nil t)
@@ -1185,7 +1152,10 @@ Regexps are those from `org-latex-special-string-regexps'."
1185 (when (car fmt) 1152 (when (car fmt)
1186 (goto-char (point-min)) 1153 (goto-char (point-min))
1187 (while (re-search-forward (concat "^#\\+" (cadr fmt) 1154 (while (re-search-forward (concat "^#\\+" (cadr fmt)
1188 ":[ \t]*\\(.*\\)") nil t) 1155 ;; ":[ \t]*\\(.*\\)") nil t)
1156 ;; FIXME: authorize spaces after #+LaTeX:
1157 ;; to get list correctly exported
1158 ":\\(.*\\)") nil t)
1189 (replace-match "\\1" t) 1159 (replace-match "\\1" t)
1190 (add-text-properties 1160 (add-text-properties
1191 (point-at-bol) (min (1+ (point-at-eol)) (point-max)) 1161 (point-at-bol) (min (1+ (point-at-eol)) (point-max))
@@ -1204,9 +1174,59 @@ Regexps are those from `org-latex-special-string-regexps'."
1204 (goto-char (match-beginning 0)) 1174 (goto-char (match-beginning 0))
1205 (end-of-line 1) 1175 (end-of-line 1)
1206 (add-text-properties (point) (org-end-of-subtree t) 1176 (add-text-properties (point) (org-end-of-subtree t)
1207 '(org-protected t)))))) 1177 '(org-protected t)))))
1178
1179 ;; Remove or replace comments
1180 ;; If :comments is set, use this char for commenting out comments and
1181 ;; protect them. otherwise delete them
1182 (goto-char (point-min))
1183 (while (re-search-forward "^#\\(.*\n?\\)" nil t)
1184 (if commentsp
1185 (progn (add-text-properties
1186 (match-beginning 0) (match-end 0) '(org-protected t))
1187 (replace-match (format commentsp (match-string 1)) t t))
1188 (replace-match "")))
1189
1190 ;; When converting to LaTeX, replace footnotes
1191 ;; FIXME: don't protect footnotes from conversion
1192 (when (plist-get org-latex-options-plist :footnotes)
1193 (goto-char (point-min))
1194 (while (re-search-forward "\\[[0-9]+\\]" nil t)
1195 (when (save-match-data
1196 (save-excursion (beginning-of-line)
1197 (looking-at "[^:|]")))
1198 (let ((foot-beg (match-beginning 0))
1199 (foot-end (match-end 0))
1200 (foot-prefix (match-string 0))
1201 footnote footnote-rpl)
1202 (when (and (re-search-forward (regexp-quote foot-prefix) nil t))
1203 (replace-match "")
1204 (let ((end (save-excursion
1205 (if (re-search-forward "^$\\|\\[[0-9]+\\]" nil t)
1206 (match-beginning 0) (point-max)))))
1207 (setq footnote
1208 (concat
1209 (org-trim (buffer-substring (point) end))
1210 ;; FIXME stupid workaround for cases where
1211 ;; `org-bracket-link-analytic-regexp' matches
1212 ;; }. as part of the link.
1213 " "))
1214 (delete-region (point) end)))
1215 (goto-char foot-beg)
1216 (delete-region foot-beg foot-end)
1217 (setq footnote-rpl (format "\\footnote{%s}" footnote))
1218 (add-text-properties 0 10 '(org-protected t) footnote-rpl)
1219 (add-text-properties (1- (length footnote-rpl))
1220 (length footnote-rpl)
1221 '(org-protected t) footnote-rpl)
1222 (insert footnote-rpl))))
1223
1224 ;; Replace footnote section tag for LaTeX
1225 (goto-char (point-min))
1226 (while (re-search-forward
1227 (concat "^" footnote-section-tag-regexp) nil t)
1228 (replace-match ""))))
1208 1229
1209(provide 'org-export-latex) 1230(provide 'org-export-latex)
1210 1231
1211;; arch-tag: 23c2b87d-da04-4c2d-ad2d-1eb6487bc3ad
1212;;; org-export-latex.el ends here 1232;;; org-export-latex.el ends here
diff --git a/lisp/textmodes/org-publish.el b/lisp/textmodes/org-publish.el
index a72b477d0b2..cdfc673b0f3 100644
--- a/lisp/textmodes/org-publish.el
+++ b/lisp/textmodes/org-publish.el
@@ -6,9 +6,11 @@
6;; Keywords: hypermedia, outlines 6;; Keywords: hypermedia, outlines
7;; Version: 1.80 7;; Version: 1.80
8 8
9;; $Id: org-publish.el,v 1.80 2007/03/22 02:31:03 dto Exp dto $
10
9;; This file is free software; you can redistribute it and/or modify 11;; This file is free software; you can redistribute it and/or modify
10;; it under the terms of the GNU General Public License as published by 12;; it under the terms of the GNU General Public License as published by
11;; the Free Software Foundation; either version 3, or (at your option) 13;; the Free Software Foundation; either version 2, or (at your option)
12;; any later version. 14;; any later version.
13 15
14;; This file is distributed in the hope that it will be useful, 16;; This file is distributed in the hope that it will be useful,
@@ -617,6 +619,4 @@ With prefix argument, force publish all files."
617 619
618 620
619(provide 'org-publish) 621(provide 'org-publish)
620
621;; arch-tag: 72807f3c-8af0-4a6b-8dca-c3376eb25adb
622;;; org-publish.el ends here 622;;; org-publish.el ends here
diff --git a/lisp/textmodes/org.el b/lisp/textmodes/org.el
index 55aa0b82684..97bde491dfb 100644
--- a/lisp/textmodes/org.el
+++ b/lisp/textmodes/org.el
@@ -2,9 +2,9 @@
2;; Carstens outline-mode for keeping track of everything. 2;; Carstens outline-mode for keeping track of everything.
3;; Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc. 3;; Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
4;; 4;;
5;; Author: Carsten Dominik <dominik at science dot uva dot nl> 5;; Author: Carsten Dominik <carsten at orgmode dot org>
6;; Keywords: outlines, hypermedia, calendar, wp 6;; Keywords: outlines, hypermedia, calendar, wp
7;; Homepage: http://www.astro.uva.nl/~dominik/Tools/org/ 7;; Homepage: http://orgmode.org
8;; Version: 5.08 8;; Version: 5.08
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
@@ -49,7 +49,7 @@
49;; --------------------------- 49;; ---------------------------
50;; See the corresponding sections in the manual at 50;; See the corresponding sections in the manual at
51;; 51;;
52;; http://staff.science.uva.nl/~dominik/Tools/org/org.html#Installation 52;; http://orgmode.org/org.html#Installation
53;; 53;;
54;; Documentation 54;; Documentation
55;; ------------- 55;; -------------
@@ -60,7 +60,7 @@
60;; in the etc/ directory of Emacs 22. 60;; in the etc/ directory of Emacs 22.
61;; 61;;
62;; A list of recent changes can be found at 62;; A list of recent changes can be found at
63;; http://www.astro.uva.nl/~dominik/Tools/org/Changes 63;; http://orgmode.org/Changes
64;; 64;;
65;;; Code: 65;;; Code:
66 66
@@ -83,7 +83,7 @@
83 83
84;;; Version 84;;; Version
85 85
86(defconst org-version "5.07" 86(defconst org-version "5.08"
87 "The version number of the file org.el.") 87 "The version number of the file org.el.")
88(defun org-version () 88(defun org-version ()
89 (interactive) 89 (interactive)
@@ -109,6 +109,8 @@
109 (save-match-data 109 (save-match-data
110 (while (string-match "\\[:alnum:\\]" ss) 110 (while (string-match "\\[:alnum:\\]" ss)
111 (setq ss (replace-match "a-zA-Z0-9" t t ss))) 111 (setq ss (replace-match "a-zA-Z0-9" t t ss)))
112 (while (string-match "\\[:alpha:\\]" ss)
113 (setq ss (replace-match "a-zA-Z" t t ss)))
112 ss)) 114 ss))
113 s)) 115 s))
114 116
@@ -1508,8 +1510,6 @@ taken from the (otherwise obsolete) variable `org-todo-interpretation'."
1508 1510
1509(defvar org-todo-keywords-1 nil) 1511(defvar org-todo-keywords-1 nil)
1510(make-variable-buffer-local 'org-todo-keywords-1) 1512(make-variable-buffer-local 'org-todo-keywords-1)
1511(defvar org-todo-tag-alist nil)
1512(make-variable-buffer-local 'org-todo-tag-alist)
1513(defvar org-todo-keywords-for-agenda nil) 1513(defvar org-todo-keywords-for-agenda nil)
1514(defvar org-done-keywords-for-agenda nil) 1514(defvar org-done-keywords-for-agenda nil)
1515(defvar org-not-done-keywords nil) 1515(defvar org-not-done-keywords nil)
@@ -1522,6 +1522,10 @@ taken from the (otherwise obsolete) variable `org-todo-interpretation'."
1522(make-variable-buffer-local 'org-todo-sets) 1522(make-variable-buffer-local 'org-todo-sets)
1523(defvar org-todo-kwd-alist nil) 1523(defvar org-todo-kwd-alist nil)
1524(make-variable-buffer-local 'org-todo-kwd-alist) 1524(make-variable-buffer-local 'org-todo-kwd-alist)
1525(defvar org-todo-key-alist nil)
1526(make-variable-buffer-local 'org-todo-key-alist)
1527(defvar org-todo-key-trigger nil)
1528(make-variable-buffer-local 'org-todo-key-trigger)
1525 1529
1526(defcustom org-todo-interpretation 'sequence 1530(defcustom org-todo-interpretation 'sequence
1527 "Controls how TODO keywords are interpreted. 1531 "Controls how TODO keywords are interpreted.
@@ -1534,6 +1538,30 @@ more information."
1534 :type '(choice (const sequence) 1538 :type '(choice (const sequence)
1535 (const type))) 1539 (const type)))
1536 1540
1541(defcustom org-use-fast-todo-selection 'prefix
1542 "Non-nil means, use the fast todo selection scheme with C-c C-t.
1543This variable describes if and under what circumstances the cycling
1544mechanism for TODO keywords will be replaced by a single-key, direct
1545selection scheme.
1546
1547When nil, fast selection is never used.
1548
1549When the symbol `prefix', it will be used when `org-todo' is called with
1550a prefix argument, i.e. `C-u C-c C-t' in an Org-mode buffer, and `C-u t'
1551in an agenda buffer.
1552
1553When t, fast selection is used by default. In this case, the prefix
1554argument forces cycling instead.
1555
1556In all cases, the special interface is only used if access keys have actually
1557been assigned by the user, i.e. if keywords in the configuration are followed
1558by a letter in parenthesis, like TODO(t)."
1559 :group 'org-todo
1560 :type '(choice
1561 (const :tag "Never" nil)
1562 (const :tag "By default" t)
1563 (const :tag "Only with C-u C-c C-t" prefix)))
1564
1537(defcustom org-after-todo-state-change-hook nil 1565(defcustom org-after-todo-state-change-hook nil
1538 "Hook which is run after the state of a TODO item was changed. 1566 "Hook which is run after the state of a TODO item was changed.
1539The new state (a string with a TODO keyword, or nil) is available in the 1567The new state (a string with a TODO keyword, or nil) is available in the
@@ -1543,8 +1571,8 @@ Lisp variable `state'."
1543 1571
1544(defcustom org-log-done nil 1572(defcustom org-log-done nil
1545 "When set, insert a (non-active) time stamp when TODO entry is marked DONE. 1573 "When set, insert a (non-active) time stamp when TODO entry is marked DONE.
1546When the state of an entry is changed from nothing to TODO, remove a previous 1574When the state of an entry is changed from nothing or a DONE state to
1547closing date. 1575a not-done TODO state, remove a previous closing date.
1548 1576
1549This can also be a list of symbols indicating under which conditions 1577This can also be a list of symbols indicating under which conditions
1550the time stamp recording the action should be annotated with a short note. 1578the time stamp recording the action should be annotated with a short note.
@@ -1713,9 +1741,11 @@ end of the second format."
1713 (concat "[" (substring f 1 -1) "]") 1741 (concat "[" (substring f 1 -1) "]")
1714 f))) 1742 f)))
1715 1743
1716(defcustom org-deadline-warning-days 30 1744(defcustom org-deadline-warning-days 14
1717 "No. of days before expiration during which a deadline becomes active. 1745 "No. of days before expiration during which a deadline becomes active.
1718This variable governs the display in sparse trees and in the agenda." 1746This variable governs the display in sparse trees and in the agenda.
1747When negative, it means use this number (the absolute value of it)
1748even if a deadline has a different individual lead time specified."
1719 :group 'org-time 1749 :group 'org-time
1720 :type 'number) 1750 :type 'number)
1721 1751
@@ -1727,6 +1757,12 @@ When nil, only the minibuffer will be available."
1727 :group 'org-time 1757 :group 'org-time
1728 :type 'boolean) 1758 :type 'boolean)
1729 1759
1760(defcustom org-edit-timestamp-down-means-later nil
1761 "Non-nil means, S-down will increase the time in a time stamp.
1762When nil, S-up will increase."
1763 :group 'org-time
1764 :type 'boolean)
1765
1730(defcustom org-calendar-follow-timestamp-change t 1766(defcustom org-calendar-follow-timestamp-change t
1731 "Non-nil means, make the calendar window follow timestamp changes. 1767 "Non-nil means, make the calendar window follow timestamp changes.
1732When a timestamp is modified and the calendar window is visible, it will be 1768When a timestamp is modified and the calendar window is visible, it will be
@@ -1743,9 +1779,10 @@ moved to the new date."
1743 "List of tags allowed in Org-mode files. 1779 "List of tags allowed in Org-mode files.
1744When this list is nil, Org-mode will base TAG input on what is already in the 1780When this list is nil, Org-mode will base TAG input on what is already in the
1745buffer. 1781buffer.
1746The value of this variable is an alist, the car may be (and should) be a 1782The value of this variable is an alist, the car of each entry must be a
1747character that is used to select that tag through the fast-tag-selection 1783keyword as a string, the cdr may be a character that is used to select
1748interface. See the manual for details." 1784that tag through the fast-tag-selection interface.
1785See the manual for details."
1749 :group 'org-tags 1786 :group 'org-tags
1750 :type '(repeat 1787 :type '(repeat
1751 (choice 1788 (choice
@@ -1781,6 +1818,12 @@ displaying the tags menu is not even shown, until you press C-c again."
1781 (const :tag "Yes" t) 1818 (const :tag "Yes" t)
1782 (const :tag "Expert" expert))) 1819 (const :tag "Expert" expert)))
1783 1820
1821(defcustom org-fast-tag-selection-include-todo nil
1822 "Non-nil means, fast tags selection interface will also offer TODO states."
1823 :group 'org-tags
1824 :group 'org-todo
1825 :type 'boolean)
1826
1784(defcustom org-tags-column 48 1827(defcustom org-tags-column 48
1785 "The column to which tags should be indented in a headline. 1828 "The column to which tags should be indented in a headline.
1786If this number is positive, it specifies the column. If it is negative, 1829If this number is positive, it specifies the column. If it is negative,
@@ -2601,8 +2644,8 @@ directory where the exported Org-mode files lives."
2601 ("cs" "Autor" "Datum" "Obsah") 2644 ("cs" "Autor" "Datum" "Obsah")
2602 ("da" "Ophavsmand" "Dato" "Indhold") 2645 ("da" "Ophavsmand" "Dato" "Indhold")
2603 ("de" "Autor" "Datum" "Inhaltsverzeichnis") 2646 ("de" "Autor" "Datum" "Inhaltsverzeichnis")
2604 ("es" "Autor" "Fecha" "\xccndice") 2647 ("es" "Autor" "Fecha" "\xcdndice")
2605 ("fr" "Auteur" "Date" "Table des Mati\xe8res") 2648 ("fr" "Auteur" "Date" "Table des mati\xe8res")
2606 ("it" "Autore" "Data" "Indice") 2649 ("it" "Autore" "Data" "Indice")
2607 ("nl" "Auteur" "Datum" "Inhoudsopgave") 2650 ("nl" "Auteur" "Datum" "Inhoudsopgave")
2608 ("nn" "Forfattar" "Dato" "Innhold") ;; nn = Norsk (nynorsk) 2651 ("nn" "Forfattar" "Dato" "Innhold") ;; nn = Norsk (nynorsk)
@@ -3730,8 +3773,9 @@ means to push this value onto the list in the variable.")
3730 "Precompute regular expressions for current buffer." 3773 "Precompute regular expressions for current buffer."
3731 (when (org-mode-p) 3774 (when (org-mode-p)
3732 (org-set-local 'org-todo-kwd-alist nil) 3775 (org-set-local 'org-todo-kwd-alist nil)
3776 (org-set-local 'org-todo-key-alist nil)
3777 (org-set-local 'org-todo-key-trigger nil)
3733 (org-set-local 'org-todo-keywords-1 nil) 3778 (org-set-local 'org-todo-keywords-1 nil)
3734 (org-set-local 'org-todo-tag-alist nil)
3735 (org-set-local 'org-done-keywords nil) 3779 (org-set-local 'org-done-keywords nil)
3736 (org-set-local 'org-todo-heads nil) 3780 (org-set-local 'org-todo-heads nil)
3737 (org-set-local 'org-todo-sets nil) 3781 (org-set-local 'org-todo-sets nil)
@@ -3823,20 +3867,25 @@ means to push this value onto the list in the variable.")
3823 (string-to-char 3867 (string-to-char
3824 (match-string 2 x))) kwsa) 3868 (match-string 2 x))) kwsa)
3825 (match-string 1 x)) 3869 (match-string 1 x))
3870 (push (list x) kwsa)
3826 x)) 3871 x))
3827 kws0) 3872 kws0)
3828 kwsa (if kwsa (append '((:startgroup)) kwsa '((:endgroup)))) 3873 kwsa (if kwsa (append '((:startgroup))
3874 (nreverse kwsa)
3875 '((:endgroup))))
3829 hw (car kws1) 3876 hw (car kws1)
3830 dws (if sep (org-remove-keyword-keys (cdr sep)) (last kws1)) 3877 dws (if sep (org-remove-keyword-keys (cdr sep)) (last kws1))
3831 tail (list inter hw (car dws) (org-last dws))) 3878 tail (list inter hw (car dws) (org-last dws)))
3832 (add-to-list 'org-todo-heads hw 'append) 3879 (add-to-list 'org-todo-heads hw 'append)
3833 (push kws1 org-todo-sets) 3880 (push kws1 org-todo-sets)
3834 (setq org-done-keywords (append org-done-keywords dws nil)) 3881 (setq org-done-keywords (append org-done-keywords dws nil))
3835 (setq org-todo-tag-alist (append org-todo-tag-alist kwsa)) 3882 (setq org-todo-key-alist (append org-todo-key-alist kwsa))
3836 (mapc (lambda (x) (push (cons x tail) org-todo-kwd-alist)) kws1) 3883 (mapc (lambda (x) (push (cons x tail) org-todo-kwd-alist)) kws1)
3837 (setq org-todo-keywords-1 (append org-todo-keywords-1 kws1 nil))) 3884 (setq org-todo-keywords-1 (append org-todo-keywords-1 kws1 nil)))
3838 (setq org-todo-sets (nreverse org-todo-sets) 3885 (setq org-todo-sets (nreverse org-todo-sets)
3839 org-todo-kwd-alist (nreverse org-todo-kwd-alist))) 3886 org-todo-kwd-alist (nreverse org-todo-kwd-alist)
3887 org-todo-key-trigger (delq nil (mapcar 'cdr org-todo-key-alist))
3888 org-todo-key-alist (org-assign-fast-keys org-todo-key-alist)))
3840 ;; Process the constants 3889 ;; Process the constants
3841 (when const 3890 (when const
3842 (let (e cst) 3891 (let (e cst)
@@ -4642,7 +4691,7 @@ between words."
4642 4691
4643(defvar org-font-lock-keywords nil) 4692(defvar org-font-lock-keywords nil)
4644 4693
4645(defconst org-property-re "^[ \t]*\\(:\\([a-zA-Z_0-9]+\\):\\)[ \t]*\\(\\S-.*\\)" 4694(defconst org-property-re (org-re "^[ \t]*\\(:\\([[:alnum:]_]+\\):\\)[ \t]*\\(\\S-.*\\)")
4646 "Regular expression matching a property line.") 4695 "Regular expression matching a property line.")
4647 4696
4648(defun org-set-font-lock-defaults () 4697(defun org-set-font-lock-defaults ()
@@ -4735,7 +4784,6 @@ between words."
4735 ((eq n 2) org-f) 4784 ((eq n 2) org-f)
4736 (t (if org-level-color-stars-only nil org-f)))) 4785 (t (if org-level-color-stars-only nil org-f))))
4737 4786
4738
4739(defun org-get-todo-face (kwd) 4787(defun org-get-todo-face (kwd)
4740 "Get the right face for a TODO keyword KWD. 4788 "Get the right face for a TODO keyword KWD.
4741If KWD is a number, get the corresponding match group." 4789If KWD is a number, get the corresponding match group."
@@ -5710,16 +5758,15 @@ If optional TREE is given, use this text instead of the kill ring."
5710 (replace-match "\n")) 5758 (replace-match "\n"))
5711 (goto-char beg) 5759 (goto-char beg)
5712 ;; Shift if necessary 5760 ;; Shift if necessary
5713 (if (= shift 0) 5761 (unless (= shift 0)
5714 (message "Pasted at level %d, without shift" new-level)
5715 (save-restriction 5762 (save-restriction
5716 (narrow-to-region beg end) 5763 (narrow-to-region beg end)
5717 (while (not (= shift 0)) 5764 (while (not (= shift 0))
5718 (org-map-region func (point-min) (point-max)) 5765 (org-map-region func (point-min) (point-max))
5719 (setq shift (+ delta shift))) 5766 (setq shift (+ delta shift)))
5720 (goto-char (point-min)) 5767 (goto-char (point-min))))
5721 (message "Pasted at level %d, with shift by %d levels" 5768 (when (interactive-p)
5722 new-level shift1))) 5769 (message "Clipboard pasted as level %d subtree" new-level))
5723 (if (and kill-ring 5770 (if (and kill-ring
5724 (eq org-subtree-clip (current-kill 0)) 5771 (eq org-subtree-clip (current-kill 0))
5725 org-subtree-clip-folded) 5772 org-subtree-clip-folded)
@@ -10922,8 +10969,8 @@ For file links, arg negates `org-context-in-file-links'."
10922 (if (and (interactive-p) link) 10969 (if (and (interactive-p) link)
10923 (progn 10970 (progn
10924 (setq org-stored-links 10971 (setq org-stored-links
10925 (cons (list cpltxt link desc) org-stored-links)) 10972 (cons (list link desc) org-stored-links))
10926 (message "Stored: %s" (or cpltxt link))) 10973 (message "Stored: %s" (or desc link)))
10927 (and link (org-make-link-string link desc))))) 10974 (and link (org-make-link-string link desc)))))
10928 10975
10929(defun org-store-link-props (&rest plist) 10976(defun org-store-link-props (&rest plist)
@@ -11172,7 +11219,10 @@ With three \\[universal-argument] prefixes, negate the meaning of
11172 (princ "Insert a link. Use TAB to complete valid link prefixes.\n") 11219 (princ "Insert a link. Use TAB to complete valid link prefixes.\n")
11173 (when org-stored-links 11220 (when org-stored-links
11174 (princ "\nStored links are available with <up>/<down> (most recent with RET):\n\n") 11221 (princ "\nStored links are available with <up>/<down> (most recent with RET):\n\n")
11175 (princ (mapconcat 'car (reverse org-stored-links) "\n")))) 11222 (princ (mapconcat
11223 (lambda (x)
11224 (if (nth 1 x) (concat (car x) " (" (nth 1 x) ")") (car x)))
11225 (reverse org-stored-links) "\n"))))
11176 (let ((cw (selected-window))) 11226 (let ((cw (selected-window)))
11177 (select-window (get-buffer-window "*Org Links*")) 11227 (select-window (get-buffer-window "*Org Links*"))
11178 (shrink-window-if-larger-than-buffer) 11228 (shrink-window-if-larger-than-buffer)
@@ -11200,9 +11250,8 @@ With three \\[universal-argument] prefixes, negate the meaning of
11200 (not org-keep-stored-link-after-insertion)) 11250 (not org-keep-stored-link-after-insertion))
11201 (setq org-stored-links (delq (assoc link org-stored-links) 11251 (setq org-stored-links (delq (assoc link org-stored-links)
11202 org-stored-links))) 11252 org-stored-links)))
11203 (setq link (if entry (nth 1 entry) link) 11253 (setq desc (or region desc (nth 1 entry)))))
11204 desc (or region desc (nth 2 entry))))) 11254
11205
11206 (if (string-match org-plain-link-re link) 11255 (if (string-match org-plain-link-re link)
11207 ;; URL-like link, normalize the use of angular brackets. 11256 ;; URL-like link, normalize the use of angular brackets.
11208 (setq link (org-make-link (org-remove-angle-brackets link)))) 11257 (setq link (org-make-link (org-remove-angle-brackets link))))
@@ -11222,6 +11271,7 @@ With three \\[universal-argument] prefixes, negate the meaning of
11222 ;; Check if we can/should use a relative path. If yes, simplify the link 11271 ;; Check if we can/should use a relative path. If yes, simplify the link
11223 (when (string-match "\\<file:\\(.*\\)" link) 11272 (when (string-match "\\<file:\\(.*\\)" link)
11224 (let* ((path (match-string 1 link)) 11273 (let* ((path (match-string 1 link))
11274 (desc-is-link (equal link desc))
11225 (case-fold-search nil)) 11275 (case-fold-search nil))
11226 (cond 11276 (cond
11227 ((eq org-link-file-path-type 'absolute) 11277 ((eq org-link-file-path-type 'absolute)
@@ -11239,7 +11289,8 @@ With three \\[universal-argument] prefixes, negate the meaning of
11239 ;; We are linking a file with relative path name. 11289 ;; We are linking a file with relative path name.
11240 (setq path (substring (expand-file-name path) 11290 (setq path (substring (expand-file-name path)
11241 (match-end 0))))))) 11291 (match-end 0)))))))
11242 (setq link (concat "file:" path)))) 11292 (setq link (concat "file:" path))
11293 (if desc (setq desc link))))
11243 11294
11244 (setq desc (read-string "Description: " desc)) 11295 (setq desc (read-string "Description: " desc))
11245 (unless (string-match "\\S-" desc) (setq desc nil)) 11296 (unless (string-match "\\S-" desc) (setq desc nil))
@@ -12190,6 +12241,9 @@ to be run from that hook to fucntion properly."
12190 (v-U (concat "[" (substring v-T 1 -1) "]")) 12241 (v-U (concat "[" (substring v-T 1 -1) "]"))
12191 (v-i initial) ; defined in `remember-mode' 12242 (v-i initial) ; defined in `remember-mode'
12192 (v-a (if (equal annotation "[[]]") "" annotation)) ; likewise 12243 (v-a (if (equal annotation "[[]]") "" annotation)) ; likewise
12244 (v-A (if (string-match "\\[\\(\\[.*?\\]\\)\\(\\[.*?\\]\\)?\\]" v-a)
12245 (replace-match "[\\1[%^{Link description}]]" nil nil v-a)
12246 v-a))
12193 (v-n user-full-name) 12247 (v-n user-full-name)
12194 (org-startup-folded nil) 12248 (org-startup-folded nil)
12195 org-time-was-given org-end-time-was-given x prompt char time) 12249 org-time-was-given org-end-time-was-given x prompt char time)
@@ -12209,7 +12263,7 @@ to be run from that hook to fucntion properly."
12209 (or headline "")))) 12263 (or headline ""))))
12210 (insert tpl) (goto-char (point-min)) 12264 (insert tpl) (goto-char (point-min))
12211 ;; Simple %-escapes 12265 ;; Simple %-escapes
12212 (while (re-search-forward "%\\([tTuUai]\\)" nil t) 12266 (while (re-search-forward "%\\([tTuUaiA]\\)" nil t)
12213 (when (and initial (equal (match-string 0) "%i")) 12267 (when (and initial (equal (match-string 0) "%i"))
12214 (save-match-data 12268 (save-match-data
12215 (let* ((lead (buffer-substring 12269 (let* ((lead (buffer-substring
@@ -12708,6 +12762,12 @@ For calling through lisp, arg is also interpreted in the following way:
12708\"WAITING\" -> switch to the specified keyword, but only if it 12762\"WAITING\" -> switch to the specified keyword, but only if it
12709 really is a member of `org-todo-keywords'." 12763 really is a member of `org-todo-keywords'."
12710 (interactive "P") 12764 (interactive "P")
12765 (when (and org-todo-key-trigger ; keys have been set up by the user
12766 (or (and (equal arg '(4)) (eq org-use-fast-todo-selection 'prefix))
12767 (and (not arg) org-use-fast-todo-selection
12768 (not (eq org-use-fast-todo-selection 'prefix)))))
12769 ;; Get the keyword with direct selction
12770 (setq arg (org-fast-todo-selection)))
12711 (save-excursion 12771 (save-excursion
12712 (org-back-to-heading) 12772 (org-back-to-heading)
12713 (if (looking-at outline-regexp) (goto-char (1- (match-end 0)))) 12773 (if (looking-at outline-regexp) (goto-char (1- (match-end 0))))
@@ -12724,6 +12784,7 @@ For calling through lisp, arg is also interpreted in the following way:
12724 (member (member this org-todo-keywords-1)) 12784 (member (member this org-todo-keywords-1))
12725 (tail (cdr member)) 12785 (tail (cdr member))
12726 (state (cond 12786 (state (cond
12787 ;; FIXME: most the fast interface here
12727 ((equal arg '(4)) 12788 ((equal arg '(4))
12728 ;; Read a state with completion 12789 ;; Read a state with completion
12729 (completing-read "State: " (mapcar (lambda(x) (list x)) 12790 (completing-read "State: " (mapcar (lambda(x) (list x))
@@ -12789,14 +12850,18 @@ For calling through lisp, arg is also interpreted in the following way:
12789 (setq dostates (and (eq interpret 'sequence) 12850 (setq dostates (and (eq interpret 'sequence)
12790 (listp org-log-done) (memq 'state org-log-done))) 12851 (listp org-log-done) (memq 'state org-log-done)))
12791 (cond 12852 (cond
12792 ((and state (not this)) 12853 ((and state (member state org-not-done-keywords)
12793 ;; FIXME: should we remove CLOSED already then state is nil? 12854 (not (member this org-not-done-keywords)))
12855 ;; This is now a todo state and was not one before
12856 ;; Remove any CLOSED timestamp, and possibly log the state change
12794 (org-add-planning-info nil nil 'closed) 12857 (org-add-planning-info nil nil 'closed)
12795 (and dostates (org-add-log-maybe 'state state 'findpos))) 12858 (and dostates (org-add-log-maybe 'state state 'findpos)))
12796 ((and state dostates) 12859 ((and state dostates)
12860 ;; This is a non-nil state, and we need to log it
12797 (org-add-log-maybe 'state state 'findpos)) 12861 (org-add-log-maybe 'state state 'findpos))
12798 ((member state org-done-keywords) 12862 ((and (member state org-done-keywords)
12799 ;; Planning info calls the note-setting command. 12863 (not (member this org-done-keywords)))
12864 ;; It is now done, and it was not done before
12800 ;; FIXME: We used to remove scheduling info.... 12865 ;; FIXME: We used to remove scheduling info....
12801; (org-add-planning-info 'closed (org-current-time) 12866; (org-add-planning-info 'closed (org-current-time)
12802; (if (org-get-repeat) nil 'scheduled)) 12867; (if (org-get-repeat) nil 'scheduled))
@@ -12835,6 +12900,68 @@ right sequence."
12835 (car org-todo-keywords-1)) 12900 (car org-todo-keywords-1))
12836 (t (nth 2 (assoc kwd org-todo-kwd-alist)))))) 12901 (t (nth 2 (assoc kwd org-todo-kwd-alist))))))
12837 12902
12903(defun org-fast-todo-selection ()
12904 "Fast TODO keyword selection with single keys.
12905Returns the new TODO keyword, or nil if no state change should occur."
12906 (let* ((fulltable org-todo-key-alist)
12907 (done-keywords org-done-keywords) ;; needed for the faces.
12908 (maxlen (apply 'max (mapcar
12909 (lambda (x)
12910 (if (stringp (car x)) (string-width (car x)) 0))
12911 fulltable)))
12912 (buf (current-buffer))
12913 (expert nil)
12914 (fwidth (+ maxlen 3 1 3))
12915 (ncol (/ (- (window-width) 4) fwidth))
12916 tg cnt e c char c1 c2 ntable tbl rtn
12917 groups ingroup)
12918 (save-window-excursion
12919 (if expert
12920 (set-buffer (get-buffer-create " *Org todo*"))
12921; (delete-other-windows)
12922; (split-window-vertically)
12923 (org-switch-to-buffer-other-window (get-buffer-create " *Org tags*")))
12924 (erase-buffer)
12925 (org-set-local 'org-done-keywords done-keywords)
12926 (setq tbl fulltable char ?a cnt 0)
12927 (while (setq e (pop tbl))
12928 (cond
12929 ((equal e '(:startgroup))
12930 (push '() groups) (setq ingroup t)
12931 (when (not (= cnt 0))
12932 (setq cnt 0)
12933 (insert "\n"))
12934 (insert "{ "))
12935 ((equal e '(:endgroup))
12936 (setq ingroup nil cnt 0)
12937 (insert "}\n"))
12938 (t
12939 (setq tg (car e) c (cdr e))
12940 (if ingroup (push tg (car groups)))
12941 (setq tg (org-add-props tg nil 'face
12942 (org-get-todo-face tg)))
12943 (if (and (= cnt 0) (not ingroup)) (insert " "))
12944 (insert "[" c "] " tg (make-string
12945 (- fwidth 4 (length tg)) ?\ ))
12946 (when (= (setq cnt (1+ cnt)) ncol)
12947 (insert "\n")
12948 (if ingroup (insert " "))
12949 (setq cnt 0)))))
12950 (insert "\n")
12951 (goto-char (point-min))
12952 (if (and (not expert) (fboundp 'fit-window-to-buffer))
12953 (fit-window-to-buffer))
12954 (message "[a-z..]:Set [SPC]:clear")
12955 (setq c (let ((inhibit-quit t)) (read-char-exclusive)))
12956 (cond
12957 ((or (= c ?\C-g)
12958 (and (= c ?q) (not (rassoc c fulltable))))
12959 (setq quit-flag t))
12960 ((= c ?\ ) 'none)
12961 ((setq e (rassoc c fulltable) tg (car e))
12962 tg)
12963 (t (setq quit-flag t))))))
12964
12838(defun org-get-repeat () 12965(defun org-get-repeat ()
12839 "Check if tere is a deadline/schedule with repeater in this entry." 12966 "Check if tere is a deadline/schedule with repeater in this entry."
12840 (save-match-data 12967 (save-match-data
@@ -13048,7 +13175,7 @@ The auto-repeater uses this.")
13048 (org-switch-to-buffer-other-window "*Org Note*") 13175 (org-switch-to-buffer-other-window "*Org Note*")
13049 (erase-buffer) 13176 (erase-buffer)
13050 (let ((org-inhibit-startup t)) (org-mode)) 13177 (let ((org-inhibit-startup t)) (org-mode))
13051 (insert (format "# Insert note for %s, finish with C-c C-c.\n\n" 13178 (insert (format "# Insert note for %s, finish with C-c C-c, or cancel with C-u C-c C-c.\n\n"
13052 (cond 13179 (cond
13053 ((eq org-log-note-purpose 'clock-out) "stopped clock") 13180 ((eq org-log-note-purpose 'clock-out) "stopped clock")
13054 ((eq org-log-note-purpose 'done) "closed todo item") 13181 ((eq org-log-note-purpose 'done) "closed todo item")
@@ -13081,6 +13208,7 @@ The auto-repeater uses this.")
13081 ""))))) 13208 "")))))
13082 (if lines (setq note (concat note " \\\\"))) 13209 (if lines (setq note (concat note " \\\\")))
13083 (push note lines)) 13210 (push note lines))
13211 (when current-prefix-arg (setq lines nil))
13084 (when lines 13212 (when lines
13085 (save-excursion 13213 (save-excursion
13086 (set-buffer (marker-buffer org-log-note-marker)) 13214 (set-buffer (marker-buffer org-log-note-marker))
@@ -13553,8 +13681,9 @@ With prefix ARG, realign all tags in headings in the current buffer."
13553 (if (or (eq t org-use-fast-tag-selection) 13681 (if (or (eq t org-use-fast-tag-selection)
13554 (and org-use-fast-tag-selection 13682 (and org-use-fast-tag-selection
13555 (delq nil (mapcar 'cdr table)))) 13683 (delq nil (mapcar 'cdr table))))
13556 (org-fast-tag-selection current-tags inherited-tags 13684 (org-fast-tag-selection
13557 table org-todo-tag-alist) 13685 current-tags inherited-tags table
13686 (if org-fast-tag-selection-include-todo org-todo-key-alist))
13558 (let ((org-add-colon-after-tag-completion t)) 13687 (let ((org-add-colon-after-tag-completion t))
13559 (org-trim 13688 (org-trim
13560 (completing-read "Tags: " 'org-tags-completion-function 13689 (completing-read "Tags: " 'org-tags-completion-function
@@ -13702,6 +13831,7 @@ Returns the new tags string, or nil to not change the current settings."
13702 tg cnt e c char c1 c2 ntable tbl rtn 13831 tg cnt e c char c1 c2 ntable tbl rtn
13703 ov-start ov-end ov-prefix 13832 ov-start ov-end ov-prefix
13704 (exit-after-next org-fast-tag-selection-single-key) 13833 (exit-after-next org-fast-tag-selection-single-key)
13834 (done-keywords org-done-keywords)
13705 groups ingroup) 13835 groups ingroup)
13706 (save-excursion 13836 (save-excursion
13707 (beginning-of-line 1) 13837 (beginning-of-line 1)
@@ -13727,6 +13857,7 @@ Returns the new tags string, or nil to not change the current settings."
13727 (split-window-vertically) 13857 (split-window-vertically)
13728 (org-switch-to-buffer-other-window (get-buffer-create " *Org tags*"))) 13858 (org-switch-to-buffer-other-window (get-buffer-create " *Org tags*")))
13729 (erase-buffer) 13859 (erase-buffer)
13860 (org-set-local 'org-done-keywords done-keywords)
13730 (org-fast-tag-insert "Inherited" inherited i-face "\n") 13861 (org-fast-tag-insert "Inherited" inherited i-face "\n")
13731 (org-fast-tag-insert "Current" current c-face "\n\n") 13862 (org-fast-tag-insert "Current" current c-face "\n\n")
13732 (org-fast-tag-show-exit exit-after-next) 13863 (org-fast-tag-show-exit exit-after-next)
@@ -13759,6 +13890,8 @@ Returns the new tags string, or nil to not change the current settings."
13759 (if ingroup (push tg (car groups))) 13890 (if ingroup (push tg (car groups)))
13760 (setq tg (org-add-props tg nil 'face 13891 (setq tg (org-add-props tg nil 'face
13761 (cond 13892 (cond
13893 ((not (assoc tg table))
13894 (org-get-todo-face tg))
13762 ((member tg current) c-face) 13895 ((member tg current) c-face)
13763 ((member tg inherited) i-face) 13896 ((member tg inherited) i-face)
13764 (t nil)))) 13897 (t nil))))
@@ -13848,12 +13981,13 @@ Returns the new tags string, or nil to not change the current settings."
13848 (while (re-search-forward 13981 (while (re-search-forward
13849 (org-re "\\[.\\] \\([[:alnum:]_@]+\\)") nil t) 13982 (org-re "\\[.\\] \\([[:alnum:]_@]+\\)") nil t)
13850 (setq tg (match-string 1)) 13983 (setq tg (match-string 1))
13851 (add-text-properties (match-beginning 1) (match-end 1) 13984 (add-text-properties
13852 (list 'face 13985 (match-beginning 1) (match-end 1)
13853 (cond 13986 (list 'face
13854 ((member tg current) c-face) 13987 (cond
13855 ((member tg inherited) i-face) 13988 ((member tg current) c-face)
13856 (t nil))))) 13989 ((member tg inherited) i-face)
13990 (t (get-text-property (match-beginning 1) 'face))))))
13857 (goto-char (point-min))))) 13991 (goto-char (point-min)))))
13858 (org-detach-overlay org-tags-overlay) 13992 (org-detach-overlay org-tags-overlay)
13859 (if rtn 13993 (if rtn
@@ -13927,7 +14061,7 @@ but in some other way.")
13927 ;; This is used by C-c C-c for property action. 14061 ;; This is used by C-c C-c for property action.
13928 (save-excursion 14062 (save-excursion
13929 (beginning-of-line 1) 14063 (beginning-of-line 1)
13930 (looking-at "^[ \t]*\\(:\\([a-zA-Z_0-9]+\\):\\)[ \t]*\\(.*\\)"))) 14064 (looking-at (org-re "^[ \t]*\\(:\\([[:alpha:]][[:alnum:]_-]*\\):\\)[ \t]*\\(.*\\)"))))
13931 14065
13932(defmacro org-with-point-at (pom &rest body) 14066(defmacro org-with-point-at (pom &rest body)
13933 "Move to buffer and point of point-or-marker POM for the duration of BODY." 14067 "Move to buffer and point of point-or-marker POM for the duration of BODY."
@@ -14016,7 +14150,7 @@ If WHICH is nil or `all', get all properties. If WHICH is
14016 (when range 14150 (when range
14017 (goto-char (car range)) 14151 (goto-char (car range))
14018 (while (re-search-forward 14152 (while (re-search-forward
14019 "^[ \t]*:\\([a-zA-Z][a-zA-Z_0-9]*\\):[ \t]*\\(\\S-.*\\)?" 14153 (org-re "^[ \t]*:\\([[:alpha:]][[:alnum:]_-]*\\):[ \t]*\\(\\S-.*\\)?")
14020 (cdr range) t) 14154 (cdr range) t)
14021 (setq key (org-match-string-no-properties 1) 14155 (setq key (org-match-string-no-properties 1)
14022 value (org-trim (or (org-match-string-no-properties 2) ""))) 14156 value (org-trim (or (org-match-string-no-properties 2) "")))
@@ -14144,7 +14278,9 @@ If the property is not present at all, nil is returned."
14144 (while (re-search-forward org-property-start-re nil t) 14278 (while (re-search-forward org-property-start-re nil t)
14145 (setq range (org-get-property-block)) 14279 (setq range (org-get-property-block))
14146 (goto-char (car range)) 14280 (goto-char (car range))
14147 (while (re-search-forward "^[ \t]*:\\([a-zA-Z0-9]+\\):" (cdr range) t) 14281 (while (re-search-forward
14282 (org-re "^[ \t]*:\\([[:alnum:]_-]+\\):")
14283 (cdr range) t)
14148 (add-to-list 'rtn (org-match-string-no-properties 1))) 14284 (add-to-list 'rtn (org-match-string-no-properties 1)))
14149 (outline-next-heading)))) 14285 (outline-next-heading))))
14150 (when include-specials 14286 (when include-specials
@@ -14385,8 +14521,8 @@ This is the compiled version of the format.")
14385 (beg (point-at-bol)) 14521 (beg (point-at-bol))
14386 (level-face (save-excursion 14522 (level-face (save-excursion
14387 (beginning-of-line 1) 14523 (beginning-of-line 1)
14388 (looking-at "\\(\\**\\)\\(\\* \\)") 14524 (and (looking-at "\\(\\**\\)\\(\\* \\)")
14389 (org-get-level-face 2))) 14525 (org-get-level-face 2))))
14390 (color (list :foreground 14526 (color (list :foreground
14391 (face-attribute (or level-face 'default) :foreground))) 14527 (face-attribute (or level-face 'default) :foreground)))
14392 props pom property ass width f string ov column) 14528 props pom property ass width f string ov column)
@@ -14851,7 +14987,7 @@ display, or in the #+COLUMNS line of the current buffer."
14851(defun org-columns-get-autowidth-alist (s cache) 14987(defun org-columns-get-autowidth-alist (s cache)
14852 "Derive the maximum column widths from the format and the cache." 14988 "Derive the maximum column widths from the format and the cache."
14853 (let ((start 0) rtn) 14989 (let ((start 0) rtn)
14854 (while (string-match "%\\([a-zA-Z]\\S-*\\)" s start) 14990 (while (string-match (org-re "%\\([[:alpha:]]\\S-*\\)") s start)
14855 (push (cons (match-string 1 s) 1) rtn) 14991 (push (cons (match-string 1 s) 1) rtn)
14856 (setq start (match-end 0))) 14992 (setq start (match-end 0)))
14857 (mapc (lambda (x) 14993 (mapc (lambda (x)
@@ -15010,8 +15146,9 @@ display, or in the #+COLUMNS line of the current buffer."
15010 "FIXME" 15146 "FIXME"
15011 (let ((start 0) width prop title op f) 15147 (let ((start 0) width prop title op f)
15012 (setq org-columns-current-fmt-compiled nil) 15148 (setq org-columns-current-fmt-compiled nil)
15013 (while (string-match "%\\([0-9]+\\)?\\([a-zA-Z_0-9]+\\)\\(?:(\\([^)]+\\))\\)?\\(?:{\\([^}]+\\)}\\)?\\s-*" 15149 (while (string-match
15014 fmt start) 15150 (org-re "%\\([0-9]+\\)?\\([[:alnum:]_-]+\\)\\(?:(\\([^)]+\\))\\)?\\(?:{\\([^}]+\\)}\\)?\\s-*")
15151 fmt start)
15015 (setq start (match-end 0) 15152 (setq start (match-end 0)
15016 width (match-string 1 fmt) 15153 width (match-string 1 fmt)
15017 prop (match-string 2 fmt) 15154 prop (match-string 2 fmt)
@@ -15412,10 +15549,25 @@ Don't touch the rest."
15412 15549
15413(defun org-deadline-close (timestamp-string &optional ndays) 15550(defun org-deadline-close (timestamp-string &optional ndays)
15414 "Is the time in TIMESTAMP-STRING close to the current date?" 15551 "Is the time in TIMESTAMP-STRING close to the current date?"
15415 (and (< (org-days-to-time timestamp-string) 15552 (setq ndays (or ndays (org-get-wdays timestamp-string)))
15416 (or ndays org-deadline-warning-days)) 15553 (and (< (org-days-to-time timestamp-string) ndays)
15417 (not (org-entry-is-done-p)))) 15554 (not (org-entry-is-done-p))))
15418 15555
15556(defun org-get-wdays (ts)
15557 "Get the deadline lead time appropriate for timestring TS."
15558 (cond
15559 ((<= org-deadline-warning-days 0)
15560 ;; 0 or negative, enforce this value no matter what
15561 (- org-deadline-warning-days))
15562 ((string-match "-\\([0-9]+\\)\\([dwmy]\\)\\(\\'\\|>\\)" ts)
15563 ;; lead time is specified.
15564 (floor (* (string-to-number (match-string 1 ts))
15565 (cdr (assoc (match-string 2 ts)
15566 '(("d" . 1) ("w" . 7)
15567 ("m" . 30.4) ("y" . 365.25)))))))
15568 ;; go for the default.
15569 (t org-deadline-warning-days)))
15570
15419(defun org-calendar-select-mouse (ev) 15571(defun org-calendar-select-mouse (ev)
15420 "Return to `org-read-date' with the date currently selected. 15572 "Return to `org-read-date' with the date currently selected.
15421This is used by `org-read-date' in a temporary keymap for the calendar buffer." 15573This is used by `org-read-date' in a temporary keymap for the calendar buffer."
@@ -15438,7 +15590,7 @@ days. If the prefix is a raw \\[universal-argument] prefix, all deadlines are s
15438 (cond 15590 (cond
15439 ((equal ndays '(4)) 100000) 15591 ((equal ndays '(4)) 100000)
15440 (ndays (prefix-numeric-value ndays)) 15592 (ndays (prefix-numeric-value ndays))
15441 (t org-deadline-warning-days))) 15593 (t (abs org-deadline-warning-days))))
15442 (case-fold-search nil) 15594 (case-fold-search nil)
15443 (regexp (concat "\\<" org-deadline-string " *<\\([^>]+\\)>")) 15595 (regexp (concat "\\<" org-deadline-string " *<\\([^>]+\\)>"))
15444 (callback 15596 (callback
@@ -17544,7 +17696,7 @@ When EMPTY is non-nil, also include days without any entries."
17544(defvar org-starting-day nil) ; local variable in the agenda buffer 17696(defvar org-starting-day nil) ; local variable in the agenda buffer
17545(defvar org-agenda-span nil) ; local variable in the agenda buffer 17697(defvar org-agenda-span nil) ; local variable in the agenda buffer
17546(defvar org-include-all-loc nil) ; local variable 17698(defvar org-include-all-loc nil) ; local variable
17547 17699(defvar org-agenda-remove-date nil) ; dynamically scoped
17548 17700
17549;;;###autoload 17701;;;###autoload
17550(defun org-agenda-list (&optional include-all start-day ndays) 17702(defun org-agenda-list (&optional include-all start-day ndays)
@@ -18262,6 +18414,13 @@ the documentation of `org-diary'."
18262 (format "mouse-2 or RET jump to org file %s" 18414 (format "mouse-2 or RET jump to org file %s"
18263 (abbreviate-file-name buffer-file-name)))) 18415 (abbreviate-file-name buffer-file-name))))
18264 (d1 (calendar-absolute-from-gregorian date)) 18416 (d1 (calendar-absolute-from-gregorian date))
18417 (remove-re
18418 (concat
18419 (regexp-quote
18420 (format-time-string
18421 "<%Y-%m-%d"
18422 (encode-time 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date))))
18423 ".*?>"))
18265 (regexp 18424 (regexp
18266 (concat 18425 (concat
18267 (regexp-quote 18426 (regexp-quote
@@ -18309,7 +18468,8 @@ the documentation of `org-diary'."
18309 tags (org-get-tags-at)) 18468 tags (org-get-tags-at))
18310 (looking-at "\\*+[ \t]+\\([^\r\n]+\\)") 18469 (looking-at "\\*+[ \t]+\\([^\r\n]+\\)")
18311 (setq txt (org-format-agenda-item 18470 (setq txt (org-format-agenda-item
18312 nil (match-string 1) category tags timestr))) 18471 nil (match-string 1) category tags timestr nil
18472 remove-re)))
18313 (setq txt org-agenda-no-heading-message)) 18473 (setq txt org-agenda-no-heading-message))
18314 (setq priority (org-get-priority txt)) 18474 (setq priority (org-get-priority txt))
18315 (org-add-props txt props 18475 (org-add-props txt props
@@ -18437,17 +18597,10 @@ the documentation of `org-diary'."
18437 (setq s (match-string 1) 18597 (setq s (match-string 1)
18438 pos (1- (match-beginning 1)) 18598 pos (1- (match-beginning 1))
18439 d2 (org-time-string-to-absolute (match-string 1) d1) 18599 d2 (org-time-string-to-absolute (match-string 1) d1)
18440 diff (- d2 d1)) 18600 diff (- d2 d1)
18441 (if (string-match "-\\([0-9]+\\)\\([dwmy]\\)\\'" s) 18601 wdays (org-get-wdays s)
18442 (setq wdays 18602 dfrac (/ (* 1.0 (- wdays diff)) wdays)
18443 (floor 18603 upcomingp (and todayp (> diff 0)))
18444 (* (string-to-number (match-string 1 s))
18445 (cdr (assoc (match-string 2 s)
18446 '(("d" . 1) ("w" . 7)
18447 ("m" . 30.4) ("y" . 365.25)))))))
18448 (setq wdays org-deadline-warning-days))
18449 (setq dfrac (/ (* 1.0 (- wdays diff)) wdays))
18450 (setq upcomingp (and todayp (> diff 0)))
18451 ;; When to show a deadline in the calendar: 18604 ;; When to show a deadline in the calendar:
18452 ;; If the expiration is within wdays warning time. 18605 ;; If the expiration is within wdays warning time.
18453 ;; Past-due deadlines are only shown on the current date 18606 ;; Past-due deadlines are only shown on the current date
@@ -18492,7 +18645,7 @@ the documentation of `org-diary'."
18492 'face (if donep 'org-done face) 18645 'face (if donep 'org-done face)
18493 'undone-face face 'done-face 'org-done) 18646 'undone-face face 'done-face 'org-done)
18494 (push txt ee)))))) 18647 (push txt ee))))))
18495 ee)) 18648 (nreverse ee)))
18496 18649
18497(defun org-agenda-deadline-face (fraction) 18650(defun org-agenda-deadline-face (fraction)
18498 "Return the face to displaying a deadline item. 18651 "Return the face to displaying a deadline item.
@@ -18569,7 +18722,7 @@ FRACTION is what fraction of the head-warning time has passed."
18569 'priority (+ (- 5 diff) (org-get-priority txt)) 18722 'priority (+ (- 5 diff) (org-get-priority txt))
18570 'org-category category) 18723 'org-category category)
18571 (push txt ee)))))) 18724 (push txt ee))))))
18572 ee)) 18725 (nreverse ee)))
18573 18726
18574(defun org-agenda-get-blocks () 18727(defun org-agenda-get-blocks ()
18575 "Return the date-range information for agenda display." 18728 "Return the date-range information for agenda display."
@@ -18659,7 +18812,7 @@ The flag is set if the currently compiled format contains a `%t'.")
18659The flag is set if the currently compiled format contains a `%T'.") 18812The flag is set if the currently compiled format contains a `%T'.")
18660 18813
18661(defun org-format-agenda-item (extra txt &optional category tags dotime 18814(defun org-format-agenda-item (extra txt &optional category tags dotime
18662 noprefix) 18815 noprefix remove-re)
18663 "Format TXT to be inserted into the agenda buffer. 18816 "Format TXT to be inserted into the agenda buffer.
18664In particular, it adds the prefix and corresponding text properties. EXTRA 18817In particular, it adds the prefix and corresponding text properties. EXTRA
18665must be a string and replaces the `%s' specifier in the prefix format. 18818must be a string and replaces the `%s' specifier in the prefix format.
@@ -18670,7 +18823,8 @@ time-of-day should be extracted from TXT for sorting of this entry, and for
18670the `%t' specifier in the format. When DOTIME is a string, this string is 18823the `%t' specifier in the format. When DOTIME is a string, this string is
18671searched for a time before TXT is. NOPREFIX is a flag and indicates that 18824searched for a time before TXT is. NOPREFIX is a flag and indicates that
18672only the correctly processes TXT should be returned - this is used by 18825only the correctly processes TXT should be returned - this is used by
18673`org-agenda-change-all-lines'. TAGS can be the tags of the headline." 18826`org-agenda-change-all-lines'. TAGS can be the tags of the headline.
18827Any match of REMOVE-RE will be removed from TXT."
18674 (save-match-data 18828 (save-match-data
18675 ;; Diary entries sometimes have extra whitespace at the beginning 18829 ;; Diary entries sometimes have extra whitespace at the beginning
18676 (if (string-match "^ +" txt) (setq txt (replace-match "" nil nil txt))) 18830 (if (string-match "^ +" txt) (setq txt (replace-match "" nil nil txt)))
@@ -18728,6 +18882,10 @@ only the correctly processes TXT should be returned - this is used by
18728 (match-string 2 txt)) 18882 (match-string 2 txt))
18729 t t txt)))) 18883 t t txt))))
18730 18884
18885 (when remove-re
18886 (while (string-match remove-re txt)
18887 (setq txt (replace-match "" t t txt))))
18888
18731 ;; Create the final string 18889 ;; Create the final string
18732 (if noprefix 18890 (if noprefix
18733 (setq rtn txt) 18891 (setq rtn txt)
@@ -19257,8 +19415,13 @@ and by additional input from the age of a schedules or deadline entry."
19257 (save-excursion 19415 (save-excursion
19258 (and (outline-next-heading) 19416 (and (outline-next-heading)
19259 (org-flag-heading nil)))) ; show the next heading 19417 (org-flag-heading nil)))) ; show the next heading
19418 (run-hooks 'org-agenda-after-show-hook)
19260 (and highlight (org-highlight (point-at-bol) (point-at-eol))))) 19419 (and highlight (org-highlight (point-at-bol) (point-at-eol)))))
19261 19420
19421(defvar org-agenda-after-show-hook nil
19422 "Normal hook run after an item has been shown from the agenda.
19423Point is in the buffer where the item originated.")
19424
19262(defun org-agenda-kill () 19425(defun org-agenda-kill ()
19263 "Kill the entry or subtree belonging to the current agenda entry." 19426 "Kill the entry or subtree belonging to the current agenda entry."
19264 (interactive) 19427 (interactive)
@@ -19909,7 +20072,7 @@ This is a command that has to be installed in `calendar-mode-map'."
19909 "Hebrew: " (calendar-hebrew-date-string date) " (until sunset)\n" 20072 "Hebrew: " (calendar-hebrew-date-string date) " (until sunset)\n"
19910 "Islamic: " (calendar-islamic-date-string date) " (until sunset)\n" 20073 "Islamic: " (calendar-islamic-date-string date) " (until sunset)\n"
19911 "French: " (calendar-french-date-string date) "\n" 20074 "French: " (calendar-french-date-string date) "\n"
19912 "Bahai: " (calendar-bahai-date-string date) " (until sunset)\n" 20075 "Baha'i: " (calendar-bahai-date-string date) " (until sunset)\n"
19913 "Mayan: " (calendar-mayan-date-string date) "\n" 20076 "Mayan: " (calendar-mayan-date-string date) "\n"
19914 "Coptic: " (calendar-coptic-date-string date) "\n" 20077 "Coptic: " (calendar-coptic-date-string date) "\n"
19915 "Ethiopic: " (calendar-ethiopic-date-string date) "\n" 20078 "Ethiopic: " (calendar-ethiopic-date-string date) "\n"
@@ -20284,7 +20447,7 @@ The images can be removed again with \\[org-ctrl-c-ctrl-c]."
20284 (save-excursion 20447 (save-excursion
20285 (goto-char 0) 20448 (goto-char 0)
20286 (let ((re (org-make-options-regexp 20449 (let ((re (org-make-options-regexp
20287 '("TITLE" "AUTHOR" "EMAIL" "TEXT" "OPTIONS" "LANGUAGE"))) 20450 '("TITLE" "AUTHOR" "DATE" "EMAIL" "TEXT" "OPTIONS" "LANGUAGE")))
20288 p key val text options) 20451 p key val text options)
20289 (while (re-search-forward re nil t) 20452 (while (re-search-forward re nil t)
20290 (setq key (org-match-string-no-properties 1) 20453 (setq key (org-match-string-no-properties 1)
@@ -20293,6 +20456,7 @@ The images can be removed again with \\[org-ctrl-c-ctrl-c]."
20293 ((string-equal key "TITLE") (setq p (plist-put p :title val))) 20456 ((string-equal key "TITLE") (setq p (plist-put p :title val)))
20294 ((string-equal key "AUTHOR")(setq p (plist-put p :author val))) 20457 ((string-equal key "AUTHOR")(setq p (plist-put p :author val)))
20295 ((string-equal key "EMAIL") (setq p (plist-put p :email val))) 20458 ((string-equal key "EMAIL") (setq p (plist-put p :email val)))
20459 ((string-equal key "DATE") (setq p (plist-put p :date val)))
20296 ((string-equal key "LANGUAGE") (setq p (plist-put p :language val))) 20460 ((string-equal key "LANGUAGE") (setq p (plist-put p :language val)))
20297 ((string-equal key "TEXT") 20461 ((string-equal key "TEXT")
20298 (setq text (if text (concat text "\n" val) val))) 20462 (setq text (if text (concat text "\n" val) val)))
@@ -20840,7 +21004,7 @@ translations. There is currently no way for users to extend this.")
20840 ;; Specific LaTeX stuff 21004 ;; Specific LaTeX stuff
20841 (when latexp 21005 (when latexp
20842 (require 'org-export-latex nil t) 21006 (require 'org-export-latex nil t)
20843 (org-export-latex-cleaned-string)) 21007 (org-export-latex-cleaned-string commentsp))
20844 21008
20845 ;; Specific HTML stuff 21009 ;; Specific HTML stuff
20846 (when htmlp 21010 (when htmlp
@@ -20854,9 +21018,6 @@ translations. There is currently no way for users to extend this.")
20854 (message "Exporting...")) 21018 (message "Exporting..."))
20855 21019
20856 ;; Remove or replace comments 21020 ;; Remove or replace comments
20857 ;; FIXME: Does LaTeX export take care of its own comments?
20858 ;; If :comments is set, use this char for commenting out comments and
20859 ;; protect them. otherwise delete them
20860 (goto-char (point-min)) 21021 (goto-char (point-min))
20861 (while (re-search-forward "^#\\(.*\n?\\)" nil t) 21022 (while (re-search-forward "^#\\(.*\n?\\)" nil t)
20862 (if commentsp 21023 (if commentsp
@@ -20968,6 +21129,15 @@ translations. There is currently no way for users to extend this.")
20968 (a (assoc rtn alist))) 21129 (a (assoc rtn alist)))
20969 (or (cdr a) rtn)))) 21130 (or (cdr a) rtn))))
20970 21131
21132(defun org-get-min-level (lines)
21133 "Get the minimum level in LINES."
21134 (let ((re "^\\(\\*+\\) ") l min)
21135 (catch 'exit
21136 (while (setq l (pop lines))
21137 (if (string-match re l)
21138 (throw 'exit (org-tr-level (length (match-string 1 l))))))
21139 1)))
21140
20971;; Variable holding the vector with section numbers 21141;; Variable holding the vector with section numbers
20972(defvar org-section-numbers (make-vector org-level-max 0)) 21142(defvar org-section-numbers (make-vector org-level-max 0))
20973 21143
@@ -21058,8 +21228,7 @@ underlined headlines. The default is 3."
21058 (buffer (find-file-noselect filename)) 21228 (buffer (find-file-noselect filename))
21059 (org-levels-open (make-vector org-level-max nil)) 21229 (org-levels-open (make-vector org-level-max nil))
21060 (odd org-odd-levels-only) 21230 (odd org-odd-levels-only)
21061 (date (format-time-string "%Y/%m/%d" (current-time))) 21231 (date (plist-get opt-plist :date))
21062 (time (format-time-string "%X" (org-current-time)))
21063 (author (plist-get opt-plist :author)) 21232 (author (plist-get opt-plist :author))
21064 (title (or (and subtree-p (org-export-get-title-from-subtree)) 21233 (title (or (and subtree-p (org-export-get-title-from-subtree))
21065 (plist-get opt-plist :title) 21234 (plist-get opt-plist :title)
@@ -21128,8 +21297,15 @@ underlined headlines. The default is 3."
21128 (insert (concat (nth 1 lang-words) ": " (or author "") 21297 (insert (concat (nth 1 lang-words) ": " (or author "")
21129 (if email (concat " <" email ">") "") 21298 (if email (concat " <" email ">") "")
21130 "\n"))) 21299 "\n")))
21131 (if (and date time org-export-time-stamp-file) 21300
21132 (insert (concat (nth 2 lang-words) ": " date " " time "\n"))) 21301 (cond
21302 ((and date (string-match "%" date))
21303 (setq date (format-time-string date (current-time))))
21304 (date)
21305 (t (setq date (format-time-string "%Y/%m/%d %X" (current-time)))))
21306
21307 (if (and date org-export-time-stamp-file)
21308 (insert (concat (nth 2 lang-words) ": " date"\n")))
21133 21309
21134 (insert "\n\n") 21310 (insert "\n\n")
21135 21311
@@ -21658,8 +21834,7 @@ the body tags themselves."
21658 (t (get-buffer-create to-buffer))) 21834 (t (get-buffer-create to-buffer)))
21659 (find-file-noselect filename))) 21835 (find-file-noselect filename)))
21660 (org-levels-open (make-vector org-level-max nil)) 21836 (org-levels-open (make-vector org-level-max nil))
21661 (date (format-time-string "%Y/%m/%d" (current-time))) 21837 (date (plist-get opt-plist :date))
21662 (time (format-time-string "%X" (org-current-time)))
21663 (author (plist-get opt-plist :author)) 21838 (author (plist-get opt-plist :author))
21664 (title (or (and subtree-p (org-export-get-title-from-subtree)) 21839 (title (or (and subtree-p (org-export-get-title-from-subtree))
21665 (plist-get opt-plist :title) 21840 (plist-get opt-plist :title)
@@ -21730,6 +21905,12 @@ the body tags themselves."
21730 (setq org-last-level org-min-level) 21905 (setq org-last-level org-min-level)
21731 (org-init-section-numbers) 21906 (org-init-section-numbers)
21732 21907
21908 (cond
21909 ((and date (string-match "%" date))
21910 (setq date (format-time-string date (current-time))))
21911 (date)
21912 (t (setq date (format-time-string "%Y/%m/%d %X" (current-time)))))
21913
21733 ;; Get the language-dependent settings 21914 ;; Get the language-dependent settings
21734 (setq lang-words (or (assoc language org-export-language-setup) 21915 (setq lang-words (or (assoc language org-export-language-setup)
21735 (assoc "en" org-export-language-setup))) 21916 (assoc "en" org-export-language-setup)))
@@ -21766,13 +21947,13 @@ lang=\"%s\" xml:lang=\"%s\">
21766<title>%s</title> 21947<title>%s</title>
21767<meta http-equiv=\"Content-Type\" content=\"text/html;charset=%s\"/> 21948<meta http-equiv=\"Content-Type\" content=\"text/html;charset=%s\"/>
21768<meta name=\"generator\" content=\"Org-mode\"/> 21949<meta name=\"generator\" content=\"Org-mode\"/>
21769<meta name=\"generated\" content=\"%s %s\"/> 21950<meta name=\"generated\" content=\"%s\"/>
21770<meta name=\"author\" content=\"%s\"/> 21951<meta name=\"author\" content=\"%s\"/>
21771%s 21952%s
21772</head><body> 21953</head><body>
21773" 21954"
21774 language language (org-html-expand title) 21955 language language (org-html-expand title)
21775 (or charset "iso-8859-1") date time author style)) 21956 (or charset "iso-8859-1") date author style))
21776 21957
21777 (insert (or (plist-get opt-plist :preamble) "")) 21958 (insert (or (plist-get opt-plist :preamble) ""))
21778 21959
@@ -22187,10 +22368,10 @@ lang=\"%s\" xml:lang=\"%s\">
22187 (insert "<a href=\"mailto:" email "\">&lt;" 22368 (insert "<a href=\"mailto:" email "\">&lt;"
22188 email "&gt;</a>\n")) 22369 email "&gt;</a>\n"))
22189 (insert "</p>\n")) 22370 (insert "</p>\n"))
22190 (when (and date time org-export-time-stamp-file) 22371 (when (and date org-export-time-stamp-file)
22191 (insert "<p class=\"date\"> " 22372 (insert "<p class=\"date\"> "
22192 (nth 2 lang-words) ": " 22373 (nth 2 lang-words) ": "
22193 date " " time "</p>\n"))) 22374 date "</p>\n")))
22194 22375
22195 (if org-export-html-with-timestamp 22376 (if org-export-html-with-timestamp
22196 (insert org-export-html-html-helper-timestamp)) 22377 (insert org-export-html-html-helper-timestamp))
@@ -23418,7 +23599,9 @@ Calls `org-timestamp-up' or `org-priority-up', or `org-previous-item',
23418depending on context. See the individual commands for more information." 23599depending on context. See the individual commands for more information."
23419 (interactive "P") 23600 (interactive "P")
23420 (cond 23601 (cond
23421 ((org-at-timestamp-p t) (call-interactively 'org-timestamp-up)) 23602 ((org-at-timestamp-p t)
23603 (call-interactively (if org-edit-timestamp-down-means-later
23604 'org-timestamp-down 'org-timestamp-up)))
23422 ((org-on-heading-p) (call-interactively 'org-priority-up)) 23605 ((org-on-heading-p) (call-interactively 'org-priority-up))
23423 ((org-at-item-p) (call-interactively 'org-previous-item)) 23606 ((org-at-item-p) (call-interactively 'org-previous-item))
23424 (t (call-interactively 'org-beginning-of-item) (beginning-of-line 1)))) 23607 (t (call-interactively 'org-beginning-of-item) (beginning-of-line 1))))
@@ -23429,7 +23612,9 @@ Calls `org-timestamp-down' or `org-priority-down', or `org-next-item'
23429depending on context. See the individual commands for more information." 23612depending on context. See the individual commands for more information."
23430 (interactive "P") 23613 (interactive "P")
23431 (cond 23614 (cond
23432 ((org-at-timestamp-p t) (call-interactively 'org-timestamp-down)) 23615 ((org-at-timestamp-p t)
23616 (call-interactively (if org-edit-timestamp-down-means-later
23617 'org-timestamp-up 'org-timestamp-down)))
23433 ((org-on-heading-p) (call-interactively 'org-priority-down)) 23618 ((org-on-heading-p) (call-interactively 'org-priority-down))
23434 (t (call-interactively 'org-next-item)))) 23619 (t (call-interactively 'org-next-item))))
23435 23620
@@ -24566,13 +24751,29 @@ Still experimental, may disappear in the furture."
24566 t))) 24751 t)))
24567 (t nil)))) ; call paragraph-fill 24752 (t nil)))) ; call paragraph-fill
24568 24753
24569(defun org-get-min-level (lines) 24754(defun org-assign-fast-keys (alist)
24570 (let ((re "^\\(\\*+\\) ") l min) 24755 "Assign fast keys to a keyword-key alist.
24571 (catch 'exit 24756Respect keys that are already there."
24572 (while (setq l (pop lines)) 24757 (let (new e k c c1 c2 (char ?a))
24573 (if (string-match re l) 24758 (while (setq e (pop alist))
24574 (throw 'exit (org-tr-level (length (match-string 1 l)))))) 24759 (cond
24575 1))) 24760 ((equal e '(:startgroup)) (push e new))
24761 ((equal e '(:endgroup)) (push e new))
24762 (t
24763 (setq k (car e) c2 nil)
24764 (if (cdr e)
24765 (setq c (cdr e))
24766 ;; automatically assign a character.
24767 (setq c1 (string-to-char
24768 (downcase (substring
24769 k (if (= (string-to-char k) ?@) 1 0)))))
24770 (if (or (rassoc c1 new) (rassoc c1 alist))
24771 (while (or (rassoc char new) (rassoc char alist))
24772 (setq char (1+ char)))
24773 (setq c2 c1))
24774 (setq c (or c2 char)))
24775 (push (cons k c) new))))
24776 (nreverse new)))
24576 24777
24577;;;; Finish up 24778;;;; Finish up
24578 24779