Mercurial > emacs
comparison lisp/org/org.el @ 98644:e1cc41b9282d
2008-10-12 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-edit-fixed-width-region): Exclude final newline from
picture area.
* org-export-latex.el (org-export-latex-subcontent): Add labels to
sections, to make internal links work.
(org-export-latex-fontify-headline): Do not remove all text
properties, to make sure that target properties survive this
process.
* org-exp.el (org-export-preprocess-string): Change sequence of
modifications, to make sure links are prepared before the LaTeX
conversions do happen.
* org-attach.el (org-attach-delete-all): Renamed from
`org-attch-delete'. Add a security query before deleting the
entire directory. New optional argument FORCE can overrule the
security query.
(org-attach-delete-one): New command.
* org-attach.el (org-attach-file-list): Fix bug with directory.
* org.el (org-apps-regexp-alist): New function.
(org-file-apps): Add auto-mode to the default value.
(org-open-file): Use the new structure of org-file-apps.
* org-attach.el (org-attach): Support the new keys.
(org-attach-method): New option.
* org-bbdb.el (org-bbdb-anniversaries): Fix but with 29 Feb/1
March.
* org.el (org-remove-uniherited-tags): Fix reverse interpretation
of the list value o `org-use-tag-inheritance'.
* org-attach.el (org-attach-auto-tag): New option.
(org-attach-tag, org-attach-untag): New functions.
(org-attach-attach, org-attach-new, org-attach-sync): Call
`org-attach-tag'.
(org-attach-delete): Call `org-attach-untag'.
* org-attach.el: New file.
* org-table.el (orgtbl-self-insert-command): Make this work for
the keypad as well.
* org.el (org-add-log-setup): Limit searc for drawers to entry
text, not to subtree.
* org-clock.el (org-clock-heading-for-remember): New variable.
(org-clock-in): Set `org-clock-heading-for-remember'.
2008-10-12 James TD Smith <ahktenzero@mohorovi.cc>
* org-remember.el (org-remember-apply-template): Add new
expansions: %k, %K for currently clocked task and a link to the
currently clocked task, and %< to file notes in the currently
clocked task.
2008-10-12 Carsten Dominik <dominik@science.uva.nl>
* org-export-latex.el (org-export-latex-make-header): Also insert
the content of the property :latex-header-extra.
* org-exp.el (org-infile-export-plist): Put the content of
#+LATEX_HEADER: into the property :latex-header-extra.
* org-colview.el (org-columns-get-format-and-top-level): Remove
resetting the marker.
* org-colview-xemacs.el (org-columns-get-format-and-top-level):
Remove resetting the marker.
* org.el (org-entry-property-inherited-from): Improve docstring.
(org-entry-get-with-inheritance): Reset marker before starting the
search.
* org-exp.el (org-infile-export-plist): Allow multiple STYLE lines.
* org.el (org-entry-get-multivalued-property)
(org-entry-protect-space, org-entry-restore-space): New
functions.
(org-file-apps-defaults-macosx): Let postscript files be opened by
preview.
(org-time-stamp-inactive): Call `org-time-stamp'.
(org-time-stamp): New argument `inactive'. Also edit inacive
stamps. Convert time stamp type.
(org-open-file): Interpret the `default' value for the `command'
in `org-file-apps'.
* org-id.el (org-id-int-to-b36-one-digit)
(org-id-b36-to-int-one-digit, org-id-int-to-b36)
(org-id-b36-to-int, org-id-time-to-b36): Modified from b62 to
b36.
* org-id.el (org-id-reverse-string): New function.
(org-id-new): Use `org-id-reverse-string' to make sure the
beginning chars of the ID are mutating fast. This allows to use a
directory structure to spread things better.
(org-id-prefix): Changed default to nil.
* org-list.el (org-move-item-down, org-move-item-up): Remember and
restore the column of the cursor position.
* org-remember.el (org-remember-apply-template): Remove properties
from `initial'.
* org-wl.el (org-wl-open): Remove useless call to
`wl-thread-open-all'.
* org-remember.el (org-remember-handler): Fix bug with `bottom'
location.
* org-bbdb.el (org-bbdb-anniversaries): Require bbdb in
`org-bbdb-anniversaries'.
* org.el (org-get-next-sibling, org-forward-same-level): New
functions, similar to the outline versions, but invisible headings
are OK.
2008-10-12 Bastien Guerry <bzg@altern.org>
* org.el (org-auto-repeat-maybe): Insert a space between
the timestamp's type and the timestamp itself.
2008-10-12 Carsten Dominik <dominik@science.uva.nl>
* org-table.el (org-table-sum): Do not format the result with %g,
it does rounding when there are too many digits.
* org.el (org-map-entries): Protect the keyword-selecting variables.
2008-10-12 Bastien Guerry <bzg@altern.org>
* org-agenda.el (org-agenda-to-appt): Make sure the function check
against all agenda files.
2008-10-12 Carsten Dominik <dominik@science.uva.nl>
* org-list.el: New file, aggregating list functions from org.el
and org-export-latex.el.
* org.el (org-edit-src-region-extra): New option.
* org-agenda.el (org-agenda-to-appt): Fix bug with appointment
time before 1am.
2008-10-12 Bastien Guerry <bzg@altern.org>
* org-export-latex.el (org-export-latex-keywords-maybe): Bug fix.
2008-10-12 James TA Smith <ahktenzero@mohorovi.cc>
* org-plot.el (org-plot/gnuplot): Make tables starting with a
hline work correctly.
(org-plot/gnuplot-script): Put commas at the end of each script
line.
* org.el (org-get-refile-targets): Replace links with their
descriptions
(org-imenu-get-tree): Replace links with their descriptions.
* org-remember.el (org-remember-apply-template): Add a new
expansion for adding properties to remember items.
* org.el (org-add-log-setup): Skip over drawers (properties,
clocks etc) when adding notes.
* org-agenda.el (org-agenda-get-closed): show durations of clocked
items as well as the start and end times.
* org-compat.el (org-get-x-clipboard-compat): Add a compat
function for fetching the X clipboard on XEmacs and GNU Emacs 21.
* org-remember.el (org-get-x-clipboard): Use the compat
function to get clipboard values when x-selection-value is
unavailable. Use substring-no-properties instead of
set-text-properties to remove text properties from the clipboard
value.
* lisp/org-clock.el (org-update-mode-line): Support limiting the
modeline clock string, and display the full todo value in the
tooltip. Set a local keymap so mouse-3 on the clock string goes to
the currently clocked task.
(org-clock-string-limit): Add a custom value for the maximum
length of the clock string in the modeline.
(org-clock-mode-map): Add a keymap for the modeline string
2008-10-12 Carsten Dominik <dominik@science.uva.nl>
* org-compat.el (org-propertize): New function.
2008-10-12 Bastien Guerry <bzg@altern.org>
* org-export-latex.el (org-export-latex-tables): protect exported
tables from further special chars conversion.
(org-export-latex-preprocess): Preserve LaTeX environments.
(org-list-parse-list): Parse descriptive lists.
(org-list-to-generic, org-list-to-latex, org-list-to-html)
(org-list-to-texinfo): Export descriptive lists.
(org-quote-chars): Remove.
(org-export-latex-keywords-maybe): Use `replace-regexp-in-string'.
(org-export-latex-list-beginning-re): Rename to
`org-list-beginning-re'
(org-list-item-begin): Rename to `org-list-item-beginning'
2008-10-12 Carsten Dominik <dominik@science.uva.nl>
* org.el (org-refile): Allow refiling to the last entry in the
buffer.
(org-get-tags-at): Fix bug when inheritance is turned off.
* org.el (org-indent-line-function): No longer check for src
regions, this is too much overhead.
* org-agenda.el (org-agenda-highlight-todo): Fix bugs with keyword
matching.
* org.el (org-scan-tags): Make sure that tags matching is not case
sensitive. TODO keyword matching is case sensitive, however, to
avoid confusion with similar words that are not meant to be
keywords.
* org.el (org-get-local-tags-at): New function.
(org-get-local-tags): New function.
* org-exp.el (org-export-get-categories): New function.
* org-agenda.el (org-sorting-choice)
(org-agenda-sorting-strategy, org-agenda-get-todos)
(org-agenda-get-timestamps, org-agenda-get-deadlines)
(org-agenda-get-scheduled, org-agenda-get-blocks)
(org-entries-lessp): Implement sorting by TODO state.
(org-cmp-todo-state): New defsubst.
* org-colview.el (org-colview-construct-allowed-dates): New
function.
(org-columns-next-allowed-value): Use
`org-colview-construct-allowed-dates'.
* org-colview-xemacs.el (org-colview-construct-allowed-dates): New
function.
(org-columns-next-allowed-value): Use
`org-colview-construct-allowed-dates'.
* org.el (org-protect-slash): New function.
(org-get-refile-targets): Use `org-protect-slash'.
* org-agenda.el (org-global-tags-completion-table): New variable.
* org-exp.el (org-export-handle-export-tags): New function.
(org-export-preprocess-string): Call
`org-export-handle-export-tags'.
* org-plot.el: New file.
* org-publish.el (org-publish-expand-components): Function removed.
(org-publish-expand-projects): Allow components to have components.
* org.el (org-indent-line-function): Do not indent in regions that
are external source code.
(org-yank-and-fold-if-subtree): New function.
* org-agenda.el (org-agenda-todayp): New function.
(org-agenda-get-deadlines, org-agenda-get-scheduled): Use
`org-agenda-todayp'.
* org.el (org-insert-heading-respect-content)
(org-insert-todo-heading-respect-content): New commands.
(org-insert-heading-respect-content): New option.
(org-insert-heading): Respect `org-insert-heading-respect-content'.
* org-clock.el (org-clock-find-position): Make sure the note after
the clock line gets moved into the new clock drawer.
* org-id.el (org-id-new): New option.
* org-table.el (org-table-copy-down): Avoid overflow during
increment. Use prefix argument 0 to temporarily disable the
increment.
* org-exp.el (org-export-as-html): Do not turn on the major mode
if the buffer will be killed anyway.
(org-get-current-options): Exclude the #+TEXT field.
(org-export-as-html): Make sure text before the first headline is
a paragraph.
* org-publish.el (org-publish-org-to): Tell the exporter that this
buffer will be killed, so it is not necessary to do major mode
initialization.
* org-archive.el (org-archive-to-archive-sibling): Show empty
lines after folding the archive sibling.
* org.el (org-log-note-extra): New variable.
2008-10-12 Bastien Guerry <bzg@altern.org>
* org.el (org-additional-option-like-keywords): Added keywords for
the _QUOTE, _VERSE and _SRC environments.
* org-export-latex.el (org-export-latex-preprocess): Fix bug when
exporting _QUOTE and _VERSE environments.
2008-10-12 Carsten Dominik <dominik@science.uva.nl>
* org-agenda.el (org-agenda-filter-by-tag): New command.
* org-exp.el (org-get-current-options): Remove angular brackets
from the date entry.
* org.el (org-edit-fixed-width-region): New function.
(org-edit-fixed-width-region): Also try
`org-edit-fixed-width-region'.
(org-edit-fixed-width-region-mode): New option.
(org-activate-code): Only interprete lines starting with colon
plus a space as example lines.
* org-remember.el (org-remember-templates): Add nil instead of
empty strings to fix the length of remember templates.
* org-table.el (org-calc-default-modes): Fix the time format for
calc, from 12 hour to 24 hour clock.
* org-agenda.el (org-agenda-get-deadlines)
(org-agenda-get-scheduled): Avoid `time-of-day' extraction for
entries that are pre-warnings of deadlines or reminders.
* org.el (org-sort-entries-or-items): Make numeric and alpha
comparisons ignore any TODO keyword and priority cookie.
* org-remember.el (org-remember-handler): Reinterpretation of the
prefix argument.
* org-agenda.el (org-agenda-get-scheduled): Use new
`org-scheduled' face.
* org-faces.el (org-scheduled): New face.
* org-wl.el (org-wl-open): Remove incorrect declaration.
* org-gnus.el (org-gnus-store-link): Support for :to information
in gnus links.
* org-exp.el (org-export-as-html): Fixed typo in creator
information.
(org-export-protect-examples): New parameter indent. Insert extra
spaces only when this parameter is specified.
(org-export-preprocess-string): Call `org-export-protect-examples'
with an indentation parameter when exporting to ASCII.
* org-remember.el (org-remember-templates)
(org-remember-apply-template): Allow the file component to be a
function.
* org.el (org-goto-local-search-headings): Renamed from
`org-goto-local-search-forward-headings'. Added the possibility
to search backwards.
* org-export-latex.el (org-export-latex): New customization
group.
* org-agenda.el (org-write-agenda): Erase buffer for txt export.
* org-exp.el (org-html-do-expand): Allow {} to terminate
tex macro
* org.el (org-buffer-list): Select buffers based on major mode,
not on file name.
* org-agenda.el (org-agenda-align-tags): Fix bug with malformed
face property.
* org-colview.el (org-columns-display-here): Use
`org-columns-modify-value-for-display-function'.
* org-colview-xemacs.el (org-columns-display-here): Use
`org-columns-modify-value-for-display-function'.
* org.el (org-columns-modify-value-for-display-function): New option.
* org-publish.el (org-publish-file): Make sure the directory match
for the publishing directory works correctly.
* org-agenda.el (org-agenda-execute-calendar-command)
(org-agenda-diary-entry): Additional optional argument.
author | Carsten Dominik <dominik@science.uva.nl> |
---|---|
date | Sun, 12 Oct 2008 06:12:44 +0000 |
parents | 11deca4a880b |
children | 48e8ecb5eb0e |
comparison
equal
deleted
inserted
replaced
98643:fd13ced7b1d5 | 98644:e1cc41b9282d |
---|---|
3 ;; Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. | 3 ;; Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. |
4 ;; | 4 ;; |
5 ;; Author: Carsten Dominik <carsten at orgmode dot org> | 5 ;; Author: Carsten Dominik <carsten at orgmode dot org> |
6 ;; Keywords: outlines, hypermedia, calendar, wp | 6 ;; Keywords: outlines, hypermedia, calendar, wp |
7 ;; Homepage: http://orgmode.org | 7 ;; Homepage: http://orgmode.org |
8 ;; Version: 6.06b | 8 ;; Version: 6.09a |
9 ;; | 9 ;; |
10 ;; This file is part of GNU Emacs. | 10 ;; This file is part of GNU Emacs. |
11 ;; | 11 ;; |
12 ;; GNU Emacs is free software: you can redistribute it and/or modify | 12 ;; GNU Emacs is free software: you can redistribute it and/or modify |
13 ;; it under the terms of the GNU General Public License as published by | 13 ;; it under the terms of the GNU General Public License as published by |
84 (require 'easymenu) | 84 (require 'easymenu) |
85 | 85 |
86 (require 'org-macs) | 86 (require 'org-macs) |
87 (require 'org-compat) | 87 (require 'org-compat) |
88 (require 'org-faces) | 88 (require 'org-faces) |
89 (require 'org-list) | |
89 | 90 |
90 ;;;; Customization variables | 91 ;;;; Customization variables |
91 | 92 |
92 ;;; Version | 93 ;;; Version |
93 | 94 |
94 (defconst org-version "6.06b" | 95 (defconst org-version "6.09a" |
95 "The version number of the file org.el.") | 96 "The version number of the file org.el.") |
96 | 97 |
97 (defun org-version (&optional here) | 98 (defun org-version (&optional here) |
98 "Show the org-mode version in the echo area. | 99 "Show the org-mode version in the echo area. |
99 With prefix arg HERE, insert it at point." | 100 With prefix arg HERE, insert it at point." |
218 This is useful since some lines containing links can be very long and | 219 This is useful since some lines containing links can be very long and |
219 uninteresting. Also tables look terrible when wrapped." | 220 uninteresting. Also tables look terrible when wrapped." |
220 :group 'org-startup | 221 :group 'org-startup |
221 :type 'boolean) | 222 :type 'boolean) |
222 | 223 |
223 (defcustom org-startup-indented nil | |
224 "Non-nil means, turn on `org-indent-mode' on startup. | |
225 This can also be configured on a per-file basis by adding one of | |
226 the following lines anywhere in the buffer: | |
227 | |
228 #+STARTUP: localindent | |
229 #+STARTUP: indent | |
230 #+STARTUP: noindent" | |
231 :group 'org-structure | |
232 :type '(choice | |
233 (const :tag "Not" nil) | |
234 (const :tag "Locally" local) | |
235 (const :tag "Globally (slow on startup in large files)" t))) | |
236 | |
237 (defcustom org-startup-align-all-tables nil | 224 (defcustom org-startup-align-all-tables nil |
238 "Non-nil means, align all tables when visiting a file. | 225 "Non-nil means, align all tables when visiting a file. |
239 This is useful when the column width in tables is forced with <N> cookies | 226 This is useful when the column width in tables is forced with <N> cookies |
240 in table fields. Such tables will look correct only after the first re-align. | 227 in table fields. Such tables will look correct only after the first re-align. |
241 This can also be configured on a per-file basis by adding one of | 228 This can also be configured on a per-file basis by adding one of |
265 `org-disputed-keys'. | 252 `org-disputed-keys'. |
266 | 253 |
267 This option is only relevant at load-time of Org-mode, and must be set | 254 This option is only relevant at load-time of Org-mode, and must be set |
268 *before* org.el is loaded. Changing it requires a restart of Emacs to | 255 *before* org.el is loaded. Changing it requires a restart of Emacs to |
269 become effective." | 256 become effective." |
257 :group 'org-startup | |
258 :type 'boolean) | |
259 | |
260 (defcustom org-use-extra-keys nil | |
261 "Non-nil means use extra key sequence definitions for certain | |
262 commands. This happens automatically if you run XEmacs or if | |
263 window-system is nil. This variable lets you do the same | |
264 manually. You must set it before loading org. | |
265 | |
266 Example: on Carbon Emacs 22 running graphically, with an external | |
267 keyboard on a Powerbook, the default way of setting M-left might | |
268 not work for either Alt or ESC. Setting this variable will make | |
269 it work for ESC." | |
270 :group 'org-startup | 270 :group 'org-startup |
271 :type 'boolean) | 271 :type 'boolean) |
272 | 272 |
273 (if (fboundp 'defvaralias) | 273 (if (fboundp 'defvaralias) |
274 (defvaralias 'org-CUA-compatible 'org-replace-disputed-keys)) | 274 (defvaralias 'org-CUA-compatible 'org-replace-disputed-keys)) |
552 following headline. | 552 following headline. |
553 | 553 |
554 Special case: when 0, never leave empty lines in collapsed view." | 554 Special case: when 0, never leave empty lines in collapsed view." |
555 :group 'org-cycle | 555 :group 'org-cycle |
556 :type 'integer) | 556 :type 'integer) |
557 (put 'org-cycle-separator-lines 'safe-local-variable 'integerp) | |
557 | 558 |
558 (defcustom org-cycle-hook '(org-cycle-hide-archived-subtrees | 559 (defcustom org-cycle-hook '(org-cycle-hide-archived-subtrees |
559 org-cycle-hide-drawers | 560 org-cycle-hide-drawers |
560 org-cycle-show-empty-lines | 561 org-cycle-show-empty-lines |
561 org-optimize-window-after-visibility-change) | 562 org-optimize-window-after-visibility-change) |
630 - When in the middle of the headline text, kill the headline up to the tags. | 631 - When in the middle of the headline text, kill the headline up to the tags. |
631 - When after the headline text, kill the tags." | 632 - When after the headline text, kill the tags." |
632 :group 'org-edit-structure | 633 :group 'org-edit-structure |
633 :type 'boolean) | 634 :type 'boolean) |
634 | 635 |
636 (defcustom org-yank-folded-subtrees t | |
637 "Non-nil means, when yanking subtrees, fold them. | |
638 If the kill is a single subtree, or a sequence of subtrees, i.e. if | |
639 it starts with a heading and all other headings in it are either children | |
640 or siblings, then fold all the subtrees." | |
641 :group 'org-edit-structure | |
642 :type 'boolean) | |
643 | |
635 (defcustom org-M-RET-may-split-line '((default . t)) | 644 (defcustom org-M-RET-may-split-line '((default . t)) |
636 "Non-nil means, M-RET will split the line at the cursor position. | 645 "Non-nil means, M-RET will split the line at the cursor position. |
637 When nil, it will go to the end of the line before making a | 646 When nil, it will go to the end of the line before making a |
638 new line. | 647 new line. |
639 You may also set this option in a different way for different | 648 You may also set this option in a different way for different |
657 (const table) | 666 (const table) |
658 (const default)) | 667 (const default)) |
659 (boolean))))) | 668 (boolean))))) |
660 | 669 |
661 | 670 |
671 (defcustom org-insert-heading-respect-content nil | |
672 "Non-nil means, insert new headings after the current subtree. | |
673 When nil, the new heading is created directly after the current line. | |
674 The commands \\[org-insert-heading-respect-content] and | |
675 \\[org-insert-todo-heading-respect-content] turn this variable on | |
676 for the duration of the command." | |
677 :group 'org-structure | |
678 :type 'boolean) | |
679 | |
662 (defcustom org-blank-before-new-entry '((heading . nil) | 680 (defcustom org-blank-before-new-entry '((heading . nil) |
663 (plain-list-item . nil)) | 681 (plain-list-item . nil)) |
664 "Should `org-insert-heading' leave a blank line before new heading/item? | 682 "Should `org-insert-heading' leave a blank line before new heading/item? |
665 The value is an alist, with `heading' and `plain-list-item' as car, | 683 The value is an alist, with `heading' and `plain-list-item' as car, |
666 and a boolean flag as cdr." | 684 and a boolean flag as cdr." |
680 When nil, such lines will be treated like ordinary lines. | 698 When nil, such lines will be treated like ordinary lines. |
681 See also the QUOTE keyword." | 699 See also the QUOTE keyword." |
682 :group 'org-edit-structure | 700 :group 'org-edit-structure |
683 :type 'boolean) | 701 :type 'boolean) |
684 | 702 |
703 (defcustom org-edit-src-region-extra nil | |
704 "Additional regexps to identify regions for editing with `org-edit-src-code'. | |
705 For examples see the function `org-edit-src-find-region-and-lang'. | |
706 The regular expression identifying the begin marker should end with a newline, | |
707 and the regexp marking the end line should start with a newline, to make sure | |
708 there are kept outside the narrowed region." | |
709 :group 'org-edit-structure | |
710 :type '(repeat | |
711 (list | |
712 (regexp :tag "begin regexp") | |
713 (regexp :tag "end regexp") | |
714 (choice :tag "language" | |
715 (string :tag "specify") | |
716 (integer :tag "from match group") | |
717 (const :tag "from `lang' element") | |
718 (const :tag "from `style' element"))))) | |
719 | |
720 (defcustom org-edit-fixed-width-region-mode 'artist-mode | |
721 "The mode that should be used to edit fixed-width regions. | |
722 These are the regions where each line starts with a colon." | |
723 :group 'org-edit-structure | |
724 :type '(choice | |
725 (const artist-mode) | |
726 (const picture-mode) | |
727 (const fundamental-mode) | |
728 (function :tag "Other (specify)"))) | |
729 | |
685 (defcustom org-goto-auto-isearch t | 730 (defcustom org-goto-auto-isearch t |
686 "Non-nil means, typing characters in org-goto starts incremental search." | 731 "Non-nil means, typing characters in org-goto starts incremental search." |
687 :group 'org-edit-structure | 732 :group 'org-edit-structure |
688 :type 'boolean) | 733 :type 'boolean) |
689 | 734 |
714 "Hook that is run after `org-occur' has constructed a sparse tree. | 759 "Hook that is run after `org-occur' has constructed a sparse tree. |
715 This can be used to recenter the window to show as much of the structure | 760 This can be used to recenter the window to show as much of the structure |
716 as possible." | 761 as possible." |
717 :group 'org-sparse-trees | 762 :group 'org-sparse-trees |
718 :type 'hook) | 763 :type 'hook) |
719 | |
720 (defgroup org-plain-lists nil | |
721 "Options concerning plain lists in Org-mode." | |
722 :tag "Org Plain lists" | |
723 :group 'org-structure) | |
724 | |
725 (defcustom org-cycle-include-plain-lists nil | |
726 "Non-nil means, include plain lists into visibility cycling. | |
727 This means that during cycling, plain list items will *temporarily* be | |
728 interpreted as outline headlines with a level given by 1000+i where i is the | |
729 indentation of the bullet. In all other operations, plain list items are | |
730 not seen as headlines. For example, you cannot assign a TODO keyword to | |
731 such an item." | |
732 :group 'org-plain-lists | |
733 :type 'boolean) | |
734 | |
735 (defcustom org-plain-list-ordered-item-terminator t | |
736 "The character that makes a line with leading number an ordered list item. | |
737 Valid values are ?. and ?\). To get both terminators, use t. While | |
738 ?. may look nicer, it creates the danger that a line with leading | |
739 number may be incorrectly interpreted as an item. ?\) therefore is | |
740 the safe choice." | |
741 :group 'org-plain-lists | |
742 :type '(choice (const :tag "dot like in \"2.\"" ?.) | |
743 (const :tag "paren like in \"2)\"" ?\)) | |
744 (const :tab "both" t))) | |
745 | |
746 (defcustom org-empty-line-terminates-plain-lists nil | |
747 "Non-nil means, an empty line ends all plain list levels. | |
748 When nil, empty lines are part of the preceeding item." | |
749 :group 'org-plain-lists | |
750 :type 'boolean) | |
751 | |
752 (defcustom org-auto-renumber-ordered-lists t | |
753 "Non-nil means, automatically renumber ordered plain lists. | |
754 Renumbering happens when the sequence have been changed with | |
755 \\[org-shiftmetaup] or \\[org-shiftmetadown]. After other editing commands, | |
756 use \\[org-ctrl-c-ctrl-c] to trigger renumbering." | |
757 :group 'org-plain-lists | |
758 :type 'boolean) | |
759 | |
760 (defcustom org-provide-checkbox-statistics t | |
761 "Non-nil means, update checkbox statistics after insert and toggle. | |
762 When this is set, checkbox statistics is updated each time you either insert | |
763 a new checkbox with \\[org-insert-todo-heading] or toggle a checkbox | |
764 with \\[org-ctrl-c-ctrl-c\\]." | |
765 :group 'org-plain-lists | |
766 :type 'boolean) | |
767 | |
768 (defcustom org-description-max-indent 20 | |
769 "Maximum indentation for the second line of a description list. | |
770 When the indentation would be larger than this, it will become | |
771 5 characters instead." | |
772 :group 'org-plain-lists | |
773 :type 'integer) | |
774 | 764 |
775 (defgroup org-imenu-and-speedbar nil | 765 (defgroup org-imenu-and-speedbar nil |
776 "Options concerning imenu and speedbar in Org-mode." | 766 "Options concerning imenu and speedbar in Org-mode." |
777 :tag "Org Imenu and Speedbar" | 767 :tag "Org Imenu and Speedbar" |
778 :group 'org-structure) | 768 :group 'org-structure) |
1123 See `org-file-apps'.") | 1113 See `org-file-apps'.") |
1124 | 1114 |
1125 (defconst org-file-apps-defaults-macosx | 1115 (defconst org-file-apps-defaults-macosx |
1126 '((remote . emacs) | 1116 '((remote . emacs) |
1127 (t . "open %s") | 1117 (t . "open %s") |
1128 ("ps" . "gv %s") | |
1129 ("ps.gz" . "gv %s") | 1118 ("ps.gz" . "gv %s") |
1130 ("eps" . "gv %s") | |
1131 ("eps.gz" . "gv %s") | 1119 ("eps.gz" . "gv %s") |
1132 ("dvi" . "xdvi %s") | 1120 ("dvi" . "xdvi %s") |
1133 ("fig" . "xfig %s")) | 1121 ("fig" . "xfig %s")) |
1134 "Default file applications on a MacOS X system. | 1122 "Default file applications on a MacOS X system. |
1135 The system \"open\" is known as a default, but we use X11 applications | 1123 The system \"open\" is known as a default, but we use X11 applications |
1148 The system \"open\" is used for most files. | 1136 The system \"open\" is used for most files. |
1149 See `org-file-apps'.") | 1137 See `org-file-apps'.") |
1150 | 1138 |
1151 (defcustom org-file-apps | 1139 (defcustom org-file-apps |
1152 '( | 1140 '( |
1153 ("txt" . emacs) | 1141 (auto-mode . emacs) |
1154 ("tex" . emacs) | 1142 ("\\.x?html?\\'" . default) |
1155 ("ltx" . emacs) | |
1156 ("org" . emacs) | |
1157 ("el" . emacs) | |
1158 ("bib" . emacs) | |
1159 ) | 1143 ) |
1160 "External applications for opening `file:path' items in a document. | 1144 "External applications for opening `file:path' items in a document. |
1161 Org-mode uses system defaults for different file types, but | 1145 Org-mode uses system defaults for different file types, but |
1162 you can use this variable to set the application for a given file | 1146 you can use this variable to set the application for a given file |
1163 extension. The entries in this list are cons cells where the car identifies | 1147 extension. The entries in this list are cons cells where the car identifies |
1164 files and the cdr the corresponding command. Possible values for the | 1148 files and the cdr the corresponding command. Possible values for the |
1165 file identifier are | 1149 file identifier are |
1166 \"ext\" A string identifying an extension | 1150 \"regex\" Regular expression matched against the file name. For backward |
1151 compatibility, this can also be a string with only alphanumeric | |
1152 characters, which is then interpreted as an extension. | |
1167 `directory' Matches a directory | 1153 `directory' Matches a directory |
1168 `remote' Matches a remote file, accessible through tramp or efs. | 1154 `remote' Matches a remote file, accessible through tramp or efs. |
1169 Remote files most likely should be visited through Emacs | 1155 Remote files most likely should be visited through Emacs |
1170 because external applications cannot handle such paths. | 1156 because external applications cannot handle such paths. |
1171 t Default for all remaining files | 1157 `auto-mode' Matches files that are mached by any entry in `auto-mode-alist', |
1158 so all files Emacs knows how to handle. Useing this with | |
1159 command `emacs' will open most files in Emacs. Beware that this | |
1160 will also open html files insite Emacs, unless you add | |
1161 (\"html\" . default) to the list as well. | |
1162 t Default for files not matched by any of the other options. | |
1172 | 1163 |
1173 Possible values for the command are: | 1164 Possible values for the command are: |
1174 `emacs' The file will be visited by the current Emacs process. | 1165 `emacs' The file will be visited by the current Emacs process. |
1175 `default' Use the default application for this file type. | 1166 `default' Use the default application for this file type, which is the |
1167 association for t in the list, most likely in the system-specific | |
1168 part. | |
1169 This can be used to overrule an unwanted seting in the | |
1170 system-specific variable. | |
1176 string A command to be executed by a shell; %s will be replaced | 1171 string A command to be executed by a shell; %s will be replaced |
1177 by the path to the file. | 1172 by the path to the file. |
1178 sexp A Lisp form which will be evaluated. The file path will | 1173 sexp A Lisp form which will be evaluated. The file path will |
1179 be available in the Lisp variable `file'. | 1174 be available in the Lisp variable `file'. |
1180 For more examples, see the system specific constants | 1175 For more examples, see the system specific constants |
1185 :type '(repeat | 1180 :type '(repeat |
1186 (cons (choice :value "" | 1181 (cons (choice :value "" |
1187 (string :tag "Extension") | 1182 (string :tag "Extension") |
1188 (const :tag "Default for unrecognized files" t) | 1183 (const :tag "Default for unrecognized files" t) |
1189 (const :tag "Remote file" remote) | 1184 (const :tag "Remote file" remote) |
1190 (const :tag "Links to a directory" directory)) | 1185 (const :tag "Links to a directory" directory) |
1186 (const :tag "Any files that have Emacs modes" | |
1187 auto-mode)) | |
1191 (choice :value "" | 1188 (choice :value "" |
1192 (const :tag "Visit with Emacs" emacs) | 1189 (const :tag "Visit with Emacs" emacs) |
1193 (const :tag "Use system default" default) | 1190 (const :tag "Use system default" default) |
1194 (string :tag "Command") | 1191 (string :tag "Command") |
1195 (sexp :tag "Lisp form"))))) | 1192 (sexp :tag "Lisp form"))))) |
1259 - a cons cell (:todo . \"KEYWORD\") to identify refile targets by | 1256 - a cons cell (:todo . \"KEYWORD\") to identify refile targets by |
1260 todo keyword. | 1257 todo keyword. |
1261 - a cons cell (:regexp . \"REGEXP\") with a regular expression matching | 1258 - a cons cell (:regexp . \"REGEXP\") with a regular expression matching |
1262 headlines that are refiling targets. | 1259 headlines that are refiling targets. |
1263 - a cons cell (:level . N). Any headline of level N is considered a target. | 1260 - a cons cell (:level . N). Any headline of level N is considered a target. |
1264 - a cons cell (:maxlevel . N). Any headline with level <= N is a target." | 1261 - a cons cell (:maxlevel . N). Any headline with level <= N is a target. |
1262 | |
1263 When this variable is nil, all top-level headlines in the current buffer | |
1264 are used, equivalent to the vlaue `((nil . (:level . 1))'." | |
1265 :group 'org-remember | 1265 :group 'org-remember |
1266 :type '(repeat | 1266 :type '(repeat |
1267 (cons | 1267 (cons |
1268 (choice :value org-agenda-files | 1268 (choice :value org-agenda-files |
1269 (const :tag "All agenda files" org-agenda-files) | 1269 (const :tag "All agenda files" org-agenda-files) |
1355 (defvar org-todo-keywords-1 nil | 1355 (defvar org-todo-keywords-1 nil |
1356 "All TODO and DONE keywords active in a buffer.") | 1356 "All TODO and DONE keywords active in a buffer.") |
1357 (make-variable-buffer-local 'org-todo-keywords-1) | 1357 (make-variable-buffer-local 'org-todo-keywords-1) |
1358 (defvar org-todo-keywords-for-agenda nil) | 1358 (defvar org-todo-keywords-for-agenda nil) |
1359 (defvar org-done-keywords-for-agenda nil) | 1359 (defvar org-done-keywords-for-agenda nil) |
1360 (defvar org-todo-keyword-alist-for-agenda nil) | |
1361 (defvar org-tag-alist-for-agenda nil) | |
1360 (defvar org-agenda-contributing-files nil) | 1362 (defvar org-agenda-contributing-files nil) |
1361 (defvar org-not-done-keywords nil) | 1363 (defvar org-not-done-keywords nil) |
1362 (make-variable-buffer-local 'org-not-done-keywords) | 1364 (make-variable-buffer-local 'org-not-done-keywords) |
1363 (defvar org-done-keywords nil) | 1365 (defvar org-done-keywords nil) |
1364 (make-variable-buffer-local 'org-done-keywords) | 1366 (make-variable-buffer-local 'org-done-keywords) |
1445 ((eq org-log-done t) (setq org-log-done 'time)) | 1447 ((eq org-log-done t) (setq org-log-done 'time)) |
1446 ((and (listp org-log-done) (memq 'done org-log-done)) | 1448 ((and (listp org-log-done) (memq 'done org-log-done)) |
1447 (setq org-log-done 'note))) | 1449 (setq org-log-done 'note))) |
1448 | 1450 |
1449 (defcustom org-log-note-clock-out nil | 1451 (defcustom org-log-note-clock-out nil |
1450 "Non-nil means, recored a note when clocking out of an item. | 1452 "Non-nil means, record a note when clocking out of an item. |
1451 This can also be configured on a per-file basis by adding one of | 1453 This can also be configured on a per-file basis by adding one of |
1452 the following lines anywhere in the buffer: | 1454 the following lines anywhere in the buffer: |
1453 | 1455 |
1454 #+STARTUP: lognoteclock-out | 1456 #+STARTUP: lognoteclock-out |
1455 #+STARTUP: nolognoteclock-out" | 1457 #+STARTUP: nolognoteclock-out" |
1676 (if (fboundp 'defvaralias) | 1678 (if (fboundp 'defvaralias) |
1677 (defvaralias 'org-popup-calendar-for-date-prompt | 1679 (defvaralias 'org-popup-calendar-for-date-prompt |
1678 'org-read-date-popup-calendar)) | 1680 'org-read-date-popup-calendar)) |
1679 | 1681 |
1680 (defcustom org-extend-today-until 0 | 1682 (defcustom org-extend-today-until 0 |
1681 "The hour when your day really ends. | 1683 "The hour when your day really ends. Must be an integer. |
1682 This has influence for the following applications: | 1684 This has influence for the following applications: |
1683 - When switching the agenda to \"today\". It it is still earlier than | 1685 - When switching the agenda to \"today\". It it is still earlier than |
1684 the time given here, the day recognized as TODAY is actually yesterday. | 1686 the time given here, the day recognized as TODAY is actually yesterday. |
1685 - When a date is read from the user and it is still before the time given | 1687 - When a date is read from the user and it is still before the time given |
1686 here, the current date and time will be assumed to be yesterday, 23:59. | 1688 here, the current date and time will be assumed to be yesterday, 23:59. |
1687 | 1689 Also, timestamps inserted in remember templates follow this rule. |
1688 FIXME: | 1690 |
1689 IMPORTANT: This is still a very experimental feature, it may disappear | 1691 IMPORTANT: This is a feature whose implementation is and likely will |
1690 again or it may be extended to mean more things." | 1692 remain incomplete. Really, it is only here because past midnight seems to |
1693 ne the favorite working time of John Wiegley :-)" | |
1691 :group 'org-time | 1694 :group 'org-time |
1692 :type 'number) | 1695 :type 'number) |
1693 | 1696 |
1694 (defcustom org-edit-timestamp-down-means-later nil | 1697 (defcustom org-edit-timestamp-down-means-later nil |
1695 "Non-nil means, S-down will increase the time in a time stamp. | 1698 "Non-nil means, S-down will increase the time in a time stamp. |
1898 field are replaced by this string. If the column is narrower than the | 1901 field are replaced by this string. If the column is narrower than the |
1899 ellipses string, only part of the ellipses string will be shown." | 1902 ellipses string, only part of the ellipses string will be shown." |
1900 :group 'org-properties | 1903 :group 'org-properties |
1901 :type 'string) | 1904 :type 'string) |
1902 | 1905 |
1906 (defcustom org-columns-modify-value-for-display-function nil | |
1907 "Function that modifies values for display in column view. | |
1908 For example, it can be used to cut out a certain part from a time stamp. | |
1909 The function must take 2 argments: | |
1910 | |
1911 column-title The tite of the column (*not* the property name) | |
1912 value The value that should be modified. | |
1913 | |
1914 The function should return the value that should be displayed, | |
1915 or nil if the normal value should be used." | |
1916 :group 'org-properties | |
1917 :type 'function) | |
1903 | 1918 |
1904 (defcustom org-effort-property "Effort" | 1919 (defcustom org-effort-property "Effort" |
1905 "The property that is being used to keep track of effort estimates. | 1920 "The property that is being used to keep track of effort estimates. |
1906 Effort estimates given in this property need to have the format H:MM." | 1921 Effort estimates given in this property need to have the format H:MM." |
1907 :group 'org-properties | 1922 :group 'org-properties |
1946 #+CATEGORY: ELisp | 1961 #+CATEGORY: ELisp |
1947 | 1962 |
1948 If the file does not specify a category, then file's base name | 1963 If the file does not specify a category, then file's base name |
1949 is used instead.") | 1964 is used instead.") |
1950 (make-variable-buffer-local 'org-category) | 1965 (make-variable-buffer-local 'org-category) |
1966 (put 'org-category 'safe-local-variable '(lambda (x) (or (symbolp x) (stringp x)))) | |
1951 | 1967 |
1952 (defcustom org-agenda-files nil | 1968 (defcustom org-agenda-files nil |
1953 "The files to be used for agenda display. | 1969 "The files to be used for agenda display. |
1954 Entries may be added to this list with \\[org-agenda-file-to-front] and removed with | 1970 Entries may be added to this list with \\[org-agenda-file-to-front] and removed with |
1955 \\[org-remove-file]. You can also use customize to edit the list. | 1971 \\[org-remove-file]. You can also use customize to edit the list. |
2342 org-table-next-field org-table-next-row org-table-paste-rectangle | 2358 org-table-next-field org-table-next-row org-table-paste-rectangle |
2343 org-table-previous-field org-table-recalculate | 2359 org-table-previous-field org-table-recalculate |
2344 org-table-rotate-recalc-marks org-table-sort-lines org-table-sum | 2360 org-table-rotate-recalc-marks org-table-sort-lines org-table-sum |
2345 org-table-toggle-coordinate-overlays | 2361 org-table-toggle-coordinate-overlays |
2346 org-table-toggle-formula-debugger org-table-wrap-region | 2362 org-table-toggle-formula-debugger org-table-wrap-region |
2347 orgtbl-mode turn-on-orgtbl))) | 2363 orgtbl-mode turn-on-orgtbl org-table-to-lisp))) |
2348 | 2364 |
2349 (defun org-at-table-p (&optional table-type) | 2365 (defun org-at-table-p (&optional table-type) |
2350 "Return t if the cursor is inside an org-type table. | 2366 "Return t if the cursor is inside an org-type table. |
2351 If TABLE-TYPE is non-nil, also check for table.el-type tables." | 2367 If TABLE-TYPE is non-nil, also check for table.el-type tables." |
2352 (if org-enable-table-editor | 2368 (if org-enable-table-editor |
2427 org-export-as-html org-export-icalendar-this-file | 2443 org-export-as-html org-export-icalendar-this-file |
2428 org-export-icalendar-all-agenda-files | 2444 org-export-icalendar-all-agenda-files |
2429 org-table-clean-before-export | 2445 org-table-clean-before-export |
2430 org-export-icalendar-combine-agenda-files org-export-as-xoxo))) | 2446 org-export-icalendar-combine-agenda-files org-export-as-xoxo))) |
2431 | 2447 |
2432 ;; Declare and autoload functions from org-exp.el | 2448 ;; Declare and autoload functions from org-agenda.el |
2433 | 2449 |
2434 (eval-and-compile | 2450 (eval-and-compile |
2435 (org-autoload "org-exp" | 2451 (org-autoload "org-agenda" |
2436 '(org-agenda org-agenda-list org-search-view | 2452 '(org-agenda org-agenda-list org-search-view |
2437 org-todo-list org-tags-view org-agenda-list-stuck-projects | 2453 org-todo-list org-tags-view org-agenda-list-stuck-projects |
2438 org-diary org-agenda-to-appt))) | 2454 org-diary org-agenda-to-appt))) |
2439 | 2455 |
2440 ;; Autoload org-remember | 2456 ;; Autoload org-remember |
3497 'keymap org-mouse-map | 3513 'keymap org-mouse-map |
3498 )) | 3514 )) |
3499 (throw 'exit t)))))) | 3515 (throw 'exit t)))))) |
3500 | 3516 |
3501 (defun org-activate-code (limit) | 3517 (defun org-activate-code (limit) |
3502 (if (re-search-forward "^[ \t]*\\(:.*\\)" limit t) | 3518 (if (re-search-forward "^[ \t]*\\(: .*\n?\\)" limit t) |
3503 (unless (get-text-property (match-beginning 1) 'face) | 3519 (progn |
3504 (remove-text-properties (match-beginning 0) (match-end 0) | 3520 (remove-text-properties (match-beginning 0) (match-end 0) |
3505 '(display t invisible t intangible t)) | 3521 '(display t invisible t intangible t)) |
3506 t))) | 3522 t))) |
3507 | 3523 |
3508 (defun org-activate-angle-links (limit) | 3524 (defun org-activate-angle-links (limit) |
3869 - When this function is called with a prefix argument, rotate the entire | 3885 - When this function is called with a prefix argument, rotate the entire |
3870 buffer through 3 states (global cycling) | 3886 buffer through 3 states (global cycling) |
3871 1. OVERVIEW: Show only top-level headlines. | 3887 1. OVERVIEW: Show only top-level headlines. |
3872 2. CONTENTS: Show all headlines of all levels, but no body text. | 3888 2. CONTENTS: Show all headlines of all levels, but no body text. |
3873 3. SHOW ALL: Show everything. | 3889 3. SHOW ALL: Show everything. |
3874 When called with two C-c C-u prefixes, switch to the startup visibility, | 3890 When called with two C-u C-u prefixes, switch to the startup visibility, |
3875 determined by the variable `org-startup-folded', and by any VISIBILITY | 3891 determined by the variable `org-startup-folded', and by any VISIBILITY |
3876 properties in the buffer. | 3892 properties in the buffer. |
3893 When called with three C-u C-u C-u prefixed, show the entire buffer, | |
3894 including drawers. | |
3877 | 3895 |
3878 - When point is at the beginning of a headline, rotate the subtree started | 3896 - When point is at the beginning of a headline, rotate the subtree started |
3879 by this line through 3 different states (local cycling) | 3897 by this line through 3 different states (local cycling) |
3880 1. FOLDED: Only the main headline is shown. | 3898 1. FOLDED: Only the main headline is shown. |
3881 2. CHILDREN: The main headline and the direct children are shown. | 3899 2. CHILDREN: The main headline and the direct children are shown. |
3915 | 3933 |
3916 (cond | 3934 (cond |
3917 | 3935 |
3918 ((equal arg '(16)) | 3936 ((equal arg '(16)) |
3919 (org-set-startup-visibility) | 3937 (org-set-startup-visibility) |
3920 (message "Startup visibility, plus VISIBILITY properties.")) | 3938 (message "Startup visibility, plus VISIBILITY properties")) |
3939 | |
3940 ((equal arg '(64)) | |
3941 (show-all) | |
3942 (message "Entire buffer visible, including drawers")) | |
3921 | 3943 |
3922 ((org-at-table-p 'any) | 3944 ((org-at-table-p 'any) |
3923 ;; Enter the table or move to the next field in the table | 3945 ;; Enter the table or move to the next field in the table |
3924 (or (org-table-recognize-table.el) | 3946 (or (org-table-recognize-table.el) |
3925 (progn | 3947 (progn |
4349 This function uses a recursive edit. It returns the selected position | 4371 This function uses a recursive edit. It returns the selected position |
4350 or nil." | 4372 or nil." |
4351 (let ((isearch-mode-map org-goto-local-auto-isearch-map) | 4373 (let ((isearch-mode-map org-goto-local-auto-isearch-map) |
4352 (isearch-hide-immediately nil) | 4374 (isearch-hide-immediately nil) |
4353 (isearch-search-fun-function | 4375 (isearch-search-fun-function |
4354 (lambda () 'org-goto-local-search-forward-headings)) | 4376 (lambda () 'org-goto-local-search-headings)) |
4355 (org-goto-selected-point org-goto-exit-command)) | 4377 (org-goto-selected-point org-goto-exit-command)) |
4356 (save-excursion | 4378 (save-excursion |
4357 (save-window-excursion | 4379 (save-window-excursion |
4358 (delete-other-windows) | 4380 (delete-other-windows) |
4359 (and (get-buffer "*org-goto*") (kill-buffer "*org-goto*")) | 4381 (and (get-buffer "*org-goto*") (kill-buffer "*org-goto*")) |
4390 (defvar org-goto-local-auto-isearch-map (make-sparse-keymap)) | 4412 (defvar org-goto-local-auto-isearch-map (make-sparse-keymap)) |
4391 (set-keymap-parent org-goto-local-auto-isearch-map isearch-mode-map) | 4413 (set-keymap-parent org-goto-local-auto-isearch-map isearch-mode-map) |
4392 (define-key org-goto-local-auto-isearch-map "\C-i" 'isearch-other-control-char) | 4414 (define-key org-goto-local-auto-isearch-map "\C-i" 'isearch-other-control-char) |
4393 (define-key org-goto-local-auto-isearch-map "\C-m" 'isearch-other-control-char) | 4415 (define-key org-goto-local-auto-isearch-map "\C-m" 'isearch-other-control-char) |
4394 | 4416 |
4395 (defun org-goto-local-search-forward-headings (string bound noerror) | 4417 (defun org-goto-local-search-headings (string bound noerror) |
4396 "Search and make sure that anu matches are in headlines." | 4418 "Search and make sure that any matches are in headlines." |
4397 (catch 'return | 4419 (catch 'return |
4398 (while (search-forward string bound noerror) | 4420 (while (if isearch-forward |
4421 (search-forward string bound noerror) | |
4422 (search-backward string bound noerror)) | |
4399 (when (let ((context (mapcar 'car (save-match-data (org-context))))) | 4423 (when (let ((context (mapcar 'car (save-match-data (org-context))))) |
4400 (and (member :headline context) | 4424 (and (member :headline context) |
4401 (not (member :tags context)))) | 4425 (not (member :tags context)))) |
4402 (throw 'return (point)))))) | 4426 (throw 'return (point)))))) |
4403 | 4427 |
4566 ;; in the middle of the line | 4590 ;; in the middle of the line |
4567 (org-show-entry) | 4591 (org-show-entry) |
4568 (let ((split | 4592 (let ((split |
4569 (org-get-alist-option org-M-RET-may-split-line 'headline)) | 4593 (org-get-alist-option org-M-RET-may-split-line 'headline)) |
4570 tags pos) | 4594 tags pos) |
4571 (if (org-on-heading-p) | 4595 (cond |
4572 (progn | 4596 (org-insert-heading-respect-content |
4573 (looking-at ".*?\\([ \t]+\\(:[[:alnum:]_@:]+:\\)\\)?[ \t]*$") | 4597 (org-end-of-subtree nil t) |
4574 (setq tags (and (match-end 2) (match-string 2))) | 4598 (open-line 1)) |
4575 (and (match-end 1) | 4599 ((org-on-heading-p) |
4576 (delete-region (match-beginning 1) (match-end 1))) | 4600 (looking-at ".*?\\([ \t]+\\(:[[:alnum:]_@:]+:\\)\\)?[ \t]*$") |
4577 (setq pos (point-at-bol)) | 4601 (setq tags (and (match-end 2) (match-string 2))) |
4578 (or split (end-of-line 1)) | 4602 (and (match-end 1) |
4579 (delete-horizontal-space) | 4603 (delete-region (match-beginning 1) (match-end 1))) |
4580 (newline (if blank 2 1)) | 4604 (setq pos (point-at-bol)) |
4581 (when tags | |
4582 (save-excursion | |
4583 (goto-char pos) | |
4584 (end-of-line 1) | |
4585 (insert " " tags) | |
4586 (org-set-tags nil 'align)))) | |
4587 (or split (end-of-line 1)) | 4605 (or split (end-of-line 1)) |
4588 (newline (if blank 2 1)))))) | 4606 (delete-horizontal-space) |
4607 (newline (if blank 2 1)) | |
4608 (when tags | |
4609 (save-excursion | |
4610 (goto-char pos) | |
4611 (end-of-line 1) | |
4612 (insert " " tags) | |
4613 (org-set-tags nil 'align)))) | |
4614 (t | |
4615 (or split (end-of-line 1)) | |
4616 (newline (if blank 2 1))))))) | |
4589 (insert head) (just-one-space) | 4617 (insert head) (just-one-space) |
4590 (setq pos (point)) | 4618 (setq pos (point)) |
4591 (end-of-line 1) | 4619 (end-of-line 1) |
4592 (unless (= (point) pos) (just-one-space) (backward-delete-char 1)) | 4620 (unless (= (point) pos) (just-one-space) (backward-delete-char 1)) |
4593 (run-hooks 'org-insert-heading-hook))))) | 4621 (run-hooks 'org-insert-heading-hook))))) |
4607 (interactive) | 4635 (interactive) |
4608 (org-back-to-heading) | 4636 (org-back-to-heading) |
4609 (org-insert-heading) | 4637 (org-insert-heading) |
4610 (org-move-subtree-down) | 4638 (org-move-subtree-down) |
4611 (end-of-line 1)) | 4639 (end-of-line 1)) |
4640 | |
4641 (defun org-insert-heading-respect-content () | |
4642 (interactive) | |
4643 (let ((org-insert-heading-respect-content t)) | |
4644 (call-interactively 'org-insert-heading))) | |
4645 | |
4646 (defun org-insert-todo-heading-respect-content () | |
4647 (interactive) | |
4648 (let ((org-insert-heading-respect-content t)) | |
4649 (call-interactively 'org-insert-todo-todo-heading))) | |
4612 | 4650 |
4613 (defun org-insert-todo-heading (arg) | 4651 (defun org-insert-todo-heading (arg) |
4614 "Insert a new heading with the same level and TODO state as current heading. | 4652 "Insert a new heading with the same level and TODO state as current heading. |
4615 If the heading has no TODO state, or if the state is DONE, use the first | 4653 If the heading has no TODO state, or if the state is DONE, use the first |
4616 state (TODO by default). Also with prefix arg, force first state." | 4654 state (TODO by default). Also with prefix arg, force first state." |
5075 (string-match (concat "\\`\\([ \t\n\r]*?\n\\)?\\(" | 5113 (string-match (concat "\\`\\([ \t\n\r]*?\n\\)?\\(" |
5076 org-outline-regexp "\\)") | 5114 org-outline-regexp "\\)") |
5077 kill) | 5115 kill) |
5078 (- (match-end 2) (match-beginning 2) 1))) | 5116 (- (match-end 2) (match-beginning 2) 1))) |
5079 (re (concat "^" org-outline-regexp)) | 5117 (re (concat "^" org-outline-regexp)) |
5080 (start (1+ (match-beginning 2)))) | 5118 (start (1+ (or (match-beginning 2) -1)))) |
5081 (if (not start-level) | 5119 (if (not start-level) |
5082 (progn | 5120 (progn |
5083 nil) ;; does not even start with a heading | 5121 nil) ;; does not even start with a heading |
5084 (catch 'exit | 5122 (catch 'exit |
5085 (while (setq start (string-match re kill (1+ start))) | 5123 (while (setq start (string-match re kill (1+ start))) |
5293 (error "Invalid key function `%s'" getkey-func))) | 5331 (error "Invalid key function `%s'" getkey-func))) |
5294 (t (error "Invalid sorting type `%c'" sorting-type))))) | 5332 (t (error "Invalid sorting type `%c'" sorting-type))))) |
5295 (lambda nil | 5333 (lambda nil |
5296 (cond | 5334 (cond |
5297 ((= dcst ?n) | 5335 ((= dcst ?n) |
5298 (if (looking-at outline-regexp) | 5336 (if (looking-at org-complex-heading-regexp) |
5299 (string-to-number (buffer-substring (match-end 0) | 5337 (string-to-number (match-string 4)) |
5300 (point-at-eol))) | |
5301 nil)) | 5338 nil)) |
5302 ((= dcst ?a) | 5339 ((= dcst ?a) |
5303 (funcall case-func (buffer-substring (point-at-bol) | 5340 (if (looking-at org-complex-heading-regexp) |
5304 (point-at-eol)))) | 5341 (funcall case-func (match-string 4)) |
5342 nil)) | |
5305 ((= dcst ?t) | 5343 ((= dcst ?t) |
5306 (if (re-search-forward org-ts-regexp | 5344 (if (re-search-forward org-ts-regexp |
5307 (save-excursion | 5345 (save-excursion |
5308 (forward-line 2) | 5346 (forward-line 2) |
5309 (point)) t) | 5347 (point)) t) |
5378 | 5416 |
5379 (defvar org-exit-edit-mode-map (make-sparse-keymap)) | 5417 (defvar org-exit-edit-mode-map (make-sparse-keymap)) |
5380 (define-key org-exit-edit-mode-map "\C-c'" 'org-edit-src-exit) | 5418 (define-key org-exit-edit-mode-map "\C-c'" 'org-edit-src-exit) |
5381 (defvar org-edit-src-force-single-line nil) | 5419 (defvar org-edit-src-force-single-line nil) |
5382 (defvar org-edit-src-from-org-mode nil) | 5420 (defvar org-edit-src-from-org-mode nil) |
5421 (defvar org-edit-src-picture nil) | |
5383 | 5422 |
5384 (define-minor-mode org-exit-edit-mode | 5423 (define-minor-mode org-exit-edit-mode |
5385 "Minor mode installing a single key binding, \"C-c '\" to exit special edit.") | 5424 "Minor mode installing a single key binding, \"C-c '\" to exit special edit.") |
5386 | 5425 |
5387 (defun org-edit-src-code () | 5426 (defun org-edit-src-code () |
5426 (org-exit-edit-mode) | 5465 (org-exit-edit-mode) |
5427 (org-set-local 'header-line-format msg) | 5466 (org-set-local 'header-line-format msg) |
5428 (message "%s" msg) | 5467 (message "%s" msg) |
5429 t))) | 5468 t))) |
5430 | 5469 |
5470 (defun org-edit-fixed-width-region () | |
5471 "Edit the fixed-width ascii drawing at point. | |
5472 This must be a region where each line starts with ca colon followed by | |
5473 a space character. | |
5474 An indirect buffer is created, and that buffer is then narrowed to the | |
5475 example at point and switched to artist-mode. When done, | |
5476 exit by killing the buffer with \\[org-edit-src-exit]." | |
5477 (interactive) | |
5478 (let ((line (org-current-line)) | |
5479 (case-fold-search t) | |
5480 (msg (substitute-command-keys | |
5481 "Edit, then exit with C-c ' (C-c and single quote)")) | |
5482 (org-mode-p (eq major-mode 'org-mode)) | |
5483 beg end lang lang-f) | |
5484 (beginning-of-line 1) | |
5485 (if (looking-at "[ \t]*[^:\n \t]") | |
5486 nil | |
5487 (if (looking-at "[ \t]*\\(\n\\|\\'\\)]") | |
5488 (setq beg (point) end (match-end 0)) | |
5489 (save-excursion | |
5490 (if (re-search-backward "^[ \t]*[^:]" nil 'move) | |
5491 (setq beg (point-at-bol 2)) | |
5492 (setq beg (point)))) | |
5493 (save-excursion | |
5494 (if (re-search-forward "^[ \t]*[^:]" nil 'move) | |
5495 (setq end (1- (match-beginning 0))) | |
5496 (setq end (point)))) | |
5497 (goto-line line) | |
5498 (if (get-buffer "*Org Edit Picture*") | |
5499 (kill-buffer "*Org Edit Picture*")) | |
5500 (switch-to-buffer (make-indirect-buffer (current-buffer) | |
5501 "*Org Edit Picture*")) | |
5502 (narrow-to-region beg end) | |
5503 (remove-text-properties beg end '(display nil invisible nil | |
5504 intangible nil)) | |
5505 (when (fboundp 'font-lock-unfontify-region) | |
5506 (font-lock-unfontify-region (point-min) (point-max))) | |
5507 (cond | |
5508 ((eq org-edit-fixed-width-region-mode 'artist-mode) | |
5509 (fundamental-mode) | |
5510 (artist-mode 1)) | |
5511 (t (funcall org-edit-fixed-width-region-mode))) | |
5512 (set (make-local-variable 'org-edit-src-force-single-line) nil) | |
5513 (set (make-local-variable 'org-edit-src-from-org-mode) org-mode-p) | |
5514 (set (make-local-variable 'org-edit-src-picture) t) | |
5515 (goto-char (point-min)) | |
5516 (while (re-search-forward "^[ \t]*: " nil t) | |
5517 (replace-match "")) | |
5518 (goto-line line) | |
5519 (org-exit-edit-mode) | |
5520 (org-set-local 'header-line-format msg) | |
5521 (message "%s" msg) | |
5522 t)))) | |
5523 | |
5524 | |
5431 (defun org-edit-src-find-region-and-lang () | 5525 (defun org-edit-src-find-region-and-lang () |
5432 "Find the region and language for a local edit. | 5526 "Find the region and language for a local edit. |
5433 Return a list with beginning and end of the region, a string representing | 5527 Return a list with beginning and end of the region, a string representing |
5434 the language, a switch telling of the content should be in a single line." | 5528 the language, a switch telling of the content should be in a single line." |
5435 (let ((re-list | 5529 (let ((re-list |
5436 '( | 5530 (append |
5437 ("<src\\>[^<]*>[ \t]*\n?" "\n?[ \t]*</src>" lang) | 5531 org-edit-src-region-extra |
5438 ("<literal\\>[^<]*>[ \t]*\n?" "\n?[ \t]*</literal>" style) | 5532 '( |
5439 ("<example>[ \t]*\n?" "\n?[ \t]*</example>" "fundamental") | 5533 ("<src\\>[^<]*>[ \t]*\n?" "\n?[ \t]*</src>" lang) |
5440 ("<lisp>[ \t]*\n?" "\n?[ \t]*</lisp>" "emacs-lisp") | 5534 ("<literal\\>[^<]*>[ \t]*\n?" "\n?[ \t]*</literal>" style) |
5441 ("<perl>[ \t]*\n?" "\n?[ \t]*</perl>" "perl") | 5535 ("<example>[ \t]*\n?" "\n?[ \t]*</example>" "fundamental") |
5442 ("<python>[ \t]*\n?" "\n?[ \t]*</python>" "python") | 5536 ("<lisp>[ \t]*\n?" "\n?[ \t]*</lisp>" "emacs-lisp") |
5443 ("<ruby>[ \t]*\n?" "\n?[ \t]*</ruby>" "ruby") | 5537 ("<perl>[ \t]*\n?" "\n?[ \t]*</perl>" "perl") |
5444 ("^#\\+begin_src\\( \\([^ \t\n]+\\)\\)?.*\n" "\n#\\+end_src" 2) | 5538 ("<python>[ \t]*\n?" "\n?[ \t]*</python>" "python") |
5445 ("^#\\+begin_example.*\n" "^#\\+end_example" "fundamental") | 5539 ("<ruby>[ \t]*\n?" "\n?[ \t]*</ruby>" "ruby") |
5446 ("^#\\+html:" "\n" "html" single-line) | 5540 ("^#\\+begin_src\\( \\([^ \t\n]+\\)\\)?.*\n" "\n#\\+end_src" 2) |
5447 ("^#\\+begin_html.*\n" "\n#\\+end_html" "html") | 5541 ("^#\\+begin_example.*\n" "\n#\\+end_example" "fundamental") |
5448 ("^#\\+begin_latex.*\n" "\n#\\+end_latex" "latex") | 5542 ("^#\\+html:" "\n" "html" single-line) |
5449 ("^#\\+latex:" "\n" "latex" single-line) | 5543 ("^#\\+begin_html.*\n" "\n#\\+end_html" "html") |
5450 ("^#\\+begin_ascii.*\n" "\n#\\+end_ascii" "fundamental") | 5544 ("^#\\+begin_latex.*\n" "\n#\\+end_latex" "latex") |
5451 ("^#\\+ascii:" "\n" "ascii" single-line) | 5545 ("^#\\+latex:" "\n" "latex" single-line) |
5452 )) | 5546 ("^#\\+begin_ascii.*\n" "\n#\\+end_ascii" "fundamental") |
5547 ("^#\\+ascii:" "\n" "ascii" single-line) | |
5548 ))) | |
5453 (pos (point)) | 5549 (pos (point)) |
5454 re re1 re2 single beg end lang) | 5550 re re1 re2 single beg end lang) |
5455 (catch 'exit | 5551 (catch 'exit |
5456 (while (setq entry (pop re-list)) | 5552 (while (setq entry (pop re-list)) |
5457 (setq re1 (car entry) re2 (nth 1 entry) lang (nth 2 entry) | 5553 (setq re1 (car entry) re2 (nth 1 entry) lang (nth 2 entry) |
5478 "Extract the src language." | 5574 "Extract the src language." |
5479 (let ((m (match-string 0))) | 5575 (let ((m (match-string 0))) |
5480 (cond | 5576 (cond |
5481 ((stringp lang) lang) | 5577 ((stringp lang) lang) |
5482 ((integerp lang) (match-string lang)) | 5578 ((integerp lang) (match-string lang)) |
5483 ((and (eq lang lang) | 5579 ((and (eq lang 'lang) |
5484 (string-match "\\<lang=\"\\([^ \t\n\"]+\\)\"" m)) | 5580 (string-match "\\<lang=\"\\([^ \t\n\"]+\\)\"" m)) |
5485 (match-string 1 m)) | 5581 (match-string 1 m)) |
5486 ((and (eq lang lang) | 5582 ((and (eq lang 'style) |
5487 (string-match "\\<style=\"\\([^ \t\n\"]+\\)\"" m)) | 5583 (string-match "\\<style=\"\\([^ \t\n\"]+\\)\"" m)) |
5488 (match-string 1 m)) | 5584 (match-string 1 m)) |
5489 (t "fundamental")))) | 5585 (t "fundamental")))) |
5490 | 5586 |
5491 (defun org-edit-src-exit () | 5587 (defun org-edit-src-exit () |
5511 (while (re-search-forward (if (org-mode-p) "^\\(.\\)" "^\\([*#]\\)") nil t) | 5607 (while (re-search-forward (if (org-mode-p) "^\\(.\\)" "^\\([*#]\\)") nil t) |
5512 (replace-match ",\\1")) | 5608 (replace-match ",\\1")) |
5513 (when font-lock-mode | 5609 (when font-lock-mode |
5514 (font-lock-unfontify-region (point-min) (point-max))) | 5610 (font-lock-unfontify-region (point-min) (point-max))) |
5515 (put-text-property (point-min) (point-max) 'font-lock-fontified t)) | 5611 (put-text-property (point-min) (point-max) 'font-lock-fontified t)) |
5612 (when (org-bound-and-true-p org-edit-src-picture) | |
5613 (goto-char (point-min)) | |
5614 (while (re-search-forward "^" nil t) | |
5615 (replace-match ": ")) | |
5616 (when font-lock-mode | |
5617 (font-lock-unfontify-region (point-min) (point-max))) | |
5618 (put-text-property (point-min) (point-max) 'font-lock-fontified t)) | |
5516 (kill-buffer (current-buffer)) | 5619 (kill-buffer (current-buffer)) |
5517 (and (org-mode-p) (org-restart-font-lock))) | 5620 (and (org-mode-p) (org-restart-font-lock))) |
5518 | 5621 |
5519 ;;;; Plain list items, including checkboxes | |
5520 | |
5521 ;;; Plain list items | |
5522 | |
5523 (defun org-at-item-p () | |
5524 "Is point in a line starting a hand-formatted item?" | |
5525 (let ((llt org-plain-list-ordered-item-terminator)) | |
5526 (save-excursion | |
5527 (goto-char (point-at-bol)) | |
5528 (looking-at | |
5529 (cond | |
5530 ((eq llt t) "\\([ \t]*\\([-+]\\|\\([0-9]+[.)]\\)\\)\\|[ \t]+\\*\\)\\( \\|$\\)") | |
5531 ((= llt ?.) "\\([ \t]*\\([-+]\\|\\([0-9]+\\.\\)\\)\\|[ \t]+\\*\\)\\( \\|$\\)") | |
5532 ((= llt ?\)) "\\([ \t]*\\([-+]\\|\\([0-9]+))\\)\\|[ \t]+\\*\\)\\( \\|$\\)") | |
5533 (t (error "Invalid value of `org-plain-list-ordered-item-terminator'"))))))) | |
5534 | |
5535 (defun org-in-item-p () | |
5536 "It the cursor inside a plain list item. | |
5537 Does not have to be the first line." | |
5538 (save-excursion | |
5539 (condition-case nil | |
5540 (progn | |
5541 (org-beginning-of-item) | |
5542 (org-at-item-p) | |
5543 t) | |
5544 (error nil)))) | |
5545 | |
5546 (defun org-insert-item (&optional checkbox) | |
5547 "Insert a new item at the current level. | |
5548 Return t when things worked, nil when we are not in an item." | |
5549 (when (save-excursion | |
5550 (condition-case nil | |
5551 (progn | |
5552 (org-beginning-of-item) | |
5553 (org-at-item-p) | |
5554 (if (org-invisible-p) (error "Invisible item")) | |
5555 t) | |
5556 (error nil))) | |
5557 (let* ((bul (match-string 0)) | |
5558 (descp (save-excursion (goto-char (match-beginning 0)) | |
5559 (beginning-of-line 1) | |
5560 (save-match-data | |
5561 (looking-at "[ \t]*.*? ::")))) | |
5562 (eow (save-excursion (beginning-of-line 1) (looking-at "[ \t]*") | |
5563 (match-end 0))) | |
5564 (blank (cdr (assq 'plain-list-item org-blank-before-new-entry))) | |
5565 pos) | |
5566 (if descp (setq checkbox nil)) | |
5567 (cond | |
5568 ((and (org-at-item-p) (<= (point) eow)) | |
5569 ;; before the bullet | |
5570 (beginning-of-line 1) | |
5571 (open-line (if blank 2 1))) | |
5572 ((<= (point) eow) | |
5573 (beginning-of-line 1)) | |
5574 (t | |
5575 (unless (org-get-alist-option org-M-RET-may-split-line 'item) | |
5576 (end-of-line 1) | |
5577 (delete-horizontal-space)) | |
5578 (newline (if blank 2 1)))) | |
5579 (insert bul | |
5580 (if checkbox "[ ]" "") | |
5581 (if descp (concat (if checkbox " " "") | |
5582 (read-string "Term: ") " :: ") "")) | |
5583 (just-one-space) | |
5584 (setq pos (point)) | |
5585 (end-of-line 1) | |
5586 (unless (= (point) pos) (just-one-space) (backward-delete-char 1))) | |
5587 (org-maybe-renumber-ordered-list) | |
5588 (and checkbox (org-update-checkbox-count-maybe)) | |
5589 t)) | |
5590 | |
5591 ;;; Checkboxes | |
5592 | |
5593 (defun org-at-item-checkbox-p () | |
5594 "Is point at a line starting a plain-list item with a checklet?" | |
5595 (and (org-at-item-p) | |
5596 (save-excursion | |
5597 (goto-char (match-end 0)) | |
5598 (skip-chars-forward " \t") | |
5599 (looking-at "\\[[- X]\\]")))) | |
5600 | |
5601 (defun org-toggle-checkbox (&optional arg) | |
5602 "Toggle the checkbox in the current line." | |
5603 (interactive "P") | |
5604 (catch 'exit | |
5605 (let (beg end status (firstnew 'unknown)) | |
5606 (cond | |
5607 ((org-region-active-p) | |
5608 (setq beg (region-beginning) end (region-end))) | |
5609 ((org-on-heading-p) | |
5610 (setq beg (point) end (save-excursion (outline-next-heading) (point)))) | |
5611 ((org-at-item-checkbox-p) | |
5612 (let ((pos (point))) | |
5613 (replace-match | |
5614 (cond (arg "[-]") | |
5615 ((member (match-string 0) '("[ ]" "[-]")) "[X]") | |
5616 (t "[ ]")) | |
5617 t t) | |
5618 (goto-char pos)) | |
5619 (throw 'exit t)) | |
5620 (t (error "Not at a checkbox or heading, and no active region"))) | |
5621 (save-excursion | |
5622 (goto-char beg) | |
5623 (while (< (point) end) | |
5624 (when (org-at-item-checkbox-p) | |
5625 (setq status (equal (match-string 0) "[X]")) | |
5626 (when (eq firstnew 'unknown) | |
5627 (setq firstnew (not status))) | |
5628 (replace-match | |
5629 (if (if arg (not status) firstnew) "[X]" "[ ]") t t)) | |
5630 (beginning-of-line 2))))) | |
5631 (org-update-checkbox-count-maybe)) | |
5632 | |
5633 (defun org-update-checkbox-count-maybe () | |
5634 "Update checkbox statistics unless turned off by user." | |
5635 (when org-provide-checkbox-statistics | |
5636 (org-update-checkbox-count))) | |
5637 | |
5638 (defun org-update-checkbox-count (&optional all) | |
5639 "Update the checkbox statistics in the current section. | |
5640 This will find all statistic cookies like [57%] and [6/12] and update them | |
5641 with the current numbers. With optional prefix argument ALL, do this for | |
5642 the whole buffer." | |
5643 (interactive "P") | |
5644 (save-excursion | |
5645 (let* ((buffer-invisibility-spec (org-inhibit-invisibility)) ; Emacs 21 | |
5646 (beg (condition-case nil | |
5647 (progn (outline-back-to-heading) (point)) | |
5648 (error (point-min)))) | |
5649 (end (move-marker (make-marker) | |
5650 (progn (outline-next-heading) (point)))) | |
5651 (re "\\(\\(\\[[0-9]*%\\]\\)\\|\\(\\[[0-9]*/[0-9]*\\]\\)\\)") | |
5652 (re-box "^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +\\(\\[[- X]\\]\\)") | |
5653 (re-find (concat re "\\|" re-box)) | |
5654 beg-cookie end-cookie is-percent c-on c-off lim | |
5655 eline curr-ind next-ind continue-from startsearch | |
5656 (cstat 0) | |
5657 ) | |
5658 (when all | |
5659 (goto-char (point-min)) | |
5660 (outline-next-heading) | |
5661 (setq beg (point) end (point-max))) | |
5662 (goto-char end) | |
5663 ;; find each statistic cookie | |
5664 (while (re-search-backward re-find beg t) | |
5665 (setq beg-cookie (match-beginning 1) | |
5666 end-cookie (match-end 1) | |
5667 cstat (+ cstat (if end-cookie 1 0)) | |
5668 startsearch (point-at-eol) | |
5669 continue-from (point-at-bol) | |
5670 is-percent (match-beginning 2) | |
5671 lim (cond | |
5672 ((org-on-heading-p) (outline-next-heading) (point)) | |
5673 ((org-at-item-p) (org-end-of-item) (point)) | |
5674 (t nil)) | |
5675 c-on 0 | |
5676 c-off 0) | |
5677 (when lim | |
5678 ;; find first checkbox for this cookie and gather | |
5679 ;; statistics from all that are at this indentation level | |
5680 (goto-char startsearch) | |
5681 (if (re-search-forward re-box lim t) | |
5682 (progn | |
5683 (org-beginning-of-item) | |
5684 (setq curr-ind (org-get-indentation)) | |
5685 (setq next-ind curr-ind) | |
5686 (while (and (bolp) (org-at-item-p) (= curr-ind next-ind)) | |
5687 (save-excursion (end-of-line) (setq eline (point))) | |
5688 (if (re-search-forward re-box eline t) | |
5689 (if (member (match-string 2) '("[ ]" "[-]")) | |
5690 (setq c-off (1+ c-off)) | |
5691 (setq c-on (1+ c-on)) | |
5692 ) | |
5693 ) | |
5694 (org-end-of-item) | |
5695 (setq next-ind (org-get-indentation)) | |
5696 ))) | |
5697 (goto-char continue-from) | |
5698 ;; update cookie | |
5699 (when end-cookie | |
5700 (delete-region beg-cookie end-cookie) | |
5701 (goto-char beg-cookie) | |
5702 (insert | |
5703 (if is-percent | |
5704 (format "[%d%%]" (/ (* 100 c-on) (max 1 (+ c-on c-off)))) | |
5705 (format "[%d/%d]" c-on (+ c-on c-off))))) | |
5706 ;; update items checkbox if it has one | |
5707 (when (org-at-item-p) | |
5708 (org-beginning-of-item) | |
5709 (when (and (> (+ c-on c-off) 0) | |
5710 (re-search-forward re-box (point-at-eol) t)) | |
5711 (setq beg-cookie (match-beginning 2) | |
5712 end-cookie (match-end 2)) | |
5713 (delete-region beg-cookie end-cookie) | |
5714 (goto-char beg-cookie) | |
5715 (cond ((= c-off 0) (insert "[X]")) | |
5716 ((= c-on 0) (insert "[ ]")) | |
5717 (t (insert "[-]"))) | |
5718 ))) | |
5719 (goto-char continue-from)) | |
5720 (when (interactive-p) | |
5721 (message "Checkbox satistics updated %s (%d places)" | |
5722 (if all "in entire file" "in current outline entry") cstat))))) | |
5723 | |
5724 (defun org-get-checkbox-statistics-face () | |
5725 "Select the face for checkbox statistics. | |
5726 The face will be `org-done' when all relevant boxes are checked. Otherwise | |
5727 it will be `org-todo'." | |
5728 (if (match-end 1) | |
5729 (if (equal (match-string 1) "100%") 'org-done 'org-todo) | |
5730 (if (and (> (match-end 2) (match-beginning 2)) | |
5731 (equal (match-string 2) (match-string 3))) | |
5732 'org-done | |
5733 'org-todo))) | |
5734 | |
5735 (defun org-get-indentation (&optional line) | |
5736 "Get the indentation of the current line, interpreting tabs. | |
5737 When LINE is given, assume it represents a line and compute its indentation." | |
5738 (if line | |
5739 (if (string-match "^ *" (org-remove-tabs line)) | |
5740 (match-end 0)) | |
5741 (save-excursion | |
5742 (beginning-of-line 1) | |
5743 (skip-chars-forward " \t") | |
5744 (current-column)))) | |
5745 | |
5746 (defun org-remove-tabs (s &optional width) | |
5747 "Replace tabulators in S with spaces. | |
5748 Assumes that s is a single line, starting in column 0." | |
5749 (setq width (or width tab-width)) | |
5750 (while (string-match "\t" s) | |
5751 (setq s (replace-match | |
5752 (make-string | |
5753 (- (* width (/ (+ (match-beginning 0) width) width)) | |
5754 (match-beginning 0)) ?\ ) | |
5755 t t s))) | |
5756 s) | |
5757 | |
5758 (defun org-fix-indentation (line ind) | |
5759 "Fix indentation in LINE. | |
5760 IND is a cons cell with target and minimum indentation. | |
5761 If the current indenation in LINE is smaller than the minimum, | |
5762 leave it alone. If it is larger than ind, set it to the target." | |
5763 (let* ((l (org-remove-tabs line)) | |
5764 (i (org-get-indentation l)) | |
5765 (i1 (car ind)) (i2 (cdr ind))) | |
5766 (if (>= i i2) (setq l (substring line i2))) | |
5767 (if (> i1 0) | |
5768 (concat (make-string i1 ?\ ) l) | |
5769 l))) | |
5770 | |
5771 (defun org-beginning-of-item () | |
5772 "Go to the beginning of the current hand-formatted item. | |
5773 If the cursor is not in an item, throw an error." | |
5774 (interactive) | |
5775 (let ((pos (point)) | |
5776 (limit (save-excursion | |
5777 (condition-case nil | |
5778 (progn | |
5779 (org-back-to-heading) | |
5780 (beginning-of-line 2) (point)) | |
5781 (error (point-min))))) | |
5782 (ind-empty (if org-empty-line-terminates-plain-lists 0 10000)) | |
5783 ind ind1) | |
5784 (if (org-at-item-p) | |
5785 (beginning-of-line 1) | |
5786 (beginning-of-line 1) | |
5787 (skip-chars-forward " \t") | |
5788 (setq ind (current-column)) | |
5789 (if (catch 'exit | |
5790 (while t | |
5791 (beginning-of-line 0) | |
5792 (if (or (bobp) (< (point) limit)) (throw 'exit nil)) | |
5793 | |
5794 (if (looking-at "[ \t]*$") | |
5795 (setq ind1 ind-empty) | |
5796 (skip-chars-forward " \t") | |
5797 (setq ind1 (current-column))) | |
5798 (if (< ind1 ind) | |
5799 (progn (beginning-of-line 1) (throw 'exit (org-at-item-p)))))) | |
5800 nil | |
5801 (goto-char pos) | |
5802 (error "Not in an item"))))) | |
5803 | |
5804 (defun org-end-of-item () | |
5805 "Go to the end of the current hand-formatted item. | |
5806 If the cursor is not in an item, throw an error." | |
5807 (interactive) | |
5808 (let* ((pos (point)) | |
5809 ind1 | |
5810 (ind-empty (if org-empty-line-terminates-plain-lists 0 10000)) | |
5811 (limit (save-excursion (outline-next-heading) (point))) | |
5812 (ind (save-excursion | |
5813 (org-beginning-of-item) | |
5814 (skip-chars-forward " \t") | |
5815 (current-column))) | |
5816 (end (catch 'exit | |
5817 (while t | |
5818 (beginning-of-line 2) | |
5819 (if (eobp) (throw 'exit (point))) | |
5820 (if (>= (point) limit) (throw 'exit (point-at-bol))) | |
5821 (if (looking-at "[ \t]*$") | |
5822 (setq ind1 ind-empty) | |
5823 (skip-chars-forward " \t") | |
5824 (setq ind1 (current-column))) | |
5825 (if (<= ind1 ind) | |
5826 (throw 'exit (point-at-bol))))))) | |
5827 (if end | |
5828 (goto-char end) | |
5829 (goto-char pos) | |
5830 (error "Not in an item")))) | |
5831 | |
5832 (defun org-next-item () | |
5833 "Move to the beginning of the next item in the current plain list. | |
5834 Error if not at a plain list, or if this is the last item in the list." | |
5835 (interactive) | |
5836 (let (ind ind1 (pos (point))) | |
5837 (org-beginning-of-item) | |
5838 (setq ind (org-get-indentation)) | |
5839 (org-end-of-item) | |
5840 (setq ind1 (org-get-indentation)) | |
5841 (unless (and (org-at-item-p) (= ind ind1)) | |
5842 (goto-char pos) | |
5843 (error "On last item")))) | |
5844 | |
5845 (defun org-previous-item () | |
5846 "Move to the beginning of the previous item in the current plain list. | |
5847 Error if not at a plain list, or if this is the first item in the list." | |
5848 (interactive) | |
5849 (let (beg ind ind1 (pos (point))) | |
5850 (org-beginning-of-item) | |
5851 (setq beg (point)) | |
5852 (setq ind (org-get-indentation)) | |
5853 (goto-char beg) | |
5854 (catch 'exit | |
5855 (while t | |
5856 (beginning-of-line 0) | |
5857 (if (looking-at "[ \t]*$") | |
5858 nil | |
5859 (if (<= (setq ind1 (org-get-indentation)) ind) | |
5860 (throw 'exit t))))) | |
5861 (condition-case nil | |
5862 (if (or (not (org-at-item-p)) | |
5863 (< ind1 (1- ind))) | |
5864 (error "") | |
5865 (org-beginning-of-item)) | |
5866 (error (goto-char pos) | |
5867 (error "On first item"))))) | |
5868 | |
5869 (defun org-first-list-item-p () | |
5870 "Is this heading the item in a plain list?" | |
5871 (unless (org-at-item-p) | |
5872 (error "Not at a plain list item")) | |
5873 (org-beginning-of-item) | |
5874 (= (point) (save-excursion (org-beginning-of-item-list)))) | |
5875 | |
5876 (defun org-move-item-down () | |
5877 "Move the plain list item at point down, i.e. swap with following item. | |
5878 Subitems (items with larger indentation) are considered part of the item, | |
5879 so this really moves item trees." | |
5880 (interactive) | |
5881 (let (beg beg0 end end0 ind ind1 (pos (point)) txt ne-end ne-beg) | |
5882 (org-beginning-of-item) | |
5883 (setq beg0 (point)) | |
5884 (save-excursion | |
5885 (setq ne-beg (org-back-over-empty-lines)) | |
5886 (setq beg (point))) | |
5887 (goto-char beg0) | |
5888 (setq ind (org-get-indentation)) | |
5889 (org-end-of-item) | |
5890 (setq end0 (point)) | |
5891 (setq ind1 (org-get-indentation)) | |
5892 (setq ne-end (org-back-over-empty-lines)) | |
5893 (setq end (point)) | |
5894 (goto-char beg0) | |
5895 (when (and (org-first-list-item-p) (< ne-end ne-beg)) | |
5896 ;; include less whitespace | |
5897 (save-excursion | |
5898 (goto-char beg) | |
5899 (forward-line (- ne-beg ne-end)) | |
5900 (setq beg (point)))) | |
5901 (goto-char end0) | |
5902 (if (and (org-at-item-p) (= ind ind1)) | |
5903 (progn | |
5904 (org-end-of-item) | |
5905 (org-back-over-empty-lines) | |
5906 (setq txt (buffer-substring beg end)) | |
5907 (save-excursion | |
5908 (delete-region beg end)) | |
5909 (setq pos (point)) | |
5910 (insert txt) | |
5911 (goto-char pos) (org-skip-whitespace) | |
5912 (org-maybe-renumber-ordered-list)) | |
5913 (goto-char pos) | |
5914 (error "Cannot move this item further down")))) | |
5915 | |
5916 (defun org-move-item-up (arg) | |
5917 "Move the plain list item at point up, i.e. swap with previous item. | |
5918 Subitems (items with larger indentation) are considered part of the item, | |
5919 so this really moves item trees." | |
5920 (interactive "p") | |
5921 (let (beg beg0 end ind ind1 (pos (point)) txt | |
5922 ne-beg ne-ins ins-end) | |
5923 (org-beginning-of-item) | |
5924 (setq beg0 (point)) | |
5925 (setq ind (org-get-indentation)) | |
5926 (save-excursion | |
5927 (setq ne-beg (org-back-over-empty-lines)) | |
5928 (setq beg (point))) | |
5929 (goto-char beg0) | |
5930 (org-end-of-item) | |
5931 (org-back-over-empty-lines) | |
5932 (setq end (point)) | |
5933 (goto-char beg0) | |
5934 (catch 'exit | |
5935 (while t | |
5936 (beginning-of-line 0) | |
5937 (if (looking-at "[ \t]*$") | |
5938 (if org-empty-line-terminates-plain-lists | |
5939 (progn | |
5940 (goto-char pos) | |
5941 (error "Cannot move this item further up")) | |
5942 nil) | |
5943 (if (<= (setq ind1 (org-get-indentation)) ind) | |
5944 (throw 'exit t))))) | |
5945 (condition-case nil | |
5946 (org-beginning-of-item) | |
5947 (error (goto-char beg0) | |
5948 (error "Cannot move this item further up"))) | |
5949 (setq ind1 (org-get-indentation)) | |
5950 (if (and (org-at-item-p) (= ind ind1)) | |
5951 (progn | |
5952 (setq ne-ins (org-back-over-empty-lines)) | |
5953 (setq txt (buffer-substring beg end)) | |
5954 (save-excursion | |
5955 (delete-region beg end)) | |
5956 (setq pos (point)) | |
5957 (insert txt) | |
5958 (setq ins-end (point)) | |
5959 (goto-char pos) (org-skip-whitespace) | |
5960 | |
5961 (when (and (org-first-list-item-p) (> ne-ins ne-beg)) | |
5962 ;; Move whitespace back to beginning | |
5963 (save-excursion | |
5964 (goto-char ins-end) | |
5965 (let ((kill-whole-line t)) | |
5966 (kill-line (- ne-ins ne-beg)) (point))) | |
5967 (insert (make-string (- ne-ins ne-beg) ?\n))) | |
5968 | |
5969 (org-maybe-renumber-ordered-list)) | |
5970 (goto-char pos) | |
5971 (error "Cannot move this item further up")))) | |
5972 | |
5973 (defun org-maybe-renumber-ordered-list () | |
5974 "Renumber the ordered list at point if setup allows it. | |
5975 This tests the user option `org-auto-renumber-ordered-lists' before | |
5976 doing the renumbering." | |
5977 (interactive) | |
5978 (when (and org-auto-renumber-ordered-lists | |
5979 (org-at-item-p)) | |
5980 (if (match-beginning 3) | |
5981 (org-renumber-ordered-list 1) | |
5982 (org-fix-bullet-type)))) | |
5983 | |
5984 (defun org-maybe-renumber-ordered-list-safe () | |
5985 (condition-case nil | |
5986 (save-excursion | |
5987 (org-maybe-renumber-ordered-list)) | |
5988 (error nil))) | |
5989 | |
5990 (defun org-cycle-list-bullet (&optional which) | |
5991 "Cycle through the different itemize/enumerate bullets. | |
5992 This cycle the entire list level through the sequence: | |
5993 | |
5994 `-' -> `+' -> `*' -> `1.' -> `1)' | |
5995 | |
5996 If WHICH is a string, use that as the new bullet. If WHICH is an integer, | |
5997 0 meand `-', 1 means `+' etc." | |
5998 (interactive "P") | |
5999 (org-preserve-lc | |
6000 (org-beginning-of-item-list) | |
6001 (org-at-item-p) | |
6002 (beginning-of-line 1) | |
6003 (let ((current (match-string 0)) | |
6004 (prevp (eq which 'previous)) | |
6005 new) | |
6006 (setq new (cond | |
6007 ((and (numberp which) | |
6008 (nth (1- which) '("-" "+" "*" "1." "1)")))) | |
6009 ((string-match "-" current) (if prevp "1)" "+")) | |
6010 ((string-match "\\+" current) | |
6011 (if prevp "-" (if (looking-at "\\S-") "1." "*"))) | |
6012 ((string-match "\\*" current) (if prevp "+" "1.")) | |
6013 ((string-match "\\." current) (if prevp "*" "1)")) | |
6014 ((string-match ")" current) (if prevp "1." "-")) | |
6015 (t (error "This should not happen")))) | |
6016 (and (looking-at "\\([ \t]*\\)\\S-+") (replace-match (concat "\\1" new))) | |
6017 (org-fix-bullet-type) | |
6018 (org-maybe-renumber-ordered-list)))) | |
6019 | |
6020 (defun org-get-string-indentation (s) | |
6021 "What indentation has S due to SPACE and TAB at the beginning of the string?" | |
6022 (let ((n -1) (i 0) (w tab-width) c) | |
6023 (catch 'exit | |
6024 (while (< (setq n (1+ n)) (length s)) | |
6025 (setq c (aref s n)) | |
6026 (cond ((= c ?\ ) (setq i (1+ i))) | |
6027 ((= c ?\t) (setq i (* (/ (+ w i) w) w))) | |
6028 (t (throw 'exit t))))) | |
6029 i)) | |
6030 | |
6031 (defun org-renumber-ordered-list (arg) | |
6032 "Renumber an ordered plain list. | |
6033 Cursor needs to be in the first line of an item, the line that starts | |
6034 with something like \"1.\" or \"2)\"." | |
6035 (interactive "p") | |
6036 (unless (and (org-at-item-p) | |
6037 (match-beginning 3)) | |
6038 (error "This is not an ordered list")) | |
6039 (let ((line (org-current-line)) | |
6040 (col (current-column)) | |
6041 (ind (org-get-string-indentation | |
6042 (buffer-substring (point-at-bol) (match-beginning 3)))) | |
6043 ;; (term (substring (match-string 3) -1)) | |
6044 ind1 (n (1- arg)) | |
6045 fmt bobp) | |
6046 ;; find where this list begins | |
6047 (org-beginning-of-item-list) | |
6048 (setq bobp (bobp)) | |
6049 (looking-at "[ \t]*[0-9]+\\([.)]\\)") | |
6050 (setq fmt (concat "%d" (match-string 1))) | |
6051 (beginning-of-line 0) | |
6052 ;; walk forward and replace these numbers | |
6053 (catch 'exit | |
6054 (while t | |
6055 (catch 'next | |
6056 (if bobp (setq bobp nil) (beginning-of-line 2)) | |
6057 (if (eobp) (throw 'exit nil)) | |
6058 (if (looking-at "[ \t]*$") (throw 'next nil)) | |
6059 (skip-chars-forward " \t") (setq ind1 (current-column)) | |
6060 (if (> ind1 ind) (throw 'next t)) | |
6061 (if (< ind1 ind) (throw 'exit t)) | |
6062 (if (not (org-at-item-p)) (throw 'exit nil)) | |
6063 (delete-region (match-beginning 2) (match-end 2)) | |
6064 (goto-char (match-beginning 2)) | |
6065 (insert (format fmt (setq n (1+ n))))))) | |
6066 (goto-line line) | |
6067 (org-move-to-column col))) | |
6068 | |
6069 (defun org-fix-bullet-type () | |
6070 "Make sure all items in this list have the same bullet as the firsst item." | |
6071 (interactive) | |
6072 (unless (org-at-item-p) (error "This is not a list")) | |
6073 (let ((line (org-current-line)) | |
6074 (col (current-column)) | |
6075 (ind (current-indentation)) | |
6076 ind1 bullet) | |
6077 ;; find where this list begins | |
6078 (org-beginning-of-item-list) | |
6079 (beginning-of-line 1) | |
6080 ;; find out what the bullet type is | |
6081 (looking-at "[ \t]*\\(\\S-+\\)") | |
6082 (setq bullet (match-string 1)) | |
6083 ;; walk forward and replace these numbers | |
6084 (beginning-of-line 0) | |
6085 (catch 'exit | |
6086 (while t | |
6087 (catch 'next | |
6088 (beginning-of-line 2) | |
6089 (if (eobp) (throw 'exit nil)) | |
6090 (if (looking-at "[ \t]*$") (throw 'next nil)) | |
6091 (skip-chars-forward " \t") (setq ind1 (current-column)) | |
6092 (if (> ind1 ind) (throw 'next t)) | |
6093 (if (< ind1 ind) (throw 'exit t)) | |
6094 (if (not (org-at-item-p)) (throw 'exit nil)) | |
6095 (skip-chars-forward " \t") | |
6096 (looking-at "\\S-+") | |
6097 (replace-match bullet)))) | |
6098 (goto-line line) | |
6099 (org-move-to-column col) | |
6100 (if (string-match "[0-9]" bullet) | |
6101 (org-renumber-ordered-list 1)))) | |
6102 | |
6103 (defun org-beginning-of-item-list () | |
6104 "Go to the beginning of the current item list. | |
6105 I.e. to the first item in this list." | |
6106 (interactive) | |
6107 (org-beginning-of-item) | |
6108 (let ((pos (point-at-bol)) | |
6109 (ind (org-get-indentation)) | |
6110 ind1) | |
6111 ;; find where this list begins | |
6112 (catch 'exit | |
6113 (while t | |
6114 (catch 'next | |
6115 (beginning-of-line 0) | |
6116 (if (looking-at "[ \t]*$") | |
6117 (throw (if (bobp) 'exit 'next) t)) | |
6118 (skip-chars-forward " \t") (setq ind1 (current-column)) | |
6119 (if (or (< ind1 ind) | |
6120 (and (= ind1 ind) | |
6121 (not (org-at-item-p))) | |
6122 (and (= (point-at-bol) (point-min)) | |
6123 (setq pos (point-min)))) | |
6124 (throw 'exit t) | |
6125 (when (org-at-item-p) (setq pos (point-at-bol))))))) | |
6126 (goto-char pos))) | |
6127 | |
6128 | |
6129 (defun org-end-of-item-list () | |
6130 "Go to the end of the current item list. | |
6131 I.e. to the text after the last item." | |
6132 (interactive) | |
6133 (org-beginning-of-item) | |
6134 (let ((pos (point-at-bol)) | |
6135 (ind (org-get-indentation)) | |
6136 ind1) | |
6137 ;; find where this list begins | |
6138 (catch 'exit | |
6139 (while t | |
6140 (catch 'next | |
6141 (beginning-of-line 2) | |
6142 (if (looking-at "[ \t]*$") | |
6143 (throw (if (eobp) 'exit 'next) t)) | |
6144 (skip-chars-forward " \t") (setq ind1 (current-column)) | |
6145 (if (or (< ind1 ind) | |
6146 (and (= ind1 ind) | |
6147 (not (org-at-item-p))) | |
6148 (eobp)) | |
6149 (progn | |
6150 (setq pos (point-at-bol)) | |
6151 (throw 'exit t)))))) | |
6152 (goto-char pos))) | |
6153 | |
6154 | |
6155 (defvar org-last-indent-begin-marker (make-marker)) | |
6156 (defvar org-last-indent-end-marker (make-marker)) | |
6157 | |
6158 (defun org-outdent-item (arg) | |
6159 "Outdent a local list item." | |
6160 (interactive "p") | |
6161 (org-indent-item (- arg))) | |
6162 | |
6163 (defun org-indent-item (arg) | |
6164 "Indent a local list item." | |
6165 (interactive "p") | |
6166 (unless (org-at-item-p) | |
6167 (error "Not on an item")) | |
6168 (save-excursion | |
6169 (let (beg end ind ind1 tmp delta ind-down ind-up) | |
6170 (if (memq last-command '(org-shiftmetaright org-shiftmetaleft)) | |
6171 (setq beg org-last-indent-begin-marker | |
6172 end org-last-indent-end-marker) | |
6173 (org-beginning-of-item) | |
6174 (setq beg (move-marker org-last-indent-begin-marker (point))) | |
6175 (org-end-of-item) | |
6176 (setq end (move-marker org-last-indent-end-marker (point)))) | |
6177 (goto-char beg) | |
6178 (setq tmp (org-item-indent-positions) | |
6179 ind (car tmp) | |
6180 ind-down (nth 2 tmp) | |
6181 ind-up (nth 1 tmp) | |
6182 delta (if (> arg 0) | |
6183 (if ind-down (- ind-down ind) 2) | |
6184 (if ind-up (- ind-up ind) -2))) | |
6185 (if (< (+ delta ind) 0) (error "Cannot outdent beyond margin")) | |
6186 (while (< (point) end) | |
6187 (beginning-of-line 1) | |
6188 (skip-chars-forward " \t") (setq ind1 (current-column)) | |
6189 (delete-region (point-at-bol) (point)) | |
6190 (or (eolp) (org-indent-to-column (+ ind1 delta))) | |
6191 (beginning-of-line 2)))) | |
6192 (org-fix-bullet-type) | |
6193 (org-maybe-renumber-ordered-list-safe) | |
6194 (save-excursion | |
6195 (beginning-of-line 0) | |
6196 (condition-case nil (org-beginning-of-item) (error nil)) | |
6197 (org-maybe-renumber-ordered-list-safe))) | |
6198 | |
6199 (defun org-item-indent-positions () | |
6200 "Return indentation for plain list items. | |
6201 This returns a list with three values: The current indentation, the | |
6202 parent indentation and the indentation a child should habe. | |
6203 Assumes cursor in item line." | |
6204 (let* ((bolpos (point-at-bol)) | |
6205 (ind (org-get-indentation)) | |
6206 ind-down ind-up pos) | |
6207 (save-excursion | |
6208 (org-beginning-of-item-list) | |
6209 (skip-chars-backward "\n\r \t") | |
6210 (when (org-in-item-p) | |
6211 (org-beginning-of-item) | |
6212 (setq ind-up (org-get-indentation)))) | |
6213 (setq pos (point)) | |
6214 (save-excursion | |
6215 (cond | |
6216 ((and (condition-case nil (progn (org-previous-item) t) | |
6217 (error nil)) | |
6218 (or (forward-char 1) t) | |
6219 (re-search-forward "^\\([ \t]*\\([-+]\\|\\([0-9]+[.)]\\)\\)\\|[ \t]+\\*\\)\\( \\|$\\)" bolpos t)) | |
6220 (setq ind-down (org-get-indentation))) | |
6221 ((and (goto-char pos) | |
6222 (org-at-item-p)) | |
6223 (goto-char (match-end 0)) | |
6224 (skip-chars-forward " \t") | |
6225 (setq ind-down (current-column))))) | |
6226 (list ind ind-up ind-down))) | |
6227 | 5622 |
6228 ;;; The orgstruct minor mode | 5623 ;;; The orgstruct minor mode |
6229 | 5624 |
6230 ;; Define a minor mode which can be used in other modes in order to | 5625 ;; Define a minor mode which can be used in other modes in order to |
6231 ;; integrate the org-mode structure editing commands. | 5626 ;; integrate the org-mode structure editing commands. |
6381 (list 'key-binding k)) | 5776 (list 'key-binding k)) |
6382 keys) | 5777 keys) |
6383 '('orgstruct-error)))))))) | 5778 '('orgstruct-error)))))))) |
6384 | 5779 |
6385 (defun org-context-p (&rest contexts) | 5780 (defun org-context-p (&rest contexts) |
6386 "Check if local context is and of CONTEXTS. | 5781 "Check if local context is any of CONTEXTS. |
6387 Possible values in the list of contexts are `table', `headline', and `item'." | 5782 Possible values in the list of contexts are `table', `headline', and `item'." |
6388 (let ((pos (point))) | 5783 (let ((pos (point))) |
6389 (goto-char (point-at-bol)) | 5784 (goto-char (point-at-bol)) |
6390 (prog1 (or (and (memq 'table contexts) | 5785 (prog1 (or (and (memq 'table contexts) |
6391 (looking-at "[ \t]*|")) | 5786 (looking-at "[ \t]*|")) |
6392 (and (memq 'headline contexts) | 5787 (and (memq 'headline contexts) |
6393 (looking-at "\\*+")) | 5788 ;;????????? (looking-at "\\*+")) |
5789 (looking-at outline-regexp)) | |
6394 (and (memq 'item contexts) | 5790 (and (memq 'item contexts) |
6395 (looking-at "[ \t]*\\([-+*] \\|[0-9]+[.)] \\)"))) | 5791 (looking-at "[ \t]*\\([-+*] \\|[0-9]+[.)] \\)"))) |
6396 (goto-char pos)))) | 5792 (goto-char pos)))) |
6397 | 5793 |
6398 (defun org-get-local-variables () | 5794 (defun org-get-local-variables () |
7029 (org-defkey minibuffer-local-completion-map " " 'self-insert-command) | 6425 (org-defkey minibuffer-local-completion-map " " 'self-insert-command) |
7030 (apply 'completing-read args))) | 6426 (apply 'completing-read args))) |
7031 | 6427 |
7032 (defun org-extract-attributes (s) | 6428 (defun org-extract-attributes (s) |
7033 "Extract the attributes cookie from a string and set as text property." | 6429 "Extract the attributes cookie from a string and set as text property." |
7034 (let (a attr key value (start 0)) | 6430 (let (a attr (start 0) key value) |
7035 (save-match-data | 6431 (save-match-data |
7036 (when (string-match "{{\\([^}]+\\)}}$" s) | 6432 (when (string-match "{{\\([^}]+\\)}}$" s) |
7037 (setq a (match-string 1 s) s (substring s 0 (match-beginning 0))) | 6433 (setq a (match-string 1 s) s (substring s 0 (match-beginning 0))) |
7038 (while (string-match "\\([a-zA-Z]+\\)=\"\\([^\"]*\\)\"" a start) | 6434 (while (string-match "\\([a-zA-Z]+\\)=\"\\([^\"]*\\)\"" a start) |
7039 (setq key (match-string 1 a) value (match-string 2 a) | 6435 (setq key (match-string 1 a) value (match-string 2 a) |
7580 (remp (and (assq 'remote apps) (org-file-remote-p file))) | 6976 (remp (and (assq 'remote apps) (org-file-remote-p file))) |
7581 (dirp (if remp nil (file-directory-p file))) | 6977 (dirp (if remp nil (file-directory-p file))) |
7582 (file (if (and dirp org-open-directory-means-index-dot-org) | 6978 (file (if (and dirp org-open-directory-means-index-dot-org) |
7583 (concat (file-name-as-directory file) "index.org") | 6979 (concat (file-name-as-directory file) "index.org") |
7584 file)) | 6980 file)) |
6981 (a-m-a-p (assq 'auto-mode apps)) | |
7585 (dfile (downcase file)) | 6982 (dfile (downcase file)) |
7586 (old-buffer (current-buffer)) | 6983 (old-buffer (current-buffer)) |
7587 (old-pos (point)) | 6984 (old-pos (point)) |
7588 (old-mode major-mode) | 6985 (old-mode major-mode) |
7589 ext cmd) | 6986 ext cmd) |
7593 (setq ext (match-string 1 dfile)))) | 6990 (setq ext (match-string 1 dfile)))) |
7594 (if in-emacs | 6991 (if in-emacs |
7595 (setq cmd 'emacs) | 6992 (setq cmd 'emacs) |
7596 (setq cmd (or (and remp (cdr (assoc 'remote apps))) | 6993 (setq cmd (or (and remp (cdr (assoc 'remote apps))) |
7597 (and dirp (cdr (assoc 'directory apps))) | 6994 (and dirp (cdr (assoc 'directory apps))) |
6995 (assoc-default dfile (org-apps-regexp-alist apps a-m-a-p) | |
6996 'string-match) | |
7598 (cdr (assoc ext apps)) | 6997 (cdr (assoc ext apps)) |
7599 (cdr (assoc t apps))))) | 6998 (cdr (assoc t apps))))) |
6999 (when (eq cmd 'default) | |
7000 (setq cmd (cdr (assoc t apps)))) | |
7600 (when (eq cmd 'mailcap) | 7001 (when (eq cmd 'mailcap) |
7601 (require 'mailcap) | 7002 (require 'mailcap) |
7602 (mailcap-parse-mailcaps) | 7003 (mailcap-parse-mailcaps) |
7603 (let* ((mime-type (mailcap-extension-to-mime (or ext ""))) | 7004 (let* ((mime-type (mailcap-extension-to-mime (or ext ""))) |
7604 (command (mailcap-mime-info mime-type))) | 7005 (command (mailcap-mime-info mime-type))) |
7645 ((eq system-type 'darwin) | 7046 ((eq system-type 'darwin) |
7646 org-file-apps-defaults-macosx) | 7047 org-file-apps-defaults-macosx) |
7647 ((eq system-type 'windows-nt) | 7048 ((eq system-type 'windows-nt) |
7648 org-file-apps-defaults-windowsnt) | 7049 org-file-apps-defaults-windowsnt) |
7649 (t org-file-apps-defaults-gnu))) | 7050 (t org-file-apps-defaults-gnu))) |
7051 | |
7052 (defun org-apps-regexp-alist (list &optional add-auto-mode) | |
7053 "Convert extensions to regular expressions in the cars of LIST. | |
7054 Also, weed out any non-string entries, because the return value is used | |
7055 only for regexp matching. | |
7056 When ADD-AUTO-MODE is set, make all matches in `auto-mode-alist' | |
7057 point to the symbol `emacs', indicating that the file should | |
7058 be opened in Emacs." | |
7059 (append | |
7060 (delq nil | |
7061 (mapcar (lambda (x) | |
7062 (if (not (stringp (car x))) | |
7063 nil | |
7064 (if (string-match "\\W" (car x)) | |
7065 x | |
7066 (cons (concat "\\." (car x) "\\'") (cdr x))))) | |
7067 list)) | |
7068 (if add-auto-mode | |
7069 (mapcar (lambda (x) (cons (car x) 'emacs)) auto-mode-alist)))) | |
7650 | 7070 |
7651 (defvar ange-ftp-name-format) ; to silence the XEmacs compiler. | 7071 (defvar ange-ftp-name-format) ; to silence the XEmacs compiler. |
7652 (defun org-file-remote-p (file) | 7072 (defun org-file-remote-p (file) |
7653 "Test whether FILE specifies a location on a remote system. | 7073 "Test whether FILE specifies a location on a remote system. |
7654 Return non-nil if the location is indeed remote. | 7074 Return non-nil if the location is indeed remote. |
7739 (widen) | 7159 (widen) |
7740 (goto-char (point-min)) | 7160 (goto-char (point-min)) |
7741 (while (re-search-forward descre nil t) | 7161 (while (re-search-forward descre nil t) |
7742 (goto-char (point-at-bol)) | 7162 (goto-char (point-at-bol)) |
7743 (when (looking-at org-complex-heading-regexp) | 7163 (when (looking-at org-complex-heading-regexp) |
7744 (setq txt (match-string 4) | 7164 (setq txt (org-link-display-format (match-string 4)) |
7745 re (concat "^" (regexp-quote | 7165 re (concat "^" (regexp-quote |
7746 (buffer-substring (match-beginning 1) | 7166 (buffer-substring (match-beginning 1) |
7747 (match-end 4))))) | 7167 (match-end 4))))) |
7748 (if (match-end 5) (setq re (concat re "[ \t]+" | 7168 (if (match-end 5) (setq re (concat re "[ \t]+" |
7749 (regexp-quote | 7169 (regexp-quote |
7750 (match-string 5))))) | 7170 (match-string 5))))) |
7751 (setq re (concat re "[ \t]*$")) | 7171 (setq re (concat re "[ \t]*$")) |
7752 (when org-refile-use-outline-path | 7172 (when org-refile-use-outline-path |
7753 (setq txt (mapconcat 'identity | 7173 (setq txt (mapconcat 'org-protect-slash |
7754 (append | 7174 (append |
7755 (if (eq org-refile-use-outline-path 'file) | 7175 (if (eq org-refile-use-outline-path 'file) |
7756 (list (file-name-nondirectory | 7176 (list (file-name-nondirectory |
7757 (buffer-file-name (buffer-base-buffer)))) | 7177 (buffer-file-name (buffer-base-buffer)))) |
7758 (if (eq org-refile-use-outline-path 'full-file-path) | 7178 (if (eq org-refile-use-outline-path 'full-file-path) |
7762 "/"))) | 7182 "/"))) |
7763 (push (list txt f re (point)) targets)) | 7183 (push (list txt f re (point)) targets)) |
7764 (goto-char (point-at-eol)))))))) | 7184 (goto-char (point-at-eol)))))))) |
7765 (nreverse targets)))) | 7185 (nreverse targets)))) |
7766 | 7186 |
7187 (defun org-protect-slash (s) | |
7188 (while (string-match "/" s) | |
7189 (setq s (replace-match "\\" t t s))) | |
7190 s) | |
7191 | |
7767 (defun org-get-outline-path () | 7192 (defun org-get-outline-path () |
7768 "Return the outline path to the current entry, as a list." | 7193 "Return the outline path to the current entry, as a list." |
7769 (let (rtn) | 7194 (let (rtn) |
7770 (save-excursion | 7195 (save-excursion |
7771 (while (org-up-heading-safe) | 7196 (while (org-up-heading-safe) |
7786 Depending on `org-reverse-note-order', the new subitem will either be the | 7211 Depending on `org-reverse-note-order', the new subitem will either be the |
7787 first of the last subitem. | 7212 first of the last subitem. |
7788 | 7213 |
7789 With prefix arg GOTO, the command will only visit the target location, | 7214 With prefix arg GOTO, the command will only visit the target location, |
7790 not actually move anything. | 7215 not actually move anything. |
7791 With a double prefix `C-c C-c', go to the location where the last refiling | 7216 With a double prefix `C-u C-u', go to the location where the last refiling |
7792 operation has put the subtree." | 7217 operation has put the subtree." |
7793 (interactive "P") | 7218 (interactive "P") |
7794 (let* ((cbuf (current-buffer)) | 7219 (let* ((cbuf (current-buffer)) |
7795 (filename (buffer-file-name (buffer-base-buffer cbuf))) | 7220 (filename (buffer-file-name (buffer-base-buffer cbuf))) |
7796 pos it nbuf file re level reversed) | 7221 pos it nbuf file re level reversed) |
7819 (goto-char pos) | 7244 (goto-char pos) |
7820 (looking-at outline-regexp) | 7245 (looking-at outline-regexp) |
7821 (setq level (org-get-valid-level (funcall outline-level) 1)) | 7246 (setq level (org-get-valid-level (funcall outline-level) 1)) |
7822 (goto-char | 7247 (goto-char |
7823 (if reversed | 7248 (if reversed |
7824 (outline-next-heading) | 7249 (or (outline-next-heading) (point-max)) |
7825 (or (save-excursion (outline-get-next-sibling)) | 7250 (or (save-excursion (outline-get-next-sibling)) |
7826 (org-end-of-subtree t t) | 7251 (org-end-of-subtree t t) |
7827 (point-max)))) | 7252 (point-max)))) |
7253 (if (not (bolp)) (newline)) | |
7828 (bookmark-set "org-refile-last-stored") | 7254 (bookmark-set "org-refile-last-stored") |
7829 (org-paste-subtree level)))) | 7255 (org-paste-subtree level)))) |
7830 (org-cut-subtree) | 7256 (org-cut-subtree) |
7831 (setq org-markers-to-move nil) | 7257 (setq org-markers-to-move nil) |
7832 (message "Entry refiled to \"%s\"" (car it))))))) | 7258 (message "Entry refiled to \"%s\"" (car it))))))) |
8014 ;;;; Completion | 7440 ;;;; Completion |
8015 | 7441 |
8016 (defconst org-additional-option-like-keywords | 7442 (defconst org-additional-option-like-keywords |
8017 '("BEGIN_HTML" "BEGIN_LaTeX" "END_HTML" "END_LaTeX" | 7443 '("BEGIN_HTML" "BEGIN_LaTeX" "END_HTML" "END_LaTeX" |
8018 "ORGTBL" "HTML:" "LaTeX:" "BEGIN:" "END:" "TBLFM" | 7444 "ORGTBL" "HTML:" "LaTeX:" "BEGIN:" "END:" "TBLFM" |
8019 "BEGIN_EXAMPLE" "END_EXAMPLE")) | 7445 "BEGIN_EXAMPLE" "END_EXAMPLE" |
7446 "BEGIN_QUOTE" "END_QUOTE" | |
7447 "BEGIN_VERSE" "END_VERSE" | |
7448 "BEGIN_SRC" "END_SRC")) | |
8020 | 7449 |
8021 (defcustom org-structure-template-alist | 7450 (defcustom org-structure-template-alist |
8022 '( | 7451 '( |
8023 ("s" "#+begin_src ?\n\n#+end_src" | 7452 ("s" "#+begin_src ?\n\n#+end_src" |
8024 "<src lang=\"?\">\n\n</src>") | 7453 "<src lang=\"?\">\n\n</src>") |
8487 (setq kwd (match-string 2)) | 7916 (setq kwd (match-string 2)) |
8488 (and kwd (setq cnt-all (1+ cnt-all))) | 7917 (and kwd (setq cnt-all (1+ cnt-all))) |
8489 (and (member kwd org-done-keywords) | 7918 (and (member kwd org-done-keywords) |
8490 (setq cnt-done (1+ cnt-done))) | 7919 (setq cnt-done (1+ cnt-done))) |
8491 (condition-case nil | 7920 (condition-case nil |
8492 (outline-forward-same-level 1) | 7921 (org-forward-same-level 1) |
8493 (error (end-of-line 1))))) | 7922 (error (end-of-line 1))))) |
8494 (replace-match | 7923 (replace-match |
8495 (if is-percent | 7924 (if is-percent |
8496 (format "[%d%%]" (/ (* 100 cnt-done) (max 1 cnt-all))) | 7925 (format "[%d%%]" (/ (* 100 cnt-done) (max 1 cnt-all))) |
8497 (format "[%d/%d]" cnt-done cnt-all))) | 7926 (format "[%d/%d]" cnt-done cnt-all))) |
8649 (defvar org-last-changed-timestamp) | 8078 (defvar org-last-changed-timestamp) |
8650 (defvar org-last-inserted-timestamp) | 8079 (defvar org-last-inserted-timestamp) |
8651 (defvar org-log-post-message) | 8080 (defvar org-log-post-message) |
8652 (defvar org-log-note-purpose) | 8081 (defvar org-log-note-purpose) |
8653 (defvar org-log-note-how) | 8082 (defvar org-log-note-how) |
8083 (defvar org-log-note-extra) | |
8654 (defun org-auto-repeat-maybe (done-word) | 8084 (defun org-auto-repeat-maybe (done-word) |
8655 "Check if the current headline contains a repeated deadline/schedule. | 8085 "Check if the current headline contains a repeated deadline/schedule. |
8656 If yes, set TODO state back to what it was and change the base date | 8086 If yes, set TODO state back to what it was and change the base date |
8657 of repeating deadline/scheduled time stamps to new date. | 8087 of repeating deadline/scheduled time stamps to new date. |
8658 This function is run automatically after each state change to a DONE state." | 8088 This function is run automatically after each state change to a DONE state." |
8718 ;; rematch, so that we have everything in place for the real shift | 8148 ;; rematch, so that we have everything in place for the real shift |
8719 (org-at-timestamp-p t) | 8149 (org-at-timestamp-p t) |
8720 (setq ts (match-string 1)) | 8150 (setq ts (match-string 1)) |
8721 (string-match "\\([.+]\\)?\\(\\+[0-9]+\\)\\([dwmy]\\)" ts)))) | 8151 (string-match "\\([.+]\\)?\\(\\+[0-9]+\\)\\([dwmy]\\)" ts)))) |
8722 (org-timestamp-change n (cdr (assoc what whata))) | 8152 (org-timestamp-change n (cdr (assoc what whata))) |
8723 (setq msg (concat msg type org-last-changed-timestamp " ")))) | 8153 (setq msg (concat msg type " " org-last-changed-timestamp " ")))) |
8724 (setq org-log-post-message msg) | 8154 (setq org-log-post-message msg) |
8725 (message "%s" msg)))) | 8155 (message "%s" msg)))) |
8726 | 8156 |
8727 (defun org-show-todo-tree (arg) | 8157 (defun org-show-todo-tree (arg) |
8728 "Make a compact tree which shows all headlines marked with TODO. | 8158 "Make a compact tree which shows all headlines marked with TODO. |
8887 | 8317 |
8888 (defvar org-log-note-marker (make-marker)) | 8318 (defvar org-log-note-marker (make-marker)) |
8889 (defvar org-log-note-purpose nil) | 8319 (defvar org-log-note-purpose nil) |
8890 (defvar org-log-note-state nil) | 8320 (defvar org-log-note-state nil) |
8891 (defvar org-log-note-how nil) | 8321 (defvar org-log-note-how nil) |
8322 (defvar org-log-note-extra nil) | |
8892 (defvar org-log-note-window-configuration nil) | 8323 (defvar org-log-note-window-configuration nil) |
8893 (defvar org-log-note-return-to (make-marker)) | 8324 (defvar org-log-note-return-to (make-marker)) |
8894 (defvar org-log-post-message nil | 8325 (defvar org-log-post-message nil |
8895 "Message to be displayed after a log note has been stored. | 8326 "Message to be displayed after a log note has been stored. |
8896 The auto-repeater uses this.") | 8327 The auto-repeater uses this.") |
8897 | 8328 |
8898 (defun org-add-note () | 8329 (defun org-add-note () |
8899 "Add a note to the current entry. | 8330 "Add a note to the current entry. |
8900 This is done in the same way as adding a state change note." | 8331 This is done in the same way as adding a state change note." |
8901 (interactive) | 8332 (interactive) |
8902 (org-add-log-setup 'note nil t nil)) | 8333 (org-add-log-setup 'note nil 'findpos nil)) |
8903 | 8334 |
8904 (defun org-add-log-setup (&optional purpose state findpos how) | 8335 (defvar org-property-end-re) |
8336 (defun org-add-log-setup (&optional purpose state findpos how &optional extra) | |
8905 "Set up the post command hook to take a note. | 8337 "Set up the post command hook to take a note. |
8906 If this is about to TODO state change, the new state is expected in STATE. | 8338 If this is about to TODO state change, the new state is expected in STATE. |
8907 When FINDPOS is non-nil, find the correct position for the note in | 8339 When FINDPOS is non-nil, find the correct position for the note in |
8908 the current entry. If not, assume that it can be inserted at point." | 8340 the current entry. If not, assume that it can be inserted at point. |
8909 (save-excursion | 8341 HOW is an indicator what kind of note should be created. |
8910 (when findpos | 8342 EXTRA is additional text that will be inserted into the notes buffer." |
8911 (org-back-to-heading t) | 8343 (save-restriction |
8912 (looking-at (concat outline-regexp "\\( *\\)[^\r\n]*" | 8344 (save-excursion |
8913 "\\(\n[^\r\n]*?" org-keyword-time-not-clock-regexp | 8345 (when findpos |
8914 "[^\r\n]*\\)?")) | 8346 (org-back-to-heading t) |
8915 (goto-char (match-end 0)) | 8347 (narrow-to-region (point) (save-excursion |
8916 (unless org-log-states-order-reversed | 8348 (outline-next-heading) (point))) |
8917 (and (= (char-after) ?\n) (forward-char 1)) | 8349 (while (re-search-forward |
8918 (org-skip-over-state-notes) | 8350 (concat "\\(" org-drawer-regexp "\\|" org-property-end-re "\\)") |
8919 (skip-chars-backward " \t\n\r"))) | 8351 (point-max) t) (forward-line)) |
8920 (move-marker org-log-note-marker (point)) | 8352 (looking-at (concat outline-regexp "\\( *\\)[^\r\n]*" |
8921 (setq org-log-note-purpose purpose | 8353 "\\(\n[^\r\n]*?" org-keyword-time-not-clock-regexp |
8922 org-log-note-state state | 8354 "[^\r\n]*\\)?")) |
8923 org-log-note-how how) | 8355 (goto-char (match-end 0)) |
8924 (add-hook 'post-command-hook 'org-add-log-note 'append))) | 8356 (unless org-log-states-order-reversed |
8357 (and (= (char-after) ?\n) (forward-char 1)) | |
8358 (org-skip-over-state-notes) | |
8359 (skip-chars-backward " \t\n\r"))) | |
8360 (move-marker org-log-note-marker (point)) | |
8361 (setq org-log-note-purpose purpose | |
8362 org-log-note-state state | |
8363 org-log-note-how how | |
8364 org-log-note-extra extra) | |
8365 (add-hook 'post-command-hook 'org-add-log-note 'append)))) | |
8925 | 8366 |
8926 (defun org-skip-over-state-notes () | 8367 (defun org-skip-over-state-notes () |
8927 "Skip past the list of State notes in an entry." | 8368 "Skip past the list of State notes in an entry." |
8928 (if (looking-at "\n[ \t]*- State") (forward-char 1)) | 8369 (if (looking-at "\n[ \t]*- State") (forward-char 1)) |
8929 (while (looking-at "[ \t]*- State") | 8370 (while (looking-at "[ \t]*- State") |
8952 ((eq org-log-note-purpose 'state) | 8393 ((eq org-log-note-purpose 'state) |
8953 (format "state change to \"%s\"" org-log-note-state)) | 8394 (format "state change to \"%s\"" org-log-note-state)) |
8954 ((eq org-log-note-purpose 'note) | 8395 ((eq org-log-note-purpose 'note) |
8955 "this entry") | 8396 "this entry") |
8956 (t (error "This should not happen"))))) | 8397 (t (error "This should not happen"))))) |
8398 (if org-log-note-extra (insert org-log-note-extra)) | |
8957 (org-set-local 'org-finish-function 'org-store-log-note))) | 8399 (org-set-local 'org-finish-function 'org-store-log-note))) |
8958 | 8400 |
8959 (defvar org-note-abort nil) ; dynamically scoped | 8401 (defvar org-note-abort nil) ; dynamically scoped |
8960 (defun org-store-log-note () | 8402 (defun org-store-log-note () |
8961 "Finish taking a log note, and insert it to where it belongs." | 8403 "Finish taking a log note, and insert it to where it belongs." |
9279 (case-fold-search nil) | 8721 (case-fold-search nil) |
9280 lspos tags tags-list | 8722 lspos tags tags-list |
9281 (tags-alist (list (cons 0 (mapcar 'downcase org-file-tags)))) | 8723 (tags-alist (list (cons 0 (mapcar 'downcase org-file-tags)))) |
9282 (llast 0) rtn rtn1 level category i txt | 8724 (llast 0) rtn rtn1 level category i txt |
9283 todo marker entry priority) | 8725 todo marker entry priority) |
9284 (when (not (member action '(agenda sparse-tree))) | 8726 (when (not (or (member action '(agenda sparse-tree)) (functionp action))) |
9285 (setq action (list 'lambda nil action))) | 8727 (setq action (list 'lambda nil action))) |
9286 (save-excursion | 8728 (save-excursion |
9287 (goto-char (point-min)) | 8729 (goto-char (point-min)) |
9288 (when (eq action 'sparse-tree) | 8730 (when (eq action 'sparse-tree) |
9289 (org-overview) | 8731 (org-overview) |
9315 (not (eq t org-use-tag-inheritance))) | 8757 (not (eq t org-use-tag-inheritance))) |
9316 ;; selective inheritance, remove uninherited ones | 8758 ;; selective inheritance, remove uninherited ones |
9317 (setcdr (car tags-alist) | 8759 (setcdr (car tags-alist) |
9318 (org-remove-uniherited-tags (cdar tags-alist)))) | 8760 (org-remove-uniherited-tags (cdar tags-alist)))) |
9319 (when (and (or (not todo-only) (member todo org-not-done-keywords)) | 8761 (when (and (or (not todo-only) (member todo org-not-done-keywords)) |
9320 (eval matcher) | 8762 (let ((case-fold-search t)) (eval matcher)) |
9321 (or | 8763 (or |
9322 (not (member org-archive-tag tags-list)) | 8764 (not (member org-archive-tag tags-list)) |
9323 ;; we have an archive tag, should we use this anyway? | 8765 ;; we have an archive tag, should we use this anyway? |
9324 (or (not org-agenda-skip-archived-trees) | 8766 (or (not org-agenda-skip-archived-trees) |
9325 (and (eq action 'agenda) org-agenda-archives-mode)))) | 8767 (and (eq action 'agenda) org-agenda-archives-mode)))) |
9371 ((stringp org-use-tag-inheritance) | 8813 ((stringp org-use-tag-inheritance) |
9372 (delq nil (mapcar | 8814 (delq nil (mapcar |
9373 (lambda (x) (if (string-match org-use-tag-inheritance x) x nil)) | 8815 (lambda (x) (if (string-match org-use-tag-inheritance x) x nil)) |
9374 tags))) | 8816 tags))) |
9375 ((listp org-use-tag-inheritance) | 8817 ((listp org-use-tag-inheritance) |
9376 (org-delete-all org-use-tag-inheritance tags)))) | 8818 (delq nil (mapcar |
8819 (lambda (x) (if (member x org-use-tag-inheritance) x nil)) | |
8820 tags))))) | |
9377 | 8821 |
9378 (defvar todo-only) ;; dynamically scoped | 8822 (defvar todo-only) ;; dynamically scoped |
9379 | 8823 |
9380 (defun org-tags-sparse-tree (&optional todo-only match) | 8824 (defun org-tags-sparse-tree (&optional todo-only match) |
9381 "Create a sparse tree according to tags string MATCH. | 8825 "Create a sparse tree according to tags string MATCH. |
9433 ;; Parse the string and create a lisp form | 8877 ;; Parse the string and create a lisp form |
9434 (let ((match0 match) | 8878 (let ((match0 match) |
9435 (re (org-re "^&?\\([-+:]\\)?\\({[^}]+}\\|LEVEL\\([<=>]\\{1,2\\}\\)\\([0-9]+\\)\\|\\([[:alnum:]_]+\\)\\([<>=]\\{1,2\\}\\)\\({[^}]+}\\|\"[^\"]*\"\\|-?[.0-9]+\\(?:[eE][-+]?[0-9]+\\)?\\)\\|[[:alnum:]_@]+\\)")) | 8879 (re (org-re "^&?\\([-+:]\\)?\\({[^}]+}\\|LEVEL\\([<=>]\\{1,2\\}\\)\\([0-9]+\\)\\|\\([[:alnum:]_]+\\)\\([<>=]\\{1,2\\}\\)\\({[^}]+}\\|\"[^\"]*\"\\|-?[.0-9]+\\(?:[eE][-+]?[0-9]+\\)?\\)\\|[[:alnum:]_@]+\\)")) |
9436 minus tag mm | 8880 minus tag mm |
9437 tagsmatch todomatch tagsmatcher todomatcher kwd matcher | 8881 tagsmatch todomatch tagsmatcher todomatcher kwd matcher |
9438 orterms term orlist re-p str-p level-p level-op | 8882 orterms term orlist re-p str-p level-p level-op time-p |
9439 prop-p pn pv po cat-p gv time-p) | 8883 prop-p pn pv po cat-p gv) |
9440 (if (string-match "/+" match) | 8884 (if (string-match "/+" match) |
9441 ;; match contains also a todo-matching request | 8885 ;; match contains also a todo-matching request |
9442 (progn | 8886 (progn |
9443 (setq tagsmatch (substring match 0 (match-beginning 0)) | 8887 (setq tagsmatch (substring match 0 (match-beginning 0)) |
9444 todomatch (substring match (match-end 0))) | 8888 todomatch (substring match (match-end 0))) |
9582 | 9026 |
9583 (defvar org-add-colon-after-tag-completion nil) ;; dynamically skoped param | 9027 (defvar org-add-colon-after-tag-completion nil) ;; dynamically skoped param |
9584 (defvar org-tags-overlay (org-make-overlay 1 1)) | 9028 (defvar org-tags-overlay (org-make-overlay 1 1)) |
9585 (org-detach-overlay org-tags-overlay) | 9029 (org-detach-overlay org-tags-overlay) |
9586 | 9030 |
9587 (defun org-get-tags-at (&optional pos) | 9031 (defun org-get-local-tags-at (&optional pos) |
9032 "Get a list of tags defined in the current headline." | |
9033 (org-get-tags-at pos 'local)) | |
9034 | |
9035 (defun org-get-local-tags () | |
9036 "Get a list of tags defined in the current headline." | |
9037 (org-get-tags-at nil 'local)) | |
9038 | |
9039 (defun org-get-tags-at (&optional pos local) | |
9588 "Get a list of all headline tags applicable at POS. | 9040 "Get a list of all headline tags applicable at POS. |
9589 POS defaults to point. If tags are inherited, the list contains | 9041 POS defaults to point. If tags are inherited, the list contains |
9590 the targets in the same sequence as the headlines appear, i.e. | 9042 the targets in the same sequence as the headlines appear, i.e. |
9591 the tags of the current headline come last." | 9043 the tags of the current headline come last. |
9044 When LOCAL is non-nil, only return tags from the current headline, | |
9045 ignore inherited ones." | |
9592 (interactive) | 9046 (interactive) |
9593 (let (tags ltags lastpos parent) | 9047 (let (tags ltags lastpos parent) |
9594 (save-excursion | 9048 (save-excursion |
9595 (save-restriction | 9049 (save-restriction |
9596 (widen) | 9050 (widen) |
9597 (goto-char (or pos (point))) | 9051 (goto-char (or pos (point))) |
9598 (save-match-data | 9052 (save-match-data |
9599 (condition-case nil | 9053 (catch 'done |
9600 (progn | 9054 (condition-case nil |
9601 (org-back-to-heading t) | 9055 (progn |
9602 (while (not (equal lastpos (point))) | 9056 (org-back-to-heading t) |
9603 (setq lastpos (point)) | 9057 (while (not (equal lastpos (point))) |
9604 (when (looking-at (org-re "[^\r\n]+?:\\([[:alnum:]_@:]+\\):[ \t]*$")) | 9058 (setq lastpos (point)) |
9605 (setq ltags (org-split-string | 9059 (when (looking-at (org-re "[^\r\n]+?:\\([[:alnum:]_@:]+\\):[ \t]*$")) |
9606 (org-match-string-no-properties 1) ":")) | 9060 (setq ltags (org-split-string |
9607 (setq tags (append (org-remove-uniherited-tags ltags) | 9061 (org-match-string-no-properties 1) ":")) |
9608 tags))) | 9062 (setq tags (append |
9609 (or org-use-tag-inheritance (error "")) | 9063 (if parent |
9610 (org-up-heading-all 1) | 9064 (org-remove-uniherited-tags ltags) |
9611 (setq parent t))) | 9065 ltags) |
9612 (error nil)))) | 9066 tags))) |
9067 (or org-use-tag-inheritance (throw 'done t)) | |
9068 (if local (throw 'done t)) | |
9069 (org-up-heading-all 1) | |
9070 (setq parent t))) | |
9071 (error nil))))) | |
9613 (append (org-remove-uniherited-tags org-file-tags) tags)))) | 9072 (append (org-remove-uniherited-tags org-file-tags) tags)))) |
9614 | 9073 |
9615 (defun org-toggle-tag (tag &optional onoff) | 9074 (defun org-toggle-tag (tag &optional onoff) |
9616 "Toggle the tag TAG for the current line. | 9075 "Toggle the tag TAG for the current line. |
9617 If ONOFF is `on' or `off', don't toggle but set to this state." | 9076 If ONOFF is `on' or `off', don't toggle but set to this state." |
10085 (org-agenda-skip-archived-trees (memq 'archive skip)) | 9544 (org-agenda-skip-archived-trees (memq 'archive skip)) |
10086 (org-agenda-skip-comment-trees (memq 'comment skip)) | 9545 (org-agenda-skip-comment-trees (memq 'comment skip)) |
10087 (org-agenda-skip-function | 9546 (org-agenda-skip-function |
10088 (car (org-delete-all '(comment archive) skip))) | 9547 (car (org-delete-all '(comment archive) skip))) |
10089 (org-tags-match-list-sublevels t) | 9548 (org-tags-match-list-sublevels t) |
10090 matcher pos file) | 9549 matcher pos file |
9550 org-todo-keywords-for-agenda | |
9551 org-done-keywords-for-agenda | |
9552 org-todo-keyword-alist-for-agenda | |
9553 org-tag-alist-for-agenda) | |
10091 | 9554 |
10092 (cond | 9555 (cond |
10093 ((eq match t) (setq matcher t)) | 9556 ((eq match t) (setq matcher t)) |
10094 ((eq match nil) (setq matcher t)) | 9557 ((eq match nil) (setq matcher t)) |
10095 (t (setq matcher (if match (org-make-tags-matcher match) t)))) | 9558 (t (setq matcher (if match (org-make-tags-matcher match) t)))) |
10350 ;; These values are assumed to be single words, separated by whitespace. | 9813 ;; These values are assumed to be single words, separated by whitespace. |
10351 (defun org-entry-add-to-multivalued-property (pom property value) | 9814 (defun org-entry-add-to-multivalued-property (pom property value) |
10352 "Add VALUE to the words in the PROPERTY in entry at point-or-marker POM." | 9815 "Add VALUE to the words in the PROPERTY in entry at point-or-marker POM." |
10353 (let* ((old (org-entry-get pom property)) | 9816 (let* ((old (org-entry-get pom property)) |
10354 (values (and old (org-split-string old "[ \t]")))) | 9817 (values (and old (org-split-string old "[ \t]")))) |
9818 (setq value (org-entry-protect-space value)) | |
10355 (unless (member value values) | 9819 (unless (member value values) |
10356 (setq values (cons value values)) | 9820 (setq values (cons value values)) |
10357 (org-entry-put pom property | 9821 (org-entry-put pom property |
10358 (mapconcat 'identity values " "))))) | 9822 (mapconcat 'identity values " "))))) |
10359 | 9823 |
10360 (defun org-entry-remove-from-multivalued-property (pom property value) | 9824 (defun org-entry-remove-from-multivalued-property (pom property value) |
10361 "Remove VALUE from words in the PROPERTY in entry at point-or-marker POM." | 9825 "Remove VALUE from words in the PROPERTY in entry at point-or-marker POM." |
10362 (let* ((old (org-entry-get pom property)) | 9826 (let* ((old (org-entry-get pom property)) |
10363 (values (and old (org-split-string old "[ \t]")))) | 9827 (values (and old (org-split-string old "[ \t]")))) |
9828 (setq value (org-entry-protect-space value)) | |
10364 (when (member value values) | 9829 (when (member value values) |
10365 (setq values (delete value values)) | 9830 (setq values (delete value values)) |
10366 (org-entry-put pom property | 9831 (org-entry-put pom property |
10367 (mapconcat 'identity values " "))))) | 9832 (mapconcat 'identity values " "))))) |
10368 | 9833 |
10369 (defun org-entry-member-in-multivalued-property (pom property value) | 9834 (defun org-entry-member-in-multivalued-property (pom property value) |
10370 "Is VALUE one of the words in the PROPERTY in entry at point-or-marker POM?" | 9835 "Is VALUE one of the words in the PROPERTY in entry at point-or-marker POM?" |
10371 (let* ((old (org-entry-get pom property)) | 9836 (let* ((old (org-entry-get pom property)) |
10372 (values (and old (org-split-string old "[ \t]")))) | 9837 (values (and old (org-split-string old "[ \t]")))) |
9838 (setq value (org-entry-protect-space value)) | |
10373 (member value values))) | 9839 (member value values))) |
10374 | 9840 |
10375 (defvar org-entry-property-inherited-from (make-marker)) | 9841 (defun org-entry-get-multivalued-property (pom property) |
9842 "Return a list of values in a multivalued property." | |
9843 (let* ((value (org-entry-get pom property)) | |
9844 (values (and value (org-split-string value "[ \t]")))) | |
9845 (mapcar 'org-entry-restore-space values))) | |
9846 | |
9847 (defun org-entry-put-multivalued-property (pom property &rest values) | |
9848 "Set multivalued PROPERTY at point-or-marker POM to VALUES. | |
9849 VALUES should be a list of strings. Spaces will be protected." | |
9850 (org-entry-put pom property | |
9851 (mapconcat 'org-entry-protect-space values " ")) | |
9852 (let* ((value (org-entry-get pom property)) | |
9853 (values (and value (org-split-string value "[ \t]")))) | |
9854 (mapcar 'org-entry-restore-space values))) | |
9855 | |
9856 (defun org-entry-protect-space (s) | |
9857 "Protect spaces and newline in string S." | |
9858 (while (string-match " " s) | |
9859 (setq s (replace-match "%20" t t s))) | |
9860 (while (string-match "\n" s) | |
9861 (setq s (replace-match "%0A" t t s))) | |
9862 s) | |
9863 | |
9864 (defun org-entry-restore-space (s) | |
9865 "Restore spaces and newline in string S." | |
9866 (while (string-match "%20" s) | |
9867 (setq s (replace-match " " t t s))) | |
9868 (while (string-match "%0A" s) | |
9869 (setq s (replace-match "\n" t t s))) | |
9870 s) | |
9871 | |
9872 (defvar org-entry-property-inherited-from (make-marker) | |
9873 "Marker pointing to the entry from where a proerty was inherited. | |
9874 Each call to `org-entry-get-with-inheritance' will set this marker to the | |
9875 location of the entry where the inheriance search matched. If there was | |
9876 no match, the marker will point nowhere. | |
9877 Note that also `org-entry-get' calls this function, if the INHERIT flag | |
9878 is set.") | |
10376 | 9879 |
10377 (defun org-entry-get-with-inheritance (property) | 9880 (defun org-entry-get-with-inheritance (property) |
10378 "Get entry property, and search higher levels if not present." | 9881 "Get entry property, and search higher levels if not present." |
9882 (move-marker org-entry-property-inherited-from nil) | |
10379 (let (tmp) | 9883 (let (tmp) |
10380 (save-excursion | 9884 (save-excursion |
10381 (save-restriction | 9885 (save-restriction |
10382 (widen) | 9886 (widen) |
10383 (catch 'ex | 9887 (catch 'ex |
10702 "The last time stamp inserted with `org-insert-time-stamp'.") | 10206 "The last time stamp inserted with `org-insert-time-stamp'.") |
10703 (defvar org-time-was-given) ; dynamically scoped parameter | 10207 (defvar org-time-was-given) ; dynamically scoped parameter |
10704 (defvar org-end-time-was-given) ; dynamically scoped parameter | 10208 (defvar org-end-time-was-given) ; dynamically scoped parameter |
10705 (defvar org-ts-what) ; dynamically scoped parameter | 10209 (defvar org-ts-what) ; dynamically scoped parameter |
10706 | 10210 |
10707 (defun org-time-stamp (arg) | 10211 (defun org-time-stamp (arg &optional inactive) |
10708 "Prompt for a date/time and insert a time stamp. | 10212 "Prompt for a date/time and insert a time stamp. |
10709 If the user specifies a time like HH:MM, or if this command is called | 10213 If the user specifies a time like HH:MM, or if this command is called |
10710 with a prefix argument, the time stamp will contain date and time. | 10214 with a prefix argument, the time stamp will contain date and time. |
10711 Otherwise, only the date will be included. All parts of a date not | 10215 Otherwise, only the date will be included. All parts of a date not |
10712 specified by the user will be filled in from the current date/time. | 10216 specified by the user will be filled in from the current date/time. |
10726 (apply 'encode-time (org-parse-time-string (match-string 1))) | 10230 (apply 'encode-time (org-parse-time-string (match-string 1))) |
10727 (current-time))) | 10231 (current-time))) |
10728 (default-input (and ts (org-get-compact-tod ts))) | 10232 (default-input (and ts (org-get-compact-tod ts))) |
10729 org-time-was-given org-end-time-was-given time) | 10233 org-time-was-given org-end-time-was-given time) |
10730 (cond | 10234 (cond |
10731 ((and (org-at-timestamp-p) | 10235 ((and (org-at-timestamp-p t) |
10732 (eq last-command 'org-time-stamp) | 10236 (memq last-command '(org-time-stamp org-time-stamp-inactive)) |
10733 (eq this-command 'org-time-stamp)) | 10237 (memq this-command '(org-time-stamp org-time-stamp-inactive))) |
10734 (insert "--") | 10238 (insert "--") |
10735 (setq time (let ((this-command this-command)) | 10239 (setq time (let ((this-command this-command)) |
10736 (org-read-date arg 'totime nil nil default-time default-input))) | 10240 (org-read-date arg 'totime nil nil |
10737 (org-insert-time-stamp time (or org-time-was-given arg))) | 10241 default-time default-input))) |
10738 ((org-at-timestamp-p) | 10242 (org-insert-time-stamp time (or org-time-was-given arg) inactive)) |
10243 ((org-at-timestamp-p t) | |
10739 (setq time (let ((this-command this-command)) | 10244 (setq time (let ((this-command this-command)) |
10740 (org-read-date arg 'totime nil nil default-time default-input))) | 10245 (org-read-date arg 'totime nil nil default-time default-input))) |
10741 (when (org-at-timestamp-p) ; just to get the match data | 10246 (when (org-at-timestamp-p t) ; just to get the match data |
10247 ; (setq inactive (eq (char-after (match-beginning 0)) ?\[)) | |
10742 (replace-match "") | 10248 (replace-match "") |
10743 (setq org-last-changed-timestamp | 10249 (setq org-last-changed-timestamp |
10744 (org-insert-time-stamp | 10250 (org-insert-time-stamp |
10745 time (or org-time-was-given arg) | 10251 time (or org-time-was-given arg) |
10746 nil nil nil (list org-end-time-was-given)))) | 10252 inactive nil nil (list org-end-time-was-given)))) |
10747 (message "Timestamp updated")) | 10253 (message "Timestamp updated")) |
10748 (t | 10254 (t |
10749 (setq time (let ((this-command this-command)) | 10255 (setq time (let ((this-command this-command)) |
10750 (org-read-date arg 'totime nil nil default-time default-input))) | 10256 (org-read-date arg 'totime nil nil default-time default-input))) |
10751 (org-insert-time-stamp time (or org-time-was-given arg) | 10257 (org-insert-time-stamp time (or org-time-was-given arg) inactive |
10752 nil nil nil (list org-end-time-was-given)))))) | 10258 nil nil (list org-end-time-was-given)))))) |
10753 | 10259 |
10754 ;; FIXME: can we use this for something else, like computing time differences? | 10260 ;; FIXME: can we use this for something else, like computing time differences? |
10755 (defun org-get-compact-tod (s) | 10261 (defun org-get-compact-tod (s) |
10756 (when (string-match "\\(\\([012]?[0-9]\\):\\([0-5][0-9]\\)\\)\\(-\\(\\([012]?[0-9]\\):\\([0-5][0-9]\\)\\)\\)?" s) | 10262 (when (string-match "\\(\\([012]?[0-9]\\):\\([0-5][0-9]\\)\\)\\(-\\(\\([012]?[0-9]\\):\\([0-5][0-9]\\)\\)\\)?" s) |
10757 (let* ((t1 (match-string 1 s)) | 10263 (let* ((t1 (match-string 1 s)) |
10773 An inactive time stamp is enclosed in square brackets instead of angle | 10279 An inactive time stamp is enclosed in square brackets instead of angle |
10774 brackets. It is inactive in the sense that it does not trigger agenda entries, | 10280 brackets. It is inactive in the sense that it does not trigger agenda entries, |
10775 does not link to the calendar and cannot be changed with the S-cursor keys. | 10281 does not link to the calendar and cannot be changed with the S-cursor keys. |
10776 So these are more for recording a certain time/date." | 10282 So these are more for recording a certain time/date." |
10777 (interactive "P") | 10283 (interactive "P") |
10778 (let (org-time-was-given org-end-time-was-given time) | 10284 (org-time-stamp arg 'inactive)) |
10779 (setq time (org-read-date arg 'totime)) | |
10780 (org-insert-time-stamp time (or org-time-was-given arg) 'inactive | |
10781 nil nil (list org-end-time-was-given)))) | |
10782 | 10285 |
10783 (defvar org-date-ovl (org-make-overlay 1 1)) | 10286 (defvar org-date-ovl (org-make-overlay 1 1)) |
10784 (org-overlay-put org-date-ovl 'face 'org-warning) | 10287 (org-overlay-put org-date-ovl 'face 'org-warning) |
10785 (org-detach-overlay org-date-ovl) | 10288 (org-detach-overlay org-date-ovl) |
10786 | 10289 |
10976 (string-match org-plain-time-of-day-regexp txt)) | 10479 (string-match org-plain-time-of-day-regexp txt)) |
10977 (setq txt (concat (substring txt 0 (match-end 0)) "-" | 10480 (setq txt (concat (substring txt 0 (match-end 0)) "-" |
10978 org-end-time-was-given | 10481 org-end-time-was-given |
10979 (substring txt (match-end 0))))) | 10482 (substring txt (match-end 0))))) |
10980 (setq org-read-date-overlay | 10483 (setq org-read-date-overlay |
10981 (make-overlay (1- (point-at-eol)) (point-at-eol))) | 10484 (org-make-overlay (1- (point-at-eol)) (point-at-eol))) |
10982 (org-overlay-display org-read-date-overlay txt 'secondary-selection)))) | 10485 (org-overlay-display org-read-date-overlay txt 'secondary-selection)))) |
10983 | 10486 |
10984 (defun org-read-date-analyze (ans def defdecode) | 10487 (defun org-read-date-analyze (ans def defdecode) |
10985 "Analyze the combined answer of the date prompt." | 10488 "Analyze the combined answer of the date prompt." |
10986 ;; FIXME: cleanup and comment | 10489 ;; FIXME: cleanup and comment |
11161 (let* ((date (calendar-cursor-to-date)) | 10664 (let* ((date (calendar-cursor-to-date)) |
11162 (time (encode-time 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date)))) | 10665 (time (encode-time 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date)))) |
11163 (setq org-ans2 (format-time-string "%Y-%m-%d" time)))) | 10666 (setq org-ans2 (format-time-string "%Y-%m-%d" time)))) |
11164 (org-move-overlay org-date-ovl (1- (point)) (1+ (point)) (current-buffer)) | 10667 (org-move-overlay org-date-ovl (1- (point)) (1+ (point)) (current-buffer)) |
11165 (select-window sw))) | 10668 (select-window sw))) |
11166 | |
11167 ; ;; Update the prompt to show new default date | |
11168 ; (save-excursion | |
11169 ; (goto-char (point-min)) | |
11170 ; (when (and org-ans2 | |
11171 ; (re-search-forward "\\[[-0-9]+\\]" nil t) | |
11172 ; (get-text-property (match-end 0) 'field)) | |
11173 ; (let ((inhibit-read-only t)) | |
11174 ; (replace-match (concat "[" org-ans2 "]") t t) | |
11175 ; (add-text-properties (point-min) (1+ (match-end 0)) | |
11176 ; (text-properties-at (1+ (point-min))))))))) | |
11177 | 10669 |
11178 (defun org-calendar-select () | 10670 (defun org-calendar-select () |
11179 "Return to `org-read-date' with the date currently selected. | 10671 "Return to `org-read-date' with the date currently selected. |
11180 This is used by `org-read-date' in a temporary keymap for the calendar buffer." | 10672 This is used by `org-read-date' in a temporary keymap for the calendar buffer." |
11181 (interactive) | 10673 (interactive) |
11878 (defun org-iswitchb (&optional arg) | 11370 (defun org-iswitchb (&optional arg) |
11879 "Use `iswitchb-read-buffer' to prompt for an Org buffer to switch to. | 11371 "Use `iswitchb-read-buffer' to prompt for an Org buffer to switch to. |
11880 With a prefix argument, restrict available to files. | 11372 With a prefix argument, restrict available to files. |
11881 With two prefix arguments, restrict available buffers to agenda files. | 11373 With two prefix arguments, restrict available buffers to agenda files. |
11882 | 11374 |
11883 Due to some yet unresolved reason, global function | 11375 Due to some yet unresolved reason, the global function |
11884 `iswitchb-mode' needs to be active for this function to work." | 11376 `iswitchb-mode' needs to be active for this function to work." |
11885 (interactive "P") | 11377 (interactive "P") |
11886 (require 'iswitchb) | 11378 (require 'iswitchb) |
11887 (let ((enabled iswitchb-mode) blist) | 11379 (let ((enabled iswitchb-mode) blist) |
11888 (or enabled (iswitchb-mode 1)) | 11380 (or enabled (iswitchb-mode 1)) |
11897 (switch-to-buffer | 11389 (switch-to-buffer |
11898 (iswitchb-read-buffer | 11390 (iswitchb-read-buffer |
11899 "Switch-to: " nil t)) | 11391 "Switch-to: " nil t)) |
11900 (or enabled (iswitchb-mode -1)))))) | 11392 (or enabled (iswitchb-mode -1)))))) |
11901 | 11393 |
11902 (defun org-buffer-list (&optional predicate tmp) | 11394 (defun org-buffer-list (&optional predicate exclude-tmp) |
11903 "Return a list of Org buffers. | 11395 "Return a list of Org buffers. |
11904 PREDICATE can be either 'export, 'files or 'agenda. | 11396 PREDICATE can be `export', `files' or `agenda'. |
11905 | 11397 |
11906 'export restrict the list to Export buffers. | 11398 export restrict the list to Export buffers. |
11907 'files restrict the list to buffers visiting Org files. | 11399 files restrict the list to buffers visiting Org files. |
11908 'agenda restrict the list to buffers visiting agenda files. | 11400 agenda restrict the list to buffers visiting agenda files. |
11909 | 11401 |
11910 If TMP is non-nil, don't include temporary buffers." | 11402 If EXCLUDE-TMP is non-nil, ignore temporary buffers." |
11911 (let (filter blist) | 11403 (let* ((bfn nil) |
11912 (setq filter | 11404 (agenda-files (and (eq predicate 'agenda) |
11913 (cond ((eq predicate 'files) "\.org$") | 11405 (mapcar 'file-truename (org-agenda-files t)))) |
11914 ((eq predicate 'export) "\*Org .*Export") | 11406 (filter |
11915 (t "\*Org \\|\.org$"))) | 11407 (cond |
11916 (setq blist | 11408 ((eq predicate 'files) |
11409 (lambda (b) (with-current-buffer b (eq major-mode 'org-mode)))) | |
11410 ((eq predicate 'export) | |
11411 (lambda (b) (string-match "\*Org .*Export" (buffer-name b)))) | |
11412 ((eq predicate 'agenda) | |
11413 (lambda (b) | |
11414 (with-current-buffer b | |
11415 (and (eq major-mode 'org-mode) | |
11416 (setq bfn (buffer-file-name b)) | |
11417 (member (file-truename bfn) agenda-files))))) | |
11418 (t (lambda (b) (with-current-buffer b | |
11419 (or (eq major-mode 'org-mode) | |
11420 (string-match "\*Org .*Export" | |
11421 (buffer-name b))))))))) | |
11422 (delq nil | |
11917 (mapcar | 11423 (mapcar |
11918 (lambda(b) | 11424 (lambda(b) |
11919 (let ((bname (buffer-name b)) | 11425 (if (and (funcall filter b) |
11920 (bfile (buffer-file-name b))) | 11426 (or (not exclude-tmp) |
11921 (if (and (string-match filter bname) | 11427 (not (string-match "tmp" (buffer-name b))))) |
11922 (if (eq predicate 'agenda) | 11428 b |
11923 (member bfile | 11429 nil)) |
11924 (mapcar (lambda(f) (file-truename f)) | 11430 (buffer-list))))) |
11925 org-agenda-files)) t) | |
11926 (if tmp (not (string-match "tmp" bname)) t)) b))) | |
11927 (buffer-list))) | |
11928 (delete nil blist))) | |
11929 | 11431 |
11930 (defun org-agenda-files (&optional unrestricted archives) | 11432 (defun org-agenda-files (&optional unrestricted archives) |
11931 "Get the list of agenda files. | 11433 "Get the list of agenda files. |
11932 Optional UNRESTRICTED means return the full list even if a restriction | 11434 Optional UNRESTRICTED means return the full list even if a restriction |
11933 is currently in place. | 11435 is currently in place. |
12127 (org-refresh-category-properties) | 11629 (org-refresh-category-properties) |
12128 (setq org-todo-keywords-for-agenda | 11630 (setq org-todo-keywords-for-agenda |
12129 (append org-todo-keywords-for-agenda org-todo-keywords-1)) | 11631 (append org-todo-keywords-for-agenda org-todo-keywords-1)) |
12130 (setq org-done-keywords-for-agenda | 11632 (setq org-done-keywords-for-agenda |
12131 (append org-done-keywords-for-agenda org-done-keywords)) | 11633 (append org-done-keywords-for-agenda org-done-keywords)) |
11634 (setq org-todo-keyword-alist-for-agenda | |
11635 (append org-todo-keyword-alist-for-agenda org-todo-key-alist)) | |
11636 (setq org-tag-alist-for-agenda | |
11637 (append org-tag-alist-for-agenda org-tag-alist)) | |
11638 | |
12132 (save-excursion | 11639 (save-excursion |
12133 (remove-text-properties (point-min) (point-max) pall) | 11640 (remove-text-properties (point-min) (point-max) pall) |
12134 (when org-agenda-skip-archived-trees | 11641 (when org-agenda-skip-archived-trees |
12135 (goto-char (point-min)) | 11642 (goto-char (point-min)) |
12136 (while (re-search-forward rea nil t) | 11643 (while (re-search-forward rea nil t) |
12139 (goto-char (point-min)) | 11646 (goto-char (point-min)) |
12140 (setq re (concat "^\\*+ +" org-comment-string "\\>")) | 11647 (setq re (concat "^\\*+ +" org-comment-string "\\>")) |
12141 (while (re-search-forward re nil t) | 11648 (while (re-search-forward re nil t) |
12142 (add-text-properties | 11649 (add-text-properties |
12143 (match-beginning 0) (org-end-of-subtree t) pc))) | 11650 (match-beginning 0) (org-end-of-subtree t) pc))) |
12144 (set-buffer-modified-p bmp)))))) | 11651 (set-buffer-modified-p bmp)))) |
11652 (setq org-todo-keyword-alist-for-agenda | |
11653 (org-uniquify org-todo-keyword-alist-for-agenda) | |
11654 org-tag-alist-for-agenda (org-uniquify org-tag-alist-for-agenda)))) | |
12145 | 11655 |
12146 ;;;; Embedded LaTeX | 11656 ;;;; Embedded LaTeX |
12147 | 11657 |
12148 (defvar org-cdlatex-mode-map (make-sparse-keymap) | 11658 (defvar org-cdlatex-mode-map (make-sparse-keymap) |
12149 "Keymap for the minor `org-cdlatex-mode'.") | 11659 "Keymap for the minor `org-cdlatex-mode'.") |
12489 | 11999 |
12490 ;;; Extra keys for tty access. | 12000 ;;; Extra keys for tty access. |
12491 ;; We only set them when really needed because otherwise the | 12001 ;; We only set them when really needed because otherwise the |
12492 ;; menus don't show the simple keys | 12002 ;; menus don't show the simple keys |
12493 | 12003 |
12494 (when (or (featurep 'xemacs) ;; because XEmacs supports multi-device stuff | 12004 (when (or org-use-extra-keys |
12005 (featurep 'xemacs) ;; because XEmacs supports multi-device stuff | |
12495 (not window-system)) | 12006 (not window-system)) |
12496 (org-defkey org-mode-map "\C-c\C-xc" 'org-table-copy-down) | 12007 (org-defkey org-mode-map "\C-c\C-xc" 'org-table-copy-down) |
12497 (org-defkey org-mode-map "\C-c\C-xM" 'org-insert-todo-heading) | 12008 (org-defkey org-mode-map "\C-c\C-xM" 'org-insert-todo-heading) |
12498 (org-defkey org-mode-map "\C-c\C-xm" 'org-meta-return) | 12009 (org-defkey org-mode-map "\C-c\C-xm" 'org-meta-return) |
12499 (org-defkey org-mode-map [?\e (return)] 'org-meta-return) | 12010 (org-defkey org-mode-map [?\e (return)] 'org-meta-return) |
12538 (org-defkey org-mode-map "\C-c\C-w" 'org-refile) | 12049 (org-defkey org-mode-map "\C-c\C-w" 'org-refile) |
12539 (org-defkey org-mode-map "\C-c/" 'org-sparse-tree) ; Minor-mode reserved | 12050 (org-defkey org-mode-map "\C-c/" 'org-sparse-tree) ; Minor-mode reserved |
12540 (org-defkey org-mode-map "\C-c\\" 'org-tags-sparse-tree) ; Minor-mode res. | 12051 (org-defkey org-mode-map "\C-c\\" 'org-tags-sparse-tree) ; Minor-mode res. |
12541 (org-defkey org-mode-map "\C-c\C-m" 'org-ctrl-c-ret) | 12052 (org-defkey org-mode-map "\C-c\C-m" 'org-ctrl-c-ret) |
12542 (org-defkey org-mode-map "\M-\C-m" 'org-insert-heading) | 12053 (org-defkey org-mode-map "\M-\C-m" 'org-insert-heading) |
12543 (org-defkey org-mode-map [(control return)] 'org-insert-heading-after-current) | 12054 (org-defkey org-mode-map [(control return)] 'org-insert-heading-respect-content) |
12055 (org-defkey org-mode-map [(shift control return)] 'org-insert-todo-heading-respect-content) | |
12544 (org-defkey org-mode-map "\C-c\C-x\C-n" 'org-next-link) | 12056 (org-defkey org-mode-map "\C-c\C-x\C-n" 'org-next-link) |
12545 (org-defkey org-mode-map "\C-c\C-x\C-p" 'org-previous-link) | 12057 (org-defkey org-mode-map "\C-c\C-x\C-p" 'org-previous-link) |
12546 (org-defkey org-mode-map "\C-c\C-l" 'org-insert-link) | 12058 (org-defkey org-mode-map "\C-c\C-l" 'org-insert-link) |
12547 (org-defkey org-mode-map "\C-c\C-o" 'org-open-at-point) | 12059 (org-defkey org-mode-map "\C-c\C-o" 'org-open-at-point) |
12548 (org-defkey org-mode-map "\C-c%" 'org-mark-ring-push) | 12060 (org-defkey org-mode-map "\C-c%" 'org-mark-ring-push) |
12575 (org-defkey org-mode-map "\C-c'" 'org-edit-special) | 12087 (org-defkey org-mode-map "\C-c'" 'org-edit-special) |
12576 (org-defkey org-mode-map "\C-c`" 'org-table-edit-field) | 12088 (org-defkey org-mode-map "\C-c`" 'org-table-edit-field) |
12577 (org-defkey org-mode-map "\C-c|" 'org-table-create-or-convert-from-region) | 12089 (org-defkey org-mode-map "\C-c|" 'org-table-create-or-convert-from-region) |
12578 (org-defkey org-mode-map [(control ?#)] 'org-table-rotate-recalc-marks) | 12090 (org-defkey org-mode-map [(control ?#)] 'org-table-rotate-recalc-marks) |
12579 (org-defkey org-mode-map "\C-c~" 'org-table-create-with-table.el) | 12091 (org-defkey org-mode-map "\C-c~" 'org-table-create-with-table.el) |
12580 (org-defkey org-mode-map "\C-c\C-q" 'org-table-wrap-region) | 12092 (org-defkey org-mode-map "\C-c\C-a" 'org-attach) |
12581 (org-defkey org-mode-map "\C-c}" 'org-table-toggle-coordinate-overlays) | 12093 (org-defkey org-mode-map "\C-c}" 'org-table-toggle-coordinate-overlays) |
12582 (org-defkey org-mode-map "\C-c{" 'org-table-toggle-formula-debugger) | 12094 (org-defkey org-mode-map "\C-c{" 'org-table-toggle-formula-debugger) |
12583 (org-defkey org-mode-map "\C-c\C-e" 'org-export) | 12095 (org-defkey org-mode-map "\C-c\C-e" 'org-export) |
12584 (org-defkey org-mode-map "\C-c:" 'org-toggle-fixed-width-section) | 12096 (org-defkey org-mode-map "\C-c:" 'org-toggle-fixed-width-section) |
12585 (org-defkey org-mode-map "\C-c\C-x\C-f" 'org-emphasize) | 12097 (org-defkey org-mode-map "\C-c\C-x\C-f" 'org-emphasize) |
12598 (org-defkey org-mode-map "\C-c\C-x\C-r" 'org-clock-report) | 12110 (org-defkey org-mode-map "\C-c\C-x\C-r" 'org-clock-report) |
12599 (org-defkey org-mode-map "\C-c\C-x\C-u" 'org-dblock-update) | 12111 (org-defkey org-mode-map "\C-c\C-x\C-u" 'org-dblock-update) |
12600 (org-defkey org-mode-map "\C-c\C-x\C-l" 'org-preview-latex-fragment) | 12112 (org-defkey org-mode-map "\C-c\C-x\C-l" 'org-preview-latex-fragment) |
12601 (org-defkey org-mode-map "\C-c\C-x\C-b" 'org-toggle-checkbox) | 12113 (org-defkey org-mode-map "\C-c\C-x\C-b" 'org-toggle-checkbox) |
12602 (org-defkey org-mode-map "\C-c\C-xp" 'org-set-property) | 12114 (org-defkey org-mode-map "\C-c\C-xp" 'org-set-property) |
12603 (org-defkey org-mode-map "\C-c\C-xr" 'org-insert-columns-dblock) | 12115 (org-defkey org-mode-map "\C-c\C-xi" 'org-insert-columns-dblock) |
12604 | 12116 |
12605 (define-key org-mode-map "\C-c\C-x\C-c" 'org-columns) | 12117 (define-key org-mode-map "\C-c\C-x\C-c" 'org-columns) |
12606 | 12118 |
12607 (when (featurep 'xemacs) | 12119 (when (featurep 'xemacs) |
12608 (org-defkey org-mode-map 'button3 'popup-mode-menu)) | 12120 (org-defkey org-mode-map 'button3 'popup-mode-menu)) |
12953 ((save-excursion | 12465 ((save-excursion |
12954 (beginning-of-line 1) | 12466 (beginning-of-line 1) |
12955 (looking-at "\\(?:#\\+\\(?:setupfile\\|include\\):?[ \t]+\"?\\|[ \t]*<include\\>.*?file=\"\\)\\([^\"\n>]+\\)")) | 12467 (looking-at "\\(?:#\\+\\(?:setupfile\\|include\\):?[ \t]+\"?\\|[ \t]*<include\\>.*?file=\"\\)\\([^\"\n>]+\\)")) |
12956 (find-file (org-trim (match-string 1)))) | 12468 (find-file (org-trim (match-string 1)))) |
12957 ((org-edit-src-code)) | 12469 ((org-edit-src-code)) |
12470 ((org-edit-fixed-width-region)) | |
12958 (t (call-interactively 'ffap)))) | 12471 (t (call-interactively 'ffap)))) |
12959 | 12472 |
12960 (defun org-ctrl-c-ctrl-c (&optional arg) | 12473 (defun org-ctrl-c-ctrl-c (&optional arg) |
12961 "Set tags in headline, or update according to changed information at point. | 12474 "Set tags in headline, or update according to changed information at point. |
12962 | 12475 |
13025 ((org-at-item-p) | 12538 ((org-at-item-p) |
13026 (call-interactively 'org-maybe-renumber-ordered-list)) | 12539 (call-interactively 'org-maybe-renumber-ordered-list)) |
13027 ((save-excursion (beginning-of-line 1) (looking-at "#\\+BEGIN:")) | 12540 ((save-excursion (beginning-of-line 1) (looking-at "#\\+BEGIN:")) |
13028 ;; Dynamic block | 12541 ;; Dynamic block |
13029 (beginning-of-line 1) | 12542 (beginning-of-line 1) |
13030 (org-update-dblock)) | 12543 (save-excursion (org-update-dblock))) |
13031 ((save-excursion (beginning-of-line 1) (looking-at "#\\+\\([A-Z]+\\)")) | 12544 ((save-excursion (beginning-of-line 1) (looking-at "#\\+\\([A-Z]+\\)")) |
13032 (cond | 12545 (cond |
13033 ((equal (match-string 1) "TBLFM") | 12546 ((equal (match-string 1) "TBLFM") |
13034 ;; Recalculate the table before this line | 12547 ;; Recalculate the table before this line |
13035 (save-excursion | 12548 (save-excursion |
13314 :style toggle :selected org-sparse-tree-open-archived-trees] | 12827 :style toggle :selected org-sparse-tree-open-archived-trees] |
13315 ["Cycling opens ARCHIVE trees" | 12828 ["Cycling opens ARCHIVE trees" |
13316 (setq org-cycle-open-archived-trees (not org-cycle-open-archived-trees)) | 12829 (setq org-cycle-open-archived-trees (not org-cycle-open-archived-trees)) |
13317 :style toggle :selected org-cycle-open-archived-trees] | 12830 :style toggle :selected org-cycle-open-archived-trees] |
13318 "--" | 12831 "--" |
12832 ["Move subtree to archive sibling" org-archive-to-archive-sibling t] | |
13319 ["Move Subtree to Archive" org-advertized-archive-subtree t] | 12833 ["Move Subtree to Archive" org-advertized-archive-subtree t] |
13320 ; ["Check and Move Children" (org-archive-subtree '(4)) | 12834 ; ["Check and Move Children" (org-archive-subtree '(4)) |
13321 ; :active t :keys "C-u C-c C-x C-s"] | 12835 ; :active t :keys "C-u C-c C-x C-s"] |
13322 ) | 12836 ) |
13323 "--" | 12837 "--" |
13511 (newline))) | 13025 (newline))) |
13512 (display-buffer buf) | 13026 (display-buffer buf) |
13513 (sit-for 0)))) | 13027 (sit-for 0)))) |
13514 | 13028 |
13515 (defun org-goto-marker-or-bmk (marker &optional bookmark) | 13029 (defun org-goto-marker-or-bmk (marker &optional bookmark) |
13516 "Go to MARKER, widen if necesary. When marker is not live, try BOOKMARK." | 13030 "Go to MARKER, widen if necessary. When marker is not live, try BOOKMARK." |
13517 (if (and marker (marker-buffer marker) | 13031 (if (and marker (marker-buffer marker) |
13518 (buffer-live-p (marker-buffer marker))) | 13032 (buffer-live-p (marker-buffer marker))) |
13519 (progn | 13033 (progn |
13520 (switch-to-buffer (marker-buffer marker)) | 13034 (switch-to-buffer (marker-buffer marker)) |
13521 (if (or (> marker (point-max)) (< marker (point-min))) | 13035 (if (or (> marker (point-max)) (< marker (point-min))) |
13565 b 'org-cwidth s) (length s)))))) | 13079 b 'org-cwidth s) (length s)))))) |
13566 (setq l (string-width s) b -1) | 13080 (setq l (string-width s) b -1) |
13567 (while (setq b (text-property-any (1+ b) (length s) 'org-dwidth t s)) | 13081 (while (setq b (text-property-any (1+ b) (length s) 'org-dwidth t s)) |
13568 (setq l (- l (get-text-property b 'org-dwidth-n s)))) | 13082 (setq l (- l (get-text-property b 'org-dwidth-n s)))) |
13569 l)) | 13083 l)) |
13084 | |
13085 (defun org-get-indentation (&optional line) | |
13086 "Get the indentation of the current line, interpreting tabs. | |
13087 When LINE is given, assume it represents a line and compute its indentation." | |
13088 (if line | |
13089 (if (string-match "^ *" (org-remove-tabs line)) | |
13090 (match-end 0)) | |
13091 (save-excursion | |
13092 (beginning-of-line 1) | |
13093 (skip-chars-forward " \t") | |
13094 (current-column)))) | |
13095 | |
13096 (defun org-remove-tabs (s &optional width) | |
13097 "Replace tabulators in S with spaces. | |
13098 Assumes that s is a single line, starting in column 0." | |
13099 (setq width (or width tab-width)) | |
13100 (while (string-match "\t" s) | |
13101 (setq s (replace-match | |
13102 (make-string | |
13103 (- (* width (/ (+ (match-beginning 0) width) width)) | |
13104 (match-beginning 0)) ?\ ) | |
13105 t t s))) | |
13106 s) | |
13107 | |
13108 (defun org-fix-indentation (line ind) | |
13109 "Fix indentation in LINE. | |
13110 IND is a cons cell with target and minimum indentation. | |
13111 If the current indenation in LINE is smaller than the minimum, | |
13112 leave it alone. If it is larger than ind, set it to the target." | |
13113 (let* ((l (org-remove-tabs line)) | |
13114 (i (org-get-indentation l)) | |
13115 (i1 (car ind)) (i2 (cdr ind))) | |
13116 (if (>= i i2) (setq l (substring line i2))) | |
13117 (if (> i1 0) | |
13118 (concat (make-string i1 ?\ ) l) | |
13119 l))) | |
13570 | 13120 |
13571 (defun org-base-buffer (buffer) | 13121 (defun org-base-buffer (buffer) |
13572 "Return the base buffer of BUFFER, if it has one. Else return the buffer." | 13122 "Return the base buffer of BUFFER, if it has one. Else return the buffer." |
13573 (if (not buffer) | 13123 (if (not buffer) |
13574 buffer | 13124 buffer |
14004 (setq column 0) | 13554 (setq column 0) |
14005 (goto-char (match-end 0)) | 13555 (goto-char (match-end 0)) |
14006 (setq column (current-column)))) | 13556 (setq column (current-column)))) |
14007 ((org-in-item-p) | 13557 ((org-in-item-p) |
14008 (org-beginning-of-item) | 13558 (org-beginning-of-item) |
14009 ; (looking-at "[ \t]*\\(\\S-+\\)[ \t]*") | |
14010 (looking-at "[ \t]*\\(\\S-+\\)[ \t]*\\(\\[[- X]\\][ \t]*\\|.*? :: \\)?") | 13559 (looking-at "[ \t]*\\(\\S-+\\)[ \t]*\\(\\[[- X]\\][ \t]*\\|.*? :: \\)?") |
14011 (setq bpos (match-beginning 1) tpos (match-end 0) | 13560 (setq bpos (match-beginning 1) tpos (match-end 0) |
14012 bcol (progn (goto-char bpos) (current-column)) | 13561 bcol (progn (goto-char bpos) (current-column)) |
14013 tcol (progn (goto-char tpos) (current-column)) | 13562 tcol (progn (goto-char tpos) (current-column)) |
14014 bullet (match-string 1) | 13563 bullet (match-string 1) |
14242 ((looking-at (org-re ".*?\\S-\\([ \t]+\\(:[[:alnum:]_@:]+:\\)\\)[ \t]*$")) | 13791 ((looking-at (org-re ".*?\\S-\\([ \t]+\\(:[[:alnum:]_@:]+:\\)\\)[ \t]*$")) |
14243 (kill-region (point) (match-beginning 1)) | 13792 (kill-region (point) (match-beginning 1)) |
14244 (org-set-tags nil t)) | 13793 (org-set-tags nil t)) |
14245 (t (kill-region (point) (point-at-eol))))) | 13794 (t (kill-region (point) (point-at-eol))))) |
14246 | 13795 |
13796 | |
14247 (define-key org-mode-map "\C-k" 'org-kill-line) | 13797 (define-key org-mode-map "\C-k" 'org-kill-line) |
13798 | |
13799 (defun org-yank () | |
13800 "Yank, and if the yanked text is a single subtree, fold it. | |
13801 In fact, if the yanked text is a sequence of subtrees, fold all of them." | |
13802 (interactive) | |
13803 (if org-yank-folded-subtrees | |
13804 (let ((beg (point)) end) | |
13805 (call-interactively 'yank) | |
13806 (setq end (point)) | |
13807 (goto-char beg) | |
13808 (when (and (bolp) | |
13809 (org-kill-is-subtree-p)) | |
13810 (or (looking-at outline-regexp) | |
13811 (re-search-forward (concat "^" outline-regexp) end t)) | |
13812 (while (and (< (point) end) (looking-at outline-regexp)) | |
13813 (hide-subtree) | |
13814 (org-cycle-show-empty-lines 'folded) | |
13815 (condition-case nil | |
13816 (outline-forward-same-level 1) | |
13817 (error (goto-char end))))) | |
13818 (goto-char end) | |
13819 (skip-chars-forward " \t\n\r")) | |
13820 (call-interactively 'yank))) | |
13821 | |
13822 (define-key org-mode-map "\C-y" 'org-yank) | |
14248 | 13823 |
14249 (defun org-invisible-p () | 13824 (defun org-invisible-p () |
14250 "Check if point is at a character currently not visible." | 13825 "Check if point is at a character currently not visible." |
14251 ;; Early versions of noutline don't have `outline-invisible-p'. | 13826 ;; Early versions of noutline don't have `outline-invisible-p'. |
14252 (if (fboundp 'outline-invisible-p) | 13827 (if (fboundp 'outline-invisible-p) |
14355 (and (outline-next-heading) | 13930 (and (outline-next-heading) |
14356 (org-flag-heading nil)))) | 13931 (org-flag-heading nil)))) |
14357 (outline-flag-region (max (point-min) (1- (point))) | 13932 (outline-flag-region (max (point-min) (1- (point))) |
14358 (save-excursion (outline-end-of-heading) (point)) | 13933 (save-excursion (outline-end-of-heading) (point)) |
14359 flag)))) | 13934 flag)))) |
13935 | |
13936 (defun org-forward-same-level (arg) | |
13937 "Move forward to the ARG'th subheading at same level as this one. | |
13938 Stop at the first and last subheadings of a superior heading. | |
13939 This is like outline-forward-same-level, but invisible headings are ok." | |
13940 (interactive "p") | |
13941 (outline-back-to-heading t) | |
13942 (while (> arg 0) | |
13943 (let ((point-to-move-to (save-excursion | |
13944 (org-get-next-sibling)))) | |
13945 (if point-to-move-to | |
13946 (progn | |
13947 (goto-char point-to-move-to) | |
13948 (setq arg (1- arg))) | |
13949 (progn | |
13950 (setq arg 0) | |
13951 (error "No following same-level heading")))))) | |
13952 | |
13953 (defun org-get-next-sibling () | |
13954 "Move to next heading of the same level, and return point. | |
13955 If there is no such heading, return nil. | |
13956 This is like outline-next-sibling, but invisible headings are ok." | |
13957 (let ((level (funcall outline-level))) | |
13958 (outline-next-heading) | |
13959 (while (and (not (eobp)) (> (funcall outline-level) level)) | |
13960 (outline-next-heading)) | |
13961 (if (or (eobp) (< (funcall outline-level) level)) | |
13962 nil | |
13963 (point)))) | |
14360 | 13964 |
14361 (defun org-end-of-subtree (&optional invisible-OK to-heading) | 13965 (defun org-end-of-subtree (&optional invisible-OK to-heading) |
14362 ;; This is an exact copy of the original function, but it uses | 13966 ;; This is an exact copy of the original function, but it uses |
14363 ;; `org-back-to-heading', to make it work also in invisible | 13967 ;; `org-back-to-heading', to make it work also in invisible |
14364 ;; trees. And is uses an invisible-OK argument. | 13968 ;; trees. And is uses an invisible-OK argument. |
14467 (goto-char (point-max)) | 14071 (goto-char (point-max)) |
14468 (while (re-search-backward re nil t) | 14072 (while (re-search-backward re nil t) |
14469 (setq level (org-reduced-level (funcall outline-level))) | 14073 (setq level (org-reduced-level (funcall outline-level))) |
14470 (when (<= level n) | 14074 (when (<= level n) |
14471 (looking-at org-complex-heading-regexp) | 14075 (looking-at org-complex-heading-regexp) |
14472 (setq head (org-match-string-no-properties 4) | 14076 (setq head (org-link-display-format |
14077 (org-match-string-no-properties 4)) | |
14473 m (org-imenu-new-marker)) | 14078 m (org-imenu-new-marker)) |
14474 (org-add-props head nil 'org-imenu-marker m 'org-imenu t) | 14079 (org-add-props head nil 'org-imenu-marker m 'org-imenu t) |
14475 (if (>= level last-level) | 14080 (if (>= level last-level) |
14476 (push (cons head m) (aref subs level)) | 14081 (push (cons head m) (aref subs level)) |
14477 (push (cons head (aref subs (1+ level))) (aref subs level)) | 14082 (push (cons head (aref subs (1+ level))) (aref subs level)) |
14483 '(progn | 14088 '(progn |
14484 (add-hook 'imenu-after-jump-hook | 14089 (add-hook 'imenu-after-jump-hook |
14485 (lambda () | 14090 (lambda () |
14486 (if (eq major-mode 'org-mode) | 14091 (if (eq major-mode 'org-mode) |
14487 (org-show-context 'org-goto)))))) | 14092 (org-show-context 'org-goto)))))) |
14093 | |
14094 (defun org-link-display-format (link) | |
14095 "Replace a link with either the description, or the link target | |
14096 if no description is present" | |
14097 (save-match-data | |
14098 (if (string-match org-bracket-link-analytic-regexp link) | |
14099 (replace-match (or (match-string 5 link) | |
14100 (concat (match-string 1 link) | |
14101 (match-string 3 link))) | |
14102 nil nil link) | |
14103 link))) | |
14488 | 14104 |
14489 ;; Speedbar support | 14105 ;; Speedbar support |
14490 | 14106 |
14491 (defvar org-speedbar-restriction-lock-overlay (org-make-overlay 1 1) | 14107 (defvar org-speedbar-restriction-lock-overlay (org-make-overlay 1 1) |
14492 "Overlay marking the agenda restriction line in speedbar.") | 14108 "Overlay marking the agenda restriction line in speedbar.") |