aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/org
diff options
context:
space:
mode:
authorCarsten Dominik2008-12-16 13:30:37 +0000
committerCarsten Dominik2008-12-16 13:30:37 +0000
commitdb55f368650667b0686cdcd36afa43d33ef219ca (patch)
tree422b66ddf983e34d10daab408d44d0468ae7f17b /lisp/org
parent8265647f5d778ca5f5dc34f922b800bcf9758ed7 (diff)
downloademacs-db55f368650667b0686cdcd36afa43d33ef219ca.tar.gz
emacs-db55f368650667b0686cdcd36afa43d33ef219ca.zip
2008-12-16 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-refile): Avoid refiling to within the region to be refiled. * org-export-latex.el (org-export-latex-special-chars): Replace special characters also in tables. * org-agenda.el (org-agenda-change-all-lines): New argument FORCE-TAGS. (org-agenda-set-tags): Cet the new tags and pas them to `org-format-agenda-item'. 2008-12-16 Carsten Dominik <carsten.dominik@gmail.com> * org-export-latex.el (org-export-latex-classes): Add longable as a default package to all classes. (org-export-latex-tables): Handle the longtable attribute and the align attribute. * org-table.el (orgtbl-to-generic): Handle tables that start with a hline. * org-export-latex.el (org-export-latex-emphasis-alist): Switch to \verb for colde-like snippets. (org-export-as-latex): Fix issues with region export. * org.el (org-up-heading-safe): Speed up function by using a direct regexp search. (org-olpa): New variable. (org-get-outline-path): Speed-up path constructions in cases where this is possible because the entire hierarchy is scanned anyway. (org-refile-get-location): Don't compare the truenames of files, this is too slow. (org-goto-max-level): New option. (org-goto): Use `org-goto-max-level'. 2008-12-16 Tassilo Horn <tassilo@member.fsf.org> * org-gnus.el (org-gnus-article-link, org-gnus-article-link): Strip angle brackets from message-ids in the former and don't do it in the latter. (org-gnus-follow-link): Open summary reliable, even if the last messages were deleted, and handle empty groups, too. 2008-12-16 Carsten Dominik <carsten.dominik@gmail.com> * org-export-latex.el (org-export-latex-emphasis-alist): Use \verb instead of \texttt for the =...= and ~===~ emphasis environments. (org-export-as-latex): Remove any old :org-license-to-kill text properties. (org-export-as-latex): Pass RBEG to `org-export-latex-first-lines'. (org-export-latex-make-header): Add some hard space after the table of contents. (org-export-latex-first-lines): Accept RBEG argument. Mark exported text so that it will be excuded in further steps. * org-table.el (org-table-get-specials): Make @0 reference the last line in a table. (org-table-recalculate): Improve docstring. 2008-12-16 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-log-done): Fix docstring. 2008-12-16 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-html-format-image): Fix bugs. * org-export-latex.el (org-export-latex-tables) (org-export-latex-links): Implement attribute, label, and caption handling. * org-exp.el (org-export-html-style-default): Add style definitions for the figure div. (org-export-preprocess-string, org-export-as-html): Implement attribute, label, and caption handling. (org-export-attach-captions-and-attributes): New function. (org-export-html-format-image): New function. (org-format-org-table-html): Implement attribute, label, and caption handling. * org.el (org-find-text-property-in-string): New function. (org-extract-attributes): Use the property org-attr instead of org-attrobutes, because this property is now set with the #+ATTR lines. 2008-12-16 Carsten Dominik <carsten.dominik@gmail.com> * org-compat.el (org-substring-no-properties): Fix for XEmacs, for the case that FROM is nil. * org.el (org-before-first-heading-p): New function. 2008-12-16 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-as-html): Do not add a space before enforces line breaks. (org-export-as-html): Close paragraph before blockquote and verse tags. 2008-12-16 Carsten Dominik <carsten.dominik@gmail.com> * org-id.el (org-id-locations-file): Wrap file name with `convert-standard-filename'. (org-id-files): New variable. (org-id-use-hash): New option. (org-id-update-id-locations): Also search in all files current listed in `org-id-files'. Convert the resulting alist to a hash if the user customation says so. (org-id-locations-save): Handle he case if `org-id-locations' is a hash. (org-id-locations-load): Convert the alist to a hash. (org-id-add-location): Handle the hast case. (kill-emacs-hook): Make sure id locations are saved when Emacs is exited. (org-id-hash-to-alist, org-id-alist-to-hash) (org-id-paste-tracker): New functions.
Diffstat (limited to 'lisp/org')
-rw-r--r--lisp/org/org-agenda.el20
-rw-r--r--lisp/org/org-archive.el2
-rw-r--r--lisp/org/org-attach.el2
-rw-r--r--lisp/org/org-bbdb.el2
-rw-r--r--lisp/org/org-bibtex.el2
-rw-r--r--lisp/org/org-clock.el5
-rw-r--r--lisp/org/org-colview.el2
-rw-r--r--lisp/org/org-compat.el4
-rw-r--r--lisp/org/org-exp.el148
-rw-r--r--lisp/org/org-export-latex.el173
-rw-r--r--lisp/org/org-faces.el2
-rw-r--r--lisp/org/org-gnus.el51
-rw-r--r--lisp/org/org-id.el306
-rw-r--r--lisp/org/org-info.el2
-rw-r--r--lisp/org/org-irc.el2
-rw-r--r--lisp/org/org-jsinfo.el2
-rw-r--r--lisp/org/org-list.el2
-rw-r--r--lisp/org/org-mac-message.el2
-rw-r--r--lisp/org/org-macs.el2
-rw-r--r--lisp/org/org-mew.el2
-rw-r--r--lisp/org/org-mhe.el2
-rw-r--r--lisp/org/org-mouse.el2
-rw-r--r--lisp/org/org-plot.el2
-rw-r--r--lisp/org/org-publish.el2
-rw-r--r--lisp/org/org-remember.el2
-rw-r--r--lisp/org/org-rmail.el2
-rw-r--r--lisp/org/org-table.el24
-rw-r--r--lisp/org/org-timer.el2
-rw-r--r--lisp/org/org-vm.el2
-rw-r--r--lisp/org/org-w3m.el2
-rw-r--r--lisp/org/org-wl.el2
-rw-r--r--lisp/org/org.el206
32 files changed, 704 insertions, 279 deletions
diff --git a/lisp/org/org-agenda.el b/lisp/org/org-agenda.el
index 8e58fb6ac07..a14a38a2f65 100644
--- a/lisp/org/org-agenda.el
+++ b/lisp/org/org-agenda.el
@@ -6,7 +6,7 @@
6;; Author: Carsten Dominik <carsten at orgmode dot org> 6;; Author: Carsten Dominik <carsten at orgmode dot org>
7;; Keywords: outlines, hypermedia, calendar, wp 7;; Keywords: outlines, hypermedia, calendar, wp
8;; Homepage: http://orgmode.org 8;; Homepage: http://orgmode.org
9;; Version: 6.14 9;; Version: 6.15a
10;; 10;;
11;; This file is part of GNU Emacs. 11;; This file is part of GNU Emacs.
12;; 12;;
@@ -5067,13 +5067,17 @@ the same tree node, and the headline of the tree node in the Org-mode file."
5067 (org-flag-heading nil))) ; show the next heading 5067 (org-flag-heading nil))) ; show the next heading
5068 (org-add-note)))) 5068 (org-add-note))))
5069 5069
5070(defun org-agenda-change-all-lines (newhead hdmarker &optional fixface just-this) 5070(defun org-agenda-change-all-lines (newhead hdmarker
5071 &optional fixface just-this
5072 force-tags)
5071 "Change all lines in the agenda buffer which match HDMARKER. 5073 "Change all lines in the agenda buffer which match HDMARKER.
5072The new content of the line will be NEWHEAD (as modified by 5074The new content of the line will be NEWHEAD (as modified by
5073`org-format-agenda-item'). HDMARKER is checked with 5075`org-format-agenda-item'). HDMARKER is checked with
5074`equal' against all `org-hd-marker' text properties in the file. 5076`equal' against all `org-hd-marker' text properties in the file.
5075If FIXFACE is non-nil, the face of each item is modified acording to 5077If FIXFACE is non-nil, the face of each item is modified acording to
5076the new TODO state." 5078the new TODO state.
5079If JUST-THIS is non-nil, change just the current line, not all.
5080If FORCE-TAGS is non nil, the car of it ar the new tags."
5077 (let* ((inhibit-read-only t) 5081 (let* ((inhibit-read-only t)
5078 (line (org-current-line)) 5082 (line (org-current-line))
5079 props m pl undone-face done-face finish new dotime cat tags) 5083 props m pl undone-face done-face finish new dotime cat tags)
@@ -5088,7 +5092,9 @@ the new TODO state."
5088 (setq props (text-properties-at (point)) 5092 (setq props (text-properties-at (point))
5089 dotime (get-text-property (point) 'dotime) 5093 dotime (get-text-property (point) 'dotime)
5090 cat (get-text-property (point) 'org-category) 5094 cat (get-text-property (point) 'org-category)
5091 tags (get-text-property (point) 'tags) 5095 tags (if force-tags
5096 (car force-tags)
5097 (get-text-property (point) 'tags))
5092 new (org-format-agenda-item "x" newhead cat tags dotime 'noprefix) 5098 new (org-format-agenda-item "x" newhead cat tags dotime 'noprefix)
5093 pl (get-text-property (point) 'prefix-length) 5099 pl (get-text-property (point) 'prefix-length)
5094 undone-face (get-text-property (point) 'undone-face) 5100 undone-face (get-text-property (point) 'undone-face)
@@ -5191,7 +5197,7 @@ the same tree node, and the headline of the tree node in the Org-mode file."
5191 (buffer (marker-buffer hdmarker)) 5197 (buffer (marker-buffer hdmarker))
5192 (pos (marker-position hdmarker)) 5198 (pos (marker-position hdmarker))
5193 (inhibit-read-only t) 5199 (inhibit-read-only t)
5194 newhead) 5200 newhead tags)
5195 (org-with-remote-undo buffer 5201 (org-with-remote-undo buffer
5196 (with-current-buffer buffer 5202 (with-current-buffer buffer
5197 (widen) 5203 (widen)
@@ -5203,9 +5209,10 @@ the same tree node, and the headline of the tree node in the Org-mode file."
5203 (org-flag-heading nil))) ; show the next heading 5209 (org-flag-heading nil))) ; show the next heading
5204 (goto-char pos) 5210 (goto-char pos)
5205 (call-interactively 'org-set-tags) 5211 (call-interactively 'org-set-tags)
5212 (setq tags (org-get-tags-at))
5206 (end-of-line 1) 5213 (end-of-line 1)
5207 (setq newhead (org-get-heading))) 5214 (setq newhead (org-get-heading)))
5208 (org-agenda-change-all-lines newhead hdmarker) 5215 (org-agenda-change-all-lines newhead hdmarker nil nil (list tags))
5209 (beginning-of-line 1))))) 5216 (beginning-of-line 1)))))
5210 5217
5211(defun org-agenda-toggle-archive-tag () 5218(defun org-agenda-toggle-archive-tag ()
@@ -5627,6 +5634,7 @@ belonging to the \"Work\" category."
5627 (time-to-days (current-time)))) 5634 (time-to-days (current-time))))
5628 (files (org-agenda-files 'unrestricted)) entries file) 5635 (files (org-agenda-files 'unrestricted)) entries file)
5629 ;; Get all entries which may contain an appt 5636 ;; Get all entries which may contain an appt
5637 (org-prepare-agenda-buffers files)
5630 (while (setq file (pop files)) 5638 (while (setq file (pop files))
5631 (setq entries 5639 (setq entries
5632 (append entries 5640 (append entries
diff --git a/lisp/org/org-archive.el b/lisp/org/org-archive.el
index 2f468818834..dbcceea5765 100644
--- a/lisp/org/org-archive.el
+++ b/lisp/org/org-archive.el
@@ -5,7 +5,7 @@
5;; Author: Carsten Dominik <carsten at orgmode dot org> 5;; Author: Carsten Dominik <carsten at orgmode dot org>
6;; Keywords: outlines, hypermedia, calendar, wp 6;; Keywords: outlines, hypermedia, calendar, wp
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 6.14 8;; Version: 6.15a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
diff --git a/lisp/org/org-attach.el b/lisp/org/org-attach.el
index fdf8a4cd274..2c518510359 100644
--- a/lisp/org/org-attach.el
+++ b/lisp/org/org-attach.el
@@ -4,7 +4,7 @@
4 4
5;; Author: John Wiegley <johnw@newartisans.com> 5;; Author: John Wiegley <johnw@newartisans.com>
6;; Keywords: org data task 6;; Keywords: org data task
7;; Version: 6.14 7;; Version: 6.15a
8 8
9;; This file is part of GNU Emacs. 9;; This file is part of GNU Emacs.
10;; 10;;
diff --git a/lisp/org/org-bbdb.el b/lisp/org/org-bbdb.el
index 1c32ce7c22d..04fd681f87e 100644
--- a/lisp/org/org-bbdb.el
+++ b/lisp/org/org-bbdb.el
@@ -6,7 +6,7 @@
6;; Thomas Baumann <thomas dot baumann at ch dot tum dot de> 6;; Thomas Baumann <thomas dot baumann at ch dot tum dot de>
7;; Keywords: outlines, hypermedia, calendar, wp 7;; Keywords: outlines, hypermedia, calendar, wp
8;; Homepage: http://orgmode.org 8;; Homepage: http://orgmode.org
9;; Version: 6.14 9;; Version: 6.15a
10;; 10;;
11;; This file is part of GNU Emacs. 11;; This file is part of GNU Emacs.
12;; 12;;
diff --git a/lisp/org/org-bibtex.el b/lisp/org/org-bibtex.el
index 5b0627e5015..da119405487 100644
--- a/lisp/org/org-bibtex.el
+++ b/lisp/org/org-bibtex.el
@@ -5,7 +5,7 @@
5;; Author: Bastien Guerry <bzg at altern dot org> 5;; Author: Bastien Guerry <bzg at altern dot org>
6;; Carsten Dominik <carsten dot dominik at gmail dot com> 6;; Carsten Dominik <carsten dot dominik at gmail dot com>
7;; Keywords: org, wp, remember 7;; Keywords: org, wp, remember
8;; Version: 6.14 8;; Version: 6.15a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
diff --git a/lisp/org/org-clock.el b/lisp/org/org-clock.el
index 17fb7c2d10e..a4947576e39 100644
--- a/lisp/org/org-clock.el
+++ b/lisp/org/org-clock.el
@@ -5,7 +5,7 @@
5;; Author: Carsten Dominik <carsten at orgmode dot org> 5;; Author: Carsten Dominik <carsten at orgmode dot org>
6;; Keywords: outlines, hypermedia, calendar, wp 6;; Keywords: outlines, hypermedia, calendar, wp
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 6.14 8;; Version: 6.15a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
@@ -118,7 +118,8 @@ be visited."
118 (const :tag "Clock and history" t) 118 (const :tag "Clock and history" t)
119 (const :tag "No persistence" nil))) 119 (const :tag "No persistence" nil)))
120 120
121(defcustom org-clock-persist-file "~/.emacs.d/org-clock-save.el" 121(defcustom org-clock-persist-file (convert-standard-filename
122 "~/.emacs.d/org-clock-save.el")
122 "File to save clock data to" 123 "File to save clock data to"
123 :group 'org-clock 124 :group 'org-clock
124 :type 'string) 125 :type 'string)
diff --git a/lisp/org/org-colview.el b/lisp/org/org-colview.el
index 08dc6565273..f42771379ca 100644
--- a/lisp/org/org-colview.el
+++ b/lisp/org/org-colview.el
@@ -5,7 +5,7 @@
5;; Author: Carsten Dominik <carsten at orgmode dot org> 5;; Author: Carsten Dominik <carsten at orgmode dot org>
6;; Keywords: outlines, hypermedia, calendar, wp 6;; Keywords: outlines, hypermedia, calendar, wp
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 6.14 8;; Version: 6.15a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
diff --git a/lisp/org/org-compat.el b/lisp/org/org-compat.el
index 08f66fcb0dc..85311204ee9 100644
--- a/lisp/org/org-compat.el
+++ b/lisp/org/org-compat.el
@@ -5,7 +5,7 @@
5;; Author: Carsten Dominik <carsten at orgmode dot org> 5;; Author: Carsten Dominik <carsten at orgmode dot org>
6;; Keywords: outlines, hypermedia, calendar, wp 6;; Keywords: outlines, hypermedia, calendar, wp
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 6.14 8;; Version: 6.15a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
@@ -284,7 +284,7 @@ that can be added."
284 284
285(defun org-substring-no-properties (string &optional from to) 285(defun org-substring-no-properties (string &optional from to)
286 (if (featurep 'xemacs) 286 (if (featurep 'xemacs)
287 (org-no-properties (substring string from to)) 287 (org-no-properties (substring string (or from 0) to))
288 (substring-no-properties string from to))) 288 (substring-no-properties string from to)))
289 289
290(provide 'org-compat) 290(provide 'org-compat)
diff --git a/lisp/org/org-exp.el b/lisp/org/org-exp.el
index bf1dd2a276b..14f16291192 100644
--- a/lisp/org/org-exp.el
+++ b/lisp/org/org-exp.el
@@ -5,7 +5,7 @@
5;; Author: Carsten Dominik <carsten at orgmode dot org> 5;; Author: Carsten Dominik <carsten at orgmode dot org>
6;; Keywords: outlines, hypermedia, calendar, wp 6;; Keywords: outlines, hypermedia, calendar, wp
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 6.14 8;; Version: 6.15a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
@@ -545,7 +545,8 @@ Org-mode file."
545 table { border-collapse: collapse; } 545 table { border-collapse: collapse; }
546 td, th { vertical-align: top; } 546 td, th { vertical-align: top; }
547 dt { font-weight: bold; } 547 dt { font-weight: bold; }
548 548 div.figure { padding: 0.5em; }
549 div.figure p { text-align: center; }
549 .org-info-js_info-navigation { border-style:none; } 550 .org-info-js_info-navigation { border-style:none; }
550 #org-info-js_console-label { font-size:10px; font-weight:bold; 551 #org-info-js_console-label { font-size:10px; font-weight:bold;
551 white-space:nowrap; } 552 white-space:nowrap; }
@@ -1432,6 +1433,8 @@ on this string to produce the exported version."
1432 (let* ((htmlp (plist-get parameters :for-html)) 1433 (let* ((htmlp (plist-get parameters :for-html))
1433 (asciip (plist-get parameters :for-ascii)) 1434 (asciip (plist-get parameters :for-ascii))
1434 (latexp (plist-get parameters :for-LaTeX)) 1435 (latexp (plist-get parameters :for-LaTeX))
1436 (backend (cond (htmlp 'html) (latexp 'latex) (asciip 'ascii)))
1437
1435 (archived-trees (plist-get parameters :archived-trees)) 1438 (archived-trees (plist-get parameters :archived-trees))
1436 (inhibit-read-only t) 1439 (inhibit-read-only t)
1437 (drawers org-drawers) 1440 (drawers org-drawers)
@@ -1465,6 +1468,9 @@ on this string to produce the exported version."
1465 1468
1466 ;; Handle source code snippets 1469 ;; Handle source code snippets
1467 (org-export-replace-src-segments) 1470 (org-export-replace-src-segments)
1471
1472 ;; Find all headings and compute the targets for them
1473 (setq target-alist (org-export-define-heading-targets target-alist))
1468 1474
1469 ;; Get rid of drawers 1475 ;; Get rid of drawers
1470 (org-export-remove-or-extract-drawers drawers 1476 (org-export-remove-or-extract-drawers drawers
@@ -1487,9 +1493,6 @@ on this string to produce the exported version."
1487 ;; Remove todo-keywords before exporting, if the user has requested so 1493 ;; Remove todo-keywords before exporting, if the user has requested so
1488 (org-export-remove-headline-metadata parameters) 1494 (org-export-remove-headline-metadata parameters)
1489 1495
1490 ;; Find all headings and compute the targets for them
1491 (setq target-alist (org-export-define-heading-targets target-alist))
1492
1493 ;; Find targets in comments and move them out of comments, 1496 ;; Find targets in comments and move them out of comments,
1494 ;; but mark them as targets that should be invisible 1497 ;; but mark them as targets that should be invisible
1495 (setq target-alist (org-export-handle-invisible-targets target-alist)) 1498 (setq target-alist (org-export-handle-invisible-targets target-alist))
@@ -1498,8 +1501,7 @@ on this string to produce the exported version."
1498 (org-export-protect-examples (if asciip 'indent nil)) 1501 (org-export-protect-examples (if asciip 'indent nil))
1499 1502
1500 ;; Protect backend specific stuff, throw away the others. 1503 ;; Protect backend specific stuff, throw away the others.
1501 (org-export-select-backend-specific-text 1504 (org-export-select-backend-specific-text backend)
1502 (cond (htmlp 'html) (latexp 'latex) (asciip 'ascii)))
1503 1505
1504 ;; Protect quoted subtrees 1506 ;; Protect quoted subtrees
1505 (org-export-protect-quoted-subtrees) 1507 (org-export-protect-quoted-subtrees)
@@ -1510,10 +1512,13 @@ on this string to produce the exported version."
1510 ;; Blockquotes and verse 1512 ;; Blockquotes and verse
1511 (org-export-mark-blockquote-and-verse) 1513 (org-export-mark-blockquote-and-verse)
1512 1514
1515 ;; Attach captions to the correct opject
1516 (setq target-alist (org-export-attach-captions-and-attributes
1517 backend target-alist))
1518
1513 ;; Remove comment environment and comment subtrees 1519 ;; Remove comment environment and comment subtrees
1514 (org-export-remove-comment-blocks-and-subtrees) 1520 (org-export-remove-comment-blocks-and-subtrees)
1515 1521
1516
1517 ;; Find matches for radio targets and turn them into internal links 1522 ;; Find matches for radio targets and turn them into internal links
1518 (org-export-mark-radio-links) 1523 (org-export-mark-radio-links)
1519 1524
@@ -1571,18 +1576,22 @@ on this string to produce the exported version."
1571The new targets are added to TARGET-ALIST, which is also returned." 1576The new targets are added to TARGET-ALIST, which is also returned."
1572 (goto-char (point-min)) 1577 (goto-char (point-min))
1573 (org-init-section-numbers) 1578 (org-init-section-numbers)
1574 (let ((re (concat "^" org-outline-regexp)) 1579 (let ((re (concat "^" org-outline-regexp
1580 "\\| [ \t]*:ID:[ \t]*\\([^ \t\r\n]+\\)"))
1575 level target) 1581 level target)
1576 (while (re-search-forward re nil t) 1582 (while (re-search-forward re nil t)
1577 (setq level (org-reduced-level 1583 (if (match-end 1)
1578 (save-excursion (goto-char (point-at-bol)) 1584 (push (cons (org-match-string-no-properties 1)
1579 (org-outline-level)))) 1585 target) target-alist)
1580 (setq target (org-solidify-link-text 1586 (setq level (org-reduced-level
1581 (format "sec-%s" (org-section-number level)))) 1587 (save-excursion (goto-char (point-at-bol))
1582 (push (cons target target) target-alist) 1588 (org-outline-level))))
1583 (add-text-properties 1589 (setq target (org-solidify-link-text
1584 (point-at-bol) (point-at-eol) 1590 (format "sec-%s" (org-section-number level))))
1585 (list 'target target)))) 1591 (push (cons target target) target-alist)
1592 (add-text-properties
1593 (point-at-bol) (point-at-eol)
1594 (list 'target target)))))
1586 target-alist) 1595 target-alist)
1587 1596
1588(defun org-export-handle-invisible-targets (target-alist) 1597(defun org-export-handle-invisible-targets (target-alist)
@@ -1611,9 +1620,11 @@ Mark them as invisible targets."
1611 target-alist) 1620 target-alist)
1612 1621
1613(defun org-export-target-internal-links (target-alist) 1622(defun org-export-target-internal-links (target-alist)
1614 "Find all internal links and assign target to them. 1623 "Find all internal links and assign targets to them.
1615If a link has a fuzzy match (i.e. not a *dedicated* target match), 1624If a link has a fuzzy match (i.e. not a *dedicated* target match),
1616let the link point to the corresponding section." 1625let the link point to the corresponding section.
1626This function also handles the id links, if they have a match in
1627the current file."
1617 (goto-char (point-min)) 1628 (goto-char (point-min))
1618 (while (re-search-forward org-bracket-link-regexp nil t) 1629 (while (re-search-forward org-bracket-link-regexp nil t)
1619 (org-if-unprotected 1630 (org-if-unprotected
@@ -1625,6 +1636,8 @@ let the link point to the corresponding section."
1625 (target 1636 (target
1626 (cond 1637 (cond
1627 ((cdr (assoc slink target-alist))) 1638 ((cdr (assoc slink target-alist)))
1639 ((and (string-match "^id:" link)
1640 (cdr (assoc (substring link 3) target-alist))))
1628 ((string-match org-link-types-re link) nil) 1641 ((string-match org-link-types-re link) nil)
1629 ((or (file-name-absolute-p link) 1642 ((or (file-name-absolute-p link)
1630 (string-match "^\\." link)) 1643 (string-match "^\\." link))
@@ -1748,17 +1761,15 @@ from the buffer."
1748 (todo (plist-get opts :todo-keywords)) 1761 (todo (plist-get opts :todo-keywords))
1749 (tags (plist-get opts :tags)) 1762 (tags (plist-get opts :tags))
1750 (pri (plist-get opts :priority)) 1763 (pri (plist-get opts :priority))
1751 rpl) 1764 (elts '(1 2 3 4 5))
1765 rpl props)
1766 (setq elts (delq nil (list 1 (if todo 2) (if pri 3) 4 (if tags 5))))
1752 (when (or (not todo) (not tags) (not pri)) 1767 (when (or (not todo) (not tags) (not pri))
1753 ;; OK, something needs to be removed
1754 (setq rpl (concat "\\1"
1755 (if todo " \\2" "")
1756 (if pri " \\3" "")
1757 " \\4"
1758 (if tags " \\5" "")))
1759 (goto-char (point-min)) 1768 (goto-char (point-min))
1760 (while (re-search-forward re nil t) 1769 (while (re-search-forward re nil t)
1761 (replace-match rpl t nil))))) 1770 (setq rpl (mapconcat (lambda (i) (if (match-end i) (match-string i) ""))
1771 elts " "))
1772 (replace-match rpl t t)))))
1762 1773
1763(defun org-export-protect-quoted-subtrees () 1774(defun org-export-protect-quoted-subtrees ()
1764 "Mark quoted subtrees with the protection property." 1775 "Mark quoted subtrees with the protection property."
@@ -1838,6 +1849,41 @@ These special cookies will later be interpreted by the backend."
1838 "ORG-VERSE-END" "ORG-VERSE-START") 1849 "ORG-VERSE-END" "ORG-VERSE-START")
1839 t t))) 1850 t t)))
1840 1851
1852(defun org-export-attach-captions-and-attributes (backend target-alist)
1853 "Move #+CAPTION, #+ATTR_BACKEND, and #+LABEL text into text properties.
1854If the next thing following is a table, add the text properties to the first
1855table line. If it is a link, add it to the line containing the link."
1856 (goto-char (point-min))
1857 (remove-text-properties (point-min) (point-max)
1858 '(org-caption nil org-attributes nil))
1859 (let ((case-fold-search t)
1860 (re (concat "^#\\+caption:[ \t]+\\(.*\\)"
1861 "\\|"
1862 "^#\\+attr_" (symbol-name backend) ":[ \t]+\\(.*\\)"
1863 "\\|"
1864 "^#\\+label:[ \t]+\\(.*\\)"
1865 "\\|"
1866 "^[ \t]*|[^-]"
1867 "\\|"
1868 "^[ \t]*\\[\\[.*\\]\\][ \t]*$"))
1869 cap attr label)
1870 (while (re-search-forward re nil t)
1871 (cond
1872 ((match-end 1)
1873 (setq cap (concat cap (if cap " " "") (org-trim (match-string 1)))))
1874 ((match-end 2)
1875 (setq attr (concat attr (if attr " " "") (org-trim (match-string 2)))))
1876 ((match-end 3)
1877 (setq label (org-trim (match-string 3))))
1878 (t
1879 (add-text-properties (point-at-bol) (point-at-eol)
1880 (list 'org-caption cap
1881 'org-attributes attr
1882 'org-label label))
1883 (if label (push (cons label label) target-alist))
1884 (setq cap nil attr nil label nil)))))
1885 target-alist)
1886
1841(defun org-export-remove-comment-blocks-and-subtrees () 1887(defun org-export-remove-comment-blocks-and-subtrees ()
1842 "Remove the comment environment, and also commented subtrees." 1888 "Remove the comment environment, and also commented subtrees."
1843 (let ((re-commented (concat "^\\*+[ \t]+" org-comment-string "\\>")) 1889 (let ((re-commented (concat "^\\*+[ \t]+" org-comment-string "\\>"))
@@ -3206,12 +3252,14 @@ lang=\"%s\" xml:lang=\"%s\">
3206 3252
3207 ;; Blockquotes and verse 3253 ;; Blockquotes and verse
3208 (when (equal "ORG-BLOCKQUOTE-START" line) 3254 (when (equal "ORG-BLOCKQUOTE-START" line)
3255 (org-close-par-maybe)
3209 (insert "<blockquote>\n<p>\n") 3256 (insert "<blockquote>\n<p>\n")
3210 (throw 'nextline nil)) 3257 (throw 'nextline nil))
3211 (when (equal "ORG-BLOCKQUOTE-END" line) 3258 (when (equal "ORG-BLOCKQUOTE-END" line)
3212 (insert "</p>\n</blockquote>\n") 3259 (insert "</p>\n</blockquote>\n")
3213 (throw 'nextline nil)) 3260 (throw 'nextline nil))
3214 (when (equal "ORG-VERSE-START" line) 3261 (when (equal "ORG-VERSE-START" line)
3262 (org-close-par-maybe)
3215 (insert "\n<p class=\"verse\">\n") 3263 (insert "\n<p class=\"verse\">\n")
3216 (setq inverse t) 3264 (setq inverse t)
3217 (throw 'nextline nil)) 3265 (throw 'nextline nil))
@@ -3225,7 +3273,7 @@ lang=\"%s\" xml:lang=\"%s\">
3225 (setq line (concat (mapconcat 'identity 3273 (setq line (concat (mapconcat 'identity
3226 (make-list (* 2 i) "\\nbsp") "") 3274 (make-list (* 2 i) "\\nbsp") "")
3227 " " (org-trim line)))) 3275 " " (org-trim line))))
3228 (setq line (concat line " \\\\")))) 3276 (setq line (concat line "\\\\"))))
3229 3277
3230 ;; make targets to anchors 3278 ;; make targets to anchors
3231 (while (string-match "<<<?\\([^<>]*\\)>>>?\\((INVISIBLE)\\)?[ \t]*\n?" line) 3279 (while (string-match "<<<?\\([^<>]*\\)>>>?\\((INVISIBLE)\\)?[ \t]*\n?" line)
@@ -3271,9 +3319,8 @@ lang=\"%s\" xml:lang=\"%s\">
3271 (string-match "^\\.\\.?/" path))) 3319 (string-match "^\\.\\.?/" path)))
3272 "file") 3320 "file")
3273 (t "internal"))) 3321 (t "internal")))
3274 (setq path (org-extract-attributes path)) 3322 (setq path (org-extract-attributes (org-link-unescape path)))
3275 (setq attr (org-attributes-to-string 3323 (setq attr (get-text-property 0 'org-attributes path))
3276 (get-text-property 0 'org-attributes path)))
3277 (setq desc1 (if (match-end 5) (match-string 5 line)) 3324 (setq desc1 (if (match-end 5) (match-string 5 line))
3278 desc2 (if (match-end 2) (concat type ":" path) path) 3325 desc2 (if (match-end 2) (concat type ":" path) path)
3279 descp (and desc1 (not (equal desc1 desc2))) 3326 descp (and desc1 (not (equal desc1 desc2)))
@@ -3302,10 +3349,8 @@ lang=\"%s\" xml:lang=\"%s\">
3302 (if (and (or (eq t org-export-html-inline-images) 3349 (if (and (or (eq t org-export-html-inline-images)
3303 (and org-export-html-inline-images (not descp))) 3350 (and org-export-html-inline-images (not descp)))
3304 (org-file-image-p path)) 3351 (org-file-image-p path))
3305 (setq rpl (concat "<img src=\"" type ":" path "\"" 3352 (setq rpl (org-export-html-format-image
3306 (if (string-match "\\<alt=" attr) 3353 (concat type ":" path)))
3307 attr (concat attr " alt=\"" path "\""))
3308 "/>"))
3309 (setq link (concat type ":" path)) 3354 (setq link (concat type ":" path))
3310 (setq rpl (concat "<a href=\"" 3355 (setq rpl (concat "<a href=\""
3311 (org-export-html-format-href link) 3356 (org-export-html-format-href link)
@@ -3363,11 +3408,7 @@ lang=\"%s\" xml:lang=\"%s\">
3363 (or (eq t org-export-html-inline-images) 3408 (or (eq t org-export-html-inline-images)
3364 (and org-export-html-inline-images 3409 (and org-export-html-inline-images
3365 (not descp)))) 3410 (not descp))))
3366 (concat "<img src=\"" thefile "\"" 3411 (org-export-html-format-image thefile)
3367 (if (string-match "alt=" attr)
3368 attr
3369 (concat attr " alt=\""
3370 thefile "\"")) "/>")
3371 (concat "<a href=\"" thefile "\"" attr ">" 3412 (concat "<a href=\"" thefile "\"" attr ">"
3372 (org-export-html-format-desc desc) 3413 (org-export-html-format-desc desc)
3373 "</a>"))) 3414 "</a>")))
@@ -3668,6 +3709,22 @@ lang=\"%s\" xml:lang=\"%s\">
3668 (org-html-do-expand s)) 3709 (org-html-do-expand s))
3669 s)) 3710 s))
3670 3711
3712(defun org-export-html-format-image (src)
3713 "Create image tag with source and attributes."
3714 (save-match-data
3715 (let* ((caption (org-find-text-property-in-string 'org-caption src))
3716 (attr (org-find-text-property-in-string 'org-attributes src))
3717 (label (org-find-text-property-in-string 'org-label src)))
3718 (format "<div %sclass=\"figure\">
3719<p><img src=\"%s\"%s></p>%s
3720</div>"
3721 (if label (format "id=\"%s\" " label) "")
3722 src
3723 (if (string-match "\\<alt=" (or attr ""))
3724 (concat " " attr )
3725 (concat " " attr " alt=\"" src "\""))
3726 (if caption (concat "\n<p>" caption "</p>") "")))))
3727
3671(defvar org-table-colgroup-info nil) 3728(defvar org-table-colgroup-info nil)
3672(defun org-format-table-ascii (lines) 3729(defun org-format-table-ascii (lines)
3673 "Format a table for ascii export." 3730 "Format a table for ascii export."
@@ -3754,10 +3811,16 @@ lang=\"%s\" xml:lang=\"%s\">
3754 ;; column and the special lines 3811 ;; column and the special lines
3755 (setq lines (org-table-clean-before-export lines))) 3812 (setq lines (org-table-clean-before-export lines)))
3756 3813
3757 (let ((head (and org-export-highlight-first-table-line 3814 (let ((caption (or (get-text-property 0 'org-caption (car lines))
3815 (get-text-property (or (next-single-property-change
3816 0 'org-caption (car lines))
3817 0)
3818 'org-caption (car lines))))
3819 (head (and org-export-highlight-first-table-line
3758 (delq nil (mapcar 3820 (delq nil (mapcar
3759 (lambda (x) (string-match "^[ \t]*|-" x)) 3821 (lambda (x) (string-match "^[ \t]*|-" x))
3760 (cdr lines))))) 3822 (cdr lines)))))
3823
3761 (nlines 0) fnum i 3824 (nlines 0) fnum i
3762 tbopen line fields html gr colgropen) 3825 tbopen line fields html gr colgropen)
3763 (if splice (setq head nil)) 3826 (if splice (setq head nil))
@@ -3814,6 +3877,7 @@ lang=\"%s\" xml:lang=\"%s\">
3814 fnum "") 3877 fnum "")
3815 html) 3878 html)
3816 (if colgropen (setq html (cons (car html) (cons "</colgroup>" (cdr html))))) 3879 (if colgropen (setq html (cons (car html) (cons "</colgroup>" (cdr html)))))
3880 (if caption (push (format "<caption>%s</caption>" caption) html))
3817 (push html-table-tag html)) 3881 (push html-table-tag html))
3818 (concat (mapconcat 'identity html "\n") "\n"))) 3882 (concat (mapconcat 'identity html "\n") "\n")))
3819 3883
diff --git a/lisp/org/org-export-latex.el b/lisp/org/org-export-latex.el
index 12565cc33ff..dbecad12093 100644
--- a/lisp/org/org-export-latex.el
+++ b/lisp/org/org-export-latex.el
@@ -4,7 +4,7 @@
4;; 4;;
5;; Emacs Lisp Archive Entry 5;; Emacs Lisp Archive Entry
6;; Filename: org-export-latex.el 6;; Filename: org-export-latex.el
7;; Version: 6.14 7;; Version: 6.15a
8;; Author: Bastien Guerry <bzg AT altern DOT org> 8;; Author: Bastien Guerry <bzg AT altern DOT org>
9;; Maintainer: Bastien Guerry <bzg AT altern DOT org> 9;; Maintainer: Bastien Guerry <bzg AT altern DOT org>
10;; Keywords: org, wp, tex 10;; Keywords: org, wp, tex
@@ -91,6 +91,7 @@
91\\usepackage[utf8]{inputenc} 91\\usepackage[utf8]{inputenc}
92\\usepackage[T1]{fontenc} 92\\usepackage[T1]{fontenc}
93\\usepackage{graphicx} 93\\usepackage{graphicx}
94\\usepackage{longtable}
94\\usepackage{hyperref}" 95\\usepackage{hyperref}"
95 ("\\section{%s}" . "\\section*{%s}") 96 ("\\section{%s}" . "\\section*{%s}")
96 ("\\subsection{%s}" . "\\subsection*{%s}") 97 ("\\subsection{%s}" . "\\subsection*{%s}")
@@ -102,6 +103,7 @@
102\\usepackage[utf8]{inputenc} 103\\usepackage[utf8]{inputenc}
103\\usepackage[T1]{fontenc} 104\\usepackage[T1]{fontenc}
104\\usepackage{graphicx} 105\\usepackage{graphicx}
106\\usepackage{longtable}
105\\usepackage{hyperref}" 107\\usepackage{hyperref}"
106 ("\\part{%s}" . "\\part*{%s}") 108 ("\\part{%s}" . "\\part*{%s}")
107 ("\\chapter{%s}" . "\\chapter*{%s}") 109 ("\\chapter{%s}" . "\\chapter*{%s}")
@@ -113,6 +115,7 @@
113\\usepackage[utf8]{inputenc} 115\\usepackage[utf8]{inputenc}
114\\usepackage[T1]{fontenc} 116\\usepackage[T1]{fontenc}
115\\usepackage{graphicx} 117\\usepackage{graphicx}
118\\usepackage{longtable}
116\\usepackage{hyperref}" 119\\usepackage{hyperref}"
117 ("\\part{%s}" . "\\part*{%s}") 120 ("\\part{%s}" . "\\part*{%s}")
118 ("\\chapter{%s}" . "\\chapter*{%s}") 121 ("\\chapter{%s}" . "\\chapter*{%s}")
@@ -163,8 +166,8 @@ to represent the section title."
163 ("/" "\\emph{%s}" nil) 166 ("/" "\\emph{%s}" nil)
164 ("_" "\\underline{%s}" nil) 167 ("_" "\\underline{%s}" nil)
165 ("+" "\\texttt{%s}" nil) 168 ("+" "\\texttt{%s}" nil)
166 ("=" "\\texttt{%s}" nil) 169 ("=" "\\verb|%s|" nil)
167 ("~" "\\texttt{%s}" t)) 170 ("~" "\\verb|%s|" t))
168 "Alist of LaTeX expressions to convert emphasis fontifiers. 171 "Alist of LaTeX expressions to convert emphasis fontifiers.
169Each element of the list is a list of three elements. 172Each element of the list is a list of three elements.
170The first element is the character used as a marker for fontification. 173The first element is the character used as a marker for fontification.
@@ -357,6 +360,8 @@ when PUB-DIR is set, use this as the publishing directory."
357 (error "Need a file name to be able to export"))) 360 (error "Need a file name to be able to export")))
358 361
359 (message "Exporting to LaTeX...") 362 (message "Exporting to LaTeX...")
363 (remove-text-properties (point-min) (point-max)
364 '(:org-license-to-kill nil))
360 (org-update-radio-target-regexp) 365 (org-update-radio-target-regexp)
361 (org-export-latex-set-initial-vars ext-plist arg) 366 (org-export-latex-set-initial-vars ext-plist arg)
362 (let* ((wcf (current-window-configuration)) 367 (let* ((wcf (current-window-configuration))
@@ -404,11 +409,10 @@ when PUB-DIR is set, use this as the publishing directory."
404 (odd org-odd-levels-only) 409 (odd org-odd-levels-only)
405 (header (org-export-latex-make-header title opt-plist)) 410 (header (org-export-latex-make-header title opt-plist))
406 (skip (cond (subtree-p nil) 411 (skip (cond (subtree-p nil)
407 (region-p t) 412 (region-p nil)
408 ;; never skip first lines when exporting a subtree
409 (t (plist-get opt-plist :skip-before-1st-heading)))) 413 (t (plist-get opt-plist :skip-before-1st-heading))))
410 (text (plist-get opt-plist :text)) 414 (text (plist-get opt-plist :text))
411 (first-lines (if skip "" (org-export-latex-first-lines))) 415 (first-lines (if skip "" (org-export-latex-first-lines rbeg)))
412 (coding-system (and (boundp 'buffer-file-coding-system) 416 (coding-system (and (boundp 'buffer-file-coding-system)
413 buffer-file-coding-system)) 417 buffer-file-coding-system))
414 (coding-system-for-write (or org-export-latex-coding-system 418 (coding-system-for-write (or org-export-latex-coding-system
@@ -420,17 +424,18 @@ when PUB-DIR is set, use this as the publishing directory."
420 (if region-p (region-end) (point-max)))) 424 (if region-p (region-end) (point-max))))
421 (string-for-export 425 (string-for-export
422 (org-export-preprocess-string 426 (org-export-preprocess-string
423 region :emph-multiline t 427 region
424 :for-LaTeX t 428 :emph-multiline t
425 :comments nil 429 :for-LaTeX t
426 :tags (plist-get opt-plist :tags) 430 :comments nil
427 :priority (plist-get opt-plist :priority) 431 :tags (plist-get opt-plist :tags)
428 :todo-keywords (plist-get opt-plist :todo-keywords) 432 :priority (plist-get opt-plist :priority)
429 :add-text (if (eq to-buffer 'string) nil text) 433 :todo-keywords (plist-get opt-plist :todo-keywords)
430 :skip-before-1st-heading skip 434 :add-text (if (eq to-buffer 'string) nil text)
431 :select-tags (plist-get opt-plist :select-tags) 435 :skip-before-1st-heading skip
432 :exclude-tags (plist-get opt-plist :exclude-tags) 436 :select-tags (plist-get opt-plist :select-tags)
433 :LaTeX-fragments nil))) 437 :exclude-tags (plist-get opt-plist :exclude-tags)
438 :LaTeX-fragments nil)))
434 439
435 (set-buffer buffer) 440 (set-buffer buffer)
436 (erase-buffer) 441 (erase-buffer)
@@ -452,12 +457,6 @@ when PUB-DIR is set, use this as the publishing directory."
452 (unless (or skip (eq to-buffer 'string)) 457 (unless (or skip (eq to-buffer 'string))
453 (insert first-lines)) 458 (insert first-lines))
454 459
455 ;; handle the case where the region does not begin with a section
456 (when region-p
457 (insert (with-temp-buffer
458 (insert string-for-export)
459 (org-export-latex-first-lines))))
460
461 ;; export the content of headlines 460 ;; export the content of headlines
462 (org-export-latex-global 461 (org-export-latex-global
463 (with-temp-buffer 462 (with-temp-buffer
@@ -733,32 +732,33 @@ OPT-PLIST is the options plist for current buffer."
733 (when (and org-export-with-toc 732 (when (and org-export-with-toc
734 (plist-get opt-plist :section-numbers)) 733 (plist-get opt-plist :section-numbers))
735 (cond ((numberp toc) 734 (cond ((numberp toc)
736 (format "\\setcounter{tocdepth}{%s}\n\\tableofcontents\n\n" 735 (format "\\setcounter{tocdepth}{%s}\n\\tableofcontents\n\\vspace*{1cm}\n"
737 (min toc (plist-get opt-plist :headline-levels)))) 736 (min toc (plist-get opt-plist :headline-levels))))
738 (toc (format "\\setcounter{tocdepth}{%s}\n\\tableofcontents\n\n" 737 (toc (format "\\setcounter{tocdepth}{%s}\n\\tableofcontents\n\\vspace*{1cm}\n"
739 (plist-get opt-plist :headline-levels)))))))) 738 (plist-get opt-plist :headline-levels))))))))
740 739
741(defun org-export-latex-first-lines (&optional comments) 740(defun org-export-latex-first-lines (&optional beg)
742 "Export the first lines before first headline. 741 "Export the first lines before first headline.
743COMMENTS is either nil to replace them with the empty string or a 742If BEG is non-nil, the is the beginning of he region."
744formatting string like %%%%s if we want to comment them out."
745 (save-excursion 743 (save-excursion
746 (goto-char (point-min)) 744 (goto-char (or beg (point-min)))
747 (if (org-at-heading-p) (beginning-of-line 2)) 745 (if (org-at-heading-p) (beginning-of-line 2))
748 (let* ((pt (point)) 746 (let* ((pt (point))
749 (end (if (and (re-search-forward "^\\* " nil t) 747 (end (if (re-search-forward "^\\*+ " nil t)
750 (not (eq pt (match-beginning 0))))
751 (goto-char (match-beginning 0)) 748 (goto-char (match-beginning 0))
752 (goto-char (point-max))))) 749 (goto-char (point-max)))))
753 (org-export-latex-content 750 (prog1
754 (org-export-preprocess-string 751 (org-export-latex-content
755 (buffer-substring (point-min) end) 752 (org-export-preprocess-string
756 :for-LaTeX t 753 (buffer-substring pt end)
757 :emph-multiline t 754 :for-LaTeX t
758 :add-text nil 755 :emph-multiline t
759 :comments nil 756 :add-text nil
760 :skip-before-1st-heading nil 757 :comments nil
761 :LaTeX-fragments nil))))) 758 :skip-before-1st-heading nil
759 :LaTeX-fragments nil))
760 (add-text-properties pt (max pt (1- end))
761 '(:org-license-to-kill t))))))
762 762
763(defun org-export-latex-content (content &optional exclude-list) 763(defun org-export-latex-content (content &optional exclude-list)
764 "Convert CONTENT string to LaTeX. 764 "Convert CONTENT string to LaTeX.
@@ -855,8 +855,8 @@ links, keywords, lists, tables, fixed-width"
855 "Export quotation marks depending on language conventions." 855 "Export quotation marks depending on language conventions."
856 (let* ((lang (plist-get org-export-latex-options-plist :language)) 856 (let* ((lang (plist-get org-export-latex-options-plist :language))
857 (quote-rpl (if (equal lang "fr") 857 (quote-rpl (if (equal lang "fr")
858 '(("\\(\\s-\\)\"" "«~") 858 '(("\\(\\s-\\)\"" "«~")
859 ("\\(\\S-\\)\"" "~»") 859 ("\\(\\S-\\)\"" "~»")
860 ("\\(\\s-\\)'" "`")) 860 ("\\(\\s-\\)'" "`"))
861 '(("\\(\\s-\\)\"" "``") 861 '(("\\(\\s-\\)\"" "``")
862 ("\\(\\S-\\)\"" "''") 862 ("\\(\\S-\\)\"" "''")
@@ -877,8 +877,9 @@ See the `org-export-latex.el' code for a complete conversion table."
877 (goto-char (point-min)) 877 (goto-char (point-min))
878 (while (re-search-forward c nil t) 878 (while (re-search-forward c nil t)
879 ;; Put the point where to check for org-protected 879 ;; Put the point where to check for org-protected
880 (unless (or (get-text-property (match-beginning 2) 'org-protected) 880; (unless (or (get-text-property (match-beginning 2) 'org-protected);
881 (org-at-table-p)) 881; (org-at-table-p))
882 (unless (get-text-property (match-beginning 2) 'org-protected)
882 (cond ((member (match-string 2) '("\\$" "$")) 883 (cond ((member (match-string 2) '("\\$" "$"))
883 (if (equal (match-string 2) "\\$") 884 (if (equal (match-string 2) "\\$")
884 (replace-match (concat (match-string 1) "$" 885 (replace-match (concat (match-string 1) "$"
@@ -1035,14 +1036,27 @@ If TIMESTAMPS, convert timestamps, otherwise delete them."
1035 (save-excursion (org-table-align)) 1036 (save-excursion (org-table-align))
1036 (let* ((beg (org-table-begin)) 1037 (let* ((beg (org-table-begin))
1037 (end (org-table-end)) 1038 (end (org-table-end))
1038 (raw-table (buffer-substring-no-properties beg end)) 1039 (raw-table (buffer-substring beg end))
1039 fnum fields line lines olines gr colgropen line-fmt align) 1040 fnum fields line lines olines gr colgropen line-fmt align
1041 caption label attr floatp longtblp)
1040 (if org-export-latex-tables-verbatim 1042 (if org-export-latex-tables-verbatim
1041 (let* ((tbl (concat "\\begin{verbatim}\n" raw-table 1043 (let* ((tbl (concat "\\begin{verbatim}\n" raw-table
1042 "\\end{verbatim}\n"))) 1044 "\\end{verbatim}\n")))
1043 (apply 'delete-region (list beg end)) 1045 (apply 'delete-region (list beg end))
1044 (insert (org-export-latex-protect-string tbl))) 1046 (insert (org-export-latex-protect-string tbl)))
1045 (progn 1047 (progn
1048 (setq caption (org-find-text-property-in-string
1049 'org-caption raw-table)
1050 attr (org-find-text-property-in-string
1051 'org-attributes raw-table)
1052 label (org-find-text-property-in-string
1053 'org-label raw-table)
1054 longtblp (and attr (stringp attr)
1055 (string-match "\\<longtable\\>" attr))
1056 align (and attr (stringp attr)
1057 (string-match "\\<align=\\([^ \t\n\r,]+\\)" attr)
1058 (match-string 1 attr))
1059 floatp (or caption label))
1046 (setq lines (split-string raw-table "\n" t)) 1060 (setq lines (split-string raw-table "\n" t))
1047 (apply 'delete-region (list beg end)) 1061 (apply 'delete-region (list beg end))
1048 (when org-export-table-remove-special-lines 1062 (when org-export-table-remove-special-lines
@@ -1076,10 +1090,11 @@ If TIMESTAMPS, convert timestamps, otherwise delete them."
1076 (string-match "^\\(|\\)?\\(.+\\)|$" line-fmt)) 1090 (string-match "^\\(|\\)?\\(.+\\)|$" line-fmt))
1077 (setq line-fmt (match-string 2 line-fmt))) 1091 (setq line-fmt (match-string 2 line-fmt)))
1078 ;; format alignment 1092 ;; format alignment
1079 (setq align (apply 'format 1093 (unless align
1080 (cons line-fmt 1094 (setq align (apply 'format
1081 (mapcar (lambda (x) (if x "r" "l")) 1095 (cons line-fmt
1082 org-table-last-alignment)))) 1096 (mapcar (lambda (x) (if x "r" "l"))
1097 org-table-last-alignment)))))
1083 ;; prepare the table to send to orgtbl-to-latex 1098 ;; prepare the table to send to orgtbl-to-latex
1084 (setq lines 1099 (setq lines
1085 (mapcar 1100 (mapcar
@@ -1089,8 +1104,34 @@ If TIMESTAMPS, convert timestamps, otherwise delete them."
1089 lines)) 1104 lines))
1090 (when insert 1105 (when insert
1091 (insert (org-export-latex-protect-string 1106 (insert (org-export-latex-protect-string
1092 (orgtbl-to-latex 1107 (concat
1093 lines `(:tstart ,(concat "\\begin{tabular}{" align "}")))) 1108 (if longtblp
1109 (concat "\\begin{longtable}{" align "}\n")
1110 (if floatp "\\begin{table}[htb]\n"))
1111 (if (or floatp longtblp)
1112 (format
1113 "\\caption{%s%s}"
1114 (if label (concat "\\\label{" label "}") "")
1115 (or caption "")))
1116 (if longtblp "\\\\\n" "\n")
1117 (if (not longtblp) "\\begin{center}\n")
1118 (if (not longtblp) (concat "\\begin{tabular}{" align "}\n"))
1119 (orgtbl-to-latex
1120 lines
1121 `(:tstart nil :tend nil
1122 :hlend ,(if longtblp
1123 (format "\\\\
1124\\hline
1125\\endhead
1126\\hline\\multicolumn{%d}{r}{Continued on next page}\\
1127\\endfoot
1128\\endlastfoot" (length org-table-last-alignment))
1129 nil)))
1130 (if (not longtblp) (concat "\n\\end{tabular}"))
1131 (if longtblp "\n" "\n\\end{center}\n")
1132 (if longtblp
1133 "\\end{longtable}"
1134 (if floatp "\\end{table}"))))
1094 "\n\n"))))))) 1135 "\n\n")))))))
1095 1136
1096(defun org-export-latex-fontify () 1137(defun org-export-latex-fontify ()
@@ -1122,10 +1163,17 @@ If TIMESTAMPS, convert timestamps, otherwise delete them."
1122 (goto-char (match-beginning 0)) 1163 (goto-char (match-beginning 0))
1123 (let* ((re-radio org-export-latex-all-targets-re) 1164 (let* ((re-radio org-export-latex-all-targets-re)
1124 (remove (list (match-beginning 0) (match-end 0))) 1165 (remove (list (match-beginning 0) (match-end 0)))
1125 (type (match-string 2))
1126 (raw-path (org-extract-attributes (match-string 3))) 1166 (raw-path (org-extract-attributes (match-string 3)))
1127 (full-raw-path (concat (match-string 1) raw-path)) 1167 (full-raw-path (concat (match-string 1) raw-path))
1128 (desc (match-string 5)) 1168 (desc (match-string 5))
1169 (type (or (match-string 2)
1170 (if (or (file-name-absolute-p raw-path)
1171 (string-match "^\\.\\.?/" raw-path))
1172 "file")))
1173 (caption (org-find-text-property-in-string 'org-caption raw-path))
1174 (attr (org-find-text-property-in-string 'org-attributes raw-path))
1175 (label (org-find-text-property-in-string 'org-label raw-path))
1176 (floatp (or label caption))
1129 imgp radiop 1177 imgp radiop
1130 ;; define the path of the link 1178 ;; define the path of the link
1131 (path (cond 1179 (path (cond
@@ -1137,7 +1185,8 @@ If TIMESTAMPS, convert timestamps, otherwise delete them."
1137 (concat type ":" raw-path)) 1185 (concat type ":" raw-path))
1138 ((equal type "file") 1186 ((equal type "file")
1139 (if (and (or (org-file-image-p (expand-file-name raw-path)) 1187 (if (and (or (org-file-image-p (expand-file-name raw-path))
1140 (string-match "\\.eps$" raw-path)) 1188 (string-match "\\.\\(pdf\\|jpg\\|ps\\|eps\\)$"
1189 raw-path))
1141 (equal desc full-raw-path)) 1190 (equal desc full-raw-path))
1142 (setq imgp t) 1191 (setq imgp t)
1143 (progn (when (string-match "\\(.+\\)::.+" raw-path) 1192 (progn (when (string-match "\\(.+\\)::.+" raw-path)
@@ -1150,10 +1199,17 @@ If TIMESTAMPS, convert timestamps, otherwise delete them."
1150 ;; process with link inserting 1199 ;; process with link inserting
1151 (apply 'delete-region remove) 1200 (apply 'delete-region remove)
1152 (cond ((and imgp (plist-get org-export-latex-options-plist :inline-images)) 1201 (cond ((and imgp (plist-get org-export-latex-options-plist :inline-images))
1153 (insert (format "\\includegraphics[%s]{%s}" 1202 (insert
1154 ;; image option should be set be a comment line 1203 (concat
1155 org-export-latex-image-default-option 1204 (if floatp "\\begin{figure}[htb]\n")
1156 (expand-file-name raw-path)))) 1205 (format "\\centerline{\\includegraphics[%s]{%s}}\n"
1206 (or attr org-export-latex-image-default-option)
1207 (expand-file-name raw-path))
1208 (if floatp
1209 (format "\\caption{%s%s}\n"
1210 (if label (concat "\\label{" label "}"))
1211 (or caption "")))
1212 (if floatp "\\end{figure}\n"))))
1157 (radiop (insert (format "\\hyperref[%s]{%s}" 1213 (radiop (insert (format "\\hyperref[%s]{%s}"
1158 (org-solidify-link-text raw-path) desc))) 1214 (org-solidify-link-text raw-path) desc)))
1159 ((not type) 1215 ((not type)
@@ -1167,7 +1223,6 @@ If TIMESTAMPS, convert timestamps, otherwise delete them."
1167 1223
1168(defun org-export-latex-preprocess () 1224(defun org-export-latex-preprocess ()
1169 "Clean stuff in the LaTeX export." 1225 "Clean stuff in the LaTeX export."
1170
1171 ;; Preserve line breaks 1226 ;; Preserve line breaks
1172 (goto-char (point-min)) 1227 (goto-char (point-min))
1173 (while (re-search-forward "\\\\\\\\" nil t) 1228 (while (re-search-forward "\\\\\\\\" nil t)
diff --git a/lisp/org/org-faces.el b/lisp/org/org-faces.el
index b6b7894b334..a031ad6756c 100644
--- a/lisp/org/org-faces.el
+++ b/lisp/org/org-faces.el
@@ -5,7 +5,7 @@
5;; Author: Carsten Dominik <carsten at orgmode dot org> 5;; Author: Carsten Dominik <carsten at orgmode dot org>
6;; Keywords: outlines, hypermedia, calendar, wp 6;; Keywords: outlines, hypermedia, calendar, wp
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 6.14 8;; Version: 6.15a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
diff --git a/lisp/org/org-gnus.el b/lisp/org/org-gnus.el
index 1058b0d988c..1585d8232f9 100644
--- a/lisp/org/org-gnus.el
+++ b/lisp/org/org-gnus.el
@@ -6,7 +6,7 @@
6;; Tassilo Horn <tassilo at member dot fsf dot org> 6;; Tassilo Horn <tassilo at member dot fsf dot org>
7;; Keywords: outlines, hypermedia, calendar, wp 7;; Keywords: outlines, hypermedia, calendar, wp
8;; Homepage: http://orgmode.org 8;; Homepage: http://orgmode.org
9;; Version: 6.14 9;; Version: 6.15a
10;; 10;;
11;; This file is part of GNU Emacs. 11;; This file is part of GNU Emacs.
12;; 12;;
@@ -74,11 +74,11 @@ If `org-store-link' was called with a prefix arg the meaning of
74 (if (and (string-match "^nntp" group) ;; Only for nntp groups 74 (if (and (string-match "^nntp" group) ;; Only for nntp groups
75 (org-xor current-prefix-arg 75 (org-xor current-prefix-arg
76 org-gnus-prefer-web-links)) 76 org-gnus-prefer-web-links))
77 (concat (if (string-match "gmane" unprefixed-group) 77 (org-make-link (if (string-match "gmane" unprefixed-group)
78 "http://news.gmane.org/" 78 "http://news.gmane.org/"
79 "http://groups.google.com/group/") 79 "http://groups.google.com/group/")
80 unprefixed-group) 80 unprefixed-group)
81 (concat "gnus:" group)))) 81 (org-make-link "gnus:" group))))
82 82
83(defun org-gnus-article-link (group newsgroups message-id x-no-archive) 83(defun org-gnus-article-link (group newsgroups message-id x-no-archive)
84 "Create a link to a Gnus article. 84 "Create a link to a Gnus article.
@@ -98,8 +98,7 @@ If `org-store-link' was called with a prefix arg the meaning of
98 (format (if (string-match "gmane\\." newsgroups) 98 (format (if (string-match "gmane\\." newsgroups)
99 "http://mid.gmane.org/%s" 99 "http://mid.gmane.org/%s"
100 "http://groups.google.com/groups/search?as_umsgid=%s") 100 "http://groups.google.com/groups/search?as_umsgid=%s")
101 (org-fixup-message-id-for-http 101 (org-fixup-message-id-for-http message-id))
102 (replace-regexp-in-string "[<>]" "" message-id)))
103 (org-make-link "gnus:" group "#" message-id))) 102 (org-make-link "gnus:" group "#" message-id)))
104 103
105(defun org-gnus-store-link () 104(defun org-gnus-store-link ()
@@ -115,7 +114,7 @@ If `org-store-link' was called with a prefix arg the meaning of
115 (unless group (error "Not on a group")) 114 (unless group (error "Not on a group"))
116 (org-store-link-props :type "gnus" :group group) 115 (org-store-link-props :type "gnus" :group group)
117 (setq desc (org-gnus-group-link group) 116 (setq desc (org-gnus-group-link group)
118 link (org-make-link desc)) 117 link desc)
119 (org-add-link-props :link link :description desc) 118 (org-add-link-props :link link :description desc)
120 link)) 119 link))
121 120
@@ -127,7 +126,8 @@ If `org-store-link' was called with a prefix arg the meaning of
127 (goto-char (point-min)) 126 (goto-char (point-min))
128 (mail-header-extract-no-properties))) 127 (mail-header-extract-no-properties)))
129 (from (mail-header 'from header)) 128 (from (mail-header 'from header))
130 (message-id (mail-header 'message-id header)) 129 (message-id (org-remove-angle-brackets
130 (mail-header 'message-id header)))
131 (date (mail-header 'date header)) 131 (date (mail-header 'date header))
132 (to (mail-header 'to header)) 132 (to (mail-header 'to header))
133 (newsgroups (mail-header 'newsgroups header)) 133 (newsgroups (mail-header 'newsgroups header))
@@ -149,6 +149,10 @@ If `org-store-link' was called with a prefix arg the meaning of
149 (error "Error in Gnus link")) 149 (error "Error in Gnus link"))
150 (setq group (match-string 1 path) 150 (setq group (match-string 1 path)
151 article (match-string 3 path)) 151 article (match-string 3 path))
152 (when group
153 (setq group (org-substring-no-properties group)))
154 (when article
155 (setq article (org-substring-no-properties article)))
152 (org-gnus-follow-link group article))) 156 (org-gnus-follow-link group article)))
153 157
154(defun org-gnus-follow-link (&optional group article) 158(defun org-gnus-follow-link (&optional group article)
@@ -156,13 +160,28 @@ If `org-store-link' was called with a prefix arg the meaning of
156 (require 'gnus) 160 (require 'gnus)
157 (funcall (cdr (assq 'gnus org-link-frame-setup))) 161 (funcall (cdr (assq 'gnus org-link-frame-setup)))
158 (if gnus-other-frame-object (select-frame gnus-other-frame-object)) 162 (if gnus-other-frame-object (select-frame gnus-other-frame-object))
163 (when group
164 (setq group (org-substring-no-properties group)))
165 (when article
166 (setq article (org-substring-no-properties article)))
159 (cond ((and group article) 167 (cond ((and group article)
160 (gnus-group-read-group 1 nil group) 168 (gnus-activate-group group t)
161 (gnus-summary-goto-article 169 (condition-case nil
162 (if (string-match "[^0-9]" article) 170 (let ((articles 1)
163 article 171 group-opened)
164 (string-to-number article)) 172 (while (and (not group-opened)
165 nil t)) 173 ;; stop on integer overflows
174 (> articles 0))
175 (setq group-opened (gnus-group-read-group articles nil group)
176 articles (if (< articles 16)
177 (1+ articles)
178 (* articles 2))))
179 (if group-opened
180 (gnus-summary-goto-article article nil t)
181 (message "Couldn't follow gnus link. %s"
182 "The summary couldn't be opened.")))
183 (quit (message "Couldn't follow gnus link. %s"
184 "The linked group is empty."))))
166 (group (gnus-group-jump-to-group group)))) 185 (group (gnus-group-jump-to-group group))))
167 186
168(defun org-gnus-no-new-news () 187(defun org-gnus-no-new-news ()
diff --git a/lisp/org/org-id.el b/lisp/org/org-id.el
index 07f78824fd6..41525f8b2c1 100644
--- a/lisp/org/org-id.el
+++ b/lisp/org/org-id.el
@@ -1,10 +1,10 @@
1;;; org-id.el --- Global identifier for Org-mode entries 1;;; org-id.el --- Global identifiers for Org-mode entries
2;; Copyright (C) 2008 Free Software Foundation, Inc. 2;; Copyright (C) 2008 Free Software Foundation, Inc.
3;; 3;;
4;; Author: Carsten Dominik <carsten at orgmode dot org> 4;; Author: Carsten Dominik <carsten at orgmode dot org>
5;; Keywords: outlines, hypermedia, calendar, wp 5;; Keywords: outlines, hypermedia, calendar, wp
6;; Homepage: http://orgmode.org 6;; Homepage: http://orgmode.org
7;; Version: 6.14 7;; Version: 6.15a
8;; 8;;
9;; This file is part of GNU Emacs. 9;; This file is part of GNU Emacs.
10;; 10;;
@@ -35,7 +35,7 @@
35;; Org has a builtin method that uses a compact encoding of the creation 35;; Org has a builtin method that uses a compact encoding of the creation
36;; time of the ID, with microsecond accuracy. This virtually 36;; time of the ID, with microsecond accuracy. This virtually
37;; guarantees globally unique identifiers, even if several people are 37;; guarantees globally unique identifiers, even if several people are
38;; creating ID's at the same time in files that will eventually be used 38;; creating IDs at the same time in files that will eventually be used
39;; together. As an exernal method `uuidgen' is supported, if installed 39;; together. As an exernal method `uuidgen' is supported, if installed
40;; on the system. 40;; on the system.
41;; 41;;
@@ -78,17 +78,26 @@
78 :tag "Org ID" 78 :tag "Org ID"
79 :group 'org) 79 :group 'org)
80 80
81(defcustom org-id-method 'org
82 "The method that should be used to create new ID's.
83 81
84An ID will consist of the prefix specified in `org-id-prefix', and a unique 82(defcustom org-id-method
85part created by the method this variable specifies. 83 (condition-case nil
84 (if (string-match "\\`[-0-9a-fA-F]\\{36\\}\\'"
85 (org-trim (shell-command-to-string "uuidgen")))
86 'uuidgen
87 'org)
88 (error 'org))
89 "The method that should be used to create new IDs.
90
91If `uuidgen' is available on the system, it will be used as the default method.
92if not. the methd `org' is used.
93An ID will consist of the optional prefix specified in `org-id-prefix',
94and a unique part created by the method this variable specifies.
86 95
87Allowed values are: 96Allowed values are:
88 97
89org Org's own internal method, using an encoding of the current time, 98org Org's own internal method, using an encoding of the current time to
90 and the current domain of the computer. This method will 99 microsecond accuracy, and optionally the current domain of the
91 honor the variable `org-id-include-domain'. 100 computer. See the variable `org-id-include-domain'.
92 101
93uuidgen Call the external command uuidgen." 102uuidgen Call the external command uuidgen."
94 :group 'org-id 103 :group 'org-id
@@ -107,26 +116,54 @@ to have no space characters in them."
107 (const :tag "No prefix") 116 (const :tag "No prefix")
108 (string :tag "Prefix"))) 117 (string :tag "Prefix")))
109 118
110(defcustom org-id-include-domain t 119(defcustom org-id-include-domain nil
111 "Non-nil means, add the domain name to new IDs. 120 "Non-nil means, add the domain name to new IDs.
112This ensures global uniqueness of ID's, and is also suggested by 121This ensures global uniqueness of IDs, and is also suggested by
113RFC 2445 in combination with RFC 822. This is only relevant if 122RFC 2445 in combination with RFC 822. This is only relevant if
114`org-id-method' is `org'. When uuidgen is used, the domain will never 123`org-id-method' is `org'. When uuidgen is used, the domain will never
115be added." 124be added.
125The default is to not use this because we have no really good way to get
126the true domain, and Org entries will normally not be shared with enough
127people to make this necessary."
128 :group 'org-id
129 :type 'boolean)
130
131(defcustom org-id-track-globally t
132 "Non-nil means, track IDs trhough files, so that links work globally.
133This work by maintaining a hash table for IDs and writing this table
134to disk when exiting Emacs. Because of this, it works best if you use
135a single Emacs process, not many.
136
137When nil, IDs are not tracked. Links to IDs will still work within
138a buffer, but not if the entry is located in another file.
139IDs can still be used if the entry with the id is in the same file as
140the link."
116 :group 'org-id 141 :group 'org-id
117 :type 'boolean) 142 :type 'boolean)
118 143
119(defcustom org-id-locations-file (convert-standard-filename 144(defcustom org-id-locations-file (convert-standard-filename
120 "~/.org-id-locations") 145 "~/.emacs.d/.org-id-locations")
121 "The file for remembering the last ID number generated." 146 "The file for remembering in which file an ID was defined.
147This variable is only relevant when `org-id-track-globally' is set."
122 :group 'org-id 148 :group 'org-id
123 :type 'file) 149 :type 'file)
124 150
125(defvar org-id-locations nil 151(defvar org-id-locations nil
126 "List of files with ID's in those files.") 152 "List of files with IDs in those files.
153Depending on `org-id-use-hash' this can also be a hash table mapping IDs
154to files.")
155
156(defvar org-id-files nil
157 "List of files that contain IDs.")
127 158
128(defcustom org-id-extra-files 'org-agenda-text-search-extra-files 159(defcustom org-id-extra-files 'org-agenda-text-search-extra-files
129 "Files to be searched for ID's, besides the agenda files." 160 "Files to be searched for IDs, besides the agenda files.
161When Org reparses files to remake the list of files and IDs it is tracking,
162it will normally scan the agenda files, the archives related to agenda files,
163any files that are listed as ID containing in the current register, and
164any Org-mode files currently visited by Emacs.
165You can list additional files here.
166This variable is only relevant when `org-id-track-globally' is set."
130 :group 'org-id 167 :group 'org-id
131 :type 168 :type
132 '(choice 169 '(choice
@@ -134,6 +171,14 @@ be added."
134 (repeat :tag "List of files" 171 (repeat :tag "List of files"
135 (file)))) 172 (file))))
136 173
174(defcustom org-id-search-archives t
175 "Non-nil means, search also the archive files of agenda files for entries.
176This is a possibility to reduce overhead, but it measn that entries moved
177to the archives can no longer be found by ID.
178This variable is only relevant when `org-id-track-globally' is set."
179 :group 'org-id
180 :type 'boolean)
181
137;;; The API functions 182;;; The API functions
138 183
139;;;###autoload 184;;;###autoload
@@ -202,7 +247,7 @@ It returns the ID of the entry. If necessary, the ID is created."
202(defun org-id-goto (id) 247(defun org-id-goto (id)
203 "Switch to the buffer containing the entry with id ID. 248 "Switch to the buffer containing the entry with id ID.
204Move the cursor to that entry in that buffer." 249Move the cursor to that entry in that buffer."
205 (interactive) 250 (interactive "sID: ")
206 (let ((m (org-id-find id 'marker))) 251 (let ((m (org-id-find id 'marker)))
207 (unless m 252 (unless m
208 (error "Cannot find entry with ID \"%s\"" id)) 253 (error "Cannot find entry with ID \"%s\"" id))
@@ -326,77 +371,163 @@ and time is the usual three-integer representation of time."
326 371
327;; Storing ID locations (files) 372;; Storing ID locations (files)
328 373
329(defun org-id-update-id-locations () 374(defun org-id-update-id-locations (&optional files)
330 "Scan relevant files for ID's. 375 "Scan relevant files for IDs.
331Store the relation between files and corresponding ID's." 376Store the relation between files and corresponding IDs.
377This will scan all agenda files, all associated archives, and all
378files currently mentioned in `org-id-locations'.
379When FILES is given, scan these files instead.
380When CHECK is given, prepare detailed iinformation about duplicate IDs."
332 (interactive) 381 (interactive)
333 (let ((files (append (org-agenda-files) 382 (if (not org-id-track-globally)
334 (if (symbolp org-id-extra-files) 383 (error "Please turn on `org-id-track-globally' if you want to track IDs.")
335 (symbol-value org-id-extra-files) 384 (let ((files
336 org-id-extra-files))) 385 (or files
337 org-agenda-new-buffers 386 (append
338 file ids reg found id) 387 ;; Agenda files and all associated archives
339 (while (setq file (pop files)) 388 (org-agenda-files t org-id-search-archives)
340 (setq ids nil) 389 ;; Explicit extra files
341 (with-current-buffer (org-get-agenda-file-buffer file) 390 (if (symbolp org-id-extra-files)
342 (save-excursion 391 (symbol-value org-id-extra-files)
343 (save-restriction 392 org-id-extra-files)
344 (widen) 393 ;; Files associated with live org-mode buffers
345 (goto-char (point-min)) 394 (delq nil
346 (while (re-search-forward "^[ \t]*:ID:[ \t]+\\(\\S-+\\)[ \t]*$" 395 (mapcar (lambda (b)
347 nil t) 396 (with-current-buffer b
348 (setq id (org-match-string-no-properties 1)) 397 (and (org-mode-p) (buffer-file-name))))
349 (if (member id found) 398 (buffer-list)))
350 (error "Duplicate ID \"%s\"" id)) 399 ;; All files known to have IDs
351 (push id found) 400 org-id-files)))
352 (push id ids)) 401 org-agenda-new-buffers
353 (push (cons file ids) reg))))) 402 file nfiles tfile ids reg found id seen (ndup 0))
354 (org-release-buffers org-agenda-new-buffers) 403 (setq nfiles (length files))
355 (setq org-agenda-new-buffers nil) 404 (while (setq file (pop files))
356 (setq org-id-locations reg) 405 (message "Finding ID locations (%d/%d files): %s"
357 (org-id-locations-save))) 406 (- nfiles (length files)) nfiles file)
407 (setq tfile (file-truename file))
408 (when (and (file-exists-p file) (not (member tfile seen)))
409 (push tfile seen)
410 (setq ids nil)
411 (with-current-buffer (org-get-agenda-file-buffer file)
412 (save-excursion
413 (save-restriction
414 (widen)
415 (goto-char (point-min))
416 (while (re-search-forward "^[ \t]*:ID:[ \t]+\\(\\S-+\\)[ \t]*$"
417 nil t)
418 (setq id (org-match-string-no-properties 1))
419 (if (member id found)
420 (progn
421 (message "Duplicate ID \"%s\", also in file %s"
422 id (car (delq
423 nil
424 (mapcar
425 (lambda (x)
426 (if (member id (cdr x)) (car x)))
427 reg))))
428 (when (= ndup 0)
429 (ding)
430 (sit-for 2))
431 (setq ndup (1+ ndup)))
432 (push id found)
433 (push id ids)))
434 (push (cons (abbreviate-file-name file) ids) reg))))))
435 (org-release-buffers org-agenda-new-buffers)
436 (setq org-agenda-new-buffers nil)
437 (setq org-id-locations reg)
438 (setq org-id-files (mapcar 'car org-id-locations))
439 (org-id-locations-save) ;; this function can also handle the alist form
440 ;; now convert to a hash
441 (setq org-id-locations (org-id-alist-to-hash org-id-locations))
442 (if (> ndup 0)
443 (message "WARNING: %d duplicate IDs found, check *Messages* buffer" ndup)
444 (message "%d unique files scanned for IDs" (length org-id-files)))
445 org-id-locations)))
358 446
359(defun org-id-locations-save () 447(defun org-id-locations-save ()
360 "Save `org-id-locations' in `org-id-locations-file'." 448 "Save `org-id-locations' in `org-id-locations-file'."
361 (with-temp-file org-id-locations-file 449 (when org-id-track-globally
362 (print org-id-locations (current-buffer)))) 450 (let ((out (if (hash-table-p org-id-locations)
451 (org-id-hash-to-alist org-id-locations)
452 org-id-locations)))
453 (with-temp-file org-id-locations-file
454 (print out (current-buffer))))))
363 455
364(defun org-id-locations-load () 456(defun org-id-locations-load ()
365 "Read the data from `org-id-locations-file'." 457 "Read the data from `org-id-locations-file'."
366 (setq org-id-locations nil) 458 (setq org-id-locations nil)
367 (with-temp-buffer 459 (when org-id-track-globally
368 (condition-case nil 460 (with-temp-buffer
369 (progn 461 (condition-case nil
370 (insert-file-contents-literally org-id-locations-file) 462 (progn
371 (goto-char (point-min)) 463 (insert-file-contents-literally org-id-locations-file)
372 (setq org-id-locations (read (current-buffer)))) 464 (goto-char (point-min))
373 (error 465 (setq org-id-locations (read (current-buffer))))
374 (message "Could not read org-id-values from %s. Setting it to nil." 466 (error
375 org-id-locations-file))))) 467 (message "Could not read org-id-values from %s. Setting it to nil."
468 org-id-locations-file))))
469 (setq org-id-files (mapcar 'car org-id-locations))
470 (setq org-id-locations (org-id-alist-to-hash org-id-locations))))
376 471
377(defun org-id-add-location (id file) 472(defun org-id-add-location (id file)
378 "Add the ID with location FILE to the database of ID loations." 473 "Add the ID with location FILE to the database of ID loations."
379 (when (and id file) ; don't error when called from a buffer with no file 474 ;; Only if global tracking is on, and when the buffer has a file
475 (when (and org-id-track-globally id file)
380 (unless org-id-locations (org-id-locations-load)) 476 (unless org-id-locations (org-id-locations-load))
381 (catch 'exit 477 (puthash id (abbreviate-file-name file) org-id-locations)
382 (let ((locs org-id-locations) list) 478 (add-to-list 'org-id-files (abbreviate-file-name file))))
383 (while (setq list (pop locs)) 479
384 (when (equal (file-truename file) (file-truename (car list))) 480(add-hook 'kill-emacs-hook 'org-id-locations-save)
385 (setcdr list (cons id (cdr list))) 481
386 (throw 'exit t)))) 482(defun org-id-hash-to-alist (hash)
387 (push (list file id) org-id-locations)) 483 "Turn an org-id hash into an alist, so that it can be written to a file."
388 (org-id-locations-save))) 484 (let (res x)
485 (maphash
486 (lambda (k v)
487 (if (setq x (member v res))
488 (setcdr x (cons k (cdr x)))
489 (push (list v k) res)))
490 hash)
491 res))
492
493(defun org-id-alist-to-hash (list)
494 "Turn an org-id location list into a hash table."
495 (let ((res (make-hash-table
496 :test 'equal
497 :size (apply '+ (mapcar 'length list))))
498 f i)
499 (mapc
500 (lambda (x)
501 (setq f (car x))
502 (mapc (lambda (i) (puthash i f res)) (cdr x)))
503 list)
504 res))
505
506(defun org-id-paste-tracker (txt &optional buffer-or-file)
507 "Update any IDs in TXT and assign BUFFER-OR-FILE to them."
508 (when org-id-track-globally
509 (save-match-data
510 (setq buffer-or-file (or buffer-or-file (current-buffer)))
511 (when (bufferp buffer-or-file)
512 (setq buffer-or-file (or (buffer-base-buffer buffer-or-file)
513 buffer-or-file))
514 (setq buffer-or-file (buffer-file-name buffer-or-file)))
515 (when buffer-or-file
516 (let ((fname (abbreviate-file-name buffer-or-file))
517 (s 0))
518 (while (string-match "^[ \t]*:ID:[ \t]+\\([^ \t\n\r]+\\)" txt s)
519 (setq s (match-end 0))
520 (org-id-add-location (match-string 1 txt) fname)))))))
389 521
390;; Finding entries with specified id 522;; Finding entries with specified id
391 523
392(defun org-id-find-id-file (id) 524(defun org-id-find-id-file (id)
393 "Query the id database for the file in which this ID is located." 525 "Query the id database for the file in which this ID is located."
394 (unless org-id-locations (org-id-locations-load)) 526 (unless org-id-locations (org-id-locations-load))
395 (catch 'found 527 (or (gethash id org-id-locations)
396 (mapc (lambda (x) (if (member id (cdr x)) 528 ;; ball back on current buffer
397 (throw 'found (car x)))) 529 (buffer-file-name (or (buffer-base-buffer (current-buffer))
398 org-id-locations) 530 (current-buffer)))))
399 nil))
400 531
401(defun org-id-find-id-in-file (id file &optional markerp) 532(defun org-id-find-id-in-file (id file &optional markerp)
402 "Return the position of the entry ID in FILE. 533 "Return the position of the entry ID in FILE.
@@ -415,8 +546,41 @@ optional argument MARKERP, return the position as a new marker."
415 (move-marker (make-marker) pos buf) 546 (move-marker (make-marker) pos buf)
416 (cons file pos)))))))) 547 (cons file pos))))))))
417 548
549;; id link type
550
551;; Calling the following function is hard-coded into `org-store-link',
552;; so we do have to add it to `org-store-link-functions'.
553
554(defun org-id-store-link ()
555 "Store a link to the current entry, using it's ID."
556 (interactive)
557 (let* ((link (org-make-link "id:" (org-id-get-create)))
558 (desc (save-excursion
559 (org-back-to-heading t)
560 (or (and (looking-at org-complex-heading-regexp)
561 (if (match-end 4) (match-string 4) (match-string 0)))
562 link))))
563 (org-store-link-props :link link :description desc :type "id")
564 link))
565
566(defun org-id-open (id)
567 "Go to the entry with id ID."
568 (org-mark-ring-push)
569 (let ((m (org-id-find id 'marker)))
570 (unless m
571 (error "Cannot find entry with ID \"%s\"" id))
572 (if (not (equal (current-buffer) (marker-buffer m)))
573 (switch-to-buffer-other-window (marker-buffer m)))
574 (goto-char m)
575 (move-marker m nil)
576 (org-show-context)))
577
578(org-add-link-type "id" 'org-id-open)
579
418(provide 'org-id) 580(provide 'org-id)
419 581
420;;; org-id.el ends here 582;;; org-id.el ends here
421 583
422;; arch-tag: e5abaca4-e16f-4b25-832a-540cfb63a712 584;; arch-tag: e5abaca4-e16f-4b25-832a-540cfb63a712
585
586
diff --git a/lisp/org/org-info.el b/lisp/org/org-info.el
index bbd8fbb77a4..88b037de1c4 100644
--- a/lisp/org/org-info.el
+++ b/lisp/org/org-info.el
@@ -5,7 +5,7 @@
5;; Author: Carsten Dominik <carsten at orgmode dot org> 5;; Author: Carsten Dominik <carsten at orgmode dot org>
6;; Keywords: outlines, hypermedia, calendar, wp 6;; Keywords: outlines, hypermedia, calendar, wp
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 6.14 8;; Version: 6.15a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
diff --git a/lisp/org/org-irc.el b/lisp/org/org-irc.el
index 897f0c93ff8..803e6cbb7dc 100644
--- a/lisp/org/org-irc.el
+++ b/lisp/org/org-irc.el
@@ -4,7 +4,7 @@
4;; 4;;
5;; Author: Philip Jackson <emacs@shellarchive.co.uk> 5;; Author: Philip Jackson <emacs@shellarchive.co.uk>
6;; Keywords: erc, irc, link, org 6;; Keywords: erc, irc, link, org
7;; Version: 6.14 7;; Version: 6.15a
8;; 8;;
9;; This file is part of GNU Emacs. 9;; This file is part of GNU Emacs.
10;; 10;;
diff --git a/lisp/org/org-jsinfo.el b/lisp/org/org-jsinfo.el
index 5f5c0b06733..40925e75f35 100644
--- a/lisp/org/org-jsinfo.el
+++ b/lisp/org/org-jsinfo.el
@@ -5,7 +5,7 @@
5;; Author: Carsten Dominik <carsten at orgmode dot org> 5;; Author: Carsten Dominik <carsten at orgmode dot org>
6;; Keywords: outlines, hypermedia, calendar, wp 6;; Keywords: outlines, hypermedia, calendar, wp
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 6.14 8;; Version: 6.15a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
diff --git a/lisp/org/org-list.el b/lisp/org/org-list.el
index 324d56cae72..e697d8b7004 100644
--- a/lisp/org/org-list.el
+++ b/lisp/org/org-list.el
@@ -6,7 +6,7 @@
6;; Bastien Guerry <bzg AT altern DOT org> 6;; Bastien Guerry <bzg AT altern DOT org>
7;; Keywords: outlines, hypermedia, calendar, wp 7;; Keywords: outlines, hypermedia, calendar, wp
8;; Homepage: http://orgmode.org 8;; Homepage: http://orgmode.org
9;; Version: 6.14 9;; Version: 6.15a
10;; 10;;
11;; This file is part of GNU Emacs. 11;; This file is part of GNU Emacs.
12;; 12;;
diff --git a/lisp/org/org-mac-message.el b/lisp/org/org-mac-message.el
index 5b9d3c355c5..c3af14e92f2 100644
--- a/lisp/org/org-mac-message.el
+++ b/lisp/org/org-mac-message.el
@@ -3,7 +3,7 @@
3;; Copyright (C) 2008 Free Software Foundation, Inc. 3;; Copyright (C) 2008 Free Software Foundation, Inc.
4 4
5;; Author: John Wiegley <johnw@gnu.org> 5;; Author: John Wiegley <johnw@gnu.org>
6;; Version: 6.14 6;; Version: 6.15a
7;; Keywords: outlines, hypermedia, calendar, wp 7;; Keywords: outlines, hypermedia, calendar, wp
8 8
9;; This file is part of GNU Emacs. 9;; This file is part of GNU Emacs.
diff --git a/lisp/org/org-macs.el b/lisp/org/org-macs.el
index db18eff00f0..785309f0693 100644
--- a/lisp/org/org-macs.el
+++ b/lisp/org/org-macs.el
@@ -5,7 +5,7 @@
5;; Author: Carsten Dominik <carsten at orgmode dot org> 5;; Author: Carsten Dominik <carsten at orgmode dot org>
6;; Keywords: outlines, hypermedia, calendar, wp 6;; Keywords: outlines, hypermedia, calendar, wp
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 6.14 8;; Version: 6.15a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
diff --git a/lisp/org/org-mew.el b/lisp/org/org-mew.el
index e5e226d68a9..b88198140b6 100644
--- a/lisp/org/org-mew.el
+++ b/lisp/org/org-mew.el
@@ -5,7 +5,7 @@
5;; Author: Tokuya Kameshima <kames at fa2 dot so-net dot ne dot jp> 5;; Author: Tokuya Kameshima <kames at fa2 dot so-net dot ne dot jp>
6;; Keywords: outlines, hypermedia, calendar, wp 6;; Keywords: outlines, hypermedia, calendar, wp
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 6.14 8;; Version: 6.15a
9 9
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11 11
diff --git a/lisp/org/org-mhe.el b/lisp/org/org-mhe.el
index 9938f52c980..b5237bac243 100644
--- a/lisp/org/org-mhe.el
+++ b/lisp/org/org-mhe.el
@@ -5,7 +5,7 @@
5;; Author: Thomas Baumann <thomas dot baumann at ch dot tum dot de> 5;; Author: Thomas Baumann <thomas dot baumann at ch dot tum dot de>
6;; Keywords: outlines, hypermedia, calendar, wp 6;; Keywords: outlines, hypermedia, calendar, wp
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 6.14 8;; Version: 6.15a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
diff --git a/lisp/org/org-mouse.el b/lisp/org/org-mouse.el
index 1e622ef0fd4..d08899ca3d6 100644
--- a/lisp/org/org-mouse.el
+++ b/lisp/org/org-mouse.el
@@ -4,7 +4,7 @@
4;; 4;;
5;; Author: Piotr Zielinski <piotr dot zielinski at gmail dot com> 5;; Author: Piotr Zielinski <piotr dot zielinski at gmail dot com>
6;; Maintainer: Carsten Dominik <carsten at orgmode dot org> 6;; Maintainer: Carsten Dominik <carsten at orgmode dot org>
7;; Version: 6.14 7;; Version: 6.15a
8;; 8;;
9;; This file is part of GNU Emacs. 9;; This file is part of GNU Emacs.
10;; 10;;
diff --git a/lisp/org/org-plot.el b/lisp/org/org-plot.el
index 0fc781053b0..6110fccd838 100644
--- a/lisp/org/org-plot.el
+++ b/lisp/org/org-plot.el
@@ -5,7 +5,7 @@
5;; Author: Eric Schulte <schulte dot eric at gmail dot com> 5;; Author: Eric Schulte <schulte dot eric at gmail dot com>
6;; Keywords: tables, plotting 6;; Keywords: tables, plotting
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 6.14 8;; Version: 6.15a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
diff --git a/lisp/org/org-publish.el b/lisp/org/org-publish.el
index 1bb96ed822d..785dbce6879 100644
--- a/lisp/org/org-publish.el
+++ b/lisp/org/org-publish.el
@@ -4,7 +4,7 @@
4;; Author: David O'Toole <dto@gnu.org> 4;; Author: David O'Toole <dto@gnu.org>
5;; Maintainer: Bastien Guerry <bzg AT altern DOT org> 5;; Maintainer: Bastien Guerry <bzg AT altern DOT org>
6;; Keywords: hypermedia, outlines, wp 6;; Keywords: hypermedia, outlines, wp
7;; Version: 6.14 7;; Version: 6.15a
8 8
9;; This file is part of GNU Emacs. 9;; This file is part of GNU Emacs.
10;; 10;;
diff --git a/lisp/org/org-remember.el b/lisp/org/org-remember.el
index 54037736482..4d6ef1bd71f 100644
--- a/lisp/org/org-remember.el
+++ b/lisp/org/org-remember.el
@@ -5,7 +5,7 @@
5;; Author: Carsten Dominik <carsten at orgmode dot org> 5;; Author: Carsten Dominik <carsten at orgmode dot org>
6;; Keywords: outlines, hypermedia, calendar, wp 6;; Keywords: outlines, hypermedia, calendar, wp
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 6.14 8;; Version: 6.15a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
diff --git a/lisp/org/org-rmail.el b/lisp/org/org-rmail.el
index ebdb1dd990a..05009990e5f 100644
--- a/lisp/org/org-rmail.el
+++ b/lisp/org/org-rmail.el
@@ -5,7 +5,7 @@
5;; Author: Carsten Dominik <carsten at orgmode dot org> 5;; Author: Carsten Dominik <carsten at orgmode dot org>
6;; Keywords: outlines, hypermedia, calendar, wp 6;; Keywords: outlines, hypermedia, calendar, wp
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 6.14 8;; Version: 6.15a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
diff --git a/lisp/org/org-table.el b/lisp/org/org-table.el
index 8a223bc0d9b..2384dcb15ee 100644
--- a/lisp/org/org-table.el
+++ b/lisp/org/org-table.el
@@ -5,7 +5,7 @@
5;; Author: Carsten Dominik <carsten at orgmode dot org> 5;; Author: Carsten Dominik <carsten at orgmode dot org>
6;; Keywords: outlines, hypermedia, calendar, wp 6;; Keywords: outlines, hypermedia, calendar, wp
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 6.14 8;; Version: 6.15a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
@@ -1897,7 +1897,8 @@ For all numbers larger than LIMIT, shift them by DELTA."
1897 (beginning-of-line 2) 1897 (beginning-of-line 2)
1898 (setq l (1+ l))) 1898 (setq l (1+ l)))
1899 (setq org-table-current-line-types (apply 'vector (nreverse types)) 1899 (setq org-table-current-line-types (apply 'vector (nreverse types))
1900 org-table-dlines (apply 'vector (cons nil (nreverse dlines))) 1900 org-table-dlines (apply 'vector (cons (car dlines)
1901 (nreverse dlines)))
1901 org-table-hlines (apply 'vector (cons nil (nreverse hlines))))))) 1902 org-table-hlines (apply 'vector (cons nil (nreverse hlines)))))))
1902 1903
1903(defun org-table-maybe-eval-formula () 1904(defun org-table-maybe-eval-formula ()
@@ -2360,12 +2361,17 @@ LISPP means to return something appropriate for a Lisp list."
2360 2361
2361(defun org-table-recalculate (&optional all noalign) 2362(defun org-table-recalculate (&optional all noalign)
2362 "Recalculate the current table line by applying all stored formulas. 2363 "Recalculate the current table line by applying all stored formulas.
2363With prefix arg ALL, do this for all lines in the table." 2364With prefix arg ALL, do this for all lines in the table.
2365With the prefix argument ALL is `(16)' (a double `C-c C-u' prefix), or if
2366it is the symbol `iterate', recompute the table until it no longer changes.
2367If NOALIGN is not nil, do not re-align the table after the computations
2368are done. This is typically used internally to save time, if it is
2369known that the table will be realigned a little later anyway."
2364 (interactive "P") 2370 (interactive "P")
2365 (or (memq this-command org-recalc-commands) 2371 (or (memq this-command org-recalc-commands)
2366 (setq org-recalc-commands (cons this-command org-recalc-commands))) 2372 (setq org-recalc-commands (cons this-command org-recalc-commands)))
2367 (unless (org-at-table-p) (error "Not at a table")) 2373 (unless (org-at-table-p) (error "Not at a table"))
2368 (if (equal all '(16)) 2374 (if (or (eq all 'iterate) (equal all '(16)))
2369 (org-table-iterate) 2375 (org-table-iterate)
2370 (org-table-get-specials) 2376 (org-table-get-specials)
2371 (let* ((eqlist (sort (org-table-get-stored-formulas) 2377 (let* ((eqlist (sort (org-table-get-stored-formulas)
@@ -3865,9 +3871,15 @@ directly by `orgtbl-send-table'. See manual."
3865 3871
3866 ;; Do we have a heading section? If so, format it and handle the 3872 ;; Do we have a heading section? If so, format it and handle the
3867 ;; trailing hline. 3873 ;; trailing hline.
3868 (if (and (not splicep) (listp (car *orgtbl-table*)) 3874 (if (and (not splicep)
3869 (memq 'hline *orgtbl-table*)) 3875 (or (consp (car *orgtbl-table*))
3876 (consp (nth 1 *orgtbl-table*)))
3877 (memq 'hline (cdr *orgtbl-table*)))
3870 (progn 3878 (progn
3879 (when (eq 'hline (car *orgtbl-table*))
3880 ;; there is a hline before the first data line
3881 (and hline (push hline *orgtbl-rtn*))
3882 (pop *orgtbl-table*))
3871 (let* ((*orgtbl-lstart* (or (plist-get params :hlstart) 3883 (let* ((*orgtbl-lstart* (or (plist-get params :hlstart)
3872 *orgtbl-lstart*)) 3884 *orgtbl-lstart*))
3873 (*orgtbl-llstart* (or (plist-get params :hllstart) 3885 (*orgtbl-llstart* (or (plist-get params :hllstart)
diff --git a/lisp/org/org-timer.el b/lisp/org/org-timer.el
index ff2fc2bff2b..07a62484b32 100644
--- a/lisp/org/org-timer.el
+++ b/lisp/org/org-timer.el
@@ -5,7 +5,7 @@
5;; Author: Carsten Dominik <carsten at orgmode dot org> 5;; Author: Carsten Dominik <carsten at orgmode dot org>
6;; Keywords: outlines, hypermedia, calendar, wp 6;; Keywords: outlines, hypermedia, calendar, wp
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 6.14 8;; Version: 6.15a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
diff --git a/lisp/org/org-vm.el b/lisp/org/org-vm.el
index a152b0395ba..b27470b4c29 100644
--- a/lisp/org/org-vm.el
+++ b/lisp/org/org-vm.el
@@ -5,7 +5,7 @@
5;; Author: Carsten Dominik <carsten at orgmode dot org> 5;; Author: Carsten Dominik <carsten at orgmode dot org>
6;; Keywords: outlines, hypermedia, calendar, wp 6;; Keywords: outlines, hypermedia, calendar, wp
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 6.14 8;; Version: 6.15a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
diff --git a/lisp/org/org-w3m.el b/lisp/org/org-w3m.el
index 9803b338eae..801484860a1 100644
--- a/lisp/org/org-w3m.el
+++ b/lisp/org/org-w3m.el
@@ -5,7 +5,7 @@
5;; Author: Andy Stewart <lazycat dot manatee at gmail dot com> 5;; Author: Andy Stewart <lazycat dot manatee at gmail dot com>
6;; Keywords: outlines, hypermedia, calendar, wp 6;; Keywords: outlines, hypermedia, calendar, wp
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 6.14 8;; Version: 6.15a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
diff --git a/lisp/org/org-wl.el b/lisp/org/org-wl.el
index 6fdf26960f6..a101c701541 100644
--- a/lisp/org/org-wl.el
+++ b/lisp/org/org-wl.el
@@ -5,7 +5,7 @@
5;; Author: Tokuya Kameshima <kames at fa2 dot so-net dot ne dot jp> 5;; Author: Tokuya Kameshima <kames at fa2 dot so-net dot ne dot jp>
6;; Keywords: outlines, hypermedia, calendar, wp 6;; Keywords: outlines, hypermedia, calendar, wp
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 6.14 8;; Version: 6.15a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
diff --git a/lisp/org/org.el b/lisp/org/org.el
index cb105c24457..86ad833f1dc 100644
--- a/lisp/org/org.el
+++ b/lisp/org/org.el
@@ -5,7 +5,7 @@
5;; Author: Carsten Dominik <carsten at orgmode dot org> 5;; Author: Carsten Dominik <carsten at orgmode dot org>
6;; Keywords: outlines, hypermedia, calendar, wp 6;; Keywords: outlines, hypermedia, calendar, wp
7;; Homepage: http://orgmode.org 7;; Homepage: http://orgmode.org
8;; Version: 6.14 8;; Version: 6.15a
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
@@ -92,7 +92,7 @@
92 92
93;;; Version 93;;; Version
94 94
95(defconst org-version "6.14" 95(defconst org-version "6.15a"
96 "The version number of the file org.el.") 96 "The version number of the file org.el.")
97 97
98(defun org-version (&optional here) 98(defun org-version (&optional here)
@@ -162,7 +162,7 @@ to add the symbol `xyz', and the package must have a call to
162 (const :tag " bbdb: Links to BBDB entries" org-bbdb) 162 (const :tag " bbdb: Links to BBDB entries" org-bbdb)
163 (const :tag " bibtex: Links to BibTeX entries" org-bibtex) 163 (const :tag " bibtex: Links to BibTeX entries" org-bibtex)
164 (const :tag " gnus: Links to GNUS folders/messages" org-gnus) 164 (const :tag " gnus: Links to GNUS folders/messages" org-gnus)
165 (const :tag " id: Global id's for identifying entries" org-id) 165 (const :tag " id: Global IDs for identifying entries" org-id)
166 (const :tag " info: Links to Info nodes" org-info) 166 (const :tag " info: Links to Info nodes" org-info)
167 (const :tag " jsinfo: Set up Sebastian Rose's JavaScript org-info.js" org-jsinfo) 167 (const :tag " jsinfo: Set up Sebastian Rose's JavaScript org-info.js" org-jsinfo)
168 (const :tag " irc: Links to IRC/ERC chat sessions" org-irc) 168 (const :tag " irc: Links to IRC/ERC chat sessions" org-irc)
@@ -178,13 +178,13 @@ to add the symbol `xyz', and the package must have a call to
178 (const :tag "C annotate-file: Annotate a file with org syntax" org-annotate-file) 178 (const :tag "C annotate-file: Annotate a file with org syntax" org-annotate-file)
179 (const :tag "C annotation-helper: Call Remeber directly from Browser" org-annotation-helper) 179 (const :tag "C annotation-helper: Call Remeber directly from Browser" org-annotation-helper)
180 (const :tag "C bookmark: Org links to bookmarks" org-bookmark) 180 (const :tag "C bookmark: Org links to bookmarks" org-bookmark)
181 (const :tag "C browser-url: Store link, directly from Browser" org-browser-url)
181 (const :tag "C depend: TODO dependencies for Org-mode" org-depend) 182 (const :tag "C depend: TODO dependencies for Org-mode" org-depend)
182 (const :tag "C elisp-symbol: Org links to emacs-lisp symbols" org-elisp-symbol) 183 (const :tag "C elisp-symbol: Org links to emacs-lisp symbols" org-elisp-symbol)
183 (const :tag "C eval: Include command output as text" org-eval) 184 (const :tag "C eval: Include command output as text" org-eval)
184 (const :tag "C eval-light: Evaluate inbuffer-code on demand" org-eval-light) 185 (const :tag "C eval-light: Evaluate inbuffer-code on demand" org-eval-light)
185 (const :tag "C expiry: Expiry mechanism for Org entries" org-expiry) 186 (const :tag "C expiry: Expiry mechanism for Org entries" org-expiry)
186 (const :tag "C exp-blocks: Pre-process blocks for export" org-exp-blocks) 187 (const :tag "C exp-blocks: Pre-process blocks for export" org-exp-blocks)
187 (const :tag "C id: Global id's for identifying entries" org-id)
188 (const :tag "C interactive-query: Interactive modification of tags query" org-interactive-query) 188 (const :tag "C interactive-query: Interactive modification of tags query" org-interactive-query)
189 (const :tag "C mairix: Hook mairix search into Org for different MUAs" org-mairix) 189 (const :tag "C mairix: Hook mairix search into Org for different MUAs" org-mairix)
190 (const :tag "C man: Support for links to manpages in Org-mode" org-man) 190 (const :tag "C man: Support for links to manpages in Org-mode" org-man)
@@ -956,6 +956,40 @@ It should match if the message is from the user him/herself."
956 :group 'org-link-store 956 :group 'org-link-store
957 :type 'regexp) 957 :type 'regexp)
958 958
959(defcustom org-link-to-org-use-id 'create-if-interactive
960 "Non-nil means, storing a link to an Org file will use entry IDs.
961
962Note that before this variable is even considered, org-id must be loaded,
963to please customize `org-modules' and turn it on.
964
965The variable can have the following values:
966
967t Create an ID if needed to make a link to the current entry.
968
969create-if-interactive
970 If `org-store-link' is called directly (interactively, as a user
971 command), do create an ID to support the link. But when doing the
972 job for remember, only use the ID if it already exists. The
973 purpose of this setting is to avoid proliferation of unwanted
974 IDs, just because you happen to be in an Org file when you
975 call `org-remember' that automatically and preemptively
976 creates a link. If you do want to get an ID link in a remember
977 template to an entry not having an ID, create it first by
978 explicitly creating a link to it, using `C-c C-l' first.
979
980use-existing
981 Use existing ID, do not create one.
982
983nil Never use an ID to make a link, instead link using a text search for
984 the headline text."
985 :group 'org-link-store
986 :type '(choice
987 (const :tag "Create ID to make link" t)
988 (const :tag "Create if string link interactively"
989 'create-if-interactive)
990 (const :tag "Only use existing" 'use-existing)
991 (const :tag "Do not use ID to create link" nil)))
992
959(defcustom org-context-in-file-links t 993(defcustom org-context-in-file-links t
960 "Non-nil means, file links from `org-store-link' contain context. 994 "Non-nil means, file links from `org-store-link' contain context.
961A search string will be added to the file name with :: as separator and 995A search string will be added to the file name with :: as separator and
@@ -1283,6 +1317,11 @@ outline-path-completion Headlines in the current buffer are offered via
1283 (const :tag "Outline" outline) 1317 (const :tag "Outline" outline)
1284 (const :tag "Outline-path-completion" outline-path-completion))) 1318 (const :tag "Outline-path-completion" outline-path-completion)))
1285 1319
1320(defcustom org-goto-max-level 5
1321 "Maximum level to be considered when running org-goto with refile interface."
1322 :group 'org-refile
1323 :type 'number)
1324
1286(defcustom org-reverse-note-order nil 1325(defcustom org-reverse-note-order nil
1287 "Non-nil means, store new notes at the beginning of a file or entry. 1326 "Non-nil means, store new notes at the beginning of a file or entry.
1288When nil, new notes will be filed to the end of a file or entry. 1327When nil, new notes will be filed to the end of a file or entry.
@@ -1515,14 +1554,22 @@ or `done', meaning any not-done or done state, respectively."
1515 (choice (const :tag "Add" t) (const :tag "Remove" nil))))))) 1554 (choice (const :tag "Add" t) (const :tag "Remove" nil)))))))
1516 1555
1517(defcustom org-log-done nil 1556(defcustom org-log-done nil
1518 "Non-nil means, record a CLOSED timestamp when moving an entry to DONE. 1557 "Information to record when a task moves to the DONE state.
1519When equal to the list (done), also prompt for a closing note. 1558
1520This can also be configured on a per-file basis by adding one of 1559Possible values are:
1521the following lines anywhere in the buffer: 1560
1561nil Don't add anything, just change the keyword
1562time Add a time stamp to the task
1563note Prompt a closing note and add it with template `org-log-note-headings'
1522 1564
1565This option can also be set with on a per-file-basis with
1566
1567 #+STARTUP: nologdone
1523 #+STARTUP: logdone 1568 #+STARTUP: logdone
1524 #+STARTUP: lognotedone 1569 #+STARTUP: lognotedone
1525 #+STARTUP: nologdone" 1570
1571You can have local logging settings for a subtree by setting the LOGGING
1572property to one or more of these keywords."
1526 :group 'org-todo 1573 :group 'org-todo
1527 :group 'org-progress 1574 :group 'org-progress
1528 :type '(choice 1575 :type '(choice
@@ -2806,11 +2853,12 @@ collapsed state."
2806 2853
2807;; Autoload ID code 2854;; Autoload ID code
2808 2855
2856(declare-function org-id-store-link "org-id")
2809(org-autoload "org-id" 2857(org-autoload "org-id"
2810 '(org-id-get-create org-id-new org-id-copy org-id-get 2858 '(org-id-get-create org-id-new org-id-copy org-id-get
2811 org-id-get-with-outline-path-completion 2859 org-id-get-with-outline-path-completion
2812 org-id-get-with-outline-drilling 2860 org-id-get-with-outline-drilling
2813 org-id-goto org-id-find)) 2861 org-id-goto org-id-find org-id-store-link))
2814 2862
2815;;; Variables for pre-computed regular expressions, all buffer local 2863;;; Variables for pre-computed regular expressions, all buffer local
2816 2864
@@ -4504,7 +4552,7 @@ which the visibility is still unchanged. After RET is will also jump to
4504the location selected in the indirect buffer and expose the 4552the location selected in the indirect buffer and expose the
4505the headline hierarchy above." 4553the headline hierarchy above."
4506 (interactive "P") 4554 (interactive "P")
4507 (let* ((org-refile-targets '((nil . (:maxlevel . 10)))) 4555 (let* ((org-refile-targets `((nil . (:maxlevel . ,org-goto-max-level))))
4508 (org-refile-use-outline-path t) 4556 (org-refile-use-outline-path t)
4509 (interface 4557 (interface
4510 (if (not alternative-interface) 4558 (if (not alternative-interface)
@@ -5268,6 +5316,7 @@ the inserted text when done."
5268 (beginning-of-line 1) 5316 (beginning-of-line 1)
5269 (unless for-yank (org-back-over-empty-lines)) 5317 (unless for-yank (org-back-over-empty-lines))
5270 (setq beg (point)) 5318 (setq beg (point))
5319 (and (fboundp 'org-id-paste-tracker) (org-id-paste-tracker txt))
5271 (insert-before-markers txt) 5320 (insert-before-markers txt)
5272 (unless (string-match "\n\\'" txt) (insert "\n")) 5321 (unless (string-match "\n\\'" txt) (insert "\n"))
5273 (setq newend (point)) 5322 (setq newend (point))
@@ -6141,7 +6190,6 @@ type. For a simple example of an export function, see `org-bbdb.el'."
6141 (setcdr (assoc type org-link-protocols) (list follow export)) 6190 (setcdr (assoc type org-link-protocols) (list follow export))
6142 (push (list type follow export) org-link-protocols))) 6191 (push (list type follow export) org-link-protocols)))
6143 6192
6144
6145;;;###autoload 6193;;;###autoload
6146(defun org-store-link (arg) 6194(defun org-store-link (arg)
6147 "\\<org-mode-map>Store an org-link to the current location. 6195 "\\<org-mode-map>Store an org-link to the current location.
@@ -6202,14 +6250,34 @@ For file links, arg negates `org-context-in-file-links'."
6202 link (org-make-link cpltxt))) 6250 link (org-make-link cpltxt)))
6203 6251
6204 ((and buffer-file-name (org-mode-p)) 6252 ((and buffer-file-name (org-mode-p))
6205 ;; Just link to current headline 6253 (cond
6206 (setq cpltxt (concat "file:" 6254 ((org-in-regexp "<<\\(.*?\\)>>")
6207 (abbreviate-file-name buffer-file-name))) 6255 (setq cpltxt
6208 ;; Add a context search string 6256 (concat "file:"
6209 (when (org-xor org-context-in-file-links arg) 6257 (abbreviate-file-name buffer-file-name)
6210 ;; Check if we are on a target 6258 "::" (match-string 1))
6211 (if (org-in-regexp "<<\\(.*?\\)>>") 6259 link (org-make-link cpltxt)))
6212 (setq cpltxt (concat cpltxt "::" (match-string 1))) 6260 ((and (featurep 'org-id)
6261 (or (eq org-link-to-org-use-id t)
6262 (and (eq org-link-to-org-use-id 'create-if-interactive)
6263 (interactive-p))
6264 (and org-link-to-org-use-id
6265 (condition-case nil
6266 (org-entry-get nil "ID")
6267 (error nil)))))
6268 ;; We can make a link using the ID.
6269 (setq link (condition-case nil
6270 (org-id-store-link)
6271 (error
6272 ;; probably before first headling, link to file only
6273 (concat "file:"
6274 (abbreviate-file-name buffer-file-name))))))
6275 (t
6276 ;; Just link to current headline
6277 (setq cpltxt (concat "file:"
6278 (abbreviate-file-name buffer-file-name)))
6279 ;; Add a context search string
6280 (when (org-xor org-context-in-file-links arg)
6213 (setq txt (cond 6281 (setq txt (cond
6214 ((org-on-heading-p) nil) 6282 ((org-on-heading-p) nil)
6215 ((org-region-active-p) 6283 ((org-region-active-p)
@@ -6221,10 +6289,10 @@ For file links, arg negates `org-context-in-file-links'."
6221 (condition-case nil 6289 (condition-case nil
6222 (org-make-org-heading-search-string txt) 6290 (org-make-org-heading-search-string txt)
6223 (error ""))) 6291 (error "")))
6224 desc "NONE")))) 6292 desc "NONE")))
6225 (if (string-match "::\\'" cpltxt) 6293 (if (string-match "::\\'" cpltxt)
6226 (setq cpltxt (substring cpltxt 0 -2))) 6294 (setq cpltxt (substring cpltxt 0 -2)))
6227 (setq link (org-make-link cpltxt))) 6295 (setq link (org-make-link cpltxt)))))
6228 6296
6229 ((buffer-file-name (buffer-base-buffer)) 6297 ((buffer-file-name (buffer-base-buffer))
6230 ;; Just link to this file here. 6298 ;; Just link to this file here.
@@ -6655,7 +6723,7 @@ used as the link location instead of reading one interactively."
6655 (setq key (match-string 1 a) value (match-string 2 a) 6723 (setq key (match-string 1 a) value (match-string 2 a)
6656 start (match-end 0) 6724 start (match-end 0)
6657 attr (plist-put attr (intern key) value)))) 6725 attr (plist-put attr (intern key) value))))
6658 (org-add-props s nil 'org-attributes attr)) 6726 (org-add-props s nil 'org-attr attr))
6659 s)) 6727 s))
6660 6728
6661(defun org-attributes-to-string (plist) 6729(defun org-attributes-to-string (plist)
@@ -6663,7 +6731,8 @@ used as the link location instead of reading one interactively."
6663 (let ((s "") key value) 6731 (let ((s "") key value)
6664 (while plist 6732 (while plist
6665 (setq key (pop plist) value (pop plist)) 6733 (setq key (pop plist) value (pop plist))
6666 (setq s (concat s " "(symbol-name key) "=\"" value "\""))) 6734 (and value
6735 (setq s (concat s " " (symbol-name key) "=\"" value "\""))))
6667 s)) 6736 s))
6668 6737
6669;;; Opening/following a link 6738;;; Opening/following a link
@@ -7392,10 +7461,12 @@ on the system \"/user@host:\"."
7392(defun org-get-refile-targets (&optional default-buffer) 7461(defun org-get-refile-targets (&optional default-buffer)
7393 "Produce a table with refile targets." 7462 "Produce a table with refile targets."
7394 (let ((entries (or org-refile-targets '((nil . (:level . 1))))) 7463 (let ((entries (or org-refile-targets '((nil . (:level . 1)))))
7395 targets txt re files f desc descre) 7464 targets txt re files f desc descre fast-path-p level)
7465 (message "Getting targets...")
7396 (with-current-buffer (or default-buffer (current-buffer)) 7466 (with-current-buffer (or default-buffer (current-buffer))
7397 (while (setq entry (pop entries)) 7467 (while (setq entry (pop entries))
7398 (setq files (car entry) desc (cdr entry)) 7468 (setq files (car entry) desc (cdr entry))
7469 (setq fast-path-p nil)
7399 (cond 7470 (cond
7400 ((null files) (setq files (list (current-buffer)))) 7471 ((null files) (setq files (list (current-buffer))))
7401 ((eq files 'org-agenda-files) 7472 ((eq files 'org-agenda-files)
@@ -7419,6 +7490,7 @@ on the system \"/user@host:\"."
7419 (cdr desc))) 7490 (cdr desc)))
7420 "\\}[ \t]"))) 7491 "\\}[ \t]")))
7421 ((eq (car desc) :maxlevel) 7492 ((eq (car desc) :maxlevel)
7493 (setq fast-path-p t)
7422 (setq descre (concat "^\\*\\{1," (number-to-string 7494 (setq descre (concat "^\\*\\{1," (number-to-string
7423 (if org-odd-levels-only 7495 (if org-odd-levels-only
7424 (1- (* 2 (cdr desc))) 7496 (1- (* 2 (cdr desc)))
@@ -7436,7 +7508,8 @@ on the system \"/user@host:\"."
7436 (while (re-search-forward descre nil t) 7508 (while (re-search-forward descre nil t)
7437 (goto-char (point-at-bol)) 7509 (goto-char (point-at-bol))
7438 (when (looking-at org-complex-heading-regexp) 7510 (when (looking-at org-complex-heading-regexp)
7439 (setq txt (org-link-display-format (match-string 4)) 7511 (setq level (org-reduced-level (- (match-end 1) (match-beginning 1)))
7512 txt (org-link-display-format (match-string 4))
7440 re (concat "^" (regexp-quote 7513 re (concat "^" (regexp-quote
7441 (buffer-substring (match-beginning 1) 7514 (buffer-substring (match-beginning 1)
7442 (match-end 4))))) 7515 (match-end 4)))))
@@ -7452,26 +7525,37 @@ on the system \"/user@host:\"."
7452 (buffer-file-name (buffer-base-buffer)))) 7525 (buffer-file-name (buffer-base-buffer))))
7453 (if (eq org-refile-use-outline-path 'full-file-path) 7526 (if (eq org-refile-use-outline-path 'full-file-path)
7454 (list (buffer-file-name (buffer-base-buffer))))) 7527 (list (buffer-file-name (buffer-base-buffer)))))
7455 (org-get-outline-path) 7528 (org-get-outline-path fast-path-p level txt)
7456 (list txt)) 7529 (list txt))
7457 "/"))) 7530 "/")))
7458 (push (list txt f re (point)) targets)) 7531 (push (list txt f re (point)) targets))
7459 (goto-char (point-at-eol)))))))) 7532 (goto-char (point-at-eol))))))))
7460 (nreverse targets)))) 7533 (message "Getting targets...done")
7534 (nreverse targets))))
7461 7535
7462(defun org-protect-slash (s) 7536(defun org-protect-slash (s)
7463 (while (string-match "/" s) 7537 (while (string-match "/" s)
7464 (setq s (replace-match "\\" t t s))) 7538 (setq s (replace-match "\\" t t s)))
7465 s) 7539 s)
7466 7540
7467(defun org-get-outline-path () 7541(defvar org-olpa (make-vector 20 nil))
7542
7543(defun org-get-outline-path (&optional fastp level heading)
7468 "Return the outline path to the current entry, as a list." 7544 "Return the outline path to the current entry, as a list."
7469 (let (rtn) 7545 (if (> level 19) (error "Outline path failure, more than 19 levels."))
7470 (save-excursion 7546 (if fastp
7471 (while (org-up-heading-safe) 7547 (progn
7472 (when (looking-at org-complex-heading-regexp) 7548 (loop for i from level upto 19 do
7473 (push (org-match-string-no-properties 4) rtn))) 7549 (aset org-olpa i nil))
7474 rtn))) 7550 (prog1
7551 (delq nil (append org-olpa nil))
7552 (aset org-olpa level heading)))
7553 (let (rtn)
7554 (save-excursion
7555 (while (org-up-heading-safe)
7556 (when (looking-at org-complex-heading-regexp)
7557 (push (org-match-string-no-properties 4) rtn)))
7558 rtn))))
7475 7559
7476(defvar org-refile-history nil 7560(defvar org-refile-history nil
7477 "History for refiling operations.") 7561 "History for refiling operations.")
@@ -7514,6 +7598,15 @@ operation has put the subtree."
7514 (setq file (nth 1 it) 7598 (setq file (nth 1 it)
7515 re (nth 2 it) 7599 re (nth 2 it)
7516 pos (nth 3 it)) 7600 pos (nth 3 it))
7601 (if (and (equal (buffer-file-name) file)
7602 (if regionp
7603 (and (>= pos region-start)
7604 (<= pos region-end))
7605 (and (>= pos (point))
7606 (< pos (save-excursion
7607 (org-end-of-subtree t t))))))
7608 (error "Cannot refile to position inside the tree or region"))
7609
7517 (setq nbuf (or (find-buffer-visiting file) 7610 (setq nbuf (or (find-buffer-visiting file)
7518 (find-file-noselect file))) 7611 (find-file-noselect file)))
7519 (if goto 7612 (if goto
@@ -7571,10 +7664,9 @@ operation has put the subtree."
7571 'org-ido-completing-read)) 7664 'org-ido-completing-read))
7572 (extra (if org-refile-use-outline-path "/" "")) 7665 (extra (if org-refile-use-outline-path "/" ""))
7573 (filename (buffer-file-name (buffer-base-buffer cbuf))) 7666 (filename (buffer-file-name (buffer-base-buffer cbuf)))
7574 (fname (and filename (file-truename filename)))
7575 (tbl (mapcar 7667 (tbl (mapcar
7576 (lambda (x) 7668 (lambda (x)
7577 (if (not (equal fname (file-truename (nth 1 x)))) 7669 (if (not (equal filename (nth 1 x)))
7578 (cons (concat (car x) extra " (" 7670 (cons (concat (car x) extra " ("
7579 (file-name-nondirectory (nth 1 x)) ")") 7671 (file-name-nondirectory (nth 1 x)) ")")
7580 (cdr x)) 7672 (cdr x))
@@ -7740,7 +7832,8 @@ This function can be used in a hook."
7740 "BEGIN_EXAMPLE" "END_EXAMPLE" 7832 "BEGIN_EXAMPLE" "END_EXAMPLE"
7741 "BEGIN_QUOTE" "END_QUOTE" 7833 "BEGIN_QUOTE" "END_QUOTE"
7742 "BEGIN_VERSE" "END_VERSE" 7834 "BEGIN_VERSE" "END_VERSE"
7743 "BEGIN_SRC" "END_SRC")) 7835 "BEGIN_SRC" "END_SRC"
7836 "CAPTION" "LABEL" "ATTR_HTML" "ATTR_LaTeX"))
7744 7837
7745(defcustom org-structure-template-alist 7838(defcustom org-structure-template-alist
7746 '( 7839 '(
@@ -9437,10 +9530,9 @@ ignore inherited ones."
9437(defun org-toggle-tag (tag &optional onoff) 9530(defun org-toggle-tag (tag &optional onoff)
9438 "Toggle the tag TAG for the current line. 9531 "Toggle the tag TAG for the current line.
9439If ONOFF is `on' or `off', don't toggle but set to this state." 9532If ONOFF is `on' or `off', don't toggle but set to this state."
9440 (unless (org-on-heading-p t) (error "Not on headling"))
9441 (let (res current) 9533 (let (res current)
9442 (save-excursion 9534 (save-excursion
9443 (beginning-of-line) 9535 (org-back-to-heading t)
9444 (if (re-search-forward (org-re "[ \t]:\\([[:alnum:]_@:]+\\):[ \t]*$") 9536 (if (re-search-forward (org-re "[ \t]:\\([[:alnum:]_@:]+\\):[ \t]*$")
9445 (point-at-eol) t) 9537 (point-at-eol) t)
9446 (progn 9538 (progn
@@ -10559,6 +10651,7 @@ completion."
10559IDENT can be a string, a symbol or a number, this function will search for 10651IDENT can be a string, a symbol or a number, this function will search for
10560the string representation of it. 10652the string representation of it.
10561Return the position where this entry starts, or nil if there is no such entry." 10653Return the position where this entry starts, or nil if there is no such entry."
10654 (interactive "sID: ")
10562 (let ((id (cond 10655 (let ((id (cond
10563 ((stringp ident) ident) 10656 ((stringp ident) ident)
10564 ((symbol-name ident) (symbol-name ident)) 10657 ((symbol-name ident) (symbol-name ident))
@@ -13412,6 +13505,12 @@ With optional NODE, go directly to that node."
13412 13505
13413;;; Generally useful functions 13506;;; Generally useful functions
13414 13507
13508(defun org-find-text-property-in-string (prop s)
13509 "Return the first non-nil value of property PROP in string S."
13510 (or (get-text-property 0 prop s)
13511 (get-text-property (or (next-single-property-change 0 prop s) 0)
13512 prop s)))
13513
13415(defun org-display-warning (message) ;; Copied from Emacs-Muse 13514(defun org-display-warning (message) ;; Copied from Emacs-Muse
13416 "Display the given MESSAGE as a warning." 13515 "Display the given MESSAGE as a warning."
13417 (if (fboundp 'display-warning) 13516 (if (fboundp 'display-warning)
@@ -14308,6 +14407,11 @@ plainly yank the text as it is.
14308 (error (error "Before first headline at position %d in buffer %s" 14407 (error (error "Before first headline at position %d in buffer %s"
14309 (point) (current-buffer))))) 14408 (point) (current-buffer)))))
14310 14409
14410(defun org-before-first-heading-p ()
14411 "Before first heading?"
14412 (save-excursion
14413 (null (re-search-backward "^\\*+ " nil t))))
14414
14311(defalias 'org-on-heading-p 'outline-on-heading-p) 14415(defalias 'org-on-heading-p 'outline-on-heading-p)
14312(defalias 'org-at-heading-p 'outline-on-heading-p) 14416(defalias 'org-at-heading-p 'outline-on-heading-p)
14313(defun org-at-heading-or-item-p () 14417(defun org-at-heading-or-item-p ()
@@ -14329,16 +14433,14 @@ With argument, move up ARG levels."
14329 "Move to the heading line of which the present line is a subheading. 14433 "Move to the heading line of which the present line is a subheading.
14330This version will not throw an error. It will return the level of the 14434This version will not throw an error. It will return the level of the
14331headline found, or nil if no higher level is found." 14435headline found, or nil if no higher level is found."
14332 (let ((pos (point)) start-level level 14436 (let (start-level re)
14333 (re (concat "^" outline-regexp))) 14437 (org-back-to-heading t)
14334 (catch 'exit 14438 (setq start-level (funcall outline-level))
14335 (org-back-to-heading t) 14439 (if (equal start-level 1)
14336 (setq start-level (funcall outline-level)) 14440 nil
14337 (if (equal start-level 1) (throw 'exit nil)) 14441 (setq re (concat "^\\*\\{1," (number-to-string (1- start-level)) "\\} "))
14338 (while (re-search-backward re nil t) 14442 (if (re-search-backward re nil t)
14339 (setq level (funcall outline-level)) 14443 (funcall outline-level)))))
14340 (if (< level start-level) (throw 'exit level)))
14341 nil)))
14342 14444
14343(defun org-first-sibling-p () 14445(defun org-first-sibling-p ()
14344 "Is this heading the first child of its parents?" 14446 "Is this heading the first child of its parents?"