• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.9.5/emacs-92/emacs/lisp/textmodes/

Lines Matching +defs:org +defs:export +defs:icalendar +defs:all +defs:agenda +defs:files

0 ;;;; org.el --- Outline-based notes management and organize
7 ;; Homepage: http://www.astro.uva.nl/~dominik/Tools/org/
33 ;; Org-mode develops organizational tasks around NOTES files that contain
36 ;; large files well structured. Visibility cycling and structure editing
39 ;; and scheduling. It dynamically compiles entries into an agenda that
42 ;; messages, BBDB entries, and any files related to the projects. For
44 ;; structured ASCII file, as HTML, or (todo and agenda items only) as an
52 ;; http://staff.science.uva.nl/~dominik/Tools/org/org.html#Installation
63 ;; http://www.astro.uva.nl/~dominik/Tools/org/Changes
86 (defvar org-version "4.67c"
87 "The version number of the file org.el.")
88 (defun org-version ()
90 (message "Org-mode version %s" org-version))
93 (defconst org-xemacs-p (featurep 'xemacs)) ; not used by org.el itself
94 (defconst org-format-transports-properties-p
102 (defgroup org nil
109 (defgroup org-startup nil
112 :group 'org)
114 (defcustom org-startup-folded t
122 :group 'org-startup
124 (const :tag "nofold: show all" nil)
126 (const :tag "content: all headlines" content)))
128 (defcustom org-startup-truncated t
132 :group 'org-startup
135 (defcustom org-startup-align-all-tables nil
136 "Non-nil means, align all tables when visiting a file.
143 :group 'org-startup
146 (defcustom org-insert-mode-line-in-empty-file nil
147 "Non-nil means insert the first line setting Org-mode in empty files.
148 When the function `org-mode' is called interactively in an empty file, this
153 :group 'org-startup
156 (defcustom org-CUA-compatible nil
162 keys both in Org-mode and in the Org-agenda buffer.
171 `org-disputed-keys'.
174 *before* org.el is loaded. Changing it requires a restart of Emacs to
176 :group 'org-startup
179 (defvar org-disputed-keys
187 second element will be used when `org-CUA-compatible' is t.")
189 (defun org-key (key)
190 "Select a key according to `org-CUA-compatible'."
191 (nth (if org-CUA-compatible 2 1)
192 (or (assq key org-disputed-keys)
193 (error "Invalid Key %s in `org-key'" key))))
195 (defcustom org-ellipsis nil
199 Changing this requires executing `M-x org-mode' in a buffer to become
201 :group 'org-startup
205 (defvar org-display-table nil
206 "The display table for org-mode, in case `org-ellipsis' is non-nil.")
208 (defgroup org-keywords nil
211 :group 'org)
213 (defcustom org-deadline-string "DEADLINE:"
217 a timestamp with \\[org-deadline].
219 :group 'org-keywords
222 (defcustom org-scheduled-string "SCHEDULED:"
226 a timestamp with \\[org-schedule].
228 :group 'org-keywords
231 (defcustom org-closed-string "CLOSED:"
233 :group 'org-keywords
236 (defcustom org-clock-string "CLOCK:"
238 :group 'org-keywords
241 (defcustom org-comment-string "COMMENT"
244 \\[org-toggle-comment].
246 :group 'org-keywords
249 (defcustom org-quote-string "QUOTE"
254 \\[org-toggle-fixed-width-section]."
255 :group 'org-keywords
258 (defvar org-repeat-re "\\<REPEAT(\\([-+ 0-9dwmy]+\\))"
262 (defgroup org-structure nil
263 "Options concerning the general structure of Org-mode files."
265 :group 'org)
267 (defgroup org-reveal-location nil
270 :group 'org-structure)
272 (defcustom org-show-hierarchy-above '((default . t))
274 Org-mode often shows locations in an org-mode file which might have
280 agenda when exposing an entry from the agenda
281 org-goto when using the command `org-goto' on key C-c C-j
282 occur-tree when using the command `org-occur' on key C-c /
288 default default for all contexts not set explicitly"
289 :group 'org-reveal-location
296 (const agenda)
297 (const org-goto)
307 (defcustom org-show-following-heading '((default . t))
309 Org-mode often shows locations in an org-mode file which might have
314 use the command \\[org-reveal] to show more context.
316 contexts. See `org-show-hierarchy-above' for valid contexts."
317 :group 'org-reveal-location
324 (const agenda)
325 (const org-goto)
335 (defcustom org-show-siblings '((default . nil) (isearch t))
336 "Non-nil means, show all sibling heading when revealing a location.
337 Org-mode often shows locations in an org-mode file which might have
339 heading are all made visible. If `org-show-hierarchy-above' is t,
342 By default this is on for the isearch context, off for all other contexts.
345 use the command \\[org-reveal] to show more context.
347 contexts. See `org-show-hierarchy-above' for valid contexts."
348 :group 'org-reveal-location
355 (const agenda)
356 (const org-goto)
366 (defgroup org-cycle nil
369 :group 'org-structure)
371 (defcustom org-cycle-global-at-bob t
376 this way, `org-cycle-hook' is disables temporarily, to make sure the
380 :group 'org-cycle
383 (defcustom org-cycle-emulate-tab t
384 "Where should `org-cycle' emulate TAB.
391 :group 'org-cycle
398 (defcustom org-cycle-hook '(org-cycle-hide-archived-subtrees
399 org-optimize-window-after-visibility-change)
400 "Hook that is run after `org-cycle' has changed the buffer visibility.
402 the new state that was set by the most recent `org-cycle' command. The
404 `overview', `content', or `all'. After a local state change, it can have
406 :group 'org-cycle
410 (defgroup org-edit-structure nil
413 :group 'org-structure)
415 (defcustom org-odd-levels-only nil
427 :group 'org-edit-structure
428 :group 'org-font-lock
431 (defcustom org-adapt-indentation t
436 body starts at column 0, indentation is not changed at all."
437 :group 'org-edit-structure
440 (defcustom org-blank-before-new-entry '((heading . nil)
442 "Should `org-insert-heading' leave a blank line before new heading/item?
445 :group 'org-edit-structure
450 (defcustom org-insert-heading-hook nil
452 :group 'org-edit-structure
455 (defcustom org-enable-fixed-width-editor t
460 :group 'org-edit-structure
463 (defgroup org-sparse-trees nil
466 :group 'org-structure)
468 (defcustom org-highlight-sparse-tree-matches t
469 "Non-nil means, highlight all matches that define a sparse tree.
472 :group 'org-sparse-trees
475 (defcustom org-remove-highlights-with-change t
477 Such highlights are created by `org-occur' and `org-clock-display'.
479 The highlights created by `org-preview-latex-fragment' always need
481 :group 'org-sparse-trees
482 :group 'org-time
486 (defcustom org-occur-hook '(org-first-headline-recenter)
487 "Hook that is run after `org-occur' has constructed a sparse tree.
490 :group 'org-sparse-trees
493 (defgroup org-plain-lists nil
496 :group 'org-structure)
498 (defcustom org-cycle-include-plain-lists nil
502 indentation of the bullet. In all other operations, plain list items are
505 :group 'org-plain-lists
508 (defcustom org-plain-list-ordered-item-terminator t
514 :group 'org-plain-lists
519 (defcustom org-auto-renumber-ordered-lists t
522 \\[org-shiftmetaup] or \\[org-shiftmetadown]. After other editing commands,
523 use \\[org-ctrl-c-ctrl-c] to trigger renumbering."
524 :group 'org-plain-lists
527 (defcustom org-provide-checkbox-statistics t
530 a new checkbox with \\[org-insert-todo-heading] or toggle a checkbox
531 with \\[org-ctrl-c-ctrl-c\\]."
532 :group 'org-plain-lists
535 (defgroup org-archive nil
538 :group 'org-structure)
540 (defcustom org-archive-tag "ARCHIVE"
543 not contribute to the agenda listings."
544 :group 'org-archive
545 :group 'org-keywords
548 (defcustom org-agenda-skip-archived-trees t
549 "Non-nil means, the agenda will skip any items located in archived trees.
551 :group 'org-archive
552 :group 'org-agenda-skip
555 (defcustom org-cycle-open-archived-trees nil
556 "Non-nil means, `org-cycle' will open archived trees.
559 normal outline commands like `show-all', but not with the cycling commands."
560 :group 'org-archive
561 :group 'org-cycle
564 (defcustom org-sparse-tree-open-archived-trees nil
568 :group 'org-archive
569 :group 'org-sparse-trees
572 (defcustom org-archive-location "%s_archive::"
587 If the current file is Projects.org, archive in file
594 \"~/org/archive.org::\"
595 Archive in file ~/org/archive.org (absolute path), as top-level trees.
605 :group 'org-archive
608 (defcustom org-archive-mark-done t
610 :group 'org-archive
613 (defcustom org-archive-stamp-time t
617 `org-archive-mark-done'."
618 :group 'org-archive
621 (defgroup org-table nil
624 :group 'org)
626 (defcustom org-enable-table-editor 'optimized
642 force one with \\[org-ctrl-c-ctrl-c].
650 See also the variable `org-table-auto-blank-field'."
651 :group 'org-table
657 (defcustom orgtbl-optimized (eq org-enable-table-editor 'optimized)
659 In the optimized version, the table editor takes over all simple keys that
666 Org-mode. See the variable `org-enable-table-editor' for details. Changing
668 :group 'org-table
693 :group 'org-table
698 (defgroup org-table-settings nil
701 :group 'org-table)
703 (defcustom org-table-default-size "5x2"
705 :group 'org-table-settings
708 (defcustom org-table-number-regexp
716 context. For example, all of the following will be considered a
721 :group 'org-table-settings
737 (defcustom org-table-number-fraction 0.5
739 In a column all non-white fields are considered. If at least this
740 fraction of fields is matched by `org-table-number-fraction',
742 :group 'org-table-settings
745 (defgroup org-table-editing nil
748 :group 'org-table)
750 (defcustom org-table-automatic-realign t
752 When nil, aligning is only done with \\[org-table-align], or after column
754 :group 'org-table-editing
757 (defcustom org-table-auto-blank-field t
761 Only relevant when `org-enable-table-editor' is equal to `optimized'."
762 :group 'org-table-editing
765 (defcustom org-table-tab-jumps-over-hlines t
768 `org-table-next-field' can either create a new row before that line, or jump
771 :group 'org-table-editing
774 (defcustom org-table-tab-recognizes-table.el t
778 :group 'org-table-editing
781 (defgroup org-table-calculation nil
784 :group 'org-table)
786 (defcustom org-table-copy-increment t
787 "Non-nil means, increment when copying current field with \\[org-table-copy-down]."
788 :group 'org-table-calculation
791 (defcustom org-calc-default-modes
804 :group 'org-table-calculation
807 (defcustom org-table-formula-evaluate-inline t
811 string of the command `org-table-eval-formula'. This feature requires the
814 the command \\[org-table-eval-formula]."
815 :group 'org-table-calculation
818 ;; FIXME this is also a variable that makes Org-mode files non-portable
821 (defcustom org-table-formula-use-constants t
824 by the value given in `org-table-formula-constants', or by a value obtained
826 :group 'org-table-calculation
829 (defcustom org-table-formula-constants nil
835 (setq org-table-formula-constants '((\"c\" . \"299792458.\")))
838 :group 'org-table-calculation
843 (defcustom org-table-allow-automatic-line-recalculation t
846 :group 'org-table-calculation
849 (defgroup org-link nil
852 :group 'org)
854 (defvar org-link-abbrev-alist-local nil
855 "buffer-local version of `org-link-abbrev-alist', which see.
857 (make-variable-buffer-local 'org-link-abbrev-alist-local)
859 (defcustom org-link-abbrev-alist nil
871 :group 'org-link
874 (defcustom org-descriptive-links t
877 state in new org-mode buffers. The setting can then be toggled on a
879 :group 'org-link
882 (defcustom org-link-file-path-type 'adaptive
890 adaptive Use relative path for files in the current directory and sub-
891 directories of it. For other files, use an absolute path."
892 :group 'org-link
899 (defcustom org-activate-links '(bracket angle plain radio tag date)
900 "Types of links that should be activated in Org-mode files.
914 :group 'org-link
922 (defgroup org-link-store nil
925 :group 'org-link)
927 (defcustom org-email-link-description-format "Email %c: %.30s"
936 will be \"to NAME\". See also the variable `org-from-is-user-regexp'.
944 :group 'org-link-store
947 (defcustom org-from-is-user-regexp
956 :group 'org-link-store
959 (defcustom org-context-in-file-links t
960 "Non-nil means, file links from `org-store-link' contain context.
963 `org-open-at-point'.
964 Using a prefix arg to the command \\[org-store-link] (`org-store-link')
966 :group 'org-link-store
969 (defcustom org-keep-stored-link-after-insertion nil
972 The command `org-store-link' adds a link pointing to the current
974 The command `org-insert-link' can be used to insert links into any
975 Org-mode file (offering completion for all stored links). When this
976 option is nil, every link which has been inserted once using \\[org-insert-link]
979 :group 'org-link-store
982 (defcustom org-usenet-links-prefer-google nil
983 "Non-nil means, `org-store-link' will create web links to Google groups.
985 Using a prefix arg to the command \\[org-store-link] (`org-store-link')
987 :group 'org-link-store
990 (defgroup org-link-follow nil
993 :group 'org-link)
995 (defcustom org-tab-follows-link nil
997 Needs to be set before org.el is loaded."
998 :group 'org-link-follow
1001 (defcustom org-return-follows-link nil
1003 Needs to be set before org.el is loaded."
1004 :group 'org-link-follow
1007 (defcustom org-mouse-1-follows-link t
1010 Needs to be set before org.el is loaded."
1011 :group 'org-link-follow
1014 (defcustom org-mark-ring-length 4
1017 :group 'org-link-follow
1020 (defcustom org-link-frame-setup
1041 :group 'org-link-follow
1058 (defcustom org-display-internal-link-with-indirect-buffer nil
1066 :group 'org-link-follow
1069 (defcustom org-open-non-existing-files nil
1070 "Non-nil means, `org-open-file' will open non-existing files.
1072 :group 'org-link-follow
1075 (defcustom org-link-mailto-program '(browse-url "mailto:%a?subject=%s")
1080 if one was given like in <mailto:arthur@galaxy.org::this subject>."
1081 :group 'org-link-follow
1088 (defcustom org-confirm-shell-link-function 'yes-or-no-p
1099 :group 'org-link-follow
1105 (defcustom org-confirm-elisp-link-function 'yes-or-no-p
1116 :group 'org-link-follow
1122 (defconst org-file-apps-defaults-gnu
1126 See `org-file-apps'.")
1128 (defconst org-file-apps-defaults-macosx
1139 for some files for which the OS does not have a good default.
1140 See `org-file-apps'.")
1142 (defconst org-file-apps-defaults-windowsnt
1151 The system \"open\" is used for most files.
1152 See `org-file-apps'.")
1154 (defcustom org-file-apps
1159 ("org" . emacs)
1167 files and the cdr the corresponding command. Possible values for the
1172 Remote files most likely should be visited through Emacs
1174 t Default for all remaining files
1184 `org-file-apps-defaults-macosx'
1185 `org-file-apps-defaults-windowsnt'
1186 `org-file-apps-defaults-gnu'."
1187 :group 'org-link-follow
1191 (const :tag "Default for unrecognized files" t)
1200 (defcustom org-mhe-search-all-folders nil
1202 all folders if the message cannot be found in the folder given in the link.
1203 Searching all folders is very efficient with one of the search engines
1205 :group 'org-link-follow
1208 (defgroup org-remember nil
1211 :group 'org)
1213 (defcustom org-directory "~/org"
1214 "Directory with org files.
1215 This directory will be used as default to prompt for org files.
1217 :group 'org-remember
1220 (defcustom org-default-notes-file "~/.notes"
1225 `org-remember-templates'."
1226 :group 'org-remember
1231 (defcustom org-remember-default-headline ""
1235 `org-remember-templates'."
1236 :group 'org-remember
1239 (defcustom org-remember-templates nil
1246 The default file is given by `org-default-notes-file'. An optional third
1249 given in the variable `org-remember-default-headline'.
1252 a first line starting with a star, to act as the org-mode headline.
1262 %a annotation, normally the link created with org-store-link
1282 gnus | %:group, for messages also all email fields
1286 :group 'org-remember
1287 :get (lambda (var) ; Make sure all entries have 4 elements
1301 (defcustom org-reverse-note-order nil
1304 :group 'org-remember
1311 (defgroup org-todo nil
1314 :group 'org)
1316 (defgroup org-progress nil
1319 :group 'org-time)
1321 (defcustom org-todo-keywords '("TODO" "DONE")
1323 \\<org-mode-map>By default, this is '(\"TODO\" \"DONE\"). The last entry in the list is
1327 The command \\[org-todo] cycles an entry through these states, and an
1329 cycling, see also the variable `org-todo-interpretation'
1331 :group 'org-todo
1332 :group 'org-keywords
1335 (defcustom org-todo-interpretation 'sequence
1337 This variable is only relevant if `org-todo-keywords' contains more than two
1338 states. \\<org-mode-map>Possible values are `sequence' and `type'.
1340 When `sequence', \\[org-todo] will always switch to the next state in the
1341 `org-todo-keywords' list. When `type', \\[org-todo] only cycles from state
1345 :group 'org-todo
1346 :group 'org-keywords
1350 (defcustom org-after-todo-state-change-hook nil
1354 :group 'org-todo
1357 (defcustom org-log-done nil
1369 interpreted as sequence, see variable `org-todo-interpretation'.
1376 `org-log-note-headings'.
1386 :group 'org-todo
1387 :group 'org-progress
1396 (defcustom org-log-note-headings
1408 :group 'org-todo
1409 :group 'org-progress
1417 (defcustom org-allow-auto-repeat t
1422 :group 'org-todo
1423 :group 'org-progress
1426 (defgroup org-priorities nil
1429 :group 'org-todo)
1431 (defcustom org-default-priority ?B
1434 :group 'org-priorities
1437 (defcustom org-lowest-priority ?C
1439 :group 'org-priorities
1442 (defgroup org-time nil
1445 :group 'org)
1447 (defcustom org-insert-labeled-timestamps-at-point nil
1452 :group 'org-time
1455 (defconst org-time-stamp-formats '("<%Y-%m-%d %a>" . "<%Y-%m-%d %a %H:%M>")
1459 (defcustom org-time-stamp-rounding-minutes 0
1465 :group 'org-time
1468 (defcustom org-display-custom-times nil
1469 "Non-nil means, overlay custom formats over all time stamps.
1470 The formats are defined through the variable `org-time-stamp-custom-formats'.
1473 :group 'org-time
1476 (make-variable-buffer-local 'org-display-custom-times)
1478 (defcustom org-time-stamp-custom-formats
1482 `org-display-custom-times' is set."
1483 :group 'org-time
1486 (defun org-time-stamp-format (&optional long inactive)
1488 (let ((f (if long (cdr org-time-stamp-formats)
1489 (car org-time-stamp-formats))))
1494 (defcustom org-deadline-warning-days 30
1496 This variable governs the display in sparse trees and in the agenda."
1497 :group 'org-time
1500 (defcustom org-popup-calendar-for-date-prompt t
1505 :group 'org-time
1508 (defcustom org-calendar-follow-timestamp-change t
1512 :group 'org-time
1515 (defgroup org-tags nil
1518 :group 'org)
1520 (defcustom org-tag-alist nil
1521 "List of tags allowed in Org-mode files.
1527 :group 'org-tags
1535 (defcustom org-use-fast-tag-selection 'auto
1541 `org-tag-alist' or through a #+TAGS line in the buffer.
1544 :group 'org-tags
1550 (defcustom org-fast-tag-selection-single-key nil
1556 :group 'org-tags
1562 (defcustom org-tags-column 48
1567 :group 'org-tags
1570 (defcustom org-auto-align-tags t
1574 the tags are again aligned to `org-tags-column'."
1575 :group 'org-tags
1578 (defcustom org-use-tag-inheritance t
1582 companion option `org-tags-match-list-sublevels'."
1583 :group 'org-tags
1586 (defcustom org-tags-match-list-sublevels nil
1588 Because of tag inheritance (see variable `org-use-tag-inheritance'),
1590 the same search. Listing all of them can create very long lists.
1597 make sure all corresponding TODO items find their way into the list."
1598 :group 'org-tags
1601 (defvar org-tags-history nil
1603 (defvar org-last-tags-completion-table nil
1606 (defgroup org-agenda nil
1607 "Options concerning agenda views in Org-mode."
1609 :group 'org)
1611 (defvar org-category nil
1612 "Variable used by org files to set a category for agenda display.
1613 Such files should use a file variable to set it, for example
1615 -*- mode: org; org-category: \"ELisp\"
1623 (make-variable-buffer-local 'org-category)
1625 (defcustom org-agenda-files nil
1626 "The files to be used for agenda display.
1627 Entries may be added to this list with \\[org-agenda-file-to-front] and removed with
1628 \\[org-remove-file]. You can also use customize to edit the list.
1631 the list of agenda files is actually stored and maintained in that file, one
1632 agenda file per line."
1633 :group 'org-agenda
1635 (repeat :tag "List of files" file)
1639 (defcustom org-agenda-confirm-kill 1
1640 "When set, remote killing from the agenda buffer needs confirmation.
1643 :group 'org-agenda
1649 (defcustom org-calendar-to-agenda-key [?c]
1650 "The key to be installed in `calendar-mode-map' for switching to the agenda.
1651 The command `org-calendar-goto-agenda' will be bound to this key. The
1653 forth between agenda and calendar."
1654 :group 'org-agenda
1657 (defgroup org-agenda-custom-commands nil
1658 "Options concerning agenda views in Org-mode."
1660 :group 'org-agenda)
1662 (defcustom org-agenda-custom-commands '(("w" todo "WAITING"))
1663 "Custom commands for the agenda.
1665 agenda dispatcher \\[org-agenda]. Each entry is a list like this:
1671 todo Entries with a specific TODO keyword, in all agenda files.
1672 tags Tags match in all agenda files.
1673 tags-todo Tags match in all agenda files, TODO entries only.
1675 tags-tree Sparse tree with all tags matches in *current* file.
1684 You can also define a set of commands, to create a composite agenda buffer.
1692 cmd An agenda command, similar to the above. However, tree commands
1693 are no allowed, but instead you can get agenda and global todo list.
1695 (agenda)
1705 :group 'org-agenda-custom-commands
1711 (const :tag "Tags search (all agenda files)" tags)
1712 (const :tag "Tags search of TODO entries (all agenda files)" tags-todo)
1713 (const :tag "TODO keyword search (all agenda files)" todo)
1721 (list :tag "Command series, all agenda files"
1726 (const :tag "Agenda" (agenda))
1761 (defcustom org-stuck-projects
1774 After defining this variable, you may use \\[org-agenda-list-stuck-projects]
1776 :group 'org-agenda-custom-commands
1783 (defgroup org-agenda-skip nil
1784 "Options concerning skipping parts of agenda files."
1786 :group 'org-agenda)
1788 (defcustom org-agenda-todo-list-sublevels t
1792 :group 'org-agenda-skip
1793 :group 'org-todo
1796 (defcustom org-agenda-todo-ignore-scheduled nil
1800 :group 'org-agenda-skip
1801 :group 'org-todo
1804 (defcustom org-agenda-todo-ignore-deadlines nil
1806 Near means closer than `org-deadline-warning-days' days.
1807 The idea behind this is that such items will appear in the agenda anyway."
1808 :group 'org-agenda-skip
1809 :group 'org-todo
1812 (defcustom org-agenda-skip-scheduled-if-done nil
1813 "Non-nil means don't show scheduled items in agenda when they are done.
1814 This is relevant for the daily/weekly agenda, not for the TODO list."
1815 :group 'org-agenda-skip
1818 (defcustom org-timeline-show-empty-dates 3
1819 "Non-nil means, `org-timeline' also shows dates without an entry.
1821 When t, all days between the first and the last date are shown.
1824 :group 'org-agenda-skip
1831 (defgroup org-agenda-startup nil
1834 :group 'org-agenda)
1836 (defcustom org-finalize-agenda-hook nil
1837 "Hook run just before displaying an agenda buffer."
1838 :group 'org-agenda-startup
1841 (defcustom org-agenda-mouse-1-follows-link nil
1842 "Non-nil means, mouse-1 on a link will follow the link in the agenda.
1844 Needs to be set before org.el is loaded."
1845 :group 'org-agenda-startup
1848 (defcustom org-agenda-start-with-follow-mode nil
1849 "The initial value of follwo-mode in a newly created agenda window."
1850 :group 'org-agenda-startup
1853 (defgroup org-agenda-windows nil
1856 :group 'org-agenda)
1858 (defcustom org-agenda-window-setup 'reorganize-frame
1859 "How the agenda buffer should be displayed.
1862 current-window Show agenda in the current window, keeping all other windows.
1863 other-frame Use `switch-to-buffer-other-frame' to display agenda.
1864 other-window Use `switch-to-buffer-other-window' to display agenda.
1866 window and the agenda.
1867 See also the variable `org-agenda-restore-windows-after-quit'."
1868 :group 'org-agenda-windows
1875 (defcustom org-agenda-restore-windows-after-quit nil
1876 "Non-nil means, restore window configuration open exiting agenda.
1877 Before the window configuration is changed for displaying the agenda,
1878 the current status is recorded. When the agenda is exited with
1880 `org-agenda-window-setup' is `other-frame', the value of this
1882 :group 'org-agenda-windows
1885 (defcustom org-indirect-buffer-display 'other-window
1888 \\[org-tree-to-indirect-buffer] and \\[org-agenda-tree-to-indirect-buffer].
1894 :group 'org-structure
1895 :group 'org-agenda-windows
1902 (defgroup org-agenda-daily/weekly nil
1903 "Options concerning the daily/weekly agenda."
1905 :group 'org-agenda)
1907 (defcustom org-agenda-ndays 7
1910 :group 'org-agenda-daily/weekly
1913 (defcustom org-agenda-start-on-weekday 1
1917 :group 'org-agenda-daily/weekly
1921 (defcustom org-agenda-show-all-dates t
1922 "Non-nil means, `org-agenda' shows every day in the selected range.
1924 :group 'org-agenda-daily/weekly
1927 (defcustom org-agenda-date-format "%A %d %B %Y"
1928 "Format string for displaying dates in the agenda.
1929 Used by the daily/weekly agenda and by the timeline. This should be
1932 :group 'org-agenda-daily/weekly
1935 (defcustom org-agenda-include-diary nil
1936 "If non-nil, include in the agenda entries from the Emacs Calendar's diary."
1937 :group 'org-agenda-daily/weekly
1940 (defcustom org-agenda-include-all-todo nil
1941 "Set means weekly/daily agenda will always contain all TODO entries.
1942 The TODO entries will be listed at the top of the agenda, before
1944 :group 'org-agenda-daily/weekly
1947 (defgroup org-agenda-time-grid nil
1950 :group 'org-agenda)
1952 (defcustom org-agenda-use-time-grid t
1953 "Non-nil means, show a time grid in the agenda schedule.
1958 the variable `org-agenda-time-grid'."
1959 :group 'org-agenda-time-grid
1962 (defcustom org-agenda-time-grid
1967 "The settings for time grid for agenda display.
1971 daily if the agenda shows a single day
1972 weekly if the agenda shows an entire week
1980 :group 'org-agenda-time-grid
1984 (const :tag "Show grid in single day agenda display" daily)
1985 (const :tag "Show grid in weekly agenda display" weekly)
1994 (defgroup org-agenda-sorting nil
1997 :group 'org-agenda)
2006 (defcustom org-agenda-sorting-strategy
2007 '((agenda time-up category-keep priority-down)
2010 "Sorting structure for the agenda items of a single day.
2018 sequence in `org-agenda-files'.
2029 means: Pull out all entries having a specified time of day and sort them,
2031 agenda listing for the day. Of the entries without a time indication, keep
2033 the sequence given in `org-agenda-files'. Within each category sort by
2038 :group 'org-agenda-sorting
2042 (cons (const :tag "Strategy for Weekly/Daily agenda" agenda)
2049 (defcustom org-sort-agenda-notime-is-late t
2055 agenda entries."
2056 :group 'org-agenda-sorting
2059 (defgroup org-agenda-prefix nil
2060 "Options concerning the entry prefix in the Org-mode agenda display."
2062 :group 'org-agenda)
2064 (defcustom org-agenda-prefix-format
2065 '((agenda . " %-12:c%?-12t% s")
2069 "Format specifications for the prefix of items in the agenda views.
2070 An alist with four entries, for the different agenda types. The keys to the
2071 sublists are `agenda', `timeline', `todo', and `tags'. The values
2113 (setq org-agenda-prefix-format \" %-11:c% s\")
2115 See also the variables `org-agenda-remove-times-when-in-prefix' and
2116 `org-agenda-remove-tags-when-in-prefix'."
2120 (cons (const agenda) (string :tag "Format"))
2124 :group 'org-agenda-prefix)
2126 (defvar org-prefix-format-compiled nil
2128 See the variable `org-agenda-prefix-format'.")
2130 (defcustom org-agenda-remove-times-when-in-prefix t
2131 "Non-nil means, remove duplicate time specifications in agenda items.
2132 When the format `org-agenda-prefix-format' contains a `%t' specifier, a
2136 11:30-4pm) will be removed for agenda display. This makes the agenda less
2141 :group 'org-agenda-prefix
2147 (defcustom org-agenda-remove-tags-when-in-prefix nil
2148 "Non-nil means, remove the tags from the headline copy in the agenda.
2150 `org-agenda-prefix-format' contains a `%T' specifier."
2151 :group 'org-agenda-prefix
2157 (defcustom org-agenda-align-tags-to-column 65
2158 "Shift tags in agenda items to this column."
2159 :group 'org-agenda-prefix
2162 (defgroup org-latex nil
2165 :group 'org)
2167 (defcustom org-format-latex-options
2182 :group 'org-latex
2185 (defgroup org-export nil
2186 "Options for exporting org-listings."
2188 :group 'org)
2190 (defgroup org-export-general nil
2191 "General options for exporting Org-mode files."
2193 :group 'org-export)
2195 (defcustom org-export-publishing-directory "."
2196 "Path to the location where exported files should be located.
2199 The variable may also be an alist with export types `:html', `:ascii',
2202 Org-mode files lives."
2203 :group 'org-export-general
2212 (defcustom org-export-language-setup
2223 "Terms used in export text, translated to different languages.
2224 Use the variable `org-export-default-language' to set the language,
2226 :group 'org-export-general
2234 (defcustom org-export-default-language "en"
2235 "The default language of HTML export, as a string.
2236 This should have an association in `org-export-language-setup'."
2237 :group 'org-export-general
2240 (defcustom org-export-headline-levels 3
2247 :group 'org-export-general
2250 (defcustom org-export-with-section-numbers t
2254 :group 'org-export-general
2257 (defcustom org-export-with-toc t
2258 "Non-nil means, create a table of contents in exported files.
2259 The TOC contains headlines with levels up to`org-export-headline-levels'.
2261 different from `org-export-headline-levels', but it will not be allowed
2266 ASCII export, and with red color in HTML output, if the option
2267 `org-export-mark-todo-in-toc' is set.
2273 :group 'org-export-general
2279 (defcustom org-export-mark-todo-in-toc nil
2281 :group 'org-export-general
2284 (defcustom org-export-preserve-breaks nil
2285 "Non-nil means, preserve all line breaks when exporting.
2287 export, line breaks will always be preserved, regardless of this variable.
2290 :group 'org-export-general
2293 (defcustom org-export-with-archived-trees 'headline
2296 nil Do not export, pretend this tree is not present
2297 t Do export the entire tree
2298 headline Only export the headline, but skip the tree below it."
2299 :group 'org-export-general
2300 :group 'org-archive
2302 (const :tag "not at all" nil)
2306 (defcustom org-export-with-timestamps t
2307 "If nil, do not export time stamps and associated keywords."
2308 :group 'org-export-general
2311 (defcustom org-export-remove-timestamps-from-toc t
2313 :group 'org-export-general
2316 (defcustom org-export-with-tags 'not-in-toc
2317 "If nil, do not export tags, just remove them from headlines.
2320 :group 'org-export-general
2326 (defgroup org-export-translation nil
2327 "Options for translating special ascii sequences for the export backends."
2329 :group 'org-export)
2331 (defcustom org-export-with-emphasize t
2333 If the export target supports emphasizing text, the word will be
2336 Not all export backends support this.
2339 :group 'org-export-translation
2342 (defcustom org-export-with-sub-superscripts t
2343 "Non-nil means, interpret \"_\" and \"^\" for export.
2358 Not all export backends support this, but HTML does.
2361 :group 'org-export-translation
2364 (defcustom org-export-with-TeX-macros t
2366 For example, HTML export converts \\alpha to &alpha; and \\AA to &Aring;.
2369 names in HTML export, see the constant `org-html-entities'.
2370 Not all export backends support this.
2373 :group 'org-export-translation
2374 :group 'org-latex
2377 (defcustom org-export-with-LaTeX-fragments nil
2385 :group 'org-export-translation
2386 :group 'org-latex
2389 (defcustom org-export-with-fixed-width t
2397 Not all export backends support this.
2400 :group 'org-export-translation
2403 (defcustom org-match-sexp-depth 3
2405 This has to be set before loading org.el to be effective."
2406 :group 'org-export-translation
2409 (defgroup org-export-tables nil
2412 :group 'org-export)
2414 (defcustom org-export-with-tables t
2422 Not all export backends support this.
2425 :group 'org-export-tables
2428 (defcustom org-export-highlight-first-table-line t
2430 In HTML export, this means use <th> instead of <td>.
2432 In Org-mode tables, all lines before the first horizontal separator
2434 :group 'org-export-tables
2437 (defcustom org-export-table-remove-special-lines t
2443 :group 'org-export-tables
2446 (defcustom org-export-prefer-native-exporter-for-tables nil
2447 "Non-nil means, always export tables created with table.el natively.
2454 :group 'org-export-tables
2457 (defgroup org-export-ascii nil
2458 "Options specific for ASCII export of Org-mode files."
2460 :group 'org-export)
2462 (defcustom org-export-ascii-underline '(?\$ ?\# ?^ ?\~ ?\= ?\-)
2463 "Characters for underlining headings in ASCII export.
2465 :group 'org-export-ascii
2468 (defcustom org-export-ascii-bullets '(?* ?+ ?-)
2469 "Bullet characters for headlines converted to lists in ASCII export.
2475 :group 'org-export-ascii
2478 (defgroup org-export-xml nil
2479 "Options specific for XML export of Org-mode files."
2481 :group 'org-export)
2483 (defgroup org-export-html nil
2484 "Options specific for HTML export of Org-mode files."
2486 :group 'org-export)
2488 (defcustom org-export-html-style
2513 "The default style specification for exported HTML files.
2534 :group 'org-export-html
2537 (defcustom org-export-html-title-format "<h1 class=\"title\">%s</h1>\n"
2538 "Format for typesetting the document title in HTML export."
2539 :group 'org-export-html
2542 (defcustom org-export-html-toplevel-hlevel 2
2543 "The <H> level for level 1 headings in HTML export."
2544 :group 'org-export-html
2547 (defcustom org-export-html-link-org-files-as-html t
2548 "Non-nil means, make file links to `file.org' point to `file.html'.
2549 When org-mode is exporting an org-mode file to HTML, links to
2550 non-html files are directly put into a href tag in HTML.
2551 However, links to other Org-mode files (recognized by the
2552 extension `.org.) should become links to the corresponding html
2553 file, assuming that the linked org-mode file will also be
2555 When nil, the links still point to the plain `.org' file."
2556 :group 'org-export-html
2559 (defcustom org-export-html-inline-images 'maybe
2565 :group 'org-export-html
2571 (defcustom org-export-html-expand t
2572 "Non-nil means, for HTML export, treat @<...> as HTML tag.
2577 :group 'org-export-html
2580 (defcustom org-export-html-table-tag
2585 :group 'org-export-html
2588 (defcustom org-export-html-with-timestamp nil
2589 "If non-nil, write `org-export-html-html-helper-timestamp'
2592 :group 'org-export-html
2595 (defcustom org-export-html-html-helper-timestamp
2598 :group 'org-export-html
2601 (defgroup org-export-icalendar nil
2602 "Options specific for iCalendar export of Org-mode files."
2604 :group 'org-export)
2606 (defcustom org-combined-agenda-icalendar-file "~/org.ics"
2607 "The file name for the iCalendar file covering all agenda files.
2608 This file is created with the command \\[org-export-icalendar-all-agenda-files].
2610 :group 'org-export-icalendar
2613 (defcustom org-icalendar-include-todo nil
2614 "Non-nil means, export to iCalendar files should also cover TODO items."
2615 :group 'org-export-icalendar
2619 (const :tag "All" all)))
2621 (defcustom org-icalendar-combined-name "OrgMode"
2622 "Calendar name for the combined iCalendar representing all agenda files."
2623 :group 'org-export-icalendar
2626 (defgroup org-font-lock nil
2629 :group 'org)
2631 (defcustom org-level-color-stars-only nil
2636 :group 'org-font-lock
2639 (defcustom org-hide-leading-stars nil
2641 This works by using the face `org-hide' for these stars. This
2643 background. You may have to customize the face `org-hide' to
2652 :group 'org-font-lock
2655 (defcustom org-fontify-done-headline nil
2659 `org-headline-done' as an additional indication."
2660 :group 'org-font-lock
2663 (defcustom org-fontify-emphasized-text t
2666 :group 'org-font-lock
2669 (defvar org-emph-re nil
2671 (defvar org-emphasis-regexp-components) ; defined just below
2672 (defvar org-emphasis-alist) ; defined just below
2673 (defun org-set-emph-re (var val)
2676 (when (and (boundp 'org-emphasis-alist)
2677 (boundp 'org-emphasis-regexp-components)
2678 org-emphasis-alist org-emphasis-regexp-components)
2679 (let* ((e org-emphasis-regexp-components)
2687 (markers (mapconcat 'car org-emphasis-alist "")))
2699 (setq org-emph-re
2711 (defcustom org-emphasis-regexp-components
2723 characters given here, all marker characters are forbidden too.
2728 export. When this is set, all marker characters (as given in
2729 `org-emphasis-alist') will be allowed as pre/post, aiding
2732 :group 'org-font-lock
2733 :set 'org-set-emph-re
2742 (defcustom org-emphasis-alist
2755 :group 'org-font-lock
2756 :set 'org-set-emph-re
2768 (defgroup org-faces nil
2771 :group 'org-font-lock)
2773 (defun org-compatible-face (specs)
2794 (defface org-hide
2800 :group 'org-faces)
2802 (defface org-level-1 ;; font-lock-function-name-face
2803 (org-compatible-face
2811 :group 'org-faces)
2813 (defface org-level-2 ;; font-lock-variable-name-face
2814 (org-compatible-face
2821 :group 'org-faces)
2823 (defface org-level-3 ;; font-lock-keyword-face
2824 (org-compatible-face
2833 :group 'org-faces)
2835 (defface org-level-4 ;; font-lock-comment-face
2836 (org-compatible-face
2845 :group 'org-faces)
2847 (defface org-level-5 ;; font-lock-type-face
2848 (org-compatible-face
2853 :group 'org-faces)
2855 (defface org-level-6 ;; font-lock-constant-face
2856 (org-compatible-face
2861 :group 'org-faces)
2863 (defface org-level-7 ;; font-lock-builtin-face
2864 (org-compatible-face
2869 :group 'org-faces)
2871 (defface org-level-8 ;; font-lock-string-face
2872 (org-compatible-face
2877 :group 'org-faces)
2879 (defface org-special-keyword ;; font-lock-string-face
2880 (org-compatible-face
2885 :group 'org-faces)
2887 (defface org-warning ;; font-lock-warning-face
2888 (org-compatible-face
2895 :group 'org-faces)
2897 (defface org-headline-done ;; font-lock-string-face
2898 (org-compatible-face
2903 This face is only used if `org-fontify-done-headline' is set."
2904 :group 'org-faces)
2906 (defface org-archived ; similar to shadow
2907 (org-compatible-face
2917 :group 'org-faces)
2919 (defface org-link
2924 :group 'org-faces)
2926 (defface org-date
2931 :group 'org-faces)
2933 (defface org-tag
2936 :group 'org-faces)
2938 (defface org-todo ;; font-lock-warning-face
2939 (org-compatible-face
2946 :group 'org-faces)
2948 (defface org-done ;; font-lock-type-face
2949 (org-compatible-face
2955 :group 'org-faces)
2957 (defface org-table ;; font-lock-function-name-face
2958 (org-compatible-face
2966 :group 'org-faces)
2968 (defface org-formula
2969 (org-compatible-face
2976 :group 'org-faces)
2978 (defface org-scheduled-today
2979 (org-compatible-face
2985 :group 'org-faces)
2987 (defface org-scheduled-previously
2988 (org-compatible-face
2995 :group 'org-faces)
2997 (defface org-upcoming-deadline
2998 (org-compatible-face
3005 :group 'org-faces)
3007 (defface org-time-grid ;; font-lock-variable-name-face
3008 (org-compatible-face
3013 :group 'org-faces)
3015 (defconst org-level-faces
3016 '(org-level-1 org-level-2 org-level-3 org-level-4
3017 org-level-5 org-level-6 org-level-7 org-level-8
3019 (defconst org-n-levels (length org-level-faces))
3022 ;;; Variables for pre-computed regular expressions, all buffer local
3024 (defvar org-done-string nil
3025 "The last string in `org-todo-keywords', indicating an item is DONE.")
3026 (make-variable-buffer-local 'org-done-string)
3027 (defvar org-todo-regexp nil
3029 (make-variable-buffer-local 'org-todo-regexp)
3030 (defvar org-not-done-regexp nil
3032 (make-variable-buffer-local 'org-not-done-regexp)
3033 (defvar org-todo-line-regexp nil
3035 (make-variable-buffer-local 'org-todo-line-regexp)
3036 (defvar org-todo-line-tags-regexp nil
3039 (make-variable-buffer-local 'org-todo-line-tags-regexp)
3040 (defvar org-nl-done-regexp nil
3042 (make-variable-buffer-local 'org-nl-done-regexp)
3043 (defvar org-looking-at-done-regexp nil
3045 (make-variable-buffer-local 'org-looking-at-done-regexp)
3046 (defvar org-todo-kwd-priority-p nil
3048 (make-variable-buffer-local 'org-todo-kwd-priority-p)
3049 (defvar org-todo-kwd-max-priority nil
3051 (make-variable-buffer-local 'org-todo-kwd-max-priority)
3052 (defvar org-ds-keyword-length 12
3054 (make-variable-buffer-local 'org-ds-keyword-length)
3055 (defvar org-deadline-regexp nil
3057 (make-variable-buffer-local 'org-deadline-regexp)
3058 (defvar org-deadline-time-regexp nil
3060 (make-variable-buffer-local 'org-deadline-time-regexp)
3061 (defvar org-deadline-line-regexp nil
3063 (make-variable-buffer-local 'org-deadline-line-regexp)
3064 (defvar org-scheduled-regexp nil
3066 (make-variable-buffer-local 'org-scheduled-regexp)
3067 (defvar org-scheduled-time-regexp nil
3069 (make-variable-buffer-local 'org-scheduled-time-regexp)
3070 (defvar org-closed-time-regexp nil
3072 (make-variable-buffer-local 'org-closed-time-regexp)
3074 (defvar org-keyword-time-regexp nil
3076 (make-variable-buffer-local 'org-keyword-time-regexp)
3077 (defvar org-keyword-time-not-clock-regexp nil
3079 (make-variable-buffer-local 'org-keyword-time-not-clock-regexp)
3080 (defvar org-maybe-keyword-time-regexp nil
3082 (make-variable-buffer-local 'org-maybe-keyword-time-regexp)
3084 (defconst org-rm-props '(invisible t face t keymap t intangible t mouse-face t
3088 (defsubst org-match-string-no-properties (num &optional string)
3091 (remove-text-properties 0 (length s) org-rm-props s)
3095 (defsubst org-no-properties (s)
3096 (remove-text-properties 0 (length s) org-rm-props s)
3099 (defsubst org-get-alist-option (option key)
3105 (defsubst org-set-local (var value)
3109 (defsubst org-mode-p ()
3111 (eq major-mode 'org-mode))
3113 (defsubst org-last (list)
3117 (defun org-let (list &rest body)
3119 (put 'org-let 'lisp-indent-function 1)
3121 (defun org-let2 (list1 list2 &rest body)
3123 (put 'org-let2 'lisp-indent-function 2)
3124 (defconst org-startup-options
3125 '(("fold" org-startup-folded t)
3126 ("overview" org-startup-folded t)
3127 ("nofold" org-startup-folded nil)
3128 ("showall" org-startup-folded nil)
3129 ("content" org-startup-folded content)
3130 ("hidestars" org-hide-leading-stars t)
3131 ("showstars" org-hide-leading-stars nil)
3132 ("odd" org-odd-levels-only t)
3133 ("oddeven" org-odd-levels-only nil)
3134 ("align" org-startup-align-all-tables t)
3135 ("noalign" org-startup-align-all-tables nil)
3136 ("customtime" org-display-custom-times t)
3137 ("logging" org-log-done t)
3138 ("logdone" org-log-done t)
3139 ("nologging" org-log-done nil)
3140 ("lognotedone" org-log-done done push)
3141 ("lognotestate" org-log-done state push)
3142 ("lognoteclock-out" org-log-done clock-out push))
3143 "Variable associated with STARTUP options for org-mode.
3149 (defun org-set-regexps-and-options ()
3151 (when (org-mode-p)
3152 (let ((re (org-make-options-regexp
3162 (setq key (match-string 1) value (org-match-string-no-properties 2))
3170 kwds (append kwds (org-split-string value splitre))))
3173 kwds (append kwds (org-split-string value splitre))))
3176 kwds (append kwds (org-split-string value splitre))))
3178 (setq tags (append tags (org-split-string value splitre))))
3182 (org-trim (match-string 2 value)))
3185 (let ((opts (org-split-string value splitre))
3187 (while (setq l (assoc (pop opts) org-startup-options))
3201 (and cat (org-set-local 'org-category cat))
3202 (and kwds (org-set-local 'org-todo-keywords kwds))
3203 (and arch (org-set-local 'org-archive-location arch))
3204 (and int (org-set-local 'org-todo-interpretation int))
3205 (and links (setq org-link-abbrev-alist-local (nreverse links)))
3217 (org-set-local 'org-tag-alist nil)
3220 (assoc (car e) org-tag-alist))
3221 (push e org-tag-alist))))))
3224 (setq org-todo-kwd-priority-p (equal org-todo-interpretation 'priority)
3225 org-todo-kwd-max-priority (1- (length org-todo-keywords))
3226 org-ds-keyword-length (+ 2 (max (length org-deadline-string)
3227 (length org-scheduled-string)))
3228 org-done-string
3229 (nth (1- (length org-todo-keywords)) org-todo-keywords)
3230 org-todo-regexp
3231 (concat "\\<\\(" (mapconcat 'regexp-quote org-todo-keywords
3233 org-not-done-regexp
3236 (nreverse (cdr (reverse org-todo-keywords)))
3239 org-todo-line-regexp
3241 (mapconcat 'regexp-quote org-todo-keywords "\\|")
3243 org-nl-done-regexp
3244 (concat "[\r\n]\\*+[ \t]+" org-done-string "\\>")
3245 org-todo-line-tags-regexp
3247 (mapconcat 'regexp-quote org-todo-keywords "\\|")
3249 org-looking-at-done-regexp (concat "^" org-done-string "\\>")
3250 org-deadline-regexp (concat "\\<" org-deadline-string)
3251 org-deadline-time-regexp
3252 (concat "\\<" org-deadline-string " *<\\([^>]+\\)>")
3253 org-deadline-line-regexp
3254 (concat "\\<\\(" org-deadline-string "\\).*")
3255 org-scheduled-regexp
3256 (concat "\\<" org-scheduled-string)
3257 org-scheduled-time-regexp
3258 (concat "\\<" org-scheduled-string " *<\\([^>]+\\)>")
3259 org-closed-time-regexp
3260 (concat "\\<" org-closed-string " *\\[\\([^]]+\\)\\]")
3261 org-keyword-time-regexp
3262 (concat "\\<\\(" org-scheduled-string
3263 "\\|" org-deadline-string
3264 "\\|" org-closed-string
3265 "\\|" org-clock-string "\\)"
3267 org-keyword-time-not-clock-regexp
3268 (concat "\\<\\(" org-scheduled-string
3269 "\\|" org-deadline-string
3270 "\\|" org-closed-string "\\)"
3272 org-maybe-keyword-time-regexp
3273 (concat "\\(\\<\\(" org-scheduled-string
3274 "\\|" org-deadline-string
3275 "\\|" org-closed-string
3276 "\\|" org-clock-string "\\)\\)?"
3279 (org-set-font-lock-defaults)))
3284 (defvar org-window-configuration nil
3286 (defvar org-finish-function nil
3300 ;; Packages that org-mode interacts with
3304 (defvar org-goto-start-pos)
3327 (defvar org-latex-regexps)
3342 (defvar org-agenda-undo-list)
3343 (defvar org-agenda-pending-undo-list)
3344 (defvar org-agenda-overriding-header)
3346 (defvar org-html-entities)
3347 (defvar org-struct-menu)
3348 (defvar org-org-menu)
3349 (defvar org-tbl-menu)
3350 (defvar org-agenda-keymap)
3351 (defvar org-category-table)
3356 (defun org-make-overlay (beg end &optional buffer)
3360 (defun org-delete-overlay (ovl)
3362 (defun org-detach-overlay (ovl)
3364 (defun org-move-overlay (ovl beg end &optional buffer)
3368 (defun org-overlay-put (ovl prop value)
3372 (defun org-overlay-display (ovl text &optional face evap)
3382 (defun org-overlay-before-string (ovl text &optional face evap)
3388 (if face (org-add-props text nil 'face face))
3391 (defun org-overlay-get (ovl prop)
3395 (defun org-overlays-at (pos)
3397 (defun org-overlays-in (&optional start end)
3401 (defun org-overlay-start (o)
3403 (defun org-overlay-end (o)
3405 (defun org-find-overlays (prop &optional pos delete)
3406 "Find all overlays specifying PROP at POS or point.
3407 If DELETE is non-nil, delete all those overlays."
3408 (let ((overlays (org-overlays-at (or pos (point))))
3411 (if (org-overlay-get ov prop)
3412 (if delete (org-delete-overlay ov) (push ov found))))
3417 (defun org-add-hook (hook function &optional append local)
3423 (defvar org-ignore-region nil
3426 (defun org-region-active-p ()
3429 (if org-ignore-region
3437 (defun org-add-to-invisibility-spec (arg)
3450 (defun org-remove-from-invisibility-spec (arg)
3458 (defun org-in-invisibility-spec-p (arg)
3467 (error "Conflict with outdated version of allout.el. Load org.el before allout.el, or ugrade to newer allout, for example by switching to Emacs 22."))
3472 (defvar org-table-may-need-update t
3474 This variable is set by `org-before-change-function'.
3475 `org-table-align' sets it back to nil.")
3476 (defvar org-mode-map)
3477 (defvar org-mode-hook nil)
3478 (defvar org-inhibit-startup nil) ; Dynamically-scoped param.
3479 (defvar org-agenda-keep-modes nil) ; Dynamically-scoped param.
3483 (define-derived-mode org-mode outline-mode "Org"
3490 of large files well structured. It supports ToDo items, deadlines and
3494 messages (Gnus), BBDB entries, and any files related to the project.
3500 \\{org-mode-map}"
3505 ;; we switch another buffer into org-mode.
3512 (define-key org-mode-map [menu-bar headings] 'undefined)
3513 (define-key org-mode-map [menu-bar hide] 'undefined)
3514 (define-key org-mode-map [menu-bar show] 'undefined))
3516 (easy-menu-add org-org-menu)
3517 (easy-menu-add org-tbl-menu)
3518 (org-install-agenda-files-menu)
3519 (if org-descriptive-links (org-add-to-invisibility-spec '(org-link)))
3520 (org-add-to-invisibility-spec '(org-cwidth))
3522 (org-set-local 'line-move-ignore-invisible t))
3525 (setq outline-level 'org-outline-level)
3526 (when (and org-ellipsis (stringp org-ellipsis)
3528 (unless org-display-table
3529 (setq org-display-table (make-display-table)))
3530 (set-display-table-slot org-display-table
3531 4 (string-to-vector org-ellipsis))
3532 (setq buffer-display-table org-display-table))
3533 (org-set-regexps-and-options)
3535 (org-set-local 'calc-embedded-open-mode "# ")
3537 (if org-startup-truncated (setq truncate-lines t))
3538 (org-set-local 'font-lock-unfontify-region-function
3539 'org-unfontify-region)
3541 (org-set-local 'org-table-may-need-update t)
3542 (org-add-hook 'before-change-functions 'org-before-change-function nil
3545 (org-add-hook 'kill-buffer-hook 'org-check-running-clock nil 'local)
3547 (org-set-autofill-regexps)
3548 (org-update-radio-target-regexp)
3551 ; (org-set-local 'comment-start "#") ;; FIXME: this breaks wrapping
3552 (org-set-local 'comment-padding " ")
3558 (org-add-hook 'isearch-mode-end-hook 'org-isearch-end 'append 'local)
3560 (org-set-local 'outline-isearch-open-invisible-function
3561 (lambda (&rest ignore) (org-show-context 'isearch))))
3563 ;; If empty file that did not turn on org-mode automatically, make it to.
3564 (if (and org-insert-mode-line-in-empty-file
3567 (insert " -*- mode: org -*-\n\n"))
3569 (unless org-inhibit-startup
3570 (when org-startup-align-all-tables
3572 (org-table-map-tables 'org-table-align)
3575 ((eq org-startup-folded t)
3576 (org-cycle '(4)))
3577 ((eq org-startup-folded 'content)
3578 (let ((this-command 'org-cycle) (last-command 'org-cycle))
3579 (org-cycle '(4)) (org-cycle '(4)))))))
3581 (defsubst org-call-with-arg (command arg)
3585 (defsubst org-current-line (&optional pos)
3590 (defun org-current-time ()
3591 "Current time, possibly rounded to `org-time-stamp-rounding-minutes'."
3592 (if (> org-time-stamp-rounding-minutes 0)
3593 (let ((r org-time-stamp-rounding-minutes)
3600 (defun org-add-props (string plist &rest props)
3607 (put 'org-add-props 'lisp-indent-function 2)
3612 (defvar org-mouse-map (make-sparse-keymap))
3613 (define-key org-mouse-map
3614 (if (featurep 'xemacs) [button2] [mouse-2]) 'org-open-at-mouse)
3615 (define-key org-mouse-map
3616 (if (featurep 'xemacs) [button3] [mouse-3]) 'org-find-file-at-mouse)
3617 (when org-mouse-1-follows-link
3618 (define-key org-mouse-map [follow-link] 'mouse-face))
3619 (when org-tab-follows-link
3620 (define-key org-mouse-map [(tab)] 'org-open-at-point)
3621 (define-key org-mouse-map "\C-i" 'org-open-at-point))
3622 (when org-return-follows-link
3623 (define-key org-mouse-map [(return)] 'org-open-at-point)
3624 (define-key org-mouse-map "\C-m" 'org-open-at-point))
3628 (defconst org-non-link-chars "]\t\n\r<>")
3629 (defconst org-link-types '("https?" "ftp" "mailto" "file" "news" "bbdb" "vm"
3631 (defconst org-link-re-with-space
3633 "<?\\(" (mapconcat 'identity org-link-types "\\|") "\\):"
3634 "\\([^" org-non-link-chars " ]"
3635 "[^" org-non-link-chars "]*"
3636 "[^" org-non-link-chars " ]\\)>?")
3639 (defconst org-link-re-with-space2
3641 "<?\\(" (mapconcat 'identity org-link-types "\\|") "\\):"
3642 "\\([^" org-non-link-chars " ]"
3644 "[^" org-non-link-chars " ]\\)>?")
3647 (defconst org-angle-link-re
3649 "<\\(" (mapconcat 'identity org-link-types "\\|") "\\):"
3650 "\\([^" org-non-link-chars " ]"
3651 "[^" org-non-link-chars "]*"
3654 (defconst org-plain-link-re
3656 "\\(" (mapconcat 'identity org-link-types "\\|") "\\):"
3660 (defconst org-bracket-link-regexp
3664 (defconst org-bracket-link-analytic-regexp
3667 "\\(\\(" (mapconcat 'identity org-link-types "\\|") "\\):\\)?"
3678 (defconst org-any-link-re
3679 (concat "\\(" org-bracket-link-regexp "\\)\\|\\("
3680 org-angle-link-re "\\)\\|\\("
3681 org-plain-link-re "\\)")
3684 (defconst org-ts-lengths
3685 (cons (length (format-time-string (car org-time-stamp-formats)))
3686 (length (format-time-string (cdr org-time-stamp-formats))))
3688 (defconst org-ts-regexp "<\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}[^\r\n>]*?\\)>"
3690 (defconst org-ts-regexp-both "[[<]\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}[^\r\n>]*?\\)[]>]"
3692 (defconst org-ts-regexp1 "\\(\\([0-9]\\{4\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\)\\([^]0-9>\r\n]*\\)\\(\\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\)\\)?\\)"
3694 (defconst org-ts-regexp2 (concat "<" org-ts-regexp1 ">")
3696 (defconst org-ts-regexp3 (concat "[[<]" org-ts-regexp1 "[]>]")
3698 (defconst org-tr-regexp (concat org-ts-regexp "--?-?" org-ts-regexp)
3700 (defconst org-tr-regexp-both
3701 (concat org-ts-regexp-both "--?-?" org-ts-regexp-both)
3703 (defconst org-tsr-regexp (concat org-ts-regexp "\\(--?-?"
3704 org-ts-regexp "\\)?")
3706 (defconst org-tsr-regexp-both (concat org-ts-regexp-both "\\(--?-?"
3707 org-ts-regexp-both "\\)?")
3711 (defvar org-emph-face nil)
3713 (defun org-do-emphasis-faces (limit)
3715 (if (re-search-forward org-emph-re limit t)
3720 org-emphasis-alist)))
3726 (defun org-activate-plain-links (limit)
3728 (if (re-search-forward org-plain-link-re limit t)
3733 'keymap org-mouse-map
3737 (defun org-activate-angle-links (limit)
3739 (if (re-search-forward org-angle-link-re limit t)
3744 'keymap org-mouse-map
3748 (defmacro org-maybe-intangible (props)
3760 (defun org-activate-bracket-links (limit)
3762 (if (re-search-forward org-bracket-link-regexp limit t)
3764 (org-match-string-no-properties 1)))
3768 (ip (org-maybe-intangible
3769 (list 'invisible 'org-link 'rear-nonsticky t
3770 'keymap org-mouse-map 'mouse-face 'highlight
3773 'keymap org-mouse-map 'mouse-face 'highlight
3789 (defun org-activate-dates (limit)
3791 (if (re-search-forward org-tsr-regexp-both limit t)
3796 'keymap org-mouse-map))
3797 (when org-display-custom-times
3799 (org-display-custom-time (match-beginning 3) (match-end 3)))
3800 (org-display-custom-time (match-beginning 1) (match-end 1)))
3803 (defvar org-target-link-regexp nil
3805 (defvar org-target-regexp "<<\\([^<>\n\r]+\\)>>"
3807 (defvar org-radio-target-regexp "<<<\\([^<>\n\r]+\\)>>>"
3810 (defun org-activate-target-links (limit)
3812 (when org-target-link-regexp
3814 (if (re-search-forward org-target-link-regexp limit t)
3819 'keymap org-mouse-map
3821 'org-linked-text t))
3824 (defun org-update-radio-target-regexp ()
3825 "Find all radio targets in this file and update the regular expression."
3827 (when (memq 'radio org-activate-links)
3828 (setq org-target-link-regexp
3829 (org-make-target-link-regexp (org-all-targets 'radio)))
3830 (org-restart-font-lock)))
3832 (defun org-hide-wide-columns (limit)
3835 'org-cwidth t))
3837 (setq e (next-single-property-change s 'org-cwidth))
3838 (add-text-properties s e (org-maybe-intangible '(invisible org-cwidth)))
3842 (defun org-restart-font-lock ()
3848 (defun org-all-targets (&optional radio)
3849 "Return a list of all targets in this file.
3851 (let ((re (if radio org-radio-target-regexp org-target-regexp))
3856 (add-to-list 'rtn (downcase (org-match-string-no-properties 1))))
3859 (defun org-make-target-link-regexp (targets)
3860 "Make regular expression matching all strings in TARGETS.
3875 (defun org-activate-tags (limit)
3881 'keymap org-mouse-map))
3884 (defun org-font-lock-level ()
3886 (org-back-to-heading t)
3889 (defun org-outline-level ()
3893 (+ (org-get-string-indentation (match-string 1)) 1000)
3896 (defvar org-font-lock-keywords nil)
3898 (defun org-set-font-lock-defaults ()
3899 (let* ((em org-fontify-emphasized-text)
3900 (lk org-activate-links)
3901 (org-font-lock-extra-keywords
3904 '("^\\(\\**\\)\\(\\*\\)\\(.*\\)" (1 (org-get-level-face 1))
3905 (2 (org-get-level-face 2)) (3 (org-get-level-face 3)))
3907 (1 'org-table))
3909 (if (memq 'angle lk) '(org-activate-angle-links (0 'org-link t)))
3910 (if (memq 'plain lk) '(org-activate-plain-links (0 'org-link t)))
3911 (if (memq 'bracket lk) '(org-activate-bracket-links (0 'org-link t)))
3912 (if (memq 'radio lk) '(org-activate-target-links (0 'org-link t)))
3913 (if (memq 'date lk) '(org-activate-dates (0 'org-date t)))
3914 (if (memq 'tag lk) '(org-activate-tags (1 'org-tag prepend)))
3915 '(org-hide-wide-columns (0 nil append))
3917 (list (concat "^\\*+[ \t]*" org-not-done-regexp)
3918 '(1 'org-todo t))
3920 (list (concat "\\[#[A-Z]\\]") '(0 'org-special-keyword t))
3922 (list org-repeat-re '(0 'org-special-keyword t))
3923 (list (concat "\\<" org-deadline-string) '(0 'org-special-keyword t))
3924 (list (concat "\\<" org-scheduled-string) '(0 'org-special-keyword t))
3925 (list (concat "\\<" org-closed-string) '(0 'org-special-keyword t))
3926 (list (concat "\\<" org-clock-string) '(0 'org-special-keyword t))
3930 '(org-do-emphasis-faces (0 nil append))
3931 '(org-do-emphasis-faces)))
3932 ;; Checkboxes, similar to Frank Ruell's org-checklet.el
3935 (if org-provide-checkbox-statistics
3937 (0 (org-get-checkbox-statistics-face) t)))
3939 (list (concat "^\\*+[ \t]*\\<\\(" org-comment-string
3940 "\\|" org-quote-string "\\)\\>")
3941 '(1 'org-special-keyword t))
3944 (if org-fontify-done-headline
3945 (list (concat "^[*]+ +\\<\\(" org-done-string "\\)\\(.*\\)\\>")
3946 '(1 'org-done t) '(2 'org-headline-done t))
3947 (list (concat "^[*]+ +\\<\\(" org-done-string "\\)\\>")
3948 '(1 'org-done t)))
3950 '("^[ \t]*\\(:.*\\)" (1 'org-table t))
3951 '("| *\\(:?=[^|\n]*\\)" (1 'org-formula t))
3952 '("^[ \t]*| *\\([#!$*_^]\\) *|" (1 'org-formula t))
3953 (if org-format-transports-properties-p
3954 '("| *\\(<[0-9]+>\\) *" (1 'org-formula t)))
3955 '("^\\*+ \\(.*:ARCHIVE:.*\\)" (1 'org-archived prepend))
3957 (setq org-font-lock-extra-keywords (delq nil org-font-lock-extra-keywords))
3959 (org-set-local 'org-font-lock-keywords org-font-lock-extra-keywords)
3960 (org-set-local 'font-lock-defaults
3961 '(org-font-lock-keywords t nil nil backward-paragraph))
3964 (defvar org-m nil)
3965 (defvar org-l nil)
3966 (defvar org-f nil)
3967 (defun org-get-level-face (n)
3969 (setq org-l (- (match-end 2) (match-beginning 1)))
3970 (if org-odd-levels-only (setq org-l (1+ (/ org-l 2))))
3971 ; (setq org-f (nth (1- (% org-l org-n-levels)) org-level-faces))
3972 (setq org-f (nth (% (1- org-l) org-n-levels) org-level-faces))
3974 ((eq n 1) (if org-hide-leading-stars 'org-hide org-f))
3975 ((eq n 2) org-f)
3976 (t (if org-level-color-stars-only nil org-f))))
3978 (defun org-unfontify-region (beg end &optional maybe_loudly)
3986 '(mouse-face t keymap t org-linked-text t
3990 ;;;; Visibility cycling, including org-goto and indirect buffer
3994 (defvar org-cycle-global-status nil)
3995 (make-variable-buffer-local 'org-cycle-global-status)
3996 (defvar org-cycle-subtree-status nil)
3997 (make-variable-buffer-local 'org-cycle-subtree-status)
4000 (defun org-cycle (&optional arg)
4006 2. CONTENTS: Show all headlines of all levels, but no body text.
4023 `org-cycle-emulate-tab' for details.
4029 (if (and (org-mode-p) org-cycle-include-plain-lists)
4032 (bob-special (and org-cycle-global-at-bob (bobp)
4034 (org-cycle-hook
4036 (delq 'org-optimize-window-after-visibility-change
4037 (copy-sequence org-cycle-hook))
4038 org-cycle-hook))
4047 ((org-at-table-p 'any)
4049 (or (org-table-recognize-table.el)
4051 (if arg (org-table-edit-field t)
4052 (org-table-justify-field-maybe)
4053 (call-interactively 'org-table-next-field)))))
4059 (eq org-cycle-global-status 'overview))
4063 (org-content)
4065 (setq org-cycle-global-status 'contents)
4066 (run-hook-with-args 'org-cycle-hook 'contents))
4069 (eq org-cycle-global-status 'contents))
4071 (show-all)
4073 (setq org-cycle-global-status 'all)
4074 (run-hook-with-args 'org-cycle-hook 'all))
4078 (org-overview)
4080 (setq org-cycle-global-status 'overview)
4081 (run-hook-with-args 'org-cycle-hook 'overview))))
4086 (org-back-to-heading)
4089 (org-show-subtree)))
4093 (org-back-to-heading)
4097 (org-back-to-heading)
4104 (org-end-of-subtree t)
4113 (setq org-cycle-subtree-status nil))
4116 (org-show-entry)
4119 (setq org-cycle-subtree-status 'children)
4120 (run-hook-with-args 'org-cycle-hook 'children))
4122 (eq org-cycle-subtree-status 'children))
4124 (org-show-subtree)
4126 (setq org-cycle-subtree-status 'subtree)
4127 (run-hook-with-args 'org-cycle-hook 'subtree))
4132 (setq org-cycle-subtree-status 'folded)
4133 (run-hook-with-args 'org-cycle-hook 'folded)))))
4136 (buffer-read-only (org-back-to-heading))
4138 ((org-try-cdlatex-tab))
4140 ((if (and (memq org-cycle-emulate-tab '(white whitestart))
4142 (or (and (eq org-cycle-emulate-tab 'white)
4144 (and (eq org-cycle-emulate-tab 'whitestart)
4147 (eq org-cycle-emulate-tab t))
4157 (org-back-to-heading)
4158 (org-cycle))))))
4161 (defun org-global-cycle (&optional arg)
4162 "Cycle the global visibility. For details see `org-cycle'."
4164 (let ((org-cycle-include-plain-lists
4165 (if (org-mode-p) org-cycle-include-plain-lists nil)))
4168 (show-all)
4170 (setq org-cycle-global-status 'contents))
4171 (org-cycle '(4)))))
4173 (defun org-overview ()
4175 Really, this shows all headlines with level equal or greater than the level
4188 (defun org-content (&optional arg)
4189 "Show all headlines in the buffer, like a table of contents.
4193 ;; Visit all headings and show their offspring
4194 (and (integerp arg) (org-overview))
4208 (defun org-optimize-window-after-visibility-change (state)
4210 This function is the default value of the hook `org-cycle-hook'."
4213 ((eq state 'overview) (org-first-headline-recenter 1))
4215 ((eq state 'all) nil)
4217 ((eq state 'children) (or (org-subtree-end-visible-p) (recenter 1)))
4218 ((eq state 'subtree) (or (org-subtree-end-visible-p) (recenter 1))))))
4220 (defun org-subtree-end-visible-p ()
4223 (save-excursion (org-end-of-subtree t) (point))))
4225 (defun org-first-headline-recenter (&optional N)
4235 (defvar org-goto-window-configuration nil)
4236 (defvar org-goto-marker nil)
4237 (defvar org-goto-map (make-sparse-keymap))
4240 (substitute-key-definition cmd cmd org-goto-map global-map)))
4241 (define-key org-goto-map "\C-m" 'org-goto-ret)
4242 (define-key org-goto-map [(left)] 'org-goto-left)
4243 (define-key org-goto-map [(right)] 'org-goto-right)
4244 (define-key org-goto-map [(?q)] 'org-goto-quit)
4245 (define-key org-goto-map [(control ?g)] 'org-goto-quit)
4246 (define-key org-goto-map "\C-i" 'org-cycle)
4247 (define-key org-goto-map [(tab)] 'org-cycle)
4248 (define-key org-goto-map [(down)] 'outline-next-visible-heading)
4249 (define-key org-goto-map [(up)] 'outline-previous-visible-heading)
4250 (define-key org-goto-map "n" 'outline-next-visible-heading)
4251 (define-key org-goto-map "p" 'outline-previous-visible-heading)
4252 (define-key org-goto-map "f" 'outline-forward-same-level)
4253 (define-key org-goto-map "b" 'outline-backward-same-level)
4254 (define-key org-goto-map "u" 'outline-up-heading)
4255 (define-key org-goto-map "\C-c\C-n" 'outline-next-visible-heading)
4256 (define-key org-goto-map "\C-c\C-p" 'outline-previous-visible-heading)
4257 (define-key org-goto-map "\C-c\C-f" 'outline-forward-same-level)
4258 (define-key org-goto-map "\C-c\C-b" 'outline-backward-same-level)
4259 (define-key org-goto-map "\C-c\C-u" 'outline-up-heading)
4261 (while l (define-key org-goto-map (int-to-string (pop l)) 'digit-argument)))
4263 (defconst org-goto-help
4267 (defun org-goto ()
4281 (let* ((org-goto-start-pos (point))
4283 (org-get-location (current-buffer) org-goto-help)))
4286 (org-mark-ring-push org-goto-start-pos)
4288 (if (or (org-invisible-p) (org-invisible-p2))
4289 (org-show-context 'org-goto)))
4292 (defvar org-selected-point nil) ; dynamically scoped parameter
4294 (defun org-get-location (buf help)
4298 (let (org-selected-point)
4302 (switch-to-buffer (get-buffer-create "*org-goto*"))
4309 (let ((org-startup-truncated t)
4310 (org-startup-folded t)
4311 (org-startup-align-all-tables nil))
4312 (org-mode))
4314 (if (and (boundp 'org-goto-start-pos)
4315 (integer-or-marker-p org-goto-start-pos))
4316 (let ((org-show-hierarchy-above t)
4317 (org-show-siblings t)
4318 (org-show-following-heading t))
4319 (goto-char org-goto-start-pos)
4320 (and (org-invisible-p) (org-show-context)))
4322 (org-beginning-of-line)
4327 (overriding-local-map org-goto-map))
4330 (use-global-map org-goto-map)
4333 (kill-buffer "*org-goto*")
4334 org-selected-point))
4336 (defun org-goto-ret (&optional arg)
4337 "Finish `org-goto' by going to the new location."
4339 (setq org-selected-point (point)
4343 (defun org-goto-left ()
4344 "Finish `org-goto' by going to the new location."
4346 (if (org-on-heading-p)
4349 (setq org-selected-point (point)
4354 (defun org-goto-right ()
4355 "Finish `org-goto' by going to the new location."
4357 (if (org-on-heading-p)
4361 (setq org-selected-point (point)
4366 (defun org-goto-quit ()
4367 "Finish `org-goto' without cursor motion."
4369 (setq org-selected-point nil)
4374 (defvar org-indirect-dedicated-frame nil
4376 (defvar org-last-indirect-buffer nil)
4378 (defun org-tree-to-indirect-buffer (&optional arg)
4385 If `org-indirect-buffer-display' is `dedicated-frame', the C-u prefix also
4394 (org-back-to-heading t)
4396 (setq level (org-outline-level))
4398 (while (> (setq level (org-outline-level)) arg)
4401 heading (org-get-heading))
4402 (org-end-of-subtree t) (setq end (point)))
4404 (buffer-live-p org-last-indirect-buffer))
4405 (kill-buffer org-last-indirect-buffer))
4406 (setq ibuf (org-get-indirect-buffer cbuf)
4407 org-last-indirect-buffer ibuf)
4409 ((or (eq org-indirect-buffer-display 'new-frame)
4410 (and arg (eq org-indirect-buffer-display 'dedicated-frame)))
4414 (org-set-frame-title heading))
4415 ((eq org-indirect-buffer-display 'dedicated-frame)
4417 (select-frame (or (and org-indirect-dedicated-frame
4418 (frame-live-p org-indirect-dedicated-frame)
4419 org-indirect-dedicated-frame)
4420 (setq org-indirect-dedicated-frame (make-frame)))))
4423 (org-set-frame-title (concat "Indirect: " heading)))
4424 ((eq org-indirect-buffer-display 'current-window)
4426 ((eq org-indirect-buffer-display 'other-window)
4430 (save-excursion (org-mode) (turn-on-font-lock)))
4432 (show-all)
4436 (defun org-get-indirect-buffer (&optional buffer)
4446 (defun org-set-frame-title (title)
4456 (defun org-insert-heading (&optional force-heading)
4466 (when (or force-heading (not (org-insert-item)))
4470 (org-back-to-heading)
4473 (blank (cdr (assq 'heading org-blank-before-new-entry)))
4476 ((and (org-on-heading-p) (bolp)
4477 (save-excursion (backward-char 1) (not (org-invisible-p))))
4480 (backward-char 1) (not (org-invisible-p))))
4487 (run-hooks 'org-insert-heading-hook)))))
4490 (defun org-insert-todo-heading (arg)
4495 (when (not (org-insert-item 'checkbox))
4496 (org-insert-heading)
4498 (org-back-to-heading)
4500 (looking-at org-todo-line-regexp))
4503 (equal (match-string 2) org-done-string))
4504 (insert (car org-todo-keywords) " ")
4509 (defun org-promote-subtree ()
4511 See also `org-promote'."
4514 (org-map-tree 'org-promote))
4515 (org-fix-position-after-promote))
4517 (defun org-demote-subtree ()
4518 "Demote the entire subtree. See `org-demote'.
4519 See also `org-promote'."
4522 (org-map-tree 'org-demote))
4523 (org-fix-position-after-promote))
4526 (defun org-do-promote ()
4528 If the region is active in `transient-mark-mode', promote all headings
4532 (if (org-region-active-p)
4533 (org-map-region 'org-promote (region-beginning) (region-end))
4534 (org-promote)))
4535 (org-fix-position-after-promote))
4537 (defun org-do-demote ()
4539 If the region is active in `transient-mark-mode', demote all headings
4543 (if (org-region-active-p)
4544 (org-map-region 'org-demote (region-beginning) (region-end))
4545 (org-demote)))
4546 (org-fix-position-after-promote))
4548 (defun org-fix-position-after-promote ()
4553 (looking-at org-todo-line-regexp)
4559 (defun org-get-legal-level (level &optional change)
4560 "Rectify a level change under the influence of `org-odd-levels-only'
4564 (if org-odd-levels-only
4570 (defun org-promote ()
4572 If the region is active in `transient-mark-mode', promote all headings
4574 (org-back-to-heading t)
4576 (up-head (make-string (org-get-legal-level level -1) ?*))
4581 (and org-auto-align-tags (org-set-tags nil t))
4582 (if org-adapt-indentation (org-fixup-indentation (- diff)))))
4584 (defun org-demote ()
4586 If the region is active in `transient-mark-mode', demote all headings
4588 (org-back-to-heading t)
4590 (down-head (make-string (org-get-legal-level level 1) ?*))
4594 (and org-auto-align-tags (org-set-tags nil t))
4595 (if org-adapt-indentation (org-fixup-indentation diff))))
4597 (defun org-map-tree (fun)
4599 (org-back-to-heading)
4609 (defun org-map-region (fun beg end)
4611 (let ((org-ignore-region t))
4624 (defun org-fixup-indentation (diff)
4627 would end up with no indentation after the change, nothing at all is done."
4643 (defun org-convert-to-odd-levels ()
4644 "Convert an org-mode file with all levels allowed to one with odd levels.
4649 (let ((org-odd-levels-only nil) n)
4655 (org-demote))
4659 (defun org-convert-to-oddeven-levels ()
4660 "Convert an org-mode file with only odd levels to one with odd and even levels.
4668 (org-show-context t)
4669 (error "Not all levels are odd in this file. Conversion not possible."))
4671 (let ((org-odd-levels-only nil) n)
4677 (org-promote))
4680 (defun org-tr-level (n)
4682 (if org-odd-levels-only (1+ (/ n 2)) n))
4686 (defun org-move-subtree-up (&optional arg)
4689 (org-move-subtree-down (- (prefix-numeric-value arg))))
4691 (defun org-move-subtree-down (&optional arg)
4701 (org-back-to-heading)
4705 (setq folded (org-invisible-p)))
4731 (defvar org-subtree-clip ""
4734 ring. We need it to check if the kill was created by `org-copy-subtree'.")
4736 (defvar org-subtree-clip-folded nil
4740 (defun org-cut-subtree ()
4744 (org-copy-subtree 'cut))
4746 (defun org-copy-subtree (&optional cut)
4752 (org-back-to-heading)
4756 (setq folded (org-invisible-p)))
4762 (setq org-subtree-clip-folded folded)
4764 (setq org-subtree-clip (current-kill 0))
4767 (length org-subtree-clip)))))
4769 (defun org-paste-subtree (&optional level tree)
4787 (unless (org-kill-is-subtree-p tree)
4828 (func (if (> shift 0) 'org-demote 'org-promote))
4829 (org-odd-levels-only nil)
4853 (org-map-region func (point-min) (point-max))
4859 (eq org-subtree-clip (current-kill 0))
4860 org-subtree-clip-folded)
4864 (defun org-kill-is-subtree-p (&optional txt)
4869 which is OK for `org-paste-subtree'.
4885 (defun org-narrow-to-subtree ()
4890 (progn (org-back-to-heading) (point))
4891 (progn (org-end-of-subtree t) (point)))))
4896 (defun org-sort (with-case)
4897 "Call `org-sort-entries' or `org-table-sort-lines', depending on context."
4899 (if (org-at-table-p)
4900 (org-call-with-arg 'org-table-sort-lines with-case)
4901 (org-call-with-arg 'org-sort-entries with-case)))
4903 (defun org-sort-entries (&optional with-case sorting-type)
4923 ((org-region-active-p)
4928 (if (not (org-on-heading-p)) (outline-next-heading))
4930 ((or (org-on-heading-p)
4931 (condition-case nil (progn (org-back-to-heading) t) (error nil)))
4933 (org-back-to-heading)
4934 (setq start (point) end (org-end-of-subtree) what "children")
4941 (or (org-on-heading-p) (outline-next-heading))
4944 (show-all)))
4963 (org-split-string txt re)))
4968 (setq entries (org-do-sort entries what with-case sorting-type)))
4976 (if (and unique (equal last (setq last (org-trim (cdr p)))))
4984 (defun org-do-sort (table what &optional with-case sorting-type)
5012 (if (string-match org-ts-regexp x)
5014 (org-time-string-to-time (match-string 0 x)))
5027 (defun org-at-item-p ()
5029 (let ((llt org-plain-list-ordered-item-terminator))
5037 (t (error "Invalid value of `org-plain-list-ordered-item-terminator'")))))))
5040 (defun org-in-item-p ()
5046 (org-beginning-of-item)
5047 (org-at-item-p)
5051 (defun org-insert-item (&optional checkbox)
5057 (org-beginning-of-item)
5058 (org-at-item-p)
5059 (if (org-invisible-p) (error "Invisible item"))
5065 (blank (cdr (assq 'plain-list-item org-blank-before-new-entry)))
5068 ((and (org-at-item-p) (<= (point) eow))
5080 (org-maybe-renumber-ordered-list)
5081 (and checkbox (org-update-checkbox-count-maybe))
5086 (defun org-at-item-checkbox-p ()
5088 (and (org-at-item-p)
5094 (defun org-toggle-checkbox (&optional arg)
5100 ((org-region-active-p)
5102 ((org-on-heading-p)
5104 ((org-at-item-checkbox-p)
5112 (when (org-at-item-checkbox-p)
5119 (org-update-checkbox-count-maybe))
5121 (defun org-update-checkbox-count-maybe ()
5123 (when org-provide-checkbox-statistics
5124 (org-update-checkbox-count)))
5126 (defun org-update-checkbox-count (&optional all)
5128 This will find all statistic cookies like [57%] and [6/12] and update them
5140 (when all
5151 ((org-on-heading-p) (outline-next-heading) (point))
5152 ((org-at-item-p) (org-end-of-item) (point))
5168 (if all "in entire file" "in current outline entry") cstat)))))
5170 (defun org-get-checkbox-statistics-face ()
5172 The face will be `org-done' when all relevant boxes are checked. Otherwise
5173 it will be `org-todo'."
5175 (if (equal (match-string 1) "100%") 'org-done 'org-todo)
5178 'org-done
5179 'org-todo)))
5181 (defun org-get-indentation (&optional line)
5185 (if (string-match "^ *" (org-remove-tabs line))
5192 (defun org-remove-tabs (s &optional width)
5204 (defun org-fix-indentation (line ind)
5209 (let* ((l (org-remove-tabs line))
5210 (i (org-get-indentation l))
5217 (defun org-beginning-of-item ()
5222 (limit (save-excursion (org-back-to-heading)
5225 (if (org-at-item-p)
5238 (throw 'exit (org-at-item-p))))))
5243 (defun org-end-of-item ()
5250 (org-beginning-of-item)
5266 (defun org-next-item ()
5271 (org-beginning-of-item)
5272 (setq ind (org-get-indentation))
5273 (org-end-of-item)
5274 (setq ind1 (org-get-indentation))
5275 (unless (and (org-at-item-p) (= ind ind1))
5279 (defun org-previous-item ()
5284 (org-beginning-of-item)
5286 (setq ind (org-get-indentation))
5293 (if (<= (org-get-indentation) ind)
5296 (org-beginning-of-item)
5300 (defun org-move-item-down ()
5306 (org-beginning-of-item)
5308 (setq ind (org-get-indentation))
5309 (org-end-of-item)
5311 (setq ind1 (org-get-indentation))
5312 (if (and (org-at-item-p) (= ind ind1))
5314 (org-end-of-item)
5321 (org-maybe-renumber-ordered-list))
5325 (defun org-move-item-up (arg)
5331 (org-beginning-of-item)
5333 (setq ind (org-get-indentation))
5334 (org-end-of-item)
5342 (if (<= (setq ind1 (org-get-indentation)) ind)
5345 (org-beginning-of-item)
5348 (setq ind1 (org-get-indentation))
5349 (if (and (org-at-item-p) (= ind ind1))
5357 (org-maybe-renumber-ordered-list))
5361 (defun org-maybe-renumber-ordered-list ()
5363 This tests the user option `org-auto-renumber-ordered-lists' before
5365 (and org-auto-renumber-ordered-lists
5366 (org-at-item-p)
5368 (org-renumber-ordered-list 1)))
5370 (defun org-get-string-indentation (s)
5381 (defun org-renumber-ordered-list (arg)
5386 (unless (and (org-at-item-p)
5389 (let ((line (org-current-line))
5391 (ind (org-get-string-indentation
5404 (not (org-at-item-p))))
5416 (if (not (org-at-item-p)) (throw 'exit nil))
5425 (defvar org-last-indent-begin-marker (make-marker))
5426 (defvar org-last-indent-end-marker (make-marker))
5428 (defun org-outdent-item (arg)
5431 (org-indent-item (- arg)))
5433 (defun org-indent-item (arg)
5436 (unless (org-at-item-p)
5440 (if (memq last-command '(org-shiftmetaright org-shiftmetaleft))
5441 (setq beg org-last-indent-begin-marker
5442 end org-last-indent-end-marker)
5443 (org-beginning-of-item)
5444 (setq beg (move-marker org-last-indent-begin-marker (point)))
5445 (org-end-of-item)
5446 (setq end (move-marker org-last-indent-end-marker (point))))
5459 (defalias 'org-advertized-archive-subtree 'org-archive-subtree)
5461 (defun org-archive-subtree (&optional find-done)
5469 If the cursor is not at a headline when this comand is called, try all level
5474 (org-archive-all-done)
5475 ;; Save all relevant TODO keyword-relatex variables
5477 (let ((tr-org-todo-line-regexp org-todo-line-regexp) ; keep despite compiler
5478 (tr-org-todo-keywords org-todo-keywords)
5479 (tr-org-todo-interpretation org-todo-interpretation)
5480 (tr-org-done-string org-done-string)
5481 (tr-org-todo-regexp org-todo-regexp)
5482 (tr-org-todo-line-regexp org-todo-line-regexp)
5483 (tr-org-odd-levels-only org-odd-levels-only)
5485 (org-archive-location org-archive-location)
5492 (setq org-archive-location (match-string 1))))
5494 (if (string-match "\\(.*\\)::\\(.*\\)" org-archive-location)
5496 (setq file (format (match-string 1 org-archive-location)
5498 heading (match-string 2 org-archive-location)))
5499 (error "Invalid `org-archive-location'"))
5514 (let (this-command) (org-copy-subtree))
5516 ;; Enforce org-mode for the archive buffer
5517 (if (not (org-mode-p))
5519 (let ((org-insert-mode-line-in-empty-file t))
5520 (call-interactively 'org-mode)))
5526 (let ((org-todo-line-regexp tr-org-todo-line-regexp)
5527 (org-todo-keywords tr-org-todo-keywords)
5528 (org-todo-interpretation tr-org-todo-interpretation)
5529 (org-done-string tr-org-done-string)
5530 (org-todo-regexp tr-org-todo-regexp)
5531 (org-todo-line-regexp tr-org-todo-line-regexp)
5532 (org-odd-levels-only
5533 (if (local-variable-p 'org-odd-levels-only)
5534 org-odd-levels-only
5535 tr-org-odd-levels-only)))
5551 (org-end-of-subtree t)
5558 (org-paste-subtree (org-get-legal-level level 1))
5559 ;; Mark the entry as done, i.e. set to last work in org-todo-keywords
5560 (if org-archive-mark-done
5561 (let (org-log-done)
5562 (org-todo (length org-todo-keywords))))
5564 (when org-archive-stamp-time
5566 (looking-at org-todo-line-regexp)
5568 (org-insert-time-stamp (org-current-time) t t "(" ")"))
5573 (let (this-command) (org-cut-subtree))
5580 (defun org-archive-all-done (&optional tag)
5582 If the cursor is not on a headline, try all level 1 trees. If
5583 it is on a headline, try all direct children.
5585 (let ((re (concat "^\\*+ +" org-not-done-regexp)) re1
5586 (rea (concat ".*:" org-archive-tag ":"))
5592 (if (org-on-heading-p)
5600 (move-marker endm (org-end-of-subtree t)))
5608 end (save-excursion (org-end-of-subtree t) (point)))
5617 (org-toggle-tag org-archive-tag 'on)
5618 (org-archive-subtree))
5623 (defun org-cycle-hide-archived-subtrees (state)
5624 "Re-hide all archived subtrees after a visibility state change."
5625 (when (and (not org-cycle-open-archived-trees)
5628 (let* ((globalp (memq state '(contents all)))
5630 (end (if globalp (point-max) (org-end-of-subtree t))))
5631 (org-hide-archived-subtrees beg end)
5633 (if (looking-at (concat ".*:" org-archive-tag ":"))
5635 "Subtree is archived and stays closed. Use \\[org-force-cycle-archived] to cycle it anyway.")))))))
5637 (defun org-force-cycle-archived ()
5640 (setq this-command 'org-cycle)
5641 (let ((org-cycle-open-archived-trees t))
5642 (call-interactively 'org-cycle)))
5644 (defun org-hide-archived-subtrees (beg end)
5645 "Re-hide all archived subtrees after a visibility state change."
5647 (let* ((re (concat ":" org-archive-tag ":")))
5650 (and (org-on-heading-p) (hide-subtree))
5651 (org-end-of-subtree t)))))
5653 (defun org-toggle-tag (tag &optional onoff)
5656 (unless (org-on-heading-p) (error "Not on headling"))
5666 (setq current (nreverse (org-split-string current ":")))
5680 (org-set-tags nil t))
5683 (defun org-toggle-archive-tag (&optional arg)
5685 With prefix ARG, check all children of current headline and offer tagging
5689 (org-archive-all-done 'tag)
5692 (org-back-to-heading t)
5693 (setq set (org-toggle-tag org-archive-tag))
5706 ;; Emacs package. We call the former org-type tables, and the latter
5709 (defun org-before-change-function (beg end)
5711 (setq org-table-may-need-update t))
5713 (defconst org-table-line-regexp "^[ \t]*|"
5714 "Detects an org-type table line.")
5715 (defconst org-table-dataline-regexp "^[ \t]*|[^-]"
5716 "Detects an org-type table line.")
5717 (defconst org-table-auto-recalculate-regexp "^[ \t]*| *# *\\(|\\|$\\)"
5719 (defconst org-table-recalculate-regexp "^[ \t]*| *[#*] *\\(|\\|$\\)"
5721 (defconst org-table-calculate-mark-regexp "^[ \t]*| *[!$^_#*] *\\(|\\|$\\)"
5723 (defconst org-table-hline-regexp "^[ \t]*|-"
5724 "Detects an org-type table hline.")
5725 (defconst org-table1-hline-regexp "^[ \t]*\\+-[-+]"
5727 (defconst org-table-any-line-regexp "^[ \t]*\\(|\\|\\+-[-+]\\)"
5728 "Detects an org-type or table-type table.")
5729 (defconst org-table-border-regexp "^[ \t]*[^| \t]"
5732 (defconst org-table-any-border-regexp "^[ \t]*[^|+ \t]"
5736 (defvar org-table-last-highlighted-reference nil)
5737 (defvar org-table-formula-history nil)
5739 (defvar org-table-column-names nil
5741 (defvar org-table-column-name-regexp nil
5743 (defvar org-table-local-parameters nil
5745 (defvar org-table-named-field-locations nil
5748 (defvar org-table-current-line-types nil
5750 (defvar org-table-current-begin-line nil
5752 (defvar org-table-dlines nil
5754 (defvar org-table-hlines nil
5757 (defconst org-table-range-regexp
5762 (defconst org-table-range-regexp2
5766 (defvar org-inhibit-highlight-removal nil)
5769 (defun org-table-create-with-table.el ()
5776 ((org-at-table.el-p)
5778 (org-table-convert)))
5779 ((org-at-table-p)
5781 (org-table-convert)))
5784 (defun org-table-create-or-convert-from-region (arg)
5789 (if (org-region-active-p)
5790 (org-table-convert-region (region-beginning) (region-end) arg)
5791 (org-table-create arg)))
5793 (defun org-table-create (&optional size)
5800 org-table-default-size "]: ")
5801 "" nil org-table-default-size)))
5805 (split (org-split-string size " *x *"))
5823 (org-table-align)))
5825 (defun org-table-convert-region (beg0 end0 &optional nspace)
5858 (org-table-align)))
5860 (defun org-table-import (file arg)
5862 The file is assumed to be tab-separated. Such files can be produced by most
5870 (org-table-convert-region beg (+ (point) (- (point-max) pm)) arg)))
5872 (defun org-table-export ()
5876 (let* ((beg (org-table-begin))
5877 (end (org-table-end))
5908 (defvar org-table-aligned-begin-marker (make-marker)
5911 (defvar org-table-aligned-end-marker (make-marker)
5914 (defvar org-table-last-alignment nil
5917 (defvar org-table-last-column-widths nil
5920 (defvar org-table-overlay-coordinates nil
5922 (make-variable-buffer-local 'org-table-overlay-coordinates)
5924 (defvar org-last-recalc-line nil)
5925 (defconst org-narrow-column-arrow "=>"
5928 (defun org-table-align ()
5929 "Align the table at point by aligning all vertical bars."
5933 (beg (org-table-begin))
5934 (end (org-table-end))
5936 (linepos (org-current-line))
5937 (colpos (org-table-current-column))
5939 (winstartline (org-current-line (min winstart (1- (point-max)))))
5953 (remove-text-properties beg end '(org-cwidth t org-dwidth t display t))
5956 (setq links (re-search-forward org-bracket-link-regexp end t))
5958 (setq dates (and org-display-custom-times
5959 (re-search-forward org-ts-regexp-both end t)))
5961 (when links (goto-char beg) (while (org-activate-bracket-links end)))
5963 (when dates (goto-char beg) (while (org-activate-dates end)))
5967 (setq narrow (and org-format-transports-properties-p
5970 (setq lines (org-split-string
5987 (org-split-string l " *| *"))
5994 (org-table-create org-table-default-size)
6000 (while (< (setq i (1+ i)) maxfields) ;; Loop over all columns
6013 (> (org-string-width xx) fmax))
6014 (org-add-props xx nil
6016 (concat "Clipped table field, use C-c ` to edit. Full value is:\n" (org-no-properties (copy-sequence xx))))
6017 (setq f1 (min fmax (or (string-match org-bracket-link-regexp xx) fmax)))
6021 (add-text-properties f1 (length xx) (list 'org-cwidth t) xx)
6023 (list 'display org-narrow-column-arrow)
6026 (push (apply 'max 1 (mapcar 'org-string-width column)) lengths)
6033 (if (string-match org-table-number-regexp x) 1 0))
6035 (push (>= frac org-table-number-fraction) typenums))
6039 (setq org-table-last-alignment typenums
6040 org-table-last-column-widths lengths)
6050 (string-match org-bracket-link-regexp (car c))
6051 (< (org-string-width (car c)) len))
6052 (setcar c (concat (car c) (make-string (- len (org-string-width (car c))) ?\ )))))))
6072 (move-marker org-table-aligned-begin-marker (point))
6074 (move-marker org-table-aligned-end-marker (point))
6075 (when (and orgtbl-mode (not (org-mode-p)))
6076 (goto-char org-table-aligned-begin-marker)
6077 (while (org-hide-wide-columns org-table-aligned-end-marker)))
6083 (org-table-goto-column colpos)
6084 (and org-table-overlay-coordinates (org-table-overlay-coordinates))
6085 (setq org-table-may-need-update nil)
6088 (defun org-string-width (s)
6090 This ignores character with invisibility property `org-link', and also
6091 characters with property `org-cwidth', because these will become invisible
6095 (assq 'org-link buffer-invisibility-spec))
6097 'invisible 'org-link s))
6101 (while (setq b (text-property-any 0 (length s) 'org-cwidth t s))
6104 b 'org-cwidth s) (length s))))))
6106 (while (setq b (text-property-any (1+ b) (length s) 'org-dwidth t s))
6107 (setq l (- l (get-text-property b 'org-dwidth-n s))))
6110 (defun org-table-begin (&optional table-type)
6115 (if table-type org-table-any-border-regexp
6116 org-table-border-regexp)
6123 (defun org-table-end (&optional table-type)
6128 (if table-type org-table-any-border-regexp
6129 org-table-border-regexp)
6135 (defun org-table-justify-field-maybe (&optional new)
6139 ((and (not new) org-table-may-need-update)) ; Realignment will happen anyway
6140 ((org-at-table-hline-p))
6142 (or (not (equal (marker-buffer org-table-aligned-begin-marker)
6144 (< (point) org-table-aligned-begin-marker)
6145 (>= (point) org-table-aligned-end-marker)))
6147 (setq org-table-may-need-update t))
6150 (col (org-table-current-column))
6151 (num (if (> col 0) (nth (1- col) org-table-last-alignment)))
6162 l (if e "|" (setq org-table-may-need-update t) ""))
6167 (setq n (concat new "|") org-table-may-need-update t)))
6169 (let (org-table-may-need-update)
6171 (setq org-table-may-need-update t))
6174 (defun org-table-next-field ()
6178 (org-table-maybe-eval-formula)
6179 (org-table-maybe-recalculate-line)
6180 (if (and org-table-automatic-realign
6181 org-table-may-need-update)
6182 (org-table-align))
6183 (let ((end (org-table-end)))
6184 (if (org-at-table-hline-p)
6192 org-table-tab-jumps-over-hlines
6198 (org-table-insert-row 'below))
6201 (org-table-insert-row 'below)))))
6203 (defun org-table-previous-field ()
6207 (org-table-justify-field-maybe)
6208 (org-table-maybe-recalculate-line)
6209 (if (and org-table-automatic-realign
6210 org-table-may-need-update)
6211 (org-table-align))
6212 (if (org-at-table-hline-p)
6214 (re-search-backward "|" (org-table-begin))
6215 (re-search-backward "|" (org-table-begin))
6217 (re-search-backward "|" (org-table-begin)))
6221 (defun org-table-next-row ()
6225 (org-table-maybe-eval-formula)
6226 (org-table-maybe-recalculate-line)
6230 (if (and org-table-automatic-realign
6231 org-table-may-need-update)
6232 (org-table-align))
6233 (let ((col (org-table-current-column)))
6235 (if (or (not (org-at-table-p))
6236 (org-at-table-hline-p))
6239 (org-table-insert-row 'below)))
6240 (org-table-goto-column col)
6244 (defun org-table-copy-down (n)
6251 If the variable `org-table-copy-increment' is non-nil and the field is an
6254 (let* ((colpos (org-table-current-column))
6255 (field (org-table-get-field))
6257 (beg (org-table-begin))
6259 (org-table-check-inside-data-field)
6262 (setq txt (org-trim field))
6263 (org-table-next-row)
6264 (org-table-blank-field))
6269 (re-search-backward org-table-dataline-regexp
6271 (org-table-goto-column colpos t)
6278 (if (and org-table-copy-increment
6282 (org-table-maybe-recalculate-line)
6283 (org-table-align))
6286 (defun org-table-check-inside-data-field ()
6290 (if (or (not (org-at-table-p))
6291 (= (org-table-current-column) 0)
6292 (org-at-table-hline-p)
6296 (defvar org-table-clip nil
6299 (defun org-table-blank-field ()
6302 (org-table-check-inside-data-field)
6303 (if (and (interactive-p) (org-region-active-p))
6304 (let (org-table-clip)
6305 (org-table-cut-region (region-beginning) (region-end)))
6311 (len (org-string-width match)))
6316 (defun org-table-get-field (&optional n replace)
6321 (and n (org-table-goto-column n))
6334 (defun org-table-field-info (arg)
6337 (org-table-get-specials)
6340 (col (org-table-current-column))
6341 (cname (car (rassoc (int-to-string col) org-table-column-names)))
6342 (name (car (rassoc (list (org-current-line) col)
6343 org-table-named-field-locations)))
6344 (eql (org-table-get-stored-formulas))
6345 (dline (org-table-current-dline))
6351 (org-show-reference 'local)
6364 (defun org-table-current-column ()
6368 (if (interactive-p) (org-table-check-inside-data-field))
6377 (defun org-table-current-dline ()
6381 (if (interactive-p) (org-table-check-inside-data-field))
6384 (goto-char (org-table-begin))
6386 (if (looking-at org-table-dataline-regexp) (setq cnt (1+ cnt)))
6391 (defun org-table-goto-column (n &optional on-delim force)
6414 (defun org-at-table-p (&optional table-type)
6415 "Return t if the cursor is inside an org-type table.
6417 (if org-enable-table-editor
6420 (looking-at (if table-type org-table-any-line-regexp
6421 org-table-line-regexp)))
6424 (defun org-at-table.el-p ()
6426 (and (org-at-table-p 'any)
6428 (goto-char (org-table-begin 'any))
6429 (looking-at org-table1-hline-regexp))))
6431 (defun org-table-recognize-table.el ()
6433 (if org-table-tab-recognizes-table.el
6434 (if (org-at-table.el-p)
6437 (if (looking-at org-table-dataline-regexp)
6439 (if (looking-at org-table1-hline-regexp)
6442 (if (looking-at org-table-any-border-regexp)
6444 (if (re-search-forward "|" (org-table-end t) t)
6457 (defun org-at-table-hline-p ()
6459 (if org-enable-table-editor
6462 (looking-at org-table-hline-regexp))
6465 (defun org-table-insert-column ()
6468 (if (not (org-at-table-p))
6470 (org-table-find-dataline)
6471 (let* ((col (max 1 (org-table-current-column)))
6472 (beg (org-table-begin))
6473 (end (org-table-end))
6475 (linepos (org-current-line))
6479 (if (org-at-table-hline-p)
6481 (org-table-goto-column col t)
6486 (org-table-goto-column colpos)
6487 (org-table-align)
6488 (org-table-fix-formulas "$" nil (1- col) 1)))
6490 (defun org-table-find-dataline ()
6492 (if (and (org-at-table-p)
6493 (not (org-at-table-hline-p)))
6496 (end (org-table-end)))
6500 (org-at-table-hline-p)))
6503 (if (and (org-at-table-p)
6504 (not (org-at-table-hline-p)))
6509 (defun org-table-delete-column ()
6512 (if (not (org-at-table-p))
6514 (org-table-find-dataline)
6515 (org-table-check-inside-data-field)
6516 (let* ((col (org-table-current-column))
6517 (beg (org-table-begin))
6518 (end (org-table-end))
6520 (linepos (org-current-line))
6524 (if (org-at-table-hline-p)
6526 (org-table-goto-column col t)
6532 (org-table-goto-column colpos)
6533 (org-table-align)
6534 (org-table-fix-formulas "$" (list (cons (number-to-string col) "INVALID"))
6537 (defun org-table-move-column-right ()
6540 (org-table-move-column nil))
6541 (defun org-table-move-column-left ()
6544 (org-table-move-column 'left))
6546 (defun org-table-move-column (&optional left)
6549 (if (not (org-at-table-p))
6551 (org-table-find-dataline)
6552 (org-table-check-inside-data-field)
6553 (let* ((col (org-table-current-column))
6555 (beg (org-table-begin))
6556 (end (org-table-end))
6558 (linepos (org-current-line))
6566 (if (org-at-table-hline-p)
6568 (org-table-goto-column col1 t)
6574 (org-table-goto-column colpos)
6575 (org-table-align)
6576 (org-table-fix-formulas
6580 (defun org-table-move-row-down ()
6583 (org-table-move-row nil))
6584 (defun org-table-move-row-up ()
6587 (org-table-move-row 'up))
6589 (defun org-table-move-row (&optional up)
6595 (looking-at org-table-hline-regexp)))
6596 (dline1 (org-table-current-dline))
6601 (unless (org-at-table-p)
6604 (setq hline2p (looking-at org-table-hline-regexp))
6615 (org-table-fix-formulas
6619 (defun org-table-insert-row (&optional arg)
6623 (if (not (org-at-table-p))
6626 (new (org-table-clean-line line)))
6631 (let (org-table-may-need-update) (insert-before-markers new "\n"))
6634 (and (or org-table-may-need-update org-table-overlay-coordinates)
6635 (org-table-align))
6636 (org-table-fix-formulas "@" nil (1- (org-table-current-dline)) 1)))
6638 (defun org-table-insert-hline (&optional arg)
6642 (if (not (org-at-table-p))
6644 (let ((line (org-table-clean-line
6656 (and org-table-overlay-coordinates (org-table-align))))
6658 (defun org-table-clean-line (s)
6666 (concat "|" (make-string (org-string-width (match-string 1 s))
6671 (defun org-table-kill-row ()
6674 (if (not (org-at-table-p))
6677 (dline (org-table-current-dline)))
6679 (if (not (org-at-table-p)) (beginning-of-line 0))
6681 (org-table-fix-formulas "@" (list (cons (number-to-string dline) "INVALID"))
6685 (defun org-table-sort-lines (with-case &optional sorting-type)
6707 (let* ((thisline (org-current-line))
6708 (thiscol (org-table-current-column))
6716 (org-table-goto-column thiscol))
6717 (org-table-check-inside-data-field)
6718 (if (org-region-active-p)
6722 (setq column (org-table-current-column)
6726 (setq column (org-table-current-column)
6728 tbeg (org-table-begin)
6729 tend (org-table-end))
6730 (if (re-search-backward org-table-hline-regexp tbeg t)
6735 (if (re-search-forward org-table-hline-regexp tend t)
6743 (org-table-goto-column column)
6746 (org-table-goto-column (1+ column))
6749 (org-table-goto-column column)
6750 (setq lns (mapcar (lambda(x) (cons (org-trim (substring x bcol ecol)) x))
6751 (org-split-string (buffer-substring beg end) "\n")))
6752 (setq lns (org-do-sort lns "Table" with-case sorting-type))
6758 (org-table-goto-column thiscol)
6761 (defun org-table-cut-region (beg end)
6762 "Copy region in table to the clipboard and blank all relevant fields."
6764 (org-table-copy-region beg end 'cut))
6766 (defun org-table-copy-region (beg end &optional cut)
6769 with `org-table-paste-rectangle'."
6775 (org-table-check-inside-data-field)
6776 (setq l01 (org-current-line)
6777 c01 (org-table-current-column))
6779 (org-table-check-inside-data-field)
6780 (setq l02 (org-current-line)
6781 c02 (org-table-current-column))
6789 (if (org-at-table-hline-p) (throw 'nextline (setq l1 (1+ l1))))
6792 (push (org-table-get-field ic1 rpl) cols)
6796 (setq org-table-clip (nreverse region))
6797 (if cut (org-table-align))
6798 org-table-clip))
6800 (defun org-table-paste-rectangle ()
6807 (unless (and org-table-clip (listp org-table-clip))
6809 (org-table-check-inside-data-field)
6810 (let* ((clip org-table-clip)
6811 (line (org-current-line))
6812 (col (org-table-current-column))
6813 (org-enable-table-editor t)
6814 (org-table-automatic-realign nil)
6817 (while (org-at-table-hline-p) (beginning-of-line 2))
6818 (if (not (org-at-table-p))
6819 (progn (end-of-line 0) (org-table-next-field)))
6822 (org-table-goto-column c nil 'force)
6823 (org-table-get-field nil field)
6827 (org-table-goto-column col)
6828 (org-table-align)))
6830 (defun org-table-convert ()
6831 "Convert from `org-mode' table to table.el and back.
6833 converted to table.el, all horizontal separator lines get lost, because
6841 (if (org-at-table.el-p)
6843 (let ((beg (move-marker (make-marker) (org-table-begin t)))
6844 (end (move-marker (make-marker) (org-table-end t))))
6850 (if (org-at-table-p)
6852 (let ((beg (move-marker (make-marker) (org-table-begin)))
6853 (end (move-marker (make-marker) (org-table-end))))
6854 ;; first, get rid of all horizontal lines
6860 (org-table-insert-hline 'above)
6864 (org-table-insert-hline))
6866 (setq end (move-marker end (org-table-end)))
6875 (defun org-table-wrap-region (arg)
6883 used to change the number of desired lines. For example, `C-2 \\[org-table-wrap]'
6898 (org-table-check-inside-data-field)
6899 (if (org-region-active-p)
6902 (cline (save-excursion (goto-char beg) (org-current-line)))
6903 (ccol (save-excursion (goto-char beg) (org-table-current-column)))
6905 (org-table-cut-region (region-beginning) (region-end))
6906 (if (> (length (car org-table-clip)) 1)
6910 (+ (length org-table-clip) arg)
6912 (length org-table-clip)))
6913 (setq org-table-clip
6914 (mapcar 'list (org-wrap (mapconcat 'car org-table-clip " ")
6917 (org-table-goto-column ccol)
6918 (org-table-paste-rectangle))
6922 (let ((s (org-table-blank-field))
6923 (col (org-table-current-column)))
6925 (while (org-at-table-hline-p) (beginning-of-line 0))
6926 (org-table-goto-column col)
6929 (insert " " (org-trim s))
6930 (org-table-align))
6936 (org-table-next-row)
6937 (insert (org-trim s) " ")
6938 (org-table-align))))))
6940 (defvar org-field-marker nil)
6942 (defun org-table-edit-field (arg)
6951 (remove-text-properties b e '(org-cwidth t invisible t
6956 (field (org-table-get-field))
6962 (org-mode)
6964 (insert (org-trim field))
6966 '(invisible t org-cwidth t display t
6969 (org-set-local 'org-finish-function
6970 'org-table-finish-edit-field)
6971 (org-set-local 'org-window-configuration cw)
6972 (org-set-local 'org-field-marker pos)
6975 (defun org-table-finish-edit-field ()
6977 Remove all newline characters, insert the result into the table, realign
6979 (let ((pos org-field-marker)
6980 (cw org-window-configuration)
6987 (setq text (org-trim (buffer-string)))
6993 (org-table-check-inside-data-field)
6994 (org-table-get-field nil text)
6995 (org-table-align)
6998 (defun org-trim (s)
7004 (defun org-wrap (string &optional width lines)
7012 (let* ((words (org-split-string string "[ \t\n]+"))
7013 (maxword (apply 'max (mapcar 'org-string-width words)))
7016 (org-do-wrap words (max maxword width)))
7019 (setq ll (org-do-wrap words maxword))
7025 (setq ll (org-do-wrap words w)))
7030 (defun org-do-wrap (words width)
7040 (defun org-split-string (string &optional separators)
7068 (defun org-table-map-tables (function)
7069 "Apply FUNCTION to the start of all tables in the buffer."
7074 (while (re-search-forward org-table-any-line-regexp nil t)
7077 (if (looking-at org-table-line-regexp)
7079 (re-search-forward org-table-any-border-regexp nil 1))))
7082 (defvar org-timecnt) ; dynamically scoped parameter
7084 (defun org-table-sum (&optional beg end nlast)
7089 If there is an active region, it is interpreted as a rectangle and all
7091 region and point is located in a table column, sum all numbers in that
7094 If at least one number looks like a time HH:MM or HH:MM:SS, all other
7101 (let (col (org-timecnt 0) diff h m s org-table-clip)
7104 ((org-region-active-p)
7107 (setq col (org-table-current-column))
7108 (goto-char (org-table-begin))
7111 (org-table-goto-column col)
7113 (goto-char (org-table-end))
7116 (org-table-goto-column col)
7118 (let* ((items (apply 'append (org-table-copy-region beg end)))
7124 (numbers (delq nil (mapcar 'org-table-get-number-for-summing
7127 (sres (if (= org-timecnt 0)
7142 (defun org-table-get-number-for-summing (s)
7157 (if (boundp 'org-timecnt) (setq org-timecnt (1+ org-timecnt)))
7162 (defun org-table-current-field-formula ()
7165 (let* ((name (car (rassoc (list (org-current-line)
7166 (org-table-current-column))
7167 org-table-named-field-locations)))
7168 (col (org-table-current-column))
7170 (ref (format "@%d$%d" (org-table-current-dline) col))
7171 (stored-list (org-table-get-stored-formulas))
7178 (defun org-table-get-formula (&optional equation named)
7181 (let* ((stored-list (org-table-get-stored-formulas))
7182 (name (car (rassoc (list (org-current-line)
7183 (org-table-current-column))
7184 org-table-named-field-locations)))
7185 (ref (format "@%d$%d" (org-table-current-dline)
7186 (org-table-current-column)))
7190 (int-to-string (org-table-current-column))))
7195 (org-table-may-need-update nil)
7204 (or stored "") 'org-table-formula-history
7211 (org-table-store-formulas stored-list)
7223 (org-table-store-formulas stored-list))
7226 (defun org-table-store-formulas (alist)
7230 (goto-char (org-table-end))
7245 (defun org-table-get-stored-formulas ()
7250 (goto-char (org-table-end))
7252 (setq strings (org-split-string (match-string 2) " *:: *"))
7265 (defun org-table-fix-formulas (key replace &optional limit delta remove)
7268 For all numbers larger than LIMIT, shift them by DELTA."
7270 (goto-char (org-table-end))
7290 (defun org-table-get-specials ()
7293 (let ((beg (org-table-begin)) (end (org-table-end))
7296 (setq org-table-column-names nil
7297 org-table-local-parameters nil
7298 org-table-named-field-locations nil
7299 org-table-current-begin-line nil
7300 org-table-current-line-types nil)
7303 (setq names (org-split-string (match-string 1) " *| *")
7308 (push (cons name (int-to-string cnt)) org-table-column-names))))
7309 (setq org-table-column-names (nreverse org-table-column-names))
7310 (setq org-table-column-name-regexp
7311 (concat "\\$\\(" (mapconcat 'car org-table-column-names "\\|") "\\)\\>"))
7314 (setq fields (org-split-string (match-string 1) " *| *"))
7318 org-table-local-parameters))))
7322 fields (org-split-string (match-string 2) " *| *"))
7325 (setq line (org-current-line) col 1)
7327 (setq fields1 (org-split-string (match-string 1) " *| *"))))
7332 (push (cons field v) org-table-local-parameters)
7333 (push (list field line col) org-table-named-field-locations))))
7336 (setq org-table-current-begin-line (org-current-line)
7337 l org-table-current-begin-line)
7343 (setq org-table-current-line-types (apply 'vector (nreverse types))
7344 org-table-dlines (apply 'vector (cons nil (nreverse dlines)))
7345 org-table-hlines (apply 'vector (cons nil (nreverse hlines)))))))
7347 (defun org-this-word ()
7354 (defun org-table-maybe-eval-formula ()
7359 (when org-table-formula-evaluate-inline
7360 (let* ((field (org-trim (or (org-table-get-field) "")))
7367 (org-table-eval-formula (if named '(4) nil) eq)
7370 (defvar org-recalc-commands nil
7374 (defvar org-recalc-marks
7383 (defun org-table-rotate-recalc-marks (&optional newchar)
7387 When there is an active region, change all the lines in the region,
7392 (unless (org-at-table-p) (error "Not at a table"))
7393 (let* ((marks (append (mapcar 'car org-recalc-marks) '(" ")))
7394 (beg (org-table-begin))
7395 (end (org-table-end))
7396 (l (org-current-line))
7397 (l1 (if (org-region-active-p) (org-current-line (region-beginning))))
7398 (l2 (if (org-region-active-p) (org-current-line (region-end))))
7403 (col (org-table-current-column))
7404 (forcenew (car (assoc newchar org-recalc-marks)))
7409 forcenew (car (assoc newchar org-recalc-marks))))
7411 (error "Invalid NEWCHAR `%s' in `org-table-rotate-recalc-marks'"
7416 (unless (looking-at org-table-dataline-regexp)
7419 (org-table-goto-column 1)
7420 (org-table-insert-column)
7421 (org-table-goto-column (1+ col)))
7425 (org-table-get-field
7435 (while (progn (beginning-of-line 2) (not (= (org-current-line) l2)))
7436 (and (looking-at org-table-dataline-regexp)
7437 (org-table-get-field 1 (concat " " new " "))))
7439 (if (not (= epos (point-at-eol))) (org-table-align))
7441 (and (interactive-p) (message (cdr (assoc new org-recalc-marks))))))
7443 (defun org-table-maybe-recalculate-line ()
7446 (and org-table-allow-automatic-line-recalculation
7447 (not (and (memq last-command org-recalc-commands)
7448 (equal org-last-recalc-line (org-current-line))))
7450 (looking-at org-table-auto-recalculate-regexp))
7451 (org-table-recalculate) t))
7453 (defvar org-table-formula-debug nil
7456 (make-variable-buffer-local 'org-table-formula-debug)
7459 (defsubst org-set-calc-mode (var &optional value)
7471 (defun org-table-eval-formula (&optional arg equation
7488 edited there. This is useful in order to use \\[org-show-reference]
7510 (org-table-check-inside-data-field)
7511 (or suppress-analysis (org-table-get-specials))
7513 (let ((eq (org-table-current-field-formula)))
7515 (org-table-get-field nil eq)
7516 (org-table-align)
7517 (setq org-table-may-need-update t))
7520 (org-table-automatic-realign nil)
7525 (org-table-get-formula equation (equal arg '(4)))))
7526 (n0 (org-table-current-column))
7527 (modes (copy-sequence org-calc-default-modes))
7534 (let ((tmp (org-split-string formula ";")))
7536 fmt (concat (cdr (assoc "%" org-table-local-parameters))
7542 (setq modes (org-set-calc-mode 'calc-internal-prec n))
7543 (setq modes (org-set-calc-mode
7556 (setq modes (org-set-calc-mode (match-string 0 fmt)))
7560 (if (and (not suppress-const) org-table-formula-use-constants)
7561 (setq formula (org-table-formula-substitute-names formula)))
7564 (setq fields (org-split-string
7565 (org-no-properties
7576 (setq form (org-rewrite-old-row-references form))
7578 (while (string-match org-table-range-regexp form)
7582 (org-table-make-reference
7583 (org-table-get-range (match-string 0 form) nil n0)
7591 (org-table-make-reference
7592 (org-sublist
7608 (org-table-make-reference x nil numbers lispp))
7620 (when org-table-formula-debug
7638 (org-table-align)
7643 (org-table-justify-field-maybe
7646 (call-interactively 'org-return)
7648 (and down (org-table-maybe-recalculate-line))
7649 (or suppress-align (and org-table-may-need-update
7650 (org-table-align))))))
7652 (defun org-table-get-range (desc &optional tbeg col highlight)
7660 (or tbeg (setq tbeg (org-table-begin)))
7661 (or col (setq col (org-table-current-column)))
7662 (let ((thisline (org-current-line))
7664 (unless (string-match org-table-range-regexp desc)
7678 (if r1 (setq r1 (org-table-get-descriptor-line r1)))
7679 (if r2 (setq r2 (org-table-get-descriptor-line r2)))
7689 (while (not (looking-at org-table-dataline-regexp))
7691 (prog1 (org-table-get-field c1)
7692 (if highlight (org-table-highlight-rectangle (point) (point)))))
7698 (while (not (looking-at org-table-dataline-regexp))
7700 (org-table-goto-column c1)
7703 (while (not (looking-at org-table-dataline-regexp))
7705 (org-table-goto-column c2)
7708 (org-table-highlight-rectangle
7711 (apply 'append (org-table-copy-region beg end))))))
7713 (defun org-table-get-descriptor-line (desc &optional cline bline table)
7718 (aref org-table-dlines (string-to-number desc))
7719 (setq cline (or cline (org-current-line))
7720 bline (or bline org-table-current-begin-line)
7721 table (or table org-table-current-line-types))
7741 (error "should never happen");;(aref org-table-dlines on) FIXME
7743 (setq i (org-find-row-type table i 'hline (equal hdir "-") nil hn)))
7745 (setq i (org-find-row-type table i 'dline (equal odir "-") rel on)))
7748 (defun org-find-row-type (table i type backwards relative n)
7762 (defun org-rewrite-old-row-references (s)
7767 (defun org-table-make-reference (elements keep-empty numbers lispp)
7793 (defun org-table-recalculate (&optional all noalign)
7794 "Recalculate the current table line by applying all stored formulas.
7795 With prefix arg ALL, do this for all lines in the table."
7797 (or (memq this-command org-recalc-commands)
7798 (setq org-recalc-commands (cons this-command org-recalc-commands)))
7799 (unless (org-at-table-p) (error "Not at a table"))
7800 (if (equal all '(16))
7801 (org-table-iterate)
7802 (org-table-get-specials)
7803 (let* ((eqlist (sort (org-table-get-stored-formulas)
7806 (line-re org-table-dataline-regexp)
7807 (thisline (org-current-line))
7808 (thiscol (org-table-current-column))
7810 ;; Insert constants in all formulas
7813 (setcdr x (org-table-formula-substitute-names (cdr x)))
7822 (if all
7824 (setq end (move-marker (make-marker) (1+ (org-table-end))))
7825 (goto-char (setq beg (org-table-begin)))
7826 (if (re-search-forward org-table-calculate-mark-regexp end t)
7828 (setq line-re org-table-recalculate-regexp)
7830 (if (and (re-search-forward org-table-dataline-regexp end t)
7831 (re-search-forward org-table-hline-regexp end t)
7832 (re-search-forward org-table-dataline-regexp end t))
7838 (and all (message "Re-applying formulas to full table..."))
7840 (unless (string-match "^ *[_^!$] *$" (org-table-get-field 1))
7842 (and all (message "Re-applying formulas to full table...(line %d)"
7844 (setq org-last-recalc-line (org-current-line))
7847 (goto-line org-last-recalc-line)
7848 (org-table-goto-column (string-to-number (car entry)) nil 'force)
7849 (org-table-eval-formula nil (cdr entry)
7852 (org-table-goto-column thiscol)
7853 (or noalign (and org-table-may-need-update (org-table-align))
7854 (and all (message "Re-applying formulas to %d lines...done" cnt)))
7858 a (assoc name org-table-named-field-locations))
7864 (aref org-table-dlines
7867 (when (and a (or all (equal (nth 1 a) thisline)))
7870 (org-table-goto-column (nth 2 a))
7871 (org-table-eval-formula nil (cdr eq) 'noalign 'nocst
7876 (org-table-goto-column thiscol)
7877 (or noalign (and org-table-may-need-update (org-table-align))
7878 (and all (message "Re-applying formulas...done"))))))
7880 (defun org-table-iterate (&optional arg)
7885 (lasttbl (buffer-substring (org-table-begin) (org-table-end)))
7890 (org-table-recalculate 'all)
7891 (setq thistbl (buffer-substring (org-table-begin) (org-table-end)))
7900 (defun org-table-formula-substitute-names (f)
7904 (while (setq start (string-match org-table-column-name-regexp f start))
7906 (setq a (assoc (match-string 1 f) org-table-column-names))
7913 (org-table-get-constant (match-string 1 f))))
7915 (if org-table-formula-debug
7919 (defun org-table-get-constant (const)
7922 (or (cdr (assoc const org-table-local-parameters))
7923 (cdr (assoc const org-table-formula-constants))
7927 (defvar org-edit-formulas-map (make-sparse-keymap))
7928 (define-key org-edit-formulas-map "\C-c\C-c" 'org-finish-edit-formulas)
7929 (define-key org-edit-formulas-map "\C-c\C-q" 'org-abort-edit-formulas)
7930 (define-key org-edit-formulas-map "\C-c?" 'org-show-reference)
7931 (define-key org-edit-formulas-map [(shift up)] 'org-table-edit-line-up)
7932 (define-key org-edit-formulas-map [(shift down)] 'org-table-edit-line-down)
7933 (define-key org-edit-formulas-map [(shift left)] 'org-table-edit-backward-field)
7934 (define-key org-edit-formulas-map [(shift right)] 'org-table-edit-next-field)
7935 (define-key org-edit-formulas-map [(meta up)] 'org-table-edit-scroll-down)
7936 (define-key org-edit-formulas-map [(meta down)] 'org-table-edit-scroll)
7937 (define-key org-edit-formulas-map [(meta tab)] 'lisp-complete-symbol)
7938 (define-key org-edit-formulas-map "\M-\C-i" 'lisp-complete-symbol)
7939 (define-key org-edit-formulas-map [(tab)] 'org-edit-formula-lisp-indent)
7940 (define-key org-edit-formulas-map "\C-i" 'org-edit-formula-lisp-indent)
7942 (defvar org-pos)
7944 (defun org-table-edit-formulas ()
7947 (unless (org-at-table-p) (error "Not at a table"))
7948 (org-table-get-specials)
7949 (let ((eql (org-table-get-stored-formulas))
7958 (org-set-local 'font-lock-global-modes (list 'not major-mode))
7959 (org-set-local 'org-pos pos)
7960 (org-set-local 'org-window-configuration wc)
7961 (use-local-map org-edit-formulas-map)
7962 (org-add-hook 'post-command-hook 'org-table-edit-formulas-post-command t t)
7977 (defun org-table-edit-formulas-post-command ()
7982 (org-show-reference)
7986 (defun org-finish-edit-formulas (&optional arg)
7990 (org-table-remove-rectangle-highlight)
7991 (let ((pos org-pos) eql var form)
7992 (setq org-pos nil)
7999 (setq form (org-trim form))
8003 (set-window-configuration org-window-configuration)
8006 (unless (org-at-table-p)
8008 (org-table-store-formulas eql)
8012 (org-table-recalculate 'all)
8015 (defun org-abort-edit-formulas ()
8018 (org-table-remove-rectangle-highlight)
8019 (let ((pos org-pos))
8020 (set-window-configuration org-window-configuration)
8026 (defun org-edit-formula-lisp-indent ()
8065 (defvar org-show-positions nil)
8067 (defun org-show-reference (&optional local)
8070 (org-table-remove-rectangle-highlight)
8072 (let ((pos (if local (point) org-pos))
8074 (org-inhibit-highlight-removal t)
8076 (org-show-positions nil)
8078 (if local (org-table-get-specials))
8080 ((org-at-regexp-p org-table-range-regexp2) 'range)
8081 ((org-at-regexp-p "\\$[a-zA-Z][a-zA-Z0-9]*") 'name)
8082 ((org-at-regexp-p "\\$[0-9]+") 'column)
8087 (org-table-add-rectangle-overlay (match-beginning 0) (match-end 0)
8089 (org-add-hook 'before-change-functions
8090 'org-table-remove-rectangle-highlight)
8094 (setq match (org-table-formula-substitute-names match)))
8100 (org-table-add-rectangle-overlay
8108 (org-table-force-dataline)
8113 (setq e (assoc name org-table-named-field-locations))
8115 (org-table-goto-column (nth 2 e)))
8119 (goto-line (aref org-table-dlines l))
8120 (org-table-goto-column c)))
8121 (t (org-table-goto-column (string-to-number name))))
8123 (org-table-highlight-rectangle nil nil face2))
8130 (org-table-get-range match nil nil 'highlight))
8132 ((setq e (assoc var org-table-named-field-locations))
8134 (org-table-goto-column (nth 2 e))
8135 (org-table-highlight-rectangle (point) (point))
8137 ((setq e (assoc var org-table-column-names))
8138 (org-table-goto-column (string-to-number (cdr e)))
8139 (org-table-highlight-rectangle (point) (point))
8140 (goto-char (org-table-begin))
8142 (org-table-end) t)
8145 (org-table-highlight-rectangle)
8150 (org-table-goto-column (string-to-number (substring match 1)))
8151 (org-table-highlight-rectangle (point) (point))
8153 ((setq e (assoc var org-table-local-parameters))
8154 (goto-char (org-table-begin))
8158 (org-table-highlight-rectangle)
8164 ((setq e (assoc var org-table-formula-constants))
8165 (message "Constant: $%s=%s in `org-table-formula-constants'."
8171 (when org-show-positions
8172 (push pos org-show-positions)
8173 (let ((min (apply 'min org-show-positions))
8174 (max (apply 'max org-show-positions)))
8182 (defun org-table-force-dataline ()
8186 (looking-at org-table-dataline-regexp))
8187 (let* ((re org-table-dataline-regexp)
8196 (defun org-table-edit-line-up ()
8199 (org-table-edit-move 'previous-line))
8201 (defun org-table-edit-line-down ()
8204 (org-table-edit-move 'next-line))
8206 (defun org-table-edit-backward-field ()
8209 (org-table-edit-move 'org-table-previous-field))
8211 (defun org-table-edit-next-field ()
8214 (org-table-edit-move 'org-table-next-field))
8216 (defun org-table-edit-move (command)
8219 (let ((org-table-allow-automatic-line-recalculation nil)
8220 (pos org-pos) (win (selected-window)) p)
8221 (select-window (get-buffer-window (marker-buffer org-pos)))
8224 (while (and (org-at-table-p)
8225 (org-at-table-hline-p))
8227 (or (org-at-table-p) (goto-char p))
8231 (defun org-table-edit-scroll (N)
8233 (let ((other-window-scroll-buffer (marker-buffer org-pos)))
8236 (defun org-table-edit-scroll-down (N)
8238 (org-table-edit-scroll (- N)))
8240 (defvar org-table-rectangle-overlays nil)
8242 (defun org-table-add-rectangle-overlay (beg end &optional face)
8244 (let ((ov (org-make-overlay beg end)))
8245 (org-overlay-put ov 'face (or face 'secondary-selection))
8246 (push ov org-table-rectangle-overlays)))
8248 (defun org-table-highlight-rectangle (&optional beg end face)
8254 (and (boundp 'org-show-positions)
8255 (setq org-show-positions (cons b (cons e org-show-positions))))
8257 (setq l1 (org-current-line)
8258 c1 (org-table-current-column))
8260 (setq l2 (org-current-line)
8261 c2 (org-table-current-column))
8266 (when (looking-at org-table-dataline-regexp)
8267 (org-table-goto-column c1)
8269 (org-table-goto-column c2)
8271 (org-table-add-rectangle-overlay beg end face))
8274 (add-hook 'before-change-functions 'org-table-remove-rectangle-highlight))
8276 (defun org-table-remove-rectangle-highlight (&rest ignore)
8278 (unless org-inhibit-highlight-removal
8279 (remove-hook 'before-change-functions 'org-table-remove-rectangle-highlight)
8280 (mapc 'org-delete-overlay org-table-rectangle-overlays)
8281 (setq org-table-rectangle-overlays nil)))
8283 (defvar org-table-coordinate-overlays nil
8285 (make-variable-buffer-local 'org-table-coordinate-overlays)
8287 (defun org-table-overlay-coordinates ()
8290 (mapc 'org-delete-overlay org-table-coordinate-overlays)
8291 (setq org-table-coordinate-overlays nil)
8294 (goto-char (org-table-begin))
8295 (while (org-at-table-p)
8297 (setq ov (org-make-overlay (point-at-bol) (1+ (point-at-bol))))
8298 (push ov org-table-coordinate-overlays)
8299 (setq hline (looking-at org-table-hline-regexp))
8302 (org-overlay-before-string ov str 'org-formula 'evaporate)
8308 (setq ov (org-make-overlay beg (+ beg (length str))))
8309 (push ov org-table-coordinate-overlays)
8310 (org-overlay-display ov str 'org-formula 'evaporate)))
8313 (defun org-table-toggle-coordinate-overlays ()
8316 (setq org-table-overlay-coordinates (not org-table-overlay-coordinates))
8318 (if org-table-overlay-coordinates "on" "off"))
8319 (if (and (org-at-table-p) org-table-overlay-coordinates)
8320 (org-table-align))
8321 (unless org-table-overlay-coordinates
8322 (mapc 'org-delete-overlay org-table-coordinate-overlays)
8323 (setq org-table-coordinate-overlays nil)))
8325 (defun org-table-toggle-formula-debugger ()
8328 (setq org-table-formula-debug (not org-table-formula-debug))
8330 (if org-table-formula-debug "on" "off")))
8335 ;; integrate the org-mode table editor.
8337 ;; This is really a hack, because the org-mode table editor uses several
8339 ;; RET keys. Here is how it works: The minor mode defines all the keys
8354 ;; all keys which are bound to `self-insert-command' in the *global map*.
8361 "Variable controlling `orgtbl-mode', a minor mode enabling the `org-mode'
8373 (defvar org-old-auto-fill-inhibit-regexp nil
8381 0 (quote 'org-table) 'prepend))
8386 "The `org-mode' table editor as a minor mode for use in other modes."
8388 (if (org-mode-p)
8390 ;; by accident in org-mode.
8391 (message "Orgtbl-mode is not useful in org-mode, command ignored")
8401 (org-set-local (quote org-table-may-need-update) t)
8402 (org-add-hook 'before-change-functions 'org-before-change-function
8404 (org-set-local 'org-old-auto-fill-inhibit-regexp
8406 (org-set-local 'auto-fill-inhibit-regexp
8411 (org-add-to-invisibility-spec '(org-cwidth))
8414 (org-restart-font-lock))
8417 (setq auto-fill-inhibit-regexp org-old-auto-fill-inhibit-regexp)
8418 (org-cleanup-narrow-column-properties)
8419 (org-remove-from-invisibility-spec '(org-cwidth))
8420 (remove-hook 'before-change-functions 'org-before-change-function t)
8423 (org-restart-font-lock))
8425 (force-mode-line-update 'all))))
8427 (defun org-cleanup-narrow-column-properties ()
8428 "Remove all properties related to narrow-column invisibility."
8431 'display org-narrow-column-arrow))
8434 (while (setq s (text-property-any s (point-max) 'org-cwidth 1))
8435 (remove-text-properties s (1+ s) '(org-cwidth t)))
8437 (while (setq s (text-property-any s (point-max) 'invisible 'org-cwidth))
8460 '(org-at-table-p)
8480 '([(meta shift left)] org-table-delete-column)
8481 '([(meta left)] org-table-move-column-left)
8482 '([(meta right)] org-table-move-column-right)
8483 '([(meta shift right)] org-table-insert-column)
8484 '([(meta shift up)] org-table-kill-row)
8485 '([(meta shift down)] org-table-insert-row)
8486 '([(meta up)] org-table-move-row-up)
8487 '([(meta down)] org-table-move-row-down)
8488 '("\C-c\C-w" org-table-cut-region)
8489 '("\C-c\M-w" org-table-copy-region)
8490 '("\C-c\C-y" org-table-paste-rectangle)
8491 '("\C-c-" org-table-insert-hline)
8492 '("\C-c}" org-table-toggle-coordinate-overlays)
8493 '("\C-c{" org-table-toggle-formula-debugger)
8494 '("\C-m" org-table-next-row)
8495 (list (org-key 'S-return) 'org-table-copy-down)
8496 '("\C-c\C-q" org-table-wrap-region)
8497 '("\C-c?" org-table-field-info)
8498 '("\C-c " org-table-blank-field)
8499 '("\C-c+" org-table-sum)
8500 '("\C-c=" org-table-eval-formula)
8501 '("\C-c'" org-table-edit-formulas)
8502 '("\C-c`" org-table-edit-field)
8503 '("\C-c*" org-table-recalculate)
8504 '("\C-c|" org-table-create-or-convert-from-region)
8505 '("\C-c^" org-table-sort-lines)
8506 '([(control ?#)] org-table-rotate-recalc-marks)))
8527 (orgtbl-make-binding 'org-table-previous-field 104
8531 (orgtbl-make-binding 'org-table-wrap-region 105
8534 (orgtbl-make-binding 'org-table-wrap-region 106
8541 (org-remap orgtbl-mode-map
8543 'delete-char 'org-delete-char
8544 'delete-backward-char 'org-delete-backward-char)
8545 (define-key orgtbl-mode-map "|" 'org-force-self-insert))
8548 ["Align" org-ctrl-c-ctrl-c :active (org-at-table-p) :keys "C-c C-c"]
8549 ["Next Field" org-cycle :active (org-at-table-p) :keys "TAB"]
8550 ["Previous Field" org-shifttab :active (org-at-table-p) :keys "S-TAB"]
8551 ["Next Row" org-return :active (org-at-table-p) :keys "RET"]
8553 ["Blank Field" org-table-blank-field :active (org-at-table-p) :keys "C-c SPC"]
8554 ["Edit Field" org-table-edit-field :active (org-at-table-p) :keys "C-c ` "]
8556 org-table-copy-down :active (org-at-table-p) :keys "S-RET"]
8559 ["Move Column Left" org-metaleft :active (org-at-table-p) :keys "M-<left>"]
8560 ["Move Column Right" org-metaright :active (org-at-table-p) :keys "M-<right>"]
8561 ["Delete Column" org-shiftmetaleft :active (org-at-table-p) :keys "M-S-<left>"]
8562 ["Insert Column" org-shiftmetaright :active (org-at-table-p) :keys "M-S-<right>"])
8564 ["Move Row Up" org-metaup :active (org-at-table-p) :keys "M-<up>"]
8565 ["Move Row Down" org-metadown :active (org-at-table-p) :keys "M-<down>"]
8566 ["Delete Row" org-shiftmetaup :active (org-at-table-p) :keys "M-S-<up>"]
8567 ["Insert Row" org-shiftmetadown :active (org-at-table-p) :keys "M-S-<down>"]
8568 ["Sort lines in region" org-table-sort-lines (org-at-table-p) :keys "C-c ^"]
8570 ["Insert Hline" org-table-insert-hline :active (org-at-table-p) :keys "C-c -"])
8572 ["Copy Rectangle" org-copy-special :active (org-at-table-p)]
8573 ["Cut Rectangle" org-cut-special :active (org-at-table-p)]
8574 ["Paste Rectangle" org-paste-special :active (org-at-table-p)]
8575 ["Fill Rectangle" org-table-wrap-region :active (org-at-table-p)])
8582 ["Set Column Formula" org-table-eval-formula :active (org-at-table-p) :keys "C-c ="]
8583 ["Set Field Formula" (org-table-eval-formula '(4)) :active (org-at-table-p) :keys "C-u C-c ="]
8584 ["Edit Formulas" org-table-edit-formulas :active (org-at-table-p) :keys "C-c '"]
8585 ["Recalculate line" org-table-recalculate :active (org-at-table-p) :keys "C-c *"]
8586 ["Recalculate all" (org-table-recalculate '(4)) :active (org-at-table-p) :keys "C-u C-c *"]
8587 ["Iterate all" (org-table-recalculate '(16)) :active (org-at-table-p) :keys "C-u C-u C-c *"]
8588 ["Toggle Recalculate Mark" org-table-rotate-recalc-marks :active (org-at-table-p) :keys "C-c #"]
8589 ["Sum Column/Rectangle" org-table-sum
8590 :active (or (org-at-table-p) (org-region-active-p)) :keys "C-c +"]
8591 ["Which Column?" org-table-current-column :active (org-at-table-p) :keys "C-c ?"]
8593 org-table-toggle-formula-debugger :active (org-at-table-p)
8595 :style toggle :selected org-table-formula-debug]
8597 org-table-toggle-coordinate-overlays :active (org-at-table-p)
8599 :style toggle :selected org-table-overlay-coordinates]
8617 (org-table-maybe-eval-formula)
8619 (call-interactively 'org-table-recalculate)
8620 (org-table-maybe-recalculate-line))
8621 (call-interactively 'org-table-align)
8627 (if (org-at-table-p)
8628 (org-call-with-arg 'org-table-recalculate t))))
8635 (if arg (org-table-edit-field t)
8636 (org-table-justify-field-maybe)
8637 (org-table-next-field)))
8642 (org-table-justify-field-maybe)
8643 (org-table-next-row))
8650 (if (and (org-at-table-p)
8652 (and org-table-auto-blank-field
8660 (org-table-blank-field))
8664 (let (org-table-may-need-update)
8669 (setq org-table-may-need-update t)
8673 (defun org-force-self-insert (N)
8681 (defvar org-table-clean-did-remove-column-1 nil)
8689 (unless (org-at-table-p) (error "Not at a table"))
8691 (when (interactive-p) (org-table-align))
8693 (goto-char (org-table-begin))
8706 (org-table-begin) (org-table-end)))
8707 (lines (nthcdr (or skip 0) (org-split-string txt "[ \t]*\n[ \t]*")))
8708 (lines (org-table-clean-before-export lines))
8709 (i0 (if org-table-clean-did-remove-column-1 2 1))
8712 (if (string-match org-table-hline-regexp x)
8714 (org-remove-by-index
8715 (org-split-string (org-trim x) "\\s-*|\\s-*")
8719 (org-table-last-alignment
8720 (org-remove-by-index (funcall fun org-table-last-alignment)
8722 (org-table-last-column-widths
8723 (org-remove-by-index (funcall fun org-table-last-column-widths)
8746 (defun org-remove-by-index (list indices &optional i0)
8766 (t (error "Not at an org table")))))
8793 (defun org-get-param (params header i sym &optional hsym)
8810 specify either :lfmt, or all of (:lstart :lend :sep). If you do not use
8827 :lfmt Format for entire line, with enough %s to capture all fields.
8862 ;; Now loop over all lines
8874 fm (org-get-param p h i :fmt :hfmt)
8875 efm (org-get-param p h i :efmt))
8882 (if (setq lfmt (org-get-param p h i :lfmt :hlfmt))
8885 (org-get-param p h i :lstart :hlstart)
8886 (mapconcat 'identity line (org-get-param p h i :sep :hsep))
8887 (org-get-param p h i :lend :hlend))
8900 Supports all parameters from `orgtbl-to-generic'. Most important for
8919 org-table-last-alignment ""))
8926 (orgtbl-to-generic table (org-combine-plists params2 params))))
8945 (setq html (org-format-org-table-html
8962 Supports all parameters from `orgtbl-to-generic'. Most important for
8976 under org-mode.
8980 (let* ((total (float (apply '+ org-table-last-column-widths)))
8984 org-table-last-column-widths " ")))
8991 (orgtbl-to-generic table (org-combine-plists params2 params))))
8997 (defun org-link-expand-abbrev (link)
8998 "Apply replacements as defined in `org-link-abbrev-alist."
9001 (as (or (assoc key org-link-abbrev-alist-local)
9002 (assoc key org-link-abbrev-alist)))
9016 (defvar org-insert-link-history nil
9017 "Minibuffer history for links inserted with `org-insert-link'.")
9019 (defvar org-stored-links nil
9020 "Contains the links stored with `org-store-link'.")
9022 (defvar org-store-link-plist nil
9023 "Plist with info about the most recently link created with `org-store-link'.")
9026 (defun org-store-link (arg)
9027 "\\<org-mode-map>Store an org-link to the current location.
9028 This link can later be inserted into an org-buffer with
9029 \\[org-insert-link].
9031 For links to usenet articles, arg negates `org-usenet-links-prefer-google'.
9032 For file links, arg negates `org-context-in-file-links'."
9034 (setq org-store-link-plist nil) ; reset
9042 link (org-make-link cpltxt))
9043 (org-store-link-props :type "bbdb" :name name :company company)))
9046 (setq link (org-make-link "info:"
9051 (org-store-link-props :type "info" :file Info-current-file
9058 (car org-time-stamp-formats)
9062 (org-store-link-props :type "calendar" :date cd)))
9076 (org-store-link-props :type "vm" :from from :to to :subject subject
9078 (setq message-id (org-remove-angle-brackets message-id))
9083 (setq cpltxt (org-email-link-description))
9084 (setq link (org-make-link "vm:" folder "#" message-id)))))
9100 (org-store-link-props :type "wl" :from from :to to
9102 (setq message-id (org-remove-angle-brackets message-id))
9103 (setq cpltxt (org-email-link-description))
9104 (setq link (org-make-link "wl:" wl-summary-buffer-folder-name
9109 (let ((from (org-mhe-get-header "From:"))
9110 (to (org-mhe-get-header "To:"))
9111 (message-id (org-mhe-get-header "Message-Id:"))
9112 (subject (org-mhe-get-header "Subject:")))
9113 (org-store-link-props :type "mh" :from from :to to
9115 (setq cpltxt (org-email-link-description))
9116 (setq link (org-make-link "mhe:" (org-mhe-get-message-real-folder) "#"
9117 (org-remove-angle-brackets message-id)))))
9128 (org-store-link-props
9131 (setq message-id (org-remove-angle-brackets message-id))
9132 (setq cpltxt (org-email-link-description))
9133 (setq link (org-make-link "rmail:" folder "#" message-id))))))
9142 (org-store-link-props :type "gnus" :group group)
9144 (if (org-xor arg org-usenet-links-prefer-google)
9148 link (org-make-link cpltxt))))
9159 (org-store-link-props :type "gnus" :from from :subject subject
9161 (setq cpltxt (org-email-link-description))
9162 (if (org-xor arg org-usenet-links-prefer-google)
9167 (org-fixup-message-id-for-http message-id))))
9168 (setq link (org-make-link "gnus:" group
9173 link (org-make-link cpltxt))
9174 (org-store-link-props :type "w3" :url (url-view-url t)))
9178 link (org-make-link w3m-current-url))
9179 (org-store-link-props :type "w3m" :url (url-view-url t)))
9182 'org-create-file-search-functions))
9190 link (org-make-link cpltxt))
9191 (org-store-link-props :type "image" :file buffer-file-name))
9199 link (org-make-link cpltxt)))
9201 ((and buffer-file-name (org-mode-p))
9206 (when (org-xor org-context-in-file-links arg)
9208 (if (org-in-regexp "<<\\(.*?\\)>>")
9211 ((org-on-heading-p) nil)
9212 ((org-region-active-p)
9217 (concat cpltxt "::" (org-make-org-heading-search-string txt))
9221 (setq link (org-make-link cpltxt)))
9228 (when (org-xor org-context-in-file-links arg)
9229 (setq txt (if (org-region-active-p)
9235 (concat cpltxt "::" (org-make-org-heading-search-string txt))
9237 (setq link (org-make-link cpltxt)))
9251 (setq org-stored-links
9252 (cons (list cpltxt link desc) org-stored-links))
9254 (org-make-link-string link desc))))
9256 (defun org-store-link-props (&rest plist)
9269 (when (and from to org-from-is-user-regexp)
9271 (if (string-match org-from-is-user-regexp from)
9274 (setq org-store-link-plist plist))
9276 (defun org-email-link-description (&optional fmt)
9278 This takes information from `org-store-link-plist' and formats it
9279 according to FMT (default from `org-email-link-description-format')."
9280 (setq fmt (or fmt org-email-link-description-format))
9281 (let* ((p org-store-link-plist)
9295 (if (and org-from-is-user-regexp from to
9296 (save-match-data (string-match org-from-is-user-regexp from)))
9299 (org-replace-escapes fmt table)))
9301 (defun org-make-org-heading-search-string (&optional string heading)
9304 (let ((s (or string (org-get-heading))))
9307 (if (string-match org-todo-regexp s)
9311 (setq s (org-trim s))
9312 (if (string-match (concat "^\\(" org-quote-string "\\|"
9313 org-comment-string "\\)") s)
9315 (while (string-match org-ts-regexp s)
9320 (mapconcat 'identity (org-split-string s "[ \t]+") " ")))
9322 (defun org-make-link (&rest strings)
9323 "Concatenate STRINGS, format resulting string with `org-link-format'."
9326 (defun org-make-link-string (link &optional description)
9332 (when (equal (org-link-escape link) description)
9336 (not (equal link (org-link-escape link))))
9338 (concat "[[" (org-link-escape link) "]"
9342 (defconst org-link-escape-chars '(("[" . "%5B") ("]" . "%5D") (" " . "%20"))
9345 (defun org-link-escape (text)
9349 org-link-escape-chars "\\|")))
9353 (cdr (assoc (match-string 0 text) org-link-escape-chars))
9357 (defun org-link-unescape (text)
9358 "Reverse the action of `org-link-escape'."
9361 org-link-escape-chars "\\|")))
9365 (car (rassoc (match-string 0 text) org-link-escape-chars))
9369 (defun org-xor (a b)
9373 (defun org-get-header (header)
9397 (defun org-fixup-message-id-for-http (s)
9407 (defun org-insert-link (&optional complete-file)
9411 `org-store-link'. When the empty string is entered (i.e. if you just
9431 `org-keep-stored-link-after-insertion'."
9433 (let ((region (if (org-region-active-p)
9439 ((org-in-regexp org-bracket-link-regexp 1)
9442 (setq desc (if (match-end 3) (org-match-string-no-properties 3)))
9444 (org-link-unescape
9445 (org-match-string-no-properties 1)))))
9446 ((or (org-in-regexp org-angle-link-re)
9447 (org-in-regexp org-plain-link-re))
9451 (org-remove-angle-brackets (match-string 0)))))
9460 (setq link (org-make-link
9464 (setq link (org-make-link "file:" (match-string 1 file))))
9467 (setq link (org-make-link
9469 (t (setq link (org-make-link "file:" file))))))
9473 (setq tmphist (append (mapcar 'car org-stored-links)
9474 org-insert-link-history))
9475 (setq link (org-completing-read
9476 "Link: " org-stored-links nil nil nil
9478 (or (car (car org-stored-links)))))
9479 (setq entry (assoc link org-stored-links))
9480 (or entry (push link org-insert-link-history))
9482 (not org-keep-stored-link-after-insertion))
9483 (setq org-stored-links (delq (assoc link org-stored-links)
9484 org-stored-links)))
9488 (if (string-match org-plain-link-re link)
9490 (setq link (org-make-link (org-remove-angle-brackets link))))
9509 ((eq org-link-file-path-type 'absolute)
9511 ((eq org-link-file-path-type 'noabbrev)
9513 ((eq org-link-file-path-type 'relative)
9529 (insert (org-make-link-string link desc))))
9531 (defun org-completing-read (&rest args)
9538 (defvar org-link-search-failed nil)
9540 (defun org-next-link ()
9544 (when (and org-link-search-failed (eq this-command last-command))
9547 (setq org-link-search-failed nil)
9549 (ct (org-context))
9552 (if (re-search-forward org-any-link-re nil t)
9555 (if (org-invisible-p) (org-show-context)))
9557 (setq org-link-search-failed t)
9560 (defun org-previous-link ()
9564 (when (and org-link-search-failed (eq this-command last-command))
9567 (setq org-link-search-failed nil)
9569 (ct (org-context))
9572 (if (re-search-backward org-any-link-re nil t)
9575 (if (org-invisible-p) (org-show-context)))
9577 (setq org-link-search-failed t)
9580 (defun org-find-file-at-mouse (ev)
9584 (org-open-at-point 'in-emacs))
9586 (defun org-open-at-mouse (ev)
9590 (org-open-at-point))
9592 (defvar org-window-config-before-follow-link nil
9596 (defvar org-open-link-marker (make-marker)
9597 "Marker pointing to the location where `org-open-at-point; was called.")
9599 (defun org-open-at-point (&optional in-emacs)
9603 Normally, files will be opened by an appropriate application. If the
9606 (move-marker org-open-link-marker (point))
9607 (setq org-window-config-before-follow-link (current-window-configuration))
9608 (org-remove-occur-highlights nil nil t)
9609 (if (org-at-timestamp-p t)
9610 (org-follow-timestamp-link)
9615 (when (org-in-regexp org-bracket-link-regexp)
9616 (setq link (org-link-unescape (org-match-string-no-properties 1)))
9619 (setq link (org-link-expand-abbrev link))
9620 (if (string-match org-link-re-with-space2 link)
9625 (when (get-text-property (point) 'org-linked-text)
9627 pos (if (get-text-property (1+ (point)) 'org-linked-text)
9630 (previous-single-property-change pos 'org-linked-text)
9631 (next-single-property-change pos 'org-linked-text)))
9635 (when (or (org-in-regexp org-angle-link-re)
9636 (org-in-regexp org-plain-link-re))
9640 (when (org-in-regexp "\\(:[A-Za-z_@0-9:]+\\):[ \t\r\n]")
9655 (let ((cmd (car org-link-mailto-program))
9656 (args (cdr org-link-mailto-program)) args1
9660 subject (org-link-escape (match-string 2 path))))
9676 (org-tags-view in-emacs path))
9680 (org-get-buffer-for-internal-link (current-buffer)))
9681 (org-mark-ring-push))
9682 (org-link-search
9685 ((equal in-emacs '(16)) 'org-occur)
9696 (org-open-file path in-emacs line search))
9699 (org-follow-gnus-link path))
9702 (org-follow-bbdb-link path))
9705 (org-follow-info-link path))
9713 (org-follow-gnus-link group article)))
9722 (org-follow-vm-link folder article in-emacs)))
9730 (org-follow-wl-link folder article)))
9738 (org-follow-mhe-link folder article)))
9746 (org-follow-rmail-link folder article)))
9753 (if (or (not org-confirm-shell-link-function)
9754 (funcall org-confirm-shell-link-function
9756 (org-add-props cmd nil
9757 'face 'org-warning))))
9765 (if (or (not org-confirm-elisp-link-function)
9766 (funcall org-confirm-elisp-link-function
9768 (org-add-props cmd nil
9769 'face 'org-warning))))
9775 (move-marker org-open-link-marker nil))
9780 (defvar org-create-file-search-functions nil
9791 file link, given after a double colon, and `org-open-at-point'
9794 added to the companion hook `org-execute-file-search-functions',
9800 buffer with \\[org-insert-link].")
9802 (defvar org-execute-file-search-functions nil
9820 the window configuration before `org-open-at-point' was called using:
9822 (set-window-configuration org-window-config-before-follow-link)")
9824 (defun org-link-search (s &optional type avoid-pos)
9827 regular expression. In org-mode files, this will create an `org-occur'
9828 sparse tree. In ordinary files, `occur' will be used to list matches.
9830 in all files. If AVOID-POS is given, ignore matches near that position."
9832 (s0 (mapconcat 'identity (org-split-string s "[ \t\r\n]+") " "))
9838 ((run-hook-with-args-until-success 'org-execute-file-search-functions s))
9851 ((org-mode-p)
9852 (org-occur (match-string 1 s)))
9855 (t (org-do-occur (match-string 1 s)))))
9867 (setq words (org-split-string s "[ \n\r\t]+")
9883 ((eq type 'org-occur) (org-occur reall))
9884 ((eq type 'occur) (org-do-occur (downcase reall) 'cleanup))
9886 (if (or (org-search-not-self 1 re0 nil t)
9887 (org-search-not-self 1 re1 nil t)
9888 (org-search-not-self 1 re2 nil t)
9889 (org-search-not-self 1 re2a nil t)
9890 (org-search-not-self 1 re3 nil t)
9891 (org-search-not-self 1 re4 nil t)
9892 (org-search-not-self 1 re5 nil t)
9903 (and (org-mode-p) (org-show-context 'link-search))))
9905 (defun org-search-not-self (group &rest args)
9907 enclose the position of `org-open-link-marker'."
9908 (let ((m org-open-link-marker))
9916 (or (not (org-in-regexp org-bracket-link-analytic-regexp 1))
9922 (defun org-get-buffer-for-internal-link (buffer)
9925 ((not org-display-internal-link-with-indirect-buffer)
9935 (with-current-buffer ib (org-overview))
9938 (defun org-do-occur (regexp &optional cleanup)
9959 (defvar org-mark-ring nil
9961 (defvar org-mark-ring-last-goto nil
9964 (setq org-mark-ring nil org-mark-ring-last-goto nil) ;; in case file is reloaded
9965 (loop for i from 1 to org-mark-ring-length do
9966 (push (make-marker) org-mark-ring))
9967 (setcdr (nthcdr (1- org-mark-ring-length) org-mark-ring)
9968 org-mark-ring)
9970 (defun org-mark-ring-push (&optional pos buffer)
9974 (setq org-mark-ring (nthcdr (1- org-mark-ring-length) org-mark-ring))
9975 (move-marker (car org-mark-ring)
9980 "Position saved to mark ring, go back with \\[org-mark-ring-goto].")))
9982 (defun org-mark-ring-goto (&optional n)
9992 (setq p (nthcdr n (or org-mark-ring-last-goto org-mark-ring)))
9993 (setq p org-mark-ring))
9994 (setq org-mark-ring-last-goto p)
9998 (if (or (org-invisible-p) (org-invisible-p2)) (org-show-context 'mark-goto))))
10000 (defun org-remove-angle-brackets (s)
10004 (defun org-add-angle-brackets (s)
10011 (defun org-follow-timestamp-link ()
10013 ((org-at-date-range-p t)
10014 (let ((org-agenda-start-on-weekday)
10017 (setq t1 (time-to-days (org-time-string-to-time t1))
10018 t2 (time-to-days (org-time-string-to-time t2)))
10019 (org-agenda-list nil t1 (1+ (- t2 t1)))))
10020 ((org-at-timestamp-p t)
10021 (org-agenda-list nil (time-to-days (org-time-string-to-time
10027 (defun org-follow-bbdb-link (name)
10051 (defun org-follow-info-link (name)
10062 (defun org-follow-gnus-link (&optional group article)
10065 (funcall (cdr (assq 'gnus org-link-frame-setup)))
10072 (defun org-follow-vm-link (&optional folder article readonly)
10075 (setq article (org-add-angle-brackets article))
10092 (funcall (cdr (assq 'vm org-link-frame-setup)) folder readonly)
10107 (defun org-follow-wl-link (folder article)
10120 (wl-summary-jump-to-msg-by-message-id (org-add-angle-brackets article))
10123 (defun org-follow-rmail-link (folder article)
10125 (setq article (org-add-angle-brackets article))
10147 (defun org-mhe-get-message-real-folder ()
10169 (org-mhe-get-message-folder-from-index)
10172 (org-mhe-get-message-folder-from-index)
10178 (defun org-mhe-get-message-folder-from-index ()
10185 (defun org-mhe-get-message-folder ()
10194 (defun org-mhe-get-message-num ()
10203 (defun org-mhe-get-header (header)
10207 (let* ((folder (org-mhe-get-message-folder))
10208 (num (org-mhe-get-message-num))
10223 (defun org-follow-mhe-link (folder article)
10226 `org-mhe-search-all-folders' is t and `mh-searcher' is pick,
10227 ARTICLE is searched in all folders. Indexed searches (swish++,
10228 namazu, and others supported by MH-E) will always search in all
10236 (setq article (org-add-angle-brackets article))
10241 (when (and org-mhe-search-all-folders
10242 (not (org-mhe-get-message-real-folder)))
10246 (if (org-mhe-get-message-real-folder)
10256 (defun org-create-file-search-in-bibtex ()
10280 (defun org-execute-file-search-in-bibtex (s)
10293 (set-window-configuration org-window-config-before-follow-link)
10301 (add-hook 'org-create-file-search-functions 'org-create-file-search-in-bibtex)
10302 (add-hook 'org-execute-file-search-functions 'org-execute-file-search-in-bibtex)
10308 (defun org-open-file (path &optional in-emacs line search)
10311 configuration variable `org-file-apps' is checked if it contains an
10323 (apps (append org-file-apps (org-default-apps)))
10324 (remp (and (assq 'remote apps) (org-file-remote-p file)))
10349 (if (and (not (eq cmd 'emacs)) ; Emacs has not problems with non-ex files
10351 (not org-open-non-existing-files))
10363 (funcall (cdr (assq 'file org-link-frame-setup)) file)
10365 (if search (org-link-search search))))
10368 (t (funcall (cdr (assq 'file org-link-frame-setup)) file)))
10369 (and (org-mode-p) (eq old-mode 'org-mode)
10372 (org-mark-ring-push old-pos old-buffer))))
10374 (defun org-default-apps ()
10378 org-file-apps-defaults-macosx)
10380 org-file-apps-defaults-windowsnt)
10381 (t org-file-apps-defaults-gnu)))
10383 (defun org-expand-file-name (path)
10388 (defun org-file-remote-p (file)
10407 (defun org-remember-annotation ()
10409 If you are using Org-mode files as target for data storage with
10412 (org-store-link nil))
10414 (defconst org-remember-help
10422 (defun org-remember-apply-template (&optional use-char skip-interactive)
10423 "Initialize *remember* buffer with template, invoke `org-mode'.
10426 (if org-remember-templates
10429 (if (= (length org-remember-templates) 1)
10430 (caar org-remember-templates)
10434 org-remember-templates " "))
10436 (entry (cdr (assoc char org-remember-templates)))
10438 (plist-p (if org-store-link-plist t nil))
10442 org-default-notes-file))
10444 (v-t (format-time-string (car org-time-stamp-formats) (org-current-time)))
10445 (v-T (format-time-string (cdr org-time-stamp-formats) (org-current-time)))
10451 (org-startup-folded nil)
10452 org-time-was-given x prompt char time)
10453 (setq org-store-link-plist
10461 ## To switch templates, use `\\[org-remember]'.\n\n"
10462 (abbreviate-file-name (or file org-default-notes-file))
10472 (org-split-string initial "\n")
10481 (and (setq x (plist-get org-store-link-plist
10484 ;; Turn on org-mode in the remember buffer, set local variables
10485 (org-mode)
10486 (org-set-local 'org-finish-function 'remember-buffer)
10488 (org-set-local 'org-default-notes-file file))
10490 (org-set-local 'org-remember-default-headline headline))
10500 (setq org-time-was-given (equal (upcase char) char))
10501 (setq time (org-read-date (equal (upcase char) "U") t nil
10503 (org-insert-time-stamp time org-time-was-given
10511 (org-mode)
10512 (org-set-local 'org-finish-function 'remember-buffer)))
10515 (defun org-remember ()
10520 (if (eq org-finish-function 'remember-buffer)
10522 (when (< (length org-remember-templates) 2)
10525 (let ((annotation (plist-get org-store-link-plist :annotation))
10526 (initial (plist-get org-store-link-plist :initial)))
10527 (org-remember-apply-template))
10529 (if (org-region-active-p)
10534 (defun org-remember-handler ()
10535 "Store stuff from remember.el into an org file.
10536 First prompts for an org file. If the user just presses return, the value
10537 of `org-default-notes-file' is used.
10562 If the variable `org-adapt-indentation' is non-nil, the entire text is
10566 See also the variable `org-reverse-note-order'."
10573 (file (if fastp org-default-notes-file (org-get-org-file)))
10574 (heading org-remember-default-headline)
10575 (visiting (org-find-base-buffer-visiting file))
10576 (org-startup-folded nil)
10577 (org-startup-align-all-tables nil)
10578 (org-goto-start-pos 1)
10581 ;; into an org tree.
10593 (if (and org-adapt-indentation indent)
10603 (setq reversed (org-notes-order-reversed-p))
10615 (setq org-goto-start-pos (match-beginning 0))))
10619 org-goto-start-pos
10620 (org-get-location (current-buffer) org-remember-help)))
10630 (org-paste-subtree (org-get-legal-level 1 1) txt)))
10638 (org-paste-subtree 1 txt)))
10639 ((and (org-on-heading-p nil) (not current-prefix-arg))
10641 (org-back-to-heading t)
10645 (org-end-of-subtree t))
10648 (org-paste-subtree (org-get-legal-level level 1) txt))
10651 ;; org-paste-subtree or from prefix arg
10652 (org-paste-subtree current-prefix-arg txt)))
10658 (defun org-get-org-file ()
10659 "Read a filename, with default directory `org-directory'."
10660 (let ((default (or org-default-notes-file remember-data-file)))
10662 (file-name-as-directory org-directory)
10665 (defun org-notes-order-reversed-p ()
10668 ((not org-reverse-note-order) nil)
10669 ((eq t org-reverse-note-order) t)
10670 ((not (listp org-reverse-note-order)) nil)
10672 (let ((all org-reverse-note-order)
10674 (while (setq entry (pop all))
10681 (defun org-find-dblock (name)
10693 (defconst org-dblock-start-re
10697 (defconst org-dblock-end-re "^#\\+END\\([: \t\r\n]\\|$\\)"
10700 (defun org-create-dblock (plist)
10713 (defun org-prepare-dblock ()
10717 (unless (looking-at org-dblock-start-re)
10723 (unless (re-search-forward org-dblock-end-re nil t)
10730 (defun org-map-dblocks (&optional command)
10731 "Apply COMMAND to all dynamic blocks in the current buffer.
10732 If COMMAND is not given, use `org-update-dblock'."
10733 (let ((cmd (or command 'org-update-dblock))
10737 (while (re-search-forward org-dblock-start-re nil t)
10743 (unless (re-search-forward org-dblock-end-re nil t)
10746 (defun org-dblock-update (&optional arg)
10748 Update the dynamic block at point. With prefix ARG, update all dynamic
10752 (org-update-all-dblocks)
10753 (or (looking-at org-dblock-start-re)
10754 (org-beginning-of-dblock))
10755 (org-update-dblock)))
10757 (defun org-update-dblock ()
10762 (params (org-prepare-dblock))
10764 (cmd (intern (concat "org-dblock-write:" name))))
10768 (defun org-beginning-of-dblock ()
10774 (if (and (re-search-backward org-dblock-start-re nil t)
10776 (re-search-forward org-dblock-end-re nil t)
10782 (defun org-update-all-dblocks ()
10783 "Update all dynamic blocks in the buffer.
10785 (when (org-mode-p)
10786 (org-map-dblocks 'org-update-dblock)))
10791 (defun org-complete (&optional arg)
10794 `org-todo-keywords'.
10800 At all other locations, this simply calls `ispell-complete-word'."
10829 (org-split-string (org-get-current-options) "\n")))
10832 org-startup-options)
10833 (link (append org-link-abbrev-alist-local
10834 org-link-abbrev-alist))
10837 org-html-entities)
10841 (mapcar 'list org-todo-keywords))
10846 (while (re-search-forward org-todo-line-regexp nil t)
10848 (org-make-org-heading-search-string
10853 (or org-tag-alist (org-get-buffer-tags)))
10877 "Press \\[org-complete] again to insert example settings"))))
10880 (let ((list (sort (all-completions pattern table confirm)
10891 (defun org-toggle-comment ()
10895 (org-back-to-heading)
10897 "\\( +\\<" org-comment-string "\\>\\)"))
10902 (insert " " org-comment-string))))))
10904 (defvar org-last-todo-state-is-todo nil
10909 (defun org-todo (&optional arg)
10916 The different keywords are specified in the variable `org-todo-keywords'.
10930 really is a member of `org-todo-keywords'."
10933 (org-back-to-heading)
10935 (or (looking-at (concat " +" org-todo-regexp " *"))
10940 (member (member this org-todo-keywords))
10946 org-todo-keywords)
10951 (car org-todo-keywords)))
10953 (if (equal member org-todo-keywords)
10956 (nth (- (length org-todo-keywords) (length tail) 2)
10957 org-todo-keywords)
10958 org-done-string)))
10964 ((eq arg 'done) (org-last org-todo-keywords))
10965 ((car (member arg org-todo-keywords)))
10967 org-todo-keywords))))
10968 ((null member) (car org-todo-keywords))
10970 ((eq org-todo-interpretation 'sequence)
10972 ((memq org-todo-interpretation '(type priority))
10975 (if (> (length tail) 0) org-done-string nil)))
10980 (setq org-last-todo-state-is-todo
10981 (not (equal state org-done-string)))
10982 (when org-log-done
10983 (setq dostates (and (eq org-todo-interpretation 'sequence)
10984 (listp org-log-done) (memq 'state org-log-done)))
10987 (org-add-planning-info nil nil 'closed)
10988 (and dostates (org-add-log-maybe 'state state 'findpos)))
10990 (org-add-log-maybe 'state state 'findpos))
10991 ((equal state org-done-string)
10993 (org-add-planning-info 'closed (org-current-time)
10994 (if (org-get-repeat) nil 'scheduled))
10995 (org-add-log-maybe 'done state 'findpos))))
10997 (and org-auto-align-tags (org-set-tags nil t))
10998 (run-hooks 'org-after-todo-state-change-hook)
10999 (and (equal state org-done-string) (org-auto-repeat-maybe))
11005 (looking-at org-todo-line-regexp))
11011 (defun org-get-repeat ()
11015 (org-back-to-heading t)
11017 org-repeat-re (save-excursion (outline-next-heading) (point)) t)
11020 (defvar org-last-changed-timestamp)
11021 (defvar org-log-post-message)
11022 (defun org-auto-repeat-maybe ()
11026 This function should be run in the `org-after-todo-state-change-hook'."
11028 (let ((repeat (org-get-repeat))
11031 (org-log-done)
11034 (org-todo (if (eq 'org-todo-interpretation 'type)
11036 (car org-todo-keywords)))
11037 (unless (memq 'org-add-log-note (default-value 'post-command-hook))
11039 (let ((org-log-done '(done)))
11040 (org-add-log-maybe 'done org-done-string 'findpos)))
11041 (org-back-to-heading t)
11042 (org-add-planning-info nil nil 'closed)
11043 (setq re (concat "\\(" org-scheduled-time-regexp "\\)\\|\\("
11044 org-deadline-time-regexp "\\)"))
11047 (setq type (if (match-end 1) org-scheduled-string org-deadline-string)
11054 (org-timestamp-change n (cdr (assoc what whata))))
11055 (setq msg (concat msg type org-last-changed-timestamp " ")))
11056 (setq org-log-post-message msg)
11059 (defun org-show-todo-tree (arg)
11060 "Make a compact tree which shows all headlines marked with TODO.
11061 The tree will show the lines where the regexp matches, and all higher
11065 of `org-todo-keywords'."
11069 (cond ((null arg) org-not-done-regexp)
11070 ((equal arg '(4)) org-todo-regexp)
11071 ((<= (prefix-numeric-value arg) (length org-todo-keywords))
11073 org-todo-keywords)))
11076 (org-occur (concat "^" outline-regexp " +" kwd-re )))))
11078 (defun org-deadline ()
11080 A timestamp is also inserted - use \\[org-timestamp-up] and \\[org-timestamp-down]
11083 (org-add-planning-info 'deadline nil 'closed))
11085 (defun org-schedule ()
11087 A timestamp is also inserted - use \\[org-timestamp-up] and \\[org-timestamp-down]
11090 (org-add-planning-info 'scheduled nil 'closed))
11092 (defun org-add-planning-info (what &optional time &rest remove)
11099 (let (org-time-was-given)
11100 (when what (setq time (or time (org-read-date nil 'to-time))))
11101 (when (and org-insert-labeled-timestamps-at-point
11104 (if (eq what 'scheduled) org-scheduled-string org-deadline-string) " ")
11105 (org-insert-time-stamp time org-time-was-given)
11110 (org-back-to-heading t)
11116 (looking-at (concat "[^\r\n]*?" org-keyword-time-regexp
11118 (not (equal (match-string 1) org-clock-string)))
11130 (re-search-forward org-scheduled-time-regexp nil t))
11132 (re-search-forward org-deadline-time-regexp nil t))
11134 (re-search-forward org-closed-time-regexp nil t)))
11142 (cond ((eq what 'scheduled) org-scheduled-string)
11143 ((eq what 'deadline) org-deadline-string)
11144 ((eq what 'closed) org-closed-string))
11146 (org-insert-time-stamp time
11147 (or org-time-was-given (eq what 'closed))
11156 (defvar org-log-note-marker (make-marker))
11157 (defvar org-log-note-purpose nil)
11158 (defvar org-log-note-state nil)
11159 (defvar org-log-note-window-configuration nil)
11160 (defvar org-log-note-return-to (make-marker))
11161 (defvar org-log-post-message nil
11165 (defun org-add-log-maybe (&optional purpose state findpos)
11167 (when (and (listp org-log-done)
11168 (memq purpose org-log-done))
11170 (org-back-to-heading t)
11172 "\\(\n[^\r\n]*?" org-keyword-time-not-clock-regexp
11175 (move-marker org-log-note-marker (point))
11176 (setq org-log-note-purpose purpose)
11177 (setq org-log-note-state state)
11178 (add-hook 'post-command-hook 'org-add-log-note 'append))))
11180 (defun org-add-log-note (&optional purpose)
11182 (remove-hook 'post-command-hook 'org-add-log-note)
11183 (setq org-log-note-window-configuration (current-window-configuration))
11185 (move-marker org-log-note-return-to (point))
11186 (switch-to-buffer (marker-buffer org-log-note-marker))
11187 (goto-char org-log-note-marker)
11190 (let ((org-inhibit-startup t)) (org-mode))
11193 ((eq org-log-note-purpose 'clock-out) "stopped clock")
11194 ((eq org-log-note-purpose 'done) "closed todo item")
11195 ((eq org-log-note-purpose 'state) "state change")
11197 (org-set-local 'org-finish-function 'org-store-log-note))
11199 (defun org-store-log-note ()
11202 (note (cdr (assq org-log-note-purpose org-log-note-headings)))
11209 (setq lines (org-split-string txt "\n"))
11212 (org-replace-escapes
11217 (org-time-stamp-format 'long 'inactive)
11219 (cons "%s" (if org-log-note-state
11220 (concat "\"" org-log-note-state "\"")
11225 (set-buffer (marker-buffer org-log-note-marker))
11227 (goto-char org-log-note-marker)
11228 (move-marker org-log-note-marker nil)
11235 (set-window-configuration org-log-note-window-configuration)
11236 (with-current-buffer (marker-buffer org-log-note-return-to)
11237 (goto-char org-log-note-return-to))
11238 (move-marker org-log-note-return-to nil)
11239 (and org-log-post-message (message org-log-post-message)))
11241 (defvar org-occur-highlights nil)
11242 (make-variable-buffer-local 'org-occur-highlights)
11244 (defun org-occur (regexp &optional keep-previous callback)
11245 "Make a compact tree which shows all matches of REGEXP.
11246 The tree will show the lines where the regexp matches, and all higher
11250 call to `org-occur' will be kept, to allow stacking of calls to this
11255 (or keep-previous (org-remove-occur-highlights nil nil t))
11260 (not org-occur-highlights)) ; no previous matches
11262 (org-overview))
11267 (org-highlight-new-match (match-beginning 0) (match-end 0))
11268 (org-show-context 'occur-tree))))
11269 (when org-remove-highlights-with-change
11270 (org-add-hook 'before-change-functions 'org-remove-occur-highlights
11272 (unless org-sparse-tree-open-archived-trees
11273 (org-hide-archived-subtrees (point-min) (point-max)))
11274 (run-hooks 'org-occur-hook)
11279 (defun org-show-context (&optional key)
11282 `org-show-hierarchy-above', `org-show-following-heading'. and
11283 `org-show-siblings'."
11284 (let ((heading-p (org-on-heading-p t))
11285 (hierarchy-p (org-get-alist-option org-show-hierarchy-above key))
11286 (following-p (org-get-alist-option org-show-following-heading key))
11287 (siblings-p (org-get-alist-option org-show-siblings key)))
11291 (org-flag-heading nil) ; only show the heading
11292 (and (or (org-invisible-p) (org-invisible-p2))
11293 (org-show-hidden-entry))) ; show entire entry
11297 (and (if heading-p (org-goto-sibling) (outline-next-heading))
11298 (org-flag-heading nil))))
11299 (when siblings-p (org-show-siblings))
11301 ;; show all higher headings, possibly with siblings
11304 (progn (org-up-heading-all 1) t)
11307 (org-flag-heading nil)
11308 (when siblings-p (org-show-siblings))))))))
11310 (defun org-reveal (&optional siblings)
11313 exposed with `org-show-hierarchy-above' or `org-show-following-heading'
11316 With optional argument SIBLINGS, on each level of the hierarchy all
11318 look like when opened with hierarchical calls to `org-cycle'."
11320 (let ((org-show-hierarchy-above t)
11321 (org-show-following-heading t)
11322 (org-show-siblings (if siblings t org-show-siblings)))
11323 (org-show-context nil)))
11325 (defun org-highlight-new-match (beg end)
11327 (let ((ov (org-make-overlay beg end)))
11328 (org-overlay-put ov 'face 'secondary-selection)
11329 (push ov org-occur-highlights)))
11331 (defun org-remove-occur-highlights (&optional beg end noremove)
11336 (unless org-inhibit-highlight-removal
11337 (mapc 'org-delete-overlay org-occur-highlights)
11338 (setq org-occur-highlights nil)
11341 'org-remove-occur-highlights 'local))))
11345 (defvar org-priority-regexp ".*?\\(\\[#\\([A-Z]\\)\\] ?\\)"
11348 (defvar org-remove-priority-next-time nil)
11350 (defun org-priority-up ()
11353 (org-priority 'up))
11355 (defun org-priority-down ()
11358 (org-priority 'down))
11360 (defun org-priority (&optional action)
11367 (org-back-to-heading)
11368 (if (looking-at org-priority-regexp)
11371 (setq current org-default-priority))
11374 (message "Priority A-%c, SPC to remove: " org-lowest-priority)
11377 ((or (< (upcase new) ?A) (> (upcase new) org-lowest-priority))
11379 ?A org-lowest-priority))))
11385 (setq new (min (max ?A (upcase new)) org-lowest-priority))
11393 (looking-at org-todo-line-regexp)
11405 (defun org-get-priority (s)
11408 (if (not (string-match org-priority-regexp s))
11409 (* 1000 (- org-lowest-priority org-default-priority))
11410 (* 1000 (- org-lowest-priority
11415 (defun org-scan-tags (action matcher &optional todo-only)
11417 ACTION can be `sparse-tree' or `agenda'. MATCHER is a Lisp form to be
11423 (nreverse (cdr (reverse org-todo-keywords)))
11427 'done-face 'org-done
11430 'org-not-done-regexp org-not-done-regexp
11431 'keymap org-agenda-keymap
11433 (format "mouse-2 or RET jump to org file %s"
11441 (when (eq action 'sparse-tree) (org-overview))
11448 category (org-get-category))
11457 (setq tags (mapcar 'downcase (org-split-string tags ":"))
11462 (if org-use-tag-inheritance
11467 (or (not org-agenda-skip-archived-trees)
11468 (not (member org-archive-tag tags-list))))
11469 (and (eq action 'agenda) (org-agenda-skip))
11473 (org-show-context 'tags-tree))
11474 (setq txt (org-format-agenda-item
11477 (if org-tags-match-list-sublevels
11479 (org-get-heading))
11482 (setq marker (org-agenda-new-marker))
11483 (org-add-props txt props
11484 'org-marker marker 'org-hd-marker marker 'org-category category)
11487 (or org-tags-match-list-sublevels (org-end-of-subtree t))))))
11489 (not org-sparse-tree-open-archived-trees))
11490 (org-hide-archived-subtrees (point-min) (point-max)))
11495 (defun org-tags-sparse-tree (&optional todo-only match)
11502 (org-scan-tags 'sparse-tree (cdr (org-make-tags-matcher match)) todo-only))
11504 (defun org-make-tags-matcher (match)
11510 (setq org-last-tags-completion-table
11511 (or org-tag-alist
11512 org-last-tags-completion-table))
11514 "Match: " 'org-tags-completion-function nil nil nil
11515 'org-tags-history)))
11538 (setq orterms (org-split-string tagsmatch "|") orlist nil)
11549 (re-p `(org-match-any-p ,(substring tag 1 -1) tags-list))
11566 (setq orterms (org-split-string todomatch "|") orlist nil)
11593 (defun org-match-any-p (re list)
11598 (defvar org-add-colon-after-tag-completion nil) ;; dynamically skoped param
11599 (defvar org-tags-overlay (org-make-overlay 1 1))
11600 (org-detach-overlay org-tags-overlay)
11602 (defun org-set-tags (&optional arg just-align)
11604 With prefix ARG, realign all tags in headings in the current buffer."
11607 (current (org-get-tags))
11615 (org-set-tags nil t)
11617 (message "All tags realigned to column %d" org-tags-column))
11622 (setq table (or org-tag-alist (org-get-buffer-tags))
11623 org-last-tags-completion-table table
11624 current-tags (org-split-string current ":")
11627 (nreverse (org-get-tags-at))))
11629 (if (or (eq t org-use-fast-tag-selection)
11630 (and org-use-fast-tag-selection
11632 (org-fast-tag-selection current-tags inherited-tags table)
11633 (let ((org-add-colon-after-tag-completion t))
11634 (org-trim
11635 (completing-read "Tags: " 'org-tags-completion-function
11636 nil nil current 'org-tags-history))))))
11655 c1 (max (1+ c0) (if (> org-tags-column 0)
11656 org-tags-column
11657 (- (- org-tags-column) (length tags))))
11664 (defun org-tags-completion-function (string predicate &optional flag)
11665 (let (s1 s2 rtn (ctable org-last-tags-completion-table)
11677 (if (and org-add-colon-after-tag-completion
11682 ;; all-completions
11683 (all-completions s2 ctable confirm)
11690 (defun org-fast-tag-insert (kwd tags face &optional end)
11693 (org-add-props (mapconcat 'identity tags " ") nil 'face face)
11696 (defun org-fast-tag-show-exit (flag)
11704 (insert (org-add-props " Next change exits" nil 'face 'org-warning)))))
11706 (defun org-set-current-tags-overlay (current prefix)
11709 (org-overlay-display org-tags-overlay (concat prefix s)
11711 (put-text-property 0 (length s) 'face '(secondary-selection org-tag) s)
11712 (org-overlay-display org-tags-overlay (concat prefix s)))))
11714 (defun org-fast-tag-selection (current inherited table)
11726 (expert (eq org-fast-tag-selection-single-key 'expert))
11730 (i-face 'org-done)
11731 (c-face 'org-tag)
11734 (exit-after-next org-fast-tag-selection-single-key)
11748 (if (> (current-column) org-tags-column)
11750 (make-string (- org-tags-column (current-column)) ?\ ))))))
11751 (org-move-overlay org-tags-overlay ov-start ov-end)
11759 (org-fast-tag-insert "Inherited" inherited i-face "\n")
11760 (org-fast-tag-insert "Current" current c-face "\n\n")
11761 (org-fast-tag-show-exit exit-after-next)
11762 (org-set-current-tags-overlay current ov-prefix)
11789 (setq tg (org-add-props tg nil 'face
11822 (org-fast-tag-show-exit
11832 (org-detach-overlay org-tags-overlay)
11843 (org-get-buffer-tags)))))
11871 (org-fast-tag-insert "Current" current c-face)
11872 (org-set-current-tags-overlay current ov-prefix)
11882 (org-detach-overlay org-tags-overlay)
11887 (defun org-get-tags ()
11889 (unless (org-on-heading-p t)
11894 (org-match-string-no-properties 1)
11897 (defun org-get-buffer-tags ()
11898 "Get a table of all tags used in the buffer, for completion."
11904 (org-split-string (org-match-string-no-properties 1) ":"))))
11909 (defvar org-last-changed-timestamp nil)
11910 (defvar org-time-was-given) ; dynamically scoped parameter
11911 (defvar org-ts-what) ; dynamically scoped parameter
11913 (defun org-time-stamp (arg)
11923 (let (org-time-was-given time)
11925 ((and (org-at-timestamp-p)
11926 (eq last-command 'org-time-stamp)
11927 (eq this-command 'org-time-stamp))
11930 (org-read-date arg 'totime)))
11931 (org-insert-time-stamp time (or org-time-was-given arg)))
11932 ((org-at-timestamp-p)
11934 (org-read-date arg 'totime)))
11935 (when (org-at-timestamp-p) ; just to get the match data
11937 (setq org-last-changed-timestamp
11938 (org-insert-time-stamp time (or org-time-was-given arg))))
11942 (org-read-date arg 'totime)))
11943 (org-insert-time-stamp time (or org-time-was-given arg))))))
11945 (defun org-time-stamp-inactive (&optional arg)
11948 brackets. It is inactive in the sense that it does not trigger agenda entries,
11952 (let (org-time-was-given time)
11953 (setq time (org-read-date arg 'totime))
11954 (org-insert-time-stamp time (or org-time-was-given arg) 'inactive)))
11956 (defvar org-date-ovl (org-make-overlay 1 1))
11957 (org-overlay-put org-date-ovl 'face 'org-warning)
11958 (org-detach-overlay org-date-ovl)
11960 (defvar org-ans1) ; dynamically scoped parameter
11961 (defvar org-ans2) ; dynamically scoped parameter
11963 (defun org-read-date (&optional with-time to-time from-string prompt)
11986 \(setq org-popup-calendar-for-date-prompt nil)
11996 (let* ((org-time-stamp-rounding-minutes
11997 (if (equal with-time '(16)) 0 org-time-stamp-rounding-minutes))
11998 (ct (org-current-time))
12004 (concat org-ts-regexp "--?-?\\=") ; 1-3 minuses
12018 ans (org-ans0 "") org-ans1 org-ans2 (deltadays 0)
12023 (org-popup-calendar-for-date-prompt
12030 (org-eval-in-calendar nil)
12034 (define-key map (kbd "RET") 'org-calendar-select)
12036 'org-calendar-select-mouse)
12038 'org-calendar-select-mouse)
12041 (org-eval-in-calendar '(calendar-backward-month 1))))
12044 (org-eval-in-calendar '(calendar-forward-month 1))))
12047 (org-eval-in-calendar '(calendar-backward-week 1))))
12050 (org-eval-in-calendar '(calendar-forward-week 1))))
12053 (org-eval-in-calendar '(calendar-backward-day 1))))
12056 (org-eval-in-calendar '(calendar-forward-day 1))))
12059 (org-eval-in-calendar '(scroll-calendar-left 1))))
12062 (org-eval-in-calendar '(scroll-calendar-right 1))))
12066 (setq org-ans0 (read-string prompt "" nil nil))
12067 ; (if (not (string-match "\\S-" org-ans0)) (setq org-ans0 nil))
12068 ;; org-ans0: from prompt
12069 ;; org-ans1: from mouse click
12070 ;; org-ans2: from calendar motion
12071 (setq ans (concat org-ans0 " " (or org-ans1 org-ans2))))
12075 (org-detach-overlay org-date-ovl)
12077 (if (string-match "^[ \t]*[-+][0-9]+[ \t]*$" org-ans0)
12106 (if (and (boundp 'org-time-was-given)
12108 (setq org-time-was-given t))
12116 (defun org-eval-in-calendar (form)
12118 Also, store the cursor date in variable org-ans2."
12125 (setq org-ans2 (format-time-string "%Y-%m-%d" time))))
12126 (org-move-overlay org-date-ovl (1- (point)) (1+ (point)) (current-buffer))
12129 (defun org-calendar-select ()
12130 "Return to `org-read-date' with the date currently selected.
12131 This is used by `org-read-date' in a temporary keymap for the calendar buffer."
12136 (setq org-ans1 (format-time-string "%Y-%m-%d" time)))
12139 (defun org-insert-time-stamp (time &optional with-hm inactive pre post)
12143 stamp will not contribute to the agenda.
12147 (let ((fmt (funcall (if with-hm 'cdr 'car) org-time-stamp-formats))
12155 (defun org-toggle-time-stamp-overlays ()
12158 (setq org-display-custom-times (not org-display-custom-times))
12159 (unless org-display-custom-times
12163 (eq (get-text-property p 'face) 'org-date))
12170 (org-restart-font-lock)
12171 (setq org-table-may-need-update t)
12172 (if org-display-custom-times
12176 (defun org-display-custom-time (beg end)
12179 (org-parse-time-string (buffer-substring beg end) t)))
12182 (tf (funcall (if with-hm 'cdr 'car) org-time-stamp-custom-formats))
12183 (time (org-fix-decoded-time t1))
12184 (str (org-add-props
12191 (list 'org-dwidth t 'org-dwidth-n (- w1 w2))))
12198 (defun org-translate-time (string)
12199 "Translate all timestamps in STRING to custom format.
12200 But do this only if the variable `org-display-custom-times' is set."
12201 (when org-display-custom-times
12204 (re org-ts-regexp-both)
12210 (org-parse-time-string (substring string beg end) t))
12214 org-time-stamp-custom-formats)
12215 time (org-fix-decoded-time t1)
12225 (defun org-fix-decoded-time (time)
12231 (defun org-days-to-time (timestamp-string)
12233 (- (time-to-days (org-time-string-to-time timestamp-string))
12236 (defun org-deadline-close (timestamp-string &optional ndays)
12238 (and (< (org-days-to-time timestamp-string)
12239 (or ndays org-deadline-warning-days))
12240 (not (org-entry-is-done-p))))
12242 (defun org-calendar-select-mouse (ev)
12243 "Return to `org-read-date' with the date currently selected.
12244 This is used by `org-read-date' in a temporary keymap for the calendar buffer."
12250 (setq org-ans1 (format-time-string "%Y-%m-%d" time)))
12253 (defun org-check-deadlines (ndays)
12255 A deadline is considered due if it happens within `org-deadline-warning-days'
12258 days. If the prefix is a raw \\[universal-argument] prefix, all deadlines are shown."
12260 (let* ((org-warn-days
12264 (t org-deadline-warning-days)))
12266 (regexp (concat "\\<" org-deadline-string " *<\\([^>]+\\)>"))
12268 (lambda () (org-deadline-close (match-string 1) org-warn-days))))
12271 (org-occur regexp nil callback)
12272 org-warn-days)))
12274 (defun org-evaluate-time-range (&optional to-buffer)
12284 (org-clock-update-time-maybe)
12286 (unless (org-at-date-range-p)
12288 (re-search-forward org-tr-regexp (point-at-eol) t))
12289 (if (not (org-at-date-range-p))
12295 (time1 (org-time-string-to-time ts1))
12296 (time2 (org-time-string-to-time ts2))
12321 (message (org-make-tdiff-string y d h m))
12322 (when (org-at-table-p)
12333 (if align (org-table-align))
12336 (defun org-make-tdiff-string (y d h m)
12349 (defun org-time-string-to-time (s)
12350 (apply 'encode-time (org-parse-time-string s)))
12352 (defun org-parse-time-string (s &optional nodefault)
12357 (if (string-match org-ts-regexp1 s)
12369 (defun org-timestamp-up (&optional arg)
12375 (org-timestamp-change (prefix-numeric-value arg)))
12377 (defun org-timestamp-down (&optional arg)
12383 (org-timestamp-change (- (prefix-numeric-value arg))))
12385 (defun org-timestamp-up-day (&optional arg)
12389 (if (and (not (org-at-timestamp-p t))
12390 (org-on-heading-p))
12391 (org-todo 'up)
12392 (org-timestamp-change (prefix-numeric-value arg) 'day)))
12394 (defun org-timestamp-down-day (&optional arg)
12398 (if (and (not (org-at-timestamp-p t))
12399 (org-on-heading-p))
12400 (org-todo 'down)
12401 (org-timestamp-change (- (prefix-numeric-value arg)) 'day)))
12403 (defsubst org-pos-in-match-range (pos n)
12408 (defun org-at-timestamp-p (&optional inactive-ok)
12411 (let* ((tsr (if inactive-ok org-ts-regexp3 org-ts-regexp2))
12419 (and (boundp 'org-ts-what)
12420 (setq org-ts-what
12422 ((org-pos-in-match-range pos 2) 'year)
12423 ((org-pos-in-match-range pos 3) 'month)
12424 ((org-pos-in-match-range pos 7) 'hour)
12425 ((org-pos-in-match-range pos 8) 'minute)
12426 ((or (org-pos-in-match-range pos 4)
12427 (org-pos-in-match-range pos 5)) 'day)
12431 (defun org-timestamp-change (n &optional what)
12438 org-ts-what
12440 (if (not (org-at-timestamp-p t))
12442 (if (and (not what) (not (eq org-ts-what 'day))
12443 org-display-custom-times
12446 (setq org-ts-what 'day))
12447 (setq org-ts-what (or what org-ts-what)
12448 with-hm (<= (abs (- (cdr org-ts-lengths)
12454 (setq time0 (org-parse-time-string ts))
12459 (list (+ (if (eq org-ts-what 'minute) n 0) (nth 1 time0)))
12460 (list (+ (if (eq org-ts-what 'hour) n 0) (nth 2 time0)))
12461 (list (+ (if (eq org-ts-what 'day) n 0) (nth 3 time0)))
12462 (list (+ (if (eq org-ts-what 'month) n 0) (nth 4 time0)))
12463 (list (+ (if (eq org-ts-what 'year) n 0) (nth 5 time0)))
12478 (setq org-last-changed-timestamp
12479 (org-insert-time-stamp time with-hm inactive))
12480 (org-clock-update-time-maybe)
12483 (if (and org-calendar-follow-timestamp-change
12485 (memq org-ts-what '(day month year)))
12486 (org-recenter-calendar (time-to-days time)))))
12488 (defun org-recenter-calendar (date)
12499 (defun org-goto-calendar (&optional arg)
12504 (let ((tsr org-ts-regexp) diff
12508 (if (or (org-at-timestamp-p)
12514 (org-time-string-to-time (match-string 1)))))
12520 (defun org-date-from-calendar ()
12524 (org-timestamp-change 0 'calendar))
12528 (defvar org-clock-marker (make-marker)
12531 (defun org-clock-in ()
12535 (org-clock-out t)
12538 (org-back-to-heading t)
12540 (when (and (looking-at (concat "[ \t]*" org-keyword-time-regexp))
12541 (not (equal (match-string 1) org-clock-string)))
12547 (insert org-clock-string " ")
12548 (setq ts (org-insert-time-stamp (current-time) 'with-hm 'inactive))
12549 (move-marker org-clock-marker (point) (buffer-base-buffer))
12552 (defun org-clock-out (&optional fail-quietly)
12557 (if (not (marker-buffer org-clock-marker))
12561 (set-buffer (marker-buffer org-clock-marker))
12562 (goto-char org-clock-marker)
12564 (if (and (looking-at (concat "[ \t]*" org-keyword-time-regexp))
12565 (equal (match-string 1) org-clock-string))
12568 (goto-char org-clock-marker)
12570 (setq te (org-insert-time-stamp (current-time) 'with-hm 'inactive))
12571 (setq s (- (time-to-seconds (apply 'encode-time (org-parse-time-string te)))
12572 (time-to-seconds (apply 'encode-time (org-parse-time-string ts))))
12578 (move-marker org-clock-marker nil)
12579 (org-add-log-maybe 'clock-out)
12582 (defun org-clock-cancel ()
12585 (if (not (marker-buffer org-clock-marker))
12588 (set-buffer (marker-buffer org-clock-marker))
12589 (goto-char org-clock-marker)
12593 (defvar org-clock-file-total-minutes nil
12594 "Holds the file total time in minutes, after a call to `org-clock-sum'.")
12595 (make-variable-buffer-local 'org-clock-file-total-minutes)
12597 (defun org-clock-sum (&optional tstart tend)
12603 org-clock-string
12611 (remove-text-properties (point-min) (point-max) '(:org-clock-minutes t))
12620 (apply 'encode-time (org-parse-time-string ts)))
12622 (apply 'encode-time (org-parse-time-string te)))
12636 (put-text-property (point) (point-at-eol) :org-clock-minutes time))))
12637 (setq org-clock-file-total-minutes (aref ltimes 0)))
12640 (defun org-clock-display (&optional total-only)
12645 (org-remove-clock-overlays)
12647 (org-clock-sum)
12651 (while (setq p (next-single-property-change (point) :org-clock-minutes))
12653 (when (setq time (get-text-property p :org-clock-minutes))
12654 (org-put-clock-overlay time (funcall outline-level))))
12655 (setq h (/ org-clock-file-total-minutes 60)
12656 m (- org-clock-file-total-minutes (* 60 h)))
12658 (when org-remove-highlights-with-change
12659 (org-add-hook 'before-change-functions 'org-remove-clock-overlays
12663 (defvar org-clock-overlays nil)
12664 (make-variable-buffer-local 'org-clock-overlays)
12666 (defun org-put-clock-overlay (time &optional level)
12669 This creates a new overlay and stores it in `org-clock-overlays', so that it
12672 (l (if level (org-get-legal-level level 0) 0))
12678 (setq ov (org-make-overlay (1- (point)) (point-at-eol))
12681 (org-add-props (format "%s %2d:%02d%s"
12687 (org-overlay-put ov 'display tx)
12688 (org-overlay-put ov 'invisible t)
12689 (org-overlay-put ov 'end-glyph (make-glyph tx)))
12690 (push ov org-clock-overlays)))
12692 (defun org-remove-clock-overlays (&optional beg end noremove)
12697 (unless org-inhibit-highlight-removal
12698 (mapc 'org-delete-overlay org-clock-overlays)
12699 (setq org-clock-overlays nil)
12702 'org-remove-clock-overlays 'local))))
12704 (defun org-clock-out-if-current ()
12707 (when (and (equal state org-done-string)
12708 (equal (marker-buffer org-clock-marker) (current-buffer))
12709 (< (point) org-clock-marker)
12711 org-clock-marker))
12713 (let ((org-log-done (if (and (listp org-log-done)
12714 (member 'clock-out org-log-done))
12716 org-log-done)))
12717 (org-clock-out))))
12719 (add-hook 'org-after-todo-state-change-hook
12720 'org-clock-out-if-current)
12722 (defun org-check-running-clock ()
12725 (when (and (equal (marker-buffer org-clock-marker) (current-buffer))
12728 (org-clock-out)
12732 (defun org-clock-report ()
12745 (org-remove-clock-overlays)
12746 (unless (org-find-dblock "clocktable")
12747 (org-create-dblock (list :name "clocktable"
12749 (org-update-dblock))
12751 (defun org-clock-update-time-maybe ()
12758 (when (looking-at org-clock-string)
12759 (let ((re (concat "[ \t]*" org-clock-string
12770 (apply 'encode-time (org-parse-time-string te)))
12772 (apply 'encode-time (org-parse-time-string ts))))
12780 (defun org-clock-special-range (key &optional time as-strings)
12817 (setq fm (cdr org-time-stamp-formats))
12822 (defun org-dblock-write:clocktable (params)
12835 (setq cc (org-clock-special-range block nil t)
12838 (apply 'encode-time (org-parse-time-string ts)))))
12840 (apply 'encode-time (org-parse-time-string te)))))
12845 (format-time-string (cdr org-time-stamp-formats))
12852 (org-clock-sum ts te)
12853 (setq h (/ org-clock-file-total-minutes 60)
12854 m (- org-clock-file-total-minutes (* 60 h)))
12859 (while (setq p (next-single-property-change (point) :org-clock-minutes))
12861 (when (setq time (get-text-property p :org-clock-minutes))
12884 (org-table-align)))
12887 (defun org-collect-clock-time-entries ()
12892 (let ((re (concat "^[ \t]*" org-clock-string
12897 (org-clock-sum)
12903 (setq beg (apply 'encode-time (org-parse-time-string beg))
12904 end (apply 'encode-time (org-parse-time-string end)))
12905 (org-back-to-heading t)
12906 (setq donep (org-entry-is-done-p))
12908 total (or (get-text-property (1+ (point)) :org-clock-minutes) 0)
12913 title (org-match-string-no-properties 2))
12915 (setq closedp (re-search-forward org-closed-time-regexp next t))
12927 ;;; Define the Org-agenda-mode
12929 (defvar org-agenda-mode-map (make-sparse-keymap)
12930 "Keymap for `org-agenda-mode'.")
12932 (defvar org-agenda-menu) ; defined later in this file.
12933 (defvar org-agenda-follow-mode nil)
12934 (defvar org-agenda-show-log nil)
12935 (defvar org-agenda-redo-command nil)
12936 (defvar org-agenda-mode-hook nil)
12937 (defvar org-agenda-type nil)
12938 (defvar org-agenda-force-single-file nil)
12940 (defun org-agenda-mode ()
12941 "Mode for time-sorted view on action items in Org-mode files.
12945 \\{org-agenda-mode-map}"
12947 (kill-all-local-variables)
12948 (setq org-agenda-undo-list nil
12949 org-agenda-pending-undo-list nil)
12950 (setq major-mode 'org-agenda-mode)
12952 (org-set-local 'font-lock-global-modes (list 'not major-mode))
12954 (use-local-map org-agenda-mode-map)
12955 (easy-menu-add org-agenda-menu)
12956 (if org-startup-truncated (setq truncate-lines t))
12957 (org-add-hook 'post-command-hook 'org-agenda-post-command-hook nil 'local)
12958 (org-add-hook 'pre-command-hook 'org-unhighlight nil 'local)
12961 (org-set-local 'buffer-substring-filters
12965 (unless org-agenda-keep-modes
12966 (setq org-agenda-follow-mode org-agenda-start-with-follow-mode
12967 org-agenda-show-log nil))
12973 (if (get 'org-agenda-files 'org-restrict)
12976 '(org-edit-agenda-file-list)
12977 (not (get 'org-agenda-files 'org-restrict)))
12979 (mapcar 'org-file-menu-entry (org-agenda-files))))
12980 (org-agenda-set-mode-name)
12983 (list 'org-agenda-mode-hook)))
12985 (substitute-key-definition 'undo 'org-agenda-undo
12986 org-agenda-mode-map global-map)
12987 (define-key org-agenda-mode-map "\C-i" 'org-agenda-goto)
12988 (define-key org-agenda-mode-map [(tab)] 'org-agenda-goto)
12989 (define-key org-agenda-mode-map "\C-m" 'org-agenda-switch-to)
12990 (define-key org-agenda-mode-map "\C-k" 'org-agenda-kill)
12991 (define-key org-agenda-mode-map "\C-c$" 'org-agenda-archive)
12992 (define-key org-agenda-mode-map "\C-c\C-x\C-s" 'org-agenda-archive)
12993 (define-key org-agenda-mode-map "$" 'org-agenda-archive)
12994 (define-key org-agenda-mode-map "\C-c\C-o" 'org-agenda-open-link)
12995 (define-key org-agenda-mode-map " " 'org-agenda-show)
12996 (define-key org-agenda-mode-map "\C-c\C-t" 'org-agenda-todo)
12997 (define-key org-agenda-mode-map "\C-c\C-xb" 'org-agenda-tree-to-indirect-buffer)
12998 (define-key org-agenda-mode-map "b" 'org-agenda-tree-to-indirect-buffer)
12999 (define-key org-agenda-mode-map "o" 'delete-other-windows)
13000 (define-key org-agenda-mode-map "L" 'org-agenda-recenter)
13001 (define-key org-agenda-mode-map "t" 'org-agenda-todo)
13002 (define-key org-agenda-mode-map "a" 'org-agenda-toggle-archive-tag)
13003 (define-key org-agenda-mode-map ":" 'org-agenda-set-tags)
13004 (define-key org-agenda-mode-map "." 'org-agenda-goto-today)
13005 (define-key org-agenda-mode-map "d" 'org-agenda-day-view)
13006 (define-key org-agenda-mode-map "w" 'org-agenda-week-view)
13007 (define-key org-agenda-mode-map (org-key 'S-right) 'org-agenda-date-later)
13008 (define-key org-agenda-mode-map (org-key 'S-left) 'org-agenda-date-earlier)
13009 (define-key org-agenda-mode-map [?\C-c ?\C-x (right)] 'org-agenda-date-later)
13010 (define-key org-agenda-mode-map [?\C-c ?\C-x (left)] 'org-agenda-date-earlier)
13012 (define-key org-agenda-mode-map ">" 'org-agenda-date-prompt)
13013 (define-key org-agenda-mode-map "\C-c\C-s" 'org-agenda-schedule)
13014 (define-key org-agenda-mode-map "\C-c\C-d" 'org-agenda-deadline)
13016 (while l (define-key org-agenda-mode-map
13019 (define-key org-agenda-mode-map "f" 'org-agenda-follow-mode)
13020 (define-key org-agenda-mode-map "l" 'org-agenda-log-mode)
13021 (define-key org-agenda-mode-map "D" 'org-agenda-toggle-diary)
13022 (define-key org-agenda-mode-map "g" 'org-agenda-toggle-time-grid)
13023 (define-key org-agenda-mode-map "r" 'org-agenda-redo)
13024 (define-key org-agenda-mode-map "q" 'org-agenda-quit)
13025 (define-key org-agenda-mode-map "x" 'org-agenda-exit)
13026 (define-key org-agenda-mode-map "s" 'org-save-all-org-buffers)
13027 (define-key org-agenda-mode-map "P" 'org-agenda-show-priority)
13028 (define-key org-agenda-mode-map "T" 'org-agenda-show-tags)
13029 (define-key org-agenda-mode-map "n" 'next-line)
13030 (define-key org-agenda-mode-map "p" 'previous-line)
13031 (define-key org-agenda-mode-map "\C-n" 'org-agenda-next-date-line)
13032 (define-key org-agenda-mode-map "\C-p" 'org-agenda-previous-date-line)
13033 (define-key org-agenda-mode-map "," 'org-agenda-priority)
13034 (define-key org-agenda-mode-map "\C-c," 'org-agenda-priority)
13035 (define-key org-agenda-mode-map "i" 'org-agenda-diary-entry)
13036 (define-key org-agenda-mode-map "c" 'org-agenda-goto-calendar)
13038 '(define-key calendar-mode-map org-calendar-to-agenda-key
13039 'org-calendar-goto-agenda))
13040 (define-key org-agenda-mode-map "C" 'org-agenda-convert-date)
13041 (define-key org-agenda-mode-map "m" 'org-agenda-phases-of-moon)
13042 (define-key org-agenda-mode-map "M" 'org-agenda-phases-of-moon)
13043 (define-key org-agenda-mode-map "S" 'org-agenda-sunrise-sunset)
13044 (define-key org-agenda-mode-map "h" 'org-agenda-holidays)
13045 (define-key org-agenda-mode-map "H" 'org-agenda-holidays)
13046 (define-key org-agenda-mode-map "+" 'org-agenda-priority-up)
13047 (define-key org-agenda-mode-map "I" 'org-agenda-clock-in)
13048 (define-key org-agenda-mode-map "O" 'org-agenda-clock-out)
13049 (define-key org-agenda-mode-map "X" 'org-agenda-clock-cancel)
13050 (define-key org-agenda-mode-map "-" 'org-agenda-priority-down)
13051 (define-key org-agenda-mode-map (org-key 'S-up) 'org-agenda-priority-up)
13052 (define-key org-agenda-mode-map (org-key 'S-down) 'org-agenda-priority-down)
13053 (define-key org-agenda-mode-map [?\C-c ?\C-x (up)] 'org-agenda-priority-up)
13054 (define-key org-agenda-mode-map [?\C-c ?\C-x (down)] 'org-agenda-priority-down)
13055 (define-key org-agenda-mode-map [(right)] 'org-agenda-later)
13056 (define-key org-agenda-mode-map [(left)] 'org-agenda-earlier)
13057 (define-key org-agenda-mode-map "\C-c\C-x\C-c" 'org-export-icalendar-combine-agenda-files)
13058 (defvar org-agenda-keymap (copy-keymap org-agenda-mode-map)
13059 "Local keymap for agenda entries from Org-mode.")
13061 (define-key org-agenda-keymap
13062 (if (featurep 'xemacs) [(button2)] [(mouse-2)]) 'org-agenda-goto-mouse)
13063 (define-key org-agenda-keymap
13064 (if (featurep 'xemacs) [(button3)] [(mouse-3)]) 'org-agenda-show-mouse)
13065 (when org-agenda-mouse-1-follows-link
13066 (define-key org-agenda-keymap [follow-link] 'mouse-face))
13067 (easy-menu-define org-agenda-menu org-agenda-mode-map "Agenda menu"
13071 ["Show" org-agenda-show t]
13072 ["Go To (other window)" org-agenda-goto t]
13073 ["Go To (this window)" org-agenda-switch-to t]
13074 ["Follow Mode" org-agenda-follow-mode
13075 :style toggle :selected org-agenda-follow-mode :active t]
13076 ["Tree to indirect frame" org-agenda-tree-to-indirect-buffer t]
13078 ["Cycle TODO" org-agenda-todo t]
13079 ["Archive subtree" org-agenda-archive t]
13080 ["Delete subtree" org-agenda-kill t]
13082 ["Goto Today" org-agenda-goto-today (org-agenda-check-type nil 'agenda 'timeline)]
13083 ["Next Dates" org-agenda-later (org-agenda-check-type nil 'agenda)]
13084 ["Previous Dates" org-agenda-earlier (org-agenda-check-type nil 'agenda)]
13087 ["Show all Tags" org-agenda-show-tags t]
13088 ["Set Tags" org-agenda-set-tags t])
13090 ["Schedule" org-agenda-schedule t]
13091 ["Set Deadline" org-agenda-deadline t]
13093 ["Change date +1 day" org-agenda-date-later (org-agenda-check-type nil 'agenda 'timeline)]
13094 ["Change date -1 day" org-agenda-date-earlier (org-agenda-check-type nil 'agenda 'timeline)]
13095 ["Change date to ..." org-agenda-date-prompt (org-agenda-check-type nil 'agenda 'timeline)])
13097 ["Set Priority" org-agenda-priority t]
13098 ["Increase Priority" org-agenda-priority-up t]
13099 ["Decrease Priority" org-agenda-priority-down t]
13100 ["Show Priority" org-agenda-show-priority t])
13102 ["New Diary Entry" org-agenda-diary-entry (org-agenda-check-type nil 'agenda 'timeline)]
13103 ["Goto Calendar" org-agenda-goto-calendar (org-agenda-check-type nil 'agenda 'timeline)]
13104 ["Phases of the Moon" org-agenda-phases-of-moon (org-agenda-check-type nil 'agenda 'timeline)]
13105 ["Sunrise/Sunset" org-agenda-sunrise-sunset (org-agenda-check-type nil 'agenda 'timeline)]
13106 ["Holidays" org-agenda-holidays (org-agenda-check-type nil 'agenda 'timeline)]
13107 ["Convert" org-agenda-convert-date (org-agenda-check-type nil 'agenda 'timeline)]
13109 ["Create iCalendar file" org-export-icalendar-combine-agenda-files t])
13112 ["Day View" org-agenda-day-view :active (org-agenda-check-type nil 'agenda)
13113 :style radio :selected (equal org-agenda-ndays 1)]
13114 ["Week View" org-agenda-week-view :active (org-agenda-check-type nil 'agenda)
13115 :style radio :selected (equal org-agenda-ndays 7)]
13117 ["Show Logbook entries" org-agenda-log-mode
13118 :style toggle :selected org-agenda-show-log :active (org-agenda-check-type nil 'agenda 'timeline)]
13119 ["Include Diary" org-agenda-toggle-diary
13120 :style toggle :selected org-agenda-include-diary :active (org-agenda-check-type nil 'agenda)]
13121 ["Use Time Grid" org-agenda-toggle-time-grid
13122 :style toggle :selected org-agenda-use-time-grid :active (org-agenda-check-type nil 'agenda)])
13123 ["Rebuild buffer" org-agenda-redo t]
13124 ["Save all Org-mode Buffers" org-save-all-org-buffers t]
13126 ["Undo Remote Editing" org-agenda-undo org-agenda-undo-list]
13128 ["Quit" org-agenda-quit t]
13129 ["Exit and Release Buffers" org-agenda-exit t]
13134 (defvar org-agenda-allow-remote-undo t
13135 "Non-nil means, allow remote undo from the agenda buffer.")
13136 (defvar org-agenda-undo-list nil
13137 "List of undoable operations in the agenda since last refresh.")
13138 (defvar org-agenda-undo-has-started-in nil
13140 (defvar org-agenda-pending-undo-list nil
13143 (defmacro org-if-unprotected (&rest body)
13144 "Execute BODY if ther is no `org-protected' text property at point."
13146 `(unless (get-text-property (point) 'org-protected)
13149 (defmacro org-with-remote-undo (_buffer &rest _body)
13152 `(let ((_cline (org-current-line))
13160 (when org-agenda-allow-remote-undo
13161 (setq _c1 (org-verify-change-for-undo
13163 _c2 (org-verify-change-for-undo
13171 org-agenda-undo-list)))))
13173 (defun org-agenda-undo ()
13174 "Undo a remote editing step in the agenda.
13175 This undoes changes both in the agenda buffer and in the remote buffer
13178 (or org-agenda-allow-remote-undo
13179 (error "Check the variable `org-agenda-allow-remote-undo' to activate remote undo."))
13181 (setq org-agenda-undo-has-started-in nil
13182 org-agenda-pending-undo-list org-agenda-undo-list))
13183 (if (not org-agenda-pending-undo-list)
13185 (let* ((entry (pop org-agenda-pending-undo-list))
13189 (org-with-remote-undo rembuf
13195 (unless (memq buf org-agenda-undo-has-started-in)
13196 (push buf org-agenda-undo-has-started-in)
13207 (defun org-verify-change-for-undo (l1 l2)
13215 (defvar org-agenda-restrict nil)
13216 (defvar org-agenda-restrict-begin (make-marker))
13217 (defvar org-agenda-restrict-end (make-marker))
13218 (defvar org-agenda-last-dispatch-buffer nil)
13221 (defun org-agenda (arg)
13222 "Dispatch agenda commands to collect entries to the agenda buffer.
13226 a Call `org-agenda-list' to display the agenda for current day or week.
13227 t Call `org-todo-list' to display the global todo list.
13228 T Call `org-todo-list' to display the global todo list, select only
13230 m Call `org-tags-view' to display headlines with tags matching
13236 `org-agenda-custom-commands'. In particular, specific tags and TODO keyword
13240 first press `1' to indicate that the agenda should be temporarily (until the
13241 next use of \\[org-agenda]) restricted to the current file."
13246 (restrict-ok (and bfn (org-mode-p)))
13247 (custom org-agenda-custom-commands)
13250 (put 'org-agenda-files 'org-restrict nil)
13251 (setq org-agenda-restrict nil)
13252 (move-marker org-agenda-restrict-begin nil)
13253 (move-marker org-agenda-restrict-end nil)
13255 (setq org-agenda-last-dispatch-buffer (current-buffer))
13262 "Press key for an agenda command:
13263 -------------------------------- C Configure custom agenda commands
13265 t List of all TODO entries T Entries with special TODO kwd
13278 (org-add-props (copy-sequence key)
13291 (org-add-props match nil 'face 'org-warning)
13295 (org-add-props "1 Restrict call to current buffer 0 Restrict call to region or subtree" nil 'face 'org-table)))
13298 (message "Press key for agenda command%s"
13304 (put 'org-agenda-files 'org-restrict (list bfn))
13305 (error "Cannot restrict agenda to current buffer"))
13311 (setq org-agenda-restrict t)
13313 (if (org-region-active-p)
13315 (move-marker org-agenda-restrict-begin (region-beginning))
13316 (move-marker org-agenda-restrict-end (region-end)))
13318 (org-back-to-heading t)
13319 (move-marker org-agenda-restrict-begin (point))
13320 (move-marker org-agenda-restrict-end
13321 (progn (org-end-of-subtree t)))))))
13323 (message "Press key for agenda command%s"
13330 ((setq entry (assoc (char-to-string c) org-agenda-custom-commands))
13337 (org-let lprops '(org-tags-view current-prefix-arg match)))
13339 (org-let lprops '(org-tags-view '(4) match)))
13341 (org-let lprops '(org-todo-list match)))
13343 (org-check-for-org-mode)
13344 (org-let lprops '(org-tags-sparse-tree current-prefix-arg match)))
13346 (org-check-for-org-mode)
13347 (org-let lprops
13348 '(org-occur (concat "^" outline-regexp "[ \t]*"
13351 (org-check-for-org-mode)
13352 (org-let lprops '(org-occur match)))
13354 (org-let lprops '(funcall type match)))
13355 (t (error "Invalid custom agenda command type %s" type))))
13356 (org-run-agenda-series (cddr entry))))
13357 ((equal c ?C) (customize-variable 'org-agenda-custom-commands))
13358 ((equal c ?a) (call-interactively 'org-agenda-list))
13359 ((equal c ?t) (call-interactively 'org-todo-list))
13360 ((equal c ?T) (org-call-with-arg 'org-todo-list (or arg '(4))))
13361 ((equal c ?m) (call-interactively 'org-tags-view))
13362 ((equal c ?M) (org-call-with-arg 'org-tags-view (or arg '(4))))
13366 (org-call-with-arg 'org-timeline arg))
13367 ((equal c ?#) (call-interactively 'org-agenda-list-stuck-projects))
13368 ((equal c ?!) (customize-variable 'org-stuck-projects))
13371 (defun org-run-agenda-series (series)
13372 (org-prepare-agenda)
13373 (let* ((org-agenda-multi t)
13374 (redo (list 'org-run-agenda-series (list 'quote series)))
13382 ((eq type 'agenda)
13383 (call-interactively 'org-agenda-list))
13385 (call-interactively 'org-todo-list))
13387 (call-interactively 'org-agenda-list-stuck-projects))
13389 (org-let2 gprops lprops
13390 '(org-tags-view current-prefix-arg match)))
13392 (org-let2 gprops lprops
13393 '(org-tags-view '(4) match)))
13395 (org-let2 gprops lprops
13396 '(org-todo-list match)))
13398 (org-let2 gprops lprops
13402 (setq org-agenda-redo-command redo)
13404 (org-finalize-agenda))
13407 (defmacro org-batch-agenda (cmd-key &rest parameters)
13408 "Run an agenda command in batch mode, send result to STDOUT.
13409 CMD-KEY is a string that is also a key in `org-agenda-custom-commands'.
13411 before running the agenda command."
13416 (eval (list 'let (nreverse pars) '(org-agenda nil))))
13420 (defmacro org-no-read-only (&rest body)
13424 (defun org-check-for-org-mode ()
13425 "Make sure current buffer is in org-mode. Error if not."
13426 (or (org-mode-p)
13427 (error "Cannot execute org-mode agenda command on buffer in %s."
13430 (defun org-fit-agenda-window ()
13432 (and (memq org-agenda-window-setup '(reorganize-frame))
13439 (defun org-agenda-files (&optional unrestricted)
13440 "Get the list of agenda files.
13444 ((and (not unrestricted) (get 'org-agenda-files 'org-restrict)))
13445 ((stringp org-agenda-files) (org-read-agenda-file-list))
13446 ((listp org-agenda-files) org-agenda-files)
13447 (t (error "Invalid value of `org-agenda-files'"))))
13449 (defun org-edit-agenda-file-list ()
13450 "Edit the list of agenda files.
13452 `org-agenda-files', or it visits the file that is holding the list. In the
13456 (if (stringp org-agenda-files)
13458 (find-file org-agenda-files)
13459 (org-set-local 'org-window-configuration cw)
13460 (org-add-hook 'after-save-hook
13463 (prog1 org-window-configuration
13465 (org-install-agenda-files-menu)
13466 (message "New agenda file list installed"))
13470 (customize-variable 'org-agenda-files)))
13472 (defun org-store-new-agenda-file-list (list)
13473 "Set new value for the agenda file list and save it correcly."
13474 (if (stringp org-agenda-files)
13475 (let ((f org-agenda-files) b)
13479 (let ((org-mode-hook nil) (default-major-mode 'fundamental-mode))
13480 (setq org-agenda-files list)
13481 (customize-save-variable 'org-agenda-files org-agenda-files))))
13483 (defun org-read-agenda-file-list ()
13484 "Read the list of agenda files from a file."
13485 (when (stringp org-agenda-files)
13487 (insert-file-contents org-agenda-files)
13488 (org-split-string (buffer-string) "[ \t\r\n]*?[\r\n][ \t\r\n]*"))))
13492 (defun org-cycle-agenda-files ()
13493 "Cycle through the files in `org-agenda-files'.
13494 If the current buffer visits an agenda file, find the next one in the list.
13495 If the current buffer does not, find the first agenda file."
13497 (let* ((fs (org-agenda-files t))
13498 (files (append fs (list (car fs))))
13501 (unless files (error "No agenda files"))
13503 (while (setq file (pop files))
13505 (when (car files)
13506 (find-file (car files))
13511 (defun org-agenda-file-to-end ()
13512 "Move/add the current file to the end of the agenda file list.
13516 (org-agenda-file-to-front 'to-end))
13518 (defun org-agenda-file-to-front (&optional to-end)
13519 "Move/add the current file to the top of the agenda file list.
13526 (org-agenda-files t)))
13535 (org-store-new-agenda-file-list (mapcar 'cdr file-alist))
13536 (org-install-agenda-files-menu)
13537 (message "File %s to %s of agenda file list"
13540 (defun org-remove-file (&optional file)
13541 "Remove current file from the list of files in variable `org-agenda-files'.
13542 These are the files which are being checked for agenda entries.
13548 (files (delq nil (mapcar
13553 (org-agenda-files t)))))
13554 (if (not (= (length files) (length (org-agenda-files t))))
13556 (org-store-new-agenda-file-list files)
13557 (org-install-agenda-files-menu)
13561 (defun org-file-menu-entry (file)
13564 (defun org-check-agenda-file (file)
13572 (org-remove-file file)
13578 (defvar org-agenda-multi nil) ; dynammically scoped
13579 (defvar org-agenda-buffer-name "*Org Agenda*")
13580 (defvar org-pre-agenda-window-conf nil)
13581 (defun org-prepare-agenda ()
13582 (if org-agenda-multi
13589 (org-agenda-maybe-reset-markers 'force)
13590 (org-prepare-agenda-buffers (org-agenda-files))
13591 (let* ((abuf (get-buffer-create org-agenda-buffer-name))
13596 ((not (setq org-pre-agenda-window-conf (current-window-configuration))))
13597 ((equal org-agenda-window-setup 'current-window)
13599 ((equal org-agenda-window-setup 'other-window)
13601 ((equal org-agenda-window-setup 'other-frame)
13603 ((equal org-agenda-window-setup 'reorganize-frame)
13608 (org-agenda-mode))
13611 (defun org-finalize-agenda ()
13612 "Finishing touch for the agenda buffer, called just before displaying it."
13613 (unless org-agenda-multi
13614 (org-agenda-align-tags)
13618 (while (org-activate-bracket-links (point-max))
13620 '(face org-link))))
13621 (run-hooks 'org-finalize-agenda-hook))))
13623 (defun org-prepare-agenda-buffers (files)
13624 "Create buffers for all agenda files, protect archived trees and comments."
13626 (let ((pa '(:org-archived t))
13627 (pc '(:org-comment t))
13628 (pall '(:org-archived t :org-comment t))
13629 (rea (concat ":" org-archive-tag ":"))
13633 (while (setq file (pop files))
13634 (org-check-agenda-file file)
13635 (set-buffer (org-get-agenda-file-buffer file))
13640 (when org-agenda-skip-archived-trees
13643 (if (org-on-heading-p t)
13644 (add-text-properties (point-at-bol) (org-end-of-subtree t) pa))))
13646 (setq re (concat "^\\*+ +" org-comment-string "\\>"))
13649 (match-beginning 0) (org-end-of-subtree t) pc)))
13652 (defvar org-agenda-skip-function nil
13653 "Function to be called at each match during agenda construction.
13658 to all future agenda commands. Instead, bind it with `let' to scope
13659 it dynamically into the agenda-constructing command.")
13661 (defun org-agenda-skip ()
13666 (and org-agenda-skip-archived-trees
13667 (get-text-property p :org-archived)
13668 (org-end-of-subtree t)
13670 (and (get-text-property p :org-comment)
13671 (org-end-of-subtree t)
13674 (when (and (functionp org-agenda-skip-function)
13677 (funcall org-agenda-skip-function)))))
13681 (defvar org-agenda-markers nil
13682 "List of all currently active markers created by `org-agenda'.")
13683 (defvar org-agenda-last-marker-time (time-to-seconds (current-time))
13684 "Creation time of the last agenda marker.")
13686 (defun org-agenda-new-marker (&optional pos)
13687 "Return a new agenda marker.
13691 (setq org-agenda-last-marker-time (time-to-seconds (current-time)))
13692 (push m org-agenda-markers)
13695 (defun org-agenda-maybe-reset-markers (&optional force)
13696 "Reset markers created by `org-agenda'. But only if they are old enough."
13697 (if (or (and force (not org-agenda-multi))
13699 org-agenda-last-marker-time)
13701 (while org-agenda-markers
13702 (move-marker (pop org-agenda-markers) nil))))
13704 (defvar org-agenda-new-buffers nil
13705 "Buffers created to visit agenda files.")
13707 (defun org-get-agenda-file-buffer (file)
13710 (let ((buf (org-find-base-buffer-visiting file)))
13715 (if buf (push buf org-agenda-new-buffers))
13718 (defun org-release-buffers (blist)
13719 "Release all buffers in list, asking the user for confirmation when needed.
13731 (defvar org-category-table nil)
13732 (defun org-get-category-table ()
13738 (push (cons (point) (org-trim (match-string 2))) tbl)))
13741 (defun org-get-category (&optional pos)
13743 (if (not org-category-table)
13745 ((null org-category)
13746 (setq org-category
13751 ((symbolp org-category) (symbol-name org-category))
13752 (t org-category))
13753 (let ((tbl org-category-table)
13757 (or (cdar tbl) (cdr (nth (1- (length org-category-table))
13758 org-category-table))))))
13761 (defun org-timeline (&optional include-all)
13762 "Show a time-sorted view of the entries in the current org file.
13764 \\[universal-argument] prefix, all unfinished TODO items will also be shown,
13770 (org-compile-prefix-format 'timeline)
13771 (org-set-sorting-strategy 'timeline)
13773 (dotodo include-all)
13774 (doclosed org-agenda-show-log)
13777 (beg (if (org-region-active-p) (region-beginning) (point-min)))
13778 (end (if (org-region-active-p) (region-end) (point-max)))
13779 (day-numbers (org-get-all-dates beg end 'no-ranges
13781 org-timeline-show-empty-dates))
13786 (setq org-agenda-redo-command
13789 (list 'org-timeline (list 'quote include-all))))
13795 (org-prepare-agenda)
13804 (put-text-property s (1- (point)) 'face 'org-level-3))
13815 (apply 'org-agenda-get-day-entries
13817 (if (or rtn (equal d today) org-timeline-show-empty-dates)
13824 ; (insert (format-time-string org-agenda-date-format
13827 (put-text-property s (1- (point)) 'face 'org-level-3)
13828 (put-text-property s (1- (point)) 'org-date-line t)
13830 (put-text-property s (1- (point)) 'org-today t))
13831 (and rtn (insert (org-finalize-agenda-entries rtn) "\n"))
13834 (goto-char (or (text-property-any (point-min) (point-max) 'org-today t)
13836 (add-text-properties (point-min) (point-max) '(org-agenda-type timeline))
13837 (org-finalize-agenda)
13840 (defun org-get-all-dates (beg end &optional no-ranges force-today inactive empty)
13841 "Return a list of all relevant day numbers from BEG to END buffer positions.
13847 (let ((re (if inactive org-ts-regexp-both org-ts-regexp))
13854 (setq day (time-to-days (org-time-string-to-time
13859 (while (re-search-forward org-tr-regexp end t)
13862 day1 (time-to-days (org-time-string-to-time ts1))
13863 day2 (time-to-days (org-time-string-to-time ts2)))
13882 (defvar org-agenda-overriding-arguments nil) ; dynamically scoped parameter
13883 (defvar org-agenda-last-arguments nil
13884 "The arguments of the previous call to org-agenda")
13885 (defvar org-starting-day nil) ; local variable in the agenda buffer
13886 (defvar org-include-all-loc nil) ; local variable
13890 (defun org-agenda-list (&optional include-all start-day ndays)
13891 "Produce a weekly view from all files in variable `org-agenda-files'.
13894 With one \\[universal-argument] prefix argument INCLUDE-ALL, all unfinished TODO items will
13896 With two \\[universal-argument] prefix argument INCLUDE-ALL, all TODO entries marked DONE
13897 on the days are also shown. See the variable `org-log-done' for how
13900 given in `org-agenda-start-on-weekday'.
13901 NDAYS defaults to `org-agenda-ndays'."
13903 (if org-agenda-overriding-arguments
13904 (setq include-all (car org-agenda-overriding-arguments)
13905 start-day (nth 1 org-agenda-overriding-arguments)
13906 ndays (nth 2 org-agenda-overriding-arguments)))
13907 (setq org-agenda-last-arguments (list include-all start-day ndays))
13908 (org-compile-prefix-format 'agenda)
13909 (org-set-sorting-strategy 'agenda)
13911 (let* ((org-agenda-start-on-weekday
13913 (and (null ndays) (equal 1 org-agenda-ndays)))
13914 nil org-agenda-start-on-weekday))
13915 (thefiles (org-agenda-files))
13916 (files thefiles)
13919 (start (if (or (null org-agenda-start-on-weekday)
13920 (< org-agenda-ndays 7))
13924 (n1 org-agenda-start-on-weekday)
13930 (setq org-agenda-redo-command
13931 (list 'org-agenda-list (list 'quote include-all) start-day ndays))
13933 (setq ndays (or ndays org-agenda-ndays)
13939 (org-prepare-agenda)
13940 (org-set-local 'org-starting-day (car day-numbers))
13941 (org-set-local 'org-include-all-loc include-all)
13942 (when (and (or include-all org-agenda-include-all-todo)
13944 (setq files thefiles
13946 (while (setq file (pop files))
13948 (org-check-agenda-file file)
13950 rtn (org-agenda-get-day-entries
13956 (list 'face 'org-level-3))
13957 (insert (org-finalize-agenda-entries rtnall) "\n")))
13959 (insert (if (= nd 7) "Week-" "Day-") "agenda:\n")
13960 (add-text-properties s (1- (point)) (list 'face 'org-level-3))
13969 (setq files thefiles
13971 (while (setq file (pop files))
13973 (org-check-agenda-file file)
13974 (if org-agenda-show-log
13975 (setq rtn (org-agenda-get-day-entries
13978 (setq rtn (org-agenda-get-day-entries
13982 (if org-agenda-include-diary
13985 (setq rtn (org-get-entries-from-diary date))
13987 (if (or rtnall org-agenda-show-all-dates)
13995 ; (insert (format-time-string org-agenda-date-format
13997 (put-text-property s (1- (point)) 'face 'org-level-3)
13998 (put-text-property s (1- (point)) 'org-date-line t)
13999 (if todayp (put-text-property s (1- (point)) 'org-today t))
14001 (org-finalize-agenda-entries
14002 (org-agenda-add-time-grid-maybe
14007 (org-fit-agenda-window)
14017 (add-text-properties (point-min) (point-max) '(org-agenda-type agenda))
14018 (org-finalize-agenda)
14024 (defvar org-select-this-todo-keyword nil)
14025 (defvar org-last-arg nil)
14028 (defun org-todo-list (arg)
14029 "Show all TODO entries from all agenda file in a single list.
14033 `org-todo-keywords'."
14036 (org-compile-prefix-format 'todo)
14037 (org-set-sorting-strategy 'todo)
14040 (kwds org-todo-keywords)
14042 (org-select-this-todo-keyword
14045 (nth (1- arg) org-todo-keywords))))
14046 rtn rtnall files file pos)
14048 (setq org-select-this-todo-keyword
14049 (completing-read "Keyword: " (mapcar 'list org-todo-keywords)
14051 (and (equal 0 arg) (setq org-select-this-todo-keyword nil))
14052 (org-prepare-agenda)
14053 (org-set-local 'org-last-arg arg)
14054 (org-set-local 'org-todo-keywords kwds)
14055 (setq org-agenda-redo-command
14056 '(org-todo-list (or current-prefix-arg org-last-arg)))
14057 (setq files (org-agenda-files)
14059 (while (setq file (pop files))
14061 (org-check-agenda-file file)
14062 (setq rtn (org-agenda-get-day-entries file date :todo))
14064 (if org-agenda-overriding-header
14065 (insert (org-add-props (copy-sequence org-agenda-overriding-header)
14066 nil 'face 'org-level-3) "\n")
14069 (list 'face 'org-level-3))
14071 (insert (or org-select-this-todo-keyword "ALL") "\n")
14072 (add-text-properties pos (1- (point)) (list 'face 'org-warning))
14074 (unless org-agenda-multi
14080 org-todo-keywords " "))
14082 (add-text-properties pos (1- (point)) (list 'face 'org-level-3)))
14084 (insert (org-finalize-agenda-entries rtnall) "\n"))
14086 (org-fit-agenda-window)
14087 (add-text-properties (point-min) (point-max) '(org-agenda-type todo))
14088 (org-finalize-agenda)
14094 (defun org-tags-view (&optional todo-only match)
14095 "Show all headlines for all `org-agenda-files' matching a TAGS criterion.
14098 (org-compile-prefix-format 'tags)
14099 (org-set-sorting-strategy 'tags)
14100 (let* ((org-tags-match-list-sublevels
14101 (if todo-only t org-tags-match-list-sublevels))
14103 rtn rtnall files file pos matcher
14105 (setq matcher (org-make-tags-matcher match)
14107 (org-prepare-agenda)
14108 (setq org-agenda-redo-command
14109 (list 'org-tags-view (list 'quote todo-only)
14111 (setq files (org-agenda-files)
14113 (while (setq file (pop files))
14115 (org-check-agenda-file file)
14117 (org-get-agenda-file-buffer file)
14120 ;; If file does not exist, merror message to agenda
14122 (format "ORG-AGENDA-ERROR: No such org-file %s" file))
14125 (unless (org-mode-p)
14126 (error "Agenda file %s is not in `org-mode'" file))
14127 (setq org-category-table (org-get-category-table))
14130 (if org-agenda-restrict
14131 (narrow-to-region org-agenda-restrict-begin
14132 org-agenda-restrict-end)
14134 (setq rtn (org-scan-tags 'agenda matcher todo-only))
14136 (if org-agenda-overriding-header
14137 (insert (org-add-props (copy-sequence org-agenda-overriding-header)
14138 nil 'face 'org-level-3) "\n")
14141 (list 'face 'org-level-3))
14144 (add-text-properties pos (1- (point)) (list 'face 'org-warning))
14146 (unless org-agenda-multi
14148 (add-text-properties pos (1- (point)) (list 'face 'org-level-3)))
14150 (insert (org-finalize-agenda-entries rtnall) "\n"))
14152 (org-fit-agenda-window)
14153 (add-text-properties (point-min) (point-max) '(org-agenda-type tags))
14154 (org-finalize-agenda)
14159 (defvar org-agenda-skip-regexp nil
14160 "Regular expression used in skipping subtrees for the agenda.
14162 used by user-defined selections using `org-agenda-skip-function'.")
14164 (defvar org-agenda-overriding-header nil
14167 (defun org-agenda-skip-subtree-when-regexp-matches ()
14168 "Checks if the current subtree contains match for `org-agenda-skip-regexp'.
14169 If yes, it returns the end position of this tree, causing agenda commands
14171 `org-agenda-skip-function' for the duration of a command."
14173 (let ((end (save-excursion (org-end-of-subtree t)))
14176 (setq skip (re-search-forward org-agenda-skip-regexp end t)))
14179 (defun org-agenda-list-stuck-projects (&rest ignore)
14180 "Create agenda view for projects that are stuck.
14183 `org-stuck-projects'.
14186 (let* ((org-agenda-skip-function 'org-agenda-skip-subtree-when-regexp-matches)
14187 (org-agenda-overriding-header "List of stuck projects: ")
14188 (matcher (nth 0 org-stuck-projects))
14189 (todo (nth 1 org-stuck-projects))
14190 (tags (nth 2 org-stuck-projects))
14198 (setq org-agenda-skip-regexp
14205 (org-tags-view nil matcher)
14206 (with-current-buffer org-agenda-buffer-name
14207 (setq org-agenda-redo-command
14208 '(org-agenda-list-stuck-projects
14209 (or current-prefix-arg org-last-arg))))))
14213 (defvar org-disable-agenda-to-diary nil) ;Dynamically-scoped param.
14215 (defun org-get-entries-from-diary (date)
14220 (cons 'org-diary-default-entry list-diary-entries-hook))
14222 (diary-modify-entry-list-string-function 'org-modify-diary-entry-string)
14224 (org-disable-agenda-to-diary t))
14236 (org-agenda-cleanup-fancy-diary)
14244 (setq entries (org-split-string entries "\n"))
14248 (setq x (org-format-agenda-item "" x "Diary" nil 'time))
14250 (org-add-props x (text-properties-at (1- (length x)) x)))
14253 (defun org-agenda-cleanup-fancy-diary ()
14256 the dummy entry installed by `org-mode' to ensure non-empty diary for each
14280 (defadvice add-to-diary-list (before org-mark-diary-entry activate)
14282 (if (and org-disable-agenda-to-diary ;; called from org-agenda
14285 (setq string (org-modify-diary-entry-string string))))))
14287 (defun org-modify-diary-entry-string (string)
14288 "Add text properties to string, allowing org-mode to act on it."
14289 (org-add-props string nil
14291 'keymap org-agenda-keymap
14294 'org-agenda-diary-link t
14295 'org-marker (org-agenda-new-marker (point-at-bol))))
14297 (defun org-diary-default-entry ()
14301 (when org-disable-agenda-to-diary
14308 (defun org-diary (&rest args)
14309 "Return diary information from org-files.
14311 It accesses org files and extracts information from those files to be
14320 `org-deadline-warning-days'. The listing occurs only
14324 :scheduled List all items which are scheduled for the given date.
14328 :todo List all TODO items from the org-file. This may be a
14335 &%%(org-diary) ~/path/to/some/orgfile.org
14337 Use a separate line for each org file to check. Or, if you omit the file name,
14338 all files listed in `org-agenda-files' will be checked automatically:
14340 &%%(org-diary)
14346 &%%(org-diary :deadline :timestamp :scheduled)
14350 function from a program - use `org-agenda-get-day-entries' instead."
14351 (org-agenda-maybe-reset-markers)
14352 (org-compile-prefix-format 'agenda)
14353 (org-set-sorting-strategy 'agenda)
14355 (let* ((files (if (and entry (stringp entry) (string-match "\\S-" entry))
14357 (org-agenda-files t)))
14359 ;; If this is called during org-agenda, don't return any entries to
14361 (if org-disable-agenda-to-diary (setq files nil))
14362 (while (setq file (pop files))
14363 (setq rtn (apply 'org-agenda-get-day-entries file date args))
14366 (concat (org-finalize-agenda-entries results) "\n"))))
14370 (defun org-agenda-get-day-entries (file date &rest args)
14371 "Does the work for `org-diary' and `org-agenda'.
14375 the documentation of `org-diary'."
14377 (let* ((org-startup-folded nil)
14378 (org-startup-align-all-tables nil)
14380 (org-get-agenda-file-buffer file)
14385 (list (format "ORG-AGENDA-ERROR: No such org-file %s" file))
14387 (unless (org-mode-p)
14388 (error "Agenda file %s is not in `org-mode'" file))
14389 (setq org-category-table (org-get-category-table))
14393 (if org-agenda-restrict
14394 (narrow-to-region org-agenda-restrict-begin
14395 org-agenda-restrict-end)
14402 (setq rtn (org-agenda-get-todos))
14405 (setq rtn (org-agenda-get-blocks))
14407 (setq rtn (org-agenda-get-timestamps))
14410 (setq rtn (org-agenda-get-scheduled))
14413 (setq rtn (org-agenda-get-closed))
14417 (setq rtn (org-agenda-get-deadlines))
14421 (defun org-entry-is-done-p ()
14425 (looking-at org-nl-done-regexp))))
14427 (defun org-at-date-range-p (&optional inactive-ok)
14435 (and (looking-at (if inactive-ok org-tr-regexp-both org-tr-regexp))
14440 (and (looking-at (if inactive-ok org-tr-regexp-both org-tr-regexp))
14445 (defun org-agenda-get-todos ()
14446 "Return the TODO information for agenda display."
14448 'done-face 'org-done
14449 'org-not-done-regexp org-not-done-regexp
14451 'keymap org-agenda-keymap
14453 (format "mouse-2 or RET jump to org file %s"
14456 (if org-select-this-todo-keyword
14457 (concat "\\<\\(" org-select-this-todo-keyword
14459 org-not-done-regexp)
14469 (when (or (and org-agenda-todo-ignore-scheduled (goto-char beg)
14470 (re-search-forward org-scheduled-time-regexp end t))
14471 (and org-agenda-todo-ignore-deadlines (goto-char beg)
14472 (re-search-forward org-deadline-time-regexp end t)
14473 (org-deadline-close (match-string 1))))
14475 (or org-agenda-todo-list-sublevels (org-end-of-subtree 'invisible))
14478 (org-agenda-skip)
14480 (setq marker (org-agenda-new-marker (1+ (match-beginning 0)))
14481 category (org-get-category)
14482 tags (org-get-tags-at (point))
14483 txt (org-format-agenda-item "" (match-string 1) category tags)
14485 (+ (org-get-priority txt)
14486 (if org-todo-kwd-priority-p
14487 (- org-todo-kwd-max-priority -2
14489 (member (match-string 2) org-todo-keywords)))
14491 (org-add-props txt props
14492 'org-marker marker 'org-hd-marker marker
14493 'priority priority 'org-category category)
14495 (if org-agenda-todo-list-sublevels
14497 (org-end-of-subtree 'invisible))))
14500 (defconst org-agenda-no-heading-message
14503 (defun org-agenda-get-timestamps ()
14504 "Return the date stamp information for agenda display."
14506 'org-not-done-regexp org-not-done-regexp
14508 'keymap org-agenda-keymap
14510 (format "mouse-2 or RET jump to org file %s"
14515 (car org-time-stamp-formats)
14524 (and (save-match-data (org-at-date-range-p)) (throw :skip nil))
14525 (org-agenda-skip)
14526 (setq marker (org-agenda-new-marker (match-beginning 0))
14527 category (org-get-category (match-beginning 0))
14530 org-ds-keyword-length))
14533 deadlinep (string-match org-deadline-regexp tmp)
14534 scheduledp (string-match org-scheduled-regexp tmp)
14535 donep (org-entry-is-done-p))
14536 (and org-agenda-skip-scheduled-if-done
14546 (setq hdmarker (org-agenda-new-marker)
14547 tags (org-get-tags-at))
14549 (setq txt (org-format-agenda-item
14554 (setq txt org-agenda-no-heading-message))
14555 (setq priority (org-get-priority txt))
14556 (org-add-props txt props
14557 'org-marker marker 'org-hd-marker hdmarker)
14559 (org-add-props txt nil
14560 'face (if donep 'org-done 'org-warning)
14561 'undone-face 'org-warning 'done-face 'org-done
14562 'org-category category 'priority (+ 100 priority))
14564 (org-add-props txt nil
14565 'face 'org-scheduled-today
14566 'undone-face 'org-scheduled-today 'done-face 'org-done
14567 'org-category category 'priority (+ 99 priority))
14568 (org-add-props txt nil 'priority priority 'org-category category)))
14573 (defun org-agenda-get-closed ()
14574 "Return the logged TODO entries for agenda display."
14576 'org-not-done-regexp org-not-done-regexp
14577 'keymap org-agenda-keymap
14579 (format "mouse-2 or RET jump to org file %s"
14582 "\\<\\(" org-closed-string "\\|" org-clock-string "\\) *\\["
14586 (car org-time-stamp-formats)
14595 (org-agenda-skip)
14596 (setq marker (org-agenda-new-marker (match-beginning 0))
14597 closedp (equal (match-string 1) org-closed-string)
14598 category (org-get-category (match-beginning 0))
14600 ;; donep (org-entry-is-done-p)
14609 (setq hdmarker (org-agenda-new-marker)
14610 tags (org-get-tags-at))
14612 (setq txt (org-format-agenda-item
14615 (setq txt org-agenda-no-heading-message))
14617 (org-add-props txt props
14618 'org-marker marker 'org-hd-marker hdmarker 'face 'org-done
14619 'priority priority 'org-category category
14620 'undone-face 'org-warning 'done-face 'org-done)
14625 (defun org-agenda-get-deadlines ()
14626 "Return the deadline information for agenda display."
14627 (let* ((wdays org-deadline-warning-days)
14629 'org-not-done-regexp org-not-done-regexp
14630 'keymap org-agenda-keymap
14632 (format "mouse-2 or RET jump to org file %s"
14634 (regexp org-deadline-time-regexp)
14642 (org-agenda-skip)
14645 (org-time-string-to-time (match-string 1)))
14652 (setq category (org-get-category))
14657 (setq tags (org-get-tags-at pos1))
14662 (if (string-match org-looking-at-done-regexp head)
14664 (setq txt (org-format-agenda-item
14666 (setq txt org-agenda-no-heading-message))
14668 (setq face (cond ((<= diff 0) 'org-warning)
14669 ((<= diff 5) 'org-upcoming-deadline)
14671 (org-add-props txt props
14672 'org-marker (org-agenda-new-marker pos)
14673 'org-hd-marker (org-agenda-new-marker pos1)
14674 'priority (+ (- 10 diff) (org-get-priority txt))
14675 'org-category category
14676 'face face 'undone-face face 'done-face 'org-done)
14680 (defun org-agenda-get-scheduled ()
14681 "Return the scheduled information for agenda display."
14682 (let* ((props (list 'face 'org-scheduled-previously
14683 'org-not-done-regexp org-not-done-regexp
14684 'undone-face 'org-scheduled-previously
14685 'done-face 'org-done
14687 'keymap org-agenda-keymap
14689 (format "mouse-2 or RET jump to org file %s"
14691 (regexp org-scheduled-time-regexp)
14699 (org-agenda-skip)
14702 (org-time-string-to-time (match-string 1)))
14708 (setq category (org-get-category))
14713 (setq tags (org-get-tags-at))
14717 (if (string-match org-looking-at-done-regexp head)
14719 (setq txt (org-format-agenda-item
14722 (setq txt org-agenda-no-heading-message))
14724 (org-add-props txt props
14725 'org-marker (org-agenda-new-marker pos)
14726 'org-hd-marker (org-agenda-new-marker pos1)
14727 'priority (+ (- 5 diff) (org-get-priority txt))
14728 'org-category category)
14732 (defun org-agenda-get-blocks ()
14733 "Return the date-range information for agenda display."
14735 'org-not-done-regexp org-not-done-regexp
14737 'keymap org-agenda-keymap
14739 (format "mouse-2 or RET jump to org file %s"
14741 (regexp org-tr-regexp)
14747 (org-agenda-skip)
14752 d1 (time-to-days (org-time-string-to-time s1))
14753 d2 (time-to-days (org-time-string-to-time s2)))
14758 (setq marker (org-agenda-new-marker (point)))
14759 (setq category (org-get-category))
14762 (setq hdmarker (org-agenda-new-marker (match-end 1)))
14764 (setq tags (org-get-tags-at))
14766 (setq txt (org-format-agenda-item
14771 (setq txt org-agenda-no-heading-message))
14772 (org-add-props txt props
14773 'org-marker marker 'org-hd-marker hdmarker
14774 'priority (org-get-priority txt) 'org-category category)
14783 (defconst org-plain-time-of-day-regexp
14798 (defconst org-stamp-time-of-day-regexp
14811 (defvar org-prefix-has-time nil
14812 "A flag, set by `org-compile-prefix-format'.
14814 (defvar org-prefix-has-tag nil
14815 "A flag, set by `org-compile-prefix-format'.
14818 (defun org-format-agenda-item (extra txt &optional category tags dotime
14820 "Format TXT to be inserted into the agenda buffer.
14830 `org-agenda-change-all-lines'. TAGS can be the tags of the headline."
14835 org-category
14843 (time-of-day (and dotime (org-get-time-of-day ts)))
14845 (when (and dotime time-of-day org-prefix-has-time)
14847 (when (or (setq stamp (string-match org-stamp-time-of-day-regexp ts))
14848 (setq plain (string-match org-plain-time-of-day-regexp ts)))
14856 (if (and org-agenda-remove-times-when-in-prefix (or stamp plain)
14858 (if (eq org-agenda-remove-times-when-in-prefix 'beg)
14863 (if s1 (setq s1 (org-get-time-of-day s1 'string t)))
14864 (if s2 (setq s2 (org-get-time-of-day s2 'string t))))
14868 (if (or (eq org-agenda-remove-tags-when-in-prefix t)
14869 (and org-agenda-remove-tags-when-in-prefix
14870 org-prefix-has-tag))
14887 (setq rtn (concat (eval org-prefix-format-compiled) txt)))
14890 (org-add-props rtn nil
14891 'org-category (downcase category) 'tags tags
14896 (defvar org-agenda-sorting-strategy)
14897 (defvar org-agenda-sorting-strategy-selected nil)
14899 (defun org-agenda-add-time-grid-maybe (list ndays todayp)
14901 (cond ((not org-agenda-use-time-grid) (throw 'exit list))
14902 ((and todayp (member 'today (car org-agenda-time-grid))))
14903 ((and (= ndays 1) (member 'daily (car org-agenda-time-grid))))
14904 ((member 'weekly (car org-agenda-time-grid)))
14909 (string (nth 1 org-agenda-time-grid))
14910 (gridtimes (nth 2 org-agenda-time-grid))
14911 (req (car org-agenda-time-grid))
14920 (push (org-format-agenda-item
14925 1 (length (car new)) 'face 'org-time-grid (car new))))
14926 (if (member 'time-up org-agenda-sorting-strategy-selected)
14930 (defun org-compile-prefix-format (key)
14933 `org-prefix-format-compiled'."
14934 (setq org-prefix-has-time nil org-prefix-has-tag nil)
14936 ((stringp org-agenda-prefix-format)
14937 org-agenda-prefix-format)
14938 ((assq key org-agenda-prefix-format)
14939 (cdr (assq key org-agenda-prefix-format)))
14951 (if (equal var 'time) (setq org-prefix-has-time t))
14952 (if (equal var 'tag) (setq org-prefix-has-tag t))
14963 (setq org-prefix-format-compiled `(format ,s ,@vars))))
14965 (defun org-set-sorting-strategy (key)
14966 (if (symbolp (car org-agenda-sorting-strategy))
14968 (setq org-agenda-sorting-strategy-selected org-agenda-sorting-strategy)
14969 (setq org-agenda-sorting-strategy-selected
14970 (or (cdr (assq key org-agenda-sorting-strategy))
14971 (cdr (assq 'agenda org-agenda-sorting-strategy))
14974 (defun org-get-time-of-day (s &optional string mod24)
15003 (defun org-finalize-agenda-entries (list &optional nosort)
15004 "Sort and concatenate the agenda items."
15005 (setq list (mapcar 'org-agenda-highlight-todo list))
15008 (mapconcat 'identity (sort list 'org-entries-lessp) "\n")))
15010 (defun org-agenda-highlight-todo (x)
15015 (setq re (get-text-property (point) 'org-not-done-regexp))
15019 '(face org-todo))))
15020 (setq re (concat (get-text-property 0 'org-not-done-regexp x))
15024 '(face org-todo) x))
15027 (defsubst org-cmp-priority (a b)
15035 (defsubst org-cmp-category (a b)
15043 (defsubst org-cmp-tag (a b)
15053 (defsubst org-cmp-time (a b)
15055 (let* ((def (if org-sort-agenda-notime-is-late 9901 -1))
15062 (defun org-entries-lessp (a b)
15063 "Predicate for sorting agenda entries."
15066 (let* ((time-up (org-cmp-time a b))
15068 (priority-up (org-cmp-priority a b))
15070 (category-up (org-cmp-category a b))
15073 (tag-up (org-cmp-tag a b))
15076 (eval (cons 'or org-agenda-sorting-strategy-selected))
15081 (defun org-agenda-check-type (error &rest types)
15082 "Check if agenda buffer is of allowed type.
15084 (if (memq org-agenda-type types)
15087 (error "Not allowed in %s-type agenda buffers" org-agenda-type)
15090 (defun org-agenda-quit ()
15091 "Exit agenda by removing the window or the buffer."
15096 (org-agenda-maybe-reset-markers 'force))
15097 ;; Maybe restore the pre-agenda window configuration.
15098 (and org-agenda-restore-windows-after-quit
15099 (not (eq org-agenda-window-setup 'other-frame))
15100 org-pre-agenda-window-conf
15101 (set-window-configuration org-pre-agenda-window-conf)))
15103 (defun org-agenda-exit ()
15104 "Exit agenda by removing the window or the buffer.
15105 Also kill all Org-mode buffers which have been loaded by `org-agenda'.
15108 (org-release-buffers org-agenda-new-buffers)
15109 (setq org-agenda-new-buffers nil)
15110 (org-agenda-quit))
15112 (defun org-save-all-org-buffers ()
15113 "Save all Org-mode buffers without user confirmation."
15115 (message "Saving all Org-mode buffers...")
15116 (save-some-buffers t 'org-mode-p)
15117 (message "Saving all Org-mode buffers... done"))
15119 (defun org-agenda-redo ()
15123 (let* ((org-agenda-keep-modes t)
15124 (line (org-current-line))
15125 (window-line (- line (org-current-line (window-start)))))
15126 (message "Rebuilding agenda buffer...")
15127 (eval org-agenda-redo-command)
15128 (setq org-agenda-undo-list nil
15129 org-agenda-pending-undo-list nil)
15130 (message "Rebuilding agenda buffer...done")
15134 (defun org-agenda-goto-today ()
15137 (org-agenda-check-type t 'timeline 'agenda)
15138 (let ((tdpos (text-property-any (point-min) (point-max) 'org-today t)))
15141 ((eq org-agenda-type 'agenda)
15142 (let ((org-agenda-overriding-arguments org-agenda-last-arguments))
15143 (setf (nth 1 org-agenda-overriding-arguments) nil)
15144 (org-agenda-redo)
15145 (org-agenda-find-today-or-agenda)))
15148 (defun org-agenda-find-today-or-agenda ()
15150 (or (text-property-any (point-min) (point-max) 'org-today t)
15151 (text-property-any (point-min) (point-max) 'org-agenda-type 'agenda)
15154 (defun org-agenda-later (arg)
15155 "Go forward in time by `org-agenda-ndays' days.
15156 With prefix ARG, go forward that many times `org-agenda-ndays'."
15158 (org-agenda-check-type t 'agenda)
15159 (let ((org-agenda-overriding-arguments
15160 (list (car org-agenda-last-arguments)
15161 (+ org-starting-day (* arg org-agenda-ndays))
15163 (org-agenda-redo)
15164 (org-agenda-find-today-or-agenda)))
15166 (defun org-agenda-earlier (arg)
15167 "Go back in time by `org-agenda-ndays' days.
15168 With prefix ARG, go back that many times `org-agenda-ndays'."
15170 (org-agenda-check-type t 'agenda)
15171 (let ((org-agenda-overriding-arguments
15172 (list (car org-agenda-last-arguments)
15173 (- org-starting-day (* arg org-agenda-ndays))
15175 (org-agenda-redo)
15176 (org-agenda-find-today-or-agenda)))
15178 (defun org-agenda-week-view ()
15179 "Switch to weekly view for agenda."
15181 (org-agenda-check-type t 'agenda)
15182 (if (= org-agenda-ndays 7)
15184 (setq org-agenda-ndays 7)
15185 (let ((org-agenda-overriding-arguments
15186 (list (car org-agenda-last-arguments)
15188 org-starting-day)
15190 (org-agenda-redo)
15191 (org-agenda-find-today-or-agenda))
15192 (org-agenda-set-mode-name)
15195 (defun org-agenda-day-view ()
15196 "Switch to daily view for agenda."
15198 (org-agenda-check-type t 'agenda)
15199 (if (= org-agenda-ndays 1)
15201 (setq org-agenda-ndays 1)
15202 (let ((org-agenda-overriding-arguments
15203 (list (car org-agenda-last-arguments)
15205 org-starting-day)
15207 (org-agenda-redo)
15208 (org-agenda-find-today-or-agenda))
15209 (org-agenda-set-mode-name)
15213 (defun org-agenda-next-date-line (&optional arg)
15214 "Jump to the next line indicating a date in agenda buffer."
15216 (org-agenda-check-type t 'agenda 'timeline)
15225 (defun org-agenda-previous-date-line (&optional arg)
15226 "Jump to the previous line indicating a date in agenda buffer."
15228 (org-agenda-check-type t 'agenda 'timeline)
15234 (defvar org-hl (org-make-overlay 1 1))
15235 (org-overlay-put org-hl 'face 'highlight)
15237 (defun org-highlight (begin end &optional buffer)
15240 org-hl begin end (or buffer (current-buffer))))
15242 (defun org-unhighlight ()
15244 (funcall (if (featurep 'xemacs) 'detach-extent 'delete-overlay) org-hl))
15246 (defun org-highlight-until-next-command (beg end &optional buffer)
15247 (org-highlight beg end buffer)
15248 (add-hook 'pre-command-hook 'org-unhighlight-once))
15250 (defun org-unhighlight-once ()
15251 (remove-hook 'pre-command-hook 'org-unhighlight-once)
15252 (org-unhighlight))
15254 (defun org-agenda-follow-mode ()
15255 "Toggle follow mode in an agenda buffer."
15257 (setq org-agenda-follow-mode (not org-agenda-follow-mode))
15258 (org-agenda-set-mode-name)
15260 (if org-agenda-follow-mode "on" "off")))
15262 (defun org-agenda-log-mode ()
15263 "Toggle log mode in an agenda buffer."
15265 (org-agenda-check-type t 'agenda 'timeline)
15266 (setq org-agenda-show-log (not org-agenda-show-log))
15267 (org-agenda-set-mode-name)
15268 (org-agenda-redo)
15270 (if org-agenda-show-log "on" "off")))
15272 (defun org-agenda-toggle-diary ()
15273 "Toggle diary inclusion in an agenda buffer."
15275 (org-agenda-check-type t 'agenda)
15276 (setq org-agenda-include-diary (not org-agenda-include-diary))
15277 (org-agenda-redo)
15278 (org-agenda-set-mode-name)
15280 (if org-agenda-include-diary "on" "off")))
15282 (defun org-agenda-toggle-time-grid ()
15283 "Toggle time grid in an agenda buffer."
15285 (org-agenda-check-type t 'agenda)
15286 (setq org-agenda-use-time-grid (not org-agenda-use-time-grid))
15287 (org-agenda-redo)
15288 (org-agenda-set-mode-name)
15290 (if org-agenda-use-time-grid "on" "off")))
15292 (defun org-agenda-set-mode-name ()
15293 "Set the mode name to indicate all the small mode settings."
15296 (if (equal org-agenda-ndays 1) " Day" "")
15297 (if (equal org-agenda-ndays 7) " Week" "")
15298 (if org-agenda-follow-mode " Follow" "")
15299 (if org-agenda-include-diary " Diary" "")
15300 (if org-agenda-use-time-grid " Grid" "")
15301 (if org-agenda-show-log " Log" "")))
15304 (defun org-agenda-post-command-hook ()
15306 (setq org-agenda-type (get-text-property (point) 'org-agenda-type))
15307 (if (and org-agenda-follow-mode
15308 (get-text-property (point) 'org-marker))
15309 (org-agenda-show)))
15311 (defun org-agenda-show-priority ()
15319 (defun org-agenda-show-tags ()
15325 (org-no-properties (mapconcat 'identity tags ":")))
15328 (defun org-agenda-goto (&optional highlight)
15331 (let* ((marker (or (get-text-property (point) 'org-marker)
15332 (org-agenda-error)))
15338 (when (org-mode-p)
15339 (org-show-context 'agenda)
15342 (org-flag-heading nil)))) ; show the next heading
15343 (and highlight (org-highlight (point-at-bol) (point-at-eol)))))
15345 (defun org-agenda-kill ()
15346 "Kill the entry or subtree belonging to the current agenda entry."
15348 (or (eq major-mode 'org-agenda-mode) (error "Not in agenda"))
15349 (let* ((marker (or (get-text-property (point) 'org-marker)
15350 (org-agenda-error)))
15354 (org-with-remote-undo buffer
15358 (if (org-mode-p)
15359 (setq dbeg (progn (org-back-to-heading t) (point))
15360 dend (org-end-of-subtree t))
15365 (setq conf (or (eq t org-agenda-confirm-kill)
15366 (and (numberp org-agenda-confirm-kill)
15367 (> n org-agenda-confirm-kill))))
15373 (org-remove-subtree-entries-from-agenda buffer dbeg dend)
15377 (defun org-agenda-archive ()
15378 "Kill the entry or subtree belonging to the current agenda entry."
15380 (or (eq major-mode 'org-agenda-mode) (error "Not in agenda"))
15381 (let* ((marker (or (get-text-property (point) 'org-marker)
15382 (org-agenda-error)))
15385 (org-with-remote-undo buffer
15387 (if (org-mode-p)
15390 (org-remove-subtree-entries-from-agenda)
15391 (org-back-to-heading t)
15392 (org-archive-subtree))
15393 (error "Archiving works only in Org-mode files"))))))
15395 (defun org-remove-subtree-entries-from-agenda (&optional buf beg end)
15396 "Remove all lines in the agenda that correspond to a given subtree.
15402 (org-back-to-heading t)
15404 (org-end-of-subtree t)
15406 (set-buffer (get-buffer org-agenda-buffer-name))
15411 (when (and (setq m (get-text-property (point) 'org-marker))
15420 (defun org-agenda-open-link ()
15425 (if (or (re-search-forward org-bracket-link-regexp eol t)
15426 (re-search-forward org-angle-link-re eol t)
15427 (re-search-forward org-plain-link-re eol t))
15428 (call-interactively 'org-open-at-point)
15431 (defun org-agenda-switch-to (&optional delete-other-windows)
15434 (let* ((marker (or (get-text-property (point) 'org-marker)
15435 (org-agenda-error)))
15442 (when (org-mode-p)
15443 (org-show-context 'agenda)
15446 (org-flag-heading nil)))))) ; show the next heading
15448 (defun org-agenda-goto-mouse (ev)
15452 (org-agenda-goto))
15454 (defun org-agenda-show ()
15458 (org-agenda-goto t)
15461 (defun org-agenda-recenter (arg)
15465 (org-agenda-goto t)
15469 (defun org-agenda-show-mouse (ev)
15473 (org-agenda-show))
15475 (defun org-agenda-check-no-diary ()
15477 (if (get-text-property (point) 'org-agenda-diary-link)
15478 (org-agenda-error)))
15480 (defun org-agenda-error ()
15483 (defun org-agenda-tree-to-indirect-buffer ()
15485 This calls the command `org-tree-to-indirect-buffer' from the original
15491 (org-agenda-check-no-diary)
15492 (let* ((marker (or (get-text-property (point) 'org-marker)
15493 (org-agenda-error)))
15499 (call-interactively 'org-tree-to-indirect-buffer)))))
15501 (defvar org-last-heading-marker (make-marker)
15503 by a remote command from the agenda.")
15505 (defun org-agenda-todo (&optional arg)
15507 This changes the line at point, all other lines in the agenda referring to
15510 (org-agenda-check-no-diary)
15512 (marker (or (get-text-property (point) 'org-marker)
15513 (org-agenda-error)))
15516 (hdmarker (get-text-property (point) 'org-hd-marker))
15519 (org-with-remote-undo buffer
15523 (org-show-context 'agenda)
15526 (org-flag-heading nil))) ; show the next heading
15527 (org-todo arg)
15529 (setq newhead (org-get-heading))
15531 (org-back-to-heading)
15532 (move-marker org-last-heading-marker (point))))
15535 (org-agenda-change-all-lines newhead hdmarker 'fixface))
15538 (defun org-agenda-change-all-lines (newhead hdmarker &optional fixface)
15539 "Change all lines in the agenda buffer which match HDMARKER.
15541 `org-format-agenda-item'). HDMARKER is checked with
15542 `equal' against all `org-hd-marker' text properties in the file.
15552 (when (and (setq m (get-text-property (point) 'org-hd-marker))
15556 cat (get-text-property (point) 'org-category)
15558 new (org-format-agenda-item "x" newhead cat tags dotime 'noprefix)
15575 (if org-last-todo-state-is-todo
15577 (org-agenda-highlight-todo 'line)
15581 (org-finalize-agenda)))
15583 ;; FIXME: allow negative value for org-agenda-align-tags-to-column
15585 (defun org-agenda-align-tags (&optional line)
15586 "Align all tags in agenda items to `org-agenda-align-tags-to-column'."
15594 (insert (org-add-props
15595 (make-string (max 1 (- org-agenda-align-tags-to-column
15599 (defun org-agenda-priority-up ()
15602 (org-agenda-priority 'up))
15604 (defun org-agenda-priority-down ()
15607 (org-agenda-priority 'down))
15609 (defun org-agenda-priority (&optional force-direction)
15611 This changes the line at point, all other lines in the agenda referring to
15614 (org-agenda-check-no-diary)
15615 (let* ((marker (or (get-text-property (point) 'org-marker)
15616 (org-agenda-error)))
15619 (hdmarker (get-text-property (point) 'org-hd-marker))
15622 (org-with-remote-undo buffer
15626 (org-show-context 'agenda)
15629 (org-flag-heading nil))) ; show the next heading
15630 (funcall 'org-priority force-direction)
15632 (setq newhead (org-get-heading)))
15633 (org-agenda-change-all-lines newhead hdmarker)
15636 (defun org-get-tags-at (&optional pos)
15637 "Get a list of all headline tags applicable at POS.
15648 (org-back-to-heading t)
15652 (setq tags (append (org-split-string
15653 (org-match-string-no-properties 1) ":")
15655 (or org-use-tag-inheritance (error ""))
15656 (org-up-heading-all 1))
15660 ;; FIXME: should fix the tags property of the agenda line.
15661 (defun org-agenda-set-tags ()
15664 (org-agenda-check-no-diary)
15665 (org-agenda-show) ;;; FIXME This is a stupid hack and should not be needed
15666 (let* ((hdmarker (or (get-text-property (point) 'org-hd-marker)
15667 (org-agenda-error)))
15672 (org-with-remote-undo buffer
15676 (org-show-context 'agenda)
15679 (org-flag-heading nil))) ; show the next heading
15680 (call-interactively 'org-set-tags)
15682 (setq newhead (org-get-heading)))
15683 (org-agenda-change-all-lines newhead hdmarker)
15686 (defun org-agenda-toggle-archive-tag ()
15689 (org-agenda-check-no-diary)
15690 (org-agenda-show) ;;; FIXME This is a stupid hack and should not be needed
15691 (let* ((hdmarker (or (get-text-property (point) 'org-hd-marker)
15692 (org-agenda-error)))
15697 (org-with-remote-undo buffer
15701 (org-show-context 'agenda)
15704 (org-flag-heading nil))) ; show the next heading
15705 (call-interactively 'org-toggle-archive-tag)
15707 (setq newhead (org-get-heading)))
15708 (org-agenda-change-all-lines newhead hdmarker)
15711 (defun org-agenda-date-later (arg &optional what)
15714 (org-agenda-check-type t 'agenda 'timeline)
15715 (org-agenda-check-no-diary)
15716 (let* ((marker (or (get-text-property (point) 'org-marker)
15717 (org-agenda-error)))
15720 (org-with-remote-undo buffer
15724 (if (not (org-at-timestamp-p))
15726 (org-timestamp-change arg (or what 'day)))
15727 (org-agenda-show-new-time marker org-last-changed-timestamp))
15728 (message "Time stamp changed to %s" org-last-changed-timestamp)))
15730 (defun org-agenda-date-earlier (arg &optional what)
15733 (org-agenda-date-later (- arg) what))
15735 (defun org-agenda-show-new-time (marker stamp)
15743 (when (equal marker (get-text-property (point) 'org-marker))
15755 (list 'display (org-add-props stamp nil
15760 (defun org-agenda-date-prompt (arg)
15762 The prefix ARG is passed to the `org-time-stamp' command and can therefore
15765 (org-agenda-check-type t 'agenda 'timeline)
15766 (org-agenda-check-no-diary)
15767 (let* ((marker (or (get-text-property (point) 'org-marker)
15768 (org-agenda-error)))
15771 (org-with-remote-undo buffer
15775 (if (not (org-at-timestamp-p))
15777 (org-time-stamp arg)
15778 (message "Time stamp changed to %s" org-last-changed-timestamp)))))
15780 (defun org-agenda-schedule (arg)
15783 (org-agenda-check-type t 'agenda 'timeline 'todo 'tags)
15784 (org-agenda-check-no-diary)
15785 (let* ((marker (or (get-text-property (point) 'org-marker)
15786 (org-agenda-error)))
15789 (org-insert-labeled-timestamps-at-point nil)
15791 (org-with-remote-undo buffer
15795 (setq ts (org-schedule))
15798 (defun org-agenda-deadline (arg)
15801 (org-agenda-check-type t 'agenda 'timeline 'todo 'tags)
15802 (org-agenda-check-no-diary)
15803 (let* ((marker (or (get-text-property (point) 'org-marker)
15804 (org-agenda-error)))
15807 (org-insert-labeled-timestamps-at-point nil)
15809 (org-with-remote-undo buffer
15813 (setq ts (org-deadline))
15816 (defun org-get-heading ()
15819 (org-back-to-heading t)
15822 (defun org-agenda-clock-in (&optional arg)
15825 (org-agenda-check-no-diary)
15826 (let* ((marker (or (get-text-property (point) 'org-marker)
15827 (org-agenda-error)))
15829 (org-with-remote-undo (marker-buffer marker)
15833 (org-clock-in)))))
15835 (defun org-agenda-clock-out (&optional arg)
15838 (unless (marker-buffer org-clock-marker)
15840 (org-with-remote-undo (marker-buffer org-clock-marker)
15841 (org-clock-out)))
15843 (defun org-agenda-clock-cancel (&optional arg)
15846 (unless (marker-buffer org-clock-marker)
15848 (org-with-remote-undo (marker-buffer org-clock-marker)
15849 (org-clock-cancel)))
15851 (defun org-agenda-diary-entry ()
15855 (org-agenda-check-type t 'agenda 'timeline)
15894 (defun org-agenda-execute-calendar-command (cmd)
15895 "Execute a calendar command from the agenda, with the date associated to
15897 (org-agenda-check-type t 'agenda 'timeline)
15918 (defun org-agenda-phases-of-moon ()
15921 (org-agenda-execute-calendar-command 'calendar-phases-of-moon))
15923 (defun org-agenda-holidays ()
15926 (org-agenda-execute-calendar-command 'list-calendar-holidays))
15928 (defun org-agenda-sunrise-sunset (arg)
15938 (org-agenda-execute-calendar-command 'calendar-sunrise-sunset)))
15940 (defun org-agenda-goto-calendar ()
15943 (org-agenda-check-type t 'agenda 'timeline)
15953 (defun org-calendar-goto-agenda ()
15954 "Compute the Org-mode agenda for the calendar date displayed at the cursor.
15957 (org-agenda-list nil (calendar-absolute-from-gregorian
15961 (defun org-agenda-convert-date ()
15963 (org-agenda-check-type t 'agenda 'timeline)
15992 (defvar org-cdlatex-mode-map (make-sparse-keymap)
15993 "Keymap for the minor `org-cdlatex-mode'.")
15995 (define-key org-cdlatex-mode-map "_" 'org-cdlatex-underscore-caret)
15996 (define-key org-cdlatex-mode-map "^" 'org-cdlatex-underscore-caret)
15997 (define-key org-cdlatex-mode-map "`" 'cdlatex-math-symbol)
15998 (define-key org-cdlatex-mode-map "'" 'org-cdlatex-math-modify)
15999 (define-key org-cdlatex-mode-map "\C-c{" 'cdlatex-environment)
16001 (defvar org-cdlatex-texmathp-advice-is-done nil
16004 (define-minor-mode org-cdlatex-mode
16005 "Toggle the minor `org-cdlatex-mode'.
16008 \\{org-cdlatex-mode-map}"
16010 (when org-cdlatex-mode (require 'cdlatex))
16011 (unless org-cdlatex-texmathp-advice-is-done
16012 (setq org-cdlatex-texmathp-advice-is-done t)
16013 (defadvice texmathp (around org-math-always-on activate)
16014 "Always return t in org-mode buffers.
16018 \\[org-cdlatex-mode-map]"
16022 ((not (org-mode-p)) ad-do-it)
16025 texmathp-why '("cdlatex-math-symbol in org-mode" . 0)))
16027 (let ((p (org-inside-LaTeX-fragment-p)))
16028 (if (and p (member (car p) (plist-get org-format-latex-options :matchers)))
16033 (defun turn-on-org-cdlatex ()
16034 "Unconditionally turn on `org-cdlatex-mode'."
16035 (org-cdlatex-mode 1))
16037 (defun org-inside-LaTeX-fragment-p ()
16055 (dodollar (member "$" (plist-get org-format-latex-options :matchers)))
16063 re (nth 1 (assoc "$" org-latex-regexps)))
16082 (defun org-try-cdlatex-tab ()
16084 It makes sense to do so if `org-cdlatex-mode' is active and if the cursor is
16088 (when org-cdlatex-mode
16095 ((org-inside-LaTeX-fragment-p)
16099 (defun org-cdlatex-underscore-caret (&optional arg)
16103 (if (org-inside-LaTeX-fragment-p)
16105 (let (org-cdlatex-mode)
16108 (defun org-cdlatex-math-modify (&optional arg)
16112 (if (org-inside-LaTeX-fragment-p)
16114 (let (org-cdlatex-mode)
16117 (defvar org-latex-fragment-image-overlays nil
16119 (make-variable-buffer-local 'org-latex-fragment-image-overlays)
16121 (defun org-remove-latex-fragment-image-overlays ()
16122 "Remove all overlays with LaTeX fragment images in current buffer."
16123 (mapc 'org-delete-overlay org-latex-fragment-image-overlays)
16124 (setq org-latex-fragment-image-overlays nil))
16126 (defun org-preview-latex-fragment (&optional subtree)
16127 "Preview the LaTeX fragment at point, or all locally or globally.
16130 all fragments in the current text, from one headline to the next. With
16131 prefix SUBTREE, display all fragments in the current subtree. With a
16133 display all fragments in the buffer.
16134 The images can be removed again with \\[org-ctrl-c-ctrl-c]."
16136 (org-remove-latex-fragment-image-overlays)
16147 (org-back-to-heading)
16148 (setq beg (point) end (org-end-of-subtree t)
16151 (if (setq at (org-inside-LaTeX-fragment-p))
16153 (org-back-to-heading))
16159 (org-format-latex
16166 (defvar org-latex-regexps
16169 ;; \000 in the following regex is needed for org-inside-LaTeX-fragment-p
16176 (defun org-format-latex (prefix &optional dir overlays msg at)
16182 (opt org-format-latex-options)
16184 (re-list org-latex-regexps)
16187 ;; Check if there are old images files with this prefix, and remove them
16190 (directory-files
16212 (org-create-formula-image
16216 (setq ov (org-make-overlay beg end))
16219 (org-overlay-put ov 'invisible t)
16220 (org-overlay-put
16223 (org-overlay-put
16226 (push ov org-latex-fragment-image-overlays)
16232 (defun org-create-formula-image (string tofile options)
16283 (defconst org-level-max 20)
16285 (defvar org-export-html-preamble nil
16287 (defvar org-export-html-postamble nil
16289 (defvar org-export-html-auto-preamble t
16291 (defvar org-export-html-auto-postamble t
16293 (defvar org-current-export-file nil) ; dynamically scoped parameter
16294 (defvar org-current-export-dir nil) ; dynamically scoped parameter
16297 (defconst org-export-plist-vars
16298 '((:language . org-export-default-language)
16299 (:customtime . org-display-custom-times)
16300 (:headline-levels . org-export-headline-levels)
16301 (:section-numbers . org-export-with-section-numbers)
16302 (:table-of-contents . org-export-with-toc)
16303 (:archived-trees . org-export-with-archived-trees)
16304 (:emphasize . org-export-with-emphasize)
16305 (:sub-superscript . org-export-with-sub-superscripts)
16306 (:TeX-macros . org-export-with-TeX-macros)
16307 (:LaTeX-fragments . org-export-with-LaTeX-fragments)
16308 (:fixed-width . org-export-with-fixed-width)
16309 (:timestamps . org-export-with-timestamps)
16310 (:tables . org-export-with-tables)
16311 (:table-auto-headline . org-export-highlight-first-table-line)
16312 (:style . org-export-html-style)
16313 (:convert-org-links . org-export-html-link-org-files-as-html)
16314 (:inline-images . org-export-html-inline-images)
16315 (:expand-quoted-html . org-export-html-expand)
16316 (:timestamp . org-export-html-with-timestamp)
16317 (:publishing-directory . org-export-publishing-directory)
16318 (:preamble . org-export-html-preamble)
16319 (:postamble . org-export-html-postamble)
16320 (:auto-preamble . org-export-html-auto-preamble)
16321 (:auto-postamble . org-export-html-auto-postamble)
16325 (defun org-default-export-plist ()
16326 "Return the property list with default settings for the export variables."
16327 (let ((l org-export-plist-vars) rtn e)
16332 (defun org-infile-export-plist ()
16333 "Return the property list with file-local settings for export."
16336 (let ((re (org-make-options-regexp
16340 (setq key (org-match-string-no-properties 1)
16341 val (org-match-string-no-properties 2))
16373 (defun org-export-directory (type plist)
16380 (defun org-export-find-first-heading-line (list)
16381 "Remove all lines from LIST which are before the first headline."
16389 (defun org-skip-comments (lines)
16391 (let ((re1 (concat "^\\(\\*+\\)[ \t]+" org-comment-string))
16406 ((and org-export-table-remove-special-lines
16416 (defun org-export (&optional arg)
16418 (let ((help "[t] insert the export option template
16419 \[v] limit export to visible part of outline tree
16421 \[a] export as ASCII
16422 \[h] export as HTML
16423 \[b] export as HTML and browse immediately
16424 \[x] export as XOXO
16426 \[i] export current file as iCalendar file
16427 \[I] export all agenda files as iCalendar files
16428 \[c] export agenda files into combined iCalendar file
16433 \[A] publish all projects")
16435 '((?t . org-insert-export-options-template)
16436 (?v . org-export-visible)
16437 (?a . org-export-as-ascii)
16438 (?h . org-export-as-html)
16439 (?b . org-export-as-html-and-open)
16440 (?x . org-export-as-xoxo)
16441 (?i . org-export-icalendar-this-file)
16442 (?I . org-export-icalendar-all-agenda-files)
16443 (?c . org-export-icalendar-combine-agenda-files)
16444 (?F . org-publish-current-file)
16445 (?P . org-publish-current-project)
16446 (?X . org-publish)
16447 (?A . org-publish-all)))
16460 (defconst org-html-entities
16758 ;;; General functions for all backends
16760 (defun org-cleaned-string-for-export (string &rest parameters)
16763 (let* ((re-radio (and org-target-link-regexp
16764 (concat "\\([^<]\\)\\(" org-target-link-regexp "\\)")))
16765 (re-plain-link (concat "\\([^[<]\\)" org-plain-link-re))
16766 (re-angle-link (concat "\\([^[]\\)" org-angle-link-re))
16767 (re-archive (concat ":" org-archive-tag ":"))
16768 (re-quote (concat "^\\*+[ \t]+" org-quote-string "\\>"))
16773 (set-buffer (get-buffer-create " org-mode-tmp"))
16776 (let ((org-inhibit-startup t)) (org-mode))
16780 (when (not (eq org-export-with-archived-trees t))
16783 (if (not (org-on-heading-p))
16784 (org-end-of-subtree t)
16787 (if org-export-with-archived-trees (1+ (point-at-eol)) (point))
16788 (org-end-of-subtree t)))))
16794 '(org-protected t)))
16801 '(org-protected t))))
16807 '(org-protected t))
16813 (add-text-properties (point) (org-end-of-subtree t)
16814 '(org-protected t)))
16831 (org-if-unprotected
16834 ;; Find all links that contain a newline and put them into a single line
16837 (org-if-unprotected
16843 (org-format-latex
16846 org-current-export-file)))
16847 org-current-export-dir nil "Creating LaTeX image %s"))
16854 (org-if-unprotected
16861 (org-if-unprotected
16867 (while (re-search-forward org-bracket-link-regexp nil t)
16868 (org-if-unprotected
16871 (org-link-expand-abbrev (match-string 1)))
16882 (while (re-search-forward org-emph-re nil t)
16883 (org-if-unprotected
16888 (kill-buffer " org-mode-tmp")
16891 (defun org-solidify-link-text (s &optional alist)
16897 (org-split-string s "[ \t\r\n]+") "--"))
16902 (defvar org-section-numbers (make-vector org-level-max 0))
16904 (defun org-init-section-numbers ()
16907 (numbers (nreverse (org-split-string "" "\\.")))
16908 (depth (1- (length org-section-numbers)))
16912 (aset org-section-numbers i 0)
16915 (aset org-section-numbers i
16917 (aset org-section-numbers i (string-to-number number-string)))
16921 (defun org-section-number (&optional level)
16924 (let* ((depth (1- (length org-section-numbers))) idx n (string ""))
16927 (aset org-section-numbers
16928 level (1+ (aref org-section-numbers level))))
16932 (aset org-section-numbers idx 0))
16936 (setq n (aref org-section-numbers idx))
16947 ;;; ASCII export
16949 (defvar org-last-level nil) ; dynamically scoped variable
16950 (defvar org-levels-open nil) ; dynamically scoped parameter
16951 (defvar org-ascii-current-indentation nil) ; For communication
16953 (defun org-export-as-ascii (arg)
16955 If there is an active region, export only the region.
16959 (setq-default org-todo-line-regexp org-todo-line-regexp)
16960 (let* ((opt-plist (org-combine-plists (org-default-export-plist)
16961 (org-infile-export-plist)))
16964 (if (org-region-active-p) (region-beginning) (point-min))
16965 (if (org-region-active-p) (region-end) (point-max))))
16966 (custom-times org-display-custom-times)
16967 (lines (org-export-find-first-heading-line
16968 (org-skip-comments
16969 (org-split-string
16970 (org-cleaned-string-for-export region)
16972 (org-ascii-current-indentation '(0 . 0))
16978 (org-export-directory :ascii opt-plist))
16983 (org-levels-open (make-vector org-level-max nil))
16984 (odd org-odd-levels-only)
16986 (time (format-time-string "%X" (org-current-time)))
16993 (quote-re0 (concat "^[ \t]*" org-quote-string "\\>"))
16994 ; (quote-re (concat "^\\(\\*+\\)\\([ \t]*" org-quote-string "\\>\\)"))
16999 (setq org-last-level 1)
17000 (org-init-section-numbers)
17004 (setq lang-words (or (assoc language org-export-language-setup)
17005 (assoc "en" org-export-language-setup)))
17009 ;; create local variables for all options, to make sure all called
17014 org-export-plist-vars)
17015 (org-set-local 'org-odd-levels-only odd)
17017 org-export-headline-levels))
17018 (setq umax-toc (if (integerp org-export-with-toc)
17019 (min org-export-with-toc umax)
17023 (if title (org-insert-centered title ?=))
17031 (if text (insert (concat (org-html-expand-for-ascii text) "\n\n")))
17035 (if org-export-with-toc
17040 (if (string-match org-todo-line-regexp
17045 level (org-tr-level level)
17048 (or (and org-export-mark-todo-in-toc
17051 org-done-string)))
17053 (and org-export-mark-todo-in-toc
17055 (org-search-todo-below
17057 (setq txt (org-html-expand-for-ascii txt))
17059 (if (and (memq org-export-with-tags '(not-in-toc nil))
17065 (if org-export-with-section-numbers
17066 (setq txt (concat (org-section-number level)
17073 (setq org-last-level level))
17077 (org-init-section-numbers)
17080 (setq line (org-html-expand-for-ascii line))
17085 (while (string-match org-bracket-link-regexp line)
17090 (setq line (org-translate-time line)))
17094 (setq level (org-tr-level (- (match-end 1) (match-beginning 1)))
17096 (org-ascii-level-start level txt umax lines))
17098 (insert (org-fix-indentation line org-ascii-current-indentation) "\n"))))
17110 (while (setq beg (next-single-property-change (point) 'org-cwidth))
17111 (setq end (next-single-property-change beg 'org-cwidth))
17116 (defun org-search-todo-below (line lines level)
17119 (re org-todo-line-regexp)
17128 org-done-string))))
17133 (defun org-html-expand-for-ascii (line)
17134 "Handle quoted HTML for ASCII export."
17135 (if org-export-html-expand
17141 (defun org-insert-centered (s &optional underline)
17150 (defun org-ascii-level-start (level title umax &optional lines)
17151 "Insert a new level in ASCII export."
17156 (char-to-string (nth (% n (length org-export-ascii-bullets))
17157 org-export-ascii-bullets))
17164 (throw 'stop (setq ind (org-get-indentation (car lines)))))
17166 (setq org-ascii-current-indentation (cons (* 2 (1+ n)) ind)))
17170 (setq char (nth (- umax level) (reverse org-export-ascii-underline)))
17171 (unless org-export-with-tags
17174 (if org-export-with-section-numbers
17175 (setq title (concat (org-section-number level) " " title)))
17177 (setq org-ascii-current-indentation '(0 . 0)))))
17179 (defun org-export-visible (type arg)
17180 "Create a copy of the visible part of the current buffer, and export it.
17182 TYPE is the final key (as a string) that also select the export command in
17183 the `C-c C-e' export dispatcher.
17185 org-mode file will not be removed but presented to you so that you can
17194 (error "Invalid export key"))
17196 '((?a . org-export-as-ascii)
17197 (?\C-a . org-export-as-ascii)
17198 (?b . org-export-as-html-and-open)
17199 (?\C-b . org-export-as-html-and-open)
17200 (?h . org-export-as-html)
17201 (?x . org-export-as-xoxo)))))
17210 (goto-char (org-find-invisible))
17212 (setq s (goto-char (org-find-visible))))
17215 ;; Copy all comment lines to the end, to make sure #+ settings are
17216 ;; still available for the second export step. Kind of a hack, but
17225 (org-inhibit-startup t))
17226 (org-mode)
17227 (show-all)
17234 (defun org-find-visible ()
17239 (defun org-find-invisible ()
17245 ;;; HTML export
17247 (defun org-get-current-options ()
17249 Does include HTML export options as well as TODO and CATEGORY stuff."
17265 (buffer-name) (user-full-name) user-mail-address org-export-default-language
17266 org-export-headline-levels
17267 org-export-with-section-numbers
17268 org-export-with-toc
17269 org-export-preserve-breaks
17270 org-export-html-expand
17271 org-export-with-fixed-width
17272 org-export-with-tables
17273 org-export-with-sub-superscripts
17274 org-export-with-emphasize
17275 org-export-with-TeX-macros
17276 org-export-with-LaTeX-fragments
17278 (if (equal org-todo-interpretation 'sequence)
17279 (mapconcat 'identity org-todo-keywords " ")
17281 (if (equal org-todo-interpretation 'type)
17282 (mapconcat 'identity org-todo-keywords " ")
17284 (cdr (assoc org-startup-folded
17286 (if org-odd-levels-only "odd" "oddeven")
17287 (if org-hide-leading-stars "hidestars" "showstars")
17288 (if org-startup-align-all-tables "align" "noalign")
17289 (cond ((eq t org-log-done) "logdone")
17290 ((not org-log-done) "nologging")
17291 ((listp org-log-done)
17293 org-log-done " ")))
17300 (or org-tag-alist (org-get-buffer-tags)) " ") "")
17301 org-archive-location
17302 "org file:~/org/%s.org"
17305 (defun org-insert-export-options-template ()
17309 (let ((s (org-get-current-options)))
17314 (defun org-toggle-fixed-width-section (arg)
17315 "Toggle the fixed-width export.
17324 (regionp (org-region-active-p))
17349 (org-back-to-heading)
17351 "\\( +\\<" org-quote-string "\\>\\)"))
17356 (insert " " org-quote-string))))))))
17358 (defun org-export-as-html-and-open (arg)
17360 If there is an active region, export only the region.
17364 (org-export-as-html arg 'hidden)
17365 (org-open-file buffer-file-name))
17367 (defun org-export-as-html-batch ()
17368 "Call `org-export-as-html', may be used in batch processing as
17370 --load=$HOME/lib/emacs/org.el
17371 --eval \"(setq org-export-headline-levels 2)\"
17372 --visit=MyFile --funcall org-export-as-html-batch"
17373 (org-export-as-html org-export-headline-levels 'hidden))
17375 (defun org-export-as-html (arg &optional hidden ext-plist)
17377 If there is an active region, export only the region.
17382 org-mode's default settings, but still inferior to file-local settings."
17385 (setq-default org-todo-line-regexp org-todo-line-regexp)
17386 (setq-default org-deadline-line-regexp org-deadline-line-regexp)
17387 (setq-default org-done-string org-done-string)
17388 (setq-default org-maybe-keyword-time-regexp org-maybe-keyword-time-regexp)
17389 (let* ((opt-plist (org-combine-plists (org-default-export-plist)
17391 (org-infile-export-plist)))
17396 (odd org-odd-levels-only)
17397 (region-p (org-region-active-p))
17404 (org-current-export-dir (org-export-directory :html opt-plist))
17405 (org-current-export-file buffer-file-name)
17407 (org-skip-comments (org-split-string
17408 (org-cleaned-string-for-export
17413 (lines (org-export-find-first-heading-line all_lines))
17418 (org-export-directory :html opt-plist))
17424 (org-levels-open (make-vector org-level-max nil))
17426 (time (format-time-string "%X" (org-current-time)))
17431 (quote-re0 (concat "^[ \t]*" org-quote-string "\\>"))
17432 (quote-re (concat "^\\(\\*+\\)\\([ \t]*" org-quote-string "\\>\\)"))
17438 (llt org-plain-list-ordered-item-terminator)
17460 (setq org-last-level 1)
17461 (org-init-section-numbers)
17464 (setq lang-words (or (assoc language org-export-language-setup)
17465 (assoc "en" org-export-language-setup)))
17474 (org-odd-levels-only odd))
17475 ;; create local variables for all options, to make sure all called
17480 org-export-plist-vars)
17482 org-export-headline-levels))
17483 (setq umax-toc (if (integerp org-export-with-toc)
17484 (min org-export-with-toc umax)
17490 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
17491 <html xmlns=\"http://www.w3.org/1999/xhtml\"
17502 language language (org-html-expand title) (or charset "iso-8859-1")
17509 (if title (insert (format org-export-html-title-format
17510 (org-html-expand title))))
17511 (if text (insert "<p>\n" (org-html-expand text) "</p>")))
17513 (if org-export-with-toc
17516 org-export-html-toplevel-hlevel
17518 org-export-html-toplevel-hlevel))
17522 (if (string-match org-todo-line-regexp line)
17526 level (org-tr-level level)
17528 (org-html-expand
17529 (org-export-cleanup-toc-line
17532 (or (and org-export-mark-todo-in-toc
17535 org-done-string)))
17537 (and org-export-mark-todo-in-toc
17539 (org-search-todo-below
17541 (if (and (memq org-export-with-tags '(not-in-toc nil))
17546 (if org-export-with-section-numbers
17547 (setq txt (concat (org-section-number level)
17552 (if (> level org-last-level)
17554 (setq cnt (- level org-last-level))
17558 (if (< level org-last-level)
17560 (setq cnt (- org-last-level level))
17565 (while (string-match org-target-regexp line)
17570 (push (cons (org-solidify-link-text tg)
17582 (setq org-last-level level))
17586 (while (> org-last-level 0)
17587 (setq org-last-level (1- org-last-level))
17591 (org-init-section-numbers)
17602 (insert (org-html-protect line) "\n")
17606 (when (and org-export-with-fixed-width
17611 (insert (org-html-protect (match-string 1 line)) "\n")
17620 (when (get-text-property 0 'org-protected line)
17635 (org-solidify-link-text (match-string 1 line))
17638 ((and org-export-with-toc (equal (string-to-char line) ?*))
17646 (org-solidify-link-text (match-string 1 line))
17650 (setq line (org-html-handle-time-stamps line))
17655 (setq line (org-html-expand line))
17659 (while (string-match org-bracket-link-analytic-regexp line start)
17668 (when (and descp (org-file-image-p desc))
17679 (org-solidify-link-text path target-alist)
17683 (if (and (or (eq t org-export-html-inline-images)
17684 (and org-export-html-inline-images (not descp)))
17685 (org-file-image-p path))
17706 (setq file-is-image-p (org-file-image-p filename))
17708 (when (and org-export-html-link-org-files-as-html
17709 (string-match "\\.org$" thefile))
17719 (org-solidify-link-text
17720 (org-link-unescape search)))))
17723 (if (string-match "\\.org$" desc)
17726 (or (eq t org-export-html-inline-images)
17727 (and org-export-html-inline-images
17734 (save-match-data (org-link-unescape path))
17739 (if (and (string-match org-todo-line-regexp line)
17741 (if (equal (match-string 2 line) org-done-string)
17751 (setq level (org-tr-level (- (match-end 1) (match-beginning 1)))
17759 (org-close-li)
17764 (org-html-level-start level txt umax
17765 (and org-export-with-toc (<= level umax))
17772 ((and org-export-with-tables
17786 (org-close-par-maybe)
17787 (insert (org-format-table-html table-buffer table-orig-buffer))))
17795 (t (error "Invalid value of `org-plain-list-ordered-item-terminator'")))
17797 (setq ind (org-get-string-indentation line)
17809 (org-close-li)
17818 (org-close-par-maybe)
17825 (org-close-li)
17838 (if (string-match "^ [-+*]-\\|^[ \t]*$" line) (org-open-par))
17844 (org-export-preserve-breaks
17849 ;; Properly close all local lists and other lists
17854 (org-close-li)
17859 (org-html-level-start 1 nil umax
17860 (and org-export-with-toc (<= level umax))
17876 (if org-export-html-with-timestamp
17877 (insert org-export-html-html-helper-timestamp))
17893 (defun org-format-table-html (lines olines)
17896 ;; A normal org table
17897 (org-format-org-table-html lines)
17911 (not org-export-prefer-native-exporter-for-tables))
17913 (org-format-table-table-html lines)
17915 (org-format-table-table-html-using-table-generate-source olines)))))
17917 (defun org-format-org-table-html (lines &optional splice)
17924 (when org-export-table-remove-special-lines
17927 (setq lines (org-table-clean-before-export lines)))
17929 (let ((head (and org-export-highlight-first-table-line
17949 (setq fields (org-split-string line "[ \t]*|[ \t]*"))
17957 (string-match org-table-number-regexp x))
17973 (if (> (/ (float x) nlines) org-table-number-fraction)
17977 (push org-export-html-table-tag html))
17980 (defun org-table-clean-before-export (lines)
17989 (setq org-table-clean-did-remove-column-1 nil)
17991 (setq org-table-clean-did-remove-column-1 t)
18001 (defun org-fake-empty-table-line (line)
18011 (defun org-format-table-table-html (lines)
18017 (head org-export-highlight-first-table-line)
18019 (setq html (concat org-export-html-table-tag "\n"))
18043 (setq fields (org-split-string line "[ \t]*|[ \t]*"))
18053 (defun org-format-table-table-html-using-table-generate-source (lines)
18058 (with-current-buffer (get-buffer-create " org-tmp1 ")
18065 (with-current-buffer (get-buffer-create " org-tmp2 ") (erase-buffer))
18066 (table-generate-source 'html " org-tmp2 ")
18067 (set-buffer " org-tmp2 ")
18070 (defun org-html-handle-time-stamps (s)
18074 (while (string-match org-maybe-keyword-time-regexp s)
18075 (if (and (match-end 1) (equal (match-string 1 s) org-clock-string))
18076 ;; never export CLOCK
18079 (if (not org-export-with-timestamps)
18089 (org-translate-time (match-string 3 s)) 1 -1)))
18099 (defun org-html-protect (s)
18111 (defun org-export-cleanup-toc-line (s)
18115 (when org-export-remove-timestamps-from-toc
18116 (while (string-match org-maybe-keyword-time-regexp s)
18120 (defun org-html-expand (string)
18121 "Prepare STRING for HTML export. Applies all active conversions.
18124 (while (setq m (string-match org-bracket-link-regexp string))
18128 (push (org-html-do-expand s) res)
18130 (push (org-html-do-expand string) res)
18133 (defun org-html-do-expand (s)
18134 "Apply all active conversions to translate special ASCII to HTML."
18135 (setq s (org-html-protect s))
18136 (if org-export-html-expand
18139 (if org-export-with-emphasize
18140 (setq s (org-export-html-convert-emphasize s)))
18141 (if org-export-with-sub-superscripts
18142 (setq s (org-export-html-convert-sub-super s)))
18143 (if org-export-with-TeX-macros
18147 (if (setq ass (assoc wd org-html-entities))
18154 (defun org-create-multibrace-regexp (left right n)
18172 (defvar org-match-substring-regexp
18175 "\\(" (org-create-multibrace-regexp "{" "}" org-match-sexp-depth) "\\)"
18177 "\\(" (org-create-multibrace-regexp "(" ")" org-match-sexp-depth) "\\)"
18182 (defun org-export-html-convert-sub-super (string)
18185 (while (string-match org-match-substring-regexp string)
18198 (defun org-export-html-convert-emphasize (string)
18200 (while (string-match org-emph-re string)
18201 (setq string (replace-match (concat "\\1" (nth 2 (assoc (match-string 3 string) org-emphasis-alist)) "\\4" (nth 3 (assoc (match-string 3 string) org-emphasis-alist)) "\\5") t nil string)))
18204 (defvar org-par-open nil)
18205 (defun org-open-par ()
18207 (org-close-par-maybe)
18209 (setq org-par-open t))
18210 (defun org-close-par-maybe ()
18212 (when org-par-open
18214 (setq org-par-open nil)))
18215 (defun org-close-li ()
18217 (org-close-par-maybe)
18224 (defun org-html-level-start (level title umax with-toc head-count)
18225 "Insert a new level in HTML export.
18226 When TITLE is nil, just close all open levels."
18227 (org-close-par-maybe)
18229 (while (<= l org-level-max)
18230 (if (aref org-levels-open (1- l))
18232 (org-html-level-close l)
18233 (aset org-levels-open (1- l) nil)))
18237 ;; all levels, so the rest is done only if title is given
18240 (if org-export-with-tags
18244 (mapconcat 'identity (org-split-string
18252 (if (aref org-levels-open (1- level))
18254 (org-close-li)
18256 (aset org-levels-open (1- level) t)
18257 (org-close-par-maybe)
18259 (if org-export-with-section-numbers
18260 (setq title (concat (org-section-number level) " " title)))
18261 (setq level (+ level org-export-html-toplevel-hlevel -1))
18266 (org-open-par)))))
18268 (defun org-html-level-close (&rest args)
18269 "Terminate one level in HTML export."
18270 (org-close-li)
18273 ;;; iCalendar export
18276 (defun org-export-icalendar-this-file ()
18281 (org-export-icalendar nil buffer-file-name))
18284 (defun org-export-icalendar-all-agenda-files ()
18285 "Export all files in `org-agenda-files' to iCalendar .ics files.
18289 (apply 'org-export-icalendar nil (org-agenda-files t)))
18292 (defun org-export-icalendar-combine-agenda-files ()
18293 "Export all files in `org-agenda-files' to a single combined iCalendar file.
18294 The file is stored under the name `org-combined-agenda-icalendar-file'."
18296 (apply 'org-export-icalendar t (org-agenda-files t)))
18298 (defun org-export-icalendar (combine &rest files)
18299 "Create iCalendar files for all elements of FILES.
18300 If COMBINE is non-nil, combine all calendar entries into a single large
18301 file and store it under the name `org-combined-agenda-icalendar-file'."
18303 (let* ((dir (org-export-directory
18305 org-export-publishing-directory)))
18306 file ical-file ical-buffer category started org-agenda-new-buffers)
18310 (if (file-name-absolute-p org-combined-agenda-icalendar-file)
18311 org-combined-agenda-icalendar-file
18312 (expand-file-name org-combined-agenda-icalendar-file dir))
18313 ical-buffer (org-get-agenda-file-buffer ical-file))
18315 (while (setq file (pop files))
18317 (org-check-agenda-file file)
18318 (set-buffer (org-get-agenda-file-buffer file))
18324 (setq ical-buffer (org-get-agenda-file-buffer ical-file))
18326 (setq category (or org-category
18333 (org-start-icalendar-file org-icalendar-combined-name))
18334 (org-start-icalendar-file category))
18335 (org-print-icalendar-entries combine)
18336 (when (or (and combine (not files)) (not combine))
18337 (org-finish-icalendar-file)
18340 (run-hooks 'org-after-save-iCalendar-file-hook)))))
18341 (org-release-buffers org-agenda-new-buffers))))
18343 (defvar org-after-save-iCalendar-file-hook nil
18349 (defun org-print-icalendar-entries (&optional combine)
18352 (let ((re2 (concat "--?-?\\(" org-ts-regexp "\\)"))
18353 (org-category-table (org-get-category-table))
18354 (dts (org-ical-ts-to-string
18355 (format-time-string (cdr org-time-stamp-formats) (current-time))
18361 (while (re-search-forward org-ts-regexp nil t)
18365 hd (org-get-heading)
18366 category (org-get-category))
18373 (- pos org-ds-keyword-length))
18375 deadlinep (string-match org-deadline-regexp tmp)
18376 scheduledp (string-match org-scheduled-regexp tmp)
18377 ;; donep (org-entry-is-done-p)
18379 (if (or (string-match org-tr-regexp hd)
18380 (string-match org-ts-regexp hd))
18382 (if (string-match org-bracket-link-regexp hd)
18394 (org-ical-ts-to-string ts "DTSTART")
18395 (org-ical-ts-to-string ts2 "DTEND" inc)
18397 (when org-icalendar-include-todo
18399 (while (re-search-forward org-todo-line-regexp nil t)
18401 (setq status (if (equal state org-done-string)
18404 (or (not (equal state org-done-string))
18405 (eq org-icalendar-include-todo 'all)))
18407 (if (string-match org-priority-regexp hd)
18411 (setq pri org-default-priority))
18412 (setq pri (floor (1+ (* 8. (/ (float (- org-lowest-priority pri))
18413 (- org-lowest-priority ?A))))))
18425 (defun org-start-icalendar-file (name)
18438 (defun org-finish-icalendar-file ()
18442 (defun org-ical-ts-to-string (s keyword &optional inc)
18447 (let ((t1 (org-parse-time-string s 'nodefault))
18451 (setq t2 (org-parse-time-string s)))
18460 ;;; XOXO export
18462 (defun org-export-as-xoxo-insert-into (buffer &rest output)
18465 (put 'org-export-as-xoxo-insert-into 'lisp-indent-function 1)
18467 (defun org-export-as-xoxo (&optional buffer)
18468 "Export the org buffer as XOXO.
18476 (let* ((opt-plist (org-combine-plists (org-default-export-plist)
18477 (org-infile-export-plist)))
18479 (org-export-directory :xoxo opt-plist))
18489 (org-export-as-xoxo-insert-into out "<ol class='xoxo'>\n")
18508 (org-export-as-xoxo-insert-into out "\n<ol>\n"))
18513 (org-export-as-xoxo-insert-into out "</li>\n"))
18514 (org-export-as-xoxo-insert-into out "</ol>\n"))
18516 (org-export-as-xoxo-insert-into out "</li>\n")
18521 (org-export-as-xoxo-insert-into out "</li>\n")))
18529 (org-export-as-xoxo-insert-into out "<li class='" (substring text 1) "'>")
18530 (org-export-as-xoxo-insert-into out "<li>" text))))
18535 (org-export-as-xoxo-insert-into out "</li>\n"))
18536 (org-export-as-xoxo-insert-into out "</ol>\n"))
18556 (define-key org-mode-map "\C-c\C-x" (make-sparse-keymap))
18559 (define-key org-mode-map "\C-i" 'org-cycle)
18560 (define-key org-mode-map [(tab)] 'org-cycle)
18561 (define-key org-mode-map [(control tab)] 'org-force-cycle-archived)
18562 (define-key org-mode-map [(meta tab)] 'org-complete)
18563 (define-key org-mode-map "\M-\t" 'org-complete)
18564 (define-key org-mode-map "\M-\C-i" 'org-complete)
18567 (define-key org-mode-map [S-iso-lefttab] 'org-shifttab))
18568 (define-key org-mode-map [(shift tab)] 'org-shifttab)
18570 (define-key org-mode-map (org-key 'S-return) 'org-table-copy-down)
18571 (define-key org-mode-map [(meta shift return)] 'org-insert-todo-heading)
18572 (define-key org-mode-map [(meta return)] 'org-meta-return)
18575 (define-key org-mode-map [(meta left)] 'org-metaleft)
18576 (define-key org-mode-map [(meta right)] 'org-metaright)
18577 (define-key org-mode-map [(meta up)] 'org-metaup)
18578 (define-key org-mode-map [(meta down)] 'org-metadown)
18580 (define-key org-mode-map [(meta shift left)] 'org-shiftmetaleft)
18581 (define-key org-mode-map [(meta shift right)] 'org-shiftmetaright)
18582 (define-key org-mode-map [(meta shift up)] 'org-shiftmetaup)
18583 (define-key org-mode-map [(meta shift down)] 'org-shiftmetadown)
18585 (define-key org-mode-map (org-key 'S-up) 'org-shiftup)
18586 (define-key org-mode-map (org-key 'S-down) 'org-shiftdown)
18587 (define-key org-mode-map (org-key 'S-left) 'org-shiftleft)
18588 (define-key org-mode-map (org-key 'S-right) 'org-shiftright)
18596 (define-key org-mode-map "\C-c\C-xc" 'org-table-copy-down)
18597 (define-key org-mode-map "\C-c\C-xM" 'org-insert-todo-heading)
18598 (define-key org-mode-map "\C-c\C-xm" 'org-meta-return)
18599 (define-key org-mode-map [?\e (return)] 'org-meta-return)
18600 (define-key org-mode-map [?\e (left)] 'org-metaleft)
18601 (define-key org-mode-map "\C-c\C-xl" 'org-metaleft)
18602 (define-key org-mode-map [?\e (right)] 'org-metaright)
18603 (define-key org-mode-map "\C-c\C-xr" 'org-metaright)
18604 (define-key org-mode-map [?\e (up)] 'org-metaup)
18605 (define-key org-mode-map "\C-c\C-xu" 'org-metaup)
18606 (define-key org-mode-map [?\e (down)] 'org-metadown)
18607 (define-key org-mode-map "\C-c\C-xd" 'org-metadown)
18608 (define-key org-mode-map "\C-c\C-xL" 'org-shiftmetaleft)
18609 (define-key org-mode-map "\C-c\C-xR" 'org-shiftmetaright)
18610 (define-key org-mode-map "\C-c\C-xU" 'org-shiftmetaup)
18611 (define-key org-mode-map "\C-c\C-xD" 'org-shiftmetadown)
18612 (define-key org-mode-map [?\C-c ?\C-x (up)] 'org-shiftup)
18613 (define-key org-mode-map [?\C-c ?\C-x (down)] 'org-shiftdown)
18614 (define-key org-mode-map [?\C-c ?\C-x (left)] 'org-shiftleft)
18615 (define-key org-mode-map [?\C-c ?\C-x (right)] 'org-shiftright))
18619 (define-key org-mode-map "\C-c\C-a" 'show-all) ; in case allout messed up.
18620 (define-key org-mode-map "\C-c\C-r" 'org-reveal)
18621 (define-key org-mode-map "\C-xns" 'org-narrow-to-subtree)
18622 (define-key org-mode-map "\C-c$" 'org-archive-subtree)
18623 (define-key org-mode-map "\C-c\C-x\C-s" 'org-advertized-archive-subtree)
18624 (define-key org-mode-map "\C-c\C-x\C-a" 'org-toggle-archive-tag)
18625 (define-key org-mode-map "\C-c\C-xb" 'org-tree-to-indirect-buffer)
18626 (define-key org-mode-map "\C-c\C-j" 'org-goto)
18627 (define-key org-mode-map "\C-c\C-t" 'org-todo)
18628 (define-key org-mode-map "\C-c\C-s" 'org-schedule)
18629 (define-key org-mode-map "\C-c\C-d" 'org-deadline)
18630 (define-key org-mode-map "\C-c;" 'org-toggle-comment)
18631 (define-key org-mode-map "\C-c\C-v" 'org-show-todo-tree)
18632 (define-key org-mode-map "\C-c\C-w" 'org-check-deadlines)
18633 (define-key org-mode-map "\C-c/" 'org-occur) ; Minor-mode reserved
18634 (define-key org-mode-map "\C-c\\" 'org-tags-sparse-tree) ; Minor-mode res.
18635 (define-key org-mode-map "\C-c\C-m" 'org-insert-heading)
18636 (define-key org-mode-map "\M-\C-m" 'org-insert-heading)
18637 (define-key org-mode-map "\C-c\C-x\C-n" 'org-next-link)
18638 (define-key org-mode-map "\C-c\C-x\C-p" 'org-previous-link)
18639 (define-key org-mode-map "\C-c\C-l" 'org-insert-link)
18640 (define-key org-mode-map "\C-c\C-o" 'org-open-at-point)
18641 (define-key org-mode-map "\C-c%" 'org-mark-ring-push)
18642 (define-key org-mode-map "\C-c&" 'org-mark-ring-goto)
18643 (define-key org-mode-map "\C-c\C-z" 'org-time-stamp) ; Alternative binding
18644 (define-key org-mode-map "\C-c." 'org-time-stamp) ; Minor-mode reserved
18645 (define-key org-mode-map "\C-c!" 'org-time-stamp-inactive) ; Minor-mode r.
18646 (define-key org-mode-map "\C-c," 'org-priority) ; Minor-mode reserved
18647 (define-key org-mode-map "\C-c\C-y" 'org-evaluate-time-range)
18648 (define-key org-mode-map "\C-c>" 'org-goto-calendar)
18649 (define-key org-mode-map "\C-c<" 'org-date-from-calendar)
18650 (define-key org-mode-map [(control ?,)] 'org-cycle-agenda-files)
18651 (define-key org-mode-map [(control ?\')] 'org-cycle-agenda-files)
18652 (define-key org-mode-map "\C-c[" 'org-agenda-file-to-front)
18653 (define-key org-mode-map "\C-c]" 'org-remove-file)
18654 (define-key org-mode-map "\C-c-" 'org-table-insert-hline)
18655 (define-key org-mode-map "\C-c^" 'org-sort)
18656 (define-key org-mode-map "\C-c\C-c" 'org-ctrl-c-ctrl-c)
18657 (define-key org-mode-map "\C-c#" 'org-update-checkbox-count)
18658 (define-key org-mode-map "\C-m" 'org-return)
18659 (define-key org-mode-map "\C-c?" 'org-table-field-info)
18660 (define-key org-mode-map "\C-c " 'org-table-blank-field)
18661 (define-key org-mode-map "\C-c+" 'org-table-sum)
18662 (define-key org-mode-map "\C-c=" 'org-table-eval-formula)
18663 (define-key org-mode-map "\C-c'" 'org-table-edit-formulas)
18664 (define-key org-mode-map "\C-c`" 'org-table-edit-field)
18665 (define-key org-mode-map "\C-c|" 'org-table-create-or-convert-from-region)
18666 (define-key org-mode-map "\C-c*" 'org-table-recalculate)
18667 (define-key org-mode-map [(control ?#)] 'org-table-rotate-recalc-marks)
18668 (define-key org-mode-map "\C-c~" 'org-table-create-with-table.el)
18669 (define-key org-mode-map "\C-c\C-q" 'org-table-wrap-region)
18670 (define-key org-mode-map "\C-c}" 'org-table-toggle-coordinate-overlays)
18671 (define-key org-mode-map "\C-c{" 'org-table-toggle-formula-debugger)
18672 (define-key org-mode-map "\C-c\C-e" 'org-export)
18673 (define-key org-mode-map "\C-c:" 'org-toggle-fixed-width-section)
18675 (define-key org-mode-map "\C-c\C-x\C-k" 'org-cut-special)
18676 (define-key org-mode-map "\C-c\C-x\C-w" 'org-cut-special)
18677 (define-key org-mode-map "\C-c\C-x\M-w" 'org-copy-special)
18678 (define-key org-mode-map "\C-c\C-x\C-y" 'org-paste-special)
18680 (define-key org-mode-map "\C-c\C-x\C-t" 'org-toggle-time-stamp-overlays)
18681 (define-key org-mode-map "\C-c\C-x\C-i" 'org-clock-in)
18682 (define-key org-mode-map "\C-c\C-x\C-o" 'org-clock-out)
18683 (define-key org-mode-map "\C-c\C-x\C-x" 'org-clock-cancel)
18684 (define-key org-mode-map "\C-c\C-x\C-d" 'org-clock-display)
18685 (define-key org-mode-map "\C-c\C-x\C-r" 'org-clock-report)
18686 (define-key org-mode-map "\C-c\C-x\C-u" 'org-dblock-update)
18687 (define-key org-mode-map "\C-c\C-x\C-l" 'org-preview-latex-fragment)
18688 (define-key org-mode-map "\C-c\C-x\C-b" 'org-toggle-checkbox)
18691 (define-key org-mode-map 'button3 'popup-mode-menu))
18693 (defsubst org-table-p () (org-at-table-p))
18695 (defun org-self-insert-command (N)
18700 (if (and (org-table-p)
18703 (and org-table-auto-blank-field
18705 '(org-cycle org-return org-shifttab org-ctrl-c-ctrl-c))
18708 (let (org-table-may-need-update) (org-table-blank-field))
18710 (org-table-blank-field)))
18714 (let (org-table-may-need-update)
18719 (setq org-table-may-need-update t)
18722 (defun org-delete-backward-char (N)
18729 (if (and (org-table-p)
18735 (c org-table-may-need-update))
18742 (if noalign (setq org-table-may-need-update c)))
18745 (defun org-delete-char (N)
18752 (if (and (org-table-p)
18759 (c org-table-may-need-update))
18766 (if noalign (setq org-table-may-need-update c)))
18770 ;; Make `delete-selection-mode' work with org-mode and orgtbl-mode
18771 (put 'org-self-insert-command 'delete-selection t)
18773 (put 'org-delete-char 'delete-selection 'supersede)
18774 (put 'org-delete-backward-char 'delete-selection 'supersede)
18777 (put 'org-self-insert-command 'flyspell-delayed t)
18779 (put 'org-delete-char 'flyspell-delayed t)
18780 (put 'org-delete-backward-char 'flyspell-delayed t)
18786 (defun org-remap (map &rest commands)
18796 (when (eq org-enable-table-editor 'optimized)
18799 (org-remap org-mode-map
18800 'self-insert-command 'org-self-insert-command
18801 'delete-char 'org-delete-char
18802 'delete-backward-char 'org-delete-backward-char)
18803 (define-key org-mode-map "|" 'org-force-self-insert))
18805 (defun org-shiftcursor-error ()
18809 (defun org-shifttab (&optional arg)
18811 Calls `org-cycle' with argument t, or `org-table-previous-field', depending
18816 ((org-at-table-p) (call-interactively 'org-table-previous-field))
18818 (org-content (prefix-numeric-value arg))
18819 (setq org-cycle-global-status 'overview))
18820 (t (call-interactively 'org-global-cycle))))
18822 (defun org-shiftmetaleft ()
18824 Calls `org-promote-subtree' or `org-table-delete-column', depending on context.
18828 ((org-at-table-p) (call-interactively 'org-table-delete-column))
18829 ((org-on-heading-p) (call-interactively 'org-promote-subtree))
18830 ((org-at-item-p) (call-interactively 'org-outdent-item))
18831 (t (org-shiftcursor-error))))
18833 (defun org-shiftmetaright ()
18835 Calls `org-demote-subtree' or `org-table-insert-column', depending on context.
18839 ((org-at-table-p) (call-interactively 'org-table-insert-column))
18840 ((org-on-heading-p) (call-interactively 'org-demote-subtree))
18841 ((org-at-item-p) (call-interactively 'org-indent-item))
18842 (t (org-shiftcursor-error))))
18844 (defun org-shiftmetaup (&optional arg)
18846 Calls `org-move-subtree-up' or `org-table-kill-row' or
18847 `org-move-item-up' depending on context. See the individual commands
18851 ((org-at-table-p) (call-interactively 'org-table-kill-row))
18852 ((org-on-heading-p) (call-interactively 'org-move-subtree-up))
18853 ((org-at-item-p) (call-interactively 'org-move-item-up))
18854 (t (org-shiftcursor-error))))
18855 (defun org-shiftmetadown (&optional arg)
18857 Calls `org-move-subtree-down' or `org-table-insert-row' or
18858 `org-move-item-down', depending on context. See the individual
18862 ((org-at-table-p) (call-interactively 'org-table-insert-row))
18863 ((org-on-heading-p) (call-interactively 'org-move-subtree-down))
18864 ((org-at-item-p) (call-interactively 'org-move-item-down))
18865 (t (org-shiftcursor-error))))
18867 (defun org-metaleft (&optional arg)
18869 Calls `org-do-promote' or `org-table-move-column', depending on context.
18874 ((org-at-table-p) (org-call-with-arg 'org-table-move-column 'left))
18875 ((or (org-on-heading-p) (org-region-active-p))
18876 (call-interactively 'org-do-promote))
18877 ((org-at-item-p) (call-interactively 'org-outdent-item))
18880 (defun org-metaright (&optional arg)
18882 Calls `org-do-demote' or `org-table-move-column', depending on context.
18887 ((org-at-table-p) (call-interactively 'org-table-move-column))
18888 ((or (org-on-heading-p) (org-region-active-p))
18889 (call-interactively 'org-do-demote))
18890 ((org-at-item-p) (call-interactively 'org-indent-item))
18893 (defun org-metaup (&optional arg)
18895 Calls `org-move-subtree-up' or `org-table-move-row' or
18896 `org-move-item-up', depending on context. See the individual commands
18900 ((org-at-table-p) (org-call-with-arg 'org-table-move-row 'up))
18901 ((org-on-heading-p) (call-interactively 'org-move-subtree-up))
18902 ((org-at-item-p) (call-interactively 'org-move-item-up))
18903 (t (org-shiftcursor-error))))
18905 (defun org-metadown (&optional arg)
18907 Calls `org-move-subtree-down' or `org-table-move-row' or
18908 `org-move-item-down', depending on context. See the individual
18912 ((org-at-table-p) (call-interactively 'org-table-move-row))
18913 ((org-on-heading-p) (call-interactively 'org-move-subtree-down))
18914 ((org-at-item-p) (call-interactively 'org-move-item-down))
18915 (t (org-shiftcursor-error))))
18917 (defun org-shiftup (&optional arg)
18919 Calls `org-timestamp-up' or `org-priority-up', depending on context.
18923 ((org-at-timestamp-p t) (call-interactively 'org-timestamp-up))
18924 ((org-on-heading-p) (call-interactively 'org-priority-up))
18925 ((org-at-item-p) (call-interactively 'org-previous-item))
18926 (t (call-interactively 'org-beginning-of-item) (beginning-of-line 1))))
18928 (defun org-shiftdown (&optional arg)
18930 Calls `org-timestamp-down' or `org-priority-down', depending on context.
18934 ((org-at-timestamp-p t) (call-interactively 'org-timestamp-down))
18935 ((org-on-heading-p) (call-interactively 'org-priority-down))
18936 (t (call-interactively 'org-next-item))))
18938 (defun org-shiftright ()
18942 ((org-at-timestamp-p t) (call-interactively 'org-timestamp-up-day))
18943 ((org-on-heading-p) (org-call-with-arg 'org-todo 'right))
18944 (t (org-shiftcursor-error))))
18946 (defun org-shiftleft ()
18950 ((org-at-timestamp-p t) (call-interactively 'org-timestamp-down-day))
18951 ((org-on-heading-p) (org-call-with-arg 'org-todo 'left))
18952 (t (org-shiftcursor-error))))
18954 (defun org-copy-special ()
18956 Calls `org-table-copy' or `org-copy-subtree', depending on context.
18960 (if (org-at-table-p) 'org-table-copy-region 'org-copy-subtree)))
18962 (defun org-cut-special ()
18964 Calls `org-table-copy' or `org-cut-subtree', depending on context.
18968 (if (org-at-table-p) 'org-table-cut-region 'org-cut-subtree)))
18970 (defun org-paste-special (arg)
18972 Calls `org-table-paste-rectangle' or `org-paste-subtree', depending on context.
18975 (if (org-at-table-p)
18976 (org-table-paste-rectangle)
18977 (org-paste-subtree arg)))
18979 (defun org-ctrl-c-ctrl-c (&optional arg)
18985 into the current line, aligned to `org-tags-column'. When called
18986 with prefix arg, realign all tags in the current buffer.
19011 (let ((org-enable-table-editor t))
19013 ((or org-clock-overlays
19014 org-occur-highlights
19015 org-latex-fragment-image-overlays)
19016 (org-remove-clock-overlays)
19017 (org-remove-occur-highlights)
19018 (org-remove-latex-fragment-image-overlays)
19020 ((and (local-variable-p 'org-finish-function (current-buffer))
19021 (fboundp org-finish-function))
19022 (funcall org-finish-function))
19023 ((org-on-target-p) (call-interactively 'org-update-radio-target-regexp))
19024 ((org-on-heading-p) (call-interactively 'org-set-tags))
19025 ((org-at-table.el-p)
19030 ((org-at-table-p)
19031 (org-table-maybe-eval-formula)
19033 (call-interactively 'org-table-recalculate)
19034 (org-table-maybe-recalculate-line))
19035 (call-interactively 'org-table-align))
19036 ((org-at-item-checkbox-p)
19037 (call-interactively 'org-toggle-checkbox))
19038 ((org-at-item-p)
19039 (call-interactively 'org-renumber-ordered-list))
19047 (if (org-at-table-p)
19048 (org-call-with-arg 'org-table-recalculate t))))
19050 (call-interactively 'org-mode-restart))))
19053 (defun org-mode-restart ()
19057 (let ((org-inhibit-startup t)) (org-mode))
19060 (defun org-return ()
19062 Calls `org-table-next-row' or `newline', depending on context.
19066 ((org-at-table-p)
19067 (org-table-justify-field-maybe)
19068 (call-interactively 'org-table-next-row))
19071 (defun org-meta-return (&optional arg)
19073 Calls `org-insert-heading' or `org-table-wrap-region', depending on context.
19077 ((org-at-table-p)
19078 (call-interactively 'org-table-wrap-region))
19079 (t (call-interactively 'org-insert-heading))))
19084 (easy-menu-define org-tbl-menu org-mode-map "Tbl menu"
19086 ["Align" org-ctrl-c-ctrl-c (org-at-table-p)]
19087 ["Next Field" org-cycle (org-at-table-p)]
19088 ["Previous Field" org-shifttab (org-at-table-p)]
19089 ["Next Row" org-return (org-at-table-p)]
19091 ["Blank Field" org-table-blank-field (org-at-table-p)]
19092 ["Edit Field" org-table-edit-field (org-at-table-p)]
19093 ["Copy Field from Above" org-table-copy-down (org-at-table-p)]
19096 ["Move Column Left" org-metaleft (org-at-table-p)]
19097 ["Move Column Right" org-metaright (org-at-table-p)]
19098 ["Delete Column" org-shiftmetaleft (org-at-table-p)]
19099 ["Insert Column" org-shiftmetaright (org-at-table-p)])
19101 ["Move Row Up" org-metaup (org-at-table-p)]
19102 ["Move Row Down" org-metadown (org-at-table-p)]
19103 ["Delete Row" org-shiftmetaup (org-at-table-p)]
19104 ["Insert Row" org-shiftmetadown (org-at-table-p)]
19105 ["Sort lines in region" org-table-sort-lines (org-at-table-p)]
19107 ["Insert Hline" org-table-insert-hline (org-at-table-p)])
19109 ["Copy Rectangle" org-copy-special (org-at-table-p)]
19110 ["Cut Rectangle" org-cut-special (org-at-table-p)]
19111 ["Paste Rectangle" org-paste-special (org-at-table-p)]
19112 ["Fill Rectangle" org-table-wrap-region (org-at-table-p)])
19115 ["Set Column Formula" org-table-eval-formula (org-at-table-p)]
19116 ["Set Field Formula" (org-table-eval-formula '(4)) :active (org-at-table-p) :keys "C-u C-c ="]
19117 ["Edit Formulas" org-table-edit-formulas (org-at-table-p)]
19119 ["Recalculate line" org-table-recalculate (org-at-table-p)]
19120 ["Recalculate all" (lambda () (interactive) (org-table-recalculate '(4))) :active (org-at-table-p) :keys "C-u C-c *"]
19121 ["Iterate all" (lambda () (interactive) (org-table-recalculate '(16))) :active (org-at-table-p) :keys "C-u C-u C-c *"]
19123 ["Toggle Recalculate Mark" org-table-rotate-recalc-marks (org-at-table-p)]
19125 ["Sum Column/Rectangle" org-table-sum
19126 (or (org-at-table-p) (org-region-active-p))]
19127 ["Which Column?" org-table-current-column (org-at-table-p)])
19129 org-table-toggle-formula-debugger
19130 :style toggle :selected org-table-formula-debug]
19132 org-table-toggle-coordinate-overlays
19133 :style toggle :selected org-table-overlay-coordinates]
19135 ["Create" org-table-create (and (not (org-at-table-p))
19136 org-enable-table-editor)]
19137 ["Convert Region" org-table-convert-region (not (org-at-table-p 'any))]
19138 ["Import from File" org-table-import (not (org-at-table-p))]
19139 ["Export to File" org-table-export (org-at-table-p)]
19141 ["Create/Convert from/to table.el" org-table-create-with-table.el t]))
19143 (easy-menu-define org-org-menu org-mode-map "Org menu"
19146 ["Cycle Visibility" org-cycle (or (bobp) (outline-on-heading-p))]
19147 ["Cycle Global Visibility" org-shifttab (not (org-at-table-p))]
19148 ["Sparse Tree" org-occur t]
19149 ["Reveal Context" org-reveal t]
19150 ["Show All" show-all t]
19152 ["Subtree to indirect buffer" org-tree-to-indirect-buffer t])
19154 ["New Heading" org-insert-heading t]
19162 ["Jump" org-goto t])
19164 ["Move Subtree Up" org-shiftmetaup (not (org-at-table-p))]
19165 ["Move Subtree Down" org-shiftmetadown (not (org-at-table-p))]
19167 ["Copy Subtree" org-copy-special (not (org-at-table-p))]
19168 ["Cut Subtree" org-cut-special (not (org-at-table-p))]
19169 ["Paste Subtree" org-paste-special (not (org-at-table-p))]
19171 ["Promote Heading" org-metaleft (not (org-at-table-p))]
19172 ["Promote Subtree" org-shiftmetaleft (not (org-at-table-p))]
19173 ["Demote Heading" org-metaright (not (org-at-table-p))]
19174 ["Demote Subtree" org-shiftmetaright (not (org-at-table-p))]
19176 ["Sort Region/Children" org-sort (not (org-at-table-p))]
19178 ["Convert to odd levels" org-convert-to-odd-levels t]
19179 ["Convert to odd/even levels" org-convert-to-oddeven-levels t])
19181 ["Toggle ARCHIVE tag" org-toggle-archive-tag t]
19182 ; ["Check and Tag Children" (org-toggle-archive-tag (4))
19185 (setq org-sparse-tree-open-archived-trees
19186 (not org-sparse-tree-open-archived-trees))
19187 :style toggle :selected org-sparse-tree-open-archived-trees]
19189 (setq org-cycle-open-archived-trees (not org-cycle-open-archived-trees))
19190 :style toggle :selected org-cycle-open-archived-trees]
19192 (setq org-agenda-skip-archived-trees (not org-agenda-skip-archived-trees))
19193 :style toggle :selected (not org-agenda-skip-archived-trees)]
19195 ["Move Subtree to Archive" org-advertized-archive-subtree t]
19196 ; ["Check and Move Children" (org-archive-subtree '(4))
19201 ["TODO/DONE/-" org-todo t]
19203 ["Next keyword" org-shiftright (org-on-heading-p)]
19204 ["Previous keyword" org-shiftleft (org-on-heading-p)]
19205 ["Complete Keyword" org-complete (assq :todo-keyword (org-context))])
19206 ["Show TODO Tree" org-show-todo-tree t]
19207 ["Global TODO list" org-todo-list t]
19209 ["Set Priority" org-priority t]
19210 ["Priority Up" org-shiftup t]
19211 ["Priority Down" org-shiftdown t]
19213 ; ["Insert Checkbox" org-insert-todo-heading (org-in-item-p)]
19214 ; ["Toggle Checkbox" org-ctrl-c-ctrl-c (org-at-item-checkbox-p)]
19215 ; ["Insert [n/m] cookie" (progn (insert "[/]") (org-update-checkbox-count))
19216 ; (or (org-on-heading-p) (org-at-item-p))]
19217 ; ["Insert [%] cookie" (progn (insert "[%]") (org-update-checkbox-count))
19218 ; (or (org-on-heading-p) (org-at-item-p))]
19219 ; ["Update Statistics" org-update-checkbox-count t]
19222 ["Timestamp" org-time-stamp t]
19223 ["Timestamp (inactive)" org-time-stamp-inactive t]
19225 ["1 Day Later" org-shiftright t]
19226 ["1 Day Earlier" org-shiftleft t]
19227 ["1 ... Later" org-shiftup t]
19228 ["1 ... Earlier" org-shiftdown t])
19229 ["Compute Time Range" org-evaluate-time-range t]
19230 ["Schedule Item" org-schedule t]
19231 ["Deadline" org-deadline t]
19233 ["Custom time format" org-toggle-time-stamp-overlays
19234 :style radio :selected org-display-custom-times]
19236 ["Goto Calendar" org-goto-calendar t]
19237 ["Date from Calendar" org-date-from-calendar t])
19239 ["Clock in" org-clock-in t]
19240 ["Clock out" org-clock-out t]
19241 ["Clock cancel" org-clock-cancel t]
19242 ["Display times" org-clock-display t]
19243 ["Create clock table" org-clock-report t]
19246 (progn (setq org-log-done (not org-log-done))
19248 org-done-string
19249 (if org-log-done "automatically" "not")))
19250 :style toggle :selected org-log-done])
19252 ["Agenda Command..." org-agenda t]
19255 ["TODO Tree" org-show-todo-tree t]
19256 ["Check Deadlines" org-check-deadlines t]
19257 ["Timeline" org-timeline t]
19258 ["Tags Tree" org-tags-sparse-tree t])
19261 ["Store Link (Global)" org-store-link t]
19262 ["Insert Link" org-insert-link t]
19263 ["Follow Link" org-open-at-point t]
19265 ["Next link" org-next-link t]
19266 ["Previous link" org-previous-link t]
19269 (progn (org-add-to-invisibility-spec '(org-link)) (org-restart-font-lock))
19270 :style radio :selected (member '(org-link) buffer-invisibility-spec)]
19273 (org-remove-from-invisibility-spec '(org-link)) (org-restart-font-lock))
19274 :style radio :selected (not (member '(org-link) buffer-invisibility-spec))])
19276 ["Export/Publish..." org-export t]
19278 ["Org CDLaTeX mode" org-cdlatex-mode :style toggle
19279 :selected org-cdlatex-mode]
19282 ["Modify math symbol" org-cdlatex-math-modify
19283 (org-inside-LaTeX-fragment-p)]
19285 (setq org-export-with-LaTeX-fragments (not org-export-with-LaTeX-fragments))
19286 :style toggle :selected org-export-with-LaTeX-fragments])
19289 ["Show Version" org-version t]
19290 ["Info Documentation" org-info t])
19292 ["Browse Org Group" org-customize t]
19294 ["Expand This Menu" org-create-customize-menu
19297 ["Refresh setup" org-mode-restart t]
19300 (defun org-toggle-log-option (type)
19301 (if (not (listp org-log-done)) (setq org-log-done nil))
19302 (if (memq type org-log-done)
19303 (setq org-log-done (delq type org-log-done))
19304 (add-to-list 'org-log-done type)))
19306 (defun org-check-log-option (type)
19307 (and (listp org-log-done) (memq type org-log-done)))
19309 (defun org-info (&optional node)
19314 (Info-goto-node (format "(org)%s" (or node ""))))
19316 (defun org-install-agenda-files-menu ()
19321 (if (org-mode-p) (setq bl nil)))
19322 (when (org-mode-p)
19327 ["Edit File List" (org-edit-agenda-file-list) t]
19328 ["Add/Move Current File to Front of List" org-agenda-file-to-front t]
19329 ["Remove Current File from List" org-remove-file t]
19330 ["Cycle through agenda files" org-cycle-agenda-files t]
19332 (mapcar 'org-file-menu-entry (org-agenda-files t))))))))
19336 (defun org-customize ()
19337 "Call the customize function with org as argument."
19339 (customize-browse 'org))
19341 (defun org-create-customize-menu ()
19348 `(["Browse Org group" org-customize t]
19350 ,(customize-menu-create 'org)
19364 (defun org-context ()
19366 If several contexts apply, all are returned.
19379 :table in an org-mode table
19397 ((org-on-heading-p)
19401 (looking-at org-todo-line-tags-regexp))
19402 (push (org-point-in-group p 1 :headline-stars) clist)
19403 (push (org-point-in-group p 2 :todo-keyword) clist)
19404 (push (org-point-in-group p 4 :tags) clist))
19408 (push (org-point-in-group p 0 :priority) clist)))
19410 ((org-at-item-p)
19411 (push (org-point-in-group p 2 :item-bullet) clist)
19413 (save-excursion (org-end-of-item) (point)))
19415 (and (org-at-item-checkbox-p)
19416 (push (org-point-in-group p 0 :checkbox) clist)))
19418 ((org-at-table-p)
19419 (push (list :table (org-table-begin) (org-table-end)) clist)
19420 (if (memq 'org-formula faces)
19424 ((org-at-table-p 'any)
19430 ((org-at-timestamp-p)
19431 (push (org-point-in-group p 0 :timestamp) clist))
19432 ((memq 'org-link faces)
19436 ((memq 'org-special-keyword faces)
19440 ((org-on-target-p)
19441 (push (org-point-in-group p 0 :target) clist)
19443 (if (looking-at org-radio-target-regexp)
19444 (push (org-point-in-group p 0 :radio-target) clist))
19449 (if (memq x org-latex-fragment-image-overlays) x))
19450 (org-overlays-at (point))))))
19452 (org-overlay-start o) (org-overlay-end o)) clist)
19454 (org-overlay-start o) (org-overlay-end o)) clist))
19455 ((org-inside-LaTeX-fragment-p)
19462 (defun org-in-regexp (re &optional nlines visually)
19479 (defun org-point-in-group (point group &optional context)
19491 (defun org-combine-plists (&rest plists)
19492 "Create a single property list from all plists in PLISTS.
19505 (defun org-move-line-down (arg)
19518 (defun org-move-line-up (arg)
19531 (defun org-replace-escapes (string table)
19548 (defun org-sublist (list start end)
19558 (defun org-at-regexp-p (regexp)
19570 (defun org-find-base-buffer-visiting (file)
19580 (defun org-set-autofill-regexps ()
19585 (org-set-local 'comment-start-skip "^#+[ \t]*")
19586 (org-set-local 'paragraph-separate "\f\\|\\*\\|[ ]*$\\|[ \t]*[:|]")
19588 (org-set-local 'paragraph-start
19592 (org-set-local
19595 "\\|[ \t]*" org-keyword-time-regexp
19596 (if (or org-enable-table-editor org-enable-fixed-width-editor)
19599 (if org-enable-table-editor "|" "")
19600 (if org-enable-fixed-width-editor ":" "")
19605 (org-set-local 'fill-paragraph-function 'org-fill-paragraph)
19608 (org-set-local 'adaptive-fill-regexp "\000")
19609 (org-set-local 'adaptive-fill-function
19610 'org-adaptive-fill-function))
19612 (defun org-fill-paragraph (&optional justify)
19614 (let ((table-p (org-at-table-p))
19615 (table.el-p (org-at-table.el-p)))
19618 (table-p (org-table-align) t) ; align org-mode tables
19624 (defun org-adaptive-fill-function ()
19625 "Return a fill prefix for org-mode files.
19635 (defun org-image-file-name-regexp ()
19649 (defun org-file-image-p (file)
19652 (string-match (org-image-file-name-regexp) file)))
19658 (defun org-beginning-of-line ()
19666 (if (org-invisible-p)
19667 (while (and (not (bobp)) (org-invisible-p))
19672 (define-key org-mode-map "\C-a" 'org-beginning-of-line)
19674 (defun org-invisible-p ()
19681 (defun org-invisible-p2 ()
19690 (defalias 'org-back-to-heading 'outline-back-to-heading)
19691 (defalias 'org-on-heading-p 'outline-on-heading-p)
19693 (defun org-on-target-p ()
19694 (or (org-in-regexp org-radio-target-regexp)
19695 (org-in-regexp org-target-regexp)))
19697 (defun org-up-heading-all (arg)
19701 (if (fboundp 'outline-up-heading-all)
19702 (outline-up-heading-all arg) ; emacs 21 version of outline.el
19705 (defun org-goto-sibling (&optional previous)
19714 (org-back-to-heading t)
19725 (defun org-show-siblings ()
19726 "Show all siblings of the current headline."
19728 (while (org-goto-sibling) (org-flag-heading nil)))
19730 (while (org-goto-sibling 'previous)
19731 (org-flag-heading nil))))
19733 (defun org-show-hidden-entry ()
19736 (org-show-entry)))
19738 (defun org-flag-heading (flag &optional entry)
19742 (org-back-to-heading t)
19746 (org-show-entry)
19749 (org-flag-heading nil))))
19754 (defun org-end-of-subtree (&optional invisible-OK)
19756 ;; `org-back-to-heading', to make it work also in invisible
19759 (org-back-to-heading invisible-OK)
19775 (defun org-show-subtree ()
19783 (defun org-show-entry ()
19788 (org-back-to-heading t)
19796 (defun org-make-options-regexp (kwds)
19806 (defun org-isearch-end ()
19812 (org-show-context 'isearch)
19815 ;; (Emacs 22 has a special variable, see function `org-mode')
19819 (org-add-hook 'post-command-hook 'org-isearch-post-command
19822 (defun org-isearch-post-command ()
19824 (remove-hook 'post-command-hook 'org-isearch-post-command 'local)
19825 (org-show-context 'isearch))
19833 (add-hook 'bookmark-after-jump-hook 'org-bookmark-jump-unhide)
19835 (defadvice bookmark-jump (after org-make-visible activate)
19837 (org-bookmark-jump-unhide))))
19839 (defun org-bookmark-jump-unhide ()
19841 (and (org-mode-p)
19842 (or (org-invisible-p)
19844 (org-invisible-p)))
19845 (org-show-context 'bookmark-jump)))
19849 '(add-to-list 'session-globals-exclude 'org-mark-ring))
19856 (provide 'org)
19858 (run-hooks 'org-load-hook)
19861 ;;; org.el ends here